public function actionSection($id)
 {
     $section = Section::find()->where(['grade_level_id' => $id])->all();
     foreach ($section as $item) {
         echo '<option value="' . $item->id . '">' . $item->section_name . '</option>';
     }
 }
Exemplo n.º 2
0
 public function destroy($id)
 {
     $section = Section::find($id);
     if (count($section->pages) > 0) {
         return false;
     }
     $section->delete();
     return true;
 }
 /**
  * Lists all Section models.
  * @return mixed
  */
 public function actionIndex()
 {
     $model = Section::find()->orderBy(['section_name' => SORT_ASC])->all();
     $grade_level = GradeLevel::find()->all();
     $listData = ArrayHelper::map($grade_level, 'id', 'name');
     $searchModel = new SectionSearch();
     $dataProvider = $searchModel->searchSection(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'listData' => $listData, 'model' => $model]);
 }
Exemplo n.º 4
0
 private function getAllSection()
 {
     $section = Section::find()->where(['uid' => Yii::$app->user->id])->all();
     $section_array['公司'] = "公司";
     foreach ($section as $item) {
         $name = $item->getAttribute('name');
         $section_array[$name] = $name;
     }
     return $section_array;
 }
Exemplo n.º 5
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Section::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, 'parent' => $this->parent, 'uid' => Yii::$app->user->id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Exemplo n.º 6
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Section::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(['sec_id' => $this->sec_id, 'sec_created' => $this->sec_created]);
     $query->andFilterWhere(['like', 'sec_title', $this->sec_title])->andFilterWhere(['like', 'sec_cnf_id', $this->sec_cnf_id]);
     return $dataProvider;
 }
Exemplo n.º 7
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function searchSection($params)
 {
     $query = Section::find();
     $pageSize = Yii::$app->params['pageSize'];
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['section_name'] = ['asc' => ['section_name' => SORT_ASC], 'desc' => ['section_name' => SORT_DESC]];
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['section_name' => SORT_ASC]], 'pagination' => ['pageSize' => $pageSize]]);
     $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, 'grade_level_id' => $this->grade_level_id]);
     $query->andFilterWhere(['like', 'section_name', $this->section_name]);
     return $dataProvider;
 }
