From f92e6e24914edcba9016506dbabbc4f97391ba97 Mon Sep 17 00:00:00 2001 From: gerchek Date: Thu, 28 Apr 2022 02:18:02 +0500 Subject: [PATCH] last update server --- modules/backend/models/ExportModel.php | 6 +- .../controllers/OnlineCardController.php | 51 ++++++++++-- .../onlinecardcontroller/_list_toolbar.htm | 14 ++++ .../onlinecardcontroller/config_filter.yaml | 14 ++++ .../config_import_export.yaml | 12 +++ .../onlinecardcontroller/export.htm | 19 +++++ .../onlinecardcontroller/import.htm | 18 ++++ plugins/atash/contact/models/CreditClass.php | 55 ++++--------- .../atash/contact/models/FilterCardData.php | 35 ++++++++ plugins/atash/contact/models/ItemExport.php | 26 ++++++ plugins/atash/contact/models/ItemImport.php | 44 ++++++++++ plugins/atash/contact/models/OnlineCard.php | 13 +++ .../contact/models/creditclass/columns.yaml | 61 ++++---------- .../contact/models/itemexport/columns.yaml | 73 +++++++++++++++++ .../contact/models/onlinecard/columns.yaml | 82 +++++-------------- ..._create_atash_contact_filter_card_data.php | 23 ++++++ ...r_table_update_atash_contact_credit_11.php | 25 ++++++ ..._update_atash_contact_filter_card_data.php | 25 ++++++ plugins/atash/contact/updates/version.yaml | 9 ++ 19 files changed, 451 insertions(+), 154 deletions(-) create mode 100644 plugins/atash/contact/controllers/onlinecardcontroller/config_import_export.yaml create mode 100644 plugins/atash/contact/controllers/onlinecardcontroller/export.htm create mode 100644 plugins/atash/contact/controllers/onlinecardcontroller/import.htm create mode 100644 plugins/atash/contact/models/FilterCardData.php create mode 100644 plugins/atash/contact/models/ItemExport.php create mode 100644 plugins/atash/contact/models/ItemImport.php create mode 100644 plugins/atash/contact/models/itemexport/columns.yaml create mode 100644 plugins/atash/contact/updates/builder_table_create_atash_contact_filter_card_data.php create mode 100644 plugins/atash/contact/updates/builder_table_update_atash_contact_credit_11.php create mode 100644 plugins/atash/contact/updates/builder_table_update_atash_contact_filter_card_data.php diff --git a/modules/backend/models/ExportModel.php b/modules/backend/models/ExportModel.php index e6a767e..8861c4c 100644 --- a/modules/backend/models/ExportModel.php +++ b/modules/backend/models/ExportModel.php @@ -28,8 +28,8 @@ abstract class ExportModel extends Model * [...] * */ - abstract public function exportData($columns, $sessionKey = null); - + //abstract public function exportData($columns, $sessionKey = null); + abstract public function exportData($records, $sessionKey = null); /** * Export data based on column names and labels. * The $columns array should be in the format of: @@ -84,7 +84,7 @@ abstract class ExportModel extends Model $defaultOptions = [ 'firstRowTitles' => true, 'useOutput' => false, - 'fileName' => 'export.csv', + 'fileName' => 'export.xlsx', 'delimiter' => null, 'enclosure' => null, 'escape' => null diff --git a/plugins/atash/contact/controllers/OnlineCardController.php b/plugins/atash/contact/controllers/OnlineCardController.php index 40de218..ea118d1 100644 --- a/plugins/atash/contact/controllers/OnlineCardController.php +++ b/plugins/atash/contact/controllers/OnlineCardController.php @@ -9,13 +9,18 @@ use Session; use Str; use Redirect; use Atash\Contact\Models\Settings; +use Atash\Contact\Models\ItemExport; +use Atash\Contact\Models\FilterCardData; class OnlineCardController extends Controller { protected $userData; - public $implement = [ 'Backend\Behaviors\ListController', 'Backend\Behaviors\FormController', 'Backend\Behaviors\ReorderController' ]; + public $implement = [ 'Backend\Behaviors\ListController', 'Backend\Behaviors\FormController', 'Backend\Behaviors\ReorderController' , 'Backend.Behaviors.ImportExportController' ]; public $listConfig = 'config_list.yaml'; + + public $importExportConfig = 'config_import_export.yaml'; + public $formConfig = 'config_form.yaml'; public $reorderConfig = 'config_reorder.yaml'; @@ -25,13 +30,43 @@ class OnlineCardController extends Controller BackendMenu::setContext('Atash.Contact', 'main-menu-item', 'side-menu-item2'); } - // public function onRun() - //{ - // $result = OnlineCard::select("*") - // ->where("payed", true) - // ->get(); - // return $result; - //} + public function onGetFilteredRecords() + { + $this->makeLists(); + $listWidget = $this->asExtension('ListController')->listGetWidget(); + + $query = $listWidget->prepareQuery(); + $records = $query->get(); + $array = []; + $array_length = 0; + foreach ($records as $key => $value) { + //dump($value->id); + $array[$array_length]=$value->id; + $array_length++; + } + //dump($array); + $data = FilterCardData::where('name','data')->first(); + if (!$data) { + FilterCardData::create([ + 'name' => 'data', + 'data' => implode(",", $array), + ]); + } + else + { + FilterCardData::where('name','data') + ->update([ + 'data' => implode(",", $array) + ]); + } + + + + + + } + + public function listExtendQuery($query) { diff --git a/plugins/atash/contact/controllers/onlinecardcontroller/_list_toolbar.htm b/plugins/atash/contact/controllers/onlinecardcontroller/_list_toolbar.htm index c172327..2d27cbf 100644 --- a/plugins/atash/contact/controllers/onlinecardcontroller/_list_toolbar.htm +++ b/plugins/atash/contact/controllers/onlinecardcontroller/_list_toolbar.htm @@ -1,6 +1,18 @@
+ + + 2) Export + + + + +
diff --git a/plugins/atash/contact/controllers/onlinecardcontroller/config_filter.yaml b/plugins/atash/contact/controllers/onlinecardcontroller/config_filter.yaml index 7b9a106..33ab69b 100644 --- a/plugins/atash/contact/controllers/onlinecardcontroller/config_filter.yaml +++ b/plugins/atash/contact/controllers/onlinecardcontroller/config_filter.yaml @@ -7,6 +7,20 @@ scopes: label: "Selected card" type: text conditions: selected_card like concat('%', :value, '%') + region: + label: "Region" + type: text + conditions: region like concat('%', :value, '%') + branch: + label: "Branch" + type: text + conditions: branch like concat('%', :value, '%') + #selected_card: + # label: Holiday Type + # type: group + # conditions: type in (:filtered) + # options: getHolidayTypesAttribute + # modelClass: Atash\Contact\Models\OnlineCard #selected_card: diff --git a/plugins/atash/contact/controllers/onlinecardcontroller/config_import_export.yaml b/plugins/atash/contact/controllers/onlinecardcontroller/config_import_export.yaml new file mode 100644 index 0000000..cd3344a --- /dev/null +++ b/plugins/atash/contact/controllers/onlinecardcontroller/config_import_export.yaml @@ -0,0 +1,12 @@ +import: + title: Import places + modelClass: Atash\Contact\Models\ItemImport + list: $/atash/contact/models/onlinecard/columns.yaml + +export: + title: Export places + modelClass: Atash\Contact\Models\ItemExport + list: $/atash/contact/models/onlinecard/columns.yaml + #export: + #useList: orders + #fileName: data.xlsx \ No newline at end of file diff --git a/plugins/atash/contact/controllers/onlinecardcontroller/export.htm b/plugins/atash/contact/controllers/onlinecardcontroller/export.htm new file mode 100644 index 0000000..280c247 --- /dev/null +++ b/plugins/atash/contact/controllers/onlinecardcontroller/export.htm @@ -0,0 +1,19 @@ + 'layout import-export']) ?> + +
+ exportRender() ?> +
+ +
+ + +
+ + \ No newline at end of file diff --git a/plugins/atash/contact/controllers/onlinecardcontroller/import.htm b/plugins/atash/contact/controllers/onlinecardcontroller/import.htm new file mode 100644 index 0000000..ba779bd --- /dev/null +++ b/plugins/atash/contact/controllers/onlinecardcontroller/import.htm @@ -0,0 +1,18 @@ + 'layout import-export']) ?> + +
+ importRender() ?> +
+ +
+ +
+ + \ No newline at end of file diff --git a/plugins/atash/contact/models/CreditClass.php b/plugins/atash/contact/models/CreditClass.php index 307c159..7c0dfb2 100644 --- a/plugins/atash/contact/models/CreditClass.php +++ b/plugins/atash/contact/models/CreditClass.php @@ -9,54 +9,35 @@ class CreditClass extends Model { use \October\Rain\Database\Traits\Validation; - /* - * Disable timestamps by default. - * Remove this line if timestamps are defined in the database table. - */ - public $timestamps = false; - /** * @var string The database table used by the model. */ public $table = 'atash_contact_credit'; -//public function getStatusOptions($keyValue = null) -//{ - // $keyValue = $this->getAttributeFromArray('status'); - -// $options['Salam'] = 'SALAM'; -// $options['Sagbol'] = 'SAGBOL'; -//$options['Salam'] = 'SALAM'; -//$options['Sag bol'] = e(trans('atash.contact::lang.app.name')); - // $options[e(trans('habinho.school::lang.lesson.monday'))] = e(trans('habinho.school::lang.lesson.monday')); - // $options[e(trans('habinho.school::lang.lesson.tuesday'))] = e(trans('habinho.school::lang.lesson.tuesday')); - // $options[e(trans('habinho.school::lang.lesson.wednesday'))] = e(trans('habinho.school::lang.lesson.wednesday')); - // $options[e(trans('habinho.school::lang.lesson.thursday'))] = e(trans('habinho.school::lang.lesson.thursday')); - // $options[e(trans('habinho.school::lang.lesson.friday'))] = e(trans('habinho.school::lang.lesson.friday')); - // $options[e(trans('habinho.school::lang.lesson.saturday'))] = e(trans('habinho.school::lang.lesson.saturday')); - // $options[e(trans('habinho.school::lang.lesson.sunday'))] = e(trans('habinho.school::lang.lesson.sunday')); - - // return $options; -//} - -//public function getStatusAttribute($value) -//{ - // return $value; -// return $this->getStatusOptions()[$value]; -//} - -//public $implement = ['RainLab.Translate.Behaviors.TranslatableModel']; - - // public $translatable = ['status','action']; - /** * @var array Validation rules */ public $rules = [ ]; - - public $attachMany = [ + +public $attachMany = [ 'file' => 'System\Models\File' ]; + +//public function getStatusOptions($keyValue = null) +//{ + // $keyValue = $this->getAttributeFromArray('status'); + //$options['Ugradyldy'] = 'SALAM'; + //dd($options); + + // return $options; +//} + +//public function getStatusAttribute($value) +//{ + //dd($value); + // return $value; + //return $this->getStatusOptions()[$value]; +//} } diff --git a/plugins/atash/contact/models/FilterCardData.php b/plugins/atash/contact/models/FilterCardData.php new file mode 100644 index 0000000..80450f3 --- /dev/null +++ b/plugins/atash/contact/models/FilterCardData.php @@ -0,0 +1,35 @@ +records = $records; + //} + + public function exportData($records, $sessionKey = null) + { + + $data = FilterCardData::where('name','data')->first(); + $res = $data->data; + $pieces = explode(",", $res); + $data = OnlineCard::whereIn('id', $pieces)->get(); + return $data->toArray(); + } + +} \ No newline at end of file diff --git a/plugins/atash/contact/models/ItemImport.php b/plugins/atash/contact/models/ItemImport.php new file mode 100644 index 0000000..48d3e13 --- /dev/null +++ b/plugins/atash/contact/models/ItemImport.php @@ -0,0 +1,44 @@ + $data) { + try { + + // Создаем новую запись + $item = Item::make(); + + // Исключить из цикла + $except = ['id']; // В этом массиве мы исключаем те переменные, которые не нужно обрабатывать в автоматическом цикле foreach ниже + + // Цикл заполнения + foreach (array_except($data, $except) as $attribute => $value) { + $item->{$attribute} = $value ?: null; // Присваивание значения в столбец по атрибуту + } + // Сохранение + $item->forceSave(); + + $this->logCreated(); + } + catch (\Exception $ex) { + // Ошибка + $this->logError($row, $ex); + } + + } + } +} \ No newline at end of file diff --git a/plugins/atash/contact/models/OnlineCard.php b/plugins/atash/contact/models/OnlineCard.php index 8776a00..b009c84 100644 --- a/plugins/atash/contact/models/OnlineCard.php +++ b/plugins/atash/contact/models/OnlineCard.php @@ -52,6 +52,19 @@ class OnlineCard extends Model ]; protected $guarded = ['*']; + + public function scopeIsMerchant($query) +{ + //WHAT GOES HERE? + dd("salam"); +} + +public function getHolidayTypesAttribute(){ + return [ + 1 => 'default', + 2 => 'new' + ]; +} #public function getHolidayTypesAttribute(){ #return [ # "Aýlyk karty" => 'Aýlyk karty' diff --git a/plugins/atash/contact/models/creditclass/columns.yaml b/plugins/atash/contact/models/creditclass/columns.yaml index fe9373d..5d499a8 100644 --- a/plugins/atash/contact/models/creditclass/columns.yaml +++ b/plugins/atash/contact/models/creditclass/columns.yaml @@ -2,57 +2,30 @@ columns: id: label: id type: number - name: - label: name - type: text - last_name: - label: last_name - type: text - addres: - label: addres - type: text - email: - label: email + region: + label: Welaýat type: text branch: - label: branch + label: Şahamça type: text - birth: - label: birth + surname: + label: Familiýa type: text - type: - label: type + name: + label: Ady type: text - middle_name: - label: middle_name - type: text - mobile_phone: - label: mobile_phone - type: text - home_phone: - label: home_phone + middlename: + label: Atasynyň ady type: text passport_series: - label: passport_series + label: Pasportyň seriýasy type: text - passport_date: - label: passport_date + type: + label: Karzyň görnüşi type: text - passport_issued_by: - label: passport_issued_by - type: text - region: - label: region - type: text - place_of_work: - label: place_of_work - type: text - amount_of_salary: - label: amount_of_salary - type: text - position: - label: position - type: text - work_experience: - label: work_experience + created_at: + label: Onlaýn-ýüzlenmäniň berlen senesi + type: datetime + status: + label: Onlaýn-ýüzlenmäniň ýagdaýy type: text diff --git a/plugins/atash/contact/models/itemexport/columns.yaml b/plugins/atash/contact/models/itemexport/columns.yaml new file mode 100644 index 0000000..0fc2305 --- /dev/null +++ b/plugins/atash/contact/models/itemexport/columns.yaml @@ -0,0 +1,73 @@ +columns: + id: + label: id + type: number + selected_card: + label: selected_card + type: text + name: + label: name + type: text + surname: + label: surname + type: text + middlename: + label: middlename + type: text + birthdate: + label: birthdate + type: text + phone_number: + label: phone_number + type: text + home_phone_number: + label: home_phone_number + type: text + email: + label: email + type: text + passport_series: + label: passport_series + type: text + date_of_passport: + label: date_of_passport + type: text + passport_by: + label: passport_by + type: text + order_id: + label: order_id + type: text + payed: + label: payed + type: text + created_at: + label: created_at + type: datetime + updated_at: + label: updated_at + type: datetime + sms_notification: + label: sms_notification + type: text + place_of_residence: + label: place_of_residence + type: text + region: + label: region + type: text + branch: + label: branch + type: text + date_arrival_bank: + label: date_arrival_bank + type: text + selected_time: + label: selected_time + type: text + the_codeword: + label: the_codeword + type: text + user_id: + label: user_id + type: number diff --git a/plugins/atash/contact/models/onlinecard/columns.yaml b/plugins/atash/contact/models/onlinecard/columns.yaml index 0fc2305..a7db31d 100644 --- a/plugins/atash/contact/models/onlinecard/columns.yaml +++ b/plugins/atash/contact/models/onlinecard/columns.yaml @@ -2,72 +2,30 @@ columns: id: label: id type: number - selected_card: - label: selected_card - type: text - name: - label: name - type: text - surname: - label: surname - type: text - middlename: - label: middlename - type: text - birthdate: - label: birthdate - type: text - phone_number: - label: phone_number - type: text - home_phone_number: - label: home_phone_number - type: text - email: - label: email - type: text - passport_series: - label: passport_series - type: text - date_of_passport: - label: date_of_passport - type: text - passport_by: - label: passport_by - type: text - order_id: - label: order_id - type: text - payed: - label: payed - type: text - created_at: - label: created_at - type: datetime - updated_at: - label: updated_at - type: datetime - sms_notification: - label: sms_notification - type: text - place_of_residence: - label: place_of_residence - type: text region: - label: region + label: Welaýat type: text branch: - label: branch + label: Şahamça type: text - date_arrival_bank: - label: date_arrival_bank + surname: + label: Familiýa type: text - selected_time: - label: selected_time + name: + label: Ady type: text - the_codeword: - label: the_codeword + middlename: + label: Atasynyň ady type: text - user_id: - label: user_id - type: number + passport_series: + label: Pasportyň seriýasy + type: text + selected_card: + label: Kartyň görnüşi + type: text + created_at: + label: Onlaýn-ýüzlenmäniň berlen senesi + type: datetime + status: + label: Onlaýn-ýüzlenmäniň ýagdaýy + type: text \ No newline at end of file diff --git a/plugins/atash/contact/updates/builder_table_create_atash_contact_filter_card_data.php b/plugins/atash/contact/updates/builder_table_create_atash_contact_filter_card_data.php new file mode 100644 index 0000000..fe7d3f9 --- /dev/null +++ b/plugins/atash/contact/updates/builder_table_create_atash_contact_filter_card_data.php @@ -0,0 +1,23 @@ +engine = 'InnoDB'; + $table->increments('id')->unsigned(); + $table->string('name')->nullable(); + $table->string('data')->nullable(); + }); + } + + public function down() + { + Schema::dropIfExists('atash_contact_filter_card_data'); + } +} diff --git a/plugins/atash/contact/updates/builder_table_update_atash_contact_credit_11.php b/plugins/atash/contact/updates/builder_table_update_atash_contact_credit_11.php new file mode 100644 index 0000000..ba2de57 --- /dev/null +++ b/plugins/atash/contact/updates/builder_table_update_atash_contact_credit_11.php @@ -0,0 +1,25 @@ +timestamp('created_at')->nullable(); + $table->timestamp('updated_at')->nullable(); + }); + } + + public function down() + { + Schema::table('atash_contact_credit', function($table) + { + $table->dropColumn('created_at'); + $table->dropColumn('updated_at'); + }); + } +} diff --git a/plugins/atash/contact/updates/builder_table_update_atash_contact_filter_card_data.php b/plugins/atash/contact/updates/builder_table_update_atash_contact_filter_card_data.php new file mode 100644 index 0000000..5a8412c --- /dev/null +++ b/plugins/atash/contact/updates/builder_table_update_atash_contact_filter_card_data.php @@ -0,0 +1,25 @@ +string('name', 191)->nullable(false)->change(); + $table->string('data', 191)->nullable(false)->change(); + }); + } + + public function down() + { + Schema::table('atash_contact_filter_card_data', function($table) + { + $table->string('name', 191)->nullable()->change(); + $table->string('data', 191)->nullable()->change(); + }); + } +} diff --git a/plugins/atash/contact/updates/version.yaml b/plugins/atash/contact/updates/version.yaml index f67c23a..77e0dcc 100644 --- a/plugins/atash/contact/updates/version.yaml +++ b/plugins/atash/contact/updates/version.yaml @@ -93,3 +93,12 @@ 1.0.32: - 'Updated table atash_contact_card_data' - builder_table_update_atash_contact_card_data_3.php +1.0.33: + - 'Created table atash_contact_filter_card_data' + - builder_table_create_atash_contact_filter_card_data.php +1.0.34: + - 'Updated table atash_contact_filter_card_data' + - builder_table_update_atash_contact_filter_card_data.php +1.0.35: + - 'Updated table atash_contact_credit' + - builder_table_update_atash_contact_credit_11.php