<?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
 * ******************************************************************
 */
defined('_JEXEC') or die();
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
jimport('joomla.html.editor');
JHtml::_('bootstrap.tooltip');
jimport('joomla.form.form');
// ini_set('display_errors', 'Off');
JHtml::_('behavior.formvalidation');
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('behavior.framework', true);
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
$document = JFactory::getDocument();
$style = '
.qcontrols {
  display: block;
  float: left;
  margin-left: 30px;
}

.wbtn {
  margin-right: 70px!important;
}

.modal-header {
  color: #fff;
  padding: 15px;
  text-align: center;
  border-bottom: 1px solid #eee;
  background-color: #428bca;
  -webkit-border-top-left-radius: 5px;
  -webkit-border-top-right-radius: 5px;
  -moz-border-radius-topleft: 5px;
  -moz-border-radius-topright: 5px;
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
  margin: 0 4px 10px 0;
}

#jform_subject {
  width: 97%;
}

.default {
  min-width: 200px;
}

#jform_selectoption {
  min-width: 200px;
}

.form-horizontal .control-label {
  font-weight: bold;
  float: left;
}

.control-group,
.btn-assign {
  margin-top: 30px;
}

#jform_seller-lbl,
#jform_selectoption-lbl {
  font-weight: bold;
}

#jform_seller_chzn {
  min-width: 190px;
}
';
$document->addStyleDeclaration($style);
$jinput=JFactory::getApplication()->input;
$pid='';
@$pids=unserialize(urldecode($jinput->get('wk_pid', null, '')));
$total=count($pids);
?>
<form action="<?php
    echo JRoute::_(
        'index.php?option=com_marketplace&tmpl=component&view=ad'.
        'minproducts&layout=assigntoseller',
        false
    );
    ?>" method="post" name="adminForm" id="item-form" class="form-validate form-horizontal">
   <div class="queshead">
      <h3 class="modal-header" ><?php
        echo JText::_('ASSIGN_PRODUCT_TO_SELLER');
        ?></h3>
   </div>
   <div class="assigntoseller">
         <div class="control-group">
            <div class="control-label" >
        <?php
        echo $this->form->getLabel('seller'); 
        ?>
            </div>
            <div class="qcontrols" >
                <?php
                echo $this->form->getInput('seller');
                ?>
            </div>
         </div>
         <div class="control-group">
            <div class="control-label">
                <?php echo $this->form->getLabel('selectoption'); ?>
            </div>
            <div class="qcontrols">
                <?php echo $this->form->getInput('selectoption'); ?>
            </div>
         </div> 
         <div class="control-group">
            <div class="control-label">
                
            </div>
            <div class="qcontrols">
                <button class="btn btn-primary assign">Assign Product</button>
                <div class="btn btn-danger cancel" >Cancel</div>
            </div>
         </div>          
   </div>
  <div class="btn-assign"> 
    <?php
    echo $this->form->getInput('getproductid');
    ?>
<script type="text/javascript">
function assignPro() {
    Joomla.submitbutton("adminproducts.assignProductToSeller");
}
jQuery(window).on('load', function () {
    jQuery('form').on('click', '.assign', function (e) {
        e.preventDefault();
        if (!(jQuery("#jform_seller").val().trim() === "")
            && !isNaN(jQuery("#jform_seller").val())) {
            jQuery("form").submit();
        } else {
            jQuery("#jform_seller").next().css({
                "border": "1px solid red"
            });
            jQuery("#jform_seller-lbl").css({
                "color": "red"
            });
        }
    });
    jQuery("form").on('click', '.cancel', function (e) {
        e.preventDefault();
        window.parent.location.href = "<?php
        echo JURI::root();
        ?>" + 'administrator/index.php?option=com_marketplace&view=adminproducts';
    });
});
</script>
</div>
<input type="hidden" name="product_id" value="<?php
    echo implode(',', $pids);
    ?>"/>
   <input type="hidden" name="task" value="adminproducts.assignProductToSeller" />
   <input type="hidden" name="boxchecked" value="" />
    <?php echo JHtml::_('form.token'); ?>
</form>
