<div id="sub_menu"> 
<a href="<?php echo Yii::app()->createUrl('site/index'); ?>">Home</a>&nbsp;&nbsp;
<img width="9" height="10" src="<?php echo Yii::app()->baseUrl; ?>/images/front/1/submenu_13.jpg">&nbsp;&nbsp;&nbsp; 
<a href="#">Submit Paper</a> 
</div>
<div id="content">
  <div id="business_solution_leftcontent">
    <?php $this->renderPartial('left_menu');  ?>
    <?php $this->renderPartial('pages/leftcontent'); ?>
  </div>
  <div id="overview_rightcontent">
    <div id="business_solution_subheadding"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Submit a Paper </div>
    <div id="view_profilebox">
    <?php
    foreach(Yii::app()->user->getFlashes() as $key => $message) {
        echo '<div class="flash-' . $key . '">' . $message . "</div>\n";
    }
    ?>
      <div id="view_profile">
        <div style="font-family:Arial, Helvetica, sans-serif;
   font-size:13px; text-align:left;">
          <?php $form=$this->beginWidget('CActiveForm', array(
			'id'=>'paper-form',
			'enableAjaxValidation'=>false,
			'htmlOptions' => array('enctype' => 'multipart/form-data'),
		)); ?>
            <?php //echo $form->errorSummary($model); ?>

	<table width="745" border="0" align="center" cellpadding="5" cellspacing="0">
  <tr>
    <td width="194"><?php echo $form->labelEx($model,'title_of_the_paper'); ?></td>
    <td width="531"><?php echo $form->textField($model,'title_of_the_paper',array('style'=>'width:247px;','size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'title_of_the_paper'); ?>
      </td>
  </tr>
  <tr>
    <td><label for="Paper_region_id"><?php echo $form->labelEx($model,'region_id'); ?></label></td>
    <td><?php  echo $form->dropDownList($model,'region_id',Country::getCountry(),array('style'=>'width:250px;','prompt'=>'Select country')); ?>
		<?php echo $form->error($model,'region_id'); ?></td>
  </tr>
  <tr>
    <td><label for="Paper_user_group_id"><?php echo $form->labelEx($model,'user_group_id'); ?></label></td>
    <td>
		<?php echo $form->dropDownList($model,'user_group_id',UserGroup::getGroups(),
											 array(
												'style'=>'width:250px',
												'prompt'=>'Select user group',
												'ajax' => array(
												'type'=>'POST',
												'url'=>CController::createUrl('site/updateProductGroup'), 
												//'update'=>'#Product_product_group_id',
												'data'=>array('user_group_id'=>'js:this.value'), 
												'success'=>'js:function(data){
													$("#Paper_product_group_id").html(data)
													$("#Paper_product_category_id").html("<option value=\"\">Select category</option>")
													$("#Paper_product_id").html("<option value=\"\">Select product</option>")
													}'
            ))); ?>
		<?php echo $form->error($model,'user_group_id'); ?></td>
  </tr>
  <tr>
    <td><?php echo $form->labelEx($model,'product_group_id'); ?></td>
    <td><?php echo $form->dropDownList($model,'product_group_id',ProductGroup::getProductGroup($model->user_group_id),array(
												'style'=>'width:250px',
												'prompt'=>'Select group',
												'ajax' => array(
												'type'=>'POST',
												'url'=>CController::createUrl('site/updateProductCategory'), 
												'data'=>array(
															  'user_group_id'=>'js:$("#Paper_user_group_id :selected").val()',  
															  'product_group_id'=>'js:this.value'
															  ),  
												'success'=>'js:function(data){
													$("#Paper_product_category_id").html(data)
													$("#Paper_product_category_id").change();
													$("#Paper_product_id").html("<option value=\"\">Select product</option>")
													}'
																		  ))); ?> 
		<?php echo $form->error($model,'product_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($model->user_group_id,$model->product_group_id),array(
												'style'=>'width:250px',
												'prompt'=>'Select category',
												'ajax' => array(
												'type'=>'POST',
												'url'=>CController::createUrl('site/updateProduct'), 
												'update'=>'#Paper_product_id',
												'data'=>array(
															  'user_group_id'=>'js:$("#Paper_user_group_id :selected").val()',  
															  'product_group_id'=>'js:$("#Paper_product_group_id :selected").val()',  
															  'product_category_id'=>'js:this.value'
															  ),  
																		  ))); ?>
		<?php echo $form->error($model,'product_category_id'); ?></td>
  </tr>
  <tr>
    <td><label for="Paper_product_id"><?php echo $form->labelEx($model,'product_id'); ?></label></td>
    <td><?php echo $form->dropDownList($model,'product_id',Product::getProduct($model->user_group_id,$model->product_group_id,$model->product_category_id),array('style'=>'width:250px', 'prompt'=>'Select product',)); ?>
		<?php echo $form->error($model,'product_id'); ?></td>
  </tr>
  <tr>
    <td><?php echo $form->labelEx($model,'industry_id'); ?></td>
    <td><?php echo $form->dropDownList($model,'industry_id',Industry::getIndustry(),array('style'=>'width:250px', 'prompt'=>'Select industry',)); ?>
		<?php echo $form->error($model,'industry_id'); ?></td>
  </tr>
  <tr>
    <td><?php echo $form->labelEx($model,'year'); ?></td>
    <td><?php for($i=date('Y');$i>=1990;$i--) $years[$i]=$i; ?>
        <?php echo $form->dropDownList($model,'year',$years,array('style'=>'width:250px', 'prompt'=>'Select Year',)); ?>
		<?php echo $form->error($model,'year'); ?></td>
  </tr>
  <tr>
    <td><label for="Paper_filename"><?php echo $form->labelEx($model,'filename'); ?></label></td>
    <td><?php echo $form->fileField($model,'filename'); ?>
		<?php echo $form->error($model,'filename'); ?>
		<?php if(!$model->isNewRecord): ?>
        <?php echo CHtml::link($model->filename,Yii::app()->baseUrl.'/media/paper/'.$model->filename); ?>
        <?php endif; ?></td>
  </tr>
  <tr>
    <td align="left" valign="top"><?php echo $form->labelEx($model,'content'); ?></td>
    <td><?php echo $form->textArea($model,'content',array('class'=>'ckeditor','cols'=>"80",'rows'=>"10")); ?>
		<?php echo $form->error($model,'content'); ?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><?php echo CHtml::submitButton($model->isNewRecord ? 'Submit' : 'Save'); ?></td>
  </tr>
</table>

<?php $this->endWidget(); ?>
        </div>
      </div>
    </div>
  </div>
</div>