Exemplo n.º 8
0
    /**
     * @param int|array $id id секций для получения по ним статистики
     */
    public static function getConferenceStat($id = 0)
    {
        // посчитаем гостей, руководителей и участников
        $sWhere = $id === 0 ? 'prs_sec_id > 0' : (is_array($id) ? 'prs_sec_id in (' . implode(',', $id) . ')' : 'prs_sec_id = ' . $id);
        $sSql = <<<EOT
Select SUM(IF(p.prs_type = 1, 1, 0 )) As cou_guest,
       SUM(IF(p.prs_type = 3 Or p.prs_type = 4, 1, 0 )) As cou_member,
       SUM(IF(p.prs_type = 2, 1, 0 )) As cou_consult,
       prs_sec_id
From confprof_person p
Where {$sWhere}
Group By prs_sec_id
Order By prs_sec_id
EOT;
        $aSectPerson = ArrayHelper::map(Yii::$app->db->createCommand($sSql)->queryAll(PDO::FETCH_ASSOC), 'prs_sec_id', function ($el) {
            return $el;
        });
        // пробежимся по секциям и докладам
        $q = Section::find()->with(['conference', 'doclads']);
        if ($id !== 0) {
            $q->where(['prs_sec_id' => $id]);
        }
        $aSect = $q->all();
        $aRet = [];
        foreach ($aSect as $oSect) {
            /** @var Section $oSect */
            $adata = ['sect_id' => $oSect->sec_id, 'sect' => $oSect->sec_title, 'conf' => $oSect->conference->cnf_title, 'doclads' => count($oSect->doclads)];
            $adata = array_merge($adata, isset($aSectPerson[$oSect->sec_id]) ? $aSectPerson[$oSect->sec_id] : ['cou_guest' => 0, 'cou_member' => 0, 'cou_consult' => 0]);
            // посчитаем уникальных лидеров проектов
            $aLeader = [];
            foreach ($oSect->doclads as $oDocl) {
                /** @var Doclad $oDocl */
                if (!isset($aLeader[$oDocl->doc_lider_email])) {
                    $aLeader[$oDocl->doc_lider_email] = 0;
                }
                $aLeader[$oDocl->doc_lider_email]++;
                // это на всякий случай
            }
            $adata['leaders'] = count($aLeader);
            $aRet[] = $adata;
        }
        return $aRet;
    }
 /**
  * Creates a new Section model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Section();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         // data section
         $data_section = $_POST['Section'];
         // name catalog
         foreach ($data_section as $vlSection) {
             $name_section = $vlSection;
         }
         // last id catalog
         $last_section = Section::find()->orderBy('id_section DESC')->one();
         $last = $last_section->id_section;
         // insert search_table
         $search_section = new SearchTable(['name_search' => $name_section, 'type_search' => '2', 'link_search' => $last]);
         $search_section->save();
         return $this->redirect(['view', 'id' => $model->id_section]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Exemplo n.º 10
0
use yii\helpers\HtmlPurifier;
use kartik\select2\Select2;
use app\models\ApplicantForm;
use app\models\ActiveRecord;
use app\models\StudentForm;
use yii\helpers\ArrayHelper;
use yii\bootstrap\ActiveForm;
use app\models\GradeLevel;
use app\models\Section;
use app\models\SchoolYear;
use app\models\Card;
use app\models\DataHelper;
$card_url = json_encode(Yii::$app->request->baseUrl . '/site/card?data=');
$current_date = date('Y');
$school_year = SchoolYear::find()->orderBy(['id' => SORT_DESC])->all();
$section = Section::find()->all();
$grade_level = GradeLevel::find()->where(['!=', 'id', 0])->all();
$status = [['id' => 1, 'status' => 'Pending'], ['id' => 0, 'status' => 'Enrolled']];
$listData = ArrayHelper::map($grade_level, 'id', 'name');
$listData2 = ArrayHelper::map($school_year, 'id', 'sy');
$listData3 = ArrayHelper::map($section, 'id', 'section_name');
$listData4 = ArrayHelper::map($status, 'id', 'status');
$state = false;
$avatar = Yii::$app->request->baseUrl . Yii::$app->params['avatar'];
!$model->isNewRecord ? !empty($model->student->students_profile_image) ? $img = Yii::$app->request->baseUrl . '/uploads/students/' . $model->student->students_profile_image : ($img = $avatar) : '';
!$model->isNewRecord ? !empty(trim($model->student->middle_name)) ? $middle = ucfirst(substr($model->student->middle_name, 0, 1)) . '.' : ($middle = '') : '';
!$model->isNewRecord ? $this->title = implode(' ', [$model->student->first_name, $middle, $model->student->last_name]) : 'New';
$model->isNewRecord ? $this->title = 'New' : ($this->title = implode(' ', [$model->student->first_name, $middle, $model->student->last_name]));
$form = ActiveForm::begin();
?>
<div class="ui three column stackable grid">
Exemplo n.º 11
0
 public function actionBand()
 {
     if (isset($_POST['start']) || isset($_POST['finish'])) {
         $start = Yii::$app->request->post('start');
         $finish = Yii::$app->request->post('finish');
         $catalog = Yii::$app->request->post('catalog');
         if ($catalog != 'all') {
             $section = Section::find()->where(['=', 'catalog_id', $catalog])->all();
             foreach ($section as $vlSection) {
                 $sect[] = $vlSection->id_section;
             }
             foreach ($sect as $vlSect) {
                 $band = Product::find()->where(['BETWEEN', 'price', $start, $finish])->andWhere(['=', 'section_id', $vlSect])->orderBy('price')->all();
             }
         } else {
             $band = Product::find()->where(['BETWEEN', 'price', $start, $finish])->orderBy('price')->all();
         }
     }
     return $this->renderAjax('band', ['band' => $band]);
 }
Exemplo n.º 12
0
Arquivo: _form.php Projeto: poykub/wph
?>
      </p>
      <div class="box box-info">
        <div class="box-header">
          <h3 class="box-title"> บันทึกการปฏิบัติงาน</h3>
        </div>
        <!-- /.box-header -->
        <div class="box-body">
          <?php 
$form = ActiveForm::begin(['fieldConfig' => ['horizontalCssClasses' => ['label' => 'col-sm-2', 'offset' => 'col-sm-offset-2', 'wrapper' => 'col-sm-10']], 'options' => ['enctype' => 'multipart/form-data']]);
?>

          <div class="row">
            <div class="col-md-4">
              <?php 
echo $form->field($model, 'section_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Section::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'หน่วยงาน/ฝ่าย/แผนก...'], 'pluginOptions' => ['allowClear' => true]]);
?>
            </div>
            <div class="col-md-3">
                  <?php 
echo $form->field($model, 'equipment_id')->inline(true)->radiolist(['1' => 'Software', '2' => 'Hardware', '3' => 'อื่นๆ']);
?>
            </div>
            <div class="col-md-5">
              <?php 
echo '<label>วันที่/เวลา ที่ดำเนินการ</label>';
echo DateTimePicker::widget(['model' => $model, 'attribute' => 'datetime', 'options' => ['placeholder' => 'เลือกวันที่ และเวลา ...'], 'pickerButton' => ['icon' => 'time'], 'removeButton' => false, 'pluginOptions' => ['todayHighlight' => true, 'autoclose' => true, 'showSeconds' => false, 'showMeridian' => false, 'minuteStep' => 1, 'secondStep' => 5], 'language' => 'th']);
?>
            </div>

          </div>
Exemplo n.º 13
0
 public function secInfo($id)
 {
     return Section::find($id);
 }
Exemplo n.º 14
0
use yii\helpers\ArrayHelper;
use app\models\Section;
use app\models\Catalog;
/* @var $this yii\web\View */
/* @var $model app\models\Product */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="product-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'section_id')->dropDownList(ArrayHelper::map(Section::find()->with('catalog')->all(), 'id_section', function ($items) {
    return $items->catalog->catalog_name . ' -> ' . $items->section_name;
}));
?>

    <?php 
