Esempio n. 1
0
 /**
  * main action
  */
 public function mainAction()
 {
     require_once 'models/ecommerce/ecommerce_product_variety.php';
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product_variety = new ecommerce_product_variety();
     $Product = new ecommerce_product();
     $this->tpl->assign('VARIETY_CONF', $Product_variety->conf);
     $Product_variety->set('id', $this->GET['id']);
     if ($_POST['save'] == 'save') {
         if ($id = $Product_variety->updateVariety($_POST['product']['variety'])) {
             msg("Product variety updated.");
             /*onxshopGoTo($_SESSION['last_diff'], 2);*/
         } else {
             msg("Can't add the product variety, is you product SKU unique?");
         }
     }
     $variety = $Product_variety->getVarietyDetail($this->GET['id']);
     $variety['publish'] = $variety['publish'] == 1 ? 'checked="checked" ' : '';
     $p = $Product->detail($variety['product_id']);
     $p['variety'] = $variety;
     $this->tpl->assign('PRODUCT', $p);
     /**
      * display confirmation if notifications are about to be sent out
      */
     require_once 'models/common/common_watchdog.php';
     $Watchdog = new common_watchdog();
     $this->tpl->assign('NOTIFICATIONS', array('back_in_stock_customer' => $Watchdog->checkWatchdog('back_in_stock_customer', $variety_id, 0, 1, true)));
     return true;
 }
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * check variety_id input
      */
     if (is_numeric($this->GET['id'])) {
         $variety_id = $this->GET['id'];
     } else {
         msg("Variety ID is not numeric", 'error');
         return false;
     }
     /**
      * initialize
      */
     require_once 'models/ecommerce/ecommerce_product_variety.php';
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product_variety = new ecommerce_product_variety();
     $Product = new ecommerce_product();
     $this->tpl->assign('VARIETY_CONF', $Product_variety->conf);
     /**
      * update variety
      */
     if ($_POST['save'] == 'save') {
         if (!isset($_POST['product']['variety']['publish'])) {
             $_POST['product']['variety']['publish'] = 0;
         }
         if ($id = $Product_variety->updateVariety($_POST['product']['variety'])) {
             msg("Product variety ID {$variety_id} updated.");
             /*onxshopGoTo($_SESSION['last_diff'], 2);*/
         } else {
             msg("Can't update the product variety, is you product code unique?", 'error');
         }
     }
     /**
      * get detail
      */
     $variety = $Product_variety->getVarietyDetail($variety_id);
     $variety['publish'] = $variety['publish'] == 1 ? 'checked="checked" ' : '';
     //alert if net weight is bigger than gross weight
     if ($variety['weight'] > $variety['weight_gross']) {
         msg("Net weight is bigger than gross weight", "error");
     }
     $p = $Product->detail($variety['product_id']);
     $p['variety'] = $variety;
     $this->tpl->assign('PRODUCT', $p);
     /**
      * display confirmation if notifications are about to be sent out
      */
     require_once 'models/common/common_watchdog.php';
     $Watchdog = new common_watchdog();
     $this->tpl->assign('NOTIFICATIONS', array('back_in_stock_customer' => $Watchdog->checkWatchdog('back_in_stock_customer', $variety['id'], 0, 1, true)));
     return true;
 }
Esempio n. 3
0
 /**
  * main action
  */
 public function mainAction()
 {
     set_time_limit(0);
     require_once 'models/common/common_watchdog.php';
     $Watchdog = new common_watchdog();
     /**
      * Get the list
      */
     $date_from = $this->GET['date_from'];
     $date_to = $this->GET['date_to'];
     $records = $Watchdog->getDataForReport($date_from, $date_to);
     $this->commonCSVAction($records, 'notifications');
     return true;
 }
Esempio n. 4
0
 /**
  * display confirmation if notifications are about to be sent out
  */
 public function checkNotifications(&$item)
 {
     require_once 'models/common/common_watchdog.php';
     $Watchdog = new common_watchdog();
     if ($item['stock'] == 0) {
         $item['num_notifications'] = $Watchdog->checkWatchdog('back_in_stock_customer', $item['variety_id'], 0, 1, true);
     } else {
         $item['num_notifications'] = 0;
     }
 }
 /**
  * update a record
  *
  * customer update function to sent notifications if stock level changes as per defined conditions
  *
  * @param array $data
  * @return integer
  */
 public function update($data = array())
 {
     $detail = $this->detail($data['id']);
     if (is_numeric($detail['stock']) && is_numeric($data['stock']) && $detail['stock'] != $data['stock']) {
         require_once 'models/common/common_watchdog.php';
         $Watchdog = new common_watchdog();
         $Watchdog->checkWatchdog('back_in_stock_admin', $data['id'], $detail['stock'], $data['stock']);
         $Watchdog->checkWatchdog('out_of_stock_admin', $data['id'], $detail['stock'], $data['stock']);
         $Watchdog->checkWatchdog('back_in_stock_customer', $data['id'], $detail['stock'], $data['stock']);
     }
     return parent::update($data);
 }