26 lines
587 B
SQL
26 lines
587 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` PROCEDURE `vn`.`company_getFiscaldata`(workerFk INT)
|
|
BEGIN
|
|
|
|
DECLARE vCompanyFk INT;
|
|
|
|
SELECT IFNULL(uc.companyFk, rc.defaultCompanyFk)
|
|
INTO vCompanyFk
|
|
FROM vn.routeConfig rc
|
|
LEFT JOIN userMultiConfig uc ON uc.userFk = workerFk;
|
|
|
|
|
|
SELECT
|
|
s.name AS name ,
|
|
s.NIF AS nif ,
|
|
s.street AS street ,
|
|
s.city AS city ,
|
|
s.postCode AS postCode
|
|
|
|
FROM vn.company c
|
|
JOIN vn.worker w ON w.id = c.workerManagerFk
|
|
JOIN vn.supplier s ON s.id = c.id
|
|
WHERE c.id = vCompanyFk;
|
|
END$$
|
|
DELIMITER ;
|