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 $oArticle->oxarticles__oxremindactive = new oxField( $oParentArticle->oxarticles__oxremindactive->value );
00051 $this->_aViewData["parentarticle"] = $oParentArticle;
00052 $this->_aViewData["oxparentid"] = $oArticle->oxarticles__oxparentid->value;
00053 }
00054
00055 $sShopID = $myConfig->getShopID();
00056 $oPriceList = oxNew("oxlist");
00057 $oPriceList->init( 'oxbase', "oxprice2article" );
00058 $sQ = "select * from oxprice2article where oxartid = '$soxId' and oxshopid = '$sShopID' and (oxamount > 0 or oxamountto > 0) order by oxamount ";
00059 $oPriceList->selectstring( $sQ );
00060
00061 $this->_aViewData["amountprices"] = $oPriceList;
00062
00063 }
00064
00065 return "article_stock.tpl";
00066 }
00067
00073 public function save()
00074 {
00075 parent::save();
00076
00077 $soxId = $this->getEditObjectId();
00078 $aParams = oxConfig::getParameter( "editval");
00079
00080
00081 if ( !isset( $aParams['oxarticles__oxremindactive'])) {
00082 $aParams['oxarticles__oxremindactive'] = 0;
00083 }
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 $oArticle->assign( $aParams );
00093
00094
00095 $oArticle->setLanguage( $this->_iEditLang );
00096 $oArticle = oxUtilsFile::getInstance()->processFiles( $oArticle );
00097
00098 if ( $oArticle->oxarticles__oxremindactive->value &&
00099 $oArticle->oxarticles__oxremindamount->value <= $oArticle->oxarticles__oxstock->value ) {
00100 $oArticle->oxarticles__oxremindactive->value = 1;
00101 }
00102
00103 $oArticle->save();
00104 }
00105
00111 public function addprice()
00112 {
00113 $myConfig = $this->getConfig();
00114
00115
00116 $soxId = $this->getEditObjectId();
00117 $aParams = oxConfig::getParameter( "editval" );
00118
00119
00120 foreach ( $aParams as $key => $sParam ) {
00121 $aParams[$key] = str_replace( ",", ".", $sParam );
00122 }
00123
00124 $sShopID = $myConfig->getShopID();
00125 $aParams['oxprice2article__oxshopid'] = $sShopID;
00126
00127 $aParams['oxprice2article__oxartid'] = $soxId;
00128 if ( !isset( $aParams['oxprice2article__oxamount'] ) || !$aParams['oxprice2article__oxamount'] ) {
00129 $aParams['oxprice2article__oxamount'] = "1";
00130 }
00131
00132 if ( !$myConfig->getConfigParam( 'blAllowUnevenAmounts' ) ) {
00133 $aParams['oxprice2article__oxamount'] = round( ( string ) $aParams['oxprice2article__oxamount'] );
00134 $aParams['oxprice2article__oxamountto'] = round( ( string ) $aParams['oxprice2article__oxamountto'] );
00135 }
00136
00137 $dPrice = $aParams['price'];
00138 $sType = $aParams['pricetype'];
00139
00140 $oArticlePrice = oxNew( "oxbase" );
00141 $oArticlePrice->init( "oxprice2article" );
00142 $oArticlePrice->assign( $aParams );
00143
00144 $oArticlePrice->$sType = new oxField( $dPrice );
00145
00146
00147
00148 if ($oArticlePrice->$sType->value &&
00149 $oArticlePrice->oxprice2article__oxamount->value &&
00150 $oArticlePrice->oxprice2article__oxamountto->value &&
00151 is_numeric( $oArticlePrice->$sType->value ) &&
00152 is_numeric( $oArticlePrice->oxprice2article__oxamount->value ) &&
00153 is_numeric( $oArticlePrice->oxprice2article__oxamountto->value ) &&
00154 $oArticlePrice->oxprice2article__oxamount->value <= $oArticlePrice->oxprice2article__oxamountto->value
00155 ) {
00156 $oArticlePrice->save();
00157 }
00158
00159 }
00160
00166 public function deleteprice()
00167 {
00168
00169 $oDb = oxDb::getDb();
00170 $sPriceId = $oDb->quote( oxConfig::getParameter("priceid" ) );
00171 $sId = $oDb->quote( $this->getEditObjectId() );
00172 $oDb->execute( "delete from oxprice2article where oxid = {$sPriceId} and oxartid = {$sId}" );
00173 }
00174
00175 }