# All files / js/pages/company-settings Create.vue

0% Statements 0/60
0% Branches 0/187
0% Functions 0/30
0% Lines 0/60

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440

     <script setup lang="ts">
    import AppLayout from '@/layouts/AppLayout.vue';
    import { Head, Link, useForm } from '@inertiajs/vue3';
    import { ArrowLeft } from 'lucide-vue-next';
    import companySettings from '@/routes/company-settings';
    import { ref } from 'vue';

    const form = useForm({
        name: '',
        email: '',
        phone: '',
        address: '',
        city: '',
        state: '',
        postal_code: '',
        country: '',
        vat_number: '',
        website: '',
        description: '',
        invoice_footer: '',
        jobcard_footer: '',
        quote_footer: '',
        default_invoice_terms: '',
        default_quote_terms: '',
        default_jobcard_terms: '',
        is_active: true,
        is_default: false,
        enable_pos: false,
        logo: null as File | null,
        bank_name: '',
        bank_account_name: '',
        bank_account_number: '',
        bank_sort_code: '',
    });

    const logoPreview = ref<string | null>(null);

    function handleLogoChange(event: Event) {
        const target = event.target as HTMLInputElement;
        if (target.files && target.files[0]) {
            form.logo = target.files[0];

            // Create preview
            const reader = new FileReader();
            reader.onload = (e) => {
                logoPreview.value = e.target?.result as string;
            };
            reader.readAsDataURL(target.files[0]);
        }
    }

    function submit() {
        form.post(companySettings.store().url, {
            forceFormData: true,
        });
    }
    </script>

    <template>
        <Head title="Create Company" />

        <AppLayout :breadcrumbs="[
            { title: 'Administration', href: '/administration' },
            { title: 'Company Settings', href: companySettings.index().url },
            { title: 'Create', href: '#' }
        ]">
            <div class="p-4">
                <!-- Header -->
                <div class="mb-6 flex items-center gap-4">
                    <Link
                        :href="companySettings.index().url"
                        class="flex items-center gap-2 text-gray-600 hover:text-gray-900"
                    >
                        <ArrowLeft class="h-4 w-4" />
                        Back to Companies
                    </Link>
                </div>

                <div class="mx-auto max-w-4xl">
                    <div class="mb-6">
                        <h1 class="text-2xl font-bold text-gray-900">Create New Company</h1>
                        <p class="text-gray-600">Add a new company to your organization</p>
                    </div>

                    <form @submit.prevent="submit" class="space-y-6">
                        <!-- Company Logo -->
                        <div class="rounded-lg border bg-white p-6">
                            <h2 class="mb-4 text-lg font-semibold text-gray-900">Company Logo</h2>
                            <div class="flex items-center gap-6">
                                <div v-if="logoPreview" class="h-20 w-20 overflow-hidden rounded-lg border">
                                    <img :src="logoPreview" alt="Company Logo" class="h-full w-full object-cover" />
                                </div>
                                <div>
                                    <input
                                        type="file"
                                        accept="image/*"
                                        @change="handleLogoChange"
                                        class="block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded-full file:border-0 file:text-sm file:font-semibold file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100"
                                    />
                                    <p class="mt-1 text-xs text-gray-500">PNG, JPG, GIF up to 2MB</p>
                                </div>
                            </div>
                        </div>

                        <!-- Company Information -->
                        <div class="rounded-lg border bg-white p-6">
                            <h2 class="mb-4 text-lg font-semibold text-gray-900">Company Information</h2>
                            <div class="grid gap-4 md:grid-cols-2">
                                <div>
                                    <label class="mb-1 block text-sm font-medium">Company Name *</label>
                                    <input
                                        v-model="form.name"
                                        type="text"
                                        class="w-full rounded border px-3 py-2"
                                        required
                                    />
                                    <div v-if="form.errors.name" class="mt-1 text-sm text-red-600">{{ form.errors.name }}</div>
                                </div>

                                <div>
                                    <label class="mb-1 block text-sm font-medium">Email</label>
                                    <input
                                        v-model="form.email"
                                        type="email"
                                        class="w-full rounded border px-3 py-2"
                                    />
                                    <div v-if="form.errors.email" class="mt-1 text-sm text-red-600">{{ form.errors.email }}</div>
                                </div>

                                <div>
                                    <label class="mb-1 block text-sm font-medium">Phone</label>
                                    <input
                                        v-model="form.phone"
                                        type="tel"
                                        class="w-full rounded border px-3 py-2"
                                    />
                                    <div v-if="form.errors.phone" class="mt-1 text-sm text-red-600">{{ form.errors.phone }}</div>
                                </div>

                                <div>
                                    <label class="mb-1 block text-sm font-medium">Website</label>
                                    <input
                                        v-model="form.website"
                                        type="url"
                                        class="w-full rounded border px-3 py-2"
                                    />
                                    <div v-if="form.errors.website" class="mt-1 text-sm text-red-600">{{ form.errors.website }}</div>
                                </div>
                            </div>
                        </div>

                        <!-- Address Information -->
                        <div class="rounded-lg border bg-white p-6">
                            <h2 class="mb-4 text-lg font-semibold text-gray-900">Address Information</h2>
                            <div class="space-y-4">
                                <div>
                                    <label class="mb-1 block text-sm font-medium">Address</label>
                                    <textarea
                                        v-model="form.address"
                                        rows="3"
                                        class="w-full rounded border px-3 py-2"
                                    ></textarea>
                                    <div v-if="form.errors.address" class="mt-1 text-sm text-red-600">{{ form.errors.address }}</div>
                                </div>

                                <div class="grid gap-4 md:grid-cols-3">
                                    <div>
                                        <label class="mb-1 block text-sm font-medium">City</label>
                                        <input
                                            v-model="form.city"
                                            type="text"
                                            class="w-full rounded border px-3 py-2"
                                        />
                                        <div v-if="form.errors.city" class="mt-1 text-sm text-red-600">{{ form.errors.city }}</div>
                                    </div>

                                    <div>
                                        <label class="mb-1 block text-sm font-medium">State/Province</label>
                                        <input
                                            v-model="form.state"
                                            type="text"
                                            class="w-full rounded border px-3 py-2"
                                        />
                                        <div v-if="form.errors.state" class="mt-1 text-sm text-red-600">{{ form.errors.state }}</div>
                                    </div>

                                    <div>
                                        <label class="mb-1 block text-sm font-medium">Postal Code</label>
                                        <input
                                            v-model="form.postal_code"
                                            type="text"
                                            class="w-full rounded border px-3 py-2"
                                        />
                                        <div v-if="form.errors.postal_code" class="mt-1 text-sm text-red-600">{{ form.errors.postal_code }}</div>
                                    </div>
                                </div>

                                <div>
                                    <label class="mb-1 block text-sm font-medium">Country</label>
                                    <input
                                        v-model="form.country"
                                        type="text"
                                        class="w-full rounded border px-3 py-2"
                                    />
                                    <div v-if="form.errors.country" class="mt-1 text-sm text-red-600">{{ form.errors.country }}</div>
                                </div>

                                <div>
                                    <label class="mb-1 block text-sm font-medium">VAT Number</label>
                                    <input
                                        v-model="form.vat_number"
                                        type="text"
                                        class="w-full rounded border px-3 py-2"
                                    />
                                    <div v-if="form.errors.vat_number" class="mt-1 text-sm text-red-600">{{ form.errors.vat_number }}</div>
                                </div>
                            </div>
                        </div>

                        <!-- Banking Details -->
                        <div class="rounded-lg border bg-white p-6">
                            <h2 class="mb-4 text-lg font-semibold text-gray-900">Banking Details</h2>
                            <p class="mb-4 text-sm text-gray-600">These details will appear on your PDF documents (invoices, quotes, jobcards).</p>
                            <div class="grid gap-4 md:grid-cols-2">
                                <div>
                                    <label class="mb-1 block text-sm font-medium">Bank Name</label>
                                    <input
                                        v-model="form.bank_name"
                                        type="text"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="e.g. FNB, Standard Bank, ABSA"
                                    />
                                    <div v-if="form.errors.bank_name" class="mt-1 text-sm text-red-600">{{ form.errors.bank_name }}</div>
                                </div>

                                <div>
                                    <label class="mb-1 block text-sm font-medium">Account Name</label>
                                    <input
                                        v-model="form.bank_account_name"
                                        type="text"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="Name on the account"
                                    />
                                    <div v-if="form.errors.bank_account_name" class="mt-1 text-sm text-red-600">{{ form.errors.bank_account_name }}</div>
                                </div>

                                <div>
                                    <label class="mb-1 block text-sm font-medium">Account Number</label>
                                    <input
                                        v-model="form.bank_account_number"
                                        type="text"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="Bank account number"
                                    />
                                    <div v-if="form.errors.bank_account_number" class="mt-1 text-sm text-red-600">{{ form.errors.bank_account_number }}</div>
                                </div>

                                <div>
                                    <label class="mb-1 block text-sm font-medium">Branch Code</label>
                                    <input
                                        v-model="form.bank_sort_code"
                                        type="text"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="e.g. 250655"
                                    />
                                    <div v-if="form.errors.bank_sort_code" class="mt-1 text-sm text-red-600">{{ form.errors.bank_sort_code }}</div>
                                </div>
                            </div>
                        </div>

                        <!-- Description -->
                        <div class="rounded-lg border bg-white p-6">
                            <h2 class="mb-4 text-lg font-semibold text-gray-900">Description</h2>
                            <div>
                                <label class="mb-1 block text-sm font-medium">Company Description</label>
                                <textarea
                                    v-model="form.description"
                                    rows="4"
                                    class="w-full rounded border px-3 py-2"
                                    placeholder="Tell us about your company..."
                                ></textarea>
                                <div v-if="form.errors.description" class="mt-1 text-sm text-red-600">{{ form.errors.description }}</div>
                            </div>
                        </div>

                        <!-- Document Footers -->
                        <div class="rounded-lg border bg-white p-6">
                            <h2 class="mb-4 text-lg font-semibold text-gray-900">Document Footers</h2>
                            <p class="mb-4 text-sm text-gray-600">These footer texts will appear at the bottom of the respective PDF documents.</p>

                            <div class="space-y-6">
                                <!-- Invoice Footer -->
                                <div>
                                    <label class="mb-1 block text-sm font-medium">Invoice Footer</label>
                                    <textarea
                                        v-model="form.invoice_footer"
                                        rows="4"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="Enter footer text that will appear on invoice PDFs (e.g., payment terms, thank you message, etc.)"
                                    ></textarea>
                                    <div v-if="form.errors.invoice_footer" class="mt-1 text-sm text-red-600">{{ form.errors.invoice_footer }}</div>
                                    <p class="mt-1 text-xs text-gray-500">This text will appear at the bottom of all invoice PDFs generated for this company.</p>
                                </div>

                                <!-- Quote Footer -->
                                <div>
                                    <label class="mb-1 block text-sm font-medium">Quote Footer</label>
                                    <textarea
                                        v-model="form.quote_footer"
                                        rows="4"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="Enter footer text that will appear on quote PDFs (e.g., validity period, terms, etc.)"
                                    ></textarea>
                                    <div v-if="form.errors.quote_footer" class="mt-1 text-sm text-red-600">{{ form.errors.quote_footer }}</div>
                                    <p class="mt-1 text-xs text-gray-500">This text will appear at the bottom of all quote PDFs generated for this company.</p>
                                </div>

                                <!-- Jobcard Footer -->
                                <div>
                                    <label class="mb-1 block text-sm font-medium">Jobcard Footer</label>
                                    <textarea
                                        v-model="form.jobcard_footer"
                                        rows="4"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="Enter footer text that will appear on jobcard PDFs (e.g., completion notes, warranty info, etc.)"
                                    ></textarea>
                                    <div v-if="form.errors.jobcard_footer" class="mt-1 text-sm text-red-600">{{ form.errors.jobcard_footer }}</div>
                                    <p class="mt-1 text-xs text-gray-500">This text will appear at the bottom of all jobcard PDFs generated for this company.</p>
                                </div>
                            </div>
                        </div>

                        <!-- Default Terms & Conditions -->
                        <div class="rounded-lg border bg-white p-6">
                            <h2 class="mb-4 text-lg font-semibold text-gray-900">Default Terms & Conditions</h2>
                            <p class="mb-4 text-sm text-gray-600">These terms will be automatically populated when creating new documents. They can be customized for each individual document.</p>

                            <div class="space-y-6">
                                <!-- Invoice Terms -->
                                <div>
                                    <label class="mb-1 block text-sm font-medium">Default Invoice Terms</label>
                                    <textarea
                                        v-model="form.default_invoice_terms"
                                        rows="4"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="Enter default terms and conditions for invoices (e.g., payment terms, late fees, etc.)"
                                    ></textarea>
                                    <div v-if="form.errors.default_invoice_terms" class="mt-1 text-sm text-red-600">{{ form.errors.default_invoice_terms }}</div>
                                    <p class="mt-1 text-xs text-gray-500">These terms will be pre-filled when creating new invoices.</p>
                                </div>

                                <!-- Quote Terms -->
                                <div>
                                    <label class="mb-1 block text-sm font-medium">Default Quote Terms</label>
                                    <textarea
                                        v-model="form.default_quote_terms"
                                        rows="4"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="Enter default terms and conditions for quotes (e.g., validity period, acceptance terms, etc.)"
                                    ></textarea>
                                    <div v-if="form.errors.default_quote_terms" class="mt-1 text-sm text-red-600">{{ form.errors.default_quote_terms }}</div>
                                    <p class="mt-1 text-xs text-gray-500">These terms will be pre-filled when creating new quotes.</p>
                                </div>

                                <!-- Jobcard Terms -->
                                <div>
                                    <label class="mb-1 block text-sm font-medium">Default Jobcard Terms</label>
                                    <textarea
                                        v-model="form.default_jobcard_terms"
                                        rows="4"
                                        class="w-full rounded border px-3 py-2"
                                        placeholder="Enter default terms and conditions for jobcards (e.g., warranty info, completion terms, etc.)"
                                    ></textarea>
                                    <div v-if="form.errors.default_jobcard_terms" class="mt-1 text-sm text-red-600">{{ form.errors.default_jobcard_terms }}</div>
                                    <p class="mt-1 text-xs text-gray-500">These terms will be pre-filled when creating new jobcards.</p>
                                </div>
                            </div>
                        </div>

                        <!-- Settings -->
                        <div class="rounded-lg border bg-white p-6">
                            <h2 class="mb-4 text-lg font-semibold text-gray-900">Settings</h2>
                            <div class="space-y-4">
                                <div>
                                    <label class="flex items-center gap-2">
                                        <input
                                            v-model="form.is_active"
                                            type="checkbox"
                                            class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                        />
                                        <span class="text-sm font-medium text-gray-700">Active (available for selection)</span>
                                    </label>
                                </div>

                                <div>
                                    <label class="flex items-center gap-2">
                                        <input
                                            v-model="form.is_default"
                                            type="checkbox"
                                            class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                        />
                                        <span class="text-sm font-medium text-gray-700">Set as default company</span>
                                    </label>
                                </div>

                                <div>
                                    <label class="flex items-center gap-2">
                                        <input
                                            v-model="form.enable_pos"
                                            type="checkbox"
                                            class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
                                        />
                                        <span class="text-sm font-medium text-gray-700">Enable Point of Sale (POS)</span>
                                    </label>
                                </div>
                            </div>
                        </div>

                        <!-- Form Actions -->
                        <div class="flex items-center justify-end gap-4">
                            <Link
                                :href="companySettings.index().url"
                                class="rounded-md border border-gray-300 px-4 py-2 text-gray-700 hover:bg-gray-50"
                            >
                                Cancel
                            </Link>
                            <button
                                type="submit"
                                :disabled="form.processing"
                                class="rounded-md bg-blue-600 px-4 py-2 text-white hover:bg-blue-700 disabled:opacity-50"
                            >
                                {{ form.processing ? 'Creating...' : 'Create Company' }}
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </AppLayout>
    </template>