이 기능은 상품 주문시에 메모와 파일을 첨부한 채로 주문을 할 수 있는 기능입니다.
예를 들어 인쇄업체에서 인쇄내용을 첨부한채로 주문시, 별도의 게시판을 필요로 없이 할 수 있게끔 하는 기능이라고 보시면됩니다.
(영카트4에서는 옵션을 입력받게끔 수정해서 사용하던 것과 비슷한 팁입니다)
고급이지 못한 실력으로 차례차례 밟아간 터라,
내용이 매끄럽지 못할것입니다.
내용이 많으니 잘 따라오세요~
참고로 영카트 본체파일을 건드려야 하니, 꼭 백업해두세요~
먼저, 필드를 두개 추가해주셔야 합니다.
/adm/config_form.php
파일에 넣었습니다만, 필드추가를 위한 부분이니 아무데나 넣고 웹에서 실행시켜줍니다.
// 주문시 추가내용/파일 입력위한 추가
sql_query(" ALTER TABLE `{$g5['g5_shop_cart_table']}`
ADD `ct_msg` varchar(255) NOT NULL DEFAULT '' AFTER `ct_select`,
ADD `ct_file` varchar(255) NOT NULL DEFAULT '' AFTER `ct_msg` ", true);
이제 mysql 은 준비되었으니,
주문하는 페이지부터 시작입니다.
/skin/shop/basic/item.form.skin.php
약 8번째줄
<form name="fitem" method="post" action="<?php echo $action_url; ?>" onsubmit="return fitem_submit(this);">
이부분을
<form name="fitem" method="post" enctype="MULTIPART/FORM-DATA" action="<?php echo $action_url; ?>" onsubmit="return fitem_submit(this);">
바꿔줍니다.
약 340번줄 즈음에
<!-- 다른 상품 보기 시작 { -->
.....
<!-- } 다른 상품 보기 끝 -->
다음에 아래를 추가해줍니다.
<!-- 별도 작업 요청사항 시작 { -->
<div id="sit_spinput">
<textarea name="work_msg"></textarea>
<input type="file" name="work_file">
</div>
<!-- } 별도 작업 요청사항 끝 -->
디자인은 알아서 잡으시구요~ ㅋ
눈에 보이는 부분이 끝났습니다.
/shop/cartupdate.php
에서 처리할 부분은 실제로 내용을 입력, 제거시 첨부파일을 삭제하는 내용입니다.
약 50번째줄
else if ($act == "alldelete") // 모두 삭제이면
이부분의 바로다음,
$sql = " delete from {$g5['g5_shop_cart_table']}
이부분의 바로 전에,
//첨부 파일 삭제
$sqld = " select ct_file from {$g5['g5_shop_cart_table']} where od_id = '$tmp_cart_id' ";
$dwresult = sql_query($sqld);
for ($i=0; $row=mysql_fetch_array($dwresult); $i++)
@unlink(G5_DATA_PATH."/odfile/".$row[ct_file]);
추가해줍니다.
약 60번째줄
else if ($act == "seldelete") // 선택삭제
이부분 다음에
$it_id = $_POST['it_id'][$i];
의 바로 아래에
//첨부 파일 삭제
$sqld = " select ct_file from {$g5['g5_shop_cart_table']} where it_id = '$it_id' and od_id = '$tmp_cart_id' ";
$dw = sql_fetch($sqld);
@unlink(G5_DATA_PATH."/odfile/".$dw[ct_file]);
추가해줍니다.
내용을 db에 입력하고 파일을 업로드할차례입니다.
같은 파일에
약 206번째줄
$sql = " INSERT INTO {$g5['g5_shop_cart_table']}
( od_id, mb_id, it_id, it_name, it_sc_type, it_sc_method, it_sc_price, it_sc_minimum, it_sc_qty, ct_status, ct_price, ct_point, ct_point_use, ct_stock_use, ct_option, ct_qty, ct_notax, io_id, io_type, io_price, ct_time, ct_ip, ct_send_cost, ct_direct, ct_select )
VALUES ";
이부분을
$sql = " INSERT INTO {$g5['g5_shop_cart_table']}
( od_id, mb_id, it_id, it_name, it_sc_type, it_sc_method, it_sc_price, it_sc_minimum, it_sc_qty, ct_status, ct_price, ct_point, ct_point_use, ct_stock_use, ct_option, ct_qty, ct_notax, io_id, io_type, io_price, ct_time, ct_ip, ct_send_cost, ct_direct, ct_select, ct_msg, ct_file )
VALUES ";
보면 끝에 두 필드가 추가되있습니다.
268번째줄정도에
// 배송비결제
....
else if($it['it_sc_type'] > 1 && $it['it_sc_method'] == 1)
$ct_send_cost = 1; // 착불
이부분이 있습니다. 바로 다음에 추가해줍니다.
//작업용 파일 업로드 추가
if($_FILES['work_file']['name']){
$ct_file_dir = G5_DATA_PATH.'/odfile';
if(!is_dir($ct_file_dir)) {
@mkdir($ct_file_dir, G5_DIR_PERMISSION);
@chmod($ct_file_dir, G5_DIR_PERMISSION);
}
$f_pt = "/[#\&\+\-%@=\/\\:;,'\"\^`~\|\!\?\*\$#<>\(\)\[\]\{\}]/";
$work_file = $_FILES['work_file']['name'];
$work_file = preg_replace("/\s+/", "", $work_file);
$work_file = preg_replace( $f_pt, "", $work_file);
$work_file = preg_replace_callback(
"/[가-힣]+/",
create_function('$matches', 'return base64_encode($matches[0]);'),
$work_file);
$work_file = preg_replace( $f_pt, "", $work_file );
$work_file_check=strtolower(array_pop(explode('.',$work_file)));
$deny_file = array("php","php3","exe","cgi","phtml","html","htm","pl","asp","jsp","inc","dll");
if(in_array($work_file_check,$deny_file))
alert('$filename 파일은 업로드할수 없는 확장자의 파일입니다.');
$work_file = $tmp_cart_id."_".$work_file;
upload_file($_FILES['work_file']['tmp_name'], $work_file, $ct_file_dir);
}
그 바로 아래에
$sql .= $comma."( '$tmp_cart_id', '{$member['mb_id']}', '{$it['it_id']}', '".addslashes($it['it_name'])."', '{$it['it_sc_type']}', '{$it['it_sc_method']}', '{$it['it_sc_price']}', '{$it['it_sc_minimum']}', '{$it['it_sc_qty']}', '쇼핑', '{$it['it_price']}', '$point', '0', '0', '$io_value', '$ct_qty', '{$it['it_notax']}', '$io_id', '$io_type', '$io_price', '".G5_TIME_YMDHIS."', '$REMOTE_ADDR', '$ct_send_cost', '$sw_direct', '$ct_select' )";
이부부을
$sql .= $comma."( '$tmp_cart_id', '{$member['mb_id']}', '{$it['it_id']}', '".addslashes($it['it_name'])."', '{$it['it_sc_type']}', '{$it['it_sc_method']}', '{$it['it_sc_price']}', '{$it['it_sc_minimum']}', '{$it['it_sc_qty']}', '쇼핑', '{$it['it_price']}', '$point', '0', '0', '$io_value', '$ct_qty', '{$it['it_notax']}', '$io_id', '$io_type', '$io_price', '".G5_TIME_YMDHIS."', '$REMOTE_ADDR', '$ct_send_cost', '$sw_direct', '$ct_select', '".addslashes($work_msg)."', '$work_file' )";
와 같이 변경해줍니다.
cartupdate.php 부분이 끝났습니다.
이제 입력된 내용을 관리자가 확인해야겠습니다.
저는
/adm/shop_admin/orderform.php
파일에서만 내용을 확인하면 되겠다고 판단했습니다.
약 164번째줄에
$sql = " select ct_id, it_id, ct_price, ct_point, ct_qty, ct_option, ct_status, cp_price, ct_stock_use, ct_point_use, ct_send_cost, io_type, io_price
이 쿼리문을
$sql = " select ct_id, it_id, ct_price, ct_point, ct_qty, ct_option, ct_status, cp_price, ct_stock_use, ct_point_use, ct_send_cost, io_type, io_price, ct_msg, ct_file
와 같이 바꿔줍니다.
약 241번째줄이 </tr>입니다. 한 주문상품의 for 문중 테이블 라인이 끝나는 부분이지요.
이 바로 다음에 추가해줍니다.
<?php
if($opt['ct_msg'] || $opt['ct_file']) {
?>
<tr>
<th>추가작업내용</th>
<td colspan="8" class="td_mngsmall"><?php echo stripslashes($opt['ct_msg']); ?></td>
<th>첨부파일</th>
<td colspan="2" class="td_mngsmall"><a href="<?php echo G5_DATA_URL."/odfile/".$opt['ct_file']?>">다운받기</a></td>
</tr>
<?php
}
?>
이 내용으로 인해 주문이 들어왔을때 메세지 혹은 파일이 있을경우 한줄이 추가되어 확인가능해집니다.
이제 주문서를 삭제했을때를 위해 수정합니다.
yc5는 리스트에서 "주문"으로 검색시 해당되는 부분만 삭제버튼이 나타나게 되어있습니다.
때문에 /adm/shop_admin/orderlistdelete.php 파일만 수정합니다.
약 14번째줄 if (!$od) continue; 다음에
//첨부 파일 삭제
$sqld = " select ct_file from {$g5['g5_shop_cart_table']} where od_id = '$od_id' ";
$dwresult = sql_query($sqld);
for ($i=0; $row=mysql_fetch_array($dwresult); $i++)
@unlink(G5_DATA_PATH."/odfile/".$row[ct_file]);
위 내용을 추가해줍니다.
이정도 까지 하면 주문할때 문제가 없고,
관리자가 확인할 때 문제가 없으며,
사용자던, 관리자던 주문서를 삭제했을때는 서버에 쓰레기 파일이 남지 않을것입니다.
관리자가 확인하고 삭제시 처리하는 부분을 응용해서,
주문확인에서도 적용시킬 수 있겠지요.
혹은 주문확인에서 본 내용만을 수정하게도 가능할것입니다.
내용이 복잡해서 미루다가 이제서야 올립니다.
아직 오픈할정도로 테스트는 이루어지지않았습니다.
버그나 오작동 할 경우 알려주세요 ^^;
예를 들어 인쇄업체에서 인쇄내용을 첨부한채로 주문시, 별도의 게시판을 필요로 없이 할 수 있게끔 하는 기능이라고 보시면됩니다.
(영카트4에서는 옵션을 입력받게끔 수정해서 사용하던 것과 비슷한 팁입니다)
고급이지 못한 실력으로 차례차례 밟아간 터라,
내용이 매끄럽지 못할것입니다.
내용이 많으니 잘 따라오세요~
참고로 영카트 본체파일을 건드려야 하니, 꼭 백업해두세요~
먼저, 필드를 두개 추가해주셔야 합니다.
/adm/config_form.php
파일에 넣었습니다만, 필드추가를 위한 부분이니 아무데나 넣고 웹에서 실행시켜줍니다.
// 주문시 추가내용/파일 입력위한 추가
sql_query(" ALTER TABLE `{$g5['g5_shop_cart_table']}`
ADD `ct_msg` varchar(255) NOT NULL DEFAULT '' AFTER `ct_select`,
ADD `ct_file` varchar(255) NOT NULL DEFAULT '' AFTER `ct_msg` ", true);
이제 mysql 은 준비되었으니,
주문하는 페이지부터 시작입니다.
/skin/shop/basic/item.form.skin.php
약 8번째줄
<form name="fitem" method="post" action="<?php echo $action_url; ?>" onsubmit="return fitem_submit(this);">
이부분을
<form name="fitem" method="post" enctype="MULTIPART/FORM-DATA" action="<?php echo $action_url; ?>" onsubmit="return fitem_submit(this);">
바꿔줍니다.
약 340번줄 즈음에
<!-- 다른 상품 보기 시작 { -->
.....
<!-- } 다른 상품 보기 끝 -->
다음에 아래를 추가해줍니다.
<!-- 별도 작업 요청사항 시작 { -->
<div id="sit_spinput">
<textarea name="work_msg"></textarea>
<input type="file" name="work_file">
</div>
<!-- } 별도 작업 요청사항 끝 -->
디자인은 알아서 잡으시구요~ ㅋ
눈에 보이는 부분이 끝났습니다.
/shop/cartupdate.php
에서 처리할 부분은 실제로 내용을 입력, 제거시 첨부파일을 삭제하는 내용입니다.
약 50번째줄
else if ($act == "alldelete") // 모두 삭제이면
이부분의 바로다음,
$sql = " delete from {$g5['g5_shop_cart_table']}
이부분의 바로 전에,
//첨부 파일 삭제
$sqld = " select ct_file from {$g5['g5_shop_cart_table']} where od_id = '$tmp_cart_id' ";
$dwresult = sql_query($sqld);
for ($i=0; $row=mysql_fetch_array($dwresult); $i++)
@unlink(G5_DATA_PATH."/odfile/".$row[ct_file]);
추가해줍니다.
약 60번째줄
else if ($act == "seldelete") // 선택삭제
이부분 다음에
$it_id = $_POST['it_id'][$i];
의 바로 아래에
//첨부 파일 삭제
$sqld = " select ct_file from {$g5['g5_shop_cart_table']} where it_id = '$it_id' and od_id = '$tmp_cart_id' ";
$dw = sql_fetch($sqld);
@unlink(G5_DATA_PATH."/odfile/".$dw[ct_file]);
추가해줍니다.
내용을 db에 입력하고 파일을 업로드할차례입니다.
같은 파일에
약 206번째줄
$sql = " INSERT INTO {$g5['g5_shop_cart_table']}
( od_id, mb_id, it_id, it_name, it_sc_type, it_sc_method, it_sc_price, it_sc_minimum, it_sc_qty, ct_status, ct_price, ct_point, ct_point_use, ct_stock_use, ct_option, ct_qty, ct_notax, io_id, io_type, io_price, ct_time, ct_ip, ct_send_cost, ct_direct, ct_select )
VALUES ";
이부분을
$sql = " INSERT INTO {$g5['g5_shop_cart_table']}
( od_id, mb_id, it_id, it_name, it_sc_type, it_sc_method, it_sc_price, it_sc_minimum, it_sc_qty, ct_status, ct_price, ct_point, ct_point_use, ct_stock_use, ct_option, ct_qty, ct_notax, io_id, io_type, io_price, ct_time, ct_ip, ct_send_cost, ct_direct, ct_select, ct_msg, ct_file )
VALUES ";
보면 끝에 두 필드가 추가되있습니다.
268번째줄정도에
// 배송비결제
....
else if($it['it_sc_type'] > 1 && $it['it_sc_method'] == 1)
$ct_send_cost = 1; // 착불
이부분이 있습니다. 바로 다음에 추가해줍니다.
//작업용 파일 업로드 추가
if($_FILES['work_file']['name']){
$ct_file_dir = G5_DATA_PATH.'/odfile';
if(!is_dir($ct_file_dir)) {
@mkdir($ct_file_dir, G5_DIR_PERMISSION);
@chmod($ct_file_dir, G5_DIR_PERMISSION);
}
$f_pt = "/[#\&\+\-%@=\/\\:;,'\"\^`~\|\!\?\*\$#<>\(\)\[\]\{\}]/";
$work_file = $_FILES['work_file']['name'];
$work_file = preg_replace("/\s+/", "", $work_file);
$work_file = preg_replace( $f_pt, "", $work_file);
$work_file = preg_replace_callback(
"/[가-힣]+/",
create_function('$matches', 'return base64_encode($matches[0]);'),
$work_file);
$work_file = preg_replace( $f_pt, "", $work_file );
$work_file_check=strtolower(array_pop(explode('.',$work_file)));
$deny_file = array("php","php3","exe","cgi","phtml","html","htm","pl","asp","jsp","inc","dll");
if(in_array($work_file_check,$deny_file))
alert('$filename 파일은 업로드할수 없는 확장자의 파일입니다.');
$work_file = $tmp_cart_id."_".$work_file;
upload_file($_FILES['work_file']['tmp_name'], $work_file, $ct_file_dir);
}
그 바로 아래에
$sql .= $comma."( '$tmp_cart_id', '{$member['mb_id']}', '{$it['it_id']}', '".addslashes($it['it_name'])."', '{$it['it_sc_type']}', '{$it['it_sc_method']}', '{$it['it_sc_price']}', '{$it['it_sc_minimum']}', '{$it['it_sc_qty']}', '쇼핑', '{$it['it_price']}', '$point', '0', '0', '$io_value', '$ct_qty', '{$it['it_notax']}', '$io_id', '$io_type', '$io_price', '".G5_TIME_YMDHIS."', '$REMOTE_ADDR', '$ct_send_cost', '$sw_direct', '$ct_select' )";
이부부을
$sql .= $comma."( '$tmp_cart_id', '{$member['mb_id']}', '{$it['it_id']}', '".addslashes($it['it_name'])."', '{$it['it_sc_type']}', '{$it['it_sc_method']}', '{$it['it_sc_price']}', '{$it['it_sc_minimum']}', '{$it['it_sc_qty']}', '쇼핑', '{$it['it_price']}', '$point', '0', '0', '$io_value', '$ct_qty', '{$it['it_notax']}', '$io_id', '$io_type', '$io_price', '".G5_TIME_YMDHIS."', '$REMOTE_ADDR', '$ct_send_cost', '$sw_direct', '$ct_select', '".addslashes($work_msg)."', '$work_file' )";
와 같이 변경해줍니다.
cartupdate.php 부분이 끝났습니다.
이제 입력된 내용을 관리자가 확인해야겠습니다.
저는
/adm/shop_admin/orderform.php
파일에서만 내용을 확인하면 되겠다고 판단했습니다.
약 164번째줄에
$sql = " select ct_id, it_id, ct_price, ct_point, ct_qty, ct_option, ct_status, cp_price, ct_stock_use, ct_point_use, ct_send_cost, io_type, io_price
이 쿼리문을
$sql = " select ct_id, it_id, ct_price, ct_point, ct_qty, ct_option, ct_status, cp_price, ct_stock_use, ct_point_use, ct_send_cost, io_type, io_price, ct_msg, ct_file
와 같이 바꿔줍니다.
약 241번째줄이 </tr>입니다. 한 주문상품의 for 문중 테이블 라인이 끝나는 부분이지요.
이 바로 다음에 추가해줍니다.
<?php
if($opt['ct_msg'] || $opt['ct_file']) {
?>
<tr>
<th>추가작업내용</th>
<td colspan="8" class="td_mngsmall"><?php echo stripslashes($opt['ct_msg']); ?></td>
<th>첨부파일</th>
<td colspan="2" class="td_mngsmall"><a href="<?php echo G5_DATA_URL."/odfile/".$opt['ct_file']?>">다운받기</a></td>
</tr>
<?php
}
?>
이 내용으로 인해 주문이 들어왔을때 메세지 혹은 파일이 있을경우 한줄이 추가되어 확인가능해집니다.
이제 주문서를 삭제했을때를 위해 수정합니다.
yc5는 리스트에서 "주문"으로 검색시 해당되는 부분만 삭제버튼이 나타나게 되어있습니다.
때문에 /adm/shop_admin/orderlistdelete.php 파일만 수정합니다.
약 14번째줄 if (!$od) continue; 다음에
//첨부 파일 삭제
$sqld = " select ct_file from {$g5['g5_shop_cart_table']} where od_id = '$od_id' ";
$dwresult = sql_query($sqld);
for ($i=0; $row=mysql_fetch_array($dwresult); $i++)
@unlink(G5_DATA_PATH."/odfile/".$row[ct_file]);
위 내용을 추가해줍니다.
이정도 까지 하면 주문할때 문제가 없고,
관리자가 확인할 때 문제가 없으며,
사용자던, 관리자던 주문서를 삭제했을때는 서버에 쓰레기 파일이 남지 않을것입니다.
관리자가 확인하고 삭제시 처리하는 부분을 응용해서,
주문확인에서도 적용시킬 수 있겠지요.
혹은 주문확인에서 본 내용만을 수정하게도 가능할것입니다.
내용이 복잡해서 미루다가 이제서야 올립니다.
아직 오픈할정도로 테스트는 이루어지지않았습니다.
버그나 오작동 할 경우 알려주세요 ^^;
댓글 52개
감사합니다. 덕분에 잘 적용했습니다.
$work_file = preg_replace_callback( "/[가-힣]+/", create_function('$matches', 'return base64_encode($matches[0]);'), $work_file);
이 부분은 php8에서 create_function 이 사용되지 않게 됨에 따라 작동하지 않습니다.
$work_file = preg_replace_callback(
"/[가-힣]+/",
function ($matches) {
return base64_encode($matches[0]);
},
$work_file
);
이렇게 수정하시면 됩니다.
게시글 목록
| 번호 | 제목 |
|---|---|
| 2503 | |
| 2501 | |
| 2497 | |
| 2495 | |
| 2491 | |
| 2490 | |
| 2489 | |
| 2486 | |
| 2484 | |
| 2483 | |
| 2481 | |
| 2476 | |
| 2475 | |
| 2474 | |
| 2472 | |
| 2469 | |
| 2467 | |
| 2466 | |
| 2465 | |
| 2464 | |
| 2463 | |
| 2460 | |
| 2459 | |
| 2456 | |
| 2449 | |
| 2446 | |
| 2441 | |
| 2420 | |
| 2419 | |
| 2417 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기