Spade

Mini Shell

Directory:~$ /proc/self/root/home/lmsyaran/public_html/css/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ //proc/self/root/home/lmsyaran/public_html/css/controllers.zip

PK3��[�d�	�	suggestions.json.phpnu�[���<?php
/**
 * @package     Joomla.Site
 * @subpackage  com_finder
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('_JEXEC') or die;

/**
 * Suggestions JSON controller for Finder.
 *
 * @since  2.5
 */
class FinderControllerSuggestions extends JControllerLegacy
{
	/**
	 * Method to find search query suggestions. Uses jQuery and
autocompleter.js
	 *
	 * @return  void
	 *
	 * @since   3.4
	 */
	public function suggest()
	{
		/** @var \Joomla\CMS\Application\CMSApplication $app */
		$app = JFactory::getApplication();
		$app->mimeType = 'application/json';

		// Ensure caching is disabled as it depends on the query param in the
model
		$app->allowCache(false);

		$suggestions = $this->getSuggestions();

		// Send the response.
		$app->setHeader('Content-Type', $app->mimeType . ';
charset=' . $app->charSet);
		$app->sendHeaders();
		echo '{ "suggestions": ' . json_encode($suggestions)
. ' }';
		$app->close();
	}

	/**
	 * Method to find search query suggestions. Uses Mootools and
autocompleter.js
	 *
	 * @param   boolean  $cachable   If true, the view output will be cached
	 * @param   array    $urlparams  An array of safe URL parameters and their
variable types, for valid values see {@link JFilterInput::clean()}.
	 *
	 * @return  void
	 *
	 * @since   2.5
	 * @deprecated 3.4
	 */
	public function display($cachable = false, $urlparams = false)
	{
		/** @var \Joomla\CMS\Application\CMSApplication $app */
		$app = JFactory::getApplication();
		$app->mimeType = 'application/json';

		// Ensure caching is disabled as it depends on the query param in the
model
		$app->allowCache(false);

		$suggestions = $this->getSuggestions();

		// Send the response.
		$app->setHeader('Content-Type', $app->mimeType . ';
charset=' . $app->charSet);
		$app->sendHeaders();
		echo json_encode($suggestions);
		$app->close();
	}

	/**
	 * Method to retrieve the data from the database
	 *
	 * @return  array  The suggested words
	 *
	 * @since   3.4
	 */
	protected function getSuggestions()
	{
		$return = array();

		$params = JComponentHelper::getParams('com_finder');

		if ($params->get('show_autosuggest', 1))
		{
			// Get the suggestions.
			$model = $this->getModel('Suggestions',
'FinderModel');
			$return = $model->getItems();
		}

		// Check the data.
		if (empty($return))
		{
			$return = array();
		}

		return $return;
	}
}
PK
��[ߏfXXaccount.phpnu�[���<?php
/* @package Joomla
 * @copyright Copyright (C) Open Source Matters. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * @extension Phoca Extension
 * @copyright Copyright (C) Jan Pavelka www.phoca.cz
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
defined('_JEXEC') or die();

class PhocaCartControllerAccount extends JControllerForm
{

	public function saveprofile()
	{
		// Check for request forgeries.
		JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));

		$app	= JFactory::getApplication();
		$model	= $this->getModel('Profile', 'UsersModel');
		$user	= PhocacartUser::getUser();
		$userId	= (int) $user->get('id');

		// Get the user data.
		$data 		= $app->input->post->get('jform', array(),
'array');
		$returnUrl 	= $app->input->post->get('return',
'', 'string');


		$lang = JFactory::getLanguage();
		//$lang->load('com_users.sys');
		$lang->load('com_users');

		// PHOCAEDIT
		jimport('joomla.application.component.model');
		//JLoader::import('user',JPATH_SITE.'/components/com_users/models');
		JModelLegacy::addIncludePath(JPATH_SITE.'/components/com_users/models');
		$model = JModelLegacy::getInstance( 'Profile',
'UsersModel' );
		$this->data	  = $model->getData();
		$loadformpath = JPATH_SITE.'/components/com_users/models';
		JForm::addFormPath($loadformpath.'/forms');
		JForm::addFieldPath($loadformpath.'/fields');
		//$this->form	  = $model->getForm();


		// Force the ID to this user.
		$data['id'] = $userId;

		// Validate the posted data.
		$form = $model->getForm();

		if (!$form)
		{
			throw new Exception($model->getError(), 500);
			return false;
		}

		// Validate the posted data.
		$data = $model->validate($form, $data);

		// Check for errors.
		if ($data === false)
		{
			// Get the validation messages.
			$errors	= $model->getErrors();

			// Push up to three validation messages out to the user.
			for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++)
			{
				if ($errors[$i] instanceof Exception)
				{
					$app->enqueueMessage($errors[$i]->getMessage(),
'warning');
				}
				else
				{
					$app->enqueueMessage($errors[$i], 'warning');
				}
			}

			// Save the data in the session.
			$app->setUserState('com_users.edit.profile.data', $data);

			// Redirect back to the edit screen.
			$userId = (int)
$app->getUserState('com_users.edit.profile.id');
			$this->setRedirect(base64_decode($returnUrl));
			return false;
		}

		// Attempt to save the data.
		$return	= $model->save($data);

		// Check for errors.
		if ($return === false)
		{
			// Save the data in the session.
			$app->setUserState('com_users.edit.profile.data', $data);

			// Redirect back to the edit screen.
			$userId = (int)
$app->getUserState('com_users.edit.profile.id');
			$this->setMessage(JText::sprintf('COM_USERS_PROFILE_SAVE_FAILED',
$model->getError()), 'warning');
			$this->setRedirect(base64_decode($returnUrl));
			return false;
		}

		// Redirect the user and adjust session state based on the chosen task.
		switch ($this->getTask())
		{
			case 'apply':
				// Check out the profile.
				$app->setUserState('com_users.edit.profile.id', $return);
				$model->checkout($return);

				// Redirect back to the edit screen.
				$this->setMessage(JText::_('COM_USERS_PROFILE_SAVE_SUCCESS'));
				$this->setRedirect(base64_decode($returnUrl));
				break;

			default:
				// Check in the profile.
				$userId = (int)
$app->getUserState('com_users.edit.profile.id');
				if ($userId)
				{
					$model->checkin($userId);
				}

				// Clear the profile id from the session.
				$app->setUserState('com_users.edit.profile.id', null);

				// Redirect to the list screen.
				$this->setMessage(JText::_('COM_USERS_PROFILE_SAVE_SUCCESS'));
				$this->setRedirect(base64_decode($returnUrl));
				break;
		}

		// Flush the data from the session.
		$app->setUserState('com_users.edit.profile.data', null);
	}

}
?>
PK
��[�2����checkout.json.phpnu�[���<?php
/* @package Joomla
 * @copyright Copyright (C) Open Source Matters. All rights reserved.
 * @license   http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * @extension Phoca Extension
 * @copyright Copyright (C) Jan Pavelka www.phoca.cz
 * @license   http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
defined('_JEXEC') or die();

class PhocaCartControllerCheckout extends JControllerForm
{
    // Set Region
    public function setregion() {

        if (!JSession::checkToken('request')) {
            $response = array(
                'status' => '0',
                'error' => '<div class="alert
alert-danger">' . JText::_('JINVALID_TOKEN') .
'</div>');
            echo json_encode($response);
            exit;
        }

        $app = JFactory::getApplication();
        $id  = $app->input->get('countryid', 0,
'int');

        //$model = $this->getModel('checkout');
        //$options = $model->getRegions($id);
        $options = PhocacartRegion::getRegionsByCountry($id);
        $o       = '';
        if (!empty($options)) {

            $o .= '<option value="">-&nbsp;'
. JText::_('COM_PHOCACART_SELECT_REGION') .
'&nbsp;-</option>';
            foreach ($options as $k => $v) {
                $o .= '<option value="' . $v->id .
'">' . htmlspecialchars($v->title) .
'</option>';
            }
        }
        $response = array(
            'status' => '1',
            'content' => $o);
        echo json_encode($response);
        exit;

    }

    // Change Data Box
    // a) Price Box
    // b) Stock Box
    // c) ID Box (SKU, EAN, ...)

	// We use common "data" for different parts (price box, stock
box, id box) so we need replace -data- class to specific for each case
	// e.g. -data- ==> -price-, -data- ==> -stock-, ... (not used in JS
but it can be used there)

    function changedatabox($tpl = null) {

        if (!JSession::checkToken('request')) {
            $response = array(
                'status' => '0',
                'error' => '<span
class="ph-result-txt ph-error-txt">' .
JText::_('JINVALID_TOKEN') . '</span>');
            echo json_encode($response);
            return;
        }

        $paramsC              = PhocacartUtils::getComponentParameters();
        $dynamic_change_price =
$paramsC->get('dynamic_change_price', 0);
        $dynamic_change_stock =
$paramsC->get('dynamic_change_stock', 0);
        $dynamic_change_id    =
$paramsC->get('dynamic_change_id', 0);
        $dynamic_change_image   =
$paramsC->get('dynamic_change_image', 0);

        $hide_add_to_cart_stock   =
$paramsC->get('hide_add_to_cart_stock', 0);
        $hide_add_to_cart_zero_price   =
$paramsC->get('hide_add_to_cart_zero_price', 0);



        $app       = JFactory::getApplication();
        $s         = PhocacartRenderStyle::getStyles();
        $attribute = $app->input->get('attribute',
'', 'array');
        $id        = $app->input->get('id', 0,
'int');
        $class     = $app->input->get('class',
'', 'string');
        $typeView  = $app->input->get('typeview',
'', 'string');

        $oA = array();

        // Sanitanize data and do the same level for all attributes:
        $aA = PhocacartAttribute::sanitizeAttributeArray($attribute);



        if ((int)$id > 0) {

            $price = new PhocacartPrice();
            $item  = PhocacartProduct::getProduct((int)$id);// We
don't need catid
            //$priceO = array();

            if (!empty($item)) {

                // ==================
                // PRICE
                $priceP = $price->getPriceItems($item->price,
$item->taxid, $item->taxrate, $item->taxcalculationtype,
$item->taxtitle, 0, '', 1, 1, $item->group_price);
                $price->getPriceItemsChangedByAttributes($priceP, $aA,
$price, $item, 1);


                $price->correctMinusPrice($priceP);


                if ($dynamic_change_price == 1) {


                    $d               = array();
                    $d['type']       = $item->type;
                    $d['s']          = $s;
                    $d['class']      =
str_replace('-data-', '-price-', $class);// change
common "data" class to specific one
                    $d['zero_price'] = 1;// Apply zero price if
possible
                    // Original Price
                   
$d['priceitemsorig']['bruttoformat'] = '';
                    if (isset($item->price_original) &&
$item->price_original != '' &&
(int)$item->price_original > 0) {
                       
$d['priceitemsorig']['bruttoformat'] =
$price->getPriceFormat($item->price_original);
                    }

                    $d['priceitems'] = $priceP;
                    $d['product_id'] = (int)$item->id;
                    $d['typeview']   = $typeView;


                    // Display discount price
                    // Move standard prices to new variable (product price
-> product discount)
                    $d['priceitemsdiscount'] =
$d['priceitems'];
                    $d['discount']           =
PhocacartDiscountProduct::getProductDiscountPrice($item->id,
$d['priceitemsdiscount']);

                    // Display cart discount (global discount) in product
views - under specific conditions only
                    // Move product discount prices to new variable
(product price -> product discount -> product discount cart)
                    $d['priceitemsdiscountcart'] =
$d['priceitemsdiscount'];
                    $d['discountcart']           =
PhocacartDiscountCart::getCartDiscountPriceForProduct($item->id,
$item->catid, $d['priceitemsdiscountcart']);

                    // Render the layout
                    $layoutP     = new
JLayoutFile('product_price', null, array('component'
=> 'com_phocacart'));

                    $oA['price'] = $layoutP->render($d);
                    $oA['priceitems'] =
$d['priceitems'];
                }


                // ==================
                // STOCK
                $stockStatus = array();
                $stock       =
PhocacartStock::getStockItemsChangedByAttributes($stockStatus, $aA, $item,
1);

                if ($dynamic_change_stock == 1) {


                    $o = '';
                    if ($stockStatus['stock_status'] ||
$stockStatus['stock_count'] !== false) {
                        $layoutS                  = new
JLayoutFile('product_stock', null, array('component'
=> 'com_phocacart'));
                        $d                        = array();
                        $d['s']                   = $s;
                        $d['class']               =
str_replace('-data-', '-stock-', $class);// change
common "data" class to specific one
                        $d['product_id']          = (int)$id;
                        $d['typeview']            = $typeView;
                        $d['stock_status_output'] =
PhocacartStock::getStockStatusOutput($stockStatus);

                        $oA['stock'] = $layoutS->render($d);

                        //$stock						=
(int)$stockStatus['stock_count'];// return stock anyway to enable
disable add to cart button if set
                    }
                    $oA['stockvalue'] = (int)$stock;
                }

                // ==================
                // ID (EAN, SKU, ...)
                if ($dynamic_change_id == 1) {
                    $id = new PhocacartId();
                    $id->getIdItemsChangedByAttributes($item, $aA, 1);

                    $d               = array();
                    $d['type']       = $item->type;
                    $d['s']          = $s;
                    $d['class']      =
str_replace('-data-', '-id-', $class);// change common
"data" class to specific one
                    $d['x']          = $item;
                    $d['product_id'] = (int)$item->id;
                    $d['typeview']   = $typeView;

                    // Render the layout
                    $layoutID = new JLayoutFile('product_id',
null, array('component' => 'com_phocacart'));
                    $oA['id'] = $layoutID->render($d);
                }

                // ================
                // IMAGE
                if ($dynamic_change_image == 2) {

                    $params = array();
                    $params['typeview'] = $typeView;

                    PhocacartImage::getImageItemsChangedByAttributes($item,
$aA, $params, 1);
                    $oA['image'] = $item->image;

                }


                // Should add to cart be displayed
                $oA['hideaddtocart'] = 1;
                $rights				= new PhocacartAccessRights();

                $priceA = isset($priceP['brutto']) ?
$priceP['brutto'] : 0;


                if($rights->canDisplayAddtocartAdvanced($item)
&& $rights->canDisplayAddtocartPrice($item, $priceA)  &&
$rights->canDisplayAddtocartStock($item, $stock)) {
		            $oA['hideaddtocart'] = 0;
                }

                $response = array(
                    'status' => '1',
                    'item' => $oA);
                echo json_encode($response);
                return;
            }
        }

        $response = array(
            'status' => '0',
            'items' => '');
        echo json_encode($response);
        return;


    }

    /*
    // Change pricebox
    function changepricebox($tpl = null) {

        if (!JSession::checkToken('request')) {
            $response = array(
                'status' => '0',
                'error' => '<span
class="ph-result-txt ph-error-txt">' .
JText::_('JINVALID_TOKEN') . '</span>');
            echo json_encode($response);
            return;
        }


        $app       = JFactory::getApplication();
        $s         = PhocacartRenderStyle::getStyles();
        $attribute = $app->input->get('attribute',
'', 'array');
        $id        = $app->input->get('id', 0,
'int');
        $class     = $app->input->get('class',
'', 'string');
        $typeView  = $app->input->get('typeview',
'', 'string');

        // Sanitanize data and do the same level for all attributes:
        $aA = PhocacartAttribute::sanitizeAttributeArray($attribute);




        if ((int)$id > 0) {
            $price = new PhocacartPrice();
            $item  = PhocacartProduct::getProduct((int)$id);// We
don't need catid
            //$priceO = array();

            if (!empty($item)) {

                $priceP = $price->getPriceItems($item->price,
$item->taxid, $item->taxrate, $item->taxcalculationtype,
$item->taxtitle, 0, '', 1, 1, $item->group_price);

                $price->getPriceItemsChangedByAttributes($priceP, $aA,
$price, $item, 1);


                $d               = array();
                $d['type']       = $item->type;
                $d['s']          = $s;
                $d['class']      = $class;
                $d['zero_price'] = 1;// Apply zero price if
possible
                // Original Price
                $d['priceitemsorig']['bruttoformat'] =
'';
                if (isset($item->price_original) &&
$item->price_original != '' &&
(int)$item->price_original > 0) {
                   
$d['priceitemsorig']['bruttoformat'] =
$price->getPriceFormat($item->price_original);
                }

                $d['priceitems'] = $priceP;
                $d['product_id'] = (int)$item->id;
                $d['typeview']   = $typeView;


                // Display discount price
                // Move standard prices to new variable (product price
-> product discount)
                $d['priceitemsdiscount'] =
$d['priceitems'];
                $d['discount']           =
PhocacartDiscountProduct::getProductDiscountPrice($item->id,
$d['priceitemsdiscount']);

                // Display cart discount (global discount) in product views
- under specific conditions only
                // Move product discount prices to new variable (product
price -> product discount -> product discount cart)
                $d['priceitemsdiscountcart'] =
$d['priceitemsdiscount'];
                $d['discountcart']           =
PhocacartDiscountCart::getCartDiscountPriceForProduct($item->id,
$item->catid, $d['priceitemsdiscountcart']);

                // Render the layout
                $layoutP = new JLayoutFile('product_price', null,
array('component' => 'com_phocacart'));
                //ob_start();
                $o = $layoutP->render($d);
                //$o = ob_get_contents();
                //ob_end_clean();


                $response = array(
                    'status' => '1',
                    'item' => $o);
                echo json_encode($response);
                return;
            }
        }

        $response = array(
            'status' => '0',
            'items' => '');
        echo json_encode($response);
        return;


    }

    // Change idbox (SKU, EAN, ...)
    function changeidbox($tpl = null) {

        if (!JSession::checkToken('request')) {
            $response = array(
                'status' => '0',
                'error' => '<span
class="ph-result-txt ph-error-txt">' .
JText::_('JINVALID_TOKEN') . '</span>');
            echo json_encode($response);
            return;
        }


        $app       = JFactory::getApplication();
        $s         = PhocacartRenderStyle::getStyles();
        $attribute = $app->input->get('attribute',
'', 'array');
        $id        = $app->input->get('id', 0,
'int');
        $class     = $app->input->get('class',
'', 'string');
        $typeView  = $app->input->get('typeview',
'', 'string');

        // Sanitanize data and do the same level for all attributes:
        $aA = PhocacartAttribute::sanitizeAttributeArray($attribute);

        if ((int)$id > 0) {
            $item = PhocacartProduct::getProduct((int)$id);// We don't
need catid
            if (!empty($item)) {

                $id = new PhocacartId();
                $id->getIdItemsChangedByAttributes($item, $aA, 1);

                $d               = array();
                $d['type']       = $item->type;
                $d['s']          = $s;
                $d['class']      = $class;
                $d['x']          = $item;
                $d['product_id'] = (int)$item->id;
                $d['typeview']   = $typeView;

                // Render the layout
                $layoutID = new JLayoutFile('product_id', null,
array('component' => 'com_phocacart'));
                //ob_start();
                $o = $layoutID->render($d);
                //$o = ob_get_contents();
                //ob_end_clean();

                $response = array(
                    'status' => '1',
                    'item' => $o);
                echo json_encode($response);
                return;
            }
        }

        $response = array(
            'status' => '0',
            'items' => '');
        echo json_encode($response);
        return;

    }

    // Change stockbox
    function changestockbox($tpl = null) {


        if (!JSession::checkToken('request')) {
            $response = array(
                'status' => '0',
                'error' => '<span
class="ph-result-txt ph-error-txt">' .
JText::_('JINVALID_TOKEN') . '</span>');
            echo json_encode($response);
            return;
        }

        $app       = JFactory::getApplication();
        $s         = PhocacartRenderStyle::getStyles();
        $attribute = $app->input->get('attribute',
'', 'array');
        $id        = $app->input->get('id', 0,
'int');
        $class     = $app->input->get('class',
'', 'string');
        $typeView  = $app->input->get('typeview',
'', 'string');

        // Sanitanize data and do the same level for all attributes:
        $aA = PhocacartAttribute::sanitizeAttributeArray($attribute);


        if ((int)$id > 0) {

            $item = PhocacartProduct::getProduct((int)$id);// We don't
need catid

            $stockStatus = array();
            $stock       =
PhocacartStock::getStockItemsChangedByAttributes($stockStatus, $aA, $item,
1);

            $o = '';
            if ($stockStatus['stock_status'] ||
$stockStatus['stock_count'] !== false) {
                $layoutS                  = new
JLayoutFile('product_stock', null, array('component'
=> 'com_phocacart'));
                $d                        = array();
                $d['s']                   = $s;
                $d['class']               = $class;
                $d['product_id']          = (int)$id;
                $d['typeview']            = $typeView;
                $d['stock_status_output'] =
PhocacartStock::getStockStatusOutput($stockStatus);

                $o = $layoutS->render($d);

                //$stock						=
(int)$stockStatus['stock_count'];// return stock anyway to enable
disable add to cart button if set
            }


            $response = array(
                'status' => '1',
                'stock' => (int)$stock,
                'item' => $o);
            echo json_encode($response);
            return;
        }


        $response = array(
            'status' => '0',
            'items' => '');
        echo json_encode($response);
        return;

    }*/

    // Add item to cart
    function add($tpl = null) {

        if (!JSession::checkToken('request')) {
            $response = array(
                'status' => '0',
                'error' => '<span
class="ph-result-txt ph-error-txt">' .
JText::_('JINVALID_TOKEN') . '</span>');
            echo json_encode($response);
            return;
        }


        $app                  = JFactory::getApplication();
        $s                    = PhocacartRenderStyle::getStyles();
        $item                 = array();
        $item['id']           =
$this->input->get('id', 0, 'int');
        $item['catid']        =
$this->input->get('catid', 0, 'int');
        $item['quantity']     =
$this->input->get('quantity', 0, 'int');
        $item['return']       =
$this->input->get('return', '',
'string');
        $item['attribute']    =
$this->input->get('attribute', array(), 'array');
        $item['checkoutview'] =
$this->input->get('checkoutview', 0, 'int');

        if ((int)$item['id'] > 0) {

            $itemP =
PhocacartProduct::getProduct((int)$item['id'],
$item['catid']);

            if (!empty($itemP)) {

                // Price (don't display add to cart when price is
zero)
                $price  = new PhocacartPrice();
                $priceP = $price->getPriceItems($itemP->price,
$itemP->taxid, $itemP->taxrate, $itemP->taxcalculationtype,
$itemP->taxtitle, 0, '', 1, 1, $itemP->group_price);
                $aA     =
PhocacartAttribute::sanitizeAttributeArray($item['attribute']);
                $price->getPriceItemsChangedByAttributes($priceP, $aA,
$price, $itemP, 1);
                $price->correctMinusPrice($priceP);
                $priceA = isset($priceP['brutto']) ?
$priceP['brutto'] : 0;

                // Stock (don't display add to cart when stock is
zero)
                $stockStatus = array();
                $stock       =
PhocacartStock::getStockItemsChangedByAttributes($stockStatus, $aA, $itemP,
1);

                $rights                                 = new
PhocacartAccessRights();
                $this->t['can_display_addtocart']       =
$rights->canDisplayAddtocartAdvanced($itemP);
                $this->t['can_display_addtocart_price'] =
$rights->canDisplayAddtocartPrice($itemP, $priceA);
                $this->t['can_display_addtocart_stock'] =
$rights->canDisplayAddtocartStock($itemP, $stock);

                $canDisplay = 1;
                if (!$this->t['can_display_addtocart']) {
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_NOT_ALLOWED_TO_ADD_PRODUCTS_TO_SHOPPING_CART'),
'error');
                    $canDisplay = 0;
                }

                if (!$this->t['can_display_addtocart_price'])
{
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_NOT_ALLOWED_TO_ADD_PRODUCTS_TO_SHOPPING_CART'),
'error');
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_PRICE_IS_ZERO'),
'error');
                    $canDisplay = 0;
                }

                if (!$this->t['can_display_addtocart_stock'])
{
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_NOT_ALLOWED_TO_ADD_PRODUCTS_TO_SHOPPING_CART'),
'error');
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_STOCK_IS_EMPTY'),
'error');
                    $canDisplay = 0;
                }

                if ($canDisplay == 0) {
                    $d             = array();
                    $d['s']        = $s;
                    $d['info_msg'] =
PhocacartRenderFront::renderMessageQueue();
                    $layoutPE      = new
JLayoutFile('popup_error', null, array('component'
=> 'com_phocacart'));
                    $oE            = $layoutPE->render($d);
                    $response      = array(
                        'status' => '0',
                        'popup' => $oE,
                        'error' => $d['info_msg']);
                    echo json_encode($response);
                    return;
                }

                $cart = new PhocacartCartRendercart();// is subclass of
PhocacartCart, so we can use only subclass

                // Get Phoca Cart Cart Module Parameters
                $module                                =
JModuleHelper::getModule('mod_phocacart_cart');
                $paramsM                               = new
JRegistry($module->params);
                $cart->params['display_image']         =
$paramsM->get('display_image', 0);
                $cart->params['display_checkout_link'] =
$paramsM->get('display_checkout_link', 1);

                $added = $cart->addItems((int)$item['id'],
(int)$item['catid'], (int)$item['quantity'],
$item['attribute']);

                if (!$added) {
                    $d             = array();
                    $d['s']        = $s;
                    $d['info_msg'] =
PhocacartRenderFront::renderMessageQueue();

                    $layoutPE = new JLayoutFile('popup_error',
null, array('component' => 'com_phocacart'));
                    $oE       = $layoutPE->render($d);
                    $response = array(
                        'status' => '0',
                        'popup' => $oE,
                        'error' => $d['info_msg']);
                    echo json_encode($response);
                    return;
                }

                //$catid	=
PhocacartProduct::getCategoryByProductId((int)$item['id']);
                $cart->setFullItems();

                $o = $o2 = '';
                // Content of the cart


                ob_start();
                echo $cart->render();
                $o = ob_get_contents();
                ob_end_clean();


                // Render the layout
                $d       = array();
                $d['s']  = $s;
                $layoutP = new JLayoutFile('popup_add_to_cart',
null, array('component' => 'com_phocacart'));

                $d['link_checkout'] =
JRoute::_(PhocacartRoute::getCheckoutRoute((int)$item['id'],
(int)$item['catid']));
                $d['link_continue'] = '';
                // It can happen that add to cart button will be e.g. in
module and when the module will be displayed on checkout site:
                // If yes and one item will be added per AJAX, we need to
refresh checkout site
                // If now and one item will be added per AJAX, everything
is OK, nothing needs to be refreshed
                $d['checkout_view'] =
(int)$item['checkoutview'];

                if ($added) {
                    $d['info_msg'] =
JText::_('COM_PHOCACART_PRODUCT_ADDED_TO_SHOPPING_CART');
                } else {
                    $d['info_msg'] =
JText::_('COM_PHOCACART_PRODUCT_NOT_ADDED_TO_SHOPPING_CART');
                }

                // Popup with info - Continue,Proceed to Checkout
                //ob_start();

                //$o2 = ob_get_contents();
                //ob_end_clean();


                $count  = $cart->getCartCountItems();
                $total  = "";
                $totalA = $cart->getCartTotalItems();
                if (!empty($totalA)) {
                     $layoutT = new JLayoutFile('cart_total',
null, array('component' => 'com_phocacart'));
                     $dT = array();
                     $dT['s']  = $s;
                     $dT['total'] = $totalA;

                     $total = $layoutT->render($dT);
                    //$total =
$price->getPriceFormat($totalA[0]['brutto']);
                    //$total = $totalA[0]['brutto'];
                }

                // Get the complete calculation total
                /*   $shippingEdit	= 0;
                   $shippingEdit	=
$app->input->get('shippingedit', 0, 'int');
                   $shippingId 	= $cart->getShippingId();
                   if (isset($shippingId) && (int)$shippingId >
0 && $shippingEdit == 0) {
                       $cart->addShippingCosts($shippingId);
                   }
                   // PAYMENT
                   $paymentEdit	= 0;
                   $paymentEdit	=
$app->input->get('paymentedit', 0, 'int');
                   $paymentMethod 	= $cart->getPaymentMethod();
                   if (isset($paymentMethod['id']) &&
(int)$paymentMethod['id'] > 0 && $paymentEdit == 0) {
                      
$cart->addPaymentCosts($paymentMethod['id']);
                   }*/
                $cart->roundTotalAmount();
                $d['total']    = $cart->getTotal();
                $d['products'] = $cart->getFullItems();
                $productKey    =
PhocacartProduct::getProductKey((int)$item['id'],
$item['attribute']);


                $d['product'] = array();
                if (isset($d['products'][0][$productKey])) {
                    $d['product'] =
$d['products'][0][$productKey];
                }

                $d['product']['current_added']     =
$added;
                $d['product']['current_id']        =
(int)$item['id'];
                $d['product']['current_catid']     =
(int)$item['catid'];
                $d['product']['current_quantity']  =
(int)$item['quantity'];
                $d['product']['current_attribute'] =
$item['attribute'];

                $o2 = $layoutP->render($d);

                $response = array(
                    'status' => '1',
                    'item' => $o,
                    'popup' => $o2,
                    'count' => $count,
                    'total' => $total);

                echo json_encode($response);
                return;

            } else {
               
$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_NOT_ADDED_TO_SHOPPING_CART'),
'error');
               
$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_NOT_FOUND'),
'error');
            }
        } else {
           
$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_NOT_ADDED_TO_SHOPPING_CART'),
'error');
           
$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_NOT_SELECTED'),
'error');
        }

        $d             = array();
        $d['s']        = $s;
        $d['info_msg'] =
PhocacartRenderFront::renderMessageQueue();

        $layoutPE = new JLayoutFile('popup_error', null,
array('component' => 'com_phocacart'));
        $oE       = $layoutPE->render($d);
        $response = array(
            'status' => '0',
            'popup' => $oE,
            'error' => $d['info_msg']);
        echo json_encode($response);
        return;
    }


    // Add item to cart
    function update($tpl = null) {

        if (!JSession::checkToken('request')) {
            $response = array(
                'status' => '0',
                'error' => '<span
class="ph-result-txt ph-error-txt">' .
JText::_('JINVALID_TOKEN') . '</span>');
            echo json_encode($response);
            return;
        }

        $msgSuffix            = '';
        $app                  = JFactory::getApplication();
        $s                    = PhocacartRenderStyle::getStyles();
        $item                 = array();
        $item['id']           =
$this->input->get('id', 0, 'int');
        $item['idkey']        =
$this->input->get('idkey', '',
'string');
        $item['quantity']     =
$this->input->get('quantity', 0, 'int');
        $item['catid']        =
$this->input->get('catid', 0, 'int');
        $item['ticketid']     =
$this->input->get('ticketid', 0, 'int');
        $item['quantity']     =
$this->input->get('quantity', 0, 'int');
        $item['return']       =
$this->input->get('return', '',
'string');
        $item['attribute']    =
$this->input->get('attribute', array(), 'array');
        $item['checkoutview'] =
$this->input->get('checkoutview', 0, 'int');
        $item['action']       =
$this->input->get('action', '',
'string');


        $rights = new PhocacartAccessRights();
        $itemProduct       =
PhocacartProduct::getProduct($item['id'],
$item['catid']);
        $this->t['can_display_addtocart'] =
$rights->canDisplayAddtocartAdvanced($itemProduct);

        if (!$this->t['can_display_addtocart']) {

           
$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_NOT_ALLOWED_TO_ADD_PRODUCTS_TO_SHOPPING_CART'),
'error');


            $d             = array();
            $d['s']        = $s;
            $d['info_msg'] =
PhocacartRenderFront::renderMessageQueue();
            $layoutPE      = new JLayoutFile('popup_error', null,
array('component' => 'com_phocacart'));
            $oE            = $layoutPE->render($d);
            $response      = array(
                'status' => '0',
                'popup' => $oE,
                'error' => $d['info_msg']);
            echo json_encode($response);
            return;
        }

        if ((int)$item['idkey'] != '' &&
$item['action'] != '') {

            $cart = new PhocacartCartRendercheckout();

            // Get Phoca Cart Cart Module Parameters
            $module                                =
JModuleHelper::getModule('mod_phocacart_cart');
            $paramsM                               = new
JRegistry($module->params);
            $cart->params['display_image']         =
$paramsM->get('display_image', 0);
            $cart->params['display_checkout_link'] =
$paramsM->get('display_checkout_link', 1);

            if ($item['action'] == 'delete') {
                $updated =
$cart->updateItemsFromCheckout($item['idkey'], 0);

                if (!$updated) {

                    $d      = array();
                    $d['s'] = $s;
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_PRODUCT_NOT_REMOVED_FROM_SHOPPING_CART')
. $msgSuffix, 'error');
                    $d['info_msg'] =
PhocacartRenderFront::renderMessageQueue();;
                    $layoutPE = new JLayoutFile('popup_error',
null, array('component' => 'com_phocacart'));
                    $oE       = $layoutPE->render($d);
                    $response = array(
                        'status' => '0',
                        'popup' => $oE,
                        'error' => $d['info_msg']);
                    echo json_encode($response);
                    return;
                }

                /*if ($updated) {
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_REMOVED_FROM_SHOPPING_CART')
. $msgSuffix, 'message');
                } else {
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_PRODUCT_NOT_REMOVED_FROM_SHOPPING_CART')
. $msgSuffix, 'error');
                }*/
            } else {// update
                $updated =
$cart->updateItemsFromCheckout($item['idkey'],
(int)$item['quantity']);

                if (!$updated) {

                    $d      = array();
                    $d['s'] = $s;
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_PRODUCT_QUANTITY_NOT_UPDATED')
. $msgSuffix, 'error');
                    $d['info_msg'] =
PhocacartRenderFront::renderMessageQueue();;
                    $layoutPE = new JLayoutFile('popup_error',
null, array('component' => 'com_phocacart'));
                    $oE       = $layoutPE->render($d);
                    $response = array(
                        'status' => '0',
                        'popup' => $oE,
                        'error' => $d['info_msg']);
                    echo json_encode($response);
                    return;
                }
                /*if ($updated) {
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_QUANTITY_UPDATED')
.$msgSuffix , 'message');
                } else {
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_PRODUCT_QUANTITY_NOT_UPDATED').
$msgSuffix, 'error');
                }*/
            }

            $cart->setFullItems();

            $o = $o2 = '';

            ob_start();
            echo $cart->render();
            $o = ob_get_contents();
            ob_end_clean();


            $count  = $cart->getCartCountItems();
            $total  = "";
            $totalA = $cart->getCartTotalItems();
            if (!empty($totalA)) {
                 $layoutT = new JLayoutFile('cart_total', null,
array('component' => 'com_phocacart'));
                 $dT = array();
                 $dT['s']  = $s;
                 $dT['total'] = $totalA;

                 $total = $layoutT->render($dT);
                //$total =
$price->getPriceFormat($totalA[0]['brutto']);
                //$total = $totalA[0]['brutto'];
            }

            $response = array(
                'status' => '1',
                'item' => $o,
                'popup' => $o2,
                'count' => $count,
                'total' => $total);

            echo json_encode($response);
            return;
        }

        $response = array(
            'status' => '0',
            'popup' => '',
            'error' => '');
        echo json_encode($response);
        return;

    }

}

