dbms_primeidc_init...1
This commit is contained in:
parent
5e4499d261
commit
1cc9d6c342
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace lib\Utils;
|
namespace lib\Configs;
|
||||||
|
|
||||||
use lib\Core\Utils\Pagination as Core;
|
use lib\Core\Utils\Pagination as Core;
|
||||||
|
|
||||||
@ -43,12 +43,11 @@ class CouponController extends ClientController
|
|||||||
$this->getServiceService()->getModel()->where('client_code', $this->client->getClientCode());
|
$this->getServiceService()->getModel()->where('client_code', $this->client->getClientCode());
|
||||||
}
|
}
|
||||||
//업체명_일회성만 나오게하기 위해서
|
//업체명_일회성만 나오게하기 위해서
|
||||||
$this->getServiceService()->getModel()->like('server_code', '%_일회성');
|
$this->getServiceService()->getModel()->like('server_code', "%\-일회성");
|
||||||
$this->curPage = intval($this->request->get('curPage', 1));
|
[$this->total, $this->entities, $this->pagination, $this->curPage, $this->perPage] = $this->getServiceService()->getList(
|
||||||
$this->perPage = intval($this->request->get('perPage', APP_VIEW_LIST_PERPAGE));
|
$this->request->get('curPage'),
|
||||||
[$this->total, $this->entities] = $this->getServiceService()->getList($this->curPage, $this->perPage);
|
$this->request->get('perPage')
|
||||||
$this->pagination = new Pagination($this->total, (int)$this->curPage, (int)$this->perPage);
|
);
|
||||||
|
|
||||||
//전체 사용자정보
|
//전체 사용자정보
|
||||||
$this->clients = $this->getClientService()->getEntities();
|
$this->clients = $this->getClientService()->getEntities();
|
||||||
return $this->render(__FUNCTION__);
|
return $this->render(__FUNCTION__);
|
||||||
|
|||||||
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
namespace lib\Controllers\Client;
|
namespace lib\Controllers\Client;
|
||||||
|
|
||||||
use lib\Utils\Pagination;
|
use lib\Models\AddDbModel;
|
||||||
|
use lib\Models\ClientModel;
|
||||||
|
|
||||||
class PaymentController extends ClientController
|
class PaymentController extends ClientController
|
||||||
{
|
{
|
||||||
@ -62,10 +63,20 @@ class PaymentController extends ClientController
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->mode = $mode;
|
$this->mode = $mode;
|
||||||
$this->curPage = intval($this->request->get('curPage', 1));
|
|
||||||
$this->perPage = intval($this->request->get('perPage', APP_VIEW_LIST_PERPAGE));
|
$table = $this->getServiceService()->getModel()->getTable();
|
||||||
[$this->total, $this->entities] = $this->getServiceService()->getEntitiesForNonPayment($this->curPage, $this->perPage, $exclude_clients);
|
$clientTable = ClientModel::TABLE;
|
||||||
$this->pagination = new Pagination($this->total, (int)$this->curPage, (int)$this->perPage);
|
$addDbTable = AddDbModel::TABLE;
|
||||||
|
$this->getServiceService()->getModel()->select("{$clientTable}.Client_Name,{$table}.service_code,service_line,server_code,service_ip,service_payment_date,service_amount,service_nonpayment,service_note,addDB_case,addDB_nonpayment,addDB_payment,addDB_accountStatus,addDB_ip,addDB_payment_date");
|
||||||
|
$this->getServiceService()->getModel()->join($clientTable, "{$table}.client_code = {$clientTable}.Client_Code");
|
||||||
|
$this->getServiceService()->getModel()->join($addDbTable, "{$table}.service_code = {$addDbTable}.service_code");
|
||||||
|
$this->getServiceService()->getModel()->whereNotIn("{$addDbTable}.client_code", $exclude_clients);
|
||||||
|
$this->getServiceService()->getModel()->whereNotIn("{$addDbTable}.addDB_accountStatus", ["complete"]);
|
||||||
|
$this->getServiceService()->getModel()->orderBy("service_payment_date", "DESC");
|
||||||
|
[$this->total, $this->entities, $this->pagination, $this->curPage, $this->perPage] = $this->getServiceService()->getList(
|
||||||
|
$this->request->get('curPage'),
|
||||||
|
$this->request->get('perPage')
|
||||||
|
);
|
||||||
return $this->render(__FUNCTION__);
|
return $this->render(__FUNCTION__);
|
||||||
}
|
}
|
||||||
} //Class
|
} //Class
|
||||||
|
|||||||
@ -5,7 +5,7 @@ namespace lib\Controllers\Client;
|
|||||||
use lib\Services\HistoryService;
|
use lib\Services\HistoryService;
|
||||||
use lib\Services\OnetimeService;
|
use lib\Services\OnetimeService;
|
||||||
use lib\Services\PointService;
|
use lib\Services\PointService;
|
||||||
use lib\Utils\Pagination;
|
use lib\Configs\Pagination;
|
||||||
use lib\Helpers\Client\PointHelper;
|
use lib\Helpers\Client\PointHelper;
|
||||||
|
|
||||||
class PointController extends ClientController
|
class PointController extends ClientController
|
||||||
@ -53,11 +53,11 @@ class PointController extends ClientController
|
|||||||
if ($client_code) {
|
if ($client_code) {
|
||||||
$this->getPointService()->getModel()->where('client_code', $client_code);
|
$this->getPointService()->getModel()->where('client_code', $client_code);
|
||||||
}
|
}
|
||||||
|
[$this->total, $this->entities, $this->pagination, $this->curPage, $this->perPage] = $this->getPointService()->getList(
|
||||||
|
$this->request->get('curPage'),
|
||||||
|
$this->request->get('perPage')
|
||||||
|
);
|
||||||
$this->client_code = $client_code;
|
$this->client_code = $client_code;
|
||||||
$this->curPage = intval($this->request->get('curPage', 1));
|
|
||||||
$this->perPage = intval($this->request->get('perPage', APP_VIEW_LIST_PERPAGE));
|
|
||||||
[$this->total, $this->entities] = $this->getPointService()->getList($this->curPage, $this->perPage);
|
|
||||||
$this->pagination = new Pagination($this->total, (int)$this->curPage, (int)$this->perPage);
|
|
||||||
return $this->render(__FUNCTION__);
|
return $this->render(__FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
namespace lib\Controllers;
|
namespace lib\Controllers;
|
||||||
|
|
||||||
use lib\Services\DefenceService;
|
use lib\Services\DefenceService;
|
||||||
use lib\Utils\Pagination;
|
use lib\Configs\Pagination;
|
||||||
|
|
||||||
class DefenceController extends DBMSController
|
class DefenceController extends DBMSController
|
||||||
{
|
{
|
||||||
@ -33,10 +33,10 @@ class DefenceController extends DBMSController
|
|||||||
$this->zone = urldecode($zone);
|
$this->zone = urldecode($zone);
|
||||||
$this->getDefenceService()->getModel()->where(['zone' => $this->zone]);
|
$this->getDefenceService()->getModel()->where(['zone' => $this->zone]);
|
||||||
$this->getDefenceService()->getModel()->orderBy(['zone' => 'asc', 'parents' => 'asc', 'child' => 'asc']);
|
$this->getDefenceService()->getModel()->orderBy(['zone' => 'asc', 'parents' => 'asc', 'child' => 'asc']);
|
||||||
$this->curPage = intval($this->request->get('curPage', 1));
|
[$this->total, $this->entities, $this->pagination, $this->curPage, $this->perPage] = $this->getDefenceService()->getList(
|
||||||
$this->perPage = intval($this->request->get('perPage', APP_VIEW_LIST_PERPAGE));
|
$this->request->get('curPage'),
|
||||||
[$this->total, $this->entities] = $this->getDefenceService()->getList($this->curPage, $this->perPage);
|
$this->request->get('perPage')
|
||||||
$this->pagination = new Pagination($this->total, (int)$this->curPage, (int)$this->perPage);
|
);
|
||||||
return $this->render(__FUNCTION__);
|
return $this->render(__FUNCTION__);
|
||||||
}
|
}
|
||||||
} //Class
|
} //Class
|
||||||
|
|||||||
@ -5,7 +5,6 @@ namespace lib\Controllers;
|
|||||||
use lib\Entities\ClientEntity;
|
use lib\Entities\ClientEntity;
|
||||||
use lib\Services\ClientService;
|
use lib\Services\ClientService;
|
||||||
use lib\Services\OnetimeService;
|
use lib\Services\OnetimeService;
|
||||||
use lib\Utils\Pagination;
|
|
||||||
|
|
||||||
class OnetimeController extends DBMSController
|
class OnetimeController extends DBMSController
|
||||||
{
|
{
|
||||||
@ -43,11 +42,11 @@ class OnetimeController extends DBMSController
|
|||||||
}
|
}
|
||||||
//업체명_일회성만 나오게하기 위해서
|
//업체명_일회성만 나오게하기 위해서
|
||||||
$this->getOnetimeService()->getModel()->where('service_code', $this->service->getServiceCode());
|
$this->getOnetimeService()->getModel()->where('service_code', $this->service->getServiceCode());
|
||||||
$this->curPage = intval($this->request->get('curPage', 1));
|
$this->getOnetimeService()->getModel()->orderBy('onetime_num', 'DESC');
|
||||||
$this->perPage = intval($this->request->get('perPage', APP_VIEW_LIST_PERPAGE));
|
[$this->total, $this->entities, $this->pagination, $this->curPage, $this->perPage] = $this->getOnetimeService()->getList(
|
||||||
[$this->total, $this->entities] = $this->getOnetimeService()->getList($this->curPage, $this->perPage);
|
$this->request->get('curPage'),
|
||||||
$this->pagination = new Pagination($this->total, (int)$this->curPage, (int)$this->perPage);
|
$this->request->get('perPage')
|
||||||
|
);
|
||||||
//전체 사용자정보
|
//전체 사용자정보
|
||||||
$this->clients = $this->getClientService()->getEntities();
|
$this->clients = $this->getClientService()->getEntities();
|
||||||
//전체 관리자정보
|
//전체 관리자정보
|
||||||
|
|||||||
@ -4,7 +4,6 @@ namespace lib\Controllers;
|
|||||||
|
|
||||||
use lib\Services\ClientService;
|
use lib\Services\ClientService;
|
||||||
use lib\Services\ServerService;
|
use lib\Services\ServerService;
|
||||||
use lib\Utils\Pagination;
|
|
||||||
|
|
||||||
class ServerController extends DBMSController
|
class ServerController extends DBMSController
|
||||||
{
|
{
|
||||||
|
|||||||
@ -4,7 +4,7 @@ namespace lib\Controllers;
|
|||||||
|
|
||||||
use lib\Services\AddDbService;
|
use lib\Services\AddDbService;
|
||||||
use lib\Services\ClientService;
|
use lib\Services\ClientService;
|
||||||
use lib\Utils\Pagination;
|
use lib\Configs\Pagination;
|
||||||
|
|
||||||
class ServiceController extends DBMSController
|
class ServiceController extends DBMSController
|
||||||
{
|
{
|
||||||
@ -76,11 +76,11 @@ class ServiceController extends DBMSController
|
|||||||
//전체 사용자정보
|
//전체 사용자정보
|
||||||
$this->clients = $this->getClientService()->getEntities();
|
$this->clients = $this->getClientService()->getEntities();
|
||||||
//부가서비스용 서비스목록 가져오기
|
//부가서비스용 서비스목록 가져오기
|
||||||
$this->curPage = intval($this->request->get('curPage', 1));
|
|
||||||
$this->perPage = intval($this->request->get('perPage', APP_VIEW_LIST_PERPAGE));
|
|
||||||
$this->getServiceService()->getModel()->whereIn('service_code', $service_codes);
|
$this->getServiceService()->getModel()->whereIn('service_code', $service_codes);
|
||||||
[$this->total, $this->entities] = $this->getServiceService()->getList($this->curPage, $this->perPage);
|
[$this->total, $this->entities, $this->pagination, $this->curPage, $this->perPage] = $this->getServiceService()->getList(
|
||||||
$this->pagination = new Pagination($this->total, (int)$this->curPage, (int)$this->perPage);
|
$this->request->get('curPage'),
|
||||||
|
$this->request->get('perPage')
|
||||||
|
);
|
||||||
return $this->render(__FUNCTION__);
|
return $this->render(__FUNCTION__);
|
||||||
}
|
}
|
||||||
} //Class
|
} //Class
|
||||||
|
|||||||
@ -45,9 +45,11 @@ class QueryBuilder
|
|||||||
if (!empty($this->joins)) {
|
if (!empty($this->joins)) {
|
||||||
$sql .= ' ' . implode(' ', $this->joins);
|
$sql .= ' ' . implode(' ', $this->joins);
|
||||||
}
|
}
|
||||||
|
// Where 처리
|
||||||
if (!empty($this->where)) {
|
if (!empty($this->where)) {
|
||||||
$sql .= " WHERE " . $this->buildWhereSql();
|
$sql .= " WHERE " . $this->buildWhereSql();
|
||||||
}
|
}
|
||||||
|
// Order 처리
|
||||||
if (!empty($this->order)) {
|
if (!empty($this->order)) {
|
||||||
$sql .= " ORDER BY " . implode(', ', $this->order);
|
$sql .= " ORDER BY " . implode(', ', $this->order);
|
||||||
}
|
}
|
||||||
@ -153,17 +155,19 @@ class QueryBuilder
|
|||||||
// $model->orLikeIn(['name', 'nickname'], '%철수%');
|
// $model->orLikeIn(['name', 'nickname'], '%철수%');
|
||||||
public function like(array|string $column, ?string $value = null, string $operator = 'LIKE', string $boolean = "AND"): static
|
public function like(array|string $column, ?string $value = null, string $operator = 'LIKE', string $boolean = "AND"): static
|
||||||
{
|
{
|
||||||
|
$escapeClause = in_array(strtoupper($operator), ['LIKE', 'NOT LIKE']) ? " ESCAPE '\\\\'" : '';
|
||||||
|
|
||||||
if (is_array($column)) {
|
if (is_array($column)) {
|
||||||
$conditions = [];
|
$conditions = [];
|
||||||
foreach ($column as $col => $val) {
|
foreach ($column as $col => $val) {
|
||||||
$placeholder = ':l_' . count($this->bindings);
|
$placeholder = ':l_' . count($this->bindings);
|
||||||
$conditions[] = "$col $operator $placeholder";
|
$conditions[] = "$col $operator $placeholder$escapeClause";
|
||||||
$this->bindings[$placeholder] = $val;
|
$this->bindings[$placeholder] = $val;
|
||||||
}
|
}
|
||||||
$this->where[] = ['condition' => '(' . implode(" $boolean ", $conditions) . ')', 'boolean' => $boolean];
|
$this->where[] = ['condition' => '(' . implode(" $boolean ", $conditions) . ')', 'boolean' => $boolean];
|
||||||
} else {
|
} else {
|
||||||
$placeholder = ':l_' . count($this->bindings);
|
$placeholder = ':l_' . count($this->bindings);
|
||||||
$condition = "$column $operator $placeholder";
|
$condition = "$column $operator $placeholder$escapeClause";
|
||||||
$this->bindings[$placeholder] = $value;
|
$this->bindings[$placeholder] = $value;
|
||||||
$this->where[] = ['condition' => $condition, 'boolean' => $boolean];
|
$this->where[] = ['condition' => $condition, 'boolean' => $boolean];
|
||||||
}
|
}
|
||||||
@ -173,15 +177,22 @@ class QueryBuilder
|
|||||||
{
|
{
|
||||||
return $this->like($column, $value, $operator, $boolean);
|
return $this->like($column, $value, $operator, $boolean);
|
||||||
}
|
}
|
||||||
|
public function notLike(array|string $column, ?string $value = null, string $operator = 'NOT LIKE', string $boolean = "AND"): static
|
||||||
|
{
|
||||||
|
return $this->like($column, $value, $operator, $boolean);
|
||||||
|
}
|
||||||
|
//likeIn 사용예:
|
||||||
public function likeIn(array $columns, string $value, string $operator = "LIKE", string $boolean = "AND"): static
|
public function likeIn(array $columns, string $value, string $operator = "LIKE", string $boolean = "AND"): static
|
||||||
{
|
{
|
||||||
|
$escapeClause = in_array(strtoupper($operator), ['LIKE', 'NOT LIKE']) ? " ESCAPE '\\\\'" : '';
|
||||||
$orConditions = [];
|
$orConditions = [];
|
||||||
|
|
||||||
foreach ($columns as $col) {
|
foreach ($columns as $col) {
|
||||||
$placeholder = ':li_' . count($this->bindings);
|
$placeholder = ':li_' . count($this->bindings);
|
||||||
$orConditions[] = "$col $operator $placeholder";
|
$orConditions[] = "$col $operator $placeholder$escapeClause";
|
||||||
$this->bindings[$placeholder] = $value;
|
$this->bindings[$placeholder] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->where[] = '(' . implode(" $boolean ", $orConditions) . ')';
|
$this->where[] = '(' . implode(" $boolean ", $orConditions) . ')';
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
219
extdbms/lib/Core/Database/QueryBuilder_Ver2.php
Normal file
219
extdbms/lib/Core/Database/QueryBuilder_Ver2.php
Normal file
@ -0,0 +1,219 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace lib\Core\Database;
|
||||||
|
|
||||||
|
use PDO;
|
||||||
|
|
||||||
|
class QueryBuilder_Ver2
|
||||||
|
{
|
||||||
|
private $_debug = false;
|
||||||
|
protected PDO $pdo;
|
||||||
|
protected string $table = '';
|
||||||
|
protected array $selects = [];
|
||||||
|
protected array $wheres = [];
|
||||||
|
protected array $bindings = [];
|
||||||
|
protected array $likes = [];
|
||||||
|
protected array $likeIns = [];
|
||||||
|
protected array $notLikeIns = [];
|
||||||
|
protected string $orderBy = '';
|
||||||
|
protected string $groupBy = '';
|
||||||
|
protected string $limit = '';
|
||||||
|
protected bool $debug = false;
|
||||||
|
protected bool $inTransaction = false;
|
||||||
|
|
||||||
|
public function __construct(PDO $pdo)
|
||||||
|
{
|
||||||
|
$this->pdo = $pdo;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function setDebug(bool $debug): void
|
||||||
|
{
|
||||||
|
$this->_debug = $debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function table(string $table): self
|
||||||
|
{
|
||||||
|
$this->table = $table;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function select(...$columns): self
|
||||||
|
{
|
||||||
|
$this->selects = array_merge($this->selects, $columns);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function where(string $column, mixed $value = null, ?string $operator = null, string $boolean = "AND")
|
||||||
|
{
|
||||||
|
$this->wheres[] = "{$this->escapeIdentifier($column)} {$operator} ?";
|
||||||
|
$this->bindings[] = $value;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function like(string $column, string $value): self
|
||||||
|
{
|
||||||
|
$this->likes[] = $this->escapeIdentifier($column) . " LIKE ?";
|
||||||
|
$this->bindings[] = "%" . $this->escapeLikeString($value) . "%";
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function orLike(string $column, string $value): self
|
||||||
|
{
|
||||||
|
$last = array_pop($this->likes);
|
||||||
|
$condition = $last ? "({$last} OR {$this->escapeIdentifier($column)} LIKE ?)" : "{$this->escapeIdentifier($column)} LIKE ?";
|
||||||
|
$this->likes[] = $condition;
|
||||||
|
$this->bindings[] = "%" . $this->escapeLikeString($value) . "%";
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function likeIn(string $column, array $values): self
|
||||||
|
{
|
||||||
|
$clauses = [];
|
||||||
|
foreach ($values as $val) {
|
||||||
|
$clauses[] = $this->escapeIdentifier($column) . " LIKE ?";
|
||||||
|
$this->bindings[] = "%" . $this->escapeLikeString($val) . "%";
|
||||||
|
}
|
||||||
|
$this->likeIns[] = '(' . implode(' OR ', $clauses) . ')';
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function notLikeIn(string $column, array $values): self
|
||||||
|
{
|
||||||
|
$clauses = [];
|
||||||
|
foreach ($values as $val) {
|
||||||
|
$clauses[] = $this->escapeIdentifier($column) . " NOT LIKE ?";
|
||||||
|
$this->bindings[] = "%" . $this->escapeLikeString($val) . "%";
|
||||||
|
}
|
||||||
|
$this->notLikeIns[] = '(' . implode(' AND ', $clauses) . ')';
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function orderBy(string $column, string $direction = 'ASC'): self
|
||||||
|
{
|
||||||
|
$this->orderBy = "ORDER BY {$this->escapeIdentifier($column)} {$direction}";
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function groupBy(string $column): self
|
||||||
|
{
|
||||||
|
$this->groupBy = "GROUP BY {$this->escapeIdentifier($column)}";
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function limit(int $limit, int $offset = 0): self
|
||||||
|
{
|
||||||
|
$this->limit = "LIMIT {$offset}, {$limit}";
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get(): array
|
||||||
|
{
|
||||||
|
$stmt = $this->execute();
|
||||||
|
return $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function first(): ?array
|
||||||
|
{
|
||||||
|
$this->limit(1);
|
||||||
|
$stmt = $this->execute();
|
||||||
|
return $stmt->fetch(PDO::FETCH_ASSOC) ?: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
$this->select("COUNT(*) as count");
|
||||||
|
$stmt = $this->execute();
|
||||||
|
return (int)($stmt->fetch(PDO::FETCH_ASSOC)['count'] ?? 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function debug(bool $debug = true): self
|
||||||
|
{
|
||||||
|
$this->debug = $debug;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function beginTransaction(): void
|
||||||
|
{
|
||||||
|
if (!$this->inTransaction) {
|
||||||
|
$this->pdo->beginTransaction();
|
||||||
|
$this->inTransaction = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function commit(): void
|
||||||
|
{
|
||||||
|
if ($this->inTransaction) {
|
||||||
|
$this->pdo->commit();
|
||||||
|
$this->inTransaction = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rollback(): void
|
||||||
|
{
|
||||||
|
if ($this->inTransaction) {
|
||||||
|
$this->pdo->rollBack();
|
||||||
|
$this->inTransaction = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(): \PDOStatement
|
||||||
|
{
|
||||||
|
$sql = $this->buildSelectQuery();
|
||||||
|
|
||||||
|
if ($this->debug) {
|
||||||
|
echo "[SQL]: {$sql}\n";
|
||||||
|
echo "[Bindings]: " . json_encode($this->bindings, JSON_UNESCAPED_UNICODE) . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt = $this->pdo->prepare($sql);
|
||||||
|
$stmt->execute($this->bindings);
|
||||||
|
return $stmt;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildSelectQuery(): string
|
||||||
|
{
|
||||||
|
$columns = $this->selects ? implode(', ', array_map([$this, 'escapeIdentifier'], $this->selects)) : '*';
|
||||||
|
$sql = "SELECT {$columns} FROM {$this->escapeIdentifier($this->table)}";
|
||||||
|
|
||||||
|
$conditions = array_merge($this->wheres, $this->likes, $this->likeIns, $this->notLikeIns);
|
||||||
|
if (!empty($conditions)) {
|
||||||
|
$sql .= " WHERE " . implode(' AND ', $conditions);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->groupBy) {
|
||||||
|
$sql .= " {$this->groupBy}";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->orderBy) {
|
||||||
|
$sql .= " {$this->orderBy}";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->limit) {
|
||||||
|
$sql .= " {$this->limit}";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Escape helpers
|
||||||
|
|
||||||
|
public function escape(mixed $value): string
|
||||||
|
{
|
||||||
|
return $this->pdo->quote($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function escapeIdentifier(string $identifier): string
|
||||||
|
{
|
||||||
|
return "`" . str_replace("`", "``", $identifier) . "`";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function escapeLikeString(string $value): string
|
||||||
|
{
|
||||||
|
return str_replace(['%', '_'], ['\\%', '\\_'], $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function escapeLikeIn(array $values): array
|
||||||
|
{
|
||||||
|
return array_map([$this, 'escapeLikeString'], $values);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,7 +9,7 @@ class OnetimeModel extends Model
|
|||||||
const TABLE = "onetimedb";
|
const TABLE = "onetimedb";
|
||||||
const PKField = "onetime_num";
|
const PKField = "onetime_num";
|
||||||
const TitleField = "onetime_sub";
|
const TitleField = "onetime_sub";
|
||||||
const PairField = self::TitleField;
|
const PairField = self::PKField;
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
namespace lib\Services;
|
namespace lib\Services;
|
||||||
|
|
||||||
use lib\Core\Service as Core;
|
use lib\Core\Service as Core;
|
||||||
|
use lib\Configs\Pagination;
|
||||||
|
|
||||||
abstract class CommonService extends Core
|
abstract class CommonService extends Core
|
||||||
{
|
{
|
||||||
@ -38,24 +39,30 @@ abstract class CommonService extends Core
|
|||||||
$entityClass = $this->getEntityClass();
|
$entityClass = $this->getEntityClass();
|
||||||
$entity = new $entityClass($result);
|
$entity = new $entityClass($result);
|
||||||
$pairField = $this->getModel()->getPairField();
|
$pairField = $this->getModel()->getPairField();
|
||||||
|
// echo "pairField:" . $pairField . "<BR>";
|
||||||
$entitys[$entity->$pairField] = $entity;
|
$entitys[$entity->$pairField] = $entity;
|
||||||
}
|
}
|
||||||
return $entitys;
|
return $entitys;
|
||||||
} //
|
} //
|
||||||
final public function getCount(string $select = "COUNT(*) as cnt", string $column = 'cnt'): int
|
final public function getCount(string $select = "COUNT(*) as cnt", string $column = 'cnt'): int
|
||||||
{
|
{
|
||||||
$count = $this->getModel()->count($select, $column);
|
return $this->getModel()->count($select, $column);
|
||||||
// echo "<BR>" . $this->getModel()->getLastQuery();
|
|
||||||
return $count;
|
|
||||||
}
|
}
|
||||||
final public function getList(int $curPage = 1, int $perPage = APP_VIEW_LIST_PERPAGE): array
|
final public function getList($curPage = null, $perPage = null): array
|
||||||
{
|
{
|
||||||
$total = $this->getCount();
|
$total = $this->getCount();
|
||||||
|
$curPage = $curPage ?? 1;
|
||||||
|
$perPage = $perPage ?? APP_VIEW_LIST_PERPAGE;
|
||||||
|
$curPage = (int)$curPage;
|
||||||
|
$perPage = (int)$perPage;
|
||||||
|
$curPage = intval($curPage > 0 ? $curPage : 1);
|
||||||
|
$perPage = intval($perPage > 0 ? $perPage : APP_VIEW_LIST_PERPAGE);
|
||||||
//limit, offset 설정
|
//limit, offset 설정
|
||||||
$this->getModel()->limit($perPage);
|
$this->getModel()->limit($perPage);
|
||||||
$this->getModel()->offset(($curPage - 1) * $perPage);
|
$this->getModel()->offset(($curPage - 1) * $perPage);
|
||||||
$entities = $this->getEntities();
|
$entities = $this->getEntities();
|
||||||
return [$total, $entities];
|
$pagination = new Pagination($total, $curPage, $perPage);
|
||||||
|
return [$total, $entities, $pagination, $curPage, $perPage];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function insert(array $formData): mixed
|
protected function insert(array $formData): mixed
|
||||||
|
|||||||
@ -32,25 +32,6 @@ class ServiceService extends CommonService
|
|||||||
return Entity::class;
|
return Entity::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
//미지급금 리스트
|
|
||||||
public function getEntitiesForNonPayment(int $curPage, int $perPage, array $exclude_clients): array
|
|
||||||
{
|
|
||||||
$table = $this->getModel()->getTable();
|
|
||||||
$clientTable = ClientModel::TABLE;
|
|
||||||
$addDbTable = AddDbModel::TABLE;
|
|
||||||
$this->getModel()->select("{$clientTable}.Client_Name,{$table}.service_code,service_line,server_code,service_ip,service_payment_date,service_amount,service_nonpayment,service_note,addDB_case,addDB_nonpayment,addDB_payment,addDB_accountStatus,addDB_ip,addDB_payment_date");
|
|
||||||
$this->getModel()->join($clientTable, "{$table}.client_code = {$clientTable}.Client_Code");
|
|
||||||
$this->getModel()->join($addDbTable, "{$table}.service_code = {$addDbTable}.service_code");
|
|
||||||
$this->getModel()->whereNotIn("{$addDbTable}.client_code", $exclude_clients);
|
|
||||||
$this->getModel()->whereNotIn("{$addDbTable}.addDB_accountStatus", ["complete"]);
|
|
||||||
$this->getModel()->orderBy("service_payment_date", "DESC");
|
|
||||||
$total = $this->getCount();
|
|
||||||
//limit, offset 설정
|
|
||||||
$this->getModel()->limit($perPage);
|
|
||||||
$this->getModel()->offset(($curPage - 1) * $perPage);
|
|
||||||
return [$total, $this->getEntities()];
|
|
||||||
}
|
|
||||||
|
|
||||||
//지역(치바,도쿄등)에 따른 DASHBOARD용 서비스 카운트
|
//지역(치바,도쿄등)에 따른 DASHBOARD용 서비스 카운트
|
||||||
private function getDistrictCountForDashboard(string $where, string $type, array $switchcodes): int
|
private function getDistrictCountForDashboard(string $where, string $type, array $switchcodes): int
|
||||||
{
|
{
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@if ($client)
|
@if ($client)
|
||||||
<h3>고객명 : <a href="/serviceDetail.sev?client_code={{$client->getClientCode()}}">{{$client->getTitle()}}</a> / 쿠폰발급대상 : {{count($entities)}} 대 / 전체 남은 수량 : {{$total_coupon}} 개</h3>
|
<h3>고객명 : <a href="/serviceDetail.sev?client_code={{$client->getClientCode()}}">{{$client->getTitle()}}</a> / 쿠폰발급대상 : {{count($entities)}} 대</h3>
|
||||||
@endif
|
@endif
|
||||||
<div class="table-responsive" id="table">
|
<div class="table-responsive" id="table">
|
||||||
<input type="hidden" id="token">
|
<input type="hidden" id="token">
|
||||||
@ -39,7 +39,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@php $i=0 @endphp
|
@php $i=0 @endphp
|
||||||
@foreach($entities as $entity)
|
@foreach($entities as $key=>$entity)
|
||||||
<form method="post" action="{{DBMS_SITE_HOST}}/dbms/client/coupon/update">
|
<form method="post" action="{{DBMS_SITE_HOST}}/dbms/client/coupon/update">
|
||||||
<input type="hidden" name="service_code" value="{{$entity->getServiceCode()}}">
|
<input type="hidden" name="service_code" value="{{$entity->getServiceCode()}}">
|
||||||
<input type="hidden" name="member_code" value="{{$member ? $member->getPK() : ""}}">
|
<input type="hidden" name="member_code" value="{{$member ? $member->getPK() : ""}}">
|
||||||
@ -51,8 +51,8 @@
|
|||||||
<td><input type="text" name="title" value="" style="width:100%"></td>
|
<td><input type="text" name="title" value="" style="width:100%"></td>
|
||||||
<td><input type="text" name="coupon" value="{{$entity->getCoupon()}}" maxlength="3" size="3"></td>
|
<td><input type="text" name="coupon" value="{{$entity->getCoupon()}}" maxlength="3" size="3"></td>
|
||||||
<td><input type="text" name="coupon_use" value="{{$entity->getUsedCoupon()}}" maxlength="3" size="3"></td>
|
<td><input type="text" name="coupon_use" value="{{$entity->getUsedCoupon()}}" maxlength="3" size="3"></td>
|
||||||
<td><textarea name="coupon_note" rows="2" cols="40">{{$entity->getUsedCoupon()}}</textarea></td>
|
<td><textarea name="coupon_note" rows="2" cols="40"></textarea></td>
|
||||||
<td><input type="submit" value="수정"> <a href="{{DBMS_SITE_HOST}}/dbms/onetime/index?service_code={{$entity->getServiceCode()}}">내역보기</a></td>
|
<td><a href="/IdcOnetimeList.sev?service_code={{$entity->getServiceCode()}}">내역보기</a> <input type="submit" value="수정"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</form>
|
</form>
|
||||||
@php $i++ @endphp
|
@php $i++ @endphp
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach ($entities as $entity)
|
@foreach($entities as $key=>$entity)
|
||||||
<tr>
|
<tr>
|
||||||
<td style="text-align:center;"><a href="/IdcDepositNonPaymentList.dep?searchContent={{$entity->Client_Name}}">{{$entity->Client_Name}}</a></td>
|
<td style="text-align:center;"><a href="/IdcDepositNonPaymentList.dep?searchContent={{$entity->Client_Name}}">{{$entity->Client_Name}}</a></td>
|
||||||
<td style="text-align:center;">{{$entity->addDB_case}}</td>
|
<td style="text-align:center;">{{$entity->addDB_case}}</td>
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@php $i=0 @endphp
|
@php $i=0 @endphp
|
||||||
@foreach($entities as $entity)
|
@foreach($entities as $key=>$entity)
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{$total-(($curPage-1)*$perPage+$i)}}</td>
|
<td>{{$total-(($curPage-1)*$perPage+$i)}}</td>
|
||||||
<td>{{$entity->getTitle()}}</td>
|
<td>{{$entity->getTitle()}}</td>
|
||||||
|
|||||||
@ -120,7 +120,7 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<ul class="table-ul">
|
<ul class="table-ul">
|
||||||
@foreach ($entities as $entity)
|
@foreach($entities as $key=>$entity)
|
||||||
@php $zone = $entity->getZone() @endphp
|
@php $zone = $entity->getZone() @endphp
|
||||||
<li class="icon-<?= $zone ?>" id="{{$zone == $this->zone ? "active" : ""}}">
|
<li class="icon-<?= $zone ?>" id="{{$zone == $this->zone ? "active" : ""}}">
|
||||||
<a href="/DefenseInfoMK.sev?zone={{$zone}}"><?= $zone ?></a>
|
<a href="/DefenseInfoMK.sev?zone={{$zone}}"><?= $zone ?></a>
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach ($entities as $entity)
|
@foreach($entities as $key=>$entity)
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{$entity->getProcess()}}</td>
|
<td>{{$entity->getProcess()}}</td>
|
||||||
<td>{{$entity->getSpec()}}</td>
|
<td>{{$entity->getSpec()}}</td>
|
||||||
|
|||||||
@ -35,12 +35,12 @@
|
|||||||
<th>상태</th>
|
<th>상태</th>
|
||||||
<th>관리자명</th>
|
<th>관리자명</th>
|
||||||
<th>작업일</th>
|
<th>작업일</th>
|
||||||
|
<th>비고</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@php $i=0 @endphp
|
@php $i=0 @endphp
|
||||||
@foreach($entities as $entity)
|
@foreach($entities as $key=>$entity)
|
||||||
{{$entity->getMemberCode()}}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{$total-(($curPage-1)*$perPage+$i)}}</td>
|
<td>{{$total-(($curPage-1)*$perPage+$i)}}</td>
|
||||||
<td>{{$clients[$entity->getClientCode()]->getTitle()}}</td>
|
<td>{{$clients[$entity->getClientCode()]->getTitle()}}</td>
|
||||||
@ -54,11 +54,11 @@
|
|||||||
<td>{{$entity->getStatus()}}</td>
|
<td>{{$entity->getStatus()}}</td>
|
||||||
<td>{{$entity->getMemberCode()}}</td>
|
<td>{{$entity->getMemberCode()}}</td>
|
||||||
<td>{{$entity->getInsertDate()}}</td>
|
<td>{{$entity->getInsertDate()}}</td>
|
||||||
|
<td style="text-align:left">{{nl2br($entity->getNote())}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@php $i++ @endphp
|
@php $i++ @endphp
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
{{DBMS_SITE_HOST}}/dbms/onetime/index?service_code={{$entity->getServiceCode()}}
|
<div style="text-align:center">{!!$pagination->render(DBMS_SITE_URL . "/IdcOnetimeList.sev", ['service_code' => $service ? $service->getServiceCode() : "", 'member_code' => $member ? $member->getPK() : "", 'curPage' => $curPage, 'perPage' => $perPage])!!}</div>
|
||||||
<div style="text-align:center">{!!$pagination->render(DBMS_SITE_HOST."/dbms/onetime/index", ['service_code' => $service->getServiceCode(), 'curPage' => $curPage, 'perPage' => $perPage])!!}</div>
|
|
||||||
@ -102,7 +102,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach ($entities as $entity)
|
@foreach($entities as $key=>$entity)
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ $entity->getClientCode()}}</td>
|
<td>{{ $entity->getClientCode()}}</td>
|
||||||
<td>{{$clients[$entity->getClientCode()]->getTitle()}}</td>
|
<td>{{$clients[$entity->getClientCode()]->getTitle()}}</td>
|
||||||
@ -117,4 +117,4 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
<tfoot></tfoot>
|
<tfoot></tfoot>
|
||||||
</table>
|
</table>
|
||||||
<div style="tex-align:center">{{$pagination->render(DBMS_SITE_URL . "/usableServerList.ser", ['ip' => $ip, 'curPage' => $curPage, 'perPage' => $perPage])}}</div>
|
<div style="text-align:center">{{$pagination->render(DBMS_SITE_URL . "/usableServerList.ser", ['ip' => $ip, 'curPage' => $curPage, 'perPage' => $perPage])}}</div>
|
||||||
@ -8,7 +8,7 @@
|
|||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h4><i class="fa fa-desktop fa-fw"></i> 일회성서비스 리스트</h4>
|
<h4><i class="fa fa-desktop fa-fw"></i> 일회성서비스 리스트</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body"><c:import url="${phpurl}/dbms/onetime/index?service_code=${param.service_code}" /></div>
|
<div class="panel-body"><c:import url="${phpurl}/dbms/onetime/index?service_code=${param.service_code}&curPage=${param.curPage}&perPage=${param.perPage}" /></div>
|
||||||
<!-- panel-body -->
|
<!-- panel-body -->
|
||||||
</div>
|
</div>
|
||||||
<!-- panel panel-default -->
|
<!-- panel panel-default -->
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user