Beispiel #1
0
 public function RightColumnContent()
 {
     if (in_array($this->Action, array('add', 'view', 'edit'))) {
         $languages = Db_Language::getLanguageWithKey();
         $this->TPL->assign('languages', $languages);
         $options = Db_Options::getFulLDetails();
         $product_options = Db_ProductOptions::getOptionsByProductId($this->Id);
         $this->TPL->assign('options', $options);
         $this->TPL->assign('product_options', $product_options);
     }
     if (in_array($this->Action, array('view', 'edit'))) {
         $product = Db_Products::getDetailsById($this->Id);
         $product_trans = Db_ProductTrans::getDetailsById($this->Id);
         $this->TPL->assign('product', $product);
         $this->TPL->assign('product_trans', $product_trans);
     }
     switch ($this->Action) {
         case 'delete':
             if ($this->Id == 0) {
                 break;
             }
             Db_Products::deleteByField('id', $this->Id);
             Db_ProductTrans::deleteAllByField('pt_product_id', $this->Id);
             Db_ProductOptions::deleteAllByField('po_product_id', $this->Id);
             Upload::rrmdir(BASE_PATH . 'files/' . $this->img_path . $this->Id, true);
             $this->Msg->SetMsg($this->_T('success_item_deleted'));
             $this->Redirect($this->PageUrl);
             break;
         case 'save':
             $p_model = getPost('p_model');
             $p_url = getPost('p_url');
             $p_published = isset($_POST['p_published']) ? 1 : 0;
             $p_price = getPost('p_price');
             $p_discount = getPost('p_discount');
             $p_discount_status = isset($_POST['p_discount_status']) ? 1 : 0;
             $pt_title = getPost('pt_title');
             $pt_description = getPost('pt_description');
             $options = getPost('options');
             $product = new Db_Products($this->DB, $this->Id, 'id');
             $product->p_model = $p_model;
             $product->p_url = $p_url;
             $product->p_published = $p_published;
             $product->p_price = $p_price;
             $product->p_discount = $p_discount;
             $product->p_discount_status = $p_discount_status;
             $product->p_type = $this->productType;
             $product->save();
             foreach ($pt_title as $lang => $item) {
                 $product_trans = new Db_ProductTrans();
                 $product_trans->findByFields(array('pt_product_id' => $product->id, 'pt_lang_id' => $lang));
                 $product_trans->pt_title = $pt_title[$lang];
                 $product_trans->pt_description = $pt_description[$lang];
                 $product_trans->pt_lang_id = $lang;
                 $product_trans->pt_product_id = $product->id;
                 $product_trans->save();
             }
             if (!empty($_FILES['p_image']) && $_FILES['p_image']['error'] == 0) {
                 $image = Db_Products::getImageById($product->id);
                 $path = BASE_PATH . 'files' . $this->img_path . $product->id . '/';
                 if (is_dir($path)) {
                     Upload::deleteImage($path, $image, $this->img_sizes);
                 }
                 if ($filename = Upload::uploadImage($path, $_FILES['p_image'], 'product', $this->img_sizes, 'crop')) {
                     $product->p_image = $filename;
                     $product->save();
                 }
             }
             if (!empty($options)) {
                 foreach ($options as $option_id => $option_value) {
                     if (empty($option_value) || empty($option_id)) {
                         continue;
                     }
                     $product_option = new Db_ProductOptions();
                     $product_option->findByFields(array('po_option_id' => $option_id, 'po_product_id' => $product->id));
                     $product_option->po_option_id = $option_id;
                     $product_option->po_product_id = $product->id;
                     $product_option->po_value = $option_value;
                     $product_option->save();
                 }
             }
             $this->Msg->SetMsg($this->_T('success_item_saved'));
             $this->Redirect($this->PageUrl . '?action=view&id=' . $product->id);
             break;
         default:
             $Objects = Db_Products::getObjects($this->productType);
             $ListGrid = false;
             if ($Objects) {
                 $ListGrid = new TGrid();
                 $ListGrid->Spacing = 0;
                 $ListGrid->Width = '100%';
                 $ListGrid->SetClass('table table-bordered table-highlight-head');
                 $ListGrid->AddHeaderRow($this->_T('id'), $this->_T('Title'), $this->_T('Url'), $this->_T('Enabled'), $this->_T('actions'));
                 $ListGrid->BeginBody();
                 foreach ($Objects as $Object) {
                     $Grid_TR = new TGrid_TTR();
                     $Grid_TD = new TGrid_TTD($Object['id'] . getButton('view', $this->PageUrl, 'view', $Object['id']));
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD($Object['title']);
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD($Object['url']);
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD($Object['enabled'] == 1 ? $this->_T('yes') : $this->_T('no'));
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD(getButton('edit', $this->PageUrl, 'edit', $Object['id']) . getButton('delete', $this->PageUrl, 'delete', $Object['id']));
                     $Grid_TD->AddAttr(new TAttr('class', 'align-center'));
                     $Grid_TR->Add($Grid_TD);
                     $ListGrid->AddTR($Grid_TR);
                 }
                 $ListGrid->EndBody();
                 $ListGrid = $ListGrid->Html();
             }
             $this->TPL->assign('ListGrid', $ListGrid);
             break;
     }
     $msg = $this->Msg->Html();
     $this->TPL->assign('msg', $msg);
     $this->TPL->assign('Action', $this->Action);
     $result = $this->TPL->display(null, true);
     $this->Msg->Clear();
     return $result;
 }
