示例#1
0
 public static function saveOrder($cart, $user, $payGty, $payGtyDetail, $deliveryGty, $deliveryDetail, $status, $guest_buying = '0')
 {
     $db = JFactory::getDBO();
     $cartItem = array_pop($cart->getAll());
     $__data = new stdClass();
     $__data->total_buyer_paid = $cart->getTotalPrice();
     $__data->point_used_to_pay = $cart->getPoint();
     $__data->status = $status;
     $__data->session_id = JFactory::getSession()->getId();
     $__data->buyer_id = $user['id'];
     $__data->buyer_detail = json_encode($user);
     $__data->referral_id = $cart->getReferralId();
     $__data->pay_gty_id = $payGty->id;
     $__data->delivery_gty_id = $deliveryGty->id;
     $__data->delivery_detail = json_encode($deliveryDetail);
     $__data->created_at = DatetimeWrapper::getDatetimeOfNow();
     $__data->updated_at = DatetimeWrapper::getDatetimeOfNow();
     $__data->paid_amount = number_format($cartItem->getCount() * $cartItem->item->price * $cartItem->item->prepay_percent / 100, 2);
     $db->insertObject('#__enmasse_order', $__data, 'id');
     if ($db->getErrorNum()) {
         echo $db->stderr();
         return false;
     } else {
         return $__data;
     }
 }
示例#2
0
function getDealListByLocationId($locationId)
{
    $mainframe = JFactory::getApplication('site');
    $db = JFactory::getDBO();
    $query = "SELECT *\n\t\t\t\tFROM `#__enmasse_deal`\n\t\t\t\tWHERE \n\t\t\t\tstatus NOT LIKE 'Pending' AND\n\t\t          \t\tpublished = '1' AND\n\t\t\t\t\t\tstart_at <='" . DatetimeWrapper::getDatetimeOfNow() . "' \n\t\t          \t\tAND end_at >= '" . DatetimeWrapper::getDatetimeOfNow() . "' \n\t\t          \t\tAND id\n\t\t\t\tIN (\t\t\t\t\n\t\t\t\t\tSELECT deal_id\n\t\t\t\t\tFROM `#__enmasse_deal_location`\n\t\t\t\t\tWHERE location_id = " . $locationId . "\n\t\t\t\t) ORDER BY created_at DESC";
    $db->setQuery($query);
    $rows = $db->loadAssocList();
    return $rows;
}
示例#3
0
function getListDeal()
{
    $mainframe = JFactory::getApplication('site');
    // deal
    $db = JFactory::getDBO();
    $query = "\tSELECT \n\t\t\t\t\t\t* \n\t\t\t\t\tFROM \n\t\t\t\t\t\t#__enmasse_deal \n\t\t\t\t\tWHERE\n\t\t\t\t\t    status NOT LIKE 'Pending' AND\n\t\t          \t\tpublished = '1' AND\n\t\t\t\t\t\tstart_at <='" . DatetimeWrapper::getDatetimeOfNow() . "' \n\t\t          \t\tAND end_at >= '" . DatetimeWrapper::getDatetimeOfNow() . "' ";
    $db->setQuery($query);
    $rows = $db->loadObjectList();
    return $rows;
}
示例#4
0
function getTodayDeal()
{
    $mainframe = JFactory::getApplication('site');
    // deal
    $db = JFactory::getDBO();
    $query = "\tSELECT\n\t\t\t\t\t\t\t* \n\t\t\t\t\t\tFROM \n\t\t\t\t\t\t\t#__enmasse_deal \n\t\t\t\t\t\tWHERE\n\t\t              \t\tpublished = '1' AND \n\t\t              \t\tend_at > '" . DatetimeWrapper::getDatetimeOfNow() . "'\n\t\t              \tORDER BY\n\t\t              \t\tposition Asc\n\t\t              \tLIMIT\n\t\t              \t\t1\n\t\t              ";
    $db->setQuery($query);
    $deal = $db->loadObject();
    return $deal;
}
示例#5
0
 function updateStatus($id, $value)
 {
     $db = JFactory::getDBO();
     $query = 'UPDATE #__enmasse_order_item SET status ="' . $value . '", updated_at = "' . DatetimeWrapper::getDatetimeOfNow() . '" where id =' . $id;
     $db->setQuery($query);
     $db->query();
     if ($this->_db->getErrorNum()) {
         JError::raiseError(500, $this->_db->stderr());
         return false;
     }
     return true;
 }
示例#6
0
 function updatePayDetail($id, $payDetail)
 {
     $db = JFactory::getDBO();
     $query = "UPDATE #__enmasse_order SET pay_detail ='" . $payDetail . "', updated_at = '" . DatetimeWrapper::getDatetimeOfNow() . "' where id =" . $id;
     $db->setQuery($query);
     $db->query();
     if ($this->_db->getErrorNum()) {
         JError::raiseError(500, $this->_db->stderr());
         return false;
     }
     return true;
 }
示例#7
0
 public function save($data)
 {
     $nUser = $data['user_id'];
     $arOrderId = $data['orders'];
     $dtNow = DatetimeWrapper::getDatetimeOfNow();
     $sInsert = "({$nUser} , '{$dtNow}', '{$dtNow}' ," . implode("),({$nUser} , '{$dtNow}', '{$dtNow}' ,", $arOrderId) . ")";
     $db = JFactory::getDbo();
     $query = "INSERT IGNORE INTO #__enmasse_order_deliverer (user_id, created_at, updated_at, order_id) VALUES " . $sInsert;
     $db->setQuery($query);
     $db->query();
     if ($db->getErrorNum()) {
         $this->setError($db->getErrorMsg());
         return false;
     } else {
         return true;
     }
 }
示例#8
0
 public function updateOrder()
 {
     $orderId = JRequest::getVar('id', 0, 'post', 'int');
     $sComment = JRequest::getVar('description');
     $sDlvStatus = JRequest::getVar('delivery_status', 'undelivered');
     $oOrderTbl = JTable::getInstance('order', 'Table');
     $oOrderTbl->load($orderId);
     $oOrderTbl->description = $sComment;
     $oOrderTbl->updated_at = DatetimeWrapper::getDatetimeOfNow();
     if ($sDlvStatus == "delivered") {
         $oOrderTbl->status = EnmasseHelper::$ORDER_STATUS_LIST['Holding_By_Deliverer'];
     }
     $oOrderTbl->store();
     JModel::getInstance('orderDeliverer', 'enmasseModel')->updateStatus($orderId, $sDlvStatus);
     $msg = JText::_('ORDER_DELIVERER_UPDATE_SUCCESS_MSG');
     $link = JRoute::_("index.php?option=com_enmasse&controller=deliverer&task=show");
     JFactory::getApplication()->redirect($link, $msg);
 }
