Inheritance: extends yii\db\ActiveRecord
Example #1
0
 public function actionCompany()
 {
     $company = Company::find()->one();
     if (empty($company)) {
         $company = new Company();
         $company->vat = 0;
         $company->logo = '';
     }
     $post = Yii::$app->request->post();
     if (!empty($post)) {
         if (!empty($_FILES['Company']['name']['logo'])) {
             $tmp_name = $_FILES['Company']['tmp_name']['logo'];
             $name = $_FILES['Company']['name']['logo'];
             if (file_exists('upload/' . $name)) {
                 unlink('upload' . $name);
             }
             if (move_uploaded_file($tmp_name, 'upload/' . $name)) {
                 $company->logo = $name;
             }
         }
         $company->name = $post['Company']['name'];
         $company->tax_code = $post['Company']['tax_code'];
         $company->tel = $post['Company']['tel'];
         $company->website = $post['Company']['website'];
         $company->address = $post['Company']['address'];
         $company->vat = $post['Company']['vat'];
         if ($company->save()) {
             $session = new Session();
             $session->setFlash('message', 'บันทึกรายการแล้ว');
             return $this->redirect(['company']);
         }
     }
     return $this->render('//config/company', ['company' => $company]);
 }
Example #2
0
 public function actionCompany()
 {
     $model = new Company();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             $model->is_sponsor = 0;
             $model->is_organisator = 0;
             $model->save();
             Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.');
             return $this->refresh();
         }
     }
     return $this->render('company', ['model' => $model]);
 }
Example #3
0
 private function createCompany($addressID)
 {
     $company = new Company();
     $company->created_at = date("Y-m-d H:i:s");
     $company->name = $this->email;
     $company->comment = "";
     $company->phone = "";
     $company->twenty_four_hours = 0;
     $company->active = 1;
     $company->status_d = 0;
     $company->address_id = $addressID;
     $company->save();
     return $company->id;
 }
Example #4
0
 public function testAssetAdd()
 {
     $company = factory(Company::class, 'company')->make();
     $values = ['name' => $company->name];
     Company::create($values);
     $this->tester->seeRecord('companies', $values);
 }
Example #5
0
 private function getCompaniesLogo()
 {
     $organisators = Company::find()->where(['is_organisator' => '1'])->orderBy('order')->all();
     $organisatorsAndMembers = [];
     foreach ($organisators as $value) {
         $organisatorsAndMembers[$value->attributes['id']]['name'] = $value->attributes['name'];
         if ($value->attributes['logo_url'] != '') {
             $organisatorsAndMembers[$value->attributes['id']]['url'] = 'http://' . Yii::$app->request->serverName . $value->attributes['logo_url'];
         } else {
             $organisatorsAndMembers[$value->attributes['id']]['url'] = 'http://' . Yii::$app->request->serverName . '/files/logo/no_logo.jpg';
         }
         $organisatorsAndMembers[$value->attributes['id']]['intro'] = $value->attributes['intro_' . Yii::$app->language];
         $organisatorsAndMembers[$value->attributes['id']]['site'] = $value->attributes['site'];
     }
     $members = Company::find()->where(['is_sponsor' => '1'])->orderBy('order')->all();
     foreach ($members as $value) {
         $organisatorsAndMembers[$value->attributes['id']]['name'] = $value->attributes['name'];
         if ($value->attributes['logo_url'] != '') {
             $organisatorsAndMembers[$value->attributes['id']]['url'] = 'http://' . Yii::$app->request->serverName . $value->attributes['logo_url'];
         } else {
             $organisatorsAndMembers[$value->attributes['id']]['url'] = 'http://' . Yii::$app->request->serverName . '/files/logo/no_logo.jpg';
         }
         $organisatorsAndMembers[$value->attributes['id']]['intro'] = $value->attributes['intro_' . Yii::$app->language];
         $organisatorsAndMembers[$value->attributes['id']]['site'] = $value->attributes['site'];
     }
     return $organisatorsAndMembers;
 }
