Yii Framework Forum: How To Calculate 2 Models Or More In Yii ? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How To Calculate 2 Models Or More In Yii ? how to calculate 2 models or more in yii ? Rate Topic: -----

#1 User is offline   rynd75 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 12-January 13

Posted 18 January 2013 - 01:51 AM

hello all,

i'm new in yii, on my last post, i have learn how to get data from two model in one form, now, i getting curious how to use calculation method within two tables in yii,

for example :
i got 2 tables,

assumption
asmp_id --> PK
asmp_name
asmp_score

cost_variable
var_id --> PK
var_name
var_score
var_qty
var_price
var_tot_price

each assumption (asmp_id) whenever it was selected by user, and according to user need, it could be calculate (+,-,*,/) with the selected value of cost_variable attributes,

for ex :

asmp_id = 1
asmp_name = discount
asmp_val = 25%

asmp_id = 2
asmp_name = tax_rate
asmp_val = 12%


var_id = 1
var_name = drilling machine
var_qty = 2
var_price = 800.000.000
var_tot_price = var_qty * var_price = 1.600.000.000

var_id = 2
var_name = cutting machine
var_qty = 2
var_price = 2.000.000.000
var_tot_price = var_qty * var_price = 4.000.000.000

var_id = 3
var_name = licensing
var_qty = 1
var_price = 150.000.000
var_tot_price = var_qty * var_price = 150.000.000

the question,
1. is it possible for me, when i choose asmp_id = 1 then i need to multiplied it with the sum of (var_id =1 + var_id =2) ? ===> 25% * (1.600.000.000 + 4.000.000) and then the result i displayed the result in a form.
2. meanwhile the first question, the asmp_id = 2 needed to calculate only with var_id = 3 (12% * 150.000.000)
2. if that was possible, how could i do that in yii?




my best regards for all members here,
thx for the attention.. :)
0

#2 User is offline   rynd75 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 12-January 13

Posted 18 January 2013 - 01:54 AM

View Postrynd75, on 18 January 2013 - 01:51 AM, said:

hello all,

i'm new in yii, on my last post, i have learn how to get data from two model in one form, now, i getting curious how to use calculation method within two tables in yii,

for example :
i got 2 tables,

assumption
asmp_id --> PK
asmp_name
asmp_score

cost_variable
var_id --> PK
var_name
var_score
var_qty
var_price
var_tot_price

each assumption (asmp_id) whenever it was selected by user, and according to user need, it could be calculate (+,-,*,/) with the selected value of cost_variable attributes,

for ex :

asmp_id = 1
asmp_name = discount
asmp_val = 25%

asmp_id = 2
asmp_name = tax_rate
asmp_val = 12%


var_id = 1
var_name = drilling machine
var_qty = 2
var_price = 800.000.000
var_tot_price = var_qty * var_price = 1.600.000.000

var_id = 2
var_name = cutting machine
var_qty = 2
var_price = 2.000.000.000
var_tot_price = var_qty * var_price = 4.000.000.000

var_id = 3
var_name = licensing
var_qty = 1
var_price = 150.000.000
var_tot_price = var_qty * var_price = 150.000.000

the question,
1. is it possible for me, when i choose asmp_id = 1 then i need to multiplied it with the sum of (var_id =1 + var_id =2) ? ===> 25% * (1.600.000.000 + 4.000.000) and then the result i displayed the result in a form.
2. meanwhile the first question, the asmp_id = 2 needed to calculate only with var_id = 3 (12% * 150.000.000)
2. if that was possible, how could i do that in yii?




my best regards for all members here,
thx for the attention.. :)


i forget, the user can determined by their selves what operation can they do to the var and assumption, this is where i really get interested in,


my thanks all
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users