Ejemplo n.º 1
0
 /**
  * Prepare some specific data.
  */
 public function prepareData()
 {
     $this->slug = $this->id . ':' . $this->alias;
     $this->catslug = $this->getCatSlug();
     // Calculate funded percent
     if (!$this->goal) {
         $this->fundedPercent = 0;
     } else {
         $this->fundedPercent = (string) Prism\Utilities\MathHelper::calculatePercentage($this->funded, $this->goal, 0);
     }
     // Calculate end date
     if ($this->funding_days > 0) {
         $fundingStartDateValidator = new Prism\Validator\Date($this->funding_start);
         if (!$fundingStartDateValidator->isValid()) {
             $this->funding_end = '1000-01-01';
         } else {
             $fundingStartDate = new Crowdfunding\Date($this->funding_start);
             $fundingEndDate = $fundingStartDate->calculateEndDate($this->funding_days);
             $this->funding_end = $fundingEndDate->toSql();
         }
     }
     // Calculate days left
     $today = new Crowdfunding\Date();
     $this->daysLeft = $today->calculateDaysLeft($this->funding_days, $this->funding_start, $this->funding_end);
 }
Ejemplo n.º 2
0
 protected function prepareFundingDurationType()
 {
     $this->fundingDuration = $this->params->get('project_funding_duration');
     switch ($this->fundingDuration) {
         case 'days':
             // Only days type is enabled
             $this->checkedDays = 'checked="checked"';
             break;
         case 'date':
             // Only date type is enabled
             $this->checkedDate = 'checked="checked"';
             break;
         default:
             // Both ( days and date ) types are enabled
             $fundingStartDateValidator = new Prism\Validator\Date($this->item->funding_end);
             $this->checkedDays = 0;
             $this->checkedDate = '';
             if ($this->item->funding_days > 0) {
                 $this->checkedDays = 'checked="checked"';
                 $this->checkedDate = '';
             } elseif ($fundingStartDateValidator->isValid()) {
                 $this->checkedDays = '';
                 $this->checkedDate = 'checked="checked"';
             }
             // If missing both, select days
             if (!$this->checkedDays and !$this->checkedDate) {
                 $this->checkedDays = 'checked="checked"';
             }
             break;
     }
 }
Ejemplo n.º 3
0
 /**
  * Method to load a row from the database by primary key and bind the fields
  * to the JTable instance properties.
  *
  * @param   mixed   $keys  An optional primary key value to load the row by, or an array of fields to match.  If not
  *                         set the instance property value is used.
  * @param   boolean $reset True to reset the default values before loading the new row.
  *
  * @return  boolean  True if successful. False if row not found or on error (internal error state set in that case).
  *
  * @link    http://docs.joomla.org/JTable/load
  * @since   11.1
  */
 public function load($keys = null, $reset = true)
 {
     parent::load($keys, $reset);
     $this->slug = $this->id . "." . $this->alias;
     // Calculate funded percent
     if (!$this->goal) {
         $this->fundedPercent = 0;
     } else {
         $percentage = new Prism\Math();
         $percentage->calculatePercentage($this->funded, $this->goal, 0);
         $this->fundedPercent = (string) $percentage;
     }
     // Calculate end date
     if (!empty($this->funding_days)) {
         $fundingStartDateValidator = new Prism\Validator\Date($this->funding_start);
         if (!$fundingStartDateValidator->isValid()) {
             $this->funding_end = "0000-00-00";
         } else {
             $fundingStartDate = new Crowdfunding\Date($this->funding_start);
             $fundingEndDate = $fundingStartDate->calculateEndDate($this->funding_days);
             $this->funding_end = $fundingEndDate->toSql();
         }
     }
     // Calculate days left
     $today = new Crowdfunding\Date();
     $this->daysLeft = $today->calculateDaysLeft($this->funding_days, $this->funding_start, $this->funding_end);
     return true;
 }
 protected function getInput()
 {
     $class = !empty($this->class) ? $this->class : '';
     $required = $this->required ? ' required aria-required="true"' : '';
     $birthdayDay = '';
     $birthdayMonth = '01';
     $birthdayYear = '';
     // Prepare birthday
     if (!empty($this->value)) {
         $date = new Prism\Validator\Date($this->value);
         if (!$date->isValid()) {
             $birthdayDay = '';
             $birthdayMonth = '';
             $birthdayYear = '';
         } else {
             $date = new JDate($this->value);
             $birthdayDay = $date->format('d');
             $birthdayMonth = $date->format('m');
             $birthdayYear = $date->format('Y');
         }
     }
     $months = new Socialcommunity\Filter\Months();
     $html = array();
     $html[] = '<div class="' . $class . '">';
     $html[] = '    <input name="' . $this->name . '[day]"   value="' . $birthdayDay . '" id="birthday_day" class="col-md-3 ' . $class . '" type="text" placeholder="' . JText::_('COM_SOCIALCOMMUNITY_DAY') . '" ' . $required . '>';
     $html[] = JHTML::_('select.genericlist', $months->toOptions(), $this->name . '[month]', array('class' => 'col-md-3 ' . $class), 'text', 'value', $birthdayMonth, 'birthday_month');
     $html[] = '    <input name="' . $this->name . '[year]"  value="' . $birthdayYear . '" id="birthday_year"  class="col-md-4 ' . $class . '" type="text" placeholder="' . JText::_('COM_SOCIALCOMMUNITY_YEAR') . '" ' . $required . '>';
     $html[] = '</div>';
     return implode($html);
 }
Ejemplo n.º 5
0
 protected function getInput()
 {
     $class = !empty($this->class) ? $this->class : '';
     $required = $this->required ? ' required aria-required="true"' : '';
     // Prepare birthday
     if (!empty($this->value)) {
         $date = new Prism\Validator\Date($this->value);
         if (!$date->isValid()) {
             $birthdayDay = "";
             $birthdayMonth = "";
             $birthdayYear = "";
         } else {
             $date = new JDate($this->value);
             $birthdayDay = $date->format("d");
             $birthdayMonth = $date->format("m");
             $birthdayYear = $date->format("Y");
         }
     }
     $html = array();
     $html[] = '<div class="' . $class . '">';
     $html[] = '    <input name="' . $this->name . '[day]"   value="' . $birthdayDay . '" id="birthday_day"   class="span3" type="text" placeholder="' . JText::_("COM_SOCIALCOMMUNITY_DAY") . '" ' . $required . '>';
     $html[] = '    <input name="' . $this->name . '[month]" value="' . $birthdayMonth . '" id="birthday_month" class="span3" type="text" placeholder="' . JText::_("COM_SOCIALCOMMUNITY_MONTH") . '" ' . $required . '>';
     $html[] = '    <input name="' . $this->name . '[year]"  value="' . $birthdayYear . '" id="birthday_year"  class="span4" type="text" placeholder="' . JText::_("COM_SOCIALCOMMUNITY_YEAR") . '" ' . $required . '>';
     $html[] = '</div>';
     return implode($html);
 }
Ejemplo n.º 6
0
 protected function prepareDefaultLayout()
 {
     $this->rewards = new Crowdfunding\User\Rewards(JFactory::getDbo());
     $this->rewards->load(array('reward_id' => $this->item->id));
     $this->rewardOwnerId = CrowdfundingHelper::getUserIdByRewardId($this->item->id);
     $dateValidator = new Prism\Validator\Date($this->item->delivery);
     $this->deliveryDate = $dateValidator->isValid() ? JHtml::_('date', $this->item->delivery, JText::_('DATE_FORMAT_LC3')) : '--';
     $this->imagesFolder = CrowdfundingHelper::getImagesFolderUri($this->rewardOwnerId);
     // Get social profile
     $socialPlatform = $this->params->get('integration_social_platform');
     if ($socialPlatform) {
         $this->socialProfile = CrowdfundingHelper::prepareIntegration($socialPlatform, $this->rewardOwnerId);
         $this->profileLink = $this->socialProfile->getLink();
     }
     $this->returnUrl = base64_encode('index.php?option=com_crowdfunding&view=reward&id=' . $this->item->id);
 }
Ejemplo n.º 7
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     $this->option = JFactory::getApplication()->input->get('option');
     // Get user ID.
     $this->userId = JFactory::getUser()->get('id');
     // Get reward ID.
     $rewardId = $app->input->getInt('id');
     // Validate reward owner
     $validator = new Crowdfunding\Validator\Reward\Owner(JFactory::getDbo(), $rewardId, $this->userId);
     if (!$validator->isValid()) {
         $app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_INVALID_REWARD'), 'notice');
         $app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute()));
         return;
     }
     $this->items = $this->get('Items');
     $this->state = $this->get('State');
     $this->pagination = $this->get('Pagination');
     // Get params
     /** @var  $params Joomla\Registry\Registry */
     $params = $this->state->get('params');
     $this->params = $params;
     // Prepare an URL where user will be redirected when change the state of a reward.
     $this->redirectUrl = 'index.php?option=com_crowdfunding&view=reward&id=' . $rewardId;
     // Prepare filters
     $this->listOrder = $this->escape($this->state->get('list.ordering'));
     $this->listDirn = $this->escape($this->state->get('list.direction'));
     $this->saveOrder = strcmp($this->listOrder, 'a.ordering') === 0;
     // Load reward data.
     $this->reward = new Crowdfunding\Reward(JFactory::getDbo());
     $this->reward->load($rewardId);
     // Prepare reward delivery date.
     $dateValidator = new Prism\Validator\Date($this->reward->getDeliveryDate());
     $this->deliveryDate = $dateValidator->isValid() ? JHtml::_('date', $this->reward->getDeliveryDate(), JText::_('DATE_FORMAT_LC3')) : '--';
     // Get images folder.
     $this->imagesFolder = CrowdfundingHelper::getImagesFolderUri($this->userId);
     // Get social profile
     $socialPlatform = $this->params->get('integration_social_platform');
     if (JString::strlen($socialPlatform) > 0) {
         $this->prepareSocialIntegration($socialPlatform);
     }
     $this->prepareDocument();
     parent::display($tpl);
 }
Ejemplo n.º 8
0
 public function validate($data)
 {
     if (!is_array($data) or count($data) === 0) {
         throw new InvalidArgumentException(JText::_('COM_CROWDFUNDING_ERROR_INVALID_REWARDS'));
     }
     $filter = JFilterInput::getInstance();
     $params = JComponentHelper::getParams('com_crowdfunding');
     /** @var  $params Joomla\Registry\Registry */
     $money = $this->getMoneyFormatter($params);
     foreach ($data as $key => &$item) {
         $item['amount'] = $money->setAmount($item['amount'])->parse();
         // Filter data
         if (!is_numeric($item['amount'])) {
             $item['amount'] = 0.0;
         }
         $item['title'] = $filter->clean($item['title'], 'string');
         $item['title'] = JString::trim($item['title']);
         $item['title'] = JString::substr($item['title'], 0, 128);
         $item['description'] = $filter->clean($item['description'], 'string');
         $item['description'] = JString::trim($item['description']);
         $item['description'] = JString::substr($item['description'], 0, 500);
         $item['number'] = (int) $item['number'];
         $item['delivery'] = trim($item['delivery']);
         $item['delivery'] = $filter->clean($item['delivery'], 'string');
         if (!empty($item['delivery'])) {
             $item['delivery'] = CrowdfundingHelper::convertToSql($item['delivery']);
             $validatorDate = new Prism\Validator\Date($item['delivery']);
             if (!$validatorDate->isValid()) {
                 $item['delivery'] = '';
             }
         }
         if (!$item['title']) {
             throw new RuntimeException(JText::_('COM_CROWDFUNDING_ERROR_INVALID_TITLE'));
         }
         if (!$item['description']) {
             throw new RuntimeException(JText::_('COM_CROWDFUNDING_ERROR_INVALID_DESCRIPTION'));
         }
         if (!$item['amount']) {
             throw new RuntimeException(JText::_('COM_CROWDFUNDING_ERROR_INVALID_AMOUNT'));
         }
     }
     unset($item);
     return $data;
 }
Ejemplo n.º 9
0
 protected function prepareDefaultLayout()
 {
     $this->rewards = new Crowdfunding\User\Rewards(JFactory::getDbo());
     $this->rewards->load(array("reward_id" => $this->item->id));
     $this->rewardOwnerId = CrowdfundingHelper::getUserIdByRewardId($this->item->id);
     $dateValidator = new Prism\Validator\Date($this->item->delivery);
     $this->deliveryDate = $dateValidator->isValid() ? JHtml::_('date', $this->item->delivery, JText::_('DATE_FORMAT_LC3')) : "--";
     $this->imagesFolder = CrowdfundingHelper::getImagesFolderUri($this->rewardOwnerId);
     // Get social profile
     $socialPlatform = $this->params->get("integration_social_platform");
     if (!empty($socialPlatform)) {
         $options = array("social_platform" => $socialPlatform, "user_id" => $this->rewardOwnerId);
         $profileBuilder = new Prism\Integration\Profile\Builder($options);
         $profileBuilder->build();
         $this->socialProfile = $profileBuilder->getProfile();
         $this->profileLink = $this->socialProfile->getLink();
     }
     $this->returnUrl = base64_encode("index.php?option=com_crowdfunding&view=reward&id=" . $this->item->id);
 }
 public static function prepareBirthday($data)
 {
     $birthdayDay = Joomla\Utilities\ArrayHelper::getValue($data['birthday'], 'day', 0, 'int');
     $birthdayMonth = Joomla\Utilities\ArrayHelper::getValue($data['birthday'], 'month', 0, 'int');
     $birthdayYear = Joomla\Utilities\ArrayHelper::getValue($data['birthday'], 'year', 0, 'int');
     if (!$birthdayDay) {
         $birthdayDay = '00';
     }
     if (!$birthdayMonth) {
         $birthdayMonth = '00';
     }
     if (!$birthdayYear) {
         $birthdayYear = '0000';
     }
     $birthday = $birthdayYear . '-' . $birthdayMonth . '-' . $birthdayDay;
     $date = new Prism\Validator\Date($birthday);
     if (!$date->isValid()) {
         $birthday = '0000-00-00';
     }
     return $birthday;
 }
Ejemplo n.º 11
0
 /**
  * Method to get an object.
  *
  * @param    integer  $id  The id of the object to get.
  *
  * @return    mixed    Object on success, false on failure.
  */
 public function getItem($id = null)
 {
     if (empty($id)) {
         $id = $this->getState($this->context . '.id');
     }
     $storedId = $this->getStoreId($id);
     if (!isset($this->item[$storedId])) {
         $this->item[$storedId] = null;
         $db = $this->getDbo();
         $query = $db->getQuery(true);
         $query->select("a.id, a.title, a.short_desc, a.description, a.image, a.location_id, " . "a.funded, a.goal, a.pitch_video, a.pitch_image, " . "a.funding_start, a.funding_end, a.funding_days, a.funding_type,  " . "a.catid, a.user_id, a.published, a.approved, a.hits, " . $query->concatenate(array("a.id", "a.alias"), ":") . ' AS slug, ' . $query->concatenate(array("b.id", "b.alias"), ":") . ' AS catslug')->from($db->quoteName("#__crowdf_projects", "a"))->innerJoin($db->quoteName("#__categories", "b") . " ON a.catid = b.id")->where("a.id = " . (int) $id);
         $db->setQuery($query, 0, 1);
         $result = $db->loadObject();
         // Attempt to load the row.
         if (!empty($result)) {
             // Calculate end date
             if (!empty($result->funding_days)) {
                 $fundingStartDateValidator = new Prism\Validator\Date($result->funding_start);
                 if (!$fundingStartDateValidator->isValid()) {
                     $result->funding_end = "0000-00-00";
                 } else {
                     $fundingStartDate = new Crowdfunding\Date($result->funding_start);
                     $fundingEndDate = $fundingStartDate->calculateEndDate($result->funding_days);
                     $result->funding_end = $fundingEndDate->format("Y-m-d");
                 }
             }
             // Calculate funded percentage.
             $math = new Prism\Math();
             $math->calculatePercentage($result->funded, $result->goal, 0);
             $result->funded_percents = (string) $math;
             // Calculate days left.
             $today = new Crowdfunding\Date();
             $result->days_left = $today->calculateDaysLeft($result->funding_days, $result->funding_start, $result->funding_end);
             $this->item[$storedId] = $result;
         }
     }
     return $this->item[$storedId];
 }
Ejemplo n.º 12
0
 /**
  * Method to get an object.
  *
  * @param    integer  $id  The id of the object to get.
  *
  * @return    mixed    Object on success, false on failure.
  */
 public function getItem($id = 0)
 {
     if ((int) $id === 0) {
         $id = $this->getState($this->context . '.id');
     }
     $storedId = $this->getStoreId($id);
     if (!array_key_exists($storedId, $this->item)) {
         $this->item[$storedId] = null;
         $db = $this->getDbo();
         $query = $db->getQuery(true);
         $query->select('a.id, a.title, a.short_desc, a.description, a.image, a.location_id, ' . 'a.funded, a.goal, a.pitch_video, a.pitch_image, ' . 'a.funding_start, a.funding_end, a.funding_days, a.funding_type,  ' . 'a.catid, a.user_id, a.published, a.approved, a.hits, ' . $query->concatenate(array('a.id', 'a.alias'), ':') . ' AS slug, ' . $query->concatenate(array('b.id', 'b.alias'), ':') . ' AS catslug')->from($db->quoteName('#__crowdf_projects', 'a'))->innerJoin($db->quoteName('#__categories', 'b') . ' ON a.catid = b.id')->where('a.id = ' . (int) $id);
         $db->setQuery($query, 0, 1);
         $result = $db->loadObject();
         // Attempt to load the row.
         if ($result !== null and is_object($result)) {
             // Calculate end date
             if ((int) $result->funding_days > 0) {
                 $fundingStartDateValidator = new Prism\Validator\Date($result->funding_start);
                 if (!$fundingStartDateValidator->isValid()) {
                     $result->funding_end = '0000-00-00';
                 } else {
                     $fundingStartDate = new Crowdfunding\Date($result->funding_start);
                     $fundingEndDate = $fundingStartDate->calculateEndDate($result->funding_days);
                     $result->funding_end = $fundingEndDate->format('Y-m-d');
                 }
             }
             // Calculate funded percentage.
             $result->funded_percents = Prism\Utilities\MathHelper::calculatePercentage($result->funded, $result->goal, 0);
             // Calculate days left.
             $today = new Crowdfunding\Date();
             $result->days_left = $today->calculateDaysLeft($result->funding_days, $result->funding_start, $result->funding_end);
             $this->item[$storedId] = $result;
         }
     }
     return $this->item[$storedId];
 }
Ejemplo n.º 13
0
 /**
  * This method calculates start date and validate funding period.
  *
  * @param CrowdfundingTableProject $table
  *
  * @throws Exception
  */
 protected function prepareTable(&$table)
 {
     // Calculate start and end date if the user publish a project for first time.
     $fundingStartDate = new Prism\Validator\Date($table->get('funding_start'));
     if (!$fundingStartDate->isValid()) {
         $app = JFactory::getApplication();
         /** @var $app JApplicationSite */
         $fundingStart = new JDate('now', $app->get('offset'));
         $table->set('funding_start', $fundingStart->toSql());
         // If funding type is 'days', calculate end date.
         if ($table->get('funding_days')) {
             $fundingStartDate = new Crowdfunding\Date($table->get('funding_start'));
             $endDate = $fundingStartDate->calculateEndDate($table->get('funding_days'));
             $table->set('funding_end', $endDate->toSql());
         }
     }
     // Get parameters
     $params = JComponentHelper::getParams('com_crowdfunding');
     /** @var  $params Joomla\Registry\Registry */
     $minDays = $params->get('project_days_minimum', 15);
     $maxDays = $params->get('project_days_maximum');
     // If there is an ending date, validate the period.
     $fundingEndDate = new Prism\Validator\Date($table->get('funding_end'));
     if ($fundingEndDate->isValid()) {
         $validatorPeriod = new Crowdfunding\Validator\Project\Period($table->get('funding_start'), $table->get('funding_end'), $minDays, $maxDays);
         if (!$validatorPeriod->isValid()) {
             if (!empty($maxDays)) {
                 throw new RuntimeException(JText::sprintf('COM_CROWDFUNDING_ERROR_INVALID_ENDING_DATE_MIN_MAX_DAYS', $minDays, $maxDays));
             } else {
                 throw new RuntimeException(JText::sprintf('COM_CROWDFUNDING_ERROR_INVALID_ENDING_DATE_MIN_DAYS', $minDays));
             }
         }
     }
 }
Ejemplo n.º 14
0
 /**
  * Display a date.
  *
  * @param string $date
  * @param string $format
  * @param string $default
  *
  * @throws  \InvalidArgumentException
  * @return  string  HTML element attributes
  */
 public static function date($date, $format = '', $default = '--')
 {
     $dateValidator = new Prism\Validator\Date($date);
     return $dateValidator->isValid() ? JHtml::_('date', $date, $format) : $default;
 }
Ejemplo n.º 15
0
 /**
  * Save data into the DB
  *
  * @param array $data   The data of item
  *
  * @return    int      Item ID
  */
 public function save($data)
 {
     $id = Joomla\Utilities\ArrayHelper::getValue($data, 'id', 0, 'int');
     $txnAmount = Joomla\Utilities\ArrayHelper::getValue($data, 'txn_amount');
     $txnCurrency = Joomla\Utilities\ArrayHelper::getValue($data, 'txn_currency');
     $txnStatus = Joomla\Utilities\ArrayHelper::getValue($data, 'txn_status');
     $txnDate = Joomla\Utilities\ArrayHelper::getValue($data, 'txn_date');
     $txnId = Joomla\Utilities\ArrayHelper::getValue($data, 'txn_id');
     $parentTxnId = Joomla\Utilities\ArrayHelper::getValue($data, 'parent_txn_id');
     $serviceProvider = Joomla\Utilities\ArrayHelper::getValue($data, 'service_provider');
     $serviceAlias = Joomla\Utilities\ArrayHelper::getValue($data, 'service_alias');
     $investorId = Joomla\Utilities\ArrayHelper::getValue($data, 'investor_id', 0, 'int');
     $receiverId = Joomla\Utilities\ArrayHelper::getValue($data, 'receiver_id', 0, 'int');
     $projectId = Joomla\Utilities\ArrayHelper::getValue($data, 'project_id', 0, 'int');
     $rewardId = Joomla\Utilities\ArrayHelper::getValue($data, 'reward_id', 0, 'int');
     $dateValidator = new Prism\Validator\Date($txnDate);
     if (!$dateValidator->isValid()) {
         $timezone = JFactory::getApplication()->get('offset');
         $currentDate = new JDate('now', $timezone);
         $txnDate = $currentDate->toSql();
     }
     // Load a record from the database.
     $row = $this->getTable();
     $row->load($id);
     $this->prepareStatus($row, $txnStatus);
     // Store the transaction data.
     $row->set('txn_amount', $txnAmount);
     $row->set('txn_currency', $txnCurrency);
     $row->set('txn_status', $txnStatus);
     $row->set('txn_date', $txnDate);
     $row->set('txn_id', $txnId);
     $row->set('parent_txn_id', $parentTxnId);
     $row->set('service_provider', $serviceProvider);
     $row->set('service_alias', $serviceAlias);
     $row->set('investor_id', $investorId);
     $row->set('receiver_id', $receiverId);
     $row->set('project_id', $projectId);
     $row->set('reward_id', $rewardId);
     $row->store();
     return $row->get('id');
 }
Ejemplo n.º 16
0
 /**
  * Generates tracking information about a transaction data.
  *
  * @param mixed $trackId
  *
  * @return string
  */
 public static function trackId($trackId)
 {
     if (!$trackId) {
         $output = JText::sprintf("COM_CROWDFUNDING_DATE_AND_TIME", "---");
     } else {
         if (!is_numeric($trackId)) {
             $output = JText::sprintf("COM_CROWDFUNDING_TRACK_ID", htmlentities($trackId, ENT_QUOTES, "UTF-8"));
         } else {
             $validator = new Prism\Validator\Date($trackId);
             if (!$validator->isValid()) {
                 $output = JText::sprintf("COM_CROWDFUNDING_DATE_AND_TIME", "---");
             } else {
                 $date = new JDate($trackId);
                 $output = JText::sprintf("COM_CROWDFUNDING_DATE_AND_TIME", $date->format(DATE_RFC822));
             }
         }
     }
     return $output;
 }
Ejemplo n.º 17
0
                <div class="cf-rewards-claimed">
                    <?php 
                if ($reward['distributed'] < $reward['number']) {
                    echo JText::sprintf('MOD_CROWDFUNDINGREWARDS_CLAIMED', $reward['distributed'], $reward['number']);
                } else {
                    echo JText::sprintf('MOD_CROWDFUNDINGREWARDS_CLAIMED_ALL_DONE', $reward['distributed'], $reward['number']);
                }
                ?>
                </div>
                <?php 
            }
            ?>

                <?php 
            if ($params->get('display_delivery_date', 0)) {
                $deliveryDate = new Prism\Validator\Date($reward['delivery']);
                if ($deliveryDate->isValid()) {
                    echo '<div class="cf-rewards-delivery">' . JText::sprintf('MOD_CROWDFUNDINGREWARDS_ESTIMATED_DELIVERY', JHtml::_('date', $reward['delivery'], JText::_('DATE_FORMAT_LC3'))) . '</div>';
                }
            }
            ?>
                <?php 
        }
        ?>

            </div>

        <?php 
    }
    ?>
defined('_JEXEC') or die;
jimport('Prism.init');
jimport('Crowdfunding.init');
$moduleclassSfx = htmlspecialchars($params->get('moduleclass_sfx'));
$option = $app->input->get('option');
$view = $app->input->get('view');
// If option is not 'com_crowdfunding' and view is not 'details',
// do not display anything.
if (strcmp($option, 'com_crowdfunding') !== 0 or strcmp($view, 'details') !== 0) {
    echo JText::_('MOD_CROWDFUNDINGINFO_ERROR_INVALID_VIEW');
    return;
}
$projectId = $app->input->getInt('id');
if (!$projectId) {
    echo JText::_('MOD_CROWDFUNDINGINFO_ERROR_INVALID_PROJECT');
    return;
}
$componentParams = JComponentHelper::getParams('com_crowdfunding');
/** @var  $componentParams Joomla\Registry\Registry */
$container = Prism\Container::getContainer();
/** @var  $container Joomla\DI\Container */
$containerHelper = new Crowdfunding\Container\Helper();
// Get Project object from the container.
$project = $containerHelper->fetchProject($container, $projectId);
$money = $containerHelper->fetchMoneyFormatter($container, $componentParams);
$goal = $money->setAmount($project->getGoal())->formatCurrency();
$funded = $money->setAmount($project->getFunded())->formatCurrency();
// Validate end date.
$dateValidator = new Prism\Validator\Date($project->getFundingEnd());
$isValidEndDate = $dateValidator->isValid();
require JModuleHelper::getLayoutPath('mod_crowdfundinginfo', $params->get('layout', 'default'));
Ejemplo n.º 19
0
 /**
  * Prepare and sanitise the table prior to saving.
  *
  * @param CrowdfundingTableProject $table
  * @param array $data
  *
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  *
  * @since    1.6
  */
 protected function prepareTableData($table, $data)
 {
     $durationType = Joomla\Utilities\ArrayHelper::getValue($data, 'duration_type');
     $fundingEnd = Joomla\Utilities\ArrayHelper::getValue($data, 'funding_end');
     $fundingDays = Joomla\Utilities\ArrayHelper::getValue($data, 'funding_days', 0, 'int');
     switch ($durationType) {
         case 'days':
             $fundingDays = $fundingDays < 0 ? 0 : (int) $fundingDays;
             $table->set('funding_days', $fundingDays);
             // Calculate end date
             $startingDateValidator = new Prism\Validator\Date($table->get('funding_start'));
             if ($startingDateValidator->isValid()) {
                 $fundingStartDate = new Crowdfunding\Date($table->get('funding_start'));
                 $fundingEndDate = $fundingStartDate->calculateEndDate($table->get('funding_days'));
                 $table->set('funding_end', $fundingEndDate->format(Prism\Constants::DATE_FORMAT_SQL_DATE));
             } else {
                 $table->set('funding_end', Prism\Constants::DATE_DEFAULT_SQL_DATE);
             }
             break;
         case 'date':
             $fundingEnd = CrowdfundingHelper::convertToSql($fundingEnd);
             $dateValidator = new Prism\Validator\Date($fundingEnd);
             if (!$dateValidator->isValid()) {
                 throw new RuntimeException(JText::_('COM_CROWDFUNDING_ERROR_INVALID_DATE'));
             }
             $date = new JDate($fundingEnd);
             $table->set('funding_days', 0);
             $table->set('funding_end', $date->toSql());
             break;
         default:
             $table->set('funding_days', 0);
             $table->set('funding_end', Prism\Constants::DATE_DEFAULT_SQL_DATE);
             break;
     }
 }
Ejemplo n.º 20
0
 /**
  * Prepare and sanitise the table prior to saving.
  *
  * @param CrowdfundingTableProject $table
  * @param array $data
  *
  * @throws RuntimeException
  *
  * @since    1.6
  */
 protected function prepareTable(&$table, $data)
 {
     $durationType = Joomla\Utilities\ArrayHelper::getValue($data, "duration_type");
     $fundingEnd = Joomla\Utilities\ArrayHelper::getValue($data, "funding_end");
     $fundingDays = Joomla\Utilities\ArrayHelper::getValue($data, "funding_days");
     switch ($durationType) {
         case "days":
             $table->funding_days = $fundingDays < 0 ? 0 : (int) $fundingDays;
             // Calculate end date
             if (!empty($table->funding_start)) {
                 $fundingStartDate = new Crowdfunding\Date($table->funding_start);
                 $fundingEndDate = $fundingStartDate->calculateEndDate($table->funding_days);
                 $table->funding_end = $fundingEndDate->format("Y-m-d");
             } else {
                 $table->funding_end = "0000-00-00";
             }
             break;
         case "date":
             $dateValidator = new Prism\Validator\Date($fundingEnd);
             if (!$dateValidator->isValid($fundingEnd)) {
                 throw new RuntimeException(JText::_("COM_CROWDFUNDING_ERROR_INVALID_DATE"));
             }
             $date = new JDate($fundingEnd);
             $table->funding_days = 0;
             $table->funding_end = $date->toSql();
             break;
         default:
             $table->funding_days = 0;
             $table->funding_end = "0000-00-00";
             break;
     }
 }
Ejemplo n.º 21
0
 /**
  * Prepare and sanitise the table prior to saving.
  *
  * @param CrowdfundingTableProject $table
  * @param array $data
  *
  * @throws RuntimeException
  *
  * @since    1.6
  */
 protected function prepareTableData($table, $data)
 {
     $durationType = Joomla\Utilities\ArrayHelper::getValue($data, 'duration_type');
     $fundingEnd = Joomla\Utilities\ArrayHelper::getValue($data, 'funding_end');
     $fundingDays = Joomla\Utilities\ArrayHelper::getValue($data, 'funding_days');
     switch ($durationType) {
         case 'days':
             $table->funding_days = $fundingDays < 0 ? 0 : (int) $fundingDays;
             // Calculate end date
             if ((int) $table->funding_start > 0) {
                 $fundingStartDate = new Crowdfunding\Date($table->funding_start);
                 $fundingEndDate = $fundingStartDate->calculateEndDate($table->funding_days);
                 $table->funding_end = $fundingEndDate->format('Y-m-d');
             } else {
                 $table->funding_end = '0000-00-00';
             }
             break;
         case 'date':
             $dateValidator = new Prism\Validator\Date($fundingEnd);
             if (!$dateValidator->isValid($fundingEnd)) {
                 throw new RuntimeException(JText::_('COM_CROWDFUNDING_ERROR_INVALID_DATE'));
             }
             $date = new JDate($fundingEnd);
             $table->funding_days = 0;
             $table->funding_end = $date->toSql();
             break;
         default:
             $table->funding_days = 0;
             $table->funding_end = '0000-00-00';
             break;
     }
 }
Ejemplo n.º 22
0
 /**
  * @param string       $endDate
  * @param int       $days
  * @param string $format
  *
  * @return string
  */
 public static function duration($endDate, $days, $format = 'd F Y')
 {
     $output = '';
     $endDateValidator = new Prism\Validator\Date($endDate);
     if ((int) $days > 0) {
         $output .= JText::sprintf('COM_CROWDFUNDING_DURATION_DAYS', (int) $days);
         // Display end date
         if ($endDateValidator->isValid()) {
             $output .= '<div class="info-mini">';
             $output .= JText::sprintf('COM_CROWDFUNDING_DURATION_END_DATE', JHtml::_('date', $endDate, $format));
             $output .= '</div>';
         }
     } elseif ($endDateValidator->isValid()) {
         $output .= JText::sprintf('COM_CROWDFUNDING_DURATION_END_DATE', JHtml::_('date', $endDate, $format));
     } else {
         $output .= '---';
     }
     return $output;
 }
 /**
  * Save data into the DB
  *
  * @param array $data   The data of item
  *
  * @throws \InvalidArgumentException
  * @throws \RuntimeException
  * @throws \UnexpectedValueException
  * @throws \OutOfBoundsException
  *
  * @return    int      Item ID
  */
 public function save($data)
 {
     $context = $this->option . '.' . $this->name;
     $id = Joomla\Utilities\ArrayHelper::getValue($data, 'id', 0, 'int');
     $txnStatus = Joomla\Utilities\ArrayHelper::getValue($data, 'txn_status');
     $txnDate = Joomla\Utilities\ArrayHelper::getValue($data, 'txn_date');
     // Parse the amount.
     $params = JComponentHelper::getParams($this->option);
     /** @var  $params Joomla\Registry\Registry */
     $moneyFormatter = $this->getMoneyFormatter($params);
     $amount = Joomla\Utilities\ArrayHelper::getValue($data, 'txn_amount');
     $amount = $moneyFormatter->setAmount($amount)->parse();
     $cleanData = array('txn_amount' => $amount, 'txn_currency' => Joomla\Utilities\ArrayHelper::getValue($data, 'txn_currency'), 'txn_status' => $txnStatus, 'txn_date' => $txnDate, 'txn_id' => Joomla\Utilities\ArrayHelper::getValue($data, 'txn_id'), 'parent_txn_id' => Joomla\Utilities\ArrayHelper::getValue($data, 'parent_txn_id'), 'service_provider' => Joomla\Utilities\ArrayHelper::getValue($data, 'service_provider'), 'service_alias' => Joomla\Utilities\ArrayHelper::getValue($data, 'service_alias'), 'investor_id' => Joomla\Utilities\ArrayHelper::getValue($data, 'investor_id', 0, 'int'), 'receiver_id' => Joomla\Utilities\ArrayHelper::getValue($data, 'receiver_id', 0, 'int'), 'project_id' => Joomla\Utilities\ArrayHelper::getValue($data, 'project_id', 0, 'int'), 'reward_id' => Joomla\Utilities\ArrayHelper::getValue($data, 'reward_id', 0, 'int'));
     $dateValidator = new Prism\Validator\Date($txnDate);
     if (!$dateValidator->isValid()) {
         $timezone = JFactory::getApplication()->get('offset');
         $currentDate = new JDate('now', $timezone);
         $cleanData['txn_date'] = $currentDate->toSql();
     }
     $transaction = new Crowdfunding\Transaction\Transaction(JFactory::getDbo());
     $transaction->load($id);
     // Check for changed transaction status and trigger the event onTransactionChangeState.
     $oldStatus = $transaction->getStatus();
     if ($oldStatus !== null and $oldStatus !== '' and strcmp($oldStatus, $txnStatus) !== 0) {
         $this->triggerOnTransactionChangeState($transaction, $oldStatus, $txnStatus);
     }
     $options = array('old_status' => $oldStatus, 'new_status' => $txnStatus);
     // Bind data.
     $transaction->bind($cleanData);
     // Process transaction.
     $transactionManager = new Crowdfunding\Transaction\TransactionManager(JFactory::getDbo());
     $transactionManager->setTransaction($transaction);
     $transactionManager->process($context, $options);
     return $transaction->getId();
 }
Ejemplo n.º 24
0
 protected function prepareFundingDurationType()
 {
     $this->fundingDuration = $this->params->get("project_funding_duration");
     switch ($this->fundingDuration) {
         case "days":
             // Only days type is enabled
             $this->checkedDays = 'checked="checked"';
             break;
         case "date":
             // Only date type is enabled
             $this->checkedDate = 'checked="checked"';
             break;
         default:
             // Both ( days and date ) types are enabled
             $this->checkedDays = 0;
             $this->checkedDate = "";
             $dateValidator = new Prism\Validator\Date($this->item->funding_end);
             if (!empty($this->item->funding_days)) {
                 $this->checkedDays = 'checked="checked"';
                 $this->checkedDate = '';
             } elseif ($dateValidator->isValid($this->item->funding_end)) {
                 $this->checkedDays = '';
                 $this->checkedDate = 'checked="checked"';
             }
             // If missing both, select days.
             if (!$this->checkedDays and !$this->checkedDate) {
                 $this->checkedDays = 'checked="checked"';
             }
             break;
     }
 }
