-
Notifications
You must be signed in to change notification settings - Fork 0
/
a_crisp.php
115 lines (99 loc) · 3.21 KB
/
a_crisp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
/**
* Crisp - Free Chat for Prestashop
*
* @category Customer Care
* @package Prestafy_Crisp
* @author Andresa Martins ([email protected])
* @copyright Copyright (c) 2019 Prestafy Desenvolvimento e Suporte (https://www.prestafy.com.br)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
class A_Crisp extends Module
{
/**
* A_Crisp constructor.
*/
public function __construct()
{
$this->name = 'a_crisp';
$this->displayName = $this->l('Crisp - Chat Gratuíto');
$this->author = 'Prestafy';
$this->tab = 'front_office_features';
$this->version = "2.0";
$this->bootstrap = true;
$this->description = $this->l('Permite que seu consumidor entre em contato diretamente com seu atendimento através de um chat flutuante em seu site.') . '<a href="https://www.prestafy.com.br/">Prestafy</a>';
parent::__construct();
}
/**
* Module installer
*
* @return bool
*/
public function install()
{
return (parent::install() && $this->registerHook('displayHeader'));
}
/**
* Uninstall this module
*
* @return bool
*/
public function uninstall()
{
return (parent::uninstall() == false);
}
/**
* Add Crisp JS to the header hook.
* Assign customer name/email if the customer is logged
*
* @param Array $params
* @return string
*/
public function hookDisplayHeader($params)
{
$websiteId = Configuration::get('ACRISP_WEBSITE_ID');
$this->context->smarty->assign(array(
'crisp_customer' => $this->context->customer,
'crisp_website_id' => $websiteId
));
return $this->display(__FILE__, 'crisp.tpl');
}
/**
* Generate admin settings page
*
* @return string
*/
public function getContent()
{
$get_website_id = Tools::getValue("crisp_website_id");
if (isset($get_website_id) && !empty($get_website_id)) {
Configuration::updateValue("ACRISP_WEBSITE_ID", Tools::getValue("crisp_website_id"));
}
$websiteId = Configuration::get('ACRISP_WEBSITE_ID');
$isCrispConnected = !empty($websiteId);
$http_callback = "http" . (
($_SERVER['SERVER_PORT'] == 443) ? "s://" : "://"
) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$storeUrl = Tools::getHttpHost(true) . __PS_BASE_URI__;
$this->context->smarty->assign(array(
'website_id' => $websiteId,
'crisp_conectado' => $isCrispConnected,
'http_callback' => $http_callback,
'caminho_imagens' => $storeUrl . 'modules/a_crisp/views/image/',
));
$this->context->controller->addJS($this->_path . "views/js/base64.js", 'all');
$this->context->controller->addCSS($this->_path . "views/css/style.css", 'all');
return $this->moduleHeader() . $this->display(__FILE__, "views/templates/admin/admin.tpl");
}
/**
* Display admin header with information about this module
*
* @return string
*/
private function moduleHeader()
{
return $this->display(__FILE__, './views/templates/hook/infos.tpl');
}
}