<style>
    .assign-to .multiselect-container.dropdown-menu{
        left: 0;
        right: unset;
        top: unset;
        box-shadow: 0 0 5px;
    }
    
    .assign-to .multiselect .caret {
        position: absolute;
        top: 65%;
        right: 12px;
        margin-top: -8px;
        width: unset;
        text-align: right;
    }
</style>
<div class="assign-to">
    <?php 
        $class = [];
        $list = [];
        if($_SESSION['userType'] == CMS_USER_INDICATOR || $this->Common->isEmployeeAsAdmin()){
            if ($this->request->params['action'] == 'clientonboarding') {
                //$list[0] = 'Please select';
                $list['My own client list'] = ['0'=>'My own client list'];
                $class['My own client list'] = 'my-own-client-list-multiple';
            }else {
                $list['My own client list'] = ['0'=>'My own client list'];
                $class['My own client list'] = 'my-own-client-list-multiple';
            }
        }
        
        if(!empty($affiliate_client_list)){
            $list['My Own Affiliate List'] = $affiliate_client_list;
            $class['My Own Affiliate List'] = 'my-own-affiliate-list-multiple';
        }
        
        if(!empty($employee_list)){
            $list['Employee List'] = $employee_list;
            $class['Employee List'] = 'my-employee-list-multiple';
        }
        
        
        if($_SESSION['userType'] == CMS_USER_INDICATOR || $this->Common->isEmployeeAsAdmin()){
            if(!empty($affiliate_client_list)){
                $list['My Own Affiliate List'] = $affiliate_client_list;
                $class['My Own Affiliate List'] = 'my-own-affiliate-list-multiple';
            }
            if(!empty($employee_affiliate_list)){
                $list['Affiliate List'] = $employee_affiliate_list;
                $class['Affiliate List'] = 'employee-affiliate-list-multiple';
            }
        }else if($_SESSION['userType'] == CRM_USER_INDICATOR && !$this->Common->isEmployeeAsAdmin()){
            if(!empty($employee_affiliate_list)){
                $list['Affiliate List'] = $employee_affiliate_list;
                $class['Affiliate List'] = 'employee-affiliate-list-multiple';
            }
            
            if(!empty($employee_list)){
                $list['Employee List'] = $employee_list;
                $class['Employee List'] = 'my-employee-list-multiple';
            }
            
        }


        $crmuser_ids = [];
        $selected_assoc = [];
        if($client->client->crmuser_id == 0 && $client->client->employee_id == 0){
             $crmuser_id = 0;
             $crmuser_ids[] = $crmuser_id;
        }
        if($client->client->crmuser_id == 0 && $client->client->employee_id > 0){
            $crmuser_id = $client->client->employee_id;
            $crmuser_ids[] = $crmuser_id;
            $selected_assoc['Employee List'][] = $crmuser_id;
        } 
        
        if($client->client->crmuser_id > 0 && $client->client->employee_id == 0){
            $crmuser_id = $client->client->crmuser_id;
            $crmuser_ids[] = $crmuser_id;
            $selected_assoc['Affiliate List'][] = $crmuser_id;
        } 
        
        if($client->client->crmuser_id > 0 && $client->client->employee_id > 0){
            $crmuser_id = $client->client->crmuser_id;
            $crmuser_ids[] = $crmuser_id;
            $crmuser_ids[] = $client->client->employee_id;
            $selected_assoc['Affiliate List'][] = $crmuser_id;
            $selected_assoc['Employee List'][] = $client->client->employee_id;
        }

        $is_own_client_disabled = false;

        echo $this->element('client_assign/multiselect_checkbox',
                [
                    'data'=>[
                            'is_own_client_checked'=>$is_own_client_checked,
                            'is_own_client_disabled'=>$is_own_client_disabled,
                            'selected'=>$client_employee_relations[$client->client->id],
                            'list'=>$list,
                            'client_id'=>$client->client->id,
                            'client_name'=>$client->client->name,
                            'class'=>$class,
                            'member_id'=>$client_employee_relationsData[$client->client->id]['member_id']
                        ]
                ]); 
        ?>
    <img id="client-assign-loader" style="display:none" src="<?php echo $this->Url->build('/images/ajax-loader.gif'); ?>">
</div>   
