355 lines
18 KiB
PHP
355 lines
18 KiB
PHP
<?php
|
|
|
|
print_r($status_counts);
|
|
?>
|
|
|
|
<div class="wrap">
|
|
<h1>Gestion des crédits</h1>
|
|
|
|
<!-- Bouton pour créer un nouveau crédit -->
|
|
<div class="credit-actions-header">
|
|
<button type="button" class="button button-primary" onclick="openCreditModal()">
|
|
<span class="dashicons dashicons-plus-alt"></span> Nouveau crédit
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Formulaire de filtres -->
|
|
<div class="credit-filters-panel">
|
|
<h3>
|
|
<span class="dashicons dashicons-filter"></span> Filtres
|
|
<button type="button" class="button button-small" id="toggle-filters" style="float: right;">
|
|
<span class="dashicons dashicons-arrow-down-alt2"></span> Afficher/Masquer
|
|
</button>
|
|
</h3>
|
|
<form id="credit-filters-form" style="display: none;">
|
|
<div class="filters-grid">
|
|
<div class="filter-group">
|
|
<label for="filter-societe">Société de crédit</label>
|
|
<select id="filter-societe" name="societe_credit">
|
|
<option value="">-- Toutes --</option>
|
|
<?php if (!empty($societes_credit)): ?>
|
|
<?php foreach ($societes_credit as $societe): ?>
|
|
<option value="<?php echo esc_attr($societe->nom); ?>">
|
|
<?php echo esc_html($societe->nom); ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="filter-group">
|
|
<label for="filter-code-postal">Code postal</label>
|
|
<input type="text" id="filter-code-postal" name="code_postal" placeholder="Ex: 1000">
|
|
</div>
|
|
|
|
<div class="filter-group">
|
|
<label for="filter-status">Status</label>
|
|
<select id="filter-status" name="status">
|
|
<option value="">-- Tous --</option>
|
|
<option value="0">En attente</option>
|
|
<option value="1">Accepté non signé</option>
|
|
<option value="2">Accepté signé</option>
|
|
<option value="-1">Refusé</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="filter-group">
|
|
<label for="filter-type">Groupe de crédit</label>
|
|
<select id="filter-type" name="type_credit">
|
|
<option value="">-- Tous --</option>
|
|
<option value="PAT">PAT - Prêt à tempérament</option>
|
|
<option value="CH">PH - Crédit hypothécaire</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="filter-group">
|
|
<label for="filter-credit-code">Type de crédit</label>
|
|
<select id="filter-credit-code" name="credit_code_select">
|
|
<option value="">-- Tous --</option>
|
|
|
|
<optgroup label="Prêt à tempérament (PAT)">
|
|
<?php foreach ($creditTypes as $code => $label): ?>
|
|
<option value="<?php echo esc_attr($code); ?>">
|
|
<?php echo esc_html($label); ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</optgroup>
|
|
|
|
<optgroup label="Crédit hypothécaire (PH)">
|
|
<?php foreach ($houseCreditTypes as $code => $label): ?>
|
|
<option value="<?php echo esc_attr($code); ?>">
|
|
<?php echo esc_html($label); ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</optgroup>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="filter-group filter-range">
|
|
<label>Montant (€)</label>
|
|
<div class="range-inputs">
|
|
<input type="number" id="filter-montant-min" name="montant_min" placeholder="Min" step="100">
|
|
<span>-</span>
|
|
<input type="number" id="filter-montant-max" name="montant_max" placeholder="Max" step="100">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="filter-group filter-range">
|
|
<label>Date de signature</label>
|
|
<div class="range-inputs">
|
|
<input type="date" id="filter-date-debut" name="date_signature_debut" placeholder="Début">
|
|
<span>-</span>
|
|
<input type="date" id="filter-date-fin" name="date_signature_fin" placeholder="Fin">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="filter-group">
|
|
<label>Situation habitation</label>
|
|
<div class="habitation-filter">
|
|
<label class="checkbox-label">
|
|
<input type="checkbox" id="filter-locataire" name="habitation_locataire" value="1">
|
|
Locataire
|
|
</label>
|
|
<label class="checkbox-label">
|
|
<input type="checkbox" id="filter-proprietaire" name="habitation_proprietaire" value="1">
|
|
Propriétaire
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="filter-actions">
|
|
<button type="submit" class="button button-primary">
|
|
<span class="dashicons dashicons-search"></span> Filtrer
|
|
</button>
|
|
<button type="button" class="button" id="reset-filters">
|
|
<span class="dashicons dashicons-image-rotate"></span> Réinitialiser
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Filtres rapides par statut -->
|
|
<div class="status-quick-filters">
|
|
<h3>Filtres rapides par statut</h3>
|
|
<div class="status-filters-buttons">
|
|
<button type="button" class="status-filter-btn status-pending" data-status="0" title="Filtrer les crédits à valider">
|
|
<span class="status-icon"><i class="fa-solid fa-clock"></i></span>
|
|
<span class="status-label">À valider</span>
|
|
<span class="status-count" data-count-status="0">(<?php echo isset($status_counts['0']) ? $status_counts['0'] : 0; ?>)</span>
|
|
</button>
|
|
|
|
<button type="button" class="status-filter-btn status-accepted-unsigned" data-status="1" title="Filtrer les crédits validés non signés">
|
|
<span class="status-icon"><i class="fa-solid fa-check"></i></span>
|
|
<span class="status-label">Validé non signé</span>
|
|
<span class="status-count" data-count-status="1">(<?php echo isset($status_counts['1']) ? $status_counts['1'] : 0; ?>)</span>
|
|
</button>
|
|
|
|
<button type="button" class="status-filter-btn status-accepted-filed" data-status="2" title="Filtrer les crédits validés classés">
|
|
<span class="status-icon"><i class="fa-solid fa-box-archive"></i></span>
|
|
<span class="status-label">Validé classé</span>
|
|
<span class="status-count" data-count-status="2">(<?php echo isset($status_counts['2']) ? $status_counts['2'] : 0; ?>)</span>
|
|
</button>
|
|
|
|
<button type="button" class="status-filter-btn status-refused" data-status="-1" title="Filtrer les crédits refusés">
|
|
<span class="status-icon"><i class="fa-solid fa-xmark"></i></span>
|
|
<span class="status-label">Refusé</span>
|
|
<span class="status-count" data-count-status="-1">(<?php echo isset($status_counts['-1']) ? $status_counts['-1'] : 0; ?>)</span>
|
|
</button>
|
|
|
|
<button type="button" class="status-filter-btn status-filter-all active" data-status="" title="Afficher tous les crédits">
|
|
<span class="status-icon"><i class="fa-solid fa-list"></i></span>
|
|
<span class="status-label">Tous</span>
|
|
<span class="status-count" id="total-count">(<?php echo isset($total_credits) ? $total_credits : 0; ?>)</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Table simple -->
|
|
<table id="credits-table" class="wp-list-table widefat striped">
|
|
<thead>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>Type</th>
|
|
<th>Nom</th>
|
|
<th>Prénom</th>
|
|
<th>Adresse</th>
|
|
<th>Localité</th>
|
|
<th>Email</th>
|
|
<th>Téléphone/GSM</th>
|
|
<th>Société de crédit</th>
|
|
<th>Montant</th>
|
|
<th>Date</th>
|
|
<th>Signature</th>
|
|
<th>N° de dossier</th>
|
|
<th>Code</th>
|
|
<th>Statut</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<!-- Les données seront chargées via AJAX par DataTables -->
|
|
</tbody>
|
|
</table>
|
|
|
|
<!-- Modal pour créer/modifier un crédit -->
|
|
<div class="credit-modal" style="display: none;">
|
|
<div class="credit-modal-content">
|
|
<div class="credit-modal-header">
|
|
<h2>Nouveau crédit</h2>
|
|
<span class="credit-modal-close" onclick="closeCreditModal()">×</span>
|
|
</div>
|
|
|
|
<form id="credit-form" class="credit-form">
|
|
<div class="form-columns">
|
|
<!-- Colonne gauche -->
|
|
<div class="form-column">
|
|
<div class="form-group">
|
|
<label for="credit-type">Type de crédit <span class="required">*</span></label>
|
|
<select id="credit-type" name="type_credit" required>
|
|
<option value="">-- Sélectionner --</option>
|
|
<option value="PAT">PAT - Prêt à tempérament</option>
|
|
<option value="CH">CH - Crédit hypothécaire</option>
|
|
<option value="CA">CA - Crédit auto</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="credit-nom">Nom <span class="required">*</span></label>
|
|
<input type="text" id="credit-nom" name="nom" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="credit-prenom">Prénom <span class="required">*</span></label>
|
|
<input type="text" id="credit-prenom" name="prenom" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="credit-email">Email <span class="required">*</span></label>
|
|
<input type="email" id="credit-email" name="email" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="credit-telephone">Téléphone</label>
|
|
<input type="tel" id="credit-telephone" name="telephone">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="credit-gsm">GSM</label>
|
|
<input type="tel" id="credit-gsm" name="gsm">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="credit-type-habitation">Type d'habitation</label>
|
|
<select id="credit-type-habitation" name="type_habitation">
|
|
<option value="">-- Sélectionner --</option>
|
|
<option value="locataire">Locataire</option>
|
|
<option value="proprietaire">Propriétaire</option>
|
|
<option value="proprietaire_sans_pret">Propriétaire sans prêt</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="credit-societe">Société de crédit</label>
|
|
<select id="credit-societe" name="societe_credit">
|
|
<option value="">-- Sélectionner une société --</option>
|
|
<?php if (!empty($societes_credit)): ?>
|
|
<?php foreach ($societes_credit as $societe): ?>
|
|
<option value="<?php echo esc_attr($societe->nom); ?>">
|
|
<?php echo esc_html($societe->nom); ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="credit-montant">Montant (€)</label>
|
|
<input type="number" id="credit-montant" name="montant" step="0.01" min="0">
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Colonne droite -->
|
|
<div class="form-column">
|
|
|
|
<div class="form-group">
|
|
<label for="credit-code">But du crédit <span class="required">*</span></label>
|
|
<select id="credit-code" name="code" required>
|
|
<option value="">-- Sélectionner --</option>
|
|
|
|
<optgroup label="Prêt à tempérament (PAT)">
|
|
<?php foreach ($creditTypes as $code => $label): ?>
|
|
<option value="<?php echo esc_attr($code); ?>">
|
|
<?php echo esc_html($label); ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</optgroup>
|
|
|
|
<optgroup label="Crédit hypothécaire (PH)">
|
|
<?php foreach ($houseCreditTypes as $code => $label): ?>
|
|
<option value="<?php echo esc_attr($code); ?>">
|
|
<?php echo esc_html($label); ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</optgroup>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="credit-localite">Localité</label>
|
|
<input type="text" id="credit-localite" name="localite">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="credit-date">Date</label>
|
|
<input type="date" id="credit-date" name="date">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="credit-signature">Signature</label>
|
|
<input type="text" id="credit-signature" name="signature">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="credit-numero-dossier">N° de dossier</label>
|
|
<input type="text" id="credit-numero-dossier" name="numero_dossier">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="credit-code">Code</label>
|
|
<input type="text" id="credit-code" name="code">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="credit-adresse">Adresse</label>
|
|
<input type="text" id="credit-adresse" name="adresse">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Remarques en une seule colonne -->
|
|
<div class="form-group-full">
|
|
<label for="credit-remarques">Remarques</label>
|
|
<textarea id="credit-remarques" name="remarques" rows="4"></textarea>
|
|
</div>
|
|
|
|
<div class="form-actions">
|
|
<button type="button" class="button button-primary" onclick="saveCredit()">
|
|
<span class="dashicons dashicons-yes"></span> Sauvegarder
|
|
</button>
|
|
<button type="button" class="button" onclick="closeCreditModal()">
|
|
<span class="dashicons dashicons-no"></span> Annuler
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
// Les assets sont gérés par le factory dans enqueue_credit_manager_assets()
|
|
?>
|
|
|
|
|
|
<?php
|
|
?>
|