Ejemplo n.º 1
0
        <tr>
            <td height="30"><?php 
    echo $i + 1;
    ?>
</td>
             <td>
                <?php 
    echo CHtml::dropDownList('TbpOutputLog[' . $i . '][mainid]', $array[$i]->mainid, CHtml::listData(TbpOutputMain::model()->findAll(array('order' => 'id ASC', 'condition' => 'opt1=1')), 'id', 'cname'), array("disabled" => $array[$i]->opt1 == 0 ? "disabled" : '', 'prompt' => '選擇主項', 'options' => array($array[$i]->mainid => array('selected' => 'selected')), 'ajax' => array('type' => 'POST', 'url' => CController::createUrl('tbpOutputStore/dynamicoutputsubs', array('index' => $i)), 'update' => '#TbpOutputLog_' . $i . '_subid')));
    ?>
 
            </td>
            
            <td>
                <?php 
    echo CHtml::dropDownList('TbpOutputLog[' . $i . '][subid]', $array[$i]->subid, CHtml::listData(TbpOutputSub::model()->findallByAttributes(array('id' => $array[$i]->subid ? $array[$i]->subid : '')), 'id', 'cname'), array("disabled" => $array[$i]->opt1 == 0 ? "disabled" : '', 'options' => array($array[$i]->subid => array('selected' => 'selected')), 'ajax' => array('type' => 'POST', 'url' => CController::createUrl('tbpOutputStore/dynamicoutputitems', array('index' => $i)), 'update' => '#TbpOutputLog_' . $i . '_itemid')));
    ?>
         
            </td>
            
            <td>
                <?php 
    echo CHtml::dropDownList('TbpOutputLog[' . $i . '][itemid]', $array[$i]->itemid, CHtml::listData(TbpOutputItem::model()->findallByAttributes(array('id' => $array[$i]->itemid ? $array[$i]->itemid : '')), 'id', 'cname'), array("disabled" => $array[$i]->opt1 == 0 ? "disabled" : '', 'options' => array($array[$i]->itemid => array('selected' => 'selected')), 'ajax' => array('url' => CController::createUrl('tbpOutputStore/dynamictype', array('index' => $i)), 'data' => array('TbpOutputLog[' . $i . '][itemid]' => 'js:this.value'), 'success' => 'function(data){
                                                   $("#opTypeBlock' . $i . '").html(data);
                                               }')));
    ?>
            </td>
            <!--<td>-->
                
                <input type="hidden" name=<?php 
    echo "TbpOutputLog[{$i}][id]";
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return TbpOutputSub the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = TbpOutputSub::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Ejemplo n.º 3
0
?>
		<?php 
echo $form->error($model, 'ename');
?>
	</div>

	<div class="row">
                      
            <?php 
echo $form->dropDownList($model, 'mainid', CHtml::listData(TbpOutputMain::model()->findAll(array('order' => 'id ASC', 'condition' => 'opt1=1')), 'id', 'cname'), array('prompt' => '選擇主項', 'ajax' => array('type' => 'POST', 'url' => CController::createUrl('tbsCom/dynamicoutputitems'), 'update' => '#TbpOutputItem_subid')));
?>
 
         
            <?php 
//                    echo $form->labelEx($model,'subid');
echo $form->dropDownList($model, 'subid', CHtml::listData(TbpOutputSub::model()->findAll(array('order' => 'id ASC', 'condition' => 'opt1=1')), 'id', 'cname'), array('empty' => '--選擇次項--'));
?>
         
     	
		<?php 
//echo $form->textField($model,'subid',array('size'=>4,'maxlength'=>4));
?>
		<?php 
echo $form->error($model, 'subid');
?>
	</div>

	<div class="row">
            
                <?php 
echo $form->labelEx($model, 'type');
Ejemplo n.º 4
0
    
 </td>
 <td>     
     <?php 
     if (isset($value)) {
         $maincname = TbpOutputMain::model()->findByPk($value->mainid);
         if ($maincname != NULL) {
             echo $maincname->cname;
         }
     }
     ?>
 </td>   
  <td>
      <?php 
     if (isset($value)) {
         $subcname = TbpOutputSub::model()->findByPk($value->subid);
         if ($subcname != NULL) {
             echo $subcname->cname;
         }
     }
     ?>
 </td>
  <td>
      <?php 
     echo $value->itemname;
     ?>
    
 </td>
 <td>
     <?php 
     switch ($value->type) {
 public function actionDynamicoutputsubs()
 {
     $row = '';
     $mainid = '';
     if (isset($_GET['index'])) {
         $row = $_GET['index'];
     }
     // 由異動欄位來的值
     if (isset($_POST)) {
         $mainid = $_POST['TbpOutputLog'][$row]['mainid'];
     }
     // 依傳入之mainid來查詢對應次項, 並且要已啟用
     $sub = TbpOutputSub::model()->findAllByAttributes(array(), $condition = "mainid = :id and opt1 = '1' order by mainid ", $params = array(':id' => (int) $mainid));
     // 取出店編號對應店名
     $data = CHtml::listData($sub, 'id', 'cname');
     // 第一列預設為空
     $empty = TRUE;
     // 連動結果第一筆為空
     if ($empty) {
         echo CHtml::tag('option', array('value' => ''), '選擇次項', true);
     }
     // 回傳至畫面
     foreach ($data as $value => $name) {
         echo CHtml::tag('option', array('value' => $value), CHtml::encode($name), true);
     }
 }