Exemplo n.º 1
0
 /**
  * Get default branch data for creating new branches.
  * @return array
  */
 function getBranchDefaultData()
 {
     $company_obj = $this->getCurrentCompanyObject();
     Debug::Text('Getting branch default data...', __FILE__, __LINE__, __METHOD__, 10);
     $next_available_manual_id = BranchListFactory::getNextAvailableManualId($company_obj->getId());
     $data = array('company_id' => $company_obj->getId(), 'status_id' => 10, 'manual_id' => $next_available_manual_id, 'city' => $company_obj->getCity(), 'country' => $company_obj->getCountry(), 'province' => $company_obj->getProvince(), 'work_phone' => $company_obj->getWorkPhone(), 'fax_phone' => $company_obj->getFaxPhone());
     return $this->returnHandler($data);
 }
Exemplo n.º 2
0
     //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();
         }
         unset($bf, $new_branch_id, $next_available_manual_id);
     }
 }
 $uf->setDefaultBranch($tmp_branch);
 unset($tmp_branch);
 function preSave()
 {
     if ($this->getStatus() == FALSE) {
         $this->setStatus(10);
     }
     if ($this->getManualID() == FALSE) {
         $this->setManualID(BranchListFactory::getNextAvailableManualId($this->getCompany()));
     }
     return TRUE;
 }
Exemplo n.º 4
0
        }
        if ($bf->isValid()) {
            $bf->Save();
            Redirect::Page(URLBuilder::getURL(NULL, 'BranchList.php'));
            break;
        }
    default:
        if (isset($id)) {
            BreadCrumb::setCrumb($title);
            $blf = TTnew('BranchListFactory');
            $blf->GetByIdAndCompanyId($id, $current_company->getId());
            foreach ($blf as $branch) {
                $branch_data = array('id' => $branch->getId(), 'status' => $branch->getStatus(), 'manual_id' => $branch->getManualID(), 'name' => $branch->getName(), 'address1' => $branch->getAddress1(), 'address2' => $branch->getAddress2(), 'city' => $branch->getCity(), 'province' => $branch->getProvince(), 'country' => $branch->getCountry(), 'postal_code' => $branch->getPostalCode(), 'work_phone' => $branch->getWorkPhone(), 'fax_phone' => $branch->getFaxPhone(), 'other_id1' => $branch->getOtherID1(), 'other_id2' => $branch->getOtherID2(), 'other_id3' => $branch->getOtherID3(), 'other_id4' => $branch->getOtherID4(), 'other_id5' => $branch->getOtherID5(), 'created_date' => $branch->getCreatedDate(), 'created_by' => $branch->getCreatedBy(), 'updated_date' => $branch->getUpdatedDate(), 'updated_by' => $branch->getUpdatedBy(), 'deleted_date' => $branch->getDeletedDate(), 'deleted_by' => $branch->getDeletedBy());
            }
        } elseif ($action != 'submit') {
            $next_available_manual_id = BranchListFactory::getNextAvailableManualId($current_company->getId());
            $branch_data = array('country' => $current_company->getCountry(), 'province' => $current_company->getProvince(), 'next_available_manual_id' => $next_available_manual_id);
        }
        //Select box options;
        $branch_data['status_options'] = $bf->getOptions('status');
        $cf = TTnew('CompanyFactory');
        $branch_data['country_options'] = $cf->getOptions('country');
        $branch_data['province_options'] = $cf->getOptions('province', $branch_data['country']);
        //Get other field names
        $oflf = TTnew('OtherFieldListFactory');
        $branch_data['other_field_names'] = $oflf->getByCompanyIdAndTypeIdArray($current_company->getID(), 4);
        $smarty->assign_by_ref('branch_data', $branch_data);
        break;
}
$smarty->assign_by_ref('bf', $bf);
$smarty->display('branch/EditBranch.tpl');