<?php include "common/user_log.php"; ?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>NWP Engineering Department</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="dist/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="dist/css/ionicons.min.css">
    <!-- daterange picker -->
    <link rel="stylesheet" href="plugins/daterangepicker/daterangepicker-bs3.css">
    <!-- iCheck for checkboxes and radio inputs -->
    <link rel="stylesheet" href="plugins/iCheck/all.css">
    <!-- Bootstrap Color Picker -->
    <link rel="stylesheet" href="plugins/colorpicker/bootstrap-colorpicker.min.css">
    <!-- Bootstrap time Picker -->
    <link rel="stylesheet" href="plugins/timepicker/bootstrap-timepicker.min.css">
    <!-- Select2 -->
    <link rel="stylesheet" href="plugins/select2/select2.min.css">
	<!-- DataTables -->
    <link rel="stylesheet" href="plugins/datatables/dataTables.bootstrap.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="bootstrap-sweetalert/lib/sweet-alert.css" />
  </head>
  <body class="hold-transition skin-blue sidebar-mini sidebar-collapse">
    <div class="wrapper">

      <header class="main-header">
        <!-- Logo -->
         <a href="home.php" class="logo">
          <!-- mini logo for sidebar mini 50x50 pixels -->
         <span class="logo-mini"><img src="img/logo.png" width="100"></span>
          <!-- logo for regular state and mobile devices -->
        <span class="logo-lg"><b><img src="img/logo.png" width="100"></b></span>
        </a>
        <!-- Header Navbar: style can be found in header.less -->
        <nav class="navbar navbar-static-top" role="navigation">
          <!-- Sidebar toggle button-->
          <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
			 <span class="logo-lg">
             &nbsp;&nbsp;<font face="Lucida Sans Unicode, Lucida Grande, sans-serif">NWP Engineering Department</font></span>
          </a>
		
          <div class="navbar-custom-menu">
            <ul class="nav navbar-nav">

              <!-- User Account: style can be found in dropdown.less -->
              <li class="dropdown user user-menu">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                  <img src="dist/img/user2-160x160.png" class="user-image" alt="User Image">
                  <span class="hidden-xs"><?php echo $name; ?></span>
                </a>
                <ul class="dropdown-menu">
                  <!-- User image -->
                  <li class="user-header">
                    <img src="dist/img/user2-160x160.png" class="img-circle" alt="User Image">
                    <p>
             NWP Engineering Department
                    
                    </p>
                  </li>
                  <!-- Menu Body -->
                 
                  <!-- Menu Footer-->
                  <li class="user-footer">
                    <div class="pull-left">
                      
                    </div>
                    <div class="pull-right">
                      <a href="distroy.php" class="btn btn-default btn-flat">Sign out</a>
                    </div>
                  </li>
                </ul>
              </li>
              <!-- Control Sidebar Toggle Button -->
              <li>
                <a href="#" data-toggle="control-sidebar"><i class="fa fa-gears"></i></a>
              </li>
            </ul>
          </div>
        </nav>
      </header>
      <!-- Left side column. contains the logo and sidebar -->
      <aside class="main-sidebar">
        <!-- sidebar: style can be found in sidebar.less -->
        <section class="sidebar">
          <!-- Sidebar user panel -->
    <?php include "common/sidebar.php"; ?>  
     
        </section>
        <!-- /.sidebar -->
      </aside>

      <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
           Procurement Plan
          </h1>
    <ol class="breadcrumb">
      <li><a href="home.php"><i class="fa fa-home"></i> Home</a></li>
    </ol>
        </section>

        <!-- Main content -->
        <section class="content">

<!-- ************************************************* -->
  <div class="box box-info only_eng"> 
    <div class="box-header with-border"> 
      <h3 class="box-title"> Procurement Plan Details</h3>
    </div>

    <div class="box-body"> 
      <form id="form_projects" action="javascript:void(0);">

      	
		<div class="form-group"> 
      	  <label>Year:<font color="#FF0000"><strong>*</strong></font></label>
      	  <select class="form-control select2" name="year" style="width: 100%;" required>
      	  	<option value="">Select Year...</option>
      	  	<option value="2016">2016</option>
      	  	<option value="2017">2017</option>
      	  	<option value="2018" selected>2018</option>
      	  	<option value="2019">2019</option>
      	  	<option value="2020">2020</option>
      	  </select>
      	</div>

      	<div class="form-group"> 
      	  <label>Project Type:<font color="#FF0000"><strong>*</strong></font></label>
      	  <select class="form-control select2 error" name="pro_type" style="width: 100%;" required>
      		<option value="">Select Project Type...</option>
			<?php 
            $sql="SELECT * FROM project_type ORDER BY id DESC";
            $result=mysqli_query($conn, $sql);

            while ($row = mysqli_fetch_array($result)){

          ?>

            <option value="<?php echo $row['id']; ?>"><?php echo $row['type']; ?></option>

          <?php } ?>
      	  </select>
      	</div>	
		
		
		<div class="form-group"> 
      	  <label>Project:<font color="#FF0000"><strong>*</strong></font></label>
      	  <select class="form-control select2 error" name="project" style="width: 100%;" required>
      	  	<option value="">Select Project...</option>
      		<?php 
            $sql="SELECT * FROM projects_reg ORDER BY id ASC";
            $result=mysqli_query($conn, $sql);

            while ($row = mysqli_fetch_array($result)){

          ?>

            <option value="<?php echo $row['id']; ?>"><?php echo $row['pro_name']; ?></option>

          <?php } ?>
      	  </select>
      	</div>
		
		<div class="form-group"> 
      	  <label>Procurement Method:<font color="#FF0000"><strong>*</strong></font></label>
      	  <select class="form-control select2" name="pro_method" style="width: 100%;" required>
      	  	<option value="">Select Procurement Method...</option>
      	  	<option value="NCB">NCB</option>
      	  </select>
      	</div>
		
		<div class="form-group"> 
      	  <label>Status:<font color="#FF0000"><strong>*</strong></font></label>
      	  <select class="form-control select2" name="pro_st" style="width: 100%;" required>
      	  	<option value="">Select Status...</option>
      	  	<option value="Schedule">Schedule</option>
      	  	<option value="Revised">Revised</option>
      	  	<option value="Actual">Actual</option>
      	  </select>
      	</div>		
		
        <div class="form-group">
          <label>Preparing Bidding Documents:<font color="#FF0000"><strong>*</strong></font></label>            
          <div class="input-group"> 
            <div class="input-group-addon"> <i class="fa fa-calendar"></i> </div>
            <input type="text" class="form-control date_picker" name="bid_prep" autocomplete="off" required>
          </div>
        </div>

        <div class="form-group">
          <label>Approved Bidding Documents:<font color="#FF0000"><strong>*</strong></font></label>            
          <div class="input-group"> 
            <div class="input-group-addon"> <i class="fa fa-calendar"></i> </div>
            <input type="text" class="form-control date_picker" name="bid_app" autocomplete="off" required>
          </div>
        </div>
		
		<div class="form-group">
          <label>Invite Bids:<font color="#FF0000"><strong>*</strong></font></label>            
          <div class="input-group"> 
            <div class="input-group-addon"> <i class="fa fa-calendar"></i> </div>
            <input type="text" class="form-control date_picker" name="bid_invite" autocomplete="off" required>
          </div>
        </div>

        <div class="form-group">
          <label>Bid Received/Opening:<font color="#FF0000"><strong>*</strong></font></label>            
          <div class="input-group"> 
            <div class="input-group-addon"> <i class="fa fa-calendar"></i> </div>
            <input type="text" class="form-control date_picker" name="bid_open" autocomplete="off" required>
          </div>
        </div>
		
		<div class="form-group">
          <label>TEC Evaluation:<font color="#FF0000"><strong>*</strong></font></label>            
          <div class="input-group"> 
            <div class="input-group-addon"> <i class="fa fa-calendar"></i> </div>
            <input type="text" class="form-control date_picker" name="TEC_eval" autocomplete="off" required>
          </div>
        </div>
		
		<div class="form-group">
          <label>PC Approval:<font color="#FF0000"><strong>*</strong></font></label>            
          <div class="input-group"> 
            <div class="input-group-addon"> <i class="fa fa-calendar"></i> </div>
            <input type="text" class="form-control date_picker" name="pc_app" autocomplete="off" required>
          </div>
        </div>
		
		<div class="form-group">
          <label>Issue Letter of Acceptance:<font color="#FF0000"><strong>*</strong></font></label>            
          <div class="input-group"> 
            <div class="input-group-addon"> <i class="fa fa-calendar"></i> </div>
            <input type="text" class="form-control date_picker" name="issue_letter" autocomplete="off" required>
          </div>
        </div>
		
		<div class="form-group">
          <label>Contract Signed:<font color="#FF0000"><strong>*</strong></font></label>            
          <div class="input-group"> 
            <div class="input-group-addon"> <i class="fa fa-calendar"></i> </div>
            <input type="text" class="form-control date_picker" name="con_sign" autocomplete="off" required>
          </div>
        </div>

		<div class="form-group"> 
          <label>Completion Period (Days):</label>
          <input type="text" class="form-control error" name="com_period" autocomplete="off">
        </div>
		
		<div class="form-group"> 
          <label>Contract No/Amount/Name of the Contractor:</label>
          <textarea type="text" class="form-control error" name="con_details" autocomplete="off" rows=3></textarea>
        </div>
		
		<div class="form-group"> 
          <label>Remarks:</label>
          <textarea type="text" class="form-control error" name="remarks" autocomplete="off" rows=3></textarea>
        </div>		

        <span style="color: red;" class="pull-right">* Required Fields</span>

        <div class="box-footer">
          <button class="btn btn-primary">SUBMIT</button>
        </div>
      </form>
    </div>	
  </div>

 <!-- /.table -->
        
    <div class="box box-info"> 
      <div class="box-header"> 
        <h3 class="box-title">Details Edit/Remove</h3>
      </div>
      <!-- /.box-header -->
      <div class="box-body table-responsive"> 
        <table id="example1" class="table table-bordered table-striped">
          <thead>
            <tr>
            	<th>ID</th>
				<th class="only_eng">Edit</th>
				<th class="only_eng">Remove</th>				
            	<th>Year</th>
            	<th>Project Type</th>
              	<th>Project</th>
              	<th>Proc. Method</th>
              	<th>Status</th>
              	<th>Prep. Bidding Doc</th>
              	<th>App. Bidding Doc</th>
              	<th>Invite Bids</th>
              	<th>Bid Received/Opening</th>
              	<th>TEC Evaluation</th>
              	<th>PC Approval</th>
              	<th>Issue Letter of Accept</th>
              	<th>Contract Signed</th>
              	<th>Completion Period (Days)</th>
              	<th>Contract No/Amount/Name of the Contractor</th>
              	<th>Remarks</th>
            </tr>
          </thead>
          <tbody>
            <?php 
              $sql="SELECT
