Browse Source

CL-561 ajout des transactions dans l'espace admin

raphael 4 years ago
parent
commit
265269f0b4

+ 34
- 0
src/CaptainLearning/Controller/BackOffice/Admin/TransactionController.php View File

@@ -0,0 +1,34 @@
1
+<?php
2
+namespace Logipro\CaptainLearning\Controller\BackOffice\Admin;
3
+
4
+use Symfony\Component\HttpFoundation\Request;
5
+use Symfony\Component\HttpFoundation\Response;
6
+use Logipro\CaptainLearning\Entity\Transaction;
7
+use Logipro\CaptainLearning\Component\Filter\Filter;
8
+use Logipro\CaptainLearning\Entity\Type\EnumTransactionStatutType;
9
+use Logipro\CaptainLearning\Controller\BackOffice\BackOfficeController;
10
+
11
+class TransactionController extends AdminController
12
+{
13
+	public function drawTransactions(Request $request,$trainingOrganizationId)
14
+	{
15
+		$this->denyAccessUnlessGranted('ROLE_ADMIN');
16
+
17
+		$manager = $this->getDoctrine()->getManager();
18
+		$repository = $manager->getRepository(Transaction::class);
19
+
20
+		// Fil d'Ariane
21
+		//$renderVariables = array();
22
+		//$breadcrumb = $this->createBreadcrumb($renderVariables);
23
+		//$breadcrumb->addActiveItem($this->translate('admin_category_link'));
24
+
25
+		// injecte le request
26
+		$filter->setFromRequest($request);
27
+		// récupère les objets
28
+		$renderVariables['transactions'] = $repository->getByTrainingOrganization($trainingOrganizationId,EnumTransactionStatutType::TYPE_NOT_INVOICED);
29
+		$renderVariables['trainingOrganization'] = $trainingOrganization;
30
+
31
+		return $this->render('backOffice/admin/transaction/form.html.twig',$renderVariables);
32
+	}
33
+}
34
+?>

+ 15
- 0
src/CaptainLearning/Repository/TransactionRepository.php View File

@@ -15,4 +15,19 @@ class TransactionRepository extends ServiceEntityRepository
15 15
 	{
16 16
 		parent::__construct($registry, Transaction::class);
17 17
 	}
18
+
19
+	public function getByTrainingOrganization($trainingOrganizationId,$statut)
20
+	{
21
+		$queryBuilder = $this->createQueryBuilder('transaction');
22
+		$queryBuilder->leftJoin('transaction.estimate', 'estimate');
23
+		$queryBuilder->leftJoin('estimate.trainingOrganization', 'trainingOrganization');
24
+		$queryBuilder->addWhere('trainingOrganization.trainingOrganizationId = :id_training_organization');
25
+		$queryBuilder->setParameter('id_training_organization',$trainingOrganizationId);
26
+		
27
+		$queryBuilder->addWhere('transaction.statut = :statut');
28
+		$queryBuilder->setParameter('statut',$statut);
29
+
30
+		$query = $queryBuilder->getQuery();
31
+		return $query->execute();
32
+	}
18 33
 }

+ 131
- 0
templates/backOffice/admin/transaction/form.html.twig View File

