<?php
    $cs = Yii::app()->getClientScript();
    $baseUrl = Yii::app()->baseUrl;
    $cs->registerScript("checkDiscontinuing", "function checkDiscontinuing(status){
        if(status  =='D')
        {
           $('.li_discontinue').show();

        }else{

            $('.li_discontinue').hide();

        }
    }", CClientScript::POS_HEAD);
    $cs->registerScript("checkSuccessor", "function checkSuccessor(status){
        if(status  =='Y')
        {
           $('.li_successor').show();

        }else{
            $('.li_successor').hide();

        }
    }", CClientScript::POS_HEAD);
    $cs->registerScript("getSuccessorModel", "function getSuccessorModel(id){
        if(id>0)
        {
           jQuery.ajax({
                    'type': 'post',
                    'dataType': 'json',
                    'url': '" . Yii::app()->createUrl('Inventory/GetSuccessorModel') . "',
                    'data': {'id':id,'YII_CSRF_TOKEN':'" . Yii::app()->request->csrfToken ." '}  ,
                    'cache': false,
                    'success': function(data) {
                        if(data.status=='success'){
                            $('#successor_model').val(data.model_name);
                            $('#successor_model').addClass('filled');
                        }
                    },
           });
           
        }
    }", CClientScript::POS_HEAD);
?>    