procurement_plan.id,
procurement_plan.`year`,
projects_reg.pro_name,
project_type.`type`,
procurement_plan.pro_method,
procurement_plan.pro_st,
procurement_plan.bid_prep,
procurement_plan.bid_app,
procurement_plan.bid_invite,
procurement_plan.bid_open,
procurement_plan.TEC_eval,
procurement_plan.pc_app,
procurement_plan.issue_letter,
procurement_plan.con_sign,
procurement_plan.com_period,
procurement_plan.con_details,
procurement_plan.remarks
FROM
procurement_plan
Inner Join projects_reg ON procurement_plan.project = projects_reg.id
Inner Join project_type ON project_type.id = procurement_plan.pro_type
";

              $result=mysqli_query($conn, $sql);
              $x = 0;
              while ($row = mysqli_fetch_array($result)){ $x++;
            ?>

            <tr>
              <td><?php echo $x; ?></td>
              <td align="center" class="only_eng">
      			     <button  class="btn btn-info btn-sm btn_up" data-toggle="modal" data-target="#edit_lng" value="<?php echo $row['id']; ?>"><span class="glyphicon glyphicon-pencil"></span> &nbsp;EDIT </button>
      			  </td> 
				  
              <td align="center" class="only_eng">
                  <button value="<?php echo $row['id']; ?>" class="btn btn-danger btn-sm btn_dell">
                <span class="glyphicon glyphicon-trash"></span> &nbsp;DELETE </button>
              </td> 
			  <td><?php echo $row['year']; ?></td>
              <td><?php echo $row['type']; ?></td>
              <td><?php echo $row['pro_name']; ?></td>
              <td><?php echo $row['pro_method']; ?></td>
              <td><?php echo $row['pro_st']; ?></td>
              <td><?php echo $row['bid_prep']; ?></td>
              <td><?php echo $row['bid_app']; ?></td>
              <td><?php echo $row['bid_invite']; ?></td>
              <td><?php echo $row['bid_open']; ?></td>
              <td><?php echo $row['TEC_eval']; ?></td>
              <td><?php echo $row['pc_app']; ?></td>
              <td><?php echo $row['issue_letter']; ?></td>
              <td><?php echo $row['con_sign']; ?></td>
              <td><?php echo $row['com_period']; ?></td>
              <td><?php echo $row['con_details']; ?></td>
              <td><?php echo $row['remarks']; ?></td>

            </tr>
            <?php  } ?>
          </tbody>
        </table>
      </div>
      <!-- /.box-body -->
    </div>
    
  </section>
   
      </div>
	      <!-- /.End table -->
