本文整理汇总了PHP中get_current_company_id函数的典型用法代码示例。如果您正苦于以下问题:PHP get_current_company_id函数的具体用法?PHP get_current_company_id怎么用?PHP get_current_company_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_current_company_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _after_insert
protected function _after_insert($id)
{
// 线索、客户、商机等上次联系时间,更新
if (I('post.crm_clue_id')) {
// 线索
$related_id = I('post.crm_clue_id');
$model = "Crm/CrmClue";
} else {
if (I('post.customer_id')) {
// 客户
$related_id = I('post.customer_id');
$model = "Crm/Customer";
}
}
if ($model && $id) {
D($model)->where(array('id' => $id, 'company_id' => get_current_company_id()))->save(array('last_contact_time' => date('Y-m-d H:i:s')));
}
if (I('post.next_contact_time') && I('post.next_contact_content') && $related_id) {
// 更新日程
if (AppService::is_app_active('calendar')) {
$event_service = D('Calendar/Events');
$event_service->create(['subject' => I('post.next_contact_content'), 'type' => 'info', 'start_at' => I('post.next_contact_time'), 'end_at' => I('post.next_contact_time'), 'related_model' => $this->module_alias, 'related_id' => $related_id]);
$event_service->add();
}
}
}
示例2: update_customer_head
public function update_customer_head($ids, $uid)
{
if (!$ids) {
return;
}
$company_id = get_current_company_id();
// 原始数据
$source = array();
if (!$uid) {
$source = $this->where(array('id' => array("IN", $ids)))->select();
$source = get_array_to_kv($source, 'user_id', 'id');
}
// 往来单位
$contacts_company = D('ContactsCompany/ContactsCompany', 'Service')->where(array('id' => array("IN", $ids)))->select();
$contacts_company = get_array_to_ka($contacts_company);
foreach ($ids as $id) {
$map = array('contacts_company_id' => $id, 'company_id' => $company_id);
$exists = $this->where($map)->find();
if ($exists) {
// 已存在更新负责人ID
$this->where($map)->save(array('head_id' => $uid));
} else {
// 不存在新增一条
$data = array('contacts_company_id' => $id, 'head_id' => $uid, 'user_id' => $uid, 'crm_clue_id' => null, 'company_id' => $company_id, 'source_from' => $contacts_company[$id]['source_form']);
$this->add($data);
}
}
$head_model = D('Crm/CustomerHeadLog');
$type = $uid ? 1 : 2;
foreach ($ids as $id) {
$user_id = $uid ? $uid : $source[$id];
$head_model->add(array('type' => $type, 'company_id' => $company_id, 'customer_id' => $id, 'user_id' => $user_id));
}
return true;
}
示例3: on_list
public function on_list()
{
$data = parent::on_list(true);
$actives = D('Home/CompanyActiveApps')->where(['company_id' => get_current_company_id()])->select();
$actives = get_array_by_field($actives, 'app_id');
$cleared_list = [];
$i = 0;
foreach ($data[1] as $k => $v) {
// 根据是否启用状态过滤
if (false !== $this->filter_only_active_status) {
if ($this->filter_only_active_status > 0 && !in_array($v['id'], $actives)) {
continue;
}
if ($this->filter_only_active_status < 1 && in_array($v['id'], $actives)) {
continue;
}
}
$cleared_list[$i] = $v;
if (in_array($v['id'], $actives)) {
$cleared_list[$i]['is_active'] = true;
} else {
$cleared_list[$i]['is_active'] = false;
}
$i++;
}
$data[1] = $cleared_list;
$this->response($data, 'app', true);
}
示例4: authorize
public function authorize($role_id, $nodes)
{
$data = array();
$included_id = array(0);
$authed_nodes = get_array_to_kv($this->get_authed_nodes_by_role($role_id), 'flag', 'auth_node_id');
foreach ($nodes as $node) {
if ($node['node']) {
$included_id[] = $node['node'];
}
// 在已授权列表中
if (array_key_exists($node['node'], $authed_nodes) && $authed_nodes[$node['node']] == $node['flag']) {
continue;
}
array_push($data, array('auth_node_id' => $node['node'], 'flag' => $node['flag'], 'auth_role_id' => $role_id, 'company_id' => get_current_company_id()));
}
$this->where(array('auth_node_id' => array('NOT IN', $included_id), 'auth_role_id' => $role_id))->delete();
if (!$data) {
return true;
}
foreach ($data as $k => $v) {
if (!$v['auth_node_id']) {
continue;
}
if (!$this->add($v)) {
$this->error = $this->getLastSql();
return false;
}
}
return true;
}
示例5: on_read
public function on_read()
{
list($id, $hash) = explode('_', I('get.hash'));
if ($hash) {
session(array('id' => $hash, 'expire' => 600));
session('[start]');
}
$file = D('Attachment')->where(array('company_id' => get_current_company_id(), 'id' => $id))->find();
if (!$file) {
return $this->httpError(404);
}
// 完整带协议地址(远程附件)
if (substr($file['real_url'], 0, 1) !== '/') {
} else {
$real_path = ENTRY_PATH . '/uploads' . $file['real_url'];
if (is_file($real_path)) {
$desc = substr($file['file_mime'], 0, 5) === 'image' ? '' : 'attachment';
header('Content-Type:' . $file['file_mime']);
header("Accept-Ranges: bytes");
header("Accept-Length: " . $file['file_size']);
header("Content-Disposition: {$desc}; filename=" . $file['source_name']);
readfile($real_path);
} else {
$this->httpError(404);
}
}
}
示例6: where
public function where($map, $parse = null)
{
if (!$this->not_belongs_to_company && !$map['id']) {
$map["company_id"] = get_current_company_id();
}
return parent::where($map, $parse);
}
示例7: where
public function where($map, $parse = null)
{
if (!$this->not_belongs_to_company) {
$this->real_model_name = $this->real_model_name ? $this->real_model_name : $this->getModelName();
$map[$this->real_model_name . ".company_id"] = get_current_company_id();
}
return parent::where($map, $parse);
}
示例8: disable
public function disable($alias)
{
$apps_info = $this->where(array('alias' => array('IN', $alias)))->select();
if (!$apps_info) {
return true;
}
$model = D('Account/CompanyActiveApps');
return $model->where(array('app_id' => array('IN', get_array_to_kv($apps_info, 'id')), 'company_id' => get_current_company_id()))->delete();
}
示例9: DBC
function DBC($alias = null)
{
$cache_key = "db_config_" . get_current_company_id();
$cached = S($cache_key);
if (DEBUG || !$cached) {
$cached = D('Home/Config', 'Service')->get_kv_config();
$cached = get_array_to_kv($cached, 'val', 'alias');
S($cache_key, $cached);
}
return $alias ? $cached[$alias] : $cached;
}
示例10: get_kv_config
public function get_kv_config($alias = null)
{
$cache_key = 'kv_db_configs/' . get_current_company_id();
$cached = S($cache_key);
if (DEBUG || !$cached) {
$source = $this->select();
$cached = array();
foreach ($source as $row) {
$cached[$row['alias']] = $row;
}
S($cache_key, $cached);
}
return $alias ? $cached[$alias] : $cached;
}
示例11: on_list
public function on_list()
{
$data = parent::on_list(true);
$actives = D('Home/CompanyActiveApps')->where(['company_id' => get_current_company_id()])->select();
$actives = get_array_by_field($actives, 'app_id');
foreach ($data[1] as $k => $v) {
if (in_array($v['id'], $actives)) {
$data[1][$k]['is_active'] = true;
} else {
$data[1][$k]['is_active'] = false;
}
}
$this->response($data, 'app', true);
}
示例12: do_delete
public function do_delete($ids)
{
if (!$ids) {
return;
}
$map = array('id' => array('IN', $ids), 'company_id' => get_current_company_id());
$files = $this->where($map)->select();
foreach ($files as $file) {
if (substr($file['real_url'], 0, 1) === '/') {
$local_path = $this->get_local_path($file['real_url']);
is_file($local_path) && @unlink($local_path);
}
}
$this->where($map)->delete();
}
示例13: insert
public function insert($source_id, $data = array(), $fields = array(), $modelName)
{
$data = $data ? $data : I('post.');
if (!$fields) {
$fields = explode(",", I('post._data_model_fields_'));
}
if (!$fields) {
return;
}
$fields_config = D('DataModelField', 'Service')->where(array('id' => array('IN', $fields)))->select();
$company_id = get_current_company_id();
foreach ($fields_config as $config) {
if (array_key_exists($config['alias'], $data)) {
$insert_data_model_data = array('source_id' => $source_id, 'data_model_field_id' => $config['id'], 'data' => $data[$config['alias']], 'company_id' => $company_id);
}
$table = $config['search_able'] > 0 ? 'data_model_data_search' : 'data_model_data';
$this->table($table)->add($insert_data_model_data, array(), true);
}
}
示例14: on_post
public function on_post()
{
if (!I('get.is_push')) {
return parent::on_post();
}
$_GET['id'] = I('get.opp_id');
// print_r(I('get.id'));exit;
$rs = parent::on_put();
if (false !== $rs && I('get.is_push')) {
// 写客户沟通日志
$stage = D('Home/CommonType')->where(array('id' => I('post.status')))->getField('name');
$source = D('Marketing/SaleOpportunities')->find(I('get.id'));
$content = sprintf(__('marketing.Push Opportunities To %s Stage'), '`' . $stage . '`');
$content .= "\n\n";
$content .= I('post.push_remark');
$model = D('Crm/CustomerCommunicate');
$model->add(array('content' => $content, 'created' => I('post.last_contact_time'), 'sale_opportunities_id' => I('get.id'), 'customer_id' => $source['customer_id'], 'company_id' => get_current_company_id(), 'user_id' => get_current_user_id()));
// echo $model->getLastSql();
}
}
示例15: add_child
public function add_child($pid, $source_data, $table)
{
$parent = $this->find($pid);
if (!$parent) {
return false;
}
$company_id = get_current_company_id();
/**
* 更新右值
*/
$map = array("rgt" => array("EGT", $parent["rgt"]), "company_id" => $company_id);
$this->startTrans();
$rs = $this->where($map)->setInc('rgt', 2);
if (false === $rs) {
$this->rollback();
return false;
}
/**
* 更新左值
*/
$map = array("lft" => array("EGT", $parent["rgt"]), "company_id" => $company_id);
$rs = $this->where($map)->setInc('rgt', 2);
if (false === $rs) {
$this->rollback();
return false;
}
/**
* 插入新值
*/
$data = array("lft" => $parent["rgt"], "rgt" => $parent["rgt"] + 1, "company_id" => $company_id);
foreach ($source_data as $k => $v) {
$data[$k] = $v;
}
$rs = $this->table($table)->add($data);
if (!$rs) {
$this->rollback();
return false;
}
$this->commit();
return $rs;
}