Announcement

Collapse
No announcement yet.

URGENT.... Best way to manage a Confirmation message/box YES or NOT

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • URGENT.... Best way to manage a Confirmation message/box YES or NOT

    Hi all,

    I'm trying to make a test message with YES and NOT button before to INSERT and also before UPDATE a record in a table using sc_exec_sql .....

    I did several tests under OnValidateSuccess :
    sc_ajax_message(" Do you like to insert a new record ? ", "TITLE...", 'modal=N&button=Y&button_label=Ok&show_close=Y&tim eout=5');
    also using "
    sc_ajax_message(" Do you like to insert a new record ? ", "TITLE...", "modal=N&button=Y&button_label=Ok&show_close=Y&tim eout=5");

    Nothing happened as the line was commented //

    Can you help me to make this simple test ? Have you got a sample like ... if OK do something and if NOT do nothing or something else.. ?
    Also using sc_confirm I'm able do nothing . ??? ;-(

    Many thanks
    Giovannino

  • #2
    AFAIK you don't have to program this but just fill a few fields in Application -> Messages
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      Hi, thanks
      It's not clear to me. I have to store the result of box YES or NOT in a global_var becouse then I have to test if to INSERT or UPDATE a new or existing record.
      Seems that messages are only as information. May I to intercept the answer of user ??

      I've tried also using this code but later I'm not able to refer to (x) becouse it's not a SC variable . echo (x) for istance makes error.

      echo "<script>
      var x=window.confirm('Are you sure you are ok?')
      if (x)
      window.alert('Good!')
      else
      window.alert('Too bad')
      </script> ";

      Comment


      • #4
        If you need to test if a record was inserted or updated then you just take the onafterinsert or onafterupdate events. I thought you needed a kind of 'do you want'... which is generated if you fill in this form. But there's no event if the user clicks 'no', but then the onrecord is fired again.
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment


        • #5
          No,
          I need to check the user willing with asking if it is YES or NOT and then carry on.
          I have to ask him before " Are sure to INSERT a new record... ? " (1) or "Are you sure to UPDATE an existing record... ? " (2)

          IF YES (1) ....

          $sql_inser_payment = "INSERT INTO payments
          (payment_cbID, payment_timingID, payment_casusal_ID, paymentDate, paydescr, amount_in,
          currency, exchange_rate, note, cashin_type, projectID, receiptID, receiptDate)
          VALUES (1, 1, 9, '$var_receiptDate', '$var_description', $var_amount,
          $var_currencyID, $var_exchange_rate, '$var_depositor', $var_cashin_type, $var_projectID, $var_receiptID,
          '$var_receiptDate')";
          sc_exec_sql($sql_inser_payment);

          or
          IF YES (2)...

          $sql_update_payment = "UPDATE payments SET
          payment_cbID = 1,
          payment_timingID = 1,
          payment_casusal_ID = 9,
          paymentDate = '$var_receiptDate',
          paydescr = '$var_description',
          amount_in = $var_amount,
          currency = $var_currencyID,
          exchange_rate = $var_exchange_rate,
          note = '$var_depositor',
          cashin_type = $var_cashin_type,
          projectID = $var_projectID,
          receiptID = $var_receiptID,
          receiptDate = '$var_receiptDate'
          WHERE receiptID = [glo_receiptID] AND receiptDate = '[glo_receiptDate]'";
          // Attention that payment_casusal_ID = 9 can change
          sc_exec_sql($sql_update_payment);

          or DO NOTHING

          Comment


          • #6
            Are you working in version 7? The enter the question at messages in the application section. This question has a default yes/no behaviour. Use the events onafterinsert and onafterupdate to do the other stuff. Just tried it and works well.
            Albert Drent
            aducom software netherlands
            scriptcase partner, reseller, support and (turn-key) development
            www.scriptcase.eu / www.scriptcase.nl

            Comment


            • #7
              Yes, ver 7.016
              It's still not clear to me how to manage the NOT reply. Do Message has the double buttons YES / NOT ?

              Why the sc_ajax_message(" Do you like to insert a new record ? ", "TITLE...", 'modal=N&button=Y&button_label=Ok&show_close=Y&tim eout=5'); do not works ?

              Comment


              • #8
                Originally posted by giovannino View Post
                Yes, ver 7.016
                It's still not clear to me how to manage the NOT reply. Do Message has the double buttons YES / NOT ?

                Why the sc_ajax_message(" Do you like to insert a new record ? ", "TITLE...", 'modal=N&button=Y&button_label=Ok&show_close=Y&tim eout=5'); do not works ?
                Why don't you try it out? It's quickly done. There will be yes/cancel buttons and if cancel is pressed nothing will be happening.

                IF YES (1) .... // on before insert message

                IF YES (2)... // on before update message

                or DO NOTHING

                And from the documentation:
                sc_ajax_message("Message", "Title", "Parameters", "Parameters_Redir")
                This macro allows the application to show customizable messages. It's use is restricted to AJAX events of Form/Control applications.

                OnValidate ... events are *not* an ajax event, but happens within php.
                Last edited by aducom; 06-26-2013, 10:22 AM.
                Albert Drent
                aducom software netherlands
                scriptcase partner, reseller, support and (turn-key) development
                www.scriptcase.eu / www.scriptcase.nl

                Comment


                • #9
                  I just tried out yet.
                  It's ok if you push YES button. Application carry on and makes what inserted under onAfterInsert or under onAfterUpdate.
                  (in my case the application update or insert into another table a record).

                  If you push NO/Undo application do nothing.
                  My willing is that application in this case update or insert only his own table.
                  How can I perform this ?

                  Comment


                  • #10
                    That won't be easy. Is it an option to add a custom field (checkbox) with the question? If checked then you update one or both tables? Then you don't have an additional popup, but an extra field. If you want to be sure that it is not overlooked you could use a threestate radio button.
                    Albert Drent
                    aducom software netherlands
                    scriptcase partner, reseller, support and (turn-key) development
                    www.scriptcase.eu / www.scriptcase.nl

                    Comment


                    • #11
                      In such cases i do the following:

                      Create a control-form with one Text field with Status Label. So the text i will show is the label of the field.
                      Then i create 2 php-Buttons where i do the things i want to do.
                      I place the variables i need in the onScriptInit and then i delete the Buttons in the master Applikation, generate one for myself and link the button to the control form. With the link i could transfer all variables without problems to the control form.

                      Comment


                      • #12
                        Hi,
                        it seems to me a little bit complicated for manage only a dual decision test.

                        If the sc_ajax_message("Message", "Title", "Parameters", "Parameters_Redir") would work in somewhere I could try to manage in one step the decision.

                        Also the
                        echo "<script>
                        var x=window.confirm('Are you sure you are ok?')
                        if (x)
                        window.alert('Good!')
                        else
                        window.alert('Too bad')
                        </script> ";

                        works , but the problem is that variable .. (x) is not readable (better I'm not able to) by php

                        Comment

                        Working...
                        X