<?php
/**
 * Marketplace - Component Marketplace 
 * ******************************************************************
 *
 * PHP version 7.0
 *
 * @category   Component
 * @package    Joomla
 * @author     WebKul software private limited <support@webkul.com>
 * @copyright  2010 WebKul software private limited
 * @license    http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @version    GIT:5.2
 * @filesource http://store.webkul.com
 * @link       Technical Support:  webkul.uvdesk.com
 * ******************************************************************
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
?>
<script>
jQuery(document).ready(function () {
    var hi = jQuery('.wk_info_div_main').height();
    jQuery('.wrapall').css({
        'height': hi
    });
    jQuery('.wk_imgdiv').css({
        'height': hi
    });
    var showChar = 100;
    var ellipsestext = '...';
    var moretext = 'Show more >';
    var lesstext = 'Show less';
    var showChar1 = 100;
    var ellipsestext1 = '...';
    var moretext1 = 'Show more >';
    var lesstext1 = 'Show less';
    jQuery('.more').each(function () {
        var ha = jQuery(this).text();
        // ha = jQuery(content).text();
        if (ha.length > showChar) {
            var c = ha.substr(0, showChar);
            var h = ha.substr(showChar, ha.length);
            var html = '<span class="txtorg">' + c + '</span><span class="moreellipses">' + ellipsestext + '&nbsp;</span><span class="morecontent"><span>' + h + '</span>&nbsp;&nbsp;<a href="javascript:void(0)" class="morelink">' + moretext + '</a></span>';
            jQuery(this).html(html);
        }
    });

    jQuery(".morelink").click(function () {
        if (jQuery(this).hasClass("less")) {
            jQuery(this).removeClass("less");
            jQuery(this).html(moretext);
            var b = jQuery('.wk_info_div_main').height();
            jQuery('.wrapall').css({
                'height': b
            });
            jQuery('.wk_imgdiv').css({
                'height': b
            });
        } else {
            jQuery(this).addClass("less");
            jQuery(this).html(lesstext);
        }

        jQuery(this).parent().prev().toggle();
        jQuery(this).prev().toggle();
        var b = jQuery('.wk_info_div_main').height();
        jQuery('.wrapall').css({
            'height': b
        });
        jQuery('.wk_imgdiv').css({
            'height': b
        });
        return false;
    });
    jQuery('.more1').each(function () {
        var h2 = jQuery(this).html();
        // var h2 = jQuery(content1).text();
        if (h2.length > showChar1) {
            var c1 = h2.substr(0, showChar1);
            var h1 = h2.substr(showChar1, h2.length - showChar1);
            var html1 = c1 + '<span class="moreellipses1">' +
                ellipsestext1 +
                '&nbsp;</span><span class="morecontent1"><span>' +
                h1 +
                '</span>&nbsp;&nbsp;<a href="javascript:void(0)" class="morelink1">' +
                moretext1 + '</a></span>';
            jQuery(this).html(html1);
        }
    });
    jQuery(".morelink1").click(function () {
        if (jQuery(this).hasClass("less1")) {
            jQuery(this).removeClass("less1");
            jQuery(this).html(moretext1);
            var a = jQuery('.wk_info_div_main').height();
            jQuery('.wrapall').css({
                'height': a
            });
            jQuery('.wk_imgdiv').css({
                'height': a
            });
        } else {
            jQuery(this).addClass("less1");
            jQuery(this).html(lesstext1);
        }
        jQuery(this).parent().prev().toggle();
        jQuery(this).prev().toggle();
        var a = jQuery('.wk_info_div_main').height();
        jQuery('.wrapall').css({
            'height': a
        });
        jQuery('.wk_imgdiv').css({
            'height': a
        });
        return false;
    });
});
</script>
<?php
$doc=JFactory::getDocument();
$app=JFactory::getApplication()->input;
$seller_id=$app->get('seller_id', 0, "INT");
$model=$this->getModel('marketplace');
$info=$model->getSellerInfo($seller_id);

if (!class_exists('MarketplaceHelper')) {
    include JPATH_ADMINISTRATOR.DIRECTORY_SEPARATOR.'components'.
    DIRECTORY_SEPARATOR.'com_marketplace'.DIRECTORY_SEPARATOR.
    'helpers'.DIRECTORY_SEPARATOR.'marketplace.php';
}
$mpHelp=new MarketplaceHelper();
$modProfFE=$mpHelp->getMarketModelS('Profile');
?>
<form action="<?php echo JRoute::_('index.php?option=com_marketplace&view=marketplace&layout=edit_seller'); ?>" method="post" name="adminForm" id="adminForm">
    <?php if (!empty($this->sidebar)) : ?>
    <div id="j-sidebar-container">
        <?php
        echo $this->sidebar;
        ?>
    </div>
    <div id="j-main-container" class="span10">
        <?php else : ?>
        <div id="j-main-container">
        <?php endif; ?>
            <div class="wrapall">
                <div class="wk_imgdiv">
                    <div class="imagewrapper">
                        <div class="imagediv">
                        <?php 
                        if (isset($info->companylogo)
                            && !strlen($info->companylogo)
                        ) {
                            if (strlen($info->gender)) {
                                if ($info->gender=="1") {
                                    $src=JURI::root().'administrator/components/com_marketplace/assets/images/dummy-male-icon.png';
                                } elseif ($info->gender=="2") {
                                    $src=JURI::root().'administrator/components/com_marketplace/assets/images/dummy-female-icon.png';
                                }
                            } else {
                                $src=JURI::root().'administrator/components/com_marketplace/assets/images/no-image.png';
                            }
                        } elseif (isset($info->companylogo)
                            && strlen($info->companylogo)
                        ) {
                            $src=JURI::root().$info->companylogo;
                        }
                        ?>
                        <img class="img" src="<?php echo $src ?>" alt="image" />
                        </div>
                        <div class="sellername">
                            <p><strong>
                            <?php
                            if (isset($info->screenname)
                                && strlen($info->screenname)
                            ) {
                                    echo $info->screenname;
                            }?></strong></p>
                            <p>
                            <?php
                            if (isset($info->email)
                                && strlen($info->email)
                            ) {
                                echo $info->email;
                            }
                            ?></p>
                        </div>
                    </div>
                </div>
                <div class="wk_info_div_main">
                    <table cellpadding="7" cellspacing="5" width="100%" height="inharit">
                        <col width="100px" />
                        <col width="300px" />
                        <tr >
                            <td  ><span class="heading"><?php echo JText::_('COMPANY_BANNER');?></span></td>
                            <td>
                            <?php
                            if (isset($info->companybanner)&& strlen($info->companybanner)) {
                            ?>
                            <img class="banner" src="<?php echo JURI::root().$info->companybanner; ?>"/></td>
                            <?php
                            } else {
                                echo "N/A";
                            }
                            ?>
                        </tr>
                        <tr>
                            <td> <span class="heading"><?php echo JText::_('SHOP_NAME');?></span></td>
                            <td>
                                <?php
                                if (isset($info->companyname)
                                    && strlen($info->companyname)
                                ) {
                                ?>
                                <span><?php echo $info->companyname ?></span>
                                <?php
                                } else {
                                    echo "N/A";
                                }
                                ?>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span class="heading"><?php echo JText::_('GENDER');?></span>
                            </td>
                            <td>
                                <?php
                                if (isset($info->gender)
                                    && strlen($info->gender)
                                ) {
                                ?>
                                <span><?php
                                if ($info->gender==1) {
                                    echo JText::_("G_MALE");
                                } else {
                                    echo JText::_("G_FEMALE");
                                }
                                ?></span>
                                <?php
                                } else {
                                    echo "N/A";
                                }
                                ?>
                            </td>
                        </tr>
                        <tr>
                            <td  ><span class="heading"><?php echo JText::_('COM_MARKETPLACE_PHONE1');?></span></td>
                            <td>
                                <?php
                                if (strlen($info->phone)) {
                                ?>
                                <span><?php echo $info->phone;?></span>
                                <?php
                                } else {
                                    echo "N/A";
                                }
                                ?>
                            </td>
                        </tr>
                            
                        <tr>
                            <td>
                                <span class="heading"><?php echo JText::_('COMPANY_DESCRIPTION');?></span>
                            </td>
                            <td>
                            <?php
                                if (isset($info->companydescription)
                                    && strlen($info->companydescription)
                                ) {
                                ?>
                                <span class="more"> <?php echo html_entity_decode($info->companydescription);?></span>
                                <?php
                                } else {
                                    echo "N/A";
                                }
                            ?>
                                    
                            </td>
                        </tr>
                                <tr>
                                    <td>
                                        <span class="heading"><?php echo JText::_('HTML_DESCRIPTION');?></span>
                                    </td>
                                    <td>
                                        <?php
                                        if (isset($info->descriptioninhtml)
                                            && strlen($info->descriptioninhtml)
                                        ) {
                                        ?>
                                        <span class="more1"><?php
                                        echo html_entity_decode($info->descriptioninhtml);
                                        ?></span>
                                        <?php
                                        } else {
                                            echo "N/A";
                                        }
                                        ?>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <span class="heading"><?php echo JText::_('PAYMENT_MODE');?></span>
                                    </td>
                                    <td>
                                        <?php
                                        if (isset($info->payment_mode)
                                            && strlen($info->payment_mode)
                                        ) {
                                        ?>
                                        <span><?php
                                        $pay_mode=explode(",", $info->payment_mode);
                                        foreach ($pay_mode as $key => $value) {
                                            if ($value == "") {
                                                unset($pay_mode[$key]);
                                            }
                                        }
                                        
                                        $pay_meth=$modProfFE->getPaymentInfo();
                                        $pay_name_disp="";$i=0;
                                        foreach ($pay_meth as $val_pay) {
                                            if (in_array($val_pay->payment_element."-".$val_pay->virtuemart_paymentmethod_id, $pay_mode) || in_array($val_pay->payment_element, $pay_mode)) {
                                                $pay_name_disp.= $val_pay->payment_name;
                                            }
                                            if($i < count($pay_mode)-1)
                                                $pay_name_disp.=",";
                                            $i++;
                                        }
                                        echo $pay_name_disp;
                                        ?></span>
                                        <?php
                                        } else {
                                            echo "N/A";
                                        }
                                        ?>
                                        
                                    </td>
                                </tr>
                            </table>
                            <div>
                                
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <input type="hidden" name="seller_id" value="<?php echo $info->seller_id;?>">
            <input type="hidden" name="task" value="">
        </form>
<?php
$style='
.wk_info_div_main {
    display: inline-block;
    float: right;
    width: 78%;
    height: auto;
}

.wk_imgdiv {
    display: inline-block;
    width: 20%;
    height: 464px;
    ;
    border-right: 2px solid #797C7D;
}

.wrapall {
    font-size: 15px;
    color: #333333;
    padding-bottom: 100px;
    padding-top: 20px;
    box-shadow: 1px 7px 18px 2px rgba(0, 0, 0, 0.2);
}

.imagewrapper {
    text-align: center;
    margin-top: 60px;
}

.imagediv {
    text-align: center;
    height: 75px;
    width: 75px;
    margin: 0 auto;
}

.img {
    border-radius: 50%;
    height: 75px;
    width: 75px;
    outline: 5px solid #FFFFFF;
    border: 2px solid #888881;
}

.banner {
    height: 120px;
}

.bannerwrapper {
    margin: 0px;
    padding: 0px;
}

.heading {
    font-weight: 900;
}

.wrapall td {
    width: 100%;
    min-width: 0;
    white-space: nowrap;
    width: 400px;
}

table {
    table-layout: fixed;
}

.morecontent span {
    display: none;
}

.morelink {
    display: inline-block;
}

.morecontent {
    height: inherit;
    width: inherit;
}

td {
    white-space: normal!important;
}

.morecontent1 span {
    display: none;
}

.morelink1 {
    display: inline-block;
}

.morecontent1 {
    height: inherit;
    width: inherit;
}

.sellername {
    margin-top: 20px;
}
.sellername p {
	word-break: break-all;
}
.more {
    word-wrap: break-word;
}

.more1 {
    word-wrap: break-word;
}
';
$doc->addStyleDeclaration($style);