<?php
session_start();
// ============
include("../../php_crud/my_class.php");
include('alert.php');
$obj=new my_class();
// ============
$branchid = $_SESSION['LOGIN_BRANCH'];
//$delete=$obj->Delete_Data("_fee_details_invoice","_std_id='686' AND _month='2'");
//$delete=$obj->Delete_Data("_fee_master_invoice","_std_id='686' AND _month='2'");
?>
<script src="module/fees/js/indi_fee_generate.js" type="text/javascript"></script>
<div id="finished_div">
<div class="main-container container-fluid">
	<div class="page-content" style="padding-bottom:5px;">
		<div class="row-fluid" style="background-color:#f5f5f5;-webkit-box-shadow: 0 8px 6px -6px black;
	   -moz-box-shadow: 0 8px 6px -6px black;
	        box-shadow: 0 8px 6px -6px black;">
            <div class="widget-header header-color-green2">
<h4 class="lighter smaller" >Individual Fee Generate</h4>
</div>
			<div class="span3">
				<div class="control-group" >
					<label class="control-label" for="form-field-1" style="font-size:14px;">STD ID<font color="#FF0000">*</font></label>
					<div class="controls">
							<input name="std_uniq_id" id="std_uniq_id" type="text">
					</div>
				</div>
			</div>
		
		
			<div class="span3">
				<div class="control-group" >
					<label class="control-label" for="form-field-1" style="font-size:14px;">Month Select : <font color="#FF0000">*</font></label>
					<div class="controls">
						<select id="month" name="month">
							<option value="">--- Select ---</option>
						    <option <?php if(date('m')=='01'){echo 'selected';} ?> value="1">January</option>
						    <option <?php if(date('m')=='02'){echo 'selected';} ?> value="2">February</option>
						    <option <?php if(date('m')=='03'){echo 'selected';} ?> value="3">March</option>
						    <option <?php if(date('m')=='04'){echo 'selected';} ?> value="4">April</option>
						    <option <?php if(date('m')=='05'){echo 'selected';} ?> value="5">May</option>
						    <option <?php if(date('m')=='06'){echo 'selected';} ?> value="6">June</option>
						    <option <?php if(date('m')=='07'){echo 'selected';} ?> value="7">July</option>
						    <option <?php if(date('m')=='08'){echo 'selected';} ?> value="8">August</option>
						    <option <?php if(date('m')=='09'){echo 'selected';} ?> value="9">September</option>
						    <option <?php if(date('m')=='10'){echo 'selected';} ?> value="10">October</option>
						    <option <?php if(date('m')=='11'){echo 'selected';} ?> value="11">November</option>
						    <option <?php if(date('m')=='12'){echo 'selected';} ?> value="12">December</option>
						</select>
					</div>
				</div>
			</div>

			<div class="span3">
				<div class="control-group" >
					<label class="control-label" for="form-field-1" style="font-size:14px;">Year Select : <font color="#FF0000">*</font></label>
					<div class="controls">
						<select id="year" name="year">
							<option value="">--- Select ---</option>
							<?php
							for ($j=date('Y')-1; $j < date('Y')+2; $j++) { 							
							?>
						    <option <?php if($j==date('Y')){echo 'selected';} ?> value="<?php echo $j; ?>"><?php echo $j; ?></option>
						    <?php } ?>
						</select>
					</div>
				</div>
			</div>
            
            <div class="span2">
				<div class="control-group" >
					<label class="control-label" for="form-field-1" style="font-size:14px;">Payment Last Date : <font color="#FF0000">*</font></label>
					<div class="controls">
						<input id="payment_last_date" name="payment_last_date" class="date-picker" type="text" data-date-format="dd-mm-yyyy" placeholder="dd-mm-yyyy" value="<?php echo date('d/m/Y',strtotime("+10 day"));?>"  />
					</div>
				</div>
			</div>

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


<!-- ================================== -->
<!-- Loading Message -->
<div class="row-fluid">
<div class="span10 loading" style="z-index:9999; position:absolute; height:600px; display:none; margin:-70px 0px 0px 0px; background: rgba(255,255,255, 0.3); text-align:center; vertical-align:middle; padding-top:70px;"></div>
</div>


