Example #1
0
 public function index()
 {
     if (Session::getActiveClientid() == NULL) {
         App::redirectUrl($this->registry->router->generate('frontend.mainside', true));
     }
     $this->Render('ClientAddress');
 }
Example #2
0
 public function index()
 {
     if (Session::getActiveClientid() > 0) {
         App::redirectUrl($this->registry->router->generate('frontend.clientsettings', true));
     }
     $this->Render('Registration');
 }
Example #3
0
 protected function getProductsTemplate()
 {
     $dataset = App::getModel('producerlistbox')->getDataset();
     if ($this->_boxAttributes['productsCount'] > 0) {
         $dataset->setPagination($this->_boxAttributes['productsCount']);
     }
     $dataset->setCurrentPage($this->currentPage);
     $dataset->setOrderBy('name', $this->orderBy);
     $dataset->setOrderDir('asc', $this->orderDir);
     $dataset->setSQLParams(array('clientid' => Session::getActiveClientid(), 'producer' => $this->producer['id'], 'pricefrom' => (double) $this->priceFrom, 'priceto' => (double) $this->priceTo));
     $products = App::getModel('producerlistbox')->getProductDataset();
     $this->dataset = $products;
     $this->registry->template->assign('items', $products['rows']);
     $this->registry->template->assign('view', $this->view);
 }
Example #4
0
 protected function getProductsTemplate($categoryId = 0)
 {
     $params = $this->_boxAttributes;
     if ($params['productsCount'] > 0) {
         $this->dataset->setPagination($params['productsCount']);
     }
     $this->dataset->setOrderBy($this->_boxAttributes['orderBy'], $this->_boxAttributes['orderBy']);
     $this->dataset->setOrderDir($this->_boxAttributes['orderDir'], $this->_boxAttributes['orderDir']);
     $this->dataset->setCurrentPage(1);
     $this->dataset->setSQLParams(array('clientid' => Session::getActiveClientid(), 'statusid' => $params['statusId'], 'category' => $categoryId));
     $products = App::getModel('ShowcaseBox')->getProductDataset();
     $this->registry->template->assign('categoryid', $categoryId);
     $this->registry->template->assign('items', $products['rows']);
     $result = $this->registry->template->fetch($this->loadTemplate('item.tpl'));
     return $result;
 }
Example #5
0
 public function index()
 {
     $include = '';
     if (!isset($this->_boxAttributes['showall'])) {
         $showall = 1;
     } else {
         $showall = $this->_boxAttributes['showall'];
         $include = isset($this->_boxAttributes['categoryIds']) ? explode(',', $this->_boxAttributes['categoryIds']) : array();
     }
     $showcount = isset($this->_boxAttributes['showcount']) && $this->_boxAttributes['showcount'] == 1 ? 1 : 0;
     $hideempty = isset($this->_boxAttributes['hideempty']) && $this->_boxAttributes['hideempty'] == 1 ? 1 : 0;
     if (($categories = $this->registry->cache->load('categories')) === FALSE) {
         $categories = App::getModel('CategoriesBox')->getCategoriesTree();
         $this->registry->cache->save('categories', $categories);
     }
     $path = App::getModel('categoriesbox')->getCurrentCategoryPath($this->getParam());
     if ($this->registry->router->getCurrentController() == 'productcart') {
         $path = App::getModel('categoriesbox')->getCategoryPathForProductById($this->registry->core->getParam());
         foreach ($categories as $key => $category) {
             if (in_array($category['id'], $path)) {
                 $categories[$key]['current'] = 1;
             }
             foreach ($category['children'] as $k => $subcategory) {
                 if (in_array($subcategory['id'], $path)) {
                     $categories[$key]['children'][$k]['current'] = 1;
                 }
             }
         }
     }
     if (Session::getActiveForceLogin() == 1 && Session::getActiveClientid() == 0) {
         $categories = array();
     }
     $this->total = count($categories);
     $this->registry->template->assign('categories', $categories);
     $this->registry->template->assign('showcount', $showcount);
     $this->registry->template->assign('path', $path);
     $this->registry->template->assign('showall', $showall);
     $this->registry->template->assign('include', $include);
     $this->registry->template->assign('hideempty', $hideempty);
     $this->registry->template->assign('current', (int) $this->registry->core->getParam());
     return $this->registry->template->fetch($this->loadTemplate('index.tpl'));
 }
 public function getProducts()
 {
     // Perform SEARCH
     if ($this->controller == 'productsearch') {
         $this->searchPhrase = str_replace('_', '', App::getModel('formprotection')->cropDangerousCode($this->getParam()));
     }
     if ($this->controller == 'productsearch' || $this->controller == 'productnews' || $this->controller == 'productpromotion') {
         $controller = $this->controller;
     } elseif ($this->controller == 'categorylist') {
         $controller = 'product';
         // categorylist is handled by product dataset
     } else {
         // return no products for other controllers (required by livesearch)
         return array();
     }
     $dataset = App::getModel($controller)->getDataset();
     $dataset->setPagination(0);
     $dataset->setCurrentPage(1);
     $dataset->setOrderBy('name', 'name');
     $dataset->setOrderDir('desc', 'desc');
     $params = array('clientid' => Session::getActiveClientid(), 'producer' => 0, 'filterbyproducer' => 0, 'pricefrom' => 0, 'priceto' => 0, 'enablelayer' => 0, 'products' => 0);
     if ($this->controller == 'productsearch') {
         $params['categoryid'] = 0;
         $params['name'] = '%' . $this->searchPhrase . '%';
     } elseif ($this->controller == 'categorylist') {
         $params['categoryid'] = $this->category['id'];
     }
     // get promotion products (no additional params needed
     //elseif($this->controller == 'productpromotion') {
     //}
     $dataset->setSQLParams($params);
     $products = App::getModel($controller)->getProductDataset();
     // array with id 0 product (non existing)
     $productIds = array(0);
     foreach ($products['rows'] as $key => $product) {
         $productIds[] = $product['id'];
     }
     return $productIds;
 }
