oxerptype_orderarticle.php

Go to the documentation of this file.
00001 <?php
00002 
00003 require_once 'oxerptype.php';
00004 
00008 class oxERPType_OrderArticle extends oxERPType
00009 {
00014     protected $_aFieldListVersions = array(
00015         '1' => array(
00016             'OXID'          => 'OXID',
00017             'OXORDERID'     => 'OXORDERID',
00018             'OXAMOUNT'      => 'OXAMOUNT',
00019             'OXARTID'       => 'OXARTID',
00020             'OXARTNUM'      => 'OXARTNUM',
00021             'OXTITLE'       => 'OXTITLE',
00022             'OXSHORTDESC'   => 'OXSHORTDESC',
00023             'OXSELVARIANT'  => 'OXSELVARIANT',
00024             'OXNETPRICE'    => 'OXNETPRICE',
00025             'OXBRUTPRICE'   => 'OXBRUTPRICE',
00026             'OXVAT'         => 'OXVAT',
00027             'OXPERSPARAM'   => 'OXPERSPARAM', //that value is a array, therefore it can be added in the way val1,val2 etc. (its written serialized in the db)
00028             'OXPRICE'       => 'OXPRICE',
00029             'OXBPRICE'      => 'OXBPRICE',
00030             'OXTPRICE'      => 'OXTPRICE',
00031             'OXWRAPID'      => 'OXWRAPID',
00032             'OXEXTURL'      => 'OXEXTURL',
00033             'OXURLDESC'     => 'OXURLDESC',
00034             'OXURLIMG'      => 'OXURLIMG',
00035             'OXTHUMB'      => 'OXTHUMB',
00036             'OXPIC1'        => 'OXPIC1',
00037             'OXPIC2'        => 'OXPIC2',
00038             'OXPIC3'        => 'OXPIC3',
00039             'OXPIC4'        => 'OXPIC4',
00040             'OXPIC5'        => 'OXPIC5',
00041             'OXWEIGHT'      => 'OXWEIGHT',
00042             'OXSTOCK'       => 'OXSTOCK',
00043             'OXDELIVERY'    => 'OXDELIVERY',
00044             'OXINSERT'      => 'OXINSERT',
00045             'OXTIMESTAMP'   => 'OXTIMESTAMP',
00046             'OXLENGTH'      => 'OXLENGTH',
00047             'OXWIDTH'       => 'OXWIDTH',
00048             'OXHEIGHT'      => 'OXHEIGHT',
00049             'OXAKTION'      => 'OXAKTION',
00050             'OXFILE'        => 'OXFILE',
00051             'OXSEARCHKEYS'  => 'OXSEARCHKEYS',
00052             'OXTEMPLATE'    => 'OXTEMPLATE',
00053             'OXQUESTIONEMAIL'=> 'OXQUESTIONEMAIL',
00054             'OXISSEARCH'    => 'OXISSEARCH',
00055             'OXFOLDER'      => 'OXFOLDER',
00056             'OXSUBCLASS'    => 'OXSUBCLASS',
00057             'OXSTORNO'      => 'OXSTORNO',
00058             'OXORDERSHOPID' => 'OXORDERSHOPID',
00059             'OXTOTALVAT'    => 'OXTOTALVAT',
00060             'OXERPSTATUS'   => 'OXERPSTATUS'
00061         ),
00062         '2' => array(
00063             'OXID' => 'OXID',
00064             'OXORDERID' => 'OXORDERID',
00065             'OXAMOUNT' => 'OXAMOUNT',
00066             'OXARTID' => 'OXARTID',
00067             'OXARTNUM' => 'OXARTNUM',
00068             'OXTITLE' => 'OXTITLE',
00069             'OXSHORTDESC' => 'OXSHORTDESC',
00070             'OXSELVARIANT' => 'OXSELVARIANT',
00071             'OXNETPRICE' => 'OXNETPRICE',
00072             'OXBRUTPRICE' => 'OXBRUTPRICE',
00073             'OXVATPRICE' => 'OXVATPRICE',
00074             'OXVAT' => 'OXVAT',
00075             'OXPERSPARAM' => 'OXPERSPARAM',
00076             'OXPRICE' => 'OXPRICE',
00077             'OXBPRICE' => 'OXBPRICE',
00078             'OXNPRICE' => 'OXNPRICE',
00079             'OXWRAPID' => 'OXWRAPID',
00080             'OXEXTURL' => 'OXEXTURL',
00081             'OXURLDESC' => 'OXURLDESC',
00082             'OXURLIMG' => 'OXURLIMG',
00083             'OXTHUMB' => 'OXTHUMB',
00084             'OXPIC1' => 'OXPIC1',
00085             'OXPIC2' => 'OXPIC2',
00086             'OXPIC3' => 'OXPIC3',
00087             'OXPIC4' => 'OXPIC4',
00088             'OXPIC5' => 'OXPIC5',
00089             'OXWEIGHT' => 'OXWEIGHT',
00090             'OXSTOCK' => 'OXSTOCK',
00091             'OXDELIVERY' => 'OXDELIVERY',
00092             'OXINSERT' => 'OXINSERT',
00093             'OXTIMESTAMP' => 'OXTIMESTAMP',
00094             'OXLENGTH' => 'OXLENGTH',
00095             'OXWIDTH' => 'OXWIDTH',
00096             'OXHEIGHT' => 'OXHEIGHT',
00097             'OXFILE' => 'OXFILE',
00098             'OXSEARCHKEYS' => 'OXSEARCHKEYS',
00099             'OXTEMPLATE' => 'OXTEMPLATE',
00100             'OXQUESTIONEMAIL' => 'OXQUESTIONEMAIL',
00101             'OXISSEARCH' => 'OXISSEARCH',
00102             'OXFOLDER' => 'OXFOLDER',
00103             'OXSUBCLASS' => 'OXSUBCLASS',
00104             'OXSTORNO' => 'OXSTORNO',
00105             'OXORDERSHOPID' => 'OXORDERSHOPID',
00106             'OXERPSTATUS' => 'OXERPSTATUS',
00107         ),
00108     );
00109 
00115     public function __construct()
00116     {
00117         parent::__construct();
00118 
00119         $this->_sTableName = 'oxorderarticles';
00120         $this->_sShopObjectName = 'oxorderarticle';
00121     }
00122 
00132     public function getSQL( $sWhere, $iLanguage = 0, $iShopID = 1)
00133     {
00134         if ( strstr( $sWhere, 'where')) {
00135             $sWhere .= ' and ';
00136         } else {
00137             $sWhere .= ' where ';
00138         }
00139 
00140         $sWhere .= 'oxordershopid = \''.$iShopID.'\'';
00141         return parent::getSQL( $sWhere, $iLanguage, $iShopID );
00142     }
00143 
00151     public function checkWriteAccess($sOxid)
00152     {
00153         $myConfig = oxConfig::getInstance();
00154 
00155         $oDB = oxDb::getDb();
00156 
00157         $sSql = "select oxordershopid from ". $this->getTableName($myConfig->getShopId()) ." where oxid = '". $sOxid ."'";
00158         $sRes = $oDB->getOne($sSql);
00159 
00160         if ( $sRes && $sRes != $myConfig->getShopId() ) {
00161             throw new Exception( oxERPBase::$ERROR_USER_NO_RIGHTS );
00162         }
00163     }
00164 
00174     protected function getSqlFieldName($sField, $iLanguage = 0, $iShopID = 1)
00175     {
00176         if ('1' == oxERPBase::getUsedDbFieldsVersion()) {
00177             switch ($sField) {
00178                 case 'OXTOTALVAT':
00179                     // We need to round this value here
00180                     return "round(OXVATPRICE * OXAMOUNT, 5) as OXTOTALVAT";
00181                 case 'OXTPRICE':
00182                 case 'OXAKTION':
00183                     return "'' as $sField";
00184             }
00185         }
00186         return parent::getSqlFieldName($sField, $iLanguage, $iShopID);
00187     }
00188 
00196     public function addExportData($aFields)
00197     {
00198         if ( isset( $aFields['OXTOTALVAT'] ) ) {
00199             // And we need to cast this value here, to remove trailing zeroes added after mysql round
00200             $aFields['OXTOTALVAT'] = (double) $aFields['OXTOTALVAT'];
00201         }
00202 
00203         if ( strlen( $aFields['OXPERSPARAM'] ) ) {
00204             $aPersVals = @unserialize($aFields['OXPERSPARAM']);
00205             if ( is_array( $aPersVals ) ) {
00206                 $aFields['OXPERSPARAM'] = implode( '|', $aPersVals );
00207             }
00208         }
00209         return $aFields;
00210     }
00211 
00212 
00222     protected function _preAssignObject($oShopObject, $aData, $blAllowCustomShopId)
00223     {
00224         $aData = parent::_preAssignObject($oShopObject, $aData, $blAllowCustomShopId);
00225         if ('1' == oxERPBase::getUsedDbFieldsVersion()) {
00226             $oDb = oxDb::getDb();
00227             if ($aData['OXAMOUNT']) {
00228                 $aData['OXVATPRICE'] = $aData['OXTOTALVAT'] / $aData['OXAMOUNT'];
00229             }
00230         }
00231 
00232         // check if data is not serialized
00233         $aPersVals = @unserialize($aData['OXPERSPARAM']);
00234         if (!is_array($aPersVals)) {
00235             // data is a string with | separation, prepare for oxid
00236             $aPersVals = explode( "|", $aData['OXPERSPARAM']);
00237             $aData['OXPERSPARAM'] = serialize($aPersVals);
00238         }
00239 
00240         return $aData;
00241     }
00242 }

Generated on Wed Apr 22 12:26:30 2009 for OXID eShop CE by  doxygen 1.5.5