Menu

#1344 Help with Custom Fields

open
None
1
2017-11-13
2017-10-24
Anonymous
No

Hi,

I'm trying to add a custom field, but I just can't add it the way I would like.
I need that when someone is making a reservation, a check field shows a few checkboxes, like checkbox 1, checkbox 2 and so on. if one of those checkboxes are thicked then a e-mail is sent to the e-mail that is associated to it.

I've tried with this:

I added a DB field named facilities to the tables entry, repeat and room, type text.
added in the file config.inc.php the code:

$select_options['entry.facilities'] = array('' => 'Nada', 'it@centimfe.com' => 'Videoprojetor', 'it@centimfe.com' => 'PC Portatil', 'food@centimfe.com' => 'Catering');

I only have a text box and the word facilities, nothing else happens, so I didn't get to the part of sending e-mail to the it or food department...

Any help will be great.
Thank you.

Discussion

  • Anonymous

    Anonymous - 2017-10-24

    UPDATE
    changed to type char in DB adn also update the code in config.inc.php to:$select_options['entry.facilities'] = array('0' => 'Nada', '1' => 'Projetor', '2' => 'PC Portatil', '3' => 'PC + Projetor', '4' => 'Catering');

    now I get a dropbox wich also fits my goal... but the field in the DB always show P or C no matter what I chose.

     

    Last edit: Anonymous 2017-10-24
  • Campbell Morrison

    You might be better off indexing the array by 'a', 'b', 'c', 'd', instead of '0', '1', '2', '3'. It'll ensure that PHP and MRBS treat this as an associative array.

     
  • Anonymous

    Anonymous - 2017-10-24

    UPDATE 2

    solved the DB... now how do I get a email sent to the right department acording to the facilities choices???

     
  • Campbell Morrison

    At its simplest you create an array (say in the config file) looking something like this:

    $email_addresses = array(
      'a' => 'it@domain.com',
      'b' => 'food@domain.com'
    );
    

    Then in functions_mail.inc you look up the address and add it to the list of people that get sent an email.

     

    Last edit: Campbell Morrison 2017-10-24
  • Anonymous

    Anonymous - 2017-10-25

    Since I'm not a coder I need a little help on this :)
    I have in config.inc.php
    $select_options['entry.facilities'] = array('a' => 'Nada', 'b' => 'Projetor', 'c' => 'PC Portatil', 'd' => 'PC e Projetor');
    $select_options['entry.catering'] = array('a' => 'Nada', 'b' => 'Café', 'c' => 'Águas', 'd' => 'Lanche');
    $email_addresses = array( 'a' => 'it@domain.com', 'b' => 'food@domain.com')

    so I need some code in functions_mail.inc that works this out:

    check if entry.facilities is b, c or d then returns email_addresses a and send mail when booking is done.
    check if entry.catering is b, c or d then returns email_addresses b and send mail when booking is done.

    Can you spare a few more minutes with this?
    Thank you.
    Paulo R

     
  • Anonymous

    Anonymous - 2017-10-26

    in functions_mail.inc where is the function that sends email on new/edit bookings? where is the start line?
    maybe it's possible to insert this piece of code in there (probably with a ton of errors, since I'm not a coder, but I will get this working... :)

    if $select_options['entry.facilities'] !== 'Nada' then $address == $email_addresses[a]';
    if $select_options['entry.catering'] !== 'Nada' then $address == $email_addresses[b]';

    share a little light on my path plz.
    thank you.
    Paulo R

     
  • Campbell Morrison

    Assuming you are using MRBS 1.6.1 then you need to insert the following lines in the function create_addresses() in functions_mail.inc at line 763:

      global $email_addresses;
      if ($data['facilities'] != 'a')
      {
        $to[] = $email_addresses['facilities'];
      }
      if ($data['catering'] != 'a')
      {
        $to[] = $email_addresses['catering'];
      }
    

    This assumes that your $email_addresses array in the config file loooks like this:

    $email_addresses = array( 'facilities' => 'it@domain.com', 'catering' => 'food@domain.com')
    

    (I changed the key from 'a' to 'facilities' etc. so as not to confuse the keys with the $select_options keys.)

     
  • Anonymous

    Anonymous - 2017-10-27

    No... not working... at first it seems to work because the room admin mail I use is the same as catering.
    But the IT mail never gets the email.
    And yes I'm using MRBS 1.6.1

    Thanks
    PR

     

    Last edit: Anonymous 2017-10-27
    • Campbell Morrison

      Sorry, if you edit a post a new notification doesn't get sent, so all I saw was the original "Works like a charm. Thank you."!

       
  • Campbell Morrison

    You could try turning on mail debugging to see what is happening:

    $mail_settings['debug'] = true;
    // Where to send the debug output.  Can be 'browser' or 'log' (for the error_log)
    $mail_settings['debug_output'] = 'browser';
    
     
  • Campbell Morrison

    Also try adding the following (temporarily) to the bottom of internalconfig.inc.php:

    error_reporting(-1);
    ini_set('display_errors', '1');
    
     
  • Anonymous

    Anonymous - 2017-11-13

    Hi,

    problem solved... Thank you.
    just put the code 3 or 4 lines down... It was before the $to and it should be below those lines