<?php
session_start();
if(!isset($_SESSION['user'])) {
	header("location: ../index.php");
	exit;
}

include"../header.php";

/*$date2 = date('Y-m-d');
$cdate2 = date('Y-m-d', strtotime('-1 months'));
$ldate2 = date('Y-m-d', strtotime('-2 months'));
$fdate2 = date('Y-m-d', strtotime($ldate2 .'30 days'));
$qry2 = mysql_query("SELECT `GuestId` FROM `guest_order_history` WHERE (`SaleDate` >= '$ldate2' AND `SaleDate` <= '$date2')");
while ($row2 = mysql_fetch_array($qry2)) {
	$gid = $row2['GuestId'];

	$lqry = mysql_query("SELECT count(DISTINCT(`GuestPhone`)) AS phone FROM `guest_order_history` WHERE `GuestId` = '$gid' AND `SaleDate` NOT BETWEEN '$cdate2' AND '$date'");
	$lrow = mysql_fetch_array($lqry);
	$totalsms = $lrow['phone'];
}*/
?>
<style>
label.checkbox-inline {
    margin-right: 50px;
    font-size: 12px;
}
.customer-days{
	color:#f38887;
}

</style>
		<link rel="stylesheet" href="../assets/css/clockpicker/jquery-clockpicker.min.css">
		<link rel="stylesheet" href="../assets/css/zomato.css">
		 
				<div class="row">
					<div class="col-lg-12">
						<div class="row">
		                    <div class="col-sm-6 col-lg-3">
		                        <div class="card text-white bg-primary br-lg">
		                            <div class="card-body pb-0 text-center">
		                                <p class="tiles-header" title="For customers who last ordered between 16 to 30 DAYS ago">Active Customers</p>
										<?php
                                   		$fdate2 = date('Y-m-d', strtotime('-30 days'));
                                   		$ldate2 = date('Y-m-d', strtotime($fdate2. '14 days'));
                                   		// $qry2 = mysql_query("SELECT count(DISTINCT(`GuestPhone`)) AS phone FROM `guest_order_history` WHERE (`SaleDate` >= '$fdate2' AND `SaleDate` <= '$ldate2')");
                                   		$qry2 = mysql_query("SELECT count(DISTINCT(goh.`GuestPhone`)) AS phone, count(DISTINCT(gd.`Email`)) AS email FROM `guest_details` AS gd INNER JOIN `guest_order_history` AS goh ON gd.`GuestId` = goh.`GuestId` WHERE (goh.`SaleDate` >= '$fdate2' AND goh.`SaleDate` <= '$ldate2')");
                                   		$row2 = mysql_fetch_array($qry2);
                                   		?>
										<p class="audience mt-2 mb-2">SMS Audience</p>
										<p class="recent-customers-data"><?php echo $row2['phone']; ?></p>
										<button type="button" class="btn btn-primary-menu px-3 mb-4 mt-2 campbtnrnd">Run Campaign</button>
		                            </div>
		                        </div>
		                    </div>
		                    <!--/.col-->

		                    <div class="col-sm-6 col-lg-3">
		                        <div class="card text-white bg-info br-lg">
		                            <div class="card-body pb-0 text-center">
		                                <p class="tiles-header" title="For customers who last ordered before 30 DAYS">Lost Customers</p>
		                                <?php
                                   		$date4 = date('Y-m-d');
                                   		$cdate4 = date('Y-m-d', strtotime('-1 months'));
                                   		$ldate4 = date('Y-m-d', strtotime('-2 months'));
                                   		$fdate4 = date('Y-m-d', strtotime($ldate4 .'30 days'));
                                   		/*$qry4 = mysql_query("SELECT DISTINCT(`GuestId`) AS gid FROM `guest_order_history` WHERE (`SaleDate` >= '$ldate4' AND `SaleDate` <= '$date4')");
                                   		$lostCust = 0;
                                   		while ($row4 = mysql_fetch_array($qry4)){
                                   			$gid = $row4['gid'];
                                   			$sqry = mysql_query("SELECT count(DISTINCT(`GuestPhone`)) AS phone FROM `guest_order_history` WHERE `GuestId` = '$gid' AND `SaleDate` NOT BETWEEN '$cdate4' AND '$date4'");
                                   			$srow = mysql_fetch_array($sqry);
                                   			$lostCust += $srow['phone'];
                                   		}*/
                                   		?>
										<p class="audience mt-2 mb-2">SMS Audience</p>
										<p class="recent-customers-data">0<?php //echo $lostCust; ?></p>
										<button type="button" class="btn btn-info-menu px-3 mb-4 mt-2 campbtnrnd">Run Campaign</button>
		                            </div>
		                        </div>
		                    </div>
		                    <!--/.col-->

		                    <div class="col-sm-6 col-lg-3">
		                        <div class="card text-white bg-warning br-lg">
		                            <div class="card-body pb-0 text-center">
		                                <p class="tiles-header" title="For customers who last ordered between 0 to 15 DAYS ago">Recent Customers</p>
		                                <?php
                                   		$date = date('Y-m-d');
                                   		$ldate = date('Y-m-d', strtotime('-15 days'));
                                   		// $qry = mysql_query("SELECT count(DISTINCT(`GuestPhone`)) AS phone FROM `guest_order_history` WHERE (`SaleDate` >= '$ldate' AND `SaleDate` <= '$date')");
                                   		$qry = mysql_query("SELECT count(DISTINCT(goh.`GuestPhone`)) AS phone, count(DISTINCT(gd.`Email`)) AS email FROM `guest_details` AS gd INNER JOIN `guest_order_history` AS goh ON gd.`GuestId` = goh.`GuestId` WHERE (goh.`SaleDate` >= '$ldate' AND goh.`SaleDate` <= '$date')");
                                   		$row = mysql_fetch_array($qry);
                                   		?>
										<p class="audience mt-2 mb-2">SMS Audience</p>
										<p class="recent-customers-data"><?php echo $row['phone']; ?></p>
										<button type="button" class="btn btn-warning-menu px-3 mb-4 mt-2 campbtnrnd">Run Campaign</button>
		                            </div>
		                        </div>
		                    </div>
		                    <!--/.col-->

		                    <div class="col-sm-6 col-lg-3">
		                        <div class="card text-white bg-danger br-lg">
		                            <div class="card-body pb-0 text-center">
		                                <p class="tiles-header credits-tiles">Credits Available</p>
		                                <p class="recent-customers-data">1</p>
		                                <button type="button" class="btn btn-danger-menu px-3 mt-4 mb-4 campbtnrnd">Recharge Now</button>
		                                <!-- <div class="row px-3 mt-4 mb-4">
											<div class="col-sm-12 col-md-12">
												<center>
													<button type="button" class="btn btn-danger-menu campbtnrnd">Recharge Now</button>
												</center>
											</div>
										</div> -->
		                            </div>
		                        </div>
		                    </div>
		                    <!--/.col-->
		                </div>
	                </div>
                </div>

                <div class="row">
					<div class="col-lg-12">
						<div class="card br-lg">
							<div class="card-body">

								<div class="dashboard-body">
									<div class="row">
					                    <div class="col-lg-3">
					                    	<div class="row">
					                    		<div class="col-md-12 col-lg-12">
					                    			<div class="card">
						                    			<div class="card-body text-center p-lg">
						                    				<p class="mt-sm">
																Define your audience and design your <br>
																	own SMS/Email campaigns.<br>
								                                You may Schedule for Later or Send Now
								                            </p>
															<button type="button" class="btn btn-primary mt-sm mb-lg campbtnrnd" id="btn-campaign">Create Campaign</button>
						                    				<!-- <blockquote class="card-bodyquote">
								                                <p align="center">
																Define your audience and design your <br>
																	own SMS/Email campaigns.<br>
								                                You may Schedule for Later or Send Now</p>
															</blockquote>
															<center>
																<button type="button" class="btn btn-primary active campbtnrnd">CREATE CAMPAIGN</button>
															</center>
															<center>
																<div class="btn-group mb-sm mt5i mb-sm">
																	<button type="button" class="btn btn-primary campbtnrnd" id="btn-campaign">CREATE CAMPAIGN</button>
																	<button type="button" data-toggle="dropdown" class="btn btn-primary active dropdown-toggle hidden-xs campbtnrnd" aria-expanded="false">CREATE CAMPAIGN</button>
																	<ul role="menu" class="dropdown-menu">
												                        <li>
												                        	<a href="create_sms_campaign.php">SMS</a>
												                  		</li>
												                        <li>
												                        	<a href="create_email_campaign.php">Email</a>
												                  		</li>
							                                 		</ul>
							                                 	</div>
															</center> -->
						                    			</div>
						                    		</div>
					                    		</div>
					                    		<div class="col-md-12 col-lg-12">
					                    			<div class="card">
						                    			<div class="card-body manualcamfont">
						                    				<center>
							                                    <a href=""><u><span class="customer-days days-css">Resend a previous campaign</span></u></a>
							                                </center>
						                    			</div>
						                    		</div>
					                    		</div>
					                    	</div>
					                    </div>
					                    <div class="col-lg-9">
					                    	<div id="fullcalendar"></div>
					                    </div>
					                </div>
					            </div>

				                <div class="campaign-body" style="display: none;">
				                	<div class="row">
				                		<div class="col-lg-3">
		                					<nav role="navigation" class="navbar navbar-fixed-top text-center create-header">
												<div class="row">
													<div class="col-lg-12 col-sm-12">
														<p class="text-lg text-dark mt20i mb-xl" style="">Campaign Work Flow</p>
													</div>
													<div class="col-lg-12 col-sm-12 text-center">
														<div class="stepwizard col-md-offset-3">
															<div class="stepwizard-row setup-panel">
																<div class="stepwizard-step">
																	<a type="button" class="btn btn-warning btn-circle js-choose-step">1</a>
																	<p>Choose Campaign Type</p>
																</div>
																<div class="stepwizard-step">
																	<a type="button" class="btn btn-default btn-circle js-detail-step" disabled="disabled">2</a>
																	<p>Define Campaign Details</p>
																</div>
																<div class="stepwizard-step">
																	<a type="button" class="btn btn-default btn-circle js-schedule-step" disabled="disabled">3</a>
																	<p>Schedule Campaign</p>
																</div>
																<div class="stepwizard-step">
																	<a type="button" class="btn btn-default btn-circle js-preview-step" disabled="disabled">4</a>
																	<p>Preview Campaign</p>
																</div>
															</div>
														</div>
													</div>
												</div>
											</nav>
		                				</div>

		                				<div class="col-lg-9">
		                					<div class="row">
		                						<div class="col-lg-11">
		                							<p class="text-lg text-dark text-center mb-xl js-campaign-selector" style="">Select Campaign Type</p>
		                							<p class="text-lg text-dark text-center mb-xl js-tell-us-more" style="display: none;">Define Your Campaign</p>
		                							<p class="text-lg text-dark text-center mb-xl js-schedule-more" style="display: none;">Schedule Date/Time</p>
		                							<p class="text-lg text-dark text-center mb-xl js-preview-more" style="display: none;">Campaign Preview</p>
		                						</div>
		                						<div class="col-lg-1">
		                							<a href="#" class="text-dark close-campaign">
														<p class="pull-right mt0 text-lg text-dark" style="margin-top: 10px;">X</p>
													</a>
		                						</div>
		                					</div>

		                					<div class="row js-campaign-selector" style="">
										        <!-- <div class="col-lg-1 hidden-sm hidden-md hidden-xs"></div> -->
									            <div class="col-lg-3 col-md-3 col-sm-6">
										            <a id="template_name" class="js-choose-template" data-name="Offer">
										              	<div class="panel widget select-type" style="height:260px;">
										                 	<div class="panel-body text-center">
										                    	<div class="media p mt0">
										                       		<div>
										                          		<img src="../assets/img/icons/1_fnitgq.png" alt="Image" class="thumb128">
										                       		</div>
											                       	<div class="media-body mt-lg">
											                          	<div class="choose">
												                            <h4 class="mt0 text-md fw400" style="">Offer</h4>
												                        </div>
											                       	</div>
										                    	</div>
										                 	</div>
										              	</div>
										            </a>
									         	</div>
									         	<div class="col-lg-3 col-md-3 col-sm-6">
										            <a id="template_name" class="js-choose-template" data-name="promotion">
										              	<div class="panel widget select-type" style="height:260px;">
										                 	<div class="panel-body text-center">
										                    	<div class="media p mt0">
										                       		<div>
										                          		<img src="../assets/img/icons/4_loud_promotion.png" alt="Image" class="thumb128">
										                       		</div>
											                       	<div class="media-body mt-lg">
											                          	<div class="choose">
												                            <h4 class="mt0 text-md fw400" style="">Promotion</h4>
												                        </div>
											                       	</div>
										                    	</div>
										                 	</div>
										              	</div>
										            </a>
									         	</div>
								             	<div class="col-lg-3 col-md-3 col-sm-6">
										            <a id="template_name" class="js-choose-template" data-name="New/Popular Product">
										              	<div class="panel widget select-type" style="height:260px;">
										                 	<div class="panel-body text-center">
											                    <div class="media p mt0">
											                       	<div>
											                          	<img src="../assets/img/icons/2_blazz4.png" alt="Image" class="thumb128">
											                       	</div>
											                       	<div class="media-body mt-lg">
											                          	<div class="choose">
											                            	<h4 class="mt0 text-md fw400" style="">New/Popular Product</h4>
											                          	</div>
											                       	</div>
											                    </div>
										                 	</div>
										              	</div>
										            </a>
									         	</div>
								             	<div class="col-lg-3 col-md-3 col-sm-6">
										            <a id="template_name" class="js-choose-template" data-name="Event or Festival">
										              	<div class="panel widget select-type" style="height:260px;">
										                 	<div class="panel-body text-center">
										                    	<div class="media p mt0">
											                       	<div>
											                          	<img src="../assets/img/icons/3_uaszs2.png" alt="Image" class="thumb128">
											                       	</div>
											                       	<div class="media-body mt-lg">
											                          	<div class="choose">
											                            	<h4 class="mt0 text-md fw400" style="">Event or Festival</h4>
											                          	</div>
											                       	</div>
										                    	</div>
										                 	</div>
										              	</div>
										            </a>
										        </div>
										    </div>

										    
									      	<div class="row js-tell-us-more" style="display: none;">
									         	<div class="col-lg-9 col-lg-offset-2">
									            	<form role="form">
									            		
									            		<fieldset class="pb-xl last-child js-offer-expiry">
									            			<div class="form-group row">
					                                            <label class="col-lg-4 col-md-4 form-control-label text-right text-md fw400" for="text-input">Campaign Name</label>
					                                            <div class="col-lg-4 col-md-4">
					                                                <input type="text" id="camp-name" name="text-input" class="form-control" placeholder="Write your campaign name">
					                                            </div>
					                                        </div>
					                                        <div class="form-group row">
					                                            <label class="col-lg-4 col-md-4 form-control-label text-right text-md fw400" for="text-input">Expiry Date</label>
					                                            <div class="col-lg-4 col-md-4">
					                                                <input type="text" id="expiry-date" name="text-input" class="form-control" placeholder="Select expiry date">
					                                            </div>
					                                        </div>
					                                        <div class="form-group row">
					                                            <label class="col-lg-4 col-md-4 form-control-label text-right text-md fw400" for="text-input">Target Customers</label>
					                                            <div class="col-lg-4 col-md-4">
					                                                <select id="target-customers" name="target-customers" class="form-control" onchange="changeCustomersFilter()">
					                                                	<option value="">Please select</option>
					                                                	<?php
					                                                	$target_qry = mysql_query("SELECT `mf_id`, `mf_name` FROM `crm_my_filter` WHERE `mf_active` = '1'");
					                                                	while ($target_row = mysql_fetch_assoc($target_qry)) {
					                                                		?>
					                                                		<option value="<?php echo $target_row['mf_id']; ?>"><?php echo $target_row['mf_name']; ?></option>
					                                                		<?php
					                                                	}
					                                                	?>
					                                                </select>
					                                            </div>
					                                            <div class="col-lg-2 col-md-2">
					                                            	<button type="button" class="btn btn-xl btn-primary btn-ladda ladda-button js-btn-filter" data-size="l" data-size="l" data-style="zoom-in" onclick="showFiltersValue(document.getElementById('target-customers').value)" style="display: none;">Show Value</button>
					                                            	<div class="text-lg text-dark js-filter-value" style="display: none;"></div>
					                                            </div>
					                                        </div>
					                                        <div class="form-group row">
					                                            <label class="col-lg-4 col-md-4 form-control-label text-right text-md fw400" for="text-input">SMS Content</label>
					                                            <!-- <div class="col-lg-2">
					                                            	<div class="radio">
					                                                    <label for="offers">
					                                                        <input type="radio" id="offers" name="smsOffers" value="offers" checked="checked">Offers
					                                                    </label>
					                                                </div>
					                                                <div class="radio">
					                                                    <label for="allsms">
					                                                        <input type="radio" id="allsms" name="smsOffers" value="all">All
					                                                    </label>
					                                                </div>
					                                            </div> -->
					                                            <div class="col-lg-4 col-md-4">
					                                            	<select id="content" name="content" class="form-control">
					                                                    <option value="">Please select</option>
					                                                    <option value="1">SMS #1</option>
					                                                    <option value="2">SMS #2</option>
					                                                    <option value="3">SMS #3</option>
					                                                </select>
					                                            </div>
					                                        </div>
					                                        <div class="form-group row">
					                                            <label class="col-lg-4 col-md-4 form-control-label text-right text-md fw400" for="text-input">Deliver To</label>
					                                            <div class="col-lg-4 col-md-4">
					                                                <!-- <label class="radio-inline" for="dnd">
					                                                    <input type="radio" class="flow-radio" id="dnd" name="deliverto" value="alldnd" checked="checked">All
					                                                </label>
					                                                <label class="radio-inline" for="nondnd">
					                                                    <input type="radio" class="flow-radio" id="nondnd" name="deliverto" value="nondnd">Non DND
					                                                </label> -->
					                                                <div class="btn-group" data-toggle="buttons">
																	    <label class="btn btn-default mr js-btn-alldnd">
																	        <input type="radio" class="flow-radio radio-alldnd" id="dnd" name="deliverto" value="alldnd" checked="checked">All
																	    </label>
																	    <label class="btn btn-default js-btn-nondnd">
																	        <input type="radio" class="flow-radio radio-nondnd" id="nondnd" name="deliverto" value="nondnd">Non DND
																	    </label>
																	</div>
					                                            </div>
					                                        </div>
										                </fieldset>

										               	<div class="form-group text-center">
										                  	<button type="button" class="btn btn-primary text-md btn-lg text-center js-request-campaign" id="" onclick="saveCampaignDetails('camp-details')">Save & Next</button>
										               	</div>
									            	</form>
									            </div>
									        </div>

									        <div class="row js-schedule-more" style="display: none;">
									         	<div class="col-lg-9 col-lg-offset-2">
									            	<form role="form">

									            		<fieldset class="pb-xl last-child js-offer-schedule">
									            			<div class="form-group row">
					                                            <div class="col-lg-4 col-md-4 text-right">
						                                            <label class=" form-control-label text-right text-md fw400 mr-xl" for="text-input">Select</label>
						                                            <div class="radio-btn float-right">
						                                            	<div class="radio">
						                                            		<label for="select-date">
						                                            			<input type="radio" class="flow-radio" id="select-date" name="select-date-day" value="date" checked="checked">Date
						                                            		</label>
						                                            	</div>
						                                            	<div class="radio">
						                                            		<label for="select-days">
						                                            			<input type="radio" class="flow-radio" id="select-days" name="select-date-day" value="day">Day
						                                            		</label>
						                                            	</div>
				                                                    </div>     
				        										</div>
					                                            <div class="col-lg-4 col-md-4">
					                                                <input type="text" id="schedule-date" name="schedule-date" class="form-control" placeholder="Select Date">
					                                                <select id="schedule-day" name="schedule-date" class="form-control" style="display: none;">
					                                                    <option value="">Please select</option>
					                                                    <option value="sun">Sunday</option>
					                                                    <option value="mon">Monday</option>
					                                                    <option value="tue">Tuesday</option>
					                                                    <option value="wed">Wednesday</option>
					                                                    <option value="thu">Thursday</option>
					                                                    <option value="fri">Friday</option>
					                                                    <option value="sat">Saturday</option>
					                                                </select>
					                                            </div>
					                                        </div>
					                                        <div class="form-group row">
					                                            <label class="col-lg-4 col-md-4 form-control-label text-right text-md fw400" for="text-input">Select Time</label>
					                                            <div class="col-lg-4 col-md-4">
					                                                <input type="text" id="schedule-time" name="schedule-time" class="form-control" placeholder="Select Time">
					                                            </div>
					                                        </div>
									            		</fieldset>
									            		<div class="form-group text-center">
										                  	<button type="button" class="btn btn-primary text-md btn-lg text-center js-request-campaign" id="" onclick="saveCampaignSchedule('camp-schedule')">Save & Next</button>
										               	</div>

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

									        <div class="row js-preview-more" style="display: none;">
									         	<div class="col-lg-7 col-lg-offset-2 well">
									            	<form role="form">
									            		<fieldset class="pb-xl last-child js-offer-preview">
									            			<div class="form-group row">
					                                            <label class="col-lg-4 col-md-4 form-control-label text-right text-md fw400" for="text-input">Offers : </label>
					                                            <div class="col-lg-8 col-md-8 text-left">
					                                                <div class="preview-offers-name">Holi 10% discount</div>
					                                                <!-- <input type="text" name="" value="Offers" readonly="readonly"> -->
					                                            </div>
					                                        </div>
					                                        <div class="form-group row">
					                                            <label class="col-lg-4 col-md-4 form-control-label text-right text-md fw400" for="text-input">Schedule On : </label>
					                                            <div class="col-lg-8 col-md-8 text-left">
					                                                <div class="row">
					                                                	<div class="col-md-5 mb-sm">
																			<input type="text" class="form-control" value="06-04-2018" placeholder="">
																		</div>
																		<div class="col-md-5 mb-sm">
																			<input type="text" class="form-control" value="10-04-2018" placeholder="">
																		</div>
																		<div class="col-md-5 mb-sm">
																			<input type="text" class="form-control" value="18-04-2018" placeholder="">
																		</div>
																		<div class="col-md-5 mb-sm">
																			<input type="text" class="form-control" value="21-04-2018" placeholder="">
																		</div>
					                                                </div>
					                                            </div>
					                                        </div>
					                                        <div class="form-group row">
					                                            <label class="col-lg-4 col-md-4 form-control-label text-right text-md fw400" for="text-input">Valid To : </label>
					                                            <div class="col-lg-8 col-md-8 text-left">
					                                                <div class="preview-type">24-05-2018</div>
					                                            </div>
					                                        </div>
					                                        <div class="form-group row">
					                                            <label class="col-lg-4 col-md-4 form-control-label text-right text-md fw400" for="text-input">Your SMS is : </label>
					                                            <div class="col-lg-8 col-md-8 text-left">
																	<div class="sms-box">
																		Hi [fname], Roses are red, violets are blue, why not order dinner for 2! Why fear when vk restaurant is here. Get Get [customer_first_offer] at vk restaurant. Valid upto 18th Apr when you place your order on [bphone]
																	</div>
																</div>
					                                        </div>
					                                        <!-- <div class="form-group row">
					                                        	<div class="col-lg-10 col-md-10 col-lg-offset-1 text-center">
					                                                <textarea class="js-simple-message form-control inputor" rows="4" placeholder="Type your message here" required="" id="message">
					                                                	Hi [fname], Roses are red, violets are blue, why not order dinner for 2! Why fear when vk restaurant is here. Get Get [customer_first_offer] at vk restaurant. Valid upto 18th Apr when you place your order on [bphone]
					                                                </textarea>
					                                                <div class="hwt-container">
												            			<div class="hwt-backdrop">
												            				<div class="hwt-highlights hwt-content">
												            					Hi <mark class="red">[fname]</mark>, Roses are red, violets are blue, why not order dinner for 2! Why fear when vk restaurant is here. Get Get [customer_first_offer] at vk restaurant. Valid upto 18th Apr when you place your order on <mark class="red">[bphone]</mark>
																			</div>
																		</div>
																		<textarea class="js-simple-message  form-control inputor hwt-input hwt-content" rows="4" placeholder="Type your message here or get ideas from our templates above" required="" id="message"></textarea>
																	</div>
					                                            </div>
					                                        </div> -->
									            		</fieldset>
									            	</form>
									            </div>
									            <div class="col-lg-4 mt-xl">
									            	
									            </div>
									        </div>

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

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

