Skip to content

Commit

Permalink
Funcionando na 1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
andresams committed Sep 7, 2017
1 parent 9d5cc1f commit 1ee3473
Show file tree
Hide file tree
Showing 19 changed files with 365 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a_crisp
# Crisp Livechat
73 changes: 73 additions & 0 deletions a_crisp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

class A_Crisp extends Module
{

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 = "1.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();
}

private function info_modulo()
{
return $this->display(__FILE__, './views/templates/hook/infos.tpl');
}

public function install()
{
return (parent::install() && $this->registerHook('displayHeader'));
}

public function uninstall()
{
return(parent::uninstall() == false);
}

public function hookDisplayHeader($params)
{
$website_id = Configuration::get('ACRISP_WEBSITE_ID');
$this->context->smarty->assign(array(
'crisp_customer' => $this->context->customer,
'crisp_website_id' => $website_id
));
return $this->display(__FILE__, 'crisp.tpl');
}

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"));
}
$website_id = Configuration::get('ACRISP_WEBSITE_ID');

$crisp_conectado = !empty($website_id);

$http_callback = "http" . (
($_SERVER['SERVER_PORT'] == 443) ? "s://" : "://"
) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];


$url_loja = Tools::getHttpHost(true).__PS_BASE_URI__;

$this->context->smarty->assign(array(
'website_id' => $website_id,
'crisp_conectado' => $crisp_conectado,
'http_callback' => $http_callback,
'caminho_imagens' => $url_loja.'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->info_modulo().$this->display(__FILE__, "views/templates/admin/admin.tpl");
}
}
12 changes: 12 additions & 0 deletions config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>a_crisp</name>
<displayName><![CDATA[Crisp - Chat Gratu&iacute;to]]></displayName>
<version><![CDATA[1.0]]></version>
<description><![CDATA[Permite que seu consumidor entre em contato diretamente com seu atendimento atrav&eacute;s de um chat flutuante em seu site.&lt;a href=&quot;https://www.prestafy.com.br/&quot;&gt;Prestafy&lt;/a&gt;]]></description>
<author><![CDATA[Prestafy]]></author>
<tab><![CDATA[front_office_features]]></tab>
<is_configurable>1</is_configurable>
<need_instance>1</need_instance>
<limited_countries></limited_countries>
</module>
Empty file added index.php
Empty file.
Binary file added logo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added views/css/index.php
Empty file.
56 changes: 56 additions & 0 deletions views/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.crisp-modal .crisp-button {
border: 0 none;
font-weight: bold;
text-align: center;
text-decoration: none;
padding: 14px 30px 15px;
cursor: pointer;
border-radius: .25rem;
width: 200px;
margin-bottom: 12px;
display: block;
}

.crisp-modal .crisp-button..crisp-success {
color: #fff;
background: #2ab27b;
text-shadow: 0 1px 1px rgba(0,0,0,.1);
}

.crisp-modal .crisp-button.crisp {
color: #fff;
background: #308AD6;
text-shadow: 0 1px 1px rgba(0,0,0,.1);
}

.crisp-modal .crisp-button.crisp-neutral, .crisp-modal .crisp-button.crisp-error {
color: #555459;
border: 1px solid #C7CACD;
background: #fbfbfa;
}

.crisp-title {
color: #555459;
font-size: 22px;
font-weight: bold;
margin: 0;
}

.crisp-subtitle {
color: #555459;
font-size: 16px;
font-weight: normal;
margin: 12px 0 26px;
}

.crisp-subtitle {
color: #555459;
font-size: 16px;
font-weight: normal;
margin: 12px 0 26px;
}

.crisp-notice {
font-size: 14px;
margin: 12px 0 26px;
}
Binary file added views/image/app_store.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added views/image/google_play.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added views/index.php
Empty file.
137 changes: 137 additions & 0 deletions views/js/base64.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/**
* @author webtoolkit.info
* @copyright Crisp IM 2016
* @license
**/

var Base64 = {

// private property
_keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

// public method for encoding
encode: function(input) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;

input = Base64._utf8_encode(input);

while (i < input.length) {

chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);

enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;

if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}

output = output +
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

}

return output;
},

// public method for decoding
decode: function(input) {
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;

input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

while (i < input.length) {

enc1 = this._keyStr.indexOf(input.charAt(i++));
enc2 = this._keyStr.indexOf(input.charAt(i++));
enc3 = this._keyStr.indexOf(input.charAt(i++));
enc4 = this._keyStr.indexOf(input.charAt(i++));

chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;

output = output + String.fromCharCode(chr1);

if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}

}

output = Base64._utf8_decode(output);

return output;

},

// private method for UTF-8 encoding
_utf8_encode: function(string) {
string = string.replace(/\r\n/g, "\n");
var utftext = "";

for (var n = 0; n < string.length; n++) {

var c = string.charCodeAt(n);

if (c < 128) {
utftext += String.fromCharCode(c);
} else if ((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
} else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}

}

return utftext;
},

