<?php
error_reporting(E_ERROR);
include_once("class.dbf.php");
include_once("/var/www/crm/config.php");
include_once("helper.php");
global $sugar_config;
$sql=mysql_connect($sugar_config['dbconfig']['db_host_name'],$sugar_config['dbconfig']['db_user_name'],$sugar_config['dbconfig']['db_password']);
mysql_select_db($sugar_config['dbconfig']['db_name']);
mysql_query("set character set utf8;");
$path = dirname(__FILE__).'/_stany.dbf';
$dbfp = new dbf_class($path);


$num_recp=$dbfp->dbf_num_rec;

$b2b_product_1 = array();
$b2b_product_0 = array();
for($i=0;$i<$num_recp;$i++){
$rowp=$dbfp->getRowAssoc($i);	
	if ($rowp['KOD_KOLORU']=='1') array_push($b2b_product_1, addslashes($rowp['INDEKS']));
	if ($rowp['KOD_KOLORU']=='0') array_push($b2b_product_0, addslashes($rowp['INDEKS']));
}

mysql_query("UPDATE ecmproducts set b2b_product='1' where index_dod IN ('".implode("','", $b2b_product_1)."')");
mysql_query("UPDATE ecmproducts set b2b_product='0' where index_dod IN ('".implode("','", $b2b_product_0)."')");
?>