| Server IP : 172.67.216.113 / Your IP : 172.71.28.146 [ Web Server : Apache System : Linux cpanel01wh.bkk1.cloud.z.com 2.6.32-954.3.5.lve1.4.59.el6.x86_64 #1 SMP Thu Dec 6 05:11:00 EST 2018 x86_64 User : cp648411 ( 1354) PHP Version : 7.2.34 Disable Function : NONE Domains : 0 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home2/cp648411/public_html/ilawasia.onnud20.com/Attachment/ |
Upload File : |
<?php
$ck='not';
include("../include/checkLogin.php");
include("../include/class.php");
include("../include/table_name.php");
$date_year = date("Y");
$date_month = date("m");
/*
$data = array(
'Message' => 'false',
'post' => $_POST,
);
echo json_encode($data, JSON_UNESCAPED_UNICODE);
exit();
echo "<pre>";
print_r($_POST);
echo "</pre>";
*/
$docdate = $util_class->date_chang_1($_POST["DocumentDate"]);
$AttachmentId = $_POST["AttachmentId"];
$sql_attach = array('table'=>$name_table,'where'=>"AttachmentId = '".@$_POST["AttachmentId"]."'");
$view_sql_attach = $view_db->view($sql_attach);
$row_attach = $view_db->q($view_sql_attach);
$attachment = @$row_attach;
$caseNumber='';
$customerCode='';
$isCreateCase=0;
$caseId = $attachment['CaseId'];
$customerId = $attachment['CustomerId'];
if(@$attachment['CaseId'] != ''){
$sql_caseN = array('table'=>$name_table2,'where'=>"CaseId = '".@$attachment["CaseId"]."'");
$view_sql_caseN = $view_db->view($sql_caseN);
$row_caseN = $view_db->q($view_sql_caseN);
$caseNumber = $row_caseN['CaseNumber'];
}
if(@$attachment['CustomerId'] != ''){
$sql_cust = array('table'=>$name_table51,'where'=>"NamesId = '".@$attachment["CustomerId"]."'");
$view_sql_cust = $view_db->view($sql_cust);
$row_cust = $view_db->q($view_sql_cust);
$customerCode = $row_cust['NamesCode'];
}
if(@$_POST['CaseNumber']!='' && @$_POST['CaseNumber'] != $caseNumber)
{
$sql_case = array('table'=>$name_table2,'where'=>"CaseNumber = '".@$_POST["CaseNumber"]."'");
$view_sql_case = $view_db->view($sql_case);
$request_case = $view_db->q_ro($view_sql_case);
$num_case = $view_db->q_nr($request_case);
if($num_case==0){
$data = array(
'Message' => 'Case is not found',
);
}
$sql_case = array('table'=>$name_table2,'where'=>"CaseNumber = '".@$_POST["CaseNumber"]."'");
$view_sql_case = $view_db->view($sql_case);
$row_case = $view_db->q($view_sql_case);
$caseId = $row_case['CaseId'];
$customerId = $row_case['CustomerId'];
$isCreateCase = 1;
}
elseif(@$_POST['CustomerCode']!='' && @$_POST['CustomerCode'] != $customerCode )
{
$sql_cust_c = array('table'=>$name_table51,'where'=>"NamesCode = '".@$_POST["CustomerCode"]."'");
$view_sql_cust_c = $view_db->view($sql_cust_c);
$request_cust_c = $view_db->q_ro($view_sql_cust_c);
$num_case_c= $view_db->q_nr($request_cust_c);
if($num_case_c==0){
$data = array(
'Message' => 'Customer is not found',
'post' => $_POST,
);
}
$sql_cust_c = array('table'=>$name_table51,'where'=>"NamesCode = '".@$_POST["CustomerCode"]."'");
$view_sql_cust_c = $view_db->view($sql_cust_c);
$row_cust_c = $view_db->q($view_sql_cust_c);
$customerId = $row_cust_c['NamesId'];
}
elseif (@$_POST['CaseNumber']=='') { $caseId = ''; $customerId = 'null';}
elseif (@$_POST['CustomerCode']=='') { $customerId = '';}
$list = array(
'table'=>$name_table,
'AttachmentId'=>$AttachmentId,
'DocumentType'=>@$_POST['DocumentType'],
'DocumentDate'=>@$docdate,
'DocumentName'=>@$_POST['DocumentName'],
'AttachmentDate'=>@$date,
'CaseId'=>@$caseId,
'CustomerId'=>@$customerId,
'CustomerId'=>@$customerId,
'UpdateBy'=>@$_SESSION["UserInfo"][0]['UserId'],
'UpdateDateTime'=>@$date,
);
$add = $actiondata_db->edit_db($list);
if($add['suc'] == 1){
$data = array(
'Message' => 'successful',
'post' => $_POST,
);
}else{
$data = array(
'Message' => 'false',
'post' => $_POST,
);
}
if($_FILES["File"]["error"] == 0)
{
$path = "../Upload/";
$subPath = "Attachment/".@$attachment['AttachmentNumber']."/";
$Directory = $path . $subPath;
if (!file_exists($Directory)) {mkdir($Directory, 0777, true);}
$name_file = $image_class->file_up($_FILES["File"],$Directory,$subPath);
$list = array(
'table'=>$name_table,
'AttachmentId'=>$AttachmentId,
'FilePath'=>@$name_file,
'UpdateBy'=>@$_SESSION["UserInfo"][0]['UserId'],
'UpdateDateTime'=>@$date,
);
$add = $actiondata_db->edit_db($list);
if($add['suc'] == 1){
$data = array(
'Message' => 'successful',
'post' => $_POST,
'attachment' => $attachment,
);
}else{
$data = array(
'Message' => 'false',
'post' => $_POST,
);
}
}
/*'FilePath'=>"'".@$path.@$name_file."'",*/
if(@$isCreateCase==1){
$list = array(
'table'=>$name_table3,
'CaseId'=>"'".$caseId."'",
'DocumentType'=>"'".$_POST['DocumentType']."'",
'DocumentDate'=>"'".@$docdate."'",
'DocumentName'=>"'".@$_POST['DocumentName']."'",
'AttachmentDate'=>"'".@$attachment['AttachmentDate']."'",
'CreateBy'=>"'".@$_SESSION["UserInfo"][0]['UserId']."'",
'CreateDateTime'=>"'".@$_POST["Status"]."'",
);
$add = $actiondata_db->add_db($list);
if($add['suc']==1){
$sql = array('table'=>$name_table3,'count'=>'MAX(CaseAttachmentId) AS max_id , FilePath AS file','where'=>"");
$view_sql = $view_db->view($sql);
$row = $view_db->q($view_sql);
$CaseAttachmentId = $row['max_id'];
$file_Path = $row['file'];
if($_FILES["File"]["error"] == 0)
{
$path = "../Upload/";
$subPath = "Case/".@$caseId."/";
$Directory = $path . $subPath;
if (!file_exists($Directory)) {mkdir($Directory, 0777, true);}
$name_file = $image_class->file_up($_FILES["File"],$Directory,$subPath);
$file_Path = @$name_file;
}
$list = array(
'table'=>$name_table3,
'CaseAttachmentId'=>$CaseAttachmentId,
'FilePath'=>"'".@$file_Path."'",
);
$add = $actiondata_db->edit_db($list);
if($add['suc'] == 1){
$data = array(
'Message' => 'successful',
'post' => $_POST,
'attachment' => $attachment,
);
}else{
$data = array(
'Message' => 'false',
'post' => $_POST,
);
}
}
}
echo json_encode($data, JSON_UNESCAPED_UNICODE);
?>