示例#1
0
$fileLimitConf = $config->projectMaxfileCount;
$reviewProjects = $config->reviewProjects;
$sealProjectBids = $config->sealProjectBids;
$seoOptimize = $config->seoProjectOptimize;
$projectUpgrades = $config->projectUpgrades;
$isNew = $this->row->id == 0 ? 1 : 0;
$title = $isNew ? JText::_('COM_JBLANCE_POST_NEW_PROJECT') : JText::_('COM_JBLANCE_EDIT_PROJECT');
//get the project upgrade amounts based on the plan
$plan = JblanceHelper::whichPlan($user->id);
$featuredProjectFee = $plan->buyFeePerFeaturedProject;
$urgentProjectFee = $plan->buyFeePerUrgentProject;
$privateProjectFee = $plan->buyFeePerPrivateProject;
$sealedProjectFee = $plan->buyFeePerSealedProject;
$ndaProjectFee = $plan->buyFeePerNDAProject;
$chargePerProject = $plan->buyChargePerProject;
$totalFund = JblanceHelper::getTotalFund($user->id);
JText::script('COM_JBLANCE_CLOSE');
$ndaFile = JURI::root() . 'components/com_jblance/images/nda.txt';
JblanceHelper::setJoomBriToken();
?>
<script type="text/javascript">
<!--
    function validateForm(f) {
        var valid = document.formvalidator.isValid(f);

        //check for validity of hours per day
        var checkedval = jQuery("input[name='project_type']:checked").val();
        if (checkedval == "COM_JBLANCE_HOURLY") {
            var cmt_prd = jQuery("#commitment_period").val();
            var cmt_int = jQuery("#commitment_interval").val();
            if (cmt_int == "COM_JBLANCE_DAY" && cmt_prd > 24) {
示例#2
0
 function getEditService()
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDbo();
     $id = $app->input->get('id', 0, 'int');
     $user = JFactory::getUser();
     $isNew = $id > 0 ? false : true;
     //check if the owner is editing the service
     $isOwnedOperation = JblanceHelper::checkOwnershipOfOperation($id, 'service');
     if ($id > 0 && !$isOwnedOperation) {
         $msg = JText::sprintf('COM_JBLANCE_NOT_AUTHORIZED_TO_ACCESS_THIS_PAGE');
         $app->enqueueMessage($msg, 'error');
         $link = JRoute::_('index.php?option=com_jblance&view=user&layout=dashboard', false);
         $app->redirect($link);
         return false;
     }
     //check if the user's plan is expired or not approved. If so, do not allow him to create service
     $planStatus = JblanceHelper::planStatus($user->id);
     if ($isNew && ($planStatus == 1 || $planStatus == 2)) {
         $msg = JText::sprintf('COM_JBLANCE_NOT_ALLOWED_TO_DO_OPERATION_NO_ACTIVE_SUBSCRIPTION');
         $app->enqueueMessage($msg, 'error');
         $link = JRoute::_('index.php?option=com_jblance&view=user&layout=dashboard', false);
         $app->redirect($link);
         return false;
     }
     //check if the user has enough fund to create new services. This should be checked for new services only
     $plan = JblanceHelper::whichPlan($user->id);
     $chargePerService = $plan->flChargePerService;
     if ($isNew && $chargePerService > 0) {
         $totalFund = JblanceHelper::getTotalFund($user->id);
         if ($totalFund < $chargePerService) {
             $msg = JText::sprintf('COM_JBLANCE_BALANCE_INSUFFICIENT_TO_POST_SERVICE', JblanceHelper::formatCurrency($chargePerService));
             $app->enqueueMessage($msg, 'error');
             $link = JRoute::_('index.php?option=com_jblance&view=membership&layout=depositfund', false);
             $app->redirect($link);
             return false;
         }
     }
     $row = JTable::getInstance('service', 'Table');
     $row->load($id);
     //show reason if service is not approved.
     if (!$isNew && !$row->approved) {
         $msg = empty($row->disapprove_reason) ? JText::_('COM_JBLANCE_SERVICE_PENDING_APPROVAL_FROM_ADMIN') : $row->disapprove_reason;
         $app->enqueueMessage(nl2br($msg), 'Error');
     }
     $return[0] = $row;
     return $return;
 }
示例#3
0
 function placeOrder()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     $post = $app->input->post->getArray();
     $row = JTable::getInstance('serviceorder', 'Table');
     $now = JFactory::getDate();
     $user = JFactory::getUser();
     $service_id = $app->input->get('service_id', 0, 'int');
     // id of service
     $svcHelper = JblanceHelper::get('helper.service');
     // create an instance of the class ServiceHelper
     $service = JTable::getInstance('service', 'Table');
     $userType = JblanceHelper::getUserType($user->id);
     //get the current user type
     $escrow = JTable::getInstance('escrow', 'Table');
     $service->load($service_id);
     $isMine = $service->user_id == $user->id;
     // check if the user is guest
     if ($user->guest) {
         //return to same page after login
         $returnUrl = JRoute::_('index.php?option=com_jblance&view=service&layout=viewservice&id=' . $service_id, false);
         $msg = JText::_('COM_JBLANCE_MUST_BE_LOGGED_IN_TO_ACCESS_THIS_PAGE');
         $link_login = JRoute::_('index.php?option=com_users&view=login&return=' . base64_encode($returnUrl), false);
         $this->setRedirect($link_login, $msg, 'warning');
     }
     // check if the user doesn't have JoomBri Profile - or he is just a Joomla user
     if ($userType->joomlauser) {
         $msg = JText::_('COM_JBLANCE_NOT_AUTHORIZED_TO_ACCESS_THIS_PAGE_CHOOSE_YOUR_ROLE');
         $link = JRoute::_('index.php?option=com_jblance&view=guest&layout=showfront', false);
         $this->setRedirect($link, $msg, 'error');
         return false;
     }
     // check if the user is a freelancer or service owner
     if ($isMine || !$userType->buyer) {
         $msg = JText::_('COM_JBLANCE_NOT_ALLOWED_TO_ORDER_SERVICE');
         $link = JRoute::_('index.php?option=com_jblance&view=service&layout=viewservice&id=' . $service_id, false);
         $this->setRedirect($link, $msg, 'error');
         return false;
     }
     //check if the user's plan is expired or not approved. If so, do not allow him to order service
     $planStatus = JblanceHelper::planStatus($user->id);
     if ($planStatus == 1 || $planStatus == 2) {
         $msg = JText::sprintf('COM_JBLANCE_NOT_ALLOWED_TO_DO_OPERATION_NO_ACTIVE_SUBSCRIPTION');
         $link = JRoute::_('index.php?option=com_jblance&view=user&layout=dashboard', false);
         $this->setRedirect($link, $msg, 'error');
         return false;
     }
     $post['user_id'] = $user->id;
     $post['status'] = 'COM_JBLANCE_ACCEPTED';
     $post['order_date'] = $now->toSql();
     //process extra add-ons
     $extras = $app->input->get('extras', null, 'array');
     $registry = new JRegistry();
     $registry->loadArray($extras);
     $post['extras'] = $registry->toString();
     //calculate the total amount and duration as they could have been tampered
     $return = $svcHelper->calculateServiceTotalPrice($service_id, $extras);
     $post['price'] = $return['totalPrice'];
     $post['duration'] = $return['totalDuration'];
     //check if the buyer has enough money to buy the service
     $totalFund = JblanceHelper::getTotalFund($user->id);
     if ($totalFund < $return['totalPrice']) {
         $msg = JText::sprintf('COM_JBLANCE_BALANCE_INSUFFICIENT_TO_BUY_SERVICE', JblanceHelper::formatCurrency($return['totalPrice']));
         $link = JRoute::_('index.php?option=com_jblance&view=membership&layout=depositfund', false);
         $this->setRedirect($link, $msg, 'error');
         return false;
     }
     if (!$row->save($post)) {
         throw new Exception($row->getError(), 500);
     }
     //deduct the amount from buyer and credit the seller after less service fee
     $plan = JblanceHelper::whichPlan($service->user_id);
     //get the plan details of the seller to get the service fee
     $serviceFee = $plan->flFeePercentPerService;
     //service fee in percent
     //deduct buyer
     $transDtl = JText::_('COM_JBLANCE_SERVICE_ORDER') . ' - ' . $service->service_title;
     $trans_buyer = JblanceHelper::updateTransaction($user->id, $transDtl, $return['totalPrice'], -1);
     $msg_debit = JText::sprintf('COM_JBLANCE_YOUR_ACCOUNT_DEBITED_WITH_CURRENCY_FOR_BUYING_SERVICE', JblanceHelper::formatCurrency($return['totalPrice']));
     $app->enqueueMessage($msg_debit);
     $app->enqueueMessage(JText::_('COM_JBLANCE_RELEASE_PAYMENT_WHEN_SATISFIED'));
     //calculate the escrow amount (less service fee)
     $amountToCredit = $return['totalPrice'] - round($serviceFee / 100 * $return['totalPrice'], 2);
     //save to escrow table
     $escrow->from_id = $user->id;
     $escrow->to_id = $service->user_id;
     $escrow->date_transfer = $now->toSql();
     $escrow->note = '';
     $escrow->amount = $amountToCredit;
     $escrow->project_id = $row->id;
     //this has to be service order id instead of service id. Changed since v1.7
     $escrow->type = 'COM_JBLANCE_SERVICE';
     $escrow->from_trans_id = $trans_buyer->id;
     if (!$escrow->store()) {
         JError::raiseError(500, $escrow->getError());
     }
     $escrow->checkin();
     //send service order notification to seller
     $jbmail = JblanceHelper::get('helper.email');
     // create an instance of the class EmailHelper
     $jbmail->sendServiceOrderNotification($row->id, $service_id);
     $msg = JText::_('COM_JBLANCE_SERVICE_ORDER_PLACED_SUCCESSFULLY') . ' : ' . $service->service_title;
     $return = JRoute::_('index.php?option=com_jblance&view=service&layout=servicebought', false);
     $this->setRedirect($return, $msg, 'message');
 }
示例#4
0
 function saveWithdrawFund()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $params = $app->input->get('params', null, 'array');
     $post = $app->input->post->getArray();
     $now = JFactory::getDate();
     $row = JTable::getInstance('withdraw', 'Table');
     $config = JblanceHelper::getConfig();
     $invoiceFormatWithdraw = $config->invoiceFormatWithdraw;
     //check if the user has enough fund to withdraw
     $totalFund = JblanceHelper::getTotalFund($user->id);
     if ($totalFund < $post['amount']) {
         $msg = JText::_('COM_JBLANCE_BALANCE_INSUFFICIENT_TO_MAKE_PAYMENT');
         $link = JRoute::_('index.php?option=com_jblance&view=membership&layout=withdrawfund&step=2&gateway=' . $post['gateway'], false);
         $this->setRedirect($link, $msg, 'error');
         return false;
     }
     $row->user_id = $user->id;
     $row->date_withdraw = $now->toSql();
     $row->finalAmount = $post['amount'] - $post['withdrawFee'];
     $registry = new JRegistry();
     $registry->loadArray($params);
     $row->params = $registry->toString();
     unset($post['params']);
     if (!$row->save($post)) {
         JError::raiseError(500, $row->getError());
     }
     $year = date("Y");
     $time = time();
     //replace the tags
     $tags = array("[ID]", "[USERID]", "[YYYY]", "[TIME]");
     $tagsValues = array("{$row->id}", "{$user->id}", "{$year}", "{$time}");
     $invoiceNo = str_replace($tags, $tagsValues, $invoiceFormatWithdraw);
     $row->invoiceNo = $invoiceNo;
     // save the changes after updating the invoice no
     if (!$row->store()) {
         JError::raiseError(500, $row->getError());
     }
     $row->checkin();
     //send withdraw request to admin
     $jbmail = JblanceHelper::get('helper.email');
     // create an instance of the class EmailHelper
     $jbmail->sendWithdrawFundRequest($row->id);
     $msg = JText::_('COM_JBLANCE_WITHDRAWAL_REQUEST_SENT_SUCCESSFULLY');
     $link = JRoute::_('index.php?option=com_jblance&view=membership&layout=managepay', false);
     $this->setRedirect($link, $msg);
     return false;
 }