<?php include"../footer.php"; ?>


<script type="text/javascript">
$( "#content" ).select2({
	theme: "bootstrap"
});

</script>
<script type="text/javascript" src="//cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
 

<script type="text/javascript">
$('#expiry-date').datepicker({
	format: 'dd-mm-yyyy',
	autoclose: true,
	todayHighlight: true,
	orientation: "bottom auto",
	startDate: new Date()
}).on('changeDate', function (ev) {

	$('#schedule-date').datepicker({
		format: 'dd-mm-yy',
		multidateSeparator: ", ",
		// autoclose: true,
		todayHighlight: true,
		orientation: "bottom auto",
		multidate: true,
		startDate: new Date(),
		endDate: ev.date
	    // maxDate: ev.date
	});

});


$('#schedule-time').clockpicker({
    placement: 'top',
    align: 'left',
    donetext: 'Done'
});

</script>
<script type="text/javascript">
$(document).ready(function() {
	$("#btn-campaign").click(function(){
		$(".dashboard-body").hide();
		$(".campaign-body").show();
	});
	$(".close-campaign").click(function(){
		$(".dashboard-body").show();
		$(".campaign-body").hide();
	});
});


$(document).ready(function() {

    $('#fullcalendar').fullCalendar({
      	header: {
	        left: 'prev,next today',
	        center: 'title',
	        right: 'month,agendaWeek,agendaDay,listWeek'
      	},
      	// defaultDate: '2018-03-12',
      	navLinks: true, // can click day/week names to navigate views
      	editable: true,
      	eventLimit: true, // allow "more" link when too many events
      	events: [
	        {
	          	title: 'All Day Event',
	          	start: '2018-03-01',
	        },
	        {
	          	title: 'Long Event',
	          	start: '2018-03-07',
	          	end: '2018-03-10'
	        },
	        {
	          	id: 999,
	          	title: 'Repeating Event',
	          	start: '2018-03-09T16:00:00'
	        },
	        {
	          	id: 999,
	          	title: 'Repeating Event',
	          	start: '2018-03-16T16:00:00'
	        },
	        {
	          	title: 'Conference',
	          	start: '2018-03-11',
	          	end: '2018-03-13'
	        },
	        {
	          	title: 'Meeting',
	          	start: '2018-03-12T10:30:00',
	          	end: '2018-03-12T12:30:00'
	        },
	        {
	          	title: 'Lunch',
	          	start: '2018-03-12T12:00:00'
	        },
	        {
	          	title: 'Meeting',
	          	start: '2018-03-12T14:30:00'
	        },
	        {
	          	title: 'Happy Hour',
	          	start: '2018-03-12T17:30:00'
	        },
	        {
	          	title: 'Dinner',
	          	start: '2018-03-12T20:00:00'
	        },
	        {
	          	title: 'Birthday Party',
	          	start: '2018-03-13T07:00:00'
	        },
	        {
	          	title: 'Click for Google',
	          	url: 'http://google.com/',
	          	start: '2018-03-28'
	        },
	        // red areas where no events can be dropped
	        {
	          	start: '2018-03-24',
	          	end: '2018-03-28',
	          	overlap: false,
	          	rendering: 'background',
	          	color: '#ff9f89'
        	},
        	{
	          	start: '2018-03-06',
	          	end: '2018-03-08',
	          	overlap: false,
	          	rendering: 'background',
	          	color: '#ff9f89'
        	},

        	{
	          	title: 'Meeting',
	          	start: '2018-03-17T11:00:00',
	          	constraint: 'availableForMeeting', // defined below
	          	color: '#257e4a'
        	},
        	// areas where "Meeting" must be dropped
	        {
	          	id: 'availableForMeeting',
	          	start: '2018-03-18T10:00:00',
	          	end: '2018-03-18T16:00:00',
	          	rendering: 'background'
	        },
	        {
	          	id: 'availableForMeeting',
	          	start: '2018-03-20T10:00:00',
	          	end: '2018-03-20T16:00:00',
	          	rendering: 'background'
	        }
      	]
    });

});


$('.js-choose-step').on("click", function() {
    $('.js-campaign-selector').show();
    $('.js-tell-us-more').hide();
    $('.js-schedule-more').hide();
    $('.js-preview-more').hide();
    $('.js-choose-step').removeClass('btn-primary');
  	$('.js-choose-step').addClass('btn-warning');
  	$('.js-detail-step').removeClass('btn-warning');
  	$('.js-detail-step').addClass('btn-default');
  	$('.js-schedule-step').removeClass('btn-primary');
  	$('.js-schedule-step').addClass('btn-default');
  	$('.js-preview-step').removeClass('btn-warning');
  	$('.js-preview-step').addClass('btn-default');
});

$('.js-detail-step').on("click", function() {
    $('.js-campaign-selector').hide();
    $('.js-tell-us-more').show();
    $('.js-schedule-more').hide();
    $('.js-preview-more').hide();
    $('.js-choose-step').addClass('btn-primary');
    $('.js-detail-step').removeClass('btn-default');
    $('.js-detail-step').removeClass('btn-primary');
  	$('.js-detail-step').addClass('btn-warning');
  	$('.js-schedule-step').removeClass('btn-warning');
  	$('.js-schedule-step').removeClass('btn-primary');
  	$('.js-schedule-step').addClass('btn-default');
  	$('.js-preview-step').removeClass('btn-warning');
  	$('.js-preview-step').addClass('btn-default');
});

$('.js-schedule-step').on("click", function() {
    $('.js-campaign-selector').hide();
    $('.js-tell-us-more').hide();
    $('.js-schedule-more').show();
    $('.js-preview-more').hide();
    $('.js-choose-step').addClass('btn-primary');
    $('.js-detail-step').removeClass('btn-default');
    $('.js-detail-step').removeClass('btn-warning');
    $('.js-detail-step').addClass('btn-primary');
    $('.js-schedule-step').removeClass('btn-primary');
    $('.js-schedule-step').removeClass('btn-default');
  	$('.js-schedule-step').addClass('btn-warning');
  	$('.js-preview-step').removeClass('btn-warning');
  	$('.js-preview-step').addClass('btn-default');
});

$('.js-preview-step').on("click", function() {
    $('.js-campaign-selector').hide();
    $('.js-tell-us-more').hide();
    $('.js-schedule-more').hide();
    $('.js-preview-more').show();
    $('.js-choose-step').addClass('btn-primary');
    $('.js-detail-step').removeClass('btn-default');
    $('.js-detail-step').addClass('btn-primary');
    $('.js-schedule-step').removeClass('btn-default');
    $('.js-schedule-step').addClass('btn-primary');
    $('.js-preview-step').removeClass('btn-default');
  	$('.js-preview-step').addClass('btn-warning');
});

