So i have decided to use a session to carry the request id to the LOAD page
to open the form with the name of the company whose link was clicked! I do
not know if this is the best solution or i'm just reaching but it is
working right now! I just dont know if in the long run it will fall apart
maye because of something i dont know about sessions & I have applied them
in the wrong way! Please advice me if i'm doing nonsense, your guidance
will be most appreciated!
This is what i did in the controller:
def quotation():
response.flash = T("PLEASE UNDERSTAND THAT ALL THE QUOTED ITEMS WILL BE
ENTERED AND QUOTED ONE ITEM AT A TIME")
* session.quotation=db.Client_Details(request.args(0, cast=int))*
return locals()
def quotationLoad():
* db.quotation.customer.default=session.quotation.id*
form=SQLFORM(db.quotation)
if form.process().accepted:
response.flash=T('Client Quoted')
return locals()
The views remained the same
*VIEW*
{{extend 'layout.html'}}
<script>
$(document).ready(function() {
var interval = setInterval(function() {
var momentNow = moment();
$('#date-part').html(momentNow.format('DD MMMM YYYY') + ' '+
momentNow.format('dddd').substring(0,3).toUpperCase());
$('#time-part').html(momentNow.format('hh:mm:ss A'));
}, 100);
});
</script>
{{block header}}
<div class="jumbotron jumbotron-fluid" style="background-color: #333;
color:white; padding:30px;word-wrap:break-word;">
<div class="container center">
<div class="appLogo2">PIQ v1.0</div>
<div id="loginDetails">
<span id='date-part'></span> | <span id="time-part"></span> | <span
id="user" >Logged In User: {{if auth.user:}}{{=auth.user.first_name}} {{=
auth.user.last_name}}</span> <span id="logout" class="glyphicon
glyphicon-log-out">{{=A('LOGOUT', _id="logingOut", _class="btn btn-info
btn-lg", _href=URL('default', 'user', args='logout'))}}</span>
{{pass}}
</div>
</div>
</div>
{{end}}
<div id="bookings" style="border: solid 2px grey; border-radius: 10px;
box-shadow: 10px 8px #888888; padding: 10px;">
<div id="viewQuotation">
* {{=A('View Quotation', _href=URL('View_Quotation',
args=session.quotation.id))}}*
</div>
<div id="quote" class="formTitle">QUOTE A CLIENT</div>
<div style="border: solid 1px red; border-radius: 10px; padding: 2px;
font-style: italic; font-weight: bold;">
<center>You are advised to Quote up to a maximum of 20 items in a
single Quotation for a clear and readable Quotation.</center>
</div>
<br />
*{{=LOAD('default', 'quotationLoad.load', ajax=True)}}</div>*
</div>
<button onclick="topFunction()" id="myBtn" title="Go to top">TOP</button>
*LOAD*
*{{=form}}*Regards;
Mostwanted
On Thursday, January 23, 2020 at 9:00:37 PM UTC+2, mostwanted wrote:
>
> What i'm trying to achieve is to select a company by clicking a link and
> have a form open up with thee selected company name for the client to fill
> up the form for that company & submit it. But I am using LOAD to take
> advantage of ajax and prevent a page reload. The problem i am facing is
> that in using LOAD the form does not open with the company name, it says a
> company has not been selected and company name in the DB is set to NULL!
>
> *CONTROLLER*
> def quotation():
> response.flash = T("PLEASE UNDERSTAND THAT ALL THE QUOTED ITEMS WILL
> BE ENTERED AND QUOTED ONE ITEM AT A TIME")
> quotation=db.Client_Details(request.args(0, cast=int))
> db.quotation.customer.default=quotation.id
> return locals()
>
> def quotationLoad():
> form=SQLFORM(db.quotation)
> if form.process().accepted:
> response.flash=T('Client Quoted')
> return locals()
>
>
> *LOAD PAGE*
> {{=form}}
>
>
> *VIEWS*
> {{extend 'layout.html'}}
>
> <script>
> $(document).ready(function() {
> var interval = setInterval(function() {
> var momentNow = moment();
> $('#date-part').html(momentNow.format('DD MMMM YYYY') + ' '+
> momentNow.format('dddd').substring(0,3).toUpperCase());
> $('#time-part').html(momentNow.format('hh:mm:ss A'));
> }, 100);
> });
> </script>
>
> {{block header}}
> <div class="jumbotron jumbotron-fluid" style="background-color: #333;
> color:white; padding:30px;word-wrap:break-word;">
> <div class="container center">
> <div class="appLogo2">PIQ v1.0</div>
> <div id="loginDetails">
> <span id='date-part'></span> | <span id="time-part"></span> | <span
> id="user" >Logged In User: {{if auth.user:}}{{=auth.user.first_name}} {{=
> auth.user.last_name}}</span> <span id="logout" class="glyphicon
> glyphicon-log-out">{{=A('LOGOUT', _id="logingOut", _class="btn btn-info
> btn-lg", _href=URL('default', 'user', args='logout'))}}</span>
> {{pass}}
>
> </div>
> </div>
> </div>
> {{end}}
> <div id="bookings" style="border: solid 2px grey; border-radius: 10px;
> box-shadow: 10px 8px #888888; padding: 10px;">
> <div id="quote" class="formTitle">QUOTE A CLIENT</div>
> <div style="border: solid 1px red; border-radius: 10px; padding: 2px;
> font-style: italic; font-weight: bold;">
> <center>You are advised to Quote up to a maximum of 20 items in a
> single Quotation for a clear and readable Quotation.</center>
> </div>
> <br />
> *{{=LOAD('default', 'quotationLoad.load', ajax=True)}}</div>*
> <button onclick="topFunction()" id="myBtn" title="Go to top">TOP</button>
>
> I am not sure if my question is clear, but if I could achieve this it
> would be great for my application. Or alternatively help me find a way to
> prevent my page from scrolling back to top everytime a page refreshes after
> submitting a form.
>
> Regards;
>
> Mostwanted
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/1278759b-a226-4cbd-b4db-478166e3d833%40googlegroups.com.