コード例 #1
0
 /**
  * {@inheritDoc}
  */
 public function getStatusMessages()
 {
     $messages = array();
     $translator = $this->container->get('translator');
     $result = \ZMRuntime::getDatabase()->querySingle('SELECT COUNT(log_id) AS counter from %table.admin_activity_log%', array(), 'admin_activity_log');
     if (0 < $result['counter']) {
         $reset = null;
         if (self::ACTIVITY_LOG_RECORD_THRESHOLD < $result['counter']) {
             $reset = $translator->trans('The Admin Activity Log table has over %count% records and should be cleaned ... ', array('%count%' => self::ACTIVITY_LOG_RECORD_THRESHOLD));
         } else {
             $sql = 'SELECT MIN(access_date) AS access_date FROM %table.admin_activity_log% WHERE access_date < DATE_SUB(CURDATE(), INTERVAL ' . self::ACTIVITY_LOG_DATE_THRESHOLD . ' DAY)';
             $result = \ZMRuntime::getDatabase()->querySingle($sql);
             if ($result && null != $result['access_date']) {
                 $reset = $translator->trans('The Admin Activity Log table has records more than %count% days old and should be cleaned ... ', array('%count%' => self::ACTIVITY_LOG_DATE_THRESHOLD));
             }
         }
         if ($reset) {
             $messages[] = array(StatusCheck::STATUS_NOTICE, $reset);
         }
     }
     if (!defined('DEFAULT_CURRENCY')) {
         $messages[] = array(StatusCheck::STATUS_WARN, $translator->trans('Please set a default currency.'));
     }
     if (!defined('DEFAULT_LANGUAGE') || DEFAULT_LANGUAGE == '') {
         $messages[] = array(StatusCheck::STATUS_NOTICE, $translator->trans('Please set a default language.'));
     }
     return $messages;
 }
コード例 #2
0
 /**
  * {@inheritDoc}
  */
 public function getStatusMessages()
 {
     $messages = array();
     $languageId = $this->container->get('settingsService')->get('storeDefaultLanguageId');
     $configService = $this->container->get('configService');
     $translator = $this->container->get('translator');
     if (null != ($value = $configService->getConfigValue('NEW_SIGNUP_DISCOUNT_COUPON'))) {
         $value = $value->getValue();
         if (!empty($value)) {
             if (null != ($coupon = $this->container->get('couponService')->getCouponForId($value, $languageId))) {
                 $expiryDate = $coupon->getExpiryDate();
                 $diff = $expiryDate->diff(new \DateTime(), true);
                 $interval = (int) $diff->format('%r%a');
                 if ($interval > 0 && $interval < self::NEW_SIGNUP_GV_EXPIRY_THRESHOLD) {
                     $message = $translation->trans('Welcome Email Discount Coupon expires in %count% days.', array('%count%' => $interval));
                     $messages[] = array(StatusCheck::STATUS_NOTICE, $message);
                 }
             }
         }
     }
     if (null != ($results = \ZMRuntime::getDatabase()->fetchAll('SELECT * FROM %table.coupon_gv_queue% where release_flag = "N"')) && 0 < count($results)) {
         $url = '<a href="' . $this->container->get('router')->generate('gv_queue') . '">' . $translator->trans('gift queue') . '</a>';
         $message = $translator->trans('%count% item(s) in %queue_url% waiting for approval.', array('%count%' => count($results), '%queue_url%' => $url));
         $messages[] = array(StatusCheck::STATUS_NOTICE, $message);
     }
     return $messages;
 }
コード例 #3
0
 /**
  * Set permissons for a role.
  *
  * @param string role The role.
  * @param array pages List of allowed request ids.
  */
 public function setPermissionsForRole($role, $pages)
 {
     $currentPages = array();
     foreach ($this->getPermissionsForRole($role) as $info) {
         $currentPages[] = $info['rid'];
     }
     // removed?
     $remove = array();
     foreach ($currentPages as $page) {
         if (!in_array($page, $pages)) {
             $remove[] = $page;
         }
     }
     // added?
     $add = array();
     foreach ($pages as $page) {
         if (!in_array($page, $currentPages)) {
             $add[] = $page;
         }
     }
     if (0 < count($remove)) {
         $sql = "DELETE FROM %table.sacs_permissions%\n                    WHERE  type = 'role' AND name = :name\n                      AND rid in (:rid)";
         \ZMRuntime::getDatabase()->updateObj($sql, array('name' => $role, 'rid' => $remove), 'sacs_permissions');
     }
     if (0 < count($add)) {
         $sql = "INSERT INTO %table.sacs_permissions%\n                    (rid, type, name) VALUES (:rid, 'role', :name)";
         foreach ($add as $rid) {
             \ZMRuntime::getDatabase()->updateObj($sql, array('rid' => $rid, 'name' => $role), 'sacs_permissions');
         }
     }
 }
