Пример #1
0
 public function actionIndex()
 {
     Yii::beginProfile('requirements');
     $criteria = RequirementApi::getCriteriaObjectForUser(Yii::app()->user->id);
     $totalRequirements = Requirement::model()->count($criteria);
     $pages = new CPagination($totalRequirements);
     $pages->pageSize = Yii::app()->params['resultsPerPage'];
     $pages->applyLimit($criteria);
     $requirements = RequirementApi::searchMyRequirementWithCriteria($criteria);
     //$requirements=RequirementApi::getRequirementByUserId(Yii::app()->user->id);
     $this->render('index', array('requirements' => $requirements, 'pages' => $pages, 'totalRequirements' => $totalRequirements));
     Yii::endProfile('requirements');
 }
function requirement_row($req, $indentation, TableCreator $table_creator, $filter_cat, $filter_pri)
{
    $ret = "";
    if ((!is_numeric($filter_cat) || $req->category == $filter_cat) && (!is_numeric($filter_pri) || $req->priority == $filter_pri)) {
        $pkg_name = array();
        foreach ($req->classes as $c) {
            array_push($pkg_name, $table_creator->link($c->full_name(), $c->name));
        }
        array_unique($pkg_name);
        sort($pkg_name);
        $cells = array($table_creator->child_indentation($indentation), $table_creator->link($req->public_id(), $req->public_id()), implode("\n\n", $pkg_name));
        $ret .= $table_creator->row($cells);
    }
    $nested = Requirement::model()->with('classes')->findAll("t.parent=:parent", array(':parent' => $req->id_requirement));
    foreach ($nested as $nreq) {
        $ret .= requirement_row($nreq, $indentation + 1, $table_creator, $filter_cat, $filter_pri);
    }
    return $ret;
}
Пример #3
0
 public function actionRequirementHandle()
 {
     if (parent::_ajax_acl('evaluate_update')) {
         $id = Yii::app()->request->getPost('id');
         $requirement = Requirement::model()->findByPk($id);
         if (!empty($requirement)) {
             $requirement->status = 1;
             if ($requirement->save()) {
                 AdminLogger::_create(array('catalog' => 'update', 'intro' => '更新学区专栏房源需求处理状态,ID:' . $requirement->id));
                 echo CJSON::encode(array('success' => true, 'msg' => '需求处理成功'));
             } else {
                 echo CJSON::encode(array('success' => false, 'msg' => '操作失败,请联系管理员'));
             }
         } else {
             echo CJSON::encode(array('success' => false, 'msg' => '此需求不存在'));
         }
     } else {
         echo CJSON::encode(array('success' => false, 'msg' => '当前角色组无权限进行此操作,请联系管理员授权'));
     }
 }
function requirement_row($req, $indentation, TableCreator $table_creator, $filter_cat, $filter_pri)
{
    $ret = "";
    if ((!is_numeric($filter_cat) || $req->category == $filter_cat) && (!is_numeric($filter_pri) || $req->priority == $filter_pri)) {
        $source_desc = array();
        foreach ($req->sources as $rc) {
            $rc->with('useCase', 'externalSource');
            if (isset($rc->useCase)) {
                array_push($source_desc, $table_creator->link($rc->useCase->public_id(), $rc->useCase->public_id()));
            } else {
                array_push($source_desc, $rc->externalSource->description);
            }
        }
        sort($source_desc);
        $cells = array($table_creator->child_indentation($indentation), $table_creator->anchor($req->public_id(), $req->public_id()), $req->category0->name . "\n\n" . $req->priority0->name, $req->description, implode("\n\n", $source_desc));
        $ret .= $table_creator->row($cells);
    }
    $nested = Requirement::model()->with('sources', 'category0', 'priority0')->findAll("t.parent=:parent", array(':parent' => $req->id_requirement));
    foreach ($nested as $nreq) {
        $ret .= requirement_row($nreq, $indentation + 1, $table_creator, $filter_cat, $filter_pri);
    }
    return $ret;
}
Пример #5
0
 /**
  * This method gets userId and array of data from user. 
  * Returns model if update successful
  * Returns null if creation fails
  ** Data arrary should have the following Hash keys
  *  string $i_want_to
  *  string $description
  *  double $covered_area_from
  *  double $covered_area_to
  *  double $plot_area_from
  *  double $plot_area_to
  *  double $min_price
  *  double $max_price
  *
  * @param int $userId,array $data
  * @return model|false
  */
 public static function updateRequirement($userId, $data)
 {
     $specialist = Requirement::model()->find('user_id=:userId', array(':userId' => $userId));
     if ($specialist) {
         $specialist->attributes = $data;
         $specialist->save();
         return $specialist;
     } else {
         return false;
     }
 }
<?php

$cats = RequirementCategory::model()->findAll();
$pris = RequirementPriority::model()->findAll();
$titles = array("Categoria");
foreach ($pris as $p) {
    array_push($titles, $p->name);
}
$table = $table_creator->begin_table(count($pris) + 1) . $table_creator->heading_row($titles);
foreach ($cats as $c) {
    $row = array($c->name);
    foreach ($pris as $p) {
        array_push($row, Requirement::model()->count("priority=:p and category=:c", array("p" => $p->id_priority, "c" => $c->id_category)));
    }
    $table .= $table_creator->row($row);
}
$table .= $table_creator->caption("Riepilogo requisiti") . $table_creator->end_table();
if ($table_creator->id() != 'html' && !$raw) {
    echo CodeGen::generic_render_code($table, 'latex', true);
} else {
    echo $table;
}
Пример #7
0
    echo CHtml::dropDownList("priority", $filter_pri, $pris);
    echo "<br/>";
    echo CHtml::submitButton("Filter");
    echo "</form></div>";
    echo "<hr/>";
}
function test_row(Requirement $req, $indentation, TableCreator $table_creator, $filter_cat, $filter_pri)
{
    $test = $req->with('system_test')->system_test;
    $ret = "";
    if (isset($req->system_test) && (!is_numeric($filter_cat) || $req->category == $filter_cat) && (!is_numeric($filter_pri) || $req->priority == $filter_pri)) {
        $test->with('test');
        $ret .= $table_creator->row(array($test->public_id(), $test->test->description, 'success', $table_creator->anchor($req->public_id(), $req->public_id())));
    }
    $nested = $req->with('requirements')->requirements;
    foreach ($nested as $nreq) {
        $ret .= test_row($nreq, $indentation + 1, $table_creator, $filter_cat, $filter_pri);
    }
    return $ret;
}
$table = $table_creator->begin_table("|l|p{6cm}|l|l|") . $table_creator->heading_row(array("Test", "Descrizione", "Stato", "Requisito"));
$toplevel = Requirement::model()->with('sources')->findAll("t.parent is null");
foreach ($toplevel as $req) {
    $table .= test_row($req, 0, $table_creator, $filter_cat, $filter_pri);
}
$table .= $table_creator->caption("Tabella di tracciamento test di sistema / requisiti") . $table_creator->end_table();
if ($table_creator->id() != 'html' && !$raw) {
    echo CodeGen::generic_render_code($table, 'latex', true);
} else {
    echo $table;
}
<?php

/// @warning HARD CODED DB PK!!!!!!!!!!!
$reqs = Requirement::model()->findAll("category != 4 and priority != 4");
$table = $table_creator->begin_table("|m{3cm}|m{6cm}|m{4cm}|") . $table_creator->heading_row(array("Id", "Descrizione", "Implementazione"));
foreach ($reqs as $r) {
    $id = $r->public_id();
    $app = $r->apported;
    $strapp = "";
    if ($app) {
        $strapp = "\\color{dkgreen}{Implementato}";
    } else {
        $strapp = "\\color{dkred}{Non implementato}";
    }
    $table .= $table_creator->row(array($id, $r->description, $strapp));
}
$table .= $table_creator->caption("Tabella implementazione requisiti opzionali e desiderabili") . $table_creator->end_table();
if ($table_creator->id() != 'html' && !$raw) {
    echo CodeGen::generic_render_code($table, 'latex', true);
} else {
    echo $table;
}
 /**
  * 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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Requirement::model()->findByPk($id);
     $model->with('category0', 'priority0', 'parent0', 'sources', 'validation0', 'system_test');
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #10
0
 /**
  * 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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Requirement::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
<?php

function req_row(Requirement $req, $indentation, TableCreator $table_creator)
{
    $req->with('validationTest', 'requirements');
    $ret = "";
    $ret .= $table_creator->row(array($table_creator->child_indentation($indentation), $req->public_id(), $req->validationTest == null ? '' : $req->validationTest->public_id()));
    $nested = $req->requirements;
    foreach ($nested as $c) {
        $ret .= req_row($c, $indentation + 1, $table_creator);
    }
    return $ret;
}
$toplevel = Requirement::model()->findAll("t.parent is null");
$table = $table_creator->begin_table("|r l|l|") . $table_creator->heading_row(array("Requisito" => 2, "Validazione"));
foreach ($toplevel as $req) {
    $table .= req_row($req, 0, $table_creator);
}
$table .= $table_creator->caption("Tabella requisiti / test validazione") . $table_creator->end_table();
if ($table_creator->id() != 'html' && !$raw) {
    echo CodeGen::generic_render_code($table, 'latex', true);
} else {
    echo $table;
}