public function searchDetails($params)
 {
     $query = UserActivities::find();
     $query->select('company_name,monthName,ym,y,sum(aktieve_dagen) as aktieve_dagen,contactperson_id')->groupBy('ym', 'company_name', 'monthName');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     if (!isset($params['monthName'])) {
         $params['monthName'] = '';
     }
     if (!isset($params['company_id'])) {
         $params['company_id'] = '';
     }
     $query->andFilterWhere(['monthName' => $params['monthName'], 'company_id' => $params['company_id']]);
     return $dataProvider;
 }
 /**
  * @param integer $cpid = contactperson_id
  * @param integer $a = active_dagen
  * @param integer $m = monthName
  * @throws NotFoundHttpException if the model cannot be found
  * return respons from zoho invoice creating
  */
 public function actionInv($cpid, $a, $m)
 {
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $UserInvoiceMdl = UserInvoice::findOne(['user_id' => $cpid]);
     $abonnementType = $query = UserActivities::find()->select("aktieve_dagen,full_name, monthName")->where("contactperson_id=" . $cpid . " and monthName =" . $m)->all();
     //print_r($query); exit;
     return \yii\helpers\Json::encode($query);
     exit;
     //haal contact persoon op
     $curl = new curl\Curl();
     $resp = $curl->setOption(CURLOPT_POSTFIELDS, http_build_query(array('')))->GET('https://invoice.zoho.com/api/v3/contacts/' . $UserInvoiceMdl->zoho_contact_id . '?authtoken=90545fa01029567ccd0ad3447cbf843c');
     $obj = json_decode($resp);
     // echo  $obj->contact->primary_contact_id; exit; //638713000000068053
     //echo $obj->contact_id; exit;
     $curl = new curl\Curl();
     $response = $curl->setOption(CURLOPT_POSTFIELDS, http_build_query(array('JSONString' => '{
                         "customer_id"="638713000000068045",
                         "template_id"="638713000000025001",
                         "line_items":[
                             {"item_id": "",
                             "name":"Jaar abonnement",
                             "item_name":"Jaar abonnement",
                             "status": "active",
                             "source": "user",
                             "is_linked_with_zohocrm": false,
                             "description": "Tarief voor P.adriaanse maand Juli 2015",
                             "rate": 0.41,
                             "quantity": 31.0,
                             "tax_id":"638713000000047019",
                             "tax_name": "BTW21","tax_percentage": 21
                             },
                             {"item_id": "",
                             "name":"Jaar abonnement",
                             "item_name":"Jaar abonnement",
                             "status": "active",
                             "source": "user",
                             "is_linked_with_zohocrm": false,
                             "description": "Tarief voor Arnord Zwagerman  Juli 2015",
                             "rate": 0.41,
                             "quantity": 28.0,
                             "tax_id":"638713000000047019",
                             "tax_name": "BTW21","tax_percentage": 21
                             }
                         ]
                         
                     }')))->POST('https://invoice.zoho.com/api/v3/invoices?authtoken=90545fa01029567ccd0ad3447cbf843c');
     return $response;
 }