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 oxStdClass();
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 $oArticle->setLanguage( 0 );
00092
00093
00094 if ( !$oArticle->oxarticles__oxparentid->value && !isset( $aParams['oxarticles__oxremindactive'])) {
00095 $aParams['oxarticles__oxremindactive'] = 0;
00096 }
00097
00098 $oArticle->assign( $aParams );
00099
00100
00101 $oArticle->setLanguage( $this->_iEditLang );
00102 $oArticle = oxUtilsFile::getInstance()->processFiles( $oArticle );
00103
00104 $oArticle->resetRemindStatus();
00105
00106 $oArticle->updateVariantsRemind();
00107
00108 $oArticle->save();
00109 }
00110
00119 public function addprice( $sOXID = null, $aUpdateParams = null )
00120 {
00121 $myConfig = $this->getConfig();
00122
00123
00124 $sOxArtId = $this->getEditObjectId();
00125
00126 $aParams = oxConfig::getParameter( "editval" );
00127
00128 if ( !is_array($aParams) ) {
00129 return;
00130 }
00131
00132 if ( isset( $aUpdateParams ) && is_array( $aUpdateParams ) ) {
00133 $aParams = array_merge( $aParams, $aUpdateParams );
00134 }
00135
00136
00137 foreach ( $aParams as $key => $sParam ) {
00138 $aParams[$key] = str_replace( ",", ".", $sParam );
00139 }
00140
00141 $sShopID = $myConfig->getShopID();
00142 $aParams['oxprice2article__oxshopid'] = $sShopID;
00143
00144 if ( isset( $sOXID ) ) {
00145 $aParams['oxprice2article__oxid'] = $sOXID;
00146 }
00147
00148 $aParams['oxprice2article__oxartid'] = $sOxArtId;
00149 if ( !isset( $aParams['oxprice2article__oxamount'] ) || !$aParams['oxprice2article__oxamount'] ) {
00150 $aParams['oxprice2article__oxamount'] = "1";
00151 }
00152
00153 if ( !$myConfig->getConfigParam( 'blAllowUnevenAmounts' ) ) {
00154 $aParams['oxprice2article__oxamount'] = round( ( string ) $aParams['oxprice2article__oxamount'] );
00155 $aParams['oxprice2article__oxamountto'] = round( ( string ) $aParams['oxprice2article__oxamountto'] );
00156 }
00157
00158 $dPrice = $aParams['price'];
00159 $sType = $aParams['pricetype'];
00160
00161 $oArticlePrice = oxNew( "oxbase" );
00162 $oArticlePrice->init( "oxprice2article" );
00163 $oArticlePrice->assign( $aParams );
00164
00165 $oArticlePrice->$sType = new oxField( $dPrice );
00166
00167
00168
00169 if ($oArticlePrice->$sType->value &&
00170 $oArticlePrice->oxprice2article__oxamount->value &&
00171 $oArticlePrice->oxprice2article__oxamountto->value &&
00172 is_numeric( $oArticlePrice->$sType->value ) &&
00173 is_numeric( $oArticlePrice->oxprice2article__oxamount->value ) &&
00174 is_numeric( $oArticlePrice->oxprice2article__oxamountto->value ) &&
00175 $oArticlePrice->oxprice2article__oxamount->value <= $oArticlePrice->oxprice2article__oxamountto->value
00176 ) {
00177 $oArticlePrice->save();
00178 }
00179
00180 }
00181
00187 public function updateprices()
00188 {
00189 $aParams = oxConfig::getParameter( "updateval" );
00190 if ( is_array( $aParams ) ) {
00191 foreach ( $aParams as $soxId => $aStockParams ) {
00192 $this->addprice( $soxId, $aStockParams );
00193 }
00194 }
00195 }
00196
00197
00198
00204 public function deleteprice()
00205 {
00206
00207 $oDb = oxDb::getDb();
00208 $sPriceId = $oDb->quote( oxConfig::getParameter("priceid" ) );
00209 $sId = $oDb->quote( $this->getEditObjectId() );
00210 $oDb->execute( "delete from oxprice2article where oxid = {$sPriceId} and oxartid = {$sId}" );
00211 }
00212
00213 }