?>
PK
��[S�h"̮̮checkout.phpnu�[���<?php
/* @package Joomla
 * @copyright Copyright (C) Open Source Matters. All rights reserved.
 * @license   http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * @extension Phoca Extension
 * @copyright Copyright (C) Jan Pavelka www.phoca.cz
 * @license   http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
defined('_JEXEC') or die();

class PhocaCartControllerCheckout extends JControllerForm
{
    /*
     * Add product to cart
     */
    public function add() {

        JSession::checkToken() or jexit('Invalid Token');

        $app               = JFactory::getApplication();
        $item              = array();
        $item['id']        =
$this->input->get('id', 0, 'int');
        $item['catid']     =
$this->input->get('catid', 0, 'int');
        $item['quantity']  =
$this->input->get('quantity', 0, 'int');
        $item['return']    =
$this->input->get('return', '',
'string');
        $item['attribute'] =
$this->input->get('attribute', array(), 'array');


        if ((int)$item['id'] > 0) {

            $itemP =
PhocacartProduct::getProduct((int)$item['id'],
$item['catid']);

            if (!empty($itemP)) {

                // Price (don't display add to cart when price is
zero)
                $price  = new PhocacartPrice();
                $priceP = $price->getPriceItems($itemP->price,
$itemP->taxid, $itemP->taxrate, $itemP->taxcalculationtype,
$itemP->taxtitle, 0, '', 1, 1, $itemP->group_price);
                $aA     =
PhocacartAttribute::sanitizeAttributeArray($item['attribute']);
                $price->getPriceItemsChangedByAttributes($priceP, $aA,
$price, $itemP, 1);
                $price->correctMinusPrice($priceP);
                $priceA = isset($priceP['brutto']) ?
$priceP['brutto'] : 0;

                // Stock (don't display add to cart when stock is
zero)
                $stockStatus = array();

                $stock       =
PhocacartStock::getStockItemsChangedByAttributes($stockStatus, $aA, $itemP,
1);

                $rights                                 = new
PhocacartAccessRights();
                $this->t['can_display_addtocart']       =
$rights->canDisplayAddtocartAdvanced($itemP);
                $this->t['can_display_addtocart_price'] =
$rights->canDisplayAddtocartPrice($itemP, $priceA);
                $this->t['can_display_addtocart_stock'] =
$rights->canDisplayAddtocartStock($itemP, $stock);

                if (!$this->t['can_display_addtocart']) {
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_NOT_ALLOWED_TO_ADD_PRODUCTS_TO_SHOPPING_CART'),
'error');
                   
$app->redirect(base64_decode($item['return']));
                }

                if (!$this->t['can_display_addtocart_price'])
{
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_NOT_ALLOWED_TO_ADD_PRODUCTS_TO_SHOPPING_CART'),
'error');
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_PRICE_IS_ZERO'),
'error');
                   
$app->redirect(base64_decode($item['return']));
                }

                if (!$this->t['can_display_addtocart_stock'])
{
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_NOT_ALLOWED_TO_ADD_PRODUCTS_TO_SHOPPING_CART'),
'error');
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_STOCK_IS_EMPTY'),
'error');
                   
$app->redirect(base64_decode($item['return']));
                }


                $cart = new PhocacartCart();
                $added = $cart->addItems((int)$item['id'],
(int)$item['catid'], (int)$item['quantity'],
$item['attribute']);

                if ($added) {
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_ADDED_TO_SHOPPING_CART'),
'message');
                } else {
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_NOT_ADDED_TO_SHOPPING_CART'),
'error');
                }
            } else {
               
$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_NOT_ADDED_TO_SHOPPING_CART'),
'error');
               
$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_NOT_FOUND'),
'error');
            }
        } else {
           
$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_NOT_ADDED_TO_SHOPPING_CART'),
'error');
           
$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_NOT_SELECTED'),
'error');
        }

       
//$app->redirect(JRoute::_('index.php?option=com_phocacart&view=checkout'));
        $app->redirect(base64_decode($item['return']));
    }

    /*
     * Change currency
     */
    public function currency() {
        JSession::checkToken() or jexit('Invalid Token');
        $app            = JFactory::getApplication();
        $item           = array();
        $item['id']     = $this->input->get('id',
0, 'int');
        $item['return'] =
$this->input->get('return', '',
'string');

        //$currency = new PhocacartCurrency();
        //$currency->setCurrentCurrency((int)$item['id']);

        PhocacartCurrency::setCurrentCurrency((int)$item['id']);

        $app->redirect(base64_decode($item['return']));
    }

    /*
     * Save billing and shipping address
     */

    public function saveaddress() {

        JSession::checkToken() or jexit('Invalid Token');
        $app                    = JFactory::getApplication();
        $item                   = array();
        $item['return']         =
$this->input->get('return', '',
'string');
        $item['jform']          =
$this->input->get('jform', array(), 'array');
        $item['phcheckoutbsas'] =
$this->input->get('phcheckoutbsas', false,
'string');

        $paramsC                       =
PhocacartUtils::getComponentParameters();
        $delivery_billing_same_enabled =
$paramsC->get('delivery_billing_same_enabled', 0);

        if ((int)$delivery_billing_same_enabled == -1) {
            // if some shipping rule is based on shipping address and
"delivery_billing_same_enabled" parameter is completery removed
            // the check all the shipping rules completely
            $item['phcheckoutbsas'] = false;
        }

        $guest     = PhocacartUserGuestuser::getGuestUser();
        $error     = 0;
        $msgSuffix = '<span id="ph-msg-ns"
class="ph-hidden"></span>';
        if (!empty($item['jform'])) {

            // Form Data
            $billing     = array();
            $shipping    = array();
            $shippingPhs = array();// shipping including postfix

            $bas         =
PhocacartUser::convertAddressTwo($item['jform']);
            $billing     = $bas[0];
            $shipping    = $bas[1];
            $shippingPhs = $bas[2];


            // Form Items
            $fI    = new PhocacartFormItems();
            $items = $fI->getFormItems(1, 1, 0);
            $model = $this->getModel('checkout');
            $form  = $model->getForm();

            if (empty($form)) {
               
$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_NO_FORM_LOADED')
. $msgSuffix, 'error');
               
$app->redirect(base64_decode($item['return']));
                return false;
            }


            // Which filds will be validated or required
            // Reqiuired and Validate is handled differently because if
shipping address is d
            if (!empty($form->getFieldset('user'))) {

                foreach ($form->getFieldset('user') as $field)
{

                    $name = $field->fieldname;

                    if ($field->fieldname == 'email' ||
$field->fieldname == 'email_phs') {
                        // This is not a registration: Checkout or Account
(first form without option to change email)
                        // Email is not stored by registered users
                        // Email by guests can be the same like stored in
database (e.g. guest orders without login)
                        $form->setFieldAttribute($field->fieldname,
'unique', 'false');
                    }


                    if (isset($billing[$name])) {
                        // such field exists in billing, require it if set
in rules, validate
                    } else if (isset($shippingPhs[$name])) {
                        // such field exists in shipping, require it if set
in rules, validate


                        // Don't check the shipping as it is not
required
                        if ($item['phcheckoutbsas']) {

                            // CHECKBOX IS ON
                            $billing['ba_sa']  = 1;
                            $shipping['ba_sa'] = 1;

                           
$form->setFieldAttribute($field->fieldname, 'required',
'false');
                           
$form->setFieldAttribute($field->fieldname, 'validate',
'');
                        } else {
                            // CHECKBOX IS OFF
                            $billing['ba_sa']  = 0;
                            $shipping['ba_sa'] = 0;

                        }

                    } else {

                        // such field does not exist, don't require
it, don't validate
                        $form->setFieldAttribute($field->fieldname,
'required', 'false');
                        $form->setFieldAttribute($field->fieldname,
'validate', '');

                    }
                }
            } else {
               
$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_NO_FORM_LOADED')
. $msgSuffix, 'error');
               
$app->redirect(base64_decode($item['return']));
                return false;
            }

        } else {
           
$app->enqueueMessage(JText::_('COM_PHOCACART_NO_DATA_STORED')
. $msgSuffix, 'error');// Not used:
COM_PHOCACART_ERROR_NO_DATA_STORED
            $app->redirect(base64_decode($item['return']));
            return false;                                                  
         // as in fact this can be possible
        }                                                                  
         // that admin does not require any data


        $data = $item['jform'];
        $data = $model->validate($form, $data);

        if ($data === false) {

            $errors = $model->getErrors();

            for ($i = 0, $n = count($errors); $i < $n && $i <
20; $i++) {
                if ($errors[$i] instanceof Exception) {
                    $app->enqueueMessage($errors[$i]->getMessage(),
'warning');
                } else {
                    $app->enqueueMessage($errors[$i],
'warning');
                }

            }

           
$this->setRedirect(base64_decode($item['return']));
            return false;
        }

        if ($guest) {
            if ($item['phcheckoutbsas']) {
                $item['jform']['ba_sa'] = 1;
                foreach ($item['jform'] as $k => $v) {
                    $pos = strpos($k, '_phs');
                    if ($pos === false) {

                    } else {
                        unset($item['jform'][$k]);
                    }
                }
            }

            if (!$model->saveAddressGuest($item['jform'])) {
                $msg =
JText::_('COM_PHOCACART_ERROR_DATA_NOT_STORED');
                $app->enqueueMessage($msg . $msgSuffix,
'error');
                $error = 1;
            }

        } else {

            if (!empty($billing)) {
                if (!$model->saveAddress($billing)) {
                    $msg =
JText::_('COM_PHOCACART_ERROR_DATA_NOT_STORED');
                    $app->enqueueMessage($msg . $msgSuffix,
'error');
                    $error = 1;
                } else {
                    //$msg =
JText::_('COM_PHOCACART_SUCCESS_DATA_STORED');
                    //$app->enqueueMessage($msg, 'message');
                    // Waiting for shipping
                }
               
//$app->redirect(base64_decode($item['return']));
            }

            // Don't store shipping address when delivery and billing
address is the same
            if (!empty($shipping) &&
!$item['phcheckoutbsas']) {
                if (!$model->saveAddress($shipping, 1)) {
                    $msg =
JText::_('COM_PHOCACART_ERROR_DATA_NOT_STORED');
                    $app->enqueueMessage($msg . $msgSuffix,
'error');
                    $error = 1;
                } else {
                    //$msg =
JText::_('COM_PHOCACART_SUCCESS_DATA_STORED');
                    //$app->enqueueMessage($msg, 'message');
                    // Waiting for shipping
                }
               
//$app->redirect(base64_decode($item['return']));
            }
        }


        // Remove shipping because shipping methods can change while
chaning address
        $cart = new PhocacartCartRendercheckout();
        $cart->setType(array(0, 1));
        $cart->setFullItems();
        $cart->updateShipping();// will be decided if shipping or
payment will be removed
        $cart->updatePayment();

        $msg = JText::_('COM_PHOCACART_SUCCESS_DATA_STORED');
        if ($error != 1) {
            $app->enqueueMessage($msg, 'message');
        }

        $app->redirect(base64_decode($item['return']));
    }


    /*
    * Save shipping method
    */

    public function saveshipping() {

        JSession::checkToken() or jexit('Invalid Token');
        $app                   = JFactory::getApplication();
        $item                  = array();
        $item['return']        =
$this->input->get('return', '',
'string');
        $item['phshippingopt'] =
$this->input->get('phshippingopt', array(),
'array');
        $guest                 = PhocacartUserGuestuser::getGuestUser();
        $msgSuffix             = '<span id="ph-msg-ns"
class="ph-hidden"></span>';

        $checkPayment = 0;

        if (!empty($item['phshippingopt']) &&
isset($item['phshippingopt'][0]) &&
(int)$item['phshippingopt'][0] > 0) {

            $model = $this->getModel('checkout');

            if ($guest) {
                if
(!$model->saveShippingGuest((int)$item['phshippingopt'][0])) {
                    $msg =
JText::_('COM_PHOCACART_ERROR_DATA_NOT_STORED');
                    $app->enqueueMessage($msg . $msgSuffix,
'error');
                } else {
                    $msg =
JText::_('COM_PHOCACART_SUCCESS_DATA_STORED');
                    $app->enqueueMessage($msg, 'message');
                    $checkPayment = 1;
                }

            } else {
                if
(!$model->saveShipping((int)$item['phshippingopt'][0])) {
                    $msg =
JText::_('COM_PHOCACART_ERROR_DATA_NOT_STORED');
                    $app->enqueueMessage($msg . $msgSuffix,
'error');
                } else {
                    $msg =
JText::_('COM_PHOCACART_SUCCESS_DATA_STORED');
                    $app->enqueueMessage($msg, 'message');
                    $checkPayment = 1;
                }
            }

        } else {
            $msg =
JText::_('COM_PHOCACART_NO_SHIPPING_METHOD_SELECTED');
            $app->enqueueMessage($msg . $msgSuffix, 'error');
        }


        // CHECK PAYMENT
        if ($checkPayment == 1) {
            //PhocacartPayment::removePayment($guest, 0);// Don't
remove coupon by guests
            $cart = new PhocacartCartRendercheckout();
            $cart->setInstance(2);//checkout
            $cart->setType(array(0, 1));
            $cart->setFullItems();
           
$cart->updatePayment((int)$item['phshippingopt'][0]);// check
payment in cart if it is valid
        }


        $app->redirect(base64_decode($item['return']));
    }

    /*
     * Save payment method and coupons
     */

    public function savepayment() {

        JSession::checkToken() or jexit('Invalid Token');
        $app                  = JFactory::getApplication();
        $item                 = array();
        $item['return']       =
$this->input->get('return', '',
'string');
        $item['phpaymentopt'] =
$this->input->get('phpaymentopt', array(),
'array');
        $item['phcoupon']     =
$this->input->get('phcoupon', -1, 'string');// -1
... no form data, '' ... form data yes but empty (e.g. when
removing coupon)
        $item['phreward']     =
$this->input->get('phreward', -1, 'int');   // -1
... no form data, 0 ... form data yes but it is set to not use points (0)
        $guest                = PhocacartUserGuestuser::getGuestUser();
        $user                 = PhocacartUser::getUser();
        $params               = $app->getParams();
        $msgSuffix            = '<span id="ph-msg-ns"
class="ph-hidden"></span>';
        $guest_checkout       = $params->get('guest_checkout',
0);
        $enable_coupons       = $params->get('enable_coupons',
2);

        // Coupon
        // 1) we save payment without coupon form --> phcoupon = -1
==> $couponId = -1 (in model the coupon will be ignored when saving to
not change current value
        // 2) we save payment with coupon form and ask the coupon class for
$couponId
        // 2a) $couponId == -2 ... empty string was set which means to
remove coupon ==> $couponId = 0
        // 2b) $couponId == 0 ... coupon is not valid ==> $couponId = 0
        // 2c) $couponId > 0 ... coupon is valid ==> $couponId > 0
        //
        // What is the difference between 2a) and 2b) - in database there
is no difference but we need to differentiate messages for the customers
(coupon empty vs. coupon not valid)
        // IMPORTANT:
        // $item['phcoupon'] = -1 ... coupon is not included in
sent payment form
        // $couponId = -1 ... coupon will be ignored in model when saving
to database because to not change the current value
        // $coupoiId = -2 ... coupon was included in sent payment form but
it was empty (empty means that user just want to remove it), we need -2 for
message only, in database we set it to 0


        if (!empty($item['phpaymentopt']) &&
isset($item['phpaymentopt'][0]) &&
(int)$item['phpaymentopt'][0] > 0) {

            // Coupon
            if ($item['phcoupon'] === -1) {
                $couponId = -1;// coupon data was not sent in the form,
don't touch its data in db
            } else {
                $msgExists = 0;
                $couponId  =
$this->getCouponIdByCouponCode($item['phcoupon']);

                // Coupons disabled
                if ($enable_coupons == 0 &&
$item['phcoupon'] != '' &&
$item['phcoupon'] !== -1) {
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_APPLYING_COUPONS_IS_DISABLED')
. $msgSuffix, 'error');
                    $couponId  = 0;// Remove coupon
                    $msgExists = 1;//
                }

                // Cupon only allowed for logged in users or guest checkout
                // Guest Checkout is still not enabled so we have message
for a) not logged in users or b) not started guest checkout users
                if ($enable_coupons == 2) {
                    if (!$guest) {
                        if ((int)$user->id < 1) {
                            if ($guest_checkout == 1) {
                               
$app->enqueueMessage(JText::_('COM_PHOCACART_PLEASE_LOG_IN_OR_ENABLE_GUEST_CHECKOUT_TO_APPLY_COUPON_FIRST')
. $msgSuffix, 'error');
                                $msgExists = 1;
                            } else {
                               
$app->enqueueMessage(JText::_('COM_PHOCACART_PLEASE_LOG_IN_TO_APPLY_COUPON_FIRST')
. $msgSuffix, 'error');
                                $msgExists = 1;
                            }
                            $couponId = 0;
                        }
                    }
                }

                if ($couponId === -2) {
                    // Coupon code is empty which means we remove the
coupon code
                    $msg =
JText::_('COM_PHOCACART_COUPON_NOT_SET');
                    $app->enqueueMessage($msg, 'message');
                    $couponId = 0;// Remove coupon
                } else if (!$couponId) {
                    // Coupon code just not valid
                    if ($msgExists == 1) {
                        // error message set so don't add another
message
                    } else {
                        $msg =
JText::_('COM_PHOCACART_COUPON_INVALID_EXPIRED_REACHED_USAGE_LIMIT');
                        $app->enqueueMessage($msg . $msgSuffix,
'error');
                    }


                    $couponId = 0;// Possible feature request - couponId
can be set to -1 to be ignored when saving. E.g. not valied coupon will not
remove previously added valid coupon
                } else {
                    // Coupon code successfuly tested
                    $msg =
JText::_('COM_PHOCACART_COUPON_ADDED');
                    $app->enqueueMessage($msg, 'message');
                }
            }


            // Reward Points
            if ($item['phreward'] === -1) {
                $rewards['used'] = -1;// reward points not sent
in the form, don't touch its data in db
            } else {

                $rewards =
$this->getRewardPointsByRewardPointsCode($item['phreward']);
                if ($rewards['used'] === false) {
                    $msg =
JText::_('COM_PHOCACART_REWARD_POINTS_NOT_ADDED');
                    $app->enqueueMessage($msg . $msgSuffix,
'error');
                } else {
                    $msg =
JText::_('COM_PHOCACART_REWARD_POINTS_ADDED');
                    $app->enqueueMessage($msg, 'message');
                }
            }


            $model = $this->getModel('checkout');

            if ($guest) {
                // 1) GUEST
                // Guest enabled
                if
(!$model->savePaymentAndCouponGuest((int)$item['phpaymentopt'][0],
$couponId)) {
                    $msg =
JText::_('COM_PHOCACART_ERROR_DATA_NOT_STORED');
                    $app->enqueueMessage($msg . $msgSuffix,
'error');
                } else {
                    $msg =
JText::_('COM_PHOCACART_SUCCESS_DATA_STORED');
                    $app->enqueueMessage($msg, 'message');
                }
            } else if ((int)$user->id < 1) {

                // 2) PRE-GUEST/PRE-LOGIN - NOT LOGGED IN OR STILL NOT
ENABLED GUEST CHECKOUT
                // Guest not enabled yet MOVECOUPON
                if
(!$model->savePaymentAndCouponGuest((int)$item['phpaymentopt'][0],
$couponId)) {
                    $msg =
JText::_('COM_PHOCACART_ERROR_DATA_NOT_STORED');
                    $app->enqueueMessage($msg . $msgSuffix,
'error');

                } else {
                    $msg =
JText::_('COM_PHOCACART_SUCCESS_DATA_STORED');
                    $app->enqueueMessage($msg, 'message');

                }

            } else {
                // 3) LOGGED IN USER
                if
(!$model->savePaymentAndCouponAndReward((int)$item['phpaymentopt'][0],
$couponId, $rewards['used'])) {
                    $msg =
JText::_('COM_PHOCACART_ERROR_DATA_NOT_STORED');
                    $app->enqueueMessage($msg . $msgSuffix,
'error');
                } else {
                    $msg =
JText::_('COM_PHOCACART_SUCCESS_DATA_STORED');
                    $app->enqueueMessage($msg, 'message');
                }
            }


        } else {
            $msg =
JText::_('COM_PHOCACART_NO_PAYMENT_METHOD_SELECTED');
            $app->enqueueMessage($msg . $msgSuffix, 'error');
        }
        $app->redirect(base64_decode($item['return']));
    }

    /*
     * Save coupon only
     */

    public function savecoupon() {


        /* There are following situations:
        a) user is not logged in and will log in - regarding coupon user is
taken as guest checkout (internally in session - so even guest checkout is
disabled)
        b) user is not logged in and will enable guest checkout - regarding
coupon user is taken as guestcheckou (internally in session - so even guest
checkout is disabled)
        c) user is logged in
        d) user enabled guest checkout
        */

        JSession::checkToken() or jexit('Invalid Token');
        $app              = JFactory::getApplication();
        $item             = array();
        $item['return']   =
$this->input->get('return', '',
'string');
        $item['phcoupon'] =
$this->input->get('phcoupon', '',
'string');
        $guest            = PhocacartUserGuestuser::getGuestUser();
        $user             = PhocacartUser::getUser();
        $params           = $app->getParams();
        $msgSuffix        = '<span id="ph-msg-ns"
class="ph-hidden"></span>';
        $guest_checkout   = $params->get('guest_checkout', 0);
        $enable_coupons   = $params->get('enable_coupons', 2);


        // Coupons disabled
        if ($enable_coupons == 0) {
           
$app->enqueueMessage(JText::_('COM_PHOCACART_APPLYING_COUPONS_IS_DISABLED'),
'error');
            $app->redirect(base64_decode($item['return']));
        }


        // Cupon only allowed for logged in users or guest checkout
        // Guest Checkout is still not enabled so we have message for a)
not logged in users or b) not started guest checkout users
        if ($enable_coupons == 2) {
            if (!$guest) {
                if ((int)$user->id < 1) {
                    if ($guest_checkout == 1) {
                       
$app->enqueueMessage(JText::_('COM_PHOCACART_PLEASE_LOG_IN_OR_ENABLE_GUEST_CHECKOUT_TO_APPLY_COUPON_FIRST'),
'error');
                    } else {
                       
$app->enqueueMessage(JText::_('COM_PHOCACART_PLEASE_LOG_IN_TO_APPLY_COUPON_FIRST'),
'error');
                    }
                   
$app->redirect(base64_decode($item['return']));
                }
            }
        }

        $couponId =
$this->getCouponIdByCouponCode($item['phcoupon']);

        $msgError = 0;
        if ($couponId === -2) {
            // Coupon code is empty which means we remove the coupon code
            $couponMessage =
JText::_('COM_PHOCACART_COUPON_NOT_SET');
            $couponId      = 0;
        } else if (!$couponId) {
            // Coupon code just not valid
            $couponMessage =
JText::_('COM_PHOCACART_COUPON_INVALID_EXPIRED_REACHED_USAGE_LIMIT');
            $couponId      = 0;
            $msgError      = 1;
        } else {
            // Coupon code successfuly tested
            $couponMessage =
JText::_('COM_PHOCACART_COUPON_ADDED');
        }


        $model = $this->getModel('checkout');

        if ($guest) {
            // 1) GUEST
            // Guest enabled
            if (!$model->saveCouponGuest($couponId)) {
                $msg = $couponMessage != '' ? $couponMessage :
JText::_('COM_PHOCACART_ERROR_DATA_NOT_STORED');
                $app->enqueueMessage($msg . $msgSuffix,
'error');

            } else {
                $msg = $couponMessage != '' ? $couponMessage :
JText::_('COM_PHOCACART_SUCCESS_DATA_STORED');

                $app->enqueueMessage($msg, 'message');
            }
        } else if ((int)$user->id < 1) {

            // 2) PRE-GUEST/PRE-LOGIN - NOT LOGGED IN OR STILL NOT ENABLED
GUEST CHECKOUT
            // Guest not enabled yet MOVECOUPON
            if (!$model->saveCouponGuest($couponId)) {
                $msg = $couponMessage != '' ? $couponMessage :
JText::_('COM_PHOCACART_ERROR_DATA_NOT_STORED');
                $app->enqueueMessage($msg . $msgSuffix,
'error');

            } else {
                $msg = $couponMessage != '' ? $couponMessage :
JText::_('COM_PHOCACART_SUCCESS_DATA_STORED');
                if ($msgError == 1) {
                    $app->enqueueMessage($msg . $msgSuffix,
'error');
                } else {
                    $app->enqueueMessage($msg, 'message');
                }

            }

        } else {

            // 3) LOGGED IN USER
            if (!$model->saveCoupon($couponId)) {
                $msg = $couponMessage != '' ? $couponMessage :
JText::_('COM_PHOCACART_ERROR_DATA_NOT_STORED');
                $app->enqueueMessage($msg . $msgSuffix,
'error');
            } else {
                $msg = $couponMessage != '' ? $couponMessage :
JText::_('COM_PHOCACART_SUCCESS_DATA_STORED');
                if ($msgError == 1) {
                    $app->enqueueMessage($msg . $msgSuffix,
'error');
                } else {
                    $app->enqueueMessage($msg, 'message');
                }
            }
        }

        $app->redirect(base64_decode($item['return']));
    }

    /*
     * return:
     * couponId = -2 (couponId = '') ... coupon code is empty,
e.g. when removing it (we use not dynamic variable)
     * couponId = 0 ... coupon code is not valid
     * couponId > 0 ... coupon code is valid
     */


    public function getCouponIdByCouponCode($code) {

        $app            = JFactory::getApplication();
        $params         = $app->getParams();
        $enable_coupons = $params->get('enable_coupons', 2);

        $couponId   = -2;
        $couponTrue = false;
        if (isset($code) && $code != '' &&
$enable_coupons > 0) {

            $coupon = new PhocacartCoupon();
            $coupon->setType(array(0, 1));
            $coupon->setCoupon(0, $code);
            //$couponTrue = $coupon->checkCoupon(1);// Basic Check -
Coupon True does not mean it is valid - only basic check done, whole check
happens in order
            //$couponTrue = $coupon->checkCoupon();// Complete Check -
mostly coupon is added at the end so do complete check - can be changed to
basic - no items, no categories can be checked

            $cart = new PhocacartCartRendercheckout();
            $cart->setInstance(2);//checkout
            $cart->setType(array(0, 1));
            $cart->setFullItems();
            $fullItems = $cart->getFullItems();
            $total     = $cart->getTotal();

            //$couponTrue		= $cart->getCouponValid();// cart itself
cannot say us if the coupon is valid, because this coupon was still not
added to the cart

            if (!empty($fullItems[4]) && !empty($total[4])) {
                foreach ($fullItems[4] as $k => $v) {
                    $validCoupon = $coupon->checkCoupon(0,
$v['id'], $v['catid'], $total[4]['quantity'],
$total[4]['netto']);

                    // !!! VALID COUPON
                    // In case the coupon is valid at least for one product
or one category it is then valid
                    // and will be divided into valid products/categories
                    // As global we mark it as valid - so change the valid
coupon variable only in case it is valid
                    if ($validCoupon == 1) {
                        $couponTrue = $validCoupon;
                        break;
                    }
                }
            }

            $couponId = 0;
            if ($couponTrue) {
                $couponData = $coupon->getCoupon();
                if (isset($couponData['id']) &&
$couponData['id'] > 0) {
                    $couponId = $couponData['id'];
                }
            }
        }

        return $couponId;
    }


    public function saverewardpoints() {


        JSession::checkToken() or jexit('Invalid Token');
        $app              = JFactory::getApplication();
        $item             = array();
        $item['return']   =
$this->input->get('return', '',
'string');
        $item['phreward'] =
$this->input->get('phreward', '',
'int');
        $guest            = PhocacartUserGuestuser::getGuestUser();
        //$user 	                = PhocacartUser::getUser();
        //$params 					= $app->getParams();
        $msgSuffix = '<span id="ph-msg-ns"
class="ph-hidden"></span>';


        // Reward Points
        $rewards =
$this->getRewardPointsByRewardPointsCode($item['phreward']);

        if ($rewards['used'] === false) {
            $rewardMessage =
JText::_('COM_PHOCACART_REWARD_POINTS_NOT_ADDED');
        } else {

            if ($rewards['used'] === 0) {
                $rewardMessage =
JText::_('COM_PHOCACART_REWARD_POINTS_REMOVED');
            } else {
                $rewardMessage =
JText::_('COM_PHOCACART_REWARD_POINTS_ADDED');
            }

        }

        $model = $this->getModel('checkout');

        if ($guest) {

        } else {

            if (!$model->saveRewardPoints($rewards['used'])) {
                $msg = $rewardMessage != '' ? $rewardMessage :
JText::_('COM_PHOCACART_ERROR_DATA_NOT_STORED');
                $app->enqueueMessage($msg . $msgSuffix,
'error');
            } else {
                $msg = $rewardMessage != '' ? $rewardMessage :
JText::_('COM_PHOCACART_SUCCESS_DATA_STORED');
                $app->enqueueMessage($msg, 'message');
            }
        }

        $app->redirect(base64_decode($item['return']));
    }


    public function getRewardPointsByRewardPointsCode($points) {

        $app            = JFactory::getApplication();
        $params         = $app->getParams();
        $enable_rewards = $params->get('enable_rewards', 1);


        $rewards         = array();
        $rewards['used'] = 0;

        if (isset($points) && $points != '' &&
$enable_rewards) {

            $reward          = new PhocacartReward();
            $rewards['used'] =
$reward->checkReward((int)$points, 1);
        }

        return $rewards;

    }


    /*
     * Update or delete from cart
     */
    public function update() {

        JSession::checkToken() or jexit('Invalid Token');
        $app              = JFactory::getApplication();
        $item             = array();
        $item['id']       =
$this->input->get('id', 0, 'int');
        $item['catid']    =
$this->input->get('catid', 0, 'int');
        $item['idkey']    =
$this->input->get('idkey', '',
'string');
        $item['quantity'] =
$this->input->get('quantity', 0, 'int');
        $item['return']   =
$this->input->get('return', '',
'string');
        $item['action']   =
$this->input->get('action', '',
'string');
        $msgSuffix        = '<span id="ph-msg-ns"
class="ph-hidden"></span>';


        $rights                           = new PhocacartAccessRights();
        $itemProduct                      =
PhocacartProduct::getProduct($item['id'],
$item['catid']);
        $this->t['can_display_addtocart'] =
$rights->canDisplayAddtocartAdvanced($itemProduct);


        if (!$this->t['can_display_addtocart']) {
           
$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_NOT_ALLOWED_TO_ADD_PRODUCTS_TO_SHOPPING_CART'),
'error');
            $app->redirect(base64_decode($item['return']));
        }

        if ((int)$item['idkey'] != '' &&
$item['action'] != '') {

            $cart = new PhocacartCart();
            if ($item['action'] == 'delete') {
                $updated =
$cart->updateItemsFromCheckout($item['idkey'], 0);
                if ($updated) {
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_REMOVED_FROM_SHOPPING_CART')
. $msgSuffix, 'message');
                } else {
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_PRODUCT_NOT_REMOVED_FROM_SHOPPING_CART')
. $msgSuffix, 'error');
                }
            } else {// update
                $updated =
$cart->updateItemsFromCheckout($item['idkey'],
(int)$item['quantity']);
                if ($updated) {
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_QUANTITY_UPDATED')
. $msgSuffix, 'message');
                } else {
                   
$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_PRODUCT_QUANTITY_NOT_UPDATED')
. $msgSuffix, 'error');
                }
            }
        }

       
