127 lines
3.7 KiB
PHP
Executable File
127 lines
3.7 KiB
PHP
Executable File
<?php
|
|
include_once("class.dbf.php");
|
|
include_once("../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__).'/ekomer/_DOSTAW.DBF';
|
|
$dbfp = new dbf_class($path);
|
|
|
|
$num_recp=$dbfp->dbf_num_rec;
|
|
|
|
$sugar_fields = array ('id','index_dbf','name','billing_address_postalcode','billing_address_street','to_vatid','phone_office','phone_fax','description','email');
|
|
|
|
$insert = array();
|
|
$count =0;
|
|
//for($i=0;$i<$num_recp;$i++){
|
|
$j=0;
|
|
for($i=$num_recp;$i>0;$i--){
|
|
|
|
$rowp=$dbfp->getRowAssoc($i);
|
|
//print_r($rowp);
|
|
//echo '<br>'.$rowp['ALBANIA'].'a<br>';
|
|
//echo $back.' '.$rowp['FASTECH_SH'].'<br>';
|
|
//echo 'lol';
|
|
|
|
$row = array (
|
|
addslashes(create_guid()), //id
|
|
addslashes(ch($rowp['NR_EWIDENC'])), //nazwa
|
|
addslashes(ch($rowp['NAZWA'])),
|
|
addslashes(ch($rowp['NIPBK'])),
|
|
|
|
|
|
|
|
);
|
|
//echo 'add<br>';
|
|
array_push($insert, $row);
|
|
// echo ch($rowp['NAZWA']);
|
|
|
|
//echo $a.'a<br>';
|
|
//END ROW ARRAY
|
|
|
|
}
|
|
|
|
//CREATE QUERY
|
|
//echo sizeof($insert).'';
|
|
|
|
///////////////
|
|
$path = dirname(__FILE__).'/ekomer/_wn.dbf';
|
|
$dbfp = new dbf_class($path);
|
|
|
|
$num_recp=$dbfp->dbf_num_rec;
|
|
|
|
$sugar_fields = array ('id','index_dbf','name','billing_address_postalcode','billing_address_street','to_vatid','phone_office','phone_fax','description','email');
|
|
|
|
$insert2 = array();
|
|
$count =0;
|
|
//for($i=0;$i<$num_recp;$i++){
|
|
$j=0;
|
|
for($i=$num_recp;$i>0;$i--){
|
|
|
|
$rowp=$dbfp->getRowAssoc($i);
|
|
//print_r($rowp);
|
|
//echo '<br>'.$rowp['ALBANIA'].'a<br>';
|
|
//echo $back.' '.$rowp['FASTECH_SH'].'<br>';
|
|
//echo 'lol';
|
|
|
|
$row = array (
|
|
addslashes(create_guid()), //id
|
|
addslashes(ch($rowp['NR_SYSTEM'])), //nazwa
|
|
addslashes(ch($rowp['KWOTA'])),
|
|
addslashes(ch($rowp['OPIS'])),
|
|
addslashes(ch($rowp['ROZL'])),
|
|
addslashes(ch($rowp['DATA'])),
|
|
addslashes(ch($rowp['SYM_DOK']." ".$rowp['NR_DOK'])),
|
|
|
|
|
|
);
|
|
//echo 'add<br>';
|
|
array_push($insert2, $row);
|
|
// echo ch($rowp['NAZWA']);
|
|
|
|
//echo $a.'a<br>';
|
|
//END ROW ARRAY
|
|
|
|
}
|
|
|
|
for ($i=0; $i<count($insert2); $i++) {
|
|
|
|
|
|
$zapyt=mysql_query("SELECT id,name from ekomer.accounts where index_dbf= '".$insert2[$i][1]."'");
|
|
$zapyt2=mysql_query("SELECT id,name from ekomer.ecminvoiceouts where name = '".$insert2[$i][6]."'");
|
|
$dane2=mysql_fetch_array($zapyt2);
|
|
if(mysql_num_rows($zapyt2)>0){
|
|
$record_type='EcmInvoiceOuts';
|
|
}
|
|
//echo "SELECT id,name from ekomer.accounts where index_dbf='".$insert2[$i][1]."'".'<br>';
|
|
$dane=mysql_fetch_array($zapyt);
|
|
$acc=mysql_num_rows($zapyt);
|
|
if($insert2[$i][2]=="") continue;
|
|
|
|
//print_r($dane);
|
|
$licznik++;
|
|
$rok=substr($insert2[$i][5],0,4);
|
|
$miech=substr($insert2[$i][5],4,2);
|
|
$dzien=substr($insert2[$i][5],6,2);
|
|
$dzien=substr($insert2[$i][5],6,2);
|
|
|
|
if($insert2[$i][4]=="T"){$payd=1; } else { $payd=0; }
|
|
//echo "SELECT id,name from ekomer.accounts where name='".$insert[$ia][2]."'";
|
|
echo "INSERT INTO ekomer.ecmtransactions(id,name,date_entered,date_modified,modified_user_id,created_by,description,deleted,assigned_user_id,value,parent_name,parent_id,payment_date,type,paid,register_date,record_type,record_id)VALUES('".$insert2[$i][0]."','".$insert2[$i][3]."','".$rok."-".$miech."-".$dzien."','".$rok."-".$miech."-".$dzien."','1','1','1','0','1','".$insert2[$i][2]."','".$dane['name']."','".$dane['id']."','".$rok."-".$miech."-".$dzien."','0','".$payd."','".$rok."-".$miech."-".$dzien."','".$record_type."','".$dane2['id']."');\n";
|
|
//echo $query;
|
|
//mysql_query(ch($query));
|
|
|
|
|
|
//echo implode("','",$insert[$i]);
|
|
//PRODUCT INSERT
|
|
//
|
|
//if (mysql_error()) echo 'Database error: '.mysql_error().'';
|
|
|
|
} echo $licznik;
|
|
mysql_close($sql);
|
|
|
|
?>
|