<ul class="clearfix form-ul material">

    <?php echo $form->hiddenField($model, 'id'); ?>
    <span>GMC</span>
    <hr style="border: 1px solid black;">
     <li class="col-sm-3">

        <?php echo $form->textField($model, 'gmc_code', array('data-label' => 'GMC Code <span style="color:red">*</span>', 'data-validation' => 'required')); ?>

    </li> 
    <li class="col-sm-3">

        <?php echo $form->dropDownList($model, 'product_category_id',  MasProductCategory::getProductCategory(), array('data-label' => 'Product Category <span style="color:red">*</span>', 'data-validation' => 'required','empty'=>'Select','data-search'=>'true')); ?>

    </li> 

   

    <li class="col-sm-3">

        <?php echo $form->textField($model, 'model_no', array('data-label' => 'Model No <span style="color:red">*</span>', 'data-validation' => 'required')); ?>

    </li> 

    <li class="col-sm-3">

        <?php echo $form->textField($model, 'base_code', array('data-label' => 'Base Code <span style="color:red">*</span>', 'data-validation' => 'required')); ?>

    </li> 
    <li class="col-sm-3">
        <?php echo $form->textField($model, 'base_category_code', array('data-label' => 'Base Category Code<span style="color:red">*</span>', 'data-validation' => 'required')); ?>
    </li> 
    <li class="col-sm-3">
        <?php echo $form->textField($model, 'base_category_name', array('data-label' => 'Base Category Name<span style="color:red">*</span>', 'data-validation' => 'required')); ?>
    </li> 
    <li class="col-sm-3">
        <?php echo $form->textArea($model, 'description', array('data-label' => 'Description<span style="color:red">*</span>', 'data-validation' => 'required')); ?>
    </li> 
    <li class="col-sm-3">
        <?php echo $form->textField($model, 'origin', array('data-label' => 'Origin<span style="color:red">*</span>', 'data-validation' => 'required')); ?>
    </li> 
    <li class="col-sm-3">
    <?php echo $form->dropdownList($model, 'show_in_order', array('Y' => 'Yes', 'N' => 'No'), array('data-label' => 'Show In Order'));  ?>
    </li>
    <li class="col-sm-3">
        <?php echo $form->dropDownList($model, 'category_type_id',MasCategoryType::getCategoryType(), array('data-label' => 'ABC Category Type(Current FY)<span style="color:red">*</span>', 'data-validation' => 'required','empty'=>'-Select-')); ?>
    </li> 
    <li class="col-sm-3">
        <?php echo $form->dropDownList($model, 'future_category_type_id',MasCategoryType::getCategoryType(), array('data-label' => 'ABC Category Type(Next FY)<span style="color:red">*</span>', 'data-validation' => 'required','empty'=>'-Select-')); ?>
    </li>
    
    <li class="col-sm-3">
        <?php echo $form->textField($model, 'gmc_sort_order', array('data-label' => 'Sort Order(Current FY) <span style="color:red">*</span>', 'data-validation' => 'required')); ?>
    </li> 
    <li class="col-sm-3">
        <?php echo $form->textField($model, 'future_gmc_sort_order', array('data-label' => 'Sort Order(Next FY) <span style="color:red">*</span>', 'data-validation' => 'required')); ?>
    </li> 
    
    <li class="col-sm-3">

    <?php echo $form->dropdownList($model, 'have_successor', array( 'N' => 'No','Y' => 'Yes'), array('data-label' => 'Is Successor','onchange'=>'checkSuccessor(this.value)')); 
    $style_li_successor ='';

     if($model->have_successor=='N'){

         $style_li_successor ='style="display:none;"';

     } ?>

    </li>
    <li class="col-sm-3 li_successor"  <?php echo $style_li_successor;?> >

        <?php 
        $modInv = new Inventory();
        $modInv = $modInv->getActiveGMCs();
        echo $form->dropDownList($model, 'successor_id',$modInv, array('data-label' => 'Successor <span style="color:red">*</span>','empty'=>'-Select-','data-search'=>'true','onchange'=>'getSuccessorModel(this.value);')); ?>

    </li>
    <li class="col-sm-3 li_successor"  <?php echo $style_li_successor;?> >

        <?php 
        $successormodel='';
        if($model->successor_id>0){
            $successormodel=$model->successor_det->model_no;
        }
        echo CHtml::textField('successor_model', $successormodel, array('data-label' => 'Successor Model <span style="color:red">*</span>')); ?>

    </li>
    <li class="col-sm-3 li_successor"  <?php echo $style_li_successor;?> >

        <?php echo $form->dropDownList($model, 'successor_from_month', Order::getmonths(), array('data-label' => 'Successor From Month <span style="color:red">*</span>','empty'=>'-Select-')); ?>

    </li>
    <li class="col-sm-3 li_successor"  <?php echo $style_li_successor;?> >

        <?php echo $form->dropDownList($model, 'successor_from_year', Order::getyear(), array('data-label' => 'Successor From Year <span style="color:red">*</span>','empty'=>'-Select-')); ?>

    </li>
    
    <li class="col-sm-3">
        <?php echo $form->textField($model, 'length', array('data-label' => 'Length <span style="color:red">*</span>', 'data-validation' => 'required')); ?>
    </li> 
    <li class="col-sm-3">
        <?php echo $form->textField($model, 'width', array('data-label' => 'Width <span style="color:red">*</span>', 'data-validation' => 'required')); ?>
    </li>
    <li class="col-sm-3">
        <?php echo $form->textField($model, 'height', array('data-label' => 'Height <span style="color:red">*</span>', 'data-validation' => 'required')); ?>
    </li>
    <li class="col-sm-3">

        <?php echo $form->textField($model, 'cbm', array('data-label' => 'CBM <span style="color:red">*</span>', 'data-validation' => 'required')); ?>

    </li> 
    <li class="col-sm-3">
        <?php echo $form->textField($model, 'weight', array('data-label' => 'Weight <span style="color:red">*</span>', 'data-validation' => 'required')); ?>
    </li>
    <li class="col-sm-3">
        <?php echo $form->textField($model, 'barcode', array('data-label' => 'Barcode <span style="color:red">*</span>', 'data-validation' => 'required')); ?>
    </li>
    <!-----gmc_colour,sub_category,spiral_sub_category,psi_series,order_lot_to_ycj,cable_modeification,other_1,other_2,other_3,other_4---------------------------------------------------------------------->   
    <li class="col-sm-3">
        <?php echo $form->textField($model, 'gmc_colour', array('data-label' => 'Colour')); ?>
    </li>
    <li class="col-sm-3">
        <?php echo $form->textField($model, 'sub_category', array('data-label' => 'Sub Category <span style="color:red">*</span>', 'data-validation' => 'required')); ?>
    </li>
    <li class="col-sm-3">
        <?php echo $form->textField($model, 'spiral_sub_category', array('data-label' => 'Series Qty wise ')); ?>
    </li>
    <li class="col-sm-3">
        <?php echo $form->textField($model, 'psi_series', array('data-label' => 'Series Amt wise ')); /*PSI Series*/?>
    </li>
    <li class="col-sm-3">
        <?php echo $form->textField($model, 'order_lot_to_ycj', array('data-label' => 'Order Lot to YCJ ')); ?>
    </li>
    <li class="col-sm-3">
        <?php echo $form->textField($model, 'cable_modeification', array('data-label' => 'Cable Modification')); ?>
    </li>
    <li class="col-sm-3">
        <?php echo $form->textField($model, 'other_1', array('data-label' => 'Other 1')); ?>
    </li>
    <li class="col-sm-3">
        <?php echo $form->textField($model, 'other_2', array('data-label' => 'Other 2')); ?>
    </li>
    <li class="col-sm-3">
        <?php echo $form->textField($model, 'other_3', array('data-label' => 'Other 3')); ?>
    </li>
    <li class="col-sm-3">
        <?php echo $form->textField($model, 'other_4', array('data-label' => 'Other 4')); ?>
    </li>
    <li class="col-sm-3">

    <?php echo $form->dropDownList($model, 'inventory_type',array('N'=>'Normal','S'=>'Strategic'), array('data-label' => 'Inventory Report Type<span style="color:red">*</span>','empty'=>'-Select-')); ?>

    </li>
    <li class="col-sm-3">

        <?php echo $form->dropdownList($model, 'is_active', array('Y' => 'Active', 'N' => 'Block', 'D' => 'Fully Discontinued'), array('data-label' => 'Status'));//,'onchange'=>'checkDiscontinuing(this.value)' ?>

        <?php echo $form->hiddenField($model, 'ymgf_fob', array('data-label' => 'YMGF FOB', 'data-validation' => 'required')); ?>

    </li>
    <li class="col-sm-3">
        <?php echo $form->dropdownList($model, 'is_confidential', array('Y' => 'Yes', 'N' => 'No'), array('data-label' => 'Is Confidential<span style="color:red">*</span>'));//,'onchange'=>'checkDiscontinuing(this.value)' ?>
    </li>
    <li class="col-sm-3">
       <?php echo $form->dropdownList($model, 'gmc_type', array('NI' => 'Normal Item', 'P' => 'Pair','K'=>'Kit'), array('data-label' => 'GMC Type'));?>
    </li>
    <?php 

    $style_li_discontinue ='';

     if($model->is_active!='D'){

         $style_li_discontinue ='style="display:none;"';

     }

    ?>

    <li class="col-sm-3 li_discontinue"  <?php echo $style_li_discontinue;?> >

        <?php echo $form->dropDownList($model, 'discontinuing_month', Order::getmonths(), array('data-label' => 'Discontinuing Month <span style="color:red">*</span>','empty'=>'-Select-')); ?>

    </li>

    <li class="col-sm-3 li_discontinue" <?php echo $style_li_discontinue;?>>

        <?php echo $form->dropDownList($model, 'discontinuing_year',Order::getyear(), array('data-label' => 'Discontinuing Year <span style="color:red">*</span>','empty'=>'-Select-')); ?>

    </li>
    <li class="col-sm-3">
        <?php echo $form->dropdownList($model, 'is_toplevel', array('Y' => 'Yes', 'N' => 'No'), array('data-label' => 'Top Level Model<span style="color:red">*</span>'));//,'onchange'=>'checkDiscontinuing(this.value)' ?>
    </li>

