Example #1
0
 private function ini()
 {
     if (!$this->ini) {
         $this->_precision = Yii::app()->user->getSetting('company.precision');
         $this->iVatRate = Item::model()->findByPK($this->item_id)->vat;
         $this->rate = Currates::model()->GetRate($this->currency_id);
         if ($this->doc_rate == 0) {
             $doc = Docs::model()->findByPk($this->doc_id);
             $this->doc_rate = Currates::model()->GetRate($doc->currency_id);
         }
         $this->ini != $this->ini;
     }
 }
Example #2
0
                <?php 
echo $form->textFieldRow($model, 'purchaseprice', array('maxlength' => 8));
?>
                <?php 
echo $form->textFieldRow($model, 'profit');
?>
                <?php 
echo $form->dropDownListRow($model, 'itemVatCat_id', CHtml::listData(ItemVatCat::model()->findAll(), 'id', 'name'));
?>
            
                <?php 
echo $form->textFieldRow($model, 'saleprice', array('maxlength' => 8));
?>
	
                <?php 
echo $form->dropDownListRow($model, 'currency_id', CHtml::listData(Currates::model()->GetRateList(), 'currency_id', 'name'));
?>
            <?php 
$this->endWidget();
?>
            
        </div>
        <div class="col-md-4 col-sm-6">
            <?php 
$this->beginWidget('TbPanel', array('header' => Yii::t('app', "EAV Fields")));
$this->Widget('application.modules.eav.components.eavProp', array('name' => get_class($model), 'attr' => $model->getEavAttributes()));
$this->endWidget();
?>
            <?php 
?>
            <?php 
Example #3
0
 /**
  * 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::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #4
0
$temp = PaymentType::model()->getList();
$temp[0] = Yii::t('app', 'None');
echo $form->dropDownList($model, "[{$i}]type", $temp);
?>
    </td>
    <td id="Doccheques_<?php 
echo $i;
?>
_text"></td>


    <td><b><?php 
echo $form->labelEx($model, 'currency_id');
?>
</b><?php 
echo $form->dropDownList($model, "[{$i}]currency_id", CHtml::listData(Currates::model()->GetRateList(), 'currency_id', 'name'), array('class' => 'currSelect'));
?>
</td>
    <td><b><?php 
echo $form->labelEx($model, 'sum');
?>
</b><?php 
echo $form->textField($model, "[{$i}]sum", array('class' => 'rcptsum', 'placeholder' => Yii::t('label', 'sum')));
?>
</td>
    
    <td class="remove">
        <?php 
$this->widget('bootstrap.widgets.TbButton', array('label' => Yii::t('app', 'Remove'), 'icon' => 'glyphicon glyphicon-remove'));
?>
Example #5
0
 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;
 }
Example #6
0
 public function beforeSave()
 {
     $this->num = $this->newNum();
     if ($this->reg_date == null) {
         $this->reg_date = date("Y-m-d H:i:s");
     }
     $cur = Yii::app()->user->settings['company.cur'];
     $acc = Accounts::model()->findByPk($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::model()->GetRate($this->currency_id);
         $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::model()->GetRate($acccur);
             if ($rate == 0) {
                 throw new CHttpException(404, Yii::t('app', 'The rate for') . $this->currency_id . Yii::t('app', 'is invalid'));
             }
             $this->sum = $this->leadsum / $rate;
         }
     }
     //secsum
     $seccur = Yii::app()->user->settings['company.seccur'];
     if ($seccur != '') {
         if ($seccur == $this->currency_id) {
             $this->secsum = $this->sum;
         } else {
             $rate = Currates::model()->GetRate($this->currency_id);
             if ($rate == 0) {
                 throw new CHttpException(404, Yii::t('app', 'The sec rate for') . $seccur . $this->currency_id . Yii::t('app', 'is invalid'));
             }
             $this->secsum = $this->leadsum / $rate;
         }
     }
     return true;
 }