3 Replies Latest reply on Jun 12, 2008 5:11 AM by (Purple_Edge)

    Compare Transaction Fields - ADDT

      Good morning,
      my problem is as follows:

      I have a manager of events.
      Before accepting the "insert record" in the database,
      I must verify that the "meeting room" is not already reserved at the same time.
      I therefore "Compare Transaction Fields" and "Check Unique Key"


      Unfortunately, it does not work.
      Can you give me a track to solve my problem?

      Initially I make a check on the dates of my form (ValidateForm): Ending> Start Date

      // Start trigger
      $formValidation = new tNG_FormValidation();
      $formValidation->addField("location_eve", true, "numeric", "", "", "", "");
      $formValidation->addField("date_start_eve", true, "date", "datetime", "", "", "");
      $formValidation->addField("date_end_eve", true, "date", "datetime", "{date_start_eve}", "", "La date/heure de fin doit être supérieure à la date/heure de début.");
      $tNGs->prepareValidation($formValidation);
      // End trigger

      Then, Compare Transaction Fields:

      //start Trigger_Compare trigger
      //remove this line if you want to edit the code by hand
      function Trigger_Compare(&$tNG) {
      $fieldCompareObj = new tNG_FieldCompare($tNG);
      $fieldCompareObj->addField("date_start_eve", "{date_end_eve}", "<=", "DB start <= FormEnd_OUT");
      $fieldCompareObj->addField("date_end_eve", "{date_start_eve}", ">=", "DB end >= FormStart");
      return $fieldCompareObj->Execute();
      }
      //end Trigger_Compare trigger

      Follow-up check Unique key:


      //start Trigger_CheckUnique trigger
      //remove this line if you want to edit the code by hand
      function Trigger_CheckUnique(&$tNG) {
      $tblFldObj = new tNG_CheckUnique($tNG);
      $tblFldObj->setTable("event_eve");
      $tblFldObj->addFieldName("location_eve");
      $tblFldObj->addFieldName("date_start_eve");
      $tblFldObj->setErrorMsg("Cette salle est déjà réservée à ce moment.");
      return $tblFldObj->Execute();
      }
      //end Trigger_CheckUnique trigger


      How do I do not accept the registration if the meeting room is already occupied at this time?

      Thank you
      Best regards
      John
      ---------------------------------------------------------------------------

      Bonjour,
      mon problème est le suivant :

      j'ai un gestionnaire d'évènements.
      Avant d'accepter l'insertion de l'enregistrement dans la base de données,
      je dois vérifier que la salle de réunion n'est pas déjà réservée à la même date/heure.
      J'utilise donc "Compare Transaction Fields" et "Check Unique Key"

      Malheureusement, cela ne fonctionne pas.
      Pouvez-vous me donner une piste pour résoudre mon problème ?
      Initialement j'effectue un contrôle sur les dates de mon formulaire (ValidateForm): Date de fin > Date de début

      // Start trigger
      $formValidation = new tNG_FormValidation();
      $formValidation->addField("location_eve", true, "numeric", "", "", "", "");
      $formValidation->addField("date_start_eve", true, "date", "datetime", "", "", "");
      $formValidation->addField("date_end_eve", true, "date", "datetime", "{date_start_eve}", "", "La date/heure de fin doit être supérieure à la date/heure de début.");
      $tNGs->prepareValidation($formValidation);
      // End trigger

      Ensuite, le Compare Transaction Fields :

      //start Trigger_Compare trigger
      //remove this line if you want to edit the code by hand
      function Trigger_Compare(&$tNG) {
      $fieldCompareObj = new tNG_FieldCompare($tNG);
      $fieldCompareObj->addField("date_start_eve", "{date_end_eve}", "<=", "DB start <= FormEnd_OUT");
      $fieldCompareObj->addField("date_end_eve", "{date_start_eve}", ">=", "DB end >= FormStart");
      return $fieldCompareObj->Execute();
      }
      //end Trigger_Compare trigger

      Suivi du check Unique key :

      //start Trigger_CheckUnique trigger
      //remove this line if you want to edit the code by hand
      function Trigger_CheckUnique(&$tNG) {
      $tblFldObj = new tNG_CheckUnique($tNG);
      $tblFldObj->setTable("event_eve");
      $tblFldObj->addFieldName("location_eve");
      $tblFldObj->addFieldName("date_start_eve");
      $tblFldObj->setErrorMsg("Cette salle est déjà réservée à ce moment.");
      return $tblFl
        • 1. Re: Compare Transaction Fields - ADDT
          Level 1
          One of the tutorials - if you look at the old help systems supplied by Iterakt you will find it - search for "duplicate key" - has an example of how to prevent a duplicate key record. The technique uses a trigger to run an SQL query and compare the result with a value in the form, and then take some action if necessary.

          This appears to be exactly what you need to do - run an SQL query to get a value if the room is occupied. If it is, then take some action to prevent the form completing. I have not used this technique for some time, so cannot help further - the tutorial has the answer.
          • 2. Re: Compare Transaction Fields - ADDT
            Hi - just wondering if you had any luck regarding this JohnCHR? I would like to do the same thing and am having trouble finding that tutorial.

            thanks
            • 3. Re: Compare Transaction Fields - ADDT
              Level 1
              Someone posted the limk in another thread...

              http://www.interaktonline.com/Documentation/MXKollection/mx_kollection.htm#075000_tutorial discussionboard.htm

              Not sure which page it is on, but it is a good tutorial to review.