<div class="main-container container-fluid">

				<div class="page-content">

					<div class="row-fluid">
						<div class="span12">

<div class="row-fluid">
	<div class="span12">
		<div class="widget-box">
			<div class="widget-header widget-header-blue widget-header-flat">
				<h4 class="lighter" style="font-weight:bold;">Generate Fee Invoice</h4>
			</div>

			<div class="widget-body">
				<div class="widget-main">
					<div class="row-fluid">

						<div id="fuelux-wizard" class="row-fluid hide" data-target="#step-container">
							<ul class="wizard-steps">
								<li data-target="#step1" class="active">
									<span class="step">1</span>
									<span class="title" style="font-weight:bold; color:#9687bf;">Others Fee</span>
								</li>

								<li data-target="#step2">
									<span class="step">2</span>
									<span class="title" style="font-weight:bold; color:#2283c5;">Attendance Fine</span>
								</li>

								<!--
								<li data-target="#step3">
									<span class="step">3</span>
									<span class="title" style="font-weight:bold; color:#2e8965;">ScholarShip</span>
								</li>

								<li data-target="#step4">
									<span class="step">4</span>
									<span class="title" style="font-weight:bold; color:#333333;">Previous Due Calculate</span>
								</li>
                                <li data-target="#step5">
									<span class="step">5</span>
									<span class="title" style="font-weight:bold; color:#333333;">Other Fee Calculate</span>
								</li>
								-->

							</ul>
						</div>

						<hr />



						<div class="step-content row-fluid position-relative" id="step-container">
							<div class="step-pane active" id="step1">
								
								
									
									<form>
									<div class="control-group info">
										<!--<div class="span2">
											
										</div>-->
                                        <div class="span12">
                         
                         <h3 class="lighter block green">Monthly Type Bill Generate</h3>
						<label class="control-label" for="inputInfo">Select Monthly Bill Type</label>

		
<style>
 .main_div { 
     width:100%;
	 
	 text-align:left; 
	 padding-left:50px;
     
 }
 .lbl { 
     width:250px; 
     float:left;
 }
 .fee_id{
 background-color:#FF0000;
 }

</style>