示例#5
0
文件: helper.php 项目: Ovi1/modules
 public static function getTotalFund()
 {
     $user = JFactory::getUser();
     $total_fund = JblanceHelper::getTotalFund($user->id);
     return $total_fund;
 }
示例#6
0
 function getPlaceBid()
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDbo();
     $user = JFactory::getUser();
     $id = $app->input->get('id', 0, 'int');
     //id is the "project id"
     $finance = JblanceHelper::get('helper.finance');
     // create an instance of the class FinanceHelper
     $project = JTable::getInstance('project', 'Table');
     $project->load($id);
     // Project author is allowed to bid on his own project
     if ($project->publisher_userid == $user->id) {
         $msg = JText::sprintf('COM_JBLANCE_NOT_ALLOWED_TO_BID_ON_YOUR_OWN_PROJECT');
         $link = JRoute::_('index.php?option=com_jblance&view=user&layout=dashboard', false);
         $app->enqueueMessage($msg, 'error');
         $app->redirect($link);
         return false;
     }
     //project in Frozen/Closed should not be allowed to bid
     if ($project->status != 'COM_JBLANCE_OPEN') {
         $link = JRoute::_('index.php?option=com_jblance&view=project&layout=listproject', false);
         $app->redirect($link);
         return;
     }
     //redirect to dashboard if this is private invite project
     if ($project->is_private_invite) {
         $invite_ids = explode(',', $project->invite_user_id);
         if (!in_array($user->id, $invite_ids)) {
             $msg = JText::_('COM_JBLANCE_THIS_IS_A_PRIVATE_INVITE_PROJECT_VISIBLE_TO_OWNER_INVITEES');
             $link_dash = JRoute::_('index.php?option=com_jblance&view=user&layout=dashboard', false);
             $app->enqueueMessage($msg, 'error');
             $app->redirect($link_dash);
         }
     }
     //get the bid id
     $query = "SELECT id FROM #__jblance_bid WHERE project_id=" . $db->quote($id) . " AND user_id=" . $db->quote($user->id);
     $db->setQuery($query);
     $bid_id = $db->loadResult();
     $bid = JTable::getInstance('bid', 'Table');
     $bid->load($bid_id);
     //check if the user's plan is expired or not approved. If so, do not allow him to bid new on project
     $planStatus = JblanceHelper::planStatus($user->id);
     if (empty($bid_id) && ($planStatus == 1 || $planStatus == 2)) {
         $msg = JText::sprintf('COM_JBLANCE_NOT_ALLOWED_TO_DO_OPERATION_NO_ACTIVE_SUBSCRIPTION');
         $link = JRoute::_('index.php?option=com_jblance&view=user&layout=dashboard', false);
         $app->enqueueMessage($msg, 'error');
         $app->redirect($link);
         return false;
     }
     //check if the user has enough fund to bid new on projects. This should be checked for new bids only
     $plan = JblanceHelper::whichPlan($user->id);
     $chargePerBid = $plan->flChargePerBid;
     if ($chargePerBid > 0 && empty($bid_id)) {
         // bid_id will be empty for new bids
         $totalFund = JblanceHelper::getTotalFund($user->id);
         if ($totalFund < $chargePerBid) {
             $msg = JText::sprintf('COM_JBLANCE_BALANCE_INSUFFICIENT_TO_BID_PROJECT', JblanceHelper::formatCurrency($chargePerBid));
             $link = JRoute::_('index.php?option=com_jblance&view=membership&layout=depositfund', false);
             $app->enqueueMessage($msg, 'error');
             $app->redirect($link);
             return false;
         }
     }
     //check if the user has any bid limit. If any and exceeds, then disallow him
     $lastSubscr = $finance->getLastSubscription($user->id);
     if (empty($bid_id) && ($lastSubscr->bids_allowed > 0 && $lastSubscr->bids_left <= 0)) {
         $msg = JText::sprintf('COM_JBLANCE_NOT_ALLOWED_TO_BID_PROJECT_LIMIT_EXCEEDED');
         $link = JRoute::_('index.php?option=com_jblance&view=membership&layout=planadd', false);
         $app->enqueueMessage($msg, 'error');
         $app->redirect($link);
         return false;
     }
     $return[0] = $project;
     $return[1] = $bid;
     return $return;
 }
示例#7
0
 * @description	: 	Pick user from the bidders (jblance)
 */
defined('_JEXEC') or die('Restricted access');
JHtml::_('jquery.framework');
$doc = JFactory::getDocument();
$doc->addScript("components/com_jblance/js/simplemodal.js");
$doc->addStyleSheet("components/com_jblance/css/simplemodal.css");
$model = $this->getModel();
$user = JFactory::getUser();
$config = JblanceHelper::getConfig();
$currencycode = $config->currencyCode;
$dformat = $config->dateFormat;
$checkFund = $config->checkfundPickuser;
$showUsername = $config->showUsername;
$nameOrUsername = $showUsername ? 'username' : 'name';
$curr_balance = JblanceHelper::getTotalFund($user->id);
$link_deposit = JRoute::_('index.php?option=com_jblance&view=membership&layout=depositfund', false);
JText::script('COM_JBLANCE_CLOSE');
JText::script('COM_JBLANCE_YES');
?>
<script>
<!--
function checkBalance(){

	if(!jQuery("input[name='assigned_userid']:checked").length){
		alert('<?php 
echo JText::_('COM_JBLANCE_PLEASE_PICK_AN_USER_FROM_THE_LIST', true);
?>
');
		return false;
	}
示例#8
0
 function saveProject()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     // Initialize variables
     $app = JFactory::getApplication();
     $db = JFactory::getDbo();
     $user = JFactory::getUser();
     $row = JTable::getInstance('project', 'Table');
     $post = $app->input->post->getArray();
     $id = $app->input->get('id', 0, 'int');
     $jbmail = JblanceHelper::get('helper.email');
     // create an instance of the class EmailHelper
     $isNew = false;
     $totalAmount = $app->input->get('totalamount', 0, 'float');
     $config = JblanceHelper::getConfig();
     $reviewProjects = $config->reviewProjects;
     //load the project value if the project is 'edit'
     if ($id > 0) {
         $row->load($id);
     } else {
         $isNew = true;
     }
     // this is a new project
     $post['publisher_userid'] = $user->id;
     //$post['description']  = $app->input->get('description', '', 'string');
     $id_category = $app->input->get('id_category', '', 'array');
     JArrayHelper::toInteger($id_category);
     if (count($id_category) > 0 && !(count($id_category) == 1 && empty($id_category[0]))) {
         $proj_categ = implode(',', $id_category);
     } elseif ($id_category[0] == 0) {
         $proj_categ = 0;
     }
     $post['id_category'] = $proj_categ;
     if ($post['project_type'] == 'COM_JBLANCE_FIXED') {
         $budgetRange = explode('-', $post['budgetrange_fixed']);
     } elseif ($post['project_type'] == 'COM_JBLANCE_HOURLY') {
         $budgetRange = explode('-', $post['budgetrange_hourly']);
     }
     $post['budgetmin'] = $budgetRange[0];
     $post['budgetmax'] = $budgetRange[1];
     //save the commitment value
     $commitment = $app->input->get('commitment', null, 'array');
     $registry = new JRegistry();
     $registry->loadArray($commitment);
     $post['commitment'] = $registry->toString();
     //save the params value
     $params = $app->input->get('params', null, 'array');
     $registry = new JRegistry();
     $registry->loadArray($params);
     $post['params'] = $registry->toString();
     if ($isNew) {
         $now = JFactory::getDate();
         $post['create_date'] = $now->toSql();
         $post['status'] = 'COM_JBLANCE_OPEN';
         //check if the project is to be reviewed by admin. If so, set the approved=0
         if ($reviewProjects) {
             $post['approved'] = 0;
         }
         // deduce `charge per project` if amount is > 0
         $plan = JblanceHelper::whichPlan($user->id);
         $chargePerProject = $plan->buyChargePerProject;
         if ($chargePerProject > 0) {
             $transDtl = JText::_('COM_JBLANCE_CHARGE_PER_PROJECT') . ' - ' . $post['project_title'];
             JblanceHelper::updateTransaction($user->id, $transDtl, $chargePerProject, -1);
             $msg_debit = JText::sprintf('COM_JBLANCE_YOUR_ACCOUNT_DEBITED_WITH_CURRENCY_FOR_POSTING_PROJECT', JblanceHelper::formatCurrency($chargePerProject));
             $app->enqueueMessage($msg_debit);
         }
     }
     // deduce the amount from user's account
     if ($totalAmount > 0) {
         //check if the user has enough fund to promote project
         $totalFund = JblanceHelper::getTotalFund($user->id);
         if ($totalFund < $totalAmount) {
             $msg = JText::_('COM_JBLANCE_BALANCE_INSUFFICIENT_TO_PROMOTE_PROJECT');
             $id_link = '';
             if ($post['id'] > 0) {
                 $id_link = '&id=' . $post['id'];
             }
             $link = JRoute::_('index.php?option=com_jblance&view=project&layout=editproject' . $id_link, false);
             $this->setRedirect($link, $msg, 'error');
             return false;
         } else {
             $post['profit_additional'] = $row->profit_additional + $post['totalamount'];
             $transDtl = JText::_('COM_JBLANCE_PROJECT_PROMOTION_FEE_FOR') . ' - ' . $post['project_title'];
             JblanceHelper::updateTransaction($user->id, $transDtl, $totalAmount, -1);
         }
     }
     if (!$row->save($post)) {
         JError::raiseError(500, $row->getError());
     }
     //save the custom field value for project
     $fields = JblanceHelper::get('helper.fields');
     // create an instance of the class fieldsHelper
     $fields->saveFieldValues('project', $row->id, $post);
     JBMediaHelper::uploadFile($post, $row);
     //remove and upload files
     //update the project posting limit in the plan subscription table
     if ($isNew) {
         $finance = JblanceHelper::get('helper.finance');
         // create an instance of the class FinanceHelper
         $finance->updateProjectLeft($user->id);
     }
     //Trigger the plugin event to feed the activity - buyer pick freelancer
     JPluginHelper::importPlugin('joombri');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onProjectAfterSave', array($row, $isNew));
     //send email to admin if the project needs review (only for new project)
     if ($isNew) {
         if ($reviewProjects) {
             $jbmail->sendAdminProjectPendingApproval($row->id);
         }
     }
     // if the project in "private invite, send him to freelancer selection page else send notification"
     if ($post['is_private_invite']) {
         $msg = JText::_('COM_JBLANCE_PROJECT_SAVED_SUCCESSFULLY') . ' : ' . $row->project_title;
         $return = JRoute::_('index.php?option=com_jblance&view=project&layout=inviteuser&id=' . $row->id, false);
         $this->setRedirect($return, $msg);
     } else {
         //send new project notification if the project doesn't need review
         if (!$reviewProjects) {
             $jbmail->sendNewProjectNotification($row->id, $isNew);
         }
         $msg = JText::_('COM_JBLANCE_PROJECT_SAVED_SUCCESSFULLY') . ' : ' . $row->project_title;
         $return = JRoute::_('index.php?option=com_jblance&view=project&layout=showmyproject', false);
         $this->setRedirect($return, $msg);
     }
 }