Ejemplo n.º 25
0
 protected function prepareBirthday($data)
 {
     $birthdayDay = Joomla\String\String::trim(Joomla\Utilities\ArrayHelper::getValue($data["birthday"], "day"));
     $birthdayMonth = Joomla\String\String::trim(Joomla\Utilities\ArrayHelper::getValue($data["birthday"], "month"));
     $birthdayYear = Joomla\String\String::trim(Joomla\Utilities\ArrayHelper::getValue($data["birthday"], "year"));
     if (!$birthdayDay) {
         $birthdayDay = "00";
     }
     if (!$birthdayMonth) {
         $birthdayMonth = "00";
     }
     if (!$birthdayYear) {
         $birthdayYear = "0000";
     }
     $birthday = $birthdayYear . "-" . $birthdayMonth . "-" . $birthdayDay;
     $date = new Prism\Validator\Date($birthday);
     if (!$date->isValid()) {
         $birthday = "0000-00-00";
     }
     return $birthday;
 }
Ejemplo n.º 26
0
 /**
  * This method calculate start date and validate funding period.
  *
  * @param CrowdfundingTableProject $table
  *
  * @throws Exception
  */
 protected function prepareTable(&$table)
 {
     // Calculate start and end date if the user publish a project for first time.
     $fundingStartDate = new Prism\Validator\Date($table->funding_start);
     if (!$fundingStartDate->isValid($table->funding_start)) {
         $fundingStart = new JDate();
         $table->funding_start = $fundingStart->toSql();
         // If funding type is "days", calculate end date.
         if ($table->get("funding_days")) {
             $fundingStartDate = new Crowdfunding\Date($table->get("funding_start"));
             $endDate = $fundingStartDate->calculateEndDate($table->get("funding_days"));
             $table->set("funding_end", $endDate->format("Y-m-d"));
         }
     }
     // Get parameters
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     $params = $app->getParams();
     /** @var  $params Joomla\Registry\Registry */
     $minDays = $params->get("project_days_minimum", 15);
     $maxDays = $params->get("project_days_maximum");
     // If there is an ending date, validate the period.
     $fundingEndDate = new Prism\Validator\Date($table->get("funding_end"));
     if ($fundingEndDate->isValid()) {
         $validatorPeriod = new Crowdfunding\Validator\Project\Period($table->get("funding_start"), $table->get("funding_end"), $minDays, $maxDays);
         if (!$validatorPeriod->isValid()) {
             if (!empty($maxDays)) {
                 throw new RuntimeException(JText::sprintf("COM_CROWDFUNDING_ERROR_INVALID_ENDING_DATE_MIN_MAX_DAYS", $minDays, $maxDays));
             } else {
                 throw new RuntimeException(JText::sprintf("COM_CROWDFUNDING_ERROR_INVALID_ENDING_DATE_MIN_DAYS", $minDays));
             }
         }
     }
 }
Ejemplo n.º 27
0
<?php

/**
 * @package      Crowdfunding
 * @subpackage   Components
 * @author       Todor Iliev
 * @copyright    Copyright (C) 2016 Todor Iliev <*****@*****.**>. All rights reserved.
 * @license      GNU General Public License version 3 or later; see LICENSE.txt
 */