示例#9
0
 function submit_review()
 {
     $nDealId = JRequest::getVar('nDealId');
     $nRating = JRequest::getVar('nRating');
     $sReviewBody = JRequest::getVar('sReviewBody');
     // Be sure this is a valid deal id
     if ($nDealId > 0) {
         // Check for a valid rating number and review content
         // User has to select his/her rating (the number is from 1 to 5)
         // and has enter his/her review
         if ($nRating <= 0 || $nRating > 5) {
             $sMessage = JText::_('PLEASE_RATE');
             $sRedirectUrl = JRoute::_('index.php?option=com_enmasse&controller=deal&task=comment&id=' . $nDealId, false);
         } elseif ($sReviewBody == '') {
             $sMessage = JText::_('PLEASE_ENTER_REVIEW');
             $sRedirectUrl = JRoute::_('index.php?option=com_enmasse&controller=deal&task=comment&id=' . $nDealId, false);
         } else {
             if (EnmasseHelper::checkSpammer(JFactory::getUser()->get('id'))) {
                 // If this user is a spammer, lie to him/her that the review is submitted but actually we store nothing
                 $sMessage = JText::_('REVIEW_SUBMITTED_SUCCESSFULLY');
                 $sRedirectUrl = JRoute::_('index.php?option=com_enmasse&controller=deal&task=comment&id=' . $nDealId, false);
             } else {
                 $aComment = array();
                 $aComment['deal_id'] = $nDealId;
                 $aComment['user_id'] = JFactory::getUser()->get('id');
                 $aComment['comment'] = $sReviewBody;
                 $aComment['rating'] = $nRating;
                 $aComment['created_at'] = DatetimeWrapper::getDatetimeOfNow();
                 $aComment['status'] = 0;
                 $oRow = JModel::getInstance('comment', 'enmasseModel')->store($aComment);
                 if ($oRow->success) {
                     $sMessage = JText::_('REVIEW_SUBMITTED_SUCCESSFULLY');
                 } else {
                     $sMessage = JText::_('SAVE_REVIEW_FAILED');
                 }
                 $sRedirectUrl = JRoute::_('index.php?option=com_enmasse&controller=deal&task=comment&id=' . $nDealId, false);
             }
         }
     } else {
         $sMessage = JText::_('SAVE_REVIEW_FAILED');
         $sRedirectUrl = JRoute::_('index.php?option=com_enmasse&view=dealtoday', false);
     }
     $this->setRedirect($sRedirectUrl, $sMessage);
 }
