/** * Lists all models. */ public function actionIndex() { $unit_model = Unit::model(); $dataProvider = array(); foreach ($unit_model->findAll() as $value) { $dataProvider[$value->id] = new CActiveDataProvider('Accounts', array('criteria' => array('condition' => "sid={$value->id}"), 'pagination' => array('pageSize' => 100))); } if (isset($_POST['yt0'])) { if (isset($_POST['group'])) { $_SESSION['data'] = $_POST['group']; } $_SESSION['title'] = $_POST['team_title']; $table_model = Accounts::model(); $table_model->create_table(); // foreach ( $_REQUEST['group'] as $key => $g ) // { // $criteria = new CDbCriteria; // $criteria->addInCondition( 'id' , $g ); // $data[$key] = new CActiveDataProvider( 'Accounts' , array( // 'criteria' => $criteria , // 'pagination' => false , // ) ); // } // $this->layout = '//layouts/'; // $this->render( 'create_table' , array( // 'title' => $_REQUEST['team_title'] , // 'data' => $data , // 'model' => $table_model , // ) ); Yii::app()->end(); } $this->render('index', array('dataProvider' => $dataProvider, 'unit' => $unit_model)); }
/** * Lists all models. */ public function actionIndex() { $unit_model = Unit::model(); $dataProvider[0] = new CActiveDataProvider('Accounts', array('pagination' => array('pageSize' => 30))); foreach ($unit_model->findAll() as $value) { $dataProvider[$value->id] = new CActiveDataProvider('Accounts', array('criteria' => array('condition' => "sid={$value->id}"), 'pagination' => array('pageSize' => 10))); } // print_r($dataProvider[0]->getData());exit; $this->render('index', array('dataProvider' => $dataProvider)); }
public function getUsercount() { $unit_model = Unit::model(); $acc_model = Accounts::model(); $data = array(); foreach ($unit_model->findAll() as $value) { $temp = $acc_model->findAll("sid=:sid", array(":sid" => $value->id)); $unit_tmp = $unit_model->find("id=:id", array(":id" => $value->id)); $data[] = array($unit_tmp->name, count($temp)); } return $data; }
/** * 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 Unit the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Unit::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php $sid_option = Unit::model()->findAll(); ?> <div id="content-header"> <div id="breadcrumb"> <a href="index.php" class="tip-bottom"><i class="icon-home"></i>首页</a> <a href="index.php?r=accounts" class="current"><i></i>成员列表</a> <a href="#" class="current"><?php echo $model->isNewRecord ? '添加新成员' : '修改 ' . $model->name; ?> </a> </div> </div> <div class="container-fluid"> <div class="widget-box"> <div class="widget-title"> <span class="icon"> <i class="icon-th"></i> </span> <h5><?php echo $model->isNewRecord ? '添加新成员' : '修改 ' . $model->name; ?> </h5> </div> <div class="widget-content nopadding"> <?php $form = $this->beginWidget('CActiveForm', array('id' => 'accounts', 'enableAjaxValidation' => false, 'htmlOptions' => array('class' => "form-horizontal"))); ?> <div class="control-group">
</div> <div class="container-fluid"> <div class="widget-box"> <div class="widget-title"> <span class="icon"> <i class="icon-th"></i> </span> <h5>成员列表</h5> <div id="options"> <a class="btn btn-success btn-mini" href="index.php?r=accounts/create">添加新成员</a> </div> </div> <ul class="nav nav-tabs"> <li class="active"><a data-toggle="tab" href="#tab0">所有成员</a></li> <?php $unit = Unit::model()->findAll(); ?> <?php foreach ($unit as $b) { ?> <li><a data-toggle="tab" href="#tab<?php echo $b['id']; ?> "><?php echo $b['name']; ?> </a></li> <?php } ?> </ul>
<?php if (!$model->isNewRecord) { ?> <div class="control-group"> <a href="#" role="button" class="btn btn-attr">New Attribute </a> <br/> <div class="js-new-attr" style="display:none;"> <?php echo CHtml::activeDropDownList($attribute, 'attribute_id', CHtml::listData(Attribute::model()->findAll(), 'id', 'attribute_name'), array('class' => 'attr-form', 'empty' => 'Select name')); ?> <?php echo $form->textField($attribute, 'value', array('class' => 'attr-form')); ?> <?php echo CHtml::activeDropDownList($attribute, 'unit_id', CHtml::listData(Unit::model()->findAll(), 'id', 'name'), array('class' => 'attr-form', 'empty' => 'Select unit')); ?> <input type="submit" class="btn" name="submit_attr" value="Add"/> </div> <br/> <?php if ($model->fileAttributes) { ?> <table class="table"> <thead> <tr> <th>Attribute Name</th> <th>Value</th> <th>Unit</th> <th></th> </tr>
'minLength' => '3', ), 'htmlOptions' => array( 'placeholder' => 'Attribute name', 'size' => 'auto', 'id'=>'js-sample-attr-attr-'.$ds->sample->id, 'style'=>'width:150px' ), )); ?> </td> <td> <input id="js-sample-attr-value-<?=$ds->sample->id?>" type="text" placeholder="Attribute Value" style="width:150px"> </td> <td> <?= CHtml::dropDownList('sampleAttr-unit', null, CHtml::listData(Unit::model()->findAll(array('order'=>'name asc')), 'id', 'name'),array('empty'=>'','id'=>'js-sample-attr-unit-'.$ds->sample->id,'style'=>'width:70px')); ?> </td> <td> <a sample-id="<?=$ds->sample->id?>" class="btn js-add-sample-attr"/>Add</a> </td> </tr> </tr> <? } ?> <? } else { ?> <tr> <td colspan="4"> <span class="empty">No results found.</span> </td> </tr> <? } ?> <tr>