</tr> <?php for ($i = 0; $i < count($array); $i++) { ?> <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);
echo $form->labelEx($model, 'ename'); ?> <?php echo $form->textField($model, 'ename', array('size' => 20, 'maxlength' => 20)); ?> <?php echo $form->error($model, 'ename'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'mainid'); ?> <?php echo $form->dropDownList($model, 'mainid', CHtml::listData(TbpOutputMain::model()->findAll(array('order' => 'id', 'condition' => "opt1='1'")), 'id', 'cname')); ?> <?php echo $form->error($model, 'mainid'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'nextlog'); ?> <?php echo $form->radioButtonList($model, 'nextlog', array('1' => '是', '0' => '否'), array('separator' => ' ')); ?> <?php
$sumTotal = 0; foreach ($models as $tbpoutput) { foreach ($tbpoutput as $k => $value) { ?> <tr> <td> <?php echo $value->pdate; ?> </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; } } ?>
/** * 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 TbpOutputMain the loaded model * @throws CHttpException */ public function loadModel($id) { $model = TbpOutputMain::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<div class="row"> <?php echo $form->labelEx($model, 'ename'); ?> <?php echo $form->textField($model, 'ename', array('size' => 20, 'maxlength' => 20)); ?> <?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'); ?>