<?php
Yii::app()->clientScript->registerScript('addremoveF',"

$('#addOneMoreFeature a').live('click',function()

{

$('#productFeaturesTable tr:last').after($('#tableRowRepeatableFeature').clone().find('input').val('').end());

}

);



$('#removeOneFeature a').live('click',function()

{

if($('#productFeaturesTable tr').length>2)

$(this).closest('tr').remove();

});



$('#addOneMoreDownloadable a').live('click',function()

{

	//alert('hi');

$('#productDownloadable tr:last').after($('#tableRowRepeatableDownloadable').clone().find('input').val('').end());

}

);



$('#removeOneDownloadable a').live('click',function()

{

	//alert($('#productDownloadable tr').length)

if($('#productDownloadable tr').length>2)

$(this).closest('tr').remove();

});

"); ?>

<div id="communicationsbox" style="height:525px; background-color:#f7eee1;">
<?php
    foreach(Yii::app()->user->getFlashes() as $key => $message) {
        echo '<div class="flash-' . $key . '">' . $message . "</div>\n";
    }
?>
  <div id="form_wrapper">
    <?php $form=$this->beginWidget('CActiveForm', array(

	'id'=>'product-form',

	'enableAjaxValidation'=>false,

	'htmlOptions' => array(

        'enctype' => 'multipart/form-data',

    ),

)); ?>
      <div class="row">
        <div id="text"><?php echo $form->labelEx($model,'product_name'); ?></div>
        <div id="box">
          <?php echo $form->textField($model,'product_name',array('size'=>20,'maxlength'=>255)); ?> <?php echo $form->error($model,'product_name'); ?>
        </div>
      </div>
      <div class="row">
        <div id="text"><?php echo $form->labelEx($model,'product_image'); ?></div>
        <div id="box">
          <?php echo $form->fileField($model,'product_image',array('size'=>20,'maxlength'=>255)); ?> <?php echo $form->error($model,'product_image'); ?>
        </div>
      </div>
      <div class="row">
        <fieldset class="current">
          <legend>Group</legend>
          <table width="800" border="0" cellspacing="0" cellpadding="0" >
            <tr>
              <td width="400"><table width="96%" border="0" align="center" cellpadding="2" cellspacing="2">
                  <tr>
                    <td width="42%"><?php echo $form->labelEx($model,'user_group_id'); ?></td>
                    <td width="58%"><?php echo $form->dropDownList($model,'user_group_id',UserGroup::getGroups()); ?> <?php echo $form->error($model,'user_group_id'); ?></td>
                  </tr>
                  <tr>
                    <td><?php echo $form->labelEx($model,'product_category_id'); ?></td>
                    <td><?php echo $form->dropDownList($model,'product_category_id',ProductCategory::getProductCategory()); ?> <?php echo $form->error($model,'product_category_id'); ?></td>
                  </tr>
                </table></td>
              <td width="400"><table width="96%" border="0" align="center" cellpadding="2" cellspacing="2">
                  <tr>
                    <td width="35%"><?php echo $form->labelEx($model,'product_group_id'); ?></td>
                    <td width="65%"><?php echo $form->dropDownList($model,'product_group_id',ProductGroup::getProductGroup()); ?> <?php echo $form->error($model,'product_group_id'); ?></td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                </table></td>
            </tr>
          </table>
        </fieldset>
      </div>
      <br />
      <div class="row">
        <fieldset class="current">
          <legend><strong>Product Features</strong></legend>
          <br />
          <table width="800" border="0" cellspacing="2" cellpadding="3" id="productFeaturesTable">
            <tr>
              <td width="400">Featurs</td>
              <td width="400">Value<div class="addOneMore" id="addOneMoreFeature">
              <a href="javascript:;"><img width="15" height="15" src="<?php echo Yii::app()->baseUrl; ?>/images/admin/green-plus-sign-md.png" alt="pluse" class="plus_position"></a></div></td>
            </tr>
            
            <?php if(!$model->isNewRecord && count($model2)>0): 
			foreach($model2 as $eachModel2):
			?>
            <tr id="tableRowRepeatableFeature">
              <td>
			  <?php echo $form->dropDownList($eachModel2,'feature_id',ProductFeature::getProductFeature(),array('name'=>'Feature[]','id'=>'','empty'=>'Select')); ?></td>
              <td>
			  <?php echo $form->textField($eachModel2,'feature_value',array('name'=>'FeatureValue[]','id'=>'','size'=>20,'maxlength'=>20)); ?>
              <div class="removeOne"  id="removeOneFeature">
              <a href="javascript:;">
              <img width="15" height="15" class="plus_position" src="<?php echo Yii::app()->baseUrl; ?>/images/admin/green--sign-md.png">
              </a>
              </div>
              </td>
            </tr>
            <?php endforeach;
			else:
			?>
			<tr id="tableRowRepeatableFeature">
              <td>
			  <?php echo $form->dropDownList($model2,'feature_id',ProductFeature::getProductFeature(),array('name'=>'Feature[]','id'=>'','empty'=>'Select','value'=>$eachModel2->feature_id)); ?></td>
              <td>
			  <?php echo $form->textField($model2,'feature_value',array('name'=>'FeatureValue[]','id'=>'','size'=>20,'maxlength'=>20,'value'=>$eachModel2->feature_value)); ?>
              <div class="removeOne"  id="removeOneFeature">
              <a href="javascript:;">
              <img width="15" height="15" class="plus_position" src="<?php echo Yii::app()->baseUrl; ?>/images/admin/green--sign-md.png">
              </a>
              </div>
              </td>
            </tr>
			<?php endif; ?>
            
            
          </table>
        </fieldset>
      </div>
      <br />
      <div class="row">
        <fieldset class="current">
          <legend><strong>Downloadables</strong></legend>
          <br />
          <br />
          <table width="800" border="0" cellspacing="2" cellpadding="3" id="productDownloadable">
            <tr>
              <td width="199">Item</td>

              <td width="331">Value</td>
              <td width="331">Files<div class="addOneMore" id="addOneMoreDownloadable"><a href="javascript:;"><img width="15" height="15" src="<?php echo Yii::app()->baseUrl; ?>/images/admin/green-plus-sign-md.png" alt="pluse" class="plus_position"></a></div></td>
            </tr>
            
            <?php if(!$model->isNewRecord && count($model3)>0): 
			foreach($model3 as $eachModel3):
			?>
            <tr id="tableRowRepeatableDownloadable">
              <td>
              <?php echo count($model3); ?>
              </td>
            </tr>
            <?php endforeach;
			else:
			?>
            <tr id="tableRowRepeatableDownloadable">
              <td>
              
              <?php echo $form->dropDownList($model3,'item_id',ProductDownloadable::getDownloadableItems(),array('name'=>'downloadbleItem[]')); ?> 
			  <?php echo $form->error($model3,'item_id'); ?>
              
              </td>
              <td><?php echo $form->textField($model3,'item_value',array('name'=>'downloadableItemValue[]','id'=>'','size'=>20,'maxlength'=>20)); ?> <?php echo $form->error($model3,'item_value'); ?></td>
              <td><?php echo $form->fileField($model3,'files_available',array('name'=>'downloadableFiles[]','id'=>'','size'=>20,'maxlength'=>20)); ?> <?php echo $form->error($model3,'files_available'); ?><div class="removeOne" id="removeOneDownloadable"><a href="javascript:;"><img width="15" height="15" class="plus_position" src="<?php echo Yii::app()->baseUrl; ?>/images/admin/green--sign-md.png"></a></div></td>
            </tr>
            <?php endif; ?>
            
            
            
            </table>
        </fieldset>
      </div>
      <div class="row">
        <fieldset class="current">
          <legend><strong>Promotion</strong></legend>
          <br />
          <br />
          <table width="800" border="0" cellspacing="2" cellpadding="3" >
            <tr>
              <td><?php echo $form->labelEx($model,'isIntoPromotion'); ?>
			  <?php echo $form->checkBox($model,'isIntoPromotion',array('value'=>'Y', 'uncheckValue'=>'N')); ?> 
			  <?php echo $form->error($model,'isIntoPromotion'); ?></td>
            </tr>
            <tr>
              <td><table width="100%" border="0" cellspacing="2" cellpadding="2">
                  <tr>
                    <td width="25%">Reward Points</td>
                    <td width="75%"><?php echo $form->textField($model,'rewardPoints',array('size'=>20,'maxlength'=>255)); ?> <?php echo $form->error($model,'rewardPoints'); ?></td>
                  </tr>
                  <tr>
                    <td>Promotion Form</td>
                    <td><?php echo $form->textField($model,'promotionForm',array('size'=>20,'maxlength'=>255)); ?> <?php echo $form->error($model,'promotionForm'); ?></td>
                  </tr>
                </table></td>
            </tr>
          </table>
        </fieldset>
      </div>
      <div class="row">
        <fieldset class="current">
          <legend><strong>Featured</strong></legend>
          <br />
          <br />
          <table width="800" border="0" cellspacing="2" cellpadding="3" >
            <tr>
              <td width="199"><?php echo $form->labelEx($model,'isFeaturedItem'); ?> <?php echo $form->checkBox($model,'isFeaturedItem',array('value'=>'Y', 'uncheckValue'=>'N')); ?> <?php echo $form->error($model,'isFeaturedItem'); ?></td>
            </tr>
          </table>
        </fieldset>
      </div>
      <br />
      <div class="row">
        <fieldset class="current">
          <legend><strong>Specifications</strong></legend>
          <br />
          <br />
          <table width="800" border="0" cellspacing="2" cellpadding="3" >
            <tr>
              <td >
              <?php echo $form->textArea($model,'specifications',array('class'=>'ckeditor','cols'=>"80",'rows'=>"10")); ?><?php echo $form->error($model,'specifications'); ?>
              </td>
            </tr>
          </table>
        </fieldset>
      </div>
      <br />
      <div class="row">
        <fieldset class="current">
          <legend><strong>Overview</strong></legend>
          <br />
          <br />
          <table width="800" border="0" cellspacing="2" cellpadding="3" >
            <tr>
              <td><?php echo $form->textArea($model,'overview',array('class'=>'ckeditor','cols'=>"80",'rows'=>"10")); ?><?php echo $form->error($model,'overview'); ?></td>
            </tr>
          </table>
        </fieldset>
      </div>
      <br />
      <div class="row">
        <fieldset class="current">
          <legend><strong>Description</strong></legend>
          <br />
          <br />
          <table width="800" border="0" cellspacing="2" cellpadding="3">
            <tr>
              <td><?php echo $form->textArea($model,'description',array('class'=>'ckeditor','cols'=>"80",'rows'=>"10")); ?><?php echo $form->error($model,'description'); ?></td>
            </tr>
          </table>
        </fieldset>
      </div>
      <br />
      <div class="row">
        <table width="800" border="0" cellspacing="2" cellpadding="3" >
          <tr>
            <td ><table width="100%" border="0" cellspacing="2" cellpadding="2">
                <tr>
                  <td height="30" align="center">
				  <?php if($model->isNewRecord): ?>

                	<?php echo CHtml::submitButton('Save & Enter Another'); ?>

                  	&nbsp;&nbsp;&nbsp;&nbsp;

                  	<?php echo CHtml::submitButton('Save & Duplicate'); ?>

                  <?php endif; ?>

                  &nbsp;&nbsp;&nbsp; 
				  <?php echo CHtml::submitButton($model->isNewRecord ? 'Submit & Close' : 'Save & Close'); ?>
                  </td>
                </tr>
              </table></td>
          </tr>
        </table>
      </div>
    <?php $this->endWidget(); ?>
  </div>
</div>