コード例 #1
0
ファイル: EdboData.php プロジェクト: upmunspel/abiturient
 /**
  *  The HOPE!
  */
 public function search_rating()
 {
     $criteria = new CDbCriteria();
     $criteria->compare('Direction', $this->Direction, true);
     $criteria->compare('SpecCode', $this->SpecCode, true);
     $criteria->compare('EduForm', $this->EduForm, true);
     $criteria->compare('Specialization', $this->Specialization, true);
     $criteria->compare('EduQualification', $this->EduQualification, true);
     $criteria->addCondition('Status IN (' . $this->statuses . ')');
     //параметр сортування даних для формування рейтингу
     $rating_order = 'Benefit DESC,' . 'Quota DESC,' . 'RatingPoints DESC,' . 'PriorityEntry DESC';
     //якщо є відмітка першочергового вступу - що ж... нехай щастить!
     return EdboData::model()->findAll($criteria);
 }
コード例 #2
0
ファイル: rating.php プロジェクト: upmunspel/abiturient
                    <?php 
            echo $benefit['name'];
            ?>
                  </div> <?php 
        }
        ?>
 
              </div> <?php 
    }
}), array('header' => 'Рейтингові відмітки', 'htmlOptions' => array('style' => 'width: 200px;'), 'value' => function ($data, $row) {
    /* @var $data Personspeciality */
    $Total = 0.0;
    $doc_val = 0;
    $doc_val_zno = 0;
    if (!$data->edbo && $data->edboID) {
        $data->edbo = EdboData::model()->findByPk($data->edboID);
    }
    // 123
    $ConverAttestat = new ConvertAttestat();
    if ($data->QualificationID == 1) {
        $doc_val = round($data->PointDocValue, 2);
        $post = ConvertAttestat::model()->findall('twelve_p=:twelve_p', array(':twelve_p' => $doc_val));
        $doc_val = (double) $post[0]['two_hundred_p'] * Yii::app()->params['scoreweight_AtestatValue'];
    } else {
        $doc_val = $data->PointDocValue;
    }
    /*$post=ConvertAttestat::model()->find(array(
          'select'=>'two_hundred_p',
          'condition'=>'twelve_p=:twelve_p',
          'params'=>array(':twelve_p'=>'9.4'),
      ));*/
コード例 #3
0
 /**
  * Метод завантажує в БД дані із Excel-файлу (з використанням бібліотеки pear)
  * @param string $file повний шлях до файлу
  * @return array лічильники в результаті оновлення БД
  */
 protected function LoadExcelToDB($file)
 {
     /*потім дістаємо структуру таблиці edbo_data, 
      * щоб знати кількість і атрибути полів*/
     $SQL = "SHOW FULL COLUMNS FROM edbo_data";
     $connection = Yii::app()->db;
     $command = $connection->createCommand($SQL);
     $rowCount = $command->execute();
     // execute the non-query SQL
     $row_header = $command->queryAll();
     // execute a query SQL
     /********************************************/
     // initialize reader object
     $excel = new Spreadsheet_Excel_Reader();
     $excel->setOutputEncoding('UTF-8');
     // read spreadsheet data
     //$file = 'E:/RequestcGVAll1(1).xls';
     $excel->read($file);
     $numCols = $excel->sheets[0]['numCols'];
     $numRows = $excel->sheets[0]['numRows'];
     if ($rowCount != $numCols) {
         return array(false, 'К-сть полів не співпадає : ' . $rowCount . ' != ' . $numCols);
     }
     $id = 0;
     $inserted = 0;
     $updated = 0;
     /**********************************************************/
     for ($j = 1; $j <= $numRows; $j++) {
         $edbo_attributes = array();
         $id++;
         for ($i = 1; $i <= $numCols; $i++) {
             //беремо дані окремої комірки
             $cell = isset($excel->sheets[0]['cells'][$j][$i]) ? empty($excel->sheets[0]['cells'][$j][$i]) ? null : $excel->sheets[0]['cells'][$j][$i] : null;
             //далі перевірка типу атрибутів і приведення типу до відповідного
             $is_float = strstr($row_header[$i - 1]['Type'], 'float') !== false;
             $is_integer = strstr($row_header[$i - 1]['Type'], 'int') !== false;
             if ($is_float) {
                 $data_item = round(floatval(str_replace(',', '.', $cell)), 2);
             }
             if ($is_integer) {
                 $data_item = intval($cell);
             }
             if (!$is_float && !$is_integer) {
                 /*врахування розміру поля таблиці БД*/
                 $match = array();
                 preg_match('/\\(([0-9]+)\\)/', $row_header[$i - 1]['Type'], $match);
                 $data_size = isset($match[1]) ? $match[1] : 1024;
                 $data_item = mb_strlen($cell, 'utf8') > $data_size && !$is_float && !$is_integer ? mb_substr($cell, 0, $data_size, 'utf8') : $cell;
             }
             $edbo_attributes[$row_header[$i - 1]['Field']] = $data_item;
         }
         if (!is_numeric($edbo_attributes['ID'])) {
             //якщо поле з числовим ідентифікатором не є числом,
             // то далі нічого робити не потрібно
             $id--;
             continue;
         }
         //якщо рядок (кортеж) в таблиці БД існує, то його можна знайти по ID
         $edbo_existing_model = EdboData::model()->findByPk($edbo_attributes['ID']);
         $is_new = false;
         $is_change = false;
         if (!$edbo_existing_model) {
             //якщо ж не існує, то це новий запис у базу
             $is_new = true;
         }
         //порівняння прибулих значень з існуюючими;
         //якщо усі такі самі, то оновлювати не треба
         for ($k = 0; $k < $numCols && $edbo_existing_model; $k++) {
             $edbo_field_value = $edbo_existing_model->getAttribute($row_header[$k]['Field']);
             $income_field_value = $edbo_attributes[$row_header[$k]['Field']];
             $edbo_param = $edbo_field_value;
             $income_param = $income_field_value;
             $is_change = $income_param != $edbo_param;
             if ($is_change) {
                 break;
             }
         }
         if (!$is_new & !$is_change) {
             continue;
         }
         /*оновлення або створення нового запису в БД з перевірками*/
         $result_of_saving_new_model = false;
         if ($is_new) {
             //якщо кортежу з прибулим ID не існувало, то це новий запис (insert)
             $edbo_model = new EdboData();
             $inserted++;
             $edbo_model->attributes = $edbo_attributes;
             $result_of_saving_new_model = $edbo_model->save();
         }
         if ($is_new && !$result_of_saving_new_model && !empty($edbo_model->errors)) {
             //якщо виникла проблема при збереженні нового кортежу
             $err_msgs = array();
             foreach ($edbo_model->errors as $ferrors) {
                 foreach ($ferrors as $err) {
                     $err_msgs[] = $err;
                 }
             }
             $err_msg = implode(' & ', $err_msgs);
             return array(false, 'error (Row:' . $id . ') ' . $err_msg);
         }
         if ($is_new && $result_of_saving_new_model) {
             continue;
         }
         $result_of_saving_existing_model = false;
         if ($is_change) {
             //якщо кортеж з прибулим ID існував, то треба оновити запис (update)
             $updated++;
             $edbo_existing_model->attributes = $edbo_attributes;
             $result_of_saving_existing_model = $edbo_existing_model->save();
         }
         if ($is_change && !$result_of_saving_existing_model && !empty($edbo_existing_model->errors)) {
             //якщо виникли проблеми з оновленням
             $err_msgs = array();
             foreach ($edbo_existing_model->errors as $ferrors) {
                 foreach ($ferrors as $err) {
                     $err_msgs[] = $err;
                 }
             }
             $err_msg = implode(' & ', $err_msgs);
             return array(false, 'error (Row:' . $id . ') ' . $err_msg);
         }
         /**********************************************************/
     }
     $at_all = $id;
     //повернення лічильників
     return array($inserted, $updated, $at_all);
 }
コード例 #4
0
 /**
  * Список рейтингів конкретної спеціальності на основі даних ЄДЕБО
  */
 public function actionEdboratinglinks()
 {
     $criteria = new CDbCriteria();
     $criteria->order = 'EduQualification ASC, StructBranch ASC, Speciality ASC,Direction ASC,SpecCode ASC';
     $criteria->group = 'CONCAT(EduQualification," ",SpecCode," ",Direction," ",Specialization," ",EduForm)';
     echo "<html><meta charset='utf8'><head></head><body><ul>";
     foreach (EdboData::model()->findAll($criteria) as $spec) {
         $href1 = 'http://' . $_SERVER['SERVER_ADDR'] . ':' . $_SERVER['SERVER_PORT'] . '/abiturient/rating/rating/edborating?&Direction=' . urlencode($spec->Direction) . '&SpecCode=' . urlencode($spec->SpecCode) . '&EduForm=' . $spec->EduForm . '&statuses=' . urlencode('"Допущено","Рекомендовано"') . '&EduQualification=' . urlencode('Бакалавр') . '&Specialization=' . urlencode($spec->Specialization ? ' (' . $spec->Specialization . ')' : '');
         $href2 = 'http://' . $_SERVER['SERVER_ADDR'] . ':' . $_SERVER['SERVER_PORT'] . '/abiturient/rating/rating/edborating?&Direction=' . urlencode($spec->Direction) . '&SpecCode=' . urlencode($spec->SpecCode) . '&EduForm=' . $spec->EduForm . '&statuses=' . urlencode('"Рекомендовано"') . '&EduQualification=' . urlencode('Бакалавр') . '&Specialization=' . urlencode($spec->Specialization ? ' (' . $spec->Specialization . ')' : '');
         echo "<li><a href='" . $href1 . "' target='_blank'>" . $spec->EduQualification . ": " . $spec->StructBranch . ': ' . $spec->SpecCode . ' ' . $spec->Direction . ($spec->Specialization ? ' (' . $spec->Specialization . ')' : '') . ', форма: ' . $spec->EduForm . " --- допущено і рекомендовано</a></li>";
         echo "<li><a href='" . $href2 . "' target='_blank'>" . $spec->EduQualification . ": " . $spec->StructBranch . ': ' . $spec->SpecCode . ' ' . $spec->Direction . ($spec->Specialization ? ' (' . $spec->Specialization . ')' : '') . ', форма: ' . $spec->EduForm . " --- рекомендовано</a></li>";
     }
     echo "</ul></body></html>";
 }