00001 <?php
00002
00006 class delivery_users_ajax extends ajaxListComponent
00007 {
00008
00014 protected $_aColumns = array('container1' => array(
00015 array('oxusername', 'oxuser', 1, 0, 0),
00016 array('oxlname', 'oxuser', 0, 0, 0),
00017 array('oxfname', 'oxuser', 0, 0, 0),
00018 array('oxstreet', 'oxuser', 0, 0, 0),
00019 array('oxstreetnr', 'oxuser', 0, 0, 0),
00020 array('oxcity', 'oxuser', 0, 0, 0),
00021 array('oxzip', 'oxuser', 0, 0, 0),
00022 array('oxfon', 'oxuser', 0, 0, 0),
00023 array('oxbirthdate', 'oxuser', 0, 0, 0),
00024 array('oxid', 'oxuser', 0, 0, 1),
00025 ),
00026 'container2' => array(
00027 array('oxusername', 'oxuser', 1, 0, 0),
00028 array('oxlname', 'oxuser', 0, 0, 0),
00029 array('oxfname', 'oxuser', 0, 0, 0),
00030 array('oxstreet', 'oxuser', 0, 0, 0),
00031 array('oxstreetnr', 'oxuser', 0, 0, 0),
00032 array('oxcity', 'oxuser', 0, 0, 0),
00033 array('oxzip', 'oxuser', 0, 0, 0),
00034 array('oxfon', 'oxuser', 0, 0, 0),
00035 array('oxbirthdate', 'oxuser', 0, 0, 0),
00036 array('oxid', 'oxobject2delivery', 0, 0, 1),
00037 )
00038 );
00039
00045 protected function _getQuery()
00046 {
00047 $myConfig = $this->getConfig();
00048
00049 $sUserTable = $this->_getViewName('oxuser');
00050 $oDb = oxDb::getDb();
00051 $sId = $myConfig->getRequestParameter('oxid');
00052 $sSynchId = $myConfig->getRequestParameter('synchoxid');
00053
00054
00055 if (!$sId) {
00056 $sQAdd = " from $sUserTable where 1 ";
00057 if (!$myConfig->getConfigParam('blMallUsers')) {
00058 $sQAdd .= " and $sUserTable.oxshopid = '" . $myConfig->getShopId() . "' ";
00059 }
00060 } elseif ($sSynchId && $sSynchId != $sId) {
00061
00062 $sQAdd = " from oxobject2group left join $sUserTable on $sUserTable.oxid = oxobject2group.oxobjectid ";
00063 $sQAdd .= " where oxobject2group.oxgroupsid = " . $oDb->quote($sId);
00064 if (!$myConfig->getConfigParam('blMallUsers')) {
00065 $sQAdd .= " and $sUserTable.oxshopid = '" . $myConfig->getShopId() . "' ";
00066 }
00067 } else {
00068 $sQAdd = " from oxobject2delivery left join $sUserTable on $sUserTable.oxid=oxobject2delivery.oxobjectid ";
00069 $sQAdd .= " where oxobject2delivery.oxdeliveryid = " . $oDb->quote($sId) . " and oxobject2delivery.oxtype = 'oxuser' and $sUserTable.oxid IS NOT NULL ";
00070 }
00071
00072 if ($sSynchId && $sSynchId != $sId) {
00073 $sQAdd .= " and $sUserTable.oxid not in ( select $sUserTable.oxid from oxobject2delivery left join $sUserTable on $sUserTable.oxid=oxobject2delivery.oxobjectid ";
00074 $sQAdd .= " where oxobject2delivery.oxdeliveryid = " . $oDb->quote($sSynchId) . " and oxobject2delivery.oxtype = 'oxuser' and $sUserTable.oxid IS NOT NULL ) ";
00075 }
00076
00077 return $sQAdd;
00078 }
00079
00083 public function removeUserFromDel()
00084 {
00085 $aRemoveGroups = $this->_getActionIds('oxobject2delivery.oxid');
00086 if ($this->getConfig()->getRequestParameter('all')) {
00087
00088 $sQ = $this->_addFilter("delete oxobject2delivery.* " . $this->_getQuery());
00089 oxDb::getDb()->Execute($sQ);
00090
00091 } elseif ($aRemoveGroups && is_array($aRemoveGroups)) {
00092 $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in (" . implode(", ", oxDb::getInstance()->quoteArray($aRemoveGroups)) . ") ";
00093 oxDb::getDb()->Execute($sQ);
00094 }
00095 }
00096
00100 public function addUserToDel()
00101 {
00102 $aChosenUsr = $this->_getActionIds('oxuser.oxid');
00103 $soxId = $this->getConfig()->getRequestParameter('synchoxid');
00104
00105
00106 if ($this->getConfig()->getRequestParameter('all')) {
00107 $sUserTable = $this->_getViewName('oxuser');
00108 $aChosenUsr = $this->_getAll($this->_addFilter("select $sUserTable.oxid " . $this->_getQuery()));
00109 }
00110
00111 if ($soxId && $soxId != "-1" && is_array($aChosenUsr)) {
00112 foreach ($aChosenUsr as $sChosenUsr) {
00113 $oObject2Delivery = oxNew('oxbase');
00114 $oObject2Delivery->init('oxobject2delivery');
00115 $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
00116 $oObject2Delivery->oxobject2delivery__oxobjectid = new oxField($sChosenUsr);
00117 $oObject2Delivery->oxobject2delivery__oxtype = new oxField('oxuser');
00118 $oObject2Delivery->save();
00119 }
00120 }
00121 }
00122 }