Example #1
0
         }
     }
     $uf->setDefaultDepartment($tmp_department);
     unset($tmp_department);
 }
 if (isset($mapped_row['group_id']) and $mapped_row['group_id'] != '') {
     if ($create_group === TRUE and !is_numeric($mapped_row['group_id'])) {
         //Check to see if branch exists or not.
         if (array_search($mapped_row['group_id'], $group_options) === FALSE) {
             $ugf = new UserGroupFactory();
             $ugf->setCompany($mapped_row['company_id']);
             $ugf->setParent(0);
             $ugf->setName($mapped_row['group_id']);
             if ($ugf->isValid()) {
                 echo "[CG: " . $mapped_row['group_id'] . "]";
                 $new_group_id = $ugf->Save();
                 $group_options[$new_group_id] = $mapped_row['group_id'];
             }
             unset($ugf, $new_group_id);
         }
     }
     $uf->setGroup(Misc::importCallInputParseFunction('group_id', $mapped_row['group_id'], $filtered_import_map['group_id']['default_value'], $filtered_import_map['group_id']['parse_hint']));
 }
 if (isset($mapped_row['title_id']) and $mapped_row['title_id'] != '') {
     if ($create_title === TRUE and !is_numeric($mapped_row['title_id'])) {
         //Check to see if title exists or not.
         if (array_search($mapped_row['title_id'], $title_options) === FALSE) {
             //Create title
             $utf = new UserTitleFactory();
             $utf->setCompany($mapped_row['company_id']);
             $utf->setName($mapped_row['title_id']);
 function createUserGroup($company_id, $type, $parent_id = 0)
 {
     $ugf = new UserGroupFactory();
     $ugf->setCompany($company_id);
     switch ($type) {
         case 10:
             $ugf->setParent($parent_id);
             $ugf->setName('Employee Group A');
             break;
         case 20:
             $ugf->setParent($parent_id);
             $ugf->setName('Employee Group A2');
             break;
         case 30:
             $ugf->setParent($parent_id);
             $ugf->setName('Employee Group A3');
             break;
         case 40:
             $ugf->setParent($parent_id);
             $ugf->setName('Employee Group B');
             break;
         case 50:
             $ugf->setParent($parent_id);
             $ugf->setName('Employee Group B2');
             break;
     }
     if ($ugf->isValid()) {
         $insert_id = $ugf->Save();
         Debug::Text('Group ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10);
         return $insert_id;
     }
     Debug::Text('Failed Creating Pay Period Schedule!', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
Example #3
0
/*
 * Get FORM variables
 */
extract(FormVariables::GetVariables(array('action', 'id', 'previous_parent_id', 'data')));
$ugf = new UserGroupFactory();
$action = Misc::findSubmitButton();
switch ($action) {
    case 'submit':
        Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10);
        $ugf->setId($data['id']);
        $ugf->setCompany($current_company->getId());
        $ugf->setPreviousParent($previous_parent_id);
        $ugf->setParent($data['parent_id']);
        $ugf->setName($data['name']);
        if ($ugf->isValid()) {
            $ugf->Save();
            Redirect::Page(URLBuilder::getURL(NULL, 'UserGroupList.php'));
            break;
        }
    default:
        $uglf = new UserGroupListFactory();
        $nodes = FastTree::FormatArray($uglf->getByCompanyIdArray($current_company->getId()), 'TEXT', TRUE);
        foreach ($nodes as $node) {
            $parent_list_options[$node['id']] = $node['text'];
        }
        $smarty->assign_by_ref('parent_list_options', $parent_list_options);
        if (isset($id)) {
            BreadCrumb::setCrumb($title);
            //Get parent data
            $ft = new FastTree($fast_tree_user_group_options);
            $ft->setTree($current_company->getID());