本文整理汇总了PHP中Company::getErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP Company::getErrors方法的具体用法?PHP Company::getErrors怎么用?PHP Company::getErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Company
的用法示例。
在下文中一共展示了Company::getErrors方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public function register()
{
$user = new User();
$user->first_name = $this->first_name;
$user->last_name = $this->last_name;
$user->email = $this->email;
$user->position = $this->position;
$user->phone = $this->phone;
$user->password = $this->password;
$user->username = $this->username;
$user->role = User::ROLE_EMPL;
$user->status = User::STATUS_DISABLED;
$user->additional_contact = $this->additional_contact;
$user->hash = md5(microtime(true) . rand());
if (!$user->save()) {
$this->addError('username', 'Can`t create user ' . serialize($user->getErrors()));
return false;
}
UserHelper::sendEmailConfirmation($user);
$company = new Company();
$company->name = $this->name;
$company->site_url = $this->site_url;
$company->address = $this->address;
$company->created_at = new CDbExpression('NOW()');
$company->updated_at = new CDbExpression('NOW()');
if (!$company->save()) {
$this->addError('name', 'Can`t create company ' . serialize($company->getErrors()));
return false;
}
$bind = new UserToCompany();
$bind->user_id = $user->id;
$bind->company_id = $company->id;
if (!$bind->save()) {
$this->addError('name', 'Can`t bind company ' . serialize($bind->getErrors()));
return false;
}
return true;
}
示例2: actionWrite
public function actionWrite()
{
parent::actionWrite();
if (isset($_POST['Company'])) {
$messages = $this->ValidateData(array(array($_POST['Company']['companyname'], 'emptycompanyname', 'emptystring'), array($_POST['Company']['address'], 'emptyaddressname', 'emptystring'), array($_POST['Company']['cityid'], 'emptycityname', 'emptystring'), array($_POST['Company']['zipcode'], 'emptyzipcode', 'emptystring'), array($_POST['Company']['currencyid'], 'emptycurrency', 'emptystring')));
if ($messages == '') {
if ((int) $_POST['Company']['companyid'] > 0) {
$model = $this->loadModel($_POST['Company']['companyid']);
$model->companyname = $_POST['Company']['companyname'];
$model->address = $_POST['Company']['address'];
$model->cityid = $_POST['Company']['cityid'];
$model->zipcode = $_POST['Company']['zipcode'];
$model->taxno = $_POST['Company']['taxno'];
$model->currencyid = $_POST['Company']['currencyid'];
$model->recordstatus = $_POST['Company']['recordstatus'];
} else {
$model = new Company();
$model->attributes = $_POST['Company'];
}
try {
if ($model->save()) {
$this->DeleteLock($this->menuname, $_POST['Company']['companyid']);
$this->GetSMessage('scoinsertsuccess');
} else {
$this->GetMessage($model->getErrors());
}
} catch (Exception $e) {
$this->GetMessage($e->getMessage());
}
}
}
}
示例3: beforeSave
/**
* Before model saved
*
* @return bool
*/
public function beforeSave()
{
// Save new company, if id is not numeric then user added a custom value
$company = Company::model()->countByAttributes(['id' => $this->company_id]);
if ($company == 0) {
$company = new Company();
$company->setAttribute('title', $this->company_id);
if (!$company->validate()) {
$this->addErrors($company->getErrors());
} else {
if ($company->save()) {
$this->company_id = $company->id;
} else {
$this->addError('company_id', [Yii::t('main', 'Error saving new company.')]);
}
}
}
// If model is updating
if (!$this->isNewRecord) {
$this->beforeUpdate();
}
return parent::beforeSave();
}
示例4: importCompany
private function importCompany($fileNameAndPath)
{
$allAccounts = array();
$dom = new domDocument();
if (!$dom->load($fileNameAndPath)) {
throw new CException(Yii::t('lazy8', 'input file could not be xml parsed'));
}
$root = $dom->documentElement;
if ($root->nodeName != "lazy8webport") {
$this->hasErrors = true;
$this->errors = array(array(Yii::t('lazy8', 'Upload failed. This is not a valid file.'), Yii::t('lazy8', 'Select a file and try again')));
$this->render('showimport');
return 0;
}
if ($root->getAttribute('version') > 1.0) {
$this->errors = array(array(Yii::t('lazy8', 'There maybe problems because this is a file version greater then this programs version'), Yii::t('lazy8', 'Select a file and try again')));
}
$nodeCompanys = $root->getElementsByTagName('company');
unset($root);
unset($dom);
$this->lastImportedPeriod = 0;
foreach ($nodeCompanys as $nodeCompany) {
//make sure the company code is unique
$modelCompany = new Company();
$code = $nodeCompany->getAttribute('code');
$code--;
//make sure the company code is valid. Change if not.
do {
$code++;
$comptest = Company::model()->find(array('condition' => 'code=' . $code));
} while ($comptest !== null);
//create the company
$modelCompany = new Company();
$modelCompany->code = $code;
$modelCompany->name = $nodeCompany->getAttribute('name');
$modelCompany->lastAbsTransNum = $nodeCompany->getAttribute('lastAbsTransNum');
if (!$modelCompany->save()) {
throw new CException(Yii::t('lazy8', 'Could not create the company, bad paramters') . ';' . var_export($modelCompany->getErrors()));
}
try {
$allAccounts = array();
$nodesAccountTypes = $nodeCompany->getElementsByTagName('accounttype');
foreach ($nodesAccountTypes as $nodeAccountType) {
$modelAccountType = new AccountType();
$modelAccountType->companyId = $modelCompany->id;
$modelAccountType->code = $nodeAccountType->getAttribute('code');
$modelAccountType->name = $nodeAccountType->getAttribute('name');
$modelAccountType->sortOrder = $nodeAccountType->getAttribute('sortorder');
$modelAccountType->isInBalance = $nodeAccountType->getAttribute('isinbalance') == "1" ? 1 : 0;
if (!$modelAccountType->save()) {
$modelCompany->delete();
throw new CException(Yii::t('lazy8', 'Could not create the AccountType, bad paramters') . ';name=' . $modelAccountType->name . ';' . serialize($modelAccountType->getErrors()));
}
$nodesAccounts = $nodeAccountType->getElementsByTagName('account');
foreach ($nodesAccounts as $nodeAccount) {
$modelAccount = new Account();
$modelAccount->companyId = $modelCompany->id;
$modelAccount->code = $nodeAccount->getAttribute('code');
$modelAccount->accountTypeId = $modelAccountType->id;
$modelAccount->name = $nodeAccount->getAttribute('name');
if (!$modelAccount->save()) {
$modelCompany->delete();
throw new CException(Yii::t('lazy8', 'Could not create the Account, bad paramters') . ';' . serialize($modelAccount->getErrors()));
}
$allAccounts[$modelAccount->code] = $modelAccount->id;
unset($nodeAccount);
unset($modelAccount);
}
unset($modelAccountType);
unset($nodeAccountType);
}
unset($nodesAccountTypes);
$allCustomers = array();
$nodesCustomers = $nodeCompany->getElementsByTagName('customer');
foreach ($nodesCustomers as $nodeCustomer) {
$modelCustomer = new Customer();
$modelCustomer->companyId = $modelCompany->id;
$modelCustomer->code = $nodeCustomer->getAttribute('code');
$modelCustomer->accountId = $this->FindAccountIdFromCode($nodeCustomer->getAttribute('accountcode'), $modelCompany->id, $allAccounts, 'customercode=' . $modelCustomer->code, $this->errors, true);
$modelCustomer->name = $nodeCustomer->getAttribute('name');
$modelCustomer->desc = $nodeCustomer->getAttribute('desc');
if (!$modelCustomer->save()) {
$modelCompany->delete();
throw new CException(Yii::t('lazy8', 'Could not create the Customer, bad paramters') . ';' . serialize($modelCustomer->getErrors()));
}
$allCustomers[$modelCustomer->code] = $modelCustomer->id;
unset($modelCustomer);
unset($nodeCustomer);
}
unset($nodesCustomers);
$nodesPeriods = $nodeCompany->getElementsByTagName('period');
foreach ($nodesPeriods as $nodePeriod) {
$modelPeriod = new Period();
$modelPeriod->companyId = $modelCompany->id;
$modelPeriod->dateStart = $nodePeriod->getAttribute('datestart');
$modelPeriod->dateEnd = $nodePeriod->getAttribute('dateend');
$modelPeriod->lastPeriodTransNum = $nodePeriod->getAttribute('lastperiodtransnum');
if (!$modelPeriod->save()) {
$modelCompany->delete();
throw new CException(Yii::t('lazy8', 'Could not create the period, bad paramters') . ';' . serialize($modelPeriod->getErrors()));
//.........这里部分代码省略.........