Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Σταύρος Παπαδάκης
gredu_labs
Commits
d9ec9d08
Commit
d9ec9d08
authored
Feb 11, 2016
by
Georgios Tsakalos
Browse files
add asset service files
parent
8b69e6c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
module/schools/src/Service/AssetService.php
0 → 100644
View file @
d9ec9d08
<?php
/**
* gredu_labs
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace
GrEduLabs\Schools\Service
;
use
RedBeanPHP\R
;
class
AssetService
implements
AssetServiceInterface
{
protected
$schoolService
;
protected
$labService
;
public
function
__construct
(
SchoolServiceInterface
$schoolservice
,
LabService
$labservice
)
{
$this
->
schoolservice
=
$schoolservice
;
$this
->
labservice
=
$labservice
;
}
public
function
createItemCategory
(
$name
){
$item_category
=
R
::
dispense
(
'itemcategory'
);
$item_category
->
name
=
$name
;
$id
=
R
::
store
(
$item_category
);
return
$id
;
}
public
function
getAllItemCategories
(){
$categories
=
R
::
findAll
(
'itemcategory'
);
return
$categories
;
}
public
function
getItemCategoryByName
(
$name
){
$cat
=
R
::
findOne
(
'itemcategory'
,
'name = ?'
,
[
$name
]);
return
$cat
;
}
public
function
getItemCategoryById
(
$id
){
$cat
=
R
::
load
(
'itemcategory'
,
$id
);
return
$cat
;
}
//Software Category Actions
public
function
createSoftwareCategory
(
array
$data
){
$soft_category
=
R
::
dispense
(
'softwarecategory'
);
$soft_category
->
name
=
$data
[
'name'
];
$soft_category
->
manufacturer
=
$data
[
'manufacturer'
];
$soft_category
->
website
=
$data
[
'website'
];
$id
=
R
::
store
(
$soft_category
);
return
$id
;
}
public
function
getAllSoftwareCategories
(){
$categories
=
R
::
findAll
(
'softwarecategory'
);
return
$categories
;
}
public
function
getSoftwareCategoryByName
(
$name
){
$cat
=
R
::
findOne
(
'softwarecategory'
,
'name = ?'
,
[
$name
]);
return
$cat
;
}
public
function
getSoftwareCategoryById
(
$id
){
$cat
=
R
::
load
(
'softwarecategory'
,
$id
);
return
$cat
;
}
//Existing Item Actions
public
function
createExistingItem
(
array
$data
){
required
=
[
'location'
,
'category'
,
'description'
,
'qty'
,
'lab'
,
'purchasedate'
];
$item
=
R
::
dispense
(
'existingitem'
);
foreach
(
$required
as
$value
){
if
(
array_key_exists
(
$value
,
$data
))
{
$item
[
$value
]
=
data
[
$value
];
}
else
{
return
-
1
;
}
if
(
array_key_exists
(
'comments'
,
$data
))
{
$item
[
'comments'
]
=
$data
[
'comments'
];
}
else
{
$item
[
'comments'
]
=
''
;
}
R
::
store
(
$item
);
}
}
}
module/schools/src/Service/AssetServiceInterface.php
0 → 100644
View file @
d9ec9d08
<?php
/**
* gredu_labs
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace
GrEduLabs\Schools\Service
;
interface
AssetServiceInterface
{
public
function
createItemCategory
(
$name
);
public
function
getAllItemCategories
();
public
function
getItemCategoryByName
(
$name
);
public
function
getItemCategoryById
(
$id
);
public
function
createSoftwareCategory
(
array
$data
);
public
function
getAllSoftwareCategories
();
public
function
getSoftwareCategoryByName
(
$name
);
public
function
getSoftwareCategoryById
(
$id
);
public
function
createExistingItem
(
array
$data
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment