OXID eShop CE  4.8.11
 All Classes Files Functions Variables Pages
delivery_main_ajax.php
Go to the documentation of this file.
1 <?php
2 
7 {
13  protected $_aColumns = array( 'container1' => array( // field , table, visible, multilanguage, ident
14  array( 'oxtitle', 'oxcountry', 1, 1, 0 ),
15  array( 'oxisoalpha2', 'oxcountry', 1, 0, 0 ),
16  array( 'oxisoalpha3', 'oxcountry', 0, 0, 0 ),
17  array( 'oxunnum3', 'oxcountry', 0, 0, 0 ),
18  array( 'oxid', 'oxcountry', 0, 0, 1 )
19  ),
20  'container2' => array(
21  array( 'oxtitle', 'oxcountry', 1, 1, 0 ),
22  array( 'oxisoalpha2', 'oxcountry', 1, 0, 0 ),
23  array( 'oxisoalpha3', 'oxcountry', 0, 0, 0 ),
24  array( 'oxunnum3', 'oxcountry', 0, 0, 0 ),
25  array( 'oxid', 'oxobject2delivery', 0, 0, 1 )
26  )
27  );
28 
34  protected function _getQuery()
35  {
36  $sCountryTable = $this->_getViewName('oxcountry');
37  $oDb = oxDb::getDb();
38  $sId = $this->getConfig()->getRequestParameter( 'oxid' );
39  $sSynchId = $this->getConfig()->getRequestParameter( 'synchoxid' );
40 
41  // category selected or not ?
42  if ( !$sId) {
43  $sQAdd = " from $sCountryTable where $sCountryTable.oxactive = '1' ";
44  } else {
45  $sQAdd = " from oxobject2delivery left join $sCountryTable on $sCountryTable.oxid=oxobject2delivery.oxobjectid ";
46  $sQAdd .= " where oxobject2delivery.oxdeliveryid = ".$oDb->quote( $sId )." and oxobject2delivery.oxtype = 'oxcountry' ";
47  }
48 
49  if ( $sSynchId && $sSynchId != $sId ) {
50  $sQAdd .= " and $sCountryTable.oxid not in ( select $sCountryTable.oxid from oxobject2delivery left join $sCountryTable on $sCountryTable.oxid=oxobject2delivery.oxobjectid ";
51  $sQAdd .= " where oxobject2delivery.oxdeliveryid = ".$oDb->quote( $sSynchId )." and oxobject2delivery.oxtype = 'oxcountry' ) ";
52  }
53 
54  return $sQAdd;
55  }
56 
62  public function removeCountryFromDel()
63  {
64  $aChosenCntr = $this->_getActionIds( 'oxobject2delivery.oxid' );
65  if ( $this->getConfig()->getRequestParameter( 'all' ) ) {
66 
67  $sQ = $this->_addFilter( "delete oxobject2delivery.* ".$this->_getQuery() );
68  oxDb::getDb()->Execute( $sQ );
69 
70  } elseif ( is_array( $aChosenCntr ) ) {
71  $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aChosenCntr ) ) . ") ";
72  oxDb::getDb()->Execute( $sQ );
73  }
74  }
75 
81  public function addCountryToDel()
82  {
83  $aChosenCntr = $this->_getActionIds( 'oxcountry.oxid' );
84  $soxId = $this->getConfig()->getRequestParameter( 'synchoxid');
85 
86  // adding
87  if ( $this->getConfig()->getRequestParameter( 'all' ) ) {
88  $sCountryTable = $this->_getViewName('oxcountry');
89  $aChosenCntr = $this->_getAll( $this->_addFilter( "select $sCountryTable.oxid ".$this->_getQuery() ) );
90  }
91 
92  if ( $soxId && $soxId != "-1" && is_array( $aChosenCntr ) ) {
93  foreach ( $aChosenCntr as $sChosenCntr) {
94  $oObject2Delivery = oxNew( 'oxbase' );
95  $oObject2Delivery->init( 'oxobject2delivery' );
96  $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
97  $oObject2Delivery->oxobject2delivery__oxobjectid = new oxField($sChosenCntr);
98  $oObject2Delivery->oxobject2delivery__oxtype = new oxField('oxcountry');
99  $oObject2Delivery->save();
100  }
101  }
102  }
103 }