vendor_main.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class Vendor_Main extends oxAdminDetails
00009 {
00017     public function render()
00018     {
00019         parent::render();
00020 
00021         $soxId = oxConfig::getParameter( "oxid");
00022         // check if we right now saved a new entry
00023         $sSavedID = oxConfig::getParameter( "saved_oxid");
00024         if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) {
00025             $soxId = $sSavedID;
00026             oxSession::deleteVar( "saved_oxid");
00027             $this->_aViewData["oxid"] =  $soxId;
00028             // for reloading upper frame
00029             $this->_aViewData["updatelist"] =  "1";
00030         }
00031 
00032         if ( $soxId != "-1" && isset( $soxId)) {
00033             // load object
00034             $oVendor = oxNew( "oxvendor" );
00035             $oVendor->loadInLang( $this->_iEditLang, $soxId );
00036 
00037             $oOtherLang = $oVendor->getAvailableInLangs();
00038             if (!isset($oOtherLang[$this->_iEditLang])) {
00039                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00040                 $oVendor->loadInLang( key($oOtherLang), $soxId );
00041             }
00042             $this->_aViewData["edit"] =  $oVendor;
00043 
00044             // category tree
00045             $sChosenArtCat = $this->_getCategoryTree( "artcattree", oxConfig::getParameter( "artcat"));
00046 
00047             //Disable editing for derived articles
00048             if ($oVendor->isDerived())
00049                $this->_aViewData['readonly'] = true;
00050 
00051             // remove already created languages
00052             $aLang = array_diff ( oxLang::getInstance()->getLanguageNames(), $oOtherLang);
00053             if ( count( $aLang))
00054                 $this->_aViewData["posslang"] = $aLang;
00055 
00056             foreach ( $oOtherLang as $id => $language) {
00057                 $oLang= new oxStdClass();
00058                 $oLang->sLangDesc = $language;
00059                 $oLang->selected = ($id == $this->_iEditLang);
00060                 $this->_aViewData["otherlang"][$id] = clone $oLang;
00061             }
00062         }
00063 
00064         if ( oxConfig::getParameter("aoc") ) {
00065 
00066             $aColumns = array();
00067             include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00068             $this->_aViewData['oxajax'] = $aColumns;
00069 
00070             return "popups/vendor_main.tpl";
00071         }
00072         return "vendor_main.tpl";
00073     }
00074 
00080     public function save()
00081     {
00082 
00083         $soxId   = oxConfig::getParameter( "oxid");
00084         $aParams = oxConfig::getParameter( "editval");
00085 
00086         if ( !isset( $aParams['oxvendor__oxactive']))
00087             $aParams['oxvendor__oxactive'] = 0;
00088 
00089             // shopid
00090             $sShopID = oxSession::getVar( "actshop");
00091             $aParams['oxvendor__oxshopid'] = $sShopID;
00092 
00093         $oVendor = oxNew( "oxvendor" );
00094 
00095         if ( $soxId != "-1")
00096             $oVendor->loadInLang( $this->_iEditLang, $soxId );
00097         else {
00098             $aParams['oxvendor__oxid'] = null;
00099         }
00100 
00101 
00102         //$aParams = $oVendor->ConvertNameArray2Idx( $aParams);
00103         $oVendor->setLanguage(0);
00104         $oVendor->assign( $aParams);
00105         $oVendor->setLanguage($this->_iEditLang);
00106         $oVendor = oxUtilsFile::getInstance()->processFiles( $oVendor );
00107         $oVendor->save();
00108         $this->_aViewData["updatelist"] = "1";
00109 
00110         // set oxid if inserted
00111         if ( $soxId == "-1")
00112             oxSession::setVar( "saved_oxid", $oVendor->oxvendor__oxid->value);
00113 
00114         return $this->autosave();
00115     }
00116 
00122     public function saveinnlang()
00123     {
00124         $soxId      = oxConfig::getParameter( "oxid");
00125         $aParams    = oxConfig::getParameter( "editval");
00126 
00127         if ( !isset( $aParams['oxvendor__oxactive']))
00128             $aParams['oxvendor__oxactive'] = 0;
00129 
00130             // shopid
00131             $sShopID = oxSession::getVar( "actshop");
00132             $aParams['oxvendor__oxshopid'] = $sShopID;
00133 
00134         $oVendor = oxNew( "oxvendor" );
00135 
00136         if ( $soxId != "-1")
00137             $oVendor->loadInLang( $this->_iEditLang, $soxId );
00138         else {
00139             $aParams['oxvendor__oxid'] = null;
00140         }
00141 
00142 
00143         //$aParams = $oVendor->ConvertNameArray2Idx( $aParams);
00144         $oVendor->setLanguage(0);
00145         $oVendor->assign( $aParams);
00146         $oVendor->setLanguage($this->_iEditLang);
00147         $oVendor = oxUtilsFile::getInstance()->processFiles( $oVendor );
00148         $oVendor->save();
00149         $this->_aViewData["updatelist"] = "1";
00150 
00151         // set oxid if inserted
00152         if ( $soxId == "-1")
00153             oxSession::setVar( "saved_oxid", $oVendor->oxvendor__oxid->value);
00154 
00155         return $this->autosave();
00156     }
00157 
00163     public function removearticle()
00164     {
00165         $aRemoveArt = oxConfig::getParameter( "artinthiscat");
00166         $soxId      = oxConfig::getParameter( "oxid");
00167 
00168 
00169         if ( isset( $aRemoveArt) && $aRemoveArt) {
00170             $sSelect =  "update oxarticles set oxvendorid = null where oxid in ( ";
00171             $blSep = false;
00172             foreach ($aRemoveArt as $sRem) {
00173                 if ( $blSep)
00174                     $sSelect .= ",";
00175                 $sSelect .= "'$sRem'";
00176                 $blSep = true;
00177             }
00178             $sSelect .= ")";
00179 
00180             oxDb::getDb()->Execute( $sSelect);
00181 
00182                 // resetting article count
00183                 oxUtilsCount::getInstance()->resetVendorArticleCount($soxId);
00184         }
00185     }
00186 
00192     public function addarticle()
00193     {
00194         $aAddArticle = oxConfig::getParameter( "allartincat");
00195         $soxId       = oxConfig::getParameter( "oxid");
00196 
00197 
00198         if ( isset( $aAddArticle) && $aAddArticle) {
00199             $sSelect =  "update oxarticles set oxvendorid = '$soxId' where oxid in ( ";
00200             $blSep = false;
00201             foreach ($aAddArticle as $sRem) {
00202                 if ( $blSep)
00203                     $sSelect .= ",";
00204                 $sSelect .= "'$sRem'";
00205                 $blSep = true;
00206             }
00207             $sSelect .= ")";
00208 
00209             oxDb::getDb()->Execute( $sSelect);
00210 
00211                 // resetting article count
00212                 oxUtilsCount::getInstance()->resetVendorArticleCount($soxId);
00213         }
00214     }
00215 }

Generated on Thu Dec 4 12:04:56 2008 for OXID eShop CE by  doxygen 1.5.5