<script type="text/javascript">
    $(document).ready(function(){
<!-- page script -->
        $('.datatables').DataTable();
        $('.datetimepicker').datetimepicker({
            viewMode: 'months',
            format: 'DD-MM-YYYY'
        });

    });
    
	function confirmvote(){
		
		
		$.ajax({
			type: "POST",
			url: "<?php echo base_url(); ?>voting/confirmvote/<?php echo $projectID; ?>",
			data: {},
			dataType:'json',
			success: function(data){
				if(data.status == 'success'){
											
					var urls = "<?php echo base_url() ?>v/p/<?php echo $projectID; ?>";
					window.location = urls;
		
				}
			}
		});
		
	}
	
	function cancelvote(){
		
		
		$.ajax({
			type: "POST",
			url: "<?php echo base_url(); ?>voting/cancelvote/<?php echo $projectID; ?>",
			data: {},
			dataType:'json',
			success: function(data){
				if(data.status == 'success'){
											
					var urls = "<?php echo base_url() ?>voting/confirmvoter/<?php echo $this->session->userdata('voterNoAhli'); ?>/<?php echo $projectID; ?>";
					window.location = urls;
		
				}
			}
		});
		
	}
	
	
</script>
<style>
 
 	.modal-content{
    	border-top-left-radius: 2em;
		border-top-right-radius: 2em;
		border-bottom-left-radius: 2em;
		border-bottom-right-radius: 2em;
	}
	.modal-header{
		color:#F0F;
	}
	
	
	
</style>


                <div id="popup_modal" class="modal fade in">
                  <div class="modal-dialog">
                    <div class="modal-content">
                      <div class="modal-header">
                        <h3 class="modal-title"><?php echo $this->lang->line('message') ?></h3>
                      </div>
                      <div class="modal-body" id="message">
                      	<p style="font-size:16px; font-family:roboto"></p>
                      </div>
                      <div class="modal-footer">
                        <button type="button" class="btn btn-warning" data-dismiss="modal"><i class="fa fa-minus-circle"></i> <?php echo $this->lang->line('close') ?></button>
                      </div>
                      
                    </div><!-- /.modal-content -->
                  </div><!-- /.modal-dialog -->
                </div><!-- end addRowModal -->


<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <!--<section class="content-header">
        <h1 style="font-family:roboto">
            <b>&nbsp;</b>
        </h1>
    </section>-->

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


        <div class="row">
            <div class="col-md-12">
                <!-- Horizontal Form -->

                <!-- general form elements disabled -->
                <div class="box box-info">
                    <div class="box-header with-border " style=" background-color:#00F">
                        <h3  class="box-title">
                            <h4 class="pull-left" style="font-family:roboto; color:#FFF"><b><?php echo $this->lang->line('votesummary');?></b></h4>
                        </h3>
                    </div><!-- /.box-header -->
                    
                    
                    <div class="box-body"><br />
                    	<div class="row">
                        	<div class="col-md-12">
                            	<p style="font-size:18px; color:#999"><b><?php echo $this->lang->line('memberNo');?> : <?php echo $votesummarylist[0]->noAhli; ?></b></p> 
                            </div>
          				</div>
										<div class="row">
											<div class="col-md-12">
												<p style="font-size:18px; color:#999"><b><?php echo $this->lang->line('entityName');?> : <?php echo $votesummarylist[0]->name; ?></b></p> 
											</div>
										</div>
                        <div class="row">
                        	<div class="col-md-12">
                            	<p style="font-size:18px; color:#999"><b><?php echo $this->lang->line('companyName');?> : <?php echo $votesummarylist[0]->companyName; ?></b></p> 
                            </div>
          				</div><br />
                        
                        <div class="row">
                        	<div class="col-md-12">
                            	<div class="box-box-info">
                                    <!-- /.box-header -->
                                    <div class="box-body">
                                      <table class="table table-bordered table-striped datatables">
                                        <tr style="background-color:#FC0">
                                          <td style="width: 10px"><b>No</b></td>
                                          <td align="center"><b><?php echo $this->lang->line('designation'); ?></b></td>
                                          <td><b><?php echo $this->lang->line('candidate'); ?></b></td>
                                        </tr>
                                        <?php
											$i=1;
											$count = 1;
											$positionID = 0;
											
											foreach($votesummarylist as $row){
												
												if($i == 1){
													echo"<tr>";
													echo"<td>".$i."</td>";
													if($row->elected > 1){	
														echo"<td align='center'>".$row->positionName." ".$count."</td>";
														$count++;
													}
													else{
														echo"<td align='center'>".$row->positionName."</td>";
													}
													echo"<td>".$row->candidateName."</td>";
													echo"</tr>";
													
													$positionID = $row->positionID;
												}
												else{
													echo"<tr>";
													echo"<td>".$i."</td>";
													if($row->elected > 1){
														if($positionID == $row->positionID){
															echo"<td align='center'>".$row->positionName." ".$count."</td>";
															$count++;
														}
														else{
															$count = 1;
															echo"<td align='center'>".$row->positionName." ".$count."</td>";
															$count++;
															$positionID = $row->positionID;
														}
													}
													else{
														echo"<td align='center'>".$row->positionName."</td>";
													}
													echo"<td>".$row->candidateName."</td>";
													echo"</tr>";
												}
												
												$i++;
											}
										
										?>
                                      </table>
                                    </div>
                                    <!-- /.box-body -->
                                  </div>
                                  <!-- /.box -->
                            </div>
                        </div><br />
                        
                        <button type="button" onclick="confirmvote()" class="btn bg-purple btn-lg fad" title="Start"><?php echo $this->lang->line('confirm');?> <i class="fa fa-mail-forward"></i></button><br /><br />
                        <button type="button" onclick="cancelvote()" class="btn btn-danger btn-lg fad" title="Start"><i class="fa fa-reply"></i> <?php echo $this->lang->line('cancelvote');?></button>
                    </div><!-- /.box-body -->
                    
                    
                </div><!-- /.box -->
                
                
            </div>
        </div>


    </section><!-- /.content -->
</div><!-- /.content-wrapper -->
