Esempio n. 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $_key = $this->argument('key');
     $_blueprint = $this->argument('blueprint');
     $_file = $this->argument('file');
     $_creator = $this->argument('creator');
     $_header = escapeshellarg($this->argument('header'));
     $blueprint = Blueprint::find($_blueprint);
     if (!$blueprint) {
         Log::error("la encuesta con id: {$_blueprint} no se encontró");
         return;
     }
     $blueprint->sending_emails = 1;
     $blueprint->update();
     $counter = 0;
     Excel::load("storage/app/" . $_key . ".xlsx", function ($reader) use($blueprint, $counter, $_key, $_header) {
         $reader->each(function ($row) use($blueprint, $counter, $_key, $_header) {
             if (trim($row->correo) != "" && filter_var($row->correo, FILTER_VALIDATE_EMAIL)) {
                 $form_key = str_replace("/", "", Hash::make('blueprint' . $blueprint->id . $row->correo));
                 $applicant = Applicant::firstOrCreate(["blueprint_id" => $blueprint->id, "form_key" => $form_key, "user_email" => $row->correo, "temporal_key" => $_key]);
                 $path = base_path();
                 exec("php {$path}/artisan email:send {$applicant->id} {$_header} > /dev/null &");
                 $update = $blueprint->emails + 1;
                 $blueprint->emails = $update;
                 $blueprint->update();
             }
         });
     })->first();
     $total = Applicant::where("temporal_key", $_key)->count();
     $mailgun = new MailgunEmail(["blueprint" => $blueprint->id, "emails" => $total]);
     $mailgun->save();
     $blueprint->sending_emails = 0;
     $blueprint->update();
 }
Esempio n. 2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $_applicant = $this->argument('applicant');
     $_header = $this->argument('header');
     $applicant = Applicant::find($_applicant);
     Mail::send('email.invitation', ['applicant' => $applicant], function ($m) use($applicant, $_header) {
         $m->from('*****@*****.**', 'Tú Evalúas');
         $m->to($applicant->user_email, "amigo")->subject($_header);
     });
 }
Esempio n. 3
0
 public function resetSurvey(Request $request)
 {
     $applicant = Applicant::where('form_key', $request->input('form_key'))->first();
     if ($applicant) {
         return response()->json($applicant->answers()->delete());
     } else {
         return response()->json(false);
     }
 }
Esempio n. 4
0
 public function actionRecoveryHandler()
 {
     $arr['katalaluan'] = $_POST['katalaluan'];
     $arr['pengesahan_katalaluan'] = $_POST['pengesahan_katalaluan'];
     $model = new \yii\base\DynamicModel($arr);
     $model->addRule(['katalaluan', 'pengesahan_katalaluan'], 'required', ['message' => 'Medan {attribute} ini wajib diisi'])->addRule('katalaluan', 'compare', ['compareAttribute' => 'pengesahan_katalaluan', 'message' => 'Katalaluan dan Pengesahan Katalaluan Mestilah Sama'])->validate();
     $str = $_POST['str'];
     $app = \app\models\Applicant::findOne(['forgot_pwd' => $str]);
     if ($model->hasErrors()) {
         return $this->render('pwd_recovery', ['errors' => $model->getErrors(), 'app' => $app]);
     } else {
         $app->password = $_POST['katalaluan'];
         $app->confirm_password = $app->password;
         // need to re-arrange on rules
         $app->com_state2 = $app->com_state;
         if ($app->validate()) {
             $app->forgot_pwd = null;
             $app->save();
             \Yii::$app->session->setFlash('msg', 'Katalaluan telah berjaya ditukar');
             return $this->goHome();
         } else {
             //var_dump($app->getErrors());
             return $this->render('pwd_recovery', ['errors' => $app->getErrors(), 'app' => $app]);
         }
     }
 }