<?php
session_start();
$companyname=$_SESSION['companyname'];
$adminemailid=$_SESSION['emailid'];
$companytype=$_SESSION['companytype'];
if(($adminemailid !="")&&($companyname!="")){
include('../Control/pipeline.php');
$myobj=new pipelinectrl();
if(isset($_POST['filtebyemp'])){
    $adminemailid=$_POST['filtebyemp'];
    $idtable="example_1";
    $result=$myobj->salespipelinedeal($companyname, $adminemailid);
}elseif($companytype=="admin"){
    $idtable="example_2";
    $result=$myobj->salespipelinedeal($companyname, "");
}else{
    $idtable="example_3";
    $result=$myobj->salespipelinedeal($companyname, $adminemailid);
}
?>

  

<script>
var tableid="<?php echo $idtable;?>";
$(document).ready(function() {
    var table = $('#'+tableid).DataTable( {
//"aLengthMenu": [[10, 20, 40, 80, 160, -1] , ["10/page", "20/page", "40/page", "80/page", "160/page" , "All"]],
"dom": "<'row'<'col-md-2'l><'col-md-7'B><'col-md-3'f>><'row'<'col-md-12't>><'row'<'col-md-6'i><'col-md-6'p>>",/*<'row'<'col-md-12't>><'row'<'col-md-12'i>>*/
"processing": true,
       "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
"order": [[ 4, 'desc' ]],
        buttons: [ 'copy', 'excel','csv', 'pdf','print', 'colvis' ]
       
    } );
        
 
    table.buttons().container()
        .appendTo( '#'+tableid+'_wrapper .col-sm-6:eq(0)' );
        
} );

</script>
<style>
#example_1 {
    font-family: "Calibri ",Helvetica,Arial,sans-serif;
    font-size: 10px;
    line-height: 1.42857143;
    color: #333;
    background-color: #fff;
}
#example_2 {
    font-family: "Calibri ",Helvetica,Arial,sans-serif;
    font-size: 10px;
    line-height: 1.42857143;
    color: #333;
    background-color: #fff;
}
#example_3 {
    font-family: "Calibri ",Helvetica,Arial,sans-serif;
    font-size: 10px;
    line-height: 1.42857143;
    color: #333;
    background-color: #fff;
}

</style>

<style>

@media 
only screen and (max-width: 760px),
(min-device-width: 768px) and (max-device-width: 1024px)  {

	/* Force table to not be like tables anymore */
	table, thead, tbody, th, td, tr { 
		display: block; 
	}
	
	/* Hide table headers (but not display: none;, for accessibility) */
	thead tr { 
		position: absolute;
		top: -9999px;
		left: -9999px;
	}
	
	tr { border: 1px solid #ccc; }
	
	
	
	td { 
		/* Behave  like a "row" */
		border: none;
		border-bottom: 1px solid #eee; 
		position: relative;
		padding-left: 50%; 
	}
	
	td:before { 
		
	}
	
	/*
	Label the data
	*/
	td:nth-of-type(1):before { content: "Deal Name: ";}
	td:nth-of-type(2):before { content: "Contact: "; }
	td:nth-of-type(3):before { content: "Owner: "; }
	td:nth-of-type(4):before { content: "Amount: "; }
	td:nth-of-type(5):before { content: "Created: "; }
    td:nth-of-type(6):before {  content: "Close Date: "; }
    td:nth-of-type(7):before {  content: "Stage: "; }


}
</style>

  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

    

<script>
$(function(){
    $('.datepicker').datepicker({
           dateFormat: 'yy-mm-dd',
          changeMonth: true,
  maxDate: 'today',
  numberOfMonths: 1,
          showButtonPanel: true,
        closeText: 'Clear',
        onClose: function (dateText, obj) {
            if ($(window.event.srcElement).hasClass('ui-datepicker-close'))
                $(".datepicker").val('');
        }
}); 
$('.datepicker1').datepicker({
           dateFormat: 'yy-mm-dd',
          changeMonth: true,
  maxDate: 'today',
  numberOfMonths: 1,
          showButtonPanel: true,
        closeText: 'Clear',
        onClose: function (dateText, obj) {
            if ($(window.event.srcElement).hasClass('ui-datepicker-close'))
                $(".datepicker1").val('');
        }
});
});

 
 </script>


<style>
table, td {
    border: 1px solid #87CEFA;
}
    th {
  font-size: 14px;
  color: white !important;
  background-color:#008080;
}
a.buttons-print {
        color: #008080;
        background:white;
    }
a.buttons-colvis {
        color: #008080;
        background:white;
    }
a.buttons-csv {
        color: #008080;
        background:white;
    }
a.buttons-pdf {
        color: #008080;
        background:white;
    }
a.buttons-excel {
        color: #008080;
        background:white;
    }
a.buttons-copy {
        color: #008080;
        background:white;
    }
a.buttons-print:hover {
        color:white;
        background: #008080;
    }
a.buttons-colvis:hover {
        color:white;
        background: #008080;
    }
a.buttons-csv:hover {
        color:white;
        background: #008080;
    }
a.buttons-pdf:hover {
        color:white;
        background: #008080;
    }
a.buttons-excel:hover {
        color:white;
        background: #008080;
    }
a.buttons-copy:hover {
        color:white;
        background: #008080;
    }
    #tblSearchCust_filter input {
  background-color: red;
}
</style>
							
							
<style>						
.home {
  position: relative;
}

.home p {
  display: inline-block;
  background: white;
  color: #000;
  padding: 0.4em 0.6em;
  font-size: 1.3em;
  
}

.home figure {
  width: 250px;
  display: none;
  position: absolute;
z-index:1;
  
  left: -5em;
  padding: 0;
  margin: 0;
/*  border: 1px solid grey;*/
  background: #fff;
  
}

.home img {
  display: block;
  max-width: 100%;
  height: auto;
}

.home:focus figure,
.home:hover figure {
  display: block;
}
.home:focus p,
.home:hover p {
  background: white;
  font-size: 14px;
}
</style>



        
        <table id="<?php echo $idtable;?>" class="table table-striped table-bordered dt-responsive nowrap " cellspacing="0" width="100%" style="font-family: 'Calibri',Helvetica,Arial,sans-serif;
            font-size: 12px;">
        				<thead >
        					<tr><b>
        						<th style="align: center;"><center>Deal Name</center></th>
        						<th style="align: center;"><center>Contact</center></th>
        						<th style="align: center;"><center>Owner</center></th>
        						<th style="align: center;"><center>Amount</center></th>
        						
        						<th style="align: center;"><center>Created</center></th>
        						<th style="align: center;"><center>Close Date</center></th>
        					    <th style="align: center;"><center>Stage</center></th>
         					</b></tr>
        				</thead>
        <tbody>
        	
    <?php foreach($result as $row3){
            $contact="<b>".$row3['org_name']."</b>.".$row3['firstname']." ".$row3['lastname'];
    ?>
    
        					<tr> 
        						<td><?php echo $row3['d_deal_name'];?></td>
    							<td><?php echo $contact;?></td>
        						<td><?php echo $row3['owner_name']?></td>
        						<td><?php echo $row3['d_amount']?></td>
        					    <td><?php echo $row3['d_date']?></td>
    					    	<td><?php echo $row3['d_closedate']?></td>
    							<td><?php echo $row3['d_stage_per']?></td>
   
        					</tr>
      <?php } ?>
        				</tbody>
        			</table>
<?php
}else{
echo "<script> location.replace('http://fieldcloud.in/Login.php') </script>";
}?>
        