[영카트4] 현재 사용중인 온라인견적 입니다. > 그누4 팁자료실

그누4 팁자료실

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요.
나누면 즐거움이 커집니다.

[영카트4] 현재 사용중인 온라인견적 입니다. 정보

[영카트4] 현재 사용중인 온라인견적 입니다.

본문

onlinecalc.php

<?
//--------------------------------------------------
// 온라인견적
//--------------------------------------------------
// 참고 : 옵션이 있는 상품은 제외됩니다.
//--------------------------------------------------
include_once("./_common.php");

if (!$oc_id)
{
    $sql = " select max(oc_id) as max_oc_id from $g4[yc4_onlinecalc_table] ";
    $row = sql_fetch($sql);
    $oc_id = $row[max_oc_id];
}

$sql = " select * from $g4[yc4_onlinecalc_table]
          where oc_id = '$oc_id' ";
$oc = sql_fetch($sql);
if (!$oc[oc_id])
    alert("등록된 온라인견적이 없습니다.");

$g4[title] = $oc[oc_subject];
include_once("./_head.php");
?>

<img src="<?=$g4[shop_img_path]?>/top_onlinecalc.gif" border=0>

<?
$himg = "$g4[path]/data/onlinecalc/{$oc_id}_h";
if (file_exists($himg))
    echo "<img src='$himg' border=0><BR>";

// 상단 HTML
echo stripslashes($oc[oc_head_html]);

if ($is_admin)
    echo "<p align=center><a href='$g4[shop_admin_path]/onlinecalcform.php?w=u&oc_id=$oc[oc_id]'><img src='$g4[shop_img_path]/btn_admin_modify.gif' border=0></a></p>";
?>

