calendar-php
<?php include 'header.php'; ?>
<script>
$(document).ready(function() {
var date = moment(); //Get the current date
var currentDate = date.format("YYYY-MM-DD");
var clandarBooking = function() {
$('#calendar').fullCalendar({
header: {
left: 'prev',
center: 'title',
right: 'next'
},
views: {
month: {// name of view
titleFormat: 'YYYY | MMMM'
// other view-specific options here
}
},
defaultDate: currentDate,
eventRender: function(event, element, view) {
//$(element).addClass('clickThrough');
if (event.id == event.id) {
element.html('<div class="' + event.title + '_' + event.id + '"><img src="' + event.description + '"></div>');
element.addClass("e_" + event.id);
}
element.html(event.description);
//element.addClass('gold-bg');
//element.html('');
// element.append('<p class="ev-date">' + event.date +'</p>')
if (event.id === 'Holiday') {
element.css({'pointer-events': 'none'});
//element.prepend('<div class="tools"> ' + event.title + '</div>')
}
},
dayClick: function(date, allDay, jsEvent, view) {
var newDt = date.format();
var days = 2;
var SetNewDate = new Date();
var res = SetNewDate.setTime(SetNewDate.getTime() + (days * 24 * 60 * 60 * 1000));
//convert to date again:
var ReSetNewDate = new Date(res);
if ((new Date(ReSetNewDate).getTime()) > (new Date(newDt).getTime())) {
alert('You can not create meal for this date.');
}
else {
$.post('<?php echo base_url() ?>lunchbox/checkdate',
{checkdateinfo: newDt},
function(result)
{
if (result == 0)
{
var meal_creation_daye = date.format();
$('#getDate').text(newDt);
$('#meal_creation_date').val(newDt);
$("#myModal2").modal("show").on('shown.bs.modal', function() {
jQuery.ajax({
url: '<?php echo base_url() ?>lunchbox/checktime',
type: 'POST',
cache: false,
success: function(data, textStatus, jqXHR) {
//console.log(data);
$('#DeliveryTimeSet').html(data);
loadFlexsliders();
},
error: function(jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});
});
}
else if (result == 'Holiday') {
var meal_creation_daye = date.format();
$('#getDate').text(newDt);
$('#meal_creation_date').val(newDt);
// location.href = '<?php echo base_url() ?>lunchbox/mealCreation/'+meal_creation_daye;
$("#myModal2").modal("show").on('shown.bs.modal', function() {
loadFlexsliders();
});
} else {
alert('Sorry, you can not edit this day because there are order placed on it.');
}
}
)
}
function loadFlexsliders() {
$('#horizontalLogo').flexslider({
animation: "slide",
animationLoop: false,
itemWidth: 90,
itemMargin: 8,
controlNav: false,
prevText: '',
nextText: '',
minItems: 6,
maxItems: 6
});
$('#verticalLogo').flexslider({
animation: "slide",
direction: "vertical",
prevText: '',
nextText: '',
controlNav: false,
minItems: 5,
maxItems: 5
});
}
;
$('.menu-scroller').slimScroll({
height: '450px'
});
},
events: '<?php echo base_url() ?>lunchbox/checkcalendardate'
});
$("#calendar").find('.fc-prev-button').children('span').removeClass('fc-icon fc-icon-left-single-arrow').addClass('left-arrow');
$("#calendar").find('.fc-next-button ').children('span').removeClass('fc-icon fc-icon-right-single-arrow').addClass('right-arrow');
$("#calendar").find('.fc-day-number').wrapInner('<span class="span-style"><span /></span>');
var view = $('#calendar').fullCalendar('getView');
//var view2 = $('#calendar').fullCalendar('getView').end;
$("#calendar").find('.fc-other-month').append('<span class="disable"></span>');
};
clandarBooking();
});
$(document).on('click', '.fc-next-button, .fc-prev-button', function() {
$("#calendar").find('.fc-other-month').append('<span class="disable"></span>');
});
</script>
<style>
</style>
<div class="my-profile clearfix">
<div class="container">
<div class="row">
<?php include 'section-navigation.php'; ?>
<div class="right-side-bdy clearfix">
<div class="portlet">
<div class="portlet-body clearfix">
<div class="col-md-12">
<div class="col-md-2">
<div class="left-sideblk-top hidden-print">
<?php $companydetails ?>
<div class="info-feature">
<img src="<?php echo $companydetails[0]['image'] ?>" >
</div>
<strong><?php echo $companydetails[0]['organization_name'] ?></strong><br><br>
<strong><?php echo $this->session->userdata('lunch_userName'); ?> <?php echo $this->session->userdata('lunch_lastName'); ?></strong>
</div>
<div class="hidden-other-media visible-print ">
<?php $companydetails ?>
<div class="print-heading ">
<div class="print-feature">
<img src="<?php echo $companydetails[0]['image'] ?>">
</div>
<div class="print-content">
<h2><?php echo $companydetails[0]['organization_name'] ?></h2>
<p><?php echo $this->session->userdata('lunch_userName'); ?> <?php echo $this->session->userdata('lunch_lastName'); ?></p>
</div>
</div>
</div>
</div>
<div class="col-md-10">
<div id="test">
<div id="calendar"></div>
</div>
<div class="clearfix">
<div class="row">
<div class="col-md-6">
<div class="btn-group hidden-print">
<a href="javascript:void(0);" onclick="printPage();"><img src="<?php echo $this->config->item('front_theme_path'); ?>default/images/print_btn2.png"/></a>
</div>
</div>
<div class="col-md-6">
<a href="javascript:void(0);" class="pull-right hidden-print"><img src="<?php echo $this->config->item('front_theme_path'); ?>default/images/cart.png"/></a>
</div>
</div>
</div>
</div>
</div>
</div> <!---/portlet-body----------------->
</div><!-----/portlet---------->
</div>
</div>
</div>
</div>
<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content new-modal-content">
<div class="modal-header">
<!-- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>-->
</div>
<div class="modal-body">
<div class="full-grid clearfix" >
<div class="row">
<div class="top-grid clearfix">
<div class="close-modal">
<button aria-label="Close" data-dismiss="modal" class="close" type="button"><span aria-hidden="true"><img src="<?php echo $this->config->item('front_theme_path');?>default/images/new-images/close_button.png" alt="logo"></span></button>
</div>
<div class="col-md-8">
<div class="content-header clearfix text-center">
<h2 class="title-normal text-normal">Choose a restaurant</h2>
</div>
<div class="content-body clearfix">
<div class="horizontal-sliding small-slider" >
<div class="flexslider carousel" id="horizontalLogo">
<ul class="slides">
<?php
foreach ($restaurant_list as $row_restaurant_image) {
?>
<li>
<div class="small-carousel-logos">
<img style="cursor: pointer;" onclick="company_food('<?php echo $row_restaurant_image['companyId']; ?>', '<?php echo $row_restaurant_image['shopLogo'] ?>')" src="<?php echo $row_restaurant_image['shopLogo'] ?>" title="<?php echo $row_restaurant_image['companyName']; ?>" alt=""/>
</div>
</li>
<?php
}
?>
</ul>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class='holiday-dates-wrapper clearfix '>
<div class='top-dates pull-right'>
<div class='dates text-right'>
<strong class="blue-title" > Date: <span id="getDate"></span></strong>
</div>
<div class='times text-right'>
<select style='' name='days' onchange='' id="set_delivery_time">
<?php
$time = '11:00'; // start
for ($i = 0; $i <= 24; $i++) {
$prev = date('g:i a', strtotime($time)); // format the start time
$next = strtotime('+15mins', strtotime($time)); // add 30 mins
$time = date('g:i a', $next); // format the next time
echo '<option value ="' . $prev . '">' . $prev . '</option>';
}
?>
</select>
<div class='checkbox'>
<label class='text-left'>
<input type="checkbox" name="same_as_time">
<span></span>
<bdo>Same time for all</bdo>
</label>
</div>
</div>
</div>
<div class='bot-holidays'>
<div class="form-group holiday-group">
<h3 class='text-normal blue-title'> Is this a holiday?</h3>
<div class="checkbox">
<label>
<input type="checkbox">
<span></span><bdo>Yes</bdo>
</label>
<label>
<input type="text" onkeyup="checkholyday()" name="holiday" id="holyday" class='form-control static-form-control'>
<span></span>
</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-12" id="msg_success"></div>
<div class="content-section">
<div class="row">
<div class="col-md-12">
<div class="option">
<div class="col-md-4 ">
<!--<button class="btn btn-primary btn-default pull-right"> Done</button>-->
</div>
</div> <!--------/option-------------->
<div class="col-md-12 option-conts no-padding">
<div class="clearfix">
<div class="option-blocks">
<div class="col-md-4">
<div class="opts">
<div class="opt-heading" id="menu_title_opt2">
<div class='menu-title'>
<h4 class="title-normal text-normal" id="manu_logo">Option2</h4>
</div>
</div>
<div class="opt-content">
<ul class="menu-scroller" id="left-defaults">
</ul>
</div>
</div><!---/opts--------->
</div> <!--------/leftBlock------------>
<div class="col-md-4 ">
<div class="opts">
<div class="opt-heading">
<div class='menu-title' id="menu_title_opt1">
<h4 class="title-normal text-normal" id="manu_logo">Option1</h4>
</div>
</div>
<div class="opt-content">
<ul class="menu-scroller" id="mid-defaults">
</ul>
</div>
</div>
</div><!---------/midBlock-------------------->
<div class="col-md-4">
<div class="opts">
<div class="opt-heading">
<div class='menu-title' id="menu_title">
<h4 class="title-normal text-normal" id="manu_logo">Select Menu</h4>
<p>Drag & your favourite menu</p>
</div>
</div>
<div class="opt-content">
<ul class="menu-scroller product-list right" id="right-defaults">
<div class="menu-options" style="">
<div class="menu-to-insert-body collapse" >
<div class="menus">
<ul class="menus-ul" >
<div class="todrag">
</div>
</ul>
</div>
</div>
</div>
</ul>
</div>
</div>
</div><!---------/rightBlock-------------------->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer clearfix">
<div class="checkbox">
<label>
<input type="checkbox">
<span></span>
<bdo>Save options for everyday</bdo>
</label>
</div>
<!-- <form id="userprofile" name="userprofile" method="post" action="<?php //echo $this->config->item('base_url'); ?>lunchbox/addmealPlan">-->
<form id="userprofile" name="userprofile" method="post">
<input type="hidden" name="meal_creation_date" id="meal_creation_date" value="">
<input type="hidden" name="meal_delivery_time" id="meal_delivery_time" value="">
<input type="hidden" name="all_day_same_time" id="all_day_same_time" value="">
<input type="hidden" name="holidayval" id="holydayval" value="">
<input type="hidden" name="option_manu_id[]" value="" id="option1manuid">
<input type="hidden" name="option_manu_id[]" value="" id="option2manuid">
<div class="col-md-12" style="float:right;">
<div class="col-md-5 col-md-offset-2">
<!--<input type="button" class="btn green-gradient-btn col-xs-3" name="" data-dismiss="modal" aria-label="Close" value="Close" onclick="clean_data();">-->
<input type="button" onclick="asktoclear();" class="btn green-gradient-btn col-xs-3" name="" value="Clear all">
<input type="button" onclick="submitform();" class="btn green-gradient-btn col-xs-3" name="" value="Submit">
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
function removeFile(list, value, separator) {
var values = list.split(separator);
//alert(values);
for (var i = 0; i < values.length; i++) {
if (values[i] == value) {
values.splice(i, 1);
return values.join(separator);
}
}
return list;
}
function checkholyday()
{
var option1 = document.getElementById("holyday").value;
document.getElementById("holydayval").value = option1;
}
function submitform()
{
// Start: Get DEisplay Date From Pop Up And Add 1 Dat
var n = 1; //number of days to add.
var today = new Date($('#getDate').html()); //Today's Date
var requiredDate = new Date(today.getFullYear(), today.getMonth(), today.getDate() + n);
// GET YYYY, MM AND DD FROM THE DATE OBJECT
var yyyy = requiredDate.getFullYear().toString();
var mm = (requiredDate.getMonth() + 1).toString();
var dd = requiredDate.getDate().toString();
// CONVERT mm AND dd INTO chars
var mmChars = mm.split('');
var ddChars = dd.split('');
// CONCAT THE STRINGS IN YYYY-MM-DD FORMAT
var datestring = yyyy + '-' + (mmChars[1] ? mm : "0" + mmChars[0]) + '-' + (ddChars[1] ? dd : "0" + ddChars[0]);
//alert(datestring);
// End: Get DEisplay Date From Pop Up And Add 1 Dat
var option1 = document.getElementById("option1manuid").value;
var option2 = document.getElementById("option2manuid").value;
var hollyday = document.getElementById("holydayval").value;
//alert(hollyday);
if ((option1 != '' && option2 != '') || hollyday != '') {
var delivery_tyme = $('#set_delivery_time').val();
$('#meal_delivery_time').val(delivery_tyme);
if ($('[name="same_as_time"]').is(':checked')) {
$('#all_day_same_time').val('1'); // checked
} else {
$('#all_day_same_time').val('0'); // unchecked
}
if (confirm("Do you want to save?")) {
//document.userprofile.submit();
var option_manu_ids = $('input[name="option_manu_id[]"]').map(function() {
return this.value
}).get()
var meal_creation_date = $('#meal_creation_date').val();
var meal_delivery_time = $('#meal_delivery_time').val();
var all_day_same_time = $('#all_day_same_time').val();
var holidayval = $('#holydayval').val();
alert(option_manu_ids);
jQuery.ajax({
url: '<?php echo base_url() ?>lunchbox/addmealPlan',
type: 'POST',
data: {option_manu_ids: option_manu_ids, meal_creation_date: meal_creation_date, meal_delivery_time: meal_delivery_time, all_day_same_time: all_day_same_time, holidayval: holidayval},
cache: false,
success: function(data, textStatus, jqXHR) {
console.log(data);
$('#getDate').html(datestring);
$('#meal_creation_date').val(datestring);
if ($('[name="same_meal_chkbox"]').is(':checked')) {
alert('Your meal is saved');
}else{
clean_data(); // model close and data clear
}
},
error: function(jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});
}
return false;
}
else {
alert('Please drug anyone product to both option');
}
}
// function company_food(company_id, src){
// //alert(src);
// $.post('<?php echo base_url() ?>lunchbox/getProduct',
// {company_id: company_id},
// function(result)
// {
// $("#manu_logo").html('<img src="' + src + '" width="80" height="20">');
// $(".product-list").html(result);
// // $(".cat-menu-lis-t").slideToggle("slow");
// $('#company_id').val(company_id);
// }
//
// )
// }
function asktoclear()
{
var r = confirm("Are you sure you want to clear all option!");
if (r == true) {
$("#manu_logo").html('');
$(".product-list").html('');
$("#left-defaults").html('');
$("#mid-defaults").html('');
}
}
function clean_data() {
$("#manu_logo").html('');
$(".product-list").html('');
$("#left-defaults").html('');
$("#mid-defaults").html('');
location.reload();
}
</script>
<?php include 'footer.php'; ?>
<script>
function company_food(company_id, src) {
$.post('<?php echo base_url() ?>lunchbox/getProduct',
{company_id: company_id},
function(result)
{
$("#manu_logo").html('<img src="' + src + '" width="200" height="100">');
$('#menu_title').hide();
$(".product-list").html(result);
var alla = [];
$(result).find('.menus-ul').each(function(){
alla = $(this).attr('id');
});
});
var drags = function(){
var selectors = [document.querySelector('#left-defaults'), document.querySelector('#mid-defaults'), document.querySelector('.product-list') ];
var dragu = dragula(selectors, {
revertOnSpill: true,
copy: true,
}).on('drop',function(el, container){
var toAppend = $(el).find('li');
$('<p class="remove-this">X</p>').appendTo( toAppend );
if($('.menus-ul li').length === 0){
$('.menus-ul').hide();
}
});
};
drags();
}
function removeFile(list, value, separator) {
var values = list.split(separator);
//alert(values);
for (var i = 0; i < values.length; i++) {
if (values[i] == value) {
values.splice(i, 1);
return values.join(separator);
}
}
//alert(list);
return list;
}
function printInfo(ele) {
// var openWindow = window.open("", "title", "attributes");
// openWindow.document.write(ele.previousSibling.innerHTML);
// openWindow.document.close();
// openWindow.focus();
// openWindow.print();
// openWindow.close();
var prtContent = document.getElementById("test");
var WinPrint = window.open('', '', 'left=300,top=100,width=800,height=900,toolbar=1,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}
function printPage() {
window.print();
}
$(document).on('click','.remove-this',function(){
$(this).parent().remove();
$('.menus-ul li').on('remove',function(){
alert('hi')
})
});
$(document).ready(function(){
if($('#mid-defaults .menus-ul li').length === 0 ){
$('#mid-defaults .menus-ul').hide();
}
});
</script>