add_balance

This commit is contained in:
SoHardKI
2019-06-21 18:05:58 +03:00
parent 0727013ddd
commit 1b088402df
313 changed files with 543 additions and 25 deletions
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Vendored Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
+3
View File
@@ -29,6 +29,9 @@ return [
'hh' => [
'class' => 'backend\modules\hh\Hh',
],
'balance' => [
'class' => 'backend\modules\balance\Balance',
],
],
'components' => [
'request' => [
Regular → Executable
View File
Regular → Executable
View File
View File
Regular → Executable
View File
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace backend\modules\balance;
/**
* card module definition class
*/
class Balance extends \yii\base\Module
{
/**
* {@inheritdoc}
*/
public $controllerNamespace = 'backend\modules\balance\controllers';
/**
* {@inheritdoc}
*/
public function init()
{
parent::init();
// custom initialization code goes here
}
}
@@ -0,0 +1,80 @@
<?php
namespace backend\modules\balance\controllers;
use backend\modules\balance\models\Balance;
use backend\modules\balance\models\BalanceSearch;
use common\classes\Debug;
use Yii;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\db\Query;
class BalanceController extends Controller
{
public function actionIndex()
{
$searchModel = new BalanceSearch();
$dataProvider = $searchModel->search();
return $this->render('index',[
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
public function actionView($id)
{
return $this->render('view',[
'model' => $this->findModel($id),
]);
}
public function actionCreate()
{
$model = new Balance();
if ($model->load(Yii::$app->request->post())) {
$model->dt_add = strtotime($model->dt_add);
$model->save();
// Debug::dd($model);
Yii::$app->session->addFlash('success', 'Баланса добавлен');
return $this->redirect(['index']);
}
return $this->render('create', [
'model' => $model,
]);
}
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('update',[
'model' => $model,
]);
}
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
protected function findModel($id)
{
if (($model = Balance::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}
@@ -0,0 +1,48 @@
<?php
namespace backend\modules\balance\models;
use common\models\FieldsValue;
use common\models\ProjectUser;
use yii\helpers\ArrayHelper;
class Balance extends \common\models\Balance
{
public function init()
{
parent::init();
$fieldValue = FieldsValue::find()
->where(
[
'balance_id' => \Yii::$app->request->get('id'),
'card_id' => null,
'company_id' => null,
])
->all();
$array = [];
if (!empty($fieldValue)) {
foreach ($fieldValue as $item) {
array_push($array, ['field_id' => $item->field_id, 'value' => $item->value, 'order' => $item->order]);
}
$this->fields = $array;
} else {
$this->fields = [
[
'field_id' => null,
'value' => null,
'order' => null,
],
];
}
$user = ArrayHelper::getColumn(ProjectUser::find()->where(['project_id' => \Yii::$app->request->get('id')])->all(),
'card_id');
if (!empty($user)) {
$this->user = $user;
}
}
}
@@ -0,0 +1,30 @@
<?php
namespace backend\modules\balance\models;
use common\classes\Debug;
use yii\base\Model;
use yii\data\ActiveDataProvider;
class BalanceSearch extends Balance
{
public function scenarios()
{
return Model::scenarios(); // TODO: Change the autogenerated stub
}
public function search()
{
$query = Balance::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
if($this->validate())
{
return $dataProvider;
}
}
}
@@ -0,0 +1,85 @@
<?php
use backend\modules\settings\models\AdditionalFields;
use unclead\multipleinput\MultipleInput;
use yii\helpers\Html;
use yii\jui\DatePicker;
use yii\web\View;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\company\models\Balance */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="balance-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'type')
->dropDownList(
[
'1' => 'активный',
'0' => 'пассивный',
]
)?>
<?= $form->field($model, 'summ')->textInput(['maxlength' => 9]) ?>
<?php
echo '<label> Выберите дату</label>';
echo '<br>';
echo DatePicker::widget([
'model' => $model,
'attribute' => 'dt_add',
'language' => 'ru',
'dateFormat' => 'dd-MM-yyyy',
]);
?>
<div class="row">
<div class="col-xs-12">
<?= $form->field($model, 'fields')->widget(MultipleInput::class, [
'columns' => [
[
'name' => 'field_id',
'type' => 'dropDownList',
'title' => 'Поле',
'defaultValue' => null,
'items' => \yii\helpers\ArrayHelper::map(AdditionalFields::find()
->joinWith('useFields')
->where(['`use_field`.`use`' => \common\models\UseField::USE_BALANCE])
->all(),
'id', 'name'),
'options' => ['prompt' => 'Выберите']
],
[
'name' => 'value',
'title' => 'Значение',
'enableError' => true,
'options' => [
'class' => 'input-priority'
]
],
[
'name' => 'order',
'title' => 'Приоритет',
'enableError' => true,
'options' => [
'class' => 'input-priority'
]
]
]
])->label('Дополнительно');
?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
@@ -0,0 +1,18 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\company\models\Balance */
$this->title = 'Добавить баланс';
$this->params['breadcrumbs'][] = ['label' => 'Список балансов', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="balance-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>
@@ -0,0 +1,30 @@
<?php
use yii\data\ActiveDataProvider;
use yii\helpers\Html;
use yii\grid\GridView;
use yii\web\View;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\company\models\BalanceSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Список балансов';
$this->params['breadcrumps'][] = $this->title;
?>
<div class="balance-index">
<p>
<?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'type',
'summ',
'dt_add',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>
@@ -0,0 +1,19 @@
<?php
use yii\helpers\Html;
use yii\web\View;
/* @var $this yii\web\View */
/* @var $model backend\modules\balance\models\Balance */
$this->title = 'Редактировать баланс №' . $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Список балансов', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Редактировать';
?>
<div class="balance-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>
@@ -0,0 +1,35 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\balance\models\Balance */
$this->title = 'Баланс №' . $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Список балансов', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="balance-view">
<p>
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Delete', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'type',
'summ',
'dt_add',
],
]) ?>
</div>
Regular → Executable
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
Regular → Executable
View File
View File
View File
View File
Regular → Executable
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File

Some files were not shown because too many files have changed in this diff Show More