@include('admin::layouts.header')
<main id="main-container">
        <!-- Hero -->
        <div class="bg-body-light">
          <div class="content content-full">
            <div class="d-flex flex-column flex-sm-row justify-content-sm-between align-items-sm-center">
              <h1 class="flex-grow-1 fs-3 fw-semibold my-2 my-sm-3">Add Supplier</h1>
              <nav class="flex-shrink-0 my-2 my-sm-0 ms-sm-3" aria-label="breadcrumb">
                <ol class="breadcrumb">
                  <li class="breadcrumb-item">Dashboard</li>
                  <li class="breadcrumb-item">Supplier</li>
                  <li class="breadcrumb-item active" aria-current="page">Add Supplier</li>
                </ol>
              </nav>
            </div>
          </div>
        </div>
        <!-- END Hero -->

        <!-- Page Content -->
        <div class="content">
          <!-- Your Block -->
          <div class="block block-rounded">
            <div class="block-header block-header-default">
              <h3 class="block-title">Add Supplier</h3>
            </div>
            <div class="block-content">
            @if(Session::has('success')) <div class="alert alert-success mt-2 mb-2">{{ Session::get('success') }}</div>@endif
            @if(Session::has('fail')) <div class="alert alert-danger mt-2 mb-2">{{ Session::get('fail') }}</div>@endif
            <form class="row" action="" method="POST" >
            @csrf
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Supplier Name</label>
                      <input type="text" class="form-control" name="suplier_name">
                      @if($errors->has("suplier_name")) <div class="alert alert-danger mt-2">{{ $errors->first('suplier_name') }}</div>@endif
                    </div>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Supplier ID</label>
                      <input type="text" class="form-control" name="suplier_id">
                      @if($errors->has("suplier_id")) <div class="alert alert-danger mt-2">{{ $errors->first('suplier_id') }}</div>@endif
                    </div>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Contact Details</label>
                      <input type="text" class="form-control" name="contact_details">
                      @if($errors->has("contact_details")) <div class="alert alert-danger mt-2">{{ $errors->first('contact_details') }}</div>@endif
                    </div>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Associated Company</label>
                      <select class="js-select2 form-select" id="example-select2" name="associated_company" style="width: 100%;" data-placeholder="Choose one..">
                        <?php foreach($companies as $company) { ?> 
                        <option value="{{$company->id}}">{{$company->company_name}}</option>
                        <?php } ?>
                      </select>
                      @if($errors->has("associated_company")) <div class="alert alert-danger mt-2">{{ $errors->first('associated_company') }}</div>@endif
                    </div>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Email</label>
                      <input type="text" class="form-control" name="email">
                      @if($errors->has("email")) <div class="alert alert-danger mt-2">{{ $errors->first('email') }}</div>@endif
                    </div>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Phone Number</label>
                      <input type="text" class="form-control" name="phone_number">
                      @if($errors->has("phone_number")) <div class="alert alert-danger mt-2">{{ $errors->first('phone_number') }}</div>@endif
                    </div>
          
                    <div>
                      <button type="submit" class="btn btn-primary">Save</button>
                    </div>
                  </form>
            </div>
          </div>
          <!-- END Your Block -->
        </div>
        <!-- END Page Content -->
</main>
<!-- END Main Container -->
@include('admin::layouts.footer')