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