English
Spanish
French
0
Notifications
0 Non lues
Aucune notification
Voir toutes
Aucune nouvelle notification
Raccourcis
Tableau de bord
Profil
Paramètres
Voir toutes les apps
Utilisateur
Utilisateur
Profil
Messages
25
Paramètres
Solde
$47.12
Support
Se déconnecter
Dashboard
Dashboard
Éditer components/document_workflow_buttons.php
/** * Composant réutilisable pour les boutons de transformation de documents * À intégrer dans les vues show/edit des documents */ // Exemple d'intégration dans une vue de devis ?> <div class="card mt-4"> <div class="card-header d-flex justify-content-between align-items-center"> <h5 class="card-title mb-0">Actions sur le document</h5> <span class="badge bg-<?= $statusColor ?>"><?= $devis['statut'] ?></span> </div> <div class="card-body"> <div class="row"> <!-- Transformation en commande --> <?php if ($devis['statut'] === 'En attente' || $devis['statut'] === 'Validé'): ?> <div class="col-md-3"> <button type="button" class="btn btn-success w-100" onclick="transformerDocument('devis', '<?= $devis['id'] ?>', 'commande')"> <i class="bx bx-package"></i> <br><small>Transformer en</small> <br><strong>Commande</strong> </button> </div> <?php endif; ?> <!-- Si déjà une commande, proposer livraison --> <?php if (isset($commande_id)): ?> <div class="col-md-3"> <button type="button" class="btn btn-warning w-100" onclick="transformerDocument('commande', '<?= $commande_id ?>', 'livraison')"> <i class="bx bx-truck"></i> <br><small>Générer</small> <br><strong>Bon de Livraison</strong> </button> </div> <?php endif; ?> <!-- Si livraison, proposer facturation --> <?php if (isset($livraison_id)): ?> <div class="col-md-3"> <button type="button" class="btn btn-primary w-100" onclick="transformerDocument('livraison', '<?= $livraison_id ?>', 'facture')"> <i class="bx bx-receipt"></i> <br><small>Transformer en</small> <br><strong>Facture</strong> </button> </div> <?php endif; ?> <!-- Actions supplémentaires --> <div class="col-md-3"> <div class="dropdown"> <button class="btn btn-outline-secondary w-100 dropdown-toggle" type="button" data-bs-toggle="dropdown"> <i class="bx bx-dots-vertical"></i> <br><small>Plus</small> <br><strong>d'actions</strong> </button> <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#" onclick="dupliquerDocument()"> <i class="bx bx-copy"></i> Dupliquer </a></li> <li><a class="dropdown-item" href="#" onclick="exporterPDF()"> <i class="bx bx-download"></i> Exporter PDF </a></li> <li><a class="dropdown-item" href="#" onclick="envoyerEmail()"> <i class="bx bx-envelope"></i> Envoyer par email </a></li> <li><hr class="dropdown-divider"></li> <li><a class="dropdown-item text-danger" href="#" onclick="annulerDocument()"> <i class="bx bx-x"></i> Annuler </a></li> </ul> </div> </div> </div> <!-- Historique des transformations --> <?php if (!empty($historique_transformations)): ?> <div class="mt-4"> <h6>Historique des transformations</h6> <div class="timeline"> <?php foreach ($historique_transformations as $transformation): ?> <div class="timeline-item"> <div class="timeline-marker bg-<?= $transformation['color'] ?>"></div> <div class="timeline-content"> <h6 class="timeline-title"><?= $transformation['action'] ?></h6> <p class="timeline-desc"> <?= $transformation['description'] ?> <br><small class="text-muted"><?= $transformation['date'] ?></small> </p> <a href="<?= $transformation['lien'] ?>" class="btn btn-sm btn-outline-primary"> Voir le document </a> </div> </div> <?php endforeach; ?> </div> </div> <?php endif; ?> </div> </div> <script> /** * JavaScript pour la transformation de documents */ function transformerDocument(typeSource, idSource, typeDestination) { // Confirmation avant transformation Swal.fire({ title: 'Confirmer la transformation', text: `Voulez-vous transformer ce ${typeSource} en ${typeDestination} ?`, icon: 'question', showCancelButton: true, confirmButtonText: 'Oui, transformer', cancelButtonText: 'Annuler', confirmButtonColor: '#3085d6' }).then((result) => { if (result.isConfirmed) { // Afficher le loader Swal.fire({ title: 'Transformation en cours...', allowOutsideClick: false, didOpen: () => { Swal.showLoading() } }); // Appel AJAX fetch('/documents/transformer', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Requested-With': 'XMLHttpRequest' }, body: JSON.stringify({ type_source: typeSource, id_source: idSource, type_destination: typeDestination }) }) .then(response => response.json()) .then(data => { Swal.close(); if (data.success) { Swal.fire({ title: 'Transformation réussie !', text: data.message, icon: 'success', showCancelButton: true, confirmButtonText: 'Voir le nouveau document', cancelButtonText: 'Rester ici' }).then((result) => { if (result.isConfirmed) { window.location.href = data.redirect_url; } else { // Recharger la page actuelle pour voir les changements location.reload(); } }); } else { Swal.fire({ title: 'Erreur', text: data.message, icon: 'error' }); } }) .catch(error => { Swal.close(); Swal.fire({ title: 'Erreur', text: 'Une erreur est survenue lors de la transformation', icon: 'error' }); console.error('Erreur:', error); }); } }); } function dupliquerDocument() { // Logique de duplication console.log('Duplication du document'); } function exporterPDF() { // Logique d'export PDF window.open('/documents/pdf/' + getCurrentDocumentId(), '_blank'); } function envoyerEmail() { // Modal pour envoyer par email $('#emailModal').modal('show'); } function annulerDocument() { Swal.fire({ title: 'Confirmer l\'annulation', text: 'Cette action est irréversible', icon: 'warning', showCancelButton: true, confirmButtonText: 'Oui, annuler', cancelButtonText: 'Non', confirmButtonColor: '#d33' }).then((result) => { if (result.isConfirmed) { // Logique d'annulation } }); } function getCurrentDocumentId() { // Récupérer l'ID du document actuel return window.location.pathname.split('/').pop(); } </script> <style> .timeline { position: relative; padding-left: 30px; } .timeline::before { content: ''; position: absolute; left: 15px; top: 0; bottom: 0; width: 2px; background: #e3e6f0; } .timeline-item { position: relative; margin-bottom: 20px; } .timeline-marker { position: absolute; left: -23px; top: 5px; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; } .timeline-content { background: #f8f9fc; padding: 15px; border-radius: 5px; border-left: 3px solid #5a5c69; } .timeline-title { margin: 0 0 5px 0; font-size: 14px; font-weight: 600; } .timeline-desc { margin: 0 0 10px 0; font-size: 13px; color: #5a5c69; } /* Boutons de transformation */ .btn .bx { font-size: 1.5rem; margin-bottom: 5px; } </style>
Annuler
Enregistrer
Switcher
Theme Styles
Theme Colors
Theme Color Mode:
Light
Dark
Menu Colors: