| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- <?php /** @noinspection PhpUnhandledExceptionInspection */
- namespace App;
- use App\Enums\Currencies;
- use App\Enums\SaleStatuses;
- use App\Helpers\HtmlHelper;
- /**
- * @var Sale $sale
- */
- $core = Core::getInstance();
- $user = $core->getUser();
- $location = $sale->getLocation();
- $customers = Customer::getAll();
- $location_options = [];
- foreach($customers as $customer) {
- foreach($customer->getLocations() as $customer_location) {
- $location_options[$customer_location->id] = $customer_location->getDisplayName();
- }
- }
- ?>
- <section class="mb-4">
- <h3 class="mb-3"><?=htmlspecialchars($sale->getTitle())?></h3>
- <form id="sale-form" class="mb-4" action="<?=htmlspecialchars($sale->getUrl())?>/submit" method="post">
- <div class="row">
- <div class="col-xl-8">
- <h4><?=htmlspecialchars(__("Main Details"))?></h4>
- <div class="mb-3">
- <label class="form-label" for="status">
- <b><?=htmlspecialchars(__("Status"))?></b>
- </label>
- <span class="ms-1"></span>
- <span class="badge rounded-pill text-bg-danger">
- <?=htmlspecialchars(__("Important"))?>
- </span>
- <select class="form-select" name="status" id="status">
- <?php
- HtmlHelper::renderOptions(SaleStatuses::options(), $sale->status);
- ?>
- </select>
- </div>
- <div class="row">
- <div class="col-md-6">
- <div class="mb-3">
- <label class="form-label" for="company-id">
- <?=htmlspecialchars(__("Company"))?>
- </label>
- <select class="form-select" name="company_id" id="company-id" required>
- <option value=""><?=htmlspecialchars(__("Select Company"))?></option>
- <?php
- HtmlHelper::renderOptions(Company::getOptions(), $sale->company_id);
- ?>
- </select>
- </div>
- </div>
- <div class="col-md-6">
- <div class="mb-3">
- <label class="form-label" for="location-id"><?= htmlspecialchars(__("Location")) ?></label>
- <select class="form-select" name="location_id" id="location-id">
- <?php
- HtmlHelper::renderOptions($location_options, $sale->location_id);
- ?>
- </select>
- </div>
- </div>
- <div class="col-md-6">
- <div class="mb-3">
- <label class="form-label" for="date-predicted-sold"><?=htmlspecialchars(__("Predicted Sold Date"))?></label>
- <input class="form-control" type="date" name="date_predicted_sold" id="date-predicted-sold" value="<?=htmlspecialchars($sale->date_predicted_sold)?>" required />
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-md">
- <div class="mb-3">
- <label class="form-label" for="currency"><?=htmlspecialchars(__("Currency"))?></label>
- <select class="form-select" name="currency" id="currency">
- <?php
- HtmlHelper::renderOptions(Currencies::options(), $sale->currency);
- ?>
- </select>
- </div>
- </div>
- <div class="col-md">
- <div class="mb-3">
- <label for="tax-rate" class="form-label">
- <?=htmlspecialchars(__("Tax Rate (%)"))?>
- </label>
- <input class="form-control" type="number" name="tax_rate" id="tax-rate" value="<?=$sale->tax_rate?>" min="0" max="100.00" step="0.01" placeholder="Type tax rate" required />
- </div>
- </div>
- </div>
- </div>
- <div class="col-xl-4">
- <div class="row">
- <div class="col-sm-6 col-xl-12">
- <?php
- View::include("related_items_section", [
- "sale" => $sale,
- "current" => $sale
- ]);
- ?>
- </div>
- <div class="col-sm-6 col-xl-12">
- <section class="mb-4">
- <h4><?=htmlspecialchars(__("Additional Details"))?></h4>
- <dl>
- <dt><?=htmlspecialchars(__("Location"))?></dt>
- <dd>
- <a href="<?=htmlspecialchars($location->getUrl())?>">
- <?=htmlspecialchars($location->getDisplayName())?>
- </a>
- </dd>
- <dt><?=htmlspecialchars(__("Created By"))?></dt>
- <dd><?=htmlspecialchars($sale->getUser()->getDisplayName())?></dd>
- <dt><?=htmlspecialchars(__("Created Date/Time"))?></dt>
- <dd><?=htmlspecialchars($sale->getDateTimeCreated()->format("d/m/Y H:i"))?></dd>
- </dl>
- </section>
- </div>
- </div>
- </div>
- </div>
- <button type="submit" class="btn btn-primary">
- <i class="fa fa-fw fa-save"></i>
- <?=htmlspecialchars(__("Save Lead"))?>
- </button>
- </form>
- </section>
- <?php
- View::include("sale_items_section", compact("sale"));
- View::include("sale_invoices_section", ["sales_orders" => $sale->getSalesOrders()]);
- View::include("sale_notes_section", compact("sale"));
- ?>
- <section class="mb-4">
- <div class="row mb-3">
- <div class="col">
- <h3><?=htmlspecialchars(__("Tickets"))?></h3>
- </div>
- <div class="col-auto">
- <button class="btn btn-success" type="button" data-bs-toggle="modal" data-bs-target="#ticket-modal" data-location-id="<?=$sale->location_id?>" data-sale-number="<?=$sale->getNumber()?>">
- <i class="fa fa-fw fa-plus"></i>
- <?=htmlspecialchars(__("Add Ticket"))?>
- </button>
- </div>
- </div>
- <?php
- $tickets = $sale->getTickets();
- if(empty($tickets)) {
- HtmlHelper::renderInfoAlert(__("No tickets to display."));
- }
- else {
- ?>
- <table class="table table-bordered table-hover">
- <colgroup>
- <col style="width: 1%"/>
- <col style="width: 10%"/>
- <col style="width: 45%"/>
- <col style="width: 10%"/>
- <col style="width: 20%"/>
- <col style="width: 15%"/>
- <col style="width: 1%"/>
- </colgroup>
- <thead>
- <tr>
- <th><?=htmlspecialchars(__("ID"))?></th>
- <th><?=htmlspecialchars(__("Date"))?></th>
- <th><?=htmlspecialchars(__("Subject"))?></th>
- <th><?=htmlspecialchars(__("Status"))?></th>
- <th><?=htmlspecialchars(__("Assigned To"))?></th>
- <th><?=htmlspecialchars(__("Last Updated"))?></th>
- <th><?=htmlspecialchars(__("Actions"))?></th>
- </tr>
- </thead>
- <tbody>
- <?php
- foreach($tickets as $ticket) {
- ?>
- <tr>
- <td class="text-end">
- <a href="<?=htmlspecialchars($ticket->getUrl())?>"><?=htmlspecialchars($ticket->id)?></a>
- </td>
- <td>
- <?=htmlspecialchars($user->formatDate($ticket->getDateTimeCreated()))?>
- </td>
- <td>
- <?=htmlspecialchars($ticket->subject)?>
- </td>
- <td>
- <?=htmlspecialchars($ticket->getDisplayStatus())?>
- </td>
- <td>
- <?=htmlspecialchars($ticket->getDisplayAssignedTo())?>
- </td>
- <td>
- <?=htmlspecialchars($user->formatDateTime($ticket->getDateTimeUpdated()))?>
- </td>
- <td class="p-1">
- <a class="btn btn-sm btn-primary" href="<?=htmlspecialchars($ticket->getUrl())?>"><?=htmlspecialchars(__("View"))?></a>
- </td>
- </tr>
- <?php
- }
- ?>
- </tbody>
- </table>
- <?php
- }
- ?>
- </section>
|