<!-- ************************************************* -->
      
           <!-- /.col -->
              </div><!-- /.row -->
            </div><!-- /.box-body -->
            
          

          <div class="row">
            
    
    
      </div>
      <!-- /.col (right) -->
         

      </div>
<footer class="main-footer"> 
<div class="pull-right hidden-xs">
          
        </div>  <strong>Copyright &copy; NWP Engineering Department</strong> All rights reserved.
      </footer>

      <!-- Control Sidebar -->
      <aside class="control-sidebar control-sidebar-dark">
        <!-- Create the tabs -->
        <ul class="nav nav-tabs nav-justified control-sidebar-tabs">
          <li><a href="#control-sidebar-home-tab" data-toggle="tab"><i class="fa fa-home"></i></a></li>
          <li><a href="#control-sidebar-settings-tab" data-toggle="tab"><i class="fa fa-gears"></i></a></li>
        </ul>
        <!-- Tab panes -->
        <div class="tab-content">
          <!-- Home tab content -->
          <div class="tab-pane" id="control-sidebar-home-tab">
          </div><!-- /.tab-pane -->

          </div><!-- /.tab-pane -->
        </div>
      </aside><!-- /.control-sidebar -->
      <!-- Add the sidebar's background. This div must be placed
           immediately after the control sidebar -->
      <div class="control-sidebar-bg"></div>
    </div><!-- ./wrapper -->

