コード例 #1
0
 /**
  * Get All User List for Searching with ajax in select2 widget
  * @param  char $search 	query search
  * @param  integer $id 		id of user
  * @return array         	['user_id'=>'User Profile Name']
  **/
 public function actionSearchUser($search = null, $id = null)
 {
     $out = ['more' => false];
     $q = new Query();
     if (!is_null($search)) {
         $q->select('usr.id, prf.name as text')->from(ResUsers::tableName() . ' as usr')->leftJoin(ResPartner::tableName() . ' prf', 'prf.id=usr.partner_id')->where('LOWER(prf.name) LIKE :search OR LOWER(usr.login) like :search')->addParams([':search' => '%' . strtolower($search) . '%']);
         $users = $q->createCommand()->queryAll();
         $out['results'] = array_values($users);
     } elseif ($id > 0) {
         $out['results'] = ['id' => $id, 'text' => ResUsers::find()->where(['id' => $id])->with('partner')->one()->partner->name];
     } else {
         $out['results'] = ['id' => 0, 'text' => 'No matching records found'];
     }
     echo Json::encode($out);
 }
コード例 #2
0
 /**
  * [getCustomerActivityCompositionByCustomer description]
  * @param  integer $partner_id [description]
  * @param  string $type       [description]
  * @return array             [description]
  */
 private function getCustomerActivityCompositionByCustomer($partner_id, $type = 'pie')
 {
     $plan = SalesActivityPlan::find();
     $plan->select('res_partner.name, count(sales_activity_plan.user_id) as cout')->leftJoin(ResUsers::tableName(), 'res_users.id=sales_activity_plan.user_id')->leftJoin(ResPartner::tableName(), 'res_partner.id=res_users.partner_id')->where('sales_activity_plan.actual_partner_id = :actual_partner_id')->addParams([':actual_partner_id' => $partner_id])->groupBy(['res_partner.name']);
     $series = [];
     foreach ($plan->createCommand()->queryAll() as $idx => $act) {
         $series[$idx] = ['name' => $act['name'], 'y' => floatval($act['cout'])];
     }
     return $series;
 }
コード例 #3
0
 public function actionGetAllUserList($search = null, $id = null)
 {
     $out = ['more' => false];
     $q = new \yii\db\Query();
     if (!is_null($search)) {
         $q->select('usr.id, prf.name as text')->from(ResGroups::tableName() . ' rg')->leftJoin(ResGroupsUsersRel::tableName() . ' rgu', 'rgu.gid = rg.id')->leftJoin(ResUsers::tableName() . ' usr', 'usr.id=rgu.uid')->leftJoin(ResPartner::tableName() . ' prf', 'prf.id=usr.partner_id')->where('rg.name like :rgName')->addParams([':rgName' => 'All Sales User'])->andWhere('LOWER(prf.name) LIKE :search', [':search' => '%' . strtolower($search) . '%']);
         $users = $q->createCommand()->queryAll();
         // var_dump($q->createCommand()->sql);
         $out['results'] = array_values($users);
     } elseif ($id > 0) {
         $out['results'] = ['id' => $id, 'text' => ResUsers::find()->where(['id' => $id])->with('partner')->one()->partner->name];
     } else {
         $out['results'] = ['id' => 0, 'text' => 'No matching records found'];
     }
     echo \yii\helpers\Json::encode($out);
 }