-
Notifications
You must be signed in to change notification settings - Fork 0
/
single-orbis_project.php
executable file
·316 lines (209 loc) · 8.39 KB
/
single-orbis_project.php
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
<?php
use Pronamic\WordPress\Money\Money;
get_header();
?>
<?php
while ( have_posts() ) :
the_post();
?>
<div class="row">
<div class="col-md-8">
<?php if ( ! empty( get_the_content() ) ) : ?>
<div class="card mb-3">
<div class="card-header"><?php esc_html_e( 'Description', 'orbis-4' ); ?></div>
<div class="card-body">
<?php the_content(); ?>
</div>
<?php get_template_part( 'templates/post-card-footer' ); ?>
</div>
<?php endif; ?>
<?php get_template_part( 'templates/project_sections' ); ?>
<?php do_action( 'orbis_after_main_content' ); ?>
<?php comments_template( '', true ); ?>
</div>
<div class="col-md-4">
<div class="card">
<div class="card-header"><?php esc_html_e( 'Project Status', 'orbis-4' ); ?></div>
<div class="card-body">
<h5 class="entry-meta"><?php esc_html_e( 'Project budget', 'orbis-4' ); ?></h5>
<?php if ( current_user_can( 'read_orbis_project_price', get_the_ID() ) ) : ?>
<?php
$price = $orbis_project->get_price();
if ( $price ) :
?>
<p class="project-time">
<?php
$price = new Money( $price, 'EUR' );
echo esc_html( $price->format_i18n() );
?>
</p>
<?php endif; ?>
<?php endif; ?>
<p class="project-time">
<?php echo esc_html( $orbis_project->get_available_time()->format() ); ?>
<?php if ( function_exists( 'orbis_project_the_logged_time' ) ) : ?>
<?php
$classes = [];
$classes[] = orbis_project_in_time() ? 'text-success' : 'text-error';
?>
<span class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>"><?php orbis_project_the_logged_time(); ?></span>
<?php endif; ?>
</p>
</div>
</div>
<div class="card mt-3">
<div class="card-header"><?php esc_html_e( 'Project Details', 'orbis-4' ); ?></div>
<div class="card-body">
<dl>
<?php if ( $orbis_project->has_principal() ) : ?>
<dt><?php esc_html_e( 'Client', 'orbis-4' ); ?></dt>
<dd>
<?php
printf(
'<a href="%s">%s</a>',
esc_attr( get_permalink( $orbis_project->get_principal_post_id() ) ),
esc_html( $orbis_project->get_principal_name() )
);
?>
</dd>
<?php endif; ?>
<dt><?php esc_html_e( 'Posted on', 'orbis-4' ); ?></dt>
<dd><?php echo esc_html( get_the_date() ); ?></dd>
<dt><?php esc_html_e( 'Posted by', 'orbis-4' ); ?></dt>
<dd><?php echo esc_html( get_the_author() ); ?></dd>
<?php if ( current_user_can( 'read_orbis_project_agreement', get_the_ID() ) ) : ?>
<?php
$agreement_id = get_post_meta( get_the_ID(), '_orbis_project_agreement_id', true );
if ( ! empty( $agreement_id ) ) :
$agreement = get_post( $agreement_id );
?>
<dt><?php esc_html_e( 'Agreement', 'orbis-4' ); ?></dt>
<dd>
<a href="<?php echo esc_attr( get_permalink( $agreement ) ); ?>"><?php echo get_the_title( $agreement ); ?></a>
</dd>
<?php endif; ?>
<?php endif; ?>
<dt><?php esc_html_e( 'Period', 'orbis-4' ); ?></dt>
<dd>
<?php
$start_date = null;
$start_date_string = \get_post_meta( get_the_ID(), '_orbis_project_start_date', true );
if ( '' !== $start_date_string ) {
$value = DateTimeImmutable::createFromFormat( 'Y-m-d', $start_date_string );
$start_date = ( false === $value ) ? null : $value->setTime( 0, 0 );
}
$end_date = null;
$end_date_string = \get_post_meta( get_the_ID(), '_orbis_project_end_date', true );
if ( '' !== $end_date_string ) {
$value = DateTimeImmutable::createFromFormat( 'Y-m-d', $end_date_string );
$end_date = ( false === $value ) ? null : $value->setTime( 0, 0 );
}
if ( null !== $start_date && null !== $end_date ) {
printf(
/* translators: 1: Period start date, 2: Period end date. */
\__( '%1$s - %2$s', 'orbis-4' ),
( null === $start_date ) ? '?' : \esc_html( \date_i18n( 'D j M Y', $start_date->getTimestamp() ) ),
( null === $end_date ) ? '?' : \esc_html( \date_i18n( 'D j M Y', $end_date->getTimestamp() ) )
);
}
?>
</dd>
<dt><?php esc_html_e( 'Status', 'orbis-4' ); ?></dt>
<dd>
<?php if ( $orbis_project->is_finished() ) : ?>
<span class="badge text-bg-success"><?php esc_html_e( 'Finished', 'orbis-4' ); ?></span>
<?php else : ?>
<span class="badge text-bg-secondary"><?php esc_html_e( 'Not finished', 'orbis-4' ); ?></span>
<?php endif; ?>
<?php if ( $orbis_project->is_invoiced() ) : ?>
<span class="badge text-bg-success"><?php esc_html_e( 'Invoiced', 'orbis-4' ); ?></span>
<?php else : ?>
<span class="badge text-bg-secondary"><?php esc_html_e( 'Not invoiced', 'orbis-4' ); ?></span>
<?php endif; ?>
<?php if ( $orbis_project->is_invoicable() ) : ?>
<span class="badge text-bg-success"><?php esc_html_e( 'Invoicable', 'orbis-4' ); ?></span>
<?php else : ?>
<span class="badge text-bg-secondary"><?php esc_html_e( 'Not invoicable', 'orbis-4' ); ?></span>
<?php endif; ?>
<?php
$project_statuses = wp_get_post_terms( $orbis_project->post->ID, 'orbis_project_status' );
foreach ( $project_statuses as $project_status ) {
$status_type = get_term_meta( $project_status->term_id, 'orbis_status_type', true ) ? get_term_meta( $project_status->term_id, 'orbis_status_type', true ) : 'primary';
printf(
'<span class="badge text-badge-%s orbis-status">%s</span>',
esc_attr( $status_type ),
esc_attr( $project_status->name )
);
}
?>
</dd>
<?php if ( has_term( null, 'orbis_payment_method' ) ) : ?>
<dt><?php esc_html_e( 'Payment Method', 'orbis-4' ); ?></dt>
<dd><?php the_terms( null, 'orbis_payment_method' ); ?></dd>
<?php endif; ?>
<?php
$invoice_header_text = get_post_meta( $post->ID, '_orbis_invoice_header_text', true );
$invoice_footer_text = get_post_meta( $post->ID, '_orbis_invoice_footer_text', true );
$invoice_line_description = get_post_meta( $post->ID, '_orbis_invoice_line_description', true );
?>
<?php if ( ! empty( $invoice_header_text ) ) : ?>
<dt><?php esc_html_e( 'Invoice Header Text', 'orbis-4' ); ?></dt>
<dd>
<?php echo nl2br( esc_html( $invoice_header_text ) ); ?></a>
</dd>
<?php endif; ?>
<?php if ( ! empty( $invoice_footer_text ) ) : ?>
<dt><?php esc_html_e( 'Invoice Footer Text', 'orbis-4' ); ?></dt>
<dd>
<?php echo nl2br( esc_html( $invoice_footer_text ) ); ?></a>
</dd>
<?php endif; ?>
<?php if ( ! empty( $invoice_line_description ) ) : ?>
<dt><?php esc_html_e( 'Invoice Line Description', 'orbis-4' ); ?></dt>
<dd>
<?php echo nl2br( esc_html( $invoice_line_description ) ); ?></a>
</dd>
<?php endif; ?>
<?php
$invoice_number = get_post_meta( get_the_ID(), '_orbis_project_invoice_number', true );
if ( ! empty( $invoice_number ) ) :
?>
<dt><?php esc_html_e( 'Final Invoice', 'orbis-4' ); ?></dt>
<dd>
<?php
$invoice_link = orbis_get_invoice_link( $invoice_number );
if ( ! empty( $invoice_link ) ) {
printf(
'<a href="%s" target="_blank">%s</a>',
esc_attr( $invoice_link ),
esc_html( $invoice_number )
);
} else {
echo esc_html( $invoice_number );
}
?>
</dd>
<?php endif; ?>
<?php if ( null !== get_edit_post_link() ) : ?>
<dt><?php esc_html_e( 'Actions', 'orbis-4' ); ?></dt>
<dd><?php edit_post_link( __( 'Edit', 'orbis-4' ) ); ?></dd>
<?php endif; ?>
</dl>
</div>
</div>
<div class="card" style="display: none;">
<div class="card-header"><?php esc_html_e( 'Project Invoices', 'orbis-4' ); ?></div>
<div class="card-body">
<dl>
<dt><?php esc_html_e( 'Posted by', 'orbis-4' ); ?></dt>
<dd><?php echo esc_html( get_the_author() ); ?></dd>
</dl>
</div>
</div>
<?php if ( function_exists( 'p2p_register_connection_type' ) ) : ?>
<?php get_template_part( 'templates/project_persons' ); ?>
<?php endif; ?>
</div>
</div>
<?php endwhile; ?>
<?php get_footer(); ?>