<!-- Modal -->
  <div class="modal fade" id="edit_lng" role="dialog">
    <div class="modal-dialog">
    
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title" id="test_id">Edit Procurement Plan</h4>
        </div>
        <div class="modal-body">

	      	<form id="form_projects_up" action="javascript:void(0);">

				<div class="form-group"> 
				  <label>Year:<font color="#FF0000"><strong>*</strong></font></label>
				  <select class="form-control" name="year" id="year" style="width: 100%;" required>
					<option value="">Select Year...</option>
					<option value="2016">2016</option>
					<option value="2017">2017</option>
					<option value="2018">2018</option>
					<option value="2019">2019</option>
					<option value="2020">2020</option>
				  </select>
				</div>

				<div class="form-group"> 
				  <label>Project Type:<font color="#FF0000"><strong>*</strong></font></label>
				  <select class="form-control error" name="pro_type" id="pro_type" style="width: 100%;" required>
					<option value="">Select Project Type...</option>
					<?php 
					$sql="SELECT * FROM project_type ORDER BY id DESC";
					$result=mysqli_query($conn, $sql);

					while ($row = mysqli_fetch_array($result)){

				  ?>

					<option value="<?php echo $row['id']; ?>"><?php echo $row['type']; ?></option>

				  <?php } ?>
				  </select>
				</div>	
				
				
				<div class="form-group"> 
				  <label>Project:<font color="#FF0000"><strong>*</strong></font></label>
				  <select class="form-control  error" name="project" id="project" style="width: 100%;" disabled>
					<option value="">Select Project...</option>
					<?php 
					$sql="SELECT * FROM projects_reg ORDER BY id ASC";
					$result=mysqli_query($conn, $sql);

					while ($row = mysqli_fetch_array($result)){

				  ?>

					<option value="<?php echo $row['id']; ?>"><?php echo $row['pro_name']; ?></option>

				  <?php } ?>
				  </select>
				</div>
				
				<div class="form-group"> 
				  <label>Procurement Method:<font color="#FF0000"><strong>*</strong></font></label>
				  <select class="form-control " name="pro_method" id="pro_method" style="width: 100%;" required>
					<option value="">Select Procurement Method...</option>
					<option value="NCB">NCB</option>
				  </select>
				</div>
				
				<div class="form-group"> 
				  <label>Status:<font color="#FF0000"><strong>*</strong></font></label>
				  <select class="form-control " name="pro_st" id="pro_st" style="width: 100%;" required>
					<option value="">Select Status...</option>
					<option value="Schedule">Schedule</option>
					<option value="Revised">Revised</option>
					<option value="Actual">Actual</option>
				  </select>
				</div>		
				
				<div class="form-group">
				  <label>Preparing Bidding Documents:<font color="#FF0000"><strong>*</strong></font></label>            
				  <div class="input-group"> 
					<div class="input-group-addon"> <i class="fa fa-calendar"></i> </div>
					<input type="text" class="form-control date_picker" name="bid_prep" id="bid_prep" autocomplete="off" required>
				  </div>
				</div>

				<div class="form-group">
				  <label>Approved Bidding Documents:<font color="#FF0000"><strong>*</strong></font></label>            
				  <div class="input-group"> 
					<div class="input-group-addon"> <i class="fa fa-calendar"></i> </div>
					<input type="text" class="form-control date_picker" name="bid_app" id="bid_app" autocomplete="off" required>
				  </div>
				</div>
				
				<div class="form-group">
				  <label>Invite Bids:<font color="#FF0000"><strong>*</strong></font></label>            
				  <div class="input-group"> 
					<div class="input-group-addon"> <i class="fa fa-calendar"></i> </div>
					<input type="text" class="form-control date_picker" name="bid_invite" id="bid_invite" autocomplete="off" required>
				  </div>
				</div>

				<div class="form-group">
				  <label>Bid Received/Opening:<font color="#FF0000"><strong>*</strong></font></label>            
				  <div class="input-group"> 
					<div class="input-group-addon"> <i class="fa fa-calendar"></i> </div>
					<input type="text" class="form-control date_picker" name="bid_open" id="bid_open" autocomplete="off" required>
				  </div>
				</div>
				
				<div class="form-group">
				  <label>TEC Evaluation:<font color="#FF0000"><strong>*</strong></font></label>            
				  <div class="input-group"> 
					<div class="input-group-addon"> <i class="fa fa-calendar"></i> </div>
					<input type="text" class="form-control date_picker" name="TEC_eval" id="TEC_eval" autocomplete="off" required>
				  </div>
				</div>
				
				<div class="form-group">
				  <label>PC Approval:<font color="#FF0000"><strong>*</strong></font></label>            
				  <div class="input-group"> 
					<div class="input-group-addon"> <i class="fa fa-calendar"></i> </div>
					<input type="text" class="form-control date_picker" name="pc_app" id="pc_app" autocomplete="off" required>
				  </div>
				</div>
				
				<div class="form-group">
				  <label>Issue Letter of Acceptance:<font color="#FF0000"><strong>*</strong></font></label>            
				  <div class="input-group"> 
					<div class="input-group-addon"> <i class="fa fa-calendar"></i> </div>
					<input type="text" class="form-control date_picker" name="issue_letter" id="issue_letter" autocomplete="off" required>
				  </div>
				</div>
				
				<div class="form-group">
				  <label>Contract Signed:<font color="#FF0000"><strong>*</strong></font></label>            
				  <div class="input-group"> 
					<div class="input-group-addon"> <i class="fa fa-calendar"></i> </div>
					<input type="text" class="form-control date_picker" name="con_sign" id="con_sign" autocomplete="off" required>
				  </div>
				</div>

				<div class="form-group"> 
				  <label>Completion Period (Days):</label>
				  <input type="text" class="form-control error" name="com_period" id="com_period" autocomplete="off">
				</div>
				
				<div class="form-group"> 
				  <label>Contract No/Amount/Name of the Contractor:</label>
				  <textarea type="text" class="form-control error" name="con_details" id="con_details" autocomplete="off" rows=3></textarea>
				</div>
				
				<div class="form-group"> 
				  <label>Remarks:</label>
				  <textarea type="text" class="form-control error" name="remarks" id="remarks" autocomplete="off" rows=3></textarea>
				</div>				

		        <span style="color: red;" class="pull-right">* Required Fields</span>

		        <div class="box-footer">
		        	<input type="hidden" id="id_holder" name="id_holder">
		          	<button class="btn btn-danger" name="btn_update">UPDATE</button>
		        </div>
		    </form>

        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
    </div>
  </div>


    <!-- jQuery 2.1.4 -->
    <script src="plugins/jQuery/jQuery-2.1.4.min.js"></script>
    <!-- Bootstrap 3.3.5 -->
    <script src="bootstrap/js/bootstrap.min.js"></script>
    <!-- Select2 -->
    <script src="plugins/select2/select2.full.min.js"></script>
	<!-- DataTables -->
    <script src="plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="plugins/datatables/dataTables.bootstrap.min.js"></script>
    <!-- InputMask -->
    <script src="plugins/input-mask/jquery.inputmask.js"></script>
    <script src="plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
    <script src="plugins/input-mask/jquery.inputmask.extensions.js"></script>
    <!-- date-range-picker -->
    <script src="plugins/daterangepicker/moment.min.js"></script>
    <script src="plugins/daterangepicker/daterangepicker.js"></script>
    <!-- bootstrap color picker -->
    <script src="plugins/colorpicker/bootstrap-colorpicker.min.js"></script>
    <!-- bootstrap time picker -->
    <script src="plugins/timepicker/bootstrap-timepicker.min.js"></script>
    <!-- SlimScroll 1.3.0 -->
    <script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
    <!-- iCheck 1.0.1 -->
    <script src="plugins/iCheck/icheck.min.js"></script>
    <!-- FastClick -->
    <script src="plugins/fastclick/fastclick.min.js"></script>
    <!-- AdminLTE App -->
    <script src="dist/js/app.min.js"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="dist/js/demo.js"></script>
    <script src="bootstrap-sweetalert/lib/sweet-alert.min.js"></script>
	
    <!-- Page script -->
    <script>
      $(function () {
        //Initialize Select2 Elements
        $(".select2").select2();

        //Datemask dd/mm/yyyy
        $("#datemask").inputmask("dd/mm/yyyy", {"placeholder": "yyyy-mm-dd"});
        //Datemask2 mm/dd/yyyy
        $("#datemask2").inputmask("mm/dd/yyyy", {"placeholder": "yyyy-mm-dd"});
        //Money Euro
        $("[data-mask]").inputmask();

        //Date range picker
        $('#reservation').daterangepicker();
        //Date range picker with time picker

       $('.date_picker').daterangepicker({timePicker: false, timePickerIncrement: 30, format: 'YYYY-MM-DD'});

        //Date range as a button
        $('#daterange-btn').daterangepicker(
            {
              ranges: {
                'Today': [moment(), moment()],
                'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                'Last 7 Days': [moment().subtract(6, 'days'), moment()],
                'Last 30 Days': [moment().subtract(29, 'days'), moment()],
                'This Month': [moment().startOf('month')],
                'Last Month': [moment().subtract(1, 'month').startOf('month')]
              },
              startDate: moment().subtract(29, 'days'),
           
            },
        function (start) {
          $('#reportrange span').html(start.format('MMMM D, YYYY'));
        }
        );

        //iCheck for checkbox and radio inputs
        $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
          checkboxClass: 'icheckbox_minimal-blue',
          radioClass: 'iradio_minimal-blue'
        });
        //Red color scheme for iCheck
        $('input[type="checkbox"].minimal-red, input[type="radio"].minimal-red').iCheck({
          checkboxClass: 'icheckbox_minimal-red',
          radioClass: 'iradio_minimal-red'
        });
        //Flat red color scheme for iCheck
        $('input[type="checkbox"].flat-red, input[type="radio"].flat-red').iCheck({
          checkboxClass: 'icheckbox_flat-green',
          radioClass: 'iradio_flat-green'
        });

        
      });
	  
      $(function () {
        $("#example1").DataTable();
        $('#example2').DataTable({
          "paging": true,
          "lengthChange": false,
          "searching": false,
          "ordering": true,
          "info": true,
          "autoWidth": false
        });
      });
	</script>

