-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #320 from leon-mbs/dev
Dev
- Loading branch information
Showing
68 changed files
with
918 additions
and
367 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
|
||
|
||
ALTER TABLE `item_set` ADD `service_id` INT NULL , ADD `cost` DECIMAL(10,2) NULL ; | ||
|
||
|
||
DROP VIEW item_set_view ; | ||
|
||
CREATE | ||
|
||
VIEW item_set_view | ||
AS | ||
SELECT | ||
`item_set`.`set_id` AS `set_id`, | ||
`item_set`.`item_id` AS `item_id`, | ||
`item_set`.`pitem_id` AS `pitem_id`, | ||
`item_set`.`qty` AS `qty`, | ||
`item_set`.`service_id` AS `service_id`, | ||
`item_set`.`cost` AS `cost`, | ||
`items`.`itemname` AS `itemname`, | ||
`items`.`item_code` AS `item_code`, | ||
`services`.`service_name` AS `service_name` | ||
FROM ((`item_set` | ||
LEFT JOIN `items` | ||
ON (((`item_set`.`item_id` = `items`.`item_id`) | ||
AND (`items`.`disabled` <> 1)))) | ||
LEFT JOIN `services` | ||
ON (((`item_set`.`service_id` = `services`.`service_id`) | ||
AND (`services`.`disabled` <> 1)))); | ||
|
||
|
||
ALTER TABLE `documents` ADD `lastupdate` DATETIME NULL; | ||
|
||
DROP VIEW documents_view ; | ||
CREATE VIEW documents_view | ||
AS | ||
SELECT | ||
`d`.`document_id` AS `document_id`, | ||
`d`.`document_number` AS `document_number`, | ||
`d`.`document_date` AS `document_date`, | ||
`d`.`user_id` AS `user_id`, | ||
`d`.`content` AS `content`, | ||
`d`.`amount` AS `amount`, | ||
`d`.`meta_id` AS `meta_id`, | ||
`u`.`username` AS `username`, | ||
`c`.`customer_id` AS `customer_id`, | ||
`c`.`customer_name` AS `customer_name`, | ||
`d`.`state` AS `state`, | ||
`d`.`notes` AS `notes`, | ||
`d`.`payamount` AS `payamount`, | ||
`d`.`payed` AS `payed`, | ||
`d`.`parent_id` AS `parent_id`, | ||
`d`.`branch_id` AS `branch_id`, | ||
`b`.`branch_name` AS `branch_name`, | ||
`d`.`firm_id` AS `firm_id`, | ||
`d`.`priority` AS `priority`, | ||
`f`.`firm_name` AS `firm_name`, | ||
`d`.`lastupdate` AS `lastupdate`, | ||
`metadata`.`meta_name` AS `meta_name`, | ||
`metadata`.`description` AS `meta_desc` | ||
FROM (((((`documents` `d` | ||
LEFT JOIN `users_view` `u` | ||
ON ((`d`.`user_id` = `u`.`user_id`))) | ||
LEFT JOIN `customers` `c` | ||
ON ((`d`.`customer_id` = `c`.`customer_id`))) | ||
JOIN `metadata` | ||
ON ((`metadata`.`meta_id` = `d`.`meta_id`))) | ||
LEFT JOIN `branches` `b` | ||
ON ((`d`.`branch_id` = `b`.`branch_id`))) | ||
LEFT JOIN `firms` `f` | ||
ON ((`d`.`firm_id` = `f`.`firm_id`))); | ||
|
||
|
||
ALTER TABLE `ppo_zformstat` ADD `fiscnumber` VARCHAR(255) NULL ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
ALTER TABLE ppo_zformstat ADD fiscnumber CHARACTER VARYING(255) NULL ; | ||
ALTER TABLE item_set ADD service_id INTEGER DEFAULT NULL ; | ||
ALTER TABLE item_set ADD cost DECIMAL(10, 2) DEFAULT NULL ; | ||
|
||
|
||
|
||
|
||
ALTER | ||
VIEW item_set_view | ||
AS | ||
SELECT | ||
item_set.set_id AS set_id, | ||
item_set.item_id AS item_id, | ||
item_set.pitem_id AS pitem_id, | ||
item_set.qty AS qty, | ||
item_set.service_id AS service_id, | ||
item_set.cost AS cost, | ||
items.itemname AS itemname, | ||
items.item_code AS item_code, | ||
services.service_name AS service_name | ||
FROM ((item_set | ||
LEFT JOIN items | ||
ON (((item_set.item_id = items.item_id) | ||
AND (items.disabled <> 1)))) | ||
LEFT JOIN services | ||
ON (((item_set.service_id = services.service_id) | ||
AND (services.disabled <> 1)))); | ||
|
||
|
||
ALTER TABLE documents ADD lastupdate TIMESTAMP NULL; | ||
|
||
|
||
|
||
|
||
ALTER VIEW documents_view | ||
AS | ||
SELECT | ||
d.document_id AS document_id, | ||
d.document_number AS document_number, | ||
d.document_date AS document_date, | ||
d.user_id AS user_id, | ||
d.content AS content, | ||
d.amount AS amount, | ||
d.meta_id AS meta_id, | ||
u.username AS username, | ||
c.customer_id AS customer_id, | ||
c.customer_name AS customer_name, | ||
d.state AS state, | ||
d.notes AS notes, | ||
d.payamount AS payamount, | ||
d.payed AS payed, | ||
d.parent_id AS parent_id, | ||
d.branch_id AS branch_id, | ||
b.branch_name AS branch_name, | ||
d.firm_id AS firm_id, | ||
d.priority AS priority, | ||
d.lastupdate AS lastupdate, | ||
f.firm_name AS firm_name, | ||
metadata.meta_name AS meta_name, | ||
metadata.description AS meta_desc | ||
FROM (((((documents d | ||
LEFT JOIN users_view u | ||
ON ((d.user_id = u.user_id))) | ||
LEFT JOIN customers c | ||
ON ((d.customer_id = c.customer_id))) | ||
JOIN metadata | ||
ON ((metadata.meta_id = d.meta_id))) | ||
LEFT JOIN branches b | ||
ON ((d.branch_id = b.branch_id))) | ||
LEFT JOIN firms f | ||
ON ((d.firm_id = f.firm_id))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,113 @@ | ||
<?php | ||
|
||
namespace App\API\Base; | ||
namespace App\API; | ||
|
||
/** | ||
* Base class for RESTFul | ||
*/ | ||
abstract class RestFul | ||
{ | ||
|
||
/** | ||
* | ||
* | ||
* @param array $params | ||
*/ | ||
public function Execute($params) { | ||
|
||
if ($_SERVER["REQUEST_METHOD"] == "GET") { | ||
$this->get($params); | ||
}; | ||
if ($_SERVER["REQUEST_METHOD"] == "POST") { | ||
$this->post($params); | ||
}; | ||
if ($_SERVER["REQUEST_METHOD"] == "DELETE") { | ||
$this->delete($params); | ||
}; | ||
if ($_SERVER["REQUEST_METHOD"] == "PUT") { | ||
$this->put($params); | ||
}; | ||
} | ||
|
||
/** | ||
* @param array $params | ||
*/ | ||
public function get($params) { | ||
$this->FailAnswer(); | ||
} | ||
|
||
/** | ||
* @param array $params | ||
*/ | ||
public function post($params) { | ||
$this->FailAnswer(); | ||
} | ||
|
||
/** | ||
* @param array $params | ||
*/ | ||
public function put($params) { | ||
$this->FailAnswer(); | ||
} | ||
|
||
/** | ||
* @param array $params | ||
*/ | ||
public function delete($params) { | ||
$this->FailAnswer(); | ||
} | ||
|
||
|
||
|
||
protected function JsonAnswer($json) { | ||
header("Content-type: application/json"); | ||
$this->headers(); | ||
header("Content-type: application/json"); | ||
http_response_code(200); | ||
echo $json; | ||
die; | ||
} | ||
|
||
protected function XMLAnswer($xml) { | ||
header("Content-type: text/xml"); | ||
echo $xml; | ||
http_response_code(200); | ||
} | ||
|
||
protected function CSVAnswer($csv) { | ||
header("Content-type: text/csv"); | ||
http_response_code(200); | ||
echo $csv; | ||
} | ||
|
||
|
||
protected function TextAnswer($text) { | ||
header("Content-type: text/plain"); | ||
$this->headers(); | ||
header("Content-type: text/plain"); | ||
http_response_code(200); | ||
echo $text; | ||
die; | ||
} | ||
|
||
|
||
protected function OKAnswer() { | ||
http_response_code(200); | ||
$this->headers(); | ||
|
||
http_response_code(200); | ||
die; | ||
} | ||
|
||
protected function FailAnswer() { | ||
http_response_code(400); | ||
protected function FailAnswer($error="") { | ||
$this->headers(400); | ||
|
||
echo $error; | ||
die; | ||
} | ||
|
||
protected function code401() { | ||
$this->headers(401); | ||
|
||
die; | ||
} | ||
|
||
protected function code403() { | ||
$this->headers(403); | ||
|
||
die; | ||
} | ||
private function headers($code=200){ | ||
header('Access-Control-Allow-Origin: *'); | ||
header('Access-Control-Allow-Credentials: true'); | ||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS"); | ||
header('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With'); | ||
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') | ||
http_response_code(200); | ||
else | ||
http_response_code($code); | ||
|
||
|
||
} | ||
protected function checkAcess() { | ||
|
||
|
||
$jwt = ""; | ||
$headers = apache_request_headers(); | ||
foreach ($headers as $header => $value) { | ||
|
||
|
||
if ( strtolower($header) == "authorization") { | ||
$jwt = str_replace("Bearer ", "", $value); | ||
$jwt = trim($jwt); | ||
break; | ||
} | ||
} | ||
|
||
$key = "defkey"; | ||
try{ | ||
$decoded = \Firebase\JWT\JWT::decode($jwt, $key, array('HS256')); | ||
} catch(\Exception $e) { | ||
$this->FailAnswer($e->getMessage()); | ||
} | ||
|
||
|
||
if($decoded->user_id >0) { | ||
|
||
//$user = \App\Entity\User::load($decoded->user_id); | ||
// if($user== null) $this->code401(); | ||
return $decoded->user_id; | ||
} else { | ||
$this->code401(); | ||
|
||
} | ||
|
||
} | ||
|
||
|
||
protected function parsePost($post){ | ||
if($post==null) $this->FailAnswer("Must be POST request") ; | ||
|
||
$post = json_decode($post) ; | ||
|
||
if($post==null) $this->FailAnswer("Invalid JSON") ; | ||
|
||
return $post; | ||
|
||
} | ||
} |
Oops, something went wrong.