last update server

This commit is contained in:
gerchek 2022-04-28 02:18:02 +05:00
parent 86171c2790
commit f92e6e2491
19 changed files with 451 additions and 154 deletions

View File

@ -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

View File

@ -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)
{

View File

@ -1,6 +1,18 @@
<div data-control="toolbar">
<a href="<?= Backend::url('atash/contact/onlinecardcontroller/create') ?>" class="btn btn-primary oc-icon-plus"><?= e(trans('backend::lang.form.create')) ?></a>
<a href="<?= Backend::url('atash/contact/onlinecardcontroller/reorder') ?>" class="btn btn-default oc-icon-list"><?= e(trans('backend::lang.reorder.default_title')) ?></a>
<button
class="btn btn-default"
data-request="onGetFilteredRecords">
1) Get All Record
</button>
<a
href="<?= Backend::url('atash/contact/onlinecardcontroller/export') ?>"
class="btn btn-default oc-icon-download">
2) Export
</a>
<button
class="btn btn-default oc-icon-trash-o"
disabled="disabled"
@ -16,4 +28,6 @@
data-stripe-load-indicator>
<?= e(trans('backend::lang.list.delete_selected')) ?>
</button>
</div>

View File

@ -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:

View File

@ -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

View File

@ -0,0 +1,19 @@
<?= Form::open(['class' => 'layout import-export']) ?>
<div class="layout-row">
<?= $this->exportRender() ?>
</div>
<div class="form-buttons">
<button
type="submit"
data-control="popup"
data-handler="onExportLoadForm"
data-keyboard="false"
class="btn btn-primary">
Export places
</button>
</div>
<?= Form::close() ?>

View File

@ -0,0 +1,18 @@
<?= Form::open(['class' => 'layout import-export']) ?>
<div class="layout-row">
<?= $this->importRender() ?>
</div>
<div class="form-buttons">
<button
type="submit"
data-control="popup"
data-handler="onImportLoadForm"
data-keyboard="false"
class="btn btn-primary">
Import posts
</button>
</div>
<?= Form::close() ?>

View File

@ -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];
//}
}

View File

@ -0,0 +1,35 @@
<?php namespace Atash\Contact\Models;
use Model;
use Atash\Contact\Models\FilterCardData;
/**
* Model
*/
class FilterCardData 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_filter_card_data';
/**
* @var array Validation rules
*/
public $rules = [
];
protected $fillable = [
'name',
'data'
];
}

View File

@ -0,0 +1,26 @@
<?php namespace Atash\Contact\Models;
session_start();
use Backend\Models\ExportModel;
use Atash\Contact\Models\OnlineCard;
use Atash\Contact\Models\FilterCardData;
class ItemExport extends ExportModel
{
protected $record;
// $public function __construct($records){
// $this->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();
}
}

View File

@ -0,0 +1,44 @@
<?php namespace Atash\Contact\Models;
use Backend\Models\ImportModel;
class ItemImport extends ImportModel
{
public $table = 'atash_contact_online_card';
/**
* Обязательные поля
*/
public $rules = [
];
public function importData($results, $sessionKey = null)
{
$firstRow = reset($results);
foreach ($results as $row => $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);
}
}
}
}

View File

@ -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'

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,23 @@
<?php namespace Atash\Contact\Updates;
use Schema;
use October\Rain\Database\Updates\Migration;
class BuilderTableCreateAtashContactFilterCardData extends Migration
{
public function up()
{
Schema::create('atash_contact_filter_card_data', function($table)
{
$table->engine = 'InnoDB';
$table->increments('id')->unsigned();
$table->string('name')->nullable();
$table->string('data')->nullable();
});
}
public function down()
{
Schema::dropIfExists('atash_contact_filter_card_data');
}
}

View File

@ -0,0 +1,25 @@
<?php namespace Atash\Contact\Updates;
use Schema;
use October\Rain\Database\Updates\Migration;
class BuilderTableUpdateAtashContactCredit11 extends Migration
{
public function up()
{
Schema::table('atash_contact_credit', function($table)
{
$table->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');
});
}
}

View File

@ -0,0 +1,25 @@
<?php namespace Atash\Contact\Updates;
use Schema;
use October\Rain\Database\Updates\Migration;
class BuilderTableUpdateAtashContactFilterCardData extends Migration
{
public function up()
{
Schema::table('atash_contact_filter_card_data', function($table)
{
$table->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();
});
}
}

View File

@ -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