/home/bjcompany/domains/benjabhorn.com/public_html/benjabhorn_group/control/project_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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
<?php
        
if(!$_GET['txtHead']){
                
$_GET['txtHead']="ข้อมูลโครงการ";
            }else{
                    
$_GET['txtHead']=$_GET['txtHead'];
                }
        
//---------------------------------------------------------
            
$monthArray = array("01"=>"มกราคม","02"=>"กุมภาพันธ์","03"=>"มีนาคม","04"=>"เมษายน""05"=>"พฤษภาคม","06"=>"มิถุนายน","07"=>"กรกฏาคม","08"=>"สิงหาคม","09"=>"กันยายน","10"=>"ตุลาคม","11"=>"พฤศจิกายน","12"=>"ธันวาคม");    
        
$currentDate=date("d");
        
$currentMonthdate("m");
        
$currentMonthnamedate("m");            
        
$currentYeardate("Y");    
            
//------------------------------------------------------------------------
            
if($_GET['currentID']){
                    
$_POST['currentID']=$_GET['currentID'];
            }
            
//-----------------------------Date------------------------------------
            
setlocale (LC_TIME'th');
            
            if(!
$sdate) { $sdatestrftime("%Y-%m-%d"); }else{ $sdate=$sdate; }
            
$time=strftime("%H:%M:%S");
            
$time_sec=explode(":",$time);
            
$time_array explode(":",$time);    
        
####################################################-DELETE IMAGEs FILE
            
if($_POST['action2']=='deletePic'){
                 if(
file_exists($path_product."/thb/".$_POST['RmPic'])){
                             @
unlink ($path_product."/thb/".$_POST['RmPic']);
                 }
                 if(
file_exists($path_product."/".$_POST['RmPic'])){
                             @
unlink ($path_product."/".$_POST['RmPic']);
                 }
                 
$query "DELETE FROM  tbl_act3_pic WHERE  pic_name = '".$_POST['RmPic']."' ";
                 
mysql_query($query);
            }
        
        
####################################################-ADD NEWS DATA  AND UPDATE
        
if($_POST['action']=='Add'){
                    
$dateAdddate("Y-d-m");
                if(
$_POST['currentID']==""){     
                    
//-------------image---------------------------------banner project
                     
if($_FILES['uploadfile']['name']!=""){
                                        
$tempFileName $_FILES['uploadfile']['name'];
                                        
GetNewFileName($_FILES['uploadfile']['tmp_name'],$_FILES['uploadfile']['name'],$i);
                                        
move_uploaded_file($_FILES['uploadfile']['tmp_name'], $path_product.$_FILES['uploadfile']['name']);
                        }
                    
//-----------------------------------------------------map project
                         
if($_FILES['uploadfile2']['name']!=""){
                                        
$tempFileName $_FILES['uploadfile2']['name'];
                                        
GetNewFileName($_FILES['uploadfile2']['tmp_name'],$_FILES['uploadfile2']['name'],$i);
                                        
move_uploaded_file($_FILES['uploadfile2']['tmp_name'], $path_product.$_FILES['uploadfile2']['name']);
                        }
                    
//-----------------------------------------------------
                    
$query="INSERT INTO `tbl_project` (`id` ,`project_name` ,`project_desc` ,`project_image` ,`project_banner` "
                    
." ,`project_status` ,`project_hilight` ,`project_localtion_id` ,`project_localtion_detail` ,`project_area` "
                    
." ,`project_unit` ,`project_office` ,`project_map_image` ,`project_google_map` ,`project_draft` , `project_plan` ) "
                    
." VALUES  "
                    
." ( '' , '".$_POST['project_name']."',  '".$_POST['project_desc']."' ,  '".$_FILES['uploadfile']['name']."' ,  '".$_POST['project_banner']."'   "
                    
." , '".$_POST['project_status']."', '0', '".$_POST['project_localtion_id']."' ,  '".$_POST['project_localtion_detail']."',  '".$_POST['project_area']."'  "
                    
." ,  '".$_POST['project_unit']."' ,   '".$_POST['project_office']."' , '".$_FILES['uploadfile2']['name']."' ,   '".$_POST['project_google_map']."'  , '0', '".$_POST['project_plan']."'   ) "    ;
                
                    
mysql_query($query);
                    
$_POST['currentID']= mysql_insert_id();
                    
                }else{
                                
//------------------banner image------------------------
                            
if($_FILES['uploadfile']['name']!=""){
                                    
$tempFileName $_FILES['uploadfile']['name'];
                                    
GetNewFileName($_FILES['uploadfile']['tmp_name'],$_FILES['uploadfile']['name'],$i);
                                    
move_uploaded_file($_FILES['uploadfile']['tmp_name'], $path_product.$_FILES['uploadfile']['name']);
                                    @
unlink($path_product.$_POST['OldChkPic']);
                                
//@unlink($path_product."thb/".$_FILES['home_plan']['name']);        
                                
}else{
                                    
$_FILES['uploadfile']['name']=$_POST['OldChkPic'];
                                }
                                
//--------------map image----------------------------    
                            
if($_FILES['uploadfile2']['name']!=""){
                                    
$tempFileName $_FILES['uploadfile2']['name'];
                                    
GetNewFileName($_FILES['uploadfile2']['tmp_name'],$_FILES['uploadfile2']['name'],$i);
                                    
move_uploaded_file($_FILES['uploadfile2']['tmp_name'], $path_product.$_FILES['uploadfile2']['name']);
                                    @
unlink($path_product.$_POST['OldMapImg']);
                                
//@unlink($path_product."thb/".$_FILES['home_plan']['name']);        
                                
}else{
                                    
$_FILES['uploadfile2']['name']=$_POST['OldMapImg'];
                                }                                    
                    
            
$query "UPDATE `tbl_project` SET  "
                    
."`project_name`='".$_POST['project_name']."' ,`project_desc`='".$_POST['project_desc']."'  ,`project_image`='".$_FILES['uploadfile']['name']."' ,`project_banner`= '".$_POST['project_banner']."'  "
                    
." ,`project_status`='".$_POST['project_status']."' ,`project_hilight`='0' ,`project_localtion_id`= '".$_POST['project_localtion_id']."' ,`project_localtion_detail`= '".$_POST['project_localtion_detail']."'  ,`project_area` = '".$_POST['project_area']."'  "
                    
." ,`project_unit`= '".$_POST['project_unit']."' ,`project_office`='".$_POST['project_office']."' ,`project_map_image`= '".$_FILES['uploadfile2']['name']."' ,`project_google_map`= '".$_POST['project_google_map']."'  ,`project_draft`='0' , `project_plan`= '".$_POST['project_plan']."'  "
                    
."   WHERE id = '".$_POST['currentID']."'  ";  //selectCateID
            
mysql_query($query);
            
                    }
            }
        
