noalyss Version-9
package_template.class.php
Go to the documentation of this file.
1
2<?php
3
4/*
5 * This file is part of NOALYSS.
6 *
7 * PhpCompta is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * NOALYSS is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with PhpCompta; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21// Copyright (2018) Author Dany De Bontridder <dany@alchimerys.be>
22
23
24/**
25 * @file
26 * @brief Show , download and install template database for accountancy from the Package repository
27 */
28
29/**
30 * @class Package_Template
31 * @brief Show , download and install template database for accountancy from the Package repository
32 *
33 */
35{
36
37 public function can_install()
38 {
39 return TRUE;
40 }
41
42 /**
43 * Install the template
44 */
45 public function install()
46 {
47 // make temp dir
48 $tmp=NOALYSS_HOME."/tmp/";
49 $tmpdir=$tmp."db-".microtime(TRUE);
50 mkdir($tmpdir);
51
52 // unzip Archive file
53 $db=new ZipArchive;
54 $db->open($tmp."/".$this->get_file());
55 $db->extractTo($tmpdir);
56
57
58 // create database
59 $cn=new Database();
60 $seq=$cn->get_value("select nextval('s_modid')");
61
62 $sql=sprintf(" create database %smod%d encoding='utf8'", domaine, $seq);
63 $cn->exec_sql($sql);
64
65 $newdb=new Database($seq, 'mod');
66
67 // Execute SQL Script
68 $newdb->execute_script($tmpdir.'/schema.sql');
69 $newdb->execute_script($tmpdir.'/data.sql');
70 $newdb->execute_script($tmpdir.'/constraint.sql');
71
72 // Register into account_repository, we add the seq number for avoiding duplicate
73 $description = sprintf(_("Installé le %s"),date("d-m-Y h:i:s"));
74 $cn->exec_sql(" insert into modeledef (mod_id,mod_name,mod_desc) values ($1,$2,$3)",
75 [$seq,$seq."-".$this->get_name(),$this->get_description()." ".$description]);
76 }
77
78}
contains the class for connecting to Noalyss
package noalyss is the mother class of the class to install and download package
Show , download and install template database for accountancy from the Package repository.
install()
Install the template.
domaine
Definition: install.php:370