本文整理汇总了PHP中app\models\Company::findOne方法的典型用法代码示例。如果您正苦于以下问题:PHP Company::findOne方法的具体用法?PHP Company::findOne怎么用?PHP Company::findOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Company
的用法示例。
在下文中一共展示了Company::findOne方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveInfo
public function saveInfo()
{
$company = Company::findOne($this->id);
if ($company) {
$company->setComment($this->info);
return true;
}
return false;
}
示例2: actionDelete
public function actionDelete()
{
$id = $_GET['id'];
//$arr=Company::findOne($id);
//echo $arr['_id'];die;
if (Company::findOne($id)->delete()) {
echo $this->success("删除成功", "index.php?r=company", '1');
} else {
echo $this->error("删除失败", "index.php?r=company", '1');
}
}
示例3: hasAccess
private function hasAccess($path)
{
//echo file_get_contents('php://input');
//return true;
$entityBody = \yii\helpers\Json::decode(file_get_contents('php://input'));
//\yii\helpers\Json::decode
Yii::info("input jsond: " . \yii\helpers\Json::encode($entityBody));
Yii::info("input: " . file_get_contents('php://input'));
//
if (isset($entityBody["login_id"])) {
$model = new \app\models\FormLogin();
$model->id = $entityBody['login_id'];
$model->hash = $entityBody['login_hash'];
//$model->company= $entityBody['login_company'];
//return true;
if ($model->apiLogin()) {
Yii::$app->timezone = Yii::$app->user->getParam('timezone');
Yii::$app->language = Yii::$app->user->getParam('language');
if ((int) $entityBody['login_company'] == 0) {
return true;
}
//no company
$company = Company::findOne($entityBody['login_company']);
if ($company !== null) {
$this->company = $company->id;
Company::loadComp($company);
return true;
}
} else {
return false;
}
}
return false;
//if isGuest() return false
$arr = explode('/', $path);
if (!isset($this->translate[$arr[0]])) {
return false;
}
return Yii::$app->user->checkAccess($path);
}
示例4: saveOptions
public function saveOptions()
{
$db = Yii::$app->db;
$transaction = $db->beginTransaction();
try {
$company = Company::findOne($this->id);
$company->name = $this->company_name;
$company->phone = $this->company_phone;
$company->twenty_four_hours = $this->shedule_twfhr;
$company->save();
$address = $company->address;
$address->region = $this->address_region;
$address->city = $this->address_city;
$address->district = $this->address_district;
$address->street = $this->address_street;
$address->home = $this->address_home;
$address->housing = $this->address_housing;
$address->building = $this->address_building;
$address->metro = $this->address_metro;
$address->save();
Shedule::deleteAll(['company_id' => $company->id]);
$days = array(1 => 'mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun');
for ($i = 1; $i <= 7; $i++) {
$day = 'shedule_' . $days[$i];
if ($this[$day] == 1) {
$shedule = new Shedule();
$shedule->company_id = $company->id;
$shedule->day = $i;
$shedule->begin = $this->b_hour . ':' . $this->b_minute . ':00';
$shedule->end = $this->e_hour . ':' . $this->e_minute . ':00';
$shedule->save();
}
}
$transaction->commit();
} catch (Exception $e) {
$transaction->rollBack();
return false;
}
return true;
}
示例5: actionIndex
public function actionIndex($id)
{
if (Yii::$app->user->isGuest) {
return $this->redirect(Url::home());
}
$user = User::findOne(Yii::$app->user->id);
if ($user->company->id != $id) {
return $this->redirect(Url::home());
}
$company = Company::findOne($id);
$shedule = Shedule::getSheduleString($company->id, $company->twenty_four_hours);
$categories = Category::find()->all();
$countries = Country::find()->all();
$cInfFrm = new CompanyInfoForm();
$cInfFrm->loadInfo($id);
$cPasFrm = new ChangePasswordForm();
$cEmailFrm = new ChangeEmailForm();
$cEmailFrm->loadEmail();
$cOptFrm = new OptionsForm();
$cOptFrm->loadData($id);
$cities = City::find()->asArray()->all();
$cities = ArrayHelper::map($cities, 'name', 'name');
return $this->render('/private-room/private-room', ['company' => $company, 'shedule' => $shedule, 'categories' => $categories, 'countries' => $countries, 'cInfFrm' => $cInfFrm, 'cPasFrm' => $cPasFrm, 'cEmailFrm' => $cEmailFrm, 'cOptFrm' => $cOptFrm, 'cities' => $cities]);
}
示例6: actionUpdate
/**
* Updates an existing Quotation model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
$updateQuotationDetail = new QuotationDetail();
$quotationDetails = QuotationDetail::find()->where(['quotationdetail_quotationid' => $id])->orderBy('quotationdetail_id')->all();
$product = Product::find()->where(['product_type' => 'p'])->orderBy('product_id')->all();
$service = Product::find()->where(['product_type' => 's'])->orderBy('product_id')->all();
$customer = Customer::find()->orderBy('customer_name')->all();
$company = Company::findOne(1);
$customerID = $model->quotation_customerid;
$thisCustomer = Customer::findOne($customerID);
$uid = Yii::$app->user->identity->user_id;
$uname = Yii::$app->user->identity->user_name;
$details = [];
foreach ($quotationDetails as $detail) {
$details[] = $detail->quotationdetail_id;
}
if (isset($_POST['description'])) {
$quotationDetailList = $_POST['description'];
$customer_id = $_POST['customer-list'];
$quotation_id = $_POST['quotation_id'];
$quotation_no = $_POST['quotation_no'];
$quotation_date = $_POST['quotation_date'];
$productType = $_POST['productType'];
$qty = $_POST['qty'];
$unit = $_POST['unit'];
$cost = $_POST['cost'];
$remarks = $_POST['remarks'];
$hidden_price = $_POST['hidden_price'];
$hidden_gst = $_POST['hidden_gst'];
$hidden_tax_code = $_POST['hidden_tax_code'];
$hidden_tax_rate = $_POST['hidden_tax_rate'];
$hidden_price_gst = $_POST['hidden_price_gst'];
$hidden_total = $_POST['hidden_total'];
$hidden_gsttotal = $_POST['hidden_gsttotal'];
$hidden_gstpricetotal = $_POST['hidden_gstpricetotal'];
$hidden_id = $_POST['hidden_id'];
$hidden_quotationid = $_POST['hidden_quotationid'];
$hidden_product_name = $_POST['hidden_product_name'];
if ($quotationDetailList != NULL) {
if ($remarks == NULL) {
$remarks = "-";
}
$updateQuotation = $this->findModel($id);
$updateQuotation->quotation_id = $quotation_id;
$updateQuotation->quotation_no = $quotation_no;
$updateQuotation->quotation_date = $quotation_date;
$updateQuotation->quotation_date_transaction = $quotation_date;
$updateQuotation->quotation_customerid = $customer_id;
$updateQuotation->quotation_createid = $uid;
$updateQuotation->quotation_createname = $uname;
$updateQuotation->quotation_remark = $remarks;
$updateQuotation->quotation_system = "y";
$updateQuotation->quotation_partno = "y";
$updateQuotation->quotation_invoice = "123";
$updateQuotation->quotation_deliveryorder = "lol";
$updateQuotation->quotation_charge = 123;
$updateQuotation->quotation_tax_label = "lol";
$updateQuotation->quotation_tax_percent = 1;
$updateQuotation->quotation_tax_amount = 100;
$updateQuotation->quotation_printed_status = "y";
$updateQuotation->quotation_revision = 1;
$updateQuotation->quotation_parts_total = $hidden_total;
$updateQuotation->quotation_no_user_format = "lol";
$updateQuotation->quotation_gst_payable = $hidden_gsttotal;
$updateQuotation->quotation_total_amount = $hidden_gstpricetotal;
$updateQuotation->save();
foreach ($quotationDetailList as $key => $n) {
if ($hidden_quotationid[$key] == NULL || $hidden_quotationid[$key] == '') {
if ($unit[$key] == NULL) {
$unit[$key] = "-";
}
$newQuotationDetail = new QuotationDetail();
$newQuotationDetail->quotationdetail_quotationid = $quotation_id;
$newQuotationDetail->quotationdetail_productid = $n;
$newQuotationDetail->quotationdetail_partno = "lol";
$newQuotationDetail->quotationdetail_productname = $hidden_product_name[$key];
$newQuotationDetail->quotationdetail_producttype = $productType[$key];
$newQuotationDetail->quotationdetail_unit = $qty[$key];
$newQuotationDetail->quotationdetail_unitname = $unit[$key];
$newQuotationDetail->quotationdetail_product_cost = $cost[$key];
$newQuotationDetail->quotationdetail_price = $hidden_price[$key];
$newQuotationDetail->quotationdetail_tax_code = $hidden_tax_code[$key];
$newQuotationDetail->quotationdetail_tax_rate = $hidden_tax_rate[$key];
$newQuotationDetail->quotationdetail_tax_amount = $hidden_gst[$key];
$newQuotationDetail->quotationdetail_total_amount = $hidden_price_gst[$key];
$newQuotationDetail->quotationdetail_gst_status = 1;
$newQuotationDetail->save();
} elseif (in_array($hidden_quotationid[$key], $details)) {
$delete = array_search($hidden_quotationid[$key], $details);
if ($delete !== false) {
unset($details[$delete]);
}
if ($unit[$key] == NULL) {
//.........这里部分代码省略.........
示例7: findModel
/**
* Finds the Company model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Company the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Company::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
示例8: loadModel
public function loadModel($id)
{
$model = Company::findOne($id);
if ($model === null) {
throw new \yii\web\HttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例9: actionUpdate
/**
* Updates an existing PurchaseOrder model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
$updatePODetail = new PurchaseOrderDetail();
$poDetails = PurchaseOrderDetail::find()->where(['purchaseorderdetail_purchaseorderid' => $id])->orderBy('purchaseorderdetail_id')->all();
$product = Product::find()->where(['product_type' => 'p'])->orderBy('product_id')->all();
$service = Product::find()->where(['product_type' => 's'])->orderBy('product_id')->all();
$customer = Customer::find()->orderBy('customer_name')->all();
$company = Company::findOne(1);
$customerID = $model->purchaseorder_customerid;
$thisCustomer = Customer::findOne($customerID);
$uid = Yii::$app->user->identity->user_id;
$uname = Yii::$app->user->identity->user_name;
if (isset($_POST['description'])) {
$poDetailList = $_POST['description'];
$customer_id = $_POST['customer-list'];
$po_id = $_POST['po_id'];
$po_no = $_POST['po_no'];
$po_date = $_POST['po_date'];
$productType = $_POST['productType'];
$qty = $_POST['qty'];
$unit = $_POST['unit'];
$cost = $_POST['cost'];
$hidden_price = $_POST['hidden_price'];
$hidden_gst = $_POST['hidden_gst'];
$hidden_tax_code = $_POST['hidden_tax_code'];
$hidden_tax_rate = $_POST['hidden_tax_rate'];
$hidden_price_gst = $_POST['hidden_price_gst'];
$hidden_total = $_POST['hidden_total'];
$hidden_gsttotal = $_POST['hidden_gsttotal'];
$hidden_gstpricetotal = $_POST['hidden_gstpricetotal'];
$hidden_id = $_POST['hidden_id'];
$hidden_poid = $_POST['hidden_poid'];
$hidden_product_name = $_POST['hidden_product_name'];
if ($updateQPODetail != NULL) {
$updateQPODetail = $this->findModel($id);
$updateQPODetail->purchaseorder_id = $po_id;
$updateQPODetail->purchaseorder_no = $po_no;
$updateQPODetail->purchaseorder_date = $po_date;
$updateQPODetail->purchaseorder_date_transaction = $po_date;
$updateQPODetail->purchaseorder_date_delete = $po_date;
$updateQPODetail->purchaseorder_customerid = $customer_id;
$updateQPODetail->purchaseorder_supplierid = 1;
$updateQPODetail->purchaseorder_supplier_quotation_no = 11;
$updateQPODetail->purchaseorder_createid = $uid;
$updateQPODetail->purchaseorder_createname = $uname;
$updateQPODetail->purchaseorder_remark = "lol";
$updateQPODetail->purchaseorder_system = "y";
$updateQPODetail->purchaseorder_partno = "y";
$updateQPODetail->purchaseorder_charge = 123;
$updateQPODetail->purchaseorder_update_stock_status = "y";
$updateQPODetail->purchaseorder_status = "y";
$updateQPODetail->purchaseorder_tax_label = "lol";
$updateQPODetail->purchaseorder_tax_percent = 1;
$updateQPODetail->purchaseorder_tax_amount = 100;
$updateQPODetail->purchaseorder_printed_status = "y";
$updateQPODetail->purchaseorder_revision = 1;
$updateQPODetail->purchaseorder_parts_total = $hidden_total;
$updateQPODetail->purchaseorder_deleteid = 1;
$updateQPODetail->purchaseorder_payment_status = "y";
$updateQPODetail->purchaseorder_no_user_format = "lol";
$updateQPODetail->purchaseorder_auto_generate = "y";
$updateQPODetail->purchaseorder_creditorid = 1;
$updateQPODetail->purchaseorder_purchase_return = 123;
$updateQPODetail->purchaseorder_payment_paid_thus_far = 123;
$updateQPODetail->purchaseorder_outstanding_amount = 123;
$updateQPODetail->purchaseorder_projectid = 1;
$updateQPODetail->purchaseorder_gst_payable = $hidden_gsttotal;
$updateQPODetail->purchaseorder_total_amount = $hidden_gstpricetotal;
$updateQPODetail->save();
foreach ($poDetailList as $key => $n) {
if ($hidden_poid[$key] != $id || $hidden_poid[$key] == NULL || $hidden_poid[$key] == '') {
if ($unit[$key] == NULL) {
$unit[$key] = "-";
}
$newPODetail = new PurchaseOrderDetail();
$newPODetail->purchaseorderdetail_purchaseorderid = $po_id;
$newPODetail->purchaseorderdetail_productid = $n;
$newPODetail->purchaseorderdetail_partno = "lol";
$newPODetail->purchaseorderdetail_productname = $hidden_product_name[$key];
$newPODetail->purchaseorderdetail_unit = $qty[$key];
$newPODetail->purchaseorderdetail_unitname = $unit[$key];
$newPODetail->purchaseorderdetail_product_cost = $cost[$key];
$newPODetail->purchaseorderdetail_price = $hidden_price[$key];
$newPODetail->purchaseorderdetail_unitsent = 0;
$newPODetail->purchaseorderdetail_status = "y";
$newPODetail->purchaseorderdetail_tax_code = $hidden_tax_code[$key];
$newPODetail->purchaseorderdetail_tax_rate = $hidden_tax_rate[$key];
$newPODetail->purchaseorderdetail_tax_amount = $hidden_gst[$key];
$newPODetail->purchaseorderdetail_total_amount = $hidden_price_gst[$key];
$newPODetail->purchaseorderdetail_gst_status = 1;
$newPODetail->save();
} elseif ($hidden_poid[$key] == $id) {
$poid = $hidden_id[$key];
//.........这里部分代码省略.........
示例10: actionDownload
public function actionDownload($id)
{
$model = \app\models\Download::findOne(['id' => $id]);
if ($model == null) {
} else {
//throw new \yii\web\HttpException(404, 'The requested page does not exist.');
$comp = \app\models\Company::findOne($model->company_id);
$comp->select($model->company_id);
$id = (int) $model->file_id;
$model = \app\models\Files::findOne($id);
if ($model === null) {
throw new \yii\web\HttpException(404, 'The requested page does not exist.');
}
$file = $model->getFullPath() . $model->id;
return Yii::$app->getResponse()->sendFile($file, $model->name);
}
}
示例11: function
</h1>
<p class="float-right">
<?php
echo Html::a('Create Job', ['create'], ['class' => 'btn btn-success']);
?>
</p>
<div class="clear"></div>
<?php
echo $this->render('_search', ['model' => $searchModel]);
?>
<div class="clear"></div>
<?php
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'company', 'value' => function ($dataProvider) {
$company = Company::findOne($dataProvider->company_id);
$company_name = $company->company_name;
return $company_name;
}], 'job_order', 'job_date', ['attribute' => 'time_in', 'format' => ['time', 'php:H:i'], 'options' => ['style' => 'width:100px;']], ['attribute' => 'time_out', 'format' => ['time', 'php:H:i'], 'options' => ['style' => 'width:100px;']], ['attribute' => 'quota', 'value' => function ($dataProvider) {
// print_r($dataProvider);exit;
$total_assign = JobSchedule::find()->where('job_id=' . $dataProvider->job_id)->count();
$quota_left = intval($dataProvider->quota - $total_assign);
return $total_assign . '/' . $dataProvider->quota;
}, 'options' => ['style' => 'width:120px;']], ['class' => 'yii\\grid\\ActionColumn', 'options' => ['style' => 'width:80px;']]]]);
?>
</div>
示例12: actionAssignCompany
public function actionAssignCompany($id)
{
$selections = Yii::$app->request->post('selection');
if (count($selections) > 0) {
foreach ($selections as $company_id) {
$company = Company::findOne($company_id);
if (isset($_POST['assign'])) {
$group_id = $id;
Yii::$app->db->createCommand("UPDATE wolf_company SET groups=CONCAT(groups,'," . $group_id . "') WHERE NOT FIND_IN_SET(" . $group_id . ",groups) AND company_id=:column2")->bindValue(':column2', $company_id)->execute();
} else {
if (isset($_POST['unassign'])) {
$group_id = $id;
Yii::$app->db->createCommand("UPDATE wolf_company SET groups=TRIM(BOTH ',' FROM REPLACE(CONCAT(',', groups, ','), '," . $group_id . ",', ',')) WHERE FIND_IN_SET(" . $group_id . ",groups) AND company_id=:column2")->bindValue(':column2', $company_id)->execute();
}
}
Yii::$app->session->setFlash('sucess', 'Company assigned');
}
}
return $this->redirect(['update', 'id' => $id]);
}
示例13: function
<?php
$attributes = ['company_name', 'company_address'];
?>
<?php
echo DetailView::widget(['model' => $model, 'attributes' => $attributes, 'template' => '<tr><th width=40%>{label}</th><td>{value}</td></tr>']);
?>
<h1>Group</h1>
<?php
$form = ActiveForm::begin(array('action' => Yii::$app->getUrlManager()->createUrl('company/assign-group?id=' . $model->company_id)));
?>
<div class="grey-col">
<?php
echo ListView::widget(['dataProvider' => $groupData, 'itemOptions' => ['class' => 'item'], 'itemView' => function ($group, $key, $index, $widget) {
$company_id = Yii::$app->request->getQueryParams()['id'];
$model = Company::findOne($company_id);
$group_arr = explode(",", $model->groups);
$checked = in_array($group->id, $group_arr) ? true : false;
$layout = '<div class="col-xs-6" style="border-bottom:1px solid #bdbdbd;padding:8px 0px 8px 0px">';
$layout .= '' . Html::checkbox('groups[]', $checked, array('value' => $group->id, 'label' => Html::encode($group->name) . ' (' . Html::encode($group->notes) . ')')) . ' ';
// $layout .=' '.Html::encode($group->name).' ('.Html::encode($group->notes).')';
$layout .= '</div>';
return $layout;
}]);
?>
</div>
<div class="clear"> </div>
<p class="float-left">
<?php
示例14: array
</h1>
<p class="float-left">
<?php
echo Html::a('Back', ['index'], ['class' => 'btn btn-primary']);
?>
</p>
<p class="float-right">
<?php
echo Html::a('Edit Details', ['update', 'id' => $model->job_id], ['class' => 'btn btn-primary']);
?>
</p>
<?php
$company = Company::findOne($model->company_id);
$company_name = $company->company_name;
?>
<?php
echo DetailView::widget(['model' => $model, 'attributes' => ['job_id', ['attribute' => 'company_id', 'value' => $company_name], 'job_order', 'job_date', 'quota', 'time_in', 'time_out', 'close_hour'], 'template' => '<tr><th width=40%>{label}</th><td>{value}</td></tr>']);
?>
<h1>Search Employee</h1>
<?php
echo $this->render('_searchEmployee', array('model' => $employeeSearch, 'job_id' => $model->job_id));
?>
<div class="clear"></div>
<?php
$form = ActiveForm::begin(array('action' => Yii::$app->getUrlManager()->createUrl('job/assign-employee?id=' . $model->job_id)));
示例15: init
public function init()
{
date_default_timezone_set('Asia/Tel_Aviv');
//\Yii::$app->language = 'he_il';
//if ($this->company==null) {
// Yii::$app->user->Set('Company', 0);
//}
if (!Yii::$app->user->isGuest) {
\app\helpers\Linet3Helper::SetTheme();
date_default_timezone_set(Yii::$app->user->getParam('timezone'));
Yii::$app->language = Yii::$app->user->getParam('language');
Yii::$app->timezone = Yii::$app->user->getParam('timezone');
//Yii::$app->theme = Yii::$app->user->getParam('theme');
if (isset(Yii::$app->session['company'])) {
$this->company = Yii::$app->session['company'];
//if(Yii::$app->user->getParam('company')!=0){
// $this->company = Yii::$app->user->getParam('company');
//Yii::$app->session['company']=0;
//}
}
} else {
//default theme
//Yii::$app->theme = 'admin4';
}
Yii::info("Selected Company ID: " . $this->company);
if ($this->company == 0) {
if ($this->id != 'company') {
//print "'".Yii::$app->controller->id."'";
$this->redirect(\yii\helpers\BaseUrl::base() . '/company/index');
Yii::$app->end();
} else {
//echo $this->id;
//Yii::$app->end();
Yii::$app->db->close();
Yii::$app->db->dsn = Yii::$app->dbMain->dsn;
Yii::$app->db->tablePrefix = Yii::$app->dbMain->tablePrefix;
Yii::$app->db->username = Yii::$app->dbMain->username;
Yii::$app->db->password = Yii::$app->dbMain->password;
Yii::$app->db->open();
}
} else {
//hasAccess!
//$this->company = Company::findByPk($this->company);
$company = Company::findOne($this->company);
if ($company !== null) {
Company::loadComp($company);
} else {
$this->redirect(\yii\helpers\BaseUrl::base() . '/company/index');
}
}
//*/
return parent::init();
}