<?php /*?><?php 
    

$data = array();
$fee_head_id = array();
foreach($obj->View_class_fee("fdc._branch_id='$branchid' AND (fh._fee_type='M' OR fh._fee_type='O') AND fdc._status='A' GROUP BY fdc._fee_head_id") AS $value1){
extract($value1);
$data[] = $value1['_fee_head'];
$fee_head_id[] = $value1['_fee_head_id'];
}
//print_r($data);
 //echo $test = sizeof($data);									
	
    $numItems = sizeof($data);

    //*** max number of rows
    $maxRows = 10;
    $maxItems = 10 * $maxRows;

    echo '<div class="main_div">';
    for ($i=0; $i<$numItems;$i++) {
        echo '<div class="lbl"><input type="checkbox" class="fee_id" id="fee_id" name="fee_id[]" onclick="monthly_fee_select()" value="'.$fee_head_id[$i].'" style="background-color:#FF0000;" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$data[$i].'</div>';
        if (($i+1) % 3 == 0) {
            //*** if divisible by 3, close row
            echo '</div><div class="main_div">'; 
        }
        if ($i == $numItems) {
            //*** last item reached, close div
            echo '</div>';  
        }
        if ($i+1 >= $maxItems ) {
            //*** max 10 row, add more button.
            echo '</div><input type="submit" value="Add More">'; 
        return; 
        }
    }

?><?php */?>




                         <?php
											$x=0;
											//foreach($obj->View_class_fee("fdc._branch_id='$branchid' AND (fh._fee_type='M' OR fh._fee_type='O') AND fdc._status='A' GROUP BY fdc._fee_head_id") AS $value1){
											foreach($obj->View_class_fee("fdc._branch_id='$branchid' AND fh._fee_type='O' AND fdc._status='A' GROUP BY fdc._fee_head_id") AS $value1){
											
											extract($value1);
											$x++;
											?>
											<div class="controls">
												<label>
													<input type="checkbox" class="fee_id" id="fee_id" name="fee_id[]" onclick="monthly_fee_select(<?php echo $x;?>)" value="<?php echo $_fee_head_id; ?>">
													<span class="lbl"> <?php echo $_fee_head; ?></span>
                                                    
                                               </label>
											</div>
											<?php } ?>
                                            
							<input type="hidden" id="fee_token" name="fee_ids" >
                                          
										
                                        </div>
										<div class="span12" style="text-align:center; padding-top:20px;">
										<button class="btn btn-small btn-success" type="button"  onclick="save_monthly_fee()"><i class="icon-ok bigger-100" style="font-size:18px;"></i>Generate</button>	
										</div>
									</div>
									</form>
								
							</div>




							<div class="step-pane" id="step2">
								
								
								<div class="row-fluid">
									<div class="span4">
                                    </div>
                                    <div class="span4">
                                    <h3 class="lighter block green">Attendance fine calculate</h3>
									<div class="control-group info">
										<label class="control-label" for="inputInfo">Are You Agree for Attendance fine calculate ??</label>

										<div class="controls">
											<div class="row-fluid">
												<label>
													<input type="checkbox" id="abs_fine" name="abs_fine" value="absent_fine">
													<span class="lbl"> Absent Fine calculate</span>
												</label>
											</div>

											<div class="row-fluid">
												<input type="text" id="abs_fine_head" name="abs_fine_head" placeholder="Write Absent Fine Head">
											</div>
										</div>

										<div class="controls">
											<div class="row-fluid">
											<label>
												<input type="checkbox" id="late_fine" name="late_fine" value="late_fine">
												<span class="lbl"> Late Fine calculate</span>
											</label>
											</div>

											<div class="row-fluid">
												<input type="text" id="late_fine_head" name="late_fine_head" placeholder="Write Late Fine Head">
											</div>

										</div>

										

									</div>
                                    <button class="btn btn-small btn-success" type="button"  onclick="save_atd_fine()"><i class="icon-ok bigger-100"></i>Generate</button>
									</div>

									<div class="span4">
										
									</div>

								</div>

							</div>

							
							<div class="step-pane" id="step3">
								<div class="controls">
									
									<div class="row-fluid">
										<div class="span4">
                                        </div>
                                        <div class="span4">
                                        <h3 class="green">ScholarShip Generate</h3>
											<?php /*?><?php
											foreach($obj->View_all_data_row_column_By_Cond("_int_scholarship_declare","_purpose","1=1 GROUP BY _purpose") AS $value1){
											extract($value1);
											?><?php */?>
											<!--<div class="controls">
												<label>
													<input type="checkbox" class="fee_id" id="scholar_generate" name="scholar_generate[]" onclick="monthly_schr_select()" value="<?php //echo $_purpose; ?>">
													<span class="lbl"> <?php //echo $_purpose; ?></span>
												</label>
											</div>
											<?php //} ?>
											<input type="hidden" id="fee_schr_token" name="scholar_generates">-->
                                            
                                            <label>
												<input type="checkbox" id="scholar_generate" name="scholar_generate" value="scholarship">
												<span class="lbl"> Are You Agree ?</span>
											</label>
                                            <button class="btn btn-small btn-success" type="button"  onclick="save_scholar()"><i class="icon-ok bigger-100"></i>Generate</button>
										</div>


										<div class="span4">
											
										</div>

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

							<div class="step-pane" id="step4">
								
                                <div class="controls">
									
									<div class="row-fluid">
										<div class="span4">
                                        </div>
                                        <div class="span4">
                                        <h3 class="green">Previous Due Calculate</h3>
											<label class="control-label" for="inputInfo">Are You Agree for Previous Due fine calculate ??</label>
                                            <label>
												<input type="checkbox" id="pre_due" name="pre_due" value="pre_due">
												<span class="lbl"> Previous Due Calculate ?</span>
											</label>
                                            <br />
                                            <label class="control-label" for="inputInfo">Are You Agree for Payment Late fine calculate ??</label>
                                            <label>
												<input type="checkbox" id="payment_late_fine" name="payment_late_fine" value="payment_late_fine">
												<span class="lbl"> Payment Late fine calculate ?</span>
											</label>
                                            <button class="btn btn-small btn-success" type="button" onclick="save_previus_due()"><i class="icon-ok bigger-100"></i>Generate</button>
										</div>

										<div class="span4" style="border:1px solid #CCCCCC;">
											<h3 class="red" style="text-align:center;">Calculate Information</h3>
                                            <ul>
                                           
                                            	<li>&nbsp;Unpaid Invoice Month : <b><span id="unpaid_invoice_month"></span></b></li>
                                                <li>&nbsp;Total Unpaid Invoice : <b><span id="unpaid_invoice"></span></b></li>
                                                <li>&nbsp;PR Invoice Month : <b><span id="pr_invoice_month"></span></b></li>
                                                <li>&nbsp;Total PR Invoice : <b><span id="pr_invoice"></span></b></li>
                                                
                                            </ul>
										</div>
									</div>
								</div>
							</div>
                            
                            <div class="step-pane" id="step5">
								
                                <div class="controls">
									
									<div class="row-fluid">
										<div class="span4">
                                        </div>
                                        <div class="span4">
                                        <h3 class="green">Other Fee Calculate</h3>
											<label class="control-label" for="inputInfo">Are You Agree for Other Fee calculate ??</label>
                                            <label>
												<input type="checkbox" id="other_fee" name="other_fee" value="other fee">
												<span class="lbl"> Other Fee Calculate ?</span>
											</label>
                                            <br />
                                             <br />
                                            
                                            
                                            <button class="btn btn-small btn-success" type="button" onclick="save_other_fee()"><i class="icon-ok bigger-100"></i>Generate</button>
										</div>

										<div class="span4">
											
										</div>
									</div>
								</div>
							</div>


						</div>

						<hr />
						<div class="row-fluid wizard-actions">
							<button class="btn btn-prev nxt" onclick="return false;" style="float:left; font-size:16px; font-weight:bold">
								<i class="icon-arrow-left"></i>
								Prev
							</button>

							<button onclick="return false;" class="btn btn-success btn-next nxt" data-last="Finish" id="next_class" style="font-size:16px; font-weight:bold">
								Next
								<i class="icon-arrow-right icon-on-right"></i>
							</button>
						</div>
					</div>
				</div><!--/widget-main-->
			</div><!--/widget-body-->
		</div>
	</div>
