-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathadd.php
84 lines (73 loc) · 1.56 KB
/
add.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
<?php
set_include_path('backbone:components:content:scripts:styles:images:model:render');
require_once('Page.php');
require_once('Template.php');
require_once('Characteristic.php');
require_once('Ingredient.php');
$page = new Page(0, "OrderUp - add things");
$tmpl = new Template();
if( !$_SESSION['active'] || $_SESSION['roleid'] > 2 )
{
$loc = urlencode("add.php");
header("Location: /login.php?code=10&fwd=$loc");
}
$tmpl->type = isset($_GET['type']) ? $_GET['type'] : null;
if( $tmpl->type == 'characteristic' )
{
$chars = Characteristic::getAll();
if( $chars )
{
if( is_object($chars) )
{
$tmpl->items = array($chars);
}
elseif( is_array($chars) )
{
$tmpl->items = $chars;
}
}
else
{
$tmpl->items = array();
}
while( (count($tmpl->items) % 6) != 0 )
{
array_push($tmpl->items, new Characteristic("",""));
}
}
elseif( $tmpl->type == 'ingredient' )
{
$ings = Ingredient::getAll();
if( $ings )
{
if( is_object($ings) )
{
$tmpl->items = array($ings);
}
elseif( is_array($ings) )
{
$tmpl->items = $ings;
}
}
else
{
$tmpl->items = array();
}
while( (count($tmpl->items) % 6) != 0 )
{
array_push($tmpl->items, new Ingredient("","","","",""));
}
}
$page->run();
$html = $tmpl->build('add.html');
$css = $tmpl->build('add.css');
$js = $tmpl->build('add.js');
$appContent = array(
'html' => $html,
'css' => array( 'code' => $css,
'link' => 'add'
),
'js' => $js
);
print $page->build($appContent);
?>