Example #6
0
 public function run()
 {
     DB::table('companies')->delete();
     $collection = [['company' => 'UAM'], ['company' => 'ADC'], ['company' => 'Boeing'], ['company' => 'Southwest'], ['company' => 'Jet Blue'], ['company' => 'Robert Half']];
     foreach ($collection as $record) {
         Company::create($record);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $objs = factory(Company::class, 10)->make();
     Company::truncate();
     foreach ($objs as $var) {
         Company::create($var->toArray());
     }
 }
Example #8
0
 public function run()
 {
     DB::table('companies')->delete();
     $collection = [['company' => 'Dagobah Charters', 'dba' => 'DCY', 'domain' => 'dagobah.com', 'folder_name' => snake_case('Dagobah Charters'), 'tier' => '2', 'corporation_type' => 'Limited Liability Corporation', 'admin_id' => 4], ['company' => 'Aerospace Disassembly Consortium', 'dba' => 'ADC', 'domain' => 'aero-eco.com', 'folder_name' => snake_case('Aerospace Disassembly Consortium'), 'tier' => '1', 'corporation_type' => 'Tennessee', 'admin_id' => 9], ['company' => 'Universal Asset Management', 'dba' => 'UAM', 'main_phone' => '9016824064', 'domain' => 'uaminc.com', 'folder_name' => snake_case('Universal Asset Management'), 'tier' => '2', 'corporation_type' => 'Tennessee', 'admin_id' => 6], ['company' => 'Braniff Airlines', 'dba' => 'Braniff', 'domain' => 'braniff.com', 'folder_name' => snake_case('Braniff Airlines'), 'tier' => '3', 'corporation_type' => 'Limited Liability Corporation', 'admin_id' => 3], ['company' => 'Starfleet Academy', 'dba' => 'SFA', 'main_phone' => '4155551212', 'domain' => 'sfa.org', 'folder_name' => snake_case('Starfleet Academy'), 'tier' => '4', 'reply_to' => '*****@*****.**', 'mail_domain' => 'sfa.org', 'website' => 'http://acad.sfa.org/', 'corporation_type' => 'San Francisco', 'admin_id' => 2]];
     foreach ($collection as $record) {
         Company::create($record);
     }
 }
 public function run()
 {
     DB::table('companies')->delete();
     $collection = [['company' => 'Dagobah Charters', 'dba' => 'DCY', 'domain' => 'dagobah.com', 'tier' => '2', 'corporation_type' => 'Limited Liability Corporation'], ['company' => 'Aerospace Disassembly Consortium', 'dba' => 'ADC', 'domain' => 'aero-eco.com', 'tier' => '1', 'corporation_type' => 'Tennessee'], ['company' => 'Universal Asset Management', 'dba' => 'UAM', 'domain' => 'uaminc.com', 'tier' => '2', 'corporation_type' => 'Tennessee'], ['company' => 'Braniff Airlines', 'dba' => 'Braniff', 'domain' => 'braniff.com', 'tier' => '3', 'corporation_type' => 'Limited Liability Corporation'], ['company' => 'Starfleet Academy', 'dba' => 'SFA', 'domain' => 'sfa.org', 'tier' => '4', 'reply_to' => '*****@*****.**', 'website' => 'http://acad.sfi.org/', 'corporation_type' => 'San Francisco']];
     foreach ($collection as $record) {
         Company::create($record);
     }
 }
 public function run()
 {
     $faker = Faker\Factory::create();
     foreach (range(1, 30) as $index) {
         Company::create(['company_name' => $faker->company]);
         $this->command->info('Company table seeded!');
     }
 }
Example #11
0
 public function trialRegister(Request $request)
 {
     $errors = [];
     $data = [];
     $email = $request->input('email');
     $password = $request->input('password');
     $password2 = $request->input('password2');
     $country_id = $request->input('country_id');
     $company = $request->input('company');
     $dba = $request->input('dba');
     $firstname = $request->input('firstname');
     $lastname = $request->input('lastname');
     $phone = $request->input('phone');
     $can_sell = $request->input('can_sell');
     $terms_agree = $request->input('terms_agree');
     $contact_please = $request->input('contact_please');
     if (!$email) {
         $errors['email'] = 'Email is required.';
     }
     if (!$password) {
         $errors['password'] = '******';
     }
     if (!$password2) {
         $errors['password2'] = 'Confirmation of password is required.';
     }
     if (!$company) {
         $errors['company'] = 'Company legal name is required.';
     }
     if (!$dba) {
         $errors['dba'] = 'Company common name is required.';
     }
     if (!$firstname) {
         $errors['firstname'] = 'First Name is required.';
     }
     if (!$lastname) {
         $errors['lastname'] = 'Last Name is required.';
     }
     if (!$phone) {
         $errors['phone'] = 'Phone Number is required.';
     }
     if (!empty($errors)) {
         $data['success'] = false;
         $data['errors'] = $errors;
     } else {
         // process form
         $newco = Company::create(['company' => $company, 'dba' => $dba, 'country_id' => $country_id, 'terms_agree' => $terms_agree, 'contact_please' => $contact_please, 'can_sell' => $can_sell, 'main_phone' => $phone, 'tier' => 2, 'folder_name' => snake_case($company)]);
         $newuser = User::create(['firstname' => $firstname, 'lastname' => $lastname, 'email' => $email, 'password' => bcrypt($password), 'company_id' => $newco->id, 'can_sell' => $can_sell]);
         $updCo = $newco->fill(['admin_id' => $newuser->id])->save();
         $updU = $newuser->fill(['manager_id' => $newuser->id])->save();
         $data['success'] = true;
         $data['message'] = 'Success';
         $data['user_id'] = $newuser->id;
         $data['company_id'] = $newco->id;
     }
     // end if
     return $this->respond($data);
 }
 public function run()
 {
     DB::table('companies')->truncate();
     $faker = Faker\Factory::create('pt_BR');
     for ($i = 0; $i < 1000; $i++) {
         $company = ['name' => $faker->company, 'city' => $faker->city, 'phone' => $faker->phoneNumber];
         Company::create($company);
     }
 }
 public function saveInfo()
 {
     $company = Company::findOne($this->id);
     if ($company) {
         $company->setComment($this->info);
         return true;
     }
     return false;
 }
Example #14
0
 public function run()
 {
     $this->command->info('Running UserTableSeeder');
     Eloquent::unguard();
     $faker = Faker\Factory::create();
     $company = Company::create();
     $account = Account::create(['name' => $faker->name, 'address1' => $faker->streetAddress, 'address2' => $faker->secondaryAddress, 'city' => $faker->city, 'state' => $faker->state, 'postal_code' => $faker->postcode, 'country_id' => Country::all()->random()->id, 'account_key' => str_random(RANDOM_KEY_LENGTH), 'invoice_terms' => $faker->text($faker->numberBetween(50, 300)), 'work_phone' => $faker->phoneNumber, 'work_email' => $faker->safeEmail, 'invoice_design_id' => min(InvoiceDesign::all()->random()->id, 10), 'header_font_id' => min(Font::all()->random()->id, 17), 'body_font_id' => min(Font::all()->random()->id, 17), 'primary_color' => $faker->hexcolor, 'timezone_id' => 1, 'company_id' => $company->id]);
     User::create(['email' => TEST_USERNAME, 'username' => TEST_USERNAME, 'account_id' => $account->id, 'password' => Hash::make(TEST_PASSWORD), 'registered' => true, 'confirmed' => true, 'notify_sent' => false, 'notify_paid' => false]);
     Affiliate::create(['affiliate_key' => SELF_HOST_AFFILIATE_KEY]);
 }
 public function run()
 {
     $person = DB::table('people')->where('first_name', 'James')->where('last_name', 'Sample')->first();
     $company = Company::where('name', 'Sample Company')->first();
     $group_type = GroupType::where('name', 'employee')->first();
     $group = Group::where('name', 'e80-helpdesk')->first();
     if (isset($person)) {
         CompanyPerson::create(['person_id' => $person->id, 'company_id' => $company->id, 'group_type_id' => $group_type->id, 'group_id' => $group->id]);
     }
 }
 /**
  * Create new review for a company.
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response
  */
 public function create(Requests\CreateReviewRequest $request)
 {
     try {
         $company = Company::findOrFail($request->input('company-id'));
         $review = new Review($request->except('company-id'));
         $company->reviews()->save($review);
         return redirect()->back()->with(['message' => 'Отзыв будет опубликован после модерации.']);
     } catch (\Exception $e) {
         return response()->view('errors.' . '503');
     }
 }
 public function update($id)
 {
     // save updated
     $record = $this->records->find($id);
     if (!$record) {
         Company::create(Input::all());
         return $this->respond($record);
     }
     $record->fill(Input::all())->save();
     return $this->respond($record);
 }
Example #18
0
 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');
     }
 }
 public function __construct()
 {
     $this->middleware('auth');
     $user_types = UserType::lists("name", "id");
     $states = State::lists("name", "id");
     $users_count = User::with("state")->latest()->get()->count();
     $universities_count = University::latest()->get()->count();
     $sos_count = SosModel::latest()->get()->count();
     $students_count = Student::latest()->get()->count();
     $companies_count = Company::latest()->get()->count();
     \View::share(compact("users_count", "universities_count", "sos_count", "states", "user_types", "students_count", "companies_count"));
 }
 public function up()
 {
     $companys = Company::find()->All();
     foreach ($companys as $company) {
         //update payment,config
         $this->insert($company->prefix . 'paymentType', ['id' => 8, 'name' => 'PayPal', 'value' => '\\app\\components\\payments\\Cash', 'oppt_account_id' => 12]);
         $this->insert($company->prefix . 'accounts', ["id" => 12, "type" => 4, 'name' => 'PayPal', 'src_tax' => 0]);
         $this->update($company->prefix . 'files', ['parent_type' => '\\app\\models\\docs'], ['parent_type' => "Docs"]);
         $this->update($company->prefix . 'files', ['parent_type' => '\\app\\models\\Accounts'], ['parent_type' => "Accounts"]);
     }
     return true;
 }
 public function cart($id)
 {
     try {
         $company = Company::findOrFail($id);
         $reviews = $company->reviews()->get();
         $phones = $company->contacts->phones()->filled()->get();
         $groups = $company->contacts->groups;
         $logo_url = empty($company->logo_url) && File::exists("uploads/images/" . $company->logo_url) ? "backend/themes/default/images/no_logo.svg" : "uploads/images/" . $company->logo_url;
         return view('companies.cart')->with(compact(['company', 'reviews', 'phones', 'groups', 'logo_url']));
     } catch (\Exception $e) {
         return response()->view('errors.' . '503');
     }
 }
 public function run()
 {
     $this->command->info('Running UserTableSeeder');
     Eloquent::unguard();
     $faker = Faker\Factory::create();
     $company = Company::create();
     $account = Account::create(['name' => $faker->name, 'address1' => $faker->streetAddress, 'address2' => $faker->secondaryAddress, 'city' => $faker->city, 'state' => $faker->state, 'postal_code' => $faker->postcode, 'country_id' => Country::all()->random()->id, 'account_key' => str_random(RANDOM_KEY_LENGTH), 'invoice_terms' => $faker->text($faker->numberBetween(50, 300)), 'work_phone' => $faker->phoneNumber, 'work_email' => $faker->safeEmail, 'invoice_design_id' => InvoiceDesign::where('id', '<', CUSTOM_DESIGN)->get()->random()->id, 'header_font_id' => min(Font::all()->random()->id, 17), 'body_font_id' => min(Font::all()->random()->id, 17), 'primary_color' => $faker->hexcolor, 'timezone_id' => 1, 'company_id' => $company->id]);
     $user = User::create(['first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'email' => TEST_USERNAME, 'username' => TEST_USERNAME, 'account_id' => $account->id, 'password' => Hash::make(TEST_PASSWORD), 'registered' => true, 'confirmed' => true, 'notify_sent' => false, 'notify_paid' => false, 'is_admin' => 1]);
     $client = Client::create(['user_id' => $user->id, 'account_id' => $account->id, 'public_id' => 1, 'name' => $faker->name, 'address1' => $faker->streetAddress, 'address2' => $faker->secondaryAddress, 'city' => $faker->city, 'state' => $faker->state, 'postal_code' => $faker->postcode, 'country_id' => DEFAULT_COUNTRY, 'currency_id' => DEFAULT_CURRENCY]);
     Contact::create(['user_id' => $user->id, 'account_id' => $account->id, 'client_id' => $client->id, 'public_id' => 1, 'email' => env('TEST_EMAIL', TEST_USERNAME), 'is_primary' => true]);
     Product::create(['user_id' => $user->id, 'account_id' => $account->id, 'public_id' => 1, 'product_key' => 'ITEM', 'notes' => 'Something nice...', 'cost' => 10]);
     Affiliate::create(['affiliate_key' => SELF_HOST_AFFILIATE_KEY]);
 }
 public function edit($id)
 {
     if (Auth::user()->can('update-equipment')) {
         $data['equipment'] = Equipment::find($id);
         $data['title'] = $data['equipment']->company->name . " - Equipment " . $data['equipment']->name;
         $data['equipment_types'] = EquipmentType::orderBy("name")->get();
         $data['company'] = Company::find($data['equipment']->company_id);
         $data['company']->company_id = $data['company']->id;
         return view('equipment/edit', $data);
     } else {
         return redirect()->back()->withErrors(['Access denied to equipment edit page']);
     }
 }
Example #24
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Company::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'pricipal_id' => $this->pricipal_id]);
     $query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'addr', $this->addr])->andFilterWhere(['like', 'intro', $this->intro])->andFilterWhere(['like', 'tel', $this->tel])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'comment', $this->comment]);
     return $dataProvider;
 }