####################################################-SELECTD DATA
        
if($_POST['currentID']){
                
$query="SELECT * FROM tbl_project WHERE id ='".$_POST['currentID']."' ";
                
$result=mysql_query($query);
                
$currentData=mysql_fetch_assoc($result);
        }        
   
//---------------------------------------SELECT LOCATION----------------------
   
$query="SELECT * FROM  tbl_location  ORDER BY id  ASC ";
   
$resultLocation=mysql_query($query);

?>

<!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 src="ajax.js"></script>
<script language="javascript">
                //--------------------------------        
            function  FormValid(){
                    if((document.form1.project_name.value=="")){
                                 alert("กรุณาใส่ชื่อโครงการ ");
                                return false;
                    }else if(document.form1.project_localtion_id.value=="-"){
                                 alert("กรุณาเลือกพื้นที่ ");
                                return false;    
                    }else if(document.form1.project_status.value=="-"){
                                 alert("กรุณาเลือกสถานะ ");
                                return false;                        
                   }else {     
                            document.form1.action.value = 'Add';
                        }
                }
        //-----------------------------------------------    
        function GetSubCate(MainCateID, SubCate){
                var str=Math.random();
                    var isNS4 = (navigator.appName=="Netscape")?1:0;
                    var mydata='MainCateID='+MainCateID+'&SubCate='+SubCate+'&str='+str;    
                     ajax = new sack('getSubCate.php');
                    ajax.element ="showSubCate";
                    ajax.runAJAX(mydata)
    }
    //-------------------------------------------------
    function removePic(pic){
        if(confirm('ต้องการลบรุปนี้')){
                document.form1.RmPic.value=pic;
                document.form1.action2.value='deletePic';
                document.form1.submit();
        }else{
                return false;
            }
    }
    //-------------------------------------------------
    function removeDoc(pic){
        if(confirm('ต้องการลบไฟล์นี้')){
                document.form1.RmPic.value=pic;
                document.form1.action2.value='deleteDoc';
                document.form1.submit();
        }else{
                return false;
            }
    }    
    //----------------------------------------
            function deleteThisClip(ids,filename){
                    if(confirm('ต้องการลบรายการนี้ ?')){
                                document.form1.action2.value='DeleteClip';
                                document.form1.dataID.value=ids;
                                document.form1.RemoveFile.value=filename;                            
                                document.form1.submit();                        
                        }else{
                               return false;
                            }
            }
