<?php

/*
 *
 * ZENDESK - ORGANIZATION PRIORITY
 * IMPORT PRIORITY LIST AND TAM FROM SALESFORCE
 *
 */
 
// Utility functions
require_once("../shared/functions.php");

// Zendesk Connect
require("config.Zendesk.inc.php");

// Zendesk Class
require("Zendesk.class.php");


if(isset($_POST['batchUpdate'])) { $batchUpdate = $_POST['batchUpdate']; }
else $batchUpdate = 1;

if(isset($_POST['organizationid']) && $_POST['organizationid'] > 0) { $organizationid = $_POST['organizationid']; }
else $organizationid = 0;

if(isset($_GET['debug']) && $_GET['debug'] > 0) { $debug = $_GET['debug']; }
else $debug = 0;

// Init vars & arrays & objets
$allSFIDs = array();
$allZIDs = array();
$allViews = array();
$AllOrganizations = array();
$UpdateOrganization = array();
$updated = $error = $ignored = 0;
// Set old category tags to purge
$oldTags = array('vip', 'cat1', 'cat2', 'cat3', 'cat4', 'cat5', 'cat6', 'cat7', 'cat8', 'cat9', 'cat10');
// Start Zendesk Class
$Zendesk = new Zendesk($resource, $token, $username);