<form name=fonlinecalc method=post action="./cartupdate.php" style="padding:0px;">
<input type=hidden name=w value="multi">
<input type=hidden name=sw_direct value=''>
<table width=100% align=center cellpadding=0 cellspacing=0>
<tr>
    <td>
        <table width=100% cellpadding=0 cellspacing=0>
        <colgroup width=150>
        <colgroup width='' align=right>
        <colgroup width=60>
        <colgroup width=90>
        <colgroup width=30>
        <tr>
            <td colspan=3 align=right style='padding-top:7px; padding-bottom:7px;'>합 계 </td>
            <td><input type=text id='tot_amount_0' name='tot_amount[0]' size=10 class=ed readonly style='text-align:right;'> 원 [부가세 별도가]</td>
            <td>&nbsp;</td>
        </tr>
        <tr><td class=c1 height=2 colspan=5></td></tr>
        <?
        $hidden = array();

        // 분류 리스트를 나누고 $cat 배열 생성
        $cat = explode("\n", trim($oc[oc_category]));

        for ($i=0; $i<count($cat); $i++)
        {
            if ($i > 0)
                echo "<tr><td height=1 colspan=5 background='$g4[shop_img_path]/dot_line.gif'></td></tr>\n";

            $ca_id = $cat[$i];
           
            $sql = " select ca_name from $g4[yc4_category_table] where ca_id = '$ca_id' ";
            $row = sql_fetch($sql);
            $ca_name = $row[ca_name];
            //echo "DEBUG $i : $ca_id - $ca_name<br>";
           
            // 대분류인지 유무를 판단하여 대분류가 아니면 <select>..</select>를 처리하도록 한다.
            if(strlen($ca_id) > 3) {    //*****************************

            echo "<tr $g_tr_mouse>\n";
            echo "<td width=120>&nbsp;$ca_name</td>\n";
            // 상품 (하위 분류의 상품을 모두 포함한다.)
            // 1.02.00
            // it_order 추가
            $sql = " select *
                      from $g4[yc4_item_table]
                      where ca_id like '$ca_id%'
                      /*
                        and it_use = 1
                        and it_tel_inq = 0
                        and it_opt1 not like '%;%'
                        and it_opt2 not like '%;%'
                        and it_opt3 not like '%;%'
                        and it_opt4 not like '%;%'
                        and it_opt5 not like '%;%'
                        and it_opt6 not like '%;%'
and it_opt7 not like '%;%'
and it_opt8 not like '%;%'
and it_opt9 not like '%;%'
and it_opt10 not like '%;%'
and it_opt11 not like '%;%'
and it_opt12 not like '%;%'
and it_opt13 not like '%;%'
and it_opt14 not like '%;%'
and it_opt15 not like '%;%'
                    */
                      order by ca_id, it_order, it_id desc ";
            $result = sql_query($sql);
            echo "<td>\n";
            echo "<select id='it_id_{$i}' name='it_id[{$i}]' onchange=\"compute_line(this.form, $i);\">\n";
            echo "<option value=''>------------------------------ 선택하십시오. ------------------------------\n";
            for ($k=0; $row=mysql_fetch_array($result); $k++)
            {
                // 재고가 없다면 제외
                if (get_it_stock_qty($row[it_id]) <= 0)
                    continue;

                $it_name = cut_str($row[it_name],10);
echo "<option value='$row[it_id]'>$row[it_name] (".display_amount(get_amount($row)).")\n";

                $hidden[$row[it_id]]->name = $row[it_name];
                $hidden[$row[it_id]]->amount = $row[it_amount];
                $hidden[$row[it_id]]->point = $row[it_point];

            }

            echo "</select>\n";
            echo "</td>\n";
            echo "<td style='padding-top:7px; padding-bottom:7px;'><input type=text id='ct_qty_{$i}' name='ct_qty[{$i}]' size=3 maxlength=4 class=ed value='1' onblur=\"change_qty(this.form, this, $i); compute_total(this.form);\" style='text-align:right;'> 개</td>\n";
            echo "<td><input type=text id='amount_{$i}' name='amount[{$i}]' size=10 class=ed readonly style='text-align:right;'> 원</td>\n";
            echo "<td><a href='#detail' onclick=\"item_detail(document.fonlinecalc.elements['it_id['+$i+']']);\">";
            echo "<img src='$g4[shop_img_path]/icon_onlinecalc.gif' border=0 align=absmiddle alt='상품 상세보기' width=20 height=20></a></td>\n";
            echo "</tr>\n";

            // 대분류인지 유무를 판단하여 대분류라면 대분류명만 보이도록 처리하도록 한다.            
            } else {    //*****************************
           
            // 다음의 3개 input hidden 이 없으면 자바스크립터에서 값계산 및 인쇄시에 오류가 발생함
            echo "<input type=hidden id='it_id_{$i}' name='it_it[{$i}]' value=''>\n";
            echo "<input type=hidden id='ct_qty_{$i}' name='ct_qty[{$i}]'>\n";
            echo "<input type=hidden id='amount_{$i}' name='amount[{$i}]'>\n";         

            echo "<tr>\n";
            echo "<td style='background:#D9EBFC; height:25px' colspan=5 height=20>&nbsp;<img src='../skin/search/basic/img/btn_more.gif' width=11 height=11 align=absmiddle>&nbsp;<b>$ca_name</b></td>\n";
           
            }  //*****************************
           
// 실제 넘기는 값
            echo "<input type=hidden id='it_name_{$i}' name='it_name[{$i}]' value=''>\n";
            echo "<input type=hidden id='it_amount_{$i}' name='it_amount[{$i}]' value=''>\n";
            echo "<input type=hidden id='it_point_{$i}' name='it_point[{$i}]' value=''>\n";

        }

        // $length 는 자바스크립트에서 사용
        $length = $i;


        // 저장해놓은 hidden 배열 출력
        foreach($hidden as $key=>$value)
        {
            echo "<input type=hidden id='tmp_name_{$key}'  name='tmp_name[{$key}]'  value='{$value->name}'>\n";
            echo "<input type=hidden id='tmp_amount_{$key}' name='tmp_amount[{$key}]' value='{$value->amount}'>\n";
            echo "<input type=hidden id='tmp_point_{$key}'  name='tmp_point[{$key}]'  value='{$value->point}'>\n";
        }
        ?>
        <tr><td class=c1 height=2 colspan=5></td></tr>
        <tr>
            <td colspan=3 align=right style='padding-top:7px; padding-bottom:7px;'>합 계 </td>
            <td>
                <input type=text id='tot_amount_1' name='tot_amount[1]' size=10 class=ed readonly style='text-align:right;'> 원 [부가세 별도가]</td>
            <td>&nbsp;</td>
        </tr>
        </table></td>
</tr>
</table>

<p align=center>
    <!--
<a href="javascript:fonlinecalc_check('buy');"><img src="<?=$g4[shop_img_path]?>/btn_buy.gif" border=0 title="주문하기"></a>&nbsp;
    <a href="javascript:fonlinecalc_check('cart');"><img src="<?=$g4[shop_img_path]?>/btn_cart_in.gif" border=0 title="장바구니 담기"></a>&nbsp;                                             
    -->
<a href="javascript:fonlinecalc_check('print');"><img src="<?=$g4[shop_img_path]?>/btn_print.gif" border=0 title="인쇄하기"></a>


<input type=hidden id='element_length' value='<?=(int)$length;?>'>
</form>

<script language='javascript'>
var delimiter = ""; // 구분자

