<?php
require_once($application_path . "view/header.tpl.php");
?>
<style>
	table {
		border: solid 2px #639;
		padding:10px;
	}
	thead {
		font-size:14px;
		color:#FFF;
		font-weight:bold;
		text-align:left;
		background-color: #639;
	}
	
	thead td {
		height:40px;
		padding: 10px;
	}

	tr td {
		height:20px;
		padding: 4px;
	}
	
	.trcls:hover { 
		background-color: #CCC;
	}	

</style>

        <!-- page content -->
        <div class="right_col" role="main">
		  
          <!-- Body First Row Items -->
          <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">
				<h2>Manage Survey</h2>
                <br />
                <form name="data_form" action="survey" method="post">
                <button type="button" class="btn btn-primary" onclick="NewSurvey()">Add New</button>
                <button type="submit" class="btn btn-danger">Delete Selected</button>
                <table style="width:100%" class="responsive">
					<thead>
						<td width="2%"></td>
                        <td width="2%"></td>
                        <td width="36%">Survey Description</td>
                        <td width="10%">Survey Type</td>
                        <td width="10%">Survey Market</td>
                        <td width="10%" align="center">Starting Date</td>
                        <td width="10%" align="center">Ending Date</td>
                        <td width="10%" align="right">Population</td>
                        <td width="10%" align="right">Sample Size</td>
                    
                    </thead>
                    
                    <?php
					foreach($survey_list as $slist) {
						$srv_detail = $SEAS_Survey_Model->get_survey_details($slist['srv_id']);
					?>
                        <tr class="trcls">
                            <td><input type="checkbox" name="chk_<?php echo $slist['srv_id']; ?>"  /></td>
                            <td><a href="#" onclick="delete_survey(<?php echo $slist['srv_id']; ?>)"><img src="view/images/trash.png"  /></a></td>
                            <td><a href="#" onclick="EditSurvey(<?php echo $slist['srv_id']; ?>)"><?php echo $slist['srv_desc']; ?></a></td>
                            <td><?php echo $srv_detail['type_desc']; ?></td>
                            <td><?php echo $srv_detail['market']; ?></td>
                            <td align="center"><?php echo $srv_detail['starting_date']; ?></td>
                            <td align="center"><?php echo $srv_detail['ending_date']; ?></td>
	                        <td align="right"><?php echo $srv_detail['population']; ?></td>
                            <td align="right"><?php echo $srv_detail['sample']; ?></td>
                        </tr>
                    <?php
					}
					?>
				</table>
                </form>
            </div>
          </div>
          <!-- End Body First Row Items -->          
          
          <br />

		  

        
        </div>
        <!-- /page content -->

<?php
require_once($application_path . "view/footer.tpl.php");
?>

<script>
	function delete_survey(p_survey_id) {
		if(confirm("Do you want to delete this survey?")) {
			window.location.href="survey?del_id=" + p_survey_id;
		}
	}

	function NewSurvey() {
		var w = 500;
		var h = 400;
		var left = (window.screen.width / 2) - ((w / 2) + 10);
		var top = (window.screen.height / 2) - ((h / 2) + 50);
		
		myWindow = window.open('newsurvey?new=1', 'tinyWindow','toolbar=false,width='+w+',height='+h+',left='+left+',top='+top+',resizable=yes,scrollbars=yes');	
			
	}
	
	

	function EditSurvey(sid) {
		var w = 500;
		var h = 400;
		var left = (window.screen.width / 2) - ((w / 2) + 10);
		var top = (window.screen.height / 2) - ((h / 2) + 50);
		
		myWindow = window.open('newsurvey?edit='+sid, 'tinyWindow','toolbar=false,width='+w+',height='+h+',left='+left+',top='+top+',resizable=yes,scrollbars=yes');	
			
	}	
</script>
