Exemplo n.º 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;
 }
Exemplo n.º 2
0
$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']);
        }
        if ($branch_data['fax_phone'] != '') {
            $bf->setFaxPhone($branch_data['fax_phone']);
        }
        if ($bf->isValid()) {
            $bf->Save();