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]); }
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; }
public function actionIndex() { $query = Company::find(); //var_dump($query);die; $pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]); $row = $query->offset($pagination->offset)->limit($pagination->limit)->all(); return $this->renderPartial('index', ['data' => $row, 'pagination' => $pagination]); }
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 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']); } }
/** * 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; }
/** * 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; }
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; }
/** * 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; }
/** * 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 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; }
public function actionGetCard($cid) { $company = Company::find()->where(['id' => $cid])->asArray()->one(); $address = Address::find()->where(['id' => $company['address_id']])->asArray()->one(); $shedule = Shedule::find()->where(['company_id' => $cid])->asArray()->all(); $brand = Company::find()->where(['id' => $cid])->one()->brand; $service = Company::find()->where(['id' => $cid])->one()->service; $srv = ArrayHelper::getColumn($service, 'category_id'); $category = Category::find()->where(['id' => $srv])->asArray()->indexBy('id')->all(); $srv = ArrayHelper::map($service, 'id', 'name', 'category_id'); $spoffer = SpecialOffer::find()->where(['company_id' => $cid])->asArray()->one(); $file = Files::find()->where(['id' => $spoffer['file_id']])->asArray()->one(); Yii::$app->response->format = Response::FORMAT_JSON; $response = ['company' => $company, 'address' => $address, 'shedule' => $shedule, 'brand' => $brand, 'category' => $category, 'service' => $srv, 'spoffer' => $spoffer, 'file' => $file]; return $response; }
public function edit_submit() { $data = \Request::all(); $company = Company::find(\Request::input('company_id')); $company->name = $data['name']; if (isset($data['image'])) { $file_name = \Common::get_img_filename($data['image']); \Common::make_square_img($file_name, 140); $res = \Common::s3_upload($file_name, 'company/'); if ($res['success']) { $company->ci = $res['filename']; } } $company->status = $data['status_group']; $company->save(); return \Redirect()->action('CompanyController@index'); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $admin_id = Yii::$app->user->identity->id; $query = Company::find(); if (Yii::$app->user->identity->type == 'normal') { $query = $query->innerJoin('wolf_admin_to_company wc', 'wc.company_id=wolf_company.company_id'); $query = $query->where('admin_id=' . $admin_id); } $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['company_id' => SORT_DESC]]]); $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(['company_id' => $this->company_id]); $query->andFilterWhere(['like', 'company_name', $this->company_name])->andFilterWhere(['like', 'company_email', $this->company_email])->andFilterWhere(['like', 'company_contact', $this->company_contact])->andFilterWhere(['like', 'company_address', $this->company_address])->andFilterWhere(['like', 'account_no', $this->account_no])->andFilterWhere(['like', 'payment_terms', $this->payment_terms])->andFilterWhere(['like', 'rate', $this->rate])->andFilterWhere(['like', 'person_in_charge', $this->person_in_charge]); return $dataProvider; }
public function actionIndex() { $company = Company::find()->orderBy('id')->one(); if (!empty($_POST)) { if (!empty($_FILES['Company'])) { // remove old logo if (!empty($company->logo)) { $old_img = $company->logo; unlink('../uploads/' . $old_img); } // upload new logo $img = $_FILES['Company']['name']['logo']; $ext = end(explode(".", $img)); $name = microtime(); $name = str_replace(' ', '', $name); $name = str_replace('.', '', $name); $name = $name . '.' . $ext; $tmp = $_FILES['Company']['tmp_name']['logo']; $company->logo = $name; move_uploaded_file($tmp, '../uploads/' . $name); } $company->name = $_POST['Company']['name']; $company->web_title = $_POST['Company']['web_title']; $company->tel = $_POST['Company']['tel']; $company->email = $_POST['Company']['email']; $company->fax = $_POST['Company']['fax']; $company->website = $_POST['Company']['website']; $company->facebook = $_POST['Company']['facebook']; $company->line_id = $_POST['Company']['line_id']; $company->address = $_POST['Company']['address']; $company->tax_code = $_POST['Company']['tax_code']; $company->payment = $_POST['Company']['payment']; $company->about = $_POST['Company']['about']; if ($company->save()) { $session = new Session(); $session->open(); $session->setFlash('message', 'Data Saved.'); return $this->redirect(['index']); } } return $this->render('//Company/Index', ['company' => $company]); }
public function update($id, UpdateCompanyRequest $request) { $company = Company::find($id); if (Input::file('profile_picture') && Input::file('profile_picture')->isValid()) { $request['file'] = Input::file('profile_picture'); $request['target'] = "companies"; $request['target_id'] = $company->id; $request['uploader_id'] = Auth::user()->active_contact->id; $repo = new FilesRepository(); $result = $repo->upload($request); if (!$result['error']) { $old_profile_picture = $company->profile_picture_id; if (!is_null($old_profile_picture)) { $company->profile_picture_id = NULL; $company->save(); $repo->destroy($old_profile_picture); } $company->profile_picture_id = $result['id']; $company->save(); } } $company->update($request->all()); $company_account_manager = CompanyAccountManager::where('company_id', '=', $id)->first(); // update account manager if (isset($company_account_manager)) { $company_account_manager->account_manager_id = Input::get('account_manager_id'); $company_account_manager->save(); } else { $company_account_manager = new CompanyAccountManager(); $company_account_manager->company_id = $id; $company_account_manager->account_manager_id = Input::get('account_manager_id'); $company_account_manager->save(); } // update main contact $main_contact = CompanyMainContact::where('company_id', '=', $id)->first(); if (isset($main_contact)) { $main_contact->main_contact_id = Input::get('main_contact_id'); $main_contact->save(); } else { $main_contact = new CompanyMainContact(); $main_contact->company_id = $id; $main_contact->main_contact_id = Input::get('account_manager_id'); $main_contact->save(); } return redirect()->route('companies.show', $id)->with('successes', ['company updated successfully']); }
use yii\widgets\ActiveForm; use app\models\Company; use app\models\Person; /* @var $this yii\web\View */ /* @var $model app\models\Park */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="park-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'company_id')->dropdownlist(Company::find()->select(['name'])->indexBy('id')->column(), ['prompt' => '选择所属公司', 'disabled' => 'disabled']); ?> <?php echo $form->field($model, 'code')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'addr')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'scale')->textInput(['maxlength' => true]);
public function actionCcompany() { $city = trim($_GET['city']); //$city = '北京'; $arr = Company::find()->where(['c_city' => $city])->asArray()->all(); if (empty($arr)) { $data = ["status" => '100', "msg" => 'no datas']; } else { $data = ["status" => '200', "msg" => 'Success', "data" => $arr]; } echo json_encode($data); }
use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; use app\models\Company; /* @var $this yii\web\View */ /* @var $model app\models\Branch */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="branch-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'company_id')->dropDownList(ArrayHelper::map(Company::find()->all(), 'id', 'name')); ?> <?php echo $form->field($model, 'branch_name')->textInput(['maxlength' => 100]); ?> <?php echo $form->field($model, 'branch_email')->textInput(['maxlength' => 50]); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div>
<div class="text-center"> <div class="form"> <div class="tab-content"> <div id="chose" class="tab-pane active"> <?php echo Yii::t('app', "Select Company"); ?> <?php use yii\data\ActiveDataProvider; use yii\helpers\Html; use app\models\Company; $dataProvider = new ActiveDataProvider(['query' => Company::find(), 'pagination' => ['pageSize' => 20]]); echo app\widgets\GridView::widget(['dataProvider' => $dataProvider, 'columns' => ['id', ['value' => function ($data) { return \yii\helpers\Html::a(\yii\helpers\Html::encode($data->getName()), $data->id, ['class' => 'chose']); }, 'format' => 'html']]]); /* echo app\widgets\GridView::widget(array( 'id'=>'comp-grid', 'dataProvider'=>$model->dp(), ////'filter'=>$model, 'template' => '{items}{pager}', 'options'=>array('class'=>'clean'), 'columns'=>array( array('value'=>'$data->id'), array( 'value'=>'\yii\helpers\Html::link(\yii\helpers\Html::encode($data->getName()),"#", array( "onclick"=>\'chose("\'.$data->id.\'")\',))',
public function SubAudit($audit) { $audit_obj = array(); foreach ($audit as $index) { $entity_obj = null; switch ($index->entity_type) { case 'user': if (in_array('VIEW_USER', $this->permission)) { $entity_obj = User::find($index->entity_id); } break; case 'company': if (User::isSuperAdmin()) { $entity_obj = \App\Models\Company::find($index->entity_id); } break; case 'inventory': if (User::isSuperAdmin()) { $entity_obj = Inventory::find($index->entity_id); } break; case 'client': if (in_array('VIEW_CLIENT', $this->permission)) { $entity_obj = Client::find($index->entity_id); } break; case 'advertiser': if (in_array('VIEW_ADVERTISER', $this->permission)) { $entity_obj = Advertiser::with('GetClientID')->find($index->entity_id); } break; case 'creative': if (in_array('VIEW_CREATIVE', $this->permission)) { $entity_obj = Creative::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'campaign': if (in_array('VIEW_CAMPAIGN', $this->permission)) { $entity_obj = Campaign::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'offer': if (in_array('VIEW_OFFER', $this->permission)) { $entity_obj = Offer::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'pixel': if (in_array('VIEW_PIXEL', $this->permission)) { $entity_obj = Pixel::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'targetgroup': if (in_array('VIEW_TARGETGROUP', $this->permission)) { $entity_obj = Targetgroup::find($index->entity_id); } break; case 'targetgroup_geolocation_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = Geolocation::find($index->after_value); } else { $entity_obj = Geolocation::find($index->entity_id); } } break; case 'targetgroup_creative_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = Creative::find($index->after_value); } else { $entity_obj = Creative::find($index->entity_id); } } break; case 'targetgroup_segment_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = Segment::find($index->after_value); } else { $entity_obj = Segment::find($index->entity_id); } } break; case 'targetgroup_geosegment_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = GeoSegmentList::find($index->after_value); } else { $entity_obj = GeoSegmentList::find($index->entity_id); } } break; case 'targetgroup_bwlist_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = BWList::find($index->after_value); } else { $entity_obj = BWList::find($index->entity_id); } } break; case 'targetgroup_bidprofile_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = Bid_Profile::find($index->after_value); } else { $entity_obj = Bid_Profile::find($index->entity_id); } } break; case 'geosegment': if (in_array('VIEW_GEOSEGMENTLIST', $this->permission)) { $entity_obj = GeoSegmentList::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'geosegmententrie': if (in_array('VIEW_GEOSEGMENTLIST', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = GeoSegment::find($index->after_value); } else { $entity_obj = GeoSegment::find($index->entity_id); } } break; case 'bwlist': if (in_array('VIEW_BWLIST', $this->permission)) { $entity_obj = BWList::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'bwlistentrie': if (in_array('VIEW_BWLIST', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = BWEntries::find($index->after_value); } else { $entity_obj = BWEntries::find($index->entity_id); } } break; case 'bid_profile': if (in_array('VIEW_BIDPROFILE', $this->permission)) { $entity_obj = Bid_Profile::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'bid_profile_entry': if (in_array('VIEW_BIDPROFILE', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = Bid_Profile::where('id', $index->after_value)->first(); } else { $entity_obj = Bid_Profile_Entry::with('getParent')->find($index->entity_id); } } break; case 'modelTable': if (in_array('VIEW_MODEL', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = BWList::where('id', $index->after_value)->first(); } else { $entity_obj = ModelTable::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } } break; case 'offer_pixel_map': if (in_array('VIEW_OFFER', $this->permission)) { $entity_obj = Pixel::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'advertiser_model_map': if (in_array('VIEW_ADVERTISER', $this->permission)) { $entity_obj = ModelTable::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'positive_offer_model': if (in_array('VIEW_MODEL', $this->permission)) { $entity_obj = Offer::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'negative_offer_model': if (in_array('VIEW_MODEL', $this->permission)) { $entity_obj = Offer::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; } if (!is_null($entity_obj)) { array_push($audit_obj, $index); array_push($audit_obj, $entity_obj); } } return $audit_obj; }
/** * Get Docs current user is authorised to manage + Process datatables ajax request. */ public function getWms(Request $request) { $records = DB::table('wms_docs AS d')->select(['d.id', 'd.reportfile', 'd.name', 'd.version', 'd.principle', 'd.principle_id', 'd.principle_signed_id', 'd.user_signed_id', 'd.for_company_id', 'd.company_id', 'd.status', 'd.updated_at', 'c.name AS company_name'])->join('companys AS c', 'd.for_company_id', '=', 'c.id')->where(function ($q) { $q->where('d.for_company_id', Auth::user()->company_id); $q->orWhere('d.company_id', Auth::user()->company_id); })->where('d.master', '0')->where('d.status', $request->get('status')); $dt = Datatables::of($records)->editColumn('id', function ($doc) { if ($doc->reportfile && file_exists(public_path('/filebank/company/' . $doc->for_company_id . '/wms/' . $doc->reportfile))) { return '<div class="text-center"><a href="/filebank/company/' . $doc->for_company_id . '/wms/' . $doc->reportfile . '"><i class="fa fa-file-text-o"></i></a></div>'; } return ''; })->editColumn('name', function ($doc) { return $doc->name . ' v' . $doc->version; })->editColumn('company_name', function ($doc) { $company = Company::find($doc->for_company_id); return $doc->user_signed_id ? $company->name : '<span class="font-red">' . $company->name . '</span>'; })->editColumn('principle', function ($doc) { $company = Company::find($doc->principle_id); return $doc->principle_signed_id ? $company->name : '<span class="font-red">' . $company->name . '</span>'; })->editColumn('updated_at', function ($doc) { return (new Carbon($doc->updated_at))->format('d/m/Y'); })->addColumn('action', function ($doc) { if ($doc->status == '0') { return '<a href="/safety/doc/wms/' . $doc->id . '/edit" class="btn blue btn-xs btn-outline sbold uppercase margin-bottom"><i class="fa fa-pencil"></i> Edit</a>'; } return '<a href="/safety/doc/wms/' . $doc->id . '" class="btn blue btn-xs btn-outline sbold uppercase margin-bottom"><i class="fa fa-search"></i> View</a>'; })->make(true); return $dt; }
/** * Email document to someone */ public function emailArchived() { $email_list = env('EMAIL_ME'); if (\App::environment('dev', 'prod')) { foreach ($this->owned_by->usersWithPermissionTo('del.wms') as $user) { if (preg_match(VALID_EMAIL_PATTERN, $user->email) && $user->is('whs.admin')) { $email_list .= '; ' . $user->email; } } } $email_list = trim($email_list); $email_list = explode(';', $email_list); $email_list = array_map('trim', $email_list); // trim white spaces $email_user = \App::environment('dev', 'prod') ? Auth::user()->email : ''; $data = ['user_email' => Auth::user()->email, 'user_fullname' => Auth::user()->fullname, 'user_company_name' => Auth::user()->company->name, 'doc_name' => $this->name, 'doc_company' => Company::find($this->for_company_id)->name, 'doc_principle' => $this->principle]; $doc = $this; Mail::send('emails/workmethod-archived', $data, function ($m) use($email_list, $email_user, $doc, $data) { $user_email = $data['user_email']; $user_email ? $send_from = $user_email : ($send_from = '*****@*****.**'); $m->from($send_from, Auth::user()->fullname); $m->to($email_list); if (preg_match(VALID_EMAIL_PATTERN, $email_user)) { $m->cc($email_user); } $m->subject('Safe Work Method Statement - ' . $doc->name); $file_path = public_path('filebank/company/' . $doc->for_company_id . '/wms/' . $doc->reportfile); if ($doc->reportfile && file_exists($file_path)) { $m->attach($file_path); } }); /* if (count(Mail::failures()) > 0) { foreach (Mail::failures as $email_address) Toastr::error("Failed to send to $email_address"); } else Toastr::success("Sent email"); */ }
/** * Reverse the migrations. * * @return void */ public function down() { $timeout = ini_get('max_execution_time'); if ($timeout == 0) { $timeout = 600; } $timeout = max($timeout - 10, $timeout * 0.9); $startTime = time(); if (!Schema::hasColumn('accounts', 'pro_plan_paid')) { Schema::table('accounts', function ($table) { $table->date('pro_plan_paid')->nullable(); $table->date('pro_plan_trial')->nullable(); }); } $company_ids = \DB::table('companies')->leftJoin('accounts', 'accounts.company_id', '=', 'companies.id')->whereNull('accounts.pro_plan_paid')->whereNull('accounts.pro_plan_trial')->where(function ($query) { $query->whereNotNull('companies.plan_paid'); $query->orWhereNotNull('companies.trial_started'); })->lists('companies.id'); $company_ids = array_unique($company_ids); if (count($company_ids)) { foreach (Company::find($company_ids) as $company) { foreach ($company->accounts as $account) { $account->pro_plan_paid = $company->plan_paid; $account->pro_plan_trial = $company->trial_started; $account->save(); } $this->checkTimeout($timeout, $startTime); } } if (Schema::hasColumn('accounts', 'company_id')) { Schema::table('accounts', function ($table) { $table->dropForeign('accounts_company_id_foreign'); $table->dropColumn('company_id'); }); } Schema::dropIfExists('companies'); }
use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; /* @var $this yii\web\View */ /* @var $model app\models\CompanyPhone */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="company-phone-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'company_id')->dropDownList(ArrayHelper::map(\app\models\Company::find()->all(), 'id', 'title')); ?> <?php echo $form->field($model, 'phone')->textInput(['maxlength' => true]); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?>
/** * Updates an existing Job model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $admin_id = Yii::$app->user->identity->id; $model = $this->findModel($id); $companies = Company::find(); if (Yii::$app->user->identity->type == 'normal') { $companies = $companies->innerJoin('wolf_admin_to_company wc', 'wc.company_id=wolf_company.company_id'); $companies = $companies->where('admin_id=' . $admin_id); } $companies = $companies->orderBy('company_name'); $companies = $companies->asArray(); $companies = $companies->all(); $jobScheduleSearch = new JobScheduleSearch(['job_id' => $id]); $scheduleData = $jobScheduleSearch->search(Yii::$app->request->getQueryParams()); $scheduleData->pagination->pageSize = -1; //infinite value if ($model->load(Yii::$app->request->post())) { $time_in_hour = $_POST['Job']['time_in_hour']; $time_in_minute = $_POST['Job']['time_in_minute']; $time_out_hour = $_POST['Job']['time_out_hour']; $time_out_minute = $_POST['Job']['time_out_minute']; $model->time_in = $time_in_hour . ':' . $time_in_minute . ':00'; $model->time_out = $time_out_hour . ':' . $time_out_minute . ':00'; } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['update', 'id' => $model->job_id]); } else { return $this->render('update', ['model' => $model, 'companies' => $companies, 'jobScheduleSearch' => $jobScheduleSearch, 'scheduleData' => $scheduleData]); } }
echo Html::a('仓库管理', ['warehouse/admin'], ['class' => 'list-group-item']); ?> <?php echo Html::a('员工管理', ['employee/admin'], ['class' => 'list-group-item']); ?> <?php echo Html::a('客户管理', ['customer/admin'], ['class' => 'list-group-item']); ?> <?php echo Html::a('供应商管理', ['suppliers/admin'], ['class' => 'list-group-item']); ?> </div> </div> <div class="col-md-10" id="ajax-data"> <?php $data = Company::find()->where(['uid' => Yii::$app->user->id])->one(); if (!count($data)) { ?> <p> <?php echo Html::a('设置公司名', ['create'], ['class' => 'btn btn-success']); ?> </p> <hr> <div class="alert alert-success"> <button type="button" class="close" data-dismiss="alert">×</button> <h4>提示</h4> 你还没有设置公司名称! </div> <?php } else {
<?php use yii\helpers\Html; use yii\bootstrap\Nav; use yii\bootstrap\NavBar; use yii\widgets\Breadcrumbs; use app\assets\AppAsset; use yii\web\Session; use app\models\Company; use yii\widgets\ActiveForm; AppAsset::register($this); $session = new \yii\web\Session(); $session->open(); $company = Company::find()->one(); $this->beginPage(); ?> <!DOCTYPE html> <html lang="<?php echo Yii::$app->language; ?> "> <head> <meta charset="<?php echo Yii::$app->charset; ?> "> <meta name="viewport" content="width=device-width, initial-scale=1"> <?php echo Html::csrfMetaTags(); ?> <title><?php
/** * A dropdown list of companies who are child of this company ie. * * @return array */ public function companyListSelect($prompt = '') { $array = []; foreach ($this->companyList() as $company) { $record = Company::find($company->id); if ($record->status) { $array[$company->id] = $record->name; } } asort($array); if ($prompt == 'all') { return $prompt && count($array) > 1 ? $array = array('' => 'All Companies') + $array : $array; } return $prompt && count($array) > 1 ? $array = array('' => 'Select Company') + $array : $array; }
echo $form->field($model, 'contact_relationship')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'contact_address')->textarea(['rows' => 6]); ?> </fieldset> </div> <div class="clear"></div> <fieldset> <legend><h3>Additional Info</h3></legend> <div class="col-xs-6"> <?php echo $form->field($model, 'company_id')->dropDownList(ArrayHelper::map(Company::find()->orderBy('company_name')->all(), 'company_id', 'company_name'), ['class' => 'form-control', 'prompt' => "Choose Company"])->label('Company Name'); ?> <?php echo $form->field($model, 'validate')->checkbox(['label' => 'Validate']); ?> <?php echo $form->field($model, 'validate_date')->widget(\yii\jui\DatePicker::classname(), ['dateFormat' => 'yyyy-MM-dd', 'clientOptions' => ['changeMonth' => true, 'changeYear' => true, 'yearRange' => '2015:2030', 'autoclose' => true], 'options' => ['class' => 'form-control', ' value' => date("Y-m-d", strtotime("+1 years"))]])->label('Validation Date'); ?> <div class="clear"></div> <?php echo $form->field($model, 'suspended')->dropDownList(['0' => 'No', '1' => 'Yes']); ?> </div>