/home/banprang/.trash/files/coremain/module/director_chart/director_edit_profile_output.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
<?php
if(id_sub_permission($id_sub)!=1){    
    
permission_fail();            
}
$navig['director_chart']=$data_name_menu_sub[name];    
$navig['director_edit_profile']="แก้ไขข้อมูลโครงสร้างการบริหาร";
navigator($navig);
echo 
"<br>";
bar_header("แก้ไขข้อมูลโครงสร้างการบริหาร"); // Bar_Header
    
fieldset_top($data_name_menu_sub[name]);
import_request_variables('pG''p_');
if(
$p_id_sub!="")            {  $id_sub=trim($p_id_sub);                        }
if(
$p_id_chart!="")            {  $id_chart=trim($p_id_chart);                    }
if(
$p_id_profile!="")        {  $id_profile=trim($p_id_profile);                }
if(
$p_name!="")                {  $name=trim($p_name);                            }
if(
$p_position!="")            {  $position=trim($p_position);                    }
if(
$p_telephone!="")        {  $telephone=trim($p_telephone);                }
if(
$p_email!="")            {  $email=trim($p_email);                        }
if(
$p_profile!="")            {  $profile=trim($p_profile);                    }


$picture=trim($_FILES['picture_file']['name']);
$fail_case = -1;

$date_time time();

if(
$picture!=""){

// check if foder for module is exists , if not create new
  
if (!file_exists($_SESSION['web_name'] . "/module_chart/" $id_sub)) {
    @
mkdir($_SESSION['web_name'] . "/module_chart/" $id_sub0777);
  }


  while (
$fail_case != 0) {
    
$allow_image allow_image_type();
    
$strings1 get_file_type($picture); // substr($picture, -4);
    
if (!in_array($strings1$allow_image)) { //if ($strings1 != ".gif" && $strings1 != ".jpg" && $strings1 != ".GIF" && $strings1 != ".JPG") {
      
$fail_case 1;
      break;
    }
    
$pic create_filename($picture);
    
$name1 "pic$pic";

    
$dlink $_SESSION['web_name'] . "/module_chart/$id_sub/" $name1;
    
$temp_name $_FILES['picture_file'];
    
upload_file_to_server($dlink$temp_name''170200);
    
    
$fail_case 0;
    break;
  }
}

if (
$fail_case == || $picture == "") {
  
// first get max position 
  
$sum_col select_count("*""cms_director_chart""id_chart = $id_chart");

  
// update profile
  
if ($picture != "") {
    
$sql "SELECT picture FROM cms_director_chart_profile WHERE id_profile = '$id_profile'";
    
$re mysql_query($sql);
    
$data mysql_fetch_array($re);
    if (
$data[0] != "") {
      @
unlink("$_SESSION[web_name]/module_chart/$id_sub/$data[0]");
    }

    
$sql "UPDATE cms_director_chart_profile SET picture='$name1',position='$position',email='$email',name='$name',profile='$profile',telephone='$telephone' WHERE id_profile = $id_profile";
  } else {
    
$sql "UPDATE cms_director_chart_profile SET email='$email',position='$position',name='$name',telephone='$telephone',profile='$profile' WHERE id_profile = $id_profile";
  }



  
mysql_query($sql) or die(mysql_error());

  
// update structure table


  
echo "<center><br><br>ข้อมูลได้ถูกแก้ไขแล้ว<br><br></center>";
  echo 
"<meta http-equiv='refresh' content='2; url=index.php?mod=director_chart&path=director_chart&id_sub=$id_sub'>";
} else {
  if (
$fail_case == 1)
    echo 
"<center><br><br>ชนิดของรูปต้องเป็น GIF หรือ JPG หรือ PNG เท่านั้น<br><br></center>";
  else if (
$fail_case == 2)
    echo 
"<center><br><br>ไม่สามารถ Upload ไฟล์ได้ กรุณาติดต่อ administrator เพื่อเปิดการเขียนไฟล์<br><br></center>";
  else if (
$fail_case == 3)
    echo 
"<center><br><br>รูปสูงเกินกว่าขนาดที่กำหนด<br><br></center>";
  else if (
$fail_case == 4)
    echo 
"<center><br><br>รูปยาวกว่าขนาดที่กำหนด<br><br></center>";
  else
    echo 
"<center><br><br>เกิดข้อผิดพลาด<br><br></center>";
  
// refresh    
  
echo "<meta http-equiv='refresh' content='2; url=index.php?mod=director_chart&path=director_chart&id_sub=$id_sub'>";
//  echo "<meta http-equiv='refresh' content='2; url=index.php?mod=boss_message_add&path=boss_message&id_top=$_GET[id_top]'>";
}
fieldset_down();
?>