<div class="table-responsive">
        <table class="table table-hover table-bordered personal-task" id="price_details">        
            <tr>            
                <th width="4%">No</th>
                <th width="40%">Area</th>        
                <th width="20%">Price</th>
                <th width="30%">Effective From</th>        
                <!--<th class="">
                    <a class="btn btn-xs btn-theme" href="javascript:void(0);" onclick="addTableRow($('#price_details'));"><i class="fa fa-plus"></i></a>
                </th>  -->
            </tr>
            <?php
            $m=1;
            foreach ($modelDetails as $i => $each){?>
            
                <tr>                
                    <td><label><?php echo ($i + 1); ?></label>
                        <?php echo $form->hiddenField($each, "[" . $i . "]id"); ?>
                    </td>
                    <td>
                        <?php echo $form->dropDownList($each,  "[" . $i . "]region_id",MasRegion::getRegions(), array('class'=>'go','empty' => 'Select')); ?>
                    </td>
                    <td>
                        <?php echo $form->textField($each,  "[" . $i . "]price", array('class'=>'go','readonly'=>'true')); ?>
                    </td>
                    <td>
                        <?php 
                        $each->from_month=(int)date('m',strtotime($each['from_date']));
                        $each->from_year=(int)date('Y',strtotime($each['from_date']));
                        $arr_months=Order::getmonths(); 
                        echo $arr_months[$each->from_month];
                        echo $each->from_year; 
                        echo $form->hiddenField($each,  "[" . $i . "]from_date"); 
                        echo $form->hiddenField($each,  "[" . $i . "]to_date");
                        echo $form->hiddenField($each,  "[" . $i . "]from_month"); 
                        echo $form->hiddenField($each,  "[" . $i . "]from_year");?>
                    </td>
                    <!--<td class="text-center nw" width="1%">  
                        <?php //echo CHtml::link('<i class="fa fa-times"></i>', 'javascript:void(0);', array('class' => 'btn btn-xs btn-danger ', 'onclick' => 'removePriceTableRow($(\'#price_details\'),this,this.id)', 'title' => 'Remove this item','id' => 'pricedet_' . $i)); ?>
                    </td> -->   
                              
                </tr>        
            <?php 
            $m++;
                    
               
            } ?>    
        </table>
    </div>
    <?php    
    $cs = Yii::app()->getClientScript();
    $cs->registerScript("removePriceTableRow", " 
        function removePriceTableRow(jQtable, evt,field_id) {
            var arr_fields= field_id.split('_');
            var row_field=arr_fields[1];
            var id=$('#InventoryPrice_'+row_field+'_id').val();
            var num_rows = jQtable.find('tr:gt(0)').length;
            if (num_rows > 1) {
                var tr = $(evt).parent().parent();
                if (isRowEmpty(tr)) {
                    if(id>0){
                        jQuery.ajax({
                            'type': 'post',
                            'dataType': 'json',
                            'url': '" . Yii::app()->createUrl('inventory/DeletePriceDetails') . "',
                            'data': {'id':id}  ,
                            'cache': false,
                            'success': function(data) {
                                if(data.status=='success'){
                                    $(evt).parents('tr').remove();
                                    var i=0;
                                    jQtable.find('tr:gt(0)').each(function() { 
                                        $(this).find('input,textarea,.errorMessage').each(function()
                                        {
                                            old_id   =   $(this).attr('id');
                                            new_id   =   old_id.replace(/\d+/,i);
                                            $(this).attr('id',new_id);
                                            old_name =   $(this).attr('name');
                                            if(old_name!==undefined) {
                                                new_name =   old_name.replace(/\d+/,i);
                                                $(this).attr('name',new_name);
                                            } 
                                        });
                                        $(this).find('td:first label').html(++i); 
                                    });
                                         t8.success('Price Details Deleted','');
                                }else{
                                  t8.error('Deletion Not Possible, History Exist','error');
                                }
                            }
                        });
                    }else{
                        $(evt).parents('tr').remove();
                        var i = 0;
                        jQtable.find('tr:gt(0)').each(function () {
                            $(this).find('input,select,textarea,.errorMessage').each(function () {
                                old_id = $(this).attr('id');
                                new_id = old_id.replace(/\d+/, i);
                                $(this).attr('id', new_id);
                                old_name = $(this).attr('name');
                                if (old_name !== undefined) {
                                    new_name = old_name.replace(/\d+/, i);
                                    $(this).attr('name', new_name);
                                }
                            });
                            $(this).find('td:first label').html(++i);
                        });
                    }
                }
            } else
                alert('Atleast one item needed here');
        }",CClientScript::POS_HEAD);
    ?>  