first commit
This commit is contained in:
659
Ticketing_v3.php
Normal file
659
Ticketing_v3.php
Normal file
@@ -0,0 +1,659 @@
|
||||
<?php
|
||||
class Ticketing_v3 extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
var $load;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
function submit_ticket()
|
||||
{
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
|
||||
if (trim($prm['title']) == "") {
|
||||
echo json_encode(array('status' => false, 'msg' => 'Title is required'));
|
||||
exit;
|
||||
}
|
||||
|
||||
if (trim($prm['sender']) == "") {
|
||||
echo json_encode(array('status' => false, 'msg' => 'Sender is required'));
|
||||
exit;
|
||||
}
|
||||
|
||||
if (trim($prm['branch_code']) == "") {
|
||||
echo json_encode(array('status' => false, 'msg' => 'Branch code is required'));
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!isset($prm['is_direct'])) {
|
||||
$prm['is_direct'] = "N";
|
||||
} else {
|
||||
$prm['is_direct'] = $prm['is_direct'] == 'False' ? "N" : "Y";
|
||||
}
|
||||
|
||||
if (trim($prm['description']) == "") {
|
||||
echo json_encode(array('status' => false, 'msg' => 'Description is required'));
|
||||
exit;
|
||||
}
|
||||
|
||||
if (trim($prm['client_id']) == "") {
|
||||
echo json_encode(array('status' => false, 'msg' => 'Client ID is required'));
|
||||
exit;
|
||||
}
|
||||
|
||||
$ticket_number = $this->generate_string();
|
||||
|
||||
$sql = "INSERT INTO ticketing (
|
||||
TicketTitle,
|
||||
TicketingNumber,
|
||||
TicketingSender,
|
||||
TicketingM_BranchCode,
|
||||
TicketingIsDirect,
|
||||
TicketingDescription,
|
||||
TicketingCreated,
|
||||
TicketingCreatedUserID,
|
||||
TicketingClientID
|
||||
)VALUES(
|
||||
'{$prm['title']}',
|
||||
'{$ticket_number}',
|
||||
'{$prm['sender']}',
|
||||
'{$prm['branch_code']}',
|
||||
'{$prm['is_direct']}',
|
||||
'{$prm['description']}',
|
||||
NOW(),
|
||||
1,
|
||||
'{$prm['client_id']}',
|
||||
)";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("error insert new ticket", $this->db);
|
||||
exit;
|
||||
}
|
||||
$xlast_id = $this->db->insert_id();
|
||||
|
||||
$path = '/home/one/project/one/one-media/one-support/';
|
||||
$config['upload_path'] = $path;
|
||||
$config['allowed_types'] = 'jpg|jpeg|png|gif';
|
||||
$config['max_size'] = '10000';
|
||||
$count = count($_FILES['files']['name']);
|
||||
$this->load->library('upload', $config);
|
||||
$images_odoo = [];
|
||||
$images_odoo_url = [];
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
|
||||
if (!empty($_FILES['files']['name'][$i])) {
|
||||
$_FILES['file']['name'] = $_FILES['files']['name'][$i];
|
||||
|
||||
$_FILES['file']['type'] = 'image/jpeg';
|
||||
|
||||
$_FILES['file']['tmp_name'] = $_FILES['files']['tmp_name'][$i];
|
||||
|
||||
$_FILES['file']['error'] = $_FILES['files']['error'][$i];
|
||||
|
||||
$_FILES['file']['size'] = $_FILES['files']['size'][$i];
|
||||
|
||||
$namex = $_FILES['files']['name'][$i];
|
||||
|
||||
$config['file_name'] = $namex;
|
||||
$this->upload->initialize($config);
|
||||
|
||||
|
||||
if ($this->upload->do_upload('file')) {
|
||||
$uploadData = $this->upload->data();
|
||||
$filename = $uploadData['file_name'];
|
||||
$sql = "INSERT INTO ticketing_images(
|
||||
TicketingImagesTicketingID,
|
||||
TicketingImagesName,
|
||||
TicketingImagesCreated,
|
||||
TicketingImagesCreatedUserID
|
||||
) VALUES(
|
||||
{$xlast_id},
|
||||
'{$filename}',
|
||||
NOW(),
|
||||
1
|
||||
)";
|
||||
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$img_attach_url = "https://devone.aplikasi.web.id/one-media/one-support/" . urlencode($filename);
|
||||
array_push($images_odoo_url, $img_attach_url);
|
||||
} else {
|
||||
$error = array('error' => $this->upload->display_errors());
|
||||
echo json_encode(array("error" => $error));
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$insert_odoo = $this->create_task_odoo($prm['title'], $prm['sender'], $ticket_number, $prm['description'], $prm['is_direct'], $prm['branch_code'], $images_odoo_url, $prm['client_id']);
|
||||
if ($insert_odoo) {
|
||||
//echo json_encode(array('status' => 'OK', 'msg' => 'Success', 'data' => array("id" => $xlast_id, 'number' => $ticket_number)));
|
||||
echo json_encode(array("status" => "success", "ticket_number" => $ticket_number, "count" => $count));
|
||||
$this->wa_to_sasone($prm['title'], $prm['description'], $ticket_number, $insert_odoo, $prm['client_id']);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function get_branchs()
|
||||
{
|
||||
$sql = "select M_BranchID, M_BranchCode, M_BranchName
|
||||
from m_branch
|
||||
WHERE
|
||||
M_BranchIsActive = 'Y'";
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
$this->sys_error_db("m_company rows", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function search_branch()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count = 0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '') {
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// Tambahkan parameter id ke dalam array $q
|
||||
if (isset($prm['client_id']) && $prm['client_id'] != '') {
|
||||
$q['client_id'] = $prm['client_id'];
|
||||
} else {
|
||||
// Berikan nilai default atau keluarkan error jika 'id' tidak ada
|
||||
$this->sys_error("Parameter 'client_id' tidak ditemukan");
|
||||
exit;
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT COUNT(*) total
|
||||
FROM m_branch
|
||||
WHERE M_BranchName LIKE ?
|
||||
AND M_BranchClientID = ?";
|
||||
$query = $this->db->query($sql, array($q['search'], $q['client_id']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_branch count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT M_BranchID, M_BranchCode, M_BranchName
|
||||
FROM m_branch
|
||||
WHERE M_BranchName LIKE ?
|
||||
AND M_BranchClientID = ?
|
||||
LIMIT ?";
|
||||
$query = $this->db->query($sql, array($q['search'], $q['client_id'], $max_rst));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("m_branch rows", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function search_client()
|
||||
{
|
||||
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["search"] . '%';
|
||||
|
||||
$sql = "SELECT clientId,clientName
|
||||
FROM client
|
||||
WHERE clientName LIKE ?
|
||||
AND clientIsActive = 'Y'
|
||||
ORDER BY clientId DESC";
|
||||
$query = $this->db->query($sql, array($qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("select client error", $this->db);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("clientID" => 0, "clientName" => "Semua");
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"data" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function generate_string()
|
||||
{
|
||||
$strength = 6;
|
||||
$input = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$input_length = strlen($input);
|
||||
$random_string = '';
|
||||
for ($i = 0; $i < $strength; $i++) {
|
||||
$random_character = $input[mt_rand(0, $input_length - 1)];
|
||||
$random_string .= $random_character;
|
||||
}
|
||||
|
||||
$sql = "SELECT COUNT(*) as xcount FROM ticketing WHERE TicketingNumber = '{$random_string}'";
|
||||
$query = $this->db->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("error select patient", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$exist_number = $query->row()->xcount;
|
||||
if ($exist_number > 0) {
|
||||
return $this->generate_string();
|
||||
} else {
|
||||
return strtoupper($random_string);
|
||||
}
|
||||
}
|
||||
|
||||
function new_ticket()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
if (trim($prm['title']) == "") {
|
||||
echo json_encode(array('status' => false, 'msg' => 'Title is required'));
|
||||
exit;
|
||||
}
|
||||
|
||||
if (trim($prm['sender']) == "") {
|
||||
echo json_encode(array('status' => false, 'msg' => 'Sender is required'));
|
||||
exit;
|
||||
}
|
||||
|
||||
if (trim($prm['branch_code']) == "") {
|
||||
echo json_encode(array('status' => false, 'msg' => 'Branch code is required'));
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!isset($prm['is_direct'])) {
|
||||
$prm['is_direct'] = "N";
|
||||
}
|
||||
|
||||
if (trim($prm['description']) == "") {
|
||||
echo json_encode(array('status' => false, 'msg' => 'Description is required'));
|
||||
exit;
|
||||
}
|
||||
|
||||
if (trim($prm['client_id']) == "") {
|
||||
echo json_encode(array('status' => false, 'msg' => 'Client ID is required'));
|
||||
exit;
|
||||
}
|
||||
|
||||
$ticket_number = $this->generate_string();
|
||||
|
||||
$sql = "INSERT INTO ticketing (
|
||||
TicketTitle,
|
||||
TicketingNumber,
|
||||
TicketingSender,
|
||||
TicketingM_BranchCode,
|
||||
TicketingIsDirect,
|
||||
TicketingDescription,
|
||||
TicketingCreated,
|
||||
TicketingCreatedUserID,
|
||||
TicketingClientID
|
||||
)VALUES(
|
||||
'{$prm['title']}',
|
||||
'{$ticket_number}',
|
||||
'{$prm['sender']}',
|
||||
'{$prm['branch_code']}',
|
||||
'{$prm['is_direct']}',
|
||||
'{$prm['description']}',
|
||||
NOW(),
|
||||
1,
|
||||
'{$prm['client_id']}'
|
||||
)";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("error insert new ticket", $this->db);
|
||||
exit;
|
||||
}
|
||||
$xlast_id = $this->db->insert_id();
|
||||
$path = '/home/one/project/one/one-media/one-support/';
|
||||
$config['upload_path'] = $path;
|
||||
$config['allowed_types'] = 'jpg|jpeg|png|gif';
|
||||
$config['max_size'] = '10000';
|
||||
$count = count($_FILES['files']['name']);
|
||||
$this->load->library('upload', $config);
|
||||
$images_odoo = [];
|
||||
$images_odoo_url = [];
|
||||
|
||||
$error = [];
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
|
||||
if (!empty($_FILES['files']['name'][$i])) {
|
||||
$_FILES['file']['name'] = $_FILES['files']['name'][$i];
|
||||
|
||||
$_FILES['file']['type'] = $_FILES['files']['type'][$i];
|
||||
|
||||
$_FILES['file']['tmp_name'] = $_FILES['files']['tmp_name'][$i];
|
||||
|
||||
$_FILES['file']['error'] = $_FILES['files']['error'][$i];
|
||||
|
||||
$_FILES['file']['size'] = $_FILES['files']['size'][$i];
|
||||
|
||||
$namex = $_FILES['files']['name'][$i];
|
||||
|
||||
$config['file_name'] = $namex;
|
||||
$this->upload->initialize($config);
|
||||
|
||||
|
||||
if ($this->upload->do_upload('file')) {
|
||||
$uploadData = $this->upload->data();
|
||||
|
||||
$filename = $uploadData['file_name'];
|
||||
$target_path = $path . $filename;
|
||||
$type = pathinfo($target_path, PATHINFO_EXTENSION);
|
||||
$data = file_get_contents($target_path);
|
||||
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
|
||||
array_push($images_odoo, $base64);
|
||||
$sql = "INSERT INTO ticketing_images(
|
||||
TicketingImagesTicketingID,
|
||||
TicketingImagesName,
|
||||
TicketingImagesCreated,
|
||||
TicketingImagesCreatedUserID
|
||||
) VALUES(
|
||||
{$xlast_id},
|
||||
'{$filename}',
|
||||
NOW(),
|
||||
1
|
||||
)";
|
||||
$img_attach_url = "https://devone.aplikasi.web.id/one-media/one-support/" . urlencode($filename);
|
||||
array_push($images_odoo_url, $img_attach_url);
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
// $xlast_id = $this->db->insert_id();
|
||||
//$data['totalFiles'][] = array('xid' => $xlast_id, 'image_url' => '/one-media/one-support/' . $filename);
|
||||
} else {
|
||||
$error = array('error' => $this->upload->display_errors());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sender_name = "Pengirim : {$prm['sender']} \n";
|
||||
$xticket_number = "No. Tiket : {$ticket_number}\n";
|
||||
$branch = "Cabang : " . $prm['branch_code'] . " - " . $prm['branch_name'] . "\n";
|
||||
|
||||
$is_direct = $prm['is_direct'] == "Y" ? "Direct Message : Ya\n" : "Direct Message : Tidak\n";
|
||||
$x_description = $sender_name . " " . $xticket_number . " " . $branch . " " . $is_direct . " {$prm['description']}";
|
||||
|
||||
$insert_odoo = $this->create_task_odoo($prm['title'], $prm['sender'], $ticket_number, $prm['description'], $prm['is_direct'], $prm['branch_code'], $images_odoo_url, $prm['client_id']);
|
||||
if ($insert_odoo) {
|
||||
echo json_encode(array('status' => 'OK', 'msg' => 'Success', 'data' => array("id" => $xlast_id, 'number' => $ticket_number)));
|
||||
$this->wa_to_sasone(
|
||||
$prm['title'],
|
||||
$x_description,
|
||||
$ticket_number,
|
||||
$insert_odoo,
|
||||
$prm['client_id']
|
||||
);
|
||||
exit;
|
||||
} else {
|
||||
echo json_encode(array('status' => 'ERR', 'msg' => 'odoo down', 'data' => array("id" => $xlast_id, 'number' => $ticket_number)));
|
||||
$this->wa_to_sasone(
|
||||
$prm['title'],
|
||||
$x_description,
|
||||
$ticket_number,
|
||||
$insert_odoo,
|
||||
$prm['client_id']
|
||||
);
|
||||
exit;
|
||||
}
|
||||
/*if ($xlast_id == 0) {
|
||||
$this->sys_error("Failed to insert new ticket, insert_id 0");
|
||||
exit;
|
||||
} else {
|
||||
|
||||
$this->create_task_odoo($prm['title'], $prm['sender'], $ticket_number, $prm['description'], $prm['is_direct'], $prm['branch_code']);
|
||||
|
||||
echo json_encode(array('status' => 'OK', 'msg' => 'Success', 'data' => array("id" => $xlast_id, 'number' => $ticket_number)));
|
||||
exit;
|
||||
}*/
|
||||
}
|
||||
function wa_to_sasone($title, $description, $tiket_number, $insert_odoo, $client_id)
|
||||
{
|
||||
$url_odoo = "http://odoo.sismedika.com/web#id=$insert_odoo&menu_id=225&action=342&active_id=70&model=project.task&view_type=form";
|
||||
$msg = "Halo! Kami telah menerima permintaan Anda dan telah membuat tiket nomor $tiket_number. Tim kami akan segera meninjau dan memberikan tanggapan sesegera mungkin";
|
||||
$msg .= "\nOdoo Task $title [# $tiket_number]\n```\n $description \n```\n";
|
||||
//$hp="6281328282909-1583223560@g.us";
|
||||
$hp = "6281328282909-1583223560@g.us";
|
||||
if ($client_id != 1) {
|
||||
$hp = "6282113702602-1584412485@g.us";
|
||||
}
|
||||
$this->load->library("Wa_sas");
|
||||
$resp = $this->wa_sas->send_message($hp, $msg, true);
|
||||
// $resp = $this->wa_sas->send_message($hp, $msg, false);
|
||||
}
|
||||
|
||||
|
||||
function base64_to_jpeg($base64_string, $output_file)
|
||||
{
|
||||
// open the output file for writing
|
||||
$ifp = fopen($output_file, 'wb');
|
||||
|
||||
// split the string on commas
|
||||
// $data[ 0 ] == "data:image/png;base64"
|
||||
// $data[ 1 ] == <actual base64 string>
|
||||
$data = explode(',', $base64_string);
|
||||
|
||||
// we could add validation here with ensuring count( $data ) > 1
|
||||
fwrite($ifp, base64_decode($data[1]));
|
||||
|
||||
// clean up the file resource
|
||||
fclose($ifp);
|
||||
|
||||
return $output_file;
|
||||
}
|
||||
|
||||
function create_task_odoo($title, $sender, $number, $description, $is_direct, $branch_code, $images_odoo, $client_id)
|
||||
{
|
||||
//print_r($images_odoo);
|
||||
$sql = "SELECT * FROM m_branch WHERE M_BranchCode = '{$branch_code}'";
|
||||
$query = $this->db->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("error select branch", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$data_branch = $query->row_array();
|
||||
|
||||
$sender_name = "Pengirim : <b>{$sender}</b><br/>";
|
||||
$ticket_number = "No. Tiket : <b>{$number}</b><br/>";
|
||||
$branch = "Cabang : <b>{$data_branch['M_BranchName']}</b><br/>";
|
||||
$is_direct = $is_direct == "Y" ? "Direct Message : Ya<br/>" : "Direct Message : Tidak<br/>";
|
||||
$x_description = $sender_name . " " . $ticket_number . " " . $branch . " " . $is_direct . " <p>{$description}</p>";
|
||||
|
||||
$project_id = 70;
|
||||
if ($client_id != 1) {
|
||||
$project_id = 123;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$json_data = array(
|
||||
'title' => $title, 'description' => $x_description,
|
||||
'images' => $images_odoo, 'client_id' => $client_id, 'project_id' => $project_id
|
||||
);
|
||||
$json_payload = json_encode($json_data);
|
||||
|
||||
// Insert ke tabel tmp_odoo
|
||||
$insert_sql = "INSERT INTO tmp_odoo (TmpOdooDate, TmpOdooJsonPayload, TmpOdooTaskUrl, TmpOdooIsSent) VALUES (NOW(), ?, ?, 'N')";
|
||||
$this->db->query($insert_sql, array($json_payload, 'devone.aplikasi.web.id/one-api/odoo/create_task'));
|
||||
|
||||
// Mengambil ID dari row yang baru saja diinsert
|
||||
$tmp_odoo_id = $this->db->insert_id();
|
||||
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => 'devone.aplikasi.web.id/one-api/odoo/create_task',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => $json_payload,
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Content-Type: application/json'
|
||||
),
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
// Decode JSON response
|
||||
$response_data = json_decode($response, true);
|
||||
|
||||
// kalau statu OK update Y kalau tidak E
|
||||
if (isset($response_data['status']) && $response_data['status'] === 'OK') {
|
||||
$update_sql = "UPDATE tmp_odoo SET TmpOdooIsSent = 'Y' WHERE TmpOdooID = ?";
|
||||
} else {
|
||||
$update_sql = "UPDATE tmp_odoo SET TmpOdooIsSent = 'E' WHERE TmpOdooID = ?";
|
||||
}
|
||||
$this->db->query($update_sql, array($tmp_odoo_id));
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function uploadimage()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// print_r($_SERVER);
|
||||
|
||||
$data = [];
|
||||
$ticketid = $this->input->post('ticketid');
|
||||
|
||||
$path = '/home/one/project/one/one-media/one-support/';
|
||||
$config['upload_path'] = $path;
|
||||
$config['allowed_types'] = 'jpg|jpeg|png|gif';
|
||||
$config['max_size'] = '10000';
|
||||
$count = count($_FILES['files']['name']);
|
||||
$this->load->library('upload', $config);
|
||||
|
||||
$error = [];
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
|
||||
if (!empty($_FILES['files']['name'][$i])) {
|
||||
$_FILES['file']['name'] = $_FILES['files']['name'][$i];
|
||||
|
||||
$_FILES['file']['type'] = $_FILES['files']['type'][$i];
|
||||
|
||||
$_FILES['file']['tmp_name'] = $_FILES['files']['tmp_name'][$i];
|
||||
|
||||
$_FILES['file']['error'] = $_FILES['files']['error'][$i];
|
||||
|
||||
$_FILES['file']['size'] = $_FILES['files']['size'][$i];
|
||||
|
||||
$namex = $_FILES['files']['name'][$i];
|
||||
|
||||
$config['file_name'] = $namex;
|
||||
$this->upload->initialize($config);
|
||||
|
||||
|
||||
if ($this->upload->do_upload('file')) {
|
||||
$uploadData = $this->upload->data();
|
||||
|
||||
$filename = $uploadData['file_name'];
|
||||
|
||||
$sql = "INSERT INTO ticketing_images(
|
||||
TicketingImagesTicketingID,
|
||||
TicketingImagesName,
|
||||
TicketingImagesCreated,
|
||||
TicketingImagesCreatedUserID
|
||||
) VALUES(
|
||||
{$ticketid},
|
||||
'{$filename}',
|
||||
NOW(),
|
||||
1
|
||||
)";
|
||||
$qry = $this->db->query($sql);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
$xlast_id = $this->db->insert_id();
|
||||
$data['totalFiles'][] = array('xid' => $xlast_id, 'image_url' => '/one-media/one-support/' . $filename);
|
||||
} else {
|
||||
$error = array('error' => $this->upload->display_errors());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = array("total" => count($data['totalFiles']), "records" => $data['totalFiles'], 'errors' => $error);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
function generateRandomString($length = 10)
|
||||
{
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
}
|
||||
81
one-new-ticket-support-v3/api/ticket.js
Normal file
81
one-new-ticket-support-v3/api/ticket.js
Normal file
@@ -0,0 +1,81 @@
|
||||
const URL = "/one-api-support/support/ticketing_v3/";
|
||||
|
||||
export async function search_branch(search, client_id) {
|
||||
try {
|
||||
var resp = await axios.post(URL + "search_branch", {
|
||||
search: search,
|
||||
client_id: client_id,
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText,
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
export async function search_client(search, client_id) {
|
||||
try {
|
||||
var resp = await axios.post(URL + "search_client", {
|
||||
search: search,
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText,
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function new_ticket(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + "new_ticket", prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText,
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function uploadimage(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + "uploadimage", prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText,
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
586
one-new-ticket-support-v3/components/oneNewTicketSupport.vue
Normal file
586
one-new-ticket-support-v3/components/oneNewTicketSupport.vue
Normal file
@@ -0,0 +1,586 @@
|
||||
<template>
|
||||
<v-layout column>
|
||||
<v-dialog v-model="dialog" width="500">
|
||||
<v-card>
|
||||
<v-card-title class="headline grey lighten-2 pt-2 pb-2" primary-title>
|
||||
Ticket Berhasil Dibuat
|
||||
</v-card-title>
|
||||
<v-card-text class="pt-2 pb-2">
|
||||
<h6 class="display-1 text-center">
|
||||
Number <span class="blue--text">{{ text_ticket_no }}</span>
|
||||
</h6>
|
||||
</v-card-text>
|
||||
<v-divider></v-divider>
|
||||
|
||||
<v-card-actions>
|
||||
<v-btn color="primary" flat @click="finish"> Tutup </v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
|
||||
<!-- Alert dialog -->
|
||||
<v-dialog v-model="dialogalert" max-width="30%">
|
||||
<v-card>
|
||||
<v-card-title class="headline grey lighten-2 pt-2 pb-2" primary-title>
|
||||
Peringatan !
|
||||
</v-card-title>
|
||||
<v-card-text class="pt-2 pb-2">
|
||||
<v-layout row>
|
||||
<v-flex xs12 d-flex>
|
||||
<v-layout row>
|
||||
<v-flex pb-1 xs12>
|
||||
<v-layout row>
|
||||
<v-flex pt-2 pr-2 xs12>
|
||||
{{ msgalert }}
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card-text>
|
||||
<v-divider></v-divider>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="primary" flat @click="dialogalert = false">
|
||||
Tutup
|
||||
</v-btn>
|
||||
<v-btn color="primary" flat @click="saveForm()"> Yakin lah </v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
<!-- End alert dialog -->
|
||||
<!-- ERROR DIALOG -->
|
||||
<v-dialog v-model="dialog_error" max-width="500px">
|
||||
<v-card>
|
||||
<v-card-title>
|
||||
<span>ERROR !</span>
|
||||
<v-spacer></v-spacer>
|
||||
</v-card-title>
|
||||
<v-divider></v-divider>
|
||||
<div class="ma-3 red--text">{{ msgError }}</div>
|
||||
<v-divider></v-divider>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="primary" flat @click="dialog_error = false"
|
||||
>Close</v-btn
|
||||
>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
<!-- END ERROR DIALOG -->
|
||||
<!-- Snackbar -->
|
||||
<v-snackbar
|
||||
v-model="snackbar"
|
||||
:timeout="5000"
|
||||
:multi-line="false"
|
||||
:vertical="false"
|
||||
:top="true"
|
||||
:color="clr"
|
||||
:value="snackbar"
|
||||
>
|
||||
{{ msgsnackbar }}
|
||||
<v-btn flat @click="snackbar = false"> Tutup </v-btn>
|
||||
</v-snackbar>
|
||||
<!-- End Snackbar -->
|
||||
|
||||
<v-card>
|
||||
<v-flex xs12>
|
||||
<v-subheader red--text text--lighten-1> BUAT TIKET BARU </v-subheader>
|
||||
<v-divider></v-divider>
|
||||
<v-layout row wrap>
|
||||
<v-flex xs12 pa-2>
|
||||
<v-layout row>
|
||||
<v-flex xs12 pa-1>
|
||||
<v-autocomplete
|
||||
auto-select-first
|
||||
:items="xclients"
|
||||
v-model="vclient"
|
||||
:search-input.sync="search_clientx"
|
||||
:loading="loading_client"
|
||||
item-text="clientName"
|
||||
item-value="clientId"
|
||||
label="CLIENT*"
|
||||
return-object
|
||||
outline
|
||||
clearable
|
||||
no-data-text="Pilih Client"
|
||||
>
|
||||
<template slot="item" slot-scope="{ item }">
|
||||
<v-list-tile-content>
|
||||
<v-list-tile-title
|
||||
v-text="item.clientName"
|
||||
></v-list-tile-title>
|
||||
</v-list-tile-content>
|
||||
</template>
|
||||
</v-autocomplete>
|
||||
<p
|
||||
v-if="checkError('requirevclient')"
|
||||
class="error pl-2 pr-2"
|
||||
style="color: #fff"
|
||||
>
|
||||
Pilih client dulu
|
||||
</p>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
<v-layout row>
|
||||
<v-flex xs12 pa-1>
|
||||
<v-text-field label="TITLE*" outline v-model="xtitle">
|
||||
</v-text-field>
|
||||
<p
|
||||
v-if="checkError('requirextitle')"
|
||||
class="error pl-2 pr-2"
|
||||
style="color: #fff"
|
||||
>
|
||||
Title belum diisi
|
||||
</p>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
<v-layout row>
|
||||
<v-flex xs12 pa-1>
|
||||
<v-text-field label="SENDER*" outline v-model="xsender">
|
||||
</v-text-field>
|
||||
<p
|
||||
v-if="checkError('requirexsender')"
|
||||
class="error pl-2 pr-2"
|
||||
style="color: #fff"
|
||||
>
|
||||
Sender belum diisi
|
||||
</p>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
<v-layout row>
|
||||
<v-flex xs12 pa-1>
|
||||
<v-autocomplete
|
||||
auto-select-first
|
||||
:items="xbranchs"
|
||||
v-model="vbranch"
|
||||
:loading="loading_branch"
|
||||
:search-input.sync="search_branchx"
|
||||
item-text="M_BranchName"
|
||||
item-value="M_BranchID"
|
||||
label="BRANCH*"
|
||||
return-object
|
||||
outline
|
||||
clearable
|
||||
no-data-text="Pilih Branch"
|
||||
>
|
||||
<template slot="item" slot-scope="{ item }">
|
||||
<v-list-tile-content>
|
||||
<v-list-tile-title
|
||||
v-text="item.M_BranchName"
|
||||
></v-list-tile-title>
|
||||
</v-list-tile-content>
|
||||
</template>
|
||||
</v-autocomplete>
|
||||
<p
|
||||
v-if="checkError('requirevbranch')"
|
||||
class="error pl-2 pr-2"
|
||||
style="color: #fff"
|
||||
>
|
||||
Pilih branch dulu
|
||||
</p>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
<v-layout row>
|
||||
<v-flex xs12 pa-1>
|
||||
<v-checkbox
|
||||
label="DIRECT MESSAGE"
|
||||
v-model="xdirect"
|
||||
></v-checkbox>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
<v-layout row>
|
||||
<v-flex xs12 pa-1>
|
||||
<v-textarea
|
||||
filled
|
||||
outline
|
||||
label="DESCRIPTION*"
|
||||
rows="3"
|
||||
v-model="xdescription"
|
||||
></v-textarea>
|
||||
<p
|
||||
v-if="checkError('requirexdescription')"
|
||||
class="error pl-2 pr-2"
|
||||
style="color: #fff"
|
||||
>
|
||||
Description belum diisi
|
||||
</p>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
<v-layout
|
||||
mr-2
|
||||
ml-2
|
||||
style="border: 1px solid black"
|
||||
align-center
|
||||
row
|
||||
pa-2
|
||||
>
|
||||
<v-flex xs12>
|
||||
<input
|
||||
type="file"
|
||||
id="files"
|
||||
ref="files"
|
||||
multiple
|
||||
v-on:change="handleFileUploads()"
|
||||
/>
|
||||
</v-flex>
|
||||
<!-- <v-flex xs3 class="text-xs-right">
|
||||
<v-btn :disabled="show_progrees_upload" small dark color="blue lighten-1" @click="submitFiles()">Upload</v-btn>
|
||||
</v-flex> -->
|
||||
</v-layout>
|
||||
<!-- <p v-if="error_image" class="mt-1 error pl-2 pr-2" style="color:#fff">Anda belum mengisi</p> -->
|
||||
<v-layout v-if="show_progrees_upload" row align-center mr-2 ml-2>
|
||||
<v-flex xs12>
|
||||
<v-progress-linear :indeterminate="true"></v-progress-linear>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<v-layout
|
||||
v-if="urls.length > 0 && !show_progrees_upload"
|
||||
align-center
|
||||
row
|
||||
>
|
||||
<v-flex v-for="(url, index) in urls" :key="index" xs12 pa-2>
|
||||
<v-img :src="url">
|
||||
<div class="fill-height bottom-gradient"></div>
|
||||
</v-img>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<!-- <v-layout v-if="images.length > 0 && !show_progrees_upload" align-center row mr-2 ml-2>
|
||||
|
||||
<v-flex v-for="image in images" xs6 pa-2>
|
||||
<v-img :src="image.image_url">
|
||||
<div class="fill-height bottom-gradient"></div>
|
||||
</v-img>
|
||||
</v-flex>
|
||||
|
||||
</v-layout> -->
|
||||
|
||||
<v-flex text-md-right class="mt-3">
|
||||
<v-btn color="info" small @click="openAddForm()"> SIMPAN </v-btn>
|
||||
</v-flex>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
</v-card>
|
||||
</v-layout>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.searchbox .v-input.v-text-field .v-input__slot {
|
||||
min-height: 60px;
|
||||
}
|
||||
.searchbox .v-btn {
|
||||
min-height: 60px;
|
||||
}
|
||||
table.v-table tbody td,
|
||||
table.v-table tbody th {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
table.v-table thead tr {
|
||||
height: 40px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
data() {
|
||||
return {
|
||||
search_branchx: "",
|
||||
search_clientx: "",
|
||||
xtitle: "",
|
||||
xsender: "",
|
||||
dialogalert: false,
|
||||
msgalert: "",
|
||||
clr: "success",
|
||||
xdescription: "",
|
||||
xdirect: false,
|
||||
// error_image:false,
|
||||
// url: null,
|
||||
urls: [],
|
||||
filesToUpload: [],
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
// this.$store.dispatch("ticket/search_client", {
|
||||
// qry: this.search_clientx,
|
||||
// });
|
||||
},
|
||||
computed: {
|
||||
selected_client_id() {
|
||||
return this.$store.state.ticket.selected_clients.clientId;
|
||||
},
|
||||
xbranchs() {
|
||||
return this.$store.state.ticket.branchs;
|
||||
},
|
||||
xclients() {
|
||||
return this.$store.state.ticket.clients;
|
||||
},
|
||||
vbranch: {
|
||||
get() {
|
||||
return this.$store.state.ticket.selected_branch;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("ticket/update_selected_branch", val);
|
||||
},
|
||||
},
|
||||
vclient: {
|
||||
get() {
|
||||
return this.$store.state.ticket.selected_clients;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("ticket/update_selected_clients", val);
|
||||
},
|
||||
},
|
||||
loading_branch() {
|
||||
return this.$store.state.ticket.loading;
|
||||
},
|
||||
loading_client() {
|
||||
return this.$store.state.ticket.loading_client;
|
||||
},
|
||||
snackbar: {
|
||||
get() {
|
||||
return this.$store.state.ticket.alert_success;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("ticket/update_alert_success", val);
|
||||
},
|
||||
},
|
||||
msgsnackbar() {
|
||||
return this.$store.state.ticket.msg_success;
|
||||
},
|
||||
dialog_error: {
|
||||
get() {
|
||||
return this.$store.state.ticket.alert_error;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("ticket/update_alert_error", val);
|
||||
},
|
||||
},
|
||||
msgError() {
|
||||
return this.$store.state.ticket.error_message;
|
||||
},
|
||||
show_progrees_upload: {
|
||||
get() {
|
||||
return this.$store.state.ticket.show_progrees_upload;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("ticket/update_show_progrees_upload", val);
|
||||
},
|
||||
},
|
||||
images() {
|
||||
return this.$store.state.ticket.images;
|
||||
},
|
||||
lastInsertId: {
|
||||
get() {
|
||||
return this.$store.state.ticket.lastInsertId;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("ticket/update_lastInsertId", val);
|
||||
},
|
||||
},
|
||||
text_ticket_no() {
|
||||
return this.$store.state.ticket.ticket_number;
|
||||
},
|
||||
dialog: {
|
||||
get() {
|
||||
return this.$store.state.ticket.dialog_is_active;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("ticket/update_dialog_is_active", val);
|
||||
},
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
finish: function () {
|
||||
this.dialog = false;
|
||||
// location.reload()
|
||||
},
|
||||
handleFileUploads() {
|
||||
// this.files = this.$refs.files.files
|
||||
|
||||
const files = this.$refs.files.files;
|
||||
this.urls = [];
|
||||
this.filesToUpload = [];
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i];
|
||||
const url = URL.createObjectURL(file);
|
||||
this.urls.push(url);
|
||||
this.filesToUpload.push(file);
|
||||
}
|
||||
// console.log('urls', this.urls)
|
||||
console.log("filesToUpload", this.filesToUpload);
|
||||
},
|
||||
submitFiles() {
|
||||
// this.error_image = false
|
||||
let formData = new FormData();
|
||||
|
||||
for (var i = 0; i < this.filesToUpload.length; i++) {
|
||||
let file = this.filesToUpload[i];
|
||||
console.log(file);
|
||||
formData.append("files[" + i + "]", file);
|
||||
}
|
||||
if (this.filesToUpload.length > 0) {
|
||||
this.show_progrees_upload = true;
|
||||
let insertId = this.$store.state.ticket.lastInsertId;
|
||||
console.log("insertId submit", insertId);
|
||||
formData.append("ticketid", insertId);
|
||||
this.$store.dispatch("ticket/uploadimage", formData);
|
||||
}
|
||||
},
|
||||
thr_search_branch: _.debounce(function () {
|
||||
this.$store.dispatch("ticket/search_branch", {
|
||||
search: this.search_branchx,
|
||||
});
|
||||
}, 1000),
|
||||
thr_search_client: _.debounce(function () {
|
||||
this.$store.dispatch("ticket/search_client", {
|
||||
search: this.search_clientx,
|
||||
});
|
||||
}, 1000),
|
||||
checkError(value) {
|
||||
var errors = this.$store.state.ticket.errors;
|
||||
if (errors.includes(value)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
resetAllInput() {
|
||||
this.xtitle = "";
|
||||
this.xsender = "";
|
||||
this.vbranch = "";
|
||||
this.vclient = "";
|
||||
this.xdirect = "";
|
||||
this.xdescription = "";
|
||||
this.urls = [];
|
||||
this.filesToUpload = [];
|
||||
},
|
||||
openAddForm() {
|
||||
this.$store.commit("ticket/update_errors", []);
|
||||
var errors = this.$store.state.ticket.errors;
|
||||
|
||||
if (_.isEmpty(this.vclient)) {
|
||||
errors.push("requirevclient");
|
||||
}
|
||||
if (_.isEmpty(this.xtitle)) {
|
||||
errors.push("requirextitle");
|
||||
}
|
||||
if (_.isEmpty(this.xsender)) {
|
||||
errors.push("requirexsender");
|
||||
}
|
||||
if (_.isEmpty(this.vbranch)) {
|
||||
errors.push("requirevbranch");
|
||||
}
|
||||
if (_.isEmpty(this.xdescription)) {
|
||||
errors.push("requirexdescription");
|
||||
}
|
||||
|
||||
if (errors.length === 0) {
|
||||
this.msgalert =
|
||||
"Yakin, Mau Buat Ticket Baru " + "(" + this.xtitle + ")" + " ?";
|
||||
this.dialogalert = true;
|
||||
} else {
|
||||
this.dialogalert = false;
|
||||
}
|
||||
},
|
||||
saveForm() {
|
||||
this.$store.commit("ticket/update_errors", []);
|
||||
var errors = this.$store.state.ticket.errors;
|
||||
|
||||
if (_.isEmpty(this.vclient)) {
|
||||
errors.push("requirevclient");
|
||||
}
|
||||
if (_.isEmpty(this.xtitle)) {
|
||||
errors.push("requirextitle");
|
||||
}
|
||||
if (_.isEmpty(this.xsender)) {
|
||||
errors.push("requirexsender");
|
||||
}
|
||||
if (_.isEmpty(this.vbranch)) {
|
||||
errors.push("requirevbranch");
|
||||
}
|
||||
if (_.isEmpty(this.xdescription)) {
|
||||
errors.push("requirexdescription");
|
||||
}
|
||||
|
||||
if (errors.length === 0) {
|
||||
var formData = new FormData();
|
||||
console.log(this.filesToUpload.length);
|
||||
for (var i = 0; i < this.filesToUpload.length; i++) {
|
||||
let file = this.filesToUpload[i];
|
||||
|
||||
formData.append("files[" + i + "]", file);
|
||||
console.log(formData);
|
||||
}
|
||||
|
||||
/*let prm = {}
|
||||
prm.title = this.xtitle
|
||||
prm.sender = this.xsender
|
||||
prm.branch_code = this.vbranch.M_BranchCode
|
||||
prm.description = this.xdescription
|
||||
prm.is_direct = this.xdirect ? 'Y' : 'N'
|
||||
prm.images = formData*/
|
||||
formData.append("client_id", this.vclient.clientId);
|
||||
formData.append("title", this.xtitle);
|
||||
formData.append("sender", this.xsender);
|
||||
formData.append("branch_code", this.vbranch.M_BranchCode);
|
||||
formData.append("branch_name", this.vbranch.M_BranchName);
|
||||
formData.append("description", this.xdescription);
|
||||
formData.append("is_direct", this.xdirect ? "Y" : "N");
|
||||
|
||||
this.$store.dispatch("ticket/new_ticket", formData);
|
||||
//this.submitFiles();
|
||||
this.resetAllInput();
|
||||
this.dialogalert = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
search_clientx(val, old) {
|
||||
if (val == old) return;
|
||||
if (!val) return;
|
||||
if (val.length > 0) {
|
||||
this.$store.dispatch("ticket/search_client", {
|
||||
search: this.search_clientx,
|
||||
});
|
||||
this.thr_search_client;
|
||||
// this.$store.dispatch("ticket/search_branch", {
|
||||
// search: this.search_branchx,
|
||||
// client_id: this.$store.state.ticket.selected_clients.clientId,
|
||||
// });
|
||||
// this.thr_search_branch;
|
||||
}
|
||||
},
|
||||
search_branchx(val, old) {
|
||||
if (val == old) return;
|
||||
if (!val) return;
|
||||
if (val.length > 0) {
|
||||
this.$store.dispatch("ticket/search_branch", {
|
||||
search: this.search_branchx,
|
||||
client_id: this.$store.state.ticket.selected_clients.clientId,
|
||||
});
|
||||
this.thr_search_branch;
|
||||
}
|
||||
},
|
||||
selected_client_id(val, old) {
|
||||
if (val == old) return;
|
||||
if (!val) return;
|
||||
if (val.length > 0) {
|
||||
this.$store.dispatch("ticket/search_branch", {
|
||||
search: this.search_branchx,
|
||||
client_id: val,
|
||||
});
|
||||
this.thr_search_branch;
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
74
one-new-ticket-support-v3/index.php
Normal file
74
one-new-ticket-support-v3/index.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>One</title>
|
||||
<link rel="stylesheet" href="../../../libs/vendor/css/google-fonts.css">
|
||||
<link rel="stylesheet" href="../../../libs/vendor/css/icomoon-fonts.css">
|
||||
<link rel="stylesheet" href="../../../libs/vendor/css/vuetify.min.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div v-cloak id="app">
|
||||
<v-app id="smartApp">
|
||||
<one-navbar></one-navbar>
|
||||
<v-content class="blue lighten-5">
|
||||
<v-container fluid fill-height class="pl-1 pr-1 pt-2 pb-2">
|
||||
<v-layout row wrap>
|
||||
<v-flex xs12 class="left" fill-height pa-1>
|
||||
<!-- komponen kiri -->
|
||||
<one-new-ticket-support></one-new-ticket-support>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-container>
|
||||
</v-content>
|
||||
<one-footer> </one-footer>
|
||||
</v-app>
|
||||
</div>
|
||||
|
||||
<!-- Vendor -->
|
||||
<script src="../../../libs/vendor/moment.min.js"></script>
|
||||
<script src="../../../libs/vendor/numeral.min.js"></script>
|
||||
<script src="../../../libs/vendor/moment-locale-id.js"></script>
|
||||
<script src="../../../libs/vendor/lodash.js"></script>
|
||||
<script src="../../../libs/vendor/axios.min.js"></script>
|
||||
<script src="../../../libs/vendor/vue.js"></script>
|
||||
<script src="../../../libs/vendor/vuex.js"></script>
|
||||
<script src="../../../libs/vendor/vuetify.js"></script>
|
||||
<script src="../../../libs/vendor/httpVueLoader.js"></script>
|
||||
<script src="../../../libs/one_global.js"></script>
|
||||
<!-- App Script -->
|
||||
<?php
|
||||
$ts = "?ts=" . Date("ymdhis");
|
||||
?>
|
||||
<script type="module">
|
||||
import {
|
||||
store
|
||||
} from './store.js<?php echo $ts ?>';
|
||||
//for testing
|
||||
window.store = store;
|
||||
new Vue({
|
||||
store,
|
||||
el: '#app',
|
||||
components: {
|
||||
'one-navbar': httpVueLoader('../../../apps/components/oneNavbarComponent.vue'),
|
||||
'one-footer': httpVueLoader('../../../apps/components/oneFooter.vue'),
|
||||
'one-new-ticket-support': httpVueLoader('./components/oneNewTicketSupport.vue')
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style>
|
||||
[v-cloak] {
|
||||
display: none
|
||||
}
|
||||
|
||||
.left {}
|
||||
|
||||
.right {}
|
||||
</style>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
193
one-new-ticket-support-v3/modules/ticket.js
Normal file
193
one-new-ticket-support-v3/modules/ticket.js
Normal file
@@ -0,0 +1,193 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/ticket.js";
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
clients: [],
|
||||
branchs: [],
|
||||
selected_clients: {
|
||||
clientId: null, // atau nilai default yang sesuai
|
||||
clientName: null,
|
||||
},
|
||||
selected_branch: {},
|
||||
loading: false,
|
||||
loading_client: false,
|
||||
error: "",
|
||||
save_status: 2,
|
||||
error_message: "",
|
||||
loading_save: false,
|
||||
alert_error: false,
|
||||
dialog_error: false,
|
||||
msg_success: "",
|
||||
alert_success: false,
|
||||
errors: [],
|
||||
show_progrees_upload: false,
|
||||
images: [],
|
||||
lastInsertId: "",
|
||||
ticket_number: "",
|
||||
dialog_is_active: false,
|
||||
},
|
||||
mutations: {
|
||||
update_branchs(state, val) {
|
||||
state.branchs = val;
|
||||
},
|
||||
update_clients(state, val) {
|
||||
state.clients = val;
|
||||
},
|
||||
update_selected_branch(state, val) {
|
||||
state.selected_branch = val;
|
||||
},
|
||||
update_selected_clients(state, val) {
|
||||
state.selected_clients = val;
|
||||
},
|
||||
update_loading(state, val) {
|
||||
state.loading = val;
|
||||
},
|
||||
update_loading_client(state, val) {
|
||||
state.loading_client = val;
|
||||
},
|
||||
update_error(state, val) {
|
||||
state.error = val;
|
||||
},
|
||||
update_save_status(state, val) {
|
||||
state.save_status = val;
|
||||
},
|
||||
update_error_message(state, val) {
|
||||
state.error_message = val;
|
||||
},
|
||||
update_loading_save(state, val) {
|
||||
state.loading_save = val;
|
||||
},
|
||||
update_alert_error(state, val) {
|
||||
state.alert_error = val;
|
||||
},
|
||||
update_dialog_error(state, val) {
|
||||
state.dialog_error = val;
|
||||
},
|
||||
update_msg_success(state, val) {
|
||||
state.msg_success = val;
|
||||
},
|
||||
update_alert_success(state, val) {
|
||||
state.alert_success = val;
|
||||
},
|
||||
update_errors(state, val) {
|
||||
state.errors = val;
|
||||
},
|
||||
update_show_progrees_upload(state, val) {
|
||||
state.show_progrees_upload = val;
|
||||
},
|
||||
update_images(state, val) {
|
||||
state.images = val;
|
||||
},
|
||||
update_lastInsertId(state, id) {
|
||||
state.lastInsertId = id;
|
||||
},
|
||||
update_ticket_number(state, val) {
|
||||
state.ticket_number = val;
|
||||
},
|
||||
update_dialog_is_active(state, val) {
|
||||
state.dialog_is_active = val;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
async search_branch(context, { search, client_id }) {
|
||||
context.commit("update_loading", true);
|
||||
try {
|
||||
let resp = await api.search_branch(search, client_id);
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error", resp.message);
|
||||
} else {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error", "");
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total,
|
||||
};
|
||||
context.commit("update_branchs", resp.data.records);
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error", e.message);
|
||||
}
|
||||
},
|
||||
async search_client(context, { search }) {
|
||||
context.commit("update_loading", true);
|
||||
try {
|
||||
let resp = await api.search_client(search);
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error", resp.message);
|
||||
} else {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error", "");
|
||||
context.commit("update_clients", resp.data.data);
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error", e.message);
|
||||
}
|
||||
},
|
||||
|
||||
async new_ticket(context, prm) {
|
||||
context.commit("update_save_status", 1);
|
||||
try {
|
||||
// prm.token = one_token()
|
||||
let resp = await api.new_ticket(prm);
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3);
|
||||
context.commit("update_error_message", resp.message);
|
||||
context.commit("update_alert_error", true);
|
||||
context.commit("update_dialog_error", true);
|
||||
} else {
|
||||
var data = {
|
||||
status: resp.status,
|
||||
};
|
||||
if (data.status == "OK") {
|
||||
context.commit("update_save_status", 2);
|
||||
context.commit("update_error_message", "");
|
||||
context.commit("update_dialog_error", false);
|
||||
let msg = "Data berhasil disimpan";
|
||||
context.commit("update_msg_success", resp.msg);
|
||||
context.commit("update_alert_success", true);
|
||||
context.commit("update_lastInsertId", resp.data.id);
|
||||
context.commit("update_ticket_number", resp.data.number);
|
||||
context.commit("update_dialog_is_active", true);
|
||||
console.log(resp.data.id);
|
||||
} else {
|
||||
context.commit("update_errors", resp.errors);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3);
|
||||
context.commit("update_error_message", e.message);
|
||||
context.commit("update_alert_error", true);
|
||||
}
|
||||
},
|
||||
|
||||
async uploadimage(context, prm) {
|
||||
context.commit("update_save_status", 1);
|
||||
try {
|
||||
let resp = await api.uploadimage(prm);
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_show_progrees_upload", false);
|
||||
context.commit("update_save_status", 3);
|
||||
} else {
|
||||
context.commit("update_save_status", 2);
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total,
|
||||
};
|
||||
context.commit("update_show_progrees_upload", false);
|
||||
context.commit("update_images", data.records);
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_show_progrees_upload", false);
|
||||
context.commit("update_save_status", 3);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
23
one-new-ticket-support-v3/store.js
Normal file
23
one-new-ticket-support-v3/store.js
Normal file
@@ -0,0 +1,23 @@
|
||||
// State
|
||||
// data ...
|
||||
// Mutations
|
||||
//
|
||||
//
|
||||
// Actions
|
||||
import ticket from "./modules/ticket.js";
|
||||
import system from "../../../apps/modules/system/system.js";
|
||||
export const store = new Vuex.Store({
|
||||
modules: {
|
||||
ticket:ticket,
|
||||
system:system
|
||||
},
|
||||
state: {
|
||||
|
||||
},
|
||||
mutations: {
|
||||
|
||||
},
|
||||
actions: {
|
||||
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user