if(isset($_POST['action']) && $_POST['action'] == 'upload' && isset($_FILES) && $_FILES['inputfile']['error'] == 0) {

    /*
     * 1 - OPEN SALESFORCE ORGANIZATIONS
     * 
     * File format CSV UTF8
     * Cols :
     * 0 Priority Note
     * 1 AM
     * 2 TAM
     * 3 Parent Account ID
     * 4 Parent Name
     * 5 Account ID
     * 6 Account Name
     */


    // Store uploaded priority List
    $dir = "./cache";
    $uploadedFileNameArr = explode(".", $_FILES['inputfile']['name']);
    $ext = end($uploadedFileNameArr);
    move_uploaded_file($_FILES['inputfile']['tmp_name'], "$dir/priority.$ext" ); //Move the file to desired directory.
    $file = "$dir/priority.$ext";

    // Process file
    if (($handle = fopen($file, "r")) !== FALSE) {

        $row = 1;
        while (($dataRaw = fgetcsv($handle, 1000, ",")) !== FALSE) {
            if($row > 1) { //  && $row < 10

                $data = new stdClass();

                $data->PriorityNote             = $dataRaw[0];
                $data->AccountManager           = $dataRaw[1];
                $data->TechnicalAccountManager  = $dataRaw[2];
                $data->ParentAccountID          = $dataRaw[3];
                $data->ParentAccountName        = $dataRaw[4];
                $data->AccountID                = $dataRaw[5];
                $data->AccountName              = $dataRaw[6];
                

                if($data->ParentAccountID) { // Is Parent
                    $SFID = $SFID_original = $data->ParentAccountID;
                    $name = $data->ParentAccountName;

                    die("Wrong export used: use an export where you already filtered Parent and Child accounts.");
                }
                else { // Is Child
                    $SFID = $SFID_original = $data->AccountID;
                    $name = $data->AccountName;
                }

                $SFID = 'SFACCOUNT'.md5($SFID); // generate hash to manage upper/lower case duplicates


                if(isset($AllOrganizations[$SFID])) {
                    /*
                     * New Scoring Object Management (1 organization = X lines)
                     * Existing line so add score to previous score
                     */
                    $AllOrganizations[$SFID]->priority  += $data->PriorityNote;
                }
                else {
                    /*
                     * New Line to read
                     */
                    $AllOrganizations[$SFID]            = new stdClass();
                    $AllOrganizations[$SFID]->name      = $name;
                    $AllOrganizations[$SFID]->SFID      = $SFID_original;
                    $AllOrganizations[$SFID]->priority  = $data->PriorityNote;
                    
                    // TAM
                    if(strlen($data->TechnicalAccountManager)) {
                        $AllOrganizations[$SFID]->tam       = $data->TechnicalAccountManager;
                        $tamArr = explode(" " , strtolower($data->TechnicalAccountManager));
                        if(is_array($tamArr) && count($tamArr)) {
                            $alias = '';
                            foreach($tamArr as $tamStr) {
                                $alias .= $tamStr[0];
                            }
                            $AllOrganizations[$SFID]->alias      = $alias;
                        }
                    }

                    $allSFIDs[] = $SFID;
                }
            }
            $row++;
        }
        fclose($handle);

        //krumo($AllOrganizations);
    }

}
elseif(isset($_POST['action']) && $_POST['action'] == 'update') {

    if(is_array($_POST['ZID']) && is_array($_POST['Name']) && is_array($_POST['Priority'])) {

        /*
         * ORGANISE JSON DATA
         */

        $PutOrganization = new stdClass();
        if($batchUpdate) { $PutOrganization->organizations = array(); }

        // Start processing POST
        $i=0;
        foreach($_POST['ZID'] as $SFID => $ZID) {
            $priority   = (int) $_POST['Priority'][$SFID];
            $name       = $_POST['Name'][$SFID];
            if(isset($_POST['Tam']) && isset($_POST['Tam'][$SFID])) {
                $tam    = $_POST['Tam'][$SFID];
            }

            if($ZID && $priority && $name) { //  && $i==0  && $name == 'Marie Claire / Magazines'

                // Purge local cache file
                if(isset($_POST['ZName'][$SFID])) {
                    $filecache = "./cache/".md5($_POST['ZName'][$SFID]).".cache.json";
                    if(file_exists($filecache)) {
                        unlink($filecache);
                    }
                }
                
                // Prepare Update
                if($batchUpdate) {

                    /*
                     * Case Batch (chunks)
                     */

                    // Default Params
                    $PutOrganization->organizations[$i] = new stdClass();
                    $PutOrganization->organizations[$i]->id = (int) $ZID;
                    $PutOrganization->organizations[$i]->external_id = $SFID;
                    $PutOrganization->organizations[$i]->name = $name;

                    // Tags
                    $newTags = array('cat'.$priority);
                    if(isset($tam) && strlen($tam)) {
                        $newTags[] = 'bits-'.$tam;
                    }
                    // Remove old category tags
                    $Zendesk->RemoveOrganizationTag($PutOrganization->organizations[$i]->id, $oldTags);

                    // Add new category and TAM tags
                    $Zendesk->AddOrganizationTag($PutOrganization->organizations[$i]->id, $newTags);

                    /*$PutOrganization->organizations[$i]->tags = array('cat'.$priority);
                    if(isset($tam) && strlen($tam)) {
                        $PutOrganization->organizations[$i]->tags[] = 'bits-'.$tam;
                    }*/

                    // Category
                    $PutOrganization->organizations[$i]->organization_fields = new stdClass();
                    $PutOrganization->organizations[$i]->organization_fields->vip_merchant = 'cat'.$priority;

                    // Store ID
                    $allZIDs[] = $ZID;
                }
                else {

                    /*
                     * Case individual organization update (for debug)
                     */

                    // Default Param
                    $PutOrganization->organization = new stdClass();
                    $PutOrganization->organization->id = (int) $ZID;
                    $PutOrganization->organization->external_id = $SFID;
                    $PutOrganization->organization->name = $name;

                    // Tags
                    $newTags = array('cat'.$priority);
                    if(isset($tam) && strlen($tam)) {
                        $newTags[] = 'bits-'.$tam;
                    }
                    // Remove old category tags
                    $Zendesk->RemoveOrganizationTag($PutOrganization->organization->id, $oldTags);

                    // Add new category and TAM tags
                    $Zendesk->AddOrganizationTag($PutOrganization->organization->id, $newTags);

                    /*$PutOrganization->organization->tags = array('cat'.$priority);
                    if(isset($tam) && strlen($tam)) {
                        $PutOrganization->organization->tags[] = 'bits-'.$tam;
                    }*/

                    // Category
                    $PutOrganization->organization->organization_fields = new stdClass();
                    $PutOrganization->organization->organization_fields->vip_merchant = 'cat'.$priority;
    
                    $queryParameters = $PutOrganization;
                    $options = array(
                            CURLOPT_URL => $resource."organizations/$ZID.json",
                            CURLOPT_USERPWD => $username."/token:$token",
                            CURLOPT_RETURNTRANSFER =>true,
                            CURLOPT_ENCODING => "",
                            CURLOPT_MAXREDIRS => 10,
                            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                            CURLOPT_CUSTOMREQUEST => "PUT",
                            CURLOPT_POSTFIELDS => json_encode($queryParameters),
                            CURLOPT_HTTPHEADER => array('Content-Type: application/json', 'Content-Length: ' . strlen(json_encode($queryParameters)))
                    );
                    require("curl.Zendesk.inc.php");
                
                    $result = json_decode($result);
                    $display_result = json_encode($PutOrganization) . "\n<br/>" . $result;
                }

                $i++;
            }
        }

        if($batchUpdate) {

            /*
            * PREPARE CHUNKS OF 100
            */

            $AllQueries = array_chunk($PutOrganization->organizations, 100, true);

            /*
            * POST TO ZENDESK JSON DATA
            */

            foreach($AllQueries as $Query) {

                $PutOrganization = new stdClass();
                $PutOrganization->organizations = $Query;

                $queryParameters = $PutOrganization;
                $options = array(
                        CURLOPT_URL => $resource."organizations/update_many.json", //?ids=".implode(',', $allZIDs),
                        CURLOPT_USERPWD => $username."/token:$token",
                        CURLOPT_RETURNTRANSFER =>true,
                        CURLOPT_ENCODING => "",
                        CURLOPT_MAXREDIRS => 10,
                        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                        CURLOPT_CUSTOMREQUEST => "PUT",
                        CURLOPT_POSTFIELDS => json_encode($queryParameters),
                        CURLOPT_HTTPHEADER => array('Content-Type: application/json', 'Content-Length: ' . strlen(json_encode($queryParameters)))
                );
                require("curl.Zendesk.inc.php");

                //$result = json_decode($result);
                $display_result = "Job created to update organizations... <br /><br /><b>Do not forget to <a id='Populate' href='javascript:void(0)'>populate to existing tickets</a></b> if needed. <div class='loader'></div><br /><br />Job result = <small>$result</small>";
            }

            
            //$result = json_decode($result);
        }
    }

}

