Problems, need help? Have a tip or advice? Post it here.
11 posts Page 1 of 2
Dear All,

Kindly Help me to understand some basic calculation with couch code.

Example if I want to calculate (555+555), (555-555),(my_variable*555),(my_variable/555)


I need some example with coding.

Thanks
Hi,

Please see http://www.couchcms.com/docs/tags-reference/add.html
At the bottom of the page you'll find links to all the other calculation related tags.

Following is an example of using two of those tags namely cms:add and cms:incr
Code: Select all
<!-- sets my_val to '555' -->
<cms:set my_val = '555' />

<!-- prints the result 1110. my_val still remains 555 -->
<cms:add my_val '555' />

<!-- sets my_result to 1110 -->
<cms:set my_result = "<cms:add my_val '555' />" />

<!-- sets my_val to 1110 -->
<cms:set my_val = "<cms:add my_val '555' />" />

<!-- sets my_val to 1112 -->
<cms:incr my_val '2' />

Usage of all other tags would be similar.

A point to keep in mind - we cannot work directly on two literal values e.g.
<cms:add '100' '555' />
would be wrong. The first value has to be a variable, as shown in the examples.

Hope this helps.
Respected, KK
Thanks for your response.
I already read
http://www.couchcms.com/docs/tags-reference/add.html (There is very short description, I want some detail)

You wrote
A point to keep in mind - we cannot work directly on two literal values e.g.
<cms:add '100' '555' />


But if I want to add two (or more) variable like

Code: Select all
<cms:set my_value='11' />
<cms set my_jk='99' />
<cms:add my_value my_jk />


its out put=11 thats mean my_value

is there anyway to solve this. and kindly help me to know can I save those value in database? if yes kindly help me. and also help me to know calulate values from database.

Kindly help me with a data-bound form for an example, and show me some simple and complex calculation. I really need this

thank you.
<cms:set my_value='11' />
<cms set my_jk='99' />
<cms:add my_value my_jk />

its out put=11 thats mean my_value

That is because your second statement has a syntax error.
It should be
<cms:set my_jk='99' />

instead of the current (missing colon between 'cms' and 'set')
<cms set my_jk='99' />

As for saving the values in the database, you can use cms:db_persist tag for that (please see viewtopic.php?f=2&t=8301&p=15104&#p15104)

Hope it helps.
Sorry for interrupt you guys conversation.

I guess you try to make a sales report, or point of sales cashier module, or some accounting page?
As soon as possible!

Touch me up : abada[dot]zulma[at]gmail[dot]com
@ GoingMarryAsap

you are right, if you have any such couch code(sales report, or point of sales cashier module, or some accounting page), kindly send me.
Subhamoy wrote: @ GoingMarryAsap

you are right, if you have any such couch code(sales report, or point of sales cashier module, or some accounting page), kindly send me.


I ever made a report module for my client's Fruts & Vegs Stock web app. The calculation method i use is : "jQuery Calx"

and make a change use :
Code: Select all
cms:db_persist



Or if you want to make a cashier module, you can use "jQuery Autocomplete" for the barcode reader. I learn the code from this app.

You can use :
Code: Select all
<cms:php>#</cms:php>

for executing custom PHP strings.

and

Code: Select all
<cms:query>#</cms:query>

for executing custom SQL queries.

Hope this help ;)
As soon as possible!

Touch me up : abada[dot]zulma[at]gmail[dot]com
Respected KK, & @ GoingMarryAsap

Actually I like to create a project like this

Think, I Have 5 Nos. Service engineer they have to go client side out of station. so They collect
INR 10,000 each from head office for 5 client side.

Now they can expenses like hotel-2000, dinner-500, spare for system 3,000, etc.

Like below Income & Expenditure web sheet for separate engineer .
Here is Mr. S. Gupta' s sheet
ex.jpg
ex.jpg (35.51 KiB) Viewed 2445 times


1. My engineer can update all data using tab or mobile device. (real time)
2. And I also need a web sheet like this so I can view cash in hand amount by engineer-wise.
cash in hand .jpg
cash in hand .jpg (44.43 KiB) Viewed 2440 times


Hope you can understand What I mean.


Thanking you
Subhamoy wrote: Actually I like to create a project like this


Is that only a report view? cos if you want to craft a realtime work project management with couch, it will need a complex php modification. And you cant reach this with couch default admin page. I was create a Databound to act like an admin page for my client's web app.

What i will suggest to you, you need to create 2 types of extended users. 1 is engineer, and 1 is client. Both of it, have an editable region that handle a value (money, stored money on cash drawer). And like i said above, you can use "that" tags to run your custom php and sql query. But you need to remember as KK said that its not secure to update or delete a database stright from frontend, it will cause an exploit.

You can try to search all things about Databound inside this forum, its already discussd.
As soon as possible!

Touch me up : abada[dot]zulma[at]gmail[dot]com
Just wondering .... maybe even stupid...

cos if you want to craft a realtime work project management with couch, it will need a complex php modification.


Isn't it possible to use something like polymer or intercooler.js to work in realtime on the frontend and use the php stuff from couch to work on the server side without big php modifications and having security issues ?
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
11 posts Page 1 of 2