Пример #1
0
 /**
  * @return mixed
  */
 public function store()
 {
     $input = \Request::all();
     $validator = \Validator::make($input, ['unit_id' => 'required', 'tenant_name' => 'required|max:255']);
     if ($validator->fails()) {
         \App::abort(400, $validator->messages()->first());
     }
     $tenant = new Tenant($input);
     $unit = Unit::find($input['unit_id']);
     $tenant = $unit->Tenants()->save($tenant);
     return \Response::json(['success' => true, 'message' => 'Tenant Created.', 'data' => $tenant]);
 }
 public function actionOptionunit()
 {
     $id = Yii::$app->request->post('id');
     $count = Unit::find()->where(['id_bahagian' => $id])->count();
     $list = Unit::find()->where(['id_bahagian' => $id])->all();
     if ($count > 0) {
         foreach ($list as $list) {
             echo '<option value="' . $list->id_unit . '">' . $list->nama_unit . '</option>';
         }
     } else {
         echo '<option>Tiada Rekod</option>';
     }
 }
Пример #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Unit::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Пример #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if (Session::get('level') == '1' || Session::get('level') == '2' && Session::get('fingerprint') == md5($_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR'])) {
         $Unit = Unit::find(e($id));
         DB::transaction(function () use($Unit) {
             Unit::find($Unit->id)->delete();
         });
         return Redirect::to('unit');
     } else {
         return Redirect::to('/');
     }
 }
 private function lokasi_file($value)
 {
     $unit_asal = unit::find($value['unit_asal']);
     $folder1 = $unit_asal['nama_unit'];
     $sub = Sub_jenis_dokumen::find($value['jenis_dokumen']);
     $folder2 = $sub['nama_sub'] . '(' . $sub['singkatan'] . ')';
     return $lokasi = $folder1 . '/';
 }
Пример #6
0
use app\models\Category;
use app\models\Productmain;
use app\models\Unit;
/* @var $this yii\web\View */
/* @var $searchModel app\models\ProductsSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Products';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="products-index">

    <h1><?php 
Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('เพิ่มรายการใหม่', ['create'], ['class' => 'btn btn-success fa fa-plus']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'panel' => ['before' => ' '], 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['label' => 'หมวดหมู่หลัก', 'format' => 'raw', 'value' => 'productmainname', 'filter' => Html::activeDropDownList($searchModel, 'productmain_id', ArrayHelper::map(Productmain::find()->asArray()->all(), 'id', 'name'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['label' => 'หมวดหมู่รอง', 'format' => 'raw', 'value' => 'Categoryname', 'filter' => Html::activeDropDownList($searchModel, 'category_id', ArrayHelper::map(Category::find()->asArray()->all(), 'id', 'name'), ['class' => 'form-control', 'prompt' => 'Select Category'])], 'sub_qty', ['label' => 'ชื่อหน่วยนับ', 'format' => 'raw', 'value' => 'unitname', 'filter' => Html::activeDropDownList($searchModel, 'productmain_id', ArrayHelper::map(Unit::find()->asArray()->all(), 'id', 'name'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['label' => 'จำนวนคงเหลือ', 'format' => 'raw', 'value' => 'unitname', 'filter' => \app\models\Inventorydetail::find()->where(['product_id' => $dataProvider->id])->sum('qty')], 'name', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
Пример #7
0
    </div>
    <div class="row">
        <div class="col-md-6">
            <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>
        </div>
        <div class="col-md-2">
            <?php 
echo $form->field($model, 'sub_qty')->textInput();
?>
        </div>
        <div class="col-md-2">
           
            <?php 
echo $form->field($model, 'unit_id')->dropdownList(ArrayHelper::map(Unit::find()->all(), 'id', 'name'), ['id' => 'unit_id', 'prompt' => 'เลือกหน่วยนับ', 'required' => '']);
?>
        </div>
    </div>
    <div class="row">
        <div class="col-md-6">
            <?php 
echo $form->field($model, 'qty')->textInput();
?>
        </div>
         <div class="col-md-6">
            <?php 
echo $form->field($model, 'price')->textInput();
?>
        </div>
    </div>