Example #1
0
 public function indexAction()
 {
     $url = $this->getRequest()->getParam('url');
     $xmlString = '<?xml version="1.0" standalone="yes"?><response></response>';
     $xml = new SimpleXMLElement($xmlString);
     if (strlen($url) < 1) {
         $xml->addChild('status', 'failed no url passed');
     } else {
         $shortid = $this->db->fetchCol("select * from urls where url = ?", $url);
         $config = Zend_Registry::getInstance();
         $sh = $config->get('configuration');
         if ($shortid[0]) {
             $hex = dechex($shortid[0]);
             $short = $sh->siteroot . $hex;
         } else {
             //if not insert then return the id
             $data = array('url' => $url, 'createdate' => date("Y-m-d h:i:s"), 'remoteip' => Pandamp_Lib_Formater::getRealIpAddr());
             $insert = $this->db->insert('urls', $data);
             $id = $this->db->lastInsertId('urls', 'id');
             $hex = dechex($id);
             $short = $sh->siteroot . $hex;
         }
         $xml->addChild('holurl', $short);
         $xml->addChild('status', 'success');
     }
     $out = $xml->asXML();
     //This returns the XML xmlreponse should be key value pairs
     $this->getResponse()->setHeader('Content-Type', 'text/xml')->setBody($out);
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
 }
Example #2
0
 function poll($aData)
 {
     $voteid = isset($aData['poll']) ? $aData['poll'] : '';
     $id = $aData['id'] ? $aData['id'] : '';
     $tblPolliP = new Pandamp_Modules_Misc_Poll_Model_PollIp();
     $ip_result = $tblPolliP->fetchRow("ip='" . Pandamp_Lib_Formater::getRealIpAddr() . "' AND pollGuid='" . $id . "'");
     if (!isset($ip_result)) {
         $rowIp = $tblPolliP->fetchNew();
         $rowIp->dateOfPoll = date("Y-m-d H:i:s");
         $rowIp->ip = Pandamp_Lib_Formater::getRealIpAddr();
         $rowIp->voteId = $voteid;
         $rowIp->pollGuid = $id;
         $rowIp->save();
         if ($voteid) {
             $tblPoll = new Pandamp_Modules_Misc_Poll_Model_Poll();
             $rowPoll = $tblPoll->find($id)->current();
             if ($rowPoll) {
                 $rowPoll->voters = $rowPoll->voters + 1;
                 $rowPoll->save();
             }
             $tblOption = new Pandamp_Modules_Misc_Option_Model_Option();
             $rowOption = $tblOption->fetchRow("guid='{$voteid}' AND pollGuid='{$id}'");
             if ($rowOption) {
                 $rowOption->hits = $rowOption->hits + 1;
                 $rowOption->save();
             }
         }
     }
 }
Example #3
0
 public function addRating($catalogGuid, array $data)
 {
     if (!isset($catalogGuid)) {
         return 0;
     }
     $whiteList = array('guid', 'userid', 'ip', 'counter', 'value');
     $addData = array();
     foreach ($data as $key => $value) {
         if (in_array($key, $whiteList)) {
             $addData[$key] = $value;
         }
     }
     if (empty($addData)) {
         return 0;
     }
     $where = $this->getAdapter()->quoteInto('guid = ?', $catalogGuid);
     $row = $this->fetchRow($where);
     if ($row) {
         // check ip
         if ($row->ip == Pandamp_Lib_Formater::getRealIpAddr()) {
             return 0;
         }
         $row->counter = $row->counter += 1;
         $row->value = $row->value += $addData['value'];
         $id = $this->update(array('counter' => $row->counter, 'value' => $row->value), $where);
     } else {
         $id = $this->insert($addData);
     }
     if ((int) $id == 0) {
         return 0;
     }
     return $id;
 }
