Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

raffelustig's avatar

Would like today's date to be selected so it's only to click "Register payment"

This is the code:

            <hr>
            <div class="row">
                <div class="col-sm-12">
                    <label>Payment-date</label>
                    <div uib-datepicker ng-model="modalcontroller.invoice.paid_at" class="well well-sm" datepicker-options="modalcontroller.options"></div>
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <div class="row">
                <div class="col-sm-6 text-left">
                    <button class="btn btn-default" type="button" ng-click="modalcontroller.cancel()">Cancel</button>
                </div>
                <div class="col-sm-6 text-right">
                    <button class="btn btn-primary" type="button" ng-click="modalcontroller.registerPayment(modalcontroller.invoice)">Register payment</button>
                </div>
            </div>
        </div>

Would like some tips on how to do that. The today's date is chosen but not selected. I want it selected same as if I click-select it. So it looks like this: https://imgur.com/H7Y3QYa

0 likes
3 replies
Nakov's avatar

I guess this ng-model="modalcontroller.invoice.paid_at" paid_at is null` it does not have a default date.. So maybe if you return anything from it, then it will get selected.

So in your Invoice model if you add:

public function getPaidAtAttribute($value)
{
	return $value ?? today();
}

it would work?

raffelustig's avatar

@Nakov It works, but the invoices is getting MARKED as paid, but not really paid. So by clicking on Register payment, the invoice got paid all right with today's date highlighted and selected. Now I need to figure out why the got marked as paid. Do you have any idea?

raffelustig's avatar

This is the part of the blade that shows the invoice number and if it's paid or not:

                        <td>
                            <div class="btn-group" ng-if="signup.invoice">
                                <button type="button"
                                        class="btn btn-xs btn-default dropdown-toggle"
                                        data-toggle="dropdown"
                                        aria-haspopup="true"
                                        aria-expanded="false">
                                    <i class="fa fa-check-square text-primary" ng-if="signup.invoice.paid_at"></i> <% signup.invoice.invoice_reference %> <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu">
                                    <li><a href="#" ng-click="signups.openPaymentModal(signup.invoice)">Markera betalning</a></li>
                                    <li><a ui-sref="competitions.admin.invoices.show({id: signup.invoice.id})">Visa fakturan</a></li>
                                </ul>
                            </div>
                            <div class="btn-group" ng-if="!signup.invoice && (!signup.requires_approval || signup.is_approved_by != 0)">
                                <button type="button"
                                        class="btn btn-xs btn-warning dropdown-toggle"
                                        data-toggle="dropdown"
                                        aria-haspopup="true"
                                        aria-expanded="false">
                                    Skapa faktura <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu">
                                    <li><a href="#" ng-click="signups.createInvoice(signup)">Skapa faktura nu</a></li>
                                    <li><a href="#" ng-click="signups.createInvoice(signup, 'paid')">Skapa faktura och markera som betald</a></li>
                                </ul>
                            </div>
                                <button type="button"
                                        ng-if="signup.requires_approval && !signup.is_approved_by"
                                        ng-click="signups.approveSignup(signup)"
                                        class="btn btn-xs btn-warning dropdown-toggle"
                                        >
                                    Godkänn efteranmälan
                                </button>
                            </div>
                        </td>
                        <td>

This is the button that shows the invoice number and marked as paid or not (at the top of the list above):

<button type="button"
                       class="btn btn-xs btn-default dropdown-toggle"
                       data-toggle="dropdown"
                       aria-haspopup="true"
                       aria-expanded="false">
     <i class="fa fa-check-square text-primary" 

ng-if="signup.invoice.paid_at"></i> 

     <% signup.invoice.invoice_reference %> 
      <span class="caret"></span>
</button>

So the ng-if="signup.invoice.paid_at" is clearly responsible for that. So how to prevent the invoice to be marked as paid? This is how it looks like: https://imgur.com/kRTwMnj the number without blue square is unpaid and with blue square marked as paid. Maybe to invoke a flag or something to determine whether the invoice is paid or not?

Please or to participate in this conversation.