00001 <?php
00002
00006 class delivery_main_ajax extends ajaxListComponent
00007 {
00008
00014 protected $_aColumns = array('container1' => array(
00015 array('oxtitle', 'oxcountry', 1, 1, 0),
00016 array('oxisoalpha2', 'oxcountry', 1, 0, 0),
00017 array('oxisoalpha3', 'oxcountry', 0, 0, 0),
00018 array('oxunnum3', 'oxcountry', 0, 0, 0),
00019 array('oxid', 'oxcountry', 0, 0, 1)
00020 ),
00021 'container2' => array(
00022 array('oxtitle', 'oxcountry', 1, 1, 0),
00023 array('oxisoalpha2', 'oxcountry', 1, 0, 0),
00024 array('oxisoalpha3', 'oxcountry', 0, 0, 0),
00025 array('oxunnum3', 'oxcountry', 0, 0, 0),
00026 array('oxid', 'oxobject2delivery', 0, 0, 1)
00027 )
00028 );
00029
00035 protected function _getQuery()
00036 {
00037 $sCountryTable = $this->_getViewName('oxcountry');
00038 $oDb = oxDb::getDb();
00039 $sId = $this->getConfig()->getRequestParameter('oxid');
00040 $sSynchId = $this->getConfig()->getRequestParameter('synchoxid');
00041
00042
00043 if (!$sId) {
00044 $sQAdd = " from {$sCountryTable} where {$sCountryTable}.oxactive = '1' ";
00045 } else {
00046 $sQAdd = " from oxobject2delivery left join {$sCountryTable} " .
00047 "on {$sCountryTable}.oxid=oxobject2delivery.oxobjectid " .
00048 " where oxobject2delivery.oxdeliveryid = " . $oDb->quote($sId) .
00049 " and oxobject2delivery.oxtype = 'oxcountry' ";
00050 }
00051
00052 if ($sSynchId && $sSynchId != $sId) {
00053 $sQAdd .= " and {$sCountryTable}.oxid not in ( select {$sCountryTable}.oxid " .
00054 "from oxobject2delivery left join {$sCountryTable} " .
00055 "on {$sCountryTable}.oxid=oxobject2delivery.oxobjectid " .
00056 " where oxobject2delivery.oxdeliveryid = " . $oDb->quote($sSynchId) .
00057 " and oxobject2delivery.oxtype = 'oxcountry' ) ";
00058 }
00059
00060 return $sQAdd;
00061 }
00062
00066 public function removeCountryFromDel()
00067 {
00068 $aChosenCntr = $this->_getActionIds('oxobject2delivery.oxid');
00069 if ($this->getConfig()->getRequestParameter('all')) {
00070
00071 $sQ = $this->_addFilter("delete oxobject2delivery.* " . $this->_getQuery());
00072 oxDb::getDb()->Execute($sQ);
00073
00074 } elseif (is_array($aChosenCntr)) {
00075 $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in (" . implode(", ", oxDb::getInstance()->quoteArray($aChosenCntr)) . ") ";
00076 oxDb::getDb()->Execute($sQ);
00077 }
00078 }
00079
00083 public function addCountryToDel()
00084 {
00085 $aChosenCntr = $this->_getActionIds('oxcountry.oxid');
00086 $soxId = $this->getConfig()->getRequestParameter('synchoxid');
00087
00088
00089 if ($this->getConfig()->getRequestParameter('all')) {
00090 $sCountryTable = $this->_getViewName('oxcountry');
00091 $aChosenCntr = $this->_getAll($this->_addFilter("select $sCountryTable.oxid " . $this->_getQuery()));
00092 }
00093
00094 if ($soxId && $soxId != "-1" && is_array($aChosenCntr)) {
00095 foreach ($aChosenCntr as $sChosenCntr) {
00096 $oObject2Delivery = oxNew('oxbase');
00097 $oObject2Delivery->init('oxobject2delivery');
00098 $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
00099 $oObject2Delivery->oxobject2delivery__oxobjectid = new oxField($sChosenCntr);
00100 $oObject2Delivery->oxobject2delivery__oxtype = new oxField('oxcountry');
00101 $oObject2Delivery->save();
00102 }
00103 }
00104 }
00105 }