function fonlinecalc_check(act)
{
    var f = document.fonlinecalc;

    if (act == 'buy') // 바로 구매
        f.sw_direct.value = '1';
    else  // 장바구니에 담기
        f.sw_direct.value = '0';

    checked = false;
    for (i=0; i<document.getElementById('element_length').value; i++)
    {
        //if (f.elements('it_id['+i+']').value != "")
        if (document.getElementById('it_id_'+i).value != "")
        {
            checked = true;
            break;
        }
    }

    if (checked == false)
    {
        alert("상품을 한개 이상 선택해 주십시오.");
        return;
    }

    if (act == "print") 
    {
        f.action = "./onlinecalcprint.php";
        f.target = "_new";
    }
    else
    {
        f.target = "_parent";
        f.action = "./cartupdate.php";
    }
    f.submit();
}

function change_qty(f, fld, idx)
{
    var qty = parseInt(fld.value);
    if( (fld.value.search(/[^0-9]+/) != -1) || (qty < 1) || (isNaN(qty) == true) )
    {
        alert('수량을 바르게 입력해 주십시오.');
        fld.focus();
        return false;
    }

    compute_line(f, idx);
}

function compute_line(f, idx)
{
    var tmp_name = "";
    var tmp_amount = 0;
    var tmp_point = 0;
    //var qty = parseInt(f.elements('ct_qty['+idx+']').value);
    //var selidx = f.elements("it_id["+idx+"]").value;
    var qty = parseInt(document.getElementById('ct_qty_'+idx).value);
    var selidx = document.getElementById('it_id_'+idx).value;

    if (selidx == "")
    {
        amount = 0;
    }
    else
    {
        //tmp_name = f.elements("tmp_name["+selidx+"]").value;
        //tmp_amount = parseInt(f.elements("tmp_amount["+selidx+"]").value);
        //tmp_point = parseInt(f.elements("tmp_point["+selidx+"]").value);
        tmp_name = document.getElementById('tmp_name_'+selidx).value;
        tmp_amount = document.getElementById('tmp_amount_'+selidx).value;
        tmp_point = document.getElementById('tmp_point_'+selidx).value;

        amount =  tmp_amount * qty;
    }

    //f.elements('it_name['+idx+']').value = tmp_name;
    //f.elements('it_amount['+idx+']').value = tmp_amount;
    //f.elements('it_point['+idx+']').value = tmp_point;
    document.getElementById('it_name_'+idx).value = tmp_name;
    document.getElementById('it_amount_'+idx).value = tmp_amount;
    document.getElementById('it_point_'+idx).value = tmp_point;

    //f.elements('amount['+idx+']').value = number_format(String(amount));
    document.getElementById('amount_'+idx).value = number_format(String(amount));

    compute_total(f);
}

function compute_total(f)
{
    tot_amount = 0;
    for (i=0; i<document.getElementById('element_length').value; i++)
    {
        //amount = f.elements('amount['+i+']').value;
        amount = document.getElementById('amount_'+i).value;
        if (amount == "") amount = "0";
        amount = no_comma(String(amount));
        tot_amount += parseInt(amount);
    }
    //f.elements('tot_amount[0]').value = f.elements('tot_amount[1]').value = number_format(String(tot_amount));
    document.getElementById('tot_amount_0').value = document.getElementById('tot_amount_1').value = number_format(String(tot_amount));
}

// 상품 상세보기
function item_detail(fld)
{
    // delimiter 구분자로 나누고
    str = fld.value.split(delimiter);
    if (str[0] == "") return false;
    window.open('./item.php?it_id='+str[0], "itemdetail");
}
</script>

<?
// 하단 HTML
echo stripslashes($oc[oc_tail_html]);

$timg = "$g4[path]/data/onlinecalc/{$oc[oc_id]}_t";
if (file_exists($timg))
    echo "<img src='$timg' border=0><br>";

include_once("./_tail.php");
?>

============================================================================

onlinecalcprint.php

<?
include_once("./_common.php");
?>
<html>
<head>
<title>온라인 견적서</title>
<meta http-equiv="Content-Type" content="text/html; charset=<?=$g4['charset']?>">
<style>
    body, td { font-size:9pt; font-family:돋움; }
</style>
</head>
<body>
<table width=640>
<tr align=center><td colspan=8 height=70><h3>온라인 견적서</h3></td></tr>
<tr><td colspan=8>견적일시 : <? echo date("Y년 m월 d일 H시 i분") ?></tr>
<tr><td colspan=8 height=2><hr size=0></td></tr>
<tr align=center height=22>
    <td width=100><b>구 분</b></td>
    <td width=340><b>품 명</b></td>
    <td width=40 align=right><b>수 량</b></td>
    <td width=80 align=right><b>단 가</b>&nbsp;</td>
    <td width=80 align=right><b>합 계</b>&nbsp;</td>