//$app->redirect(JRoute::_('index.php?option=com_phocacart&view=checkout'));
        $app->redirect(base64_decode($item['return']));
    }
    /*
     public function saveshipping() {

        JSession::checkToken() or jexit( 'Invalid Token' );
        $app					= JFactory::getApplication();
        $item					= array();
        $item['return']			= $this->input->get(
'return', '', 'string'  );
        $item['phshippingopt']	= $this->input->get(
'phshippingopt', array(), 'array'  );


        if(!empty($item['phshippingopt']) &&
isset($item['phshippingopt'][0]) &&
(int)$item['phshippingopt'][0] > 0) {

            $model 	= $this->getModel('checkout');
           
if(!$model->saveShipping((int)$item['phshippingopt'][0])) {
                $msg =
JText::_('COM_PHOCACART_ERROR_DATA_NOT_STORED');
                $app->enqueueMessage($msg, 'error');
            } else {
                $msg =
JText::_('COM_PHOCACART_SUCCESS_DATA_STORED');
                $app->enqueueMessage($msg, 'message');
            }

        } else {
           
$app->enqueueMessage(JText::_('COM_PHOCACART_NO_SHIPPING_METHOD_SELECTED'),
'error');
        }
        $app->redirect(base64_decode($item['return']));
    }
    */
    /*
     * Make an order
     */

    public function order() {

        JSession::checkToken() or jexit('Invalid Token');
        $pC                                =
PhocacartUtils::getComponentParameters();
        $display_checkout_privacy_checkbox =
$pC->get('display_checkout_privacy_checkbox', 0);
        $display_checkout_toc_checkbox     =
$pC->get('display_checkout_toc_checkbox', 2);

        $app                   = JFactory::getApplication();
        $item                  = array();
        $item['return']        =
$this->input->get('return', '',
'string');
        $item['phcheckouttac'] =
$this->input->get('phcheckouttac', false,
'string');
        $item['privacy']       =
$this->input->get('privacy', false, 'string');
        $item['newsletter']    =
$this->input->get('newsletter', false, 'string');
        $item['phcomment']     =
$this->input->get('phcomment', '',
'string');
        $msgSuffix             = '<span id="ph-msg-ns"
class="ph-hidden"></span>';

        $item['privacy']       = $item['privacy'] ? 1 :
0;
        $item['phcheckouttac'] = $item['phcheckouttac']
? 1 : 0;
        $item['newsletter']    = $item['newsletter'] ?
1 : 0;


        if ($display_checkout_privacy_checkbox == 2 &&
$item['privacy'] == 0) {
            $msg =
JText::_('COM_PHOCACART_ERROR_YOU_NEED_TO_AGREE_TO_PRIVACY_TERMS_AND_CONDITIONS');
            $app->enqueueMessage($msg . $msgSuffix, 'error');
            $app->redirect(base64_decode($item['return']));
            return false;

        }

        if ($display_checkout_toc_checkbox == 2 &&
$item['phcheckouttac'] == 0) {
            $msg =
JText::_('COM_PHOCACART_ERROR_YOU_NEED_TO_AGREE_TO_TERMS_AND_CONDITIONS');
            $app->enqueueMessage($msg . $msgSuffix, 'error');
            $app->redirect(base64_decode($item['return']));
            return false;
        }


        $order     = new PhocacartOrder();
        $orderMade = $order->saveOrderMain($item);


        if (!$orderMade) {
            $msg = '';
            if (!PhocacartUtils::issetMessage()) {
                $msg =
JText::_('COM_PHOCACART_ORDER_ERROR_PROCESSING');
            }
            $app->enqueueMessage($msg . $msgSuffix, 'error');
            $app->redirect(base64_decode($item['return']));
            return true;
        } else {

            // Lets decide Payment plugin if the cart will be emptied or
not
            $cart           = new PhocacartCart();
            $paymentMethod 	= $cart->getPaymentMethod();
            $pluginData     = array();
            $pluginData['emptycart'] = true;
            if (isset($paymentMethod['id']) &&
(int)$paymentMethod['id'] > 0) {

                $payment		= new PhocacartPayment();
                $paymentO       =
$payment->getPaymentMethod((int)$paymentMethod['id']);

                if (isset($paymentO->method)) {
                    JPluginHelper::importPlugin('pcp',
htmlspecialchars(strip_tags($paymentO->method)));
                    $eventData 					= array();
                    $proceed 					= '';
                    $eventData['pluginname'] 	=
htmlspecialchars(strip_tags($paymentO->method));
                   
JFactory::getApplication()->triggerEvent('PCPbeforeEmptyCartAfterOrder',
array(&$proceed, &$pluginData, $pC, $paymentO->params, $order,
$eventData));
                }
            }

            if ($pluginData['emptycart'] === true) {
                $cart->emptyCart();
                PhocacartUserGuestuser::cancelGuestUser();
            }



            $action     = $order->getActionAfterOrder(); // Which action
should be done
            $message    = $order->getMessageAfterOrder();// Custom
message by payment plugin Payment/Download, Payment/No Download ...
            $dataOrder  = $order->getDataAfterOrder();// Order ID,
Token, payment ID, shipping ID ... different data for info view

            $session = JFactory::getSession();
            if ($action == 4 || $action == 3) {
                // Ordered OK, but now we proceed to payment
                $session->set('infoaction', $action,
'phocaCart');
                $session->set('infomessage', $message,
'phocaCart');
                $session->set('infodata', $dataOrder,
'phocaCart');
               
$app->redirect(JRoute::_(PhocacartRoute::getPaymentRoute(), false));
                return true;
                // This message should stay
                // when order - the message is created
                // when payment - the message stays unchanged
                // after payment - it will be redirected to info view and
there the message will be displayed and then deleted

            } else {
                // Ordered OK, but the payment method does not have any
instruction to proceed to payment (e.g. cash on delivery)
                //$msg =
JText::_('COM_PHOCACART_ORDER_SUCCESSFULLY_PROCESSED');
                // We produce not message but we redirect to specific view
with message and additional instructions
                //$app->enqueueMessage($msg, 'message');

                $session->set('infoaction', $action,
'phocaCart');
                $session->set('infomessage', $message,
'phocaCart');
                $session->set('infodata', $dataOrder,
'phocaCart');
                $app->redirect(JRoute::_(PhocacartRoute::getInfoRoute(),
false));
                return true;
            }
        }


    }

    public function setguest() {

        JSession::checkToken() or jexit('Invalid Token');
        $app            = JFactory::getApplication();
        $item           = array();
        $item['id']     = $this->input->get('id',
0, 'int');
        $item['return'] =
$this->input->get('return', '',
'string');
        $msgSuffix      = '<span id="ph-msg-ns"
class="ph-hidden"></span>';


        //$guest = new PhocacartUserGuestuser();
        //$set = $guest->setGuestUser((int)$item['id']);
        $set =
PhocacartUserGuestuser::setGuestUser((int)$item['id']);
        if ((int)$item['id'] == 1) {
            if ($set) {
               
$app->enqueueMessage(JText::_('COM_PHOCACART_YOU_PROCEEDING_GUEST_CHECKOUT')
. $msgSuffix, 'message');
            } else {
               
$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_DURING_PROCEEDING_GUESTBOOK_CHECKOUT')
. $msgSuffix, 'error');
            }
        } else {
            if ($set) {
               
$app->enqueueMessage(JText::_('COM_PHOCACART_GUEST_CHECKOUT_CANCELED')
. $msgSuffix, 'message');
            } else {
               
$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_DURING_CANCELING_GUESTBOOK_CHECKOUT')
. $msgSuffix, 'error');
            }
        }
       
//$app->redirect(JRoute::_('index.php?option=com_phocacart&view=checkout'));
        $app->redirect(base64_decode($item['return']));
    }
    /*
    public function compareadd() {

        JSession::checkToken() or jexit( 'Invalid Token' );
        $app				= JFactory::getApplication();
        $item				= array();
        $item['id']			= $this->input->get( 'id',
0, 'int' );
        $item['return']		= $this->input->get(
'return', '', 'string'  );

        $compare	= new PhocacartCompare();
        $added	= $compare->addItem((int)$item['id']);
        if ($added) {
           
$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_ADDED_TO_COMPARISON_LIST'),
'message');
        } else {
           
$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_NOT_ADDED_TO_COMPARISON_LIST'),
'error');
        }
       
//$app->redirect(JRoute::_('index.php?option=com_phocacart&view=checkout'));
        $app->redirect(base64_decode($item['return']));
    }

        public function compareremove() {

        JSession::checkToken() or jexit( 'Invalid Token' );
        $app				= JFactory::getApplication();
        $item				= array();
        $item['id']			= $this->input->get( 'id',
0, 'int' );
        $item['return']		= $this->input->get(
'return', '', 'string'  );

        $compare	= new PhocacartCompare();
        $added	= $compare->removeItem((int)$item['id']);
        if ($added) {
           
$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_REMOVED_FROM_COMPARISON_LIST'),
'message');
        } else {
           
$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_NOT_REMOVED_FROM_COMPARISON_LIST'),
'error');
        }
       
//$app->redirect(JRoute::_('index.php?option=com_phocacart&view=checkout'));
        $app->redirect(base64_decode($item['return']));
    }*/

}

?>
PK
��[�.���comparison.json.phpnu�[���<?php
/* @package Joomla
 * @copyright Copyright (C) Open Source Matters. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * @extension Phoca Extension
 * @copyright Copyright (C) Jan Pavelka www.phoca.cz
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
defined('_JEXEC') or die();

class PhocaCartControllerComparison extends JControllerForm
{

	public function add() {

		if (!JSession::checkToken('request')) {
			$response = array(
				'status' => '0',
				'error' => '<span class="ph-result-txt
ph-error-txt">' . JText::_('JINVALID_TOKEN') .
'</span>');
			echo json_encode($response);
			return;
		}

		$app					= JFactory::getApplication();
		$s 					    = PhocacartRenderStyle::getStyles();
		$item					= array();
		$item['id']				= $this->input->get( 'id', 0,
'int' );
		$item['catid']			= $this->input->get( 'catid',
0, 'int' );
		$item['return']			= $this->input->get(
'return', '', 'string'  );
		$item['comparisonview']	= $this->input->get(
'comparisonview', 0, 'int'  );

		$compare	= new PhocacartCompare();
		$added		= $compare->addItem((int)$item['id'],
(int)$item['catid']);
		//$catid		=
PhocacartProduct::getCategoryByProductId((int)$item['id']);

		$o = $o2 = '';
		// Content of the comparison list
		ob_start();
		echo $compare->renderList();
		$o = ob_get_contents();
		ob_end_clean();

		// Render the layout
		$d          = array();
		$d['s']		= $s;
		$layoutC	= new JLayoutFile('popup_add_to_compare', null,
array('component' => 'com_phocacart'));

		$d['link_comparison'] =
JRoute::_(PhocacartRoute::getComparisonRoute((int)$item['id']),
(int)$item['catid']);
		$d['link_continue'] = '';
		// We need to know if module is displayed on comparison site
		// If yes and one item will be deleted per AJAX, we need to refresh
comparison site
		// If now and one item will be deleted per AJAX, everything is OK,
nothing needs to be refreshed
		$d['comparison_view'] 	=
(int)$item['comparisonview'];

		if ($added) {
			$d['info_msg'] =
JText::_('COM_PHOCACART_PRODUCT_ADDED_TO_COMPARISON_LIST');
		} else {
			$d['info_msg'] =
JText::_('COM_PHOCACART_PRODUCT_NOT_ADDED_TO_COMPARISON_LIST');

			$mO = PhocacartRenderFront::renderMessageQueue();
			$d['info_msg_additional'] = $mO;
		}

		// Popup with info - Continue,Proceed to Comparison list
		//ob_start();
		$o2 = $layoutC->render($d);
		//$o2 = ob_get_contents();
		//ob_end_clean();

		$count = $compare->getComapareCountItems();

		$response = array(
			'status'	=> '1',
			'item'		=> $o,
			'popup'		=> $o2,
			'count'		=> $count);

		echo json_encode($response);
		return;
	}

	public function remove() {

		if (!JSession::checkToken('request')) {
			$response = array(
				'status' => '0',
				'error' => '<span class="ph-result-txt
ph-error-txt">' . JText::_('JINVALID_TOKEN') .
'</span>');
			echo json_encode($response);
			return;
		}

		$app 					= JFactory::getApplication();
		$s 					    = PhocacartRenderStyle::getStyles();
		$item					= array();
		$item['id']				= $this->input->get( 'id', 0,
'int' );
		$item['catid']			= $this->input->get( 'catid',
0, 'int' );
		$item['return']			= $this->input->get(
'return', '', 'string'  );
		$item['comparisonview']	= $this->input->get(
'comparisonview', 0, 'int'  );

		$compare	= new PhocacartCompare();
		$added		= $compare->removeItem((int)$item['id']);
		//$catid		=
PhocacartProduct::getCategoryByProductId((int)$item['id']);

		$o = $o2 = '';
		// Content of the comparison list
		ob_start();
		echo $compare->renderList();
		$o = ob_get_contents();
		ob_end_clean();

		// Render the layout
		$d          = array();
		$d['s']		= $s;
		$layoutC	= new JLayoutFile('popup_remove_from_compare', null,
array('component' => 'com_phocacart'));

		$d['link_comparison'] =
JRoute::_(PhocacartRoute::getComparisonRoute((int)$item['id']),
(int)$item['catid']);
		$d['link_continue'] = '';
		// We need to know if module is displayed on comparison site
		// If yes and one item will be deleted per AJAX, we need to refresh
comparison site
		// If now and one item will be deleted per AJAX, everything is OK,
nothing needs to be refreshed
		$d['comparison_view'] 	=
(int)$item['comparisonview'];



		if ($added) {
			$d['info_msg'] =
JText::_('COM_PHOCACART_PRODUCT_REMOVED_FROM_COMPARISON_LIST');
		} else {
			$d['info_msg'] =
JText::_('COM_PHOCACART_PRODUCT_NOT_REMOVED_FROM_COMPARISON_LIST');

			$mO = PhocacartRenderFront::renderMessageQueue();
			$d['info_msg_additional'] = $mO;
		}

		// Popup with info - Continue,Proceed to Comparison list
		//ob_start();
		$o2 = $layoutC->render($d);
		//$o2 = ob_get_contents();
		//ob_end_clean();

		$count = $compare->getComapareCountItems();

		$response = array(
			'status'	=> '1',
			'item'		=> $o,
			'popup'		=> $o2,
			'count'		=> $count);

		echo json_encode($response);
		return;
	}

}
?>
PK
��[	����comparison.phpnu�[���<?php
/* @package Joomla
 * @copyright Copyright (C) Open Source Matters. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * @extension Phoca Extension
 * @copyright Copyright (C) Jan Pavelka www.phoca.cz
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
defined('_JEXEC') or die();

class PhocaCartControllerComparison extends JControllerForm
{
	
	public function add() { 
		
		JSession::checkToken() or jexit( 'Invalid Token' );
		$app				= JFactory::getApplication();
		$item				= array();
		$item['id']			= $this->input->get( 'id', 0,
'int' );
		$item['catid']		= $this->input->get( 'catid',
0, 'int' );
		$item['return']		= $this->input->get( 'return',
'', 'string'  );
		
		$compare	= new PhocacartCompare();
		$added	= $compare->addItem((int)$item['id'],
(int)$item['catid']);
		if ($added) {
			$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_ADDED_TO_COMPARISON_LIST'),
'message');
		} else {
			$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_NOT_ADDED_TO_COMPARISON_LIST'),
'error');
		}
		//$app->redirect(JRoute::_('index.php?option=com_phocacart&view=checkout'));
		$app->redirect(base64_decode($item['return']));
	}
	
		public function remove() {
		
		JSession::checkToken() or jexit( 'Invalid Token' );
		$app				= JFactory::getApplication();
		$item				= array();
		$item['id']			= $this->input->get( 'id', 0,
'int' );
		$item['return']		= $this->input->get( 'return',
'', 'string'  );
		
		$compare	= new PhocacartCompare();
		$added	= $compare->removeItem((int)$item['id']);
		if ($added) {
			$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_REMOVED_FROM_COMPARISON_LIST'),
'message');
		} else {
			$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_NOT_REMOVED_FROM_COMPARISON_LIST'),
'error');
		}
		//$app->redirect(JRoute::_('index.php?option=com_phocacart&view=checkout'));
		$app->redirect(base64_decode($item['return']));
	}
	
}
?>PK
��[UB�yrrdownload.phpnu�[���<?php
/* @package Joomla
 * @copyright Copyright (C) Open Source Matters. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * @extension Phoca Extension
 * @copyright Copyright (C) Jan Pavelka www.phoca.cz
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
defined('_JEXEC') or die();

class PhocaCartControllerDownload extends JControllerForm
{
	public function download() {
	
		JSession::checkToken() or jexit( 'Invalid Token' );
		$app				= JFactory::getApplication();
		$item				= array();
		$item['id']			= $this->input->get( 'id', 0,
'int' );
		$item['return']		= $this->input->get( 'return',
'', 'string'  );
		
		if ($item['id'] > 0) {
			$download = PhocacartDownload::download($item['id']);
			if (!$download) {
				$app->enqueueMessage(JText::_('COM_PHOCACART_FILE_CANNOT_BE_DOWNLOADED'),
'error');
			}
		} else {
			$app->enqueueMessage(JText::_('COM_PHOCACART_NO_FILE_FOUND'),
'error');
		}
		
		$app->redirect(base64_decode($item['return']));
	}
	
	public function downloadpublic() {
	
		JSession::checkToken() or jexit( 'Invalid Token' );
		$app				= JFactory::getApplication();
		$item				= array();
		$item['id']			= $this->input->get( 'id', 0,
'int' );
		$item['return']		= $this->input->get( 'return',
'', 'string'  );
		
		if ($item['id'] > 0) {
			$download = PhocacartDownload::downloadPublic($item['id']);
			if (!$download) {
				$app->enqueueMessage(JText::_('COM_PHOCACART_FILE_CANNOT_BE_DOWNLOADED'),
'error');
			}
		} else {
			$app->enqueueMessage(JText::_('COM_PHOCACART_NO_FILE_FOUND'),
'error');
		}
		
		$app->redirect(base64_decode($item['return']));
	}
}
?>PK
��[�#o,,
index.htmlnu�[���<html><body
bgcolor="#FFFFFF"></body></html>PK
��[a�u�		item.phpnu�[���<?php
/* @package Joomla
 * @copyright Copyright (C) Open Source Matters. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * @extension Phoca Extension
 * @copyright Copyright (C) Jan Pavelka www.phoca.cz
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
defined('_JEXEC') or die();

class PhocaCartControllerItem extends JControllerForm
{
	public function review() {

		JSession::checkToken() or jexit( 'Invalid Token' );
		//$paramsC 			= PhocacartUtils::getComponentParameters();
		$app				= JFactory::getApplication();
		$paramsC 			= $app->getParams();
		$approve_review 	= $paramsC->get( 'approve_review',0 );
		$u					= PhocacartUser::getUser();
		$item				= array();
		$item['id']			= $this->input->get( 'id', 0,
'int' );
		$item['catid']		= $this->input->get( 'catid',
0, 'int' );
		$item['rating']		= $this->input->get( 'rating',
0, 'int'  );
		$item['name']		= $this->input->get( 'name', 0,
'string'  );
		$item['review']		= $this->input->get( 'review',
0, 'string'  );
		$item['return']		= $this->input->get( 'return',
'', 'string'  );

		$errMsg = array();// Error message in this controller
		if ((int)$item['rating'] < 1) {
			$errorMsg[] = JText::_('COM_PHOCACART_PLEASE_ADD_RATING');
		}
		if ($item['name'] == '') {
			$errorMsg[] = JText::_('COM_PHOCACART_PLEASE_ADD_YOUR_NAME');
		}
		if ($item['review'] == '') {
			$errorMsg[] =
JText::_('COM_PHOCACART_PLEASE_ADD_YOUR_REVIEW');
		}
		if (!empty($errorMsg)) {
			$app->enqueueMessage(implode( '<br />', $errorMsg ),
'warning');
			$app->redirect(base64_decode($item['return']));
		}

		$error = 0;// Error message from database
		$added = PhocacartReview::addReview($error, $approve_review,
$item['id'], $u->id, $item['name'],
$item['rating'], $item['review']);

		if ($added) {
			$msg = JText::_('COM_PHOCACART_THANK_YOU_FOR_YOUR_REVIEW');
			if ($approve_review == 1) {
				$msg .= '. '.
JText::_('COM_PHOCACART_REVIEW_NEED_TO_BE_APPROVED_BEFORE_DISPLAYING').'.';
			}
			$app->enqueueMessage($msg, 'message');
		} else {
			if ($error == 1) {
				$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_YOU_HAVE_ALREADY_REVIEWED_THIS_PRODUCT'),
'warning');
			} else {
				$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_REVIEW_NOT_ADDED'),
'warning');
			}
		}
		//$app->redirect(JRoute::_('index.php?option=com_phocacart&view=checkout'));
		$app->redirect(base64_decode($item['return']));
	}
}
?>
PK
��[�����r�rpos.json.phpnu�[���<?php
/* @package Joomla
 * @copyright Copyright (C) Open Source Matters. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * @extension Phoca Extension
 * @copyright Copyright (C) Jan Pavelka www.phoca.cz
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
defined('_JEXEC') or die();

class PhocaCartControllerPos extends JControllerForm
{

	// Add item to cart
	function add($tpl = null){

		if (!JSession::checkToken('request')) {
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' . JText::_('JINVALID_TOKEN') .
'</div>');
			echo json_encode($response);
			return;
		}



		$app					= JFactory::getApplication();

		$paramsC 				= PhocacartUtils::getComponentParameters();
		$pos_payment_force	= $paramsC->get( 'pos_payment_force', 0
);
		$pos_shipping_force	= $paramsC->get( 'pos_shipping_force', 0
);

		if ((int)$pos_payment_force > 0) {
            $pos_payment_force =
PhocacartPayment::isPaymentMethodActive($pos_payment_force) === true ?
(int)$pos_payment_force : 0;
        }
        if ((int)$pos_shipping_force > 0) {
            $pos_shipping_force =
PhocacartShipping::isShippingMethodActive($pos_shipping_force) === true ?
(int)$pos_shipping_force : 0;
        }

		$item					= array();
		$item['id']				= $this->input->get( 'id', 0,
'int' );
		$item['catid']			= $this->input->get( 'catid',
0, 'int' );
		$item['ticketid']		= $this->input->get(
'ticketid', 0, 'int' );
		$item['unitid']			= $this->input->get(
'unitid', 0, 'int' );
		$item['sectionid']		= $this->input->get(
'sectionid', 0, 'int' );
		$item['quantity']		= $this->input->get(
'quantity', 0, 'int'  );
		$item['return']			= $this->input->get(
'return', '', 'string'  );
		$item['attribute']		= $this->input->get(
'attribute', array(), 'array'  );
		$item['checkoutview']	= $this->input->get(
'checkoutview', 0, 'int'  );
		$item['sku']			= $this->input->get( 'sku',
'', 'string' );


		// Controller name in Joomla! is not called "pos" - it includes
task variable
		// so we need to set the name for controller to "pos"
		// so other parts of system (for example cart class know we are calling
it from pos controller)
		$this->input->set('controller', 'pos');

		// IMPORTANT
		$s 					    = PhocacartRenderStyle::getStyles();//MUST BE SET AFTER
$this->input->set('controller', 'pos'); TO GET
RIGHT CLASSES


		$user				= $vendor = $ticket = $unit	= $section = array();
		$dUser				= PhocacartUser::defineUser($user, $vendor, $ticket, $unit,
$section, 1);


		if (!isset($vendor->id) || (isset($vendor->id) &&
(int)$vendor->id < 1)) {
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' .
JText::_('COM_PHOCACART_PLEASE_LOGIN_ACCESS_POS') .
'</div>');
			echo json_encode($response);
			return;
		}

		if (!PhocacartTicket::existsTicket((int)$vendor->id,
(int)$ticket->id, (int)$unit->id, (int)$section->id)) {
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' .
JText::_('COM_PHOCACART_TICKET_DOES_NOT_EXIST') .
'</div>');
			echo json_encode($response);
			return;
		}

		if ($item['sku'] != '') {

			$preferredSku = PhocacartPos::getPreferredSku();// Select if SKU, EAN,
ISBN, etc.

			$productBySku =
PhocacartProduct::getProductIdBySku($item['sku'],
$preferredSku['name'], array(0,2));

			if (isset($productBySku['id']) &&
(int)$productBySku['id'] > 0 &&
isset($productBySku['catid']) &&
(int)$productBySku['catid'] > 0) {
				$item['id'] = (int)$productBySku['id'];
				$item['catid'] = (int)$productBySku['catid'];

				if (!empty($productBySku['attributes'])) {
					$item['attribute'] = $productBySku['attributes'];
				}
			} else {

				$response = array(
					'status' => '0',
					'error' => '<div class="ph-result-txt
ph-error-txt">' .
JText::_('COM_PHOCACART_PRODUCT_NOT_FOUND') .
'</div>');
				echo json_encode($response);
				return;

			}
		}



		$cart	= new PhocacartCartRendercheckout();
		$cart->setType(array(0,2));
		$cart->params['display_image'] 			= 1;
		$cart->params['display_checkout_link'] 	= 0;



		$added	= $cart->addItems((int)$item['id'],
(int)$item['catid'], (int)$item['quantity'],
$item['attribute'], '', array(0,2));

		if (!$added) {

			$d 				= array();
			$d['s']			= $s;
			$d['info_msg']	= PhocacartRenderFront::renderMessageQueue();;
			$layoutPE		= new JLayoutFile('popup_error', null,
array('component' => 'com_phocacart'));
			$oE 			= $layoutPE->render($d);
			$response = array(
				'status' => '0',
				'popup'	=> $oE,
				'error' => '<div class="ph-result-txt
ph-error-txt">' . $d['info_msg'] .
'</div>');
			echo json_encode($response);
			return;
		}

		$cart->setFullItems();
		$cart->updateShipping();// will be decided if shipping or payment will
be removed
        $cart->updatePayment();

		// When adding new product - shipping and payment is removed - don't
add it again from not updated class (this $cart instance does not include
the info about removed shipping and payment)
		// But there is an exception in case of forced payment or shipping
	//	if ((int)$pos_shipping_force > 0) {
			$shippingId = $cart->getShippingId();


			if (isset($shippingId) && (int)$shippingId > 0) {
				$cart->addShippingCosts($shippingId);
			}
	//	}

	//	if ((int)$pos_payment_force > 0) {
			$paymentId = $cart->getPaymentId();

			if (isset($paymentId) && (int)$paymentId > 0) {
				$cart->addPaymentCosts($paymentId);// validity of payment will be
checked
			}
	//	}


		$cart->roundTotalAmount();

		$o = $o2 = '';

		ob_start();
		echo $cart->render();
		$o = ob_get_contents();
		ob_end_clean();

		$price	= new PhocacartPrice();
		$count	= $cart->getCartCountItems();
		$total	= 0;
		$totalA	= $cart->getCartTotalItems();
		if (isset($totalA[0]['brutto'])) {
			//$total = $price->getPriceFormat($totalA['fbrutto']); Set
in Layout
			$total = $totalA[0]['brutto'];
		}




		$response = array(
			'status'	=> '1',
			'item'		=> $o,
			'message'	=> '<div class="ph-result-txt
ph-success-txt">' .
JText::_('COM_PHOCACART_PRODUCT_ADDED_TO_SHOPPING_CART') .
'</div>',
			'popup'		=> $o2,
			'count'		=> $count,
			'total'		=> $total);

		echo json_encode($response);
		return;


	}







	// Add item to cart
	function update($tpl = null){

		if (!JSession::checkToken('request')) {
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' . JText::_('JINVALID_TOKEN') .
'</div>');
			echo json_encode($response);
			return;
		}




		$app				= JFactory::getApplication();

		$item				= array();
		$item['id']			= $this->input->get( 'id', 0,
'int' );
		$item['idkey']		= $this->input->get( 'idkey',
'', 'string' );
		$item['quantity']	= $this->input->get(
'quantity', 0, 'int'  );
		$item['catid']		= $this->input->get( 'catid',
0, 'int' );
		$item['ticketid']	= $this->input->get(
'ticketid', 0, 'int' );
		$item['unitid']		= $this->input->get( 'unitid',
0, 'int' );
		$item['sectionid']	= $this->input->get(
'sectionid', 0, 'int' );
		$item['quantity']	= $this->input->get(
'quantity', 0, 'int'  );
		$item['return']		= $this->input->get( 'return',
'', 'string'  );
		$item['attribute']	= $this->input->get(
'attribute', array(), 'array'  );
		$item['checkoutview']	= $this->input->get(
'checkoutview', 0, 'int'  );
		$item['action']		= $this->input->get( 'action',
'', 'string'  );

		// Controller name in Joomla! is not called "pos" - it includes
task variable
		// so we need to set the name for controller to "pos"
		// so other parts of system (for example cart class know we are calling
it from pos controller)
		$this->input->set('controller', 'pos');
		$s 					    = PhocacartRenderStyle::getStyles();//MUST BE SET AFTER
$this->input->set('controller', 'pos'); TO GET
RIGHT CLASSES

		$user				= $vendor = $ticket = $unit	= $section = array();
		$dUser				= PhocacartUser::defineUser($user, $vendor, $ticket, $unit,
$section, 1);

		if (!isset($vendor->id) || (isset($vendor->id) &&
(int)$vendor->id < 1)) {
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' .
JText::_('COM_PHOCACART_PLEASE_LOGIN_ACCESS_POS') .
'</div>');
			echo json_encode($response);
			return;
		}
		if (!PhocacartTicket::existsTicket((int)$vendor->id,
(int)$ticket->id, (int)$unit->id, (int)$section->id)) {
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' .
JText::_('COM_PHOCACART_TICKET_DOES_NOT_EXIST') .
'</div>');
			echo json_encode($response);
			return;
		}


		if ((int)$item['idkey'] != '' &&
$item['action'] != '') {

			$cart	= new PhocacartCartRendercheckout();
			$cart->setType(array(0,2));
			$cart->params['display_image'] 			= 1;
			$cart->params['display_checkout_link'] 	= 0;

			if ($item['action'] == 'delete') {
				$updated	= $cart->updateItemsFromCheckout($item['idkey'],
0);

				if (!$updated) {

					$d 				= array();
					$d['s']			= $s;
					$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_PRODUCT_NOT_REMOVED_FROM_SHOPPING_CART')
. $msgSuffix, 'error');
					$d['info_msg']	=
PhocacartRenderFront::renderMessageQueue();;
					$layoutPE		= new JLayoutFile('popup_error', null,
array('component' => 'com_phocacart'));
					$oE 			= $layoutPE->render($d);
					$response = array(
						'status' => '0',
						'popup'	=> $oE,
						'error' => $d['info_msg']);
					echo json_encode($response);

					return;
				}


				/*if ($updated) {
					$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_REMOVED_FROM_SHOPPING_CART')
. $msgSuffix, 'message');
				} else {
					$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_PRODUCT_NOT_REMOVED_FROM_SHOPPING_CART')
. $msgSuffix, 'error');
				}*/
			} else {// update
				$updated	= $cart->updateItemsFromCheckout($item['idkey'],
(int)$item['quantity']);

				if (!$updated) {

					$d 				= array();
					$d['s']			= $s;
					$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_PRODUCT_QUANTITY_NOT_UPDATED').
$msgSuffix, 'error');
					$d['info_msg']	= PhocacartRenderFront::renderMessageQueue();
					$layoutPE		= new JLayoutFile('popup_error', null,
array('component' => 'com_phocacart'));
					$oE 			= $layoutPE->render($d);
					$response = array(
						'status' => '0',
						'popup'	=> $oE,
						'error' => $d['info_msg']);
					echo json_encode($response);

					return;
				}
				/*if ($updated) {
					$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_QUANTITY_UPDATED')
.$msgSuffix , 'message');
				} else {
					$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_PRODUCT_QUANTITY_NOT_UPDATED').
$msgSuffix, 'error');
				}*/
			}


			$cart->setFullItems();

			$cart->updateShipping();// will be decided if shipping or payment
