本文整理汇总了PHP中Companies::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Companies::model方法的具体用法?PHP Companies::model怎么用?PHP Companies::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Companies
的用法示例。
在下文中一共展示了Companies::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadDocuments
/**
* Upload documents
* @param $uploadType
* @param bool $withoutMessage
* @return int
*/
public static function uploadDocuments($uploadType, $withoutMessage = false) {
if(isset($_SESSION[$uploadType]) && count($_SESSION[$uploadType]) > 0) {
$settings = UsersSettings::model()->findByAttributes(array(
'User_ID' => Yii::app()->user->userID,
));
//get default bank account
$condition = new CDbCriteria();
$condition->condition = "users_project_list.User_ID = '" . Yii::app()->user->userID . "'";
$condition->addCondition("users_project_list.Client_ID = '" . Yii::app()->user->clientID . "'");
$condition->addCondition("t.Account_Num_ID = '" . $settings->Default_Bank_Acct . "'");
$condition->join = "LEFT JOIN projects ON projects.Project_ID = t.Project_ID
LEFT JOIN users_project_list ON users_project_list.Project_ID = t.Project_ID";
$bankAcct = BankAcctNums::model()->with('client.company', 'project')->find($condition);
$defaultBankAcct = 0;
if ($bankAcct) {
$defaultBankAcct = $settings->Default_Bank_Acct;
}
//get user to send email
$person_to_email = false;
if (Yii::app()->user->id != 'user' && Yii::app()->user->id != 'single_user') {
$person_to_email = Users::model()->with('person')->findByPk(Yii::app()->user->userID);
} else {
$condition = new CDbCriteria();
$condition->join = "LEFT JOIN users_client_list ON users_client_list.User_ID = t.User_ID";
$condition->addInCondition('users_client_list.User_Type', array(UsersClientList::APPROVER, UsersClientList::PROCESSOR, UsersClientList::CLIENT_ADMIN));
$condition->addInCondition('t.User_Type', array(Users::ADMIN, Users::DB_ADMIN, Users::DATA_ENTRY_CLERK), "OR");
$condition->addCondition("users_client_list.Client_ID = '" . Yii::app()->user->clientID . "'");
$person_to_email = Users::model()->with('person')->find($condition);
}
foreach ($_SESSION[$uploadType] as $key => $current_upload_file) {
// check fed id
if ($current_upload_file['doctype'] == self::W9) {
if (!preg_match('/^(\d{2}\-\d{7})|(\d{3}\-\d{2}\-\d{4})|(IN[-]\d{6})|(T0[-]\d{7})$/', $current_upload_file['fed_id'])) {
return 2;
}
}
}
// insert documents into DB
foreach ($_SESSION[$uploadType] as $key => $current_upload_file) {
if (file_exists($current_upload_file['filepath'])) {
// create document
$document = new Documents();
$document->Document_Type = $current_upload_file['doctype'];
$document->User_ID = Yii::app()->user->userID;
$document->Client_ID = Yii::app()->user->clientID;
$document->Project_ID = Yii::app()->user->projectID;
$document->Created = date("Y-m-d H:i:s");
$document->save();
$new_doc_id=$document->Document_ID;
Audits::LogAction($document->Document_ID ,Audits::ACTION_UPLOAD);
// insert image
$image = new Images();
$imageData = addslashes(fread(fopen($current_upload_file['filepath'],"rb"),filesize($current_upload_file['filepath'])));
//$imageData = FileModification::ImageToPdfByFilePath($current_upload_file['filepath']);
$image->Document_ID = $document->Document_ID;
$image->Img = $imageData;
$image->File_Name = $current_upload_file['name'];
$image->Mime_Type = $current_upload_file['mimetype'];
$image->File_Hash = sha1_file($current_upload_file['filepath']);
$image->File_Size = intval(filesize($current_upload_file['filepath']));
$image->Pages_Count = FileModification::calculatePagesByPath($current_upload_file['filepath']);
$image->save();
$infile = @file_get_contents($current_upload_file['filepath'], FILE_BINARY);
if (($current_upload_file['mimetype'] == 'application/pdf' && $image->findPdfText($infile) == '')
|| $current_upload_file['mimetype'] != 'application/pdf') {
Documents::crateDocumentThumbnail($current_upload_file['filepath'], 'thumbs', $current_upload_file['mimetype'], $document->Document_ID, 80);
}
// delete file from temporary catalog and from cache table
//unlink($current_upload_file['filepath']);
FileCache::deleteBothFromCacheById($current_upload_file['file_id']);
if ($current_upload_file['doctype'] == self::W9) {
// if document is W9
// get additional fields
$fedId = trim($current_upload_file['fed_id']);
$newCompanyName = trim($current_upload_file['company_name']);
// get company info
$company = Companies::model()->with('client')->findByAttributes(array(
'Company_Fed_ID' => $fedId,
//.........这里部分代码省略.........
示例2: check_fed_id
/**
* Check Fed ID rule
*/
public function check_fed_id() {
$company = Companies::model()->find('Company_Fed_ID=:Fed_ID',
array(':Fed_ID'=>$this->Fed_ID));
if($company != null) {
$this->addError('Fed_ID','Company with this Fed ID already exists');
} else if (!preg_match('/^(\d{2}\-\d{7})|(\d{3}\-\d{2}\-\d{4})$/', $this->Fed_ID)) {
$this->addError('Fed_ID','Invalid Fed ID, correct formatting: xx-xxxxxxx');
}
}
示例3: check_auth
/**
* Check Auth_Code rule
*/
public function check_auth() {
$client = Clients::model()->findByPk($this->Client_ID);
if($client) {
$company = Companies::model()->findByPk($client->Company_ID);
if ($company->Auth_Code != $this->Auth_Code) {
$this->addError('Auth_Code','Invalid Authorization Code');
}
} else {
$this->addError('Auth_Code',"Company with this Authorization Code doesn't exists");
}
}
示例4: importVendors
/**
* Import Vendors
* @param $clientID
* @param $importedVendors
*/
public static function importVendors($clientID, $importedVendors)
{
$all_amount=count($importedVendors);
$i=0;
$pb= ProgressBar::init();
foreach($importedVendors as $importedVendor) {
$company = Companies::model()->with('client')->findByAttributes(array(
'Company_Fed_ID' => $importedVendor['fedId'],
));
if ($company) {
$client = $company->client;
} else {
//if company does not exists, create new company
$client = Companies::createEmptyCompany($importedVendor['fedId'], $importedVendor['companyName'], $importedVendor);
}
$vendorClientId = $client->Client_ID;
$vendor = Vendors::model()->findByAttributes(array(
'Client_Client_ID' => $clientID,
'Vendor_Client_ID' => $vendorClientId,
));
$newVendor = false;
if (!$vendor) {
$vendor = new Vendors();
$newVendor = true;
} else {
$vendor->Active_Relationship = self::ACTIVE_RELATIONSHIP;
$vendor->save();
}
$vendor->Vendor_ID_Shortcut = $importedVendor['shortcut'];
$vendor->Vendor_Client_ID = $vendorClientId;
$vendor->Client_Client_ID = $clientID;
$vendor->Vendor_Name_Checkprint = $importedVendor['checkprint'];
$vendor->Vendor_1099 = $importedVendor['v1099'];
$vendor->Vendor_Default_GL = $importedVendor['defG'];
$vendor->Vendor_Default_GL_Note = $importedVendor['defGLNote'];
$vendor->Vendor_Note_General = $importedVendor['noteGeneral'];
if ($vendor->validate()) {
$vendor->save();
} else if ($newVendor) {
$vendor = new Vendors();
$vendor->Vendor_ID_Shortcut = '';
$vendor->Vendor_Client_ID = $vendorClientId;
$vendor->Client_Client_ID = $clientID;
$vendor->Vendor_Name_Checkprint = '';
$vendor->Vendor_1099 = '';
$vendor->Vendor_Default_GL = '';
$vendor->Vendor_Default_GL_Note = '';
$vendor->Vendor_Note_General = '';
$vendor->Active_Relationship = self::ACTIVE_RELATIONSHIP;
$vendor->save();
}
$i++;
$percent=intval($i/$all_amount*100);
session_start();
$_SESSION['progress']=$percent;
session_write_close();
}
}
示例5:
</div><!--.container-->
<aside class="left-sidebar">
<div class="box-gray">
<div class="box-gray__head big">
Информация об уч. записи
</div>
<div class="box-gray__body">
<div class="box-gray__form">
<form class="fly-validation" id="form-compay-info" action="#" method="post">
<ul class="compay-info edit-row" id="compay-info">
<li><img class="image1" src="<?php
echo $correct_path;
?>
/img/company.svg"><span class="editable"
rel="company"><?php
echo Companies::model()->findByPk($user->company_id)->name;
?>
</span>
</li>
<li><img class="image1" src="<?php
echo $correct_path;
?>
/img/1111.svg"><span class="editable"
rel="name"><?php
echo $user->first_name;
?>
</span>
</li>
<li><img class="image1" src="<?php
echo $correct_path;
?>
示例6: array
<div class="popup" id="popup-compay-info">
<div class="popup__head">
<div class="title">Информация об учетной записи</div>
</div>
<div class="popup__form">
<div class="client_info">
Компания:
</div>
<?php
$form = $this->beginWidget('CActiveForm', array('id' => 'edit-current-user', 'enableAjaxValidation' => true, 'clientOptions' => array('validateOnSubmit' => true), 'action' => 'edit_current_user'));
?>
<div class="form-group">
<?php
echo $form->textField($user, 'company_name', array('value' => Companies::model()->findByPk($user->company_id)->name, 'class' => 'form-control', 'placeholder' => 'Наименование компании'));
?>
<?php
echo $form->error($user, 'company_name', array('class' => 'form-error'));
?>
<span class="star">*</span>
</div>
<div class="client_info">
Мои данные:
</div>
<div class="form-group">
<?php
echo $form->textField($user, 'first_name', array('class' => 'form-control', 'placeholder' => 'Ваше имя'));
?>
<?php
echo $form->error($user, 'first_name', array('class' => 'form-error'));
?>
<span class="star">*</span>
示例7: countCompaniesByAccount
public function countCompaniesByAccount($company_id, $account_id)
{
return Companies::model()->count(array('condition' => 't.company_id = :company_id AND Cusers.account_id = :account_id', 'params' => array(':account_id' => $account_id, ':company_id' => $company_id), 'with' => array('Cusers')));
}
示例8: actionEdit_current_user
public function actionEdit_current_user()
{
$user = Users::model()->findByPk(Yii::app()->user->id);
$user->setScenario('edit_current_user');
if ($_POST['MainUsers']) {
$user->attributes = $_POST['MainUsers'];
if (isset($_POST['ajax']) && $_POST['ajax'] == 'edit-current-user') {
echo CActiveForm::validate($user);
Yii::app()->end();
}
if ($_POST['MainUsers']['company_name']) {
$company = Companies::model()->findByPk($user->company_id);
$company->name = $_POST['MainUsers']['company_name'];
$company->update();
}
if ($user->update()) {
$this->redirect(array('user_info'));
}
}
}
示例9: beforeAction
/**
* This method is invoked right before an action is to be executed (after all possible filters.)
* @param CAction $action the action to be executed.
* @return boolean whether the action should be executed
*/
public function beforeAction($action)
{
$response = false;
//if (Yii::app()->user->getState('project_selected') != null)
//{
if (in_array($action->id, array('view', 'update'))) {
$response = Companies::model()->countCompaniesByAccount((int) $_GET['id'], Yii::app()->user->Accountid) > 0 ? true : false;
} else {
$response = true;
}
//}
//else
// return false;
if (!$response) {
throw new CHttpException(403, Yii::t('site', '403_Error'));
} else {
return $response;
}
}
示例10: getDataByName
public static function getDataByName($name) {
$result = array();
$criteria = new CDbCriteria();
$criteria->compare('Company_Name',$name,true);
$companies = Companies::model()->with('adreses')->findAll($criteria);
$i = 0;
foreach ($companies as $company) {
$result[$i]['Company_Name'] = Helper::truncLongWords($company->Company_Name,30);
$result[$i]['Address1'] = $company->adreses[0]->Address1;
$result[$i]['City'] = $company->adreses[0]->City;
$result[$i]['State'] = $company->adreses[0]->State;
$result[$i]['ZIP'] = $company->adreses[0]->ZIP;
$result[$i]['Company_Fed_ID'] = $company->Company_Fed_ID;
$i++;
}
return $result;
}
示例11: getW9ByClientID
public static function getW9ByClientID($client_id) {
$client = Clients::model()->findByPk($client_id);
//0) find company of a client
$company = Companies::model()->findByPk($client->Company_ID);
//1) find current fed_id
$cur_fed_id = $company->Company_Fed_ID;
//2) find w9 with this fed id
$sql = "select companies.Company_Fed_ID, companies.Company_ID, companies.Company_Name,
addresses.Address1, addresses.City, addresses.State, addresses.ZIP,
t.* from w9 t
LEFT JOIN documents ON documents.Document_ID=t.Document_ID
LEFT JOIN clients ON t.Client_ID=clients.Client_ID
LEFT JOIN companies ON clients.Company_ID=companies.Company_ID
LEFT JOIN company_addresses ON company_addresses.Company_ID = companies.Company_ID
LEFT JOIN addresses ON addresses.Address_ID = company_addresses.Address_ID
where
(documents.Client_ID>'0') AND (companies.Company_Fed_ID LIKE '".$cur_fed_id."')";
$list= Yii::app()->db->createCommand($sql)->queryAll();
return $list;
}
示例12: actionUpdate
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
*/
public function actionUpdate()
{
// check if user has permissions to updateProjects
if (Yii::app()->user->checkAccess('updateProjects')) {
if (Yii::app()->user->isManager) {
// get Projects object from $_GET[id] parameter
$model = $this->loadModel();
// if Projects form exist
if (isset($_POST['Projects'])) {
// set form elements to Projects model attributes
$model->attributes = $_POST['Projects'];
// validate and save
if ($model->save()) {
// save log
$attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'ProjectUpdated', 'log_resourceid' => $model->project_id, 'log_type' => Logs::LOG_UPDATED, 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id, 'project_id' => $model->project_id);
Logs::model()->saveLog($attributes);
// to prevent F5 keypress, redirect to create page
$this->redirect(array('view', 'id' => $model->project_id));
}
}
// output update page
$this->render('update', array('model' => $model, 'companies' => Companies::model()->findCompanyList(Yii::app()->user->id), 'currencies' => Currencies::model()->findAll()));
} else {
Yii::app()->controller->redirect(array("projects/view", 'id' => $_GET['id']));
}
} else {
throw new CHttpException(403, Yii::t('site', '403_Error'));
}
}
示例13: actionGenerateLetter
/**
* Generate letter for Company
*/
public function actionGenerateLetter($id)
{
if ($id === 'all') {
$companies = Companies::getEmptyCompanies('*', 50, true);
$trans = array(' '=>'-', '/'=>'-', '\\'=>'-', '~'=>'-', '&'=>'-', '?'=>'-', ','=>'-', '"'=>'-', "'"=>'-');
$html = '';
foreach($companies['not_printed'] as $company) {
// activate client
$client = $company->client;
$client->Client_Type = 1;
$client->Client_Status = Clients::ACTIVE;
$client->Client_Number = $client->Client_ID;
$client->save();
$html .= Helper::getCompanyTemplate($company->Company_ID) . '<br/><br/>';
}
foreach($companies['printed'] as $company) {
// activate client
$client = $company->client;
$client->Client_Type = 1;
$client->Client_Status = Clients::ACTIVE;
$client->Client_Number = $client->Client_ID;
$client->save();
$html .= Helper::getCompanyTemplate($company->Company_ID) . '<br/><br/>';
}
$fileName = trim(strtr(strtolower('letter for all companies.pdf'), $trans));
Yii::import('ext.html2pdf.HTML2PDF');
$html2pdf = new HTML2PDF('L', 'A6', 'en');
$html2pdf->writeHTML($html);
$html2pdf->Output($fileName);
} else if(is_numeric($id)) {
$id = intval($id);
$trans = array(' '=>'-', '/'=>'-', '\\'=>'-', '~'=>'-', '&'=>'-', '?'=>'-', ','=>'-', '"'=>'-', "'"=>'-');
$company = Companies::model()->with('client')->findByPk($id);
// activate client
$client = $company->client;
$client->Client_Type = 1;
$client->Client_Status = Clients::ACTIVE;
$client->Client_Number = $client->Client_ID;
$client->save();
$templateBody = Helper::getCompanyTemplate($id);
if ($templateBody) {
$fileName = trim(strtr(strtolower('Letter for ' . $company->Company_Name . '.pdf'), $trans));
Yii::import('ext.html2pdf.HTML2PDF');
$html2pdf = new HTML2PDF('L', 'A6', 'en');
$html2pdf->writeHTML($templateBody);
$html2pdf->Output($fileName);
} else {
Yii::app()->user->setFlash('success', "Letter for this company can not be created!");
$this->redirect('/admin?tab=empty_companies');
}
} else {
$this->redirect('/admin?tab=empty_companies');
}
}
示例14: actionIndex
/**
* Lists all models.
*/
public function actionIndex()
{
if (isset($_POST['oper']) && $_POST['oper'] == 'edit') {
$companyId = intval($_POST["id"]);
$company = Companies::model()->with('client', 'adreses')->findByPk($companyId);
if ($company) {
if ($company->client) {
$client = $company->client;
$client->Client_Number = $_POST["Client_Number"];
$client->Client_Logo_Name = $_POST["Client_Logo_Name"];
$client->Client_Approval_Amount_1 = $_POST["Client_Approval_Amount_1"] ? $_POST["Client_Approval_Amount_1"] : null;
$client->Client_Approval_Amount_2 = $_POST["Client_Approval_Amount_2"] ? $_POST["Client_Approval_Amount_2"] : null;
if ($client->validate()) {
$client->save();
echo "client\n";
}
}
if ($company->adreses) {
$addresses = $company->adreses;
if (isset($addresses[0])) {
$address = $addresses[0];
$address->Address1 = $_POST["Address1"];
$address->Address2 = $_POST["Address2"];
$address->City = $_POST["City"];
$address->State = $_POST["State"];
$address->ZIP = $_POST["ZIP"];
$address->Country = $_POST["Country"];
$address->Phone = $_POST["Phone"];
$address->Fax = $_POST["Fax"];
if ($address->validate()) {
$address->save();
echo "address\n";
}
}
}
$company->Company_Name = $_POST["Company_Name"];
$company->Company_Fed_ID = $_POST["Company_Fed_ID"];
$company->Email = $_POST["Email"];
$company->SSN = $_POST["SSN"];
$company->Business_NameW9 = $_POST["Business_NameW9"];
if ($company->validate()) {
$company->save();
echo "company\n";
}
}
die;
}
if (isset($_POST['oper']) && $_POST['oper'] == 'add') {
die;
}
if (isset($_POST['oper']) && $_POST['oper'] == 'del') {
$companyId = intval($_POST["id"]);
$company = Companies::model()->with('client', 'adreses')->findByPk($companyId);
$documents = Documents::model()->findByAttributes(array(
'Client_ID' => $company->client->Client_ID,
));
if ($company && !$documents) {
if ($company->client) {
$client = $company->client;
UsersToApprove::model()->deleteAllByAttributes(array(
'Client_ID' => $client->Client_ID,
));
UsersClientList::model()->deleteAllByAttributes(array(
'Client_ID' => $client->Client_ID,
));
UsersProjectList::model()->deleteAllByAttributes(array(
'Client_ID' => $client->Client_ID,
));
BankAcctNums::model()->deleteAllByAttributes(array(
'Client_ID' => $client->Client_ID,
));
Coa::model()->deleteAllByAttributes(array(
'Client_ID' => $client->Client_ID,
));
Vendors::model()->deleteAllByAttributes(array(
'Client_Client_ID' => $client->Client_ID,
));
Vendors::model()->deleteAllByAttributes(array(
'Vendor_Client_ID' => $client->Client_ID,
));
$w9s = W9::model()->findAllByAttributes(array(
'Client_ID' => $client->Client_ID,
//.........这里部分代码省略.........
示例15: actionCreateProject
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreateProject()
{
// check if user has permissions to createProjects
if (Yii::app()->user->checkAccess('createProjects') && Yii::app()->user->checkAccess('permissionsConfiguration') && Yii::app()->user->IsAdministrator) {
// create Projects Object
$model = new Projects();
// if Projects form exist
if (isset($_POST['Projects'])) {
// set form elements to Projects model attributes
$model->attributes = $_POST['Projects'];
// validate and save
if ($model->save()) {
// Create relation between user and project (this user will be first manager)
$modelForm = new ProjectsHasUsersForm();
$modelForm->project_id = $model->primaryKey;
$modelForm->user_id = Yii::app()->user->id;
$modelForm->isManager = 1;
$modelForm->saveUser();
// Select current project has default selection project
Yii::app()->user->setState('project_selected', $model->primaryKey);
Yii::app()->user->setState('project_selectedName', $model->project_name);
// save log
$attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'ProjectCreated', 'log_resourceid' => $model->primaryKey, 'log_type' => Logs::LOG_ASSIGNED, 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id, 'project_id' => $model->primaryKey);
Logs::model()->saveLog($attributes);
// to prevent F5 keypress, redirect to create page
Yii::app()->controller->redirect(Yii::app()->createUrl('projects/view', array('id' => $model->primaryKey)));
}
}
$this->layout = 'column2';
// output create page
$this->render('../projects/create', array('model' => $model, 'companies' => Companies::model()->findCompanyList(Yii::app()->user->id), 'currencies' => Currencies::model()->findAll()));
} else {
throw new CHttpException(403, Yii::t('site', '403_Error'));
}
}