/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Currates::findOne($id); if ($model === null) { throw new \yii\web\HttpException(404, 'The requested page does not exist.'); } return $model; }
//echo $form->error($model, 'refnum1'); ?> <?php //echo $form->labelEx($model, 'refnum2'); ?> <?php //echo $form->error($model, 'refnum2'); ?> <?php //echo $form->labelEx($model, 'currency_id'); ?> <?php echo $form->field($model, 'currency_id')->widget(Select2::className(), ['data' => \yii\helpers\ArrayHelper::map(Currates::GetRateList(), 'currency_id', 'name')]); ?> <?php //echo $form->error($model, 'currency_id'); ?> </div> </div> <div class="row"> <div class="col-md-12"> <table class="formy"> <tbody> <tr> <th class="header"><?php echo Yii::t('app', "Account"); ?> </th>
<div class="form"> <?php use yii\helpers\ArrayHelper; use kartik\select2\Select2; $form = kartik\form\ActiveForm::begin(array('id' => 'accounts-form' . $model->type, 'options' => array('enctype' => 'multipart/form-data'))); $id6111 = ArrayHelper::map(\app\models\AccId6111::find()->All(), 'id', 'name'); $id6111[0] = Yii::t('app', 'None'); $currncies = ArrayHelper::map(\app\models\Currates::GetRateList(), 'currency_id', 'name'); $accounts = ArrayHelper::map(\app\models\Accounts::find()->all(), 'id', 'name'); $accounts[0] = Yii::t('app', 'None'); $acccat = ArrayHelper::map(\app\models\AccCat::find()->where(["type_id" => $model->type])->all(), 'id', 'name'); ?> <?php echo $form->errorSummary($model); ?> <?php echo $form->field($model, 'type', ['template' => '{input}'])->hiddenInput(); ?> <div class="col-md-4 col-sm-6"> <?php app\widgets\TbPanel::begin(array('header' => Yii::t('app', "Account General Details"))); ?> <?php echo $form->field($model, 'name'); ?> <?php echo $form->field($model, 'cat_id')->dropDownList($acccat); ?>
public function beforeSave($insert) { $this->num = $this->newNum(); if ($this->reg_date == null) { $this->reg_date = date("Y-m-d H:i:s"); } $cur = \app\helpers\Linet3Helper::getSetting('company.cur'); $acc = Accounts::findOne($this->account_id); if ($acc === null) { $acccur = $this->currency_id; } else { $acccur = $acc->currency_id; } if ($this->currency_id == '') { $this->currency_id = $cur; $this->sum = $this->leadsum; } //leadsum if ($cur == $this->currency_id) { $this->leadsum = $this->sum; } else { $rate = Currates::GetRate($this->currency_id, $this->valuedate); $this->leadsum = $this->sum * $rate; } //set sum accourding to acc if (!isset($this->sum)) { //adam need to dubl chk if ($this->currency_id != $acccur) { $this->currency_id = $acccur; $rate = Currates::GetRate($acccur, $this->valuedate); if ($rate == 0) { throw new \Exception(Yii::t('app', 'The rate for') . $this->currency_id . Yii::t('app', 'is invalid')); } $this->sum = $this->leadsum / $rate; } } //secsum $seccur = \app\helpers\Linet3Helper::getSetting('company.seccur'); //$seccur = Yii::$app->user->settings['company.seccur']; if ($seccur != '') { if ($seccur == $this->currency_id) { $this->secsum = $this->sum; } else { $rate = Currates::GetRate($this->currency_id, $this->valuedate); if ($rate == 0) { throw new \Exception(Yii::t('app', 'The sec rate for') . $seccur . $this->currency_id . Yii::t('app', 'is invalid')); } $this->secsum = $this->leadsum / $rate; } } return true; }
echo $form->field($model, "[{$i}]doc_id")->hiddenInput(); ?> <?php echo $form->field($model, "[{$i}]line")->hiddenInput(); ?> <b><?php //echo $form->labelEx($model, 'type'); ?> </b> <?php //Doctype::getList() $temp = \app\models\PaymentType::getList(); $temp[0] = Yii::t('app', 'None'); $curr = \yii\helpers\ArrayHelper::map(\app\models\Currates::GetRateList(), 'currency_id', 'name'); echo $form->field($model, "[{$i}]type")->dropDownList($temp); ?> </td> <td id="Doccheques_<?php echo $i; ?> _text"></td> <td><b><?php //echo $form->labelEx($model, 'currency_id'); ?> </b><?php echo $form->field($model, "[{$i}]currency_id")->dropDownList($curr); ?>
<?php echo $form->field($model, 'purchaseprice'); ?> <?php echo $form->field($model, 'profit'); ?> <?php echo $form->field($model, 'itemVatCat_id')->dropDownList(ArrayHelper::map(ItemVatCat::find()->asArray()->all(), 'id', 'name')); ?> <?php echo $form->field($model, 'saleprice'); ?> <?php echo $form->field($model, 'currency_id')->dropDownList(ArrayHelper::map(Currates::GetRateList(), 'currency_id', 'name')); ?> <?php TbPanel::end(); ?> </div> <div class="col-md-4 col-sm-6"> <?php TbPanel::begin(array('header' => Yii::t('app', "EAV Fields"))); ///* echo app\widgets\eavProp::Widget(array('model' => $model, 'name' => get_class($model), 'attr' => $model->getEavAttributes())); //*/ TbPanel::end(); ?> <?php
private function ini() { if ($this->valuedate == null) { $this->valuedate = Record::writeDate(time()); } if (!$this->ini) { $this->_precision = Yii::$app->params['precision']; $item = Item::findByPk($this->item_id, $this->valuedate); if (is_null($item)) { $this->iVatRate = 0; } else { $this->iVatRate = $item->vat; } //for vat resons... //if ($this->rate == 0) { $this->rate = Currates::GetRate($this->currency_id, $this->valuedate); //} if ($this->doc_rate == 0) { $doc = Docs::findOne($this->doc_id); $this->doc_rate = Currates::GetRate($doc->currency_id, $this->valuedate); } $this->ini != $this->ini; } }
public function GetRateForDate($id, $date) { $criteria = new CDbCriteria(); $criteria->select = 'value'; $criteria->addColumnCondition(array('currency_id' => $id)); $criteria->addColumnCondition(array('date' => $date)); $model = Currates::model(); $value = $model->commandBuilder->createFindCommand($model->tableName(), $criteria)->queryScalar(); return $value; }