// private method for UTF-8 decoding
_utf8_decode: function(utftext) {
var string = "";
var i = 0;
var c = c1 = c2 = 0;

while (i < utftext.length) {

c = utftext.charCodeAt(i);

if (c < 128) {
string += String.fromCharCode(c);
i++;
} else if ((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i + 1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
} else {
c2 = utftext.charCodeAt(i + 1);
c3 = utftext.charCodeAt(i + 2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}

}

return string;
}

}
Empty file added views/js/index.php
Empty file.
61 changes: 61 additions & 0 deletions views/templates/admin/admin.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<script>
function conectar_crisp ()
{
var add_to_crisp_link = "https://app.crisp.im/initiate/plugin/be40c894-22bb-408c-8fdc-aafb5e6b1985?payload=";
add_to_crisp_link += Base64.encode("{$http_callback|escape:'javascript':'UTF-8'}")
window.open(add_to_crisp_link,"_self")
}
</script>

{if $crisp_conectado == true}
<div class="panel">
<div class="panel-heading">
<i class="icon-gear"></i> Configurações
</div>
<div class="wrap crisp-wrap">
<div class="crisp-modal">
<h2>Parabéns! Sua loja já está conectada com o Crisp.</h2>
<P>Você completou com sucesso a instalação do Crisp em sua loja Prestashop e o chat já deve estar visível aos seus visitantes. Caso o chat ainda não apareça, limpe o cache do Prestashop, indo no menu "Parâmetros Avançados - Desempenho", e clicando no botão "Limpar Cache".</P>
<P>Você também pode configurar a aparência do seu chat ou conectar uma outra conta nessa loja</P>

<P>
<a href="https://app.crisp.chat/website/" class="btn btn-success" role="button">Ver minhas mensagens</a>
<a href="#" class="btn btn-warning" role="button" onclick="conectar_crisp()">Conectar outra conta</a>
<a href="https://app.crisp.chat/settings/" class="btn btn-danger" role="button" target="_blank">Configurações</a>
</P>

<h2>Aplicativos para celular</h2>
<P>Você também pode acessar o Crisp e atender seus clientes diretamente do seu smartphone Android ou iOS. Para isso, instale um dos aplicativos abaixo:</P>
<P><a class="btn btn-default" href="https://itunes.apple.com/fr/app/crisp/id1085770229" target="_blank">
<img src="{$caminho_imagens}app_store.png" />
</a>
<a class="btn btn-default" href="https://play.google.com/store/apps/details?id=im.crisp.app" target="_blank">
<img src="{$caminho_imagens}google_play.png" />
</a>

</P>
</div>
</div>
</div>
{else}
<div class="panel">
<div class="panel-heading">
<i class="icon-gear"></i> Configurações
</div>
<div class="wrap crisp-wrap">
<div class="crisp-modal">
<h2>Etapa 1. Criar uma conta gratuíta no Crisp</h2>
<P>Para utilizar este chat na sua loja, é necessário que você tenha uma conta do Crisp.im. Essa conta é gratuíta e você não pagará nada por ela. Se você já tiver criado uma conta, por favor, ignore esta etapa e prossiga para a etapa 2.</P>

<P><a href="https://app.crisp.chat/initiate/signup/" class="btn btn-success" role="button" target="_blank">Criar Conta</a></P>
<h2>Etapa 2. Conectar com sua loja Prestashop</h2>
<P>Se você já criou sua conta com o Crisp, agora é necessário dar permissões para que esta loja Prestashop tenha acesso aos seus dados. Para fazer isso, por favor, clique no botão abaixo.</P>

<P><a href="#" class="btn btn-warning" role="button" onclick="conectar_crisp()">Conectar minha loja</a></P>
<h2>Etapa 3. Configurar opções do Crisp</h2>
<P>O Crisp possui uma vasta gama de opções configuráveis. Você poderá configurar diversas opções como cores, posição do chat, mensagens automáticas, notificações e diversos plugins. Para fazer isso, clique no botão abaixo. Uma nova janela será aberta no site do Crisp.</P>
<P><a href="https://app.crisp.chat/settings/" class="btn btn-danger" role="button" target="_blank">Configurações</a></P>
</div>
</div>
</div>
{/if}
Empty file added views/templates/admin/index.php
Empty file.
19 changes: 19 additions & 0 deletions views/templates/hook/crisp.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<script type='text/javascript'>
window.$crisp=[];
window.CRISP_WEBSITE_ID = "{$crisp_website_id|escape:'htmlall':'UTF-8'}";
(function(){
d=document;
s=d.createElement('script');
s.src='https://client.crisp.im/l.js';
s.async=1;
d.getElementsByTagName('head')[0].appendChild(s);
})();
{if $crisp_customer->isLogged() == true}
$crisp.push(["set", "user:nickname", "{$crisp_customer->firstname|escape:'htmlall':'UTF-8'} {$crisp_customer->lastname|escape:'htmlall':'UTF-8'}"]);
$crisp.push(["set", "user:email", "{$crisp_customer->email|escape:'htmlall':'UTF-8'}"]);
{/if}
</script>
Empty file added views/templates/hook/index.php
Empty file.
6 changes: 6 additions & 0 deletions views/templates/hook/infos.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="alert alert-info">
<img src="../modules/a_crisp/logo.png" style="float:left; margin-right:15px;" width="60" height="60">
<p><strong>{l s="Crisp - Chat Gratuíto para Atendimento ao Consumidor. " d='Modules.A_Crisp.Admin'}</strong></p>
<p>{l s="Permite que seu consumidor entre em contato diretamente com seu atendimento através de um chat flutuante em seu site." d='Modules.A_Crisp.Admin'}</p>
<p>{l s="Após enviar a primeira mensagem de contato, será solicitado que seu cliente informe seus dados de contato (e-mail ou telefone) para prosseguir na conversa." d='Modules.A_Crisp.Admin'}</p>
</div>
Empty file added views/templates/index.php
Empty file.

0 comments on commit 1ee3473

Please sign in to comment.