Objective:
The objective of this assignment is to create a simple PHP application to perform CRUD (Create, Read, Update, Delete) operations using a flat-file (no database). This will enable students to practice using arrays, iterations, conditional statements, and user-defined functions. Students will also have the opportunity to use Bootstrap in their application to present their content/pages responsively.
Operations:
Implement a user-friendly interface to allow users to create & manage records (CRUD operations). You may assume you are building the back-end portion of an application, which the owner of a store/company will use to manage the inventory. This store sells TVs of certain brands. a) Create â Consists of a form that allows users to enter information about a new record. A dedicated function should be responsible to handle adding a record to the CSV file. If insufficient data are submitted (empty/invalid data), the user should be notified and given the chance to meet the required field/s without re-entering data that was already inputted. Once the data is validated, your function should generate a unique id for the record and generate a 5-digit random number to be used as an item number. Your function would then append the record to the CSV file. The form should contain the following fields/controls: Required fields are indicated by * (asterisk) - Type * dropdown menu with following options: - Brand * radio buttons with the following options: - Model: string * - Size: Integer value represents TV size in inches * - Price: floating number up to two decimals * - Sale: floating number up to two decimals to display when a TV is on sale - Description: Text field to be used to input more info (specs) about a tv. Note: text typed in this field may contain commas, so your logic should be able to handle that (comma typed in this field should not be treated as a delimiter).
b) Read â a. Allow users to preview all records. This function would not alter the records - it would simply retrieve the resource and make it available to your controller/view to be displayed in a tabular format. The table should contain the following columns: If a TV is on sale (sale price field contains value), the sale price should be displayed instead of the original price (in red colour) as demonstrated in the example above. This view would be the default landing page for your application. It should also allow users to select: read, update, or delete an individual record if they wish. b. You should also have a function to retrieve a single record. All data (related to a single record) should be presented to the user in read-only (none-editable) format. The page should give the user an option to click to get back to the main view. To make it more user-friendly, you could provide an edit & delete buttons on this page to trigger your update/delete functionality (reusability). c) Update â Consists of a form where information about an existing record would be presented in edit mode. A dedicated function should handle the submission of this form. This function saves the record back in the CSV file without assigning a new id (the original id of the record should not change). d) Delete â There should be a function to call to remove a record from the CSV file. Users should be prompted to confirm the removal of any record to ensure they did not accidentally request that action.
e) Search â user should be able to search for a record by item number
f) Filtering records in main view â user should be able to filter out records to only view TVs of a specific brand:
g) Export the data as a CSV file â This feature (a link/button) will trigger a function that downloads the CSV file from server to userâs machine.
h) Import the data in CSV format â This feature allows the user to upload a CSV file to be used by your application. Note: you must name the new file as your original data file used by your application (replacing the existing one). Each task must be handled by a dedicated function, and