Added custom multi-selectable fields to the ZenTao BUG page

At present, the fields on the ZenTao BUG page are relatively common. If you need more fields, you need to open a second version of ZenTao. The following is an example of adding [Discovery Stage] and [Environment] custom fields:

1. Execute this SQL in the database

Enter the ZenTao initial page, select [Database Management], enter the corresponding user name and password, and execute in the database:
ALTER TABLE zt_bug ADD COLUMN stage VARCHAR(100) AFTER severity;
ALTER TABLE zt_bug ADD COLUMN environment VARCHAR(255) AFTER severity;

2. Modify zh-cn

Enter the server directory /opt/zbox/app/zentao/module/bug/lang/ (note: /opt/zbox/app/ is the ZenTao installation directory), and add the following to the zh-cn.php file:

/* Field list. */
$lang->bug->stage = 'Discovery stage';
$lang->bug->environment = 'Environment';

Same as the file, /* list of values for each field. */ Add the following below:

/*BUG new field by Xiao Gao*/
$lang->bug->stageList['tst'] = 'SIT Test';
$lang->bug->stageList['req'] = 'Requirement stage';
$lang->bug->stageList['des'] = 'Design Stage';
$lang->bug->stageList['dev'] = 'Development stage';
$lang->bug->stageList['uat'] = 'UAT Acceptance';
$lang->bug->stageList['del'] = 'Delivery Acceptance';
$lang->bug->stageList['pro'] = 'Online production';
$lang->bug->stageList['ato'] = 'Automated Test';

$lang->bug->environmentList['sit'] = 'SIT environment';
$lang->bug->environmentList['uat'] = 'UAT environment';
$lang->bug->environmentList['ban'] = 'Main line grayscale';
$lang->bug->environmentList['pre'] = 'PRE production';
$lang->bug->environmentList['dev'] = 'DEV environment';

3. Modify the model.php page

Enter the /opt/zbox/app/zentao/module/bug/model.php file and add code after lines 93 and 744:

 ->join('environment', ',')


4. Modify the create.html.php page

Go to /opt/zbox/app/zentao/module/bug/view/ and add the following code after line 177 of the create.html.php file:

 <td>
                <div class='table-col' id='stageBox'>
                 <div class='input-group'>
                  <span class='input-group-addon'><?php echo $lang->bug->stage?></span>
                  <?php echo html::select('stage', $lang->bug->stageList, $stage, "class='form-control chosen'");?>
                 </div>
                </div>
                <div class='table-col' id='environmentBox'>
                  <div class='input-group'>
                    <span class='input-group-addon fix-border'><?php echo $lang->bug->environment?></span>
                    <?php echo html::select('environment[]', $lang->bug->environmentList, $environment, "class='form-control chosen' multiple");?>
                  </div>
                </div>
                </td>

Effect after modification

5. Modify the view.html.php page

Go to /opt/zbox/app/zentao/module/bug/view/ and add the following code after line 263 of the view.html.php file:

 <tr>
                  <th><?php echo $lang->bug->stage;?></th>
                  <td><?php if(isset($lang->bug->stageList[$bug->stage])) echo $lang->bug->stageList[$bug->stage]; else echo $bug-> stage;?></td>
                </tr>
                <tr>
                  <th><?php echo $lang->bug->environment;?></th>
                  <td>
                  <?php $environmentList = explode(',', $bug->environment);?>
                  <?php if($environmentList):?>
                  <p class='environmentContent'>
                    <?php foreach($environmentList as $environment):?>
                    <?php if($environment) echo "<span class='label label-outline'>" . zget($lang->bug->environmentList, $environment) . "</span>" ;?>
                    <?php endforeach;?>
                  </p>
                  <?php endif;?>
                  </td>
                </tr>


Effect after modification

6. Modify the edit.html.php page

Go to /opt/zbox/app/zentao/module/bug/view/ and add the following code after line 193 of the edit.html.php file:

 <tr>
                  <th><?php echo $lang->bug->stage;?></th>
                  <td><?php echo html::select('stage', $lang->bug->stageList, $bug->stage, "class='form-control chosen'"); ? ></td>
                </tr>
                <tr>
                  <th><?php echo $lang->bug->environment;?></th>
                  <td><?php echo html::select('environment[]', $lang->bug->environmentList, $bug->environment, "class='form-control chosen' multiple" );?></td>
                </tr>

Result after modification

7. Modify the config.php page

Add fields in exported excel: Go to /opt/zbox/app/zentao/module/bug/ and add the following code after lines 16 and 30 of the config.php file:

stage, environment,

Add a field to the search bar: Continue with line 89 of this file and add the following code:

$config->bug->search['fields']['stage'] = $lang->bug->stage;
$config->bug->search['fields']['environment'] = $lang->bug->environment;

Continue with line 137 of this file and add the following code:

$config->bug->search['params']['stage'] = array('operator' => 'include', 'control' => ' select', 'values' => $lang->bug->stageList);
$config->bug->search['params']['environment'] = array('operator' => 'include', 'control' => 'select' , 'values' => $lang->bug->environmentList);