Go to the documentation of this file.00001 <?php
00002
00009 class Article_Stock extends oxAdminDetails
00010 {
00017 public function render()
00018 {
00019 $myConfig = $this->getConfig();
00020
00021 parent::render();
00022
00023 $this->_aViewData["edit"] = $oArticle = oxNew( "oxarticle");
00024
00025 $soxId = $this->getEditObjectId();
00026 if ( $soxId != "-1" && isset( $soxId)) {
00027
00028
00029 $oArticle->loadInLang( $this->_iEditLang, $soxId );
00030
00031
00032 $oOtherLang = $oArticle->getAvailableInLangs();
00033 if (!isset($oOtherLang[$this->_iEditLang])) {
00034
00035 $oArticle->loadInLang( key($oOtherLang), $soxId );
00036 }
00037
00038 foreach ( $oOtherLang as $id => $language) {
00039 $oLang= new stdClass();
00040 $oLang->sLangDesc = $language;
00041 $oLang->selected = ($id == $this->_iEditLang);
00042 $this->_aViewData["otherlang"][$id] = clone $oLang;
00043 }
00044
00045
00046
00047 if ( $oArticle->oxarticles__oxparentid->value) {
00048 $oParentArticle = oxNew( "oxarticle");
00049 $oParentArticle->load( $oArticle->oxarticles__oxparentid->value);
00050 $this->_aViewData["parentarticle"] = $oParentArticle;
00051 $this->_aViewData["oxparentid"] = $oArticle->oxarticles__oxparentid->value;
00052 }
00053
00054 if ( $myConfig->getConfigParam( 'blMallInterchangeArticles' ) ) {
00055 $sShopSelect = '1';
00056 } else {
00057 $sShopID = $myConfig->getShopID();
00058 $sShopSelect = " oxshopid = '$sShopID' ";
00059 }
00060
00061 $oPriceList = oxNew("oxlist");
00062 $oPriceList->init( 'oxbase', "oxprice2article" );
00063 $sQ = "select * from oxprice2article where oxartid = '$soxId' and {$sShopSelect} and (oxamount > 0 or oxamountto > 0) order by oxamount ";
00064 $oPriceList->selectstring( $sQ );
00065
00066 $this->_aViewData["amountprices"] = $oPriceList;
00067
00068 }
00069
00070 return "article_stock.tpl";
00071 }
00072
00078 public function save()
00079 {
00080 parent::save();
00081
00082 $soxId = $this->getEditObjectId();
00083 $aParams = oxConfig::getParameter( "editval");
00084
00085
00086 $sShopID = oxSession::getVar( "actshop");
00087 $aParams['oxarticles__oxshopid'] = $sShopID;
00088
00089 $oArticle = oxNew( "oxarticle");
00090 $oArticle->loadInLang( $this->_iEditLang, $soxId );
00091
00092 $oArticle->setLanguage( 0 );
00093
00094
00095 if ( !$oArticle->oxarticles__oxparentid->value && !isset( $aParams['oxarticles__oxremindactive'])) {
00096 $aParams['oxarticles__oxremindactive'] = 0;
00097 }
00098
00099 $oArticle->assign( $aParams );
00100
00101
00102 $oArticle->setLanguage( $this->_iEditLang );
00103 $oArticle = oxRegistry::get("oxUtilsFile")->processFiles( $oArticle );
00104
00105 $oArticle->resetRemindStatus();
00106
00107 $oArticle->updateVariantsRemind();
00108
00109 $oArticle->save();
00110 }
00111
00120 public function addprice( $sOXID = null, $aUpdateParams = null )
00121 {
00122 $myConfig = $this->getConfig();
00123
00124
00125 $sOxArtId = $this->getEditObjectId();
00126
00127
00128
00129 $aParams = oxConfig::getParameter( "editval" );
00130
00131 if ( !is_array($aParams) ) {
00132 return;
00133 }
00134
00135 if ( isset( $aUpdateParams ) && is_array( $aUpdateParams ) ) {
00136 $aParams = array_merge( $aParams, $aUpdateParams );
00137 }
00138
00139
00140 foreach ( $aParams as $key => $sParam ) {
00141 $aParams[$key] = str_replace( ",", ".", $sParam );
00142 }
00143
00144 $aParams['oxprice2article__oxshopid'] = $myConfig->getShopID();
00145
00146 if ( isset( $sOXID ) ) {
00147 $aParams['oxprice2article__oxid'] = $sOXID;
00148 }
00149
00150 $aParams['oxprice2article__oxartid'] = $sOxArtId;
00151 if ( !isset( $aParams['oxprice2article__oxamount'] ) || !$aParams['oxprice2article__oxamount'] ) {
00152 $aParams['oxprice2article__oxamount'] = "1";
00153 }
00154
00155 if ( !$myConfig->getConfigParam( 'blAllowUnevenAmounts' ) ) {
00156 $aParams['oxprice2article__oxamount'] = round( ( string ) $aParams['oxprice2article__oxamount'] );
00157 $aParams['oxprice2article__oxamountto'] = round( ( string ) $aParams['oxprice2article__oxamountto'] );
00158 }
00159
00160 $dPrice = $aParams['price'];
00161 $sType = $aParams['pricetype'];
00162
00163 $oArticlePrice = oxNew( "oxbase" );
00164 $oArticlePrice->init( "oxprice2article" );
00165 $oArticlePrice->assign( $aParams );
00166
00167 $oArticlePrice->$sType = new oxField( $dPrice );
00168
00169
00170 if ($oArticlePrice->$sType->value &&
00171 $oArticlePrice->oxprice2article__oxamount->value &&
00172 $oArticlePrice->oxprice2article__oxamountto->value &&
00173 is_numeric( $oArticlePrice->$sType->value ) &&
00174 is_numeric( $oArticlePrice->oxprice2article__oxamount->value ) &&
00175 is_numeric( $oArticlePrice->oxprice2article__oxamountto->value ) &&
00176 $oArticlePrice->oxprice2article__oxamount->value <= $oArticlePrice->oxprice2article__oxamountto->value
00177 ) {
00178 $oArticlePrice->save();
00179 }
00180
00181
00182 $oArticle = oxNew( "oxArticle");
00183 $oArticle->loadInLang( $this->_iEditLang, $sOxArtId );
00184
00185 if ( ( $aParams['price'] >= $oArticle->oxarticles__oxprice->value) && ($aParams['pricetype'] == 'oxprice2article__oxaddabs' ) ) {
00186 if ( is_null($sOXID) ) {
00187 $sOXID = $oArticlePrice->getId();
00188 }
00189 $this->_aViewData["errorscaleprice"][] = $sOXID;
00190 }
00191
00192 }
00193
00199 public function updateprices()
00200 {
00201
00202 $aParams = oxConfig::getParameter( "updateval" );
00203 if ( is_array( $aParams ) ) {
00204 foreach ( $aParams as $soxId => $aStockParams ) {
00205 $this->addprice( $soxId, $aStockParams );
00206 }
00207 }
00208 }
00209
00210
00211
00217 public function deleteprice()
00218 {
00219
00220 $oDb = oxDb::getDb();
00221 $sPriceId = $oDb->quote( oxConfig::getParameter("priceid" ) );
00222 $sId = $oDb->quote( $this->getEditObjectId() );
00223 $oDb->execute( "delete from oxprice2article where oxid = {$sPriceId} and oxartid = {$sId}" );
00224 }
00225
00226 }