?>
<html lang="en">
    <head>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8">
        <meta charset="utf-8">
        <title>Account Priority | Zendesk Import</title>
        <link rel="icon" type="image/png" href="images/pentagon.png" />

        <script src="//code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" crossorigin="anonymous"></script>
        <script src="//code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>

        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css" />

        <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

        <!-- Optional theme -->
        <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

        <!-- Latest compiled and minified JavaScript -->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" crossorigin="anonymous"></script>
        <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

        <style>
            .ui-autocomplete {
                z-index: 100;
            }
            .loader {
                display: none;
                border: 5px solid #f3f3f3;
                -webkit-animation: spin 1s linear infinite;
                animation: spin 1s linear infinite;
                border-top: 5px solid #555;
                border-radius: 50%;
                width: 50px;
                height: 50px;
            }

            @keyframes spin {
                0% { transform: rotate(0deg); }
                100% { transform: rotate(360deg); }
            }
        </style>

        <script>
            $(function() {
                $('[data-toggle="tooltip"]').tooltip();

                $( '.autocomplete' ).autocomplete({
                    source: "Zendesk_OrganizationAutocomplete.ajax.php",
                    minLength: 2,
                    delay: 1000,
                    select: function( event, ui ) {
                        var SFID = $(this).parent().parent().attr('data-sfid');
                        $('#ZID_'+ SFID).val(ui.item.id);

                        var SearchZID = $(" #ExistingZID ").find('li[data-ZID='+ui.item.id+']');
                        if(SearchZID.length > 0) {
                            console.log("Found "+ui.item.id);
                            $(this).parent().append('<div id="alert_'+ui.item.id+'" class="alert alert-danger" role="alert">This Zendesk Organization is already synced.<br /><a href="javascript:removeSync('+ui.item.id+');" class="removeSync alert-link" data-ZID="'+ui.item.id+'">Remove current sync ?</a></div>');
                        }
                    }
                });

                $( '.autocomplete' ).focusout(function(){
                    if($(this).val() == '') {
                        var SFID = $(this).parent().parent().attr('data-sfid');
                        var ZID = $('#ZID_'+ SFID).val();
                        $(' #ZID_'+SFID ).val('');
                        $(' #alert_'+ZID ).hide('slow').remove();
                    }
                });

                $( '.createOrganization').click(function(){

                    var SFID = $(this).attr("data-SFID");
                    var name = $(this).attr("data-name");
                    var priority = $(this).attr("data-priority");
                    var tam = $(this).attr("data-tam");

                    $.post( "Zendesk_OrganizationCreate.ajax.php", { SFID: SFID, name: name, priority: priority, tam: tam })
                    .done(function( data ) {
                        if(data == "OK") {
                            console.log("Organization "+name+" created");
                            $(" tr[data-SFID="+SFID+"] ").hide('slow');
                        }
                    });

                });

                $( '.removeSync' ).click(function(){
                    console.log("removeSync");
                    var ZID = $(this).attr("data-ZID");
                    removeSync(ZID);
                });

                $( 'button.submit' ).click(function() {
                    $(this).parent().parent().submit();
                });

                $( '#Populate').click(function(){
                    $.ajax({
                        type: "GET",
                        url: 'Zendesk_PopulateTags.ajax.php',
                        beforeSend: function() {
                            $(".loader").show();
                        },
                        success: function(data) {
                            if(data == "OK") {
                                console.log("Populatin OK");
                                $(".loader").replaceWith("<div>OK</div>");
                            }
                            else {
                                console.log("Populating Error");
                                $(".loader").replaceWith("<div>Error</div>");
                            }
                        }
                    });
                });
            });

            function removeSync(ZID) {
                console.log(ZID);
                $.post( "Zendesk_OrganizationRemoveSync.ajax.php", { ZID: ZID })
                .done(function( data ) {
                    if(data == "OK") {
                        console.log("Organization "+ZID+" removed from sync");
                        $(' li a[data-ZID='+ZID+'] ').parent().hide('slow');
                        $(' #alert_'+ZID ).hide('slow').remove();
                    }
                });
            }

            function updateViews() {
                console.log("Updating views");
                $.post( "Zendesk_UpdateViews.ajax.php")
                .done(function( data ) {
                    console.log(data);
                });
            }
        </script>

    </head>
    <body>

         <div class="container">
         <?php if(isset($display_result)) { ?>
            <div class="alert alert-warning" role="alert"><?=$display_result?></div>
         <?php } ?>

            <h2>Upload a Salesforce Account Priority Extract</h2>
            <div class="well well-sm" style="width:620px;">To start a Zendesk synchronization, you need to download a <b>CSV</b> extract with <b>UTF-8</b> encoding of the Salesforce report <b><a href="https://hipay.lightning.force.com/one/one.app#/sObject/00O0Y000007LuqpUAC/view" target="_blank"></a>Opportunity ID by Stage and Account</b>.</div>
            <div class="row">
            <form method="post" action="" enctype="multipart/form-data" class="form-inline">
                <div class="form-group">
                    <label for="inputfile">Your local file</label>
                    <input type="file" id="inputfile" name="inputfile" class="form-control" accept=".csv" />
                </div>
                <div class="form-group">
                    <input type="hidden" name="action" value="upload" />
                    <button type="button" class="btn btn-info submit"><span class="glyphicon glyphicon-open"></span> Upload</button>
                </div>
            </form>
            </div>