コード例 #4
0
 /**
  * {@inheritDoc}
  */
 public function remove($keepSettings = false)
 {
     //parent::remove($keepSettings);
     $conn = \ZMRuntime::getDatabase();
     $sm = $conn->getSchemaManager();
     $sm->dropTable($conn->getPrefix() . 'product_group_pricing');
 }
コード例 #5
0
 /**
  * Load all configuration values.
  *
  * @return array Map of all configuration values.
  */
 public function loadAll()
 {
     $map = array();
     $sql = "SELECT configuration_key, configuration_value FROM %table.product_type_layout%";
     foreach (\ZMRuntime::getDatabase()->fetchAll($sql) as $result) {
         $map[$result['configuration_key']] = $result['configuration_value'];
     }
     return $map;
 }
コード例 #6
0
 /**
  * Tear down.
  */
 public function tearDown()
 {
     parent::tearDown();
     $adminUserRoleService = $this->get('adminUserRoleService');
     ZMRuntime::getDatabase()->executeUpdate('TRUNCATE TABLE %table.admin_roles%');
     ZMRuntime::getDatabase()->executeUpdate('TRUNCATE TABLE %table.admins_to_roles%');
     $adminUserRoleService->addRole('admin');
     $adminUserRoleService->addRole('demo');
     ZMRuntime::getDatabase()->executeUpdate('INSERT INTO %table.admins_to_roles% VALUES(1, 1)');
 }
コード例 #7
0
 /**
  * Get stats.
  *
  * @return array Details about reserved quantities.
  */
 protected function getStats()
 {
     if (null === self::$qtyMap) {
         $sql = "SELECT op.products_id, SUM(op.products_quantity) AS products_quantity\n                  FROM %table.orders% o, %table.orders_products% op\n                  WHERE o.orders_id = op.orders_id\n                    AND o.orders_status NOT IN (:orderStatusId)\n                  GROUP BY op.products_id";
         $args = array('orderStatusId' => array(3, 4, 5, 6, 8, 9, 13, 17));
         self::$qtyMap = array();
         foreach (\ZMRuntime::getDatabase()->fetchAll($sql, $args, array('orders', 'orders_products')) as $result) {
             self::$qtyMap[$result['productId']] = $result['qty'];
         }
     }
     return self::$qtyMap;
 }
コード例 #8
0
 /**
  * Set pref for the given name.
  *
  * @param int adminId The adminId.
  * @param string name The pref name.
  * @param string value The pref value.
  */
 public function setPrefForName($adminId, $name, $value)
 {
     $args = array('admin_id' => $adminId, 'name' => $name, 'value' => $value);
     // check for insert/update first
     $sql = "SELECT value\n                FROM %table.admin_prefs%\n                WHERE admin_id = :admin_id AND name = :name";
     if (null != ($result = \ZMRuntime::getDatabase()->querySingle($sql, $args, 'admin_prefs'))) {
         $sql = "UPDATE %table.admin_prefs%\n                    SET value = :value\n                    WHERE admin_id = :admin_id AND name = :name";
     } else {
         $sql = "INSERT INTO %table.admin_prefs%\n                    (admin_id, name, value)\n                    VALUES (:admin_id, :name, :value)";
     }
     \ZMRuntime::getDatabase()->updateObj($sql, $args, 'admin_prefs');
 }
