Пример #1
0
 function update($params)
 {
     $c = $this->updated_companies[0];
     $c->save();
     Render::msg($c->getName() . ' Updated.');
     $this->redirectTo(array('controller' => 'Company', 'action' => 'show', 'id' => $c->id));
 }
Пример #2
0
 function destroy($params)
 {
     $params['id'] ? $clientuser = new ClientUser($params['id']) : bail('no company selected');
     $name = $clientuser->getName();
     $clientuser->destroy();
     Render::msg($name . ' Deleted.', 'bad');
     $this->redirectTo(array('controller' => 'ClientUser', 'action' => 'index'));
 }
Пример #3
0
 function update($params)
 {
     $staff = $this->updated_staffs[0];
     if (!empty($params['new_password'])) {
         Render::msg('Password Changed');
         $staff->setPassword($params['new_password']);
     }
     $staff->save();
     $this->redirectTo(array('controller' => 'Staff', 'action' => 'show', 'id' => $staff->id));
 }
Пример #4
0
 function create($params)
 {
     $p = $this->new_payments[0];
     $p->save();
     if ($params['noemail'] == 1) {
         Render::msg('No Email Sent');
     } else {
         $p->sendEmail();
     }
     isset($params['redirect']) ? $redirect = $params['redirect'] : ($redirect = array('controller' => 'Payment', 'action' => 'index'));
     $this->redirectTo($redirect);
     Render::msg('Payment Saved');
 }
Пример #5
0
 function create_session($params)
 {
     $email = $params['email'];
     $password = sha1($params['password']);
     // search for users in this order
     $user_classes = array('ClientUser', 'Staff');
     foreach ($user_classes as $user_class) {
         $user = $user_class::getOne(array('email' => $email, 'password' => $password));
         if ($user) {
             Session::startSession($user->id, $user->getUserType());
             if ($user_class == 'Staff') {
                 $this->redirectTo(array('controller' => 'Staff', 'action' => 'show', 'id' => $user->id));
             } else {
                 if ($user_class == 'ClientUser') {
                     $this->redirectTo(array('controller' => 'Client', 'action' => 'index'));
                 }
             }
             return;
         }
     }
     // no user found
     Render::msg('Invalid Email or Password', 'bad');
     $this->redirectTo(array('controller' => 'Authenticate', 'action' => 'login', 'email' => $email));
 }
Пример #6
0
 function sendEmail()
 {
     //if(!isset($this->id)) bail("must haz id to do that!");
     $d = new PHP5_Accessor();
     $d->payment = $this;
     $d->company = $this->getCompany();
     $r = getRenderer();
     $htmlcontent = $r->view('paymentReceiptEmail', $d);
     $plaincontent = $r->view('paymentReceiptEmailPlain', $d);
     $email_address = $this->getBillingEmailAddress();
     $subject = 'Radical Designs Payment Receipt ' . Util::pretty_date($this->get('date'));
     $boundary = "nextPart";
     $headers = 'From: ' . BILLING_EMAIL_ADDRESS . "\r\n";
     $headers .= "MIME-Version: 1.0\r\n";
     $headers .= "Content-Type: multipart/alternative; boundary = {$boundary}\r\n\r\n";
     $headers .= "This is a MIME encoded message.\r\n\r\n";
     $headers .= "\r\n--{$boundary}\r\n";
     // beginning \n added to separate previous content
     $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
     $headers .= $plaincontent;
     $headers .= "\r\n\r\n--{$boundary}\r\n";
     $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
     $headers .= $htmlcontent;
     $email_sent = mail($email_address, $subject, "", $headers);
     if ($email_sent) {
         Render::msg('Email Sent');
     } else {
         Render::msg('Email Failed To Send', 'bad');
     }
 }
Пример #7
0
 function sendEmail()
 {
     if (!isset($this->id)) {
         bail("must haz id to do that!");
     }
     //trigger_error('Invoice #'.$this->id.' preparing to send email');
     $d = new PHP5_Accessor();
     $d->invoice = $this;
     $d->company = $this->getCompany();
     $r = getRenderer();
     $htmlcontent = $r->view('invoiceEmail', $d);
     $plaincontent = $r->view('invoiceEmailPlain', $d);
     $email_address = $this->getBillingEmailAddress() . $this->getAdditionalRecipients();
     if ($this->getType() == 'dated') {
         $subject = 'Radical Designs Invoice ' . Util::pretty_date($this->get('end_date'));
     } else {
         $subject = 'Radical Designs Invoice ' . Util::pretty_date($this->get('date'));
     }
     $boundary = "nextPart";
     $headers = 'From: ' . BILLING_EMAIL_ADDRESS . "\n";
     $headers .= "MIME-Version: 1.0\n";
     $headers .= "Content-Type: multipart/alternative; boundary = {$boundary}\n\n";
     $headers .= "This is a MIME encoded message.\n\n";
     $headers .= "\n--{$boundary}\n";
     // beginning \n added to separate previous content
     $headers .= "Content-type: text/plain; charset=iso-8859-1\n";
     $headers .= $plaincontent;
     $headers .= "\n\n--{$boundary}\n";
     $headers .= "Content-type: text/html; charset=iso-8859-1\n";
     $headers .= $htmlcontent;
     $email_sent = mail($email_address, $subject, "", $headers);
     if ($email_sent) {
         $this->set(array('sent_date' => Util::date_format(), 'status' => 'sent'));
         Render::msg('Email Sent');
     } else {
         $this->set(array('status' => 'failed'));
         Render::msg('Email Failed To Send', 'bad');
     }
     $this->save();
 }