-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
executable file
·92 lines (90 loc) · 2.64 KB
/
functions.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
<?php
function mvc_header(){
include_once MVC_PATH.'/app/inc/header.php';
}
function mvc_footer(){
include_once MVC_PATH.'/app/inc/footer.php';
}
function adm_header(){
include_once MVC_PATH.'/app/inc/aheader.php';
}
function adm_footer(){
include_once MVC_PATH.'/app/inc/afooter.php';
}
//----helpers------//
function selection($table,$where=null,$order=null,$ascdesc=null,$limit=null,$between=null){
$q = new Query();
$q->table = $table;
if(null!==$where){$q->where = $where;}
if(null!==$order){$q->order = $order;}
if(null!==$ascdesc){$q->ascdesc = $ascdesc;}
if(null!==$limit){$q->limit = $limit;}
if(null!==$between){$q->between = $between;}
$res = $q->read();
return $res;
}
function updating($table,$where,$updatearray){
$q = new Query();
$q->table = $table;
if(null!==$where){$q->where = $where;}
$q->updatearray = $updatearray;
$q->change();
}
function inserting($table,$insertarray){
$q = new Query();
$q->table = $table;
$q->insertarray = $insertarray;
$q->insert();
return $q->lastInsertId();
}
function deleting($table,$where){
$q = new Query();
$q->table = $table;
$q->where = $where;
$q->delete();
}
function email($to,$from,$subject,$message,$attachment=null){
$e = new Email();
$e->to_email = $to;
$e->from_email = $from;
$e->subject_str = $subject;
$e->message_str = $message;
if(null!==$attachment){$e->attachment = $attachment;}
$e->sendmail();
}
function imageResize($file,$newWidth,$newHeight,$savePath,$option=null,$quality=null){
$r = new Resize($file);
$r->resizeImage($newWidth, $newHeight, $option);
$r->saveImage($savePath, $quality);
}
function translation($lang,$str){
$t = new Translate($lang);
$res = $t->trans($str);
return $res;
}
//----other----//
function q_custom($str){
$q = new Model();
$r = $q->prepare($str);
$r->execute();
return $r->fetchAll();
}
function run_session(){
$s = new Sessions('mvc');
return $s;
}
function slugging($str){
$s = strtolower($str);
$unwanted = array(' ','+','?','.',',',';',':','"','&','%','š','Š','đ','Đ','ž','Ž','č','Č','ć','Ć');
$wanted = array('-','-',' ','','','-','-','','i',' posto','s','s','d','d','z','z','c','c','c','c');
return str_replace($unwanted, $wanted, $s);
}
/*--------statistics-------*/
function prihod_total($date=null){
$s = new Statistics();
return $s->getTotalPrihod($date);
}
function prihod_by($type,$key,$date=null){
$s = new Statistics();
return $s->getKeyPrihod($type,$key,$date);
}