コード例 #9
0
 /**
  * {@inheritDoc}
  */
 public function processGet($request)
 {
     $fromDate = $request->query->get('fromDate');
     $toDate = $request->query->get('toDate');
     $exportFormat = $request->query->get('exportFormat');
     $viewData = array();
     if (null != $fromDate) {
         $dateFormat = $this->getDateFormat();
         $orderDateFrom = \DateTime::createFromFormat($dateFormat . ' H:i:s', $fromDate . ' 00:00:00');
         if (!empty($toDate)) {
             $orderDateTo = \DateTime::createFromFormat($dateFormat . ' H:i:s', $toDate . ' 00:00:00');
         } else {
             $orderDateTo = new \DateTime();
             $toDate = $orderDateTo->format($dateFormat);
         }
         // TODO: use new ZMOrders method
         $sql = "SELECT o.*, s.orders_status_name, ots.value as shippingValue\n                    FROM %table.orders% o, %table.orders_total% ot, %table.orders_status% s, %table.orders_total% ots\n                    WHERE date_purchased >= :1#orderDate AND date_purchased < :2#orderDate\n                      AND o.orders_id = ot.orders_id\n                      AND ot.class = 'ot_total'\n                      AND o.orders_id = ots.orders_id\n                      AND ots.class = 'ot_shipping'\n                      AND o.orders_status = s.orders_status_id\n                      AND s.language_id = :languageId\n                    ORDER BY orders_id DESC";
         $args = array('languageId' => 1, '1#orderDate' => $orderDateFrom, '2#orderDate' => $orderDateTo);
         // load as array to save memory
         $results = \ZMRuntime::getDatabase()->fetchAll($sql, $args, array('orders', 'orders_total', 'orders_status'));
         // prepare data
         $header = array('Date', 'Order Id', 'Customer Name', 'Shipping Country', 'Products Ordered', 'Quantity', 'Unit Products Net Price', 'Products Line Net Total', 'Products Net Total', 'Shipping Cost', 'Discount Amount', 'Discount Coupon', 'Gift Voucher Amount', 'Payment Type', 'Order Tax', 'Order Total');
         $rows = array();
         $order = Beans::getBean('ZenMagick\\StoreBundle\\Entity\\Order\\Order');
         foreach ($results as $ii => $orderData) {
             $order->reset();
             Beans::setAll($order, $orderData);
             $rows[] = $this->processOrder($order);
         }
         // additional view data
         $viewData = array('header' => $header, 'rows' => $rows, 'toDate' => $toDate);
         if ('csv' == $exportFormat) {
             // @todo should use StreamedResponse
             $response = new Response();
             $d = $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'orders.csv');
             $response->headers->set('Content-Type', 'application/csv');
             $response->headers->set('Content-Disposition', $d);
             ob_start();
             $fp = fopen('php://output', 'w');
             fputcsv($fp, $header);
             foreach ($rows as $orderRows) {
                 foreach ($orderRows as $row) {
                     fputcsv($fp, $row);
                 }
             }
             fclose($fp);
             $response->setContent(ob_get_clean());
             return $response;
         }
     }
     return $this->findView(null, $viewData);
 }
コード例 #10
0
 /**
  * {@inheritDoc}
  */
 public function getProductAssociationsForProductId($productId, $args = array())
 {
     $limit = 6;
     if (is_array($args) && array_key_exists('limit', $args)) {
         $limit = (int) $args['limit'];
     }
     $sql = "SELECT p.products_id\n                FROM %table.orders_products% opa, %table.orders_products% opb, %table.orders% o, %table.products% p\n                WHERE opa.products_id = :productId AND opa.orders_id = opb.orders_id\n                    AND opb.products_id != :productId and opb.products_id = p.products_id\n                    AND opb.orders_id = o.orders_id and p.products_status = 1\n                    GROUP BY p.products_id\n                    ORDER BY o.date_purchased DESC\n                    LIMIT " . $limit;
     $args = array('productId' => $productId);
     $assoc = array();
     foreach (\ZMRuntime::getDatabase()->fetchAll($sql, $args, 'products') as $result) {
         $assoc[] = new ProductAssociation($result['productId']);
     }
     return $assoc;
 }
コード例 #11
0
 /**
  * {@inheritDoc}
  *
  * @todo allow cancel at any time
  */
 public function processGet($request)
 {
     $translator = $this->get('translator');
     if (!Toolbox::asBoolean($this->getPlugin()->get('customerCancel'))) {
         $this->get('session.flash_bag')->error($translator->trans('Insufficient permission'));
         return $this->findView();
     }
     $orderId = $request->query->getInt('orderId');
     $order = $this->container->get('orderService')->getOrderForId($orderId, $request->getSession()->getLanguageId());
     $account = $order->getAccount();
     // make sure this is an allowed order
     if ($order->getAccountId() != $order->getAccountId()) {
         $this->get('session.flash_bag')->error($translator->trans('Invalid order selected'));
         return $this->findView();
     }
     $plugin = $this->getPlugin();
     // check for number of scheduled orders
     $sql = "SELECT COUNT(orders_id) AS total FROM %table.orders%\n                WHERE subscription_order_id = :subscriptionOrderId";
     $results = \ZMRuntime::getDatabase()->querySingle($sql, array('subscriptionOrderId' => $orderId), 'orders', Connection::MODEL_RAW);
     if ($results['total'] < $plugin->get('minOrders')) {
         $message = $translator->trans('This subscription can only be canceled after a minimum of %count% orders', array('%count%' => $plugin->get('minOrders')));
         $this->get('session.flash_bag')->error($message);
         return $this->findView();
     }
     $cancelDeadline = $plugin->get('cancelDeadline');
     if (0 < $cancelDeadline) {
         // this will return only a result if subscription_next_order is more than $cancelDeadline days in the future
         $sql = "SELECT orders_id\n                    FROM %table.orders%\n                    WHERE orders_id = :orderId\n                      AND DATE_SUB(subscription_next_order, INTERVAL " . $cancelDeadline . " DAY) >= CURDATE()";
         $result = \ZMRuntime::getDatabase()->querySingle($sql, array('orderId' => $orderId), 'orders', Connection::MODEL_RAW);
         if (null == $result) {
             $message = $translator->trans("Can't cancel less than %count% days before next subscription", array('%count%' => $cancelDeadline));
             $this->get('session.flash_bag')->error($message);
             return $this->findView();
         }
     }
     $sql = "UPDATE %table.orders%\n                SET is_subscription_canceled = :subscriptionCanceled\n                WHERE orders_id = :orderId";
     \ZMRuntime::getDatabase()->updateObj($sql, array('orderId' => $orderId, 'subscriptionCanceled' => true), 'orders');
     $this->get('session.flash_bag')->success($translator->trans('Subscription canceled!'));
     $settingsService = $this->container->get('settingsService');
     $emailTemplate = $settingsService->get('plugins.subscriptions.email.templates.cancel', 'subscription_cancel');
     $this->sendCancelEmail($order, $emailTemplate, $account->getEmail());
     $adminEmail = $plugin->get('adminEmail');
     if (empty($adminEmail)) {
         $adminEmail = $settingsService->get('storeEmail');
     }
     if (!Toolbox::isEmpty($adminEmail)) {
         $this->sendCancelEmail($order, $cancelEmailTemplate, $adminEmail);
     }
     return $this->findView();
 }
コード例 #12
0
 /**
  * {@inheritDoc}
  */
 public function getViewData($request)
 {
     if (!Toolbox::asBoolean($request->getParameter('other', false))) {
         $sql = "SELECT count(ci.customers_info_source_id) AS count, s.sources_name AS name, s.sources_id as sourceId\n                    FROM %table.customers_info% ci LEFT JOIN %table.sources% s ON s.sources_id = ci.customers_info_source_id\n                    GROUP BY s.sources_id\n                    ORDER BY ci.customers_info_source_id DESC";
         $isOther = false;
     } else {
         $sql = "SELECT count(ci.customers_info_source_id) as count, so.sources_other_name as name\n                  FROM %table.customers_info% ci, %table.sources_other% so\n                  WHERE ci.customers_info_source_id = " . ID_SOURCE_OTHER . " AND so.customers_id = ci.customers_info_id\n                  GROUP BY so.sources_other_name\n                  ORDER BY so.sources_other_name DESC";
         $isOther = true;
     }
     $sourceStats = \ZMRuntime::getDatabase()->fetchAll($sql, array(), array('sources'), 'ZenMagick\\Base\\ZMObject');
     $resultSource = new ZMArrayResultSource('ZenMagick\\Base\\ZMObject', $sourceStats);
     $resultList = Beans::getBean('ZMResultList');
     $resultList->setResultSource($resultSource);
     $resultList->setPageNumber($request->query->get('page', 1));
     return array('resultList' => $resultList, 'isOther' => $isOther);
 }
コード例 #13
0
 /**
  * {@inheritDoc}
  */
 public function remove($keepSettings = false)
 {
     //parent::remove($keepSettings);
     $conn = \ZMRuntime::getDatabase();
     $sm = $conn->getSchemaManager();
     $sm->dropTable($conn->getPrefix() . 'media_clips');
     $sm->dropTable($conn->getPrefix() . 'media_manager');
     $sm->dropTable($conn->getPrefix() . 'media_to_products');
     $sm->dropTable($conn->getPrefix() . 'media_types');
     $sm->dropTable($conn->getPrefix() . 'music_genre');
     $sm->dropTable($conn->getPrefix() . 'product_music_extra');
     $sm->dropTable($conn->getPrefix() . 'record_artists');
     $sm->dropTable($conn->getPrefix() . 'record_artists_info');
     $sm->dropTable($conn->getPrefix() . 'record_company');
     $sm->dropTable($conn->getPrefix() . 'record_company_info');
 }
