Production Create Form User Manual

This manual provides a detailed step-by-step technical explanation of the resources/views/backend/production/create.blade.php form, including its details, code structure, related controller functions, models, database tables, and views.

1. Overview

The Production Form is designed to manage and track the manufacturing or fabrication process of finished goods. The form is conceptually divided into two major sections:

2. Related Models and Database Tables

The form interacts with the following core database tables and Eloquent models to persist and validate production data:

Model Database Table Description
Production productions Stores the core master details of the production entry (e.g., date, total values, reference, status).
StockOut stock_outs Stores the details of raw materials consumed (Item identity, quantity, rate, etc.).
StockIn stock_ins Stores the details of the finished products generated along with their manufactured base rates.
Inventory / ItemInventory inventories / item_inventories Tracks all items system-wide and maintains the stock ledger (transaction history for in/out operations).
ProductPriceList product_price_lists Maintains specific pricing, barcodes, expirations, and available quantity logic for inventory control.
ProductionFromSetting production_from_settings Configuration model deciding which specific columns (barcode, warranty, dates) be displayed on the form interface.

3. Related Views & Blade Directives

The form orchestrates multiple blade templates to function correctly:

4. Step-by-Step Form Elements & Structure

The form is submitted via a POST request utilizing route('production.store'). Below is a breakdown of the form's structural components.

A. Header and Basic Details

B. Stock Out Section (Raw Material Consumption)

Displays an interactive table where the user adds raw items being heavily utilized. Powered by backend.production.stock_out_script.

C. Stock In Section (Finished Products Generation)

Similarly interactive table mapping finished products. Defined and appended by backend.production.stock_in_script.

D. Footer Details

5. The Controller (ProductionController.php) Logic

Method: create()

Prepares data constants before injection into the standard web-view. It gathers all standard relations such as Account Types, User-permitted branches, Voucher instances, Units, Categories, settings, and loads up backend.production.create with necessary compact() data parameters.

Method: store()

Handles the primary POST logic ensuring ACID compliant DB manipulations via DB::beginTransaction(). The processing procedure involves multiple steps:

  1. Validation: Ensures fields like branch, date, type, and form names exist securely.
  2. Master Production Entry: Creates the Production model with overall transaction summaries, statuses, and locations. Returns an inserted parent id.
  3. Stock Out Processing Iteration:
    • Loops through all requested _item_id[] objects.
    • Reduces quantities natively inside ProductPriceList.
    • Generates individual StockOut detail rows bridging with the new master production id.
    • Inserts negated quantity amounts into ItemInventory. This step physically decrements raw materials.
  4. Stock In Processing Iteration:
    • Loops through all _stock_in__item_id[] finished entities.
    • Stores them rigidly into StockIn binding to the parent.
    • Develops new entries in ProductPriceList (assigning fresh generated barcodes natively or utilizing previous).
    • Posts positive balance quantities into ItemInventory tracking up the stock count of forged final goods.
  5. Accounting Journals Logging: Validates Production setting variables and executes account_data_save() multiple times based entirely on _p_status (for instance: moving value to a "Transit Account", or migrating it securely between Inventory ledger hierarchies).
  6. Database Commit: DB::commit() solidifies changes avoiding data corruption, subsequently routing the user backwards with Success flash notifications.