add_balance
This commit is contained in:
48
backend/modules/balance/models/Balance.php
Normal file
48
backend/modules/balance/models/Balance.php
Normal file
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
30
backend/modules/balance/models/BalanceSearch.php
Normal file
30
backend/modules/balance/models/BalanceSearch.php
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user