MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: /home/cafsindia/allyindian_com/sbltt/application/views/demand_date/form.php
<?php
	echo form_open('demand_date/save/' . $demand_date->demand_date_id,array('id'=>'demand_date_form','class'=>'form-inline'));
?>
<fieldset id="FundBasicInfo">
	<div class="form-group ">
		<?php echo form_label("Demand Date", 'demand_month', array('class' => 'required')); ?>
		<?php			
			if(!$demand_date->demand_month){
				$demand_month = date('d-m-Y');
			}else{
				$demand_month = $demand_date->demand_month;
			}
			$sortdate = strtotime($demand_month);
			$demand_month = date('Y-m',$sortdate);
			
			echo form_input(array(
				'name'=>'demand_month',
				'id' => 'demand_month',
				'class'=>'form-control input-sm datepicker',
				'placeholder'=>'MM-YYYY',
				'value'=>date("m-Y", strtotime($demand_month)))
			);
			
			$date_info = explode('-', $demand_month);
			$year  = $date_info[0];
			$month = $date_info[1];
			$toaldays =cal_days_in_month(CAL_GREGORIAN,$month,$year);
			$style = "style='height: 60px !important; text-align: center !important; border: 1px solid #CCCCCC;font-weight: bold;'";
			for ($i = 1; $i <= $toaldays; $i++) {
				$count++;
				$col = "day_".$i;
				$atten = $demand_date->$col;
				$chk = "";
				if($atten === "1"){
					$chk = "checked";
				}
				/* UDY - Days
				$getday = strtotime("$year-$month-$i");
				$day    = date('D', $getday);
				*/
				$td_line .= "<td $style>$i <br/> <input type='checkbox' name='demand_date[]' value='$i' $chk/>  </td>";
				if($count === 7){					
					$tr_line .= "<tr>$td_line</tr>";
					$count   = 0;
					$td_line = "";
				}else{
					if($i >= $toaldays){
						$tr_line .= "<tr>$td_line</tr>";
					}
				}
			}
		?>
	</div>
	<div class="form-group ">
		<?php echo form_label("Percentage", 'percentage', array('class' => 'required')); ?>
		<?php			
			echo form_input(array(
				'name'=>'percentage',
				'id' => 'percentage',
				'class'=>'form-control input-sm',
				'placeholder'=>'Percentage',
				'value'=>$demand_date->percentage)
			);
		?>
	</div>
	<table class="table table-hover table-striped" id="calender_table">
		<?php echo $tr_line;?>
	</table>
	<div class="form-group">
		<?php
			echo form_input(
				array(
					'name'=>'demand_date_id',
					'id'=>'demand_date_id',
					'type'=>'Hidden',
					'class'=>'form-control input-sm',
					'value'=>$demand_date->demand_date_id
				)
			);
		?>
	</div>
</fieldset>
<?php echo form_close(); ?>
<script type="text/javascript">
$(document).ready(function(){
	
	demand_date_id = '<?php echo $demand_date->demand_date_id ?>';
	if(demand_date_id){
		$('#demand_month').attr('readonly', true);    
	}
	$("#demand_month").bind('blur', function(e) {
		demand_month  = $('#demand_month').val();
		urlLink = "<?php echo base_url('index.php/demand_date/exists'); ?>";
		params  = "demand_date_id=" +demand_date_id + "&demand_month=" +demand_month;
		ajaxPostJQ(urlLink, params, demand_month_callback);
	});
	/*
	month   = $('#date').val();
		emp_id  = $('#emp_id').val();
		rslt = month.split("-");

		days = getdays(rslt[1],rslt[0]);
		//alert(days);
		$('#days').val(days);
	*/
	//Datepicker format
	$(function () {
		$(".datepicker").datetimepicker({
			format: 'MM-YYYY'
		});
	});
	
	
	$(".number").bind('keyup', function(e) {
		this.value = this.value.replace(/[^0-9_.]/g,'');
	});

	/*========= Allow text validation =========*/
	$(".alpha").on("keydown", function(event){
		var arr = [8,9,16,17,20,32,35,36,37,38,39,40,45,46];
		for(var i = 65; i <= 90; i++){
			arr.push(i);
		}	
		if(jQuery.inArray(event.which, arr) === -1){
			event.preventDefault();
		}
	});
	
	$.validator.addMethod("pan", function (value, element) {
		return this.optional(element) || /^[A-Z]{5}\d{4}[A-Z]{1}$/.test(value);
	}, "Invalid Pan Number");
	
	$.validator.addMethod("gst_in", function (value, element) {
		return this.optional(element) || /^[0-9]{2}[A-Za-z]{5}[0-9]{4}[a-zA-Z][0-9]{1}[a-zA-Z]{1}[0-9]{1}$/.test(value);
	}, "Invalid GST Number");


	$('#demand_date_form').validate($.extend({
		submitHandler: function (form)
		{
		  $('#submit').attr('disabled','disabled');
			$(form).ajaxSubmit({
				success: function (response)
				{
					dialog_support.hide();
					table_support.handle_submit('<?php echo site_url($controller_name); ?>', response);
					table_support.refresh();
				},
				dataType: 'json'
			});
		},
		rules:{
			demand_date: "required",
			percentage: {
			  required: true,
			  max: 100
			}  
		}
	}));
});
function demand_month_callback(data){
	if(data === "1"){
		alert("Demand dates already added for this month");
		$('.modal ').modal('hide');
	}else{
		month   = $('#demand_month').val();
		rslt = month.split("-");
		days = getdays(rslt[0],rslt[1]);
		
		var td_line = "";
		var tr_line = "";
		var count = 0;
		var style = "style='height: 60px !important; text-align: center !important; border: 1px solid #CCCCCC;font-weight: bold;'";
		for (i = 1; i <= days; i++) {
			count++;
			td_line += "<td "+style+"> "+i+ "<br/> <input type='checkbox' name='demand_date[]' value='"+i+ "'/>  </td>";
			if(count === 7){					
				tr_line += "<tr>"+td_line+"</tr>";
				count   = 0;
				td_line = "";
			}else{
				if(i >= days){
					tr_line += "<tr>"+td_line+"</tr>";
				}
			}
		}
		$("#calender_table").html(tr_line);
	}
}
function getdays(month,year){
	 return new Date(year, month, 0).getDate();
}
function ajaxPostJQ(urlLink, params, callbackfn) {
	 $.ajax({
		type: 'POST',
		url: urlLink,
		data: params,
		dataType: 'html',
		traditional: true,
		async: true,
		success: callbackfn
	});
}
</script>