I have two tables set up and i want to show the TimeCard with all the
entries for said time card however im unsure of how to create such a view...
CONTOLLER:
def timecard_index():
tcrows =db(db.timecard).select(orderby=~db.timecard.tc_date)
tcinputs =db(db.timecard_entry).select(orderby=db.timecard_entry.timecard)
return locals()
MODEL:
db.define_table('timecard',
Field('tc_date','date'),
Field('employee', 'reference
employee',requires=IS_IN_DB(db,'employee.id','%(fname)s %(lname)s')),
Field('myid', unique=True, compute=lambda r: str(r.tc_date) +
str(r.employee))
)
db.define_table('timecard_entry',
Field('timecard', 'reference timecard', readable=False,
writable=False,),
Field('company', 'reference company', label='Company'),
Field('tc_start', 'time', requires=[IS_TIME(),IS_NOT_EMPTY()],
label='Start'),
Field('tc_stop', 'time', requires=[IS_TIME(),IS_NOT_EMPTY()],
label='Stop'),
Field('st' , 'double', label='ST', default=0.0),
Field('ot' , 'double', label='OT', default=0.0),
Field('dt' , 'double', label='DT', default=0.0),
Field('tc_classification' ,'string', label='Classification'),
auth.signature)
VIEW:
{{for timecard in tcrows:}}
<div class="well">
<table>
<tr><td><strong>{{=A(timecard.employee.fname +'
'+timecard.employee.lname,_href=URL('view_timecard',args=timecard.id))}}
{{=timecard.tc_date.strftime("%m.%d.%Y")}}</strong></td></tr>
{{for timecard_entry in tcinputs:}}
<tr><td>{{=timecard_entry.company.name}}</td><td>{{=timecard_entry.tc_start}}</td><td>{{=timecard_entry.tc_stop}}</td><td>{{=timecard_entry.st}}</td><td>{{=timecard_entry.ot}}</td><td>{{=timecard_entry.dt}}</td><td>{{=timecard_entry.tc_classification}}</td></tr>
{{pass}}
</table>
</div>
{{pass}}
This results in the same entries being put into each timecard (not the
correct ones), I know I'm missing something in the logic but I'm too green
of a programmer to see it... Im also not sure if im making the correct
query for tcinputs...
--
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].
For more options, visit https://groups.google.com/groups/opt_out.