Example #7
0
    public function getOrderByClient($idorder)
    {
        $sql = 'SELECT
					OST.name as orderstatusname,
					O.idorder,
					O.adddate as orderdate,
					O.dispatchmethodname,
					O.paymentmethodname,
					O.dispatchmethodprice,
					O.globalprice,
					O.price,
					O.globalpricenetto,
					O.currencysymbol
				FROM `order` O
				LEFT JOIN orderstatus OS ON OS.idorderstatus=O.orderstatusid
				LEFT JOIN orderstatustranslation OST ON OST.orderstatusid = OS.idorderstatus AND OST.languageid = :languageid
				WHERE O.clientid= :clientid AND idorder= :idorder';
        $Data = array();
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('idorder', $idorder);
        $stmt->bindValue('clientid', Session::getActiveClientid());
        $stmt->bindValue('languageid', Helper::getLanguageId());
        $stmt->execute();
        $rs = $stmt->fetch();
        if ($rs) {
            $invoicedata = explode('-', $rs['orderdate']);
            $invoicedata[2] = substr($invoicedata[2], 0, 2);
            $dateinvoice = $invoicedata[0] . $invoicedata[1] . $invoicedata[2];
            $Data = array('idorder' => $rs['idorder'], 'globalprice' => $rs['globalprice'], 'price' => $rs['price'], 'globalpricenetto' => $rs['globalpricenetto'], 'orderstatusname' => $rs['orderstatusname'], 'orderdate' => $rs['orderdate'], 'currencysymbol' => $rs['currencysymbol'], 'dispatchmethodname' => $rs['dispatchmethodname'], 'paymentmethodname' => $rs['paymentmethodname'], 'dispatchmethodprice' => $rs['dispatchmethodprice'], 'dateinvoice' => $dateinvoice, 'billingaddress' => $this->getOrderBillingData($rs['idorder']), 'shippingaddress' => $this->getOrderShippingData($rs['idorder']), 'invoices' => $this->getOrderInvoices($rs['idorder']));
        }
        return $Data;
    }
Example #8
0
    public function GenerateScript($containerId)
    {
        if (($LayoutBoxParams = $this->registry->cache->load('layoutbox')) === FALSE) {
            $LayoutBoxParams = $this->getLayoutBoxParams();
            $this->registry->cache->save('layoutbox', $LayoutBoxParams);
        }
        $columns = array();
        foreach ($this->_columns as $column) {
            $boxes = array();
            foreach ($column['boxes'] as $box) {
                if (!isset($box['id'])) {
                    continue;
                }
                if (in_array($box['id'], $this->boxes)) {
                    $showBox = false;
                    if (isset($LayoutBoxParams[$box['id']]['js']['iEnableBox'])) {
                        if ($LayoutBoxParams[$box['id']]['js']['iEnableBox'] == 0) {
                            $showBox = true;
                        }
                        if ($LayoutBoxParams[$box['id']]['js']['iEnableBox'] == 1 && Session::getActiveClientid() > 0) {
                            $showBox = true;
                        }
                        if ($LayoutBoxParams[$box['id']]['js']['iEnableBox'] == 2 && Session::getActiveClientid() == NULL) {
                            $showBox = true;
                        }
                        if ($LayoutBoxParams[$box['id']]['js']['iEnableBox'] == 3) {
                            $showBox = false;
                        }
                    } else {
                        $showBox = true;
                    }
                    if ($showBox == true) {
                        $boxes[] = '
											{
												sName: \'' . $box['id'] . '\',
												bCollapsed: ' . ($box['collapsed'] ? 'true' : 'false') . ',
												iSpan: ' . $box['colspan'] . '
											}';
                    }
                }
            }
            $columns[] = '
									new GLayoutColumn({
										iWidth: ' . $column['width'] . ',
										asBoxes: [' . implode(',', $boxes) . '
										]
									})';
        }
        $script = '
				<script type="text/javascript">
					/* <![CDATA[ */
						GCore.OnLoad(function() {
							$(\'#' . $containerId . '\').GLayoutBoxes({
								aoColumns: [' . implode(',', $columns) . '
								],
								sLayoutHash: \'' . $this->_GenerateLayoutHash() . '\'
							});
						});
					/* ]]> */
				</script>
			';
        return $script;
    }
