$sql = $q->prepare(); $q->clear(); $company_name = db_loadResult($sql); if (!$dept_id && $company_name === null) { $AppUI->setMsg('badCompany', UI_MSG_ERROR); $AppUI->redirect(); } // collect all the departments in the company $depts = array(0 => ''); if ($company_id) { $q = new DBQuery(); $q->addTable('departments', 'dep'); $q->addQuery('dept_id, dept_name, dept_parent'); $q->addWhere('dep.dept_company = ' . $company_id); $q->addWhere('dep.dept_id != ' . $dept_id); $depts = $q->loadArrayList(); $depts['0'] = array(0, '- ' . $AppUI->_('Select Unit') . ' -', -1); } // collect all the users for the department owner list $q = new DBQuery(); $q->addTable('users', 'u'); $q->addTable('contacts', 'con'); $q->addQuery('user_id'); $q->addQuery('CONCAT_WS(", ",contact_last_name, contact_first_name)'); $q->addOrder('contact_first_name'); $q->addWhere('u.user_contact = con.contact_id'); $q->addOrder('contact_last_name, contact_first_name'); $owners = arrayMerge(array('0' => ''), $q->loadHashList()); // setup the title block $ttl = $company_id > 0 ? "Edit Department" : "Add Department"; $titleBlock = new CTitleBlock($ttl, 'users.gif', $m, "{$m}.{$a}");
/** * This function return an array of project member's id * @return array List of users' id who are working in this project */ function getMemberIds() { if ($this->project_id > 0) { $q = new DBQuery(); $q->addTable('project_contacts'); $q->addQuery('contact_id'); $q->addWhere('project_id = ' . $this->project_id); return $q->loadArrayList(); } return array(); }