<?php 
session_start();
require_once("../../includes/display_internal_user_risk.inc.php");
require_once("../../includes/functions_internal_user_riskmangement.inc.php");
$obj = new data();
$connect = $obj->funConnect();
$display = new display();
$display->logout_iu();
$id = $_REQUEST['id'];


if (@$_REQUEST['action'] == 'submit')
 {
 	$msg = $obj->updateM2mRecords();
	header('Location:./m2m_list.php?msg='.$msg);
 }
$obj->viewM2MRecords($id);
$pagename = basename($_SERVER['PHP_SELF'])."?id=".$id;
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><?php $display->title(); ?></title>
<?php $display->favicon(); ?>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<?php $display->css(); ?>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
  <script src="../js/html5shiv.js"></script>
  <script src="../js/respond.min.js"></script>
<![endif]-->
<style>
.animated {
				vertical-align: top; 
				transition: height 0.2s;
				-webkit-transition: height 0.2s; 
				-moz-transition: height 0.2s; 
			}

form.cmxform label.error, label.error {
		/* remove the next line when you have trouble in IE6 with labels in list */
		font-family:Verdana, Arial, Helvetica, sans-serif;
		font-size:10px;
		color: red;
		font-style:normal;
		font-weight:lighter;
		margin:5px;
		vertical-align:top;
		}
</style>
</head>
    <body class="skin-blue fixed">
        <!-- header logo: style can be found in header.less -->
        <?php $display->header_tag(); ?>
		<div class="wrapper row-offcanvas row-offcanvas-left">
            <?php $display->leftmenu(6,3); ?>
			<aside class="right-side">                
                <!-- Content Header (Page header) -->
                 <section class="content-header">
                    <h1>
                        <i class="fa fa-folder-open"></i>&nbsp;Masters&nbsp;&nbsp;&nbsp;&nbsp;<small><div class="headline text-center" id="time" style="color:#000; font-weight:bold; font-size:12px;"></div></small>
                    </h1>
                    <ol class="breadcrumb">
                        <li><a href="../"><i class="fa fa-home"></i> Home</a></li>
                        <li class="active">FFA&nbsp;&nbsp;&nbsp;> Masters&nbsp;&nbsp;&nbsp; > M2M</li>
                    </ol>
                </section>

                <!-- Main content -->
                <section class="content invoice">
				<!--   content put here..................-->
				<div align="right"><a href="m2m_list.php"><button class="btn btn-info btn-flat">Back</button></a></div>
				<div style="height:10px;">&nbsp;</div>
				<form role="form" name="frm1" id="frm1" enctype="multipart/form-data" action="<?php echo $pagename;?>" method="post">			
				<div class="row">
                        <div class="col-xs-12">
                            <h2 class="page-header">
                             UPDATE M2M
                            </h2>                            
                        </div><!-- /.col -->
                    </div>
					
					<div class="row invoice-info">
                        <div class="col-sm-12 invoice-col">
						<label for="txtVCode" >Contract</label>
							<select  name="selCon" class="form-control" id="selCon" onChange="">
							
							<?php 
							echo $obj->getContractForFFA($obj->getfun4());
							?>
							</select>   
                        </div><!-- /.col -->

						<div class="col-sm-12 invoice-col">
				
							<label for="txtVCode" >FREQUENCY</label>
							<select  name="selFrequency" onchange="changePeriodStatus(this)" class="form-control"  id="selFrequency" >
							
							<option value="0">---Please select a option---</option>
							<option value="month"<?php if($obj->getfun1()=='month'){echo 'selected';}?>>Month</option>
							<option value="quarter" <?php if($obj->getfun1()=='quarter'){echo 'selected';}?>>Quarter</option>
							<option value="calendar"<?php if($obj->getfun1()=='calendar'){echo 'selected';}?>>Calendar</option>


							</select>   
						
				
	</div>
                      
						<div class="col-sm-12 invoice-col">
						<label for="txtYBDate" >PERIOD</label>
					<?php '<h1>'.$obj->getfun5();?>
						<input type="text" class="form-control" id="txtPeriod" name="txtPeriod" placeholder="Period"  value="<?= $obj->getfun5()?>">     
						<?php 
						// $obj->getBusinessTypeList1();
						?>

									
                        </div><!-- /.col -->

						<div class="col-sm-12 invoice-col">
						<label for="txtYBDate" >YEAR</label>

							<select id="selYearForFre" name ="selYearForFre" class="form-control"><option value="0">---Please select a option---</option><option value="2023"  <?php if($obj->getfun2()=='2023'){echo 'selected';}?>>2023</option><option value="2024"<?php if($obj->getfun2()=='2024'){echo 'selected';}?>>2024</option><option value="2025"<?php if($obj->getfun2()=='2025'){echo 'selected';}?>>2025</option><option value="2026"<?php if($obj->getfun2()=='2026'){echo 'selected';}?>>2026</option><option value="2027"<?php if($obj->getfun2()=='2027'){echo 'selected';}?>>2027</option></select>

							</div><!-- /.col -->
						<div class="col-sm-12 invoice-col">
						<label for="txtYBDate" >PRICE </label>
                            <address>
                               <input type="text" name="txtTAmt" id="txtTAmt" class="form-control numeric required" placeholder="Amount" autocomplete="off" value="<?= $obj->getfun6()?>" >
                               
                            </address>
                        </div><!-- /.col -->

	</div>

                        
                      
                    
                  
                    
				<div class="box-footer" align="right">
							<button type="submit" class="btn btn-primary btn-flat" onClick="return getValidate(0);">Submit</button>
							<input type="hidden" name="action" value="submit" /><input type="hidden" name="upstatus" id="upstatus" value="" />
				</div>
         
				
					
				</form>
				
				<!--   content ends here..................-->
                </section><!-- /.content -->
            </aside><!-- /.right-side -->
			
        </div><!-- ./wrapper -->
<?php $display->footer(); ?>
<?php $display->js(); ?>
<link href="../../css/jquery.alerts.css" rel="stylesheet" type="text/css" />
<script src='../../js/jquery.autosize.js'></script>

<link href="../../css/datepicker/datepicker.css" rel="stylesheet" type="text/css" />
<script src="../../js/bootstrap-datepicker.js" type="text/javascript"></script>


<script language="JavaScript" type="text/javascript" src="../../js/jquery.alerts.js"></script>
<script src="../../js/timer.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){ 
	changePeriodOnReady('<?php echo $obj->getfun1()?>')
	$('#dateFrom').datepicker({
    format: 'dd-mm-yyyy',
	autoclose: true
});


$('#dateTo').datepicker({
    format: 'dd-mm-yyyy',
	autoclose: true
});




$("#selPort").val('<?php echo $obj->getFun3();?>');
$(".areasize").autosize({append: "\n"});
$("#frm1").validate({
	rules: {
		txtTName:"required",
		selPort:"required"
		},
	messages: {	
		txtTName:"*",
		selPort:"*"
		},
submitHandler: function(form)  {
		jAlert('<b style="font-size:25px;">Please wait . . .</b><br><br><img src="../../img/loading.gif"  />', 'Alert');
		$("#popup_container").css({"background": "rgba(255,255,255,0.1)","border": "10px solid rgba(255,255,255,0.1)","width": "100%"});
		$("#popup_content").css({"background":"none","text-align":"center"});
		$("#popup_ok,#popup_title").hide();  
		form.submit();
	}
});

});




function changePeriodOnReady(val){


	
if(val=='quarter'){



var optionElement = $('<select id="selQuater" name ="selQuater" class="form-control"><option value="0">---Please select a option---</option><option value="1"<?php if($obj->getfun3()=='1'){echo 'selected';}?>>Quarter 1</option><option value="2"<?php if($obj->getfun3()=='2'){echo 'selected';}?>>Quarter 2</option><option value="3"<?php if($obj->getfun3()=='3'){echo 'selected';}?>>Quarter 3</option><option value="4"<?php if($obj->getfun3()=='4'){echo 'selected';}?>>Quarter 4</option></select>');
	$('#txtPeriod').replaceWith(optionElement);


}if(val=='calender'){


var optionElement = $('<input type="text" class="form-control" id="txtPeriod" name="txtPeriod" placeholder="Period" autocomplete="off" style="pointer-events: none;">');
	$('#txtPeriod').replaceWith(optionElement);
	$('#selQuater').replaceWith(optionElement);

$('#txtPeriod').prop('readonly', true);

}if(val=='month'){



var optionElement = $('<input type="text" class="form-control" id="txtPeriod" name="txtPeriod" placeholder="Period" autocomplete="off" value="<?= $obj->getfun5();?>">');

$('#txtPeriod').replaceWith(optionElement);


	$('#selQuater').replaceWith(optionElement);


$('#txtPeriod').prop('readonly', false);



$('#txtPeriod').datepicker({

			   
format: 'mm-yyyy',
autoclose: true,
todayBtn: true,
minuteStep: 1
}).on('changeDate', function(){  

// setCalculationForffa();
});




}






}


function changePeriodStatus(elx){

if($(elx).val()=='quarter'){



	var optionElement = $('<select id="selQuater" name ="selQuater" class="form-control"><option value="0">---Please select a option---</option><option value="1">Quarter 1</option><option value="2">Quarter 2</option><option value="3">Quarter 3</option><option value="4">Quarter 4</option></select>');
		$('#txtPeriod').replaceWith(optionElement);


}if($(elx).val()=='calender'){


	var optionElement = $('<input type="text" class="form-control" id="txtPeriod" name="txtPeriod" placeholder="Period" autocomplete="off" style="pointer-events: none;">');
		$('#txtPeriod').replaceWith(optionElement);
		$('#selQuater').replaceWith(optionElement);

	$('#txtPeriod').prop('readonly', true);

}if($(elx).val()=='month'){


	
	var optionElement = $('<input type="text" class="form-control" id="txtPeriod" name="txtPeriod" placeholder="Period" autocomplete="off">');

	$('#txtPeriod').replaceWith(optionElement);


		$('#selQuater').replaceWith(optionElement);


	$('#txtPeriod').prop('readonly', false);

	$('#txtPeriod').datepicker({

			   
	format: 'mm-yyyy',
	autoclose: true,
	todayBtn: true,
	minuteStep: 1
	}).on('changeDate', function(){  

	// setCalculationForffa();
	});



}


}





</script>
    </body>
</html>