sviluppo servizi

This commit is contained in:
AntonioF
2019-03-28 15:35:59 +01:00
parent a356d8a4ec
commit 58ec67eb8b
14 changed files with 100 additions and 82 deletions

View File

@@ -1,8 +1,7 @@
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteRule ^emailcheck/([^/]*)$ emailcheck.php?d=$1 [L]
RewriteRule ^/ordify-api/src/$ /ordify-api/$1 [L]
RewriteRule ^/ordify-api/src/$ /ordify-api|/$1 [L]
RewriteCond %{REQUEST_URI} !^/ordify-api/src/
RewriteRule ^(.*)$ /ordify-api/src/$1 [L]

View File

@@ -2,6 +2,8 @@
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group/>
<group>
<file>file:/C:/wamp/www/ordify-api/src/index.php</file>
</group>
</open-files>
</project-private>

View File

@@ -16,9 +16,11 @@ class Profile{
private $passwordDb = null;
public function __construct($hash = null){
if(!is_null($hash)){
$this->hash($hash);
if(is_null($hash)){
$hash = isset($_GET["profileHash"]) ? $_GET["profileHash"] : null;
$hash = (is_null($hash) && isset($_POST["profileHash"])) ? $_POST["profileHash"] : $hash;
}
$this->hash($hash);
}
public function hash($v){

View File

@@ -742,19 +742,26 @@ class Query{
$Ret->set_data($retValue)->set_number($timeExec);
} else{
$errorMessage = "Si &egrave; verificato un problema durante l'esecuzione di una query SQL.<br/>Sono stati riportati dettagli aggiuntivi di supporto alla risoluzione.<br/><br/>";
$errorMessage .= "<span class='small text-monospace'>";
if(!is_null($this->module)){
$errorMessage .= "<span class=''>".$this->module."</span> > ";
$htmlFormatted = false;
if($htmlFormatted){
$errorMessage = "Si &egrave; verificato un problema durante l'esecuzione di una query SQL.<br/>Sono stati riportati dettagli aggiuntivi di supporto alla risoluzione.<br/><br/>";
$errorMessage .= "<span class='small text-monospace'>";
if(!is_null($this->sqlFilename)){
$errorMessage .= "<span class=''>".$this->sqlFilename."</span><br/>";
}
$errorMessage .= "<span class='font-italic'>".$this->lastSqlMessage."</span>";
if(isset($sqlErrorFilepath) && PVM::is_debugMode()){
$errorMessage .= "<br/><span><a href='{$sqlErrorFilepath}' download>Scarica SQL compilato</a></span>";
}
$errorMessage .= "</span>";
} else{
$errorMessage = "Si &egrave; verificato un problema durante l'esecuzione di una query SQL.\nSono stati riportati dettagli aggiuntivi di supporto alla risoluzione.\n\n";
if(!is_null($this->sqlFilename)){
$errorMessage .= $this->sqlFilename."\n";
}
$errorMessage .= $this->lastSqlMessage;
}
if(!is_null($this->sqlFilename)){
$errorMessage .= "<span class=''>".$this->sqlFilename."</span><br/>";
}
$errorMessage .= "<span class='font-italic'>".$this->lastSqlMessage."</span>";
if(isset($sqlErrorFilepath) && PVM::is_debugMode()){
$errorMessage .= "<br/><span><a href='{$sqlErrorFilepath}' download>Scarica SQL compilato</a></span>";
}
$errorMessage .= "</span>";
$Ret->set_error($errorMessage, "Esecuzione query fallita");
}

View File

@@ -5,9 +5,11 @@ class Service{
private $Profile = null;
public function __construct($name = null){
if(!is_null($name)){
$this->name($name);
if(is_null($name)){
$name = isset($_GET["service"]) ? $_GET["service"] : null;
$name = (is_null($name) && isset($_POST["service"])) ? $_POST["service"] : $name;
}
$this->name($name);
}
public function name($v){

View File

@@ -25,14 +25,23 @@ class ServiceModel{
return $this;
}
public function getPostVal($key){
public function getPostParam($key){
return array_key_exists($key, $this->POST) ? $this->POST[$key] : null;
}
public function getGetVal($key){
public function getGetParam($key){
return array_key_exists($key, $this->GET) ? $this->GET[$key] : null;
}
public function getRequestParam($key){
if($this->methodRequest=="GET"){
return $this->getGetParam($key);
} else if($this->methodRequest=="POST"){
return $this->getPostParam($key);
}
return null;
}
public function getMethodRequest(){
return $this->methodRequest;
}

View File

@@ -1,28 +1,17 @@
<?
header("content-type: application/json; charset=utf-8");
header("Access-Control-Allow-Origin: *");
include "include.php";
//include "classes/Api.class.php";
$Ret = new Ret;
try{
$serviceName = isset($_GET["service"]) ? $_GET["service"] : null;
//$requestMethod = $_SERVER["REQUEST_METHOD"];
$Service = new Service($serviceName);
$Service = new Service;
$Ret = $Service->load();
if($Ret->is_OK()){
$profileHash = isset($_GET["profileHash"]) ? $_GET["profileHash"] : null;
$Profile = new Profile($profileHash);
$Profile = new Profile;
$Ret = $Profile->load();
if($Ret->is_OK()){
$Ret = $Service->Profile($Profile)->run();
//echo $Profile->get_endpointRestApi();
}
}
} catch(Exception $e){

View File

@@ -3,10 +3,9 @@ require "Login.class.php";
class GetAnagrafiche extends ServiceModel{
public function run(){
$md5User = $this->getGetVal("md5User");
$md5User = $this->getRequestParam("md5User");
$Login = new Login;
$Login->setProfile($this->Profile);
$Ret = $Login->authenticate($md5User);
$Ret = $Login->setProfile($this->Profile)->authenticate($md5User);
if($Ret->is_OK()){
$Ret = $this->get_listClieDest($md5User);
}

View File

@@ -1,31 +1,23 @@
<?php
//require "Login.class.php";
require "GetAnagrafiche.class.php";
class GetArticoli extends ServiceModel{
public function run(){
$md5User = $this->getGetVal("md5User");
$md5User = $this->getRequestParam("md5User");
$Login = new Login;
$Login->setProfile($this->Profile);
$Ret = $Login->authenticate($md5User);
$Ret = $Login->setProfile($this->Profile)->authenticate($md5User);
if($Ret->is_OK()){
$Ret = $this->get_listCodVlis($md5User);
if($Ret->is_OK()){
$arr_codVlis = $Ret->get_data();
if(count($arr_codVlis)>0){
$Query = new Query;
$Query->Profile($this->Profile)->importSqlFile("listino")->where("listino.cod_vlis", $arr_codVlis);
$Ret = $Query->execute();
// exit($Query);
$Query->Profile($this->Profile)->importSqlFile("listini")->where("listino.cod_vlis", $arr_codVlis);
$Ret = $Query->execute(); // exit($Query);
} else{
$Ret->set_error("Nessun listino trovato");
}
}
/*
$Query = new Query("select top 100 * from mtb_aart");
$Query->Profile($this->Profile);
$Ret = $Query->execute();*/
}
return $Ret;
}
@@ -39,7 +31,6 @@ class GetArticoli extends ServiceModel{
if(!is_null($anag["cod_vlis"]) && !in_array($anag["cod_vlis"], $arr_codVlis)){
$arr_codVlis[] = $anag["cod_vlis"];
}
//$codAnag = $row{"cod_anag"
foreach($anag["dest"] as $dest){
if(!is_null($dest["cod_vlis"]) && !in_array($dest["cod_vlis"], $arr_codVlis)){
$arr_codVlis[] = $dest["cod_vlis"];
@@ -50,7 +41,4 @@ class GetArticoli extends ServiceModel{
}
return $Ret;
}
}

View File

@@ -0,0 +1,23 @@
<?php
require "Login.class.php";
class GetMetodiPagamento extends ServiceModel{
public function run(){
$md5User = $this->getRequestParam("md5User");
$Login = new Login;
$Ret = $Login->setProfile($this->Profile)->authenticate($md5User);
if($Ret->is_OK()){
$Query = new Query;
$Query->Profile($this->Profile)->importSqlFile("metodiPaga");
$Ret = $Query->execute();
if($Ret->is_OK()){
$result = $Ret->get_data();
foreach($result as $i => $row){
$result[$i]["flag_abicab_needed"] = \boolValue($result[$i]["flag_abicab_needed"]);
}
$Ret->set_data($result);
}
}
return $Ret;
}
}

View File

@@ -3,8 +3,7 @@ class Login extends ServiceModel{
public $methodRequest = "POST";
public function run(){
$md5User = $this->getGetVal("md5User");
return $this->authenticate($md5User);
return $this->authenticate($this->getRequestParam("md5User"));
}
public function authenticate($md5User){
@@ -16,9 +15,10 @@ class Login extends ServiceModel{
$Ret = $ImsAPI->send();
if($Ret->is_OK()){
$retData = $Ret->get_data();
$retData = $retData["dto"];
$retData = array_change_key_case($retData["dto"], CASE_LOWER);
$retData["password_endtime"] = \Utility\Date::strtotime($retData["password_endtime"], \Format::strtotimeDMYHMS);
$retData["Last_access_datetime"] = \Utility\Date::strtotime($retData["Last_access_datetime"], \Format::strtotimeDMYHMS);
$retData["last_access_datetime"] = \Utility\Date::strtotime($retData["last_access_datetime"], \Format::strtotimeDMYHMS);
$retData["flag_password_expiring"] = \boolValue($retData["flag_password_expiring"]);
$Ret->set_data($retData);
}
} else{

View File

@@ -1,10 +1,14 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Author: AntonioF
* Created: 25-mar-2019
*/
SELECT listino.cod_vlis,
listino.cod_mart,
mtb_aart.descrizione,
/*listino.prz_vend,*/
/*listino.prz_vend_iva,*/
ISNULL(promo.prz_vend, listino.prz_vend) AS prz_vend,
/*promo.prz_vend AS prz_vend_promo,*/
promo.cod_promo,
listino.unt_mis_ven AS unt_mis
FROM dbo.Getlistinovendita(GETDATE(), NULL, NULL) listino
INNER JOIN mtb_aart ON mtb_aart.cod_mart = listino.cod_mart
LEFT OUTER JOIN dbo.Getpromozionevendita(GETDATE(), NULL, NULL, NULL, NULL) promo ON listino.cod_vlis = promo.cod_vlis AND listino.cod_mart = promo.cod_mart
WHERE mtb_aart.flag_stato = 'A' /*and promo.cod_promo is not null*/
ORDER BY listino.cod_mart

View File

@@ -1,15 +0,0 @@
SELECT listino.cod_vlis,
listino.cod_mart,
mtb_aart.descrizione,
listino.prz_vend,
/*listino.prz_vend_iva,*/
/*ISNULL(promo.prz_vend, ISNULL(listino.prz_vend, 0)) AS prz_vend,*/
promo.prz_vend AS prz_vend_promo,
promo.cod_promo,
/*CASE WHEN promo.cod_promo IS NOT NULL THEN 1 ELSE 0 END AS flag_promo,*/
listino.unt_mis_ven AS unt_mis
FROM dbo.Getlistinovendita(GETDATE(), NULL, NULL) listino
INNER JOIN mtb_aart ON mtb_aart.cod_mart = listino.cod_mart
LEFT OUTER JOIN dbo.Getpromozionevendita(GETDATE(), NULL, NULL, NULL, NULL) promo ON listino.cod_vlis = promo.cod_vlis AND listino.cod_mart = promo.cod_mart
WHERE mtb_aart.flag_stato = 'A' /*and promo.cod_promo is not null*/
ORDER BY listino.cod_mart

View File

@@ -0,0 +1,9 @@
SELECT gtb_paga.cod_paga,
descrizione,
CASE WHEN gtb_tipi_paga.flag_banca_ven = 'C' THEN 1 ELSE 0 END AS flag_abicab_needed
FROM gtb_paga INNER JOIN gtb_tipi_paga ON gtb_paga.tipo_paga = gtb_tipi_paga.tipo_paga
WHERE flag_attivo = 'S' AND
flag_paga_remoto = 'S'
ORDER BY descrizione
/*
CASE WHEN gtb_tipi_paga.flag_banca_ven = 'C' THEN 'S' ELSE 'N' END AS chiediBancaClie*/