/** * Confirm email */ public function actionConfirm($key) { /** @var \amnah\yii2\user\models\UserKey $userKey */ /** @var \amnah\yii2\user\models\User $user */ // search for userKey $success = false; $userKey = Yii::$app->getModule("user")->model("UserKey"); $userKey = $userKey::findActiveByKey($key, [$userKey::TYPE_EMAIL_ACTIVATE, $userKey::TYPE_EMAIL_CHANGE]); if ($userKey) { // confirm user $user = Yii::$app->getModule("user")->model("User"); $user = $user::findOne($userKey->user_id); $user->confirm(); // add contact information to zoho invoices $resp = $this->addZoHoContact($user); $obj = json_decode($resp); // als er geen invoice kan worden aangemaakt verzend dan email. if (!isset($obj)) { $user->sendEmailWhenError($userKey, 'Er kan voor deze nieuwe aanmelder geen Invoice worden aangemaakt. Zie zoho'); //throw new NotFoundHttpException('Er kan geen inv. aangemaakt worden foutcode(zhinv)'); } else { $invoice = new UserInvoice(); $invoice->user_id = $user->id; $invoice->zoho_contact_id = $obj->contact->contact_id; $invoice->save(false); $activedays = new UserActivedays(); $activedays->user_id = $user->id; $activedays->save(false); } // consume userKey and set success $userKey->consume(); $success = $user->email; } // render return $this->render("confirm", ["userKey" => $userKey, "success" => $success]); }
/** * @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; }