Beispiel #2
0
 public function RightColumnContent()
 {
     if (in_array($this->Action, array('add', 'additem', 'edit', 'edititem', 'viewitem'))) {
         $languages = Db_Language::getLanguageWithKey();
         $this->TPL->assign('languages', $languages);
     }
     if (in_array($this->Action, array('view', 'edit'))) {
         $slider = Db_Sliders::getDetailsById($this->Id);
         $this->TPL->assign('slider', $slider);
     }
     if (in_array($this->Action, array('edititem', 'viewitem'))) {
         $slide = Db_SliderItems::getDetailsById($this->Id);
         $slide_trans = Db_SliderItemTrans::getTransById($this->Id);
         $this->TPL->assign('slide', $slide);
         $this->TPL->assign('slide_trans', $slide_trans);
     }
     switch ($this->Action) {
         case 'delete':
             if ($this->Id == 0) {
                 return false;
             }
             $ids = Db_SliderItems::getIdsBySliderId($this->Id);
             Db_Sliders::deleteByField('id', $this->Id);
             Db_SliderItems::deleteAllByField('si_slider_id', $this->Id);
             Db_SliderItemTrans::deleteBySliderItemIds($ids);
             $this->Msg->SetMsg($this->_T('success_item_deleted'));
             $this->Redirect($this->PageUrl);
             break;
         case 'deleteitem':
             Db_SliderItems::deleteByField('id', $this->Id);
             Db_SliderItemTrans::deleteAllByField('sit_slider_item_id', $this->Id);
             $this->Msg->SetMsg($this->_T('success_item_deleted'));
             $this->Redirect($this->PageUrl . '?action=viewitems&id=' . $this->Id);
             break;
         case 'saveitem':
             if ($this->sId == 0) {
                 return '';
             }
             $si_url = getPost('si_url');
             $si_priority = getPost('si_priority');
             $sit_h1 = getPost('sit_h1');
             $sit_h2 = getPost('sit_h2');
             $sit_h3 = getPost('sit_h3');
             $sit_title_link = getPost('sit_title_link');
             $slide = new Db_SliderItems($this->DB, $this->Id, 'id');
             $slide->si_url = $si_url;
             $slide->si_priority = $si_priority;
             $slide->si_slider_id = $this->sId;
             $slide->save();
             foreach ($sit_h1 as $lang => $item) {
                 $slide_trans = new Db_SliderItemTrans();
                 $slide_trans->findByFields(array('sit_slider_item_id' => $slide->id, 'sit_lang_id' => $lang));
                 $slide_trans->sit_h1 = $sit_h1[$lang];
                 $slide_trans->sit_h2 = $sit_h2[$lang];
                 $slide_trans->sit_h3 = $sit_h3[$lang];
                 $slide_trans->sit_title_link = $sit_title_link[$lang];
                 $slide_trans->sit_slider_item_id = $slide->id;
                 $slide_trans->sit_lang_id = $lang;
                 $slide_trans->save();
             }
             if (!empty($_FILES['si_image']) && $_FILES['si_image']['error'] == 0) {
                 $image = Db_SliderItems::getImageById($this->sId);
                 $path = BASE_PATH . 'files' . $this->img_path . $this->sId . DS;
                 if (is_dir($path)) {
                     Upload::deleteImage($path, $image, $this->img_sizes);
                 }
                 if ($image = Upload::uploadImage($path, $_FILES['si_image'], 'slider', $this->img_sizes, 'crop')) {
                     $slide->si_image = $image;
                     $slide->save();
                 }
             }
             $this->Msg->SetMsg($this->_T('success_item_saved'));
             $this->Redirect($this->PageUrl . '?action=viewitem&id=' . $slide->id . '&sid=' . $this->sId);
             break;
         case 'save':
             $s_key = getPost('s_key');
             $s_enabled = isset($_POST['s_enabled']) ? 1 : 0;
             $slider = new Db_Sliders($this->DB, $this->Id, 'id');
             $slider->s_key = $s_key;
             $slider->s_enabled = $s_enabled;
             $slider->save();
             $this->Msg->SetMsg($this->_T('success_item_saved'));
             $this->Redirect($this->PageUrl . '?action=view&id=' . $slider->id);
             break;
         case 'viewitems':
             $Objects = Db_SliderItems::getFulLDetailsBySliderId($this->Id);
             $this->TPL->assign('slider_id', $this->Id);
             $ListGrid = false;
             if ($Objects) {
                 $ListGrid = new TGrid();
                 $ListGrid->Spacing = 0;
                 $ListGrid->Width = '100%';
                 $ListGrid->SetClass('table table-bordered table-highlight-head');
                 $ListGrid->AddHeaderRow($this->_T('id'), $this->_T('Image'), $this->_T('H1'), $this->_T('H2'), $this->_T('H3'), $this->_T('Link title'), $this->_T('Url'), $this->_T('Priority'), $this->_T('actions'));
                 $ListGrid->BeginBody();
                 foreach ($Objects as $Object) {
                     $Grid_TR = new TGrid_TTR();
                     $Grid_TD = new TGrid_TTD($Object['id'] . getButton('view', $this->PageUrl, 'viewitem', $Object['id'], $this->Id));
                     $Grid_TD->AddAttr(new TAttr('class', 'col-md-1'));
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD($Object['image']);
                     $Grid_TD->AddAttr(new TAttr('class', 'col-md-1'));
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD($Object['h1']);
                     $Grid_TD->AddAttr(new TAttr('class', 'col-md-1'));
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD($Object['h2']);
                     $Grid_TD->AddAttr(new TAttr('class', 'col-md-1'));
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD($Object['h3']);
                     $Grid_TD->AddAttr(new TAttr('class', 'col-md-1'));
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD($Object['title_link']);
                     $Grid_TD->AddAttr(new TAttr('class', 'col-md-1'));
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD($Object['url']);
                     $Grid_TD->AddAttr(new TAttr('class', 'col-md-1'));
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD($Object['priority']);
                     $Grid_TD->AddAttr(new TAttr('class', 'col-md-1'));
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD(getButton('edit', $this->PageUrl, 'edititem', $Object['id'], $this->Id) . getButton('delete', $this->PageUrl, 'deleteitem', $Object['id']));
                     $Grid_TD->AddAttr(new TAttr('class', 'align-center col-md-1'));
                     $Grid_TR->Add($Grid_TD);
                     $ListGrid->AddTR($Grid_TR);
                 }
                 $ListGrid->EndBody();
                 $ListGrid = $ListGrid->Html();
             }
             $this->TPL->assign('ListGrid', $ListGrid);
             break;
         default:
             $Objects = Db_Sliders::getObjects();
             $ListGrid = false;
             if ($Objects) {
                 $ListGrid = new TGrid();
                 $ListGrid->Spacing = 0;
                 $ListGrid->Width = '100%';
                 $ListGrid->SetClass('table table-bordered table-highlight-head');
                 $ListGrid->AddHeaderRow($this->_T('id'), $this->_T('Key'), $this->_T('Enabled'), $this->_T('actions'));
                 $ListGrid->BeginBody();
                 foreach ($Objects as $Object) {
                     $Grid_TR = new TGrid_TTR();
                     $Grid_TD = new TGrid_TTD($Object['id'] . getButton('view', $this->PageUrl, 'viewitems', $Object['id']));
                     $Grid_TD->AddAttr(new TAttr('class', 'col-md-1'));
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD($Object['s_key']);
                     $Grid_TD->AddAttr(new TAttr('class', 'col-md-9'));
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD($Object['s_enabled'] == 1 ? $this->_T('yes') : $this->_T('no'));
                     $Grid_TD->AddAttr(new TAttr('class', 'col-md-1'));
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD(getButton('edit', $this->PageUrl, 'edit', $Object['id']) . getButton('delete', $this->PageUrl, 'delete', $Object['id']));
                     $Grid_TD->AddAttr(new TAttr('class', 'align-center col-md-1'));
                     $Grid_TR->Add($Grid_TD);
                     $ListGrid->AddTR($Grid_TR);
                 }
                 $ListGrid->EndBody();
                 $ListGrid = $ListGrid->Html();
             }
             $this->TPL->assign('ListGrid', $ListGrid);
             break;
     }
     $msg = $this->Msg->Html();
     $this->TPL->assign('msg', $msg);
     $this->TPL->assign('Action', $this->Action);
     $result = $this->TPL->display(null, true);
     $this->Msg->Clear();
     return $result;
 }