$(".js-choose-template").on("click", function() {
  	$('.js-campaign-selector').hide();
  	$('.js-tell-us-more').show();
  	$('.js-schedule-more').hide();
  	$('.js-choose-step').removeClass('btn-warning');
  	$('.js-choose-step').addClass('btn-primary');
  	$('.js-detail-step').removeClass('btn-default');
  	$('.js-detail-step').addClass('btn-warning');
  	$('.js-detail-step').removeAttr("disabled");
});

function saveCampaignDetails(txt) {
	$('.js-campaign-selector').hide();
  	$('.js-tell-us-more').hide();
  	$('.js-schedule-more').show();
  	$('.js-detail-step').removeClass('btn-warning');
  	$('.js-detail-step').addClass('btn-primary');
  	$('.js-schedule-step').removeClass('btn-default');
  	$('.js-schedule-step').addClass('btn-warning');
  	$('.js-schedule-step').removeAttr("disabled");
}

$(document).ready(function() {
	$("#select-date").click(function() {
  		$('#schedule-date').show();
		$('#schedule-day').hide();
	});
	$("#select-days").click(function() {
  		$('#schedule-day').show();
		$('#schedule-date').hide();
	});
});

function saveCampaignSchedule(txt) {
	$('.js-campaign-selector').hide();
  	$('.js-tell-us-more').hide();
  	$('.js-schedule-more').hide();
  	$('.js-preview-more').show();
  	$('.js-schedule-step').removeClass('btn-warning');
  	$('.js-schedule-step').addClass('btn-primary');
  	$('.js-preview-step').removeClass('btn-default');
  	$('.js-preview-step').addClass('btn-warning');
  	$('.js-preview-step').removeAttr("disabled");
}


