Menu

#2767 function.mail not working after update

open
nobody
None
1
2023-06-07
2023-06-04
Steve
No

Hello,

i updatet MRBS to 1.11 but i have a failure in the functions.mail
I added some extra functions in the file so i can show some extra infos
at the email. Unfortunaly the extra infos are not shown anymore?

I compared the files and recongnized minor changes (compare old to new email, Email.EOL? etc.)

Do you have an idea, how i can bind my changes to the new "system"?

See also file attached

THX Steve

Uncaught exception 'TypeError' in C:\xampp\htdocs\mrbs\web\functions_mail.inc at line 252
MRBS\create_body_table_row(): Argument #3 ($old) must be of type string, null given, called in C:\xampp\htdocs\mrbs\web\functions_mail.inc on line 940

Uncaught exception 'TypeError' in C:\xampp\htdocs\mrbs\web\functions_mail.inc at line 252
MRBS\create_body_table_row(): Argument #3 ($old) must be of type string, null given, called in C:\xampp\htdocs\mrbs\web\functions_mail.inc on line 940
#0 C:\xampp\htdocs\mrbs\web\functions_mail.inc(940): MRBS\create_body_table_row('Headsets f\xC3\xBCr B...', '0', NULL, true, false)
#1 C:\xampp\htdocs\mrbs\web\functions_mail.inc(1267): MRBS\create_body(Array, Array, true, false, 'book', Array, false, NULL)
#2 C:\xampp\htdocs\mrbs\web\mrbs_sql.inc(2771): MRBS\notifyAdminOnBooking(Array, Array, false, false, Array)
#3 C:\xampp\htdocs\mrbs\web\edit_entry_handler.php(846): MRBS\mrbsMakeBookings(Array, 3494, false, false, 2, true, '')
#4 {main}