echo $form->field($model, 'product_name')->label('Продукт')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'description')->label('Описание')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'price')->label('Цена')->textInput(['maxlength' => true]);
?>
Exemplo n.º 15
0
 public static function section($data)
 {
     $data = Section::find()->where(['id' => $data])->one();
     return $data->section_name;
 }
Exemplo n.º 16
0
                            console.log(data);
                            $( "select#assignedform-subject_id" ).html(data);
                                $.post( "' . Yii::$app->urlManager->createUrl('assign-subject/section?id=') . '"+parseInt($("#assignedform-grade_level_id").val()), function( data ) {
                                    $("#assignedform-section_id").find("option").remove();
                                    $("#assignedform-section_id").each(function(){
                                    $(this).append(data);
                                });
                            });
                        })'])->label(false);
?>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-4 col-md-12 col-sm-12">
                    <?php 
echo $form->field($model, 'section_id', ['inputTemplate' => '<label style="padding: 0; color: #555; font-weight: 600;">Grade Level</label>{input}', 'inputOptions' => ['class' => 'form-control pva-form-control']])->dropDownList(ArrayHelper::map(Section::find()->all(), 'id', 'section_name'), ['id', 'section_name'])->label(false);
?>
                </div>
            </div>
        </div>
    </div>
    <div class="three wide rounded column">
        <div class="column">
            <?php 
echo Options::render(['scenario' => Yii::$app->controller->action->id, 'id' => $model->id, 'exist' => false]);
?>
        </div>
    </div>
</div>
<?php 
ActiveForm::end();
Exemplo n.º 17
0
 public static function itemsAlias($key)
 {
     $items = ['eqmType' => ArrayHelper::map(Comequipmenttype::find()->all(), 'id', 'name'), 'comBrand' => ArrayHelper::map(Combrand::find()->all(), 'id', 'name'), 'warranty' => ArrayHelper::map(Comwarranty::find()->all(), 'id', 'name'), 'dealer' => ArrayHelper::map(Comdealer::find()->all(), 'id', 'dealerName'), 'location' => ArrayHelper::map(Section::find()->all(), 'id', 'name'), 'status' => [1 => 'กำลังใช้งาน', 2 => 'พร้อมใช้งาน', 3 => 'อยู่ระหว่างซ่อม', 4 => 'ส่งซ่อม', 5 => 'ชำรุด/ซ่อมไม่ได้', 6 => 'จำหน่ายออก']];
     return ArrayHelper::getValue($items, $key, []);
     //return array_key_exists($key, $items) ? $items[$key] : [];
 }