<?php

if(count($AllOrganizations) && count($allSFIDs)) {

?>
    <script type="text/javascript">
        /* Prevent browser back button */
        window.history.forward();
        window.onload = function()
        {
        window.history.forward();
        };

        window.onunload = function() {
        null;
        };
    </script>
    <h2>List of Salesforce Organisations to sync with Zendesk</h2>
        <form method="post" action=""><!--  class="form-inline" -->
            <table class="table">
                <thead>
                    <tr>
                    <th scope="col">#</th>
                    <!--<th scope="col">Salesforce ID</th>-->
                    <th scope="col">Name</th>
                    <th scope="col">Priority</th>
                    <th scope="col">TAM</th>
                    <th scope="col">Zendesk ID</th>
                    <th scope="col">Zendesk Name</th>
                    <th scope="col">Action</th>
                    </tr>
                </thead>
                <tbody>

<?php

        /*
        * 2 - LIST ALREADY SYNCHED ORGANIZATIONS
        */

        /*
         * PREPARE CHUNKS OF 100
         */

        $AllQueries = array_chunk($allSFIDs, 40, true);

        /*
        * POST TO ZENDESK JSON DATA
        */

        foreach($AllQueries as $Query) {

            $options = array(
                    CURLOPT_URL => $resource."organizations/show_many.json?external_ids=".implode(',', $Query),
                    CURLOPT_USERPWD => $username."/token:$token",
                    CURLOPT_RETURNTRANSFER =>true,
                    CURLOPT_ENCODING => "",
                    CURLOPT_MAXREDIRS => 10,
                    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                    CURLOPT_CUSTOMREQUEST => "GET",
            );
            require("curl.Zendesk.inc.php");
        
            $result = json_decode($result);

            if($result->count) {
                foreach($result->organizations as $organization) {
                    $SFID = $organization->external_id;
                    if($SFID && isset($AllOrganizations[$SFID])) {
                        $UpdateOrganization[$SFID] = $AllOrganizations[$SFID];
                        $UpdateOrganization[$SFID]->ZID = $organization->id;

                        if($organization->name != $AllOrganizations[$SFID]->name || $organization->organization_fields->vip_merchant != 'cat'.$AllOrganizations[$SFID]->priority || (isset($AllOrganizations[$SFID]->alias) && array_search('bits-'.$AllOrganizations[$SFID]->alias, $organization->tags) === false)) {
                            $UpdateOrganization[$SFID]->need_refresh = 1;
                        }
                        else {
                            $UpdateOrganization[$SFID]->need_refresh = 0;
                        }

                        unset($AllOrganizations[$SFID]);
                    }
                }
            }
        }
        
       /*
        * 3 - SEARCH ORGANIZATIONS WITH SAME NAME
        */

        $row = 1;
        foreach($AllOrganizations as $SFID => $organization) if($organization->name && strlen($organization->name) > 3) { // && $row < 3

            $queryParameters = array();
            $url = $resource."organizations/autocomplete.json?name=".urlencode($organization->name);

            $filecache = "./cache/".md5($organization->name).".cache.json";

            if(!file_exists($filecache) || (file_exists($filecache) && (time() - filectime($filecache)) > 604800)) {
                $options = array(
                        CURLOPT_URL => $url,
                        CURLOPT_USERPWD => $username."/token:$token",
                        CURLOPT_RETURNTRANSFER =>true,
                        CURLOPT_ENCODING => "",
                        CURLOPT_MAXREDIRS => 10,
                        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                        CURLOPT_CUSTOMREQUEST => "GET",
                );
                require("curl.Zendesk.inc.php");

                // Write result in cache
                $fp = fopen($filecache, 'wb') or die('no fopen');	
                fwrite($fp, $result);
                fclose($fp);
            }
            else {
                echo "<!-- used cache for $organization->name -->";
                $result = file_get_contents($filecache); //locally
            }
        
            $result = json_decode($result);
    
            if($result->count) {
                $zendesk = $result->organizations[0];
            }
            else {
                $zendesk = new stdClass();
                $zendesk->id = $zendesk->name = '';
            }
?>

            <tr data-sfid='<?=$SFID?>'>
                <td scope="row"><?=$row?></td>
                <td><a href="https://hipay.lightning.force.com/one/one.app#/sObject/<?=$organization->SFID?>/view" target="_blank"><?=$organization->name?></a><input type="hidden" name="Name[<?=$SFID?>]" value="<?=$organization->name?>" /></td>
                <td><?=$organization->priority?><input type="hidden" name="Priority[<?=$SFID?>]" value="<?=$organization->priority?>" /></td>
                <td><?php if(isset($organization->tam)) { ?><span data-toggle="tooltip" title="<?=$organization->tam?>"><?=strtoupper($organization->alias)?></span><input type="hidden" name="Tam[<?=$SFID?>]" value="<?=$organization->alias?>" /><?php } ?></td>
                <td><input style="width:120px;" type="text" id="ZID_<?=$SFID?>" name="ZID[<?=$SFID?>]" value="<?=$zendesk->id?>" readonly="readonly" /></td>
                <td><input style="width:280px;"  type="text" class="autocomplete" name="ZName[<?=$SFID?>]" value="<?=$zendesk->name?>" /></td>
                <td><a href="javascript:void(0);" class="createOrganization" data-sfid='<?=$SFID?>' data-name='<?=urlencode($organization->name)?>' data-priority='<?=$organization->priority?>'<?php if(isset($organization->tam)) { ?> data-tam='<?=$organization->alias?>'<?php } ?>>create</a></td>
            </tr>

<?php
        $row++;
    }
?>
                </tbody>
                </table>

                <div class="row">
                    <b>Update mode:</b>
                    <label for ="batchUpdate1" class="radio-inline"><input type="radio" id="batchUpdate1" name="batchUpdate" value="1" checked="checked" /> Batch</label>
                    <label for ="batchUpdate0" class="radio-inline"><input type="radio" id="batchUpdate0" name="batchUpdate" value="0" /> Invidual <i>(for debug only)</i></label>
                </div>
                <div class="row">
                    <input type="hidden" name="action" value="update" />
                    <button type="button" class="btn btn-success submit"><span class="glyphicon glyphicon-retweet"></span> Start Synchronization</button>
                </div>

            <h2>Already synced Organisations</h2>
<?php
            if(is_array($UpdateOrganization)) {
?>
                <div class="well well-sm"><?=count($UpdateOrganization)?> organizations synchronized. Stared lines have an update pending. <b>Click on a line to remove sync</b> between Salesforce and Zendesk.</div>
                    <ul id="ExistingZID">
<?php
                foreach($UpdateOrganization as $SFID => $organization) {
?>
                    <li data-ZID="<?=$organization->ZID?>"><a href="javascript:void(0);" class="removeSync <?php if($organization->need_refresh) { echo 'text-danger'; } ?>" data-ZID="<?=$organization->ZID?>">
<?php
                    echo $organization->name;
                    echo " ($organization->priority)";

                    if($organization->need_refresh) {
?>
                        <b>(need update)</b>
                        <input type="hidden" name="Name[<?=$SFID?>]" value="<?=$organization->name?>" />
                        <input type="hidden" name="Priority[<?=$SFID?>]" value="<?=$organization->priority?>" />
                        <input type="hidden" name="Tam[<?=$SFID?>]" value="<?=$organization->alias?>" />
                        <input type="hidden" name="ZID[<?=$SFID?>]" value="<?=$organization->ZID?>" />
<?php
                    }
?>
                    </a></li>
<?php
                }
?>
                    </ul>
<?php
            }
            else {
?>
            <div class="alert alert-danger" role="alert">
            <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
            <span class="sr-only">Error:</span> There is no account synchronized between Salesforce and Zendesk. Please check if it is normal.
            </div>
<?php
            }
?>
                      </form>
<?php
} 
?>

        </div>
        
    </body>
</html>