will be removed
        	$cart->updatePayment();

			$shippingId 	= $cart->getShippingId();

			if (isset($shippingId) && (int)$shippingId > 0) {
				$cart->addShippingCosts($shippingId);
			}

			$paymentMethod 	= $cart->getPaymentMethod();
			if (isset($paymentMethod['id']) &&
(int)$paymentMethod['id'] > 0) {
				$cart->addPaymentCosts($paymentMethod['id']);// validity
of payment will be checked
			}


			$cart->roundTotalAmount();

			$o = $o2 = '';

			ob_start();
			echo $cart->render();
			$o = ob_get_contents();
			ob_end_clean();

			$price	= new PhocacartPrice();
			$count	= $cart->getCartCountItems();
			$total	= 0;
			$totalA	= $cart->getCartTotalItems();
			if (isset($totalA[0]['brutto'])) {
				//$total = $price->getPriceFormat($totalA['fbrutto']); Set
in Layout
				$total = $totalA[0]['brutto'];
			}



			$message = $item['action'] == 'delete' ?
JText::_('COM_PHOCACART_PRODUCT_REMOVED_FROM_SHOPPING_CART') :
JText::_('COM_PHOCACART_PRODUCT_QUANTITY_UPDATED');
			$response = array(
				'status'	=> '1',
				'item'		=> $o,
				'message'	=> '<div class="ph-result-txt
ph-success-txt">' . $message . '</div>',
				'popup'		=> $o2,
				'count'		=> $count,
				'total'		=> $total);

			echo json_encode($response);
			return;
		} else {



			// No action, no id - only refresh the cart (information about ticketid,
unitid, sectionid set in cart)
			$cart	= new PhocacartCartRendercheckout();
			$cart->setType(array(0,2));
			$cart->params['display_image'] 			= 1;
			$cart->params['display_checkout_link'] 	= 0;
			// Ticket id set by ticket class
			$cart->setFullItems();




			$cart->updateShipping();// will be decided if shipping or payment
will be removed
        	$cart->updatePayment();


        	$db 	= JFactory::getDBO();
			$query = ' SELECT shipping FROM #__phocacart_cart_multiple AS
a'
					.' WHERE a.vendor_id = 211';
			$db->setQuery($query);
			$vendor = $db->loadObject();


			$shippingId 	= $cart->getShippingId();

			if (isset($shippingId) && (int)$shippingId > 0) {
				$cart->addShippingCosts($shippingId);
			}

			$paymentMethod 	= $cart->getPaymentMethod();
			if (isset($paymentMethod['id']) &&
(int)$paymentMethod['id'] > 0) {
				$cart->addPaymentCosts($paymentMethod['id']);// validity
of payment will be checked
			}



			$cart->roundTotalAmount();

			$o = $o2 = '';

			ob_start();
			echo $cart->render();
			$o = ob_get_contents();
			ob_end_clean();

			$price	= new PhocacartPrice();
			$count	= $cart->getCartCountItems();
			$total	= 0;
			$totalA	= $cart->getCartTotalItems();

			if (isset($totalA[0]['brutto'])) {
				//$total = $price->getPriceFormat($totalA['fbrutto']); Set
in Layout
				$total = $totalA[0]['brutto'];
			}





			$response = array(
				'status'	=> '1',
				'item'		=> $o,
				'popup'		=> $o2,
				'count'		=> $count,
				'total'		=> $total);

			echo json_encode($response);
			return;
		}

		$response = array(
			'status' => '0',
			'popup'	=> '',
			'error' => '');
		echo json_encode($response);
		return;

	}



	function savecustomer($tpl = null){

		if (!JSession::checkToken('request')) {
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' . JText::_('JINVALID_TOKEN') .
'</div>');
			echo json_encode($response);
			return;
		}

		$app							= JFactory::getApplication();

		$item							= array();
		$item['id']						= $this->input->get( 'id', 0,
'int' );
		$item['card']					= $this->input->get( 'card',
'', 'string' );
		$item['loyalty_card_number'] 	= '';

		// Controller name in Joomla! is not called "pos" - it includes
task variable
		// so we need to set the name for controller to "pos"
		// so other parts of system (for example cart class know we are calling
it from pos controller)
		$this->input->set('controller', 'pos');
		$s 					    = PhocacartRenderStyle::getStyles();//MUST BE SET AFTER
$this->input->set('controller', 'pos'); TO GET
RIGHT CLASSES
		$user				= $vendor = $ticket = $unit	= $section = array();
		$dUser				= PhocacartUser::defineUser($user, $vendor, $ticket, $unit,
$section, 1);

		if (!isset($vendor->id) || (isset($vendor->id) &&
(int)$vendor->id < 1)) {
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' .
JText::_('COM_PHOCACART_PLEASE_LOGIN_ACCESS_POS') .
'</div>');
			echo json_encode($response);
			return;
		}
		if (!PhocacartTicket::existsTicket((int)$vendor->id,
(int)$ticket->id, (int)$unit->id, (int)$section->id)) {
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' .
JText::_('COM_PHOCACART_TICKET_DOES_NOT_EXIST') .
'</div>');
			echo json_encode($response);
			return;
		}

		if ($item['card'] != '') {


			$userByCardId = PhocacartUser::getUserIdByCard($item['card']);

			if (isset($userByCardId) && (int)$userByCardId > 0) {
				$item['id'] = (int)$userByCardId;
			} else {
				$item['id'] = 0;
				$item['loyalty_card_number'] = $item['card'];

			}
		}





		$updated = PhocacartPos::updateUserCart($vendor->id, $ticket->id,
$unit->id, $section->id, $item['id'],
$item['loyalty_card_number']);


		if ($updated) {

			// Remove shipping because shipping methods can change while chaning
users
			//PhocacartShipping::removeShippingAfterUpdate(0, 2);
			//PhocacartPayment::removePayment(0);
			$cart					= new PhocacartCartRendercheckout();
        	$cart->setType(array(0,2));
        	$cart->setFullItems();
        	$cart->updateShipping();// will be decided if shipping or
payment will be removed
			$cart->updatePayment();

			if ($item['id'] > 0 &&
$item['loyalty_card_number'] == '') {
				$msg = JText::_('COM_PHOCACART_SUCCESS_CUSTOMER_SELECTED');
			} else if ($item['loyalty_card_number'] != '') {
				$msg =
JText::_('COM_PHOCACART_SUCCESS_USER_NOT_FOUND_BY_LOYALTY_CARD_NUMBER');
				$msg .= '<br />' .
JText::_('COM_PHOCACART_ANONYMOUS_USER_SET');
			} else {
				$msg = JText::_('COM_PHOCACART_SUCCESS_CUSTOMER_DESELECTED');
			}

			$response = array(
				'status' => '1',
				'message'=> '<div class="ph-result-txt
ph-success-txt">' . $msg . '</div>');

			echo json_encode($response);
			return;
		} else {

			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' .
JText::_('COM_PHOCACART_ERROR_CART_NOT_UPDATED') .
'</div>');
			echo json_encode($response);
			return;
		}
	}


	public function saveshipping() {

	 	if (!JSession::checkToken('request')) {
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' . JText::_('JINVALID_TOKEN') .
'</div>');
			echo json_encode($response);
			return;
		}

		$app		= JFactory::getApplication();

		$item		= array();
		$item['id']	= $this->input->get( 'id', 0,
'int'  );

		// Controller name in Joomla! is not called "pos" - it includes
task variable
		// so we need to set the name for controller to "pos"
		// so other parts of system (for example cart class know we are calling
it from pos controller)
		$this->input->set('controller', 'pos');
		$s 					    = PhocacartRenderStyle::getStyles();//MUST BE SET AFTER
$this->input->set('controller', 'pos'); TO GET
RIGHT CLASSES
		$user				= $vendor = $ticket = $unit	= $section = array();
		$dUser				= PhocacartUser::defineUser($user, $vendor, $ticket, $unit,
$section, 1);

		if (!isset($vendor->id) || (isset($vendor->id) &&
(int)$vendor->id < 1)) {
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' .
JText::_('COM_PHOCACART_PLEASE_LOGIN_ACCESS_POS') .
'</div>');
			echo json_encode($response);
			return;
		}
		if (!PhocacartTicket::existsTicket((int)$vendor->id,
(int)$ticket->id, (int)$unit->id, (int)$section->id)) {
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' .
JText::_('COM_PHOCACART_TICKET_DOES_NOT_EXIST') .
'</div>');
			echo json_encode($response);
			return;
		}

		$model 	= $this->getModel('pos');
		if(!$model->saveShipping((int)$item['id'])) {
			$msg = JText::_('COM_PHOCACART_ERROR_DATA_NOT_STORED');
			$app->enqueueMessage($msg, 'error');
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' . PhocacartRenderFront::renderMessageQueue() .
'</div>');
			echo json_encode($response);
			return;
		} else {
			$msg = JText::_('COM_PHOCACART_SUCCESS_DATA_STORED');
			$app->enqueueMessage($msg, 'message');


			$response = array(
				'status' => '1',
				'message' => '<div class="ph-result-txt
ph-success-txt">' . PhocacartRenderFront::renderMessageQueue()
. '</div>');
			echo json_encode($response);
			return;
		}
	}



	public function savepayment() {

	 	if (!JSession::checkToken('request')) {
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' . JText::_('JINVALID_TOKEN') .
'</div>');
			echo json_encode($response);
			return;
		}

		$app				= JFactory::getApplication();

		$item				= array();
		$item['id']			= $this->input->get( 'id', 0,
'int'  );
		$item['phcoupon']	= $this->input->get(
'phcoupon', '', 'string'  );
		$item['phreward']	= $this->input->get(
'phreward', '', 'int'  );
		$params 			= $app->getParams();

		$enable_coupons		= $params->get( 'enable_coupons', 2 );
		$enable_rewards		= $params->get( 'enable_rewards', 1 );

		// Controller name in Joomla! is not called "pos" - it includes
task variable
		// so we need to set the name for controller to "pos"
		// so other parts of system (for example cart class know we are calling
it from pos controller)
		$this->input->set('controller', 'pos');
		$s 					    = PhocacartRenderStyle::getStyles();//MUST BE SET AFTER
$this->input->set('controller', 'pos'); TO GET
RIGHT CLASSES
		$user				= $vendor = $ticket = $unit	= $section = array();
		$dUser				= PhocacartUser::defineUser($user, $vendor, $ticket, $unit,
$section, 1);

		if (!isset($vendor->id) || (isset($vendor->id) &&
(int)$vendor->id < 1)) {
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' .
JText::_('COM_PHOCACART_PLEASE_LOGIN_ACCESS_POS') .
'</div>');
			echo json_encode($response);
			return;
		}
		if (!PhocacartTicket::existsTicket((int)$vendor->id,
(int)$ticket->id, (int)$unit->id, (int)$section->id)) {
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' .
JText::_('COM_PHOCACART_TICKET_DOES_NOT_EXIST') .
'</div>');
			echo json_encode($response);
			return;
		}

		// Coupon
		$couponId = 0;

		if (isset($item['phcoupon']) &&
$item['phcoupon'] != '' && $enable_coupons >
0) {

			$coupon = new PhocacartCoupon();
			$coupon->setType(array(0,2));
			$coupon->setCoupon(0, $item['phcoupon']);

			$couponTrue = $coupon->checkCoupon(1);// Basic Check - Coupon True
does not mean it is valid

			$couponId 	= 0;


			if ($couponTrue) {
				$couponData = $coupon->getCoupon();
				if (isset($couponData['id']) &&
$couponData['id'] > 0) {
					$couponId = $couponData['id'];
				}
			}

			if(!$couponId) {
				$msg =
JText::_('COM_PHOCACART_COUPON_INVALID_EXPIRED_REACHED_USAGE_LIMIT');
				$app->enqueueMessage($msg, 'error');
			} else {
				$msg = JText::_('COM_PHOCACART_COUPON_ADDED');
				$app->enqueueMessage($msg, 'message');
			}
		}

		$rewards 			= array();
		$rewards['used'] 	= 0;

		if (isset($item['phreward']) &&
$item['phreward'] != '' && $enable_rewards) {

			$reward 			= new PhocacartReward();
			$rewards['used']	=
$reward->checkReward((int)$item['phreward'], 1);


			if($rewards['used'] === false) {
				$msg = JText::_('COM_PHOCACART_REWARD_POINTS_NOT_ADDED');
				$app->enqueueMessage($msg, 'error');
			} else {
				$msg = JText::_('COM_PHOCACART_REWARD_POINTS_ADDED');
				$app->enqueueMessage($msg, 'message');
			}

		}



		$model 	= $this->getModel('pos');


		if(!$model->savePaymentAndCouponAndReward((int)$item['id'],
$couponId, $rewards['used'])) {
			$msg = JText::_('COM_PHOCACART_ERROR_DATA_NOT_STORED');
			$app->enqueueMessage($msg, 'error');
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' . PhocacartRenderFront::renderMessageQueue() .
'</div>');
			echo json_encode($response);
			return;
		} else {
			$msg = JText::_('COM_PHOCACART_SUCCESS_DATA_STORED');
			$app->enqueueMessage($msg, 'message');
			$response = array(
				'status' => '1',
				'message' => '<div class="ph-result-txt
ph-success-txt">' . PhocacartRenderFront::renderMessageQueue()
. '</div>');
			echo json_encode($response);
			return;
		}
	}


	/*public function printserver() {

		$app				= JFactory::getApplication();
		$item				= array();
		$params 			= $app->getParams();
		$pos_server_print	= $params->get( 'pos_server_print', 0 );
		$item['id']			= $this->input->get( 'id', 0,
'int'  );// Order ID

	}*/


	public function order() {


		if (!JSession::checkToken('request')) {
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' . JText::_('JINVALID_TOKEN') .
'</div>');
			echo json_encode($response);
			return;
		}

		$app				= JFactory::getApplication();

		$item				= array();

		$item									= array();
		$item['amount_tendered']				= $this->input->get(
'phAmountTendered', '', 'string'  );
		$item['amount_pay']						= $this->input->get(
'phTotalAmount', '', 'string'  );
		//$item['amount_change']					= $this->input->get(
'phAmountChange', '', 'string'  );


		if ($item['amount_pay'] > 0 &&
$item['amount_tendered'] > 0) {
			$item['amount_change'] = $item['amount_tendered'] -
$item['amount_pay'];
		} else if ($item['amount_pay'] > 0) {

			$item['amount_tendered']= 0;
			$item['amount_change']	= 0;
		} else {
			$item['amount_tendered']= 0;
			$item['amount_pay']		= 0;
			$item['amount_change']	= 0;
		}

		$params 			= $app->getParams();
		$pos_server_print	= $params->get( 'pos_server_print', 0 );

		// Controller name in Joomla! is not called "pos" - it includes
task variable
		// so we need to set the name for controller to "pos"
		// so other parts of system (for example cart class know we are calling
it from pos controller)
		$this->input->set('controller', 'pos');
		$s 					    = PhocacartRenderStyle::getStyles();//MUST BE SET AFTER
