Initial import
This commit is contained in:
74
application/controllers/hs/New_order_whatsapp.php
Normal file
74
application/controllers/hs/New_order_whatsapp.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
class New_order_whatsapp extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function index()
|
||||
{
|
||||
echo "API NEW ORDER WHATSAPP";
|
||||
}
|
||||
public function add_order($transactionID)
|
||||
{
|
||||
$sqlname = $this->db->query("SELECT t_transactionHSOrderName as pname
|
||||
FROM one_hs.t_transactionHS
|
||||
WHERE t_transactionHST_TransactionID = $transactionID")->row();
|
||||
$pname = $sqlname->pname;
|
||||
|
||||
$sqlhp = $this->db->query("SELECT t_transactionHSOrderNoHP as hp
|
||||
FROM one_hs.t_transactionHS
|
||||
WHERE t_transactionHST_TransactionID = $transactionID")->row();
|
||||
$hp = $sqlhp->hp;
|
||||
|
||||
$sqldate = $this->db->query("SELECT DATE_FORMAT(T_OrderDate,'%d-%m-%Y') as pdate
|
||||
FROM one_hs.t_transactionHS
|
||||
JOIN one_hs.t_order ON T_OrderT_TransactionID = t_transactionHST_TransactionID
|
||||
WHERE t_transactionHST_TransactionID = $transactionID
|
||||
GROUP BY t_transactionHSID")->row();
|
||||
$pdate = $sqldate->pdate;
|
||||
|
||||
$sqljam = $this->db->query("SELECT T_OrderTime as pjam
|
||||
FROM one_hs.t_transactionHS
|
||||
JOIN one_hs.t_order ON T_OrderT_TransactionID = t_transactionHST_TransactionID
|
||||
WHERE t_transactionHST_TransactionID = $transactionID
|
||||
GROUP BY t_transactionHSID")->row();
|
||||
$pjam = $sqljam->pjam;
|
||||
|
||||
$sqlmessage = $this->db->query("SELECT REPLACE(REPLACE(REPLACE(HS_MessageText,'{PASIEN}','{$pname}'),'{TANGGAL}','{$pdate}'),'{JAM}','{$pjam}') as pmessage
|
||||
FROM one_hs.hs_message
|
||||
WHERE HS_MessageType = 'NEW'")->row();
|
||||
$pmessage = $sqlmessage->pmessage;
|
||||
|
||||
$sqlwa = $this->db->query("SELECT HS_WhatsAppID as pwa
|
||||
FROM one_hs.hs_whatsapp
|
||||
WHERE HS_WhatsAppType = 'NEW' AND HS_WhatsAppT_TransactionID = $transactionID")->row();
|
||||
$pwa = $sqlwa->pwa;
|
||||
|
||||
IF(empty($pwa)){
|
||||
$sql = "INSERT INTO one_hs.hs_whatsapp (HS_WhatsAppT_TransactionID,
|
||||
HS_WhatsAppName,
|
||||
HS_WhatsAppNoHP,
|
||||
HS_WhatsAppMessage,
|
||||
HS_WhatsAppType,
|
||||
HS_WhatsAppUserID)
|
||||
VALUES(
|
||||
$transactionID,
|
||||
'{$pname}',
|
||||
'{$hp}',
|
||||
'{$pmessage}',
|
||||
'NEW',
|
||||
0)";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo json_encode(['status' => 'ERR', 'message' => print_r($this->db->error(), true)]);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode(['status' => 'OK', 'message' => $pmessage]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user