@@ -0,0 +1,131 @@
1
+
2
+{% extends "backOffice/admin/layout/layout.base.html.twig" %}
3
+{% set company = trainingOrganization.getCompany() %}
4
+<div class="container mt-3 border bg-light">
5
+	<div class="row border-bottom">
6
+		<div class="col-12 my-3">
7
+			<div class="d-flex justify-content-between align-items-center">
8
+				<h1>{{ company.getName() }}</h1>
9
+			</div>
10
+			{% include 'backOffice/admin/layout/partial/breadcrumb.html.twig' %}
11
+		</div>
12
+	</div>
13
+
14
+	{{ form_start(form, {attr: {class: 'form-with-validation needs-validation pb-0'} }) }}
15
+
16
+		<div class="message-display"></div>
17
+		<div class="row my-3 mx-auto">
18
+			<div class="col-12 px-0">
19
+				{% set icon_url = asset('build/images/entrepriseNoir.png') %}
20
+				{% if company.getLogo() != "" %}
21
+					{% set icon_url = url('drawUpload',{'name': company.getLogo()}) %}
22
+				{% endif %}
23
+				<h2 class="mx-0" >{{ 'label_transaction_training_organization_name'|trans }}</h2>
24
+				<div class="row px-3">
25
+					<img src="{{ icon_url }}" class="w-max-px-150" alt="Logo entreprise">
26
+
27
+					<div class="col">
28
+						<div>
29
+							<label class="d-inline-block w-px-100 text-right mr-4">{{ 'label_transaction_training_organisation_name'|trans }}</label>
30
+							<span>{{ company.getName() }}</span>
31
+						</div>
32
+						<div>
33
+							<label class="d-inline-block w-px-100 text-right mr-4">{{ 'label_transaction_training_organisation_siret'|trans }}</label>
34
+							<span>{{ company.getSiret() }}</span>
35
+						</div>
36
+						<div>
37
+							<label class="d-inline-block w-px-100 text-right mr-4">{{ 'label_transaction_training_organisation_address'|trans }}</label>
38
+							<span>{{ company.getAddress() }}</span>,
39
+							<span>{{ company.getPostalCode() }}</span>,
40
+							<span>{{ company.getCity() }}</span>,
41
+							<span>{% set country = company.getCountry() %}{% if country %}{{ country.getName() }}{% else %}NA{% endif %}</span>
42
+						</div>
43
+						<div>
44
+							<label class="d-inline-block w-px-100 text-right mr-4">{{ 'label_transaction_training_organisation_phone'|trans }}</label>
45
+							<span>{{ company.getPhone() }}</span>
46
+						</div>
47
+						<div>
48
+							<label class="d-inline-block w-px-100 text-right mr-4">{{ 'label_transaction_training_organisation_email'|trans }}</label>
49
+							<span>{{ company.getEmail() }}</span>
50
+						</div>
51
+					</div>
52
+				</div>
53
+			</div>
54
+		</div>
55
+
56
+		<div class="row my-3">
57
+			<div class="col-12 px-3">
58
+				<h2 class="mx-0" ><?php echo CPTViewUtility::escapeHtml(_CPT_FACTURATION_CLIENT_TRANSACTIONS); ?></h2>
59
+				<table class="table w-100 td-d-block td-d-lg-table-cell td-md-cell-label mt-1">
60
+					<thead>
61
+						<tr>
62
+							<th scope="col" class="header">{{ 'label_transaction_estimate_id'|trans }}</th>
63
+							<th scope="col" class="header">{{ 'label_transaction_create_date'|trans }}</th>
64
+							<th scope="col" class="header">{{ 'label_transaction_client_description'|trans }}</th>
65
+							<th scope="col" class="header">{{ 'label_transaction_client_price'|trans }}</th>
66
+						</tr>
67
+					</thead>
68
+					<tbody>
69
+						{% set description = "" %}
70
+						{% set total = 0 %}
71
+						{% for transaction in transaction %}
72
+							{% set estimate = transaction.getEstimate() %}
73
+							{% set description = description ~ transaction.getDescription() %}
74
+							{% set total = total + transaction.getPrice() %}
75
+						
76
+							<tr>
77
+								<td class="align-top table__cell" data-title="{{ 'label_transaction_estimate_id'|trans }}">
78
+									{{ estimate.getEstimatId() }}
79
+								</td>
80
+								<td class="align-top table__cell" data-title="{{ 'label_transaction_create_date'|trans }}">
81
+									{{ transaction.getDateCreate()|date('d/m/Y H\\hi') }}
82
+								</td>
83
+								<td class="align-top table__cell" data-title="{{ 'label_transaction_client_description'|trans }}">
84
+									{{ transaction.getDescription()|nl2br }}
85
+								</td>
86
+								<td class="align-top table__cell" data-title="{{ 'label_transaction_client_price'|trans }}">
87
+									{{ transaction.getPrice()||number_format(2, '.', ' ') }}
88
+								</td>
89
+							</tr>
90
+						{% endfor %}
91
+
92
+						<tr>
93
+							<td colspan="3" class="text-right table-active" data-title="{{ ''|trans }}">
94
+								<span id="js-copy-montant-total" data-clipboard-text="<?php echo CPTViewListUtility::escapeHtml($montantTotal); ?>" data-copied="<?php echo CPTViewUtility::escapeHtml(_CPT_FACTURATION_CLIENT_COPIE); ?>" class="mr-2 btn btn-primary">
95
+									<ion-icon class="ion-ios-copy-outline mr-2"></ion-icon><?php echo CPTViewUtility::escapeHtml(_CPT_FACTURATION_CLIENT_COPIER_MONTANT_TOTAL); ?>
96
+								</span>
97
+								<?php echo CPTViewUtility::escapeHtml(_CPT_FACTURATION_CLIENT_LISTE_MONTANT_TOTAL); ?>
98
+							</td>
99
+							<td class="table-active" data-title="{{ ''|trans }}">
100
+								<span><?php echo CPTViewListUtility::formatPrix($montantTotal); ?></span>
101
+							</td>
102
+						</tr>
103
+					</tbody>
104
+				</table>
105
+
106
+				<span id="js-show-description-global" class="btn btn-primary" data-second-text="<?php echo CPTViewUtility::escapeHtml(_CPT_FACTURATION_CLIENT_MASQUER_DESCRIPTION_GLOBAL); ?>"><?php echo CPTViewUtility::escapeHtml(_CPT_FACTURATION_CLIENT_AFFICHER_DESCRIPTION_GLOBAL); ?></span>
107
+				<div id="js-description-global" class="d-none form-control">
108
+					<span id="js-copy-description-global" data-clipboard-target="#js-description-global-text" data-copied="<?php echo CPTViewUtility::escapeHtml(_CPT_FACTURATION_CLIENT_COPIEE); ?>" class="btn btn-primary"><ion-icon class="ion-ios-copy-outline mr-2"></ion-icon><?php echo CPTViewUtility::escapeHtml(_CPT_FACTURATION_CLIENT_COPIER_DESCRIPTION_GLOBAL); ?></span>
109
+					<div id="js-description-global-text">
110
+						<?php echo nl2br(CPTViewUtility::escapeHtml($descriptionTotal)); ?>
111
+					</div>
112
+				</div>
113
+			</div>
114
+		</div>
115
+		<div class="row my-3">
116
+			<div class="col-12 px-3">
117
+				<h2 class="mx-0" ><?php echo CPTViewUtility::escapeHtml(_CPT_FACTURATION_CLIENT_INFORMATION_FACTURE); ?></h2>
118
+				<div class="form-group">
119
+					<label class="like-label"><?php echo CPTViewUtility::escapeHtml(_CPT_FACTURATION_CLIENT_NUMERO_FACTURE); ?>*</label>
120
+					<input type="text" class="form-control" name="num_facture" value="" required/>
121
+				</div>
122
+				<div class="text-center">
123
+					<button type="submit" class="btn btn-primary btn-validate"><?php echo CPTViewUtility::escapeHtml(_CPT_FACTURATION_CLIENT_FACTURE_VALIDATE); ?></button>
124
+				</div>
125
+			</div>
126
+		</div>
127
+	</form>
128
+</div>
129
+<?php CPTViewUtility::setJs("js/script-view-form.js"); ?>
130
+<?php CPTViewUtility::setJs("js/script-view-list.js"); ?>
131
+<?php CPTViewUtility::setJs("js/backOffice/admin/script-transaction-client-view-form.js"); ?>

Loading…
Cancel
Save