$this->input->set('controller', 'pos'); TO GET
RIGHT CLASSES
		$user				= $vendor = $ticket = $unit	= $section = array();
		$dUser				= PhocacartUser::defineUser($user, $vendor, $ticket, $unit,
$section, 1);

		if (!isset($vendor->id) || (isset($vendor->id) &&
(int)$vendor->id < 1)) {
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' .
JText::_('COM_PHOCACART_PLEASE_LOGIN_ACCESS_POS') .
'</div>');
			echo json_encode($response);
			return;
		}
		if (!PhocacartTicket::existsTicket((int)$vendor->id,
(int)$ticket->id, (int)$unit->id, (int)$section->id)) {
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' .
JText::_('COM_PHOCACART_TICKET_DOES_NOT_EXIST') .
'</div>');
			echo json_encode($response);
			return;
		}





		$order = new PhocacartOrder();
		$order->setType(array(0,2));
		$orderMade = $order->saveOrderMain($item);



		if(!$orderMade) {
			$msg = '';
			if (!PhocacartUtils::issetMessage()){
				$msg = JText::_('COM_PHOCACART_ORDER_ERROR_PROCESSING');
			}
			$app->enqueueMessage($msg, 'error');
			$response = array(
				'status' => '0',
				'error' => '<div class="ph-result-txt
ph-error-txt">' . PhocacartRenderFront::renderMessageQueue() .
'</div>');
			echo json_encode($response);
			return;

		} else {

			$cart = new PhocacartCart();

			// Before removing current cart after payment get the info about current
vendor,ticket,unit,section
			// to create new empty ticket after payment
			$vendorId			= $cart->getVendorId();
			$ticketId			= $cart->getTicketId();
			$unitId				= $cart->getUnitId();
			$sectionId			= $cart->getSectionId();

			$cart->emptyCart();
			PhocacartUserGuestuser::cancelGuestUser();

			$action 	= $order->getActionAfterOrder();// Which action should be
done
			$message	= $order->getMessageAfterOrder();// Custom message by
payment plugin Payment/Download, Payment/No Download ...


			// Create empty ticket (with the same ticket, unit and section) after
this current was removed
			PhocacartTicket::addNewVendorTicket($vendorId, $ticketId, $unitId,
$sectionId);
		/*	$msg = '';
			if (!empty($message)) {
				foreach ($message as $k => $v) {
					print r($v);
				}
			}*/
			$msg =
JText::_('COM_PHOCACART_ORDER_HAS_BEEN_SAVED_SUCCESSFULLY');


			// PRINT SERVER PRINT
			if ($pos_server_print == 1 || $pos_server_print == 3) {
				$order	= new PhocacartOrderRender();
				$o = $order->render((int)$orderMade, 4, 'raw',
'', 1);

				try{

					$printPos = new PhocacartPosPrint(1);
					$printPos->printOrder($o);
					//echo JText::_('COM_PHOCACART_RECEIPT_SENT_TO_PRINTER');
				} catch(Exception $e) {
					$msg .= "<br />" .
JText::_('COM_PHOCACART_ERROR'). ': '.
$e->getMessage();
					/*$response = array(
					'status' => '1',
					'id'	=> (int)$orderMade,
					'message' => '<div class="ph-result-txt
ph-error-txt">' .$msg . '</div>');
					echo json_encode($response);
					return;*/
				}


			}

			$session 	= JFactory::getSession();
			if ($action == 4 || $action == 3) {
				// Ordered OK, but now we proceed to payment
				//$session->set('infoaction', $action,
'phocaCart');
				//$session->set('infomessage', $message,
'phocaCart');
				$response = array(
				'status' => '1',
				'id'	=> (int)$orderMade,
				'message' => '<div class="ph-result-txt
ph-success-txt">' .$msg . '</div>');
				echo json_encode($response);
				return;
				//return true;
				// This message should stay
				// when order - the message is created
				// when payment - the message stays unchanged
				// after payment - it will be redirected to info view and there the
message will be displayed and then deleted

			} else {
				// Ordered OK, but the payment method does not have any instruction to
proceed to payment (e.g. cash on delivery)
				//$msg =
JText::_('COM_PHOCACART_ORDER_SUCCESSFULLY_PROCESSED');
				// We produce not message but we redirect to specific view with message
and additional instructions
				//$app->enqueueMessage($msg, 'message');
				$response = array(
				'status' => '1',
				'id'	=> (int)$orderMade,
				'message' => '<div class="ph-result-txt
ph-success-txt">' .$msg . '</div>');
				echo json_encode($response);
				return;
				//$session->set('infoaction', $action,
'phocaCart');
				//$session->set('infomessage', $message,
'phocaCart');
				//$app->redirect(JRoute::_(PhocacartRoute::getInfoRoute(), false));
				return true;
			}
		}


	}
}
?>
PK��[�L�[[pos.phpnu�[���<?php
/* @package Joomla
 * @copyright Copyright (C) Open Source Matters. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * @extension Phoca Extension
 * @copyright Copyright (C) Jan Pavelka www.phoca.cz
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
defined('_JEXEC') or die();

use Joomla\CMS\Uri\Uri;

class PhocaCartControllerPos extends JControllerForm
{

	public function addticket() {

		JSession::checkToken() or jexit( 'Invalid Token' );
		$app 				= JFactory::getApplication();
		$session 			= JFactory::getSession();
		$item				= array();
		$item['return']		= $this->input->get( 'return',
'', 'string'  );
		$item['unitid']		= $this->input->get( 'unitid',
0, 'int'  );
		$item['sectionid']	= $this->input->get(
'sectionid', 0, 'int'  );
		$user				= $vendor = $ticket = $unit	= $section = array();
		$dUser				= PhocacartUser::defineUser($user, $vendor, $ticket, $unit,
$section, 1);

		if (isset($vendor->id) && (int)$vendor->id > 0) {
			$lastTicket = PhocacartTicket::getLastVendorTicket((int)$vendor->id,
(int)$item['unitid'], (int)$item['sectionid']);

			if (!isset($lastTicket) || (isset($lastTicket)&&
(int)$lastTicket == 0)) {
				// Create the default ticket: 1
				$added = PhocaCartTicket::addNewVendorTicket((int)$vendor->id, 1,
(int)$item['unitid'], (int)$item['sectionid']);
				if ($added) {
					$lastTicket = 1;

				}
			}
			if (isset($lastTicket) && (int)$lastTicket > 0) {
				$ticket = $lastTicket + 1;

				$added = PhocaCartTicket::addNewVendorTicket((int)$vendor->id,
(int)$ticket, (int)$item['unitid'],
(int)$item['sectionid']);
				if ($added) {
					$url = base64_decode($item['return']);
					$uri = Uri::getInstance(base64_decode($item['return']));
					//$oldTicketId = $uri->getVar('ticketid');
					$uri->setVar('ticketid', $ticket);
					$app->redirect($uri->toString());
					return true;
				}
			}
		}
		$app->redirect(base64_decode($item['return']));
	}

	public function removeticket() {

		JSession::checkToken() or jexit( 'Invalid Token' );
		$app 				= JFactory::getApplication();
		$session 			= JFactory::getSession();
		$item				= array();
		$item['return']		= $this->input->get( 'return',
'', 'string'  );
		$item['ticketid']	= $this->input->get(
'ticketid', 0, 'int'  );
		$item['unitid']		= $this->input->get( 'unitid',
0, 'int'  );
		$item['sectionid']	= $this->input->get(
'sectionid', 0, 'int'  );
		$user				= $vendor = $ticket = $unit	= $section = array();
		$dUser				= PhocacartUser::defineUser($user, $vendor, $ticket, $unit,
$section, 1);

		if (isset($vendor->id) && (int)$vendor->id > 0) {

			//if (isset($lastTicket) && (int)$lastTicket > 0) {

				$removed = PhocaCartTicket::removeVendorTicket((int)$vendor->id,
(int)$item['ticketid'], (int)$item['unitid'],
(int)$item['sectionid']);
				if ($removed) {
					$url = base64_decode($item['return']);
					$uri = Uri::getInstance(base64_decode($item['return']));
					//$oldTicketId = $uri->getVar('ticketid');
					$uri->setVar('ticketid', 1);
					$app->redirect($uri->toString());
					return true;
				}
			//}
		}
		$app->redirect(base64_decode($item['return']));

	}

	/*
	 * Add product to cart
	 * see pos.json
	 */
	public function add() {

		JSession::checkToken() or jexit( 'Invalid Token' );
		$app				= JFactory::getApplication();
		$item				= array();
		$item['id']			= $this->input->get( 'id', 0,
'int' );
		$item['catid']		= $this->input->get( 'catid',
0, 'int' );
		$item['quantity']	= $this->input->get(
'quantity', 0, 'int'  );
		$item['return']		= $this->input->get( 'return',
'', 'string'  );
		$item['attribute']	= $this->input->get(
'attribute', array(), 'array'  );

		/*
		$cart	= new PhocacartCart();

		$added	= $cart->addItems((int)$item['id'],
(int)$item['catid'], (int)$item['quantity'],
$item['attribute']);

		if ($added) {
			$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_ADDED_TO_SHOPPING_CART'),
'message');
		} else {
			$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_NOT_ADDED_TO_SHOPPING_CART'),
'error');
		}
		//$app->redirect(JRoute::_('index.php?option=com_phocacart&view=checkout'));*/

		$app->redirect(base64_decode($item['return']));
	}


}
?>
PK��[�Q�0�2�2question.phpnu�[���<?php
/* @package Joomla
 * @copyright Copyright (C) Open Source Matters. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * @extension Phoca Extension
 * @copyright Copyright (C) Jan Pavelka www.phoca.cz
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
defined('_JEXEC') or die();

class PhocaCartControllerQuestion extends JControllerForm
{

	function submit() {

		JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
		$session = JFactory::getSession();

		$app    = JFactory::getApplication();
		$uri 	= \Joomla\CMS\Uri\Uri::getInstance();
		$user 	= PhocacartUser::getUser();

		$params 							= PhocacartUtils::getComponentParameters() ;
		$enable_ask_question 				=
$params->get('enable_ask_question', 0);
		$display_question_privacy_checkbox	= $params->get(
'display_question_privacy_checkbox', 0 );

		if ($enable_ask_question == 0) {
			throw new
Exception(JText::_('COM_PHOCACART_ASK_QUESTION_DISABLED'), 500);
			return false;
		}

		$namespace  		= 'phccrt' .
$params->get('session_suffix');
		$data  				= $this->input->post->get('jform', array(),
'array');
		$item['privacy']	= $this->input->get(
'privacy', false, 'string'  );

		$data['privacy'] 	= $item['privacy'] ? 1 : 0;

		if ($display_question_privacy_checkbox == 2 &&
$data['privacy'] == 0) {
			$msg =
JText::_('COM_PHOCACART_ERROR_YOU_NEED_TO_AGREE_TO_PRIVACY_TERMS_AND_CONDITIONS');
			$app->enqueueMessage($msg, 'error');
			$app->redirect(JRoute::_($uri));
			return false;

		}

		// Additional data
		$data['ip'] = PhocacartUtils::getIp();

		// Only because of information in LOG
		$productId = '';
		if (isset($data['product_id']) &&
(int)$data['product_id'] > 0) {
			$productId = (int)$data['product_id'];
		}

		// *** SECURITY
		// Default session test always enabled!
		$valid = $session->get('form_id', NULL, $namespace);
		$session->clear('form_id', $namespace);
		if (!$valid){
			$app->setUserState('com_phocacart.question.data',
'');
			$session->clear('time', $namespace);

			PhocacartLog::add(3, 'Ask a Question - Not valid session',
$productId, 'IP: '. $data['ip'].', User ID:
'.$user->id . ', User Name: '.$user->username);
			//jexit(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'));
			throw new
Exception(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'), 500);
			return false;
		}

		$model  = $this->getModel('question');

		// *** SECURITY
		// Hidden Field
		if ($params->get('enable_hidden_field_question', 0) == 1) {
			$params->set('hidden_field_id',
$session->get('hidden_field_id', 'fieldnotvalid',
$namespace));
			$params->set('hidden_field_name',
$session->get('hidden_field_name', 'fieldnotvalid',
$namespace));
			$hiddenField = $session->get('hidden_field_name',
'fieldnotvalid', $namespace);

			$session->clear('hidden_field_id', $namespace);
			$session->clear('hidden_field_name', $namespace);
			$session->clear('hidden_field_class', $namespace);

			if ($params->get('hidden_field_id') ==
'fieldnotvalid') {
				$app->setUserState('com_phocacart.question.data',
'');
				$session->clear('time', $namespace);

				PhocacartLog::add(3, 'Ask a Question - Hidden Field Error',
$productId, 'IP: '. $data['ip'].', User ID:
'.$user->id . ', User Name: '.$user->username);
				throw new
Exception(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'), 500);
				return false;
			}

			// Hidden field was filled
			if (isset($data[$hiddenField]) && $data[$hiddenField] !=
'') {
				$app->setUserState('com_phocacart.question.data',
'');
				$session->clear('time', $namespace);

				PhocacartLog::add(3, 'Ask a Question - Hidden Field Filled',
$productId, 'IP: '. $data['ip'].', User ID:
'.$user->id . ', User Name: '.$user->username);
				throw new
Exception(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'), 500);
				return false;
			}

		}

		// *** SECURITY
		// Check for a valid session cookie
		if($session->getState() != 'active'){
			// Save the data in the session.
			$app->setUserState('com_phocacart.submit.data', $data);
			$message = JText::_( 'COM_PHOCACART_SESSION_INVALID' );
			$app->enqueueMessage($message, 'error');

			PhocacartLog::add(3, 'Ask a Question - Session not active',
$productId, 'IP: '. $data['ip'].', User ID:
'.$user->id . ', User Name: '.$user->username.',
Message: '.$message);
			$app->redirect(JRoute::_($uri));
			return false;
		}

		// *** SECURITY
		// Task
		$task = $this->input->get('task');

		if ($task == 'phocacart.submit') {
			$task = 'submit';
		}
		if (($this->input->get('view') != 'question')
|| ($this->input->get('option') !=
'com_phocacart') || ($task != 'submit')) {
			$app->setUserState('com_phocacart.question.data',
'');
			$session->clear('time', $namespace);

			PhocacartLog::add(3, 'Ask a Question - No Phoca Cart part',
$productId, 'IP: '. $data['ip'].', User ID:
'.$user->id . ', User Name: '.$user->username);
			throw new
Exception(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'), 500);
			return false;
		}

		// *** SECURITY
		// Check Time
	    if((int)$params->get('enable_time_check_question', 0)
> 0) {
            $time = $session->get('time', null, $namespace);
            $delta = time() - $time;

			if($params->get('enable_time_check_question', 0) &&
$delta <= (int)$params->get('enable_time_check_question',
0)) {

				$app->setUserState('com_phocacart.question.data', $data);
				$message = JText::_( 'COM_PHOCACART_SUBMIT_TOO_FAST' );
				$app->enqueueMessage($message, 'error');

				PhocacartLog::add(3, 'Ask a Question - Submit too fast',
$productId, 'IP: '. $data['ip'].', User ID:
'.$user->id . ', User Name: '.$user->username.',
Message: '.$message . ', Time: '. $delta . '
sec.');
				$app->redirect(JRoute::_($uri));
				return false;
            }
        }

		// ***SECURITY
		// IP Ban
		if ($params->get('ip_ban', '') != '') {

			$isSpam = PhocacartSecurity::checkIpAddress($data['ip'],
$params->get('ip_ban'));

			if ($isSpam) {
				//$app->setUserState('com_phocacart.question.data',
$data);	// Save the data in the session.
				//$message = JText::_( 'COM_PHOCACART_POSSIBLE_SPAM_DETECTED'
);
				//$app->enqueueMessage($message, 'error');
				//$app->redirect(JRoute::_($uri));

				$app->setUserState('com_phocacart.question.data',
'');
				$session->clear('time', $namespace);

				PhocacartLog::add(3, 'Ask a Question - IP Ban', $productId,
'IP: '. $data['ip'].', User ID:
'.$user->id . ', User Name: '.$user->username);
				throw new
Exception(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'), 500);
				return false;
			}
		}

		// *** SECURITY
		// Validate the posted data.
		$form = $model->getForm();
		if (!$form) {
			$app->setUserState('com_phocacart.question.data',
'');
			$session->clear('time', $namespace);

			PhocacartLog::add(2, 'Ask a Question - ERROR - Model not
loaded', $productId, 'IP: '. $data['ip'].',
User ID: '.$user->id . ', User Name:
'.$user->username.', Message: '.$model->getError());
			throw new Exception($model->getError(), 500);
			return false;
		}

		// *** SECURITY
		// VALIDATE - continue with validation in case of problem
		$continueValidate 	= true;

		// SECURITY
		// Captcha - is validated in RULES of FORM FIELD - Exception for validate
fields
		$captchaId = 1;//Possible parameters in Options for different captchas
(reCaptcha = 1)
		switch ($captchaId) {
			case 1: // reCaptcha uses virtual field, so we cannot check the field
set in form
				$data['phq_captcha'] = 'OK';
			break;
		}

		$validate 			= $model->validate($form, $data);

		if ($validate === false) {
			$errors	= $model->getErrors();


			// Get (possible) attack issues
			for ($i = 0, $n = count($errors); $i < $n && $i < 5; $i++)
{


				if (($errors[$i] instanceof \Exception) &&
($errors[$i]->getCode() == E_ERROR)) {
					$app->setUserState('com_phocacart.question.data',
'');
					$session->clear('time', $namespace);

					PhocacartLog::add(2, 'Ask a Question - Validate errors',
$productId, 'IP: '. $data['ip'].', User ID:
'.$user->id . ', User Name: '.$user->username);

					$app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'),
'error');
					$app->redirect(JRoute::_($uri));
					return false;
				} else {

					$app->enqueueMessage($errors[$i]->getMessage(),
'warning');
					$continueValidate = false;
				}

			}
			// Validate error message are now in stack, so no more render
			// just redirect back to the form with information about problems and
fill the form field
			$continueValidate = false;
		}


		$data = $validate;


		// *** SECURITY
		// Forbidden Word Filter
		$fwfa	= explode( ',', trim(
$params->get('forbidden_word_filter', '') ) );
		$fwwfa	= explode( ',', trim(
$params->get('forbidden_whole_word_filter', '') ) );

		foreach ($fwfa as $item) {
			if (trim($item) != '') {

				if (isset($data['message']) &&
stripos($data['message'], trim($item)) !== false) {
					$continueValidate = false;
					PhocacartLog::add(3, 'Ask a Question - Forbidden Word Filder -
Message', $productId, 'Word: '.$item.', IP: '.
$data['ip'].', User ID: '.$user->id);
					$app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'
), 'warning');
				}
				if (isset($data['name']) &&
stripos($data['name'], trim($item)) !== false) {
					$continueValidate = false;
					PhocacartLog::add(3, 'Ask a Question - Forbidden Word Filder -
Name', $productId, 'Word: '.$item.', IP: '.
$data['ip'].', User ID: '.$user->id);
					$app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'
), 'warning');
				}
				if (isset($data['phone']) &&
stripos($data['phone'], trim($item)) !== false) {
					$continueValidate = false;
					PhocacartLog::add(3, 'Ask a Question - Forbidden Word Filder -
Phone', $productId, 'Word: '.$item.', IP: '.
$data['ip'].', User ID: '.$user->id);
					$app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'
), 'warning');
				}
				if (isset($data['email']) &&
stripos($data['email'], trim($item)) !== false) {
					$continueValidate = false;
					PhocacartLog::add(3, 'Ask a Question - Forbidden Word Filder -
Email', $productId, 'Word: '.$item.', IP: '.
$data['ip'].', User ID: '.$user->id);
					$app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'
), 'warning');
				}
			}
		}

		foreach ($fwwfa as $item) {
			if ($item != '') {
				$itemBase		= trim($item);
				$item			=
"/(^|[^a-zA-Z0-9_]){1}(".preg_quote(($item),"/").")($|[^a-zA-Z0-9_]){1}/i";


				if (isset($data['message']) && preg_match( $item,
$data['message']) == 1) {
					$continueValidate = false;
					PhocacartLog::add(3, 'Ask a Question - Forbidden Whole Word
Filder - Message', $productId, 'Word: '.$itemBase.',
IP: '. $data['ip'].', User ID: '.$user->id);
					$app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'
), 'warning');
				}
				if (isset($data['name']) && preg_match( $item,
$data['name']) == 1) {
					$continueValidate = false;
					PhocacartLog::add(3, 'Ask a Question - Forbidden Whole Word
Filder - Name', $productId, 'Word: '.$itemBase.', IP:
'. $data['ip'].', User ID: '.$user->id);
					$app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'
), 'warning');
				}
				if (isset($data['phone']) && preg_match( $item,
$data['phone']) == 1) {
					$continueValidate = false;
					PhocacartLog::add(3, 'Ask a Question - Forbidden Whole Word
Filder - Phone', $productId, 'Word: '.$itemBase.', IP:
'. $data['ip'].', User ID: '.$user->id);
					$app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'
), 'warning');
				}
				if (isset($data['email']) && preg_match( $item,
$data['email']) == 1) {
					$continueValidate = false;
					PhocacartLog::add(3, 'Ask a Question - Forbidden Whole Word
Filder - Email', $productId, 'Word: '.$itemBase.', IP:
'. $data['ip'].', User ID: '.$user->id);
					$app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'
), 'warning');
				}
			}
		}


		// remove captcha from data after check
		$data['phq_captcha'] = '';

		if ($continueValidate == false) {
			// Save the data in the session.
			$app->setUserState('com_phocacart.question.data', $data);
			// Log added before
			$app->redirect(JRoute::_($uri));
			return false;
		}


		// CHECKS DONE - store entry
		$msg = '';
		if ($model->store($data)) {

			$msg = JText::_(
'COM_PHOCACART_THANK_YOU_FOR_LEAVING_INFORMATION_ASKING_QUESTION'
);
		} else {
			$app->setUserState('com_phocacart.question.data',
'');
			$session->clear('time', $namespace);

			PhocacartLog::add(2, 'Ask a Question - ERROR - Model store
error', $productId, 'IP: '. $data['ip'].',
User ID: '.$user->id . ', User Name:
'.$user->username.', Message: '.$model->getError());

			throw new Exception($model->getError(), 500);
			return false;
		}



		// Flush the data from the session
		$app->setUserState('com_phocacart.question.data',
'');
		//$session->clear('time', $namespace);
		$app->setUserState('com_phocacart.question.data',
'success_post_saved');
		$app->enqueueMessage($msg, 'success');
		$this->setRedirect($uri->toString());

		return true;
	}
}
?>
PK��[�B���response.phpnu�[���<?php
/* @package Joomla
 * @copyright Copyright (C) Open Source Matters. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * @extension Phoca Extension
 * @copyright Copyright (C) Jan Pavelka www.phoca.cz
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
defined('_JEXEC') or die();
jimport('joomla.log.log');
JLog::addLogger( array('text_file' =>
'com_phocacart_error_log.php'), JLog::ALL,
array('com_phocacart'));

class PhocaCartControllerResponse extends JControllerForm
{

	// User gets info
	public function paymentrecieve() {

		$app		= JFactory::getApplication();
		$session 	= JFactory::getSession();
		$session->set('proceedpayment', array(),
'phocaCart');

		//JSession::checkToken() or jexit( 'Invalid Token' );
		$return = PhocacartRoute::getInfoRoute();
		//$app->enqueueMessage(JText::_('COM_PHOCACART_PAYMENT_RECEIVED'),
'message');
		//$session->set('infoaction', 3, 'phocaCart');
		//$session->set('infoaction', 4, 'phocaCart');
		// NO message here, we have set the message during order and it stays
unchanged as it is in session
		// the message will be deleted after it will be displayed in view

		$type 		= $app->input->get('type', '',
'string');
		$mid 		= $app->input->get('mid', 0, 'int'); //
message id - possible different message IDs

		$message	= array();
		//$dispatcher = J EventDispatcher::getInstance();
		$plugin 	= JPluginHelper::importPlugin('pcp',
htmlspecialchars(strip_tags($type)));
		if ($plugin) {
			$eventData 					= array();
            $eventData['pluginname'] 	=
htmlspecialchars(strip_tags($type));
			\JFactory::getApplication()->triggerEvent('PCPafterRecievePayment',
array($mid, &$message, $eventData));
		}

		if (!empty($message)) {
			$session->set('infomessage', $message,
'phocaCart');
		}
		$app->redirect($return);
	}

	// User gets info
	public function paymentcancel() {

		$app		= JFactory::getApplication();
		$session 	= JFactory::getSession();
		$session->set('proceedpayment', array(),
'phocaCart');
		//JSession::checkToken() or jexit( 'Invalid Token' );

		$type 		= $app->input->get('type', '',
'string');
		$mid 		= $app->input->get('mid', 0, 'int'); //
message id - possible different message IDs
		$message	= array();
		//$dispatcher = J EventDispatcher::getInstance();
		$plugin 	= JPluginHelper::importPlugin('pcp',
htmlspecialchars(strip_tags($type)));
		if ($plugin) {
			$eventData 					= array();
            $eventData['pluginname'] 	=
htmlspecialchars(strip_tags($type));
			\JFactory::getApplication()->triggerEvent('PCPafterCancelPayment',
array($mid, &$message, $eventData));
		}

		$return = PhocacartRoute::getInfoRoute();
		$session->set('infoaction', 5, 'phocaCart');
		$session->set('infomessage', $message,
'phocaCart');
		//$app->enqueueMessage(JText::_('COM_PHOCACART_PAYMENT_CANCELED'),
'info');
		$app->redirect($return);
	}


	// Robot gets info
	public function paymentnotify() {

		$app 	= JFactory::getApplication();
		$type 	= $app->input->get('type', '',
'string');
		$pid 	= $app->input->get('pid', 0, 'int'); //
payment id
		$uri	= \Joomla\CMS\Uri\Uri::getInstance();

		//$dispatcher = J EventDispatcher::getInstance();
		$plugin = JPluginHelper::importPlugin('pcp',
htmlspecialchars(strip_tags($type)));
		if ($plugin) {
			$eventData 					= array();
            $eventData['pluginname'] 	=
htmlspecialchars(strip_tags($type));
			\JFactory::getApplication()->triggerEvent('PCPbeforeCheckPayment',
array($pid, $eventData));
		} else {

			JLog::add('Payment method: '."Invalid HTTP request
method. Type: " . $type . " Uri: " . $uri->toString(),
'com_phocacart');
            header('Allow: POST', true, 405);
            throw new Exception("Invalid HTTP request method.");
		}

		exit;
	}


	public function paymentwebhook() {

		$app 	= JFactory::getApplication();
		$type 	= $app->input->get('type', '',
'string');
		$pid 	= $app->input->get('pid', 0, 'int'); //
payment id
		$uri	= \Joomla\CMS\Uri\Uri::getInstance();

		//$dispatcher = J EventDispatcher::getInstance();
		$plugin = JPluginHelper::importPlugin('pcp',
htmlspecialchars(strip_tags($type)));
		if ($plugin) {
			$eventData 					= array();
            $eventData['pluginname'] 	=
htmlspecialchars(strip_tags($type));
			\JFactory::getApplication()->triggerEvent('PCPonPaymentWebhook',
array($pid, $eventData));
		} else {

			JLog::add('Payment method: '."Invalid HTTP request
method. Type: " . $type . " Uri: " . $uri->toString(),
'com_phocacart');
			header('Allow: POST', true, 405);
			throw new Exception("Invalid HTTP request method.");
		}
		exit;
	}

}
?>
PK��[��ߦ55
submit.phpnu�[���<?php
/* @package Joomla
 * @copyright Copyright (C) Open Source Matters. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * @extension Phoca Extension
 * @copyright Copyright (C) Jan Pavelka www.phoca.cz
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
defined('_JEXEC') or die();

class PhocaCartControllerSubmit extends JControllerForm
{

	function submit() {

		JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
		$session = JFactory::getSession();

		$app    = JFactory::getApplication();
		$uri 	= \Joomla\CMS\Uri\Uri::getInstance();
		$user 	= PhocacartUser::getUser();

		$params 									= PhocacartUtils::getComponentParameters() ;
		$enable_submit_item 						=
$params->get('enable_submit_item', 0);
		$display_submit_item_privacy_checkbox		= $params->get(
'display_submit_item_privacy_checkbox', 0 );

		$submit_item_form_fields					= $params->get(
'submit_item_form_fields', '' );
		$submit_item_form_fields_contact			= $params->get(
'submit_item_form_fields_contact', '' );

		$formFields = array_map('trim', explode(',',
$submit_item_form_fields));
		$formFields = array_unique($formFields);
		$formFieldsC = array_map('trim', explode(',',
$submit_item_form_fields_contact));
		$formFieldsC = array_unique($formFieldsC);

		$imageRequired = false;
		if (in_array('image*', $formFields)) {
			$imageRequired = true;
		}

		if ($enable_submit_item == 0) {
			throw new
Exception(JText::_('COM_PHOCACART_SUBMIT_ITEM_DISABLED'), 500);
			return false;
		}

		if (!PhocacartSubmit::isAllowedToSubmit()) {
			throw new
Exception(JText::_('COM_PHOCACART_SUBMIT_ITEM_NOT_ALLOWED'),
500);
			return false;
		}

		$namespace  		= 'phccrt' .
$params->get('session_suffix');
		$data  				= $this->input->post->get('jform', array(),
'array');
		$file 				= JFactory::getApplication()->input->files->get(
'jform', null, 'raw');
		$item['privacy']	= $this->input->get(
'privacy', false, 'string'  );

		$data['privacy'] 	= $item['privacy'] ? 1 : 0;

		if ($display_submit_item_privacy_checkbox == 2 &&
$data['privacy'] == 0) {
			$msg =
JText::_('COM_PHOCACART_ERROR_YOU_NEED_TO_AGREE_TO_PRIVACY_TERMS_AND_CONDITIONS');
			$app->enqueueMessage($msg, 'error');
			$app->redirect(JRoute::_($uri));
			return false;

		}

		// Additional data
		$data['ip'] = PhocacartUtils::getIp();

		// *** SECURITY
		// Default session test always enabled!
		$valid = $session->get('form_id', NULL, $namespace);
		$session->clear('form_id', $namespace);
		if (!$valid){
			$app->setUserState('com_phocacart.submit.data',
'');
			$session->clear('time', $namespace);

			PhocacartLog::add(3, 'Submit Item - Not valid session', 0,
'IP: '. $data['ip'].', User ID:
'.$user->id . ', User Name: '.$user->username);
			//jexit(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'));

			throw new
Exception(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'), 500);
			return false;
		}

		$model  = $this->getModel('submit');

		// *** SECURITY
		// Hidden Field
		if ($params->get('enable_hidden_field_submit_item', 0) == 1)
{
			$params->set('hidden_field_id',
$session->get('hidden_field_id', 'fieldnotvalid',
$namespace));
			$params->set('hidden_field_name',
$session->get('hidden_field_name', 'fieldnotvalid',
$namespace));
			$hiddenField = $session->get('hidden_field_name',
'fieldnotvalid', $namespace);

			$session->clear('hidden_field_id', $namespace);
			$session->clear('hidden_field_name', $namespace);
			$session->clear('hidden_field_class', $namespace);

			if ($params->get('hidden_field_id') ==
'fieldnotvalid') {
				$app->setUserState('com_phocacart.submit.data',
'');
				$session->clear('time', $namespace);

				PhocacartLog::add(3, 'Submit Item - Hidden Field Error', 0,
'IP: '. $data['ip'].', User ID:
'.$user->id . ', User Name: '.$user->username);
				throw new
Exception(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'), 500);
				return false;
			}

			// Hidden field was filled
			if (isset($data[$hiddenField]) && $data[$hiddenField] !=
'') {
				$app->setUserState('com_phocacart.submit.data',
'');
				$session->clear('time', $namespace);

				PhocacartLog::add(3, 'Submit Item - Hidden Field Filled', 0,
'IP: '. $data['ip'].', User ID:
'.$user->id . ', User Name: '.$user->username);
				throw new
Exception(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'), 500);
				return false;
			}

		}

		// *** SECURITY
		// Check for a valid session cookie
		if($session->getState() != 'active'){
			// Save the data in the session.
			$app->setUserState('com_phocacart.submit.data', $data);
			$message = JText::_( 'COM_PHOCACART_SESSION_INVALID' );
			$app->enqueueMessage($message, 'error');

			PhocacartLog::add(3, 'Submit Item - Session not active', 0,
'IP: '. $data['ip'].', User ID:
'.$user->id . ', User Name: '.$user->username.',
Message: '.$message);
			$app->redirect(JRoute::_($uri));
			return false;
		}

		// *** SECURITY
		// Task
		$task = $this->input->get('task');

		if ($task == 'phocacart.submit') {
			$task = 'submit';
		}
		if (($this->input->get('view') != 'submit') ||
($this->input->get('option') != 'com_phocacart')
|| ($task != 'submit')) {
			$app->setUserState('com_phocacart.submit.data',
'');
			$session->clear('time', $namespace);

			PhocacartLog::add(3, 'Submit Item - No Phoca Cart part', 0,
'IP: '. $data['ip'].', User ID:
'.$user->id . ', User Name: '.$user->username);
			throw new
Exception(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'), 500);
			return false;
		}

		// *** SECURITY
		// Check Time
	    if((int)$params->get('enable_time_check_submit_item', 0)
> 0) {
            $time = $session->get('time', null, $namespace);
            $delta = time() - $time;

			if($params->get('enable_time_check_submit_item', 0)
&& $delta <=
(int)$params->get('enable_time_check_submit_item', 0)) {

				$app->setUserState('com_phocacart.submit.data', $data);
				$message = JText::_( 'COM_PHOCACART_SUBMIT_TOO_FAST' );
				$app->enqueueMessage($message, 'error');

				PhocacartLog::add(3, 'Submit Item - Submit too fast', 0,
'IP: '. $data['ip'].', User ID:
'.$user->id . ', User Name: '.$user->username.',
Message: '.$message . ', Time: '. $delta . '
sec.');
				$app->redirect(JRoute::_($uri));
				return false;
            }
        }

		// ***SECURITY
		// IP Ban
		if ($params->get('ip_ban', '') != '') {

			$isSpam = PhocacartSecurity::checkIpAddress($data['ip'],
$params->get('ip_ban'));

			if ($isSpam) {
				//$app->setUserState('com_phocacart.submit.data',
$data);	// Save the data in the session.
				//$message = JText::_( 'COM_PHOCACART_POSSIBLE_SPAM_DETECTED'
);
				//$app->enqueueMessage($message, 'error');
				//$app->redirect(JRoute::_($uri));

				$app->setUserState('com_phocacart.submit.data',
'');
				$session->clear('time', $namespace);

				PhocacartLog::add(3, 'Submit Item - IP Ban', 0, 'IP:
'. $data['ip'].', User ID: '.$user->id .
', User Name: '.$user->username);
				throw new
Exception(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'), 500);
				return false;
			}
		}

		// *** SECURITY
		// Validate the posted data.
		$form = $model->getForm();
		if (!$form) {
			$app->setUserState('com_phocacart.submit.data',
'');
			$session->clear('time', $namespace);

			PhocacartLog::add(2, 'Submit Item - ERROR - Model not loaded',
0, 'IP: '. $data['ip'].', User ID:
'.$user->id . ', User Name: '.$user->username.',
Message: '.$model->getError());
			throw new Exception($model->getError(), 500);
			return false;
		}

		// *** SECURITY
		// VALIDATE - continue with validation in case of problem
		$continueValidate 	= true;

		// SECURITY
		// Captcha - is validated in RULES of FORM FIELD - Exception for validate
fields
		$captchaId = 1;//Possible parameters in Options for different captchas
(reCaptcha = 1)
		switch ($captchaId) {
			case 1: // reCaptcha uses virtual field, so we cannot check the field
set in form
				$data['phq_captcha'] = 'OK';
			break;
		}


		$validate 			= $model->validate($form, $data);// includes
preprocessForm so it includes parameters too

		if ($validate === false) {
			$errors	= $model->getErrors();


			// Get (possible) attack issues
			for ($i = 0, $n = count($errors); $i < $n && $i < 5; $i++)
{


				if (($errors[$i] instanceof \Exception) &&
($errors[$i]->getCode() == E_ERROR)) {
					$app->setUserState('com_phocacart.submit.data',
'');
					$session->clear('time', $namespace);

					PhocacartLog::add(2, 'Submit Item - Validate errors', 0,
'IP: '. $data['ip'].', User ID:
'.$user->id . ', User Name: '.$user->username);

					$app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'),
'error');
					$app->redirect(JRoute::_($uri));
					return false;
				} else {

					$app->enqueueMessage($errors[$i]->getMessage(),
'warning');
					$continueValidate = false;
				}

			}
			// Validate error message are now in stack, so no more render
			// just redirect back to the form with information about problems and
fill the form field
			$continueValidate = false;
		}
		$data = $validate;


		// *** SECURITY
		// Forbidden Word Filter
		$fwfa	= explode( ',', trim(
$params->get('forbidden_word_filter', '') ) );
		$fwwfa	= explode( ',', trim(
$params->get('forbidden_whole_word_filter', '') ) );

		foreach ($fwfa as $item) {
			if (trim($item) != '') {

				if (!empty($formFields)) {
					foreach ($formFields as $k => $v) {
						$v = str_replace('*', '', trim($v));
						if (isset($data[$v]) && stripos($data[$v], trim($item)) !==
false) {
							$continueValidate = false;
							PhocacartLog::add(3, 'Submit Item - Forbidden Word Filder -
'.$v, 0, 'Word: '.$item.', IP: '.
$data['ip'].', User ID: '.$user->id);
							$app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'
), 'warning');
						}
					}
				}

				if (!empty($formFieldsC)) {
					foreach ($formFieldsC as $k => $v) {
						$v = str_replace('*', '', trim($v));
						if (isset($data[$v]) && stripos($data[$v], trim($item)) !==
false) {
							$continueValidate = false;
							PhocacartLog::add(3, 'Submit Item - Forbidden Word Filder -
'.$v, 0, 'Word: '.$item.', IP: '.
$data['ip'].', User ID: '.$user->id);
							$app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'
), 'warning');
						}
					}
				}

			}
		}

		foreach ($fwwfa as $item) {
			if ($item != '') {
				$itemBase		= trim($item);
				$item			=
"/(^|[^a-zA-Z0-9_]){1}(".preg_quote(($item),"/").")($|[^a-zA-Z0-9_]){1}/i";

				if (!empty($formFields)) {
					foreach ($formFields as $k => $v) {
						$v = str_replace('*', '', trim($v));
						if (isset($data[$v]) && stripos($data[$v], trim($item)) !==
false) {
							$continueValidate = false;
							PhocacartLog::add(3, 'Submit Item - Forbidden Whole Word Filder
- '.$v, 0, 'Word: '.$item.', IP: '.
$data['ip'].', User ID: '.$user->id);
							$app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'
), 'warning');
						}
					}
				}

				if (!empty($formFieldsC)) {
					foreach ($formFieldsC as $k => $v) {
						$v = str_replace('*', '', trim($v));
						if (isset($data[$v]) && stripos($data[$v], trim($item)) !==
false) {
							$continueValidate = false;
							PhocacartLog::add(3, 'Submit Item - Forbidden Whole Word Filder
- '.$v, 0, 'Word: '.$item.', IP: '.
$data['ip'].', User ID: '.$user->id);
							$app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'
), 'warning');
						}
					}
				}

			}
		}


		// remove captcha from data after check
		$data['phq_captcha'] = '';


		// IMAGE VALIDATION
		if ($imageRequired) {
			$imageUploaded = false;

			if (!empty($file['items_item']['image'])) {
				foreach ($file['items_item']['image'] as $k =>
$v) {
					if (isset($v['name']) && $v['name'] !=
'' && isset($v['tmp_name']) &&
$v['tmp_name'] != '' &&
isset($v['error']) && (int)$v['error'] < 1)
{
						$imageUploaded = true;
						break;
					}
				}
			}
			if (!$imageUploaded) {
				$continueValidate = false;
				//PhocacartLog::add(3, 'Submit Item - Image not added - '.$v,
0, 'Word: '.$item.', IP: '.
$data['ip'].', User ID: '.$user->id);
				$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_IMAGE_NOT_SUBMITTED'
), 'error');
			}
		} else {
			// Remove empty form

			if (!empty($file['items_item']['image'])) {
				foreach ($file['items_item']['image'] as $k =>
$v) {
					if (isset($v['name']) && $v['name'] !=
'' && isset($v['tmp_name']) &&
$v['tmp_name'] != '' &&
isset($v['error']) && (int)$v['error'] < 1)
{

					} else {
						unset($file['items_item']['image'][$k]);
					}
				}
			}

		}


		if ($continueValidate == false) {
			// Save the data in the session.
			$app->setUserState('com_phocacart.submit.data', $data);
			// Log added before
			$app->redirect(JRoute::_($uri));
			return false;
		}





		// CHECKS DONE - store entry
		$msg = '';
		if ($model->store($data, $file)) {

			$msg = JText::_(
'COM_PHOCACART_THANK_YOU_FOR_SUBMITTING_YOUR_ITEM' );
		} else {
			$app->setUserState('com_phocacart.submit.data',
'');
			$session->clear('time', $namespace);

			PhocacartLog::add(2, 'Submit Item - ERROR - Model store
error', 0, 'IP: '. $data['ip'].', User ID:
'.$user->id . ', User Name: '.$user->username.',
Message: '.$model->getError());

			//throw new Exception($model->getError(), 500);
			//return false;
			$app->redirect(JRoute::_($uri));
			return false;
		}



		// Flush the data from the session
		$app->setUserState('com_phocacart.submit.data',
'');
		//$session->clear('time', $namespace);
		$app->setUserState('com_phocacart.submit.data',
'success_post_saved');
		$app->enqueueMessage($msg, 'success');
		$this->setRedirect($uri->toString());

		return true;
	}
}
?>
PK��[�+��wishlist.json.phpnu�[���<?php
/* @package Joomla
 * @copyright Copyright (C) Open Source Matters. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * @extension Phoca Extension
 * @copyright Copyright (C) Jan Pavelka www.phoca.cz
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
defined('_JEXEC') or die();

class PhocaCartControllerWishList extends JControllerForm
{

	public function add() {

		if (!JSession::checkToken('request')) {
			$response = array(
				'status' => '0',
				'error' => '<span class="ph-result-txt
ph-error-txt">' . JText::_('JINVALID_TOKEN') .
'</span>');
			echo json_encode($response);
			return;
		}


		$app					= JFactory::getApplication();
		$s 					    = PhocacartRenderStyle::getStyles();
		$item					= array();
		$item['id']				= $this->input->get( 'id', 0,
'int' );
		$item['catid']			= $this->input->get( 'catid',
0, 'int' );
		$item['return']			= $this->input->get(
'return', '', 'string'  );
		$item['wishlistview']	= $this->input->get(
'wishlistview', 0, 'int'  );

		$wishlist	= new PhocacartWishlist();
		$added		= $wishlist->addItem((int)$item['id'],
(int)$item['catid']);
		//$catid		=
PhocacartProduct::getCategoryByProductId((int)$item['id']);

		$o = $o2 = '';
		// Content of the wishlist list
		ob_start();
		echo $wishlist->renderList();
		$o = ob_get_contents();
		ob_end_clean();

		// Render the layout
		$d          = array();
		$d['s']	    = $s;
		$layoutW	= new JLayoutFile('popup_add_to_wishlist', null,
array('component' => 'com_phocacart'));

		$d['link_wishlist'] =
JRoute::_(PhocacartRoute::getWishListRoute((int)$item['id']),
(int)$item['catid']);
		$d['link_continue'] = '';
		// We need to know if module is displayed on wishlist site
		// If yes and one item will be deleted per AJAX, we need to refresh
wishlist site
		// If now and one item will be deleted per AJAX, everything is OK,
nothing needs to be refreshed
		$d['wishlist_view'] 	= (int)$item['wishlistview'];

		if ($added) {
			$d['info_msg'] =
JText::_('COM_PHOCACART_PRODUCT_ADDED_TO_WISH_LIST');
		} else {
			$d['info_msg'] =
JText::_('COM_PHOCACART_PRODUCT_NOT_ADDED_TO_WISH_LIST');

			$mO = PhocacartRenderFront::renderMessageQueue();
			$d['info_msg_additional'] = $mO;
		}

		// Popup with info - Continue,Proceed to wishlist list
		//ob_start();
		$o2 = $layoutW->render($d);
		//$o2 = ob_get_contents();
		//ob_end_clean();

		$count = $wishlist->getWishListCountItems();

		$response = array(
			'status'	=> '1',
			'item'		=> $o,
			'popup'		=> $o2,
			'count'		=> $count);

		echo json_encode($response);
		return;
	}

	public function remove() {

		if (!JSession::checkToken('request')) {
			$response = array(
				'status' => '0',
				'error' => '<span class="ph-result-txt
ph-error-txt">' . JText::_('JINVALID_TOKEN') .
'</span>');
			echo json_encode($response);
			return;
		}

		$app 					= JFactory::getApplication();
		$s 					    = PhocacartRenderStyle::getStyles();
		$item					= array();
		$item['id']				= $this->input->get( 'id', 0,
'int' );
		$item['catid']			= $this->input->get( 'catid',
0, 'int' );
		$item['return']			= $this->input->get(
'return', '', 'string'  );
		$item['wishlistview']	= $this->input->get(
'wishlistview', 0, 'int'  );

		$wishlist	= new PhocacartWishlist();
		$added		= $wishlist->removeItem((int)$item['id']);
		//$catid		=
PhocacartProduct::getCategoryByProductId((int)$item['id']);

		$o = $o2 = '';
		// Content of the wishlist list
		ob_start();
		echo $wishlist->renderList();
		$o = ob_get_contents();
		ob_end_clean();

		// Render the layout
		$d          = array();
		$d['s']	    = $s;
		$layoutW	= new JLayoutFile('popup_remove_from_wishlist', null,
array('component' => 'com_phocacart'));

		$d['link_wishlist'] =
JRoute::_(PhocacartRoute::getWishListRoute((int)$item['id']),
(int)$item['catid']);
		$d['link_continue'] = '';
		// We need to know if module is displayed on wishlist site
		// If yes and one item will be deleted per AJAX, we need to refresh
wishlist site
		// If now and one item will be deleted per AJAX, everything is OK,
nothing needs to be refreshed
		$d['wishlist_view'] 	= (int)$item['wishlistview'];



		if ($added) {
			$d['info_msg'] =
JText::_('COM_PHOCACART_PRODUCT_REMOVED_FROM_WISH_LIST');
		} else {
			$d['info_msg'] =
JText::_('COM_PHOCACART_PRODUCT_NOT_REMOVED_FROM_WISH_LIST');

			$mO = PhocacartRenderFront::renderMessageQueue();
			$d['info_msg_additional'] = $mO;
		}

		// Popup with info - Continue,Proceed to wishlist list
		//ob_start();
		$o2 = $layoutW->render($d);
		//$o2 = ob_get_contents();
		//ob_end_clean();

		$count = $wishlist->getWishListCountItems();

		$response = array(
			'status'	=> '1',
			'item'		=> $o,
			'popup'		=> $o2,
			'count'		=> $count);

		echo json_encode($response);
		return;
	}

}
?>
PK��[�"�<zzwishlist.phpnu�[���<?php
/* @package Joomla
 * @copyright Copyright (C) Open Source Matters. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * @extension Phoca Extension
 * @copyright Copyright (C) Jan Pavelka www.phoca.cz
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
defined('_JEXEC') or die();

class PhocaCartControllerWishList extends JControllerForm
{
	
	public function add() { 
		
		JSession::checkToken() or jexit( 'Invalid Token' );
		$app				= JFactory::getApplication();
		$item				= array();
		$item['id']			= $this->input->get( 'id', 0,
'int' );
		$item['catid']		= $this->input->get( 'catid',
0, 'int' );
		$item['return']		= $this->input->get( 'return',
'', 'string'  );
		
		$wishlist	= new PhocacartWishlist();
		$added		= $wishlist->addItem((int)$item['id'],
(int)$item['catid']);
		if ($added) {
			$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_ADDED_TO_WISH_LIST'),
'message');
		} else {
			$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_NOT_ADDED_TO_WISH_LIST'),
'error');
		}
		//$app->redirect(JRoute::_('index.php?option=com_phocacart&view=checkout'));
		$app->redirect(base64_decode($item['return']));
	}
	
		public function remove() {
		
		JSession::checkToken() or jexit( 'Invalid Token' );
		$app				= JFactory::getApplication();
		$item				= array();
		$item['id']			= $this->input->get( 'id', 0,
'int' );
		$item['return']		= $this->input->get( 'return',
'', 'string'  );
		
		$wishlist	= new PhocacartWishlist();
		$added	= $wishlist->removeItem((int)$item['id']);
		if ($added) {
			$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_REMOVED_FROM_WISH_LIST'),
'message');
		} else {
			$app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_NOT_REMOVED_FROM_WISH_LIST'),
'error');
		}
		//$app->redirect(JRoute::_('index.php?option=com_phocacart&view=checkout'));
		$app->redirect(base64_decode($item['return']));
	}
	
}
?>PK٪�[␅�$�$
ajax.json.phpnu�[���<?php
/*----------------------------------------------------------------------------------|
 www.vdm.io  |----/
				fdsh 
/-------------------------------------------------------------------------------------------------------/

	@version		1.0.39
	@build			4th April, 2023
	@created		17th December, 2020
	@package		Reservation
	@subpackage		ajax.json.php
	@author			farhad shahbazi <http://farhad.com>	
	@copyright		Copyright (C) 2015. All Rights Reserved
	@license		GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
  ____  _____  _____  __  __  __      __       ___  _____  __  __  ____ 
_____  _  _  ____  _  _  ____ 
 (_  _)(  _  )(  _  )(  \/  )(  )    /__\     / __)(  _  )(  \/  )(  _ \( 
_  )( \( )( ___)( \( )(_  _)
.-_)(   )(_)(  )(_)(  )    (  )(__  /(__)\   ( (__  )(_)(  )    (  )___/
)(_)(  )  (  )__)  )  (   )(  
\____) (_____)(_____)(_/\/\_)(____)(__)(__)   \___)(_____)(_/\/\_)(__) 
(_____)(_)\_)(____)(_)\_) (__) 

/------------------------------------------------------------------------------------------------------*/

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

use Joomla\Utilities\ArrayHelper;

/**
 * Reservation Ajax Controller
 */
class ReservationControllerAjax extends JControllerLegacy
{
	public function __construct($config)
	{
		parent::__construct($config);
		// make sure all json stuff are set
		JFactory::getDocument()->setMimeEncoding( 'application/json'
);
		JResponse::setHeader('Content-Disposition','attachment;filename="getajax.json"');
		JResponse::setHeader("Access-Control-Allow-Origin",
"*");
		// load the tasks 
		$this->registerTask('saveChat', 'ajax');
		$this->registerTask('conversation', 'ajax');
		$this->registerTask('ajaxReadMessage', 'ajax');
		$this->registerTask('deleteChat', 'ajax');
		$this->registerTask('goToClass', 'ajax');
		$this->registerTask('getCatLevelOne', 'ajax');
		$this->registerTask('getCatLevelTwo', 'ajax');
	}

	public function ajax()
	{
		$user 		= JFactory::getUser();
		$jinput 	= JFactory::getApplication()->input;
		// Check Token!
		$token 		= JSession::getFormToken();
		$call_token	= $jinput->get('token', 0, 'ALNUM');
		if($jinput->get($token, 0, 'ALNUM') || $token ===
$call_token)
		{
			$task = $this->getTask();
			switch($task)
			{
				case 'saveChat':
					try
					{
						$returnRaw = $jinput->get('raw', false,
'BOOLEAN');
						$messageValue = $jinput->get('message', NULL,
'RAW');
						$fromValue = $jinput->get('from', NULL,
'STRING');
						$toValue = $jinput->get('to', NULL, 'STRING');
						$seidValue = $jinput->get('seid', NULL,
'INT');
						$pidValue = $jinput->get('pid', NULL, 'INT');
						$replyidValue = $jinput->get('replyid', 0,
'INT');
						$pmidValue = $jinput->get('pmid', 0, 'INT');
						if($messageValue && $user->id != 0 && $fromValue
&& $toValue && $seidValue && $pidValue)
						{
							$result =
$this->getModel('ajax')->saveChat($messageValue,
$fromValue, $toValue, $seidValue, $pidValue, $replyidValue, $pmidValue);
						}
						else
						{
							$result = false;
						}
						if($callback = $jinput->get('callback', null,
'CMD'))
						{
							echo $callback . "(".json_encode($result).");";
						}
						elseif($returnRaw)
						{
							echo json_encode($result);
						}
						else
						{
							echo "(".json_encode($result).");";
						}
					}
					catch(Exception $e)
					{
						if($callback = $jinput->get('callback', null,
'CMD'))
						{
							echo $callback."(".json_encode($e).");";
						}
						else
						{
							echo "(".json_encode($e).");";
						}
					}
				break;
				case 'conversation':
					try
					{
						$returnRaw = $jinput->get('raw', false,
'BOOLEAN');
						$user1Value = $jinput->get('user1', NULL,
'INT');
						$user2Value = $jinput->get('user2', NULL,
'INT');
						$seidValue = $jinput->get('seid', NULL,
'INT');
						$pidValue = $jinput->get('pid', NULL, 'INT');
						if($user1Value && $user->id != 0 && $user2Value
&& $seidValue && $pidValue)
						{
							$result =
$this->getModel('ajax')->conversation($user1Value,
$user2Value, $seidValue, $pidValue);
						}
						else
						{
							$result = false;
						}
						if($callback = $jinput->get('callback', null,
'CMD'))
						{
							echo $callback . "(".json_encode($result).");";
						}
						elseif($returnRaw)
						{
							echo json_encode($result);
						}
						else
						{
							echo "(".json_encode($result).");";
						}
					}
					catch(Exception $e)
					{
						if($callback = $jinput->get('callback', null,
'CMD'))
						{
							echo $callback."(".json_encode($e).");";
						}
						else
						{
							echo "(".json_encode($e).");";
						}
					}
				break;
				case 'ajaxReadMessage':
					try
					{
						$returnRaw = $jinput->get('raw', false,
'BOOLEAN');
						$midValue = $jinput->get('mid', NULL, 'INT');
						$seidValue = $jinput->get('seid', NULL,
'INT');
						if($midValue && $user->id != 0 && $seidValue)
						{
							$result =
$this->getModel('ajax')->ajaxReadMessage($midValue,
$seidValue);
						}
						else
						{
							$result = false;
						}
						if($callback = $jinput->get('callback', null,
'CMD'))
						{
							echo $callback . "(".json_encode($result).");";
						}
						elseif($returnRaw)
						{
							echo json_encode($result);
						}
						else
						{
							echo "(".json_encode($result).");";
						}
					}
					catch(Exception $e)
					{
						if($callback = $jinput->get('callback', null,
'CMD'))
						{
							echo $callback."(".json_encode($e).");";
						}
						else
						{
							echo "(".json_encode($e).");";
						}
					}
				break;
				case 'deleteChat':
					try
					{
						$returnRaw = $jinput->get('raw', false,
'BOOLEAN');
						$midValue = $jinput->get('mid', NULL, 'INT');
						if($midValue && $user->id != 0)
						{
							$result =
$this->getModel('ajax')->deleteChat($midValue);
						}
						else
						{
							$result = false;
						}
						if($callback = $jinput->get('callback', null,
'CMD'))
						{
							echo $callback . "(".json_encode($result).");";
						}
						elseif($returnRaw)
						{
							echo json_encode($result);
						}
						else
						{
							echo "(".json_encode($result).");";
						}
					}
					catch(Exception $e)
					{
						if($callback = $jinput->get('callback', null,
'CMD'))
						{
							echo $callback."(".json_encode($e).");";
						}
						else
						{
							echo "(".json_encode($e).");";
						}
					}
				break;
				case 'goToClass':
					try
					{
						$returnRaw = $jinput->get('raw', false,
'BOOLEAN');
						$user1Value = $jinput->get('user1', NULL,
'INT');
						$user2Value = $jinput->get('user2', NULL,
'INT');
						$seidValue = $jinput->get('seid', NULL,
'INT');
						$pidValue = $jinput->get('pid', NULL, 'INT');
						if($user1Value && $user->id != 0 && $user2Value
&& $seidValue && $pidValue)
						{
							$result =
$this->getModel('ajax')->goToClass($user1Value,
$user2Value, $seidValue, $pidValue);
						}
						else
						{
							$result = false;
						}
						if($callback = $jinput->get('callback', null,
'CMD'))
						{
							echo $callback . "(".json_encode($result).");";
						}
						elseif($returnRaw)
						{
							echo json_encode($result);
						}
						else
						{
							echo "(".json_encode($result).");";
						}
					}
					catch(Exception $e)
					{
						if($callback = $jinput->get('callback', null,
'CMD'))
						{
							echo $callback."(".json_encode($e).");";
						}
						else
						{
							echo "(".json_encode($e).");";
						}
					}
				break;
				case 'getCatLevelOne':
					try
					{
						$returnRaw = $jinput->get('raw', false,
'BOOLEAN');
						$extensionValue = $jinput->get('extension', NULL,
'STRING');
						if($extensionValue)
						{
							$result =
$this->getModel('ajax')->getCatLevelOne($extensionValue);
						}
						else
						{
							$result = false;
						}
						if($callback = $jinput->get('callback', null,
'CMD'))
						{
							echo $callback . "(".json_encode($result).");";
						}
						elseif($returnRaw)
						{
							echo json_encode($result);
						}
						else
						{
							echo "(".json_encode($result).");";
						}
					}
					catch(Exception $e)
					{
						if($callback = $jinput->get('callback', null,
'CMD'))
						{
							echo $callback."(".json_encode($e).");";
						}
						else
						{
							echo "(".json_encode($e).");";
						}
					}
				break;
				case 'getCatLevelTwo':
					try
					{
						$returnRaw = $jinput->get('raw', false,
'BOOLEAN');
						$catIdLevel1Value = $jinput->get('catIdLevel1', NULL,
'INT');
						if($catIdLevel1Value)
						{
							$result =
$this->getModel('ajax')->getCatLevelTwo($catIdLevel1Value);
						}
						else
						{
							$result = false;
						}
						if($callback = $jinput->get('callback', null,
'CMD'))
						{
							echo $callback . "(".json_encode($result).");";
						}
						elseif($returnRaw)
						{
							echo json_encode($result);
						}
						else
						{
							echo "(".json_encode($result).");";
						}
					}
					catch(Exception $e)
					{
						if($callback = $jinput->get('callback', null,
'CMD'))
						{
							echo $callback."(".json_encode($e).");";
						}
						else
						{
							echo "(".json_encode($e).");";
						}
					}
				break;
			}
		}
		else
		{
			if($callback = $jinput->get('callback', null,
'CMD'))
			{
				echo $callback."(".json_encode(false).");";
			}
			else
  			{
				echo "(".json_encode(false).");";
			}
		}
	}
}
PK٪�[�����comment.phpnu�[���<?php
/*----------------------------------------------------------------------------------|
 www.vdm.io  |----/
				fdsh 
/-------------------------------------------------------------------------------------------------------/

	@version		1.0.39
	@build			4th April, 2023
	@created		17th December, 2020
	@package		Reservation
	@subpackage		comment.php
	@author			farhad shahbazi <http://farhad.com>	
	@copyright		Copyright (C) 2015. All Rights Reserved
	@license		GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
  ____  _____  _____  __  __  __      __       ___  _____  __  __  ____ 
_____  _  _  ____  _  _  ____ 
 (_  _)(  _  )(  _  )(  \/  )(  )    /__\     / __)(  _  )(  \/  )(  _ \( 
_  )( \( )( ___)( \( )(_  _)
.-_)(   )(_)(  )(_)(  )    (  )(__  /(__)\   ( (__  )(_)(  )    (  )___/
)(_)(  )  (  )__)  )  (   )(  
\____) (_____)(_____)(_/\/\_)(____)(__)(__)   \___)(_____)(_/\/\_)(__) 
(_____)(_)\_)(____)(_)\_) (__) 

/------------------------------------------------------------------------------------------------------*/

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

use Joomla\Utilities\ArrayHelper;

/**
 * Reservation Comment Controller
 */
class ReservationControllerComment extends JControllerForm
{
	/**
	 * Current or most recently performed task.
	 *
	 * @var    string
	 * @since  12.2
	 * @note   Replaces _task.
	 */
	protected $task;

	public function __construct($config = array())
	{
		$this->view_list = 'login'; // safeguard for setting the
return view listing to the default site view.
		parent::__construct($config);
	}


/***[JCBGUI.site_view.php_controller.32.$$$$]***/
public function save($key = NULL, $urlVar = NULL)
{
    $app= JFactory::getApplication();
    $data=
$app->input->get('jform',array(),'array');
    $uid= $app->input->get('uid', 0);
    $userid= JFactory::getUser()->get('id', 0);
    $seid= $app->input->get('seid', 0);
    $currentUrl= (string)JUri::getInstance();


    \JPluginHelper::importPlugin('reservation');
    $dispatcher = \JEventDispatcher::getInstance();
    $result=
$dispatcher->trigger('onBeforeSaveComment',array($uid,$userid,$seid));


    $data['seid']= $seid;
    $data['sickid']= $result[0]['sickid'];
    $data['consultantid']= $result[0]['consultantid'];
    $data['token']= md5(uniqid(rand(), true));

   
JLoader::register('ReservationModelComment',JPATH_COMPONENT_ADMINISTRATOR.'/models/comment.php');
    $commentModel= new ReservationModelComment();
    \JForm::addFormPath(JPATH_COMPONENT_ADMINISTRATOR .
'/models/forms');
    $form= $commentModel->getForm($data,false);


    $filterData= $form->filter($data);
    $filterData['published']= 0;
    $validData= $commentModel->validate($form,$filterData);

    if ($validData === false)
    {
        $errors= $commentModel->getErrors();
        foreach ($errors as $error) {
           
$app->enqueueMessage($error->getMessage(),'warning');
        }
        $app->setUserState('comment.data',$filterData);
        $app->redirect($currentUrl);
    }

    if($commentModel->save($filterData))
    {
        $app->setUserState('status',1);
        $app->setUserState('comment.data','');
        $app->redirect($currentUrl);
    }


}/***[/JCBGUI$$$$]***/


	/**
	 * Method to check if you can edit an existing record.
	 *
	 * Extended classes can override this if necessary.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key;
default is id.
	 *
	 * @return  boolean
	 *
	 * @since   12.2
	 */
	protected function allowEdit($data = array(), $key = 'id')
	{
		// to insure no other tampering
		return false;
	}

        /**
	 * Method override to check if you can add a new record.
	 *
	 * @param   array  $data  An array of input data.
	 *
	 * @return  boolean
	 *
	 * @since   1.6
	 */
	protected function allowAdd($data = array())
	{
		// to insure no other tampering
		return false;
	}

	/**
	 * Method to check if you can save a new or existing record.
	 *
	 * Extended classes can override this if necessary.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key.
	 *
	 * @return  boolean
	 *
	 * @since   12.2
	 */
	protected function allowSave($data, $key = 'id')
	{
		// to insure no other tampering
		return false;
	}

	/**
	 * Function that allows child controller access to model data
	 * after the data has been saved.
	 *
	 * @param   JModelLegacy  $model      The data model object.
	 * @param   array         $validData  The validated data.
	 *
	 * @return  void
	 *
	 * @since   12.2
	 */
	protected function postSaveHook(JModelLegacy $model, $validData = array())
	{
	}
}
PK٪�[wb�v��consultantsignup.phpnu�[���<?php
/*----------------------------------------------------------------------------------|
 www.vdm.io  |----/
				fdsh 
/-------------------------------------------------------------------------------------------------------/

	@version		1.0.39
	@build			4th April, 2023
	@created		17th December, 2020
	@package		Reservation
	@subpackage		consultantsignup.php
	@author			farhad shahbazi <http://farhad.com>	
	@copyright		Copyright (C) 2015. All Rights Reserved
	@license		GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
  ____  _____  _____  __  __  __      __       ___  _____  __  __  ____ 
_____  _  _  ____  _  _  ____ 
 (_  _)(  _  )(  _  )(  \/  )(  )    /__\     / __)(  _  )(  \/  )(  _ \( 
_  )( \( )( ___)( \( )(_  _)
.-_)(   )(_)(  )(_)(  )    (  )(__  /(__)\   ( (__  )(_)(  )    (  )___/
)(_)(  )  (  )__)  )  (   )(  
\____) (_____)(_____)(_/\/\_)(____)(__)(__)   \___)(_____)(_/\/\_)(__) 
(_____)(_)\_)(____)(_)\_) (__) 

/------------------------------------------------------------------------------------------------------*/

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

use Joomla\Utilities\ArrayHelper;

/**
 * Reservation Consultantsignup Controller
 */
class ReservationControllerConsultantsignup extends JControllerForm
{
	/**
	 * Current or most recently performed task.
	 *
	 * @var    string
	 * @since  12.2
	 * @note   Replaces _task.
	 */
	protected $task;

	public function __construct($config = array())
	{
		$this->view_list = 'login'; // safeguard for setting the
return view listing to the default site view.
		parent::__construct($config);
	}


/***[JCBGUI.site_view.php_controller.31.$$$$]***/
public function signup()
{


    $app= JFactory::getApplication();

    if(!JFactory::getUser()->guest)
    {
        $app->enqueueMessage('برای ساخت حساب جدید
ابتدا از حساب فعلی خود خارج
شوید','warning');
        $app->redirect(JUri::root());
    }



    $uri = (string)JUri::getInstance();
    JLoader::register('ReservationModelConsultant',
JPATH_COMPONENT_ADMINISTRATOR.'/models/consultant.php');
    \JForm::addFormPath(JPATH_COMPONENT_ADMINISTRATOR .
'/models/forms');
    $data=
JFactory::getApplication()->input->get('jform',array(),'array');

    $consultantModel= new ReservationModelConsultant;
    $form = $consultantModel->getForm($data, false);

    $xml = new SimpleXMLElement('<field name="password"
validate="password"/>');
    $form->setField($xml);

//    $rule= JFormHelper::loadRuleType('password');
//    $res= $rule->test($xml,$data['password']);

//    $filteredData = $form->filter($data);

    $filter= JFilterInput::getInstance();


    $data['name']=  preg_replace('/[0-9]+/',
'', $data['name']);
    $data['capital']=  preg_replace('/[0-9]+/',
'', $data['capital']);
    $data['msn']= $filter->clean( $data['msn'],
'int');
    $data['nationalnumber']= $filter->clean(
$data['nationalnumber'], 'int');
    $data['experience']= $filter->clean(
$data['experience'], 'int');


    $model= $this->getModel();
    if($model->checkPhoneExist($data['phonenumber']))
    {
        $app->enqueueMessage('این شماره تلفن قبلا
در این سامانه ثبت شده است لطفا با شماره
تلفن دیگری ثبت نام کنید','warning');
        $app->setUserState('consultant.data',$data);
        $app->redirect($uri);
    }

    $validData = $consultantModel->validate($form, $data);
    if ($validData === false)
    {
        $errors = $consultantModel->getErrors();

        foreach ($errors as $error) {
           
$app->enqueueMessage($error->getMessage(),'warning');
        }
        $app->setUserState('consultant.data',$data);
        $app->redirect($uri);
    }
    else{

        $userdata = array(
            "name"=> $data['name'],
            "username"=> $data['phonenumber'],
            "password"=> $data['password'],
            "password2"=> $data['password'],
            "email"=>
'R_'.$data['phonenumber'].'@gmail.com',
            "block"=> 0,
        );


        jimport('joomla.user.helper');
        $params= $app->getparams('com_reservation');

        $userGroup= $params->get('consultantgroup');


        if(!isset($userGroup))
            $userGroup = 2;

        $userdata["groups"] = $userGroup;
        $user = new JUser;


        if(!$user->bind($userdata)) {
            $app->enqueueMessage($user->getError(),
'warning');
            $app->redirect($uri);
            return false;

        }

        if (!$user->save()) {
            $app->enqueueMessage($user->getError(),
'warning');
            $app->redirect($uri);
            return false;

        }

        $app->setUserState('consultant.data',$data);

        $userId= $user->id;

        $consultantInfo= array(
            'userid'=> $userId,
            'msn' => $data['msn'],
            'nationalnumber' =>
$data['nationalnumber'],
            'catid' => $data['catid'],
            'capital' => $data['capital'],
            'phonenumber' => $data['phonenumber'],
            'experience' => $data['experience']
        );

        if(!$consultantModel->save($consultantInfo))
        {
            $app->enqueueMessage('اطلاعات خود را
تصحیح کرده و سپس وارد نمایید',
'warning');
            $app->redirect($uri);
        }
        $app->setUserState('consultant.data','');




        echo 'user saved successfully';


    }

    $credentials = array();
    $credentials['username'] = $data['phonenumber'];
    $credentials['password'] = $data['password'];
    $login_site = JFactory::getApplication('site');
    $login_site->login($credentials, $options=array());
    $redirect = JUri::root();
    $login_site->redirect($redirect);
    
}/***[/JCBGUI$$$$]***/


	/**
	 * Method to check if you can edit an existing record.
	 *
	 * Extended classes can override this if necessary.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key;
default is id.
	 *
	 * @return  boolean
	 *
	 * @since   12.2
	 */
	protected function allowEdit($data = array(), $key = 'id')
	{
		// to insure no other tampering
		return false;
	}

        /**
	 * Method override to check if you can add a new record.
	 *
	 * @param   array  $data  An array of input data.
	 *
	 * @return  boolean
	 *
	 * @since   1.6
	 */
	protected function allowAdd($data = array())
	{
		// to insure no other tampering
		return false;
	}

	/**
	 * Method to check if you can save a new or existing record.
	 *
	 * Extended classes can override this if necessary.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key.
	 *
	 * @return  boolean
	 *
	 * @since   12.2
	 */
	protected function allowSave($data, $key = 'id')
	{
		// to insure no other tampering
		return false;
	}

	/**
	 * Function that allows child controller access to model data
	 * after the data has been saved.
	 *
	 * @param   JModelLegacy  $model      The data model object.
	 * @param   array         $validData  The validated data.
	 *
	 * @return  void
	 *
	 * @since   12.2
	 */
	protected function postSaveHook(JModelLegacy $model, $validData = array())
	{
	}
}
PK٪�[p�a���consultant_plan.phpnu�[���<?php
/*----------------------------------------------------------------------------------|
 www.vdm.io  |----/
				fdsh 
/-------------------------------------------------------------------------------------------------------/

	@version		1.0.39
	@build			4th April, 2023
	@created		17th December, 2020
	@package		Reservation
	@subpackage		consultant_plan.php
	@author			farhad shahbazi <http://farhad.com>	
	@copyright		Copyright (C) 2015. All Rights Reserved
	@license		GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
  ____  _____  _____  __  __  __      __       ___  _____  __  __  ____ 
_____  _  _  ____  _  _  ____ 
 (_  _)(  _  )(  _  )(  \/  )(  )    /__\     / __)(  _  )(  \/  )(  _ \( 
_  )( \( )( ___)( \( )(_  _)
.-_)(   )(_)(  )(_)(  )    (  )(__  /(__)\   ( (__  )(_)(  )    (  )___/
)(_)(  )  (  )__)  )  (   )(  
\____) (_____)(_____)(_/\/\_)(____)(__)(__)   \___)(_____)(_/\/\_)(__) 
(_____)(_)\_)(____)(_)\_) (__) 

/------------------------------------------------------------------------------------------------------*/

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

use Joomla\Utilities\ArrayHelper;

/**
 * Reservation Consultant_plan Controller
 */
class ReservationControllerConsultant_plan extends JControllerForm
{
	/**
	 * Current or most recently performed task.
	 *
	 * @var    string
	 * @since  12.2
	 * @note   Replaces _task.
	 */
	protected $task;

	public function __construct($config = array())
	{
		$this->view_list = 'login'; // safeguard for setting the
return view listing to the default site view.
		parent::__construct($config);
	}


/***[JCBGUI.site_view.php_controller.37.$$$$]***/
  public function delete($key = NULL, $urlVar = NULL)
  {
    $app= JFactory::getApplication();
    $uri= (string)JUri::getInstance();
    $user= JFactory::getUser();
    $jform=
$app->input->get('jform',array(),'array');


    $consultant=
ReservationHelper::getConsultant($jform['consultantid']);

    if ($consultant->userid != $user->get('id', 0))
      $app->redirect(JUri::root());


    $filename = __DIR__ . '/delete.txt';


    $plans = array_keys($jform['plans']);
    $plans = array_map(function ($a) { return intval(substr($a, 5)); },
$plans);

    // file_put_contents($filename, 'plans = ' . print_r($plans,
true) . "\n" , FILE_APPEND);



    JLoader::register('ReservationModelPlan', JPATH_ADMINISTRATOR
. '/components/com_reservation/models/plan.php');
    JLoader::register('ReservationTablePlan', JPATH_ADMINISTRATOR
. '/components/com_reservation/tables/plan.php');
    JPluginHelper::importPlugin('reservation');
    $dispatcher = JEventDispatcher::getInstance();
    foreach($plans as $pid)
    {
      $db = JFactory::getDbo();
      $planmodel = new ReservationTablePlan($db);
      $pkco = array(
        'id' => $pid
      );
      $planmodel->publish($pkco, -2);
      $pks = array($pid);
      $dispatcher->trigger('onReservationPlanStateChanged',
array($pks, -2));
      $planmodel->delete($pkco);
    }




    $app->redirect($uri);
  }
  public function save($key = NULL, $urlVar = NULL)
  {
    $filename = __DIR__ . '/save.txt';
    // file_put_contents($filename, 'key = ' . print_r($key,
true) . "\n" , FILE_APPEND);


    $uri= (string)JUri::getInstance();
    $user= JFactory::getUser();
    $app= JFactory::getApplication();
    $jform=
$app->input->get('jform',array(),'array');


    $consultant=
ReservationHelper::getConsultant($jform['consultantid']);

    if ($consultant->userid != $user->get('id', 0))
      $app->redirect(JUri::root());

    JLoader::register('ReservationModelPlan',
JPATH_ADMINISTRATOR.'/components/com_reservation/models/plan.php');
    if(isset($jform['planid']) &&
$jform['planid'])
    {
      $jform['id'] = $jform['planid'];
      $planmodel = new ReservationModelPlan();
      $planObj = $planmodel->getItem($jform['id']);
      $consultant=
ReservationHelper::getConsultant($planObj->consultantid);
      if ($consultant->userid != $user->get('id', 0))
        $app->redirect(JUri::root());
    }
    unset($jform['planid']);

    // file_put_contents($filename, 'jform = ' . print_r($jform,
true) . "\n" , FILE_APPEND);

    $planmodel= new ReservationModelPlan;
    if (!$planmodel->save($jform))
    {
     
$app->enqueueMessage(JText::_('COM_RESERVATION_FAILED_TO_SAVE_PLAN',
'danger')); // failed to save plan
      $app->redirect($uri);
    }

    $validData = (array)$planmodel->getItem();

    JPluginHelper::importPlugin('reservation');
    $dispatcher = JEventDispatcher::getInstance();
    $dispatcher->trigger('onReservationPlanCreated',
array($validData));


   
$app->enqueueMessage(JText::_('COM_RESERVATION_PLAN_SAVED_SUCCESSFULLY',
'success')); // plan saved successfully
    $app->redirect($uri);
  }
/***[/JCBGUI$$$$]***/


	/**
	 * Method to check if you can edit an existing record.
	 *
	 * Extended classes can override this if necessary.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key;
default is id.
	 *
	 * @return  boolean
	 *
	 * @since   12.2
	 */
	protected function allowEdit($data = array(), $key = 'id')
	{
		// to insure no other tampering
		return false;
	}

        /**
	 * Method override to check if you can add a new record.
	 *
	 * @param   array  $data  An array of input data.
	 *
	 * @return  boolean
	 *
	 * @since   1.6
	 */
	protected function allowAdd($data = array())
	{
		// to insure no other tampering
		return false;
	}

	/**
	 * Method to check if you can save a new or existing record.
	 *
	 * Extended classes can override this if necessary.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key.
	 *
	 * @return  boolean
	 *
	 * @since   12.2
	 */
	protected function allowSave($data, $key = 'id')
	{
		// to insure no other tampering
		return false;
	}

	/**
	 * Function that allows child controller access to model data
	 * after the data has been saved.
	 *
	 * @param   JModelLegacy  $model      The data model object.
	 * @param   array         $validData  The validated data.
	 *
	 * @return  void
	 *
	 * @since   12.2
	 */
	protected function postSaveHook(JModelLegacy $model, $validData = array())
	{
	}
}
PK٪�[r9Ѥrrdoctors.phpnu�[���<?php
/*----------------------------------------------------------------------------------|
 www.vdm.io  |----/
				fdsh 
/-------------------------------------------------------------------------------------------------------/

	@version		1.0.22
	@build			1st March, 2021
	@created		17th December, 2020
	@package		Reservation
	@subpackage		doctors.php
	@author			farhad shahbazi <http://farhad.com>	
	@copyright		Copyright (C) 2015. All Rights Reserved
	@license		GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
  ____  _____  _____  __  __  __      __       ___  _____  __  __  ____ 
_____  _  _  ____  _  _  ____ 
 (_  _)(  _  )(  _  )(  \/  )(  )    /__\     / __)(  _  )(  \/  )(  _ \( 
_  )( \( )( ___)( \( )(_  _)
.-_)(   )(_)(  )(_)(  )    (  )(__  /(__)\   ( (__  )(_)(  )    (  )___/
)(_)(  )  (  )__)  )  (   )(  
\____) (_____)(_____)(_/\/\_)(____)(__)(__)   \___)(_____)(_/\/\_)(__) 
(_____)(_)\_)(____)(_)\_) (__) 

/------------------------------------------------------------------------------------------------------*/

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

use Joomla\Utilities\ArrayHelper;

/**
 * Reservation Doctors Controller
 */
class ReservationControllerDoctors extends JControllerForm
{
	/**
	 * Current or most recently performed task.
	 *
	 * @var    string
	 * @since  12.2
	 * @note   Replaces _task.
	 */
	protected $task;

	public function __construct($config = array())
	{
		$this->view_list = 'doctor'; // safeguard for setting the
return view listing to the default site view.
		parent::__construct($config);
	}


/***[JCBGUI.site_view.php_controller.33.$$$$]***/
public function check()
{
    $app= JFactory::getApplication();
    $uid= $app->input->get('uid');
    $params= $app->getparams('com_reservation');
    $userGroups= !empty($params->get('doctorgroup'))?
$params->get('doctorgroup'): [0];
    
    $db= JFactory::getDbo();
    $query= $db->getQuery(true)
        ->select($db->quoteName('d.id'))
       
->from($db->quoteName('#__reservation_doctor','d'))
       
->join('inner',$db->quoteName('#__user_usergroup_map','uu').'on'.$db->quoteName('uu.user_id').'='.$db->quoteName('d.userid'))
       
->where($db->quoteName('d.userid').'='.$db->quote($uid))
       
->where($db->quoteName('uu.group_id').'IN('.implode(',',$userGroups).')');

    $db->setQuery($query);
    $result= $db->loadObject();

    if (empty($result))
        $app->redirect(JUri::root());

   
$app->redirect(JRoute::_('index.php?option=com_reservation&view=doctor&uid'.$uid,false));
   
}/***[/JCBGUI$$$$]***/


	/**
	 * Method to check if you can edit an existing record.
	 *
	 * Extended classes can override this if necessary.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key;
default is id.
	 *
	 * @return  boolean
	 *
	 * @since   12.2
	 */
	protected function allowEdit($data = array(), $key = 'id')
	{
		// to insure no other tampering
		return false;
	}

        /**
	 * Method override to check if you can add a new record.
	 *
	 * @param   array  $data  An array of input data.
	 *
	 * @return  boolean
	 *
	 * @since   1.6
	 */
	protected function allowAdd($data = array())
	{
		// to insure no other tampering
		return false;
	}

	/**
	 * Method to check if you can save a new or existing record.
	 *
	 * Extended classes can override this if necessary.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key.
	 *
	 * @return  boolean
	 *
	 * @since   12.2
	 */
	protected function allowSave($data, $key = 'id')
	{
		// to insure no other tampering
		return false;
	}

	/**
	 * Function that allows child controller access to model data
	 * after the data has been saved.
	 *
	 * @param   JModelLegacy  $model      The data model object.
	 * @param   array         $validData  The validated data.
	 *
	 * @return  void
	 *
	 * @since   12.2
	 */
	protected function postSaveHook(JModelLegacy $model, $validData =
array())
	{
	}
}
PK٪�[��'QQdoctorsignup.phpnu�[���<?php
/*----------------------------------------------------------------------------------|
 www.vdm.io  |----/
				fdsh 
/-------------------------------------------------------------------------------------------------------/

	@version		1.0.39
	@build			4th April, 2023
	@created		17th December, 2020
	@package		Reservation
	@subpackage		doctorsignup.php
	@author			farhad shahbazi <http://farhad.com>	
	@copyright		Copyright (C) 2015. All Rights Reserved
	@license		GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
  ____  _____  _____  __  __  __      __       ___  _____  __  __  ____ 
_____  _  _  ____  _  _  ____ 
 (_  _)(  _  )(  _  )(  \/  )(  )    /__\     / __)(  _  )(  \/  )(  _ \( 
_  )( \( )( ___)( \( )(_  _)
.-_)(   )(_)(  )(_)(  )    (  )(__  /(__)\   ( (__  )(_)(  )    (  )___/
)(_)(  )  (  )__)  )  (   )(  
\____) (_____)(_____)(_/\/\_)(____)(__)(__)   \___)(_____)(_/\/\_)(__) 
(_____)(_)\_)(____)(_)\_) (__) 

/------------------------------------------------------------------------------------------------------*/

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

use Joomla\Utilities\ArrayHelper;

/**
 * Reservation Doctorsignup Controller
 */
class ReservationControllerDoctorsignup extends JControllerForm
{
	/**
	 * Current or most recently performed task.
	 *
	 * @var    string
	 * @since  12.2
	 * @note   Replaces _task.
	 */
	protected $task;

	public function __construct($config = array())
	{
		$this->view_list = 'login'; // safeguard for setting the
return view listing to the default site view.
		parent::__construct($config);
	}


/***[JCBGUI.site_view.php_controller.34.$$$$]***/
    public function signup()
    {


        $app= JFactory::getApplication();

        if(!JFactory::getUser()->guest)
        {
            $app->enqueueMessage('برای ساخت حساب
جدید ابتدا از حساب فعلی خود خارج
شوید','warning');
            $app->redirect(JUri::root());
        }



        $uri = (string)JUri::getInstance();
        JLoader::register('ReservationModelDoctor',
JPATH_COMPONENT_ADMINISTRATOR.'/models/doctor.php');
        \JForm::addFormPath(JPATH_COMPONENT_ADMINISTRATOR .
'/models/forms');
        $data=
JFactory::getApplication()->input->get('jform',array(),'array');

        $doctorsModel= new ReservationModelDoctor;
        $form = $doctorsModel->getForm($data, false);

        $xml = new SimpleXMLElement('<field
name="password" validate="password"/>');
        $form->setField($xml);

//    $rule= JFormHelper::loadRuleType('password');
//    $res= $rule->test($xml,$data['password']);

//    $filteredData = $form->filter($data);

        $filter= JFilterInput::getInstance();


        $data['name']=  preg_replace('/[0-9]+/',
'', $data['name']);
        $data['msn']= $filter->clean( $data['msn'],
'int');


        $model= $this->getModel();
        if($model->checkPhoneExist($data['phonenumber']))
        {
            $app->enqueueMessage('این شماره تلفن
قبلا در این سامانه ثبت شده است لطفا با
شماره تلفن دیگری ثبت نام
کنید','warning');
            $app->setUserState('doctor.data',$data);
            $app->redirect($uri);
        }

        $validData = $doctorsModel->validate($form, $data);
        if ($validData === false)
        {
            $errors = $doctorsModel->getErrors();

            foreach ($errors as $error) {
               
$app->enqueueMessage($error->getMessage(),'warning');
            }
            $app->setUserState('doctor.data',$data);
            $app->redirect($uri);
        }
        else{

            $userdata = array(
                "name"=> $data['name'],
                "username"=> $data['phonenumber'],
                "password"=> $data['password'],
                "password2"=> $data['password'],
                "email"=>
'R_'.$data['phonenumber'].'@gmail.com',
                "block"=> 0,
            );


            $userGroup = 2;


            $userdata["groups"] = array($userGroup);
            $user = new JUser;


            if(!$user->bind($userdata)) {
                $app->enqueueMessage($user->getError(),
'warning');
                $app->redirect($uri);

            }

            if (!$user->save()) {
                $app->enqueueMessage($user->getError(),
'warning');
                $app->redirect($uri);

            }

            $app->setUserState('doctor.data',$data);

            $userId= $user->id;

            $doctorInfo= array(
                'userid'=> $userId,
                'msn' => $data['msn'],
                'catid' => $data['catid'],
                'capitalid' => $data['capitalid'],
                'cityid' => $data['cityid'],
                'phonenumber' =>
$data['phonenumber'],
                'officephone' =>
$data['officephone'],
                'address' => $data['address'],
            );

            if(!$doctorsModel->save($doctorInfo))
            {
                $app->enqueueMessage('اطلاعات خود را
تصحیح کرده و سپس وارد نمایید',
'warning');
                $app->redirect($uri);
            }
            $app->setUserState('doctor.data','');




            echo 'user saved successfully';


        }

        $credentials = array();
        $credentials['username'] =
$data['phonenumber'];
        $credentials['password'] = $data['password'];
        $login_site = JFactory::getApplication('site');
        $login_site->login($credentials, $options=array());
        $redirect = JUri::root();
        $login_site->redirect($redirect);

    }/***[/JCBGUI$$$$]***/


	/**
	 * Method to check if you can edit an existing record.
	 *
	 * Extended classes can override this if necessary.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key;
default is id.
	 *
	 * @return  boolean
	 *
	 * @since   12.2
	 */
	protected function allowEdit($data = array(), $key = 'id')
	{
		// to insure no other tampering
		return false;
	}

        /**
	 * Method override to check if you can add a new record.
	 *
	 * @param   array  $data  An array of input data.
	 *
	 * @return  boolean
	 *
	 * @since   1.6
	 */
	protected function allowAdd($data = array())
	{
		// to insure no other tampering
		return false;
	}

	/**
	 * Method to check if you can save a new or existing record.
	 *
	 * Extended classes can override this if necessary.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key.
	 *
	 * @return  boolean
	 *
	 * @since   12.2
	 */
	protected function allowSave($data, $key = 'id')
	{
		// to insure no other tampering
		return false;
	}

	/**
	 * Function that allows child controller access to model data
	 * after the data has been saved.
	 *
	 * @param   JModelLegacy  $model      The data model object.
	 * @param   array         $validData  The validated data.
	 *
	 * @return  void
	 *
	 * @since   12.2
	 */
	protected function postSaveHook(JModelLegacy $model, $validData = array())
	{
	}
}
PK٪�[oɢ���fileupload.phpnu�[���<?php

define('_JEXEC', 1);

define('JPATH_BASE',
dirname(dirname(dirname(dirname(__FILE__)))));
require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_BASE . '/includes/framework.php';
$app = JFactory::getApplication('site');


use Joomla\CMS\Filesystem\File;


// var_dump(function_exists('gd_info')); // check GD extension
installed and enabled on php
// var_dump(function_exists('getimagesize'));
// die();

$filename = __DIR__ . '/log.txt';
// file_put_contents($filename, '$_FILES = ' . print_r($_FILES,
True) . "\n", FILE_APPEND);
// file_put_contents($filename, '$_POST = ' . print_r($_POST,
True) . "\n", FILE_APPEND);
// file_put_contents($filename, '$_req = ' . file_get_contents(
'php://input' ) . "\n", FILE_APPEND);
// file_put_contents($filename, 'input files = ' .
print_r($app->input->files->get('atachedfile'), True) .
"\n", FILE_APPEND);



function getName($n)
{
    $characters = '0123456789abcdefghijklmnopqrstuvwxyz';
    $randomString = '';
    for ($i = 0; $i < $n; $i++)
    {
        $index = rand(0, strlen($characters) - 1);
        $randomString .= $characters[$index];
    }
    return $randomString;
}



$file = $app->input->files->get('atachedfile');


$info = pathinfo($file['name']);
if(isset($info['extension']))
{
    $ext = $info['extension']; // get the extension of the file
    $newname = getName(10) . ".$ext";
    $target = dirname(dirname(__FILE__)) . '/files/' . $newname;

    $allowUnsafe = false;

    // if (move_uploaded_file($file['tmp_name'], $target))
    if(JFile::upload($file['tmp_name'], $target, false,
$allowUnsafe))
    {
        if(function_exists('gd_info') &&
!function_exists('compress_image'))
        {
            function compress_image($src, $dest , $quality) 
            {
                $info = getimagesize($src);
             
                if ($info['mime'] == 'image/jpeg') 
                {
                    $image = imagecreatefromjpeg($src);
                }
                elseif ($info['mime'] == 'image/gif') 
                {
                    $image = imagecreatefromgif($src);
                }
                elseif ($info['mime'] == 'image/png') 
                {
                    $image = imagecreatefrompng($src);
                }
                else
                {
                    die('Unknown image file format');
                }
             
                //compress and save file to jpg
                imagejpeg($image, $dest, $quality);
             
                //return destination file
                return $dest;
            }
            compress_image($target, $target, 30);
        }
        echo $newname;
        // file_put_contents($filename, 'File is valid, and was
successfully uploaded'. "\n", FILE_APPEND);
    } 
    else
    {
        // file_put_contents($filename, 'Upload failed'.
"\n", FILE_APPEND);
    }
}

?>PK٪�[��B�"�"firstqst.phpnu�[���<?php
/*----------------------------------------------------------------------------------|
 www.vdm.io  |----/
				fdsh 
/-------------------------------------------------------------------------------------------------------/

	@version		1.0.39
	@build			4th April, 2023
	@created		17th December, 2020
	@package		Reservation
	@subpackage		firstqst.php
	@author			farhad shahbazi <http://farhad.com>	
	@copyright		Copyright (C) 2015. All Rights Reserved
	@license		GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
  ____  _____  _____  __  __  __      __       ___  _____  __  __  ____ 
_____  _  _  ____  _  _  ____ 
 (_  _)(  _  )(  _  )(  \/  )(  )    /__\     / __)(  _  )(  \/  )(  _ \( 
_  )( \( )( ___)( \( )(_  _)
.-_)(   )(_)(  )(_)(  )    (  )(__  /(__)\   ( (__  )(_)(  )    (  )___/
)(_)(  )  (  )__)  )  (   )(  
\____) (_____)(_____)(_/\/\_)(____)(__)(__)   \___)(_____)(_/\/\_)(__) 
(_____)(_)\_)(____)(_)\_) (__) 

/------------------------------------------------------------------------------------------------------*/

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

use Joomla\Utilities\ArrayHelper;

/**
 * Reservation Firstqst Controller
 */
class ReservationControllerFirstqst extends JControllerForm
{
	/**
	 * Current or most recently performed task.
	 *
	 * @var    string
	 * @since  12.2
	 * @note   Replaces _task.
	 */
	protected $task;

	public function __construct($config = array())
	{
		$this->view_list = 'login'; // safeguard for setting the
return view listing to the default site view.
		parent::__construct($config);
	}


/***[JCBGUI.site_view.php_controller.30.$$$$]***/
  public function save($key = NULL, $urlVar = NULL){
    $app = JFactory::getApplication();
    $input = $app->input;
    $firsttext = $input->get('chatMessage', '',
'string');
    $pid = $input->get('pid', 0);
    //    $uid = $app->input->get('uid', 0);

    $app->setUserState('first_chatMessage', $firsttext);
    //    $app->setUserState('pid', $pid);
    //    $app->setUserState('uid', $uid);


    $db = JFactory::getDbo();
    $query = $db->getQuery(true);
    $query->select('product_id');
    $query->from($db->quoteName('#__hikashop_product'));
    $query->where($db->quoteName('product_code') . '=
"reserve' . $pid.'"');

    $db->setQuery($query);
    $product_id = $db->loadResult();


    $db = JFactory::getDbo();
    $query = $db->getQuery(true);
    $query->select('id');
    $query->from($db->quoteName('#__reservation_sick'));
    $query->where($db->quoteName('userid') . '='
. $db->quote(JFactory::getUser()->id));
    $db->setQuery($query);
    $sick_id = $db->loadResult();



    JLoader::register('ReservationModelSession',
JPATH_ADMINISTRATOR.'/components/com_reservation/models/session.php');
    $data = array(
      'sickid'        => $sick_id,
      'planid'        => $pid,
      'firsttext'     => $firsttext,
      'channel_token' =>  JUserHelper::genRandomPassword(16)
    );

    $db = JFactory::getDbo();
    $query = $db->getQuery(true);
    $query->select(array('id', 'channel_token'));
   
$query->from($db->quoteName('#__reservation_session'));
    $query->where($db->quoteName('planid') . '='
. $db->quote($pid));
    $query->where($db->quoteName('sickid') . '='
. $db->quote($sick_id));
    $query->where($db->quoteName('published') . '=
1');
    $db->setQuery($query);
    $session = $db->loadAssoc();
    if($session)
    {
      $data['id'] = $session['id'];
      $data['channel_token'] =
$session['channel_token'];
    }

    $session_model = new ReservationModelSession();
    $session_model->save($data);

    //           
$app->redirect(JRoute::_('index.php?option=com_reservation&view=payment&seid='.$sessionId));
   
$app->redirect(JRoute::_('index.php?option=com_hikashop&ctrl=product&task=show&cid='
. $product_id));




  }

  public function createSession($pid)
  {
    require_once
JPATH_SITE.'/components/com_reservation/helpers/reservation.php';
    $app= JFactory::getApplication();
    $firsttext=
$app->getUserState('first_chatMessage',0,'string');
    //        $pid= $app->getUserState('pid',0);
    //        $uid= $app->getUserState('uid',0);
    $user_id= JFactory::getUser()->get('id',0);
    //$consultantid=
ReservationHelper::exist('#__reservation_consultant',
'userid', JFactory::getUser()->get('id', 0));

    if (!$user_id)
    {
      $app->enqueueMessage('برای رزرو نوبت مشاوره
وارد حساب کاربری مخصوص کاربران عادی خود
شوید','warning');
      $app->redirect(JUri::root());
    }

    //        if (!$pid || !$uid)
    //        {
    //            $app->enqueueMessage('مراحل خرید به
درستی طی نشده است ، لطفا مراحل را مجدد
تکرار کنید','warning');
    //            $app->redirect(JUri::root());
    //        }


    $db = JFactory::getDbo();
    $query= $db->getQuery(true)
      ->select('s.id')
     
->from($db->quoteName('#__reservation_sick','s'))
     
->where($db->quoteName('s.userid').'='.$user_id);

    $db->setQuery($query);
    $res= $db->loadObject();


    //        $db = JFactory::getDbo();
    //        $query= $db->getQuery(true)
    //            ->select('c.id')
    //           
->from($db->quoteName('#__reservation_consultant','c'))
    //           
->where($db->quoteName('c.userid').'='.$uid)
    //           
->where('('.$db->quoteName('c.account').'='.$db->quote('consultant').'
or
'.$db->quoteName('c.account').'='.$db->quote('both').')');
    //
    //        $db->setQuery($query);
    //
    //        $res2= $db->loadObject();


    if(empty($res)) {
      $app->enqueueMessage('برای رزرو نوبت مشاوره
وارد حساب کاربری مخصوص کاربران عادی خود
شوید','warning');
      JFactory::getApplication()->redirect(JUri::root());
    }

    $sickid = (int)$res->id;
    //        $cid = (int)$res2->id;
    //
    //
    //        $db = JFactory::getDbo();
    //        $query= $db->getQuery(true)
    //            ->select('p.id')
    //           
->from($db->quoteName('#__reservation_plan','p'))
    //           
->where($db->quoteName('p.id').'='.$pid)
    //           
->where($db->quoteName('p.consultantid').'='.$db->quote($cid));
    //
    //        $db->setQuery($query);
    //        $res= $db->loadObject();
    //
    //        if (empty($res)) {
    //
    //            $app->enqueueMessage('از پارامتر های
معتبر استفاده کنید','warning');
    //            JFactory::getApplication()->redirect(JUri::root());
    //        }


    $data= [
      'firsttext'=> $firsttext,
      'planid'=> $pid,
      'sickid'=> $sickid,
      'pay' => 0,
      'finish' => 0
    ];

    require_once
JPATH_ADMINISTRATOR.'/components/com_reservation/models/session.php';

    $adminSessionModel= new ReservationModelSession;

    if (!$adminSessionModel->save($data))
    {
      $app->enqueueMessage('از پارامتر های معتبر
استفاده کنید','warning');
      JFactory::getApplication()->redirect(JUri::root());
    }

    $sessionId=$adminSessionModel->getState('session.id');
    return $sessionId;
  }/***[/JCBGUI$$$$]***/


	/**
	 * Method to check if you can edit an existing record.
	 *
	 * Extended classes can override this if necessary.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key;
default is id.
	 *
	 * @return  boolean
	 *
	 * @since   12.2
	 */
	protected function allowEdit($data = array(), $key = 'id')
	{
		// to insure no other tampering
		return false;
	}

        /**
	 * Method override to check if you can add a new record.
	 *
	 * @param   array  $data  An array of input data.
	 *
	 * @return  boolean
	 *
	 * @since   1.6
	 */
	protected function allowAdd($data = array())
	{
		// to insure no other tampering
		return false;
	}

	/**
	 * Method to check if you can save a new or existing record.
	 *
	 * Extended classes can override this if necessary.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key.
	 *
	 * @return  boolean
	 *
	 * @since   12.2
	 */
	protected function allowSave($data, $key = 'id')
	{
		// to insure no other tampering
		return false;
	}

	/**
	 * Function that allows child controller access to model data
	 * after the data has been saved.
	 *
	 * @param   JModelLegacy  $model      The data model object.
	 * @param   array         $validData  The validated data.
	 *
	 * @return  void
	 *
	 * @since   12.2
	 */
	protected function postSaveHook(JModelLegacy $model, $validData = array())
	{
	}
}
PK٪�[��ѩ��	log23.txtnu�[���messageValue =
fgdagfag
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 70
    [name] => فرهاد پاشایی
    [username] => 09212428467
    [email] => fa@g.com
    [password] =>
$2y$10$hiXCMTOadhf3gDxYAtDo0ObemDVavHAYYG/PXpiTRgYosgIyMxfAm
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-02-23 04:37:55
    [lastvisitDate] => 2023-02-22 11:37:54
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 70
toValue = 78
seidValue = 50
pidValue = 1
result = 23
messageValue = test
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 70
    [name] => فرهاد پاشایی
    [username] => 09212428467
    [email] => fa@g.com
    [password] =>
$2y$10$hiXCMTOadhf3gDxYAtDo0ObemDVavHAYYG/PXpiTRgYosgIyMxfAm
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-02-23 04:37:55
    [lastvisitDate] => 2023-02-22 12:01:53
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 70
toValue = 78
seidValue = 50
pidValue = 1
result = 23
messageValue = aaaaa
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 70
    [name] => فرهاد پاشایی
    [username] => 09212428467
    [email] => fa@g.com
    [password] =>
$2y$10$hiXCMTOadhf3gDxYAtDo0ObemDVavHAYYG/PXpiTRgYosgIyMxfAm
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-02-23 04:37:55
    [lastvisitDate] => 2023-02-22 12:01:53
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 70
toValue = 78
seidValue = 50
pidValue = 1
result = 23
messageValue = test
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 70
    [name] => فرهاد پاشایی
    [username] => 09212428467
    [email] => fa@g.com
    [password] =>
$2y$10$hiXCMTOadhf3gDxYAtDo0ObemDVavHAYYG/PXpiTRgYosgIyMxfAm
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-02-23 04:37:55
    [lastvisitDate] => 2023-02-22 12:01:53
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 70
toValue = 78
seidValue = 50
pidValue = 1
result = 23
messageValue = testes
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 70
    [name] => فرهاد پاشایی
    [username] => 09212428467
    [email] => fa@g.com
    [password] =>
$2y$10$hiXCMTOadhf3gDxYAtDo0ObemDVavHAYYG/PXpiTRgYosgIyMxfAm
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-02-23 04:37:55
    [lastvisitDate] => 2023-02-22 12:01:53
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 70
toValue = 78
seidValue = 50
pidValue = 1
result = 23
messageValue = tttt
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 70
    [name] => فرهاد پاشایی
    [username] => 09212428467
    [email] => fa@g.com
    [password] =>
$2y$10$hiXCMTOadhf3gDxYAtDo0ObemDVavHAYYG/PXpiTRgYosgIyMxfAm
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-02-23 04:37:55
    [lastvisitDate] => 2023-02-22 12:01:53
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 70
toValue = 78
seidValue = 50
pidValue = 1
result = 23
messageValue = yrtyrdeyr
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 70
    [name] => فرهاد پاشایی
    [username] => 09212428467
    [email] => fa@g.com
    [password] =>
$2y$10$hiXCMTOadhf3gDxYAtDo0ObemDVavHAYYG/PXpiTRgYosgIyMxfAm
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-02-23 04:37:55
    [lastvisitDate] => 2023-02-22 12:01:53
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 70
toValue = 78
seidValue = 50
pidValue = 1
result = 23
messageValue = kkkkkk
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 68
    [name] => komeil abasi
    [username] => komeil
    [email] => komeil@gmal.com
    [password] =>
$2y$10$u0BC/UQlWaxID7o.OY8PTOS72n6btXRLsFrrcf3ntOPVpkNnmqEh6
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-02-23 04:37:13
    [lastvisitDate] => 2023-02-22 11:41:01
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 68
toValue = 70
seidValue = 49
pidValue = 5
result = 23
messageValue = jjjj
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 70
    [name] => فرهاد پاشایی
    [username] => 09212428467
    [email] => fa@g.com
    [password] =>
$2y$10$hiXCMTOadhf3gDxYAtDo0ObemDVavHAYYG/PXpiTRgYosgIyMxfAm
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-02-23 04:37:55
    [lastvisitDate] => 2023-02-22 12:01:53
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 70
toValue = 68
seidValue = 49
pidValue = 5
result = 23
messageValue = testtttt
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 78
    [name] => mahdi
    [username] => mahdi
    [email] => mahdi@gmail.com
    [password] =>
$2y$10$5hti/TLYaz4pcqgqtBwFSOvpkaquJ93nPABi5jPNrebaLzXpLxjV2
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-06-20 05:23:52
    [lastvisitDate] => 2023-02-22 11:54:18
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 78
toValue = 70
seidValue = 50
pidValue = 1
result = 23
messageValue = salam
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 70
    [name] => فرهاد پاشایی
    [username] => 09212428467
    [email] => fa@g.com
    [password] =>
$2y$10$hiXCMTOadhf3gDxYAtDo0ObemDVavHAYYG/PXpiTRgYosgIyMxfAm
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-02-23 04:37:55
    [lastvisitDate] => 2023-02-22 12:01:53
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 70
toValue = 78
seidValue = 50
pidValue = 1
result = 23
messageValue = 
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 78
    [name] => mahdi
    [username] => mahdi
    [email] => mahdi@gmail.com
    [password] =>
$2y$10$5hti/TLYaz4pcqgqtBwFSOvpkaquJ93nPABi5jPNrebaLzXpLxjV2
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-06-20 05:23:52
    [lastvisitDate] => 2023-02-22 11:54:18
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 78
toValue = 70
seidValue = 50
pidValue = 1
messageValue = <img
src="/components/com_reservation/files/IMG_2058.JPG">
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 78
    [name] => mahdi
    [username] => mahdi
    [email] => mahdi@gmail.com
    [password] =>
$2y$10$5hti/TLYaz4pcqgqtBwFSOvpkaquJ93nPABi5jPNrebaLzXpLxjV2
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-06-20 05:23:52
    [lastvisitDate] => 2023-02-22 11:54:18
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 78
toValue = 70
seidValue = 50
pidValue = 1
result = 23
messageValue = 
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 78
    [name] => mahdi
    [username] => mahdi
    [email] => mahdi@gmail.com
    [password] =>
$2y$10$5hti/TLYaz4pcqgqtBwFSOvpkaquJ93nPABi5jPNrebaLzXpLxjV2
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-06-20 05:23:52
    [lastvisitDate] => 2023-02-22 11:54:18
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 78
toValue = 70
seidValue = 50
pidValue = 1
messageValue = <img
src="/components/com_reservation/files/irnicverif.jpg">
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 78
    [name] => mahdi
    [username] => mahdi
    [email] => mahdi@gmail.com
    [password] =>
$2y$10$5hti/TLYaz4pcqgqtBwFSOvpkaquJ93nPABi5jPNrebaLzXpLxjV2
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-06-20 05:23:52
    [lastvisitDate] => 2023-02-22 11:54:18
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 78
toValue = 70
seidValue = 50
pidValue = 1
result = 23
messageValue = 
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 78
    [name] => mahdi
    [username] => mahdi
    [email] => mahdi@gmail.com
    [password] =>
$2y$10$5hti/TLYaz4pcqgqtBwFSOvpkaquJ93nPABi5jPNrebaLzXpLxjV2
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-06-20 05:23:52
    [lastvisitDate] => 2023-02-22 11:54:18
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 78
toValue = 70
seidValue = 50
pidValue = 1
messageValue = <img
src="/components/com_reservation/files/laseronconvayer.jpg">
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 78
    [name] => mahdi
    [username] => mahdi
    [email] => mahdi@gmail.com
    [password] =>
$2y$10$5hti/TLYaz4pcqgqtBwFSOvpkaquJ93nPABi5jPNrebaLzXpLxjV2
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-06-20 05:23:52
    [lastvisitDate] => 2023-02-22 11:54:18
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 78
toValue = 70
seidValue = 50
pidValue = 1
result = 23
messageValue = test
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 70
    [name] => فرهاد پاشایی
    [username] => 09212428467
    [email] => fa@g.com
    [password] =>
$2y$10$hiXCMTOadhf3gDxYAtDo0ObemDVavHAYYG/PXpiTRgYosgIyMxfAm
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-02-23 04:37:55
    [lastvisitDate] => 2023-02-22 12:01:53
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 70
toValue = 78
seidValue = 50
pidValue = 1
result = 23
messageValue = t
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 70
    [name] => فرهاد پاشایی
    [username] => 09212428467
    [email] => fa@g.com
    [password] =>
$2y$10$hiXCMTOadhf3gDxYAtDo0ObemDVavHAYYG/PXpiTRgYosgIyMxfAm
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-02-23 04:37:55
    [lastvisitDate] => 2023-02-22 12:01:53
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 70
toValue = 78
seidValue = 50
pidValue = 1
result = 23
messageValue = t
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 70
    [name] => فرهاد پاشایی
    [username] => 09212428467
    [email] => fa@g.com
    [password] =>
$2y$10$hiXCMTOadhf3gDxYAtDo0ObemDVavHAYYG/PXpiTRgYosgIyMxfAm
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-02-23 04:37:55
    [lastvisitDate] => 2023-02-22 12:31:21
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 70
toValue = 78
seidValue = 50
pidValue = 1
result = 23
messageValue = tt
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 70
    [name] => فرهاد پاشایی
    [username] => 09212428467
    [email] => fa@g.com
    [password] =>
$2y$10$hiXCMTOadhf3gDxYAtDo0ObemDVavHAYYG/PXpiTRgYosgIyMxfAm
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-02-23 04:37:55
    [lastvisitDate] => 2023-02-22 12:31:21
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 70
toValue = 78
seidValue = 50
pidValue = 1
result = 23
messageValue = ttt
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 70
    [name] => فرهاد پاشایی
    [username] => 09212428467
    [email] => fa@g.com
    [password] =>
$2y$10$hiXCMTOadhf3gDxYAtDo0ObemDVavHAYYG/PXpiTRgYosgIyMxfAm
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-02-23 04:37:55
    [lastvisitDate] => 2023-02-22 12:31:21
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 70
toValue = 78
seidValue = 50
pidValue = 1
result = 23
messageValue = ttttt
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 70
    [name] => فرهاد پاشایی
    [username] => 09212428467
    [email] => fa@g.com
    [password] =>
$2y$10$hiXCMTOadhf3gDxYAtDo0ObemDVavHAYYG/PXpiTRgYosgIyMxfAm
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-02-23 04:37:55
    [lastvisitDate] => 2023-02-22 12:31:21
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 70
toValue = 78
seidValue = 50
pidValue = 1
result = 23
messageValue = aaaaa
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 70
    [name] => فرهاد پاشایی
    [username] => 09212428467
    [email] => fa@g.com
    [password] =>
$2y$10$hiXCMTOadhf3gDxYAtDo0ObemDVavHAYYG/PXpiTRgYosgIyMxfAm
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-02-23 04:37:55
    [lastvisitDate] => 2023-02-22 12:31:21
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 70
toValue = 78
seidValue = 50
pidValue = 1
result = 23
messageValue = qqqq
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 70
    [name] => فرهاد پاشایی
    [username] => 09212428467
    [email] => fa@g.com
    [password] =>
$2y$10$hiXCMTOadhf3gDxYAtDo0ObemDVavHAYYG/PXpiTRgYosgIyMxfAm
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-02-23 04:37:55
    [lastvisitDate] => 2023-02-22 12:31:21
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 70
toValue = 78
seidValue = 50
pidValue = 1
result = 23
messageValue = تست
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 78
    [name] => mahdi
    [username] => mahdi
    [email] => mahdi@gmail.com
    [password] =>
$2y$10$5hti/TLYaz4pcqgqtBwFSOvpkaquJ93nPABi5jPNrebaLzXpLxjV2
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-06-20 05:23:52
    [lastvisitDate] => 2023-02-22 11:54:18
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 78
toValue = 70
seidValue = 50
pidValue = 1
result = 23
messageValue = تست جدید
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 78
    [name] => mahdi
    [username] => mahdi
    [email] => mahdi@gmail.com
    [password] =>
$2y$10$5hti/TLYaz4pcqgqtBwFSOvpkaquJ93nPABi5jPNrebaLzXpLxjV2
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-06-20 05:23:52
    [lastvisitDate] => 2023-02-22 11:54:18
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 78
toValue = 70
seidValue = 50
pidValue = 1
result = 23
messageValue = تست
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 68
    [name] => komeil abasi
    [username] => komeil
    [email] => komeil@gmal.com
    [password] =>
$2y$10$u0BC/UQlWaxID7o.OY8PTOS72n6btXRLsFrrcf3ntOPVpkNnmqEh6
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-02-23 04:37:13
    [lastvisitDate] => 2023-02-22 11:41:01
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 68
toValue = 70
seidValue = 49
pidValue = 5
result = 23
messageValue = کلام جدید
user = Joomla\CMS\User\User Object
(
    [isRoot:protected] => 
    [id] => 68
    [name] => komeil abasi
    [username] => komeil
    [email] => komeil@gmal.com
    [password] =>
$2y$10$u0BC/UQlWaxID7o.OY8PTOS72n6btXRLsFrrcf3ntOPVpkNnmqEh6
    [password_clear] => 
    [block] => 0
    [sendEmail] => 0
    [registerDate] => 2021-02-23 04:37:13
    [lastvisitDate] => 2023-02-22 11:41:01
    [activation] => 
    [params] =>
{"admin_style":"","admin_language":"","language":"","editor":"","timezone":""}
    [groups] => Array
        (
            [2] => 2
        )

    [guest] => 0
    [lastResetTime] => 0000-00-00 00:00:00
    [resetCount] => 0
    [requireReset] => 0
    [_params:protected] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [admin_style] => 
                    [admin_language] => 
                    [language] => 
                    [editor] => 
                    [timezone] => 
                )

            [initialized:protected] => 1
            [separator] => .
        )

    [_authGroups:protected] => 
    [_authLevels:protected] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 2
        )

    [_authActions:protected] => 
    [_errorMsg:protected] => 
    [userHelper:protected] => Joomla\CMS\User\UserWrapper Object
        (
        )

    [_errors:protected] => Array
        (
        )

    [otpKey] => 
    [otep] => 
)

fromValue = 68
toValue = 70
seidValue = 49
pidValue = 5
result = 23
PK٪�[���X�6�6	login.phpnu�[���<?php
/*----------------------------------------------------------------------------------|
 www.vdm.io  |----/
				fdsh 
/-------------------------------------------------------------------------------------------------------/

	@version		1.0.39
	@build			4th April, 2023
	@created		17th December, 2020
	@package		Reservation
	@subpackage		login.php
	@author			farhad shahbazi <http://farhad.com>	
	@copyright		Copyright (C) 2015. All Rights Reserved
	@license		GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
  ____  _____  _____  __  __  __      __       ___  _____  __  __  ____ 
_____  _  _  ____  _  _  ____ 
 (_  _)(  _  )(  _  )(  \/  )(  )    /__\     / __)(  _  )(  \/  )(  _ \( 
_  )( \( )( ___)( \( )(_  _)
.-_)(   )(_)(  )(_)(  )    (  )(__  /(__)\   ( (__  )(_)(  )    (  )___/
)(_)(  )  (  )__)  )  (   )(  
\____) (_____)(_____)(_/\/\_)(____)(__)(__)   \___)(_____)(_/\/\_)(__) 
(_____)(_)\_)(____)(_)\_) (__) 

/------------------------------------------------------------------------------------------------------*/

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

use Joomla\Utilities\ArrayHelper;

/**
 * Reservation Login Controller
 */
class ReservationControllerLogin extends JControllerForm
{
	/**
	 * Current or most recently performed task.
	 *
	 * @var    string
	 * @since  12.2
	 * @note   Replaces _task.
	 */
	protected $task;

	public function __construct($config = array())
	{
		$this->view_list = 'login'; // safeguard for setting the
return view listing to the default site view.
		parent::__construct($config);
	}


/***[JCBGUI.site_view.php_controller.43.$$$$]***/
  public function loginRegister()
  {

    $app = JFactory::getApplication();
    $phoneNumber = $app->input->get('phonenumber', 0);
    $uri = (string)JUri::getInstance();

    $info= [
      'phonenumber' => $phoneNumber,
      'userExist' => false,
      'table' => false,
      'validate' => false
    ];
    $app->setUserState('info',$info );

   
Joomla\CMS\Form\Form::addRulePath('administrator/components/com_reservation/models/rules');
    $xml = new SimpleXMLElement('<field
name="phonenumber" validate="mobile"/>');
    $rule = JFormHelper::loadRuleType('mobile');
    $validate = $rule->test($xml, $phoneNumber);

    if (!$validate) {
      $app->enqueueMessage('شماره موبایل معتبر
وارد نمایید', 'warning');
      $app->redirect($uri);
    }




    //    $view = $this->getView('login', 'html');
    $model= $this->getModel();
    list($userExist, $table)= $model->userExist($phoneNumber);
    // $userExist= $model->userExist($phoneNumber)[0];
    // $table= $model->userExist($phoneNumber)[1];

    $info= [
      'phonenumber' => $phoneNumber,
      'userExist' => $userExist,
      'table' => $table,
      'validate' => $validate,
    ];
    $app->setUserState('info',$info );


    if(!$userExist)
    {
      ReservationHelper::setExpireTime();
      $verify= ReservationHelper::setVerifyCode();


      \JPluginHelper::importPlugin('ejra');
      $dispatcher = \JEventDispatcher::getInstance();
     
$dispatcher->trigger('onAfterMobileValidate',array($phoneNumber,
$verify));
     
$app->redirect(JRoute::_('index.php?option=com_reservation&view=login&layout=default_register',false));
    }
    else
    {
      $app->setUserState('loginWith', 'password');
     
$app->redirect(JRoute::_('index.php?option=com_reservation&view=login&layout=default_password',false));
    }


  }
  public function register()
  {
    $app= JFactory::getApplication();
    $data=
$app->input->get('jform',array(),'array');

    $info= $app->getUserState('info');
    if (!$info['phonenumber'] || !$info['validate'] ||
$info['userExist'] || !JFactory::getUser()->guest)
     
$app->redirect(JRoute::_('index.php?option=com_reservation&view=login',false));

    $app->setUserState('owner.data',$data);

    $xml = new SimpleXMLElement('<field name="password"
type="text" required="true"
validate="password" minimum_length="4"
message="رمز عبور حداقل باید 4 کاراکتر
باشد" />');
    $rule = JFormHelper::loadRuleType('password');
    $validate = $rule->test($xml, $data['password']);



    if (empty($data['name']) || !$validate)
    {
      $app->enqueueMessage('اطلاعات خود را به
درستی وارد نمایید','warning');
     
$app->redirect(JRoute::_('index.php?option=com_reservation&view=login&layout=default_register',false));
    }

    date_default_timezone_set('asia/tehran');
    $verify= $app->getUserState('verify');
    $expire= $app->getUserState('expire');


    if (strtotime($expire) < time())
    {
      $app->enqueueMessage('زمان کد تایید به
پایان رسیده لطفا بر روی ارسال مجدد کد
کلیک نمایید','warning');
     
$app->redirect(JRoute::_('index.php?option=com_reservation&view=login&layout=default_register',false));
    }


    if ($data['verify'] != $verify)
    {
      $app->enqueueMessage('کد تایید را به درستی
وارد کنید','warning');
     
$app->redirect(JRoute::_('index.php?option=com_reservation&view=login&layout=default_register',false));
    }




    $userdata = array(
      "name"=> $data['name'],
      "username"=> $info['phonenumber'],
      "password"=> $data['password'],
      "password2"=> $data['password'],
      "email"=>
'E_'.$info['phonenumber'].'@gmail.com',
      "block"=> 0,
    );


    jimport('joomla.user.helper');
    $params= $app->getparams('com_Reservation');

    //       $userGroup= $params->get('ownerrgroup');
    $userGroup= 2;



    // if(!isset($userGroup))
    // $userGroup = 2;

    // $userdata["groups"] = [$userGroup];
    // $user = new JUser;


    // if(!$user->bind($userdata)) {
    // $app->enqueueMessage($user->getError(), 'warning');
    //
$app->redirect(JRoute::_('index.php?option=com_Reservation&view=login',false));
    // }

    // if (!$user->save()) {
    // $app->enqueueMessage($user->getError(), 'warning');
    //
$app->redirect(JRoute::_('index.php?option=com_Reservation&view=login',false));
    // }



    if ( ( ! file_exists( JPATH_SITE .
'/libraries/CBLib/CBLib/Core/CBLib.php' ) ) || ( ! file_exists(
JPATH_ADMINISTRATOR .
'/components/com_comprofiler/plugin.foundation.php' ) ) ) {
      echo 'CB not installed';
      return;
    }

    include_once( JPATH_ADMINISTRATOR .
'/components/com_comprofiler/plugin.foundation.php' );
    cbimport( 'cb.html' );
    global $_CB_framework, $_PLUGINS, $ueConfig;
    $_PLUGINS->loadPluginGroup($data["username"]); // for
using cb trigering
    jimport('joomla.user.helper');
    $post = isset($data["post"]) ? $data["post"] :
$data;
    $post["name"] = $post["firstname"] . " "
. $post["lastname"];



    $_PLUGINS->loadPluginGroup( 'user' );

    $user					=	new \CB\Database\Table\UserTable();
    $user->set( 'username', $userdata['username']
);
    $user->set( 'email', $userdata["email"] );
    // /* $user->set( 'firstName',
$post["firstname"] );*/
    // /* $user->set( 'lastName', $post["lastname"]
);*/
    $user->set( 'name', $userdata['name'] );
    $user->set( 'gids', array($userGroup) );
    $user->set( 'sendEmail', 0 );
    $user->set( 'registerDate',
$_CB_framework->getUTCDate() );
    $user->set( 'password',
$user->hashAndSaltPassword($userdata["password"]) );
    $user->set( 'approved', 1 );
    $user->set( 'confirmed', 1 );
    $user->set( 'block', 0 );

    if ( $user->store() ) {
      if ( $user->get( 'confirmed' ) == 0 ) {
        $user->store();
      }
    }
    // dump($user, 'user');
    // dump($userdata, 'userdata');

    $userId= $user->id;

    $sickInfo= array(
      'userid'=> $userId,
      'phonenumber' => $info['phonenumber'],
    );


    JLoader::register('ReservationModelSick',
JPATH_COMPONENT_ADMINISTRATOR.'/models/sick.php');
    $sickModel= new ReservationModelSick();
    if(!$sickModel->save($sickInfo))
    {
      $app->enqueueMessage('اطلاعات خود را تصحیح
کرده و سپس وارد نمایید', 'warning');
     
$app->redirect(JRoute::_('index.php?option=com_Reservation&view=login',false));
    }
    $app->setUserState('info','');


    $credentials = array();
    $credentials['username'] = $info['phonenumber'];
    $credentials['password'] = $data['password'];
    $login_site = JFactory::getApplication('site');
    $login_site->login($credentials, $options=array());
    $redirect = JUri::root();
    $login_site->redirect($redirect);



  }

  public function resetExpireTime()
  {
    $app= JFactory::getApplication();
    $uri= (string)JUri::getInstance();
    $data=
$app->input->get('jform',array(),'array');
    $app->setUserState('owner.data',$data);

    date_default_timezone_set('asia/tehran');
    $expire= $app->getUserState('expire');

    if (strtotime($expire) < time())
    {
      ReservationHelper::setExpireTime();
      $verify= ReservationHelper::setVerifyCode();
      $phoneNumber=
$app->getUserState('info')['phonenumber'];


      \JPluginHelper::importPlugin('ejra');
      $dispatcher = \JEventDispatcher::getInstance();
     
$dispatcher->trigger('onAfterMobileValidate',array($phoneNumber,
$verify));
    }

    $app->redirect($uri);
  }
  public function login()
  {


    $app= JFactory::getApplication();
    $info= $app->getUserState('info');
    if (!$info['phonenumber'] || !$info['validate'] ||
!$info['userExist'] || !JFactory::getUser()->guest)
    {
     
$this->app->redirect(JRoute::_('index.php?option=com_reservation&view=login',false));
    }

    $loginWith= $app->getUserState('loginWith');

    $phoneNumber=
$app->getUserState('info')['phonenumber'];
    $data=
$app->input->get('jform',array(),'array');

    $credentials = array();
    if ($loginWith== 'password')
    {


      $credentials['username'] = $phoneNumber;
      $credentials['password'] = $data['password'];
      $credentials['loginWith'] = 'password';
      $login_site = JFactory::getApplication('site');

    }
    elseif($loginWith== 'verifyCode')
    {

      date_default_timezone_set('asia/tehran');
      $verify= $app->getUserState('verify');
      $expire= $app->getUserState('expire');


      if (strtotime($expire) < time())
      {
        $app->enqueueMessage('زمان کد تایید به
پایان رسیده لطفا بر روی ارسال مجدد کد
کلیک نمایید','warning');
       
$app->redirect(JRoute::_('index.php?option=com_reservation&view=login&layout=default_password',false));
      }


      if ($data['password'] != $verify)
      {
        $app->enqueueMessage('کد تایید را به درستی
وارد کنید','warning');
       
$app->redirect(JRoute::_('index.php?option=com_reservation&view=login&layout=default_password',false));
      }

      $model= $this->getModel();
      $table= $app->getUserState('info')['table'];
      $userid= $model->getUserId($table, $phoneNumber);

      $credentials['username'] = $phoneNumber;
      $credentials['password'] = $data['password'];
      $credentials['userid'] = $userid;
      $credentials['loginWith'] = 'verifyCode';
      $login_site = JFactory::getApplication('site');

    }

    $result= $login_site->login($credentials, $options=array());

    if(!$result)
     
$login_site->redirect(JRoute::_('index.php?option=com_reservation&view=login&layout=default_password',false));


    $redirect = JUri::root();
    $app->redirect($redirect);
  }

  public function verifyCode()
  {
    $app= JFactory::getApplication();
    $app->setUserState('loginWith', 'verifyCode');

    ReservationHelper::setExpireTime();
    $verify= ReservationHelper::setVerifyCode();
    $phoneNumber=
$app->getUserState('info')['phonenumber'];


    \JPluginHelper::importPlugin('ejra');
    $dispatcher = \JEventDispatcher::getInstance();
   
$dispatcher->trigger('onAfterMobileValidate',array($phoneNumber,
$verify));

   
$app->redirect(JRoute::_('index.php?option=com_reservation&view=login&layout=default_password',false));
  }
  public function password()
  {
    $app= JFactory::getApplication();
    $app->setUserState('loginWith', 'password');
   
$app->redirect(JRoute::_('index.php?option=com_reservation&view=login&layout=default_password',false));
  }
/***[/JCBGUI$$$$]***/


	/**
	 * Method to check if you can edit an existing record.
	 *
	 * Extended classes can override this if necessary.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key;
default is id.
	 *
	 * @return  boolean
	 *
	 * @since   12.2
	 */
	protected function allowEdit($data = array(), $key = 'id')
	{
		// to insure no other tampering
		return false;
	}

        /**
	 * Method override to check if you can add a new record.
	 *
	 * @param   array  $data  An array of input data.
	 *
	 * @return  boolean
	 *
	 * @since   1.6
	 */
	protected function allowAdd($data = array())
	{
		// to insure no other tampering
		return false;
	}

	/**
	 * Method to check if you can save a new or existing record.
	 *
	 * Extended classes can override this if necessary.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key.
	 *
	 * @return  boolean
	 *
	 * @since   12.2
	 */
	protected function allowSave($data, $key = 'id')
	{
		// to insure no other tampering
		return false;
	}

	/**
	 * Function that allows child controller access to model data
	 * after the data has been saved.
	 *
	 * @param   JModelLegacy  $model      The data model object.
	 * @param   array         $validData  The validated data.
	 *
	 * @return  void
	 *
	 * @since   12.2
	 */
	protected function postSaveHook(JModelLegacy $model, $validData = array())
	{
	}
}
PK٪�[�b�~I"I"plan.phpnu�[���<?php
/*----------------------------------------------------------------------------------|
 www.vdm.io  |----/
				fdsh 
/-------------------------------------------------------------------------------------------------------/

	@version		1.0.39
	@build			4th April, 2023
	@created		17th December, 2020
	@package		Reservation
	@subpackage		plan.php
	@author			farhad shahbazi <http://farhad.com>	
	@copyright		Copyright (C) 2015. All Rights Reserved
	@license		GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
  ____  _____  _____  __  __  __      __       ___  _____  __  __  ____ 
_____  _  _  ____  _  _  ____ 
 (_  _)(  _  )(  _  )(  \/  )(  )    /__\     / __)(  _  )(  \/  )(  _ \( 
_  )( \( )( ___)( \( )(_  _)
.-_)(   )(_)(  )(_)(  )    (  )(__  /(__)\   ( (__  )(_)(  )    (  )___/
)(_)(  )  (  )__)  )  (   )(  
\____) (_____)(_____)(_/\/\_)(____)(__)(__)   \___)(_____)(_/\/\_)(__) 
(_____)(_)\_)(____)(_)\_) (__) 

/------------------------------------------------------------------------------------------------------*/

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

use Joomla\Utilities\ArrayHelper;

/**
 * Plan Controller
 */
class ReservationControllerPlan extends JControllerForm
{
	/**
	 * Current or most recently performed task.
	 *
	 * @var    string
	 * @since  12.2
	 * @note   Replaces _task.
	 */
	protected $task;

	/**
	 * Class constructor.
	 *
	 * @param   array  $config  A named array of configuration variables.
	 *
	 * @since   1.6
	 */
	public function __construct($config = array())
	{
		$this->view_list = 'login'; // safeguard for setting the
return view listing to the default site view.
		parent::__construct($config);
	}

        /**
	 * Method override to check if you can add a new record.
	 *
	 * @param   array  $data  An array of input data.
	 *
	 * @return  boolean
	 *
	 * @since   1.6
	 */
	protected function allowAdd($data = array())
	{
		// Get user object.
		$user = JFactory::getUser();
		// Access check.
		$access = $user->authorise('plan.access',
'com_reservation');
		if (!$access)
		{
			return false;
		}

		// In the absense of better information, revert to the component
permissions.
		return parent::allowAdd($data);
	}

	/**
	 * Method override to check if you can edit an existing record.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key.
	 *
	 * @return  boolean
	 *
	 * @since   1.6
	 */
	protected function allowEdit($data = array(), $key = 'id')
	{
		// get user object.
		$user = JFactory::getUser();
		// get record id.
		$recordId = (int) isset($data[$key]) ? $data[$key] : 0;


		if ($recordId)
		{
			// The record has been set. Check the record permissions.
			$permission = $user->authorise('core.edit',
'com_reservation.plan.' . (int) $recordId);
			if (!$permission)
			{
				if ($user->authorise('core.edit.own',
'com_reservation.plan.' . $recordId))
				{
					// Now test the owner is the user.
					$ownerId = (int) isset($data['created_by']) ?
$data['created_by'] : 0;
					if (empty($ownerId))
					{
						// Need to do a lookup from the model.
						$record = $this->getModel()->getItem($recordId);

						if (empty($record))
						{
							return false;
						}
						$ownerId = $record->created_by;
					}

					// If the owner matches 'me' then allow.
					if ($ownerId == $user->id)
					{
						if ($user->authorise('core.edit.own',
'com_reservation'))
						{
							return true;
						}
					}
				}
				return false;
			}
		}
		// Since there is no permission, revert to the component permissions.
		return parent::allowEdit($data, $key);
	}

	/**
	 * Gets the URL arguments to append to an item redirect.
	 *
	 * @param   integer  $recordId  The primary key id for the item.
	 * @param   string   $urlVar    The name of the URL variable for the id.
	 *
	 * @return  string  The arguments to append to the redirect URL.
	 *
	 * @since   1.6
	 */
	protected function getRedirectToItemAppend($recordId = null, $urlVar =
'id')
	{
		// get the referral options (old method use return instead see parent)
		$ref = $this->input->get('ref', 0, 'string');
		$refid = $this->input->get('refid', 0, 'int');

		// get redirect info.
		$append = parent::getRedirectToItemAppend($recordId, $urlVar);

		// set the referral options
		if ($refid && $ref)
                {
			$append = '&ref=' . (string)$ref .
'&refid='. (int)$refid . $append;
		}
		elseif ($ref)
		{
			$append = '&ref='. (string)$ref . $append;
		}

		return $append;
	}

	/**
	 * Method to run batch operations.
	 *
	 * @param   object  $model  The model.
	 *
	 * @return  boolean   True if successful, false otherwise and internal
error is set.
	 *
	 * @since   2.5
	 */
	public function batch($model = null)
	{
		JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));

		// Set the model
		$model = $this->getModel('Plan', '', array());

		// Preset the redirect
		$this->setRedirect(JRoute::_('index.php?option=com_reservation&view=plans'
. $this->getRedirectToListAppend(), false));

		return parent::batch($model);
	}

	/**
	 * Method to cancel an edit.
	 *
	 * @param   string  $key  The name of the primary key of the URL variable.
	 *
	 * @return  boolean  True if access level checks pass, false otherwise.
	 *
	 * @since   12.2
	 */
	public function cancel($key = null)
	{
		// get the referral options
		$this->ref = $this->input->get('ref', 0,
'word');
		$this->refid = $this->input->get('refid', 0,
'int');

		// Check if there is a return value
		$return = $this->input->get('return', null,
'base64');

		$cancel = parent::cancel($key);

		if (!is_null($return) &&
JUri::isInternal(base64_decode($return)))
		{
			$redirect = base64_decode($return);

			// Redirect to the return value.
			$this->setRedirect(
				JRoute::_(
					$redirect, false
				)
			);
		}
		elseif ($this->refid && $this->ref)
		{
			$redirect = '&view=' . (string)$this->ref .
'&layout=edit&id=' . (int)$this->refid;

			// Redirect to the item screen.
			$this->setRedirect(
				JRoute::_(
					'index.php?option=' . $this->option . $redirect, false
				)
			);
		}
		elseif ($this->ref)
		{
			$redirect = '&view=' . (string)$this->ref;

			// Redirect to the list screen.
			$this->setRedirect(
				JRoute::_(
					'index.php?option=' . $this->option . $redirect, false
				)
			);
		}
		return $cancel;
	}

	/**
	 * Method to save a record.
	 *
	 * @param   string  $key     The name of the primary key of the URL
variable.
	 * @param   string  $urlVar  The name of the URL variable if different
from the primary key (sometimes required to avoid router collisions).
	 *
	 * @return  boolean  True if successful, false otherwise.
	 *
	 * @since   12.2
	 */
	public function save($key = null, $urlVar = null)
	{
		// get the referral options
		$this->ref = $this->input->get('ref', 0,
'word');
		$this->refid = $this->input->get('refid', 0,
'int');

		// Check if there is a return value
		$return = $this->input->get('return', null,
'base64');
		$canReturn = (!is_null($return) &&
JUri::isInternal(base64_decode($return)));

		if ($this->ref || $this->refid || $canReturn)
		{
			// to make sure the item is checkedin on redirect
			$this->task = 'save';
		}

		$saved = parent::save($key, $urlVar);

		// This is not needed since parent save already does this
		// Due to the ref and refid implementation we need to add this
		if ($canReturn)
		{
			$redirect = base64_decode($return);

			// Redirect to the return value.
			$this->setRedirect(
				JRoute::_(
					$redirect, false
				)
			);
		}
		elseif ($this->refid && $this->ref)
		{
			$redirect = '&view=' . (string)$this->ref .
'&layout=edit&id=' . (int)$this->refid;

			// Redirect to the item screen.
			$this->setRedirect(
				JRoute::_(
					'index.php?option=' . $this->option . $redirect, false
				)
			);
		}
		elseif ($this->ref)
		{
			$redirect = '&view=' . (string)$this->ref;

			// Redirect to the list screen.
			$this->setRedirect(
				JRoute::_(
					'index.php?option=' . $this->option . $redirect, false
				)
			);
		}
		return $saved;
	}

	/**
	 * Function that allows child controller access to model data
	 * after the data has been saved.
	 *
	 * @param   JModel  &$model     The data model object.
	 * @param   array   $validData  The validated data.
	 *
	 * @return  void
	 *
	 * @since   11.1
	 */
	protected function postSaveHook(JModelLegacy $model, $validData = array())
	{

/***[JCBGUI.admin_view.php_postsavehook.112.$$$$]***/
		$id = $model->getState()->{'plan.id'};
		$validData['id'] = $id;
		JPluginHelper::importPlugin('reservation');
		$dispatcher = JEventDispatcher::getInstance();
		$dispatcher->trigger('onReservationPlanCreated',
array($validData));/***[/JCBGUI$$$$]***/


		return;
	}

}
PK٪�[�&{�nnreserve.phpnu�[���<?php
/*----------------------------------------------------------------------------------|
 www.vdm.io  |----/
				fdsh 
/-------------------------------------------------------------------------------------------------------/

	@version		1.0.32
	@build			14th June, 2021
	@created		17th December, 2020
	@package		Reservation
	@subpackage		reserve.php
	@author			farhad shahbazi <http://farhad.com>	
	@copyright		Copyright (C) 2015. All Rights Reserved
	@license		GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
  ____  _____  _____  __  __  __      __       ___  _____  __  __  ____ 
_____  _  _  ____  _  _  ____ 
 (_  _)(  _  )(  _  )(  \/  )(  )    /__\     / __)(  _  )(  \/  )(  _ \( 
_  )( \( )( ___)( \( )(_  _)
.-_)(   )(_)(  )(_)(  )    (  )(__  /(__)\   ( (__  )(_)(  )    (  )___/
)(_)(  )  (  )__)  )  (   )(  
\____) (_____)(_____)(_/\/\_)(____)(__)(__)   \___)(_____)(_/\/\_)(__) 
(_____)(_)\_)(____)(_)\_) (__) 

/------------------------------------------------------------------------------------------------------*/

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

use Joomla\Utilities\ArrayHelper;

/**
 * Reservation Reserve Controller
 */
class ReservationControllerReserve extends JControllerForm
{
	/**
	 * Current or most recently performed task.
	 *
	 * @var    string
	 * @since  12.2
	 * @note   Replaces _task.
	 */
	protected $task;

	public function __construct($config = array())
	{
		$this->view_list = 'reserve'; // safeguard for setting the
return view listing to the default site view.
		parent::__construct($config);
	}


/***[JCBGUI.site_view.php_controller.36.$$$$]***/
public function default_personalinfo()
{
    $function_to_be_executed= $this->check(__FUNCTION__);
  echo '<pre>';
  var_dump($function_to_be_executed);
  echo '</pre>';
  exit();
}

public function check($funcname)
{
    JSession::checkToken('post') or die;

    $uri= (string)JUri::getInstance();
  
    $app= JFactory::getApplication();
    $params= JComponentHelper::getParams('com_reservation');
    $chekout= $params->get('checkout');
    $function_to_be_executed=
$app->getUserState('function_to_be_executed',0);
    $step= 'checkout'.$function_to_be_executed;
    $layout= $chekout->$step->reservetemplate;
    $layout= preg_replace('/\.php$/','',$layout);

    if ($layout != $funcname)
    {
        $app->setUserState('function_to_be_executed',0);
        $app->redirect($uri);
    }

    return ++$function_to_be_executed;
}

public function reserve()
{
    require
JPATH_SITE.'/components/com_reservation/helpers/reserve.php';
    $reserve= new reserve();

}
public function reordering($checkout)
    {
        $checkout= (array) $checkout;

        $reordering= [];
        foreach ($checkout as $item) {
            $reordering[]= $item;
        }

        return $reordering;
    }

    public function getLayout()
    {
        $app= JFactory::getApplication();
        $params= JComponentHelper::getParams('com_reservation');
        $chekout= $params->get('checkout');
        $chekout= $this->reordering($chekout);
        $function_to_be_executed=
$app->getUserState('function_to_be_executed',0);
        $layout= $chekout[$function_to_be_executed]->reservetemplate;
        $layout= preg_replace('/\.php$/','',$layout);
        return $layout;
    }
  public function back()
    {
        JSession::checkToken('post') or die;
        $app= JFactory::getApplication();
        $function_to_be_executed=
$app->getUserState('function_to_be_executed',0);
       
$app->setUserState('function_to_be_executed',--$function_to_be_executed);
        $app->redirect(JUri::getInstance());
    }/***[/JCBGUI$$$$]***/


    public function payment()
    {
        require_once
JPATH_SITE.'/components/com_reservation/helpers/payment.php';
        $obj= new strategy();
        $obj->do_request();
    }

    public function paymentverify()
    {
        require_once
JPATH_SITE.'/components/com_reservation/helpers/payment.php';
        $obj= new strategy();
        $obj->do_verify();
    }


	/**
	 * Method to check if you can edit an existing record.
	 *
	 * Extended classes can override this if necessary.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key;
default is id.
	 *
	 * @return  boolean
	 *
	 * @since   12.2
	 */
	protected function allowEdit($data = array(), $key = 'id')
	{
		// to insure no other tampering
		return false;
	}

        /**
	 * Method override to check if you can add a new record.
	 *
	 * @param   array  $data  An array of input data.
	 *
	 * @return  boolean
	 *
	 * @since   1.6
	 */
	protected function allowAdd($data = array())
	{
		// to insure no other tampering
		return false;
	}

	/**
	 * Method to check if you can save a new or existing record.
	 *
	 * Extended classes can override this if necessary.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key.
	 *
	 * @return  boolean
	 *
	 * @since   12.2
	 */
	protected function allowSave($data, $key = 'id')
	{
		// to insure no other tampering
		return false;
	}

	/**
	 * Function that allows child controller access to model data
	 * after the data has been saved.
	 *
	 * @param   JModelLegacy  $model      The data model object.
	 * @param   array         $validData  The validated data.
	 *
	 * @return  void
	 *
	 * @since   12.2
	 */
	protected function postSaveHook(JModelLegacy $model, $validData =
array())
	{
	}
}
PK٪�[[\t_��reserve_appointment.phpnu�[���<?php
/*----------------------------------------------------------------------------------|
 www.vdm.io  |----/
				fdsh 
/-------------------------------------------------------------------------------------------------------/

	@version		1.0.39
	@build			4th April, 2023
	@created		17th December, 2020
	@package		Reservation
	@subpackage		reserve_appointment.php
	@author			farhad shahbazi <http://farhad.com>	
	@copyright		Copyright (C) 2015. All Rights Reserved
	@license		GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
  ____  _____  _____  __  __  __      __       ___  _____  __  __  ____ 
_____  _  _  ____  _  _  ____ 
 (_  _)(  _  )(  _  )(  \/  )(  )    /__\     / __)(  _  )(  \/  )(  _ \( 
_  )( \( )( ___)( \( )(_  _)
.-_)(   )(_)(  )(_)(  )    (  )(__  /(__)\   ( (__  )(_)(  )    (  )___/
)(_)(  )  (  )__)  )  (   )(  
\____) (_____)(_____)(_/\/\_)(____)(__)(__)   \___)(_____)(_/\/\_)(__) 
(_____)(_)\_)(____)(_)\_) (__) 

/------------------------------------------------------------------------------------------------------*/

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

use Joomla\Utilities\ArrayHelper;

/**
 * Reservation Reserve_appointment Controller
 */
class ReservationControllerReserve_appointment extends JControllerForm
{
	/**
	 * Current or most recently performed task.
	 *
	 * @var    string
	 * @since  12.2
	 * @note   Replaces _task.
	 */
	protected $task;

	public function __construct($config = array())
	{
		$this->view_list = 'login'; // safeguard for setting the
return view listing to the default site view.
		parent::__construct($config);
	}


/***[JCBGUI.site_view.php_controller.36.$$$$]***/
public function default_personalinfo()
{
    $function_to_be_executed= $this->check(__FUNCTION__);
  echo '<pre>';
  var_dump($function_to_be_executed);
  echo '</pre>';
  exit();
}

public function check($funcname)
{
    JSession::checkToken('post') or die;

    $uri= (string)JUri::getInstance();
  
    $app= JFactory::getApplication();
    $params= JComponentHelper::getParams('com_reservation');
    $chekout= $params->get('checkout');
    $function_to_be_executed=
$app->getUserState('function_to_be_executed',0);
    $step= 'checkout'.$function_to_be_executed;
    $layout= $chekout->$step->reservetemplate;
    $layout= preg_replace('/\.php$/','',$layout);

    if ($layout != $funcname)
    {
        $app->setUserState('function_to_be_executed',0);
        $app->redirect($uri);
    }

    return ++$function_to_be_executed;
}

public function reserve()
{
    require
JPATH_SITE.'/components/com_reservation/helpers/reserve.php';
    $reserve= new reserve();

}
public function reordering($checkout)
    {
        $checkout= (array) $checkout;

        $reordering= [];
        foreach ($checkout as $item) {
            $reordering[]= $item;
        }

        return $reordering;
    }

    public function getLayout()
    {
        $app= JFactory::getApplication();
        $params= JComponentHelper::getParams('com_reservation');
        $chekout= $params->get('checkout');
        $chekout= $this->reordering($chekout);
        $function_to_be_executed=
$app->getUserState('function_to_be_executed',0);
        $layout= $chekout[$function_to_be_executed]->reservetemplate;
        $layout= preg_replace('/\.php$/','',$layout);
        return $layout;
    }
  public function back()
    {
        JSession::checkToken('post') or die;
        $app= JFactory::getApplication();
        $function_to_be_executed=
$app->getUserState('function_to_be_executed',0);
       
$app->setUserState('function_to_be_executed',--$function_to_be_executed);
        $app->redirect(JUri::getInstance());
    }
  public function reset()
    {

        $uri= JUri::getInstance();
        $app= JFactory::getApplication();
        $app->setUserState('function_to_be_executed',0);
        $uri->delVar('start');
        $app->redirect((string)$uri);
    }/***[/JCBGUI$$$$]***/


	/**
	 * Method to check if you can edit an existing record.
	 *
	 * Extended classes can override this if necessary.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key;
default is id.
	 *
	 * @return  boolean
	 *
	 * @since   12.2
	 */
	protected function allowEdit($data = array(), $key = 'id')
	{
		// to insure no other tampering
		return false;
	}

        /**
	 * Method override to check if you can add a new record.
	 *
	 * @param   array  $data  An array of input data.
	 *
	 * @return  boolean
	 *
	 * @since   1.6
	 */
	protected function allowAdd($data = array())
	{
		// to insure no other tampering
		return false;
	}

	/**
	 * Method to check if you can save a new or existing record.
	 *
	 * Extended classes can override this if necessary.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key.
	 *
	 * @return  boolean
	 *
	 * @since   12.2
	 */
	protected function allowSave($data, $key = 'id')
	{
		// to insure no other tampering
		return false;
	}

	/**
	 * Function that allows child controller access to model data
	 * after the data has been saved.
	 *
	 * @param   JModelLegacy  $model      The data model object.
	 * @param   array         $validData  The validated data.
	 *
	 * @return  void
	 *
	 * @since   12.2
	 */
	protected function postSaveHook(JModelLegacy $model, $validData = array())
	{
	}
}
PK3��[�d�	�	suggestions.json.phpnu�[���PK
��[ߏfXX�	account.phpnu�[���PK
��[�2�����checkout.json.phpnu�[���PK
��[S�h"̮̮checkout.phpnu�[���PK
��[�.����Lcomparison.json.phpnu�[���PK
��[	�����_comparison.phpnu�[���PK
��[UB�yrr�gdownload.phpnu�[���PK
��[�#o,,
knindex.htmlnu�[���PK
��[a�u�		�nitem.phpnu�[���PK
��[�����r�r�xpos.json.phpnu�[���PK��[�L�[[U�pos.phpnu�[���PK��[�Q�0�2�2�question.phpnu�[���PK��[�B����.response.phpnu�[���PK��[��ߦ55
Asubmit.phpnu�[���PK��[�+��Wvwishlist.json.phpnu�[���PK��[�"�<zzN�wishlist.phpnu�[���PK٪�[␅�$�$
�ajax.json.phpnu�[���PK٪�[�����7�comment.phpnu�[���PK٪�[wb�v���consultantsignup.phpnu�[���PK٪�[p�a���C�consultant_plan.phpnu�[���PK٪�[r9Ѥrrj�doctors.phpnu�[���PK٪�[��'QQdoctorsignup.phpnu�[���PK٪�[oɢ����,fileupload.phpnu�[���PK٪�[��B�"�"�8firstqst.phpnu�[���PK٪�[��ѩ��	K[log23.txtnu�[���PK٪�[���X�6�6	ologin.phpnu�[���PK٪�[�b�~I"I"{Eplan.phpnu�[���PK٪�[�&{�nn�greserve.phpnu�[���PK٪�[[\t_���~reserve_appointment.phpnu�[���PK�~