示例#10
0
文件: tax.php 项目: marsa1985/kazabiz
 function store($data)
 {
     $row = $this->getTable();
     if (!$row->bind($data)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     if ($row->id <= 0) {
         $row->created_at = DatetimeWrapper::getDatetimeOfNow();
     }
     $row->updated_at = DatetimeWrapper::getDatetimeOfNow();
     if (!$row->check()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     return true;
 }
示例#11
0
 function generateReport()
 {
     $dealId = JRequest::getVar('dealId');
     if (!empty($dealId)) {
         $deal = JModel::getInstance('deal', 'enmasseModel')->getById($dealId);
         $orderItemList = JModel::getInstance('orderItem', 'enmasseModel')->listByPdtIdAndStatus($dealId, "Delivered");
         for ($count = 0; $count < count($orderItemList); $count++) {
             $orderItemList[$count]->invtyList = JModel::getInstance('invty', 'enmasseModel')->listByOrderItemId($orderItemList[$count]->id);
             $orderItemList[$count]->order = JModel::getInstance('order', 'enmasseModel')->getById($orderItemList[$count]->order_id);
         }
         $count = 1;
         $id = 0;
         //id of the item in itemList array
         for ($i = 0; $i < count($orderItemList); $i++) {
             $orderItem = $orderItemList[$i];
             $buyerDetail = json_decode($orderItem->order->buyer_detail);
             $deliveryDetail = json_decode($orderItem->order->delivery_detail);
             for ($j = 0; $j < count($orderItem->invtyList); $j++) {
                 $invty = $orderItem->invtyList[$j];
                 $itemList[$id]['Serial No.'] = $count++ . "\t";
                 $itemList[$id]['Buyer Name'] = $buyerDetail->name . "\t";
                 $itemList[$id]['Buyer Email'] = $buyerDetail->email . "\t";
                 $itemList[$id]['Delivery Name'] = $deliveryDetail->name . "\t";
                 $itemList[$id]['Delivery Email'] = $deliveryDetail->email . "\t";
                 $itemList[$id]['Order Comment'] = $orderItem->order->description . "\t";
                 $itemList[$id]['Purchase Date'] = DatetimeWrapper::getDisplayDatetime($orderItem->created_at) . "\t";
                 $itemList[$id]['Coupon Serial'] = $invty->name . "\t";
                 $itemList[$id]['Coupon Status'] = JTEXT::_('COUPON_' . strtoupper($invty->status)) . "</br>";
                 $id++;
             }
         }
         $filename = "Report" . date('Ymd') . ".xls";
         enmasseHelper::reportGenerator($itemList);
         header("Content-Disposition: attachment; filename=\"{$filename}\"");
         header("Content-Type: application/vnd.ms-excel");
         exit(0);
     } else {
         $this->setRedirect('http://' . $_SERVER['SERVER_NAME'] . '/administrator/index.php?option=com_enmasse&controller=report', JTEXT::_('REPORT_EMPTY_MSG'));
     }
 }
示例#12
0
 public function save($data)
 {
     $nUser = $data['user_id'];
     $arOrderId = $data['orders'];
     $dtNow = DatetimeWrapper::getDatetimeOfNow();
     $sInsert = "({$nUser} , '{$dtNow}', '{$dtNow}' ," . implode("),({$nUser} , '{$dtNow}', '{$dtNow}' ,", $arOrderId) . ")";
     $db = JFactory::getDbo();
     //Delete the order that already assigned for other deliverer
     $query = "DELETE FROM #__enmasse_order_deliverer WHERE user_id != {$nUser} AND order_id IN (" . implode(',', $arOrderId) . ")";
     $db->setQuery($query);
     $db->query();
     //insert
     $query = "INSERT IGNORE INTO #__enmasse_order_deliverer (user_id, created_at, updated_at, order_id) VALUES " . $sInsert;
     $db->setQuery($query);
     $db->query();
     if ($db->getErrorNum()) {
         $this->setError($db->getErrorMsg());
         return false;
     } else {
         return true;
     }
 }
示例#13
0
    public function createPdf()
    {
        $salesPersonId = JFactory::getSession()->get('salesPersonId');
        //$filter = JRequest::getVar('filter', array('name' => "", 'code' => "", 'merchant_id' => "", 'fromdate' => "", 'todate' => ""));
        //$filter = JRequest::getVar('filter',array(),'post','array');
        $currency_prefix = JModel::getInstance('setting', 'enmasseModel')->getCurrencyPrefix();
        $dealList = JModel::getInstance('deal', 'enmasseModel')->searchBySaleReports($salesPersonId, JRequest::getVar('name'), JRequest::getVar('merchant_id'), JRequest::getVar('fromdate'), JRequest::getVar('todate'), JRequest::getVar('code'));
        if (empty($dealList)) {
            return null;
        }
        $result = '<table style="border:1px dotted #D5D5D5; border-collapse: collapse;"><tr valign="middle"><th style="border:1px dotted #D5D5D5;" align="center" width="50">' . JText::_("No") . '</th><th style="border:1px dotted #D5D5D5;" width="150">' . JText::_("Deal Code") . '</th><th style="border:1px dotted #D5D5D5;" width="150">' . JText::_("Deal Name") . '</th><th style="border:1px dotted #D5D5D5;" width="100">' . JText::_("Merchant") . '</th><th style="border:1px dotted #D5D5D5;" align="center" width="80">' . JText::_("Qty Sold") . '</th><th style="border:1px dotted #D5D5D5;" align="center" width="80">' . JText::_("Unit Price") . '</th><th style="border:1px dotted #D5D5D5;" align="center" width="80">' . JText::_("Total Sales") . '</th></tr>';
        $i = 0;
        foreach ($dealList as $row) {
            $i++;
            $merchant_name = JModel::getInstance('merchant', 'enmasseModel')->retrieveName($row->merchant_id);
            $total_sales = $row->price * $row->cur_sold_qty;
            $result .= '<tr>
				<td style="border:1px dotted #D5D5D5;" align="center">' . $i . '</td>
				<td style="border:1px dotted #D5D5D5;">' . $row->deal_code . '</td>
				<td style="border:1px dotted #D5D5D5;">' . $row->name . '</td>
				<td style="border:1px dotted #D5D5D5;">' . $merchant_name . '</td>
				<td style="border:1px dotted #D5D5D5;" align="center">' . $row->cur_sold_qty . '</td>
				<td style="border:1px dotted #D5D5D5;" align="center">' . $currency_prefix . $row->price . '</td>
				<td style="border:1px dotted #D5D5D5;" align="center">' . $currency_prefix . $total_sales . '</td></tr>';
            $total_amount += $total_sales;
        }
        $result .= '<tr><td style="border:1px dotted #D5D5D5;" colspan="6" style="text-align:right" >Total Amount: </td>
					<td style="border:1px dotted #D5D5D5;" align="center">' . $currency_prefix . $total_amount . '</td></tr></table>';
        //todo
        require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_enmasse' . DS . 'helpers' . DS . 'html2pdf' . DS . 'html2pdf.class.php';
        $html2pdf = new HTML2PDF('P', 'A4', 'en');
        $html2pdf->setDefaultFont('Arial');
        $html2pdf->writeHTML($result);
        $outFileName = 'report-' . DatetimeWrapper::getDateOfNow() . '.pdf';
        $html2pdf->Output($outFileName, 'I');
        die;
    }
示例#14
0
 /**
  * 
  * Create bill with PDF format, return file location.
  * @param integer $nOrderId order id that need to print bill.
  * @param string $dest whether save to the file or echo direct to web browser (for preview).
  * @return string name of created file with absolute path. 
  */
 public static function createPDF($nOrderId, $dest = 'F')
 {
     $oOrder = JModel::getInstance('order', 'enmasseModel')->getById($nOrderId);
     if (empty($oOrder)) {
         return null;
     }
     $buyer = json_decode($oOrder->buyer_detail);
     $arOrderItem = JModel::getInstance('orderItem', 'enmasseModel')->listByOrderId($nOrderId);
     $sOderDetail = '<table border="1"><tr valign="middle"><th align="center" style="width:30px;">' . JText::_("BILL_TEMPLATE_ORDER_DETAIL_NO") . '</th><th style="width:60px;">' . JText::_("BILL_TEMPLATE_ORDER_DETAIL_QUANTITY") . '</th><th style="width:50px;">' . JText::_("BILL_TEMPLATE_ORDER_DETAIL_DEAL_ID") . '</th><th align="center" style="width:320px; ">' . JText::_("BILL_TEMPLATE_ORDER_DETAIL_DEAL_DESC") . '</th><th style="width:50px;">' . JText::_("BILL_TEMPLATE_ORDER_DETAIL_UNIT_PRICE") . '</th><th style="width:50px;">' . JText::_("BILL_TEMPLATE_ORDER_DETAIL_TAX") . '</th><th style="width:80px;">' . JText::_("BILL_TEMPLATE_ORDER_DETAIL_TOTAL") . '</th></tr>';
     $oPayGty = JModel::getInstance('payGty', 'enmasseModel')->getById($oOrder->pay_gty_id);
     if (empty($oPayGty)) {
         $oPayGty = new JObject();
         $oPayGty->name = "";
     }
     $count = 1;
     foreach ($arOrderItem as $oItem) {
         $sOderDetail .= '<tr valign="middle"><td >' . $count++ . '</td><td >' . $oItem->qty . '</td><td >' . $oItem->pdt_id . '</td><td style="width:300px;text-align: left">' . $oItem->description . '</td><td >' . $oItem->unit_price . '</td><td >' . '</td><td >' . $oItem->total_price . '</td></tr>';
     }
     $sOderDetail .= '<tr><td colspan="7" style="text-align:right" >Total Amount: ' . $oOrder->total_buyer_paid . '</td></tr></table>';
     $db = JFactory::getDbo();
     $query = "SELECT *\n\t\t\t\t\t\tFROM #__enmasse_bill_template\n\t\t\t\t\t\tWHERE slug_name = " . $db->quote(self::$BUYER_RECEIPT_TMPL_NAME);
     $db->setQuery($query);
     $oBillTmpl = $db->loadObject();
     $sTmpl = $oBillTmpl->content;
     $arParam = array();
     $arParam['[BUYER_NAME]'] = $buyer->name;
     $arParam['[BUYER_EMAIL]'] = $buyer->email;
     $arParam['[BILL_NUMBER]'] = EnmasseHelper::displayOrderDisplayId($oOrder->id);
     $arParam['[BILL_DATE]'] = DatetimeWrapper::getDatetimeOfNow();
     $arParam['[PAYMENT_METHOD]'] = $oPayGty->name;
     $arParam['[BILL_DETAIL]'] = $sOderDetail;
     $arParam['[BILL_DESCRIPTION]'] = $oOrder->description;
     //ADD style for table
     $sTmpl = '<style>p{margin: 8px 0px }table {border-collapse:collapse;} td, th{text-align: center} th{height: 40px}</style>' . $sTmpl;
     $arSearch = array_keys($arParam);
     $sTmpl = str_replace($arSearch, $arParam, $sTmpl);
     //-----------------------------
     //process for image tag because there have the difference source path between
     //html2pdf and richtext editor(using for edit bill template),image tag
     //was wrong source path and it cause html2pdf error
     $sPattern = '/(<img\\s+src=")(.*)(")/i';
     if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") {
         $sReplace = '$1' . JPATH_SITE . DS . '\\$2$3';
     } else {
         $sReplace = '$1' . JPATH_SITE . DS . '$2$3';
     }
     $sTmpl = preg_replace($sPattern, $sReplace, $sTmpl);
     require_once dirname(__FILE__) . '/html2pdf/html2pdf.class.php';
     try {
         $sOutFileName = "bill_preview.pdf";
         if ($dest == 'F') {
             $sOutFileName = JPATH_ADMINISTRATOR . DS . "components" . DS . "com_enmasse" . DS . "bills" . DS . EnmasseHelper::displayOrderDisplayId($oOrder->id) . ".pdf";
             if (file_exists($sOutFileName)) {
                 unlink($sOutFileName);
             }
         }
         $html2pdf = new HTML2PDF('P', 'A4', 'en');
         $html2pdf->setDefaultFont('Arial');
         $html2pdf->writeHTML($sTmpl);
         $html2pdf->Output($sOutFileName, $dest);
     } catch (HTML2PDF_exception $e) {
         return;
     }
     return $sOutFileName;
 }
        ?>
				<tr>
					<td> <?php 
        echo JHTML::_('grid.id', $count - 1, $invty->id);
        ?>
</td>
					<td><?php 
        echo $buyerDetail->name;
        ?>
</td>
					<td><?php 
        echo $orderItem->order->description;
        ?>
</td>
					<td align="center"><?php 
        echo DatetimeWrapper::getDisplayDatetime($orderItem->created_at);
        ?>
</td>
					<td align="center"><?php 
        echo $invty->name;
        ?>
</td>
					<td align="center">
						<?php 
        if ($invty->status == "Used") {
            echo "<b>";
            echo JTEXT::_('COUPON_' . $invty->status);
            echo "</b>";
        } else {
            echo JTEXT::_('COUPON_' . $invty->status);
        }
示例#16
0
 function storeGtyConfig($id, $attribute_config)
 {
     $obj->id = $id;
     $obj->attribute_config = json_encode($attribute_config);
     $row =& JTable::getInstance('payGty', 'Table');
     if (!$row->bind($obj)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $row->updated_at = DatetimeWrapper::getDatetimeOfNow();
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     return true;
 }
示例#17
0
?>
	
		</div>
	</div>
	<div  class="deal_cont_bottom">
	</div>
</div>

<!--Time Count Down Script--> 
<script language="JavaScript">
	TargetDate = "<?php 
echo date('Y/m/d H:i:s', strtotime($deal->end_at));
?>
";
    CurrentDate = "<?php 
echo date('Y/m/d H:i:s', strtotime(DatetimeWrapper::getDatetimeOfNow()));
?>
";
	CountActive = true;
	CountStepper = -1;
	LeadingZero = true;
	
	function calcage(secs, num1, num2) {
	  s = ((Math.floor(secs/num1))%num2).toString();
	  if (LeadingZero && s.length < 2)
	    s = "0" + s;
	  return  s ;
	}
	
	function CountBack(secs) {
	  if (secs < 0) {
示例#18
0
    function getCouponFreeByPdtID($id)
    {
        $db = JFactory::getDBO();
        $query = 'SELECT *
		          FROM #__enmasse_invty
		          WHERE pdt_id = ' . $id . ' AND status= "Free" AND deallocated_at < ' . strtotime(DatetimeWrapper::getDatetimeOfNow());
        $db->setQuery($query);
        return $db->loadObjectList();
    }
</a></td>
			<td name="min_needed_qty"><?php 
    echo $row->min_needed_qty;
    ?>
</td>
			<td align="center" name="published"><?php 
    if ($row->published) {
        echo "Published";
    } else {
        echo "Not Published";
    }
    ?>
</td>
			<td name="status" align="center" ><?php 
    echo JText::_('DEAL_' . str_replace(' ', '_', $row->status));
    ?>
</td>
			<td name="end_at"><?php 
    echo DatetimeWrapper::getDisplayDatetime($row->end_at);
    ?>
</td>
		</tr>
		<?php 
}
?>
	</table>
	<input type="hidden" name="option" value="com_enmasse" /> 
	<input type="hidden" name="controller" value="salesPerson" /> 
	<input type="hidden" name="task" value="dealShow" />
</form>
</div>
示例#20
0
				</div>
				<div class="subtitle"><?php 
    echo implode(", ", EnmasseHelper::getDealLocationNames($oDeal->id));
    ?>
</div>
				<div class="description">
					<?php 
    echo $oDeal->short_desc;
    ?>
				</div>
				<div class="timer">
					<span><?php 
    echo JText::_('START_AT');
    ?>
 <?php 
    echo DatetimeWrapper::getDisplayDatetime($oDeal->start_at);
    ?>
</span>
				</div>
				<div class="line"></div>
				<input name="" type="button" class="button" value="<?php 
    echo JText::_('DEAL_LIST_VIEW_THIS_DEAL');
    ?>
" onclick="window.location.href='<?php 
    echo JRoute::_($link);
    ?>
'" />
			</div>
		</div>
		<?php 
    foreach ($dealList as $oDeal) {
示例#21
0
 public static function doNotify($orderId)
 {
     $order = JModel::getInstance('order', 'enmasseModel')->getById($orderId);
     JModel::getInstance('order', 'enmasseModel')->updateStatus($order->id, 'Paid');
     $orderItemList = JModel::getInstance('orderItem', 'enmasseModel')->listByOrderId($orderId);
     $totalQty = 0;
     for ($count = 0; $count < count($orderItemList); $count++) {
         $orderItem = $orderItemList[$count];
         // only add total sold when order has status of delivered
         //JModel::getInstance('deal', 'enmasseModel')->addQtySold($orderItem->pdt_id, $orderItem->qty);
         JModel::getInstance('orderItem', 'enmasseModel')->updateStatus($orderItem->id, 'Paid');
         JModel::getInstance('invty', 'enmasseModel')->updateStatusByOrderItemId($orderItem->id, 'Sold');
         if ($count == 0) {
             $dealName = $orderItem->description;
         } elseif ($count == count($orderItemList) - 1) {
             $dealName .= " & " . $orderItem->description;
         } else {
             $dealName .= " , " . $orderItem->description;
         }
         $totalQty += $orderItem->qty;
     }
     //---------------------------
     //Create the receipt with pdf format
     //just create bill if the order is not free and buyer have full paid
     //remember full paid = order->status = "paid" and order->paid_amount == 0.0
     if ($order->total_buyer_paid > 0 && $order->paid_amount == 0.0) {
         $sBillName = BillHelper::createPDF($orderId);
     } else {
         $sBillName = "";
     }
     //--------------------------
     // Sending email
     $payment = json_decode($order->pay_detail);
     $buyer = json_decode($order->buyer_detail);
     $delivery = json_decode($order->delivery_detail);
     $params = array();
     $params['$buyerName'] = $buyer->name;
     $params['$buyerEmail'] = $buyer->email;
     $buyerEmail = $buyer->email;
     $params['$deliveryName'] = $delivery->name;
     $params['$deliveryEmail'] = $delivery->email;
     $params['$orderId'] = self::displayOrderDisplayId($order->id);
     $params['$dealName'] = $dealName;
     $params['$totalPrice'] = self::displayCurrency($order->paid_amount);
     $params['$totalQty'] = $totalQty;
     $params['$createdAt'] = DatetimeWrapper::getDisplayDatetime($order->created_at);
     if (self::getSetting()->sending_bill_auto == 1) {
         self::sendMailByTemplate($buyerEmail, 'receipt', $params, $sBillName);
         //send mail with bill attachment
     } else {
         self::sendMailByTemplate($buyerEmail, 'receipt', $params);
         //send mail with no attachment
     }
     foreach ($orderItemList as $orderItem) {
         $deal = JModel::getInstance('deal', 'enmasseModel')->getById($orderItem->pdt_id);
         if ($deal->status == "Confirmed" && $deal->prepay_percent == 100.0) {
             self::orderItemDelivered($orderItem);
         }
         //--- auto confirm deal
         if ($deal->auto_confirm && $deal->status != "Confirmed" && $deal->min_needed_qty <= $deal->cur_sold_qty) {
             //------------------------
             //generate integration class
             $isPointSystemEnabled = EnmasseHelper::isPointSystemEnabled();
             if ($isPointSystemEnabled == true) {
                 $integrationClass = EnmasseHelper::getPointSystemClassFromSetting();
                 $integrateFileName = $integrationClass . '.class.php';
                 require_once JPATH_SITE . DS . "components" . DS . "com_enmasse" . DS . "helpers" . DS . "pointsystem" . DS . $integrationClass . DS . $integrateFileName;
             }
             //--- update deal status to "Confirmed"
             JModel::getInstance('deal', 'enmasseModel')->updateStatus($deal->id, 'Confirmed');
             //--- delivery coupon by email if the deal is not partial payment
             if ($deal->prepay_percent == 100.0) {
                 $arOrderItemDelivery = JModel::getInstance('orderItem', 'enmasseModel')->listByPdtIdAndStatus($deal->id, "Paid");
                 foreach ($arOrderItemDelivery as $oOrderItem) {
                     EnmasseHelper::orderItemDelivered($oOrderItem);
                     //------------------------
                     //generate integration class
                     if ($isPointSystemEnabled == true) {
                         $buyerId = EnmasseHelper::getUserIdByOrderId($oOrderItem->order_id);
                         $referralId = EnmasseHelper::getReferralIdByOrderId($oOrderItem->order_id);
                         $integrationObject = new $integrationClass();
                         $integrationObject->integration($buyerId, 'confirmdeal');
                         if (!empty($referralId)) {
                             $integrationObject->integration($referralId, 'referralbonus');
                         }
                     }
                     sleep(1);
                 }
             }
             //--- Refund point to who paid with point but without paying by cash
             if ($isPointSystemEnabled == true) {
                 $buyerList = EnmasseHelper::getBuyerRefundConfirmDeal($deal->id);
                 $integrationObject = new $integrationClass();
                 foreach ($buyerList as $buyer) {
                     $integrationObject->integration($buyer['buyer_id'], 'refunddeal', $buyer['point_used_to_pay']);
                 }
             }
         }
     }
 }
示例#22
0
// Require specific controller if requested
if ($controller = JRequest::getWord('controller')) {
    $path = JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php';
    if (file_exists($path)) {
        require_once $path;
    } else {
        $controller = '';
    }
}
// Create the controller
$classname = 'EnmasseController' . ucFirst($controller);
$controller = new $classname();
//load language pack
$language = JFactory::getLanguage();
$base_dir = JPATH_SITE . DS . 'components' . DS . 'com_enmasse';
$version = new JVersion();
$joomla = $version->getShortVersion();
if (substr($joomla, 0, 3) >= 1.6) {
    $extension = 'com_enmasse16';
} else {
    $extension = 'com_enmasse';
}
if ($language->load($extension, $base_dir, $language->getTag(), true) == false) {
    $language->load($extension, $base_dir, 'en-GB', true);
}
// Set default time zone for fix PHP notification
DatetimeWrapper::setTimezone(DatetimeWrapper::getTimezone());
// Perform the Request task
$controller->execute(JRequest::getWord('task'));
// Redirect if set by the controller
$controller->redirect();
示例#23
0
 /**
  * 
  * Store merchant data into the DB 
  * @param array $data
  * @return boolean true on success
  */
 public function store($data)
 {
     $oRow = JTable::getInstance('merchant', 'Table');
     if (!$oRow->bind($data)) {
         $this->setError($oRow->getError());
         return false;
     }
     if (empty($oRow->id)) {
         $oRow->created_at = DatetimeWrapper::getDatetimeOfNow();
     }
     $oRow->updated_at = DatetimeWrapper::getDatetimeOfNow();
     if (!$oRow->check()) {
         $this->setError($oRow->getError());
         return false;
     }
     if (!$oRow->store()) {
         $this->setError($oRow->getError());
         return false;
     }
     //set group for the merchant person
     $jUserId = EnmasseHelper::getUserByName($data['user_name'])->id;
     $nGroup = JModel::getInstance('setting', 'EnmasseModel')->getSetting(1)->merchant_group;
     $user = new JUser($jUserId);
     $user->groups = array_merge($user->groups, array($nGroup));
     $user->save();
     return true;
 }
示例#24
0
 function generateCouponFreeStatus($pdtId, $couponName, $status)
 {
     $db = JFactory::getDBO();
     $created_at = DatetimeWrapper::getDatetimeOfNow();
     $query = "INSERT INTO #__enmasse_invty (name, pdt_id, status,created_at) VALUES ('" . $couponName . "','" . $pdtId . "','" . $status . "','" . $created_at . "')";
     $db->setQuery($query);
     $db->query();
     if ($this->_db->getErrorNum()) {
         JError::raiseError(500, $this->_db->stderr());
         return false;
     }
     return true;
 }
示例#25
0
 function save()
 {
     $data = JRequest::get('post');
     $checkchracter = EnmasseHelper::checkSpecialCharacter($data['name']);
     if ($checkchracter) {
         $msg = JText::_('SAVE_DEAL_NOTICE');
         if ($data['id'] == null) {
             $this->setRedirect('index.php?option=com_enmasse&controller=' . JRequest::getVar('controller') . '&task=add', $msg, 'notice');
             return false;
         } else {
             $this->setRedirect('index.php?option=com_enmasse&controller=' . JRequest::getVar('controller') . '&task=edit&cid[0]=' . $data['id'], $msg, 'notice');
             return false;
         }
     }
     $data['slug_name'] = EnmasseHelper::seoUrl($data['name']);
     $data['description'] = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $data['highlight'] = JRequest::getVar('highlight', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $data['terms'] = JRequest::getVar('terms', '', 'post', 'string', JREQUEST_ALLOWRAW);
     if ($data['slug_name'] == '_' || $data['slug_name'] == '') {
         $now = str_replace(":", " ", DatetimeWrapper::getDatetimeOfNow());
         $data['slug_name'] = EnmasseHelper::seoUrl($now);
     }
     $model = JModel::getInstance('deal', 'enmasseModel');
     //---------------------------------------------------------------
     // if edit deal
     if ($data['id'] > 0) {
         //---get deal data
         $deal = JModel::getInstance('deal', 'enmasseModel')->getById($data['id']);
         // get sold coupon qty for deal
         $soldCouponList = JModel::getInstance('invty', 'enmasseModel')->getSoldCouponByPdtId($deal->id);
         //if from unlimited to limited
         if ($deal->max_coupon_qty < 0) {
             if ($data['max_coupon_qty'] > 0) {
                 if ($data['max_coupon_qty'] <= count($soldCouponList)) {
                     $msg = JText::_('MSG_CURRENT_SOLD_GRATER_THAN_MODIFIED_COUPON');
                     JFactory::getApplication()->redirect('index.php?option=com_enmasse&controller=deal&task=edit&cid=' . $data['id'], $msg);
                 } else {
                     $numOfAddCoupon = $data['max_coupon_qty'] - count($soldCouponList);
                 }
             }
         } else {
             //---------------- if change from limited to unlimited
             if ($data['max_coupon_qty'] < 0) {
                 $unlimit = true;
             } else {
                 if ($data['max_coupon_qty'] < $deal->max_coupon_qty) {
                     //---------------------- if new coupon qty <= the sold coupon qty
                     if ($data['max_coupon_qty'] <= count($soldCouponList)) {
                         $msg = JText::_('MSG_CURRENT_SOLD_GRATER_THAN_MODIFIED_COUPON');
                         JFactory::getApplication()->redirect('index.php?option=com_enmasse&controller=deal&task=edit&cid=' . $data['id'], $msg);
                     } else {
                         $numOfRemoveCoupon = $deal->max_coupon_qty - $data['max_coupon_qty'];
                     }
                 } else {
                     if ($data['max_coupon_qty'] > $deal->max_coupon_qty) {
                         $numOfAddCoupon = $data['max_coupon_qty'] - $deal->max_coupon_qty;
                     }
                 }
             }
         }
         // suong.mai edit save description to oder_item
         $db =& JFactory::getDBO();
         $query = "UPDATE #__enmasse_order_item\n\t\t\t\t\t  SET description ='" . $data['name'] . "'" . "WHERE pdt_id=" . $data['id'];
         $db->setQuery($query);
         $db->query();
         //$db->updateObject($this->, $object, $key)
     }
     //------------------------
     //gemerate integration class
     $integrateFileName = EnmasseHelper::getSubscriptionClassFromSetting() . '.class.php';
     $integrationClass = EnmasseHelper::getSubscriptionClassFromSetting();
     require_once JPATH_SITE . DS . "components" . DS . "com_enmasse" . DS . "helpers" . DS . "subscription" . DS . $integrationClass . DS . $integrateFileName;
     $integrationObject = new $integrationClass();
     // store data
     $row = $model->store($data);
     if ($row->success) {
         if ($data['id'] == 0) {
             $integrationObject->integration($row, 'newDeal');
         }
         //--------------------------------------
         // store location and category
         JModel::getInstance('dealCategory', 'enmasseModel')->store($row->id, $data['pdt_cat_id']);
         JModel::getInstance('dealLocation', 'enmasseModel')->store($row->id, $data['location_id']);
         // if is new deal and limited the coupdon then create coupon in invty
         if ($data['id'] == 0 && $row->max_coupon_qty > 0) {
             for ($i = 0; $i < $row->max_coupon_qty; $i++) {
                 $name = $i + 1;
                 JModel::getInstance('invty', 'enmasseModel')->generateCouponFreeStatus($row->id, $name, 'Free');
             }
         } else {
             if ($data['id'] != 0) {
                 if (!empty($numOfRemoveCoupon)) {
                     $freeCouponList = JModel::getInstance('invty', 'enmasseModel')->getCouponFreeByPdtID($data['id']);
                     // removed the coupons from invty
                     for ($i = 0; $i < $numOfRemoveCoupon; $i++) {
                         JModel::getInstance('invty', 'enmasseModel')->removeById($freeCouponList[$i]->id);
                     }
                 } else {
                     if (!empty($numOfAddCoupon)) {
                         // add more coupon to invty
                         for ($i = 0; $i < $numOfAddCoupon; $i++) {
                             $name = $i + 1;
                             JModel::getInstance('invty', 'enmasseModel')->generateCouponFreeStatus($data['id'], $name, 'Free');
                         }
                     } else {
                         if ($unlimit) {
                             //remove all free coupon
                             JModel::getInstance('invty', 'enmasseModel')->removeCouponByPdtIdAndStatus($data['id'], 'Free');
                         }
                     }
                 }
             }
         }
         $msg = JText::_('SAVE_SUCCESS_MSG');
         $this->setRedirect('index.php?option=com_enmasse&controller=' . JRequest::getVar('controller'), $msg, $type);
     } else {
         $msg = JText::_('SAVE_ERROR_MSG') . ": " . $model->getError();
         if ($data['id'] == null) {
             $this->setRedirect('index.php?option=com_enmasse&controller=' . JRequest::getVar('controller') . '&task=add', $msg, 'error');
         } else {
             $this->setRedirect('index.php?option=com_enmasse&controller=' . JRequest::getVar('controller') . '&task=edit&cid[0]=' . $data['id'], $msg, 'error');
         }
     }
 }
示例#26
0
 function submitCheckOut()
 {
     $activeGuestBuying = EnmasseHelper::isGuestBuyingEnable();
     $bBuy4friend = JRequest::getVar('buy4friend', 0);
     $sEmailPt = "/^([0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})\$/";
     //save user input data into the session
     if (JRequest::getMethod() == "POST") {
         $arData = JRequest::get('post');
         JFactory::getApplication()->setUserState("com_enmasse.checkout.data", $arData);
     }
     //check the permission for checkout action
     if (JFactory::getUser()->get('guest') && !$activeGuestBuying) {
         $msg = JText::_("MERCHANT_PLEASE_LOGIN_BEFORE");
         $redirectUrl = base64_encode("index.php?option=com_enmasse&controller=shopping&task=checkout&buy4friend={$bBuy4friend}");
         $link = JRoute::_("index.php?option=com_users&view=login&return=" . $redirectUrl, false);
         JFactory::getApplication()->redirect($link, $msg, 'error');
     }
     //validate the cart
     $cart = unserialize(JFactory::getSession()->get('cart'));
     CartHelper::checkCart($cart);
     foreach ($cart->getAll() as $cartItem) {
         $item = $cartItem->getItem();
     }
     //get enmasse setting
     $setting = JModel::getInstance('setting', 'enmasseModel')->getSetting();
     // check max cart Item
     $this->checkMaxCartItem($cart);
     //validate Buyer information
     $buyerName = JRequest::getVar('name');
     $buyerEmail = JRequest::getVar('email');
     if (empty($buyerName) || empty($buyerEmail)) {
         $msg = JText::_("SHOP_CARD_CHECKOUT_BUYER_INFORMATION_REQUIRED_MSG");
         $link = JRoute::_("index.php?option=com_enmasse&controller=shopping&task=checkout&buy4friend={$bBuy4friend}", false);
         JFactory::getApplication()->redirect($link, $msg, 'error');
     } elseif (!preg_match($sEmailPt, $buyerEmail)) {
         $msg = JText::_("SHOP_CARD_CHECKOUT_BUYER_EMAIL_INVALID_MSG");
         $link = JRoute::_("index.php?option=com_enmasse&controller=shopping&task=checkout&buy4friend={$bBuy4friend}", false);
         JFactory::getApplication()->redirect($link, $msg, 'error');
     }
     //----- If the deal permit partial payment, it mean the coupon was delivery by directly, so we need to validate address and phone number of receiver
     if ($item->prepay_percent < 100) {
         $receiverAddress = JRequest::getVar('receiver_address');
         $receiverPhone = JRequest::getVar('receiver_phone');
         if (empty($receiverPhone) || empty($receiverAddress)) {
             $msg = JText::_("SHOP_CARD_CHECKOUT_RECEIVER_INFORMATION_REQUIRED_MSG");
             $link = JRoute::_("index.php?option=com_enmasse&controller=shopping&task=checkout&buy4friend={$bBuy4friend}", false);
             JFactory::getApplication()->redirect($link, $msg, 'error');
         } else {
             if (!preg_match('/^[0-9 \\.,\\-\\(\\)\\+]*$/', $receiverPhone)) {
                 $msg = JText::_("SHOP_CARD_CHECKOUT_RECEIVER_PHONE_INVALID");
                 $link = JRoute::_("index.php?option=com_enmasse&controller=shopping&task=checkout&buy4friend={$bBuy4friend}", false);
                 JFactory::getApplication()->redirect($link, $msg, 'error');
             }
         }
     }
     if ($bBuy4friend) {
         $receiverName = JRequest::getVar('receiver_name');
         $receiverEmail = JRequest::getVar('receiver_email');
         $receiverMsg = JRequest::getVar('receiver_msg');
         if (empty($receiverName) || empty($receiverEmail)) {
             $msg = JText::_("SHOP_CARD_CHECKOUT_RECEIVER_INFORMATION_REQUIRED_MSG");
             $link = JRoute::_("index.php?option=com_enmasse&controller=shopping&task=checkout&buy4friend={$bBuy4friend}", false);
             JFactory::getApplication()->redirect($link, $msg, 'error');
         } elseif (!preg_match($sEmailPt, $receiverEmail)) {
             $msg = JText::_("SHOP_CARD_CHECKOUT_RECEIVER_EMAIL_INVALID_MSG");
             $link = JRoute::_("index.php?option=com_enmasse&controller=shopping&task=checkout&buy4friend={$bBuy4friend}", false);
             JFactory::getApplication()->redirect($link, $msg, 'error');
         }
     }
     //------------------------------------------------------
     // to check it this deal is free for customer
     if ($cart->getTotalPrice() > 0) {
         //deal is not free
         $payGtyId = JRequest::getVar('payGtyId');
         if ($payGtyId == null) {
             $msg = JText::_("SELECT_PAYMENT_MSG");
             $link = JRoute::_("index.php?option=com_enmasse&controller=shopping&task=checkout&buy4friend={$bBuy4friend}", false);
             JFactory::getApplication()->redirect($link, $msg, 'error');
         }
         if ($setting->article_id != 0 && JRequest::getVar('terms') == false) {
             $msg = JText::_("AGREE_TERM_CONDITION_MSG");
             $link = JRoute::_("index.php?option=com_enmasse&controller=shopping&task=checkout&buy4friend={$bBuy4friend}", false);
             JFactory::getApplication()->redirect($link, $msg, 'error');
         }
         $payGty = JModel::getInstance('payGty', 'enmasseModel')->getById($payGtyId);
         // checking gateway configuration
         if (CartHelper::checkGty($payGty) == false) {
             $msg = JText::_("PAYMENT_INCOMPLETE_MSG");
             $link = JRoute::_("index.php?option=com_enmasse&controller=shopping&task=checkout&buy4friend={$bBuy4friend}", false);
             JFactory::getApplication()->redirect($link, $msg);
         }
         // save gty info into session
         JFactory::getSession()->set('payGty', serialize($payGty));
         JFactory::getSession()->set('attribute_config', json_encode($payGty->attribute_config));
         //--------If admin set the prepay_percent of the deal to 0.00, set the order status to 'Paid' (with paid_amount is 0.00)
         if ($item->prepay_percent == 0.0) {
             $status = EnmasseHelper::$ORDER_STATUS_LIST['Paid'];
             $couponStatus = EnmasseHelper::$INVTY_STATUS_LIST['Hold'];
         } else {
             //------------------------------------
             // generate name of payment gateway file and class
             $payGtyFile = 'PayGty' . ucfirst($payGty->class_name) . '.class.php';
             $className = 'PayGty' . ucfirst($payGty->class_name);
             //---------------------------------------------------
             // get payment gateway object
             require_once JPATH_SITE . DS . "components" . DS . "com_enmasse" . DS . "helpers" . DS . "payGty" . DS . $payGty->class_name . DS . $payGtyFile;
             $paymentClassObj = new $className();
             $paymentReturnStatusObj = $paymentClassObj->returnStatus();
             $status = $paymentReturnStatusObj->order;
             $couponStatus = $paymentReturnStatusObj->coupon;
         }
     } else {
         //deal is free
         $payGty = "Free";
         $status = 'Unpaid';
         $couponStatus = 'Pending';
         //save the payGty as free
         JFactory::getSession()->set('payGty', 'Free');
     }
     //----------------------------------------
     //determine information of coupon receiver
     if ($bBuy4friend) {
         $deliveryDetail = array('name' => $receiverName, 'email' => $receiverEmail, 'msg' => $receiverMsg, 'address' => $receiverAddress, 'phone' => $receiverPhone);
     } else {
         $deliveryDetail = array('name' => $buyerName, 'email' => $buyerEmail, 'msg' => '', 'address' => $receiverAddress, 'phone' => $receiverPhone);
     }
     //--------------------------
     //generate order
     $dvrGty = $item->prepay_percent < 100 ? 2 : 1;
     $deliveryGty = JModel::getInstance('deliveryGty', 'enmasseModel')->getById($dvrGty);
     $user = array();
     $user['id'] = JFactory::getUser()->get('id', 0);
     $user['name'] = $buyerName;
     $user['email'] = $buyerEmail;
     $order = CartHelper::saveOrder($cart, $user, $payGty, null, $deliveryGty, $deliveryDetail, $status);
     $session =& JFactory::getSession();
     $session->set('newOrderId', $order->id);
     $orderItemList = CartHelper::saveOrderItem($cart, $order, $status);
     //-----------------------------
     // if this deal is set limited the coupon to sold out, go to invty and allocate coupons for this order
     // if not create coupons for that order
     if ($item->max_coupon_qty > 0) {
         $now = DatetimeWrapper::getDatetimeOfNow();
         $nunOfSecondtoAdd = EnmasseHelper::getMinuteReleaseInvtyFromSetting($payGty) * 60;
         $intvy = CartHelper::allocatedInvty($orderItemList, DatetimeWrapper::mkFutureDatetimeSecFromNow($now, $nunOfSecondtoAdd), $couponStatus);
     } else {
         JModel::getInstance('invty', 'enmasseModel')->generateForOrderItem($orderItemList[0]->pdt_id, $orderItemList[0]->id, $orderItemList[0]->qty, $couponStatus);
     }
     //------------------------
     //generate integration class
     $isPointSystemEnabled = EnmasseHelper::isPointSystemEnabled();
     if ($isPointSystemEnabled) {
         $integrationClass = EnmasseHelper::getPointSystemClassFromSetting();
         $integrateFileName = $integrationClass . '.class.php';
         require_once JPATH_SITE . DS . "components" . DS . "com_enmasse" . DS . "helpers" . DS . "pointsystem" . DS . $integrationClass . DS . $integrateFileName;
         $user = JFactory::getUser();
         $user_id = $user->get('id');
         $point = $cart->getPoint();
         if ($point > 0) {
             $integrationObject = new $integrationClass();
             $integrationObject->integration($user_id, 'paybypoint', $point);
         }
     }
     //validating is ok, flush user data
     JFactory::getApplication()->setUserState("com_enmasse.checkout.data", null);
     // --------------------------------
     // if deal is free then directly do the notify
     if ($cart->getTotalPrice() > 0) {
         //deal is not free, check if buyer must prepay a specific amount
         if ($item->prepay_percent > 0) {
             $link = JRoute::_("index.php?option=com_enmasse&controller=payment&task=gateway&orderId=" . $order->id, false);
         } else {
             //do notify for the order that not to prepay
             EnmasseHelper::doNotify($order->id);
             $link = JRoute::_("index.php?option=com_enmasse&controller=deal&task=listing");
             $msg = JText::_("PARTIAL_PAYMENT_NO_PREPAY_CHECKOUT_MSG");
             JFactory::getApplication()->redirect($link, $msg);
         }
     } else {
         //deal is free
         $link = JRoute::_("index.php?option=com_enmasse&controller=payment&task=doNotify&orderId={$order->id}", false);
     }
     JFactory::getApplication()->redirect($link);
 }
				<td align="right" class="key"><?php 
    echo JTEXT::_('CREATED_AT');
    ?>
:</td>
				<td><?php 
    echo DatetimeWrapper::getDisplayDatetime($row->created_at);
    ?>
</td>
			</tr>
			<tr>
				<td align="right" class="key"><?php 
    echo JTEXT::_('UPDATED_AT');
    ?>
:</td>
				<td><?php 
    echo DatetimeWrapper::getDisplayDatetime($row->updated_at);
    ?>
</td>
			</tr>
		<?php 
}
?>
	</table>
	</fieldset>
	</div>

	<input type="hidden" name="position" value="<?php 
echo $row->position;
?>
" />
	<input type="hidden" name="id" value="<?php 
示例#28
0
 function store($data)
 {
     $row = $this->getTable();
     $data['name'] = trim($data['name']);
     if (!$row->bind($data)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     if ($row->id <= 0) {
         $row->created_at = DatetimeWrapper::getDatetimeOfNow();
     }
     $row->updated_at = DatetimeWrapper::getDatetimeOfNow();
     if (!$row->check()) {
         $this->setError($row->getError(0));
         return false;
     }
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     //set group for the merchant person
     $jUserId = EnmasseHelper::getUserByName($data['user_name'])->id;
     $nGroup = JModel::getInstance('setting', 'EnmasseModel')->getSetting(1)->merchant_group;
     $user = new JUser($jUserId);
     $user->groups = array_merge($user->groups, array($nGroup));
     $user->save();
     return true;
 }
示例#29
0
 function getDealByMerchantId($merchantId)
 {
     $db = JFactory::getDBO();
     $query = "\tSELECT \n\t\t\t\t\t\t* \n\t\t\t\t\tFROM \n\t\t\t\t\t\t#__enmasse_deal \n\t\t            where merchant_id = {$merchantId}\n\t\t            AND status != 'Voided' AND end_at <= '" . DatetimeWrapper::getDatetimeOfNow() . "'";
     $db->setQuery($query);
     $deals = $db->loadObjectList('id');
     if ($this->_db->getErrorNum()) {
         JError::raiseError(500, $this->_db->stderr());
         return false;
     }
     return $deals;
 }
示例#30
-1
    public static function pdf()
    {
        $filter = JRequest::getVar('filter', array('name' => "", 'code' => "", 'merchant_id' => "", 'fromdate' => "", 'todate' => ""));
        $dealList = JModel::getInstance('salereports', 'enmasseModel')->search($filter['code'], $filter['name'], $filter['saleperson_id'], $filter['merchant_id'], $filter['fromdate'], $filter['todate']);
        $currency = JModel::getInstance('setting', 'enmasseModel')->getCurrencyPrefix();
        if (empty($dealList)) {
            $msg = JText::_("NO_SALE_REPORT");
            JFactory::getApplication()->redirect("index.php?option=com_enmasse&controller=saleReports", $msg, 'notice');
            return false;
        }
        $result = '<table style="border:1px dotted #D5D5D5; border-collapse: collapse;"><tr valign="middle"><th style="border:1px dotted #D5D5D5;" align="center" width="30">' . JText::_("No") . '</th><th style="border:1px dotted #D5D5D5;" align="center" width="80">' . JText::_("Deal Code") . '</th><th style="border:1px dotted #D5D5D5;" align="center" width="80">' . JText::_("Deal Name") . '</th><th style="border:1px dotted #D5D5D5;" align="center" width="60">' . JText::_("Merchant") . '</th><th style="border:1px dotted #D5D5D5;" align="center" width="60">' . JText::_("Qty Sold") . '</th><th style="border:1px dotted #D5D5D5;" align="center" width="80">' . JText::_("Unit Price") . '</th><th style="border:1px dotted #D5D5D5;" align="center" width="80">' . JText::_("Total Sales") . '</th><th style="border:1px dotted #D5D5D5;" align="center" width="80">' . JText::_("Commission Percentage") . '</th><th style="border:1px dotted #D5D5D5;" align="left" width="150">' . JText::_("Total Commission Amount") . '</th></tr>';
        $i = 0;
        $total_commission_amount = 0;
        foreach ($dealList as $row) {
            $i++;
            $merchant_name = JModel::getInstance('merchant', 'enmasseModel')->retrieveName($row->merchant_id);
            $total_sales = $row->price * $row->cur_sold_qty;
            $total_amount = $total_sales * $row->commission_percent / 100;
            $result .= '<tr>
				<td style="border:1px dotted #D5D5D5;" align="center">' . $i . '</td>
				<td style="border:1px dotted #D5D5D5;">' . $row->deal_code . '</td>
				<td style="border:1px dotted #D5D5D5;">' . $row->name . '</td>
				<td style="border:1px dotted #D5D5D5;">' . $merchant_name . '</td>
				<td style="border:1px dotted #D5D5D5;" align="center">' . $row->cur_sold_qty . '</td>
				<td style="border:1px dotted #D5D5D5;" align="center">' . $currency . $row->price . '</td>
				<td style="border:1px dotted #D5D5D5;" align="center">' . $currency . $total_sales . '</td>
				<td style="border:1px dotted #D5D5D5;" align="center">' . $row->commission_percent . ' % </td>
				<td style="border:1px dotted #D5D5D5;" align="center">' . $currency . $total_amount . '</td></tr>';
            $total_commission_amount += $total_amount;
        }
        $result .= '<tr><td style="border-right:1px dotted #D5D5D5; text-align:right" colspan="8"   >Total: </td>
					<td style="border:1px dotted #D5D5D5;" align="center" align="center">' . $currency . $total_commission_amount . '</td></tr></table>';
        //todo
        require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_enmasse' . DS . 'helpers' . DS . 'html2pdf' . DS . 'html2pdf.class.php';
        $html2pdf = new HTML2PDF('P', 'A4', 'en');
        $html2pdf->setDefaultFont('Arial');
        $html2pdf->writeHTML($result);
        $outFileName = 'report-' . DatetimeWrapper::getDateOfNow() . '.pdf';
        $html2pdf->Output($outFileName, 'I');
        header("Content-type:application/pdf");
        // It will be called downloaded.pdf
        header("Content-Disposition:attachment;filename=downloaded.pdf");
        die;
    }