Files
crm.twinpol.com/modules/EcmPaymentStates/imi.php
2025-05-12 15:44:39 +00:00

64 lines
3.2 KiB
PHP
Executable File

<?php
/*
ini_set('display_errors',1);
$csv = array();
$lines = file('rap3.csv', FILE_IGNORE_NEW_LINES);
foreach ($lines as $key => $value)
{
$csv[$key] = str_getcsv($value);
}
echo '<pre>';
print_r($csv);
echo '</pre>';
$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 limit 0,100");
$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' <a href="https://192.168.1.131/crm/index.php?module=EcmPayments&action=DetailView&record=' . $dane2 ['id'] . '" target="new">' . $dane2 ['name'] . '</a><br>';
$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']."'<br>";
}
/*
while($dane4=mysql_fetch_assoc($szukaj_p)){
echo' <a href="https://192.168.1.131/crm/index.php?module=EcmTransactions&action=DetailView&record=' . $dane4 ['id'] . '" target="new">' . $dane4 ['name'] . 'a</a>';
}
while($dane3=mysql_fetch_assoc($szukaj)){
//echo $i.': '.$dane ['id'];
echo' <a href="https://192.168.1.131/crm/index.php?module=EcmTransactions&action=DetailView&record=' . $dane3 ['id'] . '" target="new">' . $dane3 ['name'] . 'b</a><br>';
//echo' <a href="https://192.168.1.131/crm/index.php?module=EcmPayments&action=DetailView&record=' . $dane2 ['id'] . '" target="new">' . $dane2 ['name'] . '</a><br>';
}
*/
}
}
echo $i;
?>