Ejemplo n.º 1
0
    public function updateProductSearch($request)
    {
        $Data = $request['data'];
        $id = $request['id'];
        DbTracker::deleteRows('productsearch', 'productid', $id);
        foreach ($Data['name'] as $key => $val) {
            $sql = 'INSERT INTO productsearch (productid, languageid, name, shortdescription, description, producername, attributes)
						VALUES (:productid, :languageid, :name, :shortdescription, :description, :producername, :attributes)';
            $stmt = Db::getInstance()->prepare($sql);
            $stmt->bindValue('productid', $id);
            $stmt->bindValue('languageid', $key);
            $stmt->bindValue('name', $Data['name'][$key]);
            $stmt->bindValue('shortdescription', $Data['shortdescription'][$key]);
            $stmt->bindValue('description', $Data['description'][$key]);
            $stmt->bindValue('producername', App::getModel('producer')->getProducerNameById($Data['producerid'], $key));
            if (!isset($Data['variants']) || $Data['variants'] == NULL) {
                $stmt->bindValue('attributes', NULL);
            } else {
                $stmt->bindValue('attributes', $Data['variants']['set']);
            }
            try {
                $stmt->execute();
            } catch (Exception $e) {
                throw new CoreException(_('ERR_PRODUCT_SEARCH_UPDATE'), 112, $e->getMessage());
            }
        }
    }
Ejemplo n.º 2
0
    public function integrationUpdate($request)
    {
        DbTracker::deleteRows('categoryceneo', 'categoryid', $request['id']);
        $sql = 'INSERT INTO categoryceneo (categoryid, ceneoid)
				VALUES (:categoryid, :ceneoid)';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('categoryid', $request['id']);
        $stmt->bindValue('ceneoid', (int) $request['data']['ceneocategory']);
        $stmt->execute();
    }
Ejemplo n.º 3
0
    public function editUnitMeasure($Data, $id)
    {
        DbTracker::deleteRows('unitmeasuretranslation', 'unitmeasureid', $id);
        foreach ($Data['name'] as $key => $val) {
            $sql = 'INSERT INTO unitmeasuretranslation (unitmeasureid, name, languageid)
					VALUES (:unitmeasureid, :name, :languageid)';
            $stmt = Db::getInstance()->prepare($sql);
            $stmt->bindValue('unitmeasureid', $id);
            $stmt->bindValue('name', $Data['name'][$key]);
            $stmt->bindValue('languageid', $key);
            try {
                $stmt->execute();
            } catch (Exception $e) {
                throw new CoreException(_('ERR_UNIT_MEASURE_ADD'), 11, $e->getMessage());
            }
        }
        return true;
    }
Ejemplo n.º 4
0
 public function deleteClientNewsletter($id)
 {
     DbTracker::deleteRows('clientnewsletter', 'idclientnewsletter', $id);
 }
Ejemplo n.º 5
0
    public function editCurrencyView($Data, $id)
    {
        DbTracker::deleteRows('currencyview', 'currencyid', $id);
        if (!empty($Data)) {
            foreach ($Data as $value) {
                $sql = 'INSERT INTO currencyview (currencyid, viewid)
							VALUES (:currencyid, :viewid)';
                $stmt = Db::getInstance()->prepare($sql);
                $stmt->bindValue('currencyid', $id);
                $stmt->bindValue('viewid', $value);
                try {
                    $stmt->execute();
                } catch (Exception $e) {
                    throw new CoreException(_('ERR_CURRENCY_VIEW_EDIT'), 4, $e->getMessage());
                }
            }
        }
    }
Ejemplo n.º 6
0
 public function deletePagescheme($id)
 {
     $theme = App::getModel('pagescheme')->getTemplateNameToEdit($id);
     if (empty($theme)) {
         throw new CoreException('Unknown ID: ' . $id);
     }
     if (is_dir(ROOTPATH . 'themes' . DS . $theme['templatefolder'])) {
         $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(ROOTPATH . 'themes' . DS . $theme['templatefolder']), RecursiveIteratorIterator::CHILD_FIRST);
         foreach ($files as $file) {
             if (in_array($file->getBasename(), array('.', '..'))) {
                 continue;
             }
             if ($file->isDir()) {
                 if (!rmdir($file->getPathname())) {
                     throw new CoreException('Can\'t remove: ' . $file->getPathname());
                 }
                 continue;
             }
             if (!unlink($file->getPathname())) {
                 throw new CoreException('Can\'t remove: ' . $file->getPathname());
             }
         }
         @rmdir(ROOTPATH . 'themes' . DS . $theme['templatefolder']);
     }
     DbTracker::deleteRows('pagescheme', 'idpagescheme', $id);
 }
Ejemplo n.º 7
0
    public function UpdateAttributeGroup($Data, $attributegroupnameid)
    {
        DbTracker::deleteRows('attributegroup', 'attributegroupnameid', $attributegroupnameid);
        if (isset($Data['attributes'])) {
            foreach ($Data['attributes']['editor'] as $key => $attributeproductid) {
                $checkid = substr($attributeproductid['id'], 0, 3);
                if ($checkid != 'new') {
                    // Dodawanie istniejacego zestwu cech + warianty
                    $sql = 'INSERT INTO attributegroup(attributegroupnameid, attributeproductid) 
								VALUES (:attributegroupnameid, :attributeproductid)';
                    $stmt = Db::getInstance()->prepare($sql);
                    $stmt->bindValue('attributegroupnameid', $attributegroupnameid);
                    $stmt->bindValue('attributeproductid', $attributeproductid['id']);
                    try {
                        $stmt->execute();
                        foreach ($attributeproductid['values'] as $key => $valueid) {
                            $checknewid = substr($valueid['id'], 0, 3);
                            if ($checknewid == 'new') {
                                $sql = 'INSERT INTO attributeproductvalue(name, attributeproductid) 
											VALUES (:name, :attributeproductid)';
                                $stmt = Db::getInstance()->prepare($sql);
                                $stmt->bindValue('name', $valueid['name']);
                                $stmt->bindValue('attributeproductid', $attributeproductid['id']);
                                try {
                                    $stmt->execute();
                                } catch (Exception $e) {
                                    throw new Exception($e->getMessage());
                                }
                            }
                        }
                    } catch (Exception $e) {
                        throw new Exception($e->getMessage());
                    }
                } else {
                    // Dodawanie nowego zestwu cech + warianty
                    $attributeproductids = $this->addNewAttributeProduct($attributeproductid['name']);
                    $sql = 'INSERT INTO attributegroup(attributegroupnameid, attributeproductid) 
								VALUES (:attributegroupnameid, :attributeproductid)';
                    $stmt = Db::getInstance()->prepare($sql);
                    $stmt->bindValue('attributegroupnameid', $attributegroupnameid);
                    $stmt->bindValue('attributeproductid', $attributeproductids);
                    try {
                        $stmt->execute();
                        if (!empty($attributeproductid['values'])) {
                            foreach ($attributeproductid['values'] as $key => $valueid) {
                                $sql = 'INSERT INTO attributeproductvalue(name, attributeproductid) VALUES (:name, :attributeproductid)';
                                $stmt = Db::getInstance()->prepare($sql);
                                $stmt->bindValue('name', $valueid['name']);
                                $stmt->bindValue('attributeproductid', $attributeproductids);
                                try {
                                    $stmt->execute();
                                } catch (Exception $e) {
                                    throw new Exception($e->getMessage());
                                }
                            }
                        }
                    } catch (Exception $e) {
                        throw new Exception($e->getMessage());
                    }
                }
            }
        }
    }
Ejemplo n.º 8
0
 public function editAttributeCategory($Data, $id)
 {
     DbTracker::deleteRows('categoryattributeproduct', 'attributeproductid', $id);
     foreach ($Data as $key => $categoryid) {
         $sql = 'INSERT INTO categoryattributeproduct(categoryid, attributeproductid) VALUES (:categoryid, :attributeproductid)';
         $stmt = Db::getInstance()->prepare($sql);
         $stmt->bindValue('categoryid', $categoryid);
         $stmt->bindValue('attributeproductid', $id);
         try {
             $stmt->execute();
         } catch (Exception $e) {
             throw new Exception($e->getMessage());
         }
     }
 }
