Forums

store credit and buy services forms

Attila16881 20 Aug, 2009
I have to create 2 kind of forms.
The first one where the administrator assigns a credit to a user; the admin insert the email of the user and the credit to charge:

Client e-mail: textbox
Client Credit: textbox
captcha: imagever
submit button

when the form is sent the credit must be stored/updated in a db table:

user_email (manual inserted in the form it is the same stored in jos_vm_user_info)
user_id (the form has to associate the user_email with the field user_id from jos_vm_user_info)
client_credit (it has to be incremented from the previous value)


In the second one used by clients:
request_price (10,20,30,50)
captcha
submit

the credit must be checked before submit (client_credit) if it is less than the form request price it will abort, if not the credit table will be decreased: client_credit = client_credit - request_price


i tried to do the first one but i have some problem to get values with other joomla db tables like jos_vm_user_info. Also i tried to use the tutorial for saving to the database, but the table is not updatet after the submit. can you help me?
GreyHead 20 Aug, 2009
Hi Attila16881,

Are the VM userid and email different from the Joomla ones? If so then you'll need to add extra SQL queries to read the tables.

When you say the table is not updated what isn't updated? Is any record added to the table? Do You have the DB Connection enabled?

Bob
Attila16881 20 Aug, 2009
i would like to use the vm fields directly, if it is not possible i could enable joomla registration and use it.


about the table not updated i mean that any record wasnt added after submitting the form. the db connection is enabled and the table selected, data storage before email.
Do i have to add anything here: "Extra dataview columns fields names"?
GreyHead 20 Aug, 2009
Hi Attila16881,

Ok you can pull the data from the VM tables but you'll need to write an sql query to do it. If they aren't registered/looged in how do you identify the user?

Possible the table doesn't have a unique id? I think Joomla uses that to save the data with the functions that ChronoForms uses.

Bob
Attila16881 21 Aug, 2009
i'm sorry i checked in the db and i found that the registration through virtuemart is still sincronized with the joomla one. i think i could use directly the user table, is it easier can you help me?

so the situation is this one:

FORM1:
the admin is logged in (only him can use this form1), he fills the form fields "registered user email" ( field email the same as in jos_users) and the "credit" (field credit) and send it.
the form has to fill the values in a table i have created for this form called client_credit, the fields i need are: email, id and credit. So he needs to associate the email with the correct id from the table jos_users.

FORM2:
these things are necessaries because when a logged user is going to make an order with a form (form2), the form itself has to check how much credit he has and if he has enaugh credit to make an order, if not the order will fail.
GreyHead 21 Aug, 2009
Hi Attila16881,

You can use the Joomla User Object $user=& JFactory::getUser(id); to get info on any user so the trick here is going to be to let your admin find the userid. Depending how many users you have you could do this with a drop-down; a filter search; or a filter search using AJAX. This bit is really more like a ChronoConnectivity application.

Once you have an id then a simple update form can be used to add credits to a table (I'd just add 'id' and 'credits' and look up email in jos_users when it's needed).

The when you have a logged in user you can use the User Object again to got their id and look up their credits from the table.

Bob
Attila16881 23 Aug, 2009
Thanks very much Bob
the original code of the form:

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;"> Client E-mail</label>
    <input class="cf_inputbox required validate-email" maxlength="150" size="30" title="" id="text_0" name="user_email" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Client Credit</label>
    <input class="cf_inputbox required validate-number" maxlength="150" size="30" title="" id="text_1" name="credito_1" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_captcha">
    <label class="cf_label" style="width: 150px;">Captcha</label>
    <span>{imageverification}</span> 
    
    </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_button">
    <input value="Send" name="button_3" type="submit" />
  </div>
  <div class="cfclear"> </div>
</div>


I have to change it in order to have:

user: dropdown/ajax search
credit: insert credit
button (update)

this will send a confirmation email and an update in the client_credit table.
could you help me more, with an example or some code to create this dropdown or ajax user search needed in the form to update?
Attila16881 27 Aug, 2009
can someone help me in some way? thanks
GreyHead 28 Aug, 2009
Hi Attila16881,

I'm sorry, both Max and I are just very busy at the moment (neither of us have any idea why this should happen in August which is usually fairly quiet). And thi sis not a question that can be answered in a quick 1-2 minute post :-(

Bob
Attila16881 28 Aug, 2009
thanks Bob, i understand you are busy, dont worry...
i will try to fix this thing in some way. When you have time to answer me i will follow your suggestion if i will be still stuck.
Attila16881 20 Sep, 2009
any news? have you time to solve my problem yet? i could also pay for the required assistance, tnx
This topic is locked and no more replies can be posted.