</script>
<style type="text/css">
.buttonHead {
    -moz-box-shadow:inset 0px 1px 0px 0px #f29c93;
    -webkit-box-shadow:inset 0px 1px 0px 0px #f29c93;
    box-shadow:inset 0px 1px 0px 0px #f29c93;
    background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #fe1a00), color-stop(1, #ce0100) );
    background:-moz-linear-gradient( center top, #fe1a00 5%, #ce0100 100% );
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fe1a00', endColorstr='#ce0100');
    background-color:#fe1a00;
    -moz-border-radius:4px;
    -webkit-border-radius:4px;
    border-radius:4px;
    border:1px solid #d83526;
    display:inline-block;
    color:#ffffff;
    font-family:Arial;
    font-size:11px;
    font-weight:bold;
    padding:4px 15px;
    text-decoration:none;
}.buttonHead:hover {
    background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ce0100), color-stop(1, #fe1a00) );
    background:-moz-linear-gradient( center top, #ce0100 5%, #fe1a00 100% );
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ce0100', endColorstr='#fe1a00');
    background-color:#ce0100;
}.buttonHead:active {
    position:relative;
    top:1px;
}
/* This imageless css button was generated by CSSButtonGenerator.com */
</style>

</head>

<body>
<form action="<?php $_SERVER['PHP_SELF']?>" method="post" name="form1" onSubmit="return FormValid();" enctype="multipart/form-data">
    <table width="100%" border="0" cellspacing="3" cellpadding="3">
  <tr>
    <td class="txt10-black">
      <table width="100%" border="0" cellspacing="1" cellpadding="3">
     <tr>
           <td height="15" colspan="2" align="center" bgcolor="#FFFFFF">
           <?php if($_POST['currentID']){ include("project_menu.php"); } ?>
           &nbsp;</td>
           </tr>
     <tr>
          <td width="100%" align="left" bgcolor="#ECECD9">&nbsp;&nbsp;<img src="images/black_icon/16x16/sq_plus.png" width="16" height="16" hspace="5" border="0" align="absmiddle" /><?php echo $_GET['txtHead']?></td>
          </tr>
     <tr>
       <td align="left"><table width="100%" border="0" cellspacing="3" cellpadding="3">
                  <tr>
            <td height="10" colspan="2" align="center" bgcolor="#FFFFFF"></td>
          </tr>

          <tr>
            <td height="10" colspan="2" align="center" bgcolor="#FFFFFF"></td>
          </tr>
         <tr>
           <td width="22%" height="1" align="right">ชื่อโครงการ</td>
           <td width="78%" align="left"><input name="project_name" type="text" id="project_name" size="45" maxlength="100" value="<?php echo $currentData['project_name']?>" />
             <span class="txt-8-red">**</span></td>
         </tr>
         
         <tr>
           <td height="1" align="right">รายละเอียดย่อ</td>
           <td width="78%" align="left"><textarea name="project_desc" cols="45" rows="5" id="project_desc"> <?php echo $currentData['project_desc']?></textarea><script language="javascript1.2">
              generate_wysiwyg('project_desc');
        </script></td>
         </tr>
         <tr>
           <td height="5" align="right">บ้านพักอาศัยทั้งหมด</td>
           <td width="78%" align="left"><input name="project_unit" type="text" id="project_unit" size="10"  value="<?php echo $currentData['project_unit']?>" /></td>
         </tr>
         <tr>
           <td height="25" align="right">เนื้อที่</td>
           <td align="left"><span >
             <script language="JavaScript1.2" type="text/javascript">
              generate_wysiwyg('detailth');
        </script>
             <input name="project_area" type="text" id="project_area" size="45" value="<?php echo $currentData['project_area']?>" />
           </span></td>
         </tr>
         <tr>
           <td height="25" align="right">เลือกพื้นที่</td>
           <td align="left"><label for="project_localtion_id"></label>
             <select name="project_localtion_id" id="project_localtion_id">
             <option value="-">--เลือกพื้นที่--</option>
             <?php while($location=mysql_fetch_assoc($resultLocation)){?>
              <option value="<?php echo $location['id']?><?php if($currentData['project_localtion_id']==$location['id']){ echo "selected";}?>><?php echo $location['location_name']?></option>
              <?php }?>
             </select>
             <span class="txt-8-red">             **
             </span></td>
         </tr> 
         <tr>
           <td height="25" align="right">รายละเอียดทำเล</td>
           <td align="left"><input name="project_localtion_detail" type="text" id="project_localtion_detail" size="45" value="<?php echo $currentData['project_localtion_detail']?>" /></td>
         </tr>
      
    
         
             <tr>
           <td height="25" align="right">สำนักงานขาย</td>
           <td align="left"><input name="project_office" type="text" id="project_office" size="45"   value="<?php echo $currentData['project_office']?>" /></td>
         </tr>
         <tr>
           <td height="11" align="right">google map</td>
           <td height="11" align="left"><textarea name="project_google_map" cols="45" rows="5" id="project_google_map"><?php echo $currentData['project_google_map']?></textarea>
           <?php echo $currentData['project_google_map']?></td>
         </tr>
         <tr>
           <td height="12" align="right">แผนที่โครงการ</td>
           <td height="12" align="left"><span class="txt-8-red">
             <?php if($currentData['project_map_image']){  
                                      
$n_width=250;$n_height=250;
                                  
$info =  pathinfo($path_product."/".$currentData['project_map_image']);
                                
$info[extension]=strtolower($info[extension]);
                                if((
$info[extension]=='pjpeg')  || ($info[extension]=='gif')  ||  ($info[extension]=='png')  ||  ($info[extension]=='x-png') || ($info[extension]=='jpeg') || ($info[extension]=='jpg')){
                                     if(!
file_exists($path_product."/thb/".$currentData['project_map_image'])){ 
                                        list(
$width$height$type$attr) = getimagesize($path_product.$currentData['project_image']);
                                        
create_thub($path_product,$currentData['project_map_image'],$n_width,$n_height);
                                     }        
                                } 
?>
                 <a href="<?php echo $path_product.$currentData['project_map_image']?>" target="_blank">
             <img src="<?php echo $path_product_thb.$currentData['project_map_image']?>" border="0" /></a><br />
             <?php }
             
                  
?>
             <input name="uploadfile2" type="file" id="uploadfile2" />
           width 900 pixel height 900 pixel***</span></td>
         </tr>
         <tr>
           <td height="25" align="right">banner โครงการ</td>
           <td height="25" align="left" class="txt-8-red">
           <?php if($currentData['project_image']){  
                                      
$n_width=250;$n_height=250;
                                  
$info =  pathinfo($path_product."/".$currentData['project_image']);
                                
$info[extension]=strtolower($info[extension]);
                                if((
$info[extension]=='pjpeg')  || ($info[extension]=='gif')  ||  ($info[extension]=='png')  ||  ($info[extension]=='x-png') || ($info[extension]=='jpeg') || ($info[extension]=='jpg')){
                                     if(!
file_exists($path_product."/thb/".$currentData['project_image'])){ 
                                        list(
$width$height$type$attr) = getimagesize($path_product.$currentData['project_image']);
                                        
create_thub($path_product,$currentData['project_image'],$n_width,$n_height);
                                     }        
                                } 
?>
                                <img src="<?php echo $path_product_thb.$currentData['project_image']?>" border="0" /><br />
               <?php }
             
                  
?>
           <input name="uploadfile" type="file" id="uploadfile" /> 
           <br />
           width 250 pixel height 180 pixel***</td>
         </tr>
        <!-- <tr>
           <td height="25" align="right">รูปแผนที่</td>
           <td height="25" align="left"><input name="textfield9" type="text" id="textfield9" size="45" /></td>
         </tr> -->
         <tr>
           <td height="25" align="right">สภานะโครงการ</td>
           <td height="25" align="left" class="txt-8-red"><select name="project_status" id="project_status">
             <option value="-">--เลือกสถานะ--</option>
             <option value="pass"  <?php if($currentData['project_status']=="pass"){ echo "selected";}?>>โครงการอดีต</option>
             <option value="present" <?php if($currentData['project_status']=="present"){ echo "selected";}?>>โครงการปัจจุบัน</option>
             <option value="future" <?php if($currentData['project_status']=="future"){ echo "selected";}?>>โครงการอนาคต</option>
           </select>
             **</td>
         </tr>
         <tr>
           <td height="25" align="right">&nbsp;<input type="hidden" name="OldChkPic"  value="<?php echo $currentData['project_image']?>" />
         <input type="hidden" name="OldMapImg"  value="<?php echo $currentData['project_map_image']?>" />
          <input type="hidden" name="RmPic" />
          <input type="hidden" name="action" id="action" />
           <input type="hidden" name="currentID" id="currentID" value="<?php echo $_POST['currentID']?>" /></td>
           <td height="25" align="left"><input type="submit" name="button" id="button" value="เพิ่ม/แก้ไขข้อมูล" /></td>
         </tr>
         <tr>
           <td height="25" align="right">&nbsp;</td>
           <td height="25" align="left">&nbsp;</td>
         </tr>
       
       </table></td>
     </tr>
      </table></td>
  </tr>
  </table>
 
</form>
</body>
</html>