コード例 #1
0
 /**
  * Tests generating options for a department selection list with
  * set spaces in front to the option
  */
 public function testGetDepartmentSelectionListSpaces()
 {
     global $departments_count;
     $departments_count = 0;
     $options = getDepartmentSelectionList(1, array(), 0, 1);
     if ($this->_AppUI->isActiveModule('departments')) {
         $this->assertEquals('<option value="1">&nbsp;Department 1</option>', $options);
     } else {
         $this->assertEquals('', $options);
     }
     $options = getDepartmentSelectionList(1, array(), 0, 5);
     if ($this->_AppUI->isActiveModule('departments')) {
         $this->assertEquals('<option value="1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Department 1</option>', $options);
     } else {
         $this->assertEquals('', $options);
     }
 }
コード例 #2
0
ファイル: addedit.php プロジェクト: kilivan/dotproject
function getDepartmentSelectionList($company_id, $checked_array = array(), $dept_parent = 0, $spaces = 0)
{
    global $departments_count;
    $parsed = '';
    if ($departments_count < 6) {
        $departments_count++;
    }
    $q = new DBQuery();
    $q->addTable('departments');
    $q->addQuery('dept_id, dept_name');
    $q->addWhere("dept_parent = '{$dept_parent}' and dept_company = '{$company_id}'");
    $q->addOrder('dept_name');
    $depts_list = $q->loadHashList("dept_id");
    foreach ($depts_list as $dept_id => $dept_info) {
        $selected = in_array($dept_id, $checked_array) ? ' selected="selected"' : '';
        $parsed .= '<option value="' . $dept_id . '"' . $selected . '>' . str_repeat('&nbsp;', $spaces) . $dept_info['dept_name'] . '</option>';
        $parsed .= getDepartmentSelectionList($company_id, $checked_array, $dept_id, $spaces + 5);
    }
    return $parsed;
}
コード例 #3
0
ファイル: addedit.php プロジェクト: illuminate3/dotproject
function getDepartmentSelectionList($company_id, $checked_array = array(), $dept_parent = 0, $spaces = 0)
{
    global $departments_count;
    $q = new DBQuery();
    $parsed = '';
    if ($departments_count < 10) {
        $departments_count++;
    }
    $q->addTable('departments');
    $q->addQuery('dept_id, dept_name');
    $q->addWhere('dept_parent = ' . $dept_parent);
    $q->addWhere('dept_company = ' . $company_id);
    $sql = $q->prepare();
    $depts_list = db_loadHashList($sql, 'dept_id');
    $q->clear();
    foreach ($depts_list as $dept_id => $dept_info) {
        if (mb_strlen($dept_info['dept_name']) > 30) {
            $dept_info['dept_name'] = mb_substr($dept_info['dept_name'], 0, 28) . '...';
        }
        $selected = in_array($dept_id, $checked_array) ? ' selected="selected"' : '';
        $parsed .= '<option value="' . $dept_id . '"' . $selected . '>' . str_repeat('&nbsp;', $spaces) . $dept_info['dept_name'] . '</option>';
        $parsed .= getDepartmentSelectionList($company_id, $checked_array, $dept_id, $spaces + 5);
    }
    return $parsed;
}
コード例 #4
0
function getDepartmentSelectionList($company_id, $checked_array = array(), $dept_parent = 0, $spaces = 0)
{
    global $departments_count, $AppUI;
    $parsed = '';
    if ($departments_count < 6) {
        $departments_count++;
    }
    $depts_list = CDepartment::getDepartmentList($AppUI, $company_id, $dept_parent);
    foreach ($depts_list as $dept_id => $dept_info) {
        $selected = in_array($dept_id, $checked_array) ? ' selected="selected"' : '';
        $parsed .= '<option value="' . $dept_id . '"' . $selected . '>' . str_repeat('&nbsp;', $spaces) . $dept_info['dept_name'] . '</option>';
        $parsed .= getDepartmentSelectionList($company_id, $checked_array, $dept_id, $spaces + 5);
    }
    return $parsed;
}
コード例 #5
0
ファイル: addedit.php プロジェクト: klr2003/sourceread
function getDepartmentSelectionList($company_id, $checked_array = array(), $dept_parent = 0, $spaces = 0)
{
    global $departments_count;
    $parsed = '';
    if ($departments_count < 6) {
        $departments_count++;
    }
    $q = new DBQuery();
    $q->addTable('departments');
    $q->addQuery('dept_id, dept_name');
    $q->addWhere("dept_parent = '{$dept_parent}' and dept_company = '{$company_id}'");
    $q->addOrder('dept_name');
    $depts_list = $q->loadHashList("dept_id");
    foreach ($depts_list as $dept_id => $dept_info) {
        $selected = in_array($dept_id, $checked_array) ? " selected=\"selected\"" : "";
        $parsed .= "<option value=\"{$dept_id}\"{$selected}>" . str_repeat("&nbsp;", $spaces) . $dept_info["dept_name"] . "</option>";
        $parsed .= getDepartmentSelectionList($company_id, $checked_array, $dept_id, $spaces + 5);
    }
    return $parsed;
}
コード例 #6
0
ファイル: addedit.php プロジェクト: juliogallardo1326/proc
function getDepartmentSelectionList($company_id, $checked_array = array(), $dept_parent = 0, $spaces = 0)
{
    global $departments_count;
    $parsed = '';
    if ($departments_count < 10) {
        $departments_count++;
    }
    $sql = "select dept_id, dept_name\n\t        from departments\n\t        where dept_parent      = '{$dept_parent}'\n\t              and dept_company = '{$company_id}'";
    $depts_list = db_loadHashList($sql, "dept_id");
    foreach ($depts_list as $dept_id => $dept_info) {
        $selected = in_array($dept_id, $checked_array) ? "selected" : "";
        if (strlen($dept_info["dept_name"]) > 30) {
            $dept_info["dept_name"] = substr($dept_info["dept_name"], 0, 28) . "...";
        }
        $parsed .= "<option value='{$dept_id}' {$selected}>" . str_repeat("&nbsp;", $spaces) . $dept_info["dept_name"] . "</option>";
        $parsed .= getDepartmentSelectionList($company_id, $checked_array, $dept_id, $spaces + 5);
    }
    return $parsed;
}
コード例 #7
0
ファイル: addedit.php プロジェクト: viniciusbudines/sisnuss
                                </td>
                                <td rowspan="6" valign="top">
                                    <?php 
