Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtrar llista proveïdors a manage_providers.php segons responsible_uf_id #282

Open
joancortes opened this issue Dec 2, 2020 · 1 comment

Comments

@joancortes
Copy link

joancortes commented Dec 2, 2020

Hola,

Estem adaptant l'Aixada al funcionament del nostre grup de consum de Llagostera, on cada membre assumeix la gestió de cada proveïdor. He trobat la manera de filtrar el llistat de proveïdors que es mostra a manage_providers.php perquè només es mostrin aquells proveïdors dels quals n'és responsable la UF que ha iniciat la sessió, però que no es filtri quan estigui el rol de caixa o hacker actiu. Aquí va la proposta.

Creo un nou procediment SQL:

create procedure get_provider_listing_resp_uf(in the_provider_id int, in include_inactive boolean, in resp_uf int)

begin
	declare wherec varchar(255) default "";
	
	-- show all providers including inactive or just active ones -- 
	set wherec = if(include_inactive=1,"","and pv.active = 1");	

	-- filter for specific provider --
	if the_provider_id > 0 then
		set wherec = concat(wherec," and pv.id=",the_provider_id);
	end if;
   
      		 -- filter for responsible uf --
	if resp_uf_id > 0 then
		set wherec = concat(wherec," and uf.id=",resp_uf_id);
	end if;
  
	set @q = concat("select pv.*, uf.id as responsible_uf_id, uf.name as responsible_uf_name from aixada_provider pv, aixada_uf uf where pv.responsible_uf_id = uf.id",wherec,"order by pv.name, pv.id;");
	  
  	prepare st from @q;
  	execute st;
 	 deallocate prepare st;
	  
end|

A config.php, afegeixo:
// Providers management rights // 0 is rights on all, 1 in only providers where the user is responsible public $rights_on_all_providers = array( 'Consumer' => 1, 'Checkout' => 0, 'Consumer Commission' => 1, 'Econo-Legal Commission' => 1, 'Logistic Commission' => 1, 'Hacker Commission' => 0, 'Fifth Column Commission' => 1, 'Producer' => 1 );

A Providers.php, modifico el switch amb :
case 'getProviders': printXML(stored_query_XML_fields('get_provider_listing_resp_uf', get_param('provider_id',0), get_param('all',0), get_session_value('uf_id')*get_config('rights_on_all_providers')[get_current_role()])); exit;

No sé si és molt barroera la solució, però funciona.

@jorix
Copy link
Contributor

jorix commented Jan 3, 2021

@joancortes

A mi em sembla una solució correcta.
(vaig pensar, ja m'ho mirare però ja no hi havia pensat més)

Per mirar coses així és més aclaridor fer una branca i posar-hi els commits.

NOTA: El nom $rights_on_all_providers és just al contrari del que hom pensaria que vol dir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants