-
Notifications
You must be signed in to change notification settings - Fork 9
/
Init.php
64 lines (51 loc) · 1.87 KB
/
Init.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
<?php
namespace FacturaScripts\Plugins\PrintTicket;
use FacturaScripts\Core\Base\AjaxForms\SalesHeaderHTML;
use FacturaScripts\Core\Base\DataBase\DataBaseWhere;
use FacturaScripts\Core\Base\InitClass;
use FacturaScripts\Dinamic\Model\ApiAccess;
use FacturaScripts\Dinamic\Model\ApiKey;
require_once __DIR__ . '/vendor/autoload.php';
class Init extends InitClass
{
public function init()
{
$this->loadExtension(new Extension\Controller\EditAlbaranCliente());
$this->loadExtension(new Extension\Controller\EditFacturaCliente());
$this->loadExtension(new Extension\Controller\EditPedidoCliente());
$this->loadExtension(new Extension\Controller\EditPresupuestoCliente());
$this->loadExtension(new Extension\Controller\EditServicioAT());
//SalesHeaderHTML::addMod(new Mod\SalesHeaderHTMLMod());
}
public function update()
{
$this->generateApiKey();
$format = new Model\FormatoTicket();
if (false === $format->loadFromCode(1)) {
$format->nombre = 'General';
$format->save();
}
}
private function generateApiKey()
{
$apiKey = new ApiKey();
$where = [new DataBaseWhere('description', 'remoteprinter')];
if (false === $apiKey->loadFromCode('', $where)) {
$apiKey->description = 'remoteprinter';
$apiKey->nick = 'admin';
$apiKey->save();
}
$apiAcces = new ApiAccess();
$where = [
new DataBaseWhere('idapikey', $apiKey->id),
new DataBaseWhere('resource', 'ticketes')
];
if (false === $apiAcces->loadFromCode('', $where)) {
$apiAcces->resource = 'ticketes';
$apiAcces->idapikey = $apiKey->id;
$apiAcces->allowget = true;
$apiAcces->allowdelete = true;
$apiAcces->save();
}
}
}