// no direct access
defined('_JEXEC') or die;
foreach ($this->items as $i => $item) {
    $dateValidator = new Prism\Validator\Date($item->delivery);
    $ordering = $this->listOrder === 'a.ordering';
    ?>
    <tr class="row<?php 
    echo $i % 2;
    ?>
">
        <td class="has-context">
            <a href="javascript: void(0);" data-id="<?php 
    echo (int) $item->id;
    ?>
" data-title="<?php 
    echo $this->escape($item->title);
    ?>
" class="js-reward-element">
                <?php 
    echo $this->escape($item->title);
    ?>
            </a>
 /**
  * Validate user data that comes from step "Funding".
  *
  * @param array $data
  * @param Joomla\Registry\Registry $params
  *
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  *
  * @return array
  */
 protected function validateStepFunding(&$data, &$params)
 {
     $result = array('success' => false, 'message' => '');
     // Validate minimum and maximum amount.
     if ($this->params->get('validate_amount', 1)) {
         $goal = Joomla\Utilities\ArrayHelper::getValue($data, 'goal', 0, 'float');
         $minAmount = (double) $params->get('project_amount_minimum', 100);
         $maxAmount = (double) $params->get('project_amount_maximum');
         // Verify minimum amount
         if ($goal < $minAmount) {
             $result['message'] = JText::_('PLG_CONTENT_CROWDFUNDINGVALIDATOR_ERROR_INVALID_GOAL');
             return $result;
         }
         // Verify maximum amount
         if ($maxAmount > 0 and $goal > $maxAmount) {
             $result['message'] = JText::_('PLG_CONTENT_CROWDFUNDINGVALIDATOR_ERROR_INVALID_GOAL');
             return $result;
         }
     }
     // Validate funding duration - days or date.
     if ($this->params->get('validate_funding_duration', 1)) {
         $minDays = (int) $params->get('project_days_minimum', 15);
         $maxDays = (int) $params->get('project_days_maximum', 0);
         $fundingType = Joomla\Utilities\ArrayHelper::getValue($data, 'funding_duration_type');
         // Validate funding type 'days'
         if (strcmp('days', $fundingType) === 0) {
             $days = Joomla\Utilities\ArrayHelper::getValue($data, 'funding_days', 0, 'integer');
             if ($days < $minDays) {
                 $result['message'] = JText::_('PLG_CONTENT_CROWDFUNDINGVALIDATOR_ERROR_INVALID_DAYS');
                 return $result;
             }
             if ($maxDays > 0 and $days > $maxDays) {
                 $result['message'] = JText::_('PLG_CONTENT_CROWDFUNDINGVALIDATOR_ERROR_INVALID_DAYS');
                 return $result;
             }
         } else {
             // Validate funding type 'date'
             $fundingEndDate = Joomla\Utilities\ArrayHelper::getValue($data, 'funding_end');
             $dateValidator = new Prism\Validator\Date($fundingEndDate);
             if (!$dateValidator->isValid()) {
                 $result['message'] = JText::_('PLG_CONTENT_CROWDFUNDINGVALIDATOR_ERROR_INVALID_DATE');
                 return $result;
             }
         }
     }
     // Validate funding duration when the projects is published and approved.
     if ($this->params->get('validate_funding_duration_approved', 1)) {
         // Get item and check it for active state ( published and approved ).
         $itemId = Joomla\Utilities\ArrayHelper::getValue($data, 'id');
         $userId = JFactory::getUser()->get('id');
         $item = $this->getItem($itemId, $userId);
         // Validate date if user want to edit date, while the project is published.
         if ($item->published and $item->approved) {
             $minDays = (int) $params->get('project_days_minimum', 15);
             $maxDays = (int) $params->get('project_days_maximum', 0);
             $fundingType = Joomla\Utilities\ArrayHelper::getValue($data, 'funding_duration_type');
             // Generate funding end date from days.
             if (strcmp('days', $fundingType) === 0) {
                 // Get funding days.
                 $days = Joomla\Utilities\ArrayHelper::getValue($data, 'funding_days', 0, 'integer');
                 $fundingStartDate = new Crowdfunding\Date($item->funding_start);
                 $endDate = $fundingStartDate->calculateEndDate($days);
                 $fundingEndDate = $endDate->format('Y-m-d');
             } else {
                 // Get funding end date from request
                 $fundingEndDate = Joomla\Utilities\ArrayHelper::getValue($data, 'funding_end');
             }
             // Validate the period.
             $dateValidator = new Crowdfunding\Validator\Project\Period($item->funding_start, $fundingEndDate, $minDays, $maxDays);
             if (!$dateValidator->isValid()) {
                 $result['message'] = $maxDays > 0 ? JText::sprintf('PLG_CONTENT_CROWDFUNDINGVALIDATOR_ERROR_INVALID_ENDING_DATE_MIN_MAX_DAYS', $minDays, $maxDays) : JText::sprintf('PLG_CONTENT_CROWDFUNDINGVALIDATOR_ERROR_INVALID_ENDING_DATE_MIN_DAYS', $minDays);
                 return $result;
             }
         }
     }
     // Validations completed successfully.
     $result = array('success' => true);
     return $result;
 }
Ejemplo n.º 29
0
 /**
  * Method to change the published state of one or more records.
  *
  * @param   array   &$pks  A list of the primary keys to change.
  * @param   integer $value The value of the published state.
  *
  * @throws Exception
  *
  * @return  boolean  True on success.
  *
  * @since   12.2
  */
 public function publish(&$pks, $value = 0)
 {
     $table = $this->getTable();
     /** @var $table CrowdfundingTableProject */
     $pks = (array) $pks;
     // Access checks.
     foreach ($pks as $pk) {
         $table->reset();
         if ($table->load($pk)) {
             if ($value == Prism\Constants::PUBLISHED) {
                 // Publish a project
                 // Validate funding period
                 $fundingEndValidator = new Prism\Validator\Date($table->funding_end);
                 if (!$table->funding_days and !$fundingEndValidator->isValid()) {
                     throw new RuntimeException(JText::_("COM_CROWDFUNDING_ERROR_INVALID_DURATION_PERIOD"));
                 }
                 // Calculate starting date if the user publish a project for first time.
                 $fundingStartValidator = new Prism\Validator\Date($table->funding_start);
                 if (!$fundingStartValidator->isValid()) {
                     $fundingStart = new JDate();
                     $table->funding_start = $fundingStart->toSql();
                     // If funding type is "days", calculate end date.
                     if (!empty($table->funding_days)) {
                         $fundingStartDate = new Crowdfunding\Date($table->funding_start);
                         $fundingEndDate = $fundingStartDate->calculateEndDate($table->funding_days);
                         $table->funding_end = $fundingEndDate->toSql();
                     }
                 }
                 // Validate the period if the funding type is days
                 $params = JComponentHelper::getParams($this->option);
                 /** @var  $params Joomla\Registry\Registry */
                 $minDays = $params->get("project_days_minimum", 15);
                 $maxDays = $params->get("project_days_maximum");
                 $fundingStartValidator = new Prism\Validator\Date($table->funding_start);
                 if ($fundingStartValidator->isValid()) {
                     $dateValidator = new Crowdfunding\Validator\Project\Period($table->funding_start, $table->funding_end, $minDays, $maxDays);
                     if (!$dateValidator->isValid()) {
                         if (!empty($maxDays)) {
                             throw new RuntimeException(JText::sprintf("COM_CROWDFUNDING_ERROR_INVALID_ENDING_DATE_MIN_MAX_DAYS", $minDays, $maxDays));
                         } else {
                             throw new RuntimeException(JText::sprintf("COM_CROWDFUNDING_ERROR_INVALID_ENDING_DATE_MIN_DAYS", $minDays));
                         }
                     }
                 }
                 $table->set("published", Prism\Constants::PUBLISHED);
                 $table->store();
             } else {
                 // Set other states - unpublished, trash,...
                 $table->publish(array($pk), $value);
             }
         }
     }
     // Trigger change state event
     $context = $this->option . '.' . $this->name;
     // Include the content plugins for the change of state event.
     JPluginHelper::importPlugin('content');
     // Trigger the onContentChangeState event.
     $dispatcher = JEventDispatcher::getInstance();
     $result = $dispatcher->trigger($this->event_change_state, array($context, $pks, $value));
     if (in_array(false, $result, true)) {
         throw new Exception(JText::_("COM_CROWDFUNDING_ERROR_CHANGE_STATE"));
     }
     // Clear the component's cache
     $this->cleanCache();
 }
Ejemplo n.º 30
0
 * @subpackage   Components
 * @author       Todor Iliev
 * @copyright    Copyright (C) 2015 Todor Iliev <*****@*****.**>. All rights reserved.
 * @license      http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
// no direct access
defined('_JEXEC') or die;
// Prepare availability number
$availability = Joomla\Utilities\ArrayHelper::getValue($this->formItem, "number", 0);
if (!$availability) {
    $availability = "";
}
// Prepare delivery date
$deliveryDate = Joomla\Utilities\ArrayHelper::getValue($this->formItem, "delivery", null);
if (!empty($deliveryDate)) {
    $dateValidator = new Prism\Validator\Date($deliveryDate);
    if (!$dateValidator->isValid()) {
        $deliveryDate = null;
    } else {
        // Formatting date
        $date = new JDate($deliveryDate);
        $deliveryDate = $date->format($this->dateFormat);
    }
}
?>
<div class="row reward-form" id="reward_box_<?php 
echo $this->formIndex;
?>
">
    <div class="col-md-2 reward-form-help"><?php 
echo JText::_("COM_CROWDFUNDING_REWARDS_REWARD");