</ul>

        <hr style="border: 1px solid black;">

        <ul class="clearfix form-ul material">

	<h4 style="color:red;font-size:15px;padding-left:12px;">Make sure that Inventory, Goods in, Backlog, Unshipped are <b>not uploaded</b> if you are changing the Month Setting</h4>

	    <li class="col-sm-3">

                <?php echo $form->dropDownList($model, 'goods_in_month', Order::getmonths(), array('data-label' => 'Goods In start Month <span style="color:red">*</span>','empty'=>'-Select-')); ?>

            </li>

            <li class="col-sm-3">

                <?php echo $form->dropDownList($model, 'goods_in_year',Order::getyear(), array('data-label' => 'Goods In Start Year <span style="color:red">*</span>','empty'=>'-Select-')); ?>

            </li>

            <!--<li class="col-sm-4">

              <?php /*echo $form->dropdownList($model, 'supply_goodsin',Inventory::getmonth_type(),array('data-label'=>'Supply GoodsIn Type')); ?>

              <?php echo $form->error($model,'supply_goodsin'); */?>

		    </li>-->

            <li class="col-sm-3">

                <?php echo $form->dropDownList($model, 'goods_in_end_month', Order::getmonths(), array('data-label' => 'Goods In End Month <span style="color:red">*</span>','empty'=>'-Select-')); ?>

            </li>

            <li class="col-sm-3">

                <?php echo $form->dropDownList($model, 'goods_in_end_year',Order::getyear(), array('data-label' => 'Goods In End Year <span style="color:red">*</span>','empty'=>'-Select-')); ?>

            </li>

            <li class="col-sm-3">

                <?php echo $form->dropDownList($model, 'backlog_month', Order::getmonths(), array('data-label' => 'Backlog Start Month <span style="color:red">*</span>','empty'=>'-Select-')); ?>

            </li>

            <li class="col-sm-3">

                <?php echo $form->dropDownList($model, 'backlog_year',Order::getyear(), array('data-label' => 'Backlog Start Year <span style="color:red">*</span>','empty'=>'-Select-')); ?>

            </li>

            <!--<li class="col-sm-4">

              <?php /*echo $form->dropdownList($model, 'supply_backlog',Inventory::getmonth_type(),array('data-label'=>'Supply Backlog Type')); ?>

              <?php echo $form->error($model,'supply_backlog'); */?>

		    </li>-->

            <li class="col-sm-3">

                <?php echo $form->dropDownList($model, 'backlog_end_month', Order::getmonths(), array('data-label' => 'Backlog End Month <span style="color:red">*</span>','empty'=>'-Select-')); ?>

            </li>

            <li class="col-sm-3">

                <?php echo $form->dropDownList($model, 'backlog_end_year',Order::getyear(), array('data-label' => 'Backlog End Year <span style="color:red">*</span>','empty'=>'-Select-')); ?>

            </li>

            

           

        </ul>

        <hr style="border: 1px solid black;">

        <ul class="clearfix form-ul material">

            <li class="col-sm-3" >

                <?php echo $form->dropDownList($model, 'new_till_month', Order::getmonths(), array('data-label' => 'New Till Month <span style="color:red">*</span>','empty'=>'-Select-')); ?>

            </li>

            <li class="col-sm-3" >

                <?php echo $form->dropDownList($model, 'new_till_year',Order::getyear(), array('data-label' => 'New Till Year <span style="color:red">*</span>','empty'=>'-Select-')); ?>

            </li>

        </ul>