<?php
/*----------------------------------------------------------------------------------|  www.vdm.io  |----/
				fdsh 
/-------------------------------------------------------------------------------------------------------/

	@version		1.0.39
	@build			4th April, 2023
	@created		17th December, 2020
	@package		Reservation
	@subpackage		default.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');


?>
<?php echo $this->toolbar->render(); ?>
<div class="chat">
    <div class="row justify-content-center">
        <div class="col-md-8">

            <div class="card">
                <div class="card-header">
                    <p><?php echo $this->item->users_name; ?></p>
                    <a class="img" href="#">
                    <?php
                      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';
                        $imgurl = '';
                      }
                      else
                      {
                        include_once( JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php' );
                        
                        cbimport( 'cb.html' );
                        $joomlaid = $id;
                        global $_CB_framework, $_PLUGINS, $ueConfig;

                        $cbUser =& CBuser::getInstance( (int) JFactory::getApplication()->input->get('uid') );
                        $user = $cbUser->getUserData();
                        $imgurl = '/images/comprofiler/' . $user->avatar;
                        // dump($user, 'user');
                      }
                    ?>
                        <img src="<?php echo $imgurl;?>" alt="">
                    </a>
                </div>
                <div class="card-body">
                    <div class="pm">
                                 <span class="text">
                                  سلام، دکتر <?= $this->item->users_name;?>  هستم <?php echo $this->item->categories_title; ?>
                                </span>
                        <br/>
                        <span class="time">22:36</span>
                    </div>
                    <div class="pm">
                                 <span class="text">
                                  از طریق این سیستم، شما می توانید با من گفتگو کنید. من از ساعت 8 صبح الی 24 پاسخگوی شما هستم و تلاش می کنم تا 10 ساعت آینده پاسخ شما رو بدهم.
                                </span>
                        <br/>
                        <span class="time">22:36</span>
                    </div>
                </div>
                <div class="card-footer">
                    <form style="padding: 15px;" action="<?= JRoute::_('index.php?option=com_reservation&view=firstQst&uid='.$this->item->userid.'&pid='.$this->item->plan->id,false);?>" method="post" id="adminForm" class="form-inline">
                        <?php if (JFactory::getUser()->guest): ?>

                            <!-- Button trigger modal -->
                            <button id="mbtn" type="button" class="btn btn-primary formbtn" data-toggle="modal" data-target="#m1">
                                ارسال
                            </button>

                        <?php else: ?>

                            <button type="submit" name="chatSendBtn" id="chatSendBtn" class="btn btn-primary formbtn" style="position:relative;;background-color:#007bff; cursor:pointer;margin-top: 0;">
                                ارسال
                                <div id="loading" class="spinner-grow text-warning" role="status">
                                    <span class="sr-only">Loading...</span>
                                </div>
                            </button>

                        <?php endif; ?>

                        <input type="text" style="flex-grow: 2" class="form-control mr-1" name="chatMessage" id="chatMessage" required placeholder="پیام خود را وارد کنید ...">
                        <input type="hidden" name="task" value="firstQst.save" />
                        <?php echo JHtml::_('form.token'); ?>
                    </form>

                </div>
            </div>

        </div>
    </div>
</div><!--[/JCBGUI$$$$]-->

<!-- Modal -->
<div class="modal fade" id="m1" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                برای شروع گفت و گو ابتدا باید وارد حساب کاربری خود شوید.
            </div>
            <div class="modal-footer">
                <a href="<?= JRoute::_('index.php?option=com_reservation&view=usersign&Itemid=642',false);?>" class="btn btn-primary">ورود به حساب کاربری</a>
            </div>
        </div>
    </div>
</div>


