|
@@ -91,6 +91,7 @@ class ocean_order {
|
|
|
* document upload
|
|
* document upload
|
|
|
*/
|
|
*/
|
|
|
if ($operate == "document_upload"){
|
|
if ($operate == "document_upload"){
|
|
|
|
|
+ //只查询public,两边数据一样,不用去同步更新新加的Client_Upload ,Notify Station,Auto-sync to Station
|
|
|
$transport_mode = $_POST['transport_mode'];
|
|
$transport_mode = $_POST['transport_mode'];
|
|
|
if($transport_mode == 'sea'){
|
|
if($transport_mode == 'sea'){
|
|
|
$document = _getViewDocType($_REQUEST["_schemas"]);
|
|
$document = _getViewDocType($_REQUEST["_schemas"]);
|
|
@@ -108,10 +109,10 @@ class ocean_order {
|
|
|
}
|
|
}
|
|
|
$file_serial_nos = implode(';',$file_serial_nos);
|
|
$file_serial_nos = implode(';',$file_serial_nos);
|
|
|
if($transport_mode == 'sea'){
|
|
if($transport_mode == 'sea'){
|
|
|
- $sql = "select display_name,format_name as file_type,serial_no,m_h from ra_online_file_format where lower(serial_no) " . common::getInNotInSql($file_serial_nos) . "
|
|
|
|
|
|
|
+ $sql = "select display_name,format_name as file_type,serial_no,m_h from public.ra_online_file_format where lower(serial_no) " . common::getInNotInSql($file_serial_nos) . "
|
|
|
and active = true and client_upload = true";
|
|
and active = true and client_upload = true";
|
|
|
}else{
|
|
}else{
|
|
|
- $sql = "select display_name,format_name as file_type,serial_no,m_h from air_file_format where lower(serial_no) " . common::getInNotInSql($file_serial_nos) . "
|
|
|
|
|
|
|
+ $sql = "select display_name,format_name as file_type,serial_no,m_h from public.air_file_format where lower(serial_no) " . common::getInNotInSql($file_serial_nos) . "
|
|
|
and active = true and client_upload = true";
|
|
and active = true and client_upload = true";
|
|
|
}
|
|
}
|
|
|
$display_name = common::excuteListSql($sql);
|
|
$display_name = common::excuteListSql($sql);
|
|
@@ -127,54 +128,292 @@ class ocean_order {
|
|
|
$_schemas = $_REQUEST["_schemas"];
|
|
$_schemas = $_REQUEST["_schemas"];
|
|
|
$transport_mode = $_POST['transport_mode'];
|
|
$transport_mode = $_POST['transport_mode'];
|
|
|
$bol = $_POST['h_bol'];
|
|
$bol = $_POST['h_bol'];
|
|
|
- $transport_mode = $_POST['file_type'];
|
|
|
|
|
if ($transport_mode == "sea") {
|
|
if ($transport_mode == "sea") {
|
|
|
- $aaa = common::excuteObjectSql("select from_station, origin_station, destination_station from ocean where lower(h_bol) = '" . strtolower($bol) . "'");
|
|
|
|
|
|
|
+ $count = common::excuteObjectSql("select * from ocean where lower(h_bol) = '" . strtolower($bol) . "'");
|
|
|
|
|
+
|
|
|
} elseif ($transport_mode == "air") {
|
|
} elseif ($transport_mode == "air") {
|
|
|
- $aaa = common::excuteObjectSql("select from_station, origin_station, destination_station from air where lower(hawb) = '" . strtolower($bol) . "'");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // try {
|
|
|
|
|
- // $tmp_name = $_FILES['file']['tmp_name'];
|
|
|
|
|
- // $file_name = $_FILES['file']["name"];
|
|
|
|
|
- // $errorMsg = "";
|
|
|
|
|
- // $sql = "";
|
|
|
|
|
- // foreach ($file_name as $i => $v) {
|
|
|
|
|
- // if (empty($v)) {
|
|
|
|
|
- // continue;
|
|
|
|
|
- // }
|
|
|
|
|
- // $size = floor($_FILES ["file"]['size'][$i] / 1024 / 1024);
|
|
|
|
|
- // if ($size > 2) {
|
|
|
|
|
- // $errorMsg .= $_FILES['file']["name"][$i] . " larger than 2M.";
|
|
|
|
|
- // continue;
|
|
|
|
|
- // }
|
|
|
|
|
- // if ($_FILES["file"]["error"][$i] > 0) {
|
|
|
|
|
- // $errorMsg .= "File Upload Error(" . $_FILES ["file"]["error"][$i] . ").";
|
|
|
|
|
- // continue;
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- // $file_path = FILE_UPLOAD_PAHT . date("Ymd") . DS;
|
|
|
|
|
- // if (!is_dir($file_path)) {
|
|
|
|
|
- // common::mkdirs($file_path);
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- // $dest_file = $file_path . $path_parts['filename'] . "_" . common::uuid() . "." . $exten;
|
|
|
|
|
- // move_uploaded_file($tmp_name[$i], $dest_file);
|
|
|
|
|
|
|
+ $count = common::excuteObjectSql("select * from air where lower(hawb) = '" . strtolower($bol) . "'");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (empty($count) || count($count) <= 0){
|
|
|
|
|
+ $data = array(
|
|
|
|
|
+ 'msg' => 'HBOL does not exist'
|
|
|
|
|
+ );
|
|
|
|
|
+ common::echo_json_encode(500,$data);
|
|
|
|
|
+ exit();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $file_type = $_POST['file_type'];
|
|
|
|
|
+ $_table = $transport_mode == "sea" ? "ra_online_doc_upload" : "air_doc_upload";
|
|
|
|
|
+ $_table_format = $transport_mode == "sea" ? "ra_online_file_format" : "air_file_format";
|
|
|
|
|
+ //格式配置只查询public
|
|
|
|
|
+ $format = common::excuteObjectSql("select serial_no,standard,client_upload,notify_station,auto_sync_to_station from public.$_table_format where format_name = '$file_type'");
|
|
|
|
|
+ //查询存在的文件类型最大序号
|
|
|
|
|
+ $num = common::excuteOneSql("select count(*) from $_table where lower(bol) = '" . strtolower($bol) . "' and format_serailno = '".$format['serial_no']."'");
|
|
|
|
|
+ try {
|
|
|
|
|
+ $allow_extend = "|.pdf|.xls|.xlsx|.doc|.docx|";
|
|
|
|
|
+ $file_name = $_FILES['file']["name"];
|
|
|
|
|
+ $errorMsg = "";
|
|
|
|
|
+ $sql = "";
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($file_name as $i => $v) {
|
|
|
|
|
+ if (empty($v)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ $size = floor($_FILES ["file"]['size'][$i] / 1024 / 1024);
|
|
|
|
|
+ if ($size > 2) {
|
|
|
|
|
+ $errorMsg .= $_FILES['file']["name"][$i] . " larger than 2M.";
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($_FILES["file"]["error"][$i] > 0) {
|
|
|
|
|
+ $errorMsg .= "File Upload Error(" . $_FILES ["file"]["error"][$i] . ").";
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ $path_parts = pathinfo($file_name[$i]);
|
|
|
|
|
+ $exten = $path_parts['extension'];
|
|
|
|
|
+ if (stristr($allow_extend, "|." . $exten . "|") === FALSE) {
|
|
|
|
|
+ $errorMsg .= 'Only can upload PDF/Excel/Doc/TXT/JPG/png/tif file.<br>';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //$filename = $file_name[$i];
|
|
|
|
|
+ $filename = $bol."_".$format['standard']."_V".($i+1+$num). "." . $exten;
|
|
|
|
|
+ $file_size = floor($_FILES ["file"]['size'][$i] / 1024) . "KB";
|
|
|
|
|
+ $order_type = $transport_mode == "sea" ? "ocean" : "air";
|
|
|
|
|
+
|
|
|
|
|
+ $origin_station = $count["origin_station"];
|
|
|
|
|
+ $destination_station = $count["destination_station"];
|
|
|
|
|
+
|
|
|
|
|
+ $format_serialno = $format['serial_no'];
|
|
|
|
|
+ $serial_no = utils::uuid();
|
|
|
|
|
+
|
|
|
|
|
+ $from_station = $count["from_station"];
|
|
|
|
|
+ if (strtolower($_schemas) == "public") {
|
|
|
|
|
+ if ($transport_mode == "sea")
|
|
|
|
|
+ $folder = DOCUMENT_OCEAN_UPLOAD_PATH . $from_station;
|
|
|
|
|
+ elseif ($transport_mode == "air")
|
|
|
|
|
+ $folder = DOCUMENT_AIR_UPLOAD_PATH . $from_station;
|
|
|
|
|
+ }else {
|
|
|
|
|
+ if ($transport_mode == "sea")
|
|
|
|
|
+ $folder = DOCUMENT_SFSOCEAN_UPLOAD_PATH . $from_station;
|
|
|
|
|
+ elseif ($transport_mode == "air")
|
|
|
|
|
+ $folder = DOCUMENT_SFSAIR_UPLOAD_PATH . $from_station;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // $sql .= "INSERT INTO public.packing_attachment_list(serial_no, att_type,file_type, created_by, created_time, filename, sourcefilename, notes) VALUES "
|
|
|
|
|
- // . "('$serial_no', 'EBooking','" . common::check_input($file_type[$i]) . "', '" . _getLoginName() . "', now(), '" . common::check_input($v) . "', '"
|
|
|
|
|
- // . common::check_input($dest_file) . "', '" . common::check_input($file_note[$i]) . "');";
|
|
|
|
|
- // }
|
|
|
|
|
- // if (!empty($errorMsg)) {
|
|
|
|
|
- // $this->echoJson(array('status' => 'Failed', 'msg' => "Save Booking Failed $errorMsg"));
|
|
|
|
|
- // }
|
|
|
|
|
- // common::excuteUpdateSqlThrow($sql);
|
|
|
|
|
- // exit(json_encode("success"));
|
|
|
|
|
- // } catch (Exception $e) {
|
|
|
|
|
- // error_log($e->getTraceAsString());
|
|
|
|
|
- // $this->echoJson(array('status' => 'Failed', 'msg' => "Save Booking Failed:Upload Filed Failed."));
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ $save_path = $folder . DS . date("Ymd") . DS;
|
|
|
|
|
+ if (common::mkdirs($save_path) === FALSE){
|
|
|
|
|
+ $errorMsg .= "Save folder create error";
|
|
|
|
|
+ }
|
|
|
|
|
+ $ppp = $_FILES['file']['tmp_name'];
|
|
|
|
|
+ $sss = $save_path . $filename;
|
|
|
|
|
+ if (move_uploaded_file($_FILES['file']['tmp_name'][$i], $save_path . $filename)) {
|
|
|
|
|
+ $sql .= "insert into $_schemas.$_table (file_name, file_path, upload_date, upload_ip, upload_by, bol, file_type, file_size, online_upload,
|
|
|
|
|
+ origin, destination, from_station, serial_no,
|
|
|
|
|
+ online_format,format_serailno,source_filename)
|
|
|
|
|
+ values ('" . common::check_input($filename) . "','" . common::check_input($save_path) . "', now(), '" . common::ip() . "',
|
|
|
|
|
+ '" . common::check_input(_getLoginName()) . "','" . common::check_input(strtoupper($bol)) . "', '$order_type', '" . common::check_input($file_size) . "',
|
|
|
|
|
+ 't', '" . common::check_input($origin_station) . "', '" .common::check_input($destination_station) . "',
|
|
|
|
|
+ '" . common::check_input($from_station) . "', '" . $serial_no . "',
|
|
|
|
|
+ '" . common::check_input($file_type) . "','" . common::check_input($format_serialno) . "','" . common::check_input($filename) . "');";
|
|
|
|
|
+ }
|
|
|
|
|
+ //根据配置,看需要同步文件
|
|
|
|
|
+ if(!empty($format['auto_sync_to_station'])){
|
|
|
|
|
+ if($format['auto_sync_to_station'] == "Origin Station"){
|
|
|
|
|
+ $sql .= "INSERT INTO public.ra_online_doc_upload_log(serial_no, station, download_time)
|
|
|
|
|
+ VALUES ('".$serial_no."', '" .common::check_input($destination_station) . "', now());";
|
|
|
|
|
+ }
|
|
|
|
|
+ if($format['auto_sync_to_station'] == "Destination Station"){
|
|
|
|
|
+ $sql .= "INSERT INTO public.ra_online_doc_upload_log(serial_no, station, download_time)
|
|
|
|
|
+ VALUES ('".$serial_no."', '" .common::check_input($origin_station) . "', now());";
|
|
|
|
|
+ }
|
|
|
|
|
+ if($format['auto_sync_to_station'] == "Origin and Destination Stations"){
|
|
|
|
|
+ //这个都同步,不需要手动补充记录去阻止文件的同步
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ //根据配置发送通知邮件 相同文件类型只提醒一次
|
|
|
|
|
+ if(!empty($format['notify_station'])){
|
|
|
|
|
+ $origin_op_email = common::excuteOneSql("select email from employee where employee_id = '".$count["origin_op_id"]."' limit 1");
|
|
|
|
|
+ $dest_op_email = common::excuteOneSql("select email from employee where employee_id = '".$count["dest_op"]."' limit 1");
|
|
|
|
|
+ $ks_from = common::excuteOneSql("select ksmart_station from public.contract_region_mapping where overeas = '".$count["from_station"]."' limit 1");
|
|
|
|
|
+ $ks_to = common::excuteOneSql("select ksmart_station from public.contract_region_mapping where overeas = '".$count["destination_station"]."' limit 1");
|
|
|
|
|
+ $ks_from = empty($ks_from)? 'f' : $ks_from;
|
|
|
|
|
+ $ks_from = 't';
|
|
|
|
|
+ $ks_to = empty($ks_to)? 'f' : $ks_to;
|
|
|
|
|
+
|
|
|
|
|
+ $curr_date_config = common::excuteObjectSql("SELECT to_char(now()::date,'Mon_DD_YYYY') as d1_day,to_char(now()::date,'Mon_DD_YYYY HH:MM') as d2_day");
|
|
|
|
|
+ $subject = "External Documentation Upload Notification"."_".$curr_date_config['d1_day'];
|
|
|
|
|
+ $email_from = "US.KApex.Online@kerryapex.com";
|
|
|
|
|
+ $upload_user_name = _getLoginName();
|
|
|
|
|
+ $upload_user_email = _getLoginEamil();
|
|
|
|
|
+ //如果有多個就留空,給Email信息就行
|
|
|
|
|
+ if ($transport_mode == "sea") {
|
|
|
|
|
+ $company =utils::getConpanyForNotify($_schemas,'ocean');
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $company =utils::getConpanyForNotify($_schemas,'air');
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ //Ksmart--> Ksmart
|
|
|
|
|
+ if ($ks_from == "t" && $ks_to == "t"){
|
|
|
|
|
+ if($format['notify_station'] == "Origin Station" || $format['notify_station'] == "Origin and Destination Stations"){
|
|
|
|
|
+ if(!empty($origin_op_email)){
|
|
|
|
|
+ //立即发送
|
|
|
|
|
+ $content = utils::getKlnDocNotifyContent($bol,$file_type,$upload_user_name,$upload_user_email,$company,$curr_date_config['d2_day']);
|
|
|
|
|
+ $sql .= "INSERT INTO email_record(type, title, from_email, to_email, content, insert_date, cc_email, attachment_path)
|
|
|
|
|
+ VALUES ('KLN_DOC_Notify', '" . pg_escape_string($subject) . "', '" . pg_escape_string($email_from) . "', '" .
|
|
|
|
|
+ pg_escape_string($origin_op_email) . "', '" . pg_escape_string($content) . "', now(), '', '');";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ //加入队列状态
|
|
|
|
|
+ $sql .= "INSERT INTO public.kln_online_upload_file_notify(h_bol, file_type, upload_by, upload_time, email, company,
|
|
|
|
|
+ is_send, checked_time, checked_type,origin_op,dest_op)
|
|
|
|
|
+ VALUES ('$bol','$file_type','$upload_user_name', now(),'$upload_user_email', '$company',
|
|
|
|
|
+ false, now(), 'origin_op_email','".$count["origin_op_id"]."','".$count["dest_op"]."');";
|
|
|
|
|
+ //做好加入队列时的日志记录
|
|
|
|
|
+ $user_type = _isApexLogin() ? "Employee" : "Customer";
|
|
|
|
|
+ $detail = $bol.": $file_type File upload,origin_op_email is null, Add Notification wait";
|
|
|
|
|
+ utils::single_operation_log_save($user_type,$upload_user_name,"Tracking","upload_file_pending",$detail);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if($format['notify_station'] == "Destination Station" || $format['notify_station'] == "Origin and Destination Stations"){
|
|
|
|
|
+ if(!empty($dest_op_email)){
|
|
|
|
|
+ //立即发送
|
|
|
|
|
+ $content = utils::getKlnDocNotifyContent($bol,$file_type,$upload_user_name,$upload_user_email,$company,$curr_date_config['d2_day']);
|
|
|
|
|
+ $sql .= "INSERT INTO email_record(type, title, from_email, to_email, content, insert_date, cc_email, attachment_path)
|
|
|
|
|
+ VALUES ('KLN_DOC_Notify', '" . pg_escape_string($subject) . "', '" . pg_escape_string($email_from) . "', '" .
|
|
|
|
|
+ pg_escape_string($dest_op_email) . "', '" . pg_escape_string($content) . "', now(), '', '');";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ //加入队列状态
|
|
|
|
|
+ $sql .= "INSERT INTO public.kln_online_upload_file_notify(h_bol, file_type, upload_by, upload_time, email, company,
|
|
|
|
|
+ is_send, checked_time, checked_type,origin_op,dest_op)
|
|
|
|
|
+ VALUES ('$bol','$file_type','$upload_user_name', now(),'$upload_user_email', '$company',
|
|
|
|
|
+ false, now(), 'dest_op_email','".$count["origin_op_id"]."','".$count["dest_op"]."');";
|
|
|
|
|
+ //做好加入队列时的日志记录
|
|
|
|
|
+ $user_type = _isApexLogin() ? "Employee" : "Customer";
|
|
|
|
|
+ $detail = $bol.": $file_type File upload,dest_op_email is null, Add Notification wait";
|
|
|
|
|
+ utils::single_operation_log_save($user_type,$upload_user_name,"Tracking","upload_file_pending",$detail);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //Ksmart-->non Ksmart
|
|
|
|
|
+ if ($ks_from == "t" && $ks_to == "f"){
|
|
|
|
|
+ if($format['notify_station'] == "Destination Station" || $format['notify_station'] == "Origin and Destination Stations"){
|
|
|
|
|
+ //避免重复邮件发给origin_op, dest_op信息缺失的话,会发送给origin_op
|
|
|
|
|
+ $dest_op_email_temp = empty($dest_op_email)? $origin_op_email:$dest_op_email;
|
|
|
|
|
+ if(!empty($dest_op_email_temp)){
|
|
|
|
|
+ //立即发送
|
|
|
|
|
+ $content = utils::getKlnDocNotifyContent($bol,$file_type,$upload_user_name,$upload_user_email,$company,$curr_date_config['d2_day']);
|
|
|
|
|
+ $sql .= "INSERT INTO email_record(type, title, from_email, to_email, content, insert_date, cc_email, attachment_path)
|
|
|
|
|
+ VALUES ('KLN_DOC_Notify', '" . pg_escape_string($subject) . "', '" . pg_escape_string($email_from) . "', '" .
|
|
|
|
|
+ pg_escape_string($dest_op_email_temp) . "', '" . pg_escape_string($content) . "', now(), '', '');";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ //加入队列状态 如果缺失,用origin_op_email
|
|
|
|
|
+ $sql .= "INSERT INTO public.kln_online_upload_file_notify(h_bol, file_type, upload_by, upload_time, email, company,
|
|
|
|
|
+ is_send, checked_time, checked_type,origin_op,dest_op)
|
|
|
|
|
+ VALUES ('$bol','$file_type','$upload_user_name', now(),'$upload_user_email', '$company',
|
|
|
|
|
+ false, now(), 'origin_op_email','".$count["origin_op_id"]."','".$count["dest_op"]."');";
|
|
|
|
|
+ //做好加入队列时的日志记录
|
|
|
|
|
+ $user_type = _isApexLogin() ? "Employee" : "Customer";
|
|
|
|
|
+ $detail = $bol.": $file_type File upload,origin_op_email is null, Add Notification wait";
|
|
|
|
|
+ utils::single_operation_log_save($user_type,$upload_user_name,"Tracking","upload_file_pending",$detail);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if($format['notify_station'] == "Origin Station" || $format['notify_station'] == "Origin and Destination Stations"){
|
|
|
|
|
+ if(empty($dest_op_email) && $format['notify_station'] == "Origin and Destination Stations"){
|
|
|
|
|
+
|
|
|
|
|
+ }else{
|
|
|
|
|
+ if(!empty($origin_op_email)){
|
|
|
|
|
+ //立即发送
|
|
|
|
|
+ $content = utils::getKlnDocNotifyContent($bol,$file_type,$upload_user_name,$upload_user_email,$company,$curr_date_config['d2_day']);
|
|
|
|
|
+ $sql .= "INSERT INTO email_record(type, title, from_email, to_email, content, insert_date, cc_email, attachment_path)
|
|
|
|
|
+ VALUES ('KLN_DOC_Notify', '" . pg_escape_string($subject) . "', '" . pg_escape_string($email_from) . "', '" .
|
|
|
|
|
+ pg_escape_string($origin_op_email) . "', '" . pg_escape_string($content) . "', now(), '', '');";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ //加入队列状态
|
|
|
|
|
+ $sql .= "INSERT INTO public.kln_online_upload_file_notify(h_bol, file_type, upload_by, upload_time, email, company,
|
|
|
|
|
+ is_send, checked_time, checked_type,origin_op,dest_op)
|
|
|
|
|
+ VALUES ('$bol','$file_type','$upload_user_name', now(),'$upload_user_email', '$company',
|
|
|
|
|
+ false, now(), 'origin_op_email','".$count["origin_op_id"]."','".$count["dest_op"]."');";
|
|
|
|
|
+ //做好加入队列时的日志记录
|
|
|
|
|
+ $user_type = _isApexLogin() ? "Employee" : "Customer";
|
|
|
|
|
+ $detail = $bol.": $file_type File upload,origin_op_email is null, Add Notification wait";
|
|
|
|
|
+ utils::single_operation_log_save($user_type,$upload_user_name,"Tracking","upload_file_pending",$detail);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //Non Ksmart-->Ksmart
|
|
|
|
|
+ if ($ks_from == "f" && $ks_to == "t"){
|
|
|
|
|
+ if($format['notify_station'] == "Origin Station" || $format['notify_station'] == "Origin and Destination Stations"){
|
|
|
|
|
+ $origin_op_email_temp = empty($origin_op_email)? $dest_op_email:$origin_op_email;
|
|
|
|
|
+ if(!empty($origin_op_email_temp)){
|
|
|
|
|
+ //立即发送
|
|
|
|
|
+ $content = utils::getKlnDocNotifyContent($bol,$file_type,$upload_user_name,$upload_user_email,$company,$curr_date_config['d2_day']);
|
|
|
|
|
+ $sql .= "INSERT INTO email_record(type, title, from_email, to_email, content, insert_date, cc_email, attachment_path)
|
|
|
|
|
+ VALUES ('KLN_DOC_Notify', '" . pg_escape_string($subject) . "', '" . pg_escape_string($email_from) . "', '" .
|
|
|
|
|
+ pg_escape_string($origin_op_email_temp) . "', '" . pg_escape_string($content) . "', now(), '', '');";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ //加入队列状态
|
|
|
|
|
+ $sql .= "INSERT INTO public.kln_online_upload_file_notify(h_bol, file_type, upload_by, upload_time, email, company,
|
|
|
|
|
+ is_send, checked_time, checked_type,origin_op,dest_op)
|
|
|
|
|
+ VALUES ('$bol','$file_type','$upload_user_name', now(),'$upload_user_email', '$company',
|
|
|
|
|
+ false, now(), 'dest_op_email','".$count["origin_op_id"]."','".$count["dest_op"]."');";
|
|
|
|
|
+ //做好加入队列时的日志记录
|
|
|
|
|
+ $user_type = _isApexLogin() ? "Employee" : "Customer";
|
|
|
|
|
+ $detail = $bol.": $file_type File upload,dest_op_email is null, Add Notification wait";
|
|
|
|
|
+ utils::single_operation_log_save($user_type,$upload_user_name,"Tracking","upload_file_pending",$detail);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if($format['notify_station'] == "Destination Station" || $format['notify_station'] == "Origin and Destination Stations"){
|
|
|
|
|
+ //避免重复邮件发给dest_op, origin_op信息缺失的话,会发送给dest_op
|
|
|
|
|
+ if(empty($origin_op_email) && $format['notify_station'] == "Origin and Destination Stations"){
|
|
|
|
|
+
|
|
|
|
|
+ }else{
|
|
|
|
|
+ if(!empty($dest_op_email)){
|
|
|
|
|
+ //立即发送
|
|
|
|
|
+ $content = utils::getKlnDocNotifyContent($bol,$file_type,$upload_user_name,$upload_user_email,$company,$curr_date_config['d2_day']);
|
|
|
|
|
+ $sql .= "INSERT INTO email_record(type, title, from_email, to_email, content, insert_date, cc_email, attachment_path)
|
|
|
|
|
+ VALUES ('KLN_DOC_Notify', '" . pg_escape_string($subject) . "', '" . pg_escape_string($email_from) . "', '" .
|
|
|
|
|
+ pg_escape_string($dest_op_email) . "', '" . pg_escape_string($content) . "', now(), '', '');";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ //加入队列状态
|
|
|
|
|
+ $sql .= "INSERT INTO public.kln_online_upload_file_notify(h_bol, file_type, upload_by, upload_time, email, company,
|
|
|
|
|
+ is_send, checked_time, checked_type,origin_op,dest_op)
|
|
|
|
|
+ VALUES ('$bol','$file_type','$upload_user_name', now(),'$upload_user_email', '$company',
|
|
|
|
|
+ false, now(), 'dest_op_email','".$count["origin_op_id"]."','".$count["dest_op"]."');";
|
|
|
|
|
+ //做好加入队列时的日志记录
|
|
|
|
|
+ $user_type = _isApexLogin() ? "Employee" : "Customer";
|
|
|
|
|
+ $detail = $bol.": $file_type File upload,dest_op_email is null, Add Notification wait";
|
|
|
|
|
+ utils::single_operation_log_save($user_type,$upload_user_name,"Tracking","upload_file_pending",$detail);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!empty($errorMsg)) {
|
|
|
|
|
+ $data = array(
|
|
|
|
|
+ 'msg' => "Save Failed $errorMsg"
|
|
|
|
|
+ );
|
|
|
|
|
+ common::echo_json_encode(500,$data);
|
|
|
|
|
+ exit();
|
|
|
|
|
+ }
|
|
|
|
|
+ common::excuteUpdateSql($sql);
|
|
|
|
|
+ $data = array(
|
|
|
|
|
+ 'msg' => "success"
|
|
|
|
|
+ );
|
|
|
|
|
+ common::echo_json_encode(200,$data);
|
|
|
|
|
+ exit();
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ error_log($e->getTraceAsString());
|
|
|
|
|
+ $data = array(
|
|
|
|
|
+ 'msg' => "Save Booking Failed:Upload Filed Failed."
|
|
|
|
|
+ );
|
|
|
|
|
+ common::echo_json_encode(500,$data);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ($operate == "save_communication") {
|
|
if ($operate == "save_communication") {
|
|
@@ -2024,5 +2263,10 @@ class ocean_order {
|
|
|
$data['marksAndDescription'] = $marksAndDescription;
|
|
$data['marksAndDescription'] = $marksAndDescription;
|
|
|
return $data;
|
|
return $data;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private function getUploadFolder() {
|
|
|
|
|
+ $sql = "SELECT ra_value from ra_online_config where lower(ra_name) = 'upload_document'";
|
|
|
|
|
+ return common::excuteOneSql($sql);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
?>
|
|
?>
|