コード例 #14
0
 /**
  * {@inheritDoc}
  */
 public function execute()
 {
     $container = $this->container;
     $settingsService = $container->get('settingsService');
     $offset = $settingsService->get('plugins.cron.jobs.birthday.offset', '');
     $template = $settingsService->get('plugins.cron.jobs.birthday.template', 'birthday');
     $sql = "SELECT * FROM %table.customers%\n                WHERE MONTH(customers_dob) = MONTH(curdate())\n                  AND DAYOFMONTH(customers_dob) = DAYOFMONTH(curdate()) " . $offset;
     $results = \ZMRuntime::getDatabase()->fetchAll($sql, array(), 'customers', 'ZenMagick\\StoreBundle\\Entity\\Account');
     foreach ($results as $account) {
         $context = array('account' => $account);
         $message = $container->get('messageBuilder')->createMessage($template, true, $request, $context);
         $subject = $container->get('translator')->trans("It's your birthday %name%", array('%name%' => $account->getFirstName()));
         $message->setSubject($subject)->setTo($account->getEmail(), $account->getFullName())->setFrom($settingsService->get('storeEmail'));
         $container->get('mailer')->send($message);
     }
     return true;
 }
コード例 #15
0
 /**
  * Start/stop all featured products.
  *
  * Stops all featured products scheduled for expiration
  * and starts all featured products scheduled to be started.
  */
 public function scheduleFeatured()
 {
     $sql = "SELECT featured_id, status, expires_date, featured_date_available\n                FROM %table.featured%";
     foreach (\ZMRuntime::getDatabase()->fetchAll($sql, array(), 'featured', 'ZenMagick\\StoreBundle\\Entity\\Catalog\\Feature') as $feature) {
         $availableDate = $feature->getAvailableDate();
         $expiryDate = $feature->getExpiryDate();
         $active = $feature->getStatus();
         if (!$active && null != $availableDate && new \DateTime() >= $availableDate) {
             $feature->setStatus(true);
             \ZMRuntime::getDatabase()->updateModel('featured', $feature);
         }
         // @todo the original code also disabled features tht haven't started yet. is that something we should worry about?
         if ($feature->getStatus() && null != $expiryDate && new \DateTime() >= $expiryDate) {
             $feature->setStatus(false);
             \ZMRuntime::getDatabase()->updateModel('featured', $feature);
         }
     }
 }
コード例 #16
0
 /**
  * {@inheritDoc}
  */
 public function processPost($request)
 {
     $orderId = $request->request->getInt('orderId');
     $cancel = $request->request->get('cancel');
     $hard = Toolbox::asBoolean($request->request->get('hard'), false);
     if (0 != $orderId && 'cancel' == $cancel) {
         $sql = "UPDATE %table.orders%\n                    SET is_subscription_canceled = :subscriptionCanceled, is_subscription = :subscription\n                    WHERE orders_id = :orderId";
         \ZMRuntime::getDatabase()->updateObj($sql, array('orderId' => $orderId, 'subscriptionCanceled' => true, 'subscription' => !$hard), 'orders');
         $this->get('session.flash_bag')->success($this->get('translator')->trans("Subscription canceled!"));
     }
     $order = $this->container->get('orderService')->getOrderForId($orderId, $request->getSession()->getLanguageId());
     $emailTemplate = $this->container->get('settingsService')->get('plugins.subscriptions.email.templates.cancel', 'subscription_cancel');
     $email = $order->getAccount()->getEmail();
     if (!Toolbox::isEmpty($email)) {
         $this->sendCancelEmail($order, $emailTemplate, $email);
     }
     return $this->findView('success');
 }
コード例 #17
0
 /**
  * Clean up.
  */
 public function tearDown()
 {
     $sql = 'SELECT customers_id FROM %table.customers% WHERE customers_lastname = \'doe\'';
     $results = ZMRuntime::getDatabase()->fetchAll($sql, array(), 'customers');
     $ids = array();
     foreach ($results as $result) {
         $ids[] = $result['accountId'];
     }
     if (0 == count($ids)) {
         // nothing to do
         return;
     }
     $sql = 'DELETE FROM %table.customers_info% WHERE customers_info_id IN (:accountId)';
     $results = ZMRuntime::getDatabase()->updateObj($sql, array('accountId' => $ids), 'customers_info');
     $sql = 'DELETE FROM %table.customers% WHERE customers_id IN (:accountId)';
     $results = ZMRuntime::getDatabase()->updateObj($sql, array('accountId' => $ids), 'customers');
     parent::tearDown();
 }
