• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Adding a counter for submissions

Adding a counter for submissions 10 years 10 months ago #23706

  • upbm
  • upbm's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 34
  • Thank you received: 4
Hello,

I use an old code found in the past in your documentation in a hidden field name counter and it works fine.
//<code>
  $db=JFactory::getDBO();
  $db->setQuery("SELECT COUNT(`SubmissionId`) FROM #__rsform_submissions WHERE FormId=16");
  $db->query();
  $result=$db->loadResult();
  return intval($result)+1;
//</code>
I want to change for the new code you give now :
//<code>
  $db = JFactory::getDbo();
  $db->setQuery("SELECT COUNT(`SubmissionId`) FROM #__rsform_submissions WHERE FormId='".(int) $formId."'");
  return $db->loadResult()+1;
//</code>

This code don't works, it give always 1, I must replace with the numeric formId to have it working, seem $formId unknow.
$db->setQuery("SELECT COUNT(`SubmissionId`) FROM #__rsform_submissions WHERE FormId=16");

More, the similar code provided in your doc for scripts called on form display works fine in my form and there, FormId='".(int) $formId."'");is good.
I don't see where is my mistake with the hidden field counter.
Any ideas ?

Didier
The administrator has disabled public write access.

Adding a counter for submissions 10 years 8 months ago #24316

  • servlet
  • servlet's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 13
remove old code from Default Value
add new code in PHP scripts - $_POST form (midle section)
The administrator has disabled public write access.

Adding a counter for submissions 10 years 8 months ago #24330

  • upbm
  • upbm's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 34
  • Thank you received: 4
Hello

Thanks for your reply, I had already corrected using the new code that has been modified in the www.rsjoomla.com/support/documentation/v...for-submissions.html documentation works very well, especially in being placed in the Scripts called on form process, it avoids the problem of identical values when several forms are completed at the same time.
Nice day.
Last Edit: 10 years 8 months ago by upbm.
The administrator has disabled public write access.

Adding a counter for submissions 10 years 5 months ago #25432

  • seal305
  • seal305's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 20
  • Thank you received: 1
This code didn't work for me because it takes the total number of submissions and adds one. What if submissions have been deleted from the middle? Then you end up with duplicate counter numbers. Also the code didn't work for me under the "default" value as suggested.

I used this in the PHP Scripts under "Script called on form process" section. It takes the highest number in the Submission column and then adds one- which I believe will always be the new SubmissionId number:

    $db = JFactory::getDbo();
    $db->setQuery("SELECT MAX(`SubmissionId`) FROM #__rsform_submissions WHERE FormId=5 ORDER BY `SubmissionId` LIMIT 1");
    $_POST['form']['counter'] = $db->loadResult()+1;

So far this has worked. Any comments comments would be appreciated.
I'm working with the Joomla 1.5 version last update of RSForm Pro
The administrator has disabled public write access.

Adding a counter for submissions 10 years 3 months ago #26164

  • denis l.
  • denis l.'s Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 19
seal305 wrote:
This code didn't work for me because it takes the total number of submissions and adds one. What if submissions have been deleted from the middle? Then you end up with duplicate counter numbers. Also the code didn't work for me under the "default" value as suggested.

I used this in the PHP Scripts under "Script called on form process" section. It takes the highest number in the Submission column and then adds one- which I believe will always be the new SubmissionId number:

    $db = JFactory::getDbo();
    $db->setQuery("SELECT MAX(`SubmissionId`) FROM #__rsform_submissions WHERE FormId=5 ORDER BY `SubmissionId` LIMIT 1");
    $_POST['form']['counter'] = $db->loadResult()+1;

So far this has worked. Any comments comments would be appreciated.
I'm working with the Joomla 1.5 version last update of RSForm Pro

Hi everyone!

I'm building a new payment form for my business website and with it, I'm sending an email to the form submitter that serves as a receipt and I would like to add to it the receipt number using the {counter:value} tag in the email. So far so good... but I have two little problems.

  • (1) I've already submitted receipts to some clients since the beginning of my business's operations so my form counter should not start at 1 for the first submission. So is there a way to set the counter to start from a specific number and go up from there? And also, for testing purpose, is it possible to reset the counter to that value when I go live?

  • (2) Other problem is that my receipts numbers are displayed in this format => 00145 (five digits sequential numbers including the zeros)... how would I apply this to the form counter?

I'm using Joomla 3.2.1 and RSForm! Pro 1.4.0 Rev 48

Thank you very much in advance for your precious help!

Denis.
Last Edit: 10 years 3 months ago by denis l..
The administrator has disabled public write access.

Adding a counter for submissions 10 years 3 months ago #26175

  • adrianp
  • adrianp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 631
  • Thank you received: 146
Hello,

You can try the following approach:

- add a hidden field with the default value of 5 digits(example, this can be 00000 or 00345 or 02356);

- use a similar script as the one that follows within the "Scripts Called on Form Process" area(PHP Scripts):
$db = JFactory::getDBO();
$db->setQuery("SELECT MAX(`FieldValue`) FROM #__rsform_submission_values WHERE `FieldName`='counter' AND `FormId`='".(int) $formId."'");
$input = $db->loadResult();
 
if($input){
	$string = intval(ltrim($input, '0'))+1;
	$_POST['form']['counter'] = str_pad($string,5,0,STR_PAD_LEFT);
}

For the above script to work properly you will have to replace "counter" (found 2 times) with your exact hidden field's name. Afterwards you can use the hidden field's placeholder within your emails.

The "Reset" part, when you go live, can be done by clearing the submissions(backend > Components > RSForm!Pro > Manage Forms, within the provided table you can notice a "Clear All Submissions" link for your form).
This is not official customer support. To receive your support, submit a support ticket here.
The administrator has disabled public write access.
The following user(s) said Thank You: denis l.

Adding a counter for submissions 10 years 3 months ago #26176

  • denis l.
  • denis l.'s Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 19
Ha!

Thank you very much adrianp for your quick response. Works like a charm! :)
Keep up the good work with this wonderful product! B)
Last Edit: 10 years 3 months ago by denis l..
The administrator has disabled public write access.

Adding a counter for submissions 6 years 8 months ago #37281

  • peter s.
  • peter s.'s Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
I would love to add a prefix (so PUB-00001)

Can't figure out where to put the 'PUB-'

in the code? Any advice?
$db = JFactory::getDBO();
$db->setQuery("SELECT MAX(`FieldValue`) FROM #__rsform_submission_values WHERE `FieldName`='LED' AND `FormId`='".(int) $formId."'");
$input = $db->loadResult();
 
if($input){
	$string = intval(ltrim($input,'LED-', '0'))+1;
	$_POST ['form']['LED'] = str_pad ($string,9,0,STR_PAD_LEFT);
}
The administrator has disabled public write access.

the counter has stopped at 1000 6 years 4 months ago #37607

  • Abdel08
  • Abdel08's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
Hi

I used your code for a year and it was perfect.

Today, the counter has stopped at 1000. And all the following emails include the number 1000.

Do you have an idea of what this is?

Thank you
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!