<?php /*----include header file----*/
require_once APPPATH."/views/common/header.php"; ?>
    <div class="boxLwd">
        <h2>Filters</h2>
        
        <div class="row costLine">
		  <form method="post" class="office" action="<?php echo base_url() ?>index.php/office">
            <div class="col-xs-12 col-sm-12 col-md-4 col-lg-4 ui-widget">
                <select name="costcenter" class="combobox costcenteroffice">
                    <option>Select Cost Center</option>
                        <?php
                            if( !empty( $costcenter ) )
                            {
                                foreach( $costcenter as $val ):
                            ?>
                                <option <?php if($val['costcenter_id']==$this->session->userdata('costcenter')){ echo "selected"; } ?> value="<?= $val['costcenter_id']; ?>"><?= ucfirst($val['costcenter_name']); ?></option>
                            <?php
                                endforeach;
                            }
                        ?>
                </select>
            </div>
             <div class="col-xs-12 col-sm-12 col-md-4 col-lg-4 cost2">
                <select name="contractarea" class="combobox contractareaoffice">
                    <option>Select Contract Area</option>
					<?php if($this->session->userdata('contractarea')!="") { ?> 
                     <?php
                            if( !empty( $contract_areas ) )
                            {
                               foreach( $contract_areas as $vals ) 
							   {
								  if($this->session->userdata('contractarea')==$vals['contractarea_id']) {
                            ?>  
                                    <option selected="selected" value="<?= $vals['contractarea_id']; ?>"><?= ucfirst($vals['contractarea_name']); ?></option>
								
                             <?php
							      }
							   }
                            }
                        ?>
					<?php } ?>
                </select>
            </div>
		  </form>
        </div>
        
        <div class="row LwdButtons">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 addNewButton">
                <button class="btn thumbnail" type="submit" data-toggle="modal" data-target="#lightbox">Add New</button>
                <button class="btn btn-default" type="submit">Export</button>
            </div>
         </div>
        
        
        <div class="row tableLWD">
            <table id="example" class="table table-striped table-bordered" width="98%" cellpadding="1" cellspacing="1">
                <thead>
                    <tr>
                        <th>Number</th>
                        <th>Cost Center</th>
                        <th style="display: none;"></th>
                        <th>Contract Area</th>
                        <th>Office</th>
                        <th>No. of LWD's</th>
                        <th>Status</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <?php

                        if( !empty( $detail ) ):
                            for( $i=0; $i<count($detail); $i++ ):
                    ?>
                        <tr>
                            <td><?= $detail[$i]['office_id']; ?></td>
                            <td><?php
                                    for( $m=0; $m<count($detail[$i]['costcenter_detail']); $m++ ){
                                       echo ucfirst( $detail[$i]['costcenter_detail'][$m]['costcenter_name'] );
                                        } 
                                ?>
                            </td>
                            <td style="display: none;"><?= $detail[$i]['create_date']; ?></td>
                            <td>
                                <?php
                                    for($j=0; $j<count($detail[$i]['contractarea_detail']); $j++)
                                    {
                                        echo ucfirst( $detail[$i]['contractarea_detail'][$j]['contractarea_name'] ); 
                                    }
                                ?>
                            </td>
                            <td><?= ucfirst( $detail[$i]['office_name'] ); ?></td>
                            <td>0</td>
                            <td> 
                                <select data-cost_id="<?= $detail[$i]['office_id']; ?>" name="status" class="office_status custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left ui-autocomplete-input">
                                    <option value="0" <?php if( $detail[$i]['status'] == 0 ) { echo 'selected'; } ?> >Pending</option>
                                    <option value="1" <?php if( $detail[$i]['status'] == 1 ) { echo 'selected'; } ?>>Inactive</option>
                                    <option value="2" <?php if( $detail[$i]['status'] == 2 ) { echo 'selected'; } ?>>Active</option>
                                </select>
                            </td>
                            <td><a href="#">Edit</a></td>
                        </tr>
                    <?php
                            endfor;
                        endif;
                    ?>
                </tbody>
            </table>
            
        </div>
   </div>
</div>
</div>


<div id="lightbox" class="modal fade modal3" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <div class="modal-content">
            <div class="modal-body">
            
            <div class="row">
            <div class="col-lg-12">
                <h2>Add Office</h2>
            </div>
            </div>
            <form id="add_office">
            <div class="ajax_msg"></div>
             <div class="row lighboxInner">
            	<div class="col-lg-12">
                <select required name="contractarea" class="costCenterSelect">
                    <option value="">Select Contract Area</option>
                        <?php
                            if( !empty( $contract_costcenter ) )
                            {
                                foreach( $contract_costcenter as $vals ):
                            ?>
                                <option value="<?= $vals['contractarea_id']; ?>"><?= ucfirst($vals['contractarea_name'].' ('.ucfirst($vals['costcenter_name']).')' ); ?></option>
                            <?php
                                endforeach;
                            }
                        ?> 
                </select>
                <a href="#"><img src="/img/addIcon.svg"></a>
                </div>
             </div>
            <div class="row lighboxInner">
            	<div class="col-lg-6">
                    <div class="form-group label-floating">
                            <label class="control-label">Office Name</label>
                            <input type="text" required="" name="office_name[]" class="form-control fullNameField">
                    </div>
                </div>
                <div class="col-lg-6">
                    <div class="form-group label-floating">
                            <label class="control-label">Admin Name</label>
                            <input type="text" required="" name="admin_name[]" class="form-control fullNameField" >
                    </div>
                    
                    <span class="login_name_error"></span>
                </div>
             </div>
             
            <div class="row lighboxInner">
            	<div class="col-lg-6">
                    <div class="form-group label-floating">
                            <label class="control-label">Email Address</label>
                            <input type="email" required="" id="email_address" name="email_address[]" class="form-control fullNameField" onchange="return email_check()">
                    </div>
                    <span class="email_error"></span>
                </div>
                <div class="col-lg-6">
                     <div class="form-group label-floating">
                            <label class="control-label">Contact Number</label>
                            <input type="text" required="" name="contact_number[]" class="form-control fullNameField">
                    </div>
              	</div>
              </div>
                
            <div class="row lighboxInner">
                   <div class="col-lg-6">
                        <div class="form-group label-floating">
                                <label class="control-label">Enter Password</label>
                                <input type="password" required id="password" name="password[]" class="form-control fullNameField">
                        </div>
                	</div>
                     <div class="col-lg-6">
                        <div class="form-group label-floating">
                                <label class="control-label">Confirm Password</label>
                                <input type="password" required id="cpassword" name="cpassword[]" class="form-control fullNameField">
                        </div>
                	</div>
                </div>
 
             

              	<div class="row lighboxInner lightBoxSelect">
	              	<div class="col-xs-12 col-sm-12 col-md-2 col-lg-12">
                       <button class="btn btn-default" type="button" value="Cancel" data-dismiss="modal" aria-hidden="true">Cancel</button>
                       <!-- <input type="submit" value="Save" name="submit" class="btn btn-default"> -->
                       <button class="btn btn-default" type="submit" value="Save"> Save </button>
                    </div>
	            </div>
	            </form>
            </div>
        </div>
    </div>
</div>

<?php require_once APPPATH."/views/common/footer.php"; ?>