Skip to content

Instantly share code, notes, and snippets.

@devinegger
Last active July 12, 2024 17:57
Show Gist options
  • Select an option

  • Save devinegger/cf9a06312f77ab8468025f747fe56971 to your computer and use it in GitHub Desktop.

Select an option

Save devinegger/cf9a06312f77ab8468025f747fe56971 to your computer and use it in GitHub Desktop.
<?php if (isset($show_header) && $show_header) { ?><h4 style="margin-top:0">Status History</h4><?php } ?>
<?php if (empty($history)) { ?>
<p>There haven't yet been any status updates to this account.</p>
<?php } ?>
<div id="status_history">
<?php foreach ($history as $sh) { ?>
<?php
$user_name = $this->ldap_auth->get_user_name($sh->user_id) ?? "<i>$sh->user_id</i>";
$alert_type = 'info';
$alert_text = '';
$is_pending = false;
$is_comment = false;
if (isset($sh->is_opt_out)) {
$alert_type = 'opt-out';
$alert_text = 'Opted ' . $sh->is_opt_out ? 'out of' : 'in to' . $sh->item_name . $sh->is_form ? 'form' : 'section' . ' by <strong>' . $user_name . '</strong>';
}
elseif ($sh->submission === true) {
spit('submission');
$alert_text = 'warning';
$department = '';
if ($sh->department !== null) {
$department .= $sh->department == "rm" ? 'Manager' : ucfirst($sh->department);
$department .= $sh->step > 0 ? " Step {$sh->step} " : ' ';
}
$alert_text = $department . 'Submitted by <strong>' . $user_name . '</strong>';
$is_pending = true;
spit($alert_text);
}
elseif ($sh->finalized === true) {
$alert_type = 'success';
$alert_text = 'Finalized by <strong>' . ($sh->user_id !== null ? $user_name : 'Finance') . '</strong>';
spit($alert_type);
}
elseif ($sh->pricing_published === true) {
$alert_type = 'success';
$alert_text = 'Pricing Published by <strong>' . ($sh->user_id !== null ? $user_name : 'Finance') . '</strong>';
spit($alert_type);
}
elseif ($sh->rm === true) {
$alert_type = 'success';
$alert_text = 'Manager Approved by <strong>' . ($sh->user_id !== null ? $user_name : 'Finance') . '</strong>';
spit($alert_type);
}
elseif (get_status_name($sh->status) === 'comment') {
spit('comment');
if ($sh->department === 'transportation') {
spit('transportation comment');
if (preg_match('/Abnormally high stop cost of \$\d{1,3}(?:,?\d{3})*\.\d{2} set/', $sh->notes)) {
$alert_type = 'danger';
} elseif (preg_match('/High stop cost of \$\d{1,3}(?:,?\d{3})*\.\d{2} set/', $sh->notes)) {
$alert_type = 'warning';
}
$alert_text = "$sh->notes - <strong>$user_name</strong>";
}
elseif ($sh->department === 'system') {
spit('system comment');
if (preg_match('/Account Packet Created/', $sh->notes)) {
$alert_type = 'success';
} elseif (preg_match('/^(Marked as abandoned|Expired due to 6 months of inactivity while being over a year old)$/', $sh->notes)) {
$alert_type = 'danger';
}
$alert_text = "$sh->notes - <strong>$user_name</strong>";
}
}
elseif ($sh->department === 'verification' && get_status_name($sh->status) === 'action') {
if (preg_match('/Pharmacy verified/', $sh->notes)) {
$alert_type = 'success';
} elseif (preg_match('/Pharmacy verification rejected/', $sh->notes)) {
$alert_type = 'danger';
} elseif (preg_match('/Pharmacy verification discarded/', $sh->notes)) {
$alert_type = 'warning';
} elseif (preg_match('/Pharmacy verification being reviewed/', $sh->notes)) {
$alert_type = 'info';
}
$alert_text = "$sh->notes - <strong>$user_name</strong>";
}
else { $is_comment = true; }
?>
<?php if (!$is_comment) { ?>
<div class="well well-small alert alert-<?= $alert_type ?>">
<?= $alert_text ?>
<small class="date"><em><?= date('M j, Y \a\t g:i a', strtotime($sh->created)); ?></em></small>
</div>
<?php if ($is_pending) { ?>
<span class="label label-warning pull-right">Pending</span>
<?php } ?>
<?php } else { ?>
<div class="panel panel-default comment">
<div class="panel-heading">
<span class="pull-right"><?= get_status_badge($sh->status); ?></span>
<strong><?= $user_name ?></strong><span class="muted"><small> <span style="padding: 0 2px;">|</span> <?= ($sh->department != 'rm' && $sh->department != 'pbc') ? ucfirst($sh->department):($sh->department == 'pbc' ? 'PBC' : 'Manager');?></small></span>
<small class="date">
<em><?= date('M j, Y \a\t g:i a', strtotime($sh->created)) ?></em>
</small>
</div>
<div class="panel-body">
<?php if (isset($sh->note_details)) { ?>
<?= $this->load->view('global/_notedetails.php', ['note_details' => $sh->note_details]); ?>
<?php } ?>
<?php if (!empty($sh->notes)) { ?>
<p class='new-line-break' style='margin: 0'><?= $sh->notes ?></p>
<?php } ?>
</div>
</div>
<?php } ?>
<?php } ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment