public static function start()
 {
     $OSCOM_PDO = Registry::get('PDO');
     $Qcounter = $OSCOM_PDO->query('select startdate, counter from :table_counter');
     $Qcounter->execute();
     $result = $Qcounter->fetchAll();
     if (count($result) > 0) {
         $OSCOM_PDO->exec('update :table_counter set counter = counter+1');
     } else {
         $Qcounterupdate = $OSCOM_PDO->prepare('insert into :table_counter (startdate, counter) values (:start_date, 1)');
         $Qcounterupdate->bindValue(':start_date', DateTime::getNow());
         $Qcounterupdate->execute();
     }
     return true;
 }
Example #2
0
 public static function start()
 {
     $OSCOM_Database = Registry::get('Database');
     $Qcounter = $OSCOM_Database->query('select startdate, counter from :table_counter');
     $Qcounter->execute();
     if ($Qcounter->numberOfRows()) {
         $counter_startdate = $Qcounter->value('startdate');
         $counter_now = $Qcounter->valueInt('counter') + 1;
         $Qcounterupdate = $OSCOM_Database->query('update :table_counter set counter = counter+1');
         $Qcounterupdate->execute();
     } else {
         $counter_startdate = DateTime::getNow();
         $counter_now = 1;
         $Qcounterupdate = $OSCOM_Database->query('insert into :table_counter (startdate, counter) values (:start_date, 1)');
         $Qcounterupdate->bindValue(':start_date', $counter_startdate);
         $Qcounterupdate->execute();
     }
     return true;
 }
Example #3
0
 /**
  * Deactivate all banners that have passed their schedule
  *
  * @access public
  */
 public function expireAll()
 {
     $OSCOM_Database = Registry::get('Database');
     $Qbanner = $OSCOM_Database->query('select b.banners_id, b.expires_date, b.expires_impressions, sum(bh.banners_shown) as banners_shown from :table_banners b, :table_banners_history bh where b.status = 1 and b.banners_id = bh.banners_id group by b.banners_id');
     $Qbanner->execute();
     while ($Qbanner->next()) {
         if (!osc_empty($Qbanner->value('expires_date'))) {
             if (DateTime::getNow() >= $Qbanner->value('expires_date')) {
                 $this->expire($Qbanner->valueInt('banners_id'));
             }
         } elseif (!osc_empty($Qbanner->valueInt('expires_impressions'))) {
             if ($Qbanner->valueInt('expires_impressions') > 0 && $Qbanner->valueInt('banners_shown') >= $Qbanner->valueInt('expires_impressions')) {
                 $this->expire($Qbanner->valueInt('banners_id'));
             }
         }
     }
 }
 protected static function log($message)
 {
     if (is_writable(OSCOM::BASE_DIRECTORY . 'Work/Logs')) {
         file_put_contents(OSCOM::BASE_DIRECTORY . 'Work/Logs/update-' . self::$_to_version . '.txt', '[' . DateTime::getNow('d-M-Y H:i:s') . '] ' . $message . "\n", FILE_APPEND);
     }
 }
 public function add($product_id, $quantity = null)
 {
     $OSCOM_Customer = Registry::get('Customer');
     $OSCOM_PDO = Registry::get('PDO');
     $OSCOM_Language = Registry::get('Language');
     if (!is_numeric($product_id)) {
         return false;
     }
     $OSCOM_Product = new Product($product_id);
     if ($OSCOM_Product->isValid()) {
         if ($this->exists($product_id)) {
             $item_id = $this->getBasketID($product_id);
             if (!is_numeric($quantity)) {
                 $quantity = $this->getQuantity($item_id) + 1;
             }
             $this->_contents[$item_id]['quantity'] = $quantity;
             if ($OSCOM_Customer->isLoggedOn()) {
                 $Qupdate = $OSCOM_PDO->prepare('update :table_shopping_carts set quantity = :quantity where customers_id = :customers_id and item_id = :item_id');
                 $Qupdate->bindInt(':quantity', $quantity);
                 $Qupdate->bindInt(':customers_id', $OSCOM_Customer->getID());
                 $Qupdate->bindInt(':item_id', $item_id);
                 $Qupdate->execute();
             }
         } else {
             if (!is_numeric($quantity)) {
                 $quantity = 1;
             }
             if ($OSCOM_Customer->isLoggedOn()) {
                 $Qid = $OSCOM_PDO->prepare('select max(item_id) as item_id from :table_shopping_carts where customers_id = :customers_id');
                 $Qid->bindInt(':customers_id', $OSCOM_Customer->getID());
                 $Qid->execute();
                 $item_id = $Qid->valueInt('item_id') + 1;
             } else {
                 if (empty($this->_contents)) {
                     $item_id = 1;
                 } else {
                     $item_id = max(array_keys($this->_contents)) + 1;
                 }
             }
             $this->_contents[$item_id] = array('item_id' => $item_id, 'id' => $product_id, 'parent_id' => (int) $OSCOM_Product->getData('parent_id'), 'name' => $OSCOM_Product->getTitle(), 'model' => $OSCOM_Product->getModel(), 'keyword' => $OSCOM_Product->getKeyword(), 'image' => $OSCOM_Product->getImage(), 'price' => $OSCOM_Product->getPrice(true), 'quantity' => $quantity, 'weight' => $OSCOM_Product->getData('weight'), 'tax_class_id' => $OSCOM_Product->getData('tax_class_id'), 'date_added' => DateTime::getShort(DateTime::getNow()), 'weight_class_id' => $OSCOM_Product->getData('weight_class_id'));
             if ($OSCOM_Customer->isLoggedOn()) {
                 $Qnew = $OSCOM_PDO->prepare('insert into :table_shopping_carts (customers_id, item_id, products_id, quantity, date_added) values (:customers_id, :item_id, :products_id, :quantity, now())');
                 $Qnew->bindInt(':customers_id', $OSCOM_Customer->getID());
                 $Qnew->bindInt(':item_id', $item_id);
                 $Qnew->bindInt(':products_id', $product_id);
                 $Qnew->bindInt(':quantity', $quantity);
                 $Qnew->execute();
             }
             if ($OSCOM_Product->getData('parent_id') > 0) {
                 $Qvariant = $OSCOM_PDO->prepare('select pvg.id as group_id, pvg.title as group_title, pvg.module, pvv.id as value_id, pvv.title as value_title from :table_products_variants pv, :table_products_variants_values pvv, :table_products_variants_groups pvg where pv.products_id = :products_id and pv.products_variants_values_id = pvv.id and pvv.languages_id = :languages_id_pvv and pvv.products_variants_groups_id = pvg.id and pvg.languages_id = :languages_id_pvg');
                 $Qvariant->bindInt(':products_id', $product_id);
                 $Qvariant->bindInt(':languages_id_pvv', $OSCOM_Language->getID());
                 $Qvariant->bindInt(':languages_id_pvg', $OSCOM_Language->getID());
                 $Qvariant->execute();
                 while ($Qvariant->fetch()) {
                     $group_title = ProductVariants::getGroupTitle($Qvariant->value('module'), $Qvariant->toArray());
                     $value_title = ProductVariants::getValueTitle($Qvariant->value('module'), $Qvariant->toArray());
                     $has_custom_value = ProductVariants::hasCustomValue($Qvariant->value('module'));
                     $this->_contents[$item_id]['variants'][] = array('group_id' => $Qvariant->valueInt('group_id'), 'value_id' => $Qvariant->valueInt('value_id'), 'group_title' => $group_title, 'value_title' => $value_title, 'has_custom_value' => $has_custom_value);
                     if ($OSCOM_Customer->isLoggedOn() && $has_custom_value === true) {
                         $Qnew = $OSCOM_PDO->prepare('insert into :table_shopping_carts_custom_variants_values (shopping_carts_item_id, customers_id, products_id, products_variants_values_id, products_variants_values_text) values (:shopping_carts_item_id, :customers_id, :products_id, :products_variants_values_id, :products_variants_values_text)');
                         $Qnew->bindInt(':shopping_carts_item_id', $item_id);
                         $Qnew->bindInt(':customers_id', $OSCOM_Customer->getID());
                         $Qnew->bindInt(':products_id', $product_id);
                         $Qnew->bindInt(':products_variants_values_id', $Qvariant->valueInt('value_id'));
                         $Qnew->bindValue(':products_variants_values_text', $value_title);
                         $Qnew->execute();
                     }
                 }
             }
         }
         $this->_cleanUp();
         $this->_calculate();
     }
 }