Example #4
0
 public function shortenAction()
 {
     //$ip = $_SERVER['REMOTE_ADDR'];
     //A new URL to make short
     $f = new Zend_Filter_StripTags();
     $url = $this->_request->getPost('url');
     //strip off the %0A
     $url = trim(preg_replace('/%0A/', '', $url));
     //see if the url is in the db if it is return the id
     $shortid = $this->db->fetchCol("select * from urls where url = ?", $url);
     $return;
     $config = Zend_Registry::getInstance();
     $sh = $config->get('configuration');
     if (isset($shortid[0])) {
         $hex = dechex($shortid[0]);
         $short = $sh->siteroot . $hex;
         $return = array('shorturl' => $short);
     } else {
         //if not insert then return the id
         $data = array('url' => $url, 'createdate' => date("Y-m-d h:i:s"), 'remoteip' => Pandamp_Lib_Formater::getRealIpAddr());
         $insert = $this->db->insert('urls', $data);
         $id = $this->db->lastInsertId('urls', 'id');
         $hex = dechex($id);
         $short = $sh->siteroot . $hex;
         $return = array('shorturl' => $short);
     }
     $this->_helper->json->sendJson($return);
 }
 function detailAction()
 {
     $catalogGuid = $this->_getParam('guid') ? $this->_getParam('guid') : '';
     $page = $this->_getParam('page') ? $this->_getParam('page') : '';
     // get current ip address
     $ip = Pandamp_Lib_Formater::getRealIpAddr();
     $modelCatalog = new Pandamp_Modules_Dms_Catalog_Model_Catalog();
     $modelCatalogAttribute = new Pandamp_Modules_Dms_Catalog_Model_CatalogAttribute();
     $decorator = new Pandamp_BeanContext_Decorator($modelCatalog);
     $rowset = $decorator->getCatalogByGuidAsEntity($catalogGuid);
     if (isset($rowset)) {
         $modelAsset = new Pandamp_Modules_Dms_Catalog_Model_AssetSetting();
     }
     $decorator = new Pandamp_BeanContext_Decorator($modelAsset);
     $rowAsset = $decorator->getAssetNumOfClickAsEntity($catalogGuid);
     $data = array('guid' => $catalogGuid, 'application' => 'ASSET', 'part' => 'MOST_READABLE_TICKER', 'valueType' => $ip, 'valueInt' => 1, 'valueText' => 'TICKER');
     $asset = $modelAsset->addCounterAsset($rowset->getId(), $data);
     $title = $modelCatalogAttribute->getCatalogAttributeValue($rowset->getId(), 'fixedTitle');
     $subtitle = $modelCatalogAttribute->getCatalogAttributeValue($rowset->getId(), 'fixedSubTitle');
     $content = $modelCatalogAttribute->getCatalogAttributeValue($rowset->getId(), 'fixedContent');
     $description = $modelCatalogAttribute->getCatalogAttributeValue($rowset->getId(), 'fixedDescription');
     $author = $modelCatalogAttribute->getCatalogAttributeValue($rowset->getId(), 'fixedAuthor');
     $array_hari = array(1 => "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu", "Minggu");
     $hari = $array_hari[date("N", strtotime($rowset->getCreatedDate()))];
     // get votes
     $modelVote = new Pandamp_Modules_Extension_Vote_Model_Vote();
     $decorator = new Pandamp_BeanContext_Decorator($modelVote);
     $rowRate = $decorator->getRatingAsEntity($catalogGuid, $ip);
     $val = $rowRate ? $rowRate->getValue() : 0;
     $counter = $rowRate ? $rowRate->getCounter() : 0;
     if ($counter < 1) {
         $count = 0;
     } else {
         $count = $counter;
         //how many votes total
     }
     $current_rating = $val;
     $tense = $count == 1 ? "vote" : "votes";
     //plural form votes/vote
     $rating = @number_format($current_rating / $count, 1);
     $drawrating = '(' . $count . ' ' . $tense . ', average: ' . $rating . ' out of 5)';
     $this->view->title = $title;
     $this->view->subtitle = $subtitle;
     $this->view->content = $content;
     $this->view->description = $description;
     $this->view->author = $author;
     $this->view->date = $hari . ', ' . date("d F Y", strtotime($rowset->getPublishedDate()));
     $this->view->numOfClick = isset($rowAsset) ? $rowAsset->getValueInt() : 0;
     $this->view->drawrating = $drawrating;
     $this->view->catalogGuid = $catalogGuid;
     $this->view->page = $page;
 }
 function klideAction()
 {
     $catalogGuid = $this->_getParam('guid') ? $this->_getParam('guid') : '';
     $ip = Pandamp_Lib_Formater::getRealIpAddr();
     $modelCatalog = new Pandamp_Modules_Dms_Catalog_Model_Catalog();
     $modelCatalogAttribute = new Pandamp_Modules_Dms_Catalog_Model_CatalogAttribute();
     $decorator = new Pandamp_BeanContext_Decorator($modelCatalog);
     $rowset = $decorator->getCatalogByGuidAsEntity($catalogGuid);
     if ($rowset) {
         $modelAsset = new Pandamp_Modules_Dms_Catalog_Model_AssetSetting();
         $decorator = new Pandamp_BeanContext_Decorator($modelAsset);
         $rowAsset = $decorator->getAssetNumOfClickAsEntity($catalogGuid);
         $data = array('guid' => $catalogGuid, 'application' => 'ASSET', 'part' => 'MOST_READABLE_CLINIC', 'valueType' => $ip, 'valueInt' => 1, 'valueText' => 'klinik');
         $asset = $modelAsset->addCounterAsset($rowset->getId(), $data);
         $title = $modelCatalogAttribute->getCatalogAttributeValue($rowset->getId(), 'fixedCommentTitle');
         $question = $modelCatalogAttribute->getCatalogAttributeValue($rowset->getId(), 'fixedCommentQuestion');
         $category = $modelCatalogAttribute->getCatalogAttributeValue($rowset->getId(), 'fixedKategoriKlinik');
         $answer = $modelCatalogAttribute->getCatalogAttributeValue($rowset->getId(), 'fixedAnswer');
         $author = $modelCatalogAttribute->getCatalogAttributeValue($rowset->getId(), 'fixedSelectNama');
         $source = $modelCatalogAttribute->getCatalogAttributeValue($rowset->getId(), 'fixedSelectMitra');
         $this->view->title = isset($title) ? $title : '';
         $this->view->question = isset($question) ? $question : '';
         $this->view->category = isset($category) ? $category : '';
         $this->view->answer = isset($answer) ? $answer : '';
         $this->view->author = isset($author) ? $author : '';
         $this->view->source = isset($source) ? $source : '';
         $this->view->createdBy = $rowset->getCreatedBy();
         $this->view->publishedDate = Pandamp_Lib_Formater::get_date($rowset->getPublishedDate());
         $this->view->numofclick = isset($rowAsset) ? $rowAsset->getValueInt() : 0;
         // get votes
         $modelVote = new Pandamp_Modules_Extension_Vote_Model_Vote();
         $decorator = new Pandamp_BeanContext_Decorator($modelVote);
         $rowRate = $decorator->getRatingAsEntity($catalogGuid, $ip);
         $val = $rowRate ? $rowRate->getValue() : 0;
         $counter = $rowRate ? $rowRate->getCounter() : 0;
         if ($counter < 1) {
             $count = 0;
         } else {
             $count = $counter;
             //how many votes total
         }
         $current_rating = $val;
         $tense = $count == 1 ? "vote" : "votes";
         //plural form votes/vote
         $rating = @number_format($current_rating / $count, 1);
         $drawrating = '(' . $count . ' ' . $tense . ', average: ' . $rating . ' out of 5)';
         $this->view->drawrating = $drawrating;
         $this->view->catalogGuid = $catalogGuid;
     }
 }
Example #7
0
 function klideAction()
 {
     $catalogGuid = $this->_getParam('guid') ? $this->_getParam('guid') : '';
     $ip = Pandamp_Lib_Formater::getRealIpAddr();
     $rowset = App_Model_Show_Catalog::show()->getCatalogByGuid($catalogGuid);
     if ($rowset) {
         $rowAsset = App_Model_Show_AssetSetting::show()->getAssetNumOfClick($catalogGuid);
         $data = array('guid' => $catalogGuid, 'application' => 'ASSET', 'part' => 'MOST_READABLE_CLINIC', 'valueType' => $ip, 'valueInt' => 1, 'valueText' => 'klinik');
         $asset = App_Model_Show_AssetSetting::show()->addCounterAsset($rowset['guid'], $data);
         $title = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowset['guid'], 'fixedCommentTitle');
         $question = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowset['guid'], 'fixedCommentQuestion');
         $category = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowset['guid'], 'fixedKategoriKlinik');
         $answer = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowset['guid'], 'fixedAnswer');
         $author = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowset['guid'], 'fixedSelectNama');
         $source = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowset['guid'], 'fixedSelectMitra');
         $dateDiff = new Pandamp_Lib_DateDiff();
         $this->view->title = isset($title) ? $title : '';
         $this->view->question = isset($question) ? $question : '';
         $this->view->category = isset($category) ? $category : '';
         $this->view->answer = isset($answer) ? $answer : '';
         $this->view->author = isset($author) ? $author : '';
         $this->view->source = isset($source) ? $source : '';
         $this->view->createdBy = $rowset['createdBy'];
         //$this->view->publishedDate	= Pandamp_Lib_Formater::get_date($rowset['publishedDate']);
         //$this->view->publishedDate	= $dateDiff->ago(strftime('%Y-%m-%d %H:%M:%S',strtotime($rowset['publishedDate'])));
         $this->view->publishedDate = date("d/m/Y", strtotime($rowset['publishedDate']));
         $this->view->createdDate = $dateDiff->ago(strftime('%Y-%m-%d %H:%M:%S', strtotime($rowset['createdDate'])));
         $this->view->numofclick = isset($rowAsset) ? $rowAsset['valueInt'] : 0;
         // get votes
         $rowRate = App_Model_Show_Vote::show()->getRating($catalogGuid, $ip);
         $val = $rowRate ? $rowRate['value'] : 0;
         $counter = $rowRate ? $rowRate['counter'] : 0;
         if ($counter < 1) {
             $count = 0;
         } else {
             $count = $counter;
             //how many votes total
         }
         $current_rating = $val;
         $tense = $count == 1 ? "vote" : "votes";
         //plural form votes/vote
         $rating = @number_format($current_rating / $count, 1);
         $drawrating = '(' . $count . ' ' . $tense . ', average: ' . $rating . ' out of 5)';
         $this->view->drawrating = $drawrating;
         $this->view->catalogGuid = $catalogGuid;
     }
 }
