-
Notifications
You must be signed in to change notification settings - Fork 0
/
HiroManagement.sol
111 lines (87 loc) · 3.08 KB
/
HiroManagement.sol
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
pragma solidity ^0.4.16;
contract Owned {
address owner;
function Owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
}
contract HiroManagement is Owned{
//Structure of clients
Client public registeredClients;
//Count the number of registered clients
address[] public clientsAccounts;
// Map verified addresses
// mapping (address => bool) public verified;
//Map all clients
mapping (address => Client) public clients;
//Events
event ClientHistory(address indexed client);
event ClientInfo(string projectName, string firstName, string lastName, string eMail);
// For clients' info
struct Client{
string projectName;
string firstName;
string lastName;
string eMail;
}
// modifier onlyHiro{
// require(msg.sender == hiro);
// _;
// }
// modifier onlyVerified{
// require(verified[msg.sender]);
// _;
// }
function addClient(address _client, string _projectName, string _firstName, string _lastName, string _eMail) public{
// verified[_client] = true;
var client = clients[_client];
uint index;
for(uint i = 0; i < clientsAccounts.length; i ++){
if(_client == clientsAccounts[i]){
index = i;
clientsAccounts[index] = clientsAccounts[clientsAccounts.length - 1];
delete clientsAccounts[index];
delete clients[_client];
clientsAccounts.length --;
client.projectName = _projectName;
client.firstName = _firstName;
client.lastName = _lastName;
client.eMail = _eMail;
}
}
client.projectName = _projectName;
client.firstName = _firstName;
client.lastName = _lastName;
client.eMail = _eMail;
clientsAccounts.push(_client) - 1;
ClientHistory(_client);
ClientInfo(_projectName, _firstName, _lastName, _eMail);
}
function removeClient(address _clientAddress) public{
// verified[_clientAddress] = false;
uint index;
for(uint i = 0; i < clientsAccounts.length; i ++){
if(_clientAddress == clientsAccounts[i]){
index = i;
}
}
clientsAccounts[index] = clientsAccounts[clientsAccounts.length - 1];
delete clientsAccounts[index];
delete clients[_clientAddress];
clientsAccounts.length --;
ClientHistory(_clientAddress);
}
function getAllClients() view public returns(address[]) {
return clientsAccounts;
}
function getOneClient(address _address) view public returns (string, string, string, string) {
return (clients[_address].projectName, clients[_address].firstName, clients[_address].lastName, clients[_address].eMail);
}
function clientsNumber() view public returns (uint) {
return clientsAccounts.length;
}
}