コード例 #18
0
 /**
  * {@inheritDoc}
  */
 public function getContents($request)
 {
     $router = $this->container->get('router');
     $translator = $this->container->get('translator');
     $contents = '<table class="grid" cellspacing="0">';
     $contents .= '<tr><th>' . $translator->trans('Status') . '</th><th>' . $translator->trans('Number of Orders') . '</th></tr>';
     $language = $request->getSelectedLanguage();
     $sql = "SELECT count(*) AS count FROM %table.orders%\n                WHERE orders_status = :orderStatusId";
     foreach ($this->container->get('orderService')->getOrderStatusList($language->getId()) as $status) {
         $args = array('orderStatusId' => $status->getOrderStatusId());
         $result = \ZMRuntime::getDatabase()->querySingle($sql, $args, 'orders');
         $contents .= '<tr>';
         $contents .= '<td><a href="' . $router->generate('zc_admin_orders', array('orderStatusId' => $status->getId())) . '">' . $status->getName() . '</a></td>';
         $contents .= '<td>' . $result['count'] . '</td>';
         $contents .= '</tr>';
     }
     $contents .= '</table>';
     return $contents;
 }
コード例 #19
0
 /**
  * {@inheritDoc}
  */
 public function processPost($request)
 {
     $action = $request->request->get('action');
     if ('create' == $action) {
         $name = $request->request->get('source');
         if (!empty($name)) {
             \ZMRuntime::getDatabase()->createModel('sources', array('sources_name' => $name));
             $this->get('session.flash_bag')->success('Source "' . $name . '" created.');
         }
     } elseif ('delete' == $action) {
         $sourceId = $request->request->get('sourceId');
         if (!empty($sourceId)) {
             $model = \ZMRuntime::getDatabase()->loadModel('sources', array('sources_id' => $sourceId));
             if (null !== $model) {
                 \ZMRuntime::getDatabase()->removeModel('sources', array('sources_id' => $sourceId));
                 $this->get('session.flash_bag')->success('Source "' . $model['sources_name'] . '" deleted.');
             }
         }
     }
     return $this->findView('success');
 }
コード例 #20
0
 /**
  * Start/stop all specials.
  *
  * Stops all specials scheduled for expiration
  * and starts all specials scheduled to be started.
  *
  * @todo finish product price retrieval that takes specials into account
  */
 public function scheduleSpecials()
 {
     $sql = "SELECT specials_id, products_id, status, expires_date, specials_date_available\n                FROM %table.specials%";
     $productService = $this->container->get('productService');
     foreach (\ZMRuntime::getDatabase()->fetchAll($sql, array(), 'specials', 'ZenMagick\\StoreBundle\\Entity\\Catalog\\Special') as $special) {
         $availableDate = $special->getAvailableDate();
         $expiryDate = $special->getExpiryDate();
         $active = $special->getStatus();
         if (!$active && null != $availableDate && new \DateTime() >= $availableDate) {
             $special->setStatus(true);
         }
         // @todo the original code also disabled specials that haven't started yet. is that something we should worry about?
         if ($special->getStatus() && null != $expiryDate && new \DateTime() >= $expiryDate) {
             $special->setStatus(false);
         }
         // changed ??
         if ($special->getStatus() != $active) {
             \ZMRuntime::getDatabase()->updateModel('specials', $special);
             $productService->updateSortPrice($special->getProductId());
         }
     }
 }
コード例 #21
0
 /**
  * Get data.
  */
 protected function getData($request)
 {
     $data = array();
     $database = \ZMRuntime::getDatabase();
     $router = $this->container->get('router');
     $translator = $this->container->get('translator');
     // customers
     $result = $database->querySingle("SELECT count(*) AS count FROM %table.customers%");
     $data[$translator->trans('Customers')] = $result['count'];
     // products
     $result = $database->querySingle("SELECT count(*) AS count FROM %table.products% WHERE products_status = '1'");
     $data[$translator->trans('Products')] = $result['count'];
     $result = $database->querySingle("SELECT count(*) AS count FROM %table.products% WHERE products_status = '0'");
     $data[$translator->trans('Inactive Products')] = $result['count'];
     // reviews
     $result = $database->querySingle("SELECT count(*) AS count FROM %table.reviews%");
     $data[$translator->trans('Reviews')] = $result['count'];
     $result = $database->querySingle("SELECT count(*) AS count FROM %table.reviews% WHERE status='0'");
     $data['<a href="' . $router->generate('reviews', array('status' => 1)) . '">' . $translator->trans('Reviews pending approval') . '</a>'] = $result['count'];
     // separator
     $data[] = null;
     // promotions
     $result = $database->querySingle("SELECT count(*) AS count FROM %table.specials% WHERE status= '0'");
     $data[$translator->trans('Specials Expired')] = $result['count'];
     $result = $database->querySingle("SELECT count(*) AS count FROM %table.specials% WHERE status= '1'");
     $data[$translator->trans('Specials Active')] = $result['count'];
     $result = $database->querySingle("SELECT count(*) AS count FROM %table.featured% WHERE status= '0'");
     $data[$translator->trans('Featured Products Expired')] = $result['count'];
     $result = $database->querySingle("SELECT count(*) AS count FROM %table.featured% WHERE status= '1'");
     $data[$translator->trans('Featured Products Active')] = $result['count'];
     $result = $database->querySingle("SELECT count(*) AS count FROM %table.salemaker_sales% WHERE sale_status= '0'");
     $data[$translator->trans('Sales Expired')] = $result['count'];
     $result = $database->querySingle("SELECT count(*) AS count FROM %table.salemaker_sales% WHERE sale_status= '1'");
     $data[$translator->trans('Sales Active')] = $result['count'];
     $event = new GenericEvent($this, array('data' => $data));
     $this->container->get('event_dispatcher')->dispatch('build_basic_stats', $event);
     return $event->getArgument('data');
 }
コード例 #22
0
 /**
  * {@inheritDoc}
  */
 public function getContents($request)
 {
     // TODO: convert into ajax pull
     $router = $this->container->get('router');
     $translator = $this->container->get('translator');
     $contents = '';
     $gvApprovalQueue = $this->container->get('couponService')->getCouponsForFlag('N');
     if (0 < count($gvApprovalQueue)) {
         $a = '<a href="' . $router->generate('gv_queue') . '">' . $translator->trans('approval') . '</a>';
         $contents .= $translator->trans('There are %count% gift cards waiting for %approval_url%.', array('%count%' => count($gvApprovalQueue), '%approval_url%' => $a));
     }
     $result = \ZMRuntime::getDatabase()->querySingle("SELECT count(*) AS count FROM %table.reviews% WHERE status='0'");
     if (0 < $result['count']) {
         $contents .= ' <a href="' . $router->generate('reviews', array('status' => 1)) . '">' . $translator->trans('There are %count% reviews pending approval.', array('%count%' => $result['count'])) . '</a>';
     }
     if (0 == strlen($contents)) {
         $contents = $translator->trans('No pending tasks found.');
     } else {
         $this->setStatus(self::STATUS_NOTICE);
     }
     $contents = '<p id="pending">' . $contents . '</p>';
     return $contents;
 }
コード例 #23
0
 /**
  * Custom create account processing
  */
 public function onCreateAccount($event)
 {
     $account = $event->getArgument('account');
     if (ID_SOURCE_OTHER == $account->getSourceId() && Account::GUEST != $account->getType()) {
         // need to store sourceOther
         $sql = "INSERT INTO %table.sources_other%\n                    VALUES (:customers_id, :sources_other_name)";
         \ZMRuntime::getDatabase()->updateObj($sql, array('customers_id' => $account->getId(), 'sources_other_name' => $account->getSourceOther()), 'sources_other');
     }
 }
コード例 #24
0
ファイル: Addresses.php プロジェクト: zenmagick/zenmagick
 /**
  * Get the address format for the given address format id.
  *
  * @param int addressFormatId The address format id.
  * @return string The address format.
  */
 public function getAddressFormatForId($addressFormatId)
 {
     $sql = "SELECT address_format\n                FROM %table.address_format%\n                WHERE address_format_id = :id";
     $result = \ZMRuntime::getDatabase()->querySingle($sql, array('id' => $addressFormatId), 'address_format');
     return $result['format'];
 }
コード例 #25
0
 /**
  * Update user.
  *
  * @param ZMUser user The user.
  * @return UserInterface The updated <code>UserInterface</code> instance.
  */
 public function updateUser($user)
 {
     \ZMRuntime::getDatabase()->updateModel('admin', $user);
     $this->roleService->setRolesForId($user->getId(), $user->getRoles());
     return true;
 }
コード例 #26
0
ファイル: MusicManager.php プロジェクト: zenmagick/zenmagick
 /**
  * Retrieve artist information for the given product.
  *
  * @param int productId The product id.
  * @param int languageId The language id.
  * @return Artist Artist information or <code>null</code>.
  */
 public function getArtistForProductId($productId, $languageId)
 {
     $sql = "SELECT * FROM %table.product_music_extra% WHERE products_id = :productId";
     $extraInfo = \ZMRuntime::getDatabase()->querySingle($sql, array('productId' => $productId), 'product_music_extra');
     $sql = "SELECT * FROM %table.record_artists% WHERE artists_id = :artistId";
     $artist = \ZMRuntime::getDatabase()->querySingle($sql, array('artistId' => $extraInfo['artistId']), 'record_artists', 'ZenMagick\\plugins\\musicProductInfo\\model\\Artist');
     if (null == $artist) {
         return null;
     }
     $sql = "SELECT * FROM %table.record_artists_info% WHERE artists_id = :artistId AND languages_id = :languageId";
     $args = array('artistId' => $artist->getArtistId(), 'languageId' => $languageId);
     $artistInfo = \ZMRuntime::getDatabase()->querySingle($sql, $args, 'record_artists_info');
     $artist->setUrl($artistInfo['url']);
     $sql = "SELECT * FROM %table.record_company% WHERE record_company_id = :recordCompanyId";
     $args = array('recordCompanyId' => $extraInfo['recordCompanyId']);
     $recordCompany = \ZMRuntime::getDatabase()->querySingle($sql, $args, 'record_company', 'ZenMagick\\plugins\\musicProductInfo\\model\\RecordCompany');
     if (null != $recordCompany) {
         $sql = "SELECT * FROM %table.record_company_info% WHERE record_company_id = :recordCompanyId AND languages_id = :languageId";
         $args = array('recordCompanyId' => $recordCompany->getRecordCompanyId(), 'languageId' => $languageId);
         $recordCompanyInfo = \ZMRuntime::getDatabase()->querySingle($sql, $args, 'record_company_info');
         $recordCompany->setUrl($recordCompanyInfo['url']);
         $artist->setRecordCompany($recordCompany);
     }
     $sql = "SELECT * FROM %table.music_genre% WHERE music_genre_id = :genreId";
     $genre = \ZMRuntime::getDatabase()->querySingle($sql, array('genreId' => $extraInfo['genreId']), 'music_genre');
     if ($genre) {
         $artist->setGenre($genre['name']);
     }
     return $artist;
 }
コード例 #27
0
ファイル: SQLRunner.php プロジェクト: zenmagick/zenmagick
 public static function table_exists($tablename, $pre_install = false)
 {
     $sm = \ZMRuntime::getDatabase()->getSchemaManager();
     $exists = $sm->tablesExist(array($tablename));
     if (ZC_UPG_DEBUG3 == true) {
         echo 'Table check (' . $tablename . ') = ' . ($exists ? 'true' : 'false') . '<br>';
     }
     return $exists;
 }
コード例 #28
0
ファイル: CouponService.php プロジェクト: zenmagick/zenmagick
 /**
  * Get all coupons.
  *
  * @param int languageId The languageId.
  * @param boolean active Optional flag to control whether to retreive active coupons only; default is <code>true</code>.
  * @return array List of coupons.
  */
 public function getCoupons($languageId, $active = true)
 {
     $sql = "SELECT * FROM %table.coupons% c, %table.coupons_description% cd\n                WHERE cd.coupon_id = c.coupon_id AND cd.language_id = :languageId";
     return \ZMRuntime::getDatabase()->fetchAll($sql, array('languageId' => $languageId), array('coupons', 'coupons_description'), 'ZenMagick\\StoreBundle\\Entity\\Coupons\\Coupon');
 }
コード例 #29
0
 /**
  * Find the product template for a given product.
  *
  * @param int productId The product id.
  * @return string The template name to be used to display product details.
  */
 public function getProductTemplate($productId)
 {
     // default
     $template = 'product';
     $sql = "SELECT products_type\n                FROM %table.products%\n                WHERE products_id = :productId";
     $result = \ZMRuntime::getDatabase()->querySingle($sql, array('productId' => $productId), 'products');
     if (null !== $result) {
         $typeId = $result['type'];
         $sql = "SELECT type_handler\n                    FROM %table.product_types%\n                    WHERE type_id = :id";
         $result = \ZMRuntime::getDatabase()->querySingle($sql, array('id' => $typeId), 'product_types');
         if (null !== $result) {
             $template = $result['handler'];
         }
     }
     return $template . '_info';
 }
コード例 #30
0
 /**
  * Remove a group pricing.
  *
  * @param ProductGroupPricing groupPricing The new product group pricing.
  * @return ProductGroupPricing The created product group pricing incl. the id.
  */
 public function removeProductGroupPricing($groupPricing)
 {
     return \ZMRuntime::getDatabase()->removeModel('product_group_pricing', $groupPricing);
 }