</tr>
<tr><td colspan=8 height=2><hr size=0></td></tr>
<?
$k = 0;
$total_amount = 0;

//print_r2($_POST[it_id]);
//echo "DEBUG it_id - count : ".count($_POST[it_id])."<br>";
//print_r2($_POST);
//echo "DEBUG it_name - count : ".count($_POST[it_name])."<br>";

//for ($i=0; $i<count($_POST[it_id]); $i++)
for ($i=0; $i<count($_POST[it_name]); $i++)
{
    $it_id = $_POST[it_id][$i];
    if (!$it_id)
        continue;

    $sql = " select b.ca_name
              from $g4[yc4_item_table] a, $g4[yc4_category_table] b
              where a.ca_id = b.ca_id
                and a.it_id= '$it_id' ";
    $ca = sql_fetch($sql);

    $qty = $_POST[ct_qty][$i];

    $amount = $_POST[it_amount][$i];
    $subtotal_amount = $amount * $qty;
    $total_amount += $subtotal_amount;

    if ($k > 0)
        echo "<tr><td colspan=8 height=1><hr size=0></td></tr>";
    $k++;

    echo "<tr height=20>";
    echo "<td align=center>$ca[ca_name]</td>";
    echo "<td>".($_POST[it_name][$i])."</td>";
    echo "<td align=center>$qty</td>";
    echo "<td align=right>".display_amount($amount)."</td>";
    echo "<td align=right>".display_amount($subtotal_amount)."</td>";
    echo "</tr>";
}
?>
<tr><td colspan=8 height=2><hr size=0></td></tr>
<tr><td colspan=8 align=right height=22><b>견적 합계 : &nbsp;&nbsp;&nbsp;<font color=crimson><? echo display_amount($total_amount) ?></font></b> [부가세 별도가]</td></tr>
<tr><td colspan=8 height=2><hr size=0></td></tr>
<tr><td colspan=8 height=3></td></tr>
<tr><td colspan=8>상 호 : <?=$default[de_admin_company_name]?></td></tr>
<tr><td colspan=8>전 화 : <?=$default[de_admin_company_tel]?></td></tr>
<tr><td colspan=8>주 소 : (<?=$default[de_admin_company_zip]?>) <?=$default[de_admin_company_addr]?></td></tr>
<tr><td colspan=8>홈페이지 : http://www.okpcas.co.kr</td></tr>
<tr><td colspan=8>- 비고 -</td></tr>
<tr><td colspan=8>가격정보는 수시로 업데이트 되므로, 본 견적서의 출력후 해당 부품의 단가는 변동될 수도 있으며, <br>제품구매시에는 최종 변경된 단가가 적용됩니다. </td></tr>
<tr><td align=right colspan=8><input type='button' value='프린트하기' onClick='javascript:window.print()'>
&nbsp;&nbsp;&nbsp;
<input type='button' value='창 닫 기' onClick='javascript:window.close()'></td></tr>
</table>
</body>
</html>

적절히 수정해서 사용 하시기 바랍니다.
(현재 옵션이 6에서 15개로 .... 옵션이 있더라도 견적화면에 출력이 가능
하게 주석처리 되어져 있습니다.)

본 자료에 대해 개인적인 질문에 대해서는 회신해 드리지 않습니다.
이 자료는 많은 회원님들과 zzzz님, root님, 관리자님의 도움으로 완성 되었습니다.
이자리를 빌어 감사의 말씀을 전합니다.

미리보기 : http://okpcas.co.kr/cart/shop/onlinecalc.php
추천
0
  • 복사

댓글 8개

에러가 나서 확인해 보니 맨 윗부분에서 
include_once("./_common.php");
다음에 나오는
?>
<?
부분을 제거 하니 잘 됩니다.  감사 합니다...

디자인상
58번 라인 <tr><td class=c1 height=2 colspan=5></td></tr> 를 삭제 하고
143번 쯤            echo "<tr><td height=2 colspan=5></td></tr>";
        echo "<tr><td class=c1 height=5 colspan=5></td></tr>";
를 추가 하니 좀더 보기가 좋아 보이는 군요...

http://manwhanara.com/shop/onlinecalc.php?oc_id=1  <------ 미리 보기 입니다.

감사 합니다...^^
select max(oc_id) as max_oc_id from

1064 : You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

error file : /gboard/shop/onlinecalc.php 이런메시지가 뜹니다. 해결할방법은 없나요
© SIRSOFT
현재 페이지 제일 처음으로