Example #9
0
 public function getMissingCart($clientid)
 {
     $sql = "SELECT \n\t\t\t\t\tMC.idmissingcart, \n\t\t\t\t\tMC.sessionid \n\t\t\t\tFROM missingcart MC\n\t\t\t\tWHERE MC.clientid = :clientid\n\t\t\t\tORDER BY MC.adddate DESC\n\t\t\t\tLIMIT 1";
     $stmt = Db::getInstance()->prepare($sql);
     $stmt->bindValue('clientid', Session::getActiveClientid());
     $Data = array();
     try {
         $stmt->execute();
         $rs = $stmt->fetch();
         if ($rs) {
             $Data = array('clientid' => $clientid, 'idmissingcart' => $rs['idmissingcart'], 'products' => $this->getProductFromMissingCart($rs['idmissingcart']), 'sessionid' => $rs['sessionid']);
         } else {
             $Data = 0;
         }
     } catch (Exception $fe) {
         new FrontendException($fe->message('Error while selecting session content from sessionhandler.'));
     }
     return $Data;
 }
Example #10
0
    public function getInvoiceById($id)
    {
        $pdf = new Pdf(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8');
        $pdf->SetCreator(PDF_CREATOR);
        $pdf->SetAuthor('Gekosale');
        $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
        $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
        $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
        $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
        $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
        $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
        $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
        $pdf->setLanguageArray(1);
        $pdf->SetFont('dejavusans', '', 10);
        $sql = 'SELECT 
					*
				FROM invoice I
				LEFT JOIN `order` O ON O.idorder = I.orderid
				WHERE 
					I.idinvoice = :id AND IF(O.clientid IS NOT NULL, O.clientid = :clientid, 1)';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('id', $id);
        $stmt->bindValue('clientid', Session::getActiveClientid());
        $stmt->execute();
        $rs = $stmt->fetch();
        $Data = array();
        if ($rs) {
            switch ($rs['contenttype']) {
                case 'html':
                    $htmlcontent = $rs['contentoriginal'];
                    $pdf->AddPage();
                    $pdf->writeHTML($htmlcontent, true, 0, true, 0);
                    @ob_clean();
                    $pdf->Output($rs['symbol'], 'D');
                    break;
                case 'pdf':
                    $data = base64_decode($rs['contentoriginal']);
                    header('Content-Type: application/pdf');
                    header('Content-Description: File Transfer');
                    header('Content-Transfer-Encoding: binary');
                    header('Content-Disposition: attachment; filename="' . $rs['symbol'] . '.pdf"');
                    header('Content-Length: ' . strlen($data));
                    header('Cache-Control: private, must-revalidate, post-check=0, pre-check=0');
                    header('Expires: 0');
                    echo $data;
                    exit;
                    break;
            }
        }
    }
Example #11
0
    public function saveClientData()
    {
        if (Session::getActiveClientid() == 0) {
            return false;
        }
        $sql = 'SELECT 
					AES_DECRYPT(email, :encryptionkey) AS email, 
					AES_DECRYPT(firstname, :encryptionkey) AS firstname,  
					AES_DECRYPT(surname, :encryptionkey) AS surname,
					clientgroupid
				FROM clientdata
				LEFT JOIN client C ON C.idclient= :clientid
				WHERE clientid= :clientid AND C.viewid= :viewid';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('clientid', Session::getActiveClientid());
        $stmt->bindValue('viewid', Helper::getViewId());
        $stmt->bindValue('encryptionkey', Session::getActiveEncryptionKeyValue());
        $stmt->execute();
        $rs = $stmt->fetch();
        if ($rs) {
            Session::setActiveClientFirstname($rs['firstname']);
            Session::setActiveClientSurname($rs['surname']);
            Session::setActiveClientEmail($rs['email']);
            Session::setActiveClientGroupid($rs['clientgroupid']);
        }
        return true;
    }