<?php

//debug($list_costcenter,1);

/*----include header file----*/
require_once APPPATH."/views/common/header.php"; ?>
    <div class="boxLwd">
        <h2>Filters</h2>
        
        <div class="row costLine">
            <div class="col-xs-12 col-sm-12 col-md-4 col-lg-4 ui-widget">
			  <form method="post" class="contractfiltersubmit" action="<?php echo base_url() ?>index.php/contractarea">
                <select name="costcenterfilter" class="combobox costcenter">
                    <option selected="selected">Select Cost Center</option>
					<option value="all">All center</option>
                         <?php
                            if( !empty( $costcenter ) )
                            {
                                foreach( $costcenter as $val ):
                            ?>
                                <option <?php if($val['costcenter_id']==$this->session->userdata('costcenterfilter')){ echo "selected"; } ?> value="<?= $val['costcenter_id']; ?>"><?= $val['costcenter_name']; ?></option>
                            <?php
                                endforeach;
                            }
                        ?>                    
                </select>
			  </form>
            </div>
        </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" onclick="return add_contract_area()">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 contractarea" width="98%" cellpadding="1" cellspacing="1">
                <thead>
                    <tr>
                        <th>Number</th>
                        <th>Cost Center</th>
                        <th style="display: none;">createDate</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( $list_costcenter ) ):
                        for( $i=0; $i<count($list_costcenter); $i++ ):
                ?>
                    <tr>
                        <td><?= $list_costcenter[$i]['contractarea_id']; ?></td>
                        <td><?= ucfirst( $list_costcenter[$i]['costcenter_id']['costcenter_name'] ); ?></td>
                        <td style="display: none;"><?= $list_costcenter[$i]['create_date']; ?></td>
                        <td><?= ucfirst( $list_costcenter[$i]['contractarea_name'] ); ?></td>
                        <td><?= $list_costcenter[$i]['office_count']; ?></td>
                        <td>0</td>
                        <td>
                            <select data-cost_id="<?= $list_costcenter[$i]['contractarea_id']; ?>" name="status" class="contractarea_status custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left ui-autocomplete-input">
                                <option value="0" <?php if( $list_costcenter[$i]['status'] == 0 ) { echo 'selected'; } ?> >Pending</option>
                                <option value="1" <?php if( $list_costcenter[$i]['status'] == 1 ) { echo 'selected'; } ?>>Inactive</option>
                                <option value="2" <?php if( $list_costcenter[$i]['status'] == 2 ) { echo 'selected'; } ?>>Active</option>
                            </select>
                        </td>
                        <td><a href="javascript:void(0);" onclick="return edit_contract_area( '<?= $list_costcenter[$i]['contractarea_id']; ?>', '<?= $list_costcenter[$i]['contractarea_name']; ?>', '<?= $list_costcenter[$i]['costcenter_id']['costcenter_name']; ?>' )">Edit</a></td>
                    </tr>
                <?php
                        endfor;
                    endif;
                ?>
                    
                    
                </tbody>
            </table>
            
        </div>
   </div>
</div>
</div>


<div id="lightbox" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <button type="button" class="close cancel"  aria-hidden="true">×</button>
		<button type="button" class="close closepopup" style="display:none;" data-dismiss="modal" aria-hidden="true">×</button>
        <div class="modal-content">
            <div class="modal-body">
            
            <div class="row">
            <div class="col-lg-12">
                <h2 id="pop_heading">Add Contract Area</h2>
            </div>
            </div>
            <form id="add_contractarea">
            <div class="ajax_msg"></div>
             <div class="row lighboxInner">
            	<div class="col-lg-12" id="add_costcenter">
                    <select name="costcenter" id="costcenter" class="costCenterSelect">
                         <option>Select Cost Center</option>
                             <?php
                                if( !empty( $costcenter ) )
                                {
                                    foreach( $costcenter as $val ):
                                ?>
                                    <option value="<?= $val['costcenter_id']; ?>"><?= $val['costcenter_name']; ?></option>
                                <?php
                                    endforeach;
                                }
                            ?> 
                    </select>
                </div>
                <div id="edit_costcenter">

                </div>
             </div>
             
             
               <div class="row lighboxInner">
            	<div class="col-lg-12">
                    <div class="form-group label-floating labelContract">
                            <label class="control-label">Contract Area Name</label>
                            <input type="text" name="contract_area" id="contract_area" class="form-control fullNameField">
                            <input type="hidden" name="contractarea_id" id="contractarea_id">
                            <!-- <a href="#"><img src="/img/addIcon.svg"></a> -->
                    </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 cancel" type="button" value="Cancel" data-dismiss="modal" aria-hidden="true">Cancel</button>
                       <button class="btn btn-default" type="submit" value="Save">Save</button>
                       <!-- <input type="submit" value="Save" name="submit" class="btn btn-default"> -->
                    </div>
	            </div>
	            </form>
            </div>
        </div>
    </div>
</div>


<div id="status_div" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <button type="button" class="close cancel" aria-hidden="true">×</button>
		<button type="button" class="close closepopup" style="display:none;" 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 Contract Area</h2>
            </div>
            </div>
            <form id="add_contractarea">
            <div class="ajax_msg"></div>
             <div class="row lighboxInner">
                <div class="col-lg-12">
                </div>
             </div>
             
             
               <div class="row lighboxInner">
                
                <div class="row lighboxInner lightBoxSelect">
                    <div class="col-xs-12 col-sm-12 col-md-2 col-lg-12">
                       <button class="btn btn-default cancel" type="button" value="Cancel" data-dismiss="modal" aria-hidden="true">Cancel</button>
                       <input type="submit" value="Save" name="submit" class="btn btn-default">
                    </div>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>

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