<style>
    .text-white{
        color: white;
    }
    a{
        color: #4c0870;
    }
</style>
<script src="<?php echo VIEWS_PATH; ?>crm/common.js"></script>
<div class="container-fluid container-fixed-lg bg-white">
    <div class="panel panel-transparent">
        <div class="panel-heading">
            <div class="panel-title"><?php echo $title; ?> </div>
        </div>
        <div class="panel-body">
            <div class="row form-group">
                <div class="col-md-3">
                    <label><?php print CommonLanguage::getMessage('customer'); ?></label>
                    <input type="hidden" name="filter_org_id" id="filter_org_id" class="full-width"/>
                </div>
                <?php  if ($permissions->hasPermission('add_crm_contact')) {?>
                <div class="col-md-4 pull-right m-t-20">
                    <a style="color:white !important;" class="btn bg-complete-dark pull-right " id="add_contact" data-origin="list" data-toggle="modal" data-target="#contact_modal">
                        <?php print CommonLanguage::getMessage('add_contact'); ?>
                    </a> 
                </div>
                <?php }?>
            </div>
            <div class="row">
                <div class="table-responsive col-md-12 m-t-10">
                    <table class="table table-bordered table-hover crm-table" id="tableWithSearch" >
                        <thead>
                            <tr>
                                <th class="text-center"><?php print CommonLanguage::getMessage('contact_name'); ?></th>
                                <th class="text-center"><?php print CommonLanguage::getMessage('customer'); ?></th>
                                <th class="text-center"><?php print CommonLanguage::getMessage('Phone'); ?></th>
                                <th class="text-center"><?php print CommonLanguage::getMessage('second_phone'); ?></th>
                                <th class="text-center"><?php print CommonLanguage::getMessage('Email'); ?></th>
                                <th class="text-center"><?php print CommonLanguage::getMessage('Action'); ?></th>
                            </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function(){ 
        build_select2($("input[name=filter_org_id]"), "xhr/getOrganizations");
        $("input[name=filter_org_id]").on('change',function(){
            RebuildDataTable($('.panel-heading .panel-title').html(),[0,1,2,3,4],'crmAjax/contactList',{organization_id:$("input[name=filter_org_id]").val()});
        });
        RebuildDataTable($('.panel-heading .panel-title').html(),[0,1,2,3,4],'crmAjax/contactList',{organization_id:$("input[name=filter_org_id]").val()});
    })
</script>
<?php  if ($permissions->hasPermission('add_crm_contact') || 
           $permissions->hasPermission('edit_crm_contact')) {
    include 'Views/crm/contact_modal.php';
}