Example #25
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Company::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'companyname', $this->companyname])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'contact', $this->contact])->andFilterWhere(['like', 'taxation_number', $this->taxation_number]);
     return $dataProvider;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(SosModelRequest $request)
 {
     $data = $request->all();
     $user = User::findOrFail($request->input('user_id'));
     $sos = SosModel::create(['name' => date("ymdh"), 'user_id' => $request->input('user_id')]);
     $sos->companies()->attach($data["company_id"]);
     foreach ($data["company_id"] as $key => $company) {
         $company = Company::findOrFail($company);
         \Mail::send('emails.letter', compact('user', 'company'), function ($message) use($company, $user) {
             $message->to($company->email, env('MAIL_FROM_NAME'))->subject('Internship Letter');
         });
     }
     return redirect("/sos-requests");
 }
Example #27
0
 public function up()
 {
     $companys = Company::find()->All();
     foreach ($companys as $company) {
         //update payment,config
         $table = Yii::$app->db->schema->getTableSchema($company->prefix . 'accHist');
         if (!isset($table->columns['subject'])) {
             $this->addColumn($company->prefix . 'accHist', 'subject', 'VARCHAR(255)');
             $this->addColumn($company->prefix . 'accHist', 'status', 'INTEGER(11)');
             $this->addColumn($company->prefix . 'accHist', 'type', 'INTEGER(11)');
         }
     }
     return true;
 }
