function createBranch($company_id, $type)
 {
     $bf = new BranchFactory();
     $bf->setCompany($company_id);
     $bf->setStatus(10);
     switch ($type) {
         case 10:
             //Branch 1
             $bf->setName('New York');
             $bf->setAddress1('123 Main St');
             $bf->setAddress2('Unit #123');
             $bf->setCity('New York');
             $bf->setCountry('US');
             $bf->setProvince('NY');
             $bf->setPostalCode('12345');
             $bf->setWorkPhone('555-555-5555');
             $bf->setManualId(1);
             break;
         case 20:
             //Branch 2
             $bf->setName('Seattle');
             $bf->setAddress1('789 Main St');
             $bf->setAddress2('Unit #789');
             $bf->setCity('Seattle');
             $bf->setCountry('US');
             $bf->setProvince('WA');
             $bf->setPostalCode('98105');
             $bf->setWorkPhone('555-555-5555');
             $bf->setManualId(2);
             break;
     }
     if ($bf->isValid()) {
         $insert_id = $bf->Save();
         Debug::Text('Branch ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10);
         return $insert_id;
     }
     Debug::Text('Failed Creating Branch!', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
Example #2
0
     $uf->setPayPeriodSchedule(Misc::importCallInputParseFunction('pay_period_schedule_id', $mapped_row['pay_period_schedule_id'], $filtered_import_map['pay_period_schedule_id']['default_value'], $filtered_import_map['pay_period_schedule_id']['parse_hint']));
 }
 if (isset($mapped_row['policy_group_id']) and $mapped_row['policy_group_id'] != '') {
     $uf->setPolicyGroup(Misc::importCallInputParseFunction('policy_group_id', $mapped_row['policy_group_id'], $filtered_import_map['policy_group_id']['default_value'], $filtered_import_map['policy_group_id']['parse_hint']));
 }
 if (isset($mapped_row['default_branch_id']) and $mapped_row['default_branch_id'] != '') {
     if ($create_branch === TRUE and !is_numeric($mapped_row['default_branch_id'])) {
         //Check to see if branch exists or not.
         //if ( array_search( $mapped_row['default_branch_id'], $branch_options ) === FALSE ) {
         if (parse_default_branch_id($mapped_row['default_branch_id']) === FALSE) {
             //Create branch
             $bf = new BranchFactory();
             $bf->setCompany($mapped_row['company_id']);
             $bf->setStatus(10);
             $next_available_manual_id = BranchListFactory::getNextAvailableManualId($mapped_row['company_id']);
             $bf->setManualId($next_available_manual_id);
             $bf->setName($mapped_row['default_branch_id']);
             $bf->setCity('NA');
             if ($bf->isValid()) {
                 echo "[CB: " . $mapped_row['default_branch_id'] . "]";
                 $new_branch_id = $bf->Save();
                 $branch_options[$new_branch_id] = $mapped_row['default_branch_id'];
             }
             unset($bf, $new_branch_id, $next_available_manual_id);
         }
     }
     $uf->setDefaultBranch(Misc::importCallInputParseFunction('default_branch_id', $mapped_row['default_branch_id'], $filtered_import_map['default_branch_id']['default_value'], $filtered_import_map['default_branch_id']['parse_hint']));
 }
 if (isset($mapped_row['default_department_id']) and $mapped_row['default_department_id'] != '') {
     if ($create_department === TRUE and !is_numeric($mapped_row['default_department_id'])) {
         //Check to see if department exists or not.
Example #3
0
 if (isset($mapped_row['policy_group_id']) and $mapped_row['policy_group_id'] != '') {
     $uf->setPolicyGroup(Misc::importCallInputParseFunction('policy_group_id', $mapped_row['policy_group_id'], $filtered_import_map['policy_group_id']['default_value'], $filtered_import_map['policy_group_id']['parse_hint']));
 }
 if (isset($mapped_row['default_branch_id']) and $mapped_row['default_branch_id'] != '') {
     $tmp_branch = Misc::importCallInputParseFunction('default_branch_id', $mapped_row['default_branch_id'], $filtered_import_map['default_branch_id']['default_value'], $filtered_import_map['default_branch_id']['parse_hint']);
     if ($create_branch === TRUE) {
         //Check to see if branch exists or not.
         if (array_search(parse_default_branch_id($mapped_row['default_branch_id']), $branch_options) === FALSE) {
             //Create branch
             $bf = new BranchFactory();
             $bf->setCompany($mapped_row['company_id']);
             $bf->setStatus(10);
             if (strtolower($filtered_import_map['default_branch_id']['parse_hint']) == 'parse_manual_id') {
                 //Parse out any digits from the branch name and use them as the manual_id.
                 $bf->setName($bf->Validator->stripNumeric($mapped_row['default_branch_id']));
                 $bf->setManualId($bf->Validator->stripNonNumeric($mapped_row['default_branch_id']));
                 $tmp_branch = $bf->getName();
             } elseif (strtolower($filtered_import_map['default_branch_id']['parse_hint']) == 'manual_id') {
                 $bf->setName($mapped_row['default_branch_id']);
                 $bf->setManualId($mapped_row['default_branch_id']);
             } else {
                 $next_available_manual_id = BranchListFactory::getNextAvailableManualId($mapped_row['company_id']);
                 $bf->setName($mapped_row['default_branch_id']);
                 $bf->setManualId($next_available_manual_id);
             }
             $bf->setCity('NA');
             if ($bf->isValid()) {
                 echo "[CB: " . $mapped_row['default_branch_id'] . "]";
                 $new_branch_id = $bf->Save(FALSE);
                 $branch_options[$new_branch_id] = $bf->getName();
                 $branch_manual_id_options[$new_branch_id] = $bf->getManualId();
Example #4
0
// See index.php
/*
 * Get FORM variables
 */
extract(FormVariables::GetVariables(array('action', 'id', 'branch_data')));
$bf = new BranchFactory();
$action = Misc::findSubmitButton();
$action = strtolower($action);
switch ($action) {
    case 'submit':
        Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10);
        $bf->setId($branch_data['id']);
        $bf->setCompany($current_company->getId());
        $bf->setStatus($branch_data['status']);
        $bf->setName($branch_data['name']);
        $bf->setManualId($branch_data['manual_id']);
        if ($branch_data['address1'] != '') {
            $bf->setAddress1($branch_data['address1']);
        }
        if ($branch_data['address2'] != '') {
            $bf->setAddress2($branch_data['address2']);
        }
        $bf->setCity($branch_data['city']);
        $bf->setCountry($branch_data['country']);
        $bf->setProvince($branch_data['province']);
        if ($branch_data['postal_code'] != '') {
            $bf->setPostalCode($branch_data['postal_code']);
        }
        if ($branch_data['work_phone'] != '') {
            $bf->setWorkPhone($branch_data['work_phone']);
        }