<div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h3 class="page-header">Tender List</h3>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                       <!--    <a href="<?php echo site_url();?>admin/Company/user_add" class="btn btn-info"> Add User</a>-->
                    <div class="panel panel-default">
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <?php $success_message = $this->session->flashdata('success_message');
                            if (!empty($success_message)) {?>
                                <div class="alert alert-success">
                                      <a class="close" data-dismiss="alert" href="components-popups.html#" aria-hidden="true">×</a>
                                      <strong><?php echo $this->session->flashdata('success_message');  ?></strong>
                                </div> 
                            <?php }  ?>
                            <?php $failure_message = $this->session->flashdata('failure_message');
                            if (!empty($failure_message)) {?>
                                <div class="alert alert-warning">
                                      <a class="close" data-dismiss="alert" href="components-popups.html#" aria-hidden="true">×</a>
                                      <strong><?php echo $this->session->flashdata('failure_message');  ?></strong>
                                </div> 
                            <?php }  ?>
							

			<style>
			body {    font-size: 9px;
  
   
}
			</style>
           <div style="overflow-x:auto;">
              
     <table id="example1" style="width:800px" class="table table-striped table-bordered responsive">
        <thead>
            <tr>
				<th width="10">Tender No.</th>
				<th  width="30">Tender Date</th>				
				<th  width="30">Tender Due Date</th>
				<th  width="30">Tender Amount</th>	
				<th  width="60">Ask Price</th>				
				<th  width="30">Status</th>	
				<th  width="10">Lost by Price</th>	
				<th  width="10">Brand win</th>	
				<th  width="10"></th>
				<th  width="10">View</th>  
				<th  width="10">Edit</th>  
				<th  width="10">Tender Download</th>  
				<th  width="10">CreatedAt</th>                

            </tr>
        </thead>
        <tbody>
			  
<?php 

foreach($tender_info as $r)
{
    $tender_id=$r['tender_id'];
	$product=$r['product'];
	$sql = "SELECT sum(amount) as amount FROM quotation where tender_id='$tender_id'";
    $record = $this->db->query($sql);
	$amount=$record->row('amount');
	
	$sql1 = "SELECT tax FROM product where IsActive=0 and id='$product'";
        $record1 = $this->db->query($sql1);
  //      $product=$record->row('product');
        $tax=$record1->row('tax');
		$tamount=(($amount*$tax)/100);
		$tamount1=$tamount+$amount;	
		
		
			$tender_date11=$r['tender_date'];
		$tender_date12=date("d-m-Y", strtotime($tender_date11));
								
		$tender_date1=$r['tender_due_date'];
		$tender_due_date=date("d-m-Y", strtotime($tender_date1));
?>							
					<tr class="gradeX">
					<td><?php echo $r['tender_no']?></td>
					<td><?php echo $tender_date12?></td>
					<td><?php echo $tender_due_date?></td>
					<td><?php echo $tamount1?></td>
				<td>
					<?php
					if($r['ask_price']!='')
					{
					
						if($_GET['tender_id']==$r['tender_id'])
						{
							?>
							<form action="<?php echo site_url();?>admin/Quotation/save_ask_price" method="post">
							<input type="text" name="ask_price" value="<?=$r['ask_price']?>"  size='5'>
							<input type="hidden" name="tender_id" value="<?=$tender_id?>">
							<input type='submit' value='save'>
							</form>
							<?php
						}
						else
						{
							?>
							<?=$r['ask_price']?>
							
					<a href="<?php echo site_url();?>admin/Quotation/tender_list?edit=yes&tender_id=<?php echo $r['tender_id']?>"><i class="fa fa-pencil fa-lg"></i></a>
					<?php
						}
					}
					else
					{
						?>
						
						<form action="<?php echo site_url();?>admin/Quotation/save_ask_price" method="post">
						<input type="text" name="ask_price" class="" size='5'>
						<input type="hidden" name="tender_id" value="<?=$tender_id?>">
						<input type='submit' value='save'>
						</form>
						<?php
					}
					?>
					</td>
									<td>
					<?php
					if($r['status']!='')
					{
						?>
						<?=$r['status']?>
				<?php	
				}
				else
				{
				?>
					
					<a href="#" id="myBtn" data-toggle="modal" data-id='<?php echo $r['tender_id'];?>' data-target="#myModal" class="myModalClass action tocompare" title="Enquiry">Add
				</a>
				<?php
				}
				?>
				</td>
					<td><?=$r['loss_price']?></td>
					<td>
					<?php
					$bid=$r['brand'];
					$sql1 = "SELECT * FROM competitor where id='$bid'";
					$record1 = $this->db->query($sql1);
					$a2=$record1->result_array();
					?>
					<?=$a2[0]['brand']?></td>

                    <td>
					<?php 
					if($r['cstatus']=='Incomplete')
					{
						echo '<font color="red">'.$r['cstatus'].'</font>';
					}
					else
					{
						echo '<font color="green">'.$r['cstatus'].'</font>';
					}
					
					?>
					</td>
					<td><a href="<?php echo site_url();?>admin/Quotation/view_tender/<?php echo $r['tender_id']?>" title="View Tender" class="btn btn-primary btn-circle" target="_blank"><i class="fa fa-eye" aria-hidden="true"></i></td>

					<td><a href="<?php echo site_url();?>admin/Quotation/edit_tender/<?php echo $r['tender_id']?>" title="View Tender" class="btn btn-info btn-circle"><i class="fa fa-pencil" aria-hidden="true"></i></td>
						<td>
						    <?php
						    if($r['path']!='')
						    {
						        ?>
						        
						    <a href="<?php echo $r['path']?>" download>Download</a>
						    <?php
						    }
						    ?>
						    </td>
						<td><?php echo $r['createdAt']?></td>
					</tr>
<?php
}

