<?php
/**
 * Created by PhpStorm.
 * User: jasmanto
 * Date: 17/09/2018
 * Time: 19.35
 */


switch ($mode) {

    case "view":
        // matiHere(__LINE__);
        $strContent = "";
        $strContent .= "
            <style>
                .list-group-item {
                    padding: 5px 7.5px;
                }
                .list-group {
                    padding-left: 7px;
                    margin-bottom: 0px;
                }
            </style>
        ";
        if (isset($items)) {
            if (is_array($items) && (sizeof($items) > 0)) {
                $strContent .= "<ul class='list-group text-left' style='line-height:28px;min-width: 255px;'>";
                foreach ($items as $iSpec) {
                    $strContent .= "<li class='list-group-item'>";
                    if(isset($iSpec['minValue'])){
                        $defaultValue = $iSpec['minValue'];
                        $defVal = "&minValue=$defaultValue";
                    }
                    else{
                        $defVal = "";
                    }

                    if(isset($iSpec['usedMaps']) && $iSpec['usedMaps']==true && $iSpec['map_check']==1 && $iSpec['lat']<>0 && $iSpec['lng']<>0 && $iSpec['isMobile'] ){

                        $label_f = strlen($iSpec['label'])>15 ? substr($iSpec['label'],0,12)."...." : $iSpec['label'];

                        $arrInc = base64_encode(json_encode($iSpec));
                        $actionTarget = "top.BootstrapDialog.show({
                                            title: 'VALIDASI LOKASI SELLER<div class=\'text-bold text-left text-uppercase text-danger\'>($label_f)</div>',
                                            message: " . 'top.$' . "('<div></div>').load('$iSpec[urlLokasi]?id=$iSpec[id]$defVal&encval=$arrInc'),
                                            draggable:false,
                                            animate: false,
                                            size:top.BootstrapDialog.SIZE_WIDE,
                                            type:top.BootstrapDialog.TYPE_DEFAULT,
                                            closable:true,
                                            onshow: function(dialogRef){

                                            },
                                            onshown: function(dialogRef){

                                            },
                                            onhide: function(dialogRef){

                                            },
                                            onhidden: function(dialogRef){

                                            }
                                        });";

                        $strContent .= "<div onclick=\"$actionTarget\" class='text-capitalize text-link'>";

                        $strContent .= "<span class='text-left fa-2x'>" . $label_f . "</span>";
                        $strContent .= "<span class='pull-right fa-stack'>
                                            <i class='fa fa-map-marker text-green fa-stack-1x'></i>
                                            <i class='fa fa-ban text-danger fa-stack-2x'></i>
                                        </span>";
                        $strContent .= "<div style='line-height:10px;font-family: monospace;margin-bottom:3px;'><span class='small text-green text-bold'><i class='fa fa-map-marker text-red'></i> ".substr($iSpec['alamat'],0,30)."...</span></div>";
                        $strContent .= "</div>";
                    }
                    else{
                        $strContent .= " <a class='text-capitalize' href='javascript:void(0);' stylea='font-size:0.9em;' onclick=\"document.getElementById('result').src='$iSpec[target]?id=$iSpec[id]$defVal'\">";
                        $strContent .= $iSpec['label'];
                        if (isset($iSpec['label_view'])) {
                            if (strlen($iSpec['label_view']) > 0) {
                                $strContent .= "<span class='text-red'><small>(" . $iSpec['label_view'] . ")</small></span>";
                            }
                        }
                        $strContent .= "</a>";
                    }

                    $strContent .= "</li class='list-group-item'>";
                }
                $strContent .= "<li style='line-height:13px;background:#e5e5c5;' class='list-group-item text-center text-muted bg-warning' style='background:#e5e5c5;'><small>... type more keywords<br>for more specific results ...</small>";
                $strContent .= "</li>";
                $strContent .= "</ul class='list-group'>";
                $strContent .= "</ul class='list-group text-left'>";
            }
            else{
                $strContent .= "<div class='form-control text-center'>";
                $strContent .= "- no matched item -";
                $strContent .= "</div>";
            }
        }
        else{
            $strContent .= "<div class='form-control text-center'>";
            $strContent .= "- no matched item -";
            $strContent .= "</div>";
        }
        echo $strContent;

        // echo "<script>";
        // echo "  if(top.document.getElementById('shopping_cart')){";
        // echo "  top.$('#shopping_cart').load('" . base_url() . $this->modul . "/_shoppingCart/viewCart/" . $this->jenisTr . "?selID=$id');";
        // echo "  }";
        // echo "</script>";
        break;
}