Beispiel #3
0
    public function RightColumnContent()
    {
        switch ($this->Action) {
            case 'view':
                $this->CheckIdExist();
                $Object = Db_Product::getObjectById($this->Id);
                $this->TPL->assign('Object', $Object);
                $ObjectTrans = Db_ProductTrans::getTransByObjectId($this->Id);
                $this->TPL->assign('ObjectTrans', $ObjectTrans);
                $LanguageModel = Db_Language::getLanguageWithKey();
                $this->TPL->assign('LanguageModel', $LanguageModel);
                $ObjectImages = Db_ProductImages::getImagesByObjectId($this->Id);
                $this->TPL->assign('ObjectImages', $ObjectImages);
                break;
            case 'edit':
                $this->CheckIdExist();
                $Object = Db_Product::getObjectById($this->Id);
                $this->TPL->assign('Object', $Object);
                $ObjectTrans = Db_ProductTrans::getTransByObjectId($this->Id);
                $this->TPL->assign('ObjectTrans', $ObjectTrans);
                $LanguageModel = Db_Language::getLanguageWithKey();
                $this->TPL->assign('LanguageModel', $LanguageModel);
                $types = Db_Type::getSelect($this->LangId, $this->Id);
                $this->TPL->assign('types', $types);
                $Color = Db_Color::getSelect($this->LangId, $this->Id);
                $this->TPL->assign('Color', $Color);
                $categories = Db_Category::getSelect($this->Id);
                $this->TPL->assign('categories', $categories);
                $Brand = Db_Brand::getSelect($this->LangId);
                $this->TPL->assign('Brand', $Brand);
                $ObjectImages = Db_ProductImages::getImagesByObjectId($this->Id);
                $this->TPL->assign('ObjectImages', $ObjectImages);
                break;
            case 'delete':
                if ($this->Id != 0) {
                    Db_Product::deleteByField('id', $this->Id);
                    Db_ProductTrans::deleteByField('pt_product_id', $this->Id, 0);
                    if (is_dir(BASE_PATH . 'files/' . $this->object_path . $this->Id)) {
                        removeDir(BASE_PATH . 'files/' . $this->object_path . $this->Id);
                    }
                    $this->Msg->SetMsg($this->_T('success_item_deleted'));
                    $this->Redirect($this->PageUrl);
                }
                break;
            case 'add':
                $types = Db_Type::getSelect($this->LangId, $this->Id);
                $this->TPL->assign('types', $types);
                $LanguageModel = Db_Language::getLanguageWithKey();
                $this->TPL->assign('LanguageModel', $LanguageModel);
                //                $Feature = Db_Feature::getSelect($this->LangId);
                //                $this->TPL->assign('Feature', $Feature);
                $Color = Db_Color::getSelect($this->LangId);
                $this->TPL->assign('Color', $Color);
                $types = Db_Type::getSelect($this->LangId);
                $this->TPL->assign('types', $types);
                //                $Style = Db_Style::getSelect($this->LangId);
                //                $this->TPL->assign('Style', $Style);
                //                $Brand = Db_Brand::getSelect($this->LangId);
                //                $this->TPL->assign('Brand', $Brand);
                break;
            case 'deleteimages':
                // Db_{database_name_images}
                $ObjectImage = Db_ProductImages::getObjectDetails($this->Id);
                // $ObjectImage['{image_field}']
                if (!empty($ObjectImage) && !empty($ObjectImage['pi_image'])) {
                    // $ObjectImage['{object_id}']
                    Upload::deleteImage(BASE_PATH . '/files' . $this->object_path . $ObjectImage['pi_product_id'] . '/images/', $ObjectImage['pi_image'], $this->imageSizes);
                    $result = Db_ProductImages::deleteByField('id', $this->Id, 1);
                }
                if (isset($result)) {
                    die((string) $this->Id);
                } else {
                    die('error');
                }
                break;
            case 'save':
                if ($this->Id != 0) {
                    $this->CheckIdExist();
                }
                //                dump($_FILES); die;
                $p_new = isset($_POST['p_new']) ? 1 : 0;
                $p_published = isset($_POST['p_published']) ? 1 : 0;
                $p_price = getPost('p_price');
                $p_priority = getPost('p_priority');
                $p_discount = getPost('p_discount');
                $p_discount_status = isset($_POST['p_discount_status']) ? 1 : 0;
                $pt_title = getPost('pt_title');
                $pt_description = getPost('pt_description');
                $p_brand_id = isset($_POST['p_brand_id']) ? getPost('p_brand_id') : '';
                $p_category_id = getPost('p_category_id');
                $p_color = getPost('p_color');
                $p_style = isset($_POST['p_style']) ? getPost('p_style') : '';
                $p_type_id = getPost('p_type_id');
                //                Save data into OBJECT
                $Object = new Db_Product($this->DB, $this->Id, 'id');
                $Object->p_new = $p_new;
                $Object->p_published = $p_published;
                $Object->p_price = $p_price;
                $Object->p_priority = $p_priority;
                $Object->p_discount = $p_discount;
                $Object->p_discount_status = $p_discount_status;
                $Object->p_brand_id = $p_brand_id;
                $Object->p_category_id = !empty($p_category_id) ? implode(',', $p_category_id) : '0';
                $Object->p_color = !empty($p_color) ? implode(',', $p_color) : 0;
                $Object->p_style = $p_style;
                $Object->p_type_id = $p_type_id;
                $Object->save();
                $id = $Object->id;
                $url = Utils::FilterDotURL($pt_title[1]) . '-' . $Object->id;
                $Object->p_url = $url;
                $Object->save();
                //                Save trans values into $ObjectTrans
                foreach ($pt_title as $lang => $title) {
                    $ObjectTrans = new Db_ProductTrans();
                    $ObjectTrans->findByFields(array('pt_product_id' => $id, 'pt_lang_id' => $lang));
                    $ObjectTrans->pt_title = $pt_title[$lang];
                    $ObjectTrans->pt_description = $pt_description[$lang];
                    $ObjectTrans->pt_lang_id = $lang;
                    $ObjectTrans->pt_product_id = $id;
                    $ObjectTrans->save();
                }
                if (!empty($_FILES['p_image']) && $_FILES['p_image']['error'] == 0) {
                    $image = Db_Product::getObjectById($id);
                    if (!empty($image['p_image']) && is_dir(BASE_PATH . 'files/' . $this->object_path . $this->Id)) {
                        removeDir(BASE_PATH . 'files/' . $this->object_path . $this->Id);
                    }
                    $path = BASE_PATH . 'files/' . $this->object_path . '/' . $id . '/';
                    if ($filename = Upload::uploadImageWorkshop($path, $_FILES['p_image'], $this->imageSizes)) {
                        $Object = new Db_Product($this->DB, $id, 'id');
                        $Object->p_image = $filename;
                        $Object->save();
                    }
                }
                $pi_priority = $this->getPost('pi_priority');
                $i_priority = $this->getPost('i_priority');
                if (!empty($_FILES['li_image']) && !empty($_FILES['li_image']['name'])) {
                    $path = BASE_PATH . 'files/' . $this->object_path . '/' . $id . '/images/';
                    $files = fixFilesArray($_FILES['li_image']);
                    $imageNames = array();
                    foreach ($files as $index => $value) {
                        $imageNames[$index] = Upload::uploadImageWorkshop($path, $files[$index], $this->imageSizes);
                    }
                    foreach ($imageNames as $index => $value) {
                        if (!empty($value)) {
                            $ObjectImages = new Db_ProductImages();
                            $ObjectImages->pi_product_id = $id;
                            $ObjectImages->pi_image = $value;
                            $ObjectImages->pi_priority = $pi_priority[$index];
                            $ObjectImages->save();
                        }
                    }
                }
                if ($i_priority) {
                    foreach ($i_priority as $index => $value) {
                        $OldImages = new Db_ProductImages();
                        $OldImages->findByFields(array('id' => $index));
                        $OldImages->pi_priority = $value;
                        $OldImages->save();
                    }
                }
                $this->Msg->SetMsg($this->_T('success_item_saved'));
                $this->Redirect($this->PageUrl . '?action=view&id=' . $id);
                break;
            default:
                $Objects = Db_Product::getObjects();
                $ObjectsTrans = Db_ProductTrans::getTransByLang($this->LangId);
                $ListGrid = false;
                if ($Objects) {
                    $ListGrid = new TGrid();
                    $ListGrid->Spacing = 0;
                    $ListGrid->Width = '100%';
                    $ListGrid->SetClass('table table-bordered table-highlight-head');
                    $ListGrid->AddHeaderRow($this->_T('id'), $this->_T('Title'), $this->_T('Price'), $this->_T('New'), $this->_T('Published'), $this->_T('actions'));
                    $ListGrid->BeginBody();
                    foreach ($Objects as $Object) {
                        $Grid_TR = new TGrid_TTR();
                        $Grid_TD = new TGrid_TTD($Object['id'] . ' (&nbsp;<a href="' . $this->PageUrl . '?action=view&id=' . $Object['id'] . '">' . $this->_T('see') . '</a>&nbsp;)');
                        $Grid_TR->Add($Grid_TD);
                        $Grid_TD = new TGrid_TTD($ObjectsTrans[$Object['id']]['pt_title']);
                        $Grid_TR->Add($Grid_TD);
                        $Grid_TD = new TGrid_TTD($Object['p_price']);
                        $Grid_TR->Add($Grid_TD);
                        $Grid_TD = new TGrid_TTD($Object['p_new'] == 1 ? $this->_T('yes') : $this->_T('no'));
                        $Grid_TR->Add($Grid_TD);
                        $Grid_TD = new TGrid_TTD($Object['p_published'] == 1 ? $this->_T('yes') : $this->_T('no'));
                        $Grid_TR->Add($Grid_TD);
                        $Grid_TD = new TGrid_TTD('
								<a class="bs-tooltip" title="" href="' . $this->PageUrl . '?action=edit&id=' . $Object['id'] . '" data-original-title="' . $this->_T('edit') . '"><i class="icon-pencil"></i></a>
								<a class="bs-tooltip confirm-dialog" data-text="' . _T('sure_you_want_to_delete') . '" title="" href="' . $this->PageUrl . '?action=delete&id=' . $Object['id'] . '" data-original-title="' . $this->_T('delete') . '"><i class="icon-trash"></i></a>
							');
                        $Grid_TD->AddAttr(new TAttr('class', 'align-center'));
                        $Grid_TR->Add($Grid_TD);
                        $ListGrid->AddTR($Grid_TR);
                    }
                    $ListGrid->EndBody();
                    $ListGrid = $ListGrid->Html();
                }
                $this->TPL->assign('ListGrid', $ListGrid);
                break;
        }
        $msg = $this->Msg->Html();
        $this->TPL->assign('msg', $msg);
        $this->TPL->assign('Action', $this->Action);
        $result = $this->TPL->display(null, true);
        $this->Msg->Clear();
        return $result;
    }
Beispiel #4
0
    public function RightColumnContent()
    {
        switch ($this->Action) {
            case 'view':
                $this->CheckIdExist();
                $LakeModel = Db_Lake::getObjectDetails($this->Id);
                $this->TPL->assign('LakeModel', $LakeModel);
                $LakeTransModel = Db_LakeTrans::getObjectTransById($this->Id);
                $this->TPL->assign('LakeTransModel', $LakeTransModel);
                $LakeImageModel = Db_LakeImage::getObjectById($this->Id);
                $this->TPL->assign('LakeImageModel', $LakeImageModel);
                $LocationModel = Db_Location::getLocationByLakeIdAndLangId($this->Id, 2);
                $this->TPL->assign('LocationModel', $LocationModel);
                $LanguageModel = Db_Language::getLanguageWithKey();
                $this->TPL->assign('LanguageModel', $LanguageModel);
                $LakeNearModelSelected = Db_LakeNear::getAllSelectedNearLakesById($this->Id);
                $this->TPL->assign('LakeNearModelSelected', $LakeNearModelSelected);
                break;
            case 'edit':
                $this->CheckIdExist();
                $LakeModel = Db_Lake::getObjectDetails($this->Id);
                $this->TPL->assign('LakeModel', $LakeModel);
                $LakeTransModel = Db_LakeTrans::getObjectTransById($this->Id);
                $this->TPL->assign('LakeTransModel', $LakeTransModel);
                $LocationModel = Db_Location::getAllObjects();
                $this->TPL->assign('LocationModel', $LocationModel);
                $LakeImageModel = Db_LakeImage::getObjectById($this->Id);
                $this->TPL->assign('LakeImageModel', $LakeImageModel);
                $LakeNearModelSelected = Db_LakeNear::getAllSelectedNearLakesById($this->Id);
                $this->TPL->assign('LakeNearModelSelected', $LakeNearModelSelected);
                $LakeNearModel = Db_LakeNear::getAllNearLakesById($this->Id);
                $this->TPL->assign('LakeNearModel', $LakeNearModel);
                $LanguageModel = Db_Language::getLanguageWithKey();
                $this->TPL->assign('LanguageModel', $LanguageModel);
                break;
            case 'delete':
                if ($this->Id != 0) {
                    Db_Lake::deleteByField('id', $this->Id, 1);
                    Db_LakeImage::deleteByField('li_lake_id', $this->Id);
                    Db_LakeNear::deleteByField('ln_lake_id', $this->Id);
                    Db_LakeTrans::deleteByField('lt_lake_id', $this->Id, 3);
                    if (is_dir(BASE_PATH . $this->imageFolderPath . $this->Id)) {
                        removeDir(BASE_PATH . $this->imageFolderPath . $this->Id);
                    }
                    $this->Msg->SetMsg($this->_T('success_item_deleted'));
                    $this->Redirect($this->PageUrl);
                }
                break;
            case 'deletefromlake':
                $LakeImageItem = Db_LakeImage::getObjectDetails($this->Id);
                if (!empty($LakeImageItem) && !empty($LakeImageItem->li_img_name)) {
                    Upload::deleteImage(BASE_PATH . $this->imageFolderPath . '/' . $LakeImageItem->li_lake_id . '/images/', $LakeImageItem->li_img_name, $this->imageSizes);
                    $result = Db_LakeImage::deleteByField('id', $this->Id, 1);
                }
                if ($result) {
                    die($this->Id);
                } else {
                    die('error');
                }
                break;
            case 'add':
                $this->LakeModel = Db_Lake::getObjectDetails($this->Id);
                $this->TPL->assign('LakeModel', $this->LakeModel);
                $this->LakeTransModel = Db_LakeTrans::getObjectTransById($this->Id);
                $this->TPL->assign('LakeTransModel', $this->LakeTransModel);
                $LocationModel = Db_Location::getAllObjects();
                $this->TPL->assign('LocationModel', $LocationModel);
                $LakeNearModel = Db_Lake::getAllAvailableLakesById($this->Id);
                $this->TPL->assign('LakeNearModel', $LakeNearModel);
                $LakeNearSelectedModel = Db_LakeNear::getAllNearLakesById($this->Id);
                $this->TPL->assign('LakeNearSelectedModel', $LakeNearSelectedModel);
                $LanguageModel = Db_Language::getLanguageWithKey();
                $this->TPL->assign('LanguageModel', $LanguageModel);
                break;
            case 'save':
                if ($this->Id != 0) {
                    $this->CheckIdExist();
                }
                /* Variables for Lake =======================================*/
                $l_location = $this->getPost('l_location');
                $l_location_lat = $this->getPost('l_location_lat');
                $l_location_lng = $this->getPost('l_location_lng');
                $l_price_rod = $this->getPost('l_price_rod', 'float');
                $l_price_fider = $this->getPost('l_price_fider', 'float');
                $l_price = $this->getPost('l_price');
                $l_site = $this->getPost('l_site');
                $l_video = stripslashes($this->getPost('l_video', 'any', true));
                $l_date = date(DATE_FORMAT_USER);
                $l_link = $this->getPost('l_link');
                $l_published = $this->getPost('l_published') ? 1 : 0;
                $l_approved = $this->getPost('l_approved') ? 1 : 0;
                $l_recommended = $this->getPost('l_recommended') ? 1 : 0;
                $l_f_restrict = $this->getPost('l_fishing_restrict') ? 1 : 0;
                /* Variables for LakeTrans ===================================*/
                $lt_title = $this->getPost('lt_title');
                $lt_desc = $this->getPost('lt_desc');
                /* Validate form =============================================*/
                if (!$lt_title[2]) {
                    $this->Msg->SetMsg($this->_T('error_mandatory_fields'));
                    $this->Msg->SetError(true);
                    if ($this->Id != 0) {
                        $this->Redirect($this->PageUrl . '?action=edit&id=' . $this->Id);
                    } else {
                        $this->Redirect($this->PageUrl . '?action=add');
                    }
                }
                /* Perform link */
                if ($l_link) {
                    $l_link = Utils::FilterURL($l_link);
                    $LinkModel = Db_Lake::checkLinkUniqueness($l_link, $this->Id);
                    if (!empty($LinkModel)) {
                        $this->Msg->SetMsg($this->_T('error_link_uniqueness'));
                        $this->Msg->SetError(true);
                        if ($this->Id != 0) {
                            $this->Redirect($this->PageUrl . '?action=edit&id=' . $this->Id);
                        } else {
                            $this->Redirect($this->PageUrl . '?action=add');
                        }
                    }
                } else {
                    $l_link = Utils::FilterURL($lt_title[2]);
                }
                /* Save data into Lake table */
                $this->LakeModel = new Db_Lake($this->DB, $this->Id, 'id');
                $this->LakeModel->l_location = $l_location;
                $this->LakeModel->l_location_lat = $l_location_lat;
                $this->LakeModel->l_location_lng = $l_location_lng;
                $this->LakeModel->l_price_rod = $l_price_rod;
                $this->LakeModel->l_price_fider = $l_price_fider;
                $this->LakeModel->l_price = $l_price;
                $this->LakeModel->l_site = $l_site;
                $this->LakeModel->l_date = $l_date;
                $this->LakeModel->l_link = $l_link;
                $this->LakeModel->l_published = $l_published;
                $this->LakeModel->l_approved = $l_approved;
                $this->LakeModel->l_recommended = $l_recommended;
                $this->LakeModel->l_fishing_restrict = $l_f_restrict;
                if (!empty($l_video)) {
                    $this->LakeModel->l_video = $l_video;
                }
                $this->LakeModel->save();
                $lake_id = $this->LakeModel->id;
                $img_link_slider = BASE_PATH . $this->imageFolderPath . $lake_id . '/slider/';
                $img_link_main = BASE_PATH . $this->imageFolderPath . $lake_id . '/main/';
                $l_img_slider = '';
                if (isset($_FILES['l_img_slider']) && $_FILES['l_img_slider']['error'] == 0) {
                    if (is_dir($img_link_slider)) {
                        removeDir($img_link_slider);
                    }
                    $l_img_slider = Upload::uploadImage($img_link_slider, $_FILES['l_img_slider'], 'slider', $this->imageSizes);
                    $this->LakeModel->updateSliderImage($lake_id, $l_img_slider);
                }
                if (isset($_FILES['l_img_main']) && $_FILES['l_img_main']['error'] == 0) {
                    if (is_dir($img_link_main)) {
                        removeDir($img_link_main);
                    }
                    $l_img_main = Upload::uploadImage($img_link_main, $_FILES['l_img_main'], 'main', $this->imageSizes);
                    $this->LakeModel->updateMainImage($lake_id, $l_img_main);
                }
                /* Save data into LakeTrans table */
                $lake_id = $this->LakeModel->id;
                foreach ($lt_title as $langid => $value) {
                    $this->LakeTransModel = new Db_LakeTrans();
                    $this->LakeTransModel->findByFields(array('lt_lake_id' => $lake_id, 'lt_lang_id' => $langid));
                    $this->LakeTransModel->lt_lake_id = $lake_id;
                    $this->LakeTransModel->lt_title = $lt_title[$langid];
                    $this->LakeTransModel->lt_desc = $lt_desc[$langid];
                    $this->LakeTransModel->lt_lang_id = $langid;
                    $this->LakeTransModel->save();
                }
                /* Variables for LakeNear ====================================*/
                $ln_lake_near_id = $this->getPost('ln_lake_near_id');
                Db_LakeNear::deleteAllById($this->Id);
                foreach ($ln_lake_near_id as $lake_near_id) {
                    $LakeNear = new Db_LakeNear($this->DB, $this->Id, 'id');
                    $LakeNear->ln_lake_id = $this->LakeModel->id;
                    $LakeNear->ln_lake_near_id = $lake_near_id;
                    $LakeNear->save();
                }
                /* Save images */
                $img_priority = $this->getPost('img_priority');
                $imgs_link = BASE_PATH . $this->imageFolderPath . $lake_id . '/images/';
                if (isset($_FILES['li_image'])) {
                    $gallery = fixFilesArray($_FILES['li_image']);
                    array_pop($gallery);
                    $imageNames = array();
                    foreach ($gallery as $index => $value) {
                        $imageNames[$index] = Upload::uploadImage($imgs_link, $gallery[$index], 'comment_image', $this->imageSizes);
                    }
                    foreach ($imageNames as $index => $value) {
                        if (!empty($value)) {
                            $newLakeImage = new Db_LakeImage($this->DB);
                            $newLakeImage->li_lake_id = $this->LakeModel->id;
                            $newLakeImage->li_img_name = $value;
                            $newLakeImage->li_priority = $img_priority[$index] ? '0' : $img_priority[$index];
                            $newLakeImage->save();
                        }
                    }
                }
                $this->Msg->SetMsg($this->_T('success_item_saved'));
                $this->Redirect($this->PageUrl . '?action=view&id=' . $this->LakeModel->id);
                break;
            default:
                $Objects = Db_Lake::getAllObjects();
                $ObjectsTrans = Db_LakeTrans::getObjectsTrans($this->LangId);
                $ListGrid = false;
                if ($Objects) {
                    $ListGrid = new TGrid();
                    $ListGrid->Spacing = 0;
                    $ListGrid->Width = '100%';
                    $ListGrid->SetClass('table table-bordered table-highlight-head');
                    $ListGrid->AddHeaderRow($this->_T('id'), $this->_T('title'), $this->_T('price_rod'), $this->_T('price_fiber'), $this->_T('site'), $this->_T('published'), $this->_T('field_approved'), $this->_T('actions'));
                    $ListGrid->BeginBody();
                    foreach ($Objects as $Object) {
                        $Grid_TR = new TGrid_TTR();
                        $Grid_TD = new TGrid_TTD($Object['id'] . ' (&nbsp;<a href="' . $this->PageUrl . '?action=view&id=' . $Object['id'] . '">' . $this->_T('see') . '</a>&nbsp;)');
                        $Grid_TR->Add($Grid_TD);
                        $Grid_TD = new TGrid_TTD(isset($ObjectsTrans[$Object['id']]['lt_title']) ? $ObjectsTrans[$Object['id']]['lt_title'] : '');
                        $Grid_TR->Add($Grid_TD);
                        $Grid_TD = new TGrid_TTD($Object['l_price_rod']);
                        $Grid_TR->Add($Grid_TD);
                        $Grid_TD = new TGrid_TTD($Object['l_price_fider']);
                        $Grid_TR->Add($Grid_TD);
                        $Grid_TD = new TGrid_TTD($Object['l_site']);
                        $Grid_TR->Add($Grid_TD);
                        $Grid_TD = new TGrid_TTD($Object['l_published'] == 1 ? $this->_T('yes') : $this->_T('no'));
                        $Grid_TR->Add($Grid_TD);
                        $Grid_TD = new TGrid_TTD($Object['l_approved'] == 1 ? $this->_T('yes') : $this->_T('no'));
                        $Grid_TR->Add($Grid_TD);
                        $Grid_TD = new TGrid_TTD('
								<a class="bs-tooltip" title="" href="' . $this->PageUrl . '?action=edit&id=' . $Object['id'] . '" data-original-title="' . $this->_T('edit') . '"><i class="icon-pencil"></i></a>
								<a class="bs-tooltip confirm-dialog" data-text="' . _T('sure_you_want_to_delete') . '" title="" href="' . $this->PageUrl . '?action=delete&id=' . $Object['id'] . '" data-original-title="' . $this->_T('delete') . '"><i class="icon-trash"></i></a>
							');
                        $Grid_TD->AddAttr(new TAttr('class', 'align-center'));
                        $Grid_TR->Add($Grid_TD);
                        $ListGrid->AddTR($Grid_TR);
                    }
                    $ListGrid->EndBody();
                    $ListGrid = $ListGrid->Html();
                }
                $this->TPL->assign('ListGrid', $ListGrid);
                break;
        }
        $msg = $this->Msg->Html();
        $this->TPL->assign('msg', $msg);
        $this->TPL->assign('Action', $this->Action);
        $result = $this->TPL->display(null, true);
        $this->Msg->Clear();
        return $result;
    }
Beispiel #5
0
 public function RightColumnContent()
 {
     if (in_array($this->Action, array('view', 'edit', 'add'))) {
         $languages = Db_Language::getLanguageWithKey();
         $this->TPL->assign('languages', $languages);
     }
     if (in_array($this->Action, array('view', 'edit'))) {
         $blog = Db_Blog::getObjectById($this->Id);
         $blog_trans = Db_BlogTrans::getTransById($this->Id);
         $this->TPL->assign('blog', $blog);
         $this->TPL->assign('blog_trans', $blog_trans);
     }
     switch ($this->Action) {
         case 'delete':
             if ($this->Id != 0) {
                 Db_Blog::deleteByField('id', $this->Id);
                 Db_BlogTrans::deleteByField('bt_blog_id', $this->Id, 0);
                 $this->rrmdir(BASE_PATH . 'files/' . $this->img_path . $this->Id, true);
                 $this->Msg->SetMsg($this->_T('success_item_deleted'));
                 $this->Redirect($this->PageUrl);
             }
             break;
         case 'save':
             $b_enabled = isset($_POST['b_enabled']) ? 1 : 0;
             $b_priority = getPost('b_priority');
             $b_date_start = getPost('b_date_start');
             $b_date_end = getPost('b_date_end');
             $b_url = getPost('b_url');
             $bt_title = getPost('bt_title');
             $bt_short_description = getPost('bt_short_description');
             $bt_description = getPost('bt_description');
             $blog = new Db_Blog($this->DB, $this->Id, 'id');
             $blog->b_enabled = $b_enabled;
             $blog->b_priority = $b_priority;
             $blog->b_date_start = $b_date_start;
             $blog->b_date_end = $b_date_end;
             $blog->b_url = $b_url;
             $blog->save();
             foreach ($bt_title as $lang => $item) {
                 $blog_trans = new Db_BlogTrans();
                 $blog_trans->findByFields(array('bt_blog_id' => $blog->id, 'bt_lang_id' => $lang));
                 $blog_trans->bt_blog_id = $blog->id;
                 $blog_trans->bt_title = $bt_title[$lang];
                 $blog_trans->bt_short_description = $bt_short_description[$lang];
                 $blog_trans->bt_description = $bt_description[$lang];
                 $blog_trans->bt_lang_id = $lang;
                 $blog_trans->save();
             }
             if (!empty($_FILES['b_image']) && $_FILES['b_image']['error'] == 0) {
                 $image = Db_Blog::getImageById($blog->id);
                 $path = BASE_PATH . 'files' . $this->img_path . $blog->id . DS;
                 if (is_dir($path)) {
                     Upload::deleteImage($path, $image, $this->img_sizes);
                 }
                 if ($image = Upload::uploadImage($path, $_FILES['b_image'], 'image', $this->img_sizes, 'crop')) {
                     $blog->b_image = $image;
                     $blog->save();
                 }
             }
             $this->Msg->SetMsg($this->_T('success_item_saved'));
             $this->Redirect($this->PageUrl . '?action=view&id=' . $blog->id);
             break;
         default:
             $Objects = Db_Blog::getObjects();
             $ObjectsTrans = Db_BlogTrans::getTransByLang($this->LangId);
             $ListGrid = false;
             if ($Objects) {
                 $ListGrid = new TGrid();
                 $ListGrid->Spacing = 0;
                 $ListGrid->Width = '100%';
                 $ListGrid->SetClass('table table-bordered table-highlight-head');
                 $ListGrid->AddHeaderRow($this->_T('id'), $this->_T('Title'), $this->_T('Url'), $this->_T('Date start'), $this->_T('Date end'), $this->_T('Enabled'), $this->_T('actions'));
                 $ListGrid->BeginBody();
                 foreach ($Objects as $Object) {
                     $Grid_TR = new TGrid_TTR();
                     $Grid_TD = new TGrid_TTD($Object['id'] . getButton('view', $this->PageUrl, 'view', $Object['id']));
                     $Grid_TD->AddAttr(new TAttr('class', 'col-md-1'));
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD($ObjectsTrans[$Object['id']]['bt_title']);
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD($Object['b_url']);
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD($Object['b_date_start']);
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD($Object['b_date_end']);
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD($Object['b_enabled'] == 1 ? $this->_T('yes') : $this->_T('no'));
                     $Grid_TD->AddAttr(new TAttr('class', 'col-md-1'));
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD(getButton('edit', $this->PageUrl, 'edit', $Object['id']) . getButton('delete', $this->PageUrl, 'delete', $Object['id']));
                     $Grid_TD->AddAttr(new TAttr('class', 'align-center col-md-1'));
                     $Grid_TR->Add($Grid_TD);
                     $ListGrid->AddTR($Grid_TR);
                 }
                 $ListGrid->EndBody();
                 $ListGrid = $ListGrid->Html();
             }
             $this->TPL->assign('ListGrid', $ListGrid);
             break;
     }
     $msg = $this->Msg->Html();
     $this->TPL->assign('msg', $msg);
     $this->TPL->assign('Action', $this->Action);
     $result = $this->TPL->display(null, true);
     $this->Msg->Clear();
     return $result;
 }