Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
Hello All!

I am trying to calculate the warranty on a product.

My setup has a DBF. I am setting the current date (i.e. billing date) by:
Code: Select all
<cms:set bdate="<cms:date format='F d, Y' />" scope="global" />

and displaying it in the DBF using:
Code: Select all
<cms:show bdate />

as the billing date should not be editable. I am relying on the couch cms method wherein the publish date is by default set to the current date.

Below there are two radio buttons having values:
3 Years
7 Years

denoting the warranty on the product.

When a bill is generated the person on the counter will select the warranty (using the radio button). To calculate the warranty I referred to viewtopic.php?f=8&t=10559#p28383. And was able to calculate the date of warranty by:
Code: Select all
For 3 Years:
<cms:date '+3 years -1day' />

For 7 Years:
<cms:date '+7 years -1day' />


I need help to be able to:
1. Display the Warranty expiry date only after selecting the radio option.
2. Saving the Warranty expiry date through the DBF in a datetime editable.
3. Also it would be greate if I could save the Billing date in the DBF in a datetime editable.

Thanks in advance.

Regards,
GenXCoders (Aashish)
Image
where innovation meets technology
1. Display the Warranty expiry date only after selecting the radio option.


This i was able to achieve by the code:
Code: Select all
<!-- Warranty -->
                  <div class="col-md-2">
                     <label for="warranty">Warranty</label>
                     <div class="gxcpl-ptop-10"></div>
                  </div>
                  <div class="col-md-10">
                     <input type="radio" id='three' value="3" name="f_warranty"> 3 Years<br>
                     <input type="radio" id='seven' value="7" name="f_warranty"> 7 Years
                     <cms:hide><cms:input name="warranty" type="bound" /></cms:hide>
                     <div class="gxcpl-ptop-10"></div>
                  </div>
                  <!-- Warranty -->

                  <!-- Warranty Validity -->
                  <div class="col-md-2">
                     <label for="warrantyvalidity">Warranty Validity</label>
                     <div class="gxcpl-ptop-10"></div>
                  </div>
                  <div class="col-md-10">
                     <div name="f_wdate" id='show-three' style='display:none'>
                        <cms:set warranty_three="<cms:date '+3 years -1day' />" />
                        <input name="f_wdate" class="form-control" readonly="1" value="<cms:show warranty_three />">
                     </div>
                     <div name="f_wdate" id='show-seven' style='display:none'>
                        <cms:set warranty_seven="<cms:date '+7 years -1day' />" />
                        <input name="f_wdate" class="form-control" readonly="1" value="<cms:show warranty_seven />">
                     </div>
                     <cms:hide><cms:input name="wdate" type="bound" /></cms:hide>
                     <div class="gxcpl-ptop-10"></div>
                  </div>
                  <!-- Warranty Validity -->


and some script:
Code: Select all
$(document).ready(function() {
            $('input[type="radio"]').click(function() {
               if($(this).attr('id') == 'three') {
                  $('#show-three').show();           
                  $('#show-seven').hide();
               }
               else if($(this).attr('id') == 'seven') {
                  $('#show-seven').show();
                  $('#show-three').hide();
               }
               else {
                  $('#show-three').hide();
                  $('#show-seven').hide();   
               }
            });
         });


But I am not able to save the Warranty Expiry Date and the Billing Date in the CouchCMS Admin Panel in datetime or for tht matter text region also. How can that be achieved?

Regards,
GenXCoders (Aashish)
Image
where innovation meets technology
The method that i employed above just displays on the frontend what needs to be displayed. But in the backend it saves the value for +7years as lapse of warranty.

So the above method does not solve the issue.

Can some one shed some light on the very concept, wherein, When the form in loaded, the current (i.e. todays) date is displayed in a readonly manner (in format: November 08, 2018) and saved in the couch end as a datetime region when the form is submitted.

Regards,
GenXCoders
Image
where innovation meets technology
BUMP!

Any ideas?

@KK Sir and @All Couchies!

1. I have a DBF.
2. On this DBF I need to show Current (i.e. Today) Date in form of label or any way which will not allow the user to change it.
3. But when the form is submitted the Current Date needs to be stored in an editable region defined as:
Code: Select all
<cms:editable name='bdate' label='Billing date' type='datetime' required='1' order='1' />


Problem #1: How can the above be achieved.

==============================================================================

Depending on the Current date above I need to calculate the warranty.
1. In the same DBF warranty date needs to be saved.
2. The warranty can be of 3years or 7years. This I am displaying by the editable region
Code: Select all
<cms:editable name="warranty" label="Warranty" desc="in years" type="radio" opt_values="3 Years=3 || 7 Years=7" order="6" required="1" />

3. If the warranty is selected as "3 Years" then depending on the current date (i.e the bdate) the warranty needs to be calculated. I am performing that calculation as:
Code: Select all
<cms:date '+3 years -1day' />

4. So the resulting date needs to be displayed, again as not editable.
5. when the form is submitted the warranty date should be saved to the backend in the editable region defined as:
Code: Select all
<cms:editable name="wdate" label="Warranty Validity" type="datetime" order="7" />


Problem #2: How can this be done?

==============================================================================

On the DBF all dates need to be displayed in the format F d, Y.

Please guide.

Regards,
GenXCoders (Aashish)
Image
where innovation meets technology
I am posting from mobile so i dont have the reference. But in my quest to find the answer i searched the forum and saw operations on date.

I was curious what is wrong with the following code or is it even allowed?
Code: Select all
<cms:date bdate return='+3 Years -1 Day' />


I am expecting that if bdate is November 09, 2018 then setting above into a variable should return November 08, 2021

But it doesnot.

Please suggest.
Image
where innovation meets technology
5 posts Page 1 of 1
cron