$value)
{
$csv[$key] = str_getcsv($value);
}
echo '
';
print_r($csv);
echo '
';
$link = mysql_connect('localhost', 'root', '5z#JaL');
$db_selected = mysql_select_db('crm', $link);
foreach($csv as $key)
{
if($key[2]=='Przekazany'){
$r=mysql_query("INSERT INTO nr_faktury
(`nr_faktury`)
VALUES
('".$key[1]."');");
}
}
*/
$link = mysql_connect('localhost', 'root', '5z#JaL');
$db_selected = mysql_select_db('crm', $link);
$r=mysql_query("select p.id,p.document_no,p.total,p.paid,p.register_date,p.payment_date,p.total,p.ecminvoiceout_id, p.ecmpayment_id,p.account_id from ecmpayments_ecminvoiceouts as p inner join ecminvoiceouts as i on p.ecminvoiceout_id=i.id and i.type!='canceled' where p.deleted='0' and p.date_entered > '2011-12-31' order by p.date_entered");
$i=0;
while($dane=mysql_fetch_assoc($r)){
$req=mysql_query( "select p.id, p.name,p.value from ecmpayments_ecminvoiceouts_rel as r inner join ecmpayments as p on p.id=r.ecmpayment_id where r.ee_id='" . $dane ['id'] . "'" );
while($dane2=mysql_fetch_assoc($req)){
$szukaj=mysql_query("select * from ecmtransactions where name='".$dane2['name']."' and value='".$dane2['value']."'");
$i++;
//echo $i.': '.$dane ['id'];
//echo' ' . $dane2 ['name'] . '
';
$szukaj_p=mysql_query("select * from ecmtransactions where name='".$dane['document_no']."' and value='".$dane['total']."'");
echo $i.': '.$dane ['id'];
$dane4=mysql_fetch_assoc($szukaj_p);
$dane3=mysql_fetch_assoc($szukaj);
if(mysql_num_rows($szukaj_p)>0 && mysql_num_rows($szukaj)>0){
// $cos=mysql_query("insert into ecmpayments2_ecminvoiceouts(id,ecmpayment_id,ecminvoiceout_id,date_entered,paid,created_by,modified_user_id,deleted,account_id) values('".create_guid()."','".$dane4 ['id']."','".$dane3 ['id']."','".$dane['register_date']."','1','2e72f487-d92b-954e-f50c-528b10ce81c9','2e72f487-d92b-954e-f50c-528b10ce81c9','0','".$dane['account_id']."');");
//echo "insert into ecmpayments2_ecminvoiceouts(id,ecmpayment_id,ecminvoiceout_id,date_entered,paid,created_by,modified_user_id,deleted,account_id) values('".create_guid()."','".$dane4 ['id']."','".$dane3 ['id']."','".$dane['register_date']."','1','2e72f487-d92b-954e-f50c-528b10ce81c9','2e72f487-d92b-954e-f50c-528b10ce81c9','0','".$dane['account_id']."'
";
echo' ' . $dane4 ['name'] . '';
echo' ' . $dane3 ['name'] . '
';
}
/*
while($dane4=mysql_fetch_assoc($szukaj_p)){
echo' ' . $dane4 ['name'] . '';
} /*
while($dane3=mysql_fetch_assoc($szukaj)){
//echo $i.': '.$dane ['id'];
echo' ' . $dane3 ['name'] . '
';
//echo' ' . $dane2 ['name'] . '
';
}
*/
}
}
echo $i;
?>