Ejemplo n.º 9
0
    public function updateLayoutBox($submittedData, $id)
    {
        DbTracker::deleteRows('layoutboxtranslation', 'layoutboxid', $id);
        $sql = 'UPDATE layoutbox SET
					name= :name,
					controller = :controller
				WHERE
					idlayoutbox = :idlayoutbox';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('idlayoutbox', $id);
        $stmt->bindValue('name', $submittedData['name']);
        $stmt->bindValue('controller', $submittedData['box_content']);
        try {
            $stmt->execute();
            foreach ($submittedData['title'] as $languageid => $title) {
                $sql = '
						INSERT INTO
							layoutboxtranslation (layoutboxid, languageid, title)
						VALUES (:layoutboxid, :languageid, :title)
					';
                $stmt = Db::getInstance()->prepare($sql);
                $stmt->bindValue('layoutboxid', $id);
                $stmt->bindValue('languageid', $languageid);
                $stmt->bindValue('title', $title);
                $stmt->execute();
            }
        } catch (Exception $e) {
            return false;
        }
        return true;
    }
Ejemplo n.º 10
0
    public function updateViewCategory($Data, $id)
    {
        DbTracker::deleteRows('viewcategory', 'viewid', $id);
        if (!empty($Data)) {
            foreach ($Data as $category) {
                $sql = 'INSERT INTO viewcategory (viewid, categoryid)
							VALUES (:viewid, :categoryid)';
                $stmt = Db::getInstance()->prepare($sql);
                $stmt->bindValue('viewid', $id);
                $stmt->bindValue('categoryid', $category);
                try {
                    $stmt->execute();
                } catch (Exception $e) {
                    throw new CoreException(_('ERR_PRODUCT_CATEGORY_UPDATE'), 112, $e->getMessage());
                }
            }
        }
    }
Ejemplo n.º 11
0
    public function updateLanguageView($array, $id)
    {
        DbTracker::deleteRows('languageview', 'languageid', $id);
        foreach ($array as $value) {
            $sql = 'INSERT INTO languageview (viewid, languageid)
						VALUES (:viewid, :languageid)';
            $stmt = Db::getInstance()->prepare($sql);
            $stmt->bindValue('languageid', $id);
            $stmt->bindValue('viewid', $value);
            try {
                $stmt->execute();
            } catch (Exception $e) {
                throw new Exception($e->getMessage());
            }
        }
    }
