Skip to content

Commit

Permalink
Add declarability options.
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Jan 9, 2025
1 parent 95ac944 commit 47240cf
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 98 deletions.
44 changes: 40 additions & 4 deletions admin/meta-box-project-details.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@

wp_nonce_field( 'orbis_save_project_details', 'orbis_project_details_meta_box_nonce' );

$orbis_id = get_post_meta( $post->ID, '_orbis_project_id', true );
$principal_id = get_post_meta( $post->ID, '_orbis_project_principal_id', true );
$seconds = get_post_meta( $post->ID, '_orbis_project_seconds_available', true );
$agreement_id = get_post_meta( $post->ID, '_orbis_project_agreement_id', true );
$orbis_id = get_post_meta( $post->ID, '_orbis_project_id', true );
$principal_id = get_post_meta( $post->ID, '_orbis_project_principal_id', true );
$seconds = get_post_meta( $post->ID, '_orbis_project_seconds_available', true );
$agreement_id = get_post_meta( $post->ID, '_orbis_project_agreement_id', true );
$declarability = get_post_meta( $post->ID, '_orbis_project_declarability', true );

$invoice_reference = get_post_meta( $post->ID, '_orbis_invoice_reference', true );
$invoice_line_description = get_post_meta( $post->ID, '_orbis_invoice_line_description', true );
Expand All @@ -23,6 +24,7 @@
$principal_id = $project->principal_id;
$invoice_number = $project->invoice_number;
$seconds = $project->number_seconds;
$declarability = $project->declarability;
}

$principal = $wpdb->get_var( $wpdb->prepare( "SELECT name FROM $wpdb->orbis_companies WHERE id= %d;", $principal_id ) );
Expand Down Expand Up @@ -161,6 +163,40 @@
</td>
</tr>

<tr valign="top">
<th scope="row">
<label for="_orbis_project_declarability">
<?php esc_html_e( 'Declarability', 'orbis-projects' ); ?>
</label>
</th>
<td>
<?php

$options = [
'' => \__( '— Select Declarability —', 'orbis-projects' ),
'chargeable' => \_x( 'Chargeable', 'declarability', 'orbis-projects' ),
'non_chargeable' => \_x( 'Non-chargeable', 'declarability', 'orbis-projects' ),
'excluded' => \_x( 'Excluded', 'declarability', 'orbis-projects' ),
];

?>
<select id="_orbis_project_declarability" name="_orbis_project_declarability">
<?php

foreach ( $options as $value => $label ) {
printf(
'<option value="%s" %s>%s</option>',
\esc_attr( $value ),
\selected( $declarability, $value, false ),
\esc_html( $label )
);
}

?>
</select>
</td>
</tr>

<?php if ( current_user_can( 'edit_orbis_project_administration' ) ) : ?>

<tr valign="top">
Expand Down
5 changes: 5 additions & 0 deletions classes/AdminProjectPostType.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public function save_project( $post_id, $post ) {
'_orbis_project_agreement_id' => FILTER_VALIDATE_INT,
'_orbis_project_is_finished' => FILTER_VALIDATE_BOOLEAN,
'_orbis_project_is_invoicable' => FILTER_VALIDATE_BOOLEAN,
'_orbis_project_declarability' => FILTER_SANITIZE_STRING,
'_orbis_project_invoice_number' => FILTER_SANITIZE_STRING,
'_orbis_invoice_reference' => FILTER_SANITIZE_STRING,
'_orbis_invoice_line_description' => FILTER_SANITIZE_STRING,
Expand Down Expand Up @@ -224,6 +225,7 @@ public function save_project_sync( $post_id, $post ) {

$principal_id = get_post_meta( $post_id, '_orbis_project_principal_id', true );
$is_invoicable = get_post_meta( $post_id, '_orbis_project_is_invoicable', true );
$declarability = get_post_meta( $post_id, '_orbis_project_declarability', true );
$is_invoiced = get_post_meta( $post_id, '_orbis_project_is_invoiced', true );
$invoice_number = get_post_meta( $post_id, '_orbis_project_invoice_number', true );
$is_finished = get_post_meta( $post_id, '_orbis_project_is_finished', true );
Expand All @@ -250,6 +252,9 @@ public function save_project_sync( $post_id, $post ) {
$data['invoicable'] = $is_invoicable;
$form['invoicable'] = '%d';

$data['declarability'] = $declarability;
$form['declarability'] = '%s';

$data['invoiced'] = $is_invoiced;
$form['invoiced'] = '%d';

Expand Down
1 change: 1 addition & 0 deletions classes/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public function install() {
invoice_number VARCHAR(128) DEFAULT NULL,
finished BOOLEAN NOT NULL DEFAULT FALSE,
billable_amount DECIMAL(15,2) DEFAULT NULL,
declarability VARCHAR(16) DEFAULT '',
PRIMARY KEY (id),
KEY post_id (post_id),
KEY principal_id (principal_id)
Expand Down
Binary file modified languages/orbis-projects-nl_NL.mo
Binary file not shown.
Loading

0 comments on commit 47240cf

Please sign in to comment.