Last active
December 15, 2015 20:09
-
-
Save jsolid/5316493 to your computer and use it in GitHub Desktop.
Add a "Show All" link as search criteria in Invoices module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// File location: siwapp\apps\siwapp\modules\search\templates\_form.php | |
<ul class="filters"> | |
<li><?php echo __('Status');?>: </li> | |
<li><?php echo filter_by_status(__('Opened'), Invoice::OPENED, $status = $form['status']->getValue()) ?> |</li> | |
<li><?php echo filter_by_status(__('Closed'), Invoice::CLOSED, $status) ?> |</li> | |
<li><?php echo filter_by_status(__('Overdue'), Invoice::OVERDUE, $status) ?> |</li> | |
<li><?php echo filter_by_status(__('Drafts'), Invoice::DRAFT, $status) ?> |</li> | |
<li><?php echo filter_by_status(__('Show All'), 99, $status) ?></li> | |
</ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function status($status, $is = true) | |
{ | |
// $status = 99 to show all result, ignore filtering | |
if($status !== null && $status != "" && (int)$status < 10) | |
{ | |
$status = (array) $status; | |
$statusString = implode(", ", (array) $status); | |
if($is) | |
{ | |
$this->andWhere(sprintf('i.status IN (%s)', $statusString)); | |
} | |
else | |
{ | |
$this->andWhere(sprintf('i.status NOT IN (%s)', $statusString)); | |
} | |
} | |
return $this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment