private function _save()
 {
     $bpm = new Kutu_Core_Bpm_Catalog();
     $r = $this->getRequest();
     $aData = $r->getParams();
     $bpm->uploadFile($aData, $aData['relatedGuid']);
 }
 public function foldersAction()
 {
     $r = $this->getRequest();
     $guid = $r->getParam('g');
     $this->view->catalogGuid = $guid;
     $bpm = new Kutu_Core_Bpm_Catalog();
     $this->view->rowsetFolder = $bpm->getFolders($guid);
 }
Example #3
0
 public function __construct($catalogGuid)
 {
     $this->view = new Zend_View();
     $this->view->setScriptPath(dirname(__FILE__));
     $this->catalogGuid = $catalogGuid;
     $this->view->catalogGuid = $catalogGuid;
     $this->view->addHelperPath(KUTU_ROOT_DIR . '/lib/Kutu/View/Helper', 'Kutu_View_Helper');
     $bpm = new Kutu_Core_Bpm_Catalog();
     $this->view->rowsetFolder = $bpm->getFolders($catalogGuid);
 }
 protected function completeItem()
 {
     $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'] * $this->_paymentVars['taxRate'] / 100;
     $result['grandTotal'] = $result['subTotal'] + $result['taxAmount'];
     return $result;
 }
Example #5
0
 public function forceDelete($folderGuid)
 {
     Zend_Loader::loadClass('Kutu_Core_Orm_Table_Folder');
     $tblFolder = new Kutu_Core_Orm_Table_Folder();
     $rowSet = $tblFolder->fetchChildren($folderGuid);
     $row1 = $tblFolder->find($folderGuid)->current();
     foreach ($rowSet as $row) {
         $this->forceDelete($row->guid);
     }
     echo $row1->title . ' ';
     $rowsetCatalogFolder = $row1->findDependentRowsetCatalogFolder();
     $tblCatalog = new Kutu_Core_Orm_Table_Catalog();
     $bpmCatalog = new Kutu_Core_Bpm_Catalog();
     if (count($rowsetCatalogFolder)) {
         foreach ($rowsetCatalogFolder as $rowCatalogFolder) {
             $rowCatalog = $tblCatalog->find($rowCatalogFolder->catalogGuid)->current();
             echo $rowCatalog->guid . '<br>';
             $bpmCatalog->delete($rowCatalog->guid);
         }
         $this->delete($row1->guid);
     } else {
         $this->delete($row1->guid);
     }
 }
 public function detailsAction()
 {
     //$this->_helper->layout()->setLayout('layout-iht');
     $r = $this->getRequest();
     $catalogGuid = $r->getParam('guid');
     $this->view->catalogGuid = $catalogGuid;
     $folderGuid = $r->getParam('node');
     $this->view->currentNode = $folderGuid;
     $tblCatalog = new Kutu_Core_Orm_Table_Catalog();
     $rowCatalog = $tblCatalog->find($catalogGuid)->current();
     //update number of downloads and number of views
     $bpm = new Kutu_Core_Bpm_Catalog();
     $bpm->updateNumberOfViews($rowCatalog->guid);
     $this->view->bpm = $bpm;
     $rowsetAttribute = $rowCatalog->findDependentRowsetCatalogAttribute();
     $rowTitle = $rowsetAttribute->findByAttributeGuid('fixedTitle');
     $this->view->catalogTitle = $rowTitle->value;
     $rowSubTitle = $rowsetAttribute->findByAttributeGuid('fixedSubTitle');
     $this->view->catalogSubTitle = $rowSubTitle->value;
     $modDir = $this->getFrontController()->getModuleDirectory();
     require_once $modDir . '/components/Dms/Catalog/DetailsViewer.php';
     $w = new Dms_Catalog_DetailsViewer($catalogGuid, 'root');
     $this->view->widget1 = $w;
     if (empty($folderGuid)) {
         $rowsetFolder = $rowCatalog->findManyToManyRowset('Kutu_Core_Orm_Table_Folder', 'Kutu_Core_Orm_Table_CatalogFolder');
         if (count($rowsetFolder) > 0) {
             $rowFolder = $rowsetFolder->current();
             $folderGuid = $rowFolder->guid;
             $this->view->currentNode = $folderGuid;
         }
     }
 }