MRBS GET: Array
(
)
MRBS POST: Array
(
    [csrf_token] => a599cfe7843b4dbc07ed4eb90c03f4ddd7996557694791e920614ebb77215669
    [returl] => https://mrbs/index.php?view=day&view_all=1&page_date=2023-06-09&area=1&room=2
    [edit_type] =>
    [original_room_id] => 2
    [ical_uid] => MRBS-6479d7357f874-7e2dc160@mrbs
    [ical_sequence] => 0
    [id] => 3494
    [f_KS] => 2050
    [f_PS] => 2
    [f_Leiter] => TEST
    [name] => TEST
    [create_by] => M04214
    [description] =>
    [start_date] => 2023-06-09
    [start_seconds] => 43200
    [end_date] => 2023-06-09
    [end_seconds] => 46800
    [rooms] => Array
        (
            [0] => 2
        )

    [type] => A
    [f_MC] => on
    [f_LS] => 1
    [f_GS] => 1
    [f_PSA] => 0
    [f_HS] => 0
    [f_info] => TEST
    [f_Gesamtkosten] => 130
)
MRBS SESSION: Array
(
1 Attachments

Discussion

  • Steve

    Steve - 2023-06-04

    i tried to workauround the error message:

    @cimorrison

    $mail_previous[$key]:

    if ($compare && isset($mail_previous[$key])) {
    $previousValue = $mail_previous[$key];
    if (!is_string($previousValue)) {
    //its not a string, put a standard value in
    $previousValue= ' ';
    }
    $mail_previous[$key] = $previousValue;
    } else (
    $mail_previous[$key] = ' ';

    But i still get error messages anytime :-( I reinstalled all files and keep all files "vanilla" without modifications and still get following error messages:

    Uncaught exception 'Error' in C:\xampp\htdocs\mrbs\web\functions_mail.inc at line 931
    Call to undefined function MRBS\get_display_name()
    #0 C:\xampp\htdocs\mrbs\web\functions_mail.inc(1290): MRBS\create_body(Array, Array, false, false, 'book', Array, false, '')
    #1 C:\xampp\htdocs\mrbs\web\mrbs_sql.inc(2771): MRBS\notifyAdminOnBooking(Array, Array, true, false, Array)
    #2 C:\xampp\htdocs\mrbs\web\edit_entry_handler.php(846): MRBS\mrbsMakeBookings(Array, NULL, false, false, NULL, true, 'series')
    #3 {main}
    
    MRBS GET: Array
    (
    )
    MRBS POST: Array
    (
        [csrf_token] => f7831d32036c22d79ed00e80a00e8151c259eb1eaefa0563ad75caed843a0b8f
        [returl] => https://mrbs/index.php?view=day&view_all=1&page_date=2023-06-09&area=1&room=3
        [rep_id] => 0
        [edit_type] => series
        [f_KS] => 1020
        [f_PS] => 6
        [f_Leiter] => TEST
        [name] => TEST
        [create_by] => M04214
        [description] =>
        [start_date] => 2023-06-09
        [start_seconds] => 45000
        [end_date] => 2023-06-09
        [end_seconds] => 48600
        [rooms] => Array
            (
                [0] => 1
            )
    
        [type] => A
        [f_MIK] => on
        [f_LS] =>
        [f_GS] =>
        [f_PSA] =>
        [f_HS] =>
        [f_info] => TEST
        [f_Gesamtkosten] => 180
        [rep_type] => 0
        [rep_day] => Array
            (
                [0] => 5
            )
    
        [month_type] => 0
        [month_absolute] => 9
        [month_relative_ord] => 2
        [month_relative_day] => FR
        [rep_interval] => 1
        [rep_end_date] => 2023-06-09
    )
    MRBS SESSION: Array
    
     
  • Campbell Morrison

    I don't think you can have reinstalled all the vanilla files. Line 931 of functions_mail.inc in MRBS 1.11.0 is

      $compare = !$new_entry;
    
     

    Last edit: Campbell Morrison 2023-06-04
  • Anonymous

    Anonymous - 2023-06-05

    i download the file mrbs_main_code from github.

    This is on line 931:

    if ($mail_settings['html'])
      {
        $html_body['content'] = create_body($data, $mail_previous, $compare, $series, $action, $start_times, true, $note);
        $html_body['cid'] = generate_global_uid("html");
      }
    

    After using the file from Github, making an entry is working without error and emails are coming also. But integrating my calculation function is throwing errors at me

    Anyways, it seems to me, that my modified "calc functions" didnt work anymore, with the "new" HTML -Email_EOL, parenthese around the HTML version something like that, but i am not sure!

    Do you have any idea, how i can bind my modified function (normaly i put it between line 354 to 682) to the "new" layout?:

      function create_price_calc($data) { // Preisliste erstellen für Email
      /*
       * $data = array (
      'create_by' => 'testuser',
      'modified_by' => '',
      'name' => 'kurzbeschreibung',
      'type' => 'I',
      'description' => 'kurzbeschreibung',
      'room_id' => '1',
      'start_time' => 1751434200,
      'end_time' => 1751610600,
      'rep_type' => 0,
      'rep_opt' => '',
      'rep_interval' => 1,
      'end_date' => 0,
      'ical_uid' => 'MRBS-5fa609828352d-8a688e39@localhost',
      'ical_sequence' => 0,
      'ical_recur_id' => NULL,
      'allow_registration' => NULL,
      'enable_registrant_limit' => NULL,
      'registrant_limit' => 1,
      'MC' => true,
      'KS' => 'a',
      'FC' => true,
      'PS' => 1,
      'FIK' => false,
      'MIK' => false,
      'LS' => false,
      'GS' => false,
      'PSA' => false,
      'Leiter' => '',
      'info' => 'kurzbeschreibung',
      'Preis' => 0,
      'private' => false,
      'awaiting_approval' => false,
      'tentative' => true,
      'entry_type' => 0,
      'repeat_id' => NULL,
      'duration' => 49,
      'dur_units' => 'hours',
      'id' => '58',
      'room_name' => 'Casino Raum 1',
      'area_name' => 'Casino',
    
    )
       * */
    
      if($data){
        // values
        $CASINORAUM1    = 15;
        $CASINORAUM2    = 20;
        $CASINORAUM3    = 25;
        $SPEISESAAL    = 0;
        $RAUMIDUNA     = 4.50;
        $RAUMODIN      = 4.50;
        $RAUMTYR       = 4.50;
        $RAUMWALHALLA  = 4.50;
    
        $startTime = $data['start_time'];
        $endTime = $data['end_time'];
    
        $GESAMTKOSTEN = 0;
    
        $f_FC = $data['FC'];
        $f_FIK = $data['FIK'];
        $f_GS = $data['GS'];
        $f_KS = $data['KS'];
        $f_LS = $data['LS'];
        $f_Leiter = $data['Leiter'];
        $f_MC = $data['MC'];
        $f_MIK = $data['MIK'];
        $personenAnzahl = $data['PS'];
        $f_PSA = $data['PSA'];
        $f_HS = $data['HS'];
        $f_BC = $data['BC'];
        $f_Preis = $data['Preis'];
        $f_info = $data['info'];
        $hours = floatval(str_replace(',', '.', $data['duration']));
        $days = round($hours/24);
    
        $raum_id = $data['room_id'];
    
        $result = "<hr>\n";
        $result .= "<p>Kostenaufstellung:</p>\n";
    
        $result .= "<table>";
    
        // Raum ausrechnen
        $raumkosten = 0;
        switch($raum_id) {
          case 1:
            $raumkosten = $personenAnzahl * $CASINORAUM1;
            break;
          case 2:
            $raumkosten = $personenAnzahl * $CASINORAUM2;
            break;
          case 3:
            $raumkosten = $personenAnzahl * $CASINORAUM3;
            break;
          case 19:
            $raumkosten = $personenAnzahl * $SPEISESAAL;
            break;
          case 13:
            $raumkosten = $personenAnzahl * $RAUMIDUNA;
            break;
          case 12:
            $raumkosten = $personenAnzahl * $RAUMODIN;
            break;
          case 11:
            $raumkosten = $personenAnzahl * $RAUMTYR;
            break;
          case 14:
            $raumkosten = $personenAnzahl * $RAUMWALHALLA;
            break;
        }
        // ### ROW
        $result .= "<tr>\n";
        // The label
        $result .= "<td>";
        $result .= htmlspecialchars("Raumkosten");
        $result .= "</td>\n";
        // Kosten
        $result .= "<td>";
        $result .= htmlspecialchars($raumkosten . "€");
        $result .= "</td>\n";
        $result .= "<td>";
        $result .= "</tr>\n";
        // ### END ROW
        $GESAMTKOSTEN += $raumkosten;
        // End Raum ausrechnen
    
        // Buchungsoptionen
        if($f_MC){ // Menü im Casino
          $option = (30 * $personenAnzahl);
          //if($days > 1) { $mc *= $days;} // Wenn mehr als 1 Tag
    
          $result .= "<tr>\n";
          // The label
          $result .= "<td>";
          $result .= htmlspecialchars("Menü im Casino");
          $result .= "</td>\n";
          // The new value
          $result .= "<td>";
          $result .= htmlspecialchars($option."€");
          $result .= "</td>\n";
          $result .= "<td>";
          $result .= "</tr>\n";
    
          $GESAMTKOSTEN += $option;
    
        }
        if($f_FC){ // Fingerfood im Casino
    
          $option = (25 * $personenAnzahl);
          //if($days > 1) { $option *= $days;} // Wenn mehr als 1 Tag
    
          $result .= "<tr>\n";
          // The label
          $result .= "<td>";
          $result .= htmlspecialchars("Fingerfood im Casino");
          $result .= "</td>\n";
          // The new value
          $result .= "<td>";
          $result .= htmlspecialchars($option."€");
          $result .= "</td>\n";
          $result .= "<td>";
          $result .= "</tr>\n";
    
          $GESAMTKOSTEN += $option;
    
        }
        if($f_FIK){ // Jubiläumsfrühstück Kantine
    
          $option = (17.25 * $personenAnzahl);
          //if($days > 1) { $option *= $days;} // Wenn mehr als 1 Tag
    
          $result .= "<tr>\n";
          // The label
          $result .= "<td>";
          $result .= htmlspecialchars("Jubiläumsfrühstück Kantine");
          $result .= "</td>\n";
          // The new value
          $result .= "<td>";
          $result .= htmlspecialchars($option."€");
          $result .= "</td>\n";
          $result .= "<td>";
          $result .= "</tr>\n";
    
          $GESAMTKOSTEN += $option;
    
        }
        if($f_MIK){ // Mittagessen in der Kantine
    
          $option = (15 * $personenAnzahl);
          //if($days > 1) { $option *= $days;} // Wenn mehr als 1 Tag
    
          $result .= "<tr>\n";
          // The label
          $result .= "<td>";
          $result .= htmlspecialchars("Mittagessen in der Kantine");
          $result .= "</td>\n";
          // The new value
          $result .= "<td>";
          $result .= htmlspecialchars($option."€");
          $result .= "</td>\n";
          $result .= "<td>";
          $result .= "</tr>\n";
    
          $GESAMTKOSTEN += $option;
    
        }
        if($f_LS){ // Foodboxen TO GO
          $option = (15 * $f_LS);
          //if($days > 1) { $option *= $days;} // Wenn mehr als 1 Tag
    
          $result .= "<tr>\n";
          // The label
          $result .= "<td>";
          $result .= htmlspecialchars("Foodboxen TO GO");
          $result .= "</td>\n";
          // The new value
          $result .= "<td>";
          $result .= htmlspecialchars($option."€");
          $result .= "</td>\n";
          $result .= "<td>";
          $result .= "</tr>\n";
    
          $GESAMTKOSTEN += $option;
    
        }
        if($f_GS){ // Foodboxen OHNE Schwein
          $option = (15 * $f_GS);
          //if($days > 1) { $option *= $days;} // Wenn mehr als 1 Tag
    
          $result .= "<tr>\n";
          // The label
          $result .= "<td>";
          $result .= htmlspecialchars("Foodboxen OHNE Schwein");
          $result .= "</td>\n";
          // The new value
          $result .= "<td>";
          $result .= htmlspecialchars($option."€");
          $result .= "</td>\n";
          $result .= "<td>";
          $result .= "</tr>\n";
    
          $GESAMTKOSTEN += $option;
    
        }
        if($f_PSA){ // Persönliche Schutzausrüstung
          $option = (5 * $f_PSA);
          //if($days > 1) { $option *= $days;} // Wenn mehr als 1 Tag
    
          $result .= "<tr>\n";
          // The label
          $result .= "<td>";
          $result .= htmlspecialchars("Persönliche Schutzausrüstung");
          $result .= "</td>\n";
          // The new value
          $result .= "<td>";
          $result .= htmlspecialchars($option."€");
          $result .= "</td>\n";
          $result .= "<td>";
          $result .= "</tr>\n";
    
          $GESAMTKOSTEN += $option;
    
        }
    
         if($f_HS){ // Headsets für Besuchergruppen
          $option = (5 * $f_HS);
         //if($days > 1) { $option *= $days;} // Wenn mehr als 1 Tag
    
          $result .= "<tr>\n";
          // The label
          $result .= "<td>";
          $result .= htmlspecialchars("Headsets für Besuchergruppen");
          $result .= "</td>\n";
          // The new value
          $result .= "<td>";
          $result .= htmlspecialchars($option."€");
          $result .= "</td>\n";
          $result .= "<td>";
          $result .= "</tr>\n";
    
          $GESAMTKOSTEN += $option;
    
        }
    
        if($f_BC){ // Belegte Brötchen im Casino
          $option = (4 * $personenAnzahl);
         //if($days > 1) { $option *= $days;} // Wenn mehr als 1 Tag
    
          $result .= "<tr>\n";
          // The label
          $result .= "<td>";
          $result .= htmlspecialchars("Belegte Brötchen im Casino");
          $result .= "</td>\n";
          // The new value
          $result .= "<td>";
          $result .= htmlspecialchars($option."€");
          $result .= "</td>\n";
          $result .= "<td>";
          $result .= "</tr>\n";
    
          $GESAMTKOSTEN += $option;
    
        }
    
    
          // ### ROW
          $result .= "<tr>\n";
          // The label
          $result .= "<td>";
          $result .= "<b>Gesamtkosten</b>";
          $result .= "</td>\n";
          // The new value
          $result .= "<td>";
          $result .= htmlspecialchars($GESAMTKOSTEN . "€");
          $result .= "</td>\n";
          $result .= "<td>";
          $result .= "</tr>\n";
          // ### END ROW
          $result .= "</table>";
        }
    
      return $result;
    
    }
    

    THX in Advance

     

    Last edit: Campbell Morrison 2023-06-05
  • Campbell Morrison

    Ah, OK, you are using the latest development code rather than 1.11.0. That's fine.

    What is the error you are getting now?

     
  • Anonymous

    Anonymous - 2023-06-05

    Dont ask me why, but i had to reformat the file funvtion.mail.inc to UTF-8. No more Error message are thrown at me,
    but my added function "calc_price"(see function above) is not showing any result if i make an entry :-(

    I add 2 minor functions:

    1. add function (see above) from line 392 to 682
    2. i add two lines at line 1024:

    if ($as_html)
    {
    $body .= create_price_calc($data); // Todo: Preise auf body ausgeben
    $body .= '' . MAIL_EOL;
    $body .= '' . MAIL_EOL;
    $body .= '' . MAIL_EOL;
    echo "Die Kantinenmitarbeiter stehen Ihnen im Servicezeitraum von 6:00-14:00 Uhr zur Verfügung";
    }

    return $body;
    }

    Unfortunaly there are no more any values shown, if i get the email :-(

     
  • Campbell Morrison

    You'll need to start debugging it using tools such as var_dump() to find out why it's not giving you anything.

     

    Last edit: Campbell Morrison 2023-06-05
  • Steve

    Steve - 2023-06-07

    I am not finished yet with fishing my errors, but i got 2 errors first in the funvtion_mail.inc:

    Incorrect use of <label for=FORM_ELEMENT>
    
    <label for="gesamtsumme" style="width: 198.94px;">Gesamtpreis in €</label>
    

    and

    <label for="rep_end_date" style="width: 198.94px;">Serienende</label>
    

    Do you have any idea?

     

    Last edit: Campbell Morrison 2023-06-07
  • Campbell Morrison

    That normally means that you don't have a form control, eg <input> with an id corresponding to the for attribute.

    Where are you seeing those error messages? If it's in your email then it's probably because <label> is the wrong kind of element to use there: it should only be used with a form control.