<?php
    $this->load->model('landcustomerregistrationmodel/landcustomerregistrationmodel', 'CREGModel');
    $obj = $this->CREGModel;
?>

   <div class="page-content" >


                        <div class="row">
                         <?php
                                $message = $this->session->userdata('message');
                                if (!empty($message)) {
                                    ?>
                                    <div class="alert alert-block alert-success">
                                        <h6 class="lighter arial green"  style="text-align:center;"><b>
                                                <?php echo $message;
                                                $this->session->unset_userdata('message');
                                                ?>
                                            </b></h6>
                                    </div>
                                    <?php
                                }
                                $errormessage = $this->session->userdata('errormessage');
                                if (!empty($errormessage)) {
                                    ?>
                                    <div class="alert alert-block alert-danger">
                                        <h6 class="lighter arial red"  style="text-align:center;"><b>
                                                <?php echo $errormessage;
                                                $this->session->unset_userdata('errormessage');
                                                ?>
                                            </b></h6>
                                    </div>
                                    <?php
                                }
                                ?>

                    <?php if(!empty($allLandcustomer)){?>
                            <div class="col-xs-12">
                                <!-- PAGE CONTENT BEGINS -->
                     <?php $adminLebel=$this->session->userdata('admin_level');?>



                                <div class="row">
                                    <div class="col-xs-12">


                                        <div class="clearfix">
                                            <div class="pull-right tableTools-container"></div>
                                        </div>
                                        <div class="table-header" style="text-align:center;">
                                           Land Customer
                                        </div>

                                        <!-- div.table-responsive -->

                                        <!-- div.dataTables_borderWrap -->
                                        <div>
                                            <table id="dynamic-table" class="table table-striped table-bordered table-hover">
                                                <thead>
                                                    <tr style="color:red;">

                                                        <th style="color:red;">Serial</th>
                                                        <th>Id, Name & Plot Id</th>
                                                        <th>Mobile & Ref.</th>

                                                        <th>
                                                            Email & Others
                                                        </th>

                                                        <th >Photo</th>
                                                        <th>
                                                            Nominee/Mob & Others
                                                        </th>
                                                        <th>Action</th>
                                                    </tr>
                                                </thead>

                                                <tbody>

                <?php
                $i=0;
                foreach($allLandcustomer as $value){?>

                                                    <tr>


                                                        <td>
                                                            <?php echo ++$i;?>
                                                        </td>
                                        <td style="color:red;">Id :&nbsp;&nbsp;<?php if(!empty($value['customerId'])) {echo $value['customerId'];?> <?php  echo ", Ps: ".$value['plote_size'];?> <br/> Name:&nbsp;&nbsp;
                                                <a href="<?php echo admin_url()?>/landcustomerRegistration/viewProfile/<?php echo $value['id'];?>"><?php echo $value['applicant_name'];}?></a><br/> Plot Id:&nbsp;&nbsp; <?php if(!empty($value['kro_num'])) {echo $value['kro_num'];}?>
                                                        
                                                        </td>
                                                <td>
                                                    <?php if(!empty($value['mobile'])) {echo $value['mobile']."</br>";}
                                                        if(!empty($value['customer_ref'])){
                                                            if(isset($value['ref_type'])){
                                                                if($value['ref_type'] == 1){
                                                                    echo "Ref:<a href='".base_url('admin/landcustomerRegistration/viewProfile').'/'.$value['ref_id']."'>".$value['customer_ref']."</a></br>";
                                                                }
                                                                if($value['ref_type'] == 2){
                                                                    echo "Ref:<a href='".base_url('admin/employeesetup/view_profile/').'/'.$value['ref_id']."'>".$value['customer_ref']."</a></br>";
                                                                }
                                                            }else{
                                                                $userId = $obj->getCustomerIdByName($value['customer_ref']);
                                                                echo "Ref:<a href='".base_url('admin/landcustomerRegistration/viewProfile').'/'.$userId['id']."'>".$value['customer_ref']."</a></br>";
                                                            }
                                                        }
                                                    ?>
                                                    
                                                    <?php 
                                                            if(!empty($value['customerId'])) {$customerId = $value['customerId']; }
                                                            $data['customerlastcall'] =$this->CREGModel->getcustomerlastcall($customerId);
                                                            
                                                            if(!empty($data['customerlastcall'])){
                                                                echo "<span style='color:green; font-weight:bolder'>";
                                                                echo $data['customerlastcall']['description'];
                                                                echo "</span>";
                                                            }
                                                            
                                                    ?>
                                                </td>
                                                <td>
                                                <?php
                                                    if(!empty($value['email'])) {echo "Email: " .$value['email']."</br>";}
                                                   if($adminLebel==1 /*|| $adminLebel==3*/)
                                                   {
                                                        if(!empty($value['user_name'])) {echo "login: ".$value['user_name']."</br>";}
                                                        if(!empty($value['user_password'])) {echo "pass: ".$value['user_password']."</br>";}
                                                    }
                                                ?>
                                                </td>
                                            <td>
                                            <?php if(!empty($value['photo'])){?>
        <img  src="<?php if(file_exists($value['photo'])){ echo base_url().$value['photo'];}else{ echo base_url()."uploadimage/customerImage/logo1.png"; }?> " width="50">
                            <?php }?>
                                            </td>
                         <td><?php  echo $value['nomineeName'];?> <br/> <?php echo "mob: " .$value['nominee_mobile'];?> <br/> <?php  echo "Tc: ".$value['total_cost'];?> <?php  echo ", In: ".$value['dues'];?>

                                                        <td>
                                                            <div class="hidden-sm hidden-xs action-buttons">
                                                                <?php if($adminLebel==1){?>
                                                                <a class="green" href="<?php echo admin_url()?>/landcustomerRegistration/edit_customer/<?php echo $value['id'];?>">
                                                                    <i class="ace-icon fa fa-pencil bigger-130"></i>
                                                                </a>

                                                                <a class="red" href="<?php echo admin_url()?>/landcustomerRegistration/delete_customer/<?php echo $value['id'];?>" onclick="return ConfirmDelete()">
                                                                    <i class="ace-icon fa fa-trash-o bigger-130"></i>
                                                                </a>
                                                                <?php }?>
                                                                <a class="red" href="<?php echo admin_url()?>/landcustomerRegistration/viewProfile/<?php echo $value['id'];?>">
                                                                    <i class="ace-icon fa fa-user  bigger-130"></i>
                                                                </a>
                                                                <a class="red" href="<?php echo admin_url()?>/landcustomerRegistration/viewCommission/<?php echo $value['id'];?>">
                                                                    <i class="ace-icon fa fa-money  bigger-130"></i>
                                                                </a>
                                                                <a target="_blank" class="red" href="<?php echo admin_url()?>/customerCalls/entrybyid?custidget=<?php echo $value['customerId'];?>&custname=<?php echo $value['applicant_name'];?>&custmobile=<?php echo $value['mobile'];?>&custnmobile=<?php echo $value['nominee_mobile'];?>">
                                                                    <i class="ace-icon fa fa-phone  bigger-130"></i>
                                                                </a>

                                                            </div>
                                                            

                                                        </td>
                                                    </tr>

                   <?php }?>


                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>


                                </div><!-- PAGE CONTENT ENDS -->
                                <?php }?>
                            </div><!-- /.col -->
                        </div><!-- /.row -->