<script>
/****************************** Insert  *********************************************************/

$("#form_projects").on('submit',(function(e) {

    /*for (instance in CKEDITOR.instances) {
        CKEDITOR.instances[instance].updateElement();
    }*/

    e.preventDefault();
    $.ajax({
    url: "function/procurement_plan_fun.php",
    type: "POST",
    data:  new FormData(this),
    contentType: false,
        cache: false,
    processData:false,
    beforeSend : function()
    {
      //$("#preview").fadeOut();
      //$("#err").fadeOut();
    },
    success: function(data){
      if(data.status=='ok')
      {
        swal({
          title: "Added!",
          text: "Successfully Added!",
          type: "success",
          confirmButtonText: "OK"
            },
            function (isConfirm) {
          if (isConfirm) {
              window.location.href = "procurement_plan.php";
          }
        });
      }
	  else if(data.status=='error2')
      {
        swal("", "Details Already Exist!", "warning");
      }
	  else
      {
        swal("Oops...", "Something went wrong!", "warning");
      }
      
      },
      error: function(e) 
      {
        //$("#err").html(e).fadeIn();
        alert("err2");
      }
   });
  //alert("Done");
}));

/******************************************* Remove Contact **************************************/

$(".btn_dell").click(function(){
  var x = $(this).val();
  swal({
	title: "Are you sure?",
	text: "Your may not be able to recover!",
	type: "warning",
	showCancelButton: true,
	confirmButtonClass: "btn-danger",
	confirmButtonText: "Yes, delete it!",
	closeOnConfirm: false
  },
	function () {
	  del_func(x);
	}
  );
});

