dbms init...1
This commit is contained in:
parent
4834142a5c
commit
a587f600a3
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
namespace lib\Controller;
|
||||
|
||||
namespace lib\Controllers;
|
||||
|
||||
require_once "lib/autoload.php";
|
||||
|
||||
@ -9,15 +10,11 @@ if ($argc < 2) {
|
||||
if (!is_file($argv[1])) {
|
||||
die($argv[1] . "는 파일형식이 아닙니다. \n");
|
||||
}
|
||||
$client_type = isset($argv[2]) ? $argv[2]:'Client_Code';
|
||||
$client_field = isset($argv[2]) ? $argv[2] : 'Client_Code';
|
||||
$lines = file($argv[1]);
|
||||
if (!is_array($lines)) {
|
||||
die($argv[1] . "는 파일데이터에 오류가 있습니다. \n");
|
||||
}
|
||||
|
||||
$debug = false;
|
||||
$coupon = new Coupon();
|
||||
list($successes,$failes) = $coupon->execute($lines,$client_type,$debug);
|
||||
print("Coupon 설정이 완료되었습니다.\n");
|
||||
print_r($successes);
|
||||
print_r($failes);
|
||||
$control = new ServiceController();
|
||||
$control->execute($lines, $client_field);
|
||||
echo "Coupon 설정이 완료되었습니다.\n";
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
<?php
|
||||
namespace lib\Controller;
|
||||
|
||||
namespace lib\Controllers;
|
||||
|
||||
require_once "lib/autoload.php";
|
||||
try {
|
||||
$extra = new ExtraService();
|
||||
return $extra->execute("딥파인더");
|
||||
} catch (\Exception $e) {
|
||||
die($e->getMessage());
|
||||
}
|
||||
$control = new ServiceController();
|
||||
return $extra->execute("딥파인더");
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
<?php
|
||||
namespace lib\Controller;
|
||||
|
||||
namespace lib\Controllers;
|
||||
|
||||
require_once "lib/autoload.php";
|
||||
try {
|
||||
$billing = new Billing();
|
||||
return $billing->execute($_GET);
|
||||
$control = new ClientController();
|
||||
return $control->getBillingPaper($_GET);
|
||||
} catch (\Exception $e) {
|
||||
die($e->getMessage());
|
||||
}
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
<?php
|
||||
namespace lib\Controller;
|
||||
|
||||
namespace lib\Controllers;
|
||||
|
||||
require_once "lib/autoload.php";
|
||||
try {
|
||||
$extra = new ExtraService();
|
||||
return $extra->execute("닷 디펜더");
|
||||
} catch (\Exception $e) {
|
||||
die($e->getMessage());
|
||||
}
|
||||
$control = new ServiceController();
|
||||
return $extra->execute("닷 디펜더");
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace lib\Controller;
|
||||
|
||||
use lib\Core\Controller;
|
||||
|
||||
class Billing extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
} //
|
||||
|
||||
final public function getAccounts($site_id)
|
||||
{
|
||||
switch ($site_id) {
|
||||
case 'PRIMEIDC':
|
||||
return [
|
||||
["id" => "331301-04-217387", "name" => '국민은행', "owner" => "주)듀나미스"],
|
||||
];
|
||||
break;
|
||||
case "ITSOLUTION":
|
||||
return [
|
||||
["id" => "351-0995-6751-73", "name" => '농협', "owner" => "주식회사 르호봇"],
|
||||
["id" => "9002-1932-1654-1", "name" => '새마을금고', "owner" => "주식회사 르호봇"],
|
||||
];
|
||||
break;
|
||||
case 'GDIDC':
|
||||
return [
|
||||
["id" => "1005-204-100758", "name" => '우리은행', "owner" => " (주)브엘라해로이"],
|
||||
];
|
||||
break;
|
||||
default:
|
||||
throw new \Exception(sprintf(__METHOD__ . "에서 오류 SiteID[%s]가 정의되지 않았습니다.", $site_id));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function execute($datas)
|
||||
{
|
||||
$this->view->site = $this->getSite();
|
||||
$this->view->client = $this->getModel("Client")->getData(array(sprintf("Client_Code='%s'", $datas['client_code'])));
|
||||
$this->view->accounts = $this->getAccounts($this->view->site['id']);
|
||||
return $this->render('depositbillpaper');
|
||||
}
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
namespace lib\Controller;
|
||||
|
||||
use lib\Core\Controller;
|
||||
|
||||
class Coupon extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
} //
|
||||
final public function getCouponInfo($data, $field)
|
||||
{
|
||||
$client = $this->getModel("Client")->getClient(sprintf("%s='%s'", $field, $data));
|
||||
$service = $this->getModel("Service")->getOneTime($client->Client_Name);
|
||||
return array(
|
||||
"client" => $client,
|
||||
"service" => $service,
|
||||
);
|
||||
} //
|
||||
|
||||
public function execute(array $lines, $field = "Client_Code", $debug=false)
|
||||
{
|
||||
$loop=1;
|
||||
$successes = array();
|
||||
$failes = array();
|
||||
foreach ($lines as $line) {
|
||||
list($info, $coupon_cnt) = explode("||", rtrim($line));
|
||||
$coupon = $this->getCouponInfo($info, $field);
|
||||
if(isset($coupon['service']->service_code)){
|
||||
//쿠폰 설정
|
||||
$where = sprintf("service_code='%s'", $coupon['service']->service_code);
|
||||
$this->getModel("Service")->setCoupon($coupon_cnt, $where, $debug);
|
||||
|
||||
$result = sprintf("%20s[%20s:%15s]=>쿠폰 %3d개 설정 성공\n", $coupon['client']->Client_Name,
|
||||
$coupon['service']->server_code, $coupon['service']->service_code, $coupon_cnt);
|
||||
array_push($successes, $result);
|
||||
} else {
|
||||
$result = sprintf("%5d번째: %s 설정 실패\n", $loop,rtrim($line));
|
||||
array_push($failes, $result);
|
||||
}
|
||||
$loop++;
|
||||
}
|
||||
return array($successes,$failes);
|
||||
}
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
namespace lib\Controller;
|
||||
|
||||
use lib\Core\Controller;
|
||||
|
||||
class ExtraService extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
} //
|
||||
|
||||
public function execute($code)
|
||||
{
|
||||
$this->view->results = $this->getModel("Service")->getExtras($code);
|
||||
return $this->render('extraservice');
|
||||
}
|
||||
} //Class
|
||||
23
extdbms/lib/Controllers/ClientController.php
Normal file
23
extdbms/lib/Controllers/ClientController.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace lib\Controllers;
|
||||
|
||||
class ClientController extends CommonController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
} //
|
||||
|
||||
public function getBillingPaper(array $datas)
|
||||
{
|
||||
$this->view->siteinfo = $this->getSiteInfo();
|
||||
$this->getClientModel()->where(["Client_Code" => $datas['client_code']]);
|
||||
$entity = $this->getClientModel()->getEntity();
|
||||
if (!$entity) {
|
||||
throw new \Exception($datas['client_code'] . "에 해당하는 고객이 존재하지 않습니다.");
|
||||
}
|
||||
$this->view->client = $entity;
|
||||
return $this->render('depositbillpaper');
|
||||
}
|
||||
}
|
||||
76
extdbms/lib/Controllers/CommonController.php
Normal file
76
extdbms/lib/Controllers/CommonController.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace lib\Controllers;
|
||||
|
||||
use lib\Core\Controller;
|
||||
use lib\Models\ClientModel;
|
||||
use lib\Models\ServiceModel;
|
||||
|
||||
abstract class CommonController extends Controller
|
||||
{
|
||||
private $_clientModel = null;
|
||||
private $_serviceModel = null;
|
||||
protected function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
} //
|
||||
|
||||
final protected function getClientModel(): ClientModel
|
||||
{
|
||||
if ($this->_clientModel === null) {
|
||||
$this->_clientModel = new ClientModel();
|
||||
}
|
||||
return $this->_clientModel;
|
||||
}
|
||||
final protected function getServiceModel(): ServiceModel
|
||||
{
|
||||
if ($this->_serviceModel === null) {
|
||||
$this->_serviceModel = new ServiceModel();
|
||||
}
|
||||
return $this->_serviceModel;
|
||||
}
|
||||
|
||||
final public function getSiteInfo(): array
|
||||
{
|
||||
$domain = array_key_exists("HTTP_HOST", $_SERVER) ? $_SERVER["HTTP_HOST"] : false;
|
||||
switch ($domain) {
|
||||
case 'dbms.prime-idc.jp':
|
||||
return [
|
||||
"id" => "PRIMEIDC",
|
||||
"domain" => "dbms.prime-idc.jp",
|
||||
"name" => "PrimeIDC",
|
||||
"email" => "primeidc.jp@gmail.com",
|
||||
"banks" => [
|
||||
["id" => "331301-04-217387", "name" => '국민은행', "owner" => "주)듀나미스"]
|
||||
],
|
||||
];
|
||||
break;
|
||||
case "dbms.itsolution-idc.jp":
|
||||
return [
|
||||
"id" => "ITSOLUTION",
|
||||
"domain" => "dbms.itsolution-idc.jp",
|
||||
"name" => "Itsolution",
|
||||
"email" => "support@itsoution-idc.jp",
|
||||
"banks" => [
|
||||
["id" => "9002-1932-1654-1", "name" => '새마을금고', "owner" => "주식회사 르호봇"],
|
||||
["id" => "351-0995-6751-73", "name" => '농협', "owner" => "주식회사 르호봇"],
|
||||
],
|
||||
];
|
||||
break;
|
||||
case 'dbms.gdidc.jp':
|
||||
return [
|
||||
"id" => "GDIDC",
|
||||
"domain" => "dbms.gdidc.jp",
|
||||
"name" => "GDIDC",
|
||||
"email" => "support@gdidc.jp",
|
||||
"banks" => [
|
||||
["id" => "1005-204-100758", "name" => '우리은행', "owner" => " (주)브엘라해로이"],
|
||||
],
|
||||
];
|
||||
break;
|
||||
default:
|
||||
throw new \Exception(sprintf(__METHOD__ . "에서 오류 Domain[%s]이 정의되지 않았습니다.", $domain));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} //Class
|
||||
@ -1,18 +1,18 @@
|
||||
<?php
|
||||
namespace lib\Controller;
|
||||
|
||||
use lib\Core\Controller;
|
||||
namespace lib\Controllers;
|
||||
|
||||
class Statistics extends Controller
|
||||
class DashboardController extends CommonController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
} //
|
||||
public function execute()
|
||||
public function mainPage()
|
||||
{
|
||||
$this->view->types = $this->getModel("Service")->getTypes_Dashboard();
|
||||
$this->view->results = $this->getModel("Service")->getSummary_Dashboard($this->getSite()['id']);
|
||||
$this->view->types = $this->getServiceModel()->getTypes_Dashboard();
|
||||
$site = $this->getSiteInfo();
|
||||
$this->view->results = $this->getServiceModel()->getSummary_Dashboard($site['id']);
|
||||
|
||||
$summary = array();
|
||||
foreach ($this->view->types as $type) {
|
||||
@ -32,7 +32,6 @@ class Statistics extends Controller
|
||||
$total['Tokyo'] += $summary[$type]['Tokyo'];
|
||||
$total['Chiba'] += $summary[$type]['Chiba'];
|
||||
}
|
||||
|
||||
$this->view->summary = $summary;
|
||||
$this->view->total = $total;
|
||||
return $this->render('total_counting');
|
||||
52
extdbms/lib/Controllers/ServiceController.php
Normal file
52
extdbms/lib/Controllers/ServiceController.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace lib\Controllers;
|
||||
|
||||
class ServiceController extends CommonController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
} //
|
||||
public function getExtra($code)
|
||||
{
|
||||
$this->view->results = $this->getServiceModel()->getExtras($code);
|
||||
return $this->render('extraservice');
|
||||
}
|
||||
|
||||
public function execute(array $lines, $client_field = "Client_Code", $debug = false)
|
||||
{
|
||||
$loop = 1;
|
||||
foreach ($lines as $line) {
|
||||
list($clientData, $coupon_cnt) = explode("||", rtrim($line));
|
||||
try {
|
||||
//고객정보 가져오기
|
||||
$this->getClientModel()->where([$client_field => $clientData]);
|
||||
$client = $this->getClientModel()->getEntity();
|
||||
//고객 일회성서비스정보(쿠폰) 가져오기
|
||||
$this->getServiceModel()->where(["server_code" => $client->Client_Name . "-일회성"]);
|
||||
$service = $this->getServiceModel()->getEntity();
|
||||
if (isset($service->service_code)) {
|
||||
throw new \Exception("{$loop}번째: [{$client->Client_Name}]고객의 일회성장비가 존재하지 않습니다.");
|
||||
}
|
||||
//쿠폰 설정
|
||||
$this->getServiceModel()->where(["service_code" => $service->service_code]);
|
||||
$this->getServiceModel()->modify(['coupon' => $coupon_cnt]);
|
||||
printf(
|
||||
"%20s[%20s:%15s]=>쿠폰 %3d개 설정 성공\n",
|
||||
$client->Client_Name,
|
||||
$service->server_code,
|
||||
$service->service_code,
|
||||
$coupon_cnt
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
printf(
|
||||
"{$loop}번째: %s 설정 실패:%s\n",
|
||||
rtrim($line),
|
||||
$e->getMessage()
|
||||
);
|
||||
}
|
||||
$loop++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace lib\Core;
|
||||
|
||||
use lib\Core\View;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
private $_debug = false;
|
||||
private $_models = [];
|
||||
protected $view = null;
|
||||
protected function __construct()
|
||||
{
|
||||
@ -18,55 +20,8 @@ abstract class Controller
|
||||
{
|
||||
return $this->_debug;
|
||||
}
|
||||
|
||||
//Model
|
||||
final public function getModel($name)
|
||||
{
|
||||
if (!array_key_exists($name, $this->_models)) {
|
||||
//require_once "lib/Model/" . $model . ".php";
|
||||
$modelName = sprintf("lib\Model\%s", $name);
|
||||
$model = new $modelName();
|
||||
if (!$model instanceof Model) {
|
||||
throw new \Exception("%s Model이 생성되지 않았습니다\n", $modelName);
|
||||
}
|
||||
$this->_models[$name] = $model;
|
||||
}
|
||||
return $this->_models[$name];
|
||||
}
|
||||
|
||||
public function render($file)
|
||||
{
|
||||
return $this->view->render($file);
|
||||
}
|
||||
|
||||
final public function getSite()
|
||||
{
|
||||
$domain = array_key_exists("HTTP_HOST", $_SERVER) ? $_SERVER["HTTP_HOST"] : false;
|
||||
switch ($domain) {
|
||||
case 'dbms.prime-idc.jp':
|
||||
return array(
|
||||
"id" => "PRIMEIDC",
|
||||
"domain" => "dbms.prime-idc.jp",
|
||||
"name" => "PrimeIDC",
|
||||
"email" => "primeidc.jp@gmail.com");
|
||||
break;
|
||||
case "dbms.itsolution-idc.jp":
|
||||
return array(
|
||||
"id" => "ITSOLUTION",
|
||||
"domain" => "dbms.itsolution-idc.jp",
|
||||
"name" => "Itsolution",
|
||||
"email" => "support@itsoution-idc.jp");
|
||||
break;
|
||||
case 'dbms.gdidc.jp':
|
||||
return array(
|
||||
"id" => "GDIDC",
|
||||
"domain" => "dbms.gdidc.jp",
|
||||
"name" => "GDIDC",
|
||||
"email" => "support@gdidc.jp");
|
||||
break;
|
||||
default:
|
||||
throw new \Exception(sprintf(__METHOD__ . "에서 오류 Domain[%s]이 정의되지 않았습니다.", $domain));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} //Class
|
||||
|
||||
30
extdbms/lib/Core/Entity.php
Normal file
30
extdbms/lib/Core/Entity.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace lib\Core;
|
||||
|
||||
class Entity
|
||||
{
|
||||
private $_values = [];
|
||||
private $_debug = false;
|
||||
public function __construct($datas)
|
||||
{
|
||||
$this->values = $datas;
|
||||
} //
|
||||
final public function setDebug($debug)
|
||||
{
|
||||
$this->_debug = $debug;
|
||||
}
|
||||
final public function getDebug()
|
||||
{
|
||||
return $this->_debug;
|
||||
}
|
||||
|
||||
final public function __get($name)
|
||||
{
|
||||
return $this->_values[$name];
|
||||
}
|
||||
final public function __set($name, $value)
|
||||
{
|
||||
$this->_values[$name] = $value;
|
||||
}
|
||||
} //Class
|
||||
@ -1,29 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace lib\Core;
|
||||
|
||||
use lib\Core\Entity;
|
||||
use \PDO;
|
||||
use PDOStatement;
|
||||
|
||||
abstract class Model
|
||||
{
|
||||
private $db = null;
|
||||
private $_db = null;
|
||||
private $_debug = false;
|
||||
private $_mode = PDO::FETCH_OBJ;
|
||||
protected function __construct()
|
||||
private $_column = "*";
|
||||
private $_wheres = [];
|
||||
protected function __construct() {} //
|
||||
|
||||
abstract public function getTable();
|
||||
abstract public function getEntity(): Entity;
|
||||
abstract public function getEntitys(): array;
|
||||
final public function getConnect(): PDO
|
||||
{
|
||||
if ($this->_db === null) {
|
||||
$envs = parse_ini_file("./env.ini", true);
|
||||
if (!$envs) {
|
||||
throw new \Exception(var_export($envs, true));
|
||||
}
|
||||
//echo var_dump($envs);exit;
|
||||
$dsn = sprintf("%s:host=%s;dbname=%s;charset=%s", $envs['db']['driver'], $envs['db']['host'], $envs['db']['name'], $envs['db']['charset']);
|
||||
$this->db = new PDO($dsn, $envs['db']['id'], $envs['db']['passwd']);
|
||||
$this->db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} //
|
||||
|
||||
abstract public function getTable();
|
||||
final public function getDB()
|
||||
{
|
||||
$dsn = sprintf("%s:host=%s;dbname=%s;charset=%s", $envs['db']['driver'], $envs['db']['host'], $envs['db']['name'], $envs['db']['charset']);
|
||||
$this->_db = new PDO($dsn, $envs['db']['id'], $envs['db']['passwd']);
|
||||
$this->_db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||
$this->_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
}
|
||||
return $this->_db;
|
||||
}
|
||||
final public function setDebug($debug)
|
||||
@ -34,42 +40,76 @@ abstract class Model
|
||||
{
|
||||
return $this->_debug;
|
||||
}
|
||||
final public function setMode($mode)
|
||||
|
||||
final public function where(array $wheres, $condition = "AND")
|
||||
{
|
||||
$this->_mode = $mode;
|
||||
foreach ($wheres as $key => $value) {
|
||||
if ($value !== "") {
|
||||
$value = "='{$value}'";
|
||||
}
|
||||
$this->_wheres[] = sprintf("%s%s%s", count($this->_wheres) ? " " . $condition . " " : "", $key, $value);
|
||||
}
|
||||
}
|
||||
final public function getMode()
|
||||
final public function orWhere(array $wheres)
|
||||
{
|
||||
return $this->_mode;
|
||||
$this->where($wheres, "OR");
|
||||
}
|
||||
final public function getWhere()
|
||||
{
|
||||
return count($this->_wheres) ? "WHERE " . implode(" ", $this->_wheres) : "";
|
||||
}
|
||||
|
||||
final public function execute($sql)
|
||||
final public function execute($sql): bool|PDOStatement
|
||||
{
|
||||
$stmt = $this->db->prepare($sql);
|
||||
$stmt = $this->getConnect()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$this->_wheres = [];
|
||||
$this->_column = "*";
|
||||
return $stmt;
|
||||
}
|
||||
final protected function getRow($sql)
|
||||
{
|
||||
$stmt = $this->execute($sql);
|
||||
return $stmt->fetch($this->getMode());
|
||||
}
|
||||
final protected function getRows($sql, $mode = PDO::FETCH_OBJ)
|
||||
{
|
||||
$stmt = $this->execute($sql);
|
||||
return $stmt->fetchAll($this->getMode());
|
||||
}
|
||||
|
||||
final public function getData($wheres = array(), $column = "*")
|
||||
//CUD문
|
||||
final public function create($datas)
|
||||
{
|
||||
$sql = sprintf("SELECT %s FROM %s %s", $column, $this->getTable(), count($wheres) ? "WHERE " . implode("AND", $wheres) : "");
|
||||
//echo $sql;
|
||||
return $this->getRow($sql);
|
||||
$sql = sprintf("INSERT INTO %s VALUES(%s) %s", $this->getTable(), implode(",", $datas), $this->getWhere());
|
||||
return $this->execute($sql);
|
||||
} //
|
||||
final public function modify($datas)
|
||||
{
|
||||
$sql = sprintf("UPDATE %s SET %s %s", $this->getTable(), implode(",", $datas), $this->getWhere());
|
||||
return $this->execute($sql);
|
||||
} //
|
||||
final public function delete()
|
||||
{
|
||||
$sql = sprintf("DELETE FROM %s %s", $this->getTable(), $this->getWhere());
|
||||
return $this->execute($sql);
|
||||
} //
|
||||
|
||||
//Select문
|
||||
final public function setColumn($column)
|
||||
{
|
||||
$this->_column = $column;
|
||||
}
|
||||
final public function getDatas(array $wheres = array(), $column = "*")
|
||||
final public function getColumn()
|
||||
{
|
||||
$sql = sprintf("SELECT %s FROM %s %s", $column, $this->getTable(), count($wheres) ? "WHERE " . implode("AND", $wheres) : "");
|
||||
//echo $sql;
|
||||
return $this->getRows($sql);
|
||||
return $this->_column;
|
||||
}
|
||||
final protected function getRow($mode = PDO::FETCH_OBJ)
|
||||
{
|
||||
$sql = sprintf("SELECT %s FROM %s WHERE %s", $this->getColumn(), $this->getTable(), $this->getWhere());
|
||||
$stmt = $this->execute($sql);
|
||||
return $stmt->fetch($mode);
|
||||
}
|
||||
final protected function getRows($mode = PDO::FETCH_OBJ)
|
||||
{
|
||||
$sql = sprintf("SELECT %s FROM %s WHERE %s", $this->getColumn(), $this->getTable(), $this->getWhere());
|
||||
$stmt = $this->execute($sql);
|
||||
return $stmt->fetchAll($mode);
|
||||
}
|
||||
final protected function getSelectColumn($column, int $return_column = 0)
|
||||
{
|
||||
$sql = sprintf("SELECT %s FROM %s WHERE %s", $column, $this->getTable(), $this->getWhere());
|
||||
$stmt = $this->execute($sql);
|
||||
return $stmt->fetchColumn($return_column);
|
||||
}
|
||||
} //Class
|
||||
|
||||
13
extdbms/lib/Entitys/ClientEntity.php
Normal file
13
extdbms/lib/Entitys/ClientEntity.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace lib\Entitys;
|
||||
|
||||
use lib\Core\Entity;
|
||||
|
||||
class ClientEntity extends Entity
|
||||
{
|
||||
public function __construct($datas)
|
||||
{
|
||||
parent::__construct($datas);
|
||||
} //
|
||||
} //Class
|
||||
11
extdbms/lib/Entitys/CommonEntity.php
Normal file
11
extdbms/lib/Entitys/CommonEntity.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace lib\Core;
|
||||
|
||||
abstract class ClientEntity extends Entity
|
||||
{
|
||||
public function __construct($datas)
|
||||
{
|
||||
parent::__construct($datas);
|
||||
} //
|
||||
} //Class
|
||||
13
extdbms/lib/Entitys/ServiceEntity.php
Normal file
13
extdbms/lib/Entitys/ServiceEntity.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace lib\Entitys;
|
||||
|
||||
use lib\Core\Entity;
|
||||
|
||||
class ServiceEntity extends Entity
|
||||
{
|
||||
public function __construct($datas)
|
||||
{
|
||||
parent::__construct($datas);
|
||||
} //
|
||||
} //Class
|
||||
@ -1,23 +0,0 @@
|
||||
<?php
|
||||
namespace lib\Model;
|
||||
|
||||
use lib\Core\Model as Model;
|
||||
|
||||
class Client extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
} //
|
||||
|
||||
final public function getTable()
|
||||
{
|
||||
return 'clientdb';
|
||||
}
|
||||
|
||||
final public function getClient($where)
|
||||
{
|
||||
$sql = sprintf("SELECT * FROM %s WHERE %s", $this->getTable(), $where);
|
||||
return $this->getRow($sql);
|
||||
} //
|
||||
} //Class
|
||||
@ -1,120 +0,0 @@
|
||||
<?php
|
||||
namespace lib\Model;
|
||||
|
||||
use lib\Core\Model as Model;
|
||||
|
||||
class Service extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
} //
|
||||
|
||||
final public function getTable()
|
||||
{
|
||||
return 'servicedb';
|
||||
}
|
||||
//쿠폰 추가
|
||||
final public function addCoupon($coupon, $where = "",$debug=false)
|
||||
{
|
||||
$sql = sprintf("UPDATE %s SET coupon = coupon+%d %s", $this->getTable(), $coupon, $where ? "WHERE " . $where : $where);
|
||||
if($debug){
|
||||
echo $sql."\n";
|
||||
}else{
|
||||
return $this->execute($sql);
|
||||
}
|
||||
} //
|
||||
//쿠폰 설정
|
||||
final public function setCoupon($coupon, $where = "",$debug=false)
|
||||
{
|
||||
$sql = sprintf("UPDATE %s SET coupon = %d %s", $this->getTable(), $coupon, $where ? "WHERE " . $where : $where);
|
||||
if($debug){
|
||||
echo $sql."\n";
|
||||
}else{
|
||||
return $this->execute($sql);
|
||||
}
|
||||
} //
|
||||
//일회성서비스정보 가져오기
|
||||
final public function getOneTime($client_name)
|
||||
{
|
||||
$sql = sprintf("SELECT * FROM %s WHERE server_code = '%s-일회성'", $this->getTable(), $client_name);
|
||||
//echo $sql . "\n";
|
||||
return $this->getRow($sql);
|
||||
} //
|
||||
final public function getCount($where = "")
|
||||
{
|
||||
$sql = sprintf("SELECT COUNT(*) FROM %s WHERE %s ", $this->getTable(), $where);
|
||||
//echo $sql . "\n";
|
||||
$stmt = $this->execute($sql);
|
||||
return $stmt->fetchColumn(0);
|
||||
} //
|
||||
|
||||
final public function getExtras($code)
|
||||
{
|
||||
$sql = sprintf("SELECT C.Client_Name,S.server_code,S.service_ip,S.service_os,S.service_sw
|
||||
FROM servicedb AS S
|
||||
JOIN clientdb AS C
|
||||
ON S.client_code = C.Client_Code
|
||||
WHERE S.service_code IN (SELECT service_code FROM adddb WHERE addDB_code ='%s')", $code);
|
||||
return $this->getRows($sql);
|
||||
}
|
||||
|
||||
//Dashboard
|
||||
private function getCompanies($site_id)
|
||||
{
|
||||
switch ($site_id) {
|
||||
case 'PRIMEIDC':
|
||||
return array(
|
||||
"idcjp" => "AND Client_Code NOT IN ('C116','C012','C636')",
|
||||
"winidc" => "AND Client_Code='C116'",
|
||||
"gamewing" => "AND Client_Code='C012'",
|
||||
"GDIDC" => "AND Client_Code='C636'",
|
||||
);
|
||||
break;
|
||||
case "ITSOLUTION":
|
||||
return array(
|
||||
"winidc" => "AND Client_Code NOT IN ('C237')",
|
||||
"bosch" => "AND Client_Code='C237'",
|
||||
);
|
||||
break;
|
||||
case 'GDIDC':
|
||||
return array(
|
||||
"gdidc" => "",
|
||||
);
|
||||
break;
|
||||
default:
|
||||
throw new \Exception(sprintf(__METHOD__ . "에서 오류 SiteID[%s]가 정의되지 않았습니다.", $site_id));
|
||||
break;
|
||||
}
|
||||
}
|
||||
final public function getTypes_Dashboard()
|
||||
{
|
||||
return array("normal", "defence", "solo", "substitution", "test");
|
||||
}
|
||||
private function getCountByCenter_Dashboard($where)
|
||||
{
|
||||
$centers_conditions = array(
|
||||
"Chiba" => "service_sw BETWEEN 'C00%' AND 'C64%'",
|
||||
"Tokyo" => "service_sw BETWEEN 'C80%' AND 'C99%'",
|
||||
);
|
||||
$temps = array();
|
||||
foreach ($centers_conditions as $name => $condition) {
|
||||
$temps[$name] = $this->getCount(sprintf("%s AND %s", $where, $condition));
|
||||
}
|
||||
//return array("Chiba" => $temps['Center1'] + $temps['Center2'], "Tokyo" => $temps['Tokyo']);
|
||||
return $temps;
|
||||
}
|
||||
final public function getSummary_Dashboard($site_id)
|
||||
{
|
||||
$temps = array();
|
||||
foreach ($this->getCompanies($site_id) as $name => $condition) {
|
||||
$temps[$name] = array();
|
||||
foreach ($this->getTypes_Dashboard() as $type) {
|
||||
$where = sprintf("service_line='%s' AND service_status='o' %s", $type, $condition);
|
||||
$temps[$name][$type] = $this->getCountByCenter_Dashboard($where);
|
||||
} //foreach
|
||||
//echo var_dump($temps);
|
||||
} //foreach
|
||||
return $temps;
|
||||
}
|
||||
} //Class
|
||||
31
extdbms/lib/Models/ClientModel.php
Normal file
31
extdbms/lib/Models/ClientModel.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace lib\Models;
|
||||
|
||||
use lib\Entitys\ClientEntity as Entity;
|
||||
|
||||
class ClientModel extends CommonModel
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
} //
|
||||
|
||||
final public function getTable()
|
||||
{
|
||||
return 'clientdb';
|
||||
}
|
||||
|
||||
final public function getEntity(): Entity
|
||||
{
|
||||
return new Entity($this->getRow());
|
||||
} //
|
||||
final public function getEntitys(): array
|
||||
{
|
||||
$entitys = [];
|
||||
foreach ($this->getRows() as $row) {
|
||||
$entitys[] = new Entity($row);
|
||||
}
|
||||
return $entitys;
|
||||
} //
|
||||
} //Class
|
||||
13
extdbms/lib/Models/CommonModel.php
Normal file
13
extdbms/lib/Models/CommonModel.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace lib\Models;
|
||||
|
||||
use lib\Core\Model as Model;
|
||||
|
||||
abstract class CommonModel extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
} //
|
||||
} //Class
|
||||
93
extdbms/lib/Models/ServiceModel.php
Normal file
93
extdbms/lib/Models/ServiceModel.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace lib\Models;
|
||||
|
||||
use lib\Entitys\ServiceEntity as Entity;
|
||||
|
||||
class ServiceModel extends CommonModel
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
} //
|
||||
|
||||
final public function getTable()
|
||||
{
|
||||
return 'servicedb';
|
||||
}
|
||||
final public function getEntity(): Entity
|
||||
{
|
||||
return new Entity($this->getRow());
|
||||
} //
|
||||
final public function getEntitys(): array
|
||||
{
|
||||
$entitys = [];
|
||||
foreach ($this->getRows() as $row) {
|
||||
$entitys[] = new Entity($row);
|
||||
}
|
||||
return $entitys;
|
||||
} //
|
||||
|
||||
final public function getExtras($code)
|
||||
{
|
||||
$sql = sprintf("SELECT C.Client_Name,S.server_code,S.service_ip,S.service_os,S.service_sw
|
||||
FROM servicedb AS S
|
||||
JOIN clientdb AS C
|
||||
ON S.client_code = C.Client_Code
|
||||
WHERE S.service_code IN (SELECT service_code FROM adddb WHERE addDB_code ='%s')", $code);
|
||||
return $this->getRows($sql);
|
||||
}
|
||||
|
||||
//Dashboard
|
||||
private function getCompanies($site_id)
|
||||
{
|
||||
$companies = [];
|
||||
switch ($site_id) {
|
||||
case 'PRIMEIDC':
|
||||
$companies = [
|
||||
"idcjp" => "Client_Code NOT IN ('C116','C012','C636')",
|
||||
"winidc" => "Client_Code='C116'",
|
||||
"gamewing" => "Client_Code='C012'",
|
||||
"GDIDC" => "Client_Code='C636'",
|
||||
];
|
||||
break;
|
||||
case "ITSOLUTION":
|
||||
$companies = [
|
||||
"winidc" => "Client_Code NOT IN ('C237')",
|
||||
"bosch" => "Client_Code='C237'",
|
||||
];
|
||||
break;
|
||||
case 'GDIDC':
|
||||
$companies = [
|
||||
"gdidc" => "",
|
||||
];
|
||||
break;
|
||||
default:
|
||||
throw new \Exception(sprintf(__METHOD__ . "에서 오류 SiteID[%s]가 정의되지 않았습니다.", $site_id));
|
||||
}
|
||||
return $companies;
|
||||
}
|
||||
final public function getTypes_Dashboard()
|
||||
{
|
||||
return array("normal", "defence", "solo", "substitution", "test");
|
||||
}
|
||||
final public function getSummary_Dashboard($site_id)
|
||||
{
|
||||
$temps = array();
|
||||
foreach ($this->getCompanies($site_id) as $name => $where) {
|
||||
$temps[$name] = array();
|
||||
foreach ($this->getTypes_Dashboard() as $type) {
|
||||
$this->where([
|
||||
$where,
|
||||
"service_line" => $type,
|
||||
"service_status" => 'o',
|
||||
"Chiba=service_sw BETWEEN 'C00%' AND 'C64%'" => "",
|
||||
"Tokyo=service_sw BETWEEN 'C80%' AND 'C99%'" => "",
|
||||
]);
|
||||
$temps[$name][$type] = $this->getSelectColumn("COUNT(*)");
|
||||
} //foreach
|
||||
//echo var_dump($temps);
|
||||
} //foreach
|
||||
return $temps;
|
||||
}
|
||||
} //Class
|
||||
@ -1,10 +1,11 @@
|
||||
<?php
|
||||
namespace lib\Controller;
|
||||
|
||||
namespace lib\Controllers;
|
||||
|
||||
require_once "lib/autoload.php";
|
||||
try {
|
||||
$statistics = new Statistics();
|
||||
return $statistics->execute();
|
||||
$control = new DashboardController();
|
||||
return $control->mainPage();
|
||||
} catch (\Exception $e) {
|
||||
die($e->getMessage());
|
||||
}
|
||||
|
||||
@ -987,6 +987,7 @@ $(function()
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="des_pay"><input type="text" size="8" value="${iusc.client_money}" class="money" readonly="readonly" /></td>
|
||||
<td class="des_pay"><input type="text" size="8" value="${iusc.client_money}" class="money" readonly="readonly" /></td>
|
||||
<td class="all_pay"><input type="text" size="8" value="${iusc.client_total_amount}" class="money" readonly="readonly" /></td>
|
||||
<td class="n_pay">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user