Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
SAMBUMBA
pasteque-server
Commits
f957607f
Commit
f957607f
authored
Oct 03, 2017
by
philippepary
Browse files
Added Product model
parent
db4d1019
Changes
3
Hide whitespace changes
Inline
Side-by-side
bin/generate_swagger_file.php
View file @
f957607f
<?php
require
(
__DIR__
.
"/../vendor/autoload.php"
);
$files
=
[
"../src/http/public/index.php"
,
"../src/lib/Model/Product.php"
,
];
$dirs
=
[
"../src/http/routes/"
,
"../src/lib/Model/"
,
];
$SwaggerGen
=
new
\
SwaggerGen\SwaggerGen
(
$_SERVER
[
'HTTP_HOST'
]
,
dirname
(
$_SERVER
[
'REQUEST_URI'
])
"my.pasteque.org"
,
"/api"
);
error_log
(
dirname
(
$_SERVER
[
'REQUEST_URI'
]));
$routesFiles
=
[
'../src/http/routes/attributes.php'
,
'../src/http/routes/cashmvt.php'
,
'../src/http/routes/cash.php'
,
'../src/http/routes/cashregister.php'
,
'../src/http/routes/category.php'
,
'../src/http/routes/composition.php'
,
'../src/http/routes/currency.php'
,
'../src/http/routes/customer.php'
,
'../src/http/routes/discount.php'
,
'../src/http/routes/discountprofile.php'
,
'../src/http/routes/image.php'
,
'../src/http/routes/inventory.php'
,
'../src/http/routes/location.php'
,
'../src/http/routes/login.php'
,
'../src/http/routes/paymentmode.php'
,
'../src/http/routes/place.php'
,
'../src/http/routes/product.php'
,
'../src/http/routes/provider.php'
,
'../src/http/routes/resource.php'
,
'../src/http/routes/role.php'
,
'../src/http/routes/stock.php'
,
'../src/http/routes/sync.php'
,
'../src/http/routes/tariffarea.php'
,
'../src/http/routes/tax.php'
,
'../src/http/routes/ticket.php'
,
'../src/http/routes/ticketShared.php'
,
'../src/http/routes/user.php'
,
'../src/http/routes/version.php'
,
];
$swagger
=
$SwaggerGen
->
getSwagger
(
$routesFiles
,
array
(),
\
SwaggerGen\SwaggerGen
::
FORMAT_JSON_PRETTY
);
$swagger
=
$SwaggerGen
->
getSwagger
(
$files
,
$dirs
,
\
SwaggerGen\SwaggerGen
::
FORMAT_JSON_PRETTY
);
header
(
'Content-type: application/json'
);
echo
$swagger
;
...
...
src/lib/Model/Product.php
View file @
f957607f
...
...
@@ -28,9 +28,28 @@ use \Pasteque\Server\System\DAO\DoctrineModel;
/**
* Class Product
* @package Pasteque
* @SWG\Definition(type="object")
* @Entity
* @Table(name="products")
* @rest\model Product
* @rest\description A product
* @rest\property Int id Id of the product
* @rest\property String reference Code of the product, user-friendly ID
* @rest\property String barcode Barcode of the product
* @rest\property String label Full name of the product
* @rest\property Float priceBuy Buy price without taxes, used for estimated margin computation
* @rest\property Float priceSell Sell price of the product
* @rest\property Boolean visible Is the product visible on cash registers ?
* @rest\property Boolean scaled Is the product sold by Scale ? scaled can be false with a scaleType (ex: a box of 200g)
* @rest\property Int scaleType See SCALE_TYPE* constants. Used to compute reference prices like price per liter or kilogram
* @rest\property Float The scale value per unit when scaled is true. Useless if scaled is false
* @rest\property Int category ID of the category for the product
* @rest\property Int dispOrder Place of the product in the cash registers
* @rest\property Int tax ID of a tax
* @rest\property Boolean hasImage True if there is a custom image for the product
* @rest\property Boolean discountEnabled True if there is a current discount on the product (Soldes, black friday …)
* @rest\property Float discountRate If discountEnabled is true, this sets the discount rate (between 0 and 1)
* @rest\property Boolean prepay True if this product is a prepayment refill. In almost all cases, this has to be false
* @rest\property Boolean composition True if this product is a composition. In almost all cases, this has to be false
*/
class
Product
extends
DoctrineModel
{
...
...
@@ -66,7 +85,6 @@ class Product extends DoctrineModel
/**
* ID of the product
* @var integer
* @SWG\Property()
* @Id @Column(type="integer")
* @GeneratedValue
*/
...
...
@@ -77,7 +95,6 @@ class Product extends DoctrineModel
* Code of the product, user-friendly ID.
* It is automatically set from label if not explicitely set.
* @var string
* @SWG\Property()
* @Column(type="string", unique=true)
*/
protected
$reference
;
...
...
@@ -87,7 +104,6 @@ class Product extends DoctrineModel
/**
* barcode of a product
* @var string
* @SWG\Property()
* @Column(type="string", nullable=true)
*/
protected
$barcode
;
...
...
@@ -97,7 +113,6 @@ class Product extends DoctrineModel
/**
* name of a product
* @var string
* @SWG\Property()
* @Column(type="string")
*/
protected
$label
;
...
...
@@ -112,7 +127,6 @@ class Product extends DoctrineModel
/**
* Buy price without taxes, used for estimated margin computation.
* @var float
* @SWG\Property()
* @Column(type="float", nullable=true)
*/
protected
$priceBuy
=
null
;
...
...
@@ -122,7 +136,6 @@ class Product extends DoctrineModel
/**
* sell price without taxes.
* @var float
* @SWG\Property()
* @Column(type="float")
*/
protected
$priceSell
;
...
...
@@ -132,7 +145,6 @@ class Product extends DoctrineModel
/**
* Is product currently in sale (visible on cash registers) ?
* @var bool
* @SWG\Property()
* @Column(type="boolean")
*/
protected
$visible
=
true
;
...
...
@@ -146,7 +158,6 @@ class Product extends DoctrineModel
* isScale can be false with a SCALE_TYPE_WEIGHT (i.e. a box of 200g).
* When isScale is true, scaleValue is meaningless.
* @var bool
* @SWG\Property()
* @Column(type="boolean")
*/
protected
$scaled
=
false
;
...
...
@@ -165,7 +176,6 @@ class Product extends DoctrineModel
* See SCALE_TYPE_* constants.
* Used to compute reference prices like price per liter or kg.
* @var int
* @SWG\Property()
* @Column(type="smallint")
*/
protected
$scaleType
=
Product
::
SCALE_TYPE_NONE
;
...
...
@@ -183,7 +193,6 @@ class Product extends DoctrineModel
* The scale value for products referenced by weight or volume and
* not soled by scale.
* @var float
* @SWG\Property()
* @Column(type="float")
*/
protected
$scaleValue
=
1.0
;
...
...
@@ -193,7 +202,6 @@ class Product extends DoctrineModel
/**
* ID of the category
* @var integer
* @SWG\Property()
* @ManyToOne(targetEntity="Category")
* @JoinColumn(name="category_id", referencedColumnName="id", nullable=false)
*/
...
...
@@ -204,7 +212,6 @@ class Product extends DoctrineModel
/**
* Order of display inside it's category
* @var int order
* @SWG\Property(format="int32")
* @Column(type="integer", name="disp_order")
*/
protected
$dispOrder
=
0
;
...
...
@@ -214,7 +221,6 @@ class Product extends DoctrineModel
/**
* ID of a tax
* @var integer
* @SWG\Property()
* @ManyToOne(targetEntity="Tax")
* @JoinColumn(name="tax_id", referencedColumnName="id", nullable=false)
*/
...
...
@@ -225,7 +231,6 @@ class Product extends DoctrineModel
/**
* True if an image can be found for this model.
* @var bool
* @SWG\Property()
* @Column(type="boolean")
*/
protected
$hasImage
=
false
;
...
...
@@ -236,7 +241,6 @@ class Product extends DoctrineModel
/**
* Is discount currently enabled ?
* @var bool
* @SWG\Property()
* @Column(type="boolean")
*/
protected
$discountEnabled
=
false
;
...
...
@@ -248,7 +252,6 @@ class Product extends DoctrineModel
/**
* rate of the discount
* @var float
* @SWG\Property()
* @Column(type="float")
*/
protected
$discountRate
=
0.0
;
...
...
@@ -258,7 +261,6 @@ class Product extends DoctrineModel
/**
* Is product a prepayment refill?
* @var bool
* @SWG\Property()
* @Column(type="boolean")
*/
protected
$prepay
=
false
;
...
...
@@ -269,7 +271,6 @@ class Product extends DoctrineModel
/**
* Is product a composition?
* @var bool
* @SWG\Property()
* @Column(type="boolean")
*/
protected
$composition
=
false
;
...
...
src/swag.php
deleted
100644 → 0
View file @
db4d1019
<?php
/**
* @SWG\Info(title="Pasteque API", version="0.1")
*/
Write
Preview
Supports
Markdown
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