Ejemplo n.º 12
0
    public function editCategory($Data, $id)
    {
        Db::getInstance()->beginTransaction();
        $sql = 'UPDATE category SET
					categoryid=:categoryid,
					distinction = :distinction,
					enable = :enable
				WHERE idcategory = :id';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('id', $id);
        if ($Data['categoryid'] > 0) {
            $stmt->bindValue('categoryid', $Data['categoryid']);
        } else {
            $stmt->bindValue('categoryid', NULL);
        }
        if (isset($Data['enable']) && $Data['enable'] == 1) {
            $stmt->bindValue('enable', $Data['enable']);
        } else {
            $stmt->bindValue('enable', 0);
        }
        $stmt->bindValue('distinction', $Data['distinction']);
        try {
            $stmt->execute();
        } catch (Exception $e) {
            throw new CoreException(_('ERR_CATEGORY_UPDATE'), 1, $e->getMessage());
            return false;
        }
        if ($Data['photo']['unmodified'] == 0) {
            $sql = 'UPDATE category SET photoid = :photo
					WHERE idcategory = :id';
            $stmt = Db::getInstance()->prepare($sql);
            $stmt->bindValue('id', $id);
            if ($Data['photo'][0] > 0) {
                $stmt->bindValue('photo', $Data['photo'][0]);
            } else {
                $stmt->bindValue('photo', NULL);
            }
            try {
                $stmt->execute();
            } catch (Exception $e) {
                throw new CoreException(_('ERR_CATEGORY_UPDATE'), 1, $e->getMessage());
                return false;
            }
        }
        DbTracker::deleteRows('categorytranslation', 'categoryid', $id);
        foreach ($Data['name'] as $key => $val) {
            $sql = 'INSERT INTO categorytranslation (categoryid,name,shortdescription, description, languageid, seo, keyword_title, keyword, keyword_description)
					VALUES (:categoryid,:name,:shortdescription, :description, :languageid, :seo, :keyword_title, :keyword, :keyword_description)';
            $stmt = Db::getInstance()->prepare($sql);
            $stmt->bindValue('categoryid', $id);
            $stmt->bindValue('name', $Data['name'][$key]);
            $stmt->bindValue('shortdescription', $Data['shortdescription'][$key]);
            $stmt->bindValue('description', $Data['description'][$key]);
            $stmt->bindValue('languageid', $key);
            $stmt->bindValue('seo', $Data['seo'][$key]);
            $stmt->bindValue('keyword_title', $Data['keywordtitle'][$key]);
            $stmt->bindValue('keyword', $Data['keyword'][$key]);
            $stmt->bindValue('keyword_description', $Data['keyworddescription'][$key]);
            try {
                $stmt->execute();
            } catch (Exception $e) {
                throw new CoreException(_('ERR_NEWS_ADD'), 4, $e->getMessage());
            }
        }
        DbTracker::deleteRows('viewcategory', 'categoryid', $id);
        foreach ($Data['view'] as $key => $val) {
            $sql = 'INSERT INTO viewcategory (categoryid,viewid)
					VALUES (:categoryid, :viewid)';
            $stmt = Db::getInstance()->prepare($sql);
            $stmt->bindValue('categoryid', $id);
            $stmt->bindValue('viewid', $val);
            try {
                $stmt->execute();
            } catch (Exception $e) {
                throw new CoreException(_('ERR_CATEGORY_VIEW_ADD'), 4, $e->getMessage());
            }
        }
        DbTracker::deleteRows('productcategory', 'categoryid', $id);
        if (!empty($Data['products'])) {
            foreach ($Data['products'] as $key => $val) {
                $sql = 'INSERT INTO productcategory (productid, categoryid)
						VALUES (:productid, :categoryid)';
                $stmt = Db::getInstance()->prepare($sql);
                $stmt->bindValue('productid', $val);
                $stmt->bindValue('categoryid', $id);
                try {
                    $stmt->execute();
                } catch (Exception $e) {
                    throw new CoreException(_('ERR_PRODUCT_CATEGORY_ADD'), 11, $e->getMessage());
                }
            }
        }
        $sql = 'UPDATE category SET enable = :enable WHERE idcategory IN (SELECT categoryid FROM categorypath WHERE ancestorcategoryid = :id)';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('id', $id);
        if (isset($Data['enable']) && $Data['enable'] == 1) {
            $stmt->bindValue('enable', $Data['enable']);
        } else {
            $stmt->bindValue('enable', 0);
        }
        $stmt->execute();
        Db::getInstance()->commit();
        Event::dispatch($this, 'admin.category.model.save', array('id' => $id, 'data' => $Data));
        $this->getCategoriesPathById();
        $this->flushCache();
        return true;
    }
Ejemplo n.º 13
0
    protected function updateClientNewsletterHistory($Data, $id)
    {
        DbTracker::deleteRows('clientgroupnewsletterhistory', 'newsletterid', $id);
        if (is_array($Data['clients'])) {
            foreach ($Data['clients'] as $value) {
                $sql = 'INSERT INTO clientnewsletterhistory (clientnewsletterid, newsletterid)
							VALUES (:clientnewsletterid, :newsletterid)';
                $stmt = Db::getInstance()->prepare($sql);
                $stmt->bindValue('clientnewsletterid', $value);
                $stmt->bindValue('newsletterid', $id);
                try {
                    $stmt->execute();
                } catch (Exception $e) {
                    throw new CoreException(_('ERR_CLIENT_NEWSLETTER_ADD'), 112, $e->getMessage());
                }
            }
        } else {
            $sql = 'INSERT INTO clientnewsletterhistory (clientnewsletterid, newsletterid)
						VALUES (:clientnewsletterid, :newsletterid)';
            $stmt = Db::getInstance()->prepare($sql);
            $stmt->bindValue('clientnewsletterid', NULL);
            $stmt->bindValue('newsletterid', $id);
            try {
                $stmt->execute();
            } catch (Exception $e) {
                throw new CoreException(_('ERR_CLIENT_NEWSLETTER_ADD'), 11, $e->getMessage());
            }
        }
    }