Example #8
0
 public function save($aData)
 {
     $aResult = array();
     $parent = $aData['parent_id'];
     $objectId = $aData['guid'];
     $name = $aData['name'];
     $email = $aData['email'];
     $title = $aData['title'];
     $comment = $aData['comment'];
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $userId = $auth->getIdentity()->kopel;
     } else {
         $userId = 0;
     }
     $modelComment = new App_Model_Db_Table_Comment();
     $catalogGuid = $modelComment->addComment(array('parent' => $parent, 'object_id' => $objectId, 'userid' => $userId, 'name' => $name, 'email' => $email, 'title' => $title, 'comment' => $comment, 'ip' => Pandamp_Lib_Formater::getRealIpAddr(), 'date' => new Zend_Db_Expr('NOW()')));
     return $catalogGuid;
 }
Example #9
0
 function detailAction()
 {
     $catalogGuid = $this->_getParam('guid') ? $this->_getParam('guid') : '';
     // get current ip address
     $ip = Pandamp_Lib_Formater::getRealIpAddr();
     $rowset = App_Model_Show_Catalog::show()->getCatalogByGuid($catalogGuid);
     if (isset($rowset)) {
         $rowAsset = App_Model_Show_AssetSetting::show()->getAssetNumOfClick($catalogGuid);
     }
     $data = array('guid' => $catalogGuid, 'application' => 'ASSET', 'part' => 'MOST_READABLE_TICKER', 'valueType' => $ip, 'valueInt' => 1, 'valueText' => 'TICKER');
     $asset = App_Model_Show_AssetSetting::show()->addCounterAsset($rowset['guid'], $data);
     $title = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowset['guid'], 'fixedTitle');
     $subtitle = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowset['guid'], 'fixedSubTitle');
     $content = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowset['guid'], 'fixedContent');
     $description = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowset['guid'], 'fixedDescription');
     $author = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowset['guid'], 'fixedAuthor');
     $array_hari = array(1 => "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu", "Minggu");
     $hari = $array_hari[date("N", strtotime($rowset['createdDate']))];
     // get votes
     $rowRate = App_Model_Show_Vote::show()->getRating($catalogGuid, $ip);
     $val = $rowRate ? $rowRate['value'] : 0;
     $counter = $rowRate ? $rowRate['counter'] : 0;
     if ($counter < 1) {
         $count = 0;
     } else {
         $count = $counter;
         //how many votes total
     }
     $current_rating = $val;
     $tense = $count == 1 ? "vote" : "votes";
     //plural form votes/vote
     $rating = @number_format($current_rating / $count, 1);
     $drawrating = '(' . $count . ' ' . $tense . ', average: ' . $rating . ' out of 5)';
     $this->view->title = $title;
     $this->view->subtitle = $subtitle;
     $this->view->content = $content;
     $this->view->description = $description;
     $this->view->author = $author;
     $this->view->date = $hari . ', ' . date("d F Y", strtotime($rowset['publishedDate']));
     $this->view->numOfClick = isset($rowAsset) ? $rowAsset['valueInt'] : 0;
     $this->view->drawrating = $drawrating;
     $this->view->catalogGuid = $catalogGuid;
 }
