}
        }
    }
}
$i = 1;
?>
        <div id="wizard" class="tab-content-bdr-0">
            <?php 
if ((int) $show_payment_tab > 0) {
    echo "<script>var show_payment_tab=1;</script>";
} else {
    echo "<script>var show_payment_tab=0;</script>";
}
if (!empty($myvar)) {
    foreach ($myvar as $key => $value) {
        if (is_user_company_billing() && !is_user_company_admin()) {
            if (strtolower($key) == 'payments') {
                if (strtolower($key) == 'payments') {
                    if ((int) $show_payment_tab > 0) {
                        ?>
                                    <h2><?php 
                        echo $key;
                        ?>
</h2>
                                    <section>
                                    <?php 
                        echo $myvar[$key];
                        ?>
                                    </section>
                                    <?php 
                    } else {
<?php

global $wpdb, $per_page, $resulttotal, $current_user;
$total = 'select count(*) as total from ' . $wpdb->prefix . 'application_data where status = "modified"  and deleted_on is null;';
$resulttotal = $wpdb->get_results($total);
$resulttotal = $resulttotal[0]->total;
if (isset($_GET['paged'])) {
    $sql = "select * from " . $wpdb->prefix . "application_data where status = 'modified' and deleted_on is null limit " . $start_from . "," . $per_page;
} else {
    $sql = "select * from " . $wpdb->prefix . "application_data where status = 'modified' and deleted_on is null limit " . $start_from . "," . $per_page;
}
$resultfromdb = $wpdb->get_results($sql);
$roles = get_user_meta(get_current_user_id(), "wp_capabilities");
$company_admin = is_user_company_admin();
if (user_can($current_user, "customer") && $company_admin == 1) {
    $sql = "select `id`, `name`, `doc_id` from " . $wpdb->prefix . "applications ";
    $new_accreditation = $wpdb->get_results($sql);
    ?>
<script>
$(document).ready(function() {
    $('#apply_for_new_accreditation_table').DataTable( {
        "searching": false,
		"processing": true,
		"bPaginate":false,
		"aoColumnDefs": [
          { 'bSortable': false, 'aTargets': [ 1,2 ] }
       ]
    } );
	jQuery(".colorbox-inline-70").colorbox({
			 overlayClose: false, 
			 inline:true, 
function get_application_by_certificate_crm_id()
{
    global $current_user, $wpdb;
    $result = array();
    $third_party_array = array(2, 7, 10);
    if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) {
        $crm_id = $_REQUEST['id'];
        $app_data = $wpdb->get_results("SELECT ad.id as app_id,ad.application_name,ad.certificate_status,ad.certificate_url,ad.status,ad.certificate_name,ad.new_application_id,ad.program_id,p.name as program_name,c.name as company, ad.crm_id from " . $wpdb->prefix . "application_data as ad left join " . $wpdb->prefix . "programs as p on p.id = ad.program_id left join " . $wpdb->prefix . "company as c on c.id = ad.company_id and c.id=ad.company_id  where certificate_crm_id ='" . $crm_id . "'");
        //echo "SELECT ad.id as app_id,ad.application_name,p.name as program_name,c.name from " . $wpdb->prefix . "application_data as ad join " . $wpdb->prefix . "programs as p join " . $wpdb->prefix . "company as c  on p.id = ad.program_id and c.id=ad.company_id  where certificate_crm_id ='".$crm_id."'";die;
        if (count($app_data) > 0) {
            foreach ($app_data as $ad) {
                $opr = '';
                $temp = array();
                $temp['app_id'] = $ad->app_id;
                $temp['app_name'] = $ad->application_name;
                $temp['program_name'] = $ad->program_name;
                $temp['company'] = $ad->company;
                $temp['status'] = $ad->status;
                if (user_can($current_user, "staff")) {
                    //$opr .= '<a href="' . site_url() . '/index.php/listings/?page=create-form-register&id=' . base64_encode($ad->app_id) . '&view=true" title="View Application"><span style="font-size: 20px;" aria-hidden="true" class="glyphicon glyphicon-eye-open"></span></a>';
                    if (strtolower($ad->status) == 'new' || strtolower($ad->status) == 'modified' || strtolower($ad->status) == 'draft') {
                        $request_url = get_admin_url() . 'admin-post.php?action=approve-application-form&id=' . base64_encode($ad->app_id) . '&is_ajax=true';
                        $redirect_url = site_url() . '/index.php/listings?page=application-form-register&view=approved';
                        if ($ad->status == 'modified') {
                            $opr .= '<li style="float: left;list-style-type: none; margin-right: 5px;"><a  title="View Difference From Last Update" href="#app_diff" class="colorbox-inline" onclick="getAppDiff(\'' . $ad->app_id . '\',\'app\', \'' . $ad->company . '\', \'' . get_admin_url() . 'admin-post.php?action=approve-application-form&id=' . base64_encode($ad->app_id) . '\', \'' . $ad->certificate_name . '\', \'' . $redirect_url . '\' );getAppDocDiff(\'' . $ad->app_id . '\', \'doc\', \'' . $ad->company . '\')" ><span style="font-size: 20px;" aria-hidden="true" class="glyphicon glyphicon-random"></span></li></a>';
                        }
                        if (!empty($ad->certificate_name) && !in_array($ad->program_id, $third_party_array)) {
                            $opr .= '<li style="float: left;list-style-type: none; margin-right: 5px;"><a href="#" onclick="application_push_to_crm(\'' . $request_url . '\', \'' . $redirect_url . '\')" class="approveLink" value=""  title="Push To CRM"><span style="font-size: 20px;" aria-hidden="true" class="glyphicon glyphicon-okglyphicon glyphicon-ok"></span></li></a>';
                        } else {
                            $certificate_name = isset($ad->certificate_name) && $ad->certificate_name != '' ? $ad->certificate_name : '';
                            $new_inspectionagencycert = isset($json->new_application->_linked->new_certificate->new_inspectionagencycert) ? $json->new_application->_linked->new_certificate->new_inspectionagencycert : '';
                            $opr .= '<li style="float: left;list-style-type: none; margin-right: 5px;"><a href="#app_certification_popup" id="approve-link-' . $ad->app_id . '" onclick="return openCertificatePopUp(\'' . $ad->app_id . '\',\'' . $ad->program_id . '\',\'' . $new_inspectionagencycert . '\',\'' . $ad->certificate_name . '\')" data-href="' . $request_url . '" redirect-href="' . $redirect_url . '" class="colorbox-inline" value=""  title="Push To CRM"><span style="font-size: 20px;" aria-hidden="true" class="glyphicon glyphicon-ok"></span></li></a>';
                        }
                    }
                    if (empty($ad->certificate_url)) {
                        if (strtolower($ad->status) != 'completed') {
                            $opr .= '<li style="float: left;list-style-type: none; margin-right: 5px;"><a  class="icon-3" href="' . site_url() . '/index.php/listings/?page=create-form-register&id=' . base64_encode($ad->app_id) . '&view=true" title="View Application"><span style="font-size: 20px;" aria-hidden="true" class="glyphicon glyphicon-eye-open"></span></li></a>';
                        }
                        if (strtolower($ad->status) == 'new' || strtolower($ad->status) == 'modified' || strtolower($ad->status) == 'draft') {
                            $opr .= '<li style="float: left;list-style-type: none; margin-right: 5px;"><a  title="Edit Application" class="icon-3" href="' . site_url() . '/index.php/listings/?page=create-form-register&id=' . base64_encode($ad->app_id) . '&view=false"><span style="font-size: 20px;" aria-hidden="true" class="glyphicon glyphicon-edit"></span></li></a>';
                        }
                    }
                } else {
                    if ((user_can($current_user, "customer") || is_user_company_admin()) && empty($ad->certificate_url)) {
                        if (strtolower($ad->status) != 'completed') {
                            $opr .= '<li style="float: left;list-style-type: none; margin-right: 5px;"><a  class="icon-3" href="' . site_url() . '/index.php/listings/?page=create-form-register&id=' . base64_encode($ad->app_id) . '&view=true" title="View Application"><span style="font-size: 20px;" aria-hidden="true" class="glyphicon glyphicon-eye-open"></span></li></a>';
                        }
                        if ($ad->new_application_id == 0 && strtolower($ad->status) != 'completed') {
                            $opr .= '<li  style="float: left;list-style-type: none; margin-right: 5px;"><a  title="Edit Application" class="icon-3" href="' . site_url() . '/index.php/listings/?page=create-form-register&id=' . base64_encode($ad->app_id) . '&view=false"><span style="font-size: 20px;" aria-hidden="true" class="glyphicon glyphicon-edit"></span></li></a>';
                        }
                    } else {
                        if (user_can($current_user, "assessor") && empty($ad->certificate_url) && strtolower($ad->status) != 'completed') {
                            $opr .= '<li style="float: left;list-style-type: none; margin-right: 5px;"><a  class="icon-3" href="' . site_url() . '/index.php/listings/?page=create-form-register&id=' . base64_encode($ad->app_id) . '&view=true" title="View Application"><span style="font-size: 20px;" aria-hidden="true" class="glyphicon glyphicon-eye-open"></span></li></a>';
                        }
                    }
                }
                if (is_user_company_admin() && empty($ad->crm_id) && strtolower($ad->status) != 'completed') {
                    $opr .= '<li style="float: left;list-style-type: none; margin-right: 5px;"><a title="Delete Application" class="icon-3" href="' . get_admin_url() . 'admin-post.php?action=delete-application-form&id=' . base64_encode($ad->app_id) . '" onclick="return confirm(\'Are you sure you want to delete this application ?\');"><span style="font-size: 20px;" aria-hidden="true" class="glyphicon glyphicon-trash">' . $ad->crm_id . '</span></li></a>';
                }
                $temp['act'] = $opr;
                $result[$ad->app_id] = $temp;
            }
        }
    }
    echo json_encode($result);
    die;
}