======Attachment Directive====== ==== Summary ==== ^ Objective | Handle attachments and attachments types | ^ Name | attachments | ^ Script | /applications/controller/attachment.php | ^ Tables | setup_attachments; attachments; list_ambits | ^ Configurations | $upload_dir | ^ Dependency | nothing in particular | ==== What are we talking about ==== * Attachment is the feature that allows the user to upload attachmnts to the system after having selected a certain attachment type and description; * We handle a dedicated admin page to conifugure the attachment types; * Attachments can be referred to any entity (activities, threads, troubles, etc); * To do so we have a simple html tag that can be included in the view to show the attachment form; * All attachments are saved in local folder after $upload_dir; * All attachment metadata are saved in the attachments table where we have customer_id (compulsory), be_id (not compulsory) and entity_key and entity_id (both compulsory). ==== How does is work ==== Attachment in WManager can be handled through a simple html tag that allows you to add attachments sections to yours web pages where you can add,delete or download attachments. It is handled through a angular directive that be used all around the application. The syntax to use it is.
**What are ambits?** Ambits are nothing but the entity to be which attachment will be added for eg. Activity,troubles etc. ^Parameter List | | ^attachment-refkey: |The key from setup_ambits table | ^attachment-refid: |The id reference for the ambid | ^custid: |The id field from clients table | ^beid: |The be_id for the customer | The tables in which the attachments will be stored is **attachment**. And the path in which the attachment will be stored is in the config value **UPLOAD_DIR**. Attachment type is taken from **list_ambits** table. If the **setup_attachment** table has more then one ambits it will show types in the dropdown list otherwise attach type will be taken from the hidden field. On saving the attachment, it will get stored in attachment table and the file will be upload in the configuration **folder/customer_id/attachment_id/file**. ^Controller FileName: |/common/new_attachment.php | ^Attachment List function: |attachment_list($ref_id, $ref_key) | ^Attachment Upload function: |upload($ref_key,$ref_id) | ^Attachment Delete function: |delete_file($attachment_id) | ^Attachment Download function: |download_file($attachment_id,$key,$id) | The library **Attachment_with_ref** will be used by this controller to perform all the upload operations.