Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
I have an editable region as:
Code: Select all
<cms:editable name='fir_time' label='FIR Time' type='datetime' allow_time='1' show_labels='0' minute_steps="1" only_time="1" order='2' />

Now the value of this region is sent through an app in the form of a querystring parameter. The value of 'fir_time' coming from the form in the mobile in the querystring is not getting saved.

It saves nothing but displays only the current system time. But not the actual value of time.
The data comes in the format:
localhost/ARMAN/rest/receiveFIR.php?hashTokencheck=493765724746473263544474794f523470503763&userid=38&fir_title=7&fir_train_no=567777&fir_loco_no=78766&fir_ohemast=1427& fir_informer_no=1234569870&fir_disaster_image=&fir_date=2019-08-11&fir_time=20:20&fir_lati=20.123456&fir_longi=78.265489&fir_desc=ghjhgfgcf

where fir_time is set to say "fir_time=20:20" but it is not saving.

I am using db_persist. What can i do to save the time?

My db_persist code is:
Code: Select all
<?php require_once( '../couch/cms.php' ); ?>
<?php require_once( 'loginClass.php' ); ?>

<cms:template title='Receive FIR'/>

<cms:set userid="<cms:gpc 'userid' method='get' />" scope="global" />
<cms:set hashToken_url="<cms:gpc 'hashTokencheck' method='get' />" scope="global" />

<cms:if hashToken_url ne "" >
    <cms:if userid ne "">
        <cms:query sql="SELECT as page_id,p.page_name,cu.access_level FROM couch_pages p INNER JOIN couch_users cu on cu.title = p.page_title and = <cms:show userid /> WHERE p.template_id= 3 ">
            <cms:set user_access_level="<cms:show access_level />" scope="global" />
            <cms:set user_page_id="<cms:show page_id />" scope="global" />
            <cms:set user_page_name="<cms:show page_name />" scope="global" />

    <cms:query sql="select COALESCE(count(hashToken),0) as hashcnt,COALESCE(id,0) as userid_set from couch_users where hashToken='<cms:show hashToken_url />' and id='<cms:show userid />'" >
        <cms:if hashcnt eq '1'>
            <cms:set hashToken_verify="1" scope="global" />
        <cms:else_if hashcnt eq '0' />
            <cms:set hashToken_verify="0" scope="global" />

    <cms:if hashToken_verify eq '1' &&  userid ne "">
        <cms:if user_page_id>
            <cms:set page_title="<cms:gpc 'fir_title' method='get' />" scope="global" />
            <cms:set fir_train_no="<cms:gpc 'fir_train_no' method='get' />" scope="global" />
            <cms:set fir_loco_no="<cms:gpc 'fir_loco_no' method='get' />" scope="global" />
            <cms:set fir_date="<cms:gpc 'fir_date' method='get' />" scope='global' />
            <cms:set fir_time="<cms:gpc 'fir_time' method='get' />" scope='global' />
            <cms:set fir_informer_name="<cms:show user_page_id />" scope="global" />
            <cms:set fir_informer_no="<cms:gpc 'fir_informer_no' method='get' />" scope="global" />
            <cms:set fir_disaster_image="<cms:gpc 'fir_disaster_image' method='get' />" scope="global" />
            <cms:set fir_ohemast="<cms:pages masterpage='ohe-mast.php' id="<cms:gpc 'fir_ohemast' method='get' />" limit='1' show_future_entires='1'><cms:show k_page_id /></cms:pages>" scope="global" />
            <cms:set fir_lati="<cms:gpc 'fir_lati' method='get' />" scope="global" />
            <cms:set fir_longi="<cms:gpc 'fir_longi' method='get' />" scope="global" />
            <cms:set fir_desc="<cms:gpc 'fir_desc' method='get' />" scope="global" />

            <cms:content_type 'application/json'/>
                _auto_title         =   '0'
                _invalidate_cache   =   '0'
                _masterpage         =   'generate-fir.php'
                _mode               =   'create'
                k_page_title        =   "<cms:show page_title />"
                k_page_name         =   "<cms:show k_page_title />"
                fir_train_no        =   "<cms:show fir_train_no />"   
                fir_loco_no         =   "<cms:show fir_loco_no />"
                fir_date            =   "<cms:date fir_date format='Y-m-d' />"
                fir_time            =   "<cms:date fir_time format='H:i' />"
                fir_informer_name   =   "<cms:show fir_informer_name />"
                fir_informer_no     =   "<cms:show fir_informer_no />"
                fir_disaster_image  =   "<cms:show fir_disaster_image />"
                fir_ohemast         =   "<cms:show fir_ohemast />"
                fir_lati            =   "<cms:show fir_lati />"
                fir_longi           =   "<cms:show fir_longi />"
                fir_desc            =   "<cms:show fir_desc />"
               <cms:if k_error >
                       <cms:each k_error >
                        "value":<cms:escape_json><cms:show item /><br></cms:escape_json>
                <cms:else />
                      "id":"<cms:show k_last_insert_id />",
                        "title":<cms:escape_json><cms:show page_title /></cms:escape_json>,
                        "fir_time_temp":<cms:escape_json><cms:date fir_time format='H:i' />::<cms:date fir_time_gpc format='H:i' /></cms:escape_json>

    <cms:else />
            "Status":"You are not authenticated"

<cms:else />
        "Status":"Hash Token Missing"
<?php COUCH::invoke(); ?>

How to save the time? in the backend as it is sent from the mobile end.

Also when i access the above URL in POSTMAN in get the following result:
"success": "1",
"id": "2085",
"title": "8",
"fir_time_temp": "20:20"

Here the fir_time_temp is defined as:
Code: Select all
"fir_time_temp":<cms:escape_json><cms:date fir_time format='H:i' /></cms:escape_json>

And it outputs the correct value of the fir_time. But it is not saved in editable.

GenXCoders (Aashish)
where innovation meets technology

All dates are stored internally by Couch in a single format ('Y-m-d H:i:s' format e.g. 2019-05-30 21:35:54).
Although the specific region you are using is configured to show only the 'time' component, it is no exception to the rule above - it internally adds '1970-01-01' as the 'date' component so as to conform to the format,

In your code where you are currently using the following -
Code: Select all
    fir_time = "<cms:date fir_time format='H:i' />"

- please try formatting the input date as this instead:
Code: Select all
    fir_time = "<cms:date fir_time format='1970-01-01 H:i:00' />"

Hope it helps.
@KK Sir

it internally adds '1970-01-01' as the 'date' component so as to conform to the format

Yes I was aware about this fact. Had seen the same in the core couch code once. It never crossed my mind to handle it this way.
Hope it helps.

As always sir it helps! I am thankful to you for the finishing touches to my code! Your guidance always sorts my troubles. Thanks a lot sir.

It is now working as expected. The data comes in from the mobile and is saved in to the editable as expected.

GenXCoders (Aashish)
where innovation meets technology
3 posts Page 1 of 1

Who is online

In total there are 8 users online :: 0 registered, 0 hidden and 8 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 8 guests