<?php /*----include header file----*/
require_once APPPATH."/views/common/header.php"; ?>
    <div class="boxLwd">
        <h2><span>Office</span>  <?php if($this->session->userdata('contractarea')!=""){?> <span style="display:inline-block;"><a href="<?= base_url() ?>index.php/office">
                    <button class="btn thumbnail" type="submit">View all list<div class="ripple-container"></div></button>
                </a></span> <?php } ?></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['lindex']==$this->session->userdata('costcenter')){ echo "selected"; } ?> value="<?= $val['lindex']; ?>"><?= ucfirst($val['description']); ?></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['lindex']) {
                            ?>  
                                    <option selected="selected" value="<?= $vals['lindex']; ?>"><?= ucfirst($vals['description']); ?></option>
								
                             <?php
							      }
							   }
                            }
                        ?>
					<?php } ?>
                </select>
				<span style="padding-left:30px; display:none; font-size:22px;"  class="loading" ><i class="fa fa-spinner" aria-hidden="true"></i></span>
				 
            </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="100%" 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]['lindex']; ?></td>
                            <td><?php
                                    for( $m=0; $m<count($detail[$i]['costcenter_detail']); $m++ ){
                                       echo ucfirst( $detail[$i]['costcenter_detail'][$m]['description'] );
                                        } 
                                ?>
                            </td>
                            <td style="display: none;"><?= $detail[$i]['create_date']; ?></td>
                            <td><span ></span>
                                <?php
                                    for($j=0; $j<count($detail[$i]['contractarea_detail']); $j++)
                                    {
                                        echo ucfirst( $detail[$i]['contractarea_detail'][$j]['description'] ); 
                                    }
                                ?>
                            </td>
                            <td><?= ucfirst( $detail[$i]['description'] ); ?></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="javascript:void(0)" data-id="<?= $detail[$i]['lindex']; ?>" class="edit_office_model">Edit</a></td>
                        </tr>
                    <?php
                            endfor;
                        endif;
                    ?>
                </tbody>
            </table>
            
        </div>
   </div>
</div>
</div>


<div id="lightbox" class="modal fade modal3 popupOrbis" 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 row1Popup">
             <div class="col-xs-12">
                <select name="costcenter" class="" id="costcenter_dropdown" >
                    <option>Select Cost Center</option>
                        <?php
                            if( !empty( $costcenter ) )
                            {
                                foreach( $costcenter as $val ):
                            ?>
                                <option <?php if($val['lindex']==$this->session->userdata('costcenter')){ echo "selected"; } ?> value="<?= $val['lindex']; ?>"><?= ucfirst($val['description']); ?></option>
                            <?php
                                endforeach;
                            }
                        ?>
                </select>
            </div>
            </div>
             <div class="row lighboxInner row1Popup">
            	<div class="col-lg-12">
                <select required name="contractarea" disabled="" class="" id="constractArea">
                    <option value="">Select Contract Area</option>
                        <?php
                            if( !empty( $contract_costcenter ) )
                            {
                                foreach( $contract_costcenter as $vals ):
                            ?>
                                <option value="<?= $vals['lindex']; ?>"><?= ucfirst($vals['description'].' ('.ucfirst($vals['description']).')' ); ?></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" id="submit_form" type="submit" value="Save"> Save </button>
                    </div>
	            </div>
	            </form>
            </div>
        </div>
    </div>
</div>

<div id="edit_popup" class="modal edit_office fade modal3 popupOrbis" 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>Edit Office</h2>
            </div>
            </div>
            <form id="edit_offce">
            <div class="ajax_msg"></div>
             <div class="row lighboxInner">
             <div class="col-xs-12">
             <div class="form-group label-floating is-focused">
             <label class="control-label">Cost Centre</label>
                <input type="text" readonly name="office_name" id="edit_costcentre" class="form-control fullNameField">
                <input type="hidden" name="officeID" id="officeID">
            </div>
            </div>
                <div class="col-lg-12">
                <div class="form-group label-floating is-focused">
                <label class="control-label">Contract Area</label>
                    <input type="text" readonly name="office_name" id="edit_contractarea" class="form-control fullNameField">
                </div>
             </div>
             </div>
            <div class="row lighboxInner">
                <div class="col-lg-6">
                    <div class="form-group label-floating is-focused">
                            <label class="control-label">Office Name</label>
                            <input type="text" required="" id="edit_description" name="office_name" class="form-control fullNameField">
                    </div>
                </div>
                <div class="col-lg-6">
                    <div class="form-group label-floating is-focused">
                            <label class="control-label">Admin Name</label>
                            <input type="text" required="" id="edit_admin_name" 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 is-focused">
                            <label class="control-label">Email Address</label>
                            <input type="email" required="" id="edit_email" 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 is-focused">
                            <label class="control-label">Contact Number</label>
                            <input type="text" required="" id="number" 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 is-focused">
                                <label class="control-label">Enter Password</label>
                                <input type="password" required id="edit_password" name="password" class="form-control fullNameField">
                        </div>
                    </div>
                     <div class="col-lg-6">
                        <div class="form-group label-floating is-focused">
                                <label class="control-label">Confirm Password</label>
                                <input type="password" required id="edit_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" id="submit_form" type="submit" value="Save"> Save </button>
                    </div>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>

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