예제 #1
0
 /**
  * Get Request Handler
  *
  * This method is called when a request is a GET
  *
  * @return array
  */
 public function executeGet()
 {
     $valid = $this->hasRequiredParameters($this->requiredParams);
     if ($valid instanceof Frapi_Error) {
         return $valid;
     }
     $username = $this->getParam('username');
     $password = $this->getParam('password');
     $project_id = $this->getParam('project_id', self::TYPE_INT);
     // Attempt to login as user, a little bit of a hack as we currently
     // require the $_POST['login'] var to be set as well as a global AppUI
     $AppUI = new CAppUI();
     $GLOBALS['AppUI'] = $AppUI;
     $_POST['login'] = '******';
     if (!$AppUI->login($username, $password)) {
         throw new Frapi_Error('INVALID_LOGIN');
     }
     $project = new CProject();
     $allowed_projects = $project->getAllowedProjects($AppUI->user_id);
     // Project ID  is the key, so lets get them in to an array so we can
     // easily check
     $allowed_projects = array_keys($allowed_projects);
     if (!in_array($project_id, $allowed_projects)) {
         throw new Frapi_Error('PERMISSION_ERROR');
     }
     // User has permission so load the project for display
     $project = (array) $project->load($project_id);
     $project_departments = CProject::getDepartments($AppUI, $project_id);
     $project_contacts = CProject::getContacts($AppUI, $project_id);
     $project['project_departments'] = array();
     foreach ($project_departments as $key => $value) {
         $project['project_departments'][] = $value['dept_id'];
     }
     $project['project_contacts'] = array();
     foreach ($project_contacts as $key => $value) {
         $project['project_contacts'][] = $value['contact_id'];
     }
     // Remove the data that is not for display
     unset($project['_tbl_prefix'], $project['_tbl'], $project['_tbl_key'], $project['_error'], $project['_query'], $project['_tbl_module']);
     $this->data['project'] = $project;
     $this->data['success'] = true;
     $this->setTemplateFileName('Project');
     return $this->toArray();
 }
예제 #2
0
 /**
  * Put Request Handler
  *
  * This method is called when a request is a PUT
  *
  * @return array
  */
 public function executePut()
 {
     $valid = $this->hasRequiredParameters($this->requiredParams);
     if ($valid instanceof Frapi_Error) {
         return $valid;
     }
     $username = $this->getParam('username');
     $password = $this->getParam('password');
     // Attempt to login as user, a little bit of a hack as we currently
     // require the $_POST['login'] var to be set as well as a global AppUI
     $AppUI = new CAppUI();
     $GLOBALS['AppUI'] = $AppUI;
     $_POST['login'] = '******';
     if (!$AppUI->login($username, $password)) {
         throw new Frapi_Error('INVALID_LOGIN');
     }
     $post_data = array('project_id' => 0, 'project_creator' => $AppUI->user_id, 'project_contacts' => $this->getParam('project_contacts'), 'project_name' => $this->getParam('project_name'), 'project_parent' => $this->getParam('project_parent'), 'project_owner' => $this->getParam('project_owner'), 'project_company' => $this->getParam('project_company'), 'project_location' => $this->getParam('project_location'), 'project_start_date' => $this->getParam('project_start_date'), 'project_end_date' => $this->getParam('project_end_date'), 'project_target_budget' => $this->getParam('project_target_budget'), 'project_actual_budget' => $this->getParam('project_actual_budget'), 'project_url' => $this->getParam('project_url'), 'project_demo_url' => $this->getParam('project_demo_url'), 'project_priority' => $this->getParam('project_priority'), 'project_short_name' => $this->getParam('project_short_name'), 'project_color_identifier' => $this->getParam('project_color_identifier'), 'project_type' => $this->getParam('project_type'), 'project_status' => $this->getParam('project_status'), 'project_description' => $this->getParam('project_description'), 'project_departments' => $this->getParam('project_departments', self::TYPE_ARRAY), 'project_active' => $this->getParam('project_active'));
     $project = new CProject();
     $project->bind($post_data);
     $error_array = $project->store($AppUI);
     // Return all the validation messages
     if ($error_array !== true) {
         $error_message = '';
         foreach ($error_array as $error) {
             $error_message .= $error . '. ';
         }
         throw new Frapi_Error('SAVE_ERROR', $error_message);
     }
     $project = (array) $project;
     $pd = CProject::getDepartments($AppUI, $project['project_id']);
     $project_departments = array();
     foreach ($pd as $key => $value) {
         $project_departments[] = $value['dept_id'];
     }
     $project['project_departments'] = $project_departments;
     // Remove the data that is not for display
     unset($project['_tbl_prefix'], $project['_tbl'], $project['_tbl_key'], $project['_error'], $project['_query'], $project['_tbl_module']);
     $this->data['project'] = $project;
     $this->data['success'] = true;
     return new Frapi_Response(array('code' => 201, 'data' => $this->data));
 }
예제 #3
0
 /**
  * Test finding of departments of project
  *
  * @expectedException PHPUnit_Framework_Error
  */
 public function testGetDepartments()
 {
     $departments = CProject::getDepartments(null, 1);
     /*
      * Beyond the deprecation notice, nothing else should be tested here. The
      *   useful test is CProject->testGetDepartmentList().
      */
 }
예제 #4
0
echo $AppUI->_('Calendar');
?>
" border="0" />
                                    </a>
                                </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;
    }
}
?>
예제 #5
0
파일: view.php 프로젝트: joly/web2project
echo $total_hours;
?>
</td>
		</tr>
		<tr>
			<td align="right" nowrap="nowrap"><?php 
echo $AppUI->_('Project Hours');
?>
:</td>
			<td class="hilite" width="100%"><?php 
echo $total_project_hours;
?>
</td>
		</tr>				
		<?php 
$depts = CProject::getDepartments($AppUI, $project->project_id);
if (count($depts) > 0) {
    ?>
		    <tr>
		    	<td><strong><?php 
    echo $AppUI->_('Departments');
    ?>
</strong></td>
		    </tr>
		    <tr>
		    	<td colspan='3' class="hilite">
		    		<?php 
    foreach ($depts as $dept_id => $dept_info) {
        echo '<div>';
        echo '<a href="?m=departments&a=view&dept_id=' . $dept_id . '">' . $dept_info['dept_name'] . '</a>';
        if ($dept_info['dept_phone'] != '') {
예제 #6
0
             if ($row[$field] < 0) {
                 $s .= '<img src="' . w2PfindImage('icons/priority-' . -$row[$field] . '.gif') . '" width=13 height=16>';
             } elseif ($row['project_priority'] > 0) {
                 $s .= '<img src="' . w2PfindImage('icons/priority+' . $row[$field] . '.gif') . '"  width=13 height=16>';
             }
             $s .= '</td>';
             break;
         case 'task_log_problem':
             $s .= '<td class="center">';
             $s .= $row[$field] ? '<a href="?m=tasks&a=index&f=all&project_id=' . $row['project_id'] . '">' : '';
             $s .= $row[$field] ? w2PshowImage('icons/dialog-warning5.png', 16, 16, 'Problem', 'Problem') : '-';
             $s .= $row[$field] ? '</a>' : '';
             $s .= '</td>';
             break;
         case 'department_list':
             $dept_array = CProject::getDepartments($AppUI, $row['project_id']);
             $s .= '<td>';
             foreach ($dept_array as $dept) {
                 $s .= '<a href="?m=departments&a=view&dept_id=' . $dept['dept_id'] . '">';
                 $s .= $dept['dept_name'];
                 $s .= '</a>';
                 $s .= '<br />';
             }
             $s .= '</td>';
             break;
         default:
             $s .= w2p_Output_HTMLHelper::renderColumn($AppUI, $field, $row);
     }
 }
 $s .= '<td class="center"><input type="checkbox" name="project_id[]" value="' . $row['project_id'] . '" /></td>';
 if ($show_all_projects) {
예제 #7
0
 /**
  * Test finding of departments of project
  */
 public function testGetDepartments()
 {
     global $AppUI;
     $departments = CProject::getDepartments($AppUI, 1);
     $this->assertEquals(2, count($departments));
     $this->assertEquals(1, $departments[1]['dept_id']);
     $this->assertEquals('Department 1', $departments[1]['dept_name']);
     $this->assertEquals('', $departments[1]['dept_phone']);
     $this->assertEquals(1, $departments[1][0]);
     $this->assertEquals('Department 1', $departments[1][1]);
     $this->assertEquals('', $departments[1][2]);
 }