public function calcPay() { $this->step = 1; $this->dates(); $incomes = Accounts::findAllByType(3); //incomes foreach ($incomes as $account) { //echo $transaction->date.','.$transaction->sum.'<br>'; if ($account->src_tax == 0) { $this->income_sum_novat += $account->getTotal($this->from_date, $this->to_date); } else { $this->income_sum += $account->getTotal($this->from_date, $this->to_date); } } $this->selvat_acc = \app\helpers\Linet3Helper::getSetting('company.acc.sellvat'); $selvat = Accounts::findOne($this->selvat_acc); $this->selvat_total = $selvat->getTotal($this->from_date, $this->to_date); $this->buyvat_acc = \app\helpers\Linet3Helper::getSetting('company.acc.buyvat'); $buyvat = Accounts::findOne($this->buyvat_acc); $this->buyvat_total = $buyvat->getTotal($this->from_date, $this->to_date) * -1; //hAS TO INVERT $this->assetvat_acc = \app\helpers\Linet3Helper::getSetting('company.acc.assetvat'); $assetvat = Accounts::findOne($this->assetvat_acc); $this->assetvat_total = $assetvat->getTotal($this->from_date, $this->to_date) * -1; //hAS TO INVERT $this->payvat_total = $this->selvat_total - ($this->buyvat_total + $this->assetvat_total); return $this->payvat_total; }
public function find() { // Warning: Please modify the following code to remove attributes that // should not be searched. $filter = 1; //small change $type = 0; //$type = (int) $this->type; $accounts = Accounts::findAllByType($type); // or using: $rawData=User::find()->All(); $list = []; foreach ($accounts as $account) { $transBalance = $account->getBalance(); $docBalance = $this->getDocs($account->id); if ($transBalance > $filter || $transBalance < $filter * -1) { $list[] = array('id' => $account->id, 'name' => $account->name, 'transactions' => $transBalance, 'doc' => $docBalance, 'sum' => $transBalance - $docBalance); } } $dataProvider = new \yii\data\ArrayDataProvider(array('allModels' => $list, 'id' => 'user', 'sort' => array('attributes' => ['id', 'name', 'transactions', 'doc', 'sum']), 'pagination' => false)); return $dataProvider; // $dataProvider->getData() will return a list of arrays. }
<?php use kartik\select2\Select2; use kartik\datecontrol\DateControl; use app\models\Accounts; $this->params["menu"] = array(); app\widgets\MiniForm::begin(array('header' => Yii::t('app', "Create deposit"))); ?> <?php $form = kartik\form\ActiveForm::begin(array('id' => 'deposit-form', 'enableAjaxValidation' => true)); $temp = \yii\helpers\ArrayHelper::map(Accounts::findAllByType(7), 'id', 'name'); $temp[''] = Yii::t('app', 'Choose Bank'); //$model->account_id = 0; ?> <div class='row'> <div class='col-md-3'> <?php echo $form->field($model, "account_id")->widget(Select2::className(), ['data' => $temp]); ?> <?php echo $form->field($model, 'refnum'); ?> <?php echo $form->field($model, 'date')->widget(DateControl::classname(), ['type' => 'date']); ?> </div>
<?php echo $form->field($model, 'details'); ?> <?php echo $form->field($model, 'refnum'); ?> <?php echo $form->field($model, 'sum'); ?> <?php echo $form->field($model, 'currency_id')->widget(kartik\select2\Select2::className(), ['data' => \yii\helpers\ArrayHelper::map(Currates::GetRateList(), 'currency_id', 'name')]); //currency ?> <?php echo $form->field($model, 'account_id')->widget(kartik\select2\Select2::className(), ['data' => \yii\helpers\ArrayHelper::map(Accounts::findAllByType(7), 'id', 'name')]); ?> <div class="form-actions"> <?php echo \yii\helpers\Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => 'btn btn-success']); ?> </div> <?php kartik\form\ActiveForm::end();
use app\models\Language; //use kartik\markdown\MarkdownEditor; $form = kartik\form\ActiveForm::begin(array('id' => 'docs-form', 'enableAjaxValidation' => false, 'enableClientValidation' => false, 'validateOnSubmit' => false, 'options' => array('enctype' => 'multipart/form-data'))); $docnum = $model->getMax($model->doctype) != $model->docType->last_docnum; if ($docnum) { \Yii::$app->getSession()->setFlash('danger', Yii::t('app', 'Document exists please fix last_num Value') . " " . Html::a('Here', yii\helpers\BaseUrl::base() . '/doctype/update/' . $model->doctype)); } $docstatus = ArrayHelper::map(\app\models\Docstatus::find()->where(['doc_type' => $model->doctype])->all(), 'num', 'name'); $currncies = ArrayHelper::map(\app\models\Currates::GetRateList(), 'currency_id', 'name'); $accounts = ArrayHelper::map(\app\models\Accounts::findAllByType($model->docType->account_type), 'id', 'name'); if ($model->doctype == 6) { $accounts1 = ArrayHelper::map(\app\models\Accounts::findAllByType(9), 'id', 'name'); $accounts += $accounts1; } $accounts[0] = Yii::t('app', 'None'); $oppts = ArrayHelper::map(\app\models\Accounts::findAllByType($model->docType->oppt_account_type), 'id', 'name'); $oppts[""] = Yii::t('app', 'None'); //echo $form->dropDownList($model, "[$i]item_id", $oppts); $this->registerJs("var baseAddress='" . yii\helpers\BaseUrl::base() . "';" . "var oppt_account_type=" . (int) $model->docType->oppt_account_type . ";", \yii\web\View::POS_HEAD); $this->registerJsFile(yii\helpers\BaseUrl::base() . '/assets/docs.js', ['depends' => [\yii\web\JqueryAsset::className()]]); ?> <div class="form"> <!-- <p class="note">Fields with <span class="required">*</span> are required.</p>--> <?php echo $form->errorSummary($model); ?> <?php echo $form->field($model, "doctype", ['template' => '{input}'])->hiddenInput(); ?> <?php