init
This commit is contained in:
48
modules/EcmPaymentStates/checkpaymentdate.php
Normal file
48
modules/EcmPaymentStates/checkpaymentdate.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*echo "find diff<br>";
|
||||
$w=$GLOBALS['db']->query("select document_no,payment_date,type,id from ecminvoiceouts where register_date>'2010-03-01'");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select register_date,total from ecmpayments_ecminvoiceouts where document_no like '".$r['document_no']."'"));
|
||||
if($r['payment_date']!=$rr['register_date']){
|
||||
echo $r['document_no']." ".$r['payment_date']." ".$rr['register_date']."<br>";
|
||||
$GLOBALS['db']->query("update ecmpayments_ecminvoiceouts set register_date='".$r['payment_date']."' where document_no like '".$r['document_no']."'");
|
||||
}
|
||||
if($rr['total']==0){
|
||||
if($r['type']=="correct"){
|
||||
$total=0;
|
||||
$www=$GLOBALS['db']->query("select price,quantity,ecmvat_value,ecminvoiceoutitem_id from ecminvoiceoutitems where ecminvoiceout_id='".$r['id']."' and deleted='0'");
|
||||
while($rrr=$GLOBALS['db']->fetchByAssoc($www)){
|
||||
$rrrr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select price,quantity,ecmvat_value from ecminvoiceoutitems where id='".$rrr['ecminvoiceoutitem_id']."'"));
|
||||
$total+=$rrr['price']*$rrr['quantity']*(1+$rrr['ecmvat_value']/100)-$rrrr['price']*$rrrr['quantity']*(1+$rrrr['ecmvat_value']/100);
|
||||
}
|
||||
$GLOBALS['db']->query("update ecmpayments_ecminvoiceouts set total='".$total."' where document_no='".$r['document_no']."'");
|
||||
}
|
||||
else{
|
||||
$total=0;
|
||||
$www=$GLOBALS['db']->query("select price,quantity,ecmvat_value,ecminvoiceoutitem_id from ecminvoiceoutitems where ecminvoiceout_id='".$r['id']."' and deleted='0'");
|
||||
while($rrr=$GLOBALS['db']->fetchByAssoc($www)){
|
||||
$total+=$rrr['price']*$rrr['quantity']*(1+$rrr['ecmvat_value']/100);
|
||||
}
|
||||
$GLOBALS['db']->query("update ecmpayments_ecminvoiceouts set total='".$total."' where document_no='".$r['document_no']."'");
|
||||
}
|
||||
echo $r['document_no']." ".$total."<br>";
|
||||
}
|
||||
}*/
|
||||
echo "find dup<br>";
|
||||
$w=$GLOBALS['db']->query("select document_no,payment_date,type,id from ecminvoiceouts where register_date>'2010-03-01'");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$num=mysql_num_rows($GLOBALS['db']->query("select id from ecmpayments_ecminvoiceouts where document_no like '".$r['document_no']."'"));
|
||||
if($num>1){
|
||||
echo $r['document_no']." ".$num."<br>";
|
||||
$i=0;
|
||||
$ww=$GLOBALS['db']->query("select id from ecmpayments_ecminvoiceouts where document_no like '".$r['document_no']."'");
|
||||
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
|
||||
if($i!=0){
|
||||
$GLOBALS['db']->query("delete from ecmpayments_ecminvoiceouts where id='".$rr['id']."'");
|
||||
echo mysql_error();
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user