Пример #1
0
 * @copyright   :	Copyright (C) 2012 - 2015 BriTech Solutions. All rights reserved.
 * @license     :	GNU General Public License version 2 or later
 * @author      :	Faisel
 * @description	: 	User Groups (jblance)
 */
defined('_JEXEC') or die('Restricted access');
//JHtml::_('jquery.framework');
//JHtml::_('behavior.formvalidator');
$doc = JFactory::getDocument();
//$doc->addStyleSheet("components/com_jblance/css/pricing.css");
$app = JFactory::getApplication();
$user = JFactory::getUser();
$model = $this->getModel();
$config = JblanceHelper::getConfig();
$link_dashboard = JRoute::_('index.php?option=com_jblance&view=user&layout=dashboard');
jbimport('fbconnect');
$fb = new FbconnectHelper();
$user_info = $fb->initFbLogin();
//check if app key/secret is empty. If empty, do not show the FB connect button
$showFbConnect = true;
$app_id = $config->fbApikey;
$app_sec = $config->fbAppsecret;
if (empty($app_id) || empty($app_sec)) {
    $showFbConnect = false;
}
?>




<div class="panel panel-default">
Пример #2
0
 function saveBid()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     $jbmail = JblanceHelper::get('helper.email');
     // create an instance of the class EmailHelper
     $projhelp = JblanceHelper::get('helper.project');
     // create an instance of the class ProjectHelper
     $finance = JblanceHelper::get('helper.finance');
     // create an instance of the class FinanceHelper
     $user = JFactory::getUser();
     $post = $app->input->post->getArray();
     $id = $app->input->get('id', 0, 'int');
     $row = JTable::getInstance('bid', 'Table');
     $message = JTable::getInstance('message', 'Table');
     $project_id = $app->input->get('project_id', 0, 'int');
     $proj_detail = $projhelp->getProjectDetails($project_id);
     $isNew = false;
     $now = JFactory::getDate();
     $config = JblanceHelper::getConfig();
     if ($id > 0) {
         $row->load($id);
     } else {
         $isNew = true;
     }
     // if the placed bid is new, check for bids left
     $lastSubscr = $finance->getLastSubscription($user->id);
     if ($isNew && ($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);
         $this->setRedirect($link, $msg, 'error');
         return false;
     }
     $post['user_id'] = $user->id;
     $post['outbid'] = $app->input->get('outbid', 0, 'int');
     if ($isNew) {
         $post['bid_date'] = $now->toSql();
         // deduce `charge per bid` if amount is > 0
         $plan = JblanceHelper::whichPlan($user->id);
         $chargePerBid = $plan->flChargePerBid;
         if ($chargePerBid > 0) {
             $transDtl = JText::_('COM_JBLANCE_CHARGE_PER_BID') . ' - ' . $proj_detail->project_title;
             JblanceHelper::updateTransaction($user->id, $transDtl, $chargePerBid, -1);
             $msg_debit = JText::sprintf('COM_JBLANCE_YOUR_ACCOUNT_DEBITED_WITH_CURRENCY_FOR_BIDDING_PROJECT', JblanceHelper::formatCurrency($chargePerBid));
             $app->enqueueMessage($msg_debit);
         }
     }
     //if the freelancer has denied the bid and is editing, reset the status. Edit option is available if the project is reopened by buyer.
     $row->status = '';
     if (!$row->save($post)) {
         JError::raiseError(500, $row->getError());
     }
     //if the project requires NDA and not signed
     $is_nda_signed = $app->input->get('is_nda_signed', 0, 'int');
     if ($proj_detail->is_nda && $is_nda_signed) {
         jimport('joomla.filesystem.folder');
         jbimport('pdflib.fpdf');
         if (!JFolder::exists(JBBIDNDA_PATH)) {
             if (JFolder::create(JBBIDNDA_PATH)) {
                 if (JFile::exists(JPATH_SITE . '/images/index.html')) {
                     JFile::copy(JPATH_SITE . '/images/index.html', JBBIDNDA_PATH . '/index.html');
                 }
             }
         }
         $new_doc = "nda_" . $row->id . "_" . $proj_detail->id . "_" . strtotime("now") . ".pdf";
         //file name format: nda_BIDID_PROJECTID_time.pdf
         $dest = JBBIDNDA_PATH . '/' . $new_doc;
         //replace texts in the file
         $dformat = $config->dateFormat;
         $ndaFile = JPATH_COMPONENT . '/images/nda.txt';
         $ndaText = file_get_contents($ndaFile);
         $siteURL = JURI::root();
         $projectName = $proj_detail->project_title;
         $startDate = JHtml::_('date', $proj_detail->start_date, $dformat . ' H:i:s', false);
         $bidderName = JFactory::getUser($row->user_id)->name;
         $bidDate = JHtml::_('date', $row->bid_date, $dformat . ' H:i:s', false);
         $publisherName = JFactory::getUser($proj_detail->publisher_userid)->name;
         $tags = array("[SITEURL]", "[PROJECTNAME]", "[STARTDATE]", "[BIDDERNAME]", "[BIDDATE]", "[PUBLISHERNAME]");
         $tagsValues = array("{$siteURL}", "{$projectName}", "{$startDate}", "{$bidderName}", "{$bidDate}", "{$publisherName}");
         $ndaText = str_replace($tags, $tagsValues, $ndaText);
         $pdf = new PDF();
         $title = JText::_('COM_JBLANCE_NON_DISCLOSURE_AGREEMENT');
         $pdf->SetTitle($title);
         $pdf->PrintChapter($ndaText);
         $pdf->Output($dest, 'F');
         $row->attachment = $title . ';' . $new_doc;
     }
     // save the changes after updating nda
     if (!$row->store()) {
         JError::raiseError(500, $row->getError());
     }
     $row->checkin();
     //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->updateBidsLeft($user->id);
     }
     //save and send PM
     $send_pm = $app->input->get('sendpm', 0, 'int');
     if ($send_pm) {
         //save the file attachment `if` checked
         $chkAttach = $app->input->get('chk-uploadmessage', 0, 'int');
         $attachedFile = $app->input->get('attached-file-uploadmessage', '', 'string');
         if ($chkAttach) {
             $post['attachment'] = $attachedFile;
         } else {
             $attFile = explode(';', $attachedFile);
             $filename = $attFile[1];
             $delete = JBMESSAGE_PATH . '/' . $filename;
             if (JFile::exists($delete)) {
                 unlink($delete);
             }
         }
         $post['date_sent'] = $now->toSql();
         $post['idFrom'] = $user->id;
         $post['idTo'] = $proj_detail->publisher_userid;
         $post['type'] = 'COM_JBLANCE_PROJECT';
         //check if messages to be moderated
         $reviewMessages = $config->reviewMessages;
         if ($reviewMessages) {
             $post['approved'] = 0;
         }
         if (!$message->save($post)) {
             JError::raiseError(500, $message->getError());
         }
         //if message does not require moderation, send PM notification email to recipient else send to admin for approval
         if ($reviewMessages) {
             $jbmail->sendAdminMessagePendingApproval($message->id);
         } else {
             $jbmail->sendMessageNotification($message->id);
         }
     }
     //send mail to publisher and outbid notify
     /* if($isNew){
     			$jbmail->sendNewBidNotification($row->id, $project_id);
     		} */
     $jbmail->sendNewBidNotification($row->id, $project_id, $isNew);
     //send out bid notification to bidders with higher amount
     $jbmail->sendOutBidNotification($row->id, $project_id);
     //Trigger the plugin event to feed the activity - buyer pick freelancer
     JPluginHelper::importPlugin('joombri');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBidAfterSave', array($row, $proj_detail->publisher_userid, $isNew));
     $msg = $isNew ? JText::_('COM_JBLANCE_BID_PLACED_SUCCESSFULLY') : JText::_('COM_JBLANCE_BID_EDITED_SUCCESSFULLY');
     $msg .= ' - ' . $proj_detail->project_title;
     $return = JRoute::_('index.php?option=com_jblance&view=project&layout=showmybid', false);
     $this->setRedirect($return, $msg);
 }