?>			
             
        </tbody>
    </table>
	</div>
	
	    <link href="<?php echo site_url();?>assets/css/jquery.dataTables.min.css" rel="stylesheet">
	    <link href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css" rel="stylesheet">
    
	<script src="//code.jquery.com/jquery-1.12.4.js"></script> 
	<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script> 
	<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script> 
	<script src="//cdn.datatables.net/buttons/1.4.2/js/buttons.flash.min.js"></script> 
	<script src="//cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script> 
	<script src="//cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script> 
	<script src="//cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script> 
	<script src="//cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script> 
	<script src="//cdn.datatables.net/buttons/1.4.2/js/buttons.print.min.js"></script> 

	
	<script>
$(document).ready(function() {
    $('#example1').DataTable( {
        dom: 'Bfrtip',
        "pageLength": 50,
        buttons: [
             'csv', 'excel'
        ],
          "order": [[ 1, "desc" ]],
       
    } );
} );			
	</script>
                            
                          
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->            
        </div>
        <!-- /#page-wrapper -->

<!-- DataTables JavaScript -->
   <script type="text/javascript">
$(document).ready(function() {
    $('#example').DataTable( {
        dom: 'T<"clear">lfrtip',
        tableTools: {
            "sSwfPath": "../js/datatables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf"
        }
    } );
} );

</script>
<script>
function doconfirm()
{
    job=confirm("Are you sure to delete permanently?");
    if(job!=true)
    {
        return false;
    }
}
</script>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                 <h2 class="modal-title" id="myModalLabel">Product Enquiry </h2>
            </div>
            <div class="modal-body">
			<form action="<?php echo site_url();?>admin/Quotation/save_status" method="post">
				<input type="hidden" class="form-control" id="myValue" name="tender_id" value="<?=$tender_id?>" placeholder="product" required>
				<div class="row">
				<div class="col-md-12">
				<div class="col-md-2">
				Status :
				</div>
				<div class="col-md-4">
				<select name="status" class="form-control" id='purpose' required>
					<option value="">select</option>
					<option value="Won">Won</option>
					<option value="Loss">Loss</option>
				</select>
				</div>
				
				</div>
				</div>
				<br /><br />
	<div class="row">
	 <div class="col-md-12">
				
			<div style='display:none;' id='business'>
			<div class="col-md-2">	
			 Lost by Price
			</div>
			<div class="col-md-3">	
				<input type='text' class='form-control' name='loss_price'/>
			</div>	
<br /><br /><br /><br />
			<div class="col-md-2">	
			 Brand win
			</div>
			<div class="col-md-4">	
			<?php
			$sql = "SELECT * FROM competitor where IsActive=0";
			$record = $this->db->query($sql);
			$a=$record->result_array();
			?>
				<select name="brand" class="form-control">
				<option value="">select</option>
				<?php
				foreach($a as $a1)
				{
					?>
					<option value="<?=$a1['id']?>"><?=$a1['brand']?></option>
					<?php
				}
				?>
				</select>
			</div>
			</div>
<script>
$('#purpose').on('change', function () {
    $("#business").css('display', (this.value == 'Loss') ? 'block' : 'none');
});
</script>

			</div>
			</div>
			</div>
            <div class="modal-footer">
                <input type="submit" class="btn btn-primary" name="submit" value="Submit">
            </div>
			</form>
        </div>
    </div>							
</div>
 <script>
 $(document).on("click", ".myModalClass", function () {
     var myValue = $(this).data('id');
     $(".modal-body #myValue").val( myValue ); // myValue has the value 'myModal1'
});
 </script>
<script>
$(document).ready(function () {
      
    $("#myBtn").click(function(){
         $('#myModal').modal('show');
    });
});
</script>