Example #1
0
 public function getProducerAll()
 {
     $sql = 'SELECT 
		P.idproducer AS id,
		PT.name,
		PT.seo, 
		P.photoid, 
		COUNT(PROD.idproduct) AS totalproducts
	FROM producer P
	LEFT JOIN producertranslation PT ON PT.producerid = P.idproducer AND PT.languageid = :language
	LEFT JOIN producerview PV ON P.idproducer = PV.producerid
	LEFT JOIN product PROD ON PROD.producerid = P.idproducer AND PROD.enable = 1
	WHERE PV.viewid = :viewid
	GROUP BY P.idproducer
	HAVING totalproducts > 0
	ORDER BY PT.name ASC';
     $Data = array();
     $stmt = Db::getInstance()->prepare($sql);
     $stmt->bindValue('language', Helper::getLanguageId());
     $stmt->bindValue('viewid', Helper::getViewId());
     $stmt->execute();
     while ($rs = $stmt->fetch()) {
         $Data[] = array('id' => $rs['id'], 'name' => $rs['name'], 'seo' => $rs['seo'], 'link' => $this->registry->router->generate('frontend.producerlist', true, array('param' => $rs['seo'])), 'active' => $this->getParam() == $rs['seo'] ? true : false, 'photo' => App::getModel('categorylist')->getImagePath($rs['photoid']));
     }
     return $Data;
 }
Example #2
0
 public function index()
 {
     if (App::getModel('cart')->getMinimumOrderValue() > 0) {
         App::redirectUrl($this->registry->router->generate('frontend.cart'));
     }
     $this->Render('Checkout');
 }
Example #3
0
 public function index()
 {
     $this->registry->template->assign('producers', $this->producers);
     $this->registry->template->assign('activePath', App::getModel('staticcontent')->getActivePath());
     $this->registry->template->assign('view', $this->_boxAttributes['view']);
     return $this->registry->template->fetch($this->loadTemplate('index.tpl'));
 }
