<?php 
/****************************************************************/
/*          e-mo.pl © 2017                                      */
/*          http://www.e-mo.com.pl                              */
/*          e-mail: info@e-mo.pl                                */
/*          produkt: Action2osCommerce                          */
/*          wersja: 1.9.7                                       */
/*          webserwis: oscGold                                  */
/*          sciezka: https://www.e-mo.com.pl/plikit,1918,533545b244d7d.php*/
/*          data: 2017-09-25                                    */
/*          godz: 10:45:12                                      */
/****************************************************************/



	@require_once('source/products_to_categories.php');
	@require_once('source/products.php');

	$kat = new products_to_categories();
	$kat->Conn = $db->Conn;

	$kat->products_id = $_POST['pk_Produkt'];//products::Szukaj($_POST['pk_Symbol']);	
		
	if($kat->Usun())
	{
		echo '<usun>0</usun>';
	}
	else echo '<usun>1</usun>';
	
	$doc = new DOMDocument();
	$doc->loadXML(stripslashes($_POST['paczka']));
	
	$xpath = new DOMXPath($doc);
	$query = '//kategorie/kategoria';

	$entries = $xpath->query($query);

	foreach ($entries as $entry) {
		
		echo '<katpro ';
		echo 'produkt="'.$entry->getAttribute('pro').'" ';
		echo 'kategoria="'.$entry->getAttribute('kat').'" ';
		echo 'kluczObcy="'.$entry->getAttribute('kluczObcy').'" ';

		$kat->categories_id = $entry->getAttribute('kat');	
	
		if($kat->categories_id > 0 && $kat->Dodaj())
		{
			echo 'error="0" ';	
			echo 'errMsg="OK" ';
		}
		elseif($kat->categories_id=0)
		{
			echo 'error="1" ';	
			echo 'errMsg="Brak kategorii w sklepie" ';
		}
		else
		{
			echo 'error="1" ';	
			echo 'errMsg="'.$kat->errMsg[2].'" ';	
		}
		
		echo '/>';
	}


	//unlink($nazwapliku);


?>
