Exemplo n.º 1
0
 public function newsletter()
 {
     $action = $_GET['action'];
     $newsletter_model = new \models\newsletter();
     $user_model = new \models\users();
     $this->data['subscribers'] = $newsletter_model->byGroup();
     $this->data['title'] = 'Newsletter';
     if (isset($_POST) && !empty($_POST)) {
         $group = $_POST['subscribers'];
         $content = $_POST['content'];
         $subject = $_POST['subject'];
         //$slug = \helpers\url::generateSafeSlug($pagename);
         $subscribers = $newsletter_model->get(array('group' => $group));
         $mail_helper = new \helpers\phpmailer\mail();
         foreach ($subscribers as $item) {
             $mail_helper->template('newsletter');
             $mail_helper->newsletter($item->email, $subject, $content);
         }
         $this->data['success'] = 'Mails Sent!';
     }
     View::rendertemplate('home_header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('crm/newsletter', $this->data);
     View::rendertemplate('footer', $this->data);
 }
Exemplo n.º 2
0
 public function signup($slug = null)
 {
     $this->data['title'] = 'Join Us';
     // $module_slug = $slug[0];
     $role = new \models\userrole();
     $user = new User();
     $this->data['user_role'] = $role->all();
     //PULL DATA FROM SITESETTINGS
     $document = new \Helpers\Document();
     $details = $document->siteSettings();
     //GET NEW USER STATUS ID
     $this->model->table('user_status');
     $user_status = $this->model->get_row(array("title" => "inactive"));
     $this->data['reg_form'] = $details['reg_form'];
     if (isset($_POST) && !empty($_POST)) {
         if ($_POST['password'] == $_POST['password2']) {
             $encrypted = md5($_POST['password']);
             $row_count = $user->get(array("email" => $_POST['email']));
             if (count($row_count) >= 1) {
                 $this->data['error'] = 'Email exists in our records, please use a different email';
             } else {
                 $insert_array = array('firstname' => $_POST['fname'], 'lastname' => $_POST['lname'], 'email' => $_POST['email'], 'password' => $encrypted, 'role' => $_POST['role'], 'status' => $user_status->id);
                 $hash = $user->register($insert_array);
                 if ($hash != '') {
                     //SEND ACCOUNT DETAILS TO USER
                     $fullname = $_POST['fname'] . ' ' . $_POST['lname'];
                     $subject = 'New Account';
                     $mail = new \helpers\phpmailer\mail();
                     $mail->template('welcome');
                     $mail->generalEmail($_POST['email'], $subject, $fullname, $hash);
                     $this->data['success'] = 'A link has been sent to your email, please click to activate your account';
                 } else {
                     $this->data['error'] = 'Operation Fails, Please contact admin';
                 }
             }
         } else {
             $this->data['error'] = 'Password does not match!';
         }
     }
     View::rendertemplate('header', $this->data);
     View::render('account/signup', $this->data);
     View::rendertemplate('footer', $this->data);
 }