/home/bjcompany/domains/benjabhorn.com/public_html/benjabhorn_group/control/service_add.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php 
    
if($_POST['action']=='ChStatus'){
        }
    
//-------------------------------------------------------------
       
if($_POST['action']=='ChStatus2'){
        }
   
//-------------------------------------------------------------
    
if($_POST['action']=='AddPack'){
                    
$query="INSERT IGNORE INTO `tbl_service` (`id` ,`seviceName` ,`serviceDesc` ,`serviceRate` ,`serviceUnitDiscount` ,`serviceRate2` ,`serviceStatus`) "
                    
." VALUES "
                    
." ( '' ,  '".$_POST['seviceName']."',  '".$_POST['serviceDesc']."',  '".$_POST['serviceRate']."',  '".$_POST['serviceUnitDiscount']."',  '".$_POST['serviceRate2']."',   '".$_POST['serviceStatus']."') ";
                        if(
mysql_query($query)){
                
?>
                         <script language="javascript">window.location.href='main.php?work=Service';</script>
                    <?php }else{ ?>
                             <script language="javascript">window.location.href='main.php?work=errService&error=cannotInsert';</script>
                    <?php }

        }
        
//------------------------------------------------------------------------------------------------------------------------    

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script language="javascript">
            //--------------------------------
            function changeStatus(ids,mainSetid){
                            document.form1.currID.value = ids;    
                            document.form1.action.value = 'ChStatus';
                            document.form1.MainSetID.value = mainSetid;                            
                            document.form1.submit();    
            }
            //--------------------------------        
            function  FormValid(){
                     if(document.form1.seviceName.value==''){
                                 alert("กรุณาใส่ชื่อ บริการ ");
                                return false;
                         }
                     else if(document.form1.serviceDesc.value==''){
                                 alert("กรุณาใส่รายละเอียด");
                                return false;
                         }    
                    else if(document.form1.serviceRate.value==''){
                                 alert("กรุณาใส่ราคา/หน่วย ");
                        }else {     
                            document.form1.action.value = 'AddPack';
                        }
                }
            //---------------------------------------------------
            
            function numbersonly(e, decimal) {
                    var key;
                    var keychar;

                if (window.event) {
                   key = window.event.keyCode;
                } else if (e) {   key = e.which; }
                else {
                   return true;
                }
                keychar = String.fromCharCode(key);

                if ((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27) ) {
                   return true;
                }else if ((("0123456789").indexOf(keychar) > -1)) {
                       return true;
                }else if (decimal && (keychar == ".")) { 
                      return true;
                }
            else
           return false;
        }
            
</script>
</head>

<body>
<form action="<?php $_SERVER['PHP_SELF']?>" method="post" name="form1" onSubmit="return FormValid();">
    <table width="100%" border="0" cellspacing="3" cellpadding="3">
  <tr>
    <td colspan="2" class="txt10-black"><?php include("service_menu.php")?></td>
  </tr>
   <tr>
     <td width="2%"></td>
     <td><table width="100%" border="0" cellpadding="3" cellspacing="3" class="txt10-black">
       <tr>
         <td width="22%" align="right">ระบุชื่อ บริการเสริม</td>
         <td width="78%"><input name="seviceName" type="text" id="seviceName" size="40" maxlength="50" /></td>
       </tr>
       <tr>
         <td align="right">ระบุรายละเอียด</td>
         <td><textarea name="serviceDesc" cols="40" rows="5" id="serviceDesc"></textarea></td>
       </tr>
       <tr>
         <td colspan="2" align="right"><table width="100%" border="0" cellspacing="5" cellpadding="5">
           <tr>
             <td width="37%" align="right">ราคา/หน่วย 
               <input name="serviceRate" type="text" id="serviceRate" size="10" maxlength="13" onKeyPress="return numbersonly(event, true)" /></td>
             <td width="63%" align="left">บาท</td>
             </tr>
           <tr>
             <td align="right">จำนวนที่จะลดราคา
               <input name="serviceUnitDiscount" type="text" id="serviceUnitDiscount"  onKeyPress="return numbersonly(event, false)" value="0" size="10" maxlength="13"/></td>
             <td align="left">&nbsp;</td>
             </tr>
           <tr>
             <td align="right">ราคาลด
               <input name="serviceRate2" type="text" id="serviceRate2"  onkeypress="return numbersonly(event, true)" value="0" size="10" maxlength="13"/></td>
             <td align="left">บาท</td>
           </tr>
           <tr>
             <td align="right">สถานะ </td>
             <td align="left"><select name="serviceStatus" id="serviceStatus">
                 <option value="1">แสดงทันที</option>
                 <option value="0">ระงับการแสดง</option>
               </select></td>
             </tr>
           <tr>
             <td height="50" colspan="2" align="center"><input type="hidden" name="action" id="action" />
               <input type="button" name="button" id="button" value="กลับหน้าหลัก" onClick="window.location.href='main.php?work=Service';" />&nbsp;&nbsp;&nbsp;
             <input type="submit" name="button2" id="button2" value="บันทึกข้อมูล" />&nbsp;&nbsp;&nbsp;
             <input type="reset" name="button3" id="button3" value=" ล้างค่า " /></td>
             </tr>
         </table></td>
         </tr>
     </table></td>
   </tr>

    <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>

</table>
</form>
</body>
</html>