Example #28
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Company::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'need_presentation' => $this->need_presentation, 'need_training' => $this->need_training, 'pay_agree' => $this->pay_agree, 'is_organisator' => $this->is_organisator, 'is_sponsor' => $this->is_sponsor, 'order' => $this->order]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'ideas', $this->ideas])->andFilterWhere(['like', 'contact_person', $this->contact_person])->andFilterWhere(['like', 'telephone', $this->telephone])->andFilterWhere(['like', 'e_mail', $this->e_mail])->andFilterWhere(['like', 'site', $this->site])->andFilterWhere(['like', 'skype', $this->skype])->andFilterWhere(['like', 'logo_url', $this->logo_url])->andFilterWhere(['like', 'intro_uk', $this->intro_uk])->andFilterWhere(['like', 'intro_ru', $this->intro_ru])->andFilterWhere(['like', 'intro_en', $this->intro_en])->andFilterWhere(['like', 'facebook_profile', $this->facebook_profile])->andFilterWhere(['like', 'google_profile', $this->google_profile])->andFilterWhere(['like', 'linkedin_profile', $this->linkedin_profile])->andFilterWhere(['like', 'vk_profile', $this->vk_profile]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Company::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'email', $this->email]);
     return $dataProvider;
 }
Example #30
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Company::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'uid' => Yii::$app->user->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'addr', $this->addr]);
     return $dataProvider;
 }