📄 db.inc.php
字号:
<?
/**
*
* Package Monitor Page
*
* OsoonCRM Project
* Copyright 2003-2004 (c)
* http://osooncrm.cosoft.org.cn/
*/
if (_DB_INC_PHP_ != 1):
define(_DB_INC_PHP_, 1);
//数据库信息, hostname, username, password
$mysql_host = "localhost";
$mysql_user = "root";
$mysql_pass = "";
//调用的数据库名称
$db_crm = "crm";
//数据库表
$tbl_crm_user = "user";
$tbl_crm_department = "department";
$tbl_crm_account = "crm_account";
$tbl_crm_account_human_scale = "crm_account_human_scale";
$tbl_crm_account_relationship = "crm_account_relationship";
$tbl_crm_account_type = "crm_account_type";
$tbl_crm_account_industry = "crm_account_industry";
$tbl_crm_account_year_revenue = "crm_account_year_revenue";
$tbl_crm_activity = "crm_activity";
$tbl_crm_contact = "crm_contact";
$tbl_crm_contact_folk = "crm_contact_folk";
$tbl_crm_expense = "crm_expense";
$tbl_crm_jieduan = "crm_jieduan";
$tbl_crm_project = "crm_project";
$tbl_crm_project_state = "crm_project_state";
$tbl_crm_slt_column = "crm_slt_column";
$tbl_crm_source = "crm_source";
$tbl_crm_tbl_column_explain = "crm_tbl_column_explain";
$tbl_crm_area = "crm_area";
$tbl_crm_expense_type = "crm_expense_type";
$tbl_crm_expense_name = "crm_expense_name";
$tbl_crm_attach = "crm_attach";
//附件保存原始路径
$upload_path = "/usr/local/www/htdocs/crm/attach/";
//连接数据库
$db=mysql_connect($mysql_host, $mysql_user, $mysql_pass);
if (!isset($db)) {
echo "连接数据库出错,请检查...";
exit;
}
mysql_select_db("$db_crm");
////////////////////////////////////////////////////////
// 用户下属员工(包括自己)的用户ID列表
//$list_crm_uid = $G_uid.",";
//$list_crm_uid = substr($list_crm_uid, 0, -1);
////////////////////////////////////////////////////////
//用户下属员工(包括自己)的用户ID列表
//获得下属的部门(包括本部门)的列表
function Department_dir($deptid) {
global $list_crm_deptid;
global $tbl_crm_department;
$list_crm_deptid .= $deptid.",";
$sql = "select departmentid from $tbl_crm_department where parent_id='$deptid'";
$res = mysql_query($sql);
$num = @mysql_num_rows($res);
if (!$num) return;
while ($row=@mysql_fetch_array($res)) {
$deptid = $row[0];
Department_dir($deptid); // 递归
}
}
$list_crm_uid = "";
//总经理或部门经理可以查看的下属部门的所有员工的列表
if ($privilege>0 || $departmentid==1) {
$list_crm_deptid = "";
$dept_id = $privilege; //部门权限
if ($departmentid==1) $dept_id = $departmentid; // 总经理特权
Department_dir($dept_id);
$list_crm_deptid = substr($list_crm_deptid, 0, -1);
$sql = "select * from $tbl_crm_user where departmentid in ($list_crm_deptid)";
$res = mysql_query($sql);
while ($row=@mysql_fetch_array($res)) {
$list_crm_uid .= $row[uid].",";
}
} else {
$list_crm_uid .= $G_uid.",";
}
$list_crm_uid = substr($list_crm_uid, 0, -1);
//========================================================================
// 用户下属员工(包括自己)的客户ID列表(共享的客户ID也在里面)
//========================================================================
$sql_tmp = "select AccountId from $tbl_crm_account where AccountOwnerID in ($list_crm_uid) or Shared='1'";
//echo $sql_tmp;
$res_tmp = @mysql_query($sql_tmp);
$list_crm_aid = "";
while ($row_tmp=@mysql_fetch_array($res_tmp))
{
$list_crm_aid .= $row_tmp[0].",";
}
unset($sql_tmp);
$list_crm_aid = substr($list_crm_aid, 0, -1);
//可以看到的项目:可以查看
$where_account_view = " AccountID in ($list_crm_aid) ";
//用户的客户ID列表
$sql_tmp = "select AccountId from $tbl_crm_account where AccountOwnerID='$G_uid'";
$res_tmp = @mysql_query($sql_tmp);
$list_crm_aid_self = "";
while ($row_tmp=@mysql_fetch_array($res_tmp))
{
$list_crm_aid_self .= $row_tmp[0].",";
}
unset($sql_tmp);
$list_crm_aid_self = substr($list_crm_aid_self, 0, -1);
//自己的项目:可以操作
$where_account_self = " AccountID in ($list_crm_aid_self) ";
endif;
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -