forked from dfar2008/taobaocrm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupgrade_account.php
More file actions
154 lines (131 loc) · 4.99 KB
/
upgrade_account.php
File metadata and controls
154 lines (131 loc) · 4.99 KB
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
<?php
require_once('config.inc.php');
require_once('include/utils/utils.php');
require_once('include/database/PearDatabase.php');
global $adb;
/**
addTableFiles("ec_account","oneweekbuy","int");
insertIntoField("ec_account","oneweekbuy","Accounts",1,"一周购买次数");
addTableFiles("ec_account","onemonthbuy","int");
insertIntoField("ec_account","onemonthbuy","Accounts",1,"一月购买次数");
addTableFiles("ec_account","threemonthbuy","int");
insertIntoField("ec_account","threemonthbuy","Accounts",1,"三月购买次数");
addTableFiles("ec_account","oneweeksendmess","int");
insertIntoField("ec_account","oneweeksendmess","Accounts",1,"一周发送短信次数");
addTableFiles("ec_account","onemonthsendmess","int");
insertIntoField("ec_account","onemonthsendmess","Accounts",1,"一月发送短信次数");
addTableFiles("ec_account","threemonthsendmess","int");
insertIntoField("ec_account","threemonthsendmess","Accounts",1,"三月发送短信次数");
addTableFiles("ec_account","oneweeksendmail","int");
insertIntoField("ec_account","oneweeksendmail","Accounts",1,"一周发送邮件次数");
addTableFiles("ec_account","onemonthsendmail","int");
insertIntoField("ec_account","onemonthsendmail","Accounts",1,"一月发送邮件次数");
addTableFiles("ec_account","threemonthsendmail","int");
insertIntoField("ec_account","threemonthsendmail","Accounts",1,"三月发送邮件次数");
addTableFiles("ec_account","lastsendmessdate","date");
insertIntoField("ec_account","lastsendmessdate","Accounts",5,"最新发送短信日期");
addTableFiles("ec_account","lastsendmaildate","date");
insertIntoField("ec_account","lastsendmaildate","Accounts",5,"最新发送邮件日期");
addTableFiles("ec_account","allsuccessbuy","int");
insertIntoField("ec_account","allsuccessbuy","Accounts",1,"总共成功购买次数");
**/
echo "OK!";
/**
* 给表添加字段
* @param $tableName 要添加字段的表名
* @param $add_filelds 字段名称
* @param $type 字段类型 默认 int
* @param $is_null 是否为空 默认 null
*/
function addTableFiles($tableName,$add_filelds,$type = "int",$size="30",$is_null = "null"){
global $adb;
if($tableName && $tableName != "" && $add_filelds && $add_filelds != ""){
if($type == "int"){
$fileldtype = "INT";
}else if($type == "string"){
$fileldtype = "VARCHAR( ".$size." ) CHARACTER SET utf8 COLLATE utf8_general_ci";
}else if($type == "varchar"){
$fileldtype = "VARCHAR( ".$size." ) ";
}else if($type == "price"){
$fileldtype = "DECIMAL( 19, 2 )";
}else if($type == "timestamp"){
$fileldtype = "timestamp";
}else if($type == "numeric"){
$fileldtype = "numeric( 18, 4 )";
}else if($type == "date"){
$fileldtype = "DATE";
}else if($type == "time"){
$fileldtype = "DATETIME";
}else if($type == "uniqueidentifier"){
$fileldtype = "uniqueidentifier";
}else if($type == "text"){
$fileldtype = "TEXT";
}else{
$fileldtype = "INT";
}
if($is_null == "null"){
$is_null = "NULL";
}else{
$is_null = "NOT NULL";
}
///
$query = "ALTER TABLE ".$tableName." ADD ".$add_filelds." ".$fileldtype." ".$is_null." ";
echo $query;
$adb->query($query);
return true;
}
return false;
}
/**
* 将一个字段插入到关联字段中去
* @param $tableName 要插入的表名
* @param $add_filelds 要插入的字段名
* @param $modues 表相关模块名
* @param $uitype 字段显示格式
* @param $labelName 字段描述
*/
function insertIntoField($tableName,$add_filelds,$modues,$uitype,$labelName){
global $adb;
$tabid = getTabid($modues);
$blockid = get_block_id($tabid);
$fieldid = $adb->getUniqueID("ec_field");
$query = "insert into ec_field values (".$tabid.",".$fieldid.",'".$add_filelds."','".$tableName."',1,'".$uitype."','".$add_filelds."','".$labelName."',1,0,0,100,5,".$blockid.",1,'V~O',1,'','BAS')";
echo $query."<br>";
$adb->query($query);
insertModuleProfile2field_1($tabid,$fieldid);
}
function insertModuleProfile2field_1($tab_id,$field_id)
{
global $adb;
$adb->query("insert into ec_def_org_field values (".$tab_id.",".$field_id.",0,1)");
$query = "SELECT * FROM ec_profile order by profileid";
$fld_result = $adb->query($query);
$num_rows = $adb->num_rows($fld_result);
for($i=0; $i<$num_rows; $i++)
{
$profileid = $adb->query_result($fld_result,$i,'profileid');
$adb->query("insert into ec_profile2field values (".$profileid.",".$tab_id.",".$field_id.",0,1)");
//$adb->query("insert into ec_profile2utility values (".$profileid.",".$tab_id.",11,0)");//approve permission
}
}
function get_block_id($tab_id)
{
global $adb;
$query = "SELECT blockid FROM ec_blocks where tabid=".$tab_id." order by blockid";
$fld_result = $adb->query($query);
$num_rows = $adb->num_rows($fld_result);
if($num_rows > 0)
{
$blockid = $adb->query_result($fld_result,0,'blockid');
return $blockid;
}
return 0;
}
function get_next_blockid() {
global $adb;
$query = "select max(blockid) as blockid from ec_blocks";
$result = $adb->query($query);
$block_id = $adb->query_result($result,0,"blockid") + 1;
return $block_id;
}
?>