public function getCurrency()
 {
     $this->setSession(Yii::app()->session);
     if (!isset($this->session['payment_dcurrency'])) {
         $this->setCurrency(CurrencyType::model()->getDefaultCurr()->code);
     }
     return $this->session['payment_dcurrency'];
 }
 protected function sessionInfo($data = array())
 {
     //$data=array();
     $data['cust_fullname'] = '';
     $data['items'] = Yii::app()->wshoppingCart->getCart();
     $data['count_item'] = Yii::app()->wshoppingCart->getQuantityTotal();
     $data['qtytotal'] = Yii::app()->wshoppingCart->getQuantityTotal();
     $data['payments'] = Yii::app()->wshoppingCart->getPayments();
     $data['count_payment'] = count(Yii::app()->wshoppingCart->getPayments());
     $data['payment_received'] = Yii::app()->wshoppingCart->getPaymentsTotal();
     $data['sub_total'] = 0;
     $data['sub_total_mc'] = Yii::app()->wshoppingCart->getSubTotalMC();
     //$data['sub_total_usd'] = Yii::app()->wshoppingCart->getSubTotal()[0];
     //$data['sub_total_khr'] = Yii::app()->wshoppingCart->getSubTotal()[1];
     //$data['sub_total_thb'] = Yii::app()->wshoppingCart->getSubTotal()[2];
     //$data['total_usd'] = Yii::app()->wshoppingCart->getTotal()[0];
     //$data['total_khr'] = Yii::app()->wshoppingCart->getTotal()[1];
     //$data['total_thb'] = Yii::app()->wshoppingCart->getTotal()[2];
     $data['total_mc'] = Yii::app()->wshoppingCart->getTotalMC();
     $data['total_due'] = Yii::app()->wshoppingCart->getTotalDue();
     $data['amount_change'] = Yii::app()->wshoppingCart->getAmountDue();
     $data['customer_id'] = Yii::app()->wshoppingCart->getCustomer();
     $data['comment'] = Yii::app()->wshoppingCart->getComment();
     $data['employee_id'] = Yii::app()->session['employeeid'];
     $data['transaction_date'] = date('d/m/Y');
     $data['transaction_time'] = date('h:i:s');
     $data['session_sale_id'] = Yii::app()->wshoppingCart->getSaleId();
     $data['employee'] = ucwords(Yii::app()->session['emp_fullname']);
     $data['total_discount'] = Yii::app()->wshoppingCart->getTotalDiscount();
     //$data['discount_amt_usd'] = $data['sub_total_usd'] * $data['total_discount']/100;
     //$data['discount_amt_khr'] = $data['sub_total_khr'] * $data['total_discount']/100;
     //$data['discount_amt_thb'] = $data['sub_total_thb'] * $data['total_discount']/100;
     $data['disable_editprice'] = Yii::app()->user->checkAccess('sale.editprice') ? false : true;
     $data['disable_discount'] = Yii::app()->user->checkAccess('sale.discount') ? false : true;
     $data['colspan'] = Yii::app()->settings->get('sale', 'discount') == 'hidden' ? '3' : '4';
     // Customer Account Info
     $data['account'] = $this->custAccountInfo($data['customer_id']);
     $data['currency_type'] = CurrencyType::model()->getActiveCurrency();
     $data['selected_currency'] = CurrencyType::model()->getSelectedCurrency(Yii::app()->wshoppingCart->getCurrency());
     //$data['currency_array'] = CurrencyType::model()->getActiveCurArr();
     /*
     foreach($data['currency_type'] as $record) {
         $currency[] = $record->code;
     }
     $data['currency'] = $currency;
      * 
     */
     //$data['cust_fullname'] = $account !== null ? $account->name : '';
     //$data['acc_balance'] = $account !== null ? $account->current_balance : '';
     return $data;
 }
Пример #3
0
 public function getTotalDue()
 {
     $currency_type = CurrencyType::model()->getActiveCurrency();
     $total_data = array();
     $total_mc = array();
     foreach ($currency_type as $i => $currency) {
         $total_ = 0;
         foreach ($this->getCart() as $item) {
             if ($item['currency_id'] == $currency->currency_id) {
                 $total_ += Common::calDiscount($item['discount'], $item['price'], $item['quantity']);
             }
         }
         $account = Account::model()->getAccountByCurType($this->getCustomer(), $currency->code);
         if ($account) {
             foreach ($account as $acc) {
                 $total_ = $acc['current_balance'] + $total_;
             }
         }
         foreach ($this->getPayments() as $payment) {
             if ($currency->code == $payment["currency_code"]) {
                 $total_ = $total_ - $total_ * $this->getTotalDiscount() / 100 - $payment["payment_amount"];
             }
         }
         //$total_ = $total_ - $total_*$this->getTotalDiscount()/100;
         $total_data = array((int) $currency->code => array('currency_code' => $currency->code, 'currency_id' => $currency->currency_id, 'currency_symbol' => $currency->currency_symbol, 'total' => $total_));
         $total_mc += $total_data;
     }
     return $total_mc;
 }
Пример #4
0
<?php

foreach ($values as $key => $val) {
    ?>
    <div class="form-group"> 
        <?php 
    echo CHtml::label($model->getAttributesLabels($key), $key, array('class' => 'col-sm-3 control-label no-padding-right'));
    ?>
        <div class="col-sm-9">
        <?php 
    if ($key === 'currencySymbol' || $key === 'altcurrencySymbol') {
        echo CHtml::dropDownList(get_class($model) . '[' . $category . '][' . $key . ']', $val, CurrencyType::model()->getCurrency());
    } elseif ($key == 'priceTax') {
        echo CHtml::checkBox(get_class($model) . '[' . $category . '][' . $key . ']', $val);
        echo '<span class="lbl"></span>';
    } else {
        echo CHtml::textField(get_class($model) . '[' . $category . '][' . $key . ']', $val, array('class' => 'col-xs-10 col-sm-5'));
    }
    ?>
        <?php 
    echo CHtml::error($model, $category);
    ?>
        </div>    
    </div>
<?php 
}
Пример #5
0
                    <?php 
//echo TbHtml::alert(TbHtml::ALERT_COLOR_ERROR,'');
?>

                    <?php 
//echo $form->textFieldControlGroup($model,'total_due',array('class'=>3,'disabled'=>true,'value'=>$balance));
?>

                    <?php 
echo $form->textFieldControlGroup($model, 'payment_amount', array('class' => '3 payment-amount-txt', 'autocomplete' => 'off'));
?>

                    <div class="form-group">
                        <div class="col-sm-3">
                            <?php 
echo $form->dropDownList($model, 'payment_type', CurrencyType::model()->getCurrency(), array('id' => 'currency_type_id', 'options' => array($selected_currency->code => array('selected' => true)), 'class' => 'col-xs-10 col-sm-8'));
?>
                        </div>
                        <div class="col-sm-9">
                             <span class="input-icon">
                                <?php 
echo $form->textField($model, 'payment_amount', array('class' => 'input-large text-center payment-amount-txt', 'id' => 'payment_amount_id', 'data-url' => Yii::app()->createUrl('wholeSale/AddPayment/'), 'placeholder' => Yii::t('app', 'Payment Amount') . ' ' . $selected_currency->currency_symbol));
?>
                                 <i class="ace-icon fa fa-money green"><?php 
echo $selected_currency->currency_symbol;
?>
</i>
                             </span>
                        </div>
                    </div>
Пример #6
0
 public function updateAccount($client_id, $client_fname)
 {
     $currency_type = CurrencyType::model()->getActiveCurrency();
     foreach ($currency_type as $currency) {
         $account = Account::model()->find('client_id=:client_id and currency_code=:currency_code', array(':client_id' => $client_id, ':currency_code' => $currency->code));
         if ($account) {
             $account->name = $client_fname;
             $account->save();
         } else {
             $this->saveAccount($client_id, $client_fname, $currency->code);
         }
     }
 }
Пример #7
0
 public function getCurrencyCode()
 {
     $model = CurrencyType::model()->findAll();
     $list = CHtml::listData($model, 'code', 'CurrencyInfo');
     return $list;
 }
Пример #8
0
 public function getSelectedCurrency($code)
 {
     $currency_type = CurrencyType::model()->find(array('condition' => 'code=:code and status=:status', 'params' => array(':code' => $code, ':status' => '1')));
     return $currency_type;
 }
 protected function sessionInfo($data = array())
 {
     $model = new SalePayment();
     $data['model'] = $model;
     $data['cust_fullname'] = 'Not Set';
     $data['client_id'] = Yii::app()->paymentCart->getClientId();
     $data['employee_id'] = Yii::app()->session['employeeid'];
     $data['currency_code'] = Yii::app()->paymentCart->getCurrency();
     $data['currency_type'] = CurrencyType::model()->getActiveCurrency();
     $data['selected_currency'] = CurrencyType::model()->getSelectedCurrency($data['currency_code']);
     if ($data['client_id'] !== null) {
         $data['account'] = Account::model()->getAccountInfo($data['client_id']);
         $data['save_button'] = false;
         foreach ($data['account'] as $acc) {
             if ($acc['currency_code'] == $data['currency_code']) {
                 $data['balance'] = $acc['current_balance'];
                 $data['cust_fullname'] = $acc['name'];
             }
         }
     } else {
         $data['balance'] = 0;
         $data['save_button'] = true;
     }
     return $data;
 }
	    <?php 
echo $form->textFieldControlGroup($model, 'name', array('class' => 'span3', 'maxlength' => 100));
?>
        
        <?php 
echo $form->textFieldControlGroup($model, 'isbn', array('class' => 'span3', 'maxlength' => 100));
?>
        
        <div class="unittype-wrapper" style="display:none">    
            <?php 
//echo $form->textFieldControlGroup($model,'sub_quantity',array('class'=>'span2','prepend'=>'$'));
?>
        </div>
        
        <?php 
echo $form->dropDownListControlGroup($model, 'currency_code', CurrencyType::model()->getCurrencyCode(), array('class' => 'span3'));
?>
        
        <?php 
echo $form->textFieldControlGroup($model, 'cost_price', array('class' => 'span3'));
?>
        
        <?php 
echo $form->dropDownListControlGroup($model, 'profit_margin_id', ProfitMargin::model()->getProfitMargin(), array('class' => 'span3', 'empty' => '-- Select Profit Margin --', 'data-url' => Yii::app()->createUrl('item/f5pricetier')));
?>

	    <?php 
//echo $form->textFieldControlGroup($model,'unit_price',array('class'=>'span3'));
?>
        
        <div id="pricetier_cart">