Example #7
0
 function display_cart($jcart)
 {
     // JCART ARRAY HOLDS USER CONFIG SETTINGS
     extract($jcart);
     // ASSIGN USER CONFIG VALUES TO POST VARS
     // VALUES ARE HTML NAME ATTRIBUTES FROM THE ADD-TO-CART FORM
     @($item_id = $_POST[$item_id]);
     @($item_qty = ltrim($_POST[$item_qty], '-'));
     // PREVENT QTY FROM BEING NEGATIVE
     @($item_price = ltrim($_POST[$item_price], '-'));
     // PREVENT PRICE FROM BEING NEGATIVE
     @($item_name = $_POST[$item_name]);
     // ADD ITEM
     if (@$_POST[$item_add]) {
         $sanitized_item_id = filter_var($item_id, FILTER_SANITIZE_SPECIAL_CHARS);
         $valid_item_qty = filter_var($item_qty, FILTER_VALIDATE_INT);
         $valid_item_price = filter_var($item_price, FILTER_VALIDATE_FLOAT);
         $sanitized_item_name = filter_var($item_name, FILTER_SANITIZE_SPECIAL_CHARS);
         // VALIDATION
         if (!$valid_item_qty) {
             $error_message = $text['quantity_error'];
         } else {
             if (!$valid_item_price) {
                 //[CUSTOM]
                 if (empty($valid_item_price)) {
                     $error_message = '<script>alert("This is a Free Item.");</script>';
                 } else {
                     $error_message = $text['price_error'];
                 }
             } else {
                 /*//[CUSTOM]
                 					// check if catalog has documents
                 					$tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem();
                 					$where = "relatedGuid='$sanitized_item_id' AND relateAs='RELATED_FILE'";
                 					$rowsetRelatedItem = $tblRelatedItem->fetchAll($where);
                 					if(count($rowsetRelatedItem) > 0)
                 					{
                 						//check if the physical FILE is available in uploads directory.
                 						$flagFileFound = true;
                 
                 						foreach($rowsetRelatedItem as $rowRelatedItem)
                 						{
                 							$tblCatalog = new Kutu_Core_Orm_Table_Catalog();
                 					    	$rowsetCatalog = $tblCatalog->find($rowRelatedItem->itemGuid);
                 				
                 							$rowCatalog = $rowsetCatalog->current();
                 				    		$rowsetCatAtt = $rowCatalog->findDependentRowsetCatalogAttribute();
                 
                 					    	$contentType = $rowsetCatAtt->findByAttributeGuid('docMimeType')->value;
                 							$systemname = $rowsetCatAtt->findByAttributeGuid('docSystemName')->value;
                 							$filename = $rowsetCatAtt->findByAttributeGuid('docOriginalName')->value;
                 							
                 							if(true)
                 							{
                 								$parentGuid = $rowRelatedItem->relatedGuid;
                 								$sDir1 = KUTU_ROOT_DIR.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'files'.DIRECTORY_SEPARATOR.$systemname;
                 								$sDir2 = KUTU_ROOT_DIR.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'files'.DIRECTORY_SEPARATOR.$parentGuid.DIRECTORY_SEPARATOR.$systemname;
                 
                 								if(file_exists($sDir1))
                 								{
                 									//$flagFileFound = true;
                 								}
                 								else 
                 									if(file_exists($sDir2))
                 									{
                 										//$flagFileFound = true;
                 									}
                 									else 
                 									{
                 										$flagFileFound = false;
                 									}
                 							}
                 						}
                 						
                 						//echo "punya file kok";
                 						//$error_message = '<script>alert("");</script>';
                 						// ADD THE ITEM
                 						if($flagFileFound)
                 						{
                 							$auth =  Zend_Auth::getInstance();
                 							$hasBought = false;
                 							
                 							if($auth->hasIdentity())
                 							{
                 								$bpm = new Kutu_Core_Bpm_Catalog();
                 								$hasBought = $bpm->isBoughtByUser($sanitized_item_id, $auth->getIdentity()->guid);
                 							}
                 							
                 							if($hasBought)
                 							{
                 								$error_message = '<script>alert("You have bought this Item before. Please check your account.");</script>';
                 							}
                 							else
                 								$this->add_item($sanitized_item_id, $valid_item_qty, $valid_item_price, $sanitized_item_name);
                 						}
                 						else
                 							$error_message = '<script>alert("We are Sorry. The document(s) you are requesting is still not complete. Please check back later.");</script>';
                 					}
                 					else
                 					{
                 						$error_message = '<script>alert("We are Sorry. The document(s) you are requesting is still under review. Please check back later.");</script>';
                 					}
                 					*/
                 require_once 'Kutu/Core/Bpm/Catalog.php';
                 $bpmCatalog = new Kutu_Core_Bpm_Catalog();
                 $aReturn = $bpmCatalog->jCartIsItemSellable($sanitized_item_id);
                 if ($aReturn['isError']) {
                     $error_message = '<script>alert("' . $aReturn['message'] . '");</script>';
                 } else {
                     $this->add_item($sanitized_item_id, $valid_item_qty, $valid_item_price, $sanitized_item_name);
                 }
             }
         }
     }
     // REMOVE ITEM
     /*
     GET VAR COMES FROM A LINK, WITH THE ITEM ID TO BE REMOVED IN ITS QUERY STRING
     AFTER AN ITEM IS REMOVED ITS ID STAYS SET IN THE QUERY STRING, PREVENTING THE SAME ITEM FROM BEING ADDED BACK TO THE CART
     SO WE CHECK TO MAKE SURE ONLY THE GET VAR IS SET, AND NOT THE POST VARS
     
     USING POST VARS TO REMOVE ITEMS DOESN'T WORK BECAUSE WE HAVE TO PASS THE ID OF THE ITEM TO BE REMOVED AS THE VALUE OF THE BUTTON
     IF USING AN INPUT WITH TYPE SUBMIT, ALL BROWSERS DISPLAY THE ITEM ID, INSTEAD OF ALLOWING FOR USER FRIENDLY TEXT SUCH AS 'remove'
     IF USING AN INPUT WITH TYPE IMAGE, INTERNET EXPLORER DOES NOT SUBMIT THE VALUE, ONLY X AND Y COORDINATES WHERE BUTTON WAS CLICKED
     CAN'T USE A HIDDEN INPUT EITHER SINCE THE CART FORM HAS TO ENCOMPASS ALL ITEMS TO RECALCULATE TOTAL WHEN A QUANTITY IS CHANGED, WHICH MEANS THERE ARE MULTIPLE REMOVE BUTTONS AND NO WAY TO ASSOCIATE THEM WITH THE CORRECT HIDDEN INPUT
     */
     if (@$_GET['jcart_remove'] && @(!$_POST[$item_add]) && @(!$_POST['jcart_update_cart']) && @(!$_POST['jcart_check_out'])) {
         // ENSURE THE VALUE IS AN INTEGER
         //$rid = intval($_GET['jcart_remove']);
         $rid = $_GET['jcart_remove'];
         // REMOVE THE ITEM
         //die($rid);
         $this->del_item($rid);
     }
     // EMPTY CART
     if (@$_POST['jcart_empty']) {
         $this->empty_cart();
     }
     // UPDATE ALL ITEMS IN CART SINCE VISITOR MAY UPDATE MULTIPLE FIELDS BEFORE CLICKING UPDATE
     // ONLY USED WHEN JAVASCRIPT IS DISABLED
     // WHEN JAVASCRIPT IS ENABLED, THE CART IS UPDATED WHEN AN ITEM QTY IS CHANGED
     if (@$_POST['jcart_update_cart']) {
         // POST VALUE IS AN ARRAY OF ALL ITEM IDs IN THE CART
         $item_ids = $_POST['jcart_item_id'];
         // IF NO ITEM IDs, THE CART IS EMPTY
         if ($item_ids) {
             // POST VALUE IS AN ARRAY OF ALL ITEM QUANTITIES IN THE CART
             // TREAT VALUES AS A STRING FOR VALIDATION
             $item_qtys = implode($_POST['jcart_item_qty']);
             $valid_item_qtys = filter_var($item_qtys, FILTER_VALIDATE_INT);
             // VALIDATION
             // ITEM QTY CAN ONLY BE AN INTEGER OR ZERO
             if (!$valid_item_qtys && $item_qtys !== '0') {
                 $error_message = $text['quantity_error'];
             } else {
                 // THE INDEX OF THE ITEM AND ITS QUANTITY IN THEIR RESPECTIVE ARRAYS
                 $count = 0;
                 // FOR EACH ITEM IN THE CART
                 foreach ($item_ids as $item_id) {
                     // SANITIZE THE ITEM ID
                     $sanitized_item_id = filter_var($item_id, FILTER_SANITIZE_SPECIAL_CHARS);
                     // GET THE ITEM QTY AND DOUBLE-CHECK THAT THE VALUE IS AN INTEGER
                     $update_item_qty = intval($_POST['jcart_item_qty'][$count]);
                     // UPDATE THE ITEM
                     $this->edit_item($sanitized_item_id, $update_item_qty);
                     // INCREMENT INDEX FOR THE NEXT ITEM
                     $count++;
                 }
             }
         }
     }
     // CHECKING POST VALUE AGAINST $text ARRAY FAILS??
     // HAVE TO CHECK AGAINST $jcart ARRAY
     if (@$_POST['jcart_update_item'] == $jcart['text']['update_button']) {
         // SANITIZE THE ITEM ID
         $item_id = $_POST['item_id'];
         $sanitized_item_id = filter_var($item_id, FILTER_SANITIZE_SPECIAL_CHARS);
         // GET THE ITEM QTY AND CHECK THAT THE VALUE IS AN INTEGER
         $item_qty = $_POST['item_qty'];
         $valid_item_qty = filter_var($item_qty, FILTER_VALIDATE_INT);
         // VALIDATION
         // ITEM QTY CAN ONLY BE AN INTEGER, OR ZERO, OR EMPTY
         if (!$valid_item_qty && $item_qty !== '0' && $item_qty !== '') {
             $error_message = $text['quantity_error'];
         } else {
             // UPDATE THE ITEM
             $this->edit_item($sanitized_item_id, $valid_item_qty);
         }
     }
     // OUTPUT THE CART
     // DETERMINE WHICH TEXT TO USE FOR THE NUMBER OF ITEMS IN THE CART
     if ($this->itemcount >= 0) {
         $text['items_in_cart'] = $text['multiple_items'];
     }
     if ($this->itemcount == 1) {
         $text['items_in_cart'] = $text['single_item'];
     }
     // IF THERE'S AN ERROR MESSAGE WRAP IT IN SOME HTML
     if (@$error_message) {
         $error_message = "<p class='jcart-error'>{$error_message}</p>";
     }
     // DISPLAY THE CART HEADER
     echo "<!-- BEGIN JCART -->\n<div id='jcart'>\n";
     echo @$error_message . "\n";
     echo "<form method='post' action='" . $form_action . "'>\n\n";
     echo "<table border='1'>\n";
     echo "<tr>\n";
     echo "<th colspan='3'>\n";
     echo "<strong id='jcart-title'>" . $text['cart_title'] . "</strong> (" . $this->itemcount . "&nbsp;" . $text['items_in_cart'] . ")\n";
     echo "</th>\n";
     echo "</tr>" . "\n";
     // IF ANY ITEMS IN THE CART
     if ($this->itemcount > 0) {
         // DISPLAY LINE ITEMS
         foreach ($this->get_contents() as $item) {
             echo "<tr>\n";
             // ADD THE ITEM ID AS THE INPUT ID ATTRIBUTE
             // THIS ALLOWS US TO ACCESS THE ITEM ID VIA JAVASCRIPT ON QTY CHANGE, AND THEREFORE UPDATE THE CORRECT ITEM
             // NOTE THAT THE ITEM ID IS ALSO PASSED AS A SEPARATE FIELD FOR PROCESSING VIA PHP
             echo "<td class='jcart-item-qty'>\n";
             echo "<input type='text' size='2' id='jcart-item-id-" . $item['id'] . "' name='jcart_item_qty[ ]' value='" . $item['qty'] . "' />\n";
             echo "</td>\n";
             echo "<td class='jcart-item-name'>\n";
             echo $item['info'] . "<input type='hidden' name='jcart_item_info[ ]' value='" . $item['info'] . "' />\n";
             echo "<input type='hidden' name='jcart_item_id[ ]' value='" . $item['id'] . "' />\n";
             echo "</td>\n";
             echo "<td class='jcart-item-price'><span>\n";
             echo $text['currency_symbol'] . number_format($item['subtotal'], 2) . "</span><input type='hidden' name='jcart_item_price[ ]' value='" . $item['price'] . "' />\n";
             echo "<a class='jcart-remove' href='?jcart_remove=" . $item['id'] . "'>" . $text['remove_link'] . "</a>\n";
             echo "</td>\n";
             echo "</tr>\n";
         }
     } else {
         echo "<tr><td colspan='3' class='empty'>" . $text['empty_message'] . "</td></tr>\n";
     }
     // DISPLAY THE CART FOOTER
     echo "<tr>\n";
     echo "<th colspan='3'>\n";
     echo "<input type='submit' id='jcart-checkout' name='jcart_checkout' class='jcart-button' value='" . $text['checkout_button'] . "' />\n";
     echo "<span id='jcart-subtotal'>" . $text['subtotal'] . ": <strong>" . $text['currency_symbol'] . number_format($this->total, 2) . "</strong></span>\n";
     echo "</th>\n";
     echo "</tr>\n";
     echo "</table>\n\n";
     echo "<div class='jcart-hide'>\n";
     echo "<input type='submit' name='jcart_update_cart' value='" . $text['update_button'] . "' class='jcart-button' />\n";
     echo "<input type='submit' name='jcart_empty' value='" . $text['empty_button'] . "' class='jcart-button' />\n";
     echo "</div>\n";
     echo "</form>\n";
     echo "</div>\n<!-- END JCART -->\n";
 }
Example #8
0
 private function _checkAccess($itemGuid)
 {
     $bpm = new Kutu_Core_Bpm_Catalog();
     $acl = Kutu_Acl::manager();
     if ($acl->checkAcl("site", 'all', 'user', $this->_auth->getIdentity()->username, false, false)) {
         return true;
     }
     if ($bpm->getPrice($itemGuid) <= 0) {
         // can be downloaded
         return true;
     } else {
         //check if the logged in user has once bought the parent Catalog
         return $bpm->isBoughtByUser($itemGuid, $this->_auth->getIdentity()->guid);
     }
 }
Example #9
0
 public function getFolders($catalogGuid)
 {
     $bpm = new Kutu_Core_Bpm_Catalog();
     return $bpm->getFolders($catalogGuid);
 }
Example #10
0
 public function completeorderAction()
 {
     //this is where we generate invoice
     // and then empty cart
     // and then if payment method is paypal, ask if user wants to continue to pay via paypal.
     // if payment method is manual, then print-out the payment instruction.
     // send invoice to user.
     $tblPaymentSetting = new Kutu_Core_Orm_Table_PaymentSetting();
     $rowTaxRate = $tblPaymentSetting->fetchRow("settingKey='taxRate'");
     $cart =& $_SESSION['jCart'];
     if (!is_object($cart)) {
         $cart = new jCart();
     }
     if (empty($cart) || count($cart->items) == 0) {
         //die("CART IS EMPTY");
         $this->_helper->redirector('cartempty', 'store', 'site');
     }
     $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'];
     $method = $this->_request->getParam('paymentMethod');
     $orderId = $this->saveOrder($result, $method);
     $cart = null;
     $data = $this->_request->getParams();
     $this->view->cart = $result;
     $this->view->data = $data;
     $this->view->orderId = $orderId;
     //send notification to user
     // 1. send invoice
     // 2. if paymentmethod=bank, also send instruction
     $mod = new Site_Model_Store_Mailer();
     switch (strtolower($method)) {
         case 'manual':
         case 'bank':
             $mod->sendBankInvoiceToUser($orderId);
             break;
         case 'paypal':
             $mod->sendInvoiceToUser($orderId);
             break;
         case 'postpaid':
             $mod->sendInvoiceToUser($orderId);
             break;
     }
 }
 public function alterdateAction()
 {
     $urlReferer = $_SERVER['HTTP_REFERER'];
     $r = $this->getRequest();
     $guid = $r->getParam('guid');
     $tblCatalog = new Kutu_Core_Orm_Table_Catalog();
     $rowset = $tblCatalog->find($guid);
     if (count($rowset)) {
         $row = $rowset->current();
         $this->view->row = $row;
         $this->view->guid = $row->guid;
         $this->view->catalogTitle = Kutu_Core_Util::getCatalogAttributeValue($row->guid, 'fixedTitle');
         if ($r->isPost()) {
             $sessHistory = new Zend_Session_Namespace('BROWSER_HISTORY');
             $urlReferer = $sessHistory->urlReferer;
             $createdDate = $r->getParam('createdDate');
             $modifiedDate = $r->getParam('modifiedDate');
             $bpm = new Kutu_Core_Bpm_Catalog();
             $bpm->alterDate($r->getParams());
             $this->view->message = "Date has been altered.";
         } else {
         }
     }
     $sessHistory = new Zend_Session_Namespace('BROWSER_HISTORY');
     $sessHistory->urlReferer = $urlReferer;
     $this->view->urlReferer = $sessHistory->urlReferer;
 }
