2017-02-15 22:01:15 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace DataAccess\Statuses;
|
|
|
|
|
|
|
|
|
|
|
|
use BusinessLogic\Statuses\Status;
|
2017-02-16 21:46:47 -05:00
|
|
|
use DataAccess\CommonDao;
|
2017-02-15 22:01:15 -05:00
|
|
|
|
2017-02-16 21:46:47 -05:00
|
|
|
class StatusGateway extends CommonDao {
|
2017-02-15 22:01:15 -05:00
|
|
|
|
|
|
|
/**
|
2017-02-16 21:46:47 -05:00
|
|
|
* @param $defaultAction string
|
2017-02-15 22:01:15 -05:00
|
|
|
* @return Status
|
|
|
|
*/
|
2017-02-16 21:46:47 -05:00
|
|
|
function getStatusForDefaultAction($defaultAction, $heskSettings) {
|
|
|
|
$this->init();
|
|
|
|
|
|
|
|
$metaRs = hesk_dbQuery('SELECT * FROM `' . hesk_dbEscape($heskSettings['db_pfix']) . 'statuses`
|
|
|
|
WHERE `' . $defaultAction . '` = 1');
|
|
|
|
if (hesk_dbNumRows($metaRs) === 0) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
$row = hesk_dbFetchAssoc($metaRs);
|
|
|
|
|
|
|
|
$languageRs = hesk_dbQuery('SELECT * FROM `' . hesk_dbEscape($heskSettings['db_pfix']) . 'text_to_status_xref`
|
|
|
|
WHERE `status_id` = ' . intval($row['ID']));
|
|
|
|
|
|
|
|
$status = Status::fromDatabase($row, $languageRs);
|
|
|
|
|
|
|
|
$this->close();
|
|
|
|
|
|
|
|
return $status;
|
2017-02-15 22:01:15 -05:00
|
|
|
}
|
2017-04-28 13:03:25 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param $heskSettings array
|
|
|
|
* @return Status[]
|
|
|
|
*/
|
|
|
|
function getStatuses($heskSettings) {
|
|
|
|
$this->init();
|
|
|
|
|
|
|
|
$metaRs = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "statuses`");
|
|
|
|
|
|
|
|
$statuses = array();
|
|
|
|
while ($row = hesk_dbFetchAssoc($metaRs)) {
|
|
|
|
$languageRs = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "text_to_status_xref`
|
|
|
|
WHERE `status_id` = " . intval($row['ID']));
|
|
|
|
|
|
|
|
$statuses[] = Status::fromDatabase($row, $languageRs);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->close();
|
|
|
|
|
|
|
|
return $statuses;
|
|
|
|
}
|
2017-02-15 22:01:15 -05:00
|
|
|
}
|