$company_internal_id = intval(dPgetParam($_GET, "company_internal_id", 0)); $contact_id = intval(dPgetParam($_GET, "contact_id", 0)); // check permissions for this record $canEdit = getPermission($m, 'edit', $project_id); $canAuthor = getPermission($m, 'add', $project_id); if (!($canEdit && $project_id || $canAuthor && !$project_id)) { $AppUI->redirect('m=public&a=access_denied'); } // get a list of permitted companies require_once $AppUI->getModuleClass('companies'); $row = new CCompany(); $companies = $row->getAllowedRecords($AppUI->user_id, 'company_id,company_name', 'company_name'); $companies = arrayMerge(array('0' => ''), $companies); // get internal companies // 6 is standard value for internal companies $companies_internal = $row->listCompaniesByType(array('6')); $companies_internal = arrayMerge(array('0' => ''), $companies_internal); // pull users $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_last_name'); $q->addWhere('u.user_contact = con.contact_id'); $users = $q->loadHashList(); // load the record data $row = new CProject(); if (!$row->load($project_id, false) && $project_id > 0) { $AppUI->setMsg('Project'); $AppUI->setMsg("invalidID", UI_MSG_ERROR, true);