コード例 #1
0
 /**
  * Finds the Assets model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Assets the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Assets::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #2
0
ファイル: _form.php プロジェクト: nirantarnoy/paperless
/* @var $this yii\web\View */
/* @var $model backend\models\Reqdevice */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="reqdevice-form">

    <?php 
$form = ActiveForm::begin();
?>
    
    <?php 
$devicetype = new Assettype();
?>
    <?php 
$device = new Assets();
?>
    <label>ประเภทอุปกรณ์</label>
    <?php 
echo $form->field($model, 'usdef1')->dropDownList(ArrayHelper::map($devicetype->find()->all(), 'recid', 'typename'), ['prompt' => 'เลือกประเภท', 'onchange' => '
         $.ajax({
         type: "post",
         url: "index.php?r=reqdevice/showdevice&id=" +$(this).val(),
         data:{},
         //dataType: "json",
         contentType: "application/json; charset=utf-8",
         success: function(data) {
           $("#devicelist").html(data);
          },
         error: function(data){
            alert("fail");
コード例 #3
0
 /**
  * Finds the Reqdevice model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Reqdevice the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 public function actionShowdevice($id)
 {
     $count = Assets::find()->where(['assettypeid' => $id])->count();
     // $xx = $ass->find()->all();
     $val = Assets::find()->where(['assettypeid' => $id])->all();
     if ($count > 0) {
         foreach ($val as $data) {
             echo "<option value='" . $data->recid . "'>" . $data->assetname . "</option>";
         }
     } else {
         echo "<option> --- </option>";
     }
 }