Example #10
0
 private function uvote($catalogGuid)
 {
     // get current ip address
     $ip = Pandamp_Lib_Formater::getRealIpAddr();
     // get votes
     $rowRate = App_Model_Show_Vote::show()->getRating($catalogGuid, $ip);
     $val = $rowRate ? $rowRate['value'] : 0;
     $counter = $rowRate ? $rowRate['counter'] : 0;
     if ($counter < 1) {
         $count = 0;
     } else {
         $count = $counter;
         //how many votes total
     }
     $current_rating = $val;
     $tense = $count == 1 ? "vote" : "votes";
     //plural form votes/vote
     $rating = @number_format($current_rating / $count, 1);
     $drawrating = '(' . $count . ' ' . $tense . ', average: ' . $rating . ' out of 5)';
     return $drawrating;
 }
 private function uvote($catalogGuid)
 {
     // get current ip address
     $ip = Pandamp_Lib_Formater::getRealIpAddr();
     // get votes
     $modelVote = new Pandamp_Modules_Extension_Vote_Model_Vote();
     $decorator = new Pandamp_BeanContext_Decorator($modelVote);
     $rowRate = $decorator->getRatingAsEntity($catalogGuid, $ip);
     $val = $rowRate ? $rowRate->getValue() : 0;
     $counter = $rowRate ? $rowRate->getCounter() : 0;
     if ($counter < 1) {
         $count = 0;
     } else {
         $count = $counter;
         //how many votes total
     }
     $current_rating = $val;
     $tense = $count == 1 ? "vote" : "votes";
     //plural form votes/vote
     $rating = @number_format($current_rating / $count, 1);
     $drawrating = '(' . $count . ' ' . $tense . ', average: ' . $rating . ' out of 5)';
     return $drawrating;
 }
Example #12
0
 function visitAction()
 {
     $guid = $this->_getParam('guid');
     $tblPowerban = new Pandamp_Modules_Misc_Banner_Model_Powerban();
     $rowset = $tblPowerban->find($guid);
     if (count($rowset)) {
         $row = $rowset->current();
         $row->visits = $row->visits + 1;
         $gid = $row->save();
         if ($gid) {
             $tblPowerbanVisit = new Pandamp_Modules_Misc_Banner_Statistic_Model_PowerbanStatistik();
             $rowPStatistik = $tblPowerbanVisit->fetchNew();
             $rowPStatistik->bid = $guid;
             $rowPStatistik->host = gethostbyname($_SERVER['HTTP_REFERER']);
             $rowPStatistik->address = Pandamp_Lib_Formater::getRealIpAddr();
             $rowPStatistik->agent = $_SERVER['HTTP_USER_AGENT'];
             $rowPStatistik->datetime = date("Y-m-d h:i:s");
             $rowPStatistik->referer = $_SERVER['HTTP_REFERER'];
             $rowPStatistik->save();
         }
         $this->_redirect($row->url);
     }
 }
Example #13
0
 private function saveOrder($cart, $payment)
 {
     $defaultCurrency = 'Rp';
     $tblPaymentSetting = new App_Model_Db_Table_PaymentSetting();
     $usdIdrEx = $tblPaymentSetting->fetchRow(" settingKey= 'USDIDR'");
     $currencyValue = $usdIdrEx->settingValue;
     $rowTaxRate = $tblPaymentSetting->fetchRow("settingKey='taxRate'");
     $taxRate = $rowTaxRate->settingValue;
     $tblOrder = new App_Model_Db_Table_Order();
     $row = $tblOrder->fetchNew();
     $row->userId = $this->_user->kopel;
     //get value from post var (store/checkout.phtml)
     if ($this->getRequest()->getPost()) {
         $value = $this->getRequest()->getPost();
         $row->taxNumber = '';
         $row->taxCompany = $value['taxCompany'];
         $row->taxAddress = $value['taxAddress'];
         $row->taxCity = $value['taxCity'];
         $row->taxZip = $value['taxZip'];
         $row->taxProvince = $value['taxProvince'];
         $row->taxCountryId = '';
         $row->paymentMethod = $payment['method'];
         $row->bankName = $payment['bank_options'];
     }
     $row->datePurchased = date('YmdHis');
     $row->orderStatus = 1;
     //pending
     $row->currency = $defaultCurrency;
     $row->currencyValue = $currencyValue;
     $row->discount = $cart['disc'];
     $row->orderTotal = $cart['grandTotal'];
     $row->orderTax = $cart['taxAmount'];
     $row->ipAddress = Pandamp_Lib_Formater::getRealIpAddr();
     $orderId = $row->save();
     $rowJustInserted = $tblOrder->find($orderId)->current();
     //      $rowJustInserted->invoiceNumber = date('Ymd') . '.' . $orderId;
     $tblNumber = new App_Model_Db_Table_GenerateNumber();
     $rowset = $tblNumber->fetchRow();
     $num = $rowset->invoice;
     $totdigit = 5;
     $num = strval($num);
     $jumdigit = strlen($num);
     $noinvoice = str_repeat("0", $totdigit - $jumdigit) . $num;
     $rowset->invoice = $rowset->invoice += 1;
     $tblNumber->update(array('invoice' => $rowset->invoice), NULL);
     $rowJustInserted->invoiceNumber = $noinvoice;
     $rowJustInserted->save();
     $this->view->invoiceNumber = $rowJustInserted->invoiceNumber;
     $this->view->datePurchased = $rowJustInserted->datePurchased;
     $tblOrderDetail = new App_Model_Db_Table_OrderDetail();
     for ($iCart = 0; $iCart < count($cart['items']); $iCart++) {
         $rowDetail = $tblOrderDetail->fetchNew();
         $itemId = $cart['items'][$iCart]['itemId'];
         $rowDetail->orderId = $orderId;
         $rowDetail->itemId = $itemId;
         $rowDetail->documentName = $cart['items'][$iCart]['item_name'];
         $rowDetail->price = $cart['items'][$iCart]['itemPrice'];
         $itemPrice = $rowDetail->price;
         @($rowDetail->tax = ($cart['grandTotal'] - $cart['subTotal']) / $cart['subTotal'] * 100);
         $rowDetail->discount = $cart['disc'];
         $rowDetail->qty = $cart['items'][$iCart]['qty'];
         $rowDetail->finalPrice = $cart['items'][$iCart]['itemTotal'];
         $rowDetail->save();
     }
     //[TODO] MUST ALSO INSERT/UPDATE KutuUserFinance
     return $orderId;
 }