Exemplo n.º 18
0
 /**
  * Импорт модераторов
  * Взят вордовский файл с секциями для инжененрных классов
  * Таблица скопирована в эксель и сохранена как csv
  * Ручками подправлено так, чтобы в строке были полностью данные по людям:
  * 1 столбец: номер
  * 2 столбец: ФИО и слова (ответственный эксперт)
  * 3 столбец: ВУЗ
  * 4 столбец: email
  * могут быть пустые строки
  */
 public function actionImportmoderate($filename, $idConference = 1)
 {
     if (($hd = fopen($filename, "r")) !== false) {
         $aFields = ['', 'us_name', 'us_description', 'us_email'];
         $aResultData = [];
         $sCurSection = '';
         $nSectionId = 0;
         $nRow = 0;
         while (($data = fgetcsv($hd, 2000, ";")) !== false) {
             $nRow++;
             $num = count($data);
             if ($num < 4) {
                 $this->printStr("Error fields: " . implode(', ', $data) . " num = " . $num . " [{$nRow}]\n\n");
                 continue;
             }
             // *************************************************************************************************
             // конвертируем в UTF-8
             $data = array_map(function ($s) {
                 return iconv('CP1251', 'UTF-8', $s);
             }, $data);
             // *************************************************************************************************
             // тут пробуем найти секцию в строке, где только в первой ячейке название
             if (!empty($data[0]) && empty($data[1])) {
                 $aSec = Section::find()->where(['sec_title' => $data[0], 'sec_cnf_id' => $idConference])->all();
                 if (count($aSec) != 1) {
                     $this->printStr("Error find section: " . $data[0] . " n = " . count($aSec) . " [{$nRow}]\n\n");
                     break;
                     //                        continue;
                 }
                 $sCurSection = $aSec[0]->sec_title;
                 $nSectionId = $aSec[0]->sec_id;
                 $this->printStr("New Section: " . $aSec[0]->sec_title . " [{$aSec[0]->sec_id}]\n\n");
                 continue;
             }
             //                $this->printStr(
             //                    "DATA: " . implode(', ', $data) . " num = ".$num." [{$nRow}]\n\n"
             //                );
             // *************************************************************************************************
             // тут пропускаем строку с заголовками колонок
             if (strpos($data[1], 'Фамилия') !== false && strpos($data[2], 'ВУЗ') !== false) {
                 //                    $this->printStr(
                 //                        "Col titles: " . implode(', ', $data) . " num = ".$num." [{$nRow}]\n\n"
                 //                    );
                 continue;
             }
             // *************************************************************************************************
             // тут получаем данные по полям строки
             $bEmpty = true;
             // это останется true в полностью пустой строке
             $aAttr = [];
             for ($i = 0; $i < $num; $i++) {
                 if (!empty($data[$i])) {
                     $bEmpty = false;
                     //                        $this->printStr(
                     //                            "row [{$nRow}]: $i = " . $data[$i] . " -> {$aFields[$i]}\n\n"
                     //                        );
                     if (!empty($aFields[$i])) {
                         $aAttr[$aFields[$i]] = $data[$i];
                     }
                 }
             }
             // *************************************************************************************************
             // тут пропускаем полностью пустую строку
             if ($bEmpty) {
                 //                    $this->printStr(
                 //                        "Empty row: " . implode(', ', $data) . " num = ".$num." [{$nRow}]\n\n"
                 //                    );
                 continue;
             }
             // *************************************************************************************************
             // тут пропускаем без почты
             if (!isset($aAttr['us_email'])) {
                 $this->printStr("No email: " . implode(', ', $data) . " [{$nRow}]\n\n");
                 continue;
             }
             $oUser = User::find()->where(['us_email' => $aAttr['us_email']])->one();
             if (strpos($aAttr['us_name'], '(ответственный эксперт)') !== false) {
                 $aAttr['us_name'] = str_replace('(ответственный эксперт)', '', $aAttr['us_name']);
                 $aAttr['us_description'] = "ответственный эксперт \t " . $aAttr['us_description'];
             }
             //                $this->printStr(
             //                    "Data row: " . print_r($aAttr, true) . " [{$nRow}]\n\n"
             //                );
             if ($oUser === null) {
                 //нового заводим
                 $oUser = new User();
                 $oUser->scenario = 'modregister';
                 $aAttr['password'] = Yii::$app->security->generateRandomString(6);
                 $oUser->us_group = User::USER_GROUP_MODERATOR;
                 $oUser->attributes = $aAttr;
                 $oUser->sectionids = [$nSectionId];
                 $oUser->us_active = User::STATUS_ACTIVE;
                 if (!$oUser->save()) {
                     $this->printStr("Error save new user: "******" [{$nRow}]\n\n");
                 } else {
                     $aResultData[] = ['us_name' => $aAttr['us_name'], 'password' => $aAttr['password'], 'us_description' => $aAttr['us_description'], 'section' => $sCurSection, 'us_email' => $aAttr['us_email']];
                 }
             } else {
                 // пробуем добавить новую секцию
                 if (!in_array($nSectionId, $oUser->sectionids)) {
                     $oUser->sectionids = array_merge($oUser->sectionids, [$nSectionId]);
                     if (!$oUser->save()) {
                         $this->printStr("Error save user sections: " . print_r($oUser->getErrors(), true) . print_r($oUser->sectionids, true) . " [{$nRow}]\n\n");
                     } else {
                         //                            $this->printStr(
                         //                                "Save user sections: " . print_r($oUser->attributes, true) . print_r($oUser->sectionids, true) . " [{$nRow}]\n\n"
                         //                            );
                     }
                 } else {
                     //                        $this->printStr(
                     //                            "User has section [{$nSectionId}]: " . print_r($oUser->attributes, true) . print_r($oUser->sectionids, true) . " [{$nRow}]\n\n"
                     //                        );
                 }
             }
             //                break;
         }
         fclose($hd);
         if (count($aResultData) > 0) {
             $sFile = dirname($filename) . DIRECTORY_SEPARATOR . 'users-' . time() . '.csv';
             $this->printResult($aResultData, $sFile);
             $this->printStr("Users save: " . count($aResultData) . ", file {$sFile}\n\n");
         }
     } else {
         echo "\n\nCan't open file {$filename}\n\n";
     }
 }