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);
 }
 public function on_put()
 {
     if (I('post.action') == 'update_head') {
         $uid = I('post.uid') === "null" ? null : I('post.uid');
         if (false !== D('Crm/CrmClue', 'Service')->update_clue_head(I('post.clue_id'), $uid)) {
             $this->success(__('common.Operation Success'));
         }
         return;
     }
     parent::on_put();
 }
 public function on_read()
 {
     $user_info = parent::on_read(true);
     $auth_user_role_model = D("AuthUserRole");
     $roles = $auth_user_role_model->where(['user_id' => $user_info['id']])->select();
     $user_info['auth_role_id'] = [];
     foreach ($roles as $role) {
         array_push($user_info['auth_role_id'], (int) $role['auth_role_id']);
     }
     $this->response($user_info, 'user', true);
 }
Exemple #4
0
 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);
 }
Exemple #5
0
 public function on_list()
 {
     $data = parent::on_list(true);
     $list = $data[1];
     $product_ids = get_array_by_field($list, 'product_id');
     $map = ['product_id' => ['IN', $product_ids]];
     $total_balance = D('Storage/Stock')->field('SUM(balance) as total_balance, product_id, product_unique_id')->where($map)->group('product_unique_id')->select();
     $total_balance = get_array_to_ka($total_balance, 'product_unique_id');
     foreach ($list as $k => $v) {
         if (array_key_exists($v['product_unique_id'], $total_balance)) {
             $list[$k]['total_balance'] = $total_balance[$v['product_unique_id']]['total_balance'];
         }
     }
     $data[1] = reIndex($list);
     $this->response($data, 'stock', true);
 }
 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();
     }
 }
 public function on_list()
 {
     $data = parent::on_list(true);
     switch (I('get._mf')) {
         case "ContactsCompany.id":
             $head_log = D('Crm/CustomerHeadLog', 'Model')->get_by_customer(I('get._mv'), true);
             break;
         case "crm_clue_id":
         default:
             return $this->response($data, 'customer_communicate', true);
     }
     if ($head_log) {
         foreach ($head_log as $k => $v) {
             $head_log[$k]['content'] = __('crm.Customer Head Log Type ' . $v['type']);
         }
         $data = array_merge((array) $data, $head_log);
         // 按时间排序
         $data = multi_array_sort($data, 'created', SORT_DESC);
     }
     return $this->response($data, 'customer_communicate', true);
 }
 public function on_list()
 {
     $data = parent::on_list(true);
     $list = $data[1];
     $progress_model = D('Bpm/WorkflowProgress');
     $data[1] = $progress_model->assign_last_progress_to_list($list);
     $this->response($data, D($this->main_model));
 }
Exemple #9
0
 public function on_read()
 {
     $data = parent::on_read(true);
     $model = D("AuthUserRole");
 }