$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;
}
$toplevel = Requirement::model()->with('sources', 'category0', 'priority0')->findAll("t.parent is null");
$table = $table_creator->begin_table("|r l|p{2cm}|p{6cm}|p{2cm}|") . $table_creator->heading_row(array("Requisito" => 2, "Tipologia", "Descrizione", "Fonti"));
foreach ($toplevel as $req) {
    $table .= requirement_row($req, 0, $table_creator, $filter_cat, $filter_pri);
}
$fc = is_numeric($filter_cat) ? strtolower(RequirementCategory::model()->findByPk($filter_cat)->latex_name) . " " : "";
$table .= $table_creator->caption("Tabella requisiti {$fc}/ fonti") . $table_creator->end_table();
if ($table_creator->id() != 'html' && !$raw) {
    echo CodeGen::generic_render_code($table, 'latex', true);
} else {
    echo $table;
}
<?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;
}
Beispiel #3
0
<?php 
Yii::app()->clientScript->registerScript('remove_source', "\n\nfunction rmitem(element)\n{\n    element = document.getElementById(element);\n    \n    var list_input = document.getElementById('sourcelist');\n    \n    var oldlist = JSON.parse(list_input.value);\n    \n    var numid = element.id.match(/[0-9]+/);\n    \n    for ( var i = 0; i < oldlist.length; i++ )\n    {\n        if ( oldlist[i] == numid )\n        {\n            oldlist.splice(i,1);\n            i--;\n        }\n    }\n    list_input.value = JSON.stringify(oldlist);\n    \n    element.parentNode.removeChild(element);\n}", CClientScript::POS_BEGIN);
Yii::app()->clientScript->registerScript('insert_source', "\n\nvar currentid = -1;\n\n\$('#addsource').click(function(){\n\n    if ( currentid != -1 )\n    {\n        var list_input = \$('#sourcelist');\n        var desc_container = \$('#source_desc_list');\n        var autocomplete = \$('#source_autocomplete');\n        \n        var oldlist = JSON.parse(list_input.val());\n        oldlist.push(currentid);\n        list_input.val ( JSON.stringify(oldlist) );\n        \n        var itemid = 'source_item_'+currentid;\n        desc_container.append(\n            '<li id=\"'+itemid+'\">'+\n                autocomplete.val()+' ('+currentid+')'+\n                '<input type=\"button\" value=\"Remove\" onClick=\"rmitem('+itemid+');\" />'+\n            '</li>');\n        \n        autocomplete.val('');\n        \n        currentid = -1;\n    }\n    return false;\n});\n\n\n");
$form = $this->beginWidget('CActiveForm', array('id' => 'requirement-form', 'enableAjaxValidation' => false));
?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php 
echo $form->errorSummary($model);
?>

	<div class="row">
        <?php 
echo $form->labelEx($model, 'category');
echo $form->dropDownList($model, 'category', CHtml::listData(RequirementCategory::model()->findAll(), 'id_category', 'name'));
echo $form->error($model, 'category');
?>
	</div>

	<div class="row">
        <?php 
echo $form->labelEx($model, 'priority');
echo $form->dropDownList($model, 'priority', CHtml::listData(RequirementPriority::model()->findAll(), 'id_priority', 'name'));
echo $form->error($model, 'priority');
?>
 
	</div>

	<div class="row">
        <?php 
<?php

if (!$raw) {
    $cats = CHtml::listData(RequirementCategory::model()->findAll(), "id_category", "name");
    $cats[""] = "Tutti";
    $pris = CHtml::listData(RequirementPriority::model()->findAll(), "id_priority", "name");
    $pris[""] = "Tutti";
    echo "<div><form>";
    echo CHtml::label("Category", "category");
    echo CHtml::dropDownList("category", $filter_cat, $cats);
    echo "<br/>";
    echo CHtml::label("Priority", "priority");
    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;
Beispiel #5
0
<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<?php 
echo CHtml::link('Advanced Search', '#', array('class' => 'search-button'));
?>
<div class="search-form" style="display:none">
<?php 
$this->renderPartial('_search', array('model' => $model));
?>
</div><!-- search-form -->

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'requirement-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'enablePagination' => false, 'columns' => array('id_requirement:text:Id', array('class' => 'CDataColumn', 'header' => 'Id LaTeX', 'type' => 'html', 'value' => 'CHtml::link($data->public_id(),
                array("view","id"=>$data->id_requirement))'), 'apported', array('type' => 'html', 'name' => 'category', 'filter' => CHtml::listData(RequirementCategory::model()->findAll(), 'id_category', 'name'), 'value' => 'CHtml::link($data->category0->name,
                        array("index","Requirement[id_category]"=>$data->category0->id_category) )'), array('name' => 'priority', 'type' => 'html', 'filter' => CHtml::listData(RequirementPriority::model()->findAll(), 'id_priority', 'name'), 'value' => 'CHtml::link($data->priority0->name,
                        array("index","Requirement[id_priority]"=>$data->priority0->id_priority) )'), array('class' => 'CDataColumn', 'header' => 'Parent description', 'type' => 'html', 'value' => 'isset($data->parent0) ?
                        CHtml::link($data->parent0->description,
                                    array("view","id"=>$data->parent0->id_requirement) ) :
                        null'), 'parent', 'description', array('name' => 'validation', 'type' => 'html', 'filter' => CHtml::listData(RequirementValidation::model()->findAll(), 'id_validation', 'name'), 'value' => 'isset($data->validation0) ?
                    CHtml::link($data->validation0->name,
                        array("index","Requirement[id_validation]"=>
                            $data->validation0->id_validation) )    :
                    null'), array('class' => 'CDataColumn', 'header' => 'Test', 'type' => 'html', 'value' => 'isset($data->system_test) ?
                        CHtml::link($data->system_test->with("test")->test->description,
                            array("test/view",
                                  "id"=>$data->system_test->test->id_test) ) :
                        null'), array('class' => 'CButtonColumn'))));
 function actionCategories()
 {
     $model = new RequirementCategory();
     if (isset($_GET['edit'])) {
         $model_edit = RequirementCategory::model()->findByPk($_GET['edit']);
         if ($model_edit !== null) {
             $model = $model_edit;
         }
     }
     if (isset($_POST['RequirementCategory'])) {
         $model->attributes = $_POST['RequirementCategory'];
         $model->save();
     }
     $this->render('categories', array('model' => $model));
 }