if ($AppUI->isActiveModule('contacts') && canView('contacts')) {
    echo '<input type="button" class="button" value="' . $AppUI->_('Select contacts...') . '" onclick="javascript:popContacts();" />';
}
if ($AppUI->isActiveModule('departments') && canAccess('departments')) {
    //Build display list for departments
    $company_id = $project->project_company;
    $selected_departments = array();
    if ($project_id) {
        $myDepartments = CProject::getDepartments($AppUI, $project_id);
        $selected_departments = count($myDepartments) > 0 ? array_keys($myDepartments) : array();
    }
    $departments_count = 0;
    $department_selection_list = getDepartmentSelectionList($company_id, $selected_departments);
    if ($department_selection_list != '' || $project_id) {
        $department_selection_list = $AppUI->_('Departments') . '<br /><select name="project_departments[]" multiple="multiple" class="text"><option value="0"></option>' . $department_selection_list . '</select>';
    } else {
        $department_selection_list = '<input type="button" class="button" value="' . $AppUI->_('Select department...') . '" onclick="javascript:popDepartment();" /><input type="hidden" name="project_departments"';
    }
    // Let's check if the actual company has departments registered
    if ($department_selection_list != '') {
        echo '<br />' . $department_selection_list;
    }
}
?>
                                </td>
                            </tr>
                            <tr>
                                <td align="right" nowrap="nowrap"><?php 
コード例 #8
0
function getDepartmentSelectionList($company_id, $checked_array = array(), $dept_parent = 0, $spaces = 0)
{
    global $departments_count, $AppUI;
    $parsed = '';
    if ($AppUI->isActiveModule('departments') && canView('departments')) {
        $department = new CDepartment();
        $depts_list = $department->departments($company_id, $dept_parent);
        foreach ($depts_list as $dept_id => $dept_info) {
            $selected = in_array($dept_id, $checked_array) ? ' selected="selected"' : '';
            $parsed .= '<option value="' . $dept_id . '"' . $selected . '>' . str_repeat('&nbsp;', $spaces) . $dept_info['dept_name'] . '</option>';
            $parsed .= getDepartmentSelectionList($company_id, $checked_array, $dept_id, $spaces + 5);
        }
    }
    return $parsed;
}
コード例 #9
0
ファイル: projects.test.php プロジェクト: eureka2/web2project
 /**
  * Tests generating options for a department selection list with
  * set spaces in front to the option
  */
 public function testGetDepartmentSelectionListSpaces()
 {
     global $AppUI, $departments_count;
     $departments_count = 0;
     $options = getDepartmentSelectionList(1, array(), 0, 1);
     $this->assertEquals('<option value="1">&nbsp;Department 1</option>', $options);
     $options = getDepartmentSelectionList(1, array(), 0, 5);
     $this->assertEquals('<option value="1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Department 1</option>', $options);
 }