Example #12
0
 public function jCartIsItemSellable($catalogGuid)
 {
     //apakah pernah dibeli
     $auth = Zend_Auth::getInstance();
     $hasBought = false;
     if ($auth->hasIdentity()) {
         $bpm = new Kutu_Core_Bpm_Catalog();
         $hasBought = $bpm->isBoughtByUser($catalogGuid, $auth->getIdentity()->guid);
     }
     if ($hasBought) {
         $aReturn['isError'] = true;
         $aReturn['message'] = 'You have bought this Item before. Please check your account.';
         $aReturn['code'] = 1;
         return $aReturn;
     }
     // if status=draft then return false
     $tblCatalog = new Kutu_Core_Orm_Table_Catalog();
     $rowCatalog = $tblCatalog->find($catalogGuid)->current();
     if ($rowCatalog) {
         if ($rowCatalog->status != 99) {
             $aReturn['isError'] = true;
             $aReturn['message'] = 'This item is not ready to be bought yet.';
             $aReturn['code'] = 1;
             return $aReturn;
         }
         // if price <= 0 then return false
         if ($rowCatalog->price <= 0) {
             $aReturn['isError'] = true;
             $aReturn['message'] = 'This item is for FREE.';
             $aReturn['code'] = 2;
             return $aReturn;
         }
         $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem();
         $where = "relatedGuid='{$catalogGuid}' AND relateAs='RELATED_FILE'";
         $rowsetRelatedItem = $tblRelatedItem->fetchAll($where);
         if (count($rowsetRelatedItem) > 0) {
             //check if the physical FILE is available in uploads directory.
             $flagFileFound = true;
             foreach ($rowsetRelatedItem as $rowRelatedItem) {
                 $tblCatalog = new Kutu_Core_Orm_Table_Catalog();
                 $rowsetCatalogFile = $tblCatalog->find($rowRelatedItem->itemGuid);
                 $rowCatalogFile = $rowsetCatalogFile->current();
                 $rowsetCatAtt = $rowCatalogFile->findDependentRowsetCatalogAttribute();
                 $contentType = $rowsetCatAtt->findByAttributeGuid('docMimeType')->value;
                 $systemname = $rowsetCatAtt->findByAttributeGuid('docSystemName')->value;
                 $filename = $rowsetCatAtt->findByAttributeGuid('docOriginalName')->value;
                 if (true) {
                     $parentGuid = $rowRelatedItem->relatedGuid;
                     $sDir1 = KUTU_ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $systemname;
                     $sDir2 = KUTU_ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $parentGuid . DIRECTORY_SEPARATOR . $systemname;
                     if (file_exists($sDir1)) {
                         //$flagFileFound = true;
                     } else {
                         if (file_exists($sDir2)) {
                             //$flagFileFound = true;
                         } else {
                             $flagFileFound = false;
                         }
                     }
                 }
             }
             if ($flagFileFound) {
                 $aReturn['isError'] = false;
                 $aReturn['message'] = 'This item is SELLABLE.';
                 $aReturn['code'] = 99;
                 return $aReturn;
             } else {
                 $aReturn['isError'] = true;
                 $aReturn['message'] = 'We are Sorry. The document(s) you are requesting is still under review. Please check back later.';
                 $aReturn['code'] = 5;
                 return $aReturn;
             }
         } else {
             $aReturn['isError'] = true;
             $aReturn['message'] = 'We are Sorry. The document(s) you are requesting is still being prepared. Please check back later.';
             $aReturn['code'] = 5;
             return $aReturn;
         }
     } else {
         $aReturn['isError'] = true;
         $aReturn['message'] = 'Can not find your selected item(s).';
         $aReturn['code'] = 10;
         return $aReturn;
     }
     //if ada record related document, but tidak ada dokumen fisik, then return false
     // if tidak ada record related document (blm ada dokumen/file diupload), then return false
     // if pernah dibeli user sebelumnya, then return false
 }
 public function indexAction()
 {
     //$this->view->render(
     $r = $this->getRequest();
     $folderLegalDb = "lgs4a0ee4ab533b4";
     $guid = $r->getParam('g');
     if (empty($guid)) {
         $this->_forward('index', "index", 'site', $r->getParams());
         return true;
     }
     $tblFolder = new Kutu_Core_Orm_Table_Folder();
     $rowset = $tblFolder->find($guid);
     if (count($rowset)) {
         $row = $rowset->current();
         $json = new Zend_Json();
         if (empty($row->cmsParams)) {
             //check if folder is child of folderLegalDb
             if (strpos($row->path, $folderLegalDb) === false) {
                 $this->_forward('list', "pages", 'site', $r->getParams());
             } else {
                 $this->_redirect(KUTU_ROOT_URL . '/dms/' . $row->guid);
             }
             return true;
             //die();
         } else {
             $aData = $json->decode($row->cmsParams);
             if (!empty($aData['a']) && !empty($aData['c']) && !empty($aData['m'])) {
                 $aData['p'] = array_merge($aData['p'], $r->getParams());
                 $this->_forward($aData['a'], $aData['c'], $aData['m'], $aData['p']);
                 return true;
             } else {
                 $aData['p'] = array_merge($aData['p'], $r->getParams());
                 //check if folder is child of folderLegalDb
                 if (strpos($row->path, $folderLegalDb) === false) {
                     $this->_forward('list', "pages", 'site', $aData['p']);
                 } else {
                     $this->_redirect(KUTU_ROOT_URL . '/dms/' . $row->guid);
                 }
                 return true;
             }
         }
     } else {
         $tblCatalog = new Kutu_Core_Orm_Table_Catalog();
         $rowset = $tblCatalog->find($guid);
         if (count($rowset)) {
             $row = $rowset->current();
             //update number of downloads and number of views
             $bpm = new Kutu_Core_Bpm_Catalog();
             $bpm->updateNumberOfViews($row->guid);
             switch ($row->profileGuid) {
                 case 'kutu_peraturan':
                 case 'kutu_putusan':
                     $this->_redirect(KUTU_ROOT_URL . '/dms/catalog/' . $guid);
                     return true;
             }
             $rowsetFolder = $row->findManyToManyRowset('Kutu_Core_Orm_Table_Folder', 'Kutu_Core_Orm_Table_CatalogFolder');
             if (count($rowsetFolder) > 0) {
                 foreach ($rowsetFolder as $rowFolder) {
                     //$rowFolder = $rowsetFolder->current();
                     $folderGuid = $rowFolder->guid;
                     if (strpos($rowFolder->path, $folderLegalDb) !== false) {
                         //do nothing
                     } else {
                         $aParams = $r->getParams();
                         $aParams['node'] = $folderGuid;
                         //Should forward to specific controller based on catalog's profileGuid
                         $this->_forward('generic', "pages_details", 'site', $aParams);
                         return true;
                     }
                 }
                 $this->_redirect(KUTU_ROOT_URL . '/dms/catalog/' . $guid . '/node/' . $folderGuid);
             } else {
                 $this->_redirect(KUTU_ROOT_URL . '/dms/catalog/' . $guid . '/node/' . $folderGuid);
             }
         } else {
         }
     }
 }