forked from philippK-de/Collabtive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
managecompany.php
54 lines (52 loc) · 1.57 KB
/
managecompany.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
<?php
require("init.php");
if (!isset($_SESSION['userid'])) {
$template->assign("loginerror", 0);
$template->display("login.tpl");
die();
}
//check if the user is an admin
if (!$userpermissions["admin"]["add"] and $action != "addpro") {
$errtxt = $langfile["nopermission"];
$noperm = $langfile["accessdenied"];
$template->assign("errortext", "$errtxt<br>$noperm");
$template->display("error.tpl");
die();
}
$customer = (object) new company();
$action = getArrayVal($_GET,"action" );
$id = getArrayVal($_GET,"id" );
if($action == "editform")
{
$customer = $customer->getCompany($id);
$template->assign("customer",$customer);
$template->display("editcustomer.tpl");
}
elseif($action == "edit")
{
$customerData = array();
$customerData["id"] = $id;
$customerData["company"] = getArrayVal($_POST,"company");
$customerData["contact"] = getArrayVal($_POST,"contact");
$customerData["email"] = getArrayVal($_POST,"email");
$customerData["phone"] = getArrayVal($_POST,"tel1");
$customerData["mobile"] = getArrayVal($_POST,"tel2");
$customerData["url"] = getArrayVal($_POST,"web");
$customerData["address"] = getArrayVal($_POST,"address");
$customerData["zip"] = getArrayVal($_POST,"zip");
$customerData["city"] = getArrayVal($_POST,"city");
$customerData["country"] = getArrayVal($_POST,"country");
$customerData["state"] = getArrayVal($_POST,"state");
$customerData["desc"] = getArrayVal($_POST,"desc");
if($customer->edit($customerData))
{
header("Location: admin.php?action=customers&mode=edited");
}
}
elseif($action == "del")
{
if($customer->del($id))
{
echo "ok";
}
}