Files
crm.twinpol.com/modules/EcmStockStates/add_invoices_payments.php

55 lines
3.2 KiB
PHP
Raw Permalink Normal View History

2025-05-12 15:44:39 +00:00
<?
/*$w=mysql_query("select id,total,register_date,document_no,parent_id from ecminvoiceouts where register_date>'2009-12-31' and deleted='0'");
while($r=mysql_fetch_array($w)){
echo "insert into ecmpayments_ecminvoiceouts(id,ecminvoiceout_id,date_entered,date_modified,modified_user_id,deleted,paid,total,document_no,account_id,register_date,payment_date) values('".create_guid()."','".$r['id']."','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."','1','0','0','".$r['total']."','".$r['document_no']."','".$r['parent_id']."','".$r['register_date']."','');<br>";
}*/
/*$w=mysql_query("select register_date,id,ecminvoiceout_id,document_no from ecmpayments_ecminvoiceouts where document_no like '%/10' order by document_no asc");
while($r=mysql_fetch_array($w)){
$rr=mysql_fetch_array(mysql_query("select ecmpaymentcondition_id from ecminvoiceouts where id='".$r['ecminvoiceout_id']."'"));
$rr=mysql_fetch_array(mysql_query("select days from ecmpaymentconditions where id='".$rr['ecmpaymentcondition_id']."'"));
$exp=explode("-",$r['register_date']);
$date=date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0])+3600*24*$rr['days']);
echo "update ecmpayments_ecminvoiceouts set document_no='".$r['document_no']."',register_date='".$date."' where id='".$r['id']."';";
}*/
include_once("modules/EcmStockStates/class.dbf.php");
//include_once("modules/EcmStockStates/helper.php");
?>
<textarea style="width:900px;height:600px;">
<?
/*
$w=mysql_query("select id,name,dir from ecmstocks where dir is null and deleted='0'");
while($r=mysql_fetch_array($w)){
$dbf = new dbf_class('modules/EcmStockStates/klk/'.$r['dir'].'/_wn.dbf');
$num_rec=$dbf->dbf_num_rec;
for($i=0;$i<$num_rec;$i++){
$row=$dbf->getRowAssoc($i);
if($row['DATA_DOK']>'20091231')continue;
if($row['ROZL']=="T")$paid=1;
else $paid=0;
echo "update ecmpayments_ecminvoiceouts set paid='".$paid."' where document_no='".$row['SYM_DOK']." ".$row['NR_DOK']."';";
}
}
*/
/*
$w=mysql_query("select * from contacts where created_by='1633fa7a-fd76-08dc-ef31-4b544bbb5932' and date_entered like '2010-01-25%'");
while($r=mysql_fetch_array($w)){
echo "insert into accounts set id='".create_guid()."',date_entered='".date("Y-m-d H:i:s")."',date_modified='".date("Y-m-d H:i:s")."',assigned_user_id='1633fa7a-fd76-08dc-ef31-4b544bbb5932',modified_user_id='1633fa7a-fd76-08dc-ef31-4b544bbb5932',created_by='1633fa7a-fd76-08dc-ef31-4b544bbb5932',name='".$r['last_name']."',phone_office='".$r['phone_work']."',billing_address_street='".$r['primary_address_street']."',billing_address_city='".$r['primary_address_city']."',billing_address_postalcode='".$r['primary_address_postalcode']."';
";
$ids[$r['id']]=$r['id'];
}
foreach($ids as $id){
echo "update contacts set deleted='1' where id='".$id."';
";
}*/
$ww=mysql_query("select id from ecminvoiceouts where register_date='2010-01-26'");
while($rr=mysql_fetch_array($ww)){
$total=0;
$w=mysql_query("select p.price,p.quantity,p.ecmvat_value from ecminvoiceoutitems as p where p.ecminvoiceout_id='".$rr['id']."'");
while($r=mysql_fetch_array($w)){
$total+=$r['quantity']*$r['price']*(1+$r['ecmvat_value']/100);
}
echo "update ecmpayments_ecminvoiceouts set total='".$total."' where ecminvoiceout_id='".$rr['id']."';
";
}
?>
</textarea>