Menu

#353 add file to room reservation

open
nobody
None
1
2020-04-09
2017-03-22
Anonymous
No

Is there a way to add a file (scanned pdf document) to a room reservation? The idea is that the reserving party must agree in writing to our use policy and we want to retain a pdf with the reservation in the form of an attached pdf scan of said document.

Discussion

  • Campbell Morrison

    Not at the moment without modifying MRBS, but it wouldn't be that difficult to do.

     
  • Sony Martha

    Sony Martha - 2019-02-07

    pls make mrbs can upload application letter

     

    Last edit: Sony Martha 2019-02-07
  • Campbell Morrison

    This is slightly more complicated than I first thought. It probably needs a new table to hold attachments (and their file names?). And then it will need changes to pages such as view_entry.php to allow the attachments to be downloaded and also changes to email notifications to allow the attachments to be sent.

     
  • Sony Martha

    Sony Martha - 2019-02-08

    im already make new field in mrbs_entry table, when i input character in phpmyadmin, this field is readable, but when i want to try to edit letter field, database not save what im entry before, so i think this database can be read by system, but this system cant edit it,

    nb : user edit "letter" field in system, not in phpmyadmin

     

    Last edit: Sony Martha 2019-02-08
  • Campbell Morrison

    Adding scanned pdfs is going to require a BLOB field of some kind in the database. However I don't think that it makes sense to add the BLOB field to the entry and repeat tables as (a) this is going to use up lots of storage space and (b) there's no room to store metadata such as the filename. Instead I think it's going to need a new table to hold attachments and then the entry and repeat tables can point to the id of the row in the attachments table.

    All of which means, unfortunately, that this would require a fairly major change to MRBS.

     
  • Sony Martha

    Sony Martha - 2019-02-10

    nonono, u not must to save file like pdf or something like jpeg, database just save file address of file, for example in database written (file/letter.pdf), so database just save address,

     
  • Sony Martha

    Sony Martha - 2019-02-10

    so mrbs not use blob, just save filename of file, ex:holiday.jpeg, database not save picture binary

     
  • Campbell Morrison

    Well, in the general case I think it's better to save the file in the database. If you just save the file address then you run into all sorts of problems if the file is deleted or moved.

    However, if you are happy in your case just to save the address then this should be possible in MRBS as it stands. Just create a custom field in the entry and repeat tables that's long enough to hold the file address.

     
  • Sony Martha

    Sony Martha - 2019-02-13

    okay but i have a problem, i was create new field, mrbs can read it, and show it, but mrbs cant edit it, what should i do, can u give me some solution ??
    and about repeat tables, how i can find "repeat tables" ??

     
  • Campbell Morrison

    Which version of MRBS are you using? How did you create the new field?

    What you should do is, using phpMyAdmin or something similar, create a new field in both the mrbs_entry and mrbs_repeat tables that is a VARCHAR. If the field is longer than a VARCHAR(70) then you will need to change the setting of $text_input_max in your config file so that the field is presented as a text input rather than a textarea on forms. For example set

    $text_input_max = 255;
    

    [Note that if you have changed $tbl_prefix ffrom the default of mrbs_ then obviously your tables will be called something different.]

     
    • Campbell Morrison

      PS There are full instructions oin creating custom fields in the INSTALL document under "ADDING EXTRA COLUMNS TO THE DATABASE TABLES".

       
  • Sony Martha

    Sony Martha - 2019-02-18

    how to using ElementInputFile to new field ? this function will save path of file right ???

     
    • Campbell Morrison

      No. The class ElementInputFile will create the element <input type="file">. This will allow you to choose a file for upload to the server.

       
  • Sony Martha

    Sony Martha - 2019-02-20

    can u give me example when i want to make new field with this, for example new field is 'lumos'

     
    • Campbell Morrison

      For an example of how to use ElementInputFile see import.php. This page allows you to upload a .ics file containing one or more events and import them into MRBS. If you were going to use this, then you'd have to upload the .pdf file, write it out to the local file system and then store the file address in the MRBS database. But you'd then have to have some way of the user reading that file on, for example, the view_entry page.

      As I said before, it would be better to store the file as some kind of BLOB rather than in the local file syystem.

       
  • Anonymous

    Anonymous - 2019-02-25

    this web just for local-small system, so i think its ok when other user reading this file

     
  • Anonymous

    Anonymous - 2020-02-27

    We' re also interested in using a upload function.

     
  • carmean

    carmean - 2020-04-07

    We also would like to upload a file to the server (not the database) from edit_entry.php and looking at the above I was optimistic. I want to save the $upload_directory and $uploaded_filename to fields in the database and create a link to the file that admins can view. (In other non-MRBS solutions I have been adding a 'random' prefix to the file name to keep the uploads private.)

    In MRBS version 1.4.11 I am able to upload the file but not grab the file name into the MySQL database. However I probably am missing something simple

    In 1.8 I tried several things but mostly wasted time.... modified edit_entry.php adding
    use MRBS\Form\FieldInputFile; and $custom_fields_map['uploaded_filename']['nature'] = 'File'; and
    ~~~
    if ($custom_field['nature'] == 'File')
    {
    $class = 'ElementInputFile';
    }
    ~~~
    Any suggestions would be welcome- I really appreciate all the time that has gone into this project and the new version (1.8) is really good.

     
  • Campbell Morrison

    $custom_field['nature'] doesn't recognise files at the moment. So I think the best thing to do is to detect your file input by the field name, and then create a file input. You'll obviously need to create a new class 'ElementInputFile'. You'll also need to modify edit_entry_handler.php so that it does some special processing for the file.

    Be sure your file upload form has the attribute enctype="multipart/form-data" otherwise the file upload will not work. You should be able to get the uploaded file details from the $_FILES global. See the PHP manual for further details.

     
MongoDB Logo MongoDB