</div>

						</div><!--/.span-->
					</div><!--/.row-fluid-->
				</div><!--/.page-content-->

		</div><!--/.main-container-->
</div><!--/Finished Div Load-->
		<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-small btn-inverse">
			<i class="icon-double-angle-up icon-only bigger-110"></i>
		</a>

		<script src="assets/js/fuelux/fuelux.wizard.min.js"></script>
		<script src="assets/js/jquery.validate.min.js"></script>
		<script src="assets/js/additional-methods.min.js"></script>
		<script src="assets/js/bootbox.min.js"></script>
		<script src="assets/js/jquery.maskedinput.min.js"></script>
		<script src="assets/js/select2.min.js"></script>


		<script type="text/javascript">
			$(function() {
			
				$('[data-rel=tooltip]').tooltip();
			
				$(".select2").css('width','150px').select2({allowClear:true})
				.on('change', function(){
					$(this).closest('form').validate().element($(this));
				}); 
			
			
				var $validation = false;
				$('#fuelux-wizard').ace_wizard().on('change' , function(e, info){
						if(info.step == 1 && $validation) {
						if(!$('#validation-form').valid()) return false;
					}
				}).on('finished', function(e) {
// ==========================================================
					var month =$.trim($('#month').val());
					var year =$.trim($('#year').val());
					var std_uniq_id =$.trim($('#std_uniq_id').val());
					$('#finished_div').html("<span style='color:#2e8965;font-size:16px;font-weight:bold;text-align:center;'>Please Wait.....  <img src='php_crud/img/preloader.gif' /></span>");
					//alert('Fee Generate Complete');
					$('#finished_div').load('module/fees/indi_generate_fee_summary.php',{'month':month,'year':year,'std_uniq_id':std_uniq_id},function(data){
			//alert(data);
					}); 
					
// ==========================================================
				}).on('stepclick', function(e){
					//return false;//prevent clicking on steps
				});
			
			


				$('#validation-form').hide();

				$('#skip-validation').removeAttr('checked').on('click', function(){
					$validation = this.checked;
					if(this.checked) {
						$('#sample-form').hide();
						$('#validation-form').show();
					}
					else {
						$('#validation-form').hide();
						$('#sample-form').show();
					}
				});
			
			
			
				//documentation : http://docs.jquery.com/Plugins/Validation/validate
			
			
				$.mask.definitions['~']='[+-]';
				$('#phone').mask('(999) 999-9999');
			
				jQuery.validator.addMethod("phone", function (value, element) {
					return this.optional(element) || /^\(\d{3}\) \d{3}\-\d{4}( x\d{1,6})?$/.test(value);
				}, "Enter a valid phone number.");
			
				$('#validation-form').validate({
					errorElement: 'span',
					errorClass: 'help-inline',
					focusInvalid: false,
					rules: {
						email: {
							required: true,
							email:true
						},
						password: {
							required: true,
							minlength: 5
						},
						password2: {
							required: true,
							minlength: 5,
							equalTo: "#password"
						},
						name: {
							required: true
						},
						phone: {
							required: true,
							phone: 'required'
						},
						url: {
							required: true,
							url: true
						},
						comment: {
							required: true
						},
						state: {
							required: true
						},
						platform: {
							required: true
						},
						subscription: {
							required: true
						},
						gender: 'required',
						agree: 'required'
					},
			
					messages: {
						email: {
							required: "Please provide a valid email.",
							email: "Please provide a valid email."
						},
						password: {
							required: "Please specify a password.",
							minlength: "Please specify a secure password."
						},
						subscription: "Please choose at least one option",
						gender: "Please choose gender",
						agree: "Please accept our policy"
					},
			
					invalidHandler: function (event, validator) { //display error alert on form submit   
						$('.alert-error', $('.login-form')).show();
					},
			
					highlight: function (e) {
						$(e).closest('.control-group').removeClass('info').addClass('error');
					},
			
					success: function (e) {
						$(e).closest('.control-group').removeClass('error').addClass('info');
						$(e).remove();
					},
			
					errorPlacement: function (error, element) {
						if(element.is(':checkbox') || element.is(':radio')) {
							var controls = element.closest('.controls');
							if(controls.find(':checkbox,:radio').length > 1) controls.append(error);
							else error.insertAfter(element.nextAll('.lbl:eq(0)').eq(0));
						}
						else if(element.is('.select2')) {
							error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
						}
						else if(element.is('.chzn-select')) {
							error.insertAfter(element.siblings('[class*="chzn-container"]:eq(0)'));
						}
						else error.insertAfter(element);
					},
			
					submitHandler: function (form) {
					},
					invalidHandler: function (form) {
					}
				});
			
				
			})

</script>
<script type="text/javascript">
	$('.date-picker').datepicker({
		format: 'dd/mm/yyyy',
		todayHighlight:'TRUE',
		startDate: '-0d',
		autoclose: true,
	})
	/*$('.date-picker').datepicker().next().on(ace.click_event, function(){
     $(this).prev().focus();
    });*/
	$("#next_class").click(function(){
	var std_uniq_id =$.trim($('#std_uniq_id').val());
	//alert(class_id);
	var datast="std_uniq_id="+std_uniq_id;
	if(std_uniq_id==""){
		alert("Please Enter Student ID. Otherwise Not Show Unpaid Invoice.");
		$('#std_uniq_id').focus();
		return false;
	}else{
	//alert(datast);
	$.ajax({
			type:"post",
			url:"module/fees/indi_wise_calculate_ajax.php",
			data:datast ,
			success:function(result){
				//alert(result);
				var arr = result.split('#@!');
				$('#unpaid_invoice').html(arr[0]);
				$('#pr_invoice').html(arr[1]);
				$('#unpaid_invoice_month').html(arr[2]);
				$('#pr_invoice_month').html(arr[3]);
				//$(".loading").hide();
			}
		});
	}
});
	
</script>



