00001 <?php
00002
00003 require_once 'oxerptype.php';
00004
00008 class oxERPType_Order extends oxERPType
00009 {
00014 protected $_aFieldListVersions = array(
00015 '1' => array(
00016 'OXID' => 'OXID',
00017 'OXSHOPID' => 'OXSHOPID',
00018 'OXUSERID' => 'OXUSERID',
00019 'OXORDERDATE' => 'OXORDERDATE',
00020 'OXORDERNR' => 'OXORDERNR',
00021 'OXBILLCOMPANY' => 'OXBILLCOMPANY',
00022 'OXBILLEMAIL' => 'OXBILLEMAIL',
00023 'OXBILLFNAME' => 'OXBILLFNAME',
00024 'OXBILLLNAME' => 'OXBILLLNAME',
00025 'OXBILLSTREET' => 'OXBILLSTREET',
00026 'OXBILLSTREETNR' => 'OXBILLSTREETNR',
00027 'OXBILLADDINFO' => 'OXBILLADDINFO',
00028 'OXBILLUSTID' => 'OXBILLUSTID',
00029 'OXBILLCITY' => 'OXBILLCITY',
00030 'OXBILLCOUNTRY' => 'OXBILLCOUNTRY',
00031 'OXBILLZIP' => 'OXBILLZIP',
00032 'OXBILLFON' => 'OXBILLFON',
00033 'OXBILLFAX' => 'OXBILLFAX',
00034 'OXBILLSAL' => 'OXBILLSAL',
00035 'OXDELCOMPANY' => 'OXDELCOMPANY',
00036 'OXDELFNAME' => 'OXDELFNAME',
00037 'OXDELLNAME' => 'OXDELLNAME',
00038 'OXDELSTREET' => 'OXDELSTREET',
00039 'OXDELSTREETNR' => 'OXDELSTREETNR',
00040 'OXDELADDINFO' => 'OXDELADDINFO',
00041 'OXDELCITY' => 'OXDELCITY',
00042 'OXDELCOUNTRY' => 'OXDELCOUNTRY',
00043 'OXDELZIP' => 'OXDELZIP',
00044 'OXDELFON' => 'OXDELFON',
00045 'OXDELFAX' => 'OXDELFAX',
00046 'OXDELSAL' => 'OXDELSAL',
00047 'OXPAYMENTID' => 'OXPAYMENTID',
00048 'OXPAYMENTTYPE' => 'OXPAYMENTTYPE',
00049 'OXDELCOST' => 'OXDELCOST',
00050 'OXDELVAT' => 'OXDELVAT',
00051 'OXPAYCOST' => 'OXPAYCOST',
00052 'OXPAYVAT' => 'OXPAYVAT',
00053 'OXWRAPCOST' => 'OXWRAPCOST',
00054 'OXWRAPVAT' => 'OXWRAPVAT',
00055 'OXCARDID' => 'OXCARDID',
00056 'OXCARDTEXT' => 'OXCARDTEXT',
00057 'OXDISCOUNT' => 'OXDISCOUNT',
00058 'OXEXPORT' => 'OXEXPORT',
00059 'OXBILLNR' => 'OXBILLNR',
00060 'OXTRACKCODE' => 'OXTRACKCODE',
00061 'OXSENDDATE' => 'OXSENDDATE',
00062 'OXREMARK' => 'OXREMARK',
00063 'OXVOUCHERDISCOUNT' => 'OXVOUCHERDISCOUNT',
00064 'OXCURRENCY' => 'OXCURRENCY',
00065 'OXCURRATE' => 'OXCURRATE',
00066 'OXFOLDER' => 'OXFOLDER',
00067 'OXPIDENT' => 'OXPIDENT',
00068 'OXTRANSID' => 'OXTRANSID',
00069 'OXPAYID' => 'OXPAYID',
00070 'OXXID' => 'OXXID',
00071 'OXPAID' => 'OXPAID',
00072 'OXSTORNO' => 'OXSTORNO',
00073 'OXIP' => 'OXIP',
00074 'OXTRANSSTATUS' => 'OXTRANSSTATUS',
00075 'OXLANG' => 'OXLANG',
00076 'OXINVOICENR' => 'OXINVOICENR',
00077 'OXPHAPPROVED' => 'OXPHAPPROVED',
00078 'OXPHISPHORDER' => 'OXPHISPHORDER',
00079 'OXDELTYPE' => 'OXDELTYPE',
00080 'OXPIXIEXPORT' => 'OXPIXIEXPORT',
00081 ),
00082 '2' => array(
00083 'OXID' => 'OXID',
00084 'OXSHOPID' => 'OXSHOPID',
00085 'OXUSERID' => 'OXUSERID',
00086 'OXORDERDATE' => 'OXORDERDATE',
00087 'OXORDERNR' => 'OXORDERNR',
00088 'OXBILLCOMPANY' => 'OXBILLCOMPANY',
00089 'OXBILLEMAIL' => 'OXBILLEMAIL',
00090 'OXBILLFNAME' => 'OXBILLFNAME',
00091 'OXBILLLNAME' => 'OXBILLLNAME',
00092 'OXBILLSTREET' => 'OXBILLSTREET',
00093 'OXBILLSTREETNR' => 'OXBILLSTREETNR',
00094 'OXBILLADDINFO' => 'OXBILLADDINFO',
00095 'OXBILLUSTID' => 'OXBILLUSTID',
00096 'OXBILLUSTIDSTATUS' => 'OXBILLUSTIDSTATUS',
00097 'OXBILLCITY' => 'OXBILLCITY',
00098 'OXBILLCOUNTRYID' => 'OXBILLCOUNTRYID',
00099 'OXBILLZIP' => 'OXBILLZIP',
00100 'OXBILLFON' => 'OXBILLFON',
00101 'OXBILLFAX' => 'OXBILLFAX',
00102 'OXBILLSAL' => 'OXBILLSAL',
00103 'OXDELCOMPANY' => 'OXDELCOMPANY',
00104 'OXDELFNAME' => 'OXDELFNAME',
00105 'OXDELLNAME' => 'OXDELLNAME',
00106 'OXDELSTREET' => 'OXDELSTREET',
00107 'OXDELSTREETNR' => 'OXDELSTREETNR',
00108 'OXDELADDINFO' => 'OXDELADDINFO',
00109 'OXDELCITY' => 'OXDELCITY',
00110 'OXDELCOUNTRYID' => 'OXDELCOUNTRYID',
00111 'OXDELZIP' => 'OXDELZIP',
00112 'OXDELFON' => 'OXDELFON',
00113 'OXDELFAX' => 'OXDELFAX',
00114 'OXDELSAL' => 'OXDELSAL',
00115 'OXPAYMENTID' => 'OXPAYMENTID',
00116 'OXPAYMENTTYPE' => 'OXPAYMENTTYPE',
00117 'OXTOTALNETSUM' => 'OXTOTALNETSUM',
00118 'OXTOTALBRUTSUM' => 'OXTOTALBRUTSUM',
00119 'OXTOTALORDERSUM' => 'OXTOTALORDERSUM',
00120 'OXDELCOST' => 'OXDELCOST',
00121 'OXDELVAT' => 'OXDELVAT',
00122 'OXPAYCOST' => 'OXPAYCOST',
00123 'OXPAYVAT' => 'OXPAYVAT',
00124 'OXWRAPCOST' => 'OXWRAPCOST',
00125 'OXWRAPVAT' => 'OXWRAPVAT',
00126 'OXCARDID' => 'OXCARDID',
00127 'OXCARDTEXT' => 'OXCARDTEXT',
00128 'OXDISCOUNT' => 'OXDISCOUNT',
00129 'OXEXPORT' => 'OXEXPORT',
00130 'OXBILLNR' => 'OXBILLNR',
00131 'OXTRACKCODE' => 'OXTRACKCODE',
00132 'OXSENDDATE' => 'OXSENDDATE',
00133 'OXREMARK' => 'OXREMARK',
00134 'OXVOUCHERDISCOUNT' => 'OXVOUCHERDISCOUNT',
00135 'OXCURRENCY' => 'OXCURRENCY',
00136 'OXCURRATE' => 'OXCURRATE',
00137 'OXFOLDER' => 'OXFOLDER',
00138 'OXPIDENT' => 'OXPIDENT',
00139 'OXTRANSID' => 'OXTRANSID',
00140 'OXPAYID' => 'OXPAYID',
00141 'OXXID' => 'OXXID',
00142 'OXPAID' => 'OXPAID',
00143 'OXSTORNO' => 'OXSTORNO',
00144 'OXIP' => 'OXIP',
00145 'OXTRANSSTATUS' => 'OXTRANSSTATUS',
00146 'OXLANG' => 'OXLANG',
00147 'OXINVOICENR' => 'OXINVOICENR',
00148 'OXDELTYPE' => 'OXDELTYPE',
00149 'OXPIXIEXPORT' => 'OXPIXIEXPORT',
00150 ),
00151 );
00152
00158 public function __construct()
00159 {
00160 parent::__construct();
00161
00162 $this->_sTableName = 'oxorder';
00163 $this->_sShopObjectName = 'oxorder';
00164 $this->_blRestrictedByShopId = true;
00165 }
00166
00176 protected function getSqlFieldName($sField, $iLanguage = 0, $iShopID = 1)
00177 {
00178 if ('1' == oxERPBase::getUsedDbFieldsVersion()) {
00179 switch ($sField) {
00180 case 'OXBILLCOUNTRY':
00181 return "(select oxtitle from oxcountry where oxcountry.oxid = OXBILLCOUNTRYID limit 1) as OXBILLCOUNTRY";
00182 case 'OXDELCOUNTRY':
00183 return "(select oxtitle from oxcountry where oxcountry.oxid = OXDELCOUNTRYID limit 1) as OXDELCOUNTRY";
00184 case 'OXPHAPPROVED':
00185 case 'OXPHISPHORDER':
00186 return "'' as $sField";
00187 }
00188 }
00189 return parent::getSqlFieldName($sField, $iLanguage, $iShopID);
00190 }
00191
00201 protected function _preAssignObject($oShopObject, $aData, $blAllowCustomShopId)
00202 {
00203 $aData = parent::_preAssignObject($oShopObject, $aData, $blAllowCustomShopId);
00204
00205 if ('1' == oxERPBase::getUsedDbFieldsVersion()) {
00206 $oDb = oxDb::getDb();
00207 $sTitle = mysql_real_escape_string($aData['OXBILLCOUNTRY']);
00208 if ($id = $oDb->getOne("select oxid from oxcountry where oxtitle = '$sTitle' limit 1")) {
00209 $aData['OXBILLCOUNTRYID'] = $id;
00210 }
00211 $sTitle = mysql_real_escape_string($aData['OXDELCOUNTRY']);
00212 if ($id = $oDb->getOne("select oxid from oxcountry where oxtitle = '$sTitle' limit 1")) {
00213 $aData['OXDELCOUNTRYID'] = $id;
00214 }
00215 }
00216 return $aData;
00217 }
00218
00227 protected function _postSaveObject($oShopObject, $aData)
00228 {
00229 if ('1' == oxERPBase::getRequestedVersion()) {
00230 if (!$aData['OXORDERNR']) {
00231
00232 if ($sOxid = $oShopObject->getId()) {
00233 oxDb::getDb()->Execute("update oxorder set oxordernr=0 where oxid='$sOxid' limit 1");
00234 }
00235 }
00236 } elseif ( '1.1' == oxERPBase::getRequestedVersion() ) {
00237 return array('OXID'=>$oShopObject->getId(), 'OXORDERNR'=>$oShopObject->oxorder__oxordernr->value);
00238 }
00239 return parent::_postSaveObject($oShopObject, $aData);
00240 }
00241 }