function del_func(reg_id){
	if(reg_id === '') {

		swal("Warning!", "Please Select Valid Record!", "warning");
	
	} else {
		
		$.post( "function/procurement_plan_fun.php", {remove_reg: "data", reg_id : reg_id}, function( data ) {
		    if (data.status == 'ok') {
			  swal({
				title: "Deleted!",
				text: "Successfully Deleted!",
				type: "success",
				confirmButtonText: "OK"
			  },
				  function (isConfirm) {
				if (isConfirm) {
					window.location.href = "procurement_plan.php";
				}
			  });
			}else if(data.status == 'error2') {
			  swal("", "Data Already Exist!", "warning");
			
			} else{
			  swal("Oops...", "Something went wrong!", "warning");
			}
		}, "json");
	}
}

/******************************************* Load Form Data **************************************/

$(".btn_up").click(function(){	
	load_form_data($(this).val());
	$("#id_holder").val($(this).val());
});

function load_form_data(reg_id){
	$.post( "function/procurement_plan_fun.php", { get_dataset: "data", reg_id : reg_id }, function( data ) {
		$.each(data, function (index, data) {

      $('#year').val(data.year);
      $('#pro_type').val(data.pro_type);
      $('#project').val(data.project);
      $('#pro_method').val(data.pro_method);
      $('#pro_st').val(data.pro_st);
      $('#bid_prep').val(data.bid_prep);
      $('#bid_invite').val(data.bid_invite);
      $('#bid_app').val(data.bid_app);
      $('#bid_open').val(data.bid_open);
      $('#TEC_eval').val(data.TEC_eval);
      $('#pc_app').val(data.pc_app);
      $('#issue_letter').val(data.issue_letter);
	  $('#con_sign').val(data.con_sign);
	  $('#com_period').val(data.com_period);
	  $('#con_details').val(data.con_details);
	  $('#remarks').val(data.remarks);
			
		});

	}, "json");
}

/****************************** update  *********************************************************/

$("#form_projects_up").on('submit',(function(e) {

    /*for (instance in CKEDITOR.instances) {
        CKEDITOR.instances[instance].updateElement();
    }*/

    e.preventDefault();
    $.ajax({
    url: "function/procurement_plan_fun.php",
    type: "POST",
    data:  new FormData(this),
    contentType: false,
        cache: false,
    processData:false,
    beforeSend : function()
    {
      //$("#preview").fadeOut();
      //$("#err").fadeOut();
    },
    success: function(data){
      if(data.status=='ok')
      {
        swal({
          title: "Updated!",
          text: "Successfully Updated!",
          type: "success",
          confirmButtonText: "OK"
            },
            function (isConfirm) {
          if (isConfirm) {
              window.location.href = "procurement_plan.php";
          }
        });
      }
	  else if(data.status=='error2')
      {
        swal("", "Details Already Exist!", "warning");
      }
	  else
      {
        swal("Oops...", "Something went wrong!", "warning");
      }
      
      },
      error: function(e) 
      {
        //$("#err").html(e).fadeIn();
        alert("err2");
      }
   });
  //alert("Done");
}));

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