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         $oStr = getStr();
00135         if ( $oStr->strstr( $sWhere, 'where')) {
00136             $sWhere .= ' and ';
00137         } else {
00138             $sWhere .= ' where ';
00139         }
00140 
00141         $sWhere .= 'oxordershopid = \''.$iShopID.'\'';
00142         return parent::getSQL( $sWhere, $iLanguage, $iShopID );
00143     }
00144 
00152     public function checkWriteAccess($sOxid)
00153     {
00154         $myConfig = oxConfig::getInstance();
00155 
00156         $oDB = oxDb::getDb();
00157 
00158         $sSql = "select oxordershopid from ". $this->getTableName($myConfig->getShopId()) ." where oxid = ".$oDB->quote( $sOxid );
00159         $sRes = $oDB->getOne($sSql);
00160 
00161         if ( $sRes && $sRes != $myConfig->getShopId() ) {
00162             throw new Exception( oxERPBase::$ERROR_USER_NO_RIGHTS );
00163         }
00164     }
00165 
00175     protected function getSqlFieldName($sField, $iLanguage = 0, $iShopID = 1)
00176     {
00177         if ('1' == oxERPBase::getUsedDbFieldsVersion()) {
00178             switch ($sField) {
00179                 case 'OXTOTALVAT':
00180                     // We need to round this value here
00181                     return "round(OXVATPRICE * OXAMOUNT, 5) as OXTOTALVAT";
00182                     break;
00183                 case 'OXTPRICE':
00184                 case 'OXAKTION':
00185                     return "'' as $sField";
00186                     break;
00187             }
00188         }
00189         return parent::getSqlFieldName($sField, $iLanguage, $iShopID);
00190     }
00191 
00199     public function addExportData($aFields)
00200     {
00201         if ( isset( $aFields['OXTOTALVAT'] ) ) {
00202             // And we need to cast this value here, to remove trailing zeroes added after mysql round
00203             $aFields['OXTOTALVAT'] = (double) $aFields['OXTOTALVAT'];
00204         }
00205 
00206         if ( strlen( $aFields['OXPERSPARAM'] ) ) {
00207             $aPersVals = @unserialize($aFields['OXPERSPARAM']);
00208             if ( is_array( $aPersVals ) ) {
00209                 $aFields['OXPERSPARAM'] = implode( '|', $aPersVals );
00210             }
00211         }
00212         return $aFields;
00213     }
00214 
00215 
00225     protected function _preAssignObject($oShopObject, $aData, $blAllowCustomShopId)
00226     {
00227         $aData = parent::_preAssignObject($oShopObject, $aData, $blAllowCustomShopId);
00228         if ('1' == oxERPBase::getUsedDbFieldsVersion()) {
00229             $oDb = oxDb::getDb();
00230             if ($aData['OXAMOUNT']) {
00231                 $aData['OXVATPRICE'] = $aData['OXTOTALVAT'] / $aData['OXAMOUNT'];
00232             }
00233         }
00234 
00235         // check if data is not serialized
00236         $aPersVals = @unserialize($aData['OXPERSPARAM']);
00237         if (!is_array($aPersVals)) {
00238             // data is a string with | separation, prepare for oxid
00239             $aPersVals = explode( "|", $aData['OXPERSPARAM']);
00240             $aData['OXPERSPARAM'] = serialize($aPersVals);
00241         }
00242 
00243         return $aData;
00244     }
00245 }

Generated by  doxygen 1.6.2