diff --git a/config/logging.php b/config/logging.php index 900d481..bdc61c4 100644 --- a/config/logging.php +++ b/config/logging.php @@ -13,7 +13,7 @@ return [ | */ - 'default' => env('LOG_CHANNEL', 'single'), + 'default' => env('LOG_CHANNEL', 'info'), /* |-------------------------------------------------------------------------- @@ -42,6 +42,11 @@ return [ 'path' => storage_path('logs/system.log'), 'level' => 'debug', ], + 'info' => [ + 'driver' => 'single', + 'path' => storage_path('logs/info.log'), + 'level' => 'debug', + ], 'daily' => [ 'driver' => 'daily', diff --git a/plugins/rainlab/user/models/User.php b/plugins/rainlab/user/models/User.php index 3692970..720d773 100644 --- a/plugins/rainlab/user/models/User.php +++ b/plugins/rainlab/user/models/User.php @@ -37,6 +37,12 @@ class User extends UserBase 'groups' => [UserGroup::class, 'table' => 'users_groups'] ]; + public $hasOne = [ + 'shop' => [ + 'Tps\Shops\Models\Shop', + ] + ]; + public $attachOne = [ 'avatar' => \System\Models\File::class ]; diff --git a/plugins/tps/shops/Plugin.php b/plugins/tps/shops/Plugin.php index 2b96720..140ba72 100644 --- a/plugins/tps/shops/Plugin.php +++ b/plugins/tps/shops/Plugin.php @@ -1,6 +1,8 @@ bindEvent('model.beforeSave', function() use ($model) { + + // $records = \October\Rain\Database\Models\DeferredBinding::where([ + // 'master_type' => 'Tps\Shops\Models\Report', // <- REPLACE WITH YOUR MODEL(ModelName) + // "master_field" => "file", // <- REPLACE WITH ATTACHEMNT MODEL (gallery) + // "slave_type" => "System\Models\File", + // "session_key" => post('_session_key') + // ])->get(); + + + // foreach($records as $record) { + // $fileRecord = \System\Models\File::find($record->slave_id); + + // // $fileRecord = \System\Models\File::find($this->id); + + // $zip = new ZipArchive(); + // $status = $zip->open($fileRecord->getRealPath()); + // if ($status !== true) { + // throw new \Exception($status); + // } + // else{ + // $storageDestinationPath= storage_path("app/uploads/unzip/"); + + // if (!\File::exists( $storageDestinationPath)) { + // \File::makeDirectory($storageDestinationPath, 0755, true); + // } + // $zip->extractTo($storageDestinationPath); + // $zip->close(); + // // return back() + // // ->with('success','You have successfully extracted zip.'); + // } + // } + // }); + // }); + // } } diff --git a/plugins/tps/shops/classes/FileAttachment.php b/plugins/tps/shops/classes/FileAttachment.php new file mode 100644 index 0000000..4758a01 --- /dev/null +++ b/plugins/tps/shops/classes/FileAttachment.php @@ -0,0 +1,45 @@ +disk_name, 'hoto/')) + return ''; + + return 'file/'. implode('/', array_slice(explode( "-", $this->disk_name), 0, 3)) . '/'; + + } + + // /** + // * Generates a disk name from the supplied file name. + // */ + protected function getDiskName() + { + if ($this->disk_name !== null) { + return $this->disk_name; + } + + $ext = strtolower($this->getExtension()); + + // If file was uploaded without extension, attempt to guess it + if (!$ext && $this->data instanceof UploadedFile) { + $ext = $this->data->guessExtension(); + } + + // $name = str_replace('.', '', uniqid(null, true)); + + $name = str_replace('.', '', date('Y-m-d-').uniqid(null, true)); + + return $this->disk_name = !empty($ext) ? $name.'.'.$ext : $name; + } +} \ No newline at end of file diff --git a/plugins/tps/shops/controllers/Report.php b/plugins/tps/shops/controllers/Report.php new file mode 100644 index 0000000..d775b1c --- /dev/null +++ b/plugins/tps/shops/controllers/Report.php @@ -0,0 +1,35 @@ +name; + echo ''; + echo 'alert("message successfully sent")'; + echo ''; + // return \Backend::redirect('tps/shops/report'); + } +} diff --git a/plugins/tps/shops/controllers/Shops.php b/plugins/tps/shops/controllers/Shops.php index 198f469..1697efe 100644 --- a/plugins/tps/shops/controllers/Shops.php +++ b/plugins/tps/shops/controllers/Shops.php @@ -2,6 +2,8 @@ use Backend\Classes\Controller; use BackendMenu; +use Illuminate\Http\Request; +use Tps\Shops\Models\Shop; class Shops extends Controller { @@ -16,4 +18,10 @@ class Shops extends Controller parent::__construct(); BackendMenu::setContext('Tps.Shops', 'main-menu-item'); } + + public function updateShop(Request $request){ + Shop::where("id",$request->id)->first()->update($request->all()); + + return redirect()->back(); + } } diff --git a/plugins/tps/shops/controllers/report/_list_toolbar.htm b/plugins/tps/shops/controllers/report/_list_toolbar.htm new file mode 100644 index 0000000..79fc8c4 --- /dev/null +++ b/plugins/tps/shops/controllers/report/_list_toolbar.htm @@ -0,0 +1,18 @@ +
+ + +
diff --git a/plugins/tps/shops/controllers/report/config_form.yaml b/plugins/tps/shops/controllers/report/config_form.yaml new file mode 100644 index 0000000..21aa9d3 --- /dev/null +++ b/plugins/tps/shops/controllers/report/config_form.yaml @@ -0,0 +1,10 @@ +name: Report +form: $/tps/shops/models/report/fields.yaml +modelClass: Tps\Shops\Models\Report +defaultRedirect: tps/shops/report +create: + redirect: 'tps/shops/report/update/:id' + redirectClose: tps/shops/report +update: + redirect: tps/shops/report + redirectClose: tps/shops/report diff --git a/plugins/tps/shops/controllers/report/config_list.yaml b/plugins/tps/shops/controllers/report/config_list.yaml new file mode 100644 index 0000000..032eb32 --- /dev/null +++ b/plugins/tps/shops/controllers/report/config_list.yaml @@ -0,0 +1,12 @@ +list: $/tps/shops/models/report/columns.yaml +modelClass: Tps\Shops\Models\Report +title: Report +noRecordsMessage: 'backend::lang.list.no_records' +showSetup: true +showCheckboxes: true +recordsPerPage: 20 +toolbar: + buttons: list_toolbar + search: + prompt: 'backend::lang.list.search_prompt' +recordUrl: 'tps/shops/report/update/:id' diff --git a/plugins/tps/shops/controllers/report/create.htm b/plugins/tps/shops/controllers/report/create.htm new file mode 100644 index 0000000..a7f775c --- /dev/null +++ b/plugins/tps/shops/controllers/report/create.htm @@ -0,0 +1,48 @@ + + + + +fatalError): ?> + + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + + +
+
+ + + + +

fatalError)) ?>