Example #4
0
   public function initDataset($dataset)
   {
       App::getModel('product')->productsDataset($dataset);
       $dataset->queryColumns['id'] = array('source' => 'UP.relatedproductid');
       $dataset->queryColumns['hierarchy'] = array('source' => 'UP.hierarchy');
       $dataset->queryFrom = '
     upsell UP
     LEFT JOIN product P ON  P.idproduct = UP.relatedproductid
     LEFT JOIN productcategory PC ON PC.productid = P.idproduct
     LEFT JOIN viewcategory VC ON PC.categoryid = VC.categoryid AND VC.viewid = :viewid
     LEFT JOIN productnew PN ON P.idproduct = PN.productid
   ' . $dataset->queryFrom;
       if ($this->registry->router->getCurrentController() == 'cart') {
           $dataset->setAdditionalWhere('
			FIND_IN_SET(CAST(UP.productid as CHAR), :ids) AND
			P.enable = 1 AND
			VC.viewid  = :viewid
		');
           $dataset->setSQLParams(array('ids' => App::getModel('cart')->getProductIds()));
       } else {
           $dataset->setAdditionalWhere('
			UP.productid = (SELECT productid FROM producttranslation WHERE seo = :seo LIMIT 1) AND 
			P.enable = 1 AND
			VC.viewid  = :viewid
		');
           $dataset->setSQLParams(array('seo' => $this->registry->core->getParam()));
       }
       $dataset->setGroupBy('
		UP.relatedproductid
	');
   }
Example #5
0
 public function getMetadata()
 {
     $id = App::getModel('staticcontent')->getConditionsId();
     if ($id > 0) {
         return App::getModel('staticcontent')->getMetaData($id);
     }
 }
Example #6
0
 public function saveOrder($Data)
 {
     $Data['clientaddress']['phone'] = $Data['contactData']['phone'];
     $Data['clientaddress']['phone2'] = $Data['contactData']['phone2'];
     $Data['clientaddress']['email'] = $Data['contactData']['email'];
     $Data['deliveryAddress']['phone'] = $Data['contactData']['phone'];
     $Data['deliveryAddress']['phone2'] = $Data['contactData']['phone2'];
     $Data['deliveryAddress']['email'] = $Data['contactData']['email'];
     Db::getInstance()->beginTransaction();
     try {
         $clientId = $Data['clientid'];
         if ($clientId == NULL || $clientId == 0) {
             $clientId = Session::getActiveClientid();
         }
         $orderId = $this->addOrder($Data, $clientId);
         $this->addOrderClientData($Data['clientaddress'], $clientId, $orderId);
         $this->addOrderClientDeliveryData($Data['deliveryAddress'], $orderId);
         $this->addOrderProduct($Data['cart'], $orderId);
         App::getModel('order')->updateSessionString($orderId);
         $this->syncStock();
         Event::dispatch($this, 'frontend.order.saveOrder', array('id' => $orderId, 'data' => $Data));
     } catch (Exception $e) {
         throw new FrontendException($e->getMessage());
     }
     Db::getInstance()->commit();
     return $orderId;
 }
Example #7
0
 /**
  * Logout Action
  * Clears Session information & Redirects to index
  */
 public function logout()
 {
     $session = \App::getModel('session');
     $session->clear();
     header('Location: ' . \Config::get('site.url') . '/Index');
     exit;
 }
Example #8
0
   public function initDataset($dataset)
   {
       $product_id = App::getModel('product')->getProductIdBySeo($this->registry->core->getParam());
       App::getModel('product')->productsDataset($dataset);
       $dataset->queryColumns['count'] = array('source' => 'SUM(DISTINCT OP.qty)');
       $dataset->queryFrom = '
     orderproduct OP
     LEFT JOIN productcategory PC ON PC.productid = OP.productid
     LEFT JOIN category C ON PC.categoryid= C.idcategory
     LEFT JOIN viewcategory VC ON PC.categoryid = VC.categoryid
     LEFT JOIN product P ON PC.productid = P.idproduct
     LEFT JOIN productnew PN ON P.idproduct = PN.productid
   ' . $dataset->queryFrom;
       $dataset->setAdditionalWhere('
		OP.qty IS NOT NULL AND 
		OP.name IS NOT NULL AND 
		P.idproduct IS NOT NULL AND 
		VC.viewid = :viewid AND 
		OP.orderid IN (:ids) AND 
		OP.productid != :productid AND
		P.enable = 1
	');
       $dataset->setGroupBy('
			P.idproduct
		');
       $dataset->setSQLParams(array('ids' => App::getModel('product')->getAlsoProduct($product_id), 'productid' => $product_id));
   }
Example #9
0
 public function __construct($registry, $box)
 {
     parent::__construct($registry, $box);
     $this->model = App::getModel('staticcontent');
     $this->id = App::getModel('staticcontent')->getConditionsId();
     $this->cms = $this->model->getStaticContent($this->id);
 }
Example #10
0
 public function getMetadata()
 {
     if ($this->getParam() == '') {
         return App::getModel('seo')->getMetadataForPage();
     } else {
         return App::getModel('producerlistbox')->getProducerBySeo($this->getParam());
     }
 }
 public function loadProductData($request)
 {
     $products = [];
     foreach ($request['products'] as $product) {
         $products[] = App::getModel('product/product')->getProductVariantDetails($product);
     }
     return array('products' => $products);
 }
Example #12
0
 public function getDatagrid()
 {
     if ($this->datagrid == null) {
         $this->datagrid = App::getModel('datagrid/datagrid');
         call_user_func($this->attributes['datagrid_init_function'], $this->datagrid);
     }
     return $this->datagrid;
 }
Example #13
0
 public function __construct()
 {
     $player = \App::getModel('session');
     if ($player->isLoggedIn()) {
         header('Location: Home');
         exit;
     }
 }
 public function dbStatusAction()
 {
     $yupp = new Yupp();
     $appNames = $yupp->getAppNames();
     $appModelClasses = array();
     // [appName][class][tablename,creada o no]
     // Incluye todas las clases del modelo de todas las apps
     YuppLoader::loadModel();
     // Para saber si se crearon las tablas para todas las
     // clases del modelo de todas las aplicaciones.
     $allTablesCreated = true;
     $fn = new FileNames();
     // http://code.google.com/p/yupp/issues/detail?id=123
     $createDatabaseForApps = array();
     // Aplicaciones a las que se sugiere que se cree su base de datos
     foreach ($appNames as $appName) {
         $app = new App($appName);
         $modelClassFileNames = $app->getModel();
         // no incluye las clases, solo obtiene los nombres
         //print_r($modelClassFileNames);
         // Necesito que sea plano el array, si no, tengo que hacer recorrida recursiva.
         // Esto no seria necesario si modifico la recorrida en la vista, para mostrar
         // la estructura interna de paquetes del modelo de la aplicacion.
         $modelClassFileNames = $this->array_flatten($modelClassFileNames);
         //print_r($modelClassFileNames);
         // Toda la informacion de las clases y tablas creadas para esta app
         $appModelClasses[$appName] = array();
         // http://code.google.com/p/yupp/issues/detail?id=123
         try {
             $dal = new DAL($appName);
             // Falla sino existe la base para la app $appName
         } catch (Exception $e) {
             if ($e->getCode() == 666) {
                 $createDatabaseForApps[] = $appName;
             }
             continue;
             // Para el for appNames
         }
         foreach ($modelClassFileNames as $classFileName) {
             $fileInfo = $fn->getFileNameInfo($classFileName);
             $className = $fileInfo['name'];
             // Para incluir las clases (por si no estan incluidas)
             // Ticket: http://code.google.com/p/yupp/issues/detail?id=71
             YuppLoader::load($fileInfo['package'], $className);
             $tableName = YuppConventions::tableName($className);
             if ($dal->tableExists($tableName)) {
                 $appModelClasses[$appName][$className] = array('tableName' => $tableName, 'created' => "CREADA");
             } else {
                 $appModelClasses[$appName][$className] = array('tableName' => $tableName, 'created' => "NO CREADA");
                 $allTablesCreated = false;
             }
         }
     }
     $this->params['allTablesCreated'] = $allTablesCreated;
     $this->params['appModelClasses'] = $appModelClasses;
     $this->params['createDatabaseForApps'] = $createDatabaseForApps;
     return $this->render("dbStatus");
 }
Example #15
0
   public function initDataset($dataset)
   {
       App::getModel('product')->productsDataset($dataset);
       $dataset->queryFrom = '
     productcategory PC
     LEFT JOIN viewcategory VC ON PC.categoryid = VC.categoryid
     LEFT JOIN product P ON PC.productid = P.idproduct
     LEFT JOIN productnew PN ON P.idproduct = PN.productid
   ' . $dataset->queryFrom;
       if ($this->registry->router->getCurrentController() == 'categorylist') {
           $dataset->setAdditionalWhere('
				IF(PGP.promotion = 1 AND IF(PGP.promotionstart IS NOT NULL, PGP.promotionstart <= CURDATE(), 1) AND IF(PGP.promotionend IS NOT NULL, PGP.promotionend >= CURDATE(), 1),
			 	PGP.discountprice IS NOT NULL,
			 	IF(PGP.groupprice IS NULL AND P.promotion = 1 AND IF(P.promotionstart IS NOT NULL, P.promotionstart <= CURDATE(), 1) AND IF(P.promotionend IS NOT NULL, P.promotionend >= CURDATE(), 1), P.discountprice IS NOT NULL, NULL)
				) AND
				VC.viewid = :viewid AND
				P.enable = 1 AND
				CT.seo = :seo
			');
           $dataset->setSQLParams(array('seo' => $this->getParam()));
       } elseif ($this->registry->router->getCurrentController() == 'producerlist') {
           $producer = App::getModel('producerlistbox')->getProducerBySeo($this->getParam());
           $dataset->setAdditionalWhere('
				IF(PGP.promotion = 1 AND IF(PGP.promotionstart IS NOT NULL, PGP.promotionstart <= CURDATE(), 1) AND IF(PGP.promotionend IS NOT NULL, PGP.promotionend >= CURDATE(), 1),
			 	PGP.discountprice IS NOT NULL,
			 	IF(PGP.groupprice IS NULL AND P.promotion = 1 AND IF(P.promotionstart IS NOT NULL, P.promotionstart <= CURDATE(), 1) AND IF(P.promotionend IS NOT NULL, P.promotionend >= CURDATE(), 1), P.discountprice IS NOT NULL, NULL)
				) AND
				VC.viewid = :viewid AND
				P.enable = 1 AND
				P.producerid = :id
			');
           $dataset->setSQLParams(array('id' => $producer['id']));
       } else {
           $dataset->setAdditionalWhere('
         IF(PGP.promotion = 1 AND IF(PGP.promotionstart IS NOT NULL, PGP.promotionstart <= CURDATE(), 1) AND IF(PGP.promotionend IS NOT NULL, PGP.promotionend >= CURDATE(), 1),
         PGP.discountprice IS NOT NULL,
         IF(PGP.groupprice IS NULL AND P.promotion = 1 AND IF(P.promotionstart IS NOT NULL, P.promotionstart <= CURDATE(), 1) AND IF(P.promotionend IS NOT NULL, P.promotionend >= CURDATE(), 1), P.discountprice IS NOT NULL, NULL)
           ) AND
           VC.viewid = :viewid AND
         IF(:filterbyproducer > 0, FIND_IN_SET(CAST(P.producerid as CHAR), :producer), 1) AND
         P.enable = 1 AND
         IF(:enablelayer > 0, FIND_IN_SET(CAST(P.idproduct as CHAR), :products), 1)
       ');
           //$dataset->queryFrom = '
           //productcategory PC
           //LEFT JOIN viewcategory VC ON PC.categoryid = VC.categoryid AND VC.viewid = :viewid
           //LEFT JOIN product P ON PC.productid = P.idproduct
           //LEFT JOIN productnew PN ON P.idproduct = PN.productid
           //' . $dataset->queryFrom;
           $dataset->setHavingString('
         finalprice BETWEEN IF(:pricefrom > 0, :pricefrom, 0) AND IF( :priceto > 0, :priceto, 999999)
       ');
           $dataset->setSQLParams(array('producer' => 0, 'pricefrom' => 0, 'priceto' => 0, 'filterbyproducer' => 0, 'enablelayer' => 0, 'products' => array()));
       }
       $dataset->setGroupBy('
		P.idproduct
	');
   }
 public function deleteAction()
 {
     $maFormationSession = App::getModel("FormationSession");
     if (isset($_GET['id'])) {
         $maFormationSession->load($_GET['id']);
         $maFormationSession->delete();
         header("Location: index.php?c=FormationSession");
     }
 }
Example #17
0
 public function sitemap()
 {
     try {
         // one sitemap for all search engines (use Google sitemap settings)
         App::getModel('sitemap')->generateSitemap(2);
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
Example #18
0
 public function __construct($attributes)
 {
     parent::__construct($attributes);
     if (!isset($this->attributes['base_price_field']) || !$this->attributes['base_price_field'] instanceof Field) {
         throw new Exception("Base price source field (attribute: base_price_field) not set for field '{$this->attributes['name']}'.");
     }
     $this->attributes['base_price_field_name'] = $this->attributes['base_price_field']->getName();
     $this->attributes['suffixes'] = App::getModel('suffix/suffix')->getSuffixTypesForSelect();
 }
Example #19
0
 public function getFormation()
 {
     if (!$this->_formation) {
         $f = App::getModel('Formation');
         $f->load($this->getData('formation_id'));
         $this->_formation = $f;
     }
     return $this->_formation;
 }
Example #20
0
 public function deletePost()
 {
     $model = App::getModel('login');
     $model->init($this->request->getPost());
     if ($model->delete()) {
         Session::Clear();
         $this->redirectUrl(URL);
     }
     //display errors...
     $this->redirectUrl(URL . 'help');
 }
Example #21
0
 public function logout()
 {
     if ($this->registry->router->getAdministrativeMode() == 1) {
         App::getModel('Frontend/login/login')->destroyAdminAutologinKey();
         Session::flush();
         App::redirect('login');
     } else {
         Session::flush();
         App::redirect('');
     }
 }
	public function authenticate()
	{
		$adminMapper = App::getModel('security/auth/users/mapper');
		$where = "login='".$this->_username."' AND passwd='".md5($this->_password)."'";
		$entity = $adminMapper->find($where);
		if($entity instanceof CG_DomainModel_Abstract_Entity){
			return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $entity->toVoEntity());
		}else{
			return new Zend_Auth_Result(Zend_Auth_Result::FAILURE, null);		
		}
	}
Example #23
0
 public function logout()
 {
     if ($this->registry->router->getAdministrativeMode() == 1) {
         Session::flush();
         App::redirectUrl($this->registry->router->generate('frontend.login', true));
     } else {
         App::getModel('clientlogin')->destroyAutologinKey();
         Session::flush();
         App::redirectUrl($this->registry->router->generate('frontend.home', true));
     }
 }
Example #24
0
 public function __construct($message, $code = 0, $messageToLogFile = NULL)
 {
     parent::__construct($message, $code, $messageToLogFile);
     if (__ENABLE_DEBUG__ == 0) {
         App::redirect('admin/mainside');
     }
     $this->errorDesignPath = 'error/index/index.tpl';
     App::getModel('template')->assign('SHOP_NAME', App::getRegistry()->session->getActiveShopName());
     App::getModel('template')->assign('error', preg_replace('/(\\n|\\r)+/', '\\n', nl2br(addslashes($this->errorText))));
     App::getModel('template')->display($this->errorDesignPath);
     die;
 }
Example #25
0
 /**
  * playerLogin
  * @param array $data
  */
 public function playerLogin($data)
 {
     $session = \App::getModel('Session');
     $auth = \App::getModel('Auth');
     $session->clear();
     $auth->setLastActive($data['username']);
     $session->set('player_id', $data['player_id']);
     $session->set('hash', $session->generateSignature());
     $session->set('lastActive', time());
     header('Location: Home');
     exit;
 }
Example #26
0
 public function __construct($message, $code = 0, $messageToLogFile = NULL)
 {
     parent::__construct($message, $code, $messageToLogFile);
     if (__ENABLE_DEBUG__ == 0) {
         App::redirectSeo(App::getURLAdress());
     }
     App::getModel('template')->assign('SHOP_NAME', App::getRegistry()->session->getActiveShopName());
     App::getModel('template')->assign('error', $this->errorText);
     App::getModel('template')->assign('BASE_URL', App::getURLAdress());
     App::getModel('template')->display('error/index/layout.tpl');
     die;
 }
 public function __construct($registry, $box)
 {
     parent::__construct($registry, $box);
     $dataset = App::getModel('productscrosssellbox')->getDataset();
     if ($this->_boxAttributes['productsCount'] > 0) {
         $dataset->setPagination($this->_boxAttributes['productsCount']);
     }
     $dataset->setOrderBy($this->_boxAttributes['orderBy'], $this->_boxAttributes['orderBy']);
     $dataset->setOrderDir($this->_boxAttributes['orderDir'], $this->_boxAttributes['orderDir']);
     $dataset->setCurrentPage(1);
     $products = App::getModel('productscrosssellbox')->getProductDataset();
     $this->dataset = $products;
 }
Example #28
0
 public function index()
 {
     if ($this->registry->core->getParam() > 0) {
         //header('Content-type: text/xml');
         try {
             App::getModel('sitemap')->generateSitemap($this->registry->core->getParam());
         } catch (Exception $e) {
             echo $e->getMessage();
         }
     } else {
         $this->Render('Sitemap');
     }
 }
 public function __construct($registry, $box)
 {
     parent::__construct($registry, $box);
     $dataset = App::getModel('customproductlistbox')->getDataset();
     if ($this->_boxAttributes['productsCount'] > 0) {
         $dataset->setPagination($this->_boxAttributes['productsCount']);
     }
     $dataset->setSQLParams(array('ids' => isset($this->_boxAttributes['products']) && strlen($this->_boxAttributes['products']) > 0 ? explode(',', $this->_boxAttributes['products']) : array(0)));
     $dataset->setOrderBy($this->_boxAttributes['orderBy'], $this->_boxAttributes['orderBy']);
     $dataset->setOrderDir($this->_boxAttributes['orderDir'], $this->_boxAttributes['orderDir']);
     $dataset->setCurrentPage(1);
     $products = App::getModel('customproductlistbox')->getProductDataset();
     $this->dataset = $products;
 }
 public function index()
 {
     $producers = $this->model->getProducersLinks();
     $attributes = $this->model->getAttributesLinks();
     $this->registry->template->assign('priceFrom', $this->getParam('priceFrom', 0));
     $this->registry->template->assign('priceTo', $this->getParam('priceTo', 0));
     $this->registry->template->assign('producers', $producers);
     if ($this->controller == 'categorylist') {
         $this->registry->template->assign('currentCategory', App::getModel('categorylist')->getCurrentCategory());
         $this->registry->template->assign('current', (int) $this->registry->core->getParam());
     }
     $this->registry->template->assign('groups', $attributes);
     return $this->registry->template->fetch($this->loadTemplate('index.tpl'));
 }