add CRM module start
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
{% extends 'layouts/base.twig' %}
|
||||
|
||||
{% block title %}{{ title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-8">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h3 mb-0">{{ title }}</h1>
|
||||
<a href="{{ site_url('/crm/contacts') }}" class="btn btn-outline-secondary">
|
||||
<i class="fa-solid fa-arrow-left me-2"></i>К списку
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{# Сообщения об ошибках #}
|
||||
{% if errors is defined and errors|length > 0 %}
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<ul class="mb-0">
|
||||
{% for error in errors %}
|
||||
<li>{{ error }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<form method="POST" action="{{ actionUrl }}">
|
||||
{{ csrf_field()|raw }}
|
||||
|
||||
{% if contact is defined %}
|
||||
<input type="hidden" name="_method" value="PUT">
|
||||
{% endif %}
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label fw-bold">Имя *</label>
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
id="name"
|
||||
name="name"
|
||||
value="{{ old.name|default(contact.name|default('')) }}"
|
||||
required
|
||||
placeholder="Иван Иванов">
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-6">
|
||||
<label for="email" class="form-label fw-bold">Email</label>
|
||||
<input type="email"
|
||||
class="form-control"
|
||||
id="email"
|
||||
name="email"
|
||||
value="{{ old.email|default(contact.email|default('')) }}"
|
||||
placeholder="email@example.com">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="phone" class="form-label fw-bold">Телефон</label>
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
id="phone"
|
||||
name="phone"
|
||||
value="{{ old.phone|default(contact.phone|default('')) }}"
|
||||
placeholder="+7 (999) 123-45-67">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-6">
|
||||
<label for="position" class="form-label fw-bold">Должность</label>
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
id="position"
|
||||
name="position"
|
||||
value="{{ old.position|default(contact.position|default('')) }}"
|
||||
placeholder="Менеджер, Директор...">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="customer_id" class="form-label fw-bold">Клиент</label>
|
||||
<select class="form-select" id="customer_id" name="customer_id">
|
||||
<option value="">Не привязан</option>
|
||||
{% for client in clients %}
|
||||
<option value="{{ client.id }}"
|
||||
{{ (old.customer_id|default(contact.customer_id|default(''))) == client.id ? 'selected' : '' }}>
|
||||
{{ client.name }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="notes" class="form-label fw-bold">Заметки</label>
|
||||
<textarea class="form-control"
|
||||
id="notes"
|
||||
name="notes"
|
||||
rows="3"
|
||||
placeholder="Дополнительная информация...">{{ old.notes|default(contact.notes|default('')) }}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input"
|
||||
type="checkbox"
|
||||
id="is_primary"
|
||||
name="is_primary"
|
||||
value="1"
|
||||
{{ (old.is_primary|default(contact.is_primary|default(false))) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="is_primary">
|
||||
Основной контакт клиента
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end gap-2 pt-3 border-top">
|
||||
<a href="{{ site_url('/crm/contacts') }}" class="btn btn-outline-secondary">Отмена</a>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fa-solid fa-check me-2"></i>
|
||||
{{ contact is defined ? 'Сохранить' : 'Создать' }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,89 @@
|
||||
{% extends 'layouts/base.twig' %}
|
||||
|
||||
{% block title %}{{ title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h1 class="h3 mb-0">{{ title }}</h1>
|
||||
</div>
|
||||
<a href="{{ site_url('/crm/contacts/create') }}" class="btn btn-primary">
|
||||
<i class="fa-solid fa-plus me-2"></i>Добавить контакт
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{# Сообщения #}
|
||||
{% if success is defined %}
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
{{ success }}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body p-0">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th>Имя</th>
|
||||
<th>Email</th>
|
||||
<th>Телефон</th>
|
||||
<th>Должность</th>
|
||||
<th>Клиент</th>
|
||||
<th class="text-end" style="width: 120px;">Действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for contact in contacts %}
|
||||
<tr>
|
||||
<td>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<div class="bg-primary rounded-circle d-flex align-items-center justify-content-center"
|
||||
style="width: 32px; height: 32px; min-width: 32px;">
|
||||
<span class="text-white small">{{ contact.name|slice(0, 2)|upper }}</span>
|
||||
</div>
|
||||
<span class="fw-medium">{{ contact.name }}</span>
|
||||
{% if contact.is_primary %}
|
||||
<span class="badge bg-success" style="font-size: 0.7rem;">Основной</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
<td>{{ contact.email ?: '—' }}</td>
|
||||
<td>{{ contact.phone ?: '—' }}</td>
|
||||
<td>{{ contact.position ?: '—' }}</td>
|
||||
<td>
|
||||
{% if contact.customer_id %}
|
||||
<span class="text-muted">{{ contact.customer_id }}</span>
|
||||
{% else %}
|
||||
<span class="text-muted">—</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<a href="{{ site_url('/crm/contacts/' ~ contact.id ~ '/edit') }}"
|
||||
class="btn btn-outline-primary btn-sm" title="Редактировать">
|
||||
<i class="fa-solid fa-pen"></i>
|
||||
</a>
|
||||
<form action="{{ site_url('/crm/contacts/' ~ contact.id) }}" method="POST" class="d-inline">
|
||||
{{ csrf_field()|raw }}
|
||||
<input type="hidden" name="_method" value="DELETE">
|
||||
<button type="submit" class="btn btn-outline-danger btn-sm"
|
||||
onclick="return confirm('Удалить контакт?')" title="Удалить">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="6" class="text-center py-4 text-muted">
|
||||
Контактов пока нет
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user