+

+ \ No newline at end of file diff --git a/plugins/tps/shops/controllers/report/index.htm b/plugins/tps/shops/controllers/report/index.htm new file mode 100644 index 0000000..ea43a36 --- /dev/null +++ b/plugins/tps/shops/controllers/report/index.htm @@ -0,0 +1 @@ +listRender() ?> diff --git a/plugins/tps/shops/controllers/report/preview.htm b/plugins/tps/shops/controllers/report/preview.htm new file mode 100644 index 0000000..24f3e03 --- /dev/null +++ b/plugins/tps/shops/controllers/report/preview.htm @@ -0,0 +1,22 @@ + + + + +fatalError): ?> + +
+ formRenderPreview() ?> +
+ + +

fatalError) ?>

+ + +

+ + + +

\ No newline at end of file diff --git a/plugins/tps/shops/controllers/report/update.htm b/plugins/tps/shops/controllers/report/update.htm new file mode 100644 index 0000000..a5017c7 --- /dev/null +++ b/plugins/tps/shops/controllers/report/update.htm @@ -0,0 +1,68 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + + + + Zip Extract + +
+ + + + +
+
+ + + +

fatalError)) ?>

+

+ \ No newline at end of file diff --git a/plugins/tps/shops/models/Report.php b/plugins/tps/shops/models/Report.php new file mode 100644 index 0000000..d6179ea --- /dev/null +++ b/plugins/tps/shops/models/Report.php @@ -0,0 +1,93 @@ + 'System\Models\File', + // 'file' => 'Tps\Shops\Classes\FileAttachment', + ]; + + public $translatable = ['name']; + + // public function afterSave() + // public function beforeSave() + public function formAfterSave($model) + { + // $this->name = $this->file; + $filePath = \System\Models\File::find($model->id)->getLocalPath(); + + // $filePath = Input::file('file')->getPath(); + Log::error("FILE PATH IS ------------------------".$filePath); + + // throw new ApplicationException("FILE PATH IS ------------------------".$filePath); + // App::abort(403, "FILE PATH IS ------------------------".$filePath); + // $fileRecord = Input::file('file'); + // $fileRecord = \System\Models\File::find($model->id); + // $files = \System\Models\File::find($model->file); + // $new = $this->file()->withDeferred($this->sessionKey)->first()->getPath();; + // $fileRecord = \October\Rain\Database\Models\DeferredBinding::where([ + // 'master_type' => 'Tps\Shops\Models\Report', // <- REPLACE WITH YOUR MODEL(ModelName) + // "master_field" => "file", // <- REPLACE WITH ATTACHEMNT MODEL (gallery) + // "slave_type" => "System\Models\File", + // "session_key" => post('_session_key') + // ])->get()->first(); + + // $fileRecord = (new \System\Models\File)->fromData($model->file, 'logo.png'); + // $fileRecord = $model->file->getPath();; + // $fileRecord = $model->file->getLocalPath();; + // if($fileRecord){ + // echo ""; + // dd($fileRecord); + + // $zip = new ZipArchive(); + // $status = $zip->open($fileRecord); + // if ($status !== true) { + // throw new \Exception($status); + // } + // else{ + // $storageDestinationPath= storage_path("app/uploads/unzip/"); + + // if (!\File::exists( $storageDestinationPath)) { + // \File::makeDirectory($storageDestinationPath, 0755, true); + // } + // $zip->extractTo($storageDestinationPath); + // $zip->close(); + // // return back() + // // ->with('success','You have successfully extracted zip.'); + // } + // }else{ + // // dd("aaa"); + // } + + } +} diff --git a/plugins/tps/shops/models/Shop.php b/plugins/tps/shops/models/Shop.php index 1ad0597..09589bf 100644 --- a/plugins/tps/shops/models/Shop.php +++ b/plugins/tps/shops/models/Shop.php @@ -20,6 +20,8 @@ class Shop extends Model */ public $rules = [ ]; + + public $fillable = ["name", "floor", "phone", "instagram_name", "instagram_link"]; public $attachOne = [ 'badge' => 'System\Models\File', @@ -30,6 +32,9 @@ class Shop extends Model 'category' => [ 'Tps\Shops\Models\Category' ], + 'user' => [ + 'RainLab\User\Models\User' + ], ]; public $translatable = ['name','description','open_time']; diff --git a/plugins/tps/shops/models/report/columns.yaml b/plugins/tps/shops/models/report/columns.yaml new file mode 100644 index 0000000..67648ee --- /dev/null +++ b/plugins/tps/shops/models/report/columns.yaml @@ -0,0 +1,7 @@ +columns: + date: + label: date + type: text + name: + label: name + type: text diff --git a/plugins/tps/shops/models/report/fields.yaml b/plugins/tps/shops/models/report/fields.yaml new file mode 100644 index 0000000..e479fc3 --- /dev/null +++ b/plugins/tps/shops/models/report/fields.yaml @@ -0,0 +1,20 @@ +fields: + date: + label: Date + mode: date + span: auto + type: datepicker + name: + label: Name + span: auto + type: text + file: + label: File + span: auto + mode: file + useCaption: true + thumbOptions: + mode: crop + extension: auto + fileTypes: 'zip,rar' + type: fileupload diff --git a/plugins/tps/shops/models/shop/fields.yaml b/plugins/tps/shops/models/shop/fields.yaml index af8cb2f..54aa7a6 100644 --- a/plugins/tps/shops/models/shop/fields.yaml +++ b/plugins/tps/shops/models/shop/fields.yaml @@ -9,6 +9,12 @@ fields: descriptionFrom: name span: auto type: relation + user: + label: User + nameFrom: name + descriptionFrom: name + span: auto + type: relation floor: label: Floor span: auto diff --git a/plugins/tps/shops/plugin.yaml b/plugins/tps/shops/plugin.yaml index 1c17a69..d9b37ce 100644 --- a/plugins/tps/shops/plugin.yaml +++ b/plugins/tps/shops/plugin.yaml @@ -30,3 +30,7 @@ navigation: label: Sliders url: tps/shops/sliders icon: icon-square + side-menu-item6: + label: Report + url: tps/shops/report + icon: icon-file-pdf-o diff --git a/plugins/tps/shops/routes.php b/plugins/tps/shops/routes.php new file mode 100644 index 0000000..582f958 --- /dev/null +++ b/plugins/tps/shops/routes.php @@ -0,0 +1,16 @@ + 'fatoni.generate.api', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\ApiGeneratorController@generateApi')); +// Route::post('fatoni/update/api/{id}', array('as' => 'fatoni.update.api', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\ApiGeneratorController@updateApi')); +// Route::get('fatoni/delete/api/{id}', array('as' => 'fatoni.delete.api', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\ApiGeneratorController@deleteApi')); + +// Route::resource('api/news', 'AhmadFatoni\ApiGenerator\Controllers\API\newsController', ['except' => ['destroy', 'create', 'edit']]); +// Route::get('api/news/{id}/delete', ['as' => 'api/news.delete', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\API\newsController@destroy']); + + +// Custom Routes +Route::name('update.shop')->any('update/shop', 'Tps\Shops\Controllers\Shops@updateShop'); +Route::name('report.create')->any('add/report', 'Tps\Shops\Controllers\Reports@createReport'); +Route::name('zip.extract')->any('zip/extract/{id}', 'Tps\Shops\Controllers\Reports@createReport'); \ No newline at end of file diff --git a/plugins/tps/shops/updates/builder_table_create_tps_shops_reports.php b/plugins/tps/shops/updates/builder_table_create_tps_shops_reports.php new file mode 100644 index 0000000..aaa1028 --- /dev/null +++ b/plugins/tps/shops/updates/builder_table_create_tps_shops_reports.php @@ -0,0 +1,24 @@ +engine = 'InnoDB'; + $table->increments('id')->unsigned(); + $table->date('date'); + $table->text('name'); + $table->text('file'); + }); + } + + public function down() + { + Schema::dropIfExists('tps_shops_reports'); + } +} diff --git a/plugins/tps/shops/updates/builder_table_update_tps_shops__11.php b/plugins/tps/shops/updates/builder_table_update_tps_shops__11.php new file mode 100644 index 0000000..cc89f11 --- /dev/null +++ b/plugins/tps/shops/updates/builder_table_update_tps_shops__11.php @@ -0,0 +1,23 @@ +integer('user_id'); + }); + } + + public function down() + { + Schema::table('tps_shops_', function($table) + { + $table->dropColumn('user_id'); + }); + } +} diff --git a/plugins/tps/shops/updates/version.yaml b/plugins/tps/shops/updates/version.yaml index 4f444ff..b0f6dc7 100644 --- a/plugins/tps/shops/updates/version.yaml +++ b/plugins/tps/shops/updates/version.yaml @@ -66,3 +66,9 @@ 1.0.23: - 'Created table tps_shops_sales' - builder_table_create_tps_shops_sales.php +1.0.24: + - 'Updated table tps_shops_' + - builder_table_update_tps_shops__11.php +1.0.25: + - 'Created table tps_shops_reports' + - builder_table_create_tps_shops_reports.php diff --git a/themes/berkarar/layouts/default.htm b/themes/berkarar/layouts/default.htm index 5458d7b..5467b2c 100644 --- a/themes/berkarar/layouts/default.htm +++ b/themes/berkarar/layouts/default.htm @@ -1,10 +1,15 @@ description = "Default layout" -[localePicker] -forceUrl = 0 - [session] security = "all" + +[account] +paramCode = "code" +forceSecure = 0 +requirePassword = 0 + +[localePicker] +forceUrl = 0 == diff --git a/themes/berkarar/pages/profile.htm b/themes/berkarar/pages/profile.htm new file mode 100644 index 0000000..563c499 --- /dev/null +++ b/themes/berkarar/pages/profile.htm @@ -0,0 +1,167 @@ +title = "profile" +url = "/profile" +layout = "default" +is_hidden = 0 + +[session] +security = "user" +redirect = "home" +== +{% component 'session' %} + + +
+
+
+
+ + + + + + + + Главная + + +

+ Профиль +

+
+
+
+
+ + + +
+
+
+
+
+

+ Счета +

+ +

+ Контактная информация +

+
+ +
+
+
+

+ 23.02.2023 +

+

+ Счет за электричество +

+
+ + + + + + + + + + + + + Скачать PDF файл + +
+ +
+
+

+ 23.02.2023 +

+

+ Счет за свет +

+
+ + + + + + + + + + + + + Скачать PDF файл + +
+
+ +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/themes/berkarar/partials/site/header.htm b/themes/berkarar/partials/site/header.htm index 450d9f9..51f29e3 100644 --- a/themes/berkarar/partials/site/header.htm +++ b/themes/berkarar/partials/site/header.htm @@ -41,7 +41,12 @@ function onStart(){
{% if user %} - Выйти + + + + Выйти + + {% else %} {% endif %} diff --git a/themes/berkarar/partials/site/login.htm b/themes/berkarar/partials/site/login.htm new file mode 100644 index 0000000..be22e8c --- /dev/null +++ b/themes/berkarar/partials/site/login.htm @@ -0,0 +1,31 @@ +== + + + \ No newline at end of file