function changeCustomersFilter() {
	$('.js-btn-filter').show();
  	$('.js-filter-value').hide();
}

function showFiltersValue(val) {
	var l = Ladda.create( document.querySelector( '.ladda-button'));
	l.start();
	$.ajax({
		url: 'crm_data.php?act=campfiltervalue&mf_id='+val,
		success : function(data) {
			var data2 = JSON.parse(data);
			var phone = data2.phone;
			$('.js-btn-filter').hide();
  			$('.js-filter-value').show();
  			$('.js-filter-value').html(phone);
  			l.stop();
		}
	});
}

$(document).ready(function(){
	$(".js-btn-alldnd").click(function(){
		var val = $(".radio-alldnd").val();
		// alert(val);
		$(".js-btn-alldnd").removeClass("btn-default");
		$(".js-btn-alldnd").addClass("btn-success");
		$(".js-btn-nondnd").removeClass("btn-success");
		$(".js-btn-nondnd").addClass("btn-default");
	});
	$(".js-btn-nondnd").click(function(){
		var val = $(".radio-nondnd").val();
		// alert(val);
		$(".js-btn-nondnd").removeClass("btn-default");
		$(".js-btn-nondnd").addClass("btn-success");
		$(".js-btn-alldnd").removeClass("btn-success");
		$(".js-btn-alldnd").addClass("btn-default");
	});
});
</script>
