Beispiel #1
0
 /**
  * Returns an object of Subs_Rowset of subs belonging to this brand
  *
  * @return object $this->_subs Subs_Rowset
  */
 public function subs()
 {
     if (!$this->_subs) {
         $subModel = Base::getModel('Subs');
         $select = $subModel->select()->where('brand_id = ?', $this->id);
         $this->_subs = $subModel->fetchAll($select);
     }
     return $this->_subs;
 }
 /**
  * Display list of ACL Roles in the system.
  */
 public function indexAction()
 {
     $request = $this->getRequest();
     $acrModel = Base::getModel('AclRoles');
     $where = $acrModel->select()->order('id ASC');
     $paginator = Zend_Paginator::factory($where);
     $paginator->setItemCountPerPage(10);
     $paginator->setCurrentPageNumber($request->getParam('page'));
     $aclroles = $paginator;
     $this->view->aclroles = $aclroles;
 }
 /**
  * Controller action to list brand code
  */
 public function indexAction()
 {
     $user = $this->loggedInUser();
     $request = $this->getRequest();
     $brnModel = Base::getModel('Brands');
     $select = $brnModel->select();
     $license_id = $request->getParam('license-id');
     if ($license_id) {
         $select->where('license_id = ?', $license_id);
     }
     $paginator = Zend_Paginator::factory($select);
     $paginator->setItemCountPerPage(10);
     $paginator->setCurrentPageNumber($request->getParam('page'));
     $brands = $paginator;
     $this->view->brands = $brands;
     $this->view->licenses = $user->licenses();
     // generate the license options
     $this->view->license_options = array_merge(array('' => 'All'), $user->licenses()->inSelect());
 }
 function createDuplicateOrderAction()
 {
     // init paramaters
     $request = $this->getRequest();
     $user = $this->loggedInUser();
     // get the order records
     $order_number = $request->getParam('order_number');
     if ($order_number) {
         $ordModel = Base::getModel('Common_Orders');
         $select = $ordModel->select()->where('order_number = ?', $order_number);
         $order = $ordModel->fetchRow($select);
         if (!$order) {
             $this->addFlash('Invalid order', 'errors');
             return;
         }
     }
     $cart = Modules_Client_Cart::getInstance();
     $cart->setStorage('session');
     $cart->setCommonUserId($order->common_user_id);
     $duplicate_order_params = $cart->getDuplicateOrderParams();
     if (isset($duplicate_order_params['common_user_id'])) {
         $cuModel = Base::getModel('Common_Users');
         $common_user = $cuModel->fetchById($duplicate_order_params['common_user_id']);
     }
     $order_id = $cart->toOrder();
     if ($common_user->order_notify == 1) {
         $common_user->confirmemail($order_id);
     }
     //$this->log()->log('Order ID: ' .$order_id . ' : ' . $_SERVER['HTTP_USER_AGENT'] , Zend_Log::INFO);
     // clear the cart here
     $cart->clear();
     // redirect to payment option page
     $this->_redirect('/common/orders/edit/id/' . $order_id, array('exit' => true));
 }
Beispiel #5
0
 /**
  * subscribe this use to the newsletter
  *
  * @return null
  */
 public function subscribeNewsletter()
 {
     // check if the user is already subscribed
     $subscription = $this->newsletterRecord();
     if ($subscription) {
         $subscription->resubscribe($this->first_name);
     } else {
         // create a new record
         $data = array('email' => $this->email, 'common_user_id' => $this->id, 'first_name' => $this->first_name, 'sub_id' => $this->sub_id);
         $nwlModel = Base::getModel('Newsletter');
         $created = $nwlModel->process($data, 'insert');
     }
     return;
 }
Beispiel #6
0
 /**
  * returns any un-used shipping records from this order. This is mainly based on any shipping that
  * belongs to this order but not assigned to any items and not marked as sent.
  *
  * @return object $unusedShipping Common_Orders_Shipping_Rowset
  */
 public function unUsedShipping()
 {
     // get all unused shipping
     $cosModel = Base::getModel('Common_Orders_Shipping');
     $select = $cosModel->select()->where('common_order_id = ?', $this->id)->where('date_sent IS NULL')->order('id DESC');
     // define and exclude assigned item shippings
     $db = Zend_Registry::get('db');
     $sql = $db->quoteInto("SELECT common_order_shipping_id FROM common_items WHERE common_order_id = ?", $this->id);
     $item_shipping_ids = $db->fetchCol($sql);
     if (!empty($item_shipping_ids)) {
         $select->where('id NOT IN (?)', $item_shipping_ids);
     }
     $shippings = $cosModel->fetchAll($select);
     return $shippings;
 }
#!/usr/bin/php5
<?php 
// include required files
include_once 'script_bootstrap.php';
// create new discount (certificate) record
$cdModel = Base::getModel('Client_Discounts');
$options = array('date_start' => '2012-11-01', 'date_end' => '2013-01-30');
// 139 vouchers with $30 value, Expiry date of 30/1/13
for ($count = 0; $count <= 139; $count++) {
    $discount = $cdModel->createNewGiftPackDiscount(NULL, 'PROMO $30', 1, 30.0, $options);
    $discount->generateGiftpackPDF();
    echo $discount->id . "\n";
}
// 40 vouchers with $25 value, Expiry date of 30/1/13
for ($count = 0; $count <= 40; $count++) {
    $discount = $cdModel->createNewGiftPackDiscount(NULL, 'PROMO $25', 1, 25.0, $options);
    $discount->generateGiftpackPDF();
    echo $discount->id . "\n";
}
echo "\nDone.\n";
 public function clearCartAction()
 {
     $request = $this->getRequest();
     $user_id = $request->getParam('user_id');
     $cuModel = Base::getModel('Common_Users');
     $select = $cuModel->select()->where('id = ?', $user_id);
     $common_user = $cuModel->fetchRow($select);
     $common_user->cart_data = '';
     $common_user->sub_id = $request->getParam('sub_id');
     $common_user->save();
     $this->addFlash('The cart data is cleared.', 'notice');
     $this->_redirect('/common/users/edit/id/' . $user_id, array('exit' => true));
 }
 public function pendingOrdersAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     $this->getResponse()->setHeader('Content-Type', 'text/html');
     $cache = Zend_Registry::get('cache');
     $date_start = date('Y-m-d') . ' 00:00:00';
     $date_end = date('Y-m-d') . ' 23:59:59';
     $key = __METHOD__ . '_' . $date_start . '_' . $date_end . '_' . 'pendingOrders';
     $cache_key = Base_Utils_String::slug($key);
     if ($cache_date_end < date('Y-m-d', time()) && ($result = $cache->load($cache_key))) {
         $this->getResponse()->setBody(Zend_Json::encode($result));
         return;
     }
     // init variables
     $coModel = Base::getModel('Common_Orders');
     $select = $coModel->select()->setIntegrityCheck(false)->from(array('co' => 'common_orders'), array('count' => 'count(co.id)'))->where("co.status = 'PENDING'");
     $order = $coModel->fetchRow($select);
     if (!$order) {
         $result['errcode'] = 1;
         $result['errmsg'] = "errmsg";
     } else {
         $result = array('errcode' => 0, 'errmsg' => 'OK', 'data' => $order->count, 'link' => '/common/orders?status=PENDING');
         $cache->save($result, $cache_key);
     }
     $this->getResponse()->setBody(Zend_Json::encode($result));
 }