function getDepartment($department_id, $fieldname)
{
    $department = new CDepartment();
    $department->load((int) $department_id);
    $response = new xajaxResponse();
    $response->assign($fieldname, 'value', $department->dept_name);
    return $response;
}
Example #2
0
    if (!$perms->checkModuleItem('departments', 'edit', $dept_id)) {
        $AppUI->redirect('m=public&a=access_denied');
    }
} else {
    if (!$perms->checkModule('departments', 'add')) {
        $AppUI->redirect('m=public&a=access_denied');
    }
}
$obj = new CDepartment();
if ($msg = $obj->bind($_POST)) {
    $AppUI->setMsg($msg, UI_MSG_ERROR);
    $AppUI->redirect();
}
// prepare (and translate) the module name ready for the suffix
if ($del) {
    $dep = new CDepartment();
    $msg = $dep->load($obj->dept_id);
    if ($msg = $obj->delete($AppUI)) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
        $AppUI->redirect();
    } else {
        $AppUI->setMsg('deleted', UI_MSG_ALERT, true);
        $AppUI->redirect('m=companies&a=view&company_id=' . $dep->dept_company);
    }
} else {
    if ($result = $obj->store($AppUI)) {
        if (is_array($result)) {
            $AppUI->setMsg($result, UI_MSG_ERROR, true);
            $AppUI->holdObject($obj);
            $AppUI->redirect('m=departments&a=addedit');
        }
    public static function searchContacts(CAppUI $AppUI = null, $where = '', $searchString = '')
    {
        global $AppUI;
        $showfields = array('contact_address1' => 'contact_address1', 'contact_address2' => 'contact_address2', 'contact_city' => 'contact_city', 'contact_state' => 'contact_state', 'contact_zip' => 'contact_zip', 'contact_country' => 'contact_country', 'contact_company' => 'contact_company', 'company_name' => 'company_name', 'dept_name' => 'dept_name');
        $additional_filter = '';
        if ($searchString != '') {
            $additional_filter = "OR contact_first_name like '%{$searchString}%'\n                                  OR contact_last_name  like '%{$searchString}%'\n\t\t\t                      OR CONCAT(contact_first_name, ' ', contact_last_name)  like '%{$searchString}%'\n                                  OR company_name like '%{$searchString}%'\n                                  OR contact_notes like '%{$searchString}%'";
        }
        // assemble the sql statement
        $q = new w2p_Database_Query();
        $q->addQuery('contact_id, contact_order_by');
        $q->addQuery($showfields);
        $q->addQuery('contact_first_name, contact_last_name, contact_title');
        $q->addQuery('contact_updatekey, contact_updateasked, contact_lastupdate');
        $q->addQuery('contact_email, contact_phone');
        $q->addQuery('user_id');
        $q->addTable('contacts', 'a');
        $q->leftJoin('companies', 'b', 'a.contact_company = b.company_id');
        $q->leftJoin('departments', '', 'contact_department = dept_id');
        $q->leftJoin('users', '', 'contact_id = user_contact');
        $q->addWhere("(contact_first_name LIKE '{$where}%' OR contact_last_name LIKE '{$where}%' " . $additional_filter . ")");
        $q->addWhere('
			(contact_private=0
				OR (contact_private=1 AND contact_owner=' . $AppUI->user_id . ')
				OR contact_owner IS NULL OR contact_owner = 0
			)');
        $company = new CCompany();
        $company->setAllowedSQL($AppUI->user_id, $q);
        $department = new CDepartment();
        $department->setAllowedSQL($AppUI->user_id, $q);
        $q->addOrder('contact_first_name');
        $q->addOrder('contact_last_name');
        return $q->loadList();
    }
$q->addQuery('contact_id, contact_first_name, contact_last_name, contact_company, contact_department');
$q->addQuery('company_name');
$q->addQuery('dept_name');
if ($where) {
    // Don't assume where is set. Change needed to fix Mantis Bug 0002056
    $q->addWhere($where);
}
if ($where_dept) {
    // Don't assume where is set. Change needed to fix Mantis Bug 0002056
    $q->addWhere($where_dept);
}
$oCpy = new CCompany();
$aCpies = $oCpy->getAllowedRecords($AppUI->user_id, 'company_id, company_name', 'company_name');
$where = $oCpy->getAllowedSQL($AppUI->user_id, 'contact_company');
$q->addWhere($where);
$oDpt = new CDepartment();
$where = $oDpt->getAllowedSQL($AppUI->user_id, 'contact_department');
$q->addWhere($where);
$q->addWhere('(contact_owner = ' . (int) $AppUI->user_id . ' OR contact_private = 0)');
$q->addOrder('company_name, contact_company, dept_name, contact_department, contact_last_name');
// May need to review this.
$contacts = $q->loadHashList('contact_id');
?>

<form action="index.php?m=public&a=contact_selector&dialog=1&<?php 
if (!is_null($call_back)) {
    echo 'call_back=' . $call_back . '&';
}
?>
company_id=<?php 
echo $company_id;
Example #5
0
        $id_field = 'company_id';
        $name_field = 'company_name';
        $selection_string = 'Company';
        $dataId = $company_id;
        $company = new CCompany();
        $companyList = $company->getCompanyList();
        foreach ($companyList as $comp) {
            $select_list[$comp['company_id']] = $comp['company_name'];
        }
        break;
    case 'departments':
        $id_field = 'dept_id';
        $name_field = 'dept_name';
        $selection_string = 'Department';
        $dataId = $dept_id;
        $deptList = CDepartment::getDepartmentList(null, $company_id, null);
        foreach ($deptList as $dept) {
            $select_list[$dept['dept_id']] = $dept['dept_name'];
        }
        break;
}
$select_list = array('0' => '') + $select_list;
$myId = (int) w2PgetParam($_POST, $id_field, 0);
if ($myId) {
    $q = new w2p_Database_Query();
    $q->addTable($table_name);
    $q->addQuery('*');
    $q->addWhere($id_field . '=' . $myId);
    $r_data = $q->loadHash();
    $q->clear();
    $data_update_script = '';
        $id_field = 'company_id';
        $name_field = 'company_name';
        $selection_string = 'Company';
        $dataId = $company_id;
        $company = new CCompany();
        $companyList = $company->getCompanyList($AppUI);
        foreach ($companyList as $comp) {
            $select_list[$comp['company_id']] = $comp['company_name'];
        }
        break;
    case 'departments':
        $id_field = 'dept_id';
        $name_field = 'dept_name';
        $selection_string = 'Department';
        $dataId = $dept_id;
        $deptList = CDepartment::getDepartmentList($AppUI, $company_id, null);
        foreach ($deptList as $dept) {
            $select_list[$dept['dept_id']] = $dept['dept_name'];
        }
        break;
}
$select_list = array('0' => '') + $select_list;
$myId = (int) w2PgetParam($_POST, $id_field, 0);
if ($myId) {
    $q = new w2p_Database_Query();
    $q->addTable($table_name);
    $q->addQuery('*');
    $q->addWhere($id_field . '=' . $myId);
    $r_data = $q->loadHash();
    $q->clear();
    $data_update_script = '';
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;
}
Example #8
0
<?php

/* $Id: view.php 1923 2011-05-10 06:02:37Z caseydk $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/tags/version2.4/modules/departments/view.php $ */
if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
global $department, $min_view;
$dept_id = (int) w2PgetParam($_GET, 'dept_id', 0);
$tab = $AppUI->processIntState('DeptVwTab', $_GET, 'tab', 0);
// check permissions
$canRead = canView($m, $dept_id);
$canEdit = canEdit($m, $dept_id);
if (!$canRead) {
    $AppUI->redirect('m=public&a=access_denied');
}
$department = new CDepartment();
$department->loadFull($AppUI, $dept_id);
if (!$department) {
    $AppUI->setMsg('Department');
    $AppUI->setMsg('invalidID', UI_MSG_ERROR, true);
    $AppUI->redirect();
} else {
    $AppUI->savePlace();
}
$countries = w2PgetSysVal('GlobalCountries');
$types = w2PgetSysVal('DepartmentType');
$titleBlock = new CTitleBlock('View Department', 'departments.png', $m, $m . '.' . $a);
if ($canEdit) {
    $titleBlock->addCell();
    $titleBlock->addCell('<input type="submit" class="button" value="' . $AppUI->_('new department') . '">', '', '<form action="?m=departments&a=addedit&company_id=' . $department->dept_company . '&dept_parent=' . $dept_id . '" method="post" accept-charset="utf-8">', '</form>');
}
 public static function getDepartmentList(CAppUI $AppUI = null, $companyId, $departmentId = 0)
 {
     global $AppUI;
     $q = new w2p_Database_Query();
     $q->addTable('departments');
     $q->addQuery('dept_id, dept_name');
     if (is_int($departmentId)) {
         $q->addWhere('dept_parent = ' . (int) $departmentId);
     }
     $q->addWhere('dept_company = ' . (int) $companyId);
     $q->addOrder('dept_name');
     $department = new CDepartment();
     $department->setAllowedSQL($AppUI->user_id, $q);
     return $q->loadHashList('dept_id');
 }
Example #10
0
<?php

if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
$dept_id = (int) w2PgetParam($_GET, 'dept_id', 0);
$department_id = (int) w2PgetParam($_GET, 'department_id', 0);
$dept_id = max($dept_id, $department_id);
$tab = $AppUI->processIntState('DeptVwTab', $_GET, 'tab', 0);
$department = new CDepartment();
if (!$department->load($dept_id)) {
    $AppUI->redirect(ACCESS_DENIED);
}
$canEdit = $department->canEdit();
$canDelete = $department->canDelete();
$titleBlock = new w2p_Theme_TitleBlock('View Department', 'icon.png', $m);
$titleBlock->addCrumb('?m=companies', 'company list');
$titleBlock->addCrumb('?m=companies&a=view&company_id=' . $department->dept_company, 'view this company');
$titleBlock->addCrumb('?m=' . $m, $m . ' list');
if ($canEdit) {
    $titleBlock->addCell();
    $titleBlock->addButton('New department', '?m=departments&a=addedit&company_id=' . $department->dept_company . '&dept_parent=' . $dept_id);
    $titleBlock->addCrumb('?m=departments&a=addedit&dept_id=' . $dept_id, 'edit this department');
    if ($canDelete) {
        $titleBlock->addCrumbDelete('delete department', $canDelete, $msg);
    }
}
$titleBlock->show();
$view = new w2p_Controllers_View($AppUI, $department, 'Department');
$view->setDoSQL('do_dept_aed');
$view->addField('dept_company', $department->dept_company);
    public function search($search, $days = 0)
    {
        $hook = $this->hook_search();
        $searchfields = $hook['search_fields'];
        foreach ($searchfields as $key => $field) {
            $searchfields[$key] = "{$field} like '%{$search}%'";
        }
        $where = implode(' OR ', $searchfields);
        $q = $this->_getQuery();
        $q->addQuery('distinct(c.contact_id)');
        $q->addQuery('c.*');
        $q->addQuery('user_id');
        $q->addTable('contacts', 'c');
        $q->leftJoin('companies', 'b', 'c.contact_company = b.company_id');
        $q->leftJoin('departments', '', 'c.contact_department = dept_id');
        $q->leftJoin('users', '', 'contact_id = user_contact');
        $q->leftJoin('contacts_methods', 'cm', 'c.contact_id = cm.contact_id');
        $q->addWhere('(' . $where . ')');
        if ($days) {
            $q->addWhere('contact_lastupdate >= ' . $q->dbfnDateAdd($q->dbfnNow(), -$days, 'DAY'));
        }
        $q->addWhere('
			(contact_private=0
				OR (contact_private=1 AND contact_owner=' . $this->_AppUI->user_id . ')
				OR contact_owner IS NULL OR contact_owner = 0
			)');
        //TODO: We need to convert this from static to use ->overrideDatabase() for testing.
        $company = new CCompany();
        $allow_where = $company->getAllowedSQL($this->_AppUI->user_id, 'contact_company');
        if (count($allow_where)) {
            $q->addWhere('(contact_company = 0 OR contact_company IS NULL OR (' . implode(' AND ', $allow_where) . '))');
        }
        //TODO: We need to convert this from static to use ->overrideDatabase() for testing.
        $department = new CDepartment();
        $q = $department->setAllowedSQL($this->_AppUI->user_id, $q);
        $q->addOrder('contact_first_name');
        $q->addOrder('contact_last_name');
        return $q->loadList();
    }
Example #12
0
<?php

/* $Id$ $URL$ */
if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
global $search_string, $owner_filter_id, $currentTabId, $orderby, $orderdir;
$types = w2PgetSysVal('DepartmentType');
$dept_type_filter = $currentTabId - 1;
// get any records denied from viewing
$dept = new CDepartment();
$deptList = $dept->getFilteredDepartmentList($AppUI, $dept_type_filter, $search_string, $owner_filter_id, $orderby, $orderdir);
?>

<table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl">
	<tr>
        <?php 
$fieldList = array('dept_name', 'countp', 'inactive', 'dept_type');
$fieldNames = array('Department Name', 'Active Projects', 'Archived Projects', 'Type');
foreach ($fieldNames as $index => $name) {
    ?>
<th nowrap="nowrap">
                <a href="?m=departments&orderby=<?php 
    echo $fieldList[$index];
    ?>
" class="hdr">
                    <?php 
    echo $AppUI->_($fieldNames[$index]);
    ?>
                </a>
            </th><?php 
Example #13
0
			<td align="right" nowrap="nowrap"><?php 
echo $AppUI->_('Project Hours');
?>
:</td>
			<td class="hilite" width="100%"><?php 
echo $total_project_hours;
?>
</td>
		</tr>				
		<?php 
$q = new DBQuery();
$q->addTable('departments', 'a');
$q->addTable('project_departments', 'b');
$q->addQuery('a.dept_id, a.dept_name, a.dept_phone');
$q->addWhere('a.dept_id = b.department_id and b.project_id = ' . (int) $project_id);
$department = new CDepartment();
$department->setAllowedSQL($AppUI->user_id, $q);
$depts = $q->loadHashList('dept_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>' . $dept_info['dept_name'];
Example #14
0
 /**
  * Tests the delete of a dept
  */
 public function testDelete()
 {
     $this->obj->bind($this->post_data);
     $result = $this->obj->store();
     $this->assertTrue($result);
     $original_id = $this->obj->dept_id;
     $result = $this->obj->delete();
     $item = new CDepartment();
     $item->overrideDatabase($this->mockDB);
     $this->mockDB->stageHash(array('dept_name' => '', 'dept_owner' => ''));
     $item->load($original_id);
     $this->assertEquals('', $item->dept_name);
     $this->assertEquals('', $item->dept_owner);
 }
<?php

/* DEPARTMENTS $Id: do_dept_aed.php,v 1.2 2003/04/04 05:02:05 eddieajau Exp $ */
$del = isset($_POST['del']) ? $_POST['del'] : 0;
$dept = new CDepartment();
if ($msg = $dept->bind($_POST)) {
    $AppUI->setMsg($msg, UI_MSG_ERROR);
    $AppUI->redirect();
}
// prepare (and translate) the module name ready for the suffix
$AppUI->setMsg('Department');
if ($del) {
    if ($msg = $dept->delete()) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
    } else {
        $AppUI->setMsg("deleted", UI_MSG_ALERT, true);
    }
} else {
    if ($msg = $dept->store()) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
    } else {
        $isNotNew = @$_POST['department_id'];
        $AppUI->setMsg($isNotNew ? 'updated' : 'inserted', UI_MSG_OK, true);
    }
}
$AppUI->redirect();
Example #16
0
function w2PgetUsersHashList($stub = null, $where = null, $orderby = 'contact_first_name, contact_last_name')
{
    global $AppUI;
    $q = new DBQuery();
    $q->addTable('users');
    $q->addQuery('DISTINCT(user_id), user_username, contact_last_name, contact_first_name,
		 contact_email, company_name, contact_company, dept_id, dept_name, CONCAT(contact_first_name,\' \',contact_last_name) contact_name, user_type');
    $q->addJoin('contacts', 'con', 'contact_id = user_contact', 'inner');
    if ($stub) {
        $q->addWhere('(UPPER(user_username) LIKE \'' . $stub . '%\' or UPPER(contact_first_name) LIKE \'' . $stub . '%\' OR UPPER(contact_last_name) LIKE \'' . $stub . '%\')');
    } elseif ($where) {
        $where = $q->quote('%' . $where . '%');
        $q->addWhere('(UPPER(user_username) LIKE ' . $where . ' OR UPPER(contact_first_name) LIKE ' . $where . ' OR UPPER(contact_last_name) LIKE ' . $where . ')');
    }
    $q->addGroup('user_id');
    $q->addOrder($orderby);
    // get CCompany() to filter by company
    $obj = new CCompany();
    $companies = $obj->getAllowedSQL($AppUI->user_id, 'company_id');
    $q->addJoin('companies', 'com', 'company_id = contact_company');
    if ($companies) {
        $q->addWhere('(' . implode(' OR ', $companies) . ' OR contact_company=\'\' OR contact_company IS NULL OR contact_company = 0)');
    }
    $dpt = new CDepartment();
    $depts = $dpt->getAllowedSQL($AppUI->user_id, 'dept_id');
    $q->addJoin('departments', 'dep', 'dept_id = contact_department');
    if ($depts) {
        $q->addWhere('(' . implode(' OR ', $depts) . ' OR contact_department=0)');
    }
    return $q->loadHashList('user_id');
}
Example #17
0
}
$orderby = $AppUI->getState('DeptIdxOrderBy') ? $AppUI->getState('DeptIdxOrderBy') : 'dept_name';
$orderdir = $AppUI->getState('DeptIdxOrderDir') ? $AppUI->getState('DeptIdxOrderDir') : 'asc';
if (isset($_REQUEST['owner_filter_id'])) {
    $AppUI->setState('dept_owner_filter_id', w2PgetParam($_REQUEST, 'owner_filter_id', null));
    $owner_filter_id = w2PgetParam($_REQUEST, 'owner_filter_id', null);
} else {
    $owner_filter_id = $AppUI->getState('dept_owner_filter_id');
    if (!isset($owner_filter_id)) {
        $owner_filter_id = 0;
        //By default show all companies instead of $AppUI->user_id current user.
        $AppUI->setState('dept_owner_filter_id', $owner_filter_id);
    }
}
// get any records denied from viewing
$obj = new CDepartment();
$deny = $obj->getDeniedRecords($AppUI->user_id);
// Company search by Kist
$search_string = w2PgetParam($_REQUEST, 'search_string', '');
if ($search_string != '') {
    $search_string = $search_string == '-1' ? '' : $search_string;
    $AppUI->setState('dept_search_string', $search_string);
} else {
    $search_string = $AppUI->getState('dept_search_string');
}
$search_string = w2PformSafe($search_string, true);
$perms =& $AppUI->acl();
$owner_list = array(0 => $AppUI->_('All', UI_OUTPUT_RAW)) + $perms->getPermittedUsers('departments');
$owner_combo = arraySelect($owner_list, 'owner_filter_id', 'class="text" onchange="javascript:document.searchform.submit()"', $owner_filter_id, false);
// setup the title block
$titleBlock = new w2p_Theme_TitleBlock('Departments', 'departments.png', $m, $m . '.' . $a);
Example #18
0
<?php

/* $Id$ $URL$ */
if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
$contact_id = intval(w2PgetParam($_GET, 'contact_id', 0));
$company_id = intval(w2PgetParam($_GET, 'company_id', 0));
$dept_id = intval(w2PgetParam($_GET, 'dept_id', 0));
$company = new CCompany();
$company->load($company_id);
$company_name = $company->company_name;
$dept = new CDepartment();
$dept->load($dept_id);
$dept_name = $dept->dept_name;
// check permissions for this record
$perms =& $AppUI->acl();
$canAuthor = $perms->checkModule('contacts', 'add');
$canEdit = $perms->checkModuleItem('contacts', 'edit', $contact_id);
// check permissions
if (!$canAuthor && !$contact_id) {
    $AppUI->redirect('m=public&a=access_denied');
}
if (!$canEdit && $contact_id) {
    $AppUI->redirect('m=public&a=access_denied');
}
if ($msg == $AppUI->_('contactsDeleteUserError', UI_OUTPUT_JS)) {
    $userDeleteProtect = true;
}
// load the record data
$row = new CContact();
Example #19
0
<?php

/* DEPARTMENTS $Id$ */
if (!defined('DP_BASE_DIR')) {
    die('You should not access this file directly.');
}
$del = isset($_POST['del']) ? $_POST['del'] : 0;
$dept = new CDepartment();
if ($msg = $dept->bind($_POST)) {
    $AppUI->setMsg($msg, UI_MSG_ERROR);
    $AppUI->redirect();
}
// prepare (and translate) the module name ready for the suffix
$AppUI->setMsg('Department');
if ($del) {
    $dep = new CDepartment();
    $msg = $dep->load($dept->dept_id);
    if ($msg = $dept->delete()) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
        $AppUI->redirect();
    } else {
        $AppUI->setMsg("deleted", UI_MSG_ALERT, true);
        $AppUI->redirect('m=companies&a=view&company_id=' . $dep->dept_company);
    }
} else {
    if ($msg = $dept->store()) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
    } else {
        $isNotNew = @$_POST['department_id'];
        $AppUI->setMsg($isNotNew ? 'updated' : 'inserted', UI_MSG_OK, true);
    }
Example #20
0
$ttl = $object_id > 0 ? 'Edit Task' : 'Add Task';
$titleBlock = new w2p_Theme_TitleBlock($ttl, 'icon.png', $m);
$titleBlock->addViewLink('project', $task_project);
$titleBlock->addViewLink('task', $object_id);
$titleBlock->show();
// Get contacts list
$selected_contacts = array();
if ($object_id) {
    $myContacts = $object->getContacts(null, $object_id);
    $selected_contacts = array_keys($myContacts);
}
if ($object_id == 0 && (isset($contact_id) && $contact_id > 0)) {
    $selected_contacts[] = '' . $contact_id;
}
$department_selection_list = array();
$department = new CDepartment();
$deptList = $department->departments($project->project_company);
foreach ($deptList as $dept) {
    $department_selection_list[$dept['dept_id']] = $dept['dept_name'];
}
$department_selection_list = arrayMerge(array('0' => ''), $department_selection_list);
//Dynamic tasks are by default now off because of dangerous behavior if incorrectly used
if (is_null($object->task_dynamic)) {
    $object->task_dynamic = 0;
}
$can_edit_time_information = $object->canUserEditTimeInformation($project->project_owner, $AppUI->user_id);
//get list of projects, for task move drop down list.
$tmpprojects = $project->getAllowedProjects($AppUI->user_id);
$projects = array();
$projects[0] = $AppUI->_('Do not move');
foreach ($tmpprojects as $proj) {
Example #21
0
        constructTaskTree($root_task);
    }
}
// setup the title block
$ttl = $task_id > 0 ? 'Edit Task' : 'Add Task';
$titleBlock = new CTitleBlock($ttl, 'applet-48.png', $m, $m . '.' . $a);
$titleBlock->addCrumb('?m=tasks', 'tasks list');
if ($canReadProject) {
    $titleBlock->addCrumb('?m=projects&a=view&project_id=' . $task_project, 'view this project');
}
if ($task_id > 0) {
    $titleBlock->addCrumb('?m=tasks&a=view&task_id=' . $task->task_id, 'view this task');
}
$titleBlock->show();
$department_selection_list = array();
$deptList = CDepartment::getDepartmentList($AppUI, $project->project_company, null);
foreach ($deptList as $dept) {
    $department_selection_list[$dept['dept_id']] = $dept['dept_name'];
}
$department_selection_list = arrayMerge(array('0' => ''), $department_selection_list);
//Dynamic tasks are by default now off because of dangerous behavior if incorrectly used
if (is_null($task->task_dynamic)) {
    $task->task_dynamic = 0;
}
$can_edit_time_information = $task->canUserEditTimeInformation();
//get list of projects, for task move drop down list.
$pq = new DBQuery();
$pq->addQuery('pr.project_id, project_name');
$pq->addTable('projects', 'pr');
$pq->addWhere('( project_active = 1 or pr.project_id = ' . (int) $task_project . ')');
$pq->addOrder('project_name');
Example #22
0
 public function getStructuredProjects($active_only = false)
 {
     //global $st_projects_arr;
     $st_projects = array(0 => '');
     $q = $this->getQuery();
     $q->addTable('projects');
     $q->addJoin('companies', '', 'projects.project_company = company_id', 'inner');
     $q->addQuery('DISTINCT(projects.project_id), project_name, project_parent, project_company');
     if ($this->project_original_parent) {
         $q->addWhere('project_original_parent = ' . (int) $this->project_original_parent);
     }
     if ($this->project_status >= 0) {
         $q->addWhere('project_status = ' . (int) $this->project_status);
     }
     if ($active_only) {
         $q->addWhere('project_active = 1');
     }
     $q->addOrder('project_start_date, project_end_date');
     $obj = new CCompany();
     $obj->overrideDatabase($this->_query);
     $q = $obj->setAllowedSQL($this->_AppUI->user_id, $q);
     $dpt = new CDepartment();
     $dpt->overrideDatabase($this->_query);
     $q = $dpt->setAllowedSQL($this->_AppUI->user_id, $q);
     $q->leftJoin('project_departments', 'pd', 'pd.project_id = projects.project_id');
     $q->leftJoin('departments', 'd', 'd.dept_id = pd.department_id');
     $st_projects = $q->loadList();
     $tnums = count($st_projects);
     for ($i = 0; $i < $tnums; $i++) {
         $st_project = $st_projects[$i];
         if ($st_project['project_parent'] == $st_project['project_id']) {
             $this->show_st_project($st_project);
             $this->find_proj_child($st_projects, $st_project['project_id']);
         }
     }
     return $this->st_projects_arr;
 }
Example #23
0
 public static function getDepartments($AppUI, $companyId)
 {
     $perms = $AppUI->acl();
     if ($AppUI->isActiveModule('departments') && $perms->checkModule('departments', 'view')) {
         $q = new DBQuery();
         $q->addTable('departments');
         $q->addQuery('departments.*, COUNT(contact_department) dept_users');
         $q->addJoin('contacts', 'c', 'c.contact_department = dept_id');
         $q->addWhere('dept_company = ' . (int) $companyId);
         $q->addGroup('dept_id');
         $q->addOrder('dept_parent, dept_name');
         $department = new CDepartment();
         $department->setAllowedSQL($AppUI->user_id, $q);
         return $q->loadList();
     }
 }
 /**
  * @deprecated
  */
 public static function getDepartmentList($AppUI = null, $companyId, $departmentId = 0)
 {
     trigger_error("The CDepartment::getDepartmentList static method has been deprecated in 3.1 and will be removed in v4.0. Please use CDepartment->departments() instead.", E_USER_NOTICE);
     $department = new CDepartment();
     return $department->departments($companyId, $departmentId);
 }
 public static function getDepartments(CAppUI $AppUI = null, $projectId)
 {
     global $AppUI;
     $perms = $AppUI->acl();
     if ($AppUI->isActiveModule('departments') && canView('departments')) {
         $q = new w2p_Database_Query();
         $q->addTable('departments', 'a');
         $q->addTable('project_departments', 'b');
         $q->addQuery('a.dept_id, a.dept_name, a.dept_phone');
         $q->addWhere('a.dept_id = b.department_id and b.project_id = ' . (int) $projectId);
         $department = new CDepartment();
         $department->setAllowedSQL($AppUI->user_id, $q);
         return $q->loadHashList('dept_id');
     }
 }
Example #26
0
<?php

/* $Id$ $URL$ */
if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
global $department, $min_view;
$dept_id = (int) w2PgetParam($_GET, 'dept_id', 0);
$tab = $AppUI->processIntState('DeptVwTab', $_GET, 'tab', 0);
// check permissions
$canRead = canView($m, $dept_id);
$canEdit = canEdit($m, $dept_id);
if (!$canRead) {
    $AppUI->redirect('m=public&a=access_denied');
}
$department = new CDepartment();
$department->loadFull(null, $dept_id);
if (!$department) {
    $AppUI->setMsg('Department');
    $AppUI->setMsg('invalidID', UI_MSG_ERROR, true);
    $AppUI->redirect();
} else {
    $AppUI->savePlace();
}
$countries = w2PgetSysVal('GlobalCountries');
$types = w2PgetSysVal('DepartmentType');
$titleBlock = new w2p_Theme_TitleBlock('View Department', 'departments.png', $m, $m . '.' . $a);
if ($canEdit) {
    $titleBlock->addCell();
    $titleBlock->addCell('<input type="submit" class="button" value="' . $AppUI->_('new department') . '">', '', '<form action="?m=departments&a=addedit&company_id=' . $department->dept_company . '&dept_parent=' . $dept_id . '" method="post" accept-charset="utf-8">', '</form>');
}
Example #27
0
 /**
  *	Calculate the extent of utilization of user assignments
  *	@param string hash	 a hash for the returned hashList
  *	@param array users	 an array of user_ids calculating their assignment capacity
  *	@return array		 returns hashList of extent of utilization for assignment of the users
  */
 public function getAllocation($hash = null, $users = null, $get_user_list = false)
 {
     /*
      * TODO: The core of this function has been simplified to always return 100%
      * free capacity available.  The allocation checking (aka resource
      * management) is a complex subject which is currently not even close to be
      * handled properly.
      */
     global $AppUI;
     if (!w2PgetConfig('check_overallocation', false)) {
         if ($get_user_list) {
             $users_list = w2PgetUsersHashList();
             foreach ($users_list as $key => $user) {
                 $users_list[$key]['userFC'] = $user['contact_name'];
             }
             $hash = $users_list;
         } else {
             $hash = array();
         }
     } else {
         $q = new w2p_Database_Query();
         // retrieve the systemwide default preference for the assignment maximum
         $q->addTable('user_preferences');
         $q->addQuery('pref_value');
         $q->addWhere('pref_user = 0 AND pref_name = \'' . TASKASSIGNMAX . '\'');
         $sysChargeMax = $q->loadHash();
         $q->clear();
         if (!$sysChargeMax) {
             $scm = 0;
         } else {
             $scm = $sysChargeMax['pref_value'];
         }
         /*
          * provide actual assignment charge, individual chargeMax
          * and freeCapacity of users' assignments to tasks
          */
         $q->addTable('users', 'u');
         $q->addJoin('contacts', 'c', 'c.contact_id = u.user_contact', 'inner');
         $q->leftJoin('user_tasks', 'ut', 'ut.user_id = u.user_id');
         $q->leftJoin('user_preferences', 'up', 'up.pref_user = u.user_id');
         $q->addWhere("up.pref_name = 'TASKASSIGNMAX'");
         $q->addQuery('u.user_id, CONCAT(CONCAT_WS(\' [\', CONCAT_WS(\' \', contact_first_name, contact_last_name), IF(IFNULL((IFNULL(up.pref_value, ' . $scm . ') - SUM(ut.perc_assignment)), up.pref_value) > 0, IFNULL((IFNULL(up.pref_value, ' . $scm . ') - SUM(ut.perc_assignment)), up.pref_value), 0)), \'%]\') AS userFC, IFNULL(SUM(ut.perc_assignment), 0) AS charge');
         $q->addQuery('u.user_username, IFNULL(up.pref_value,' . $scm . ') AS chargeMax');
         $q->addQuery('IFNULL(up.pref_value, ' . $scm . ') AS freeCapacity');
         if (!empty($users)) {
             // use userlist if available otherwise pull data for all users
             $q->addWhere('u.user_id IN (' . implode(',', $users) . ')');
         }
         $q->addGroup('u.user_id');
         $q->addOrder('contact_first_name, contact_last_name');
         // get CCompany() to filter by company
         $obj = new CCompany();
         $companies = $obj->getAllowedSQL($AppUI->user_id, 'company_id');
         $q->addJoin('companies', 'com', 'company_id = contact_company');
         if ($companies) {
             $q->addWhere('(' . implode(' OR ', $companies) . ' OR contact_company=\'\' OR contact_company IS NULL OR contact_company = 0)');
         }
         $dpt = new CDepartment();
         $depts = $dpt->getAllowedSQL($AppUI->user_id, 'dept_id');
         $q->addJoin('departments', 'dep', 'dept_id = contact_department');
         if ($depts) {
             $q->addWhere('(' . implode(' OR ', $depts) . ' OR contact_department=0)');
         }
         $hash = $q->loadHashList($hash);
         $q->clear();
     }
     return $hash;
 }
Example #28
0
?>

<table border="0" cellpadding="2" cellspacing="1" width="100%" class="tbl">

<tr><th><?php 
echo $AppUI->_('Name');
?>
</th><th><?php 
echo $AppUI->_('Email');
?>
</th><th><?php 
echo $AppUI->_('Telephone');
?>
</th></tr>
<?php 
$contacts = CDepartment::getContactList($AppUI, $dept_id);
$contact = new CContact();
foreach ($contacts as $contact_id => $contact_data) {
    $contact->contact_id = $contact_id;
    echo '<tr><td><a href="./index.php?m=contacts&a=view&contact_id=' . $contact_data['contact_id'] . '">' . $contact_data['contact_first_name'] . ' ' . $contact_data['contact_last_name'] . '</a></td>';
    echo '<td>' . w2p_email($contact_data['contact_email']) . '</td>';
    echo '<td>' . $contact_data['contact_phone'] . '</td></tr>';
}
?>
	<tr>
		<td colspan="3" align="right" valign="top" style="background-color:#ffffff">
			<input type="button" class="button" value="<?php 
echo $AppUI->_('new contact');
?>
" onclick="javascript:window.location='./index.php?m=contacts&a=addedit&company_id=<?php 
echo $company_id;
Example #29
0
<?php

/* $Id$ $URL$ */
if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
global $search_string, $owner_filter_id, $currentTabId, $orderby, $orderdir;
$types = w2PgetSysVal('DepartmentType');
$dept_type_filter = $currentTabId - 1;
// get any records denied from viewing
$dept = new CDepartment();
$depts = $dept->getFilteredDepartmentList(null, $dept_type_filter, $search_string, $owner_filter_id, $orderby, $orderdir);
?>
<table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl list">
    <tr>
        <?php 
$fieldList = array();
$fieldNames = array();
$module = new w2p_Core_Module();
$fields = $module->loadSettings('departments', 'index_list');
if (count($fields) > 0) {
    $fieldList = array_keys($fields);
    $fieldNames = array_values($fields);
} else {
    // TODO: This is only in place to provide an pre-upgrade-safe
    //   state for versions earlier than v3.0
    //   At some point at/after v4.0, this should be deprecated
    $fieldList = array('dept_name', 'countp', 'inactive', 'dept_type');
    $fieldNames = array('Department Name', 'Active Projects', 'Archived Projects', 'Type');
}
//TODO: The link below is commented out because this module doesn't support sorting... yet.
 public function departments($companyId)
 {
     if ($this->_AppUI->isActiveModule('departments') && canView('departments')) {
         $q = $this->_getQuery();
         $q->addTable('departments');
         $q->addQuery('departments.*, COUNT(contact_department) dept_users');
         $q->addJoin('contacts', 'c', 'c.contact_department = dept_id');
         $q->addWhere('dept_company = ' . (int) $companyId);
         $q->addGroup('dept_id');
         $q->addOrder('dept_parent, dept_name');
         $department = new CDepartment();
         $q = $department->setAllowedSQL($this->_AppUI->user_id, $q);
         return $q->loadList();
     }
 }