CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Multi-table dynamic fields custom insert

Print topic Send  topic

Author Message
Aleister

Posts: 73
Posted: 01/19/2010, 1:37 PM

Hello,

I am building an application in which every day is considered a new record. For every day we need to keep all income and expenses of a company. For every day a set of "dynamic" fields needs to be inserted, by dynamic I mean that at this time we might have (fuel, rentals, car expenses) and in the future we need to add more fields (mobile phones payments, electric bills e.t.c.). All of this, I need to be displayed in one screen (add / edit / delete / view).

So, starting with expenses, I am thinking of implementing it like this :
- Table dailyexpenses (*id (autoinc), recdate(date))
- Table availfields(*id (autoinc), name(char(255)))
- Table dailyexpenses_has_availfields (*id (autoinc), dailyexpenses_id(ref), availfields_id(ref), amount)

The thing is that I need to display every possible field of "availfields" in one screen so the user can select where he needs to enter a value and what to leave blank:

-- January 19, 2010 --
fuel:
rentals:
car expenses:
mobile phones payments:
electric bills:

and so on...

Every filled amount will create a record in dailyexpenses_has_availfields but blank amounts will not.

Then he will be able to edit the above, erase an amount e.t.c.

Does anyone have any ideas of how to implement that? For starters, how can I display a textbox after each payment type, and how to get its contents so I can insert them to database after user submits the form?

Thank you.
View profile  Send private message
datadoit
Posted: 01/19/2010, 2:24 PM

Aleister wrote:
> Does anyone have any ideas of how to implement that? For starters, how can I
> display a textbox after each payment type, and how to get its contents so I can
> insert them to database after user submits the form?
>
> ---------------------------------------

Let's focus on the CodeCharge specific issues you may have...

Are you wanting the textbox to only display at certain times, such as if
there's a value entered or selected in the Payment Type field?
Aleister

Posts: 73
Posted: 01/19/2010, 2:50 PM

No, I want every available field in "availfields" to be displayed so the user can select where to enter an amount. In edit mode the user will see the amounts he entered and all the unfilled as blank.

I could do it the easy way like "add payment -> select type -> enter amount -> submit" but I need it all to be in one screen like filing a form on paper.
View profile  Send private message
datadoit
Posted: 01/19/2010, 4:30 PM

Understood. So what exactly is not working?
Aleister

Posts: 73
Posted: 01/20/2010, 1:25 AM

I am looking for a way to display dynamic custom textboxes in a record (for start) without defining them by hand in CCS because I don't know how many are they.

So, in other words, how to create a dynamic record. Feed the captions from table A, create empty textbox after each caption and then, after submit, read the value of each textbox and insert them to table B, all from a CCS record.

I know that I can create an out-of-ccs custom class to create the captions and textboxes, put them on a label in the record and get their values after post manually but if I can solve it using CCS would be better because then I can use CCS's validation and events.
View profile  Send private message
quasimidi


Posts: 151
Posted: 01/20/2010, 4:23 AM

I hope I understand your question correctly: there is no way to create records, grids, fields dynamically. CCS framework has no support for that. :(
_________________
RS
View profile  Send private message
Aleister

Posts: 73
Posted: 01/20/2010, 7:00 AM

Thank you quasimidi, yes, that is what I am trying to do.

I know that ccs does not "officially" support that but I am sure there is a way around this limitation and was wondering if someone implemented something like this before.

If not, I am sure going to try.
View profile  Send private message
quasimidi


Posts: 151
Posted: 01/20/2010, 7:12 AM

Quote Aleister:
Thank you quasimidi, yes, that is what I am trying to do.

I know that ccs does not "officially" support that but I am sure there is a way around this limitation and was wondering if someone implemented something like this before.

If not, I am sure going to try.

It is possible, however you have to rewrite the main classes in the Common and Classes php.
Don't bother it friend, it could be a nightmare to update and optimize the code later. I tried that once... :(
_________________
RS
View profile  Send private message
datadoit
Posted: 01/20/2010, 7:54 AM

If you can do it in your chosen language (ie PHP) then you can do it in
CodeCharge. You can put your code in the page's BeforeShow, or drop on
a label and do it in the BeforeShow there. The label merely creates the
object for which you can assign events to. You can still use many of
the CCS built-in classes in your custom code. Ex: Connections,
CCGetSession(), etc.etc.

I think that's the most underreported, best feature of CodeCharge. The
question shouldn't be whether CodeCharge can do it, but rather can my
preferred language do it. CCS can make things easier by automating many
tasks, but it doesn't inhibit anything anywhere that I can find.

Google around to see if someone has posted a PHP solution for dynamic
fields and tables. I'll do the same. If something is found, then we'll
CodeChargisize it.
Aleister

Posts: 73
Posted: 01/20/2010, 11:28 AM

Quote datadoit:
Google around to see if someone has posted a PHP solution for dynamic
fields and tables. I'll do the same. If something is found, then we'll
CodeChargisize it.
It's much more simple than this, it is not dynamic database fields, the tables are not going to be altered, it is just dynamic creation and display of textboxes without losing ccs functionality (events, validation e.t.c.)
View profile  Send private message
Aleister

Posts: 73
Posted: 01/20/2010, 3:05 PM

From my first tests, it is easily doable, the way to do it is unorthodox, but it's doable. For it to be easily maintainable, the record is in an includable page.

It needs to edit ccs generated source in 10 places (in my test), add a template variable and a couple of custom lines of code in before show page to push the display code to template var.

The main idea is to create a textbox (textbox1) and make it function the way you want using ccs. Then, after each line -in generated code- it references textbox1 you enter your extra fields following what you see textbox1 declares. At the end, just delete all references of textbox1. We need to customize only the page we need this functionality (no changes to common.php etc) and - I believe - it will be easy to remake the page even if ccs change completely the way it handles textboxes, for minor ccs changes a source compare with the original will guide us very easily.

Validation works fine, I didn't try events yet but they will work one way or another.

So, so easy. Now I need to put it in real use and see how it works.
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.