function confirmAction() { if (!Pandamp_Controller_Action_Helper_IsAllowed::isAllowed('membership', 'all')) { $this->_redirect(ROOT_URL . '/' . $this->_zl->getLanguage() . '/error/restricted'); } $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(TRUE); $aResult = array(); $id = $this->_request->getParam('id') ? $this->_request->getParam('id') : ''; $tblInvoice = new App_Model_Db_Table_Invoice(); $rowInvoice = $tblInvoice->find($id)->current(); if ($rowInvoice) { if ($rowInvoice->isPaid == "N") { $tblUser = new App_Model_Db_Table_User(); $sql = $tblUser->select()->setIntegrityCheck(false); $sql->from(array('ku' => 'KutuUser'))->join(array('gag' => 'gacl_aro_groups'), 'ku.packageId = gag.id')->where('ku.kopel=?', $rowInvoice->uid); $rowUser = $tblUser->fetchRow($sql); if ($rowUser) { if (in_array($rowUser->packageId, array(14, 15, 16, 17, 18))) { $rowInvoice->invoiceConfirmDate = date("Y-m-d"); $rowInvoice->isPaid = 'Y'; // get expiration date $temptime = time(); $temptime = Pandamp_Lib_Formater::DateAdd('m', $rowUser->paymentId, $temptime); $rowInvoice->expirationDate = strftime('%Y-%m-%d', $temptime); $rowInvoice->save(); $rowUser->periodeId = 3; $rowUser->modifiedDate = date("Y-m-d h:i:s"); $rowUser->modifiedBy = "{$rowUser->username}"; $result = $rowUser->save(); if ($result) { $aResult['isError'] = false; $aResult['msg'] = $rowUser->username . ", confirm saved"; } else { $aResult['isError'] = true; $aResult['msg'] = "Error user confirmation!"; } } } else { $aResult['isError'] = true; $aResult['msg'] = 'There is no such user!'; } } else { $aResult['isError'] = true; $aResult['msg'] = 'Invoice has been paid!'; } } else { $aResult['isError'] = true; $aResult['msg'] = 'Wrong Package!'; } echo Zend_Json::encode($aResult); }
function confirmAction() { $this->_helper->getHelper('layout')->disableLayout(); $this->_helper->getHelper('viewRenderer')->setNoRender(); $request = $this->getRequest(); $result = 'RESULT_ERROR'; if (Pandamp_Controller_Action_Helper_IsAllowed::isAllowed('membership', 'all')) { if ($request->isPost()) { $id = $request->getPost('id'); // $ids = array(); // $ids = Zend_Json::decode($id); $aclMan = Pandamp_Acl::manager(); $modelUser = new App_Model_Db_Table_User(); // foreach ($ids as $id) { $sql = $modelUser->select()->setIntegrityCheck(false); $sql->from(array('ku' => 'KutuUser'))->join(array('gag' => 'gacl_aro_groups'), 'ku.packageId = gag.id')->where('ku.kopel=?', $id); $rowUser = $modelUser->fetchRow($sql); $modelPackage = new App_Model_Db_Table_Package(); $rowPackage = $modelPackage->fetchRow("packageId=" . $rowUser->packageId); //if (in_array($rowUser->packageId,array(14,15,16,17,18))) { if ($rowPackage) { $tblInvoice = new App_Model_Db_Table_Invoice(); $where = $tblInvoice->getAdapter()->quoteInto("uid=?", $id); $rowInvoice = $tblInvoice->fetchRow($where); if ($rowInvoice) { $rowInvoice->invoiceConfirmDate = date("Y-m-d"); $rowInvoice->isPaid = 'Y'; // get expiration date $temptime = time(); $temptime = Pandamp_Lib_Formater::DateAdd('m', $rowUser->paymentId, $temptime); $rowInvoice->expirationDate = strftime('%Y-%m-%d', $temptime); $rowInvoice->save(); // delete user group = trial from gacl $aclMan->deleteUser($rowUser->username); // add user to gacl $aReturn = $aclMan->getGroupData($rowUser->packageId); $aclMan->addUser($rowUser->username, $aReturn[2]); $rowUser->periodeId = 3; $rowUser->isActive = 1; $rowUser->modifiedDate = date("Y-m-d h:i:s"); $rowUser->modifiedBy = "{$rowUser->username}"; $rowUser->save(); $result = 'RESULT_OK'; } else { $result = 'Create Invoice First'; } } else { $result = 'Wrong Package'; } // } } } $this->getResponse()->setBody($result); }