示例#1
0
 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;
 }
示例#2
0
             $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();
             }
             unset($bf, $new_branch_id, $next_available_manual_id);
         }
     }
     $uf->setDefaultBranch($tmp_branch);
     unset($tmp_branch);
 }
 if (isset($mapped_row['default_department_id']) and $mapped_row['default_department_id'] != '') {
     $tmp_department = Misc::importCallInputParseFunction('default_department_id', $mapped_row['default_department_id'], $filtered_import_map['default_department_id']['default_value'], $filtered_import_map['default_department_id']['parse_hint']);
     if ($create_department === TRUE) {
         //Check to see if department exists or not.