public function query() { $params['order'] = isset($params['order']) ? $params['order'] : ['name|ASC']; $companies = Company::select("companies.*"); $companies->leftJoin("company_main_contacts", "companies.id", "=", "company_main_contacts.company_id"); $companies->leftJoin("company_person as company_person_main_contacts", "company_person_main_contacts.id", "=", "company_main_contacts.main_contact_id"); $companies->leftJoin("company_account_managers", "companies.id", "=", "company_account_managers.company_id"); $companies->leftJoin("company_person as company_person_account_managers", "company_person_account_managers.id", "=", "company_account_managers.account_manager_id"); $companies->leftJoin("people as account_managers", "company_person_account_managers.person_id", "=", "account_managers.id"); $companies->leftJoin("people as main_contacts", "company_person_main_contacts.person_id", "=", "main_contacts.id"); if (!Auth::user()->active_contact->isE80()) { $companies->where("companies.id", "=", Auth::user()->active_contact->company_id); } return $companies; }
public function actionOpenfrmtimport() { $model = new FormOpenfrmt(); if (isset($_POST['SwitchType'])) { //save current //$corComp=Yii::$app->user->Database->id; $newComp = (int) $_POST['companyId']; //company load Company::select($newComp); foreach ($_POST['SwitchType'] as $old => $new) { \app\models\Acctype::switchType($old, $new); } //end //$this->redirect(\yii\helpers\BaseUrl::base() . '/company/index'); } if (isset($_POST['FormOpenfrmt'])) { //$yiiUser=Yii::$app->user->id; //$configPath=\app\helpers\Linet3Helper::getSetting("company.path"); $file = Company::getFilePath() . "ini.txt"; $model->iniFile = $_POST['FormOpenfrmt']['iniFile']; $model->iniFile = \yii\web\UploadedFile::getInstance($model, 'iniFile'); if ($model->iniFile->saveAs($file)) { $model->iniFile = $file; //$model->read(); } $file = Company::getFilePath() . "/bkmv.txt"; $model->bkmvFile = $_POST['FormOpenfrmt']['bkmvFile']; $model->bkmvFile = \yii\web\UploadedFile::getInstance($model, 'bkmvFile'); if ($model->bkmvFile->saveAs($file)) { //$corComp = ; $model->bkmvFile = $file; $model->readIni(); $this->company = $model->companyId; Company::select($this->company); $model->readBkmv(); Company::select($this->company); } return $this->render('openfrmtimportajax', array('model' => $model)); Yii::$app->end(); } return $this->render('openfrmtimport', array('model' => $model)); //echo $model->read(); }
/** * Get Companies options for 'select' dropdown in Vuejs format */ public function getCompanies(Request $request, $company_id, $trade_id, $site_id) { $company_list = Auth::user()->company->companyList('1')->pluck('id')->toArray(); if ($company_id == 'match-trade' || $trade_id == 'match-trade') { //if ($trade_id == 'match-trade') // All authorised companies that have the given trade_id $companies = Company::select(['companys.id', 'companys.name'])->join('company_trade', 'companys.id', '=', 'company_trade.company_id')->where('companys.status', '1')->where('company_trade.trade_id', $trade_id)->whereIn('companys.id', $company_list)->orderBy('name')->get(); } else { if ($company_id == 'all') { // All authorised companies $companies = Company::where('status', '1')->whereIn('id', $company_list)->orderBy('name')->get(); } else { // All authorised companies except the given company_id $companies = Company::where('status', '1')->whereIn('id', $company_list)->where('id', '<>', $company_id)->orderBy('name')->get(); } } // Unique array of companies currently on planner for given site_id $companiesOnPlanner = SitePlanner::distinct()->select('entity_id')->where('site_id', $site_id)->where('entity_type', 'c')->groupBy('entity_id')->lists('entity_id')->toArray(); $array = []; $array[] = ['value' => '', 'text' => 'Select company']; if ($company_id == 'match-trade') { $array[] = ['value' => 'gen', 'text' => 'Unassigned (Generic)']; } // Create array in specific Vuejs 'select' format. foreach ($companies as $company) { $text = $company->name; if (in_array($company->id, $companiesOnPlanner)) { $text = '<b>' . $company->name . '</b>'; } $array[] = ['value' => $company->id, 'text' => $text, 'name' => $company->name]; } return $array; }
/** * Function Remove * Process Delete the Brand Data * * @return \Illuminate\Http\JsonResponse */ public function onDelete() { $id = Input::get('id'); $Model = \App\Models\Company::select(['id'])->where('id', $id)->first(); if ($Model) { \App\Models\Company::where('id', $id)->delete(); $param['message'] = Lang::get('info.has deleted'); $param['error'] = false; } else { $param['message'] = Lang::get('info.has error'); $param['error'] = true; } return json_encode($param); }