Example #14
0
 function completeAction()
 {
     $formater = new Pandamp_Core_Hol_User();
     $defaultCurrency = 'Rp';
     $kopel = $this->_request->getParam('kopel');
     $method = $this->_request->getParam('method');
     $packageId = $this->_request->getParam('packageId');
     $paymentSubscription = $this->_request->getParam('payment');
     $tblPaymentSetting = new App_Model_Db_Table_PaymentSetting();
     $usdIdrEx = $tblPaymentSetting->fetchRow(" settingKey= 'USDIDR'");
     $currencyValue = $usdIdrEx->settingValue;
     $rowTaxRate = $tblPaymentSetting->fetchRow("settingKey='taxRate'");
     $taxRate = $rowTaxRate->settingValue;
     $tblUser = new App_Model_Db_Table_User();
     $rowUser = $tblUser->find($kopel)->current();
     /*
         	$modelGroup = new Kutu_Core_Orm_Table_Group();
         	$row = $modelGroup->fetchRow("id=".$this->_user->packageId);
     if ($row->name == "free") {
     	$rowUser->periodeId = 2;
     	$rowUser->save();
     }
     */
     $this->view->rowUser = $rowUser;
     // discount
     $disc = $formater->checkPromoValidation('Disc', $packageId, $rowUser->promotionId, $paymentSubscription);
     $total = $formater->checkPromoValidation('Total', $packageId, $rowUser->promotionId, $paymentSubscription);
     $tblPackage = new App_Model_Db_Table_Package();
     $rowPackage = $tblPackage->fetchRow("packageId={$packageId}");
     $this->view->rowPackage = $rowPackage;
     $tblOrder = new App_Model_Db_Table_Order();
     $row = $tblOrder->fetchNew();
     $row->userId = $kopel;
     if ($this->getRequest()->getPost()) {
         $value = $this->getRequest()->getPost();
         $row->taxNumber = $value['taxNumber'];
         $row->taxCompany = $value['taxCompany'];
         $row->taxAddress = $value['taxAddress'];
         $row->taxCity = $value['taxCity'];
         $row->taxZip = $value['taxZip'];
         $row->taxProvince = $value['taxProvince'];
         $row->taxCountryId = $value['taxCountry'];
         $row->paymentMethod = $method;
     }
     $row->datePurchased = date('YmdHis');
     $row->paymentMethodNote = "membership";
     if ($method == "nsiapay") {
         $row->orderStatus = 8;
     } else {
         $row->orderStatus = 1;
         //pending
     }
     $row->currency = $defaultCurrency;
     $row->currencyValue = $currencyValue;
     $row->orderTotal = $total;
     $row->ipAddress = Pandamp_Lib_Formater::getRealIpAddr();
     $orderId = $row->save();
     $rowJustInserted = $tblOrder->find($orderId)->current();
     $rowJustInserted->invoiceNumber = date('Ymd') . '.' . $orderId;
     $temptime = time();
     $temptime = Pandamp_Lib_Formater::DateAdd('d', 5, $temptime);
     $rowJustInserted->discount = $disc;
     $rowJustInserted->invoiceExpirationDate = strftime('%Y-%m-%d', $temptime);
     $rowJustInserted->save();
     $this->view->invoiceNumber = $rowJustInserted->invoiceNumber;
     $this->view->datePurchased = $rowJustInserted->datePurchased;
     $tblOrderDetail = new App_Model_Db_Table_OrderDetail();
     $rowDetail = $tblOrderDetail->fetchNew();
     $rowDetail->orderId = $orderId;
     $rowDetail->itemId = $rowPackage->packageId;
     $modelGroup = new App_Model_Db_Table_Group();
     $row = $modelGroup->fetchRow("id={$packageId}");
     $group = "Subsciption for Member " . ucwords(strtolower($row->name)) . " " . $paymentSubscription . " Months";
     $this->view->packageId = $packageId;
     $this->view->paymentSubscription = $paymentSubscription;
     $this->view->itemName = $group;
     $rowDetail->documentName = $group;
     $rowDetail->price = $total;
     $numOfUsers = $tblUser->getUserCount($rowUser->kopel);
     $this->view->numOfUsers = $numOfUsers;
     $this->view->grandtotal = $total;
     $this->view->method = $method;
     $this->view->orderId = $orderId;
     $this->view->total = $rowPackage->charge;
     $rowDetail->qty = $numOfUsers;
     $rowDetail->finalPrice = $total;
     $rowDetail->save();
     $data = $this->_request->getParams();
     $this->view->data = $data;
     $modDir = $this->getFrontController()->getModuleDirectory();
     require_once $modDir . '/models/Store/Mailer.php';
     $mod = new Membership_Model_Store_Mailer();
     switch (strtolower($method)) {
         case 'manual':
         case 'bank':
             $mod->sendBankInvoiceToUser($orderId);
             break;
         case 'nsiapay':
             $mod->sendInvoiceToUser($orderId);
             break;
     }
 }