当前位置: 首页>>代码示例>>PHP>>正文


PHP Addresses::validate方法代码示例

本文整理汇总了PHP中Addresses::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Addresses::validate方法的具体用法?PHP Addresses::validate怎么用?PHP Addresses::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Addresses的用法示例。


在下文中一共展示了Addresses::validate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createEmptyCompany

    /**
     * Create Empty company without users
     * @param $fedId
     * @param $newCompanyName
     * @param $impVendorInfo
     * @return Clients
     */
    public static function createEmptyCompany($fedId, $newCompanyName, $impVendorInfo = null)
    {
        $client = new Clients;

        // begin transaction
        $transaction = Yii::app()->db->beginTransaction();
        try {
            $company = new Companies;
            $project = new Projects;
            $companyAdreses = new CompanyAddresses;
            //$usersClientList = new UsersClientList;

            $company->Company_Name = $newCompanyName;
            $company->Company_Fed_ID = $fedId;
            if (preg_match('/^(\d{2}\-\d{7})|(\d{3}\-\d{2}\-\d{4})$/', $company->Company_Fed_ID)) {
                //usual w9 do nothing
            }

            if (preg_match('/^(IN[-]\d{7})$/', $company->Company_Fed_ID)) {
            //international w9
                $company->Temp_Fed_ID_Flag = 'N';

            }
            if (preg_match('/^(T0[-]\d{7})$/', $company->Company_Fed_ID)) {
                //international w9
                $company->Temp_Fed_ID_Flag = 'T';
            }

            $company->Auth_Code = Helper::generatePassword();

            $company->save();


            $company_adress = new Addresses;

            if ($impVendorInfo) {
                $company_adress = new Addresses;
                $company_adress->Address1 = $impVendorInfo['address'];
                $company_adress->City = $impVendorInfo['city'];
                $company_adress->State = $impVendorInfo['state'];
                $company_adress->ZIP = $impVendorInfo['zip'];
                if ($company_adress->validate()) {
                    $company_adress->save();
                } else {
                    $company_adress = new Addresses;
                    $company_adress->save();
                }
            }

            $company_adress->save();

            $companyAdreses->Company_ID = $company->Company_ID;
            $companyAdreses->Address_ID = $company_adress->Address_ID ? $company_adress->Address_ID : 0;
            $companyAdreses->save();

            $client->Company_ID = $company->Company_ID;
            $client->Client_Type = 1;
            $client->Client_Number = 1;
            $client->save();

            //create client project
            $project->Client_ID = $client->Client_ID;
            $project->Project_Name = "Corporate";
            $project->Project_Description = "Description of the Project";
            $project->PO_Starting_Number = Projects::DEFAULT_PO_STARTING_NUMBER;
            $project->Ck_Req_Starting_Numb = Projects::DEFAULT_CKRQ_STARTING_NUMBER;
            $project->save();

            $transaction->commit();
        } catch(Exception $e) {
            $transaction->rollback();
        }

        return $client;
    }
开发者ID:ranvijayj,项目名称:htmlasa,代码行数:82,代码来源:Companies.php


注:本文中的Addresses::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。