OXID eShop CE  4.8.10
 All Classes Files Functions Variables Pages
delivery_users_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( 'oxusername', 'oxuser', 1, 0, 0 ),
15  array( 'oxlname', 'oxuser', 0, 0, 0 ),
16  array( 'oxfname', 'oxuser', 0, 0, 0 ),
17  array( 'oxstreet', 'oxuser', 0, 0, 0 ),
18  array( 'oxstreetnr', 'oxuser', 0, 0, 0 ),
19  array( 'oxcity', 'oxuser', 0, 0, 0 ),
20  array( 'oxzip', 'oxuser', 0, 0, 0 ),
21  array( 'oxfon', 'oxuser', 0, 0, 0 ),
22  array( 'oxbirthdate', 'oxuser', 0, 0, 0 ),
23  array( 'oxid', 'oxuser', 0, 0, 1 ),
24  ),
25  'container2' => array(
26  array( 'oxusername', 'oxuser', 1, 0, 0 ),
27  array( 'oxlname', 'oxuser', 0, 0, 0 ),
28  array( 'oxfname', 'oxuser', 0, 0, 0 ),
29  array( 'oxstreet', 'oxuser', 0, 0, 0 ),
30  array( 'oxstreetnr', 'oxuser', 0, 0, 0 ),
31  array( 'oxcity', 'oxuser', 0, 0, 0 ),
32  array( 'oxzip', 'oxuser', 0, 0, 0 ),
33  array( 'oxfon', 'oxuser', 0, 0, 0 ),
34  array( 'oxbirthdate', 'oxuser', 0, 0, 0 ),
35  array( 'oxid', 'oxobject2delivery', 0, 0, 1 ),
36  )
37  );
38 
44  protected function _getQuery()
45  {
46  $myConfig = $this->getConfig();
47 
48  $sUserTable = $this->_getViewName('oxuser');
49  $oDb = oxDb::getDb();
50  $sId = $myConfig->getRequestParameter( 'oxid' );
51  $sSynchId = $myConfig->getRequestParameter( 'synchoxid' );
52 
53  // category selected or not ?
54  if ( !$sId) {
55  $sQAdd = " from $sUserTable where 1 ";
56  if (!$myConfig->getConfigParam( 'blMallUsers' ) )
57  $sQAdd .= " and $sUserTable.oxshopid = '".$myConfig->getShopId()."' ";
58  } elseif ( $sSynchId && $sSynchId != $sId ) {
59  // selected group ?
60  $sQAdd = " from oxobject2group left join $sUserTable on $sUserTable.oxid = oxobject2group.oxobjectid ";
61  $sQAdd .= " where oxobject2group.oxgroupsid = ".$oDb->quote( $sId );
62  if (!$myConfig->getConfigParam( 'blMallUsers' ) )
63  $sQAdd .= " and $sUserTable.oxshopid = '".$myConfig->getShopId()."' ";
64  } else {
65  $sQAdd = " from oxobject2delivery left join $sUserTable on $sUserTable.oxid=oxobject2delivery.oxobjectid ";
66  $sQAdd .= " where oxobject2delivery.oxdeliveryid = ".$oDb->quote( $sId )." and oxobject2delivery.oxtype = 'oxuser' and $sUserTable.oxid IS NOT NULL ";
67  }
68 
69  if ( $sSynchId && $sSynchId != $sId) {
70  $sQAdd .= " and $sUserTable.oxid not in ( select $sUserTable.oxid from oxobject2delivery left join $sUserTable on $sUserTable.oxid=oxobject2delivery.oxobjectid ";
71  $sQAdd .= " where oxobject2delivery.oxdeliveryid = ".$oDb->quote( $sSynchId )." and oxobject2delivery.oxtype = 'oxuser' and $sUserTable.oxid IS NOT NULL ) ";
72  }
73 
74  return $sQAdd;
75  }
76 
82  public function removeUserFromDel()
83  {
84  $aRemoveGroups = $this->_getActionIds( 'oxobject2delivery.oxid' );
85  if ( $this->getConfig()->getRequestParameter( 'all' ) ) {
86 
87  $sQ = $this->_addFilter( "delete oxobject2delivery.* ".$this->_getQuery() );
88  oxDb::getDb()->Execute( $sQ );
89 
90  } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
91  $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aRemoveGroups ) ) . ") ";
92  oxDb::getDb()->Execute( $sQ );
93  }
94  }
95 
101  public function addUserToDel()
102  {
103  $aChosenUsr = $this->_getActionIds( 'oxuser.oxid' );
104  $soxId = $this->getConfig()->getRequestParameter( 'synchoxid' );
105 
106  // adding
107  if ( $this->getConfig()->getRequestParameter( 'all' ) ) {
108  $sUserTable = $this->_getViewName('oxuser');
109  $aChosenUsr = $this->_getAll( $this->_addFilter( "select $sUserTable.oxid ".$this->_getQuery() ) );
110  }
111 
112  if ( $soxId && $soxId != "-1" && is_array( $aChosenUsr ) ) {
113  foreach ( $aChosenUsr as $sChosenUsr) {
114  $oObject2Delivery = oxNew( 'oxbase' );
115  $oObject2Delivery->init( 'oxobject2delivery' );
116  $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
117  $oObject2Delivery->oxobject2delivery__oxobjectid = new oxField($sChosenUsr);
118  $oObject2Delivery->oxobject2delivery__oxtype = new oxField('oxuser');
119  $oObject2Delivery->save();
120  }
121  }
122  }
123 }