function setJobItemGroup($ids) { if (getTTProductEdition() != TT_PRODUCT_PROFESSIONAL) { return FALSE; } Debug::text('Setting IDs...', __FILE__, __LINE__, __METHOD__, 10); if (is_array($ids)) { $tmp_ids = array(); if (!$this->isNew()) { //If needed, delete mappings first. $lf_a = new PremiumPolicyJobItemGroupListFactory(); $lf_a->getByPremiumPolicyId($this->getId()); foreach ($lf_a as $obj) { $id = $obj->getJobItemGroup(); Debug::text('Job Item Group ID: ' . $obj->getJobItemGroup() . ' ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10); //Delete users that are not selected. if (!in_array($id, $ids)) { Debug::text('Deleting: ' . $id, __FILE__, __LINE__, __METHOD__, 10); $obj->Delete(); } else { //Save ID's that need to be updated. Debug::text('NOT Deleting : ' . $id, __FILE__, __LINE__, __METHOD__, 10); $tmp_ids[] = $id; } } unset($id, $obj); } //Insert new mappings. $lf_b = new JobItemGroupListFactory(); foreach ($ids as $id) { if (isset($ids) and $id > 0 and !in_array($id, $tmp_ids)) { $f = new PremiumPolicyJobItemGroupFactory(); $f->setPremiumPolicy($this->getId()); $f->setJobItemGroup($id); $obj = $lf_b->getById($id)->getCurrent(); if ($this->Validator->isTrue('job_item_group', $f->Validator->isValid(), TTi18n::gettext('Selected Task Group is invalid') . ' (' . $obj->getName() . ')')) { $f->save(); } } } return TRUE; } Debug::text('No IDs to set.', __FILE__, __LINE__, __METHOD__, 10); return FALSE; }
$data['selected_department_options'] = Misc::arrayIntersectByKey((array) $data['department_ids'], $department_options); if ($current_company->getProductEdition() == 20) { //Get Job Groups $jglf = new JobGroupListFactory(); $nodes = FastTree::FormatArray($jglf->getByCompanyIdArray($current_company->getId()), 'TEXT', TRUE); $job_group_options = $jglf->getArrayByNodes($nodes, FALSE, FALSE); $data['src_job_group_options'] = Misc::arrayDiffByKey((array) $data['job_group_ids'], $job_group_options); $data['selected_job_group_options'] = Misc::arrayIntersectByKey((array) $data['job_group_ids'], $job_group_options); //Get Jobs $jlf = new JobListFactory(); $jlf->getByCompanyId($current_company->getId()); $job_options = $jlf->getArrayByListFactory($jlf, FALSE, TRUE); $data['src_job_options'] = Misc::arrayDiffByKey((array) $data['job_ids'], $job_options); $data['selected_job_options'] = Misc::arrayIntersectByKey((array) $data['job_ids'], $job_options); //Get Job Item Groups $jiglf = new JobItemGroupListFactory(); $nodes = FastTree::FormatArray($jiglf->getByCompanyIdArray($current_company->getId()), 'TEXT', TRUE); $job_item_group_options = $jiglf->getArrayByNodes($nodes, FALSE, FALSE); $data['src_job_item_group_options'] = Misc::arrayDiffByKey((array) $data['job_item_group_ids'], $job_item_group_options); $data['selected_job_item_group_options'] = Misc::arrayIntersectByKey((array) $data['job_item_group_ids'], $job_item_group_options); //Get Job Items $jilf = new JobItemListFactory(); $jilf->getByCompanyId($current_company->getId()); $job_item_options = $jilf->getArrayByListFactory($jilf, FALSE, TRUE); $data['src_job_item_options'] = Misc::arrayDiffByKey((array) $data['job_item_ids'], $job_item_options); $data['selected_job_item_options'] = Misc::arrayIntersectByKey((array) $data['job_item_ids'], $job_item_options); } //Select box options; $wglf = new WageGroupListFactory(); $data['wage_group_options'] = $wglf->getArrayByListFactory($wglf->getByCompanyId($current_company->getId()), TRUE); $data['type_options'] = $ppf->getOptions('type');