function preDispatch() { $this->_helper->layout()->setLayout('layout-final-inside'); $saveHandlerManager = new Kutu_Session_SaveHandler_Manager(); $saveHandlerManager->setSaveHandler(); Zend_Session::start(); $sReturn = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $sReturn = urlencode($sReturn); $this->view->returnTo = $sReturn; $auth = Zend_Auth::getInstance(); if (!$auth->hasIdentity()) { $this->_redirect(KUTU_ROOT_URL . '/helper/sso/login' . '?returnTo=' . $sReturn); } else { // [TODO] else: check if user has access to admin page $username = $auth->getIdentity()->username; $this->view->username = $username; } $userId = $auth->getIdentity()->guid; $tblUserFinance = new Kutu_Core_Orm_Table_UserFinance(); $this->_userInfo = $tblUserFinance->find($userId)->current(); //$config = new Zend_Config_Ini(CONFIG_PATH.'/store.ini', APPLICATION_ENV); $registry = Zend_Registry::getInstance(); $reg = $registry->get(ZEND_APP_REG_ID); $storeConfig = $reg->getOption('store'); $this->_configStore = $storeConfig; }
private function _checkAuth() { $auth = Zend_Auth::getInstance(); $userId = $auth->getIdentity()->guid; if (!$auth->hasIdentity()) { $this->_redirect(KUTU_ROOT_URL . '/helper/sso/login' . '?returnTo=' . $sReturn); } else { // [TODO] else: check if user has access to admin page $username = $auth->getIdentity()->username; $this->view->username = $username; } //$userId=$auth->getIdentity()->guid; $tblUser = new Kutu_Core_Orm_Table_User(); $this->_userDetailInfo = $tblUser->find($userId)->current(); $tblUserFinance = new Kutu_Core_Orm_Table_UserFinance(); $this->_userInfo = $tblUserFinance->find($userId)->current(); if (empty($this->_userInfo)) { $finance = $tblUserFinance->fetchNew(); $finance['userId'] = $userId; $finance->save(); $this->_userInfo = $tblUserFinance->find($userId)->current(); } }
public function confirmorderAction() { //this page will do: //1. show all details that has been previously inputted //2. calculate TAX, and show it to user //3. GRAND TOTAL PRICE //check if jcart is empty. If empty it means user has not put any items into cart or user has just finished complete order, // but then going back to confirm order page. //var_dump($_SESSION['jCart']); if (!is_object($_SESSION['jCart'])) { //forward to somewhere echo "FORWARDED"; $this->_helper->redirector('cartempty', 'store_payment', 'site'); } if (count($_SESSION['jCart']->items) == 0) { //forward to somewhere echo "SHOULD BE FORWARDED"; $this->_helper->redirector('cartempty', 'store', 'site'); } $tblPaymentSetting = new Kutu_Core_Orm_Table_PaymentSetting(); $rowTaxRate = $tblPaymentSetting->fetchRow("settingKey='taxRate'"); $cart =& $_SESSION['jCart']; if (!is_object($cart)) { $cart = new jCart(); } $bpm = new Kutu_Core_Bpm_Catalog(); $result = array('subTotal' => 0, 'taxAmount' => 0, 'grandTotal' => 0, 'items' => array()); for ($iCart = 0; $iCart < count($cart->items); $iCart++) { $itemId = $cart->items[$iCart]; $qty = 1; $itemPrice = $bpm->getPrice($itemId); //$itemPrice=20; $result['items'][$iCart]['itemId'] = $itemId; $result['items'][$iCart]['item_name'] = Kutu_Core_Util::getCatalogAttributeValue($itemId, 'fixedTitle'); $result['items'][$iCart]['itemPrice'] = $itemPrice; $result['items'][$iCart]['qty'] = $qty; $result['subTotal'] += $itemPrice * $qty; } $result['taxAmount'] = $result['subTotal'] * $rowTaxRate->settingValue / 100; $result['grandTotal'] = $result['subTotal'] + $result['taxAmount']; $data = array(); foreach ($this->_request->getParams() as $key => $value) { $data[$key] = $value; } $this->view->cart = $result; $this->view->data = $data; if ($data['method'] == 'postpaid') { $tblUserFinance = new Kutu_Core_Orm_Table_UserFinance(); $userFinanceInfo = $tblUserFinance->find($this->_userId)->current(); if (!$userFinanceInfo->isPostPaid) { echo 'Not Post Paid Customer'; //$paymentObject->submitPayment(); return $this->_helper->redirector('notpostpaid', 'store_payment', 'site'); } } }
private function _checkAuth() { $auth = Zend_Auth::getInstance(); if (!$auth->hasIdentity()) { $sReturn = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; $sReturn = base64_encode($sReturn); $registry = Zend_Registry::getInstance(); $config = $registry->get('config'); $loginUrl = $config->identity->config->local->login->url; $this->_redirect(KUTU_ROOT_URL . $loginUrl . '?returnTo=' . $sReturn); } else { $this->_user = $auth->getIdentity(); } $modelUserFinance = new Kutu_Core_Orm_Table_UserFinance(); $this->_userFinanceInfo = $modelUserFinance->find($this->_user->kopel)->current(); if (empty($this->_userFinanceInfo)) { $finance = $modelUserFinance->fetchNew(); $finance['userId'] = $this->_user->kopel; $finance->save(); $this->_userFinanceInfo = $modelUserFinance->find($this->_user->kopel)->current(); } }
public function delete($userId) { //[TODO] WE MUST DEFINE RELATIONSHIP AND CASCADE DELETE ON EVERY TABLES $tblUser = new Kutu_Core_Orm_Table_User(); $rowUser = $tblUser->find($userId)->current(); $username = $rowUser->username; print_r($username); //delete from KutuOrder //$tblOrder = new Kutu_Core_Orm_Table_Order(); //$tblOrder->delete("userId='$userId'"); //delete from PHPGACL (use PHPGACL function to delete user) $acl = Kutu_Acl::manager(); $acl->deleteUser($username); //delete from KutuUserFinance $tblUserFinance = new Kutu_Core_Orm_Table_UserFinance(); $rowsetUserFinance = $tblUserFinance->find($userId); if (count($rowsetUserFinance)) { $rowUserFinance = $rowsetUserFinance->current(); $rowUserFinance->delete(); } //delete from KutuUser $rowUser->delete(); //delete from all table that Chenri made (Store related tables) }
public function postpaidaddAction() { $act = $this->_request->get('act'); $this->view->action = $act; if ($act == 'select') { $tblUserFinance = new Kutu_Core_Orm_Table_UserFinance(); $userList = $tblUserFinance->getUser($this->_request->getParam('username')); $this->view->userList = $userList; $this->view->Query = $this->_request->getParam('username'); $lmt = $this->_request->getParam('creditLimit'); if (empty($lmt)) { $limit = 'unlimited'; } else { $limit = $this->_request->getParam('creditLimit'); } $this->view->creditLimit = $limit; } elseif ($act == 'conf') { $id = $this->_request->getParam('id'); $CL = $this->_request->getParam('CL'); $tblUserFinance = new Kutu_Core_Orm_Table_UserFinance(); $rowset = $tblUserFinance->getUserFinance($id); $this->view->rowset = $rowset; $this->view->CL = $CL; //print_r($this->_request->getParams()); } elseif ($act == 'done') { $tblUserFinance = new Kutu_Core_Orm_Table_UserFinance(); if ($this->_request->getParam('CL') == 'unlimited') { $data['creditLimit'] = 0; } else { $data['creditLimit'] = $this->_request->getParam('CL'); } $data['isPostpaid'] = 1; $userId = $this->_request->getParam('id'); $tblUserFinance->update($data, "userId = '" . $userId . "'"); } }
function upgradesubAction() { $packageId = $this->_getParam('packageId'); $this->view->packageId = $packageId; $this->view->rowUser = $this->_user; $modelUserFinance = new Kutu_Core_Orm_Table_UserFinance(); $userFinanceInfo = $modelUserFinance->fetchRow("userId='" . $this->_user->kopel . "'"); if (!$userFinanceInfo) { $finance = $modelUserFinance->fetchNew(); $finance->userId = $this->_user->kopel; $finance->taxNumber = ''; $finance->taxCompany = $this->_user->company; $finance->taxAddress = $this->_user->address; $finance->taxCity = $this->_user->city; $finance->taxProvince = $this->_user->state; $finance->taxCountryId = $this->_user->countryId; $finance->taxZip = $this->_user->zip; $finance->save(); } $userFinanceInfo = $modelUserFinance->fetchRow("userId='" . $this->_user->kopel . "'"); $this->view->userInfo = $userFinanceInfo; }