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

85 lines
3.4 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
if($_REQUEST['type']=="save"){
global $current_user;
require_once('include/Upload.php');
$_POST['file']=upload_file("file","modules/EcmPaymentStates/files/");
chmod("modules/EcmPaymentStates/files/".$_POST['file'],0777);
$content=file_get_contents("modules/EcmPaymentStates/files/".$_POST['file']);
$a1=array("FV "," / ","WR ","AD ","MD ","FVKOR ","FK ","NW ","YX ","WX ","WM ","YZ ","NZ ");
$a2=array("FV","/","WR","AD","MD","FVKOR","FK","NW","YX","WX","WM","YZ","NZ");
$content=str_replace($a1,$a2,$content);
$content=explode("
",$content);
$count=count($content);
for($i=0;$i<$count;$i++){
$exp=explode(" ",$content[$i]);
$value=floatval(str_replace(",","",$exp[7]));
$name=$exp[1];
//echo $value.' - '.$name.'<br>';
$d=$exp[0];
$rd=explode(".",$d);
$register_date=$rd[2]."-".$rd[1]."-".$rd[0];
$t=new EcmTransaction();
$t->name=$name;
$t->parent_id=$_POST['account_id'];
$t->parent_name=$_POST['account_name'];
$t->value=$value;
$t->payment_date=$_REQUEST['date'];
$t->register_date=$_REQUEST['date'];
$t->created_by = $current_user->id;
$t->assigned_user_id = $current_user->id;
$t->assigned_user_id = '2';
$t->currency_id = 'PLN';
$t->currency_name = 'PLN';
$t->type='1';
//$t->type2='W_zap_dos';
$sum+=$value;
$id=$t->save();
echo $value.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$name.'<br>';
}
echo "SUMA: ".$sum;
die();
}
?>
<h2>Payments States: Import TXT</h2>
<br>
<form action="index.php?module=EcmPaymentStates&action=importTXT&type=save" method="post" name="importTXT" enctype="multipart/form-data">
<table width="100%" cellspacing="0" cellpadding="0" border="0" style="border-top: 0px none; margin-bottom: 4px;" class="tabForm">
<tr>
<td class="dataLabel" width="10%" nowrap="nowrap">Kontrahent</td>
<td class="dataField" width="90%" nowrap="nowrap">
<input name="account_name" tabindex="" id="account_name" size="" value="<?php echo $_REQUEST['account_name'];?>" title="" type="text">
<input name="account_id" id="account_id" value="<?php echo $_REQUEST['account_id'];?>" type="hidden">
<input name="btn_account_name" tabindex="" title="Select [Alt+T]" accesskey="T" class="button" value="Select" onclick='open_popup("Accounts", 600, 400, "", true, false, {"call_back_function":"set_return","form_name":"importTXT","field_to_name_array":{"id":"account_id","name":"account_name"}}, "single", true);' type="button"> </td>
<td class="dataLabel" width="10%" nowrap="nowrap">Plik</td>
<td class="dataField" width="90%" nowrap="nowrap">
<input name="file" type="file" /> </td>
</tr>
<tr>
<td class="dataLabel" nowrap="nowrap">Data pĹatnoĹci</td>
<td class="dataField" nowrap="nowrap">
<input autocomplete="off" name="date" id="date" value="<?php echo $_REQUEST['date'];?>" title="" tabindex="" size="11" maxlength="10" type="text">
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_trigger" align="absmiddle" border="0">
<script type="text/javascript">
Calendar.setup ({
inputField : "date",
daFormat : "<? echo str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));?>",
button : "date_trigger",
singleClick : true,
dateStr : "",
step : 1
}
);
</script>
</td>
<td class="dataLabel" nowrap="nowrap">&nbsp;</td>
<td class="dataField" nowrap="nowrap">&nbsp;</td>
</tr>
</table>
<input class='button' type='submit' name='button' value='Importuj' />
</form>