Download FV asDocument from E5 CRM; E-Commerce: fix rewizor encoding
This commit is contained in:
@@ -1,37 +1,38 @@
|
|||||||
<?php
|
<?php
|
||||||
// preDb_0dcc87940d3655fa574b253df04ca1c3
|
// preDb_0dcc87940d3655fa574b253df04ca1c3
|
||||||
// %g7!@fG
|
// %g7!@fG
|
||||||
function createPzFromInvoice($record, $stockId) {
|
function createPzFromInvoice($record, $stockId)
|
||||||
|
{
|
||||||
global $app_list_strings;
|
global $app_list_strings;
|
||||||
$db = $GLOBALS['db'];
|
$db = $GLOBALS['db'];
|
||||||
|
|
||||||
if ($stockId == null) {
|
if ($stockId == null) {
|
||||||
die('Nie wskazano magazynu');
|
die('Nie wskazano magazynu');
|
||||||
} else {
|
} else {
|
||||||
$stock = $db->fetchByAssoc($db->query("SELECT id, name FROM ecmstocks WHERE id = '".$stockId."'"));
|
$stock = $db->fetchByAssoc($db->query("SELECT id, name FROM ecmstocks WHERE id = '" . $stockId . "'"));
|
||||||
if ($stock == null) {
|
if ($stock == null) {
|
||||||
die("Wskazano błedny magazyn");
|
die("Wskazano błedny magazyn");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET' );
|
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
|
||||||
curl_setopt($curl, CURLOPT_VERBOSE, 1);
|
curl_setopt($curl, CURLOPT_VERBOSE, 1);
|
||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
|
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
|
||||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
|
||||||
curl_setopt($curl, CURLOPT_URL, "https://crm.e5.pl/REST/index.php?key=7e50a8a5-f01f-4fbc-8c1b-59f3fc474bb5&action=getInvoice&record=".$record);
|
curl_setopt($curl, CURLOPT_URL, "https://crm.e5.pl/REST/index.php?key=7e50a8a5-f01f-4fbc-8c1b-59f3fc474bb5&action=getInvoice&record=" . $record);
|
||||||
$res = curl_exec($curl);
|
$res = curl_exec($curl);
|
||||||
$inv = json_decode($res);
|
$inv = json_decode($res);
|
||||||
$inv->position_list = json_decode($inv->position_list);
|
$inv->position_list = json_decode($inv->position_list);
|
||||||
echo 'Tworzę dokument PZ w Twinpol<br>';
|
echo 'Tworzę dokument PZ w Twinpol<br>';
|
||||||
echo 'Numer faktury: '.$inv->document_no.'<br>';
|
echo 'Numer faktury: ' . $inv->document_no . '<br>';
|
||||||
echo 'Na magazyn: '.$stock['name'].' (ID: '.$stock['id'].')<br><br>';
|
echo 'Na magazyn: ' . $stock['name'] . ' (ID: ' . $stock['id'] . ')<br><br>';
|
||||||
|
|
||||||
//check if PZ not exists
|
//check if PZ not exists
|
||||||
$exists = $db->fetchByAssoc($db->query("SELECT id, document_no FROM ecmstockdocins WHERE name='".$inv->document_no."'"));
|
$exists = $db->fetchByAssoc($db->query("SELECT id, document_no FROM ecmstockdocins WHERE name='" . $inv->document_no . "'"));
|
||||||
if ($exists) {
|
if ($exists) {
|
||||||
echo "Istnieje już dokument PZ przypisany do tej faktury: <a target='new' href='https://crm.twinpol.com/index.php?module=EcmStockDocIns&action=DetailView&record=".$exists['id']."'>".$exists['document_no']."</a>";
|
echo "Istnieje już dokument PZ przypisany do tej faktury: <a target='new' href='https://crm.twinpol.com/index.php?module=EcmStockDocIns&action=DetailView&record=" . $exists['id'] . "'>" . $exists['document_no'] . "</a>";
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,8 +75,8 @@ function createPzFromInvoice($record, $stockId) {
|
|||||||
$pz->fromREST = true;
|
$pz->fromREST = true;
|
||||||
|
|
||||||
$gotAllProducts = true; // hope :)
|
$gotAllProducts = true; // hope :)
|
||||||
foreach ( $inv->position_list as $product ) {
|
foreach ($inv->position_list as $product) {
|
||||||
echo 'Produkt: '.$product->product_code.'<br>';
|
echo 'Produkt: ' . $product->product_code . '<br>';
|
||||||
$p = getProduct($product->product_code);
|
$p = getProduct($product->product_code);
|
||||||
if (!$p) {
|
if (!$p) {
|
||||||
echo ' Produkt nie istnieje w bazie TWINPOL<br>';
|
echo ' Produkt nie istnieje w bazie TWINPOL<br>';
|
||||||
@@ -115,7 +116,7 @@ function createPzFromInvoice($record, $stockId) {
|
|||||||
die();
|
die();
|
||||||
} else {
|
} else {
|
||||||
$new = $pz->save(true);
|
$new = $pz->save(true);
|
||||||
echo '<a target="new" href="https://crm.twinpol.com/index.php?module=EcmStockDocIns&action=DetailView&record='.$new.'">Utworzono PZ.</a>';
|
echo '<a target="new" href="https://crm.twinpol.com/index.php?module=EcmStockDocIns&action=DetailView&record=' . $new . '">Utworzono PZ.</a>';
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,12 +134,13 @@ function sendStocks()
|
|||||||
}
|
}
|
||||||
echo json_encode($stocks);
|
echo json_encode($stocks);
|
||||||
}
|
}
|
||||||
function sendSale($record) {
|
function sendSale($record)
|
||||||
|
{
|
||||||
require_once('modules/EcmSales/EcmSale.php');
|
require_once('modules/EcmSales/EcmSale.php');
|
||||||
$sale = new EcmSale();
|
$sale = new EcmSale();
|
||||||
$sale->retrieve($record);
|
$sale->retrieve($record);
|
||||||
$pl = $sale->getPositionList();
|
$pl = $sale->getPositionList();
|
||||||
$response = array (
|
$response = array(
|
||||||
'document_no' => $sale->document_no,
|
'document_no' => $sale->document_no,
|
||||||
'name' => $sale->name,
|
'name' => $sale->name,
|
||||||
'parent_document_no' => $sale->parent_document_no,
|
'parent_document_no' => $sale->parent_document_no,
|
||||||
@@ -167,15 +169,86 @@ function sendSale($record) {
|
|||||||
);
|
);
|
||||||
echo json_encode($response);
|
echo json_encode($response);
|
||||||
}
|
}
|
||||||
|
function updateSaleE5Number($record, $e5_record, $e5_document_no)
|
||||||
function updateSaleE5Number($record, $e5_record, $e5_document_no) {
|
{
|
||||||
$db = $GLOBALS['db'];
|
$db = $GLOBALS['db'];
|
||||||
$db->query("UPDATE ecmsales SET edi_zs_id='$e5_record', edi_zs_document_no='$e5_document_no' WHERE id='$record'");
|
$db->query("UPDATE ecmsales SET edi_zs_id='$e5_record', edi_zs_document_no='$e5_document_no' WHERE id='$record'");
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
function createCostDocumentFromInvoice($record)
|
||||||
|
{
|
||||||
|
global $app_list_strings;
|
||||||
|
$db = $GLOBALS['db'];
|
||||||
|
|
||||||
|
|
||||||
|
$curl = curl_init();
|
||||||
|
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
|
||||||
|
curl_setopt($curl, CURLOPT_VERBOSE, 1);
|
||||||
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
|
||||||
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
|
||||||
|
curl_setopt($curl, CURLOPT_URL, "https://crm.e5.pl/REST/index.php?key=7e50a8a5-f01f-4fbc-8c1b-59f3fc474bb5&action=getInvoice&record=" . $record);
|
||||||
|
$res = curl_exec($curl);
|
||||||
|
$inv = json_decode($res);
|
||||||
|
$inv->position_list = json_decode($inv->position_list);
|
||||||
|
echo 'Tworzę dokument kosztowy w Twinpol<br>';
|
||||||
|
echo 'Numer faktury: ' . $inv->document_no . '<br>';
|
||||||
|
|
||||||
|
removeDocumentIfExists($inv->document_no);
|
||||||
|
|
||||||
|
$doc = new Document();
|
||||||
|
$doc->document_name = $inv->document_no;
|
||||||
|
$doc->document_number = $inv->document_no;
|
||||||
|
$doc->doc_symbol = $inv->document_no;
|
||||||
|
$doc->revision = 1;
|
||||||
|
|
||||||
|
$doc->category_id = 'revision_note';
|
||||||
|
$doc->status = '2';
|
||||||
|
$doc->transaction_type = '1';
|
||||||
|
$doc->document_type = 'k';
|
||||||
|
|
||||||
|
$doc->active_date = $inv->register_date;
|
||||||
|
$doc->payment_date = $inv->payment_date;
|
||||||
|
$doc->document_date = $inv->register_date;
|
||||||
|
$doc->date_entered = date('Y-m-d H:i:s');
|
||||||
|
$doc->date_modified = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
$doc->value = $inv->total_brutto;
|
||||||
|
$doc->left_paid = $inv->total_brutto;
|
||||||
|
$doc->currency_id = $inv->currency_id;
|
||||||
|
$doc->currency_value = 1;
|
||||||
|
|
||||||
|
$id = $doc->save();
|
||||||
|
|
||||||
|
$parents = array();
|
||||||
|
$parent = array();
|
||||||
|
$parent['id'] = create_guid();
|
||||||
|
$parent['name'] = 'E5 Polska Sp. z o.o.';
|
||||||
|
$parent['parent_id'] = 'f084e64a-4e63-a3d1-6417-58cbf730df3f';
|
||||||
|
$parent['parent_type'] = 'Accounts';
|
||||||
|
$parents[] = $parent;
|
||||||
|
$doc->saveParentList($parents);
|
||||||
|
|
||||||
|
$vats = array();
|
||||||
|
$vatList = explode(',', $inv->vats_summary);
|
||||||
|
foreach ($vatList as $vatItem) {
|
||||||
|
if (empty($vatItem)) continue;
|
||||||
|
$parts = explode(':', $vatItem);
|
||||||
|
if (count($parts) != 5) continue;
|
||||||
|
$vat = array();
|
||||||
|
$vat['netto'] = $parts[1];
|
||||||
|
$vat['vat'] = $parts[2];
|
||||||
|
$vat['vat_id'] = str_replace('%', '', $parts[0]);
|
||||||
|
$vat['vat_value'] = $parts[0];
|
||||||
|
$vats[] = $vat;
|
||||||
|
}
|
||||||
|
$doc->saveVatList($vats);
|
||||||
|
|
||||||
|
echo 'Utworzono dokument kosztowy: <a target="new" href="https://crm.twinpol.com/index.php?module=Documents&action=DetailView&record=' . $id . '">' . $doc->document_name . '</a><br>';
|
||||||
|
}
|
||||||
// local helpers
|
// local helpers
|
||||||
function getProduct($code) {
|
function getProduct($code)
|
||||||
|
{
|
||||||
$db = $GLOBALS['db'];
|
$db = $GLOBALS['db'];
|
||||||
$res = $db->fetchByAssoc($db->query("SELECT * FROM ecmproducts WHERE code='$code' AND deleted=0"));
|
$res = $db->fetchByAssoc($db->query("SELECT * FROM ecmproducts WHERE code='$code' AND deleted=0"));
|
||||||
if (!$res) {
|
if (!$res) {
|
||||||
@@ -187,6 +260,7 @@ function getProduct($code) {
|
|||||||
return $prod;
|
return $prod;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
function createProduct($record) {
|
function createProduct($record) {
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET' );
|
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET' );
|
||||||
@@ -221,11 +295,21 @@ function createProduct($record) {
|
|||||||
//$new->save();
|
//$new->save();
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
function brecho($msg) {
|
*/
|
||||||
|
function removeDocumentIfExists($document_number)
|
||||||
|
{
|
||||||
|
$db = $GLOBALS['db'];
|
||||||
|
$res = $db->fetchByAssoc($db->query("SELECT id FROM documents WHERE document_number='$document_number'"));
|
||||||
|
if ($res) {
|
||||||
|
echo 'Istnieje już dokument kosztowy o numerze ' . $document_number . '. Usuwam go...<br>';
|
||||||
|
$db->query("DELETE FROM documents WHERE id='" . $res['id'] . "'");
|
||||||
|
$db->query("DELETE FROM documents_accounts WHERE document_id='" . $res['id'] . "'");
|
||||||
|
$db->query("DELETE FROM documents_vat WHERE document_id='" . $res['id'] . "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function brecho($msg)
|
||||||
|
{
|
||||||
echo '<br><br>';
|
echo '<br><br>';
|
||||||
var_dump($msg);
|
var_dump($msg);
|
||||||
echo '<br><br>';
|
echo '<br><br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// mysql create table with fields id varchar, created_at datetime, and payload max text
|
|
||||||
// create table e5_logs (id varchar(255), created_at datetime, payload text);
|
|
||||||
|
|||||||
@@ -35,5 +35,9 @@
|
|||||||
case 'updateSaleE5Number':
|
case 'updateSaleE5Number':
|
||||||
updateSaleE5Number($_GET['record'], $_GET['e5_record'], $_GET['e5_document_no']);
|
updateSaleE5Number($_GET['record'], $_GET['e5_record'], $_GET['e5_document_no']);
|
||||||
break;
|
break;
|
||||||
|
case 'createCostDocumentFromInvoice':
|
||||||
|
createCostDocumentFromInvoice($_GET['record']);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
// https://crm.twinpol.com/REST/index.php?key=d68dac4c-f784-4e1b-8267-9ffcfa0eda4c&action=createCostDocumentFromInvoice&record=c3f6eaa6-0cbd-8c89-1a8c-683ff19a36db
|
||||||
?>
|
?>
|
||||||
@@ -67,6 +67,13 @@ class Document extends SugarBean {
|
|||||||
var $related_doc_rev_number;
|
var $related_doc_rev_number;
|
||||||
var $is_template;
|
var $is_template;
|
||||||
var $template_type;
|
var $template_type;
|
||||||
|
var $payment_date;
|
||||||
|
var $transaction_type;
|
||||||
|
var $document_type;
|
||||||
|
var $value;
|
||||||
|
var $left_paid;
|
||||||
|
var $currency_id;
|
||||||
|
var $document_number;
|
||||||
//additional fields.
|
//additional fields.
|
||||||
var $revision;
|
var $revision;
|
||||||
var $last_rev_create_date;
|
var $last_rev_create_date;
|
||||||
@@ -354,6 +361,7 @@ class Document extends SugarBean {
|
|||||||
$return_array [] = $w;
|
$return_array [] = $w;
|
||||||
}
|
}
|
||||||
$json = getJSONobj();
|
$json = getJSONobj();
|
||||||
|
var_dump($return_array);
|
||||||
return $array ? $return_array : $json->encode($return_array);
|
return $array ? $return_array : $json->encode($return_array);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
if (! defined ( 'sugarEntry' ) || ! sugarEntry)
|
if (! defined('sugarEntry') || ! sugarEntry)
|
||||||
die ( 'Not A Valid Entry Point' );
|
die('Not A Valid Entry Point');
|
||||||
/**
|
/**
|
||||||
* *******************************************************************************
|
* *******************************************************************************
|
||||||
* SugarCRM is a customer relationship management program developed by
|
* SugarCRM is a customer relationship management program developed by
|
||||||
@@ -38,25 +38,25 @@ if (! defined ( 'sugarEntry' ) || ! sugarEntry)
|
|||||||
* "Powered by SugarCRM".
|
* "Powered by SugarCRM".
|
||||||
* ******************************************************************************
|
* ******************************************************************************
|
||||||
*/
|
*/
|
||||||
$dictionary ['Document'] = array (
|
$dictionary['Document'] = array(
|
||||||
'table' => 'documents',
|
'table' => 'documents',
|
||||||
'fields' => array (
|
'fields' => array(
|
||||||
|
|
||||||
// add mz
|
// add mz
|
||||||
'value' => array (
|
'value' => array(
|
||||||
'name' => 'value',
|
'name' => 'value',
|
||||||
'vname' => 'LBL_VALUE',
|
'vname' => 'LBL_VALUE',
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
'required'=>true,
|
'required' => true,
|
||||||
|
|
||||||
),
|
),
|
||||||
'left_paid' => array (
|
'left_paid' => array(
|
||||||
'name' => 'left_paid',
|
'name' => 'left_paid',
|
||||||
'vname' => 'LBL_VALUE_PAID',
|
'vname' => 'LBL_VALUE_PAID',
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
|
|
||||||
),
|
),
|
||||||
'parent_type' => array (
|
'parent_type' => array(
|
||||||
'name' => 'parent_type',
|
'name' => 'parent_type',
|
||||||
'vname' => 'LBL_PARENT_NAME',
|
'vname' => 'LBL_PARENT_NAME',
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
@@ -66,41 +66,41 @@ $dictionary ['Document'] = array (
|
|||||||
'len' => '25',
|
'len' => '25',
|
||||||
'comment' => 'The Sugar object to which the call is related'
|
'comment' => 'The Sugar object to which the call is related'
|
||||||
),
|
),
|
||||||
'currency_id' => array (
|
'currency_id' => array(
|
||||||
'name' => 'currency_id',
|
'name' => 'currency_id',
|
||||||
'type' => 'enum',
|
'type' => 'enum',
|
||||||
'options' => 'currency_dom',
|
'options' => 'currency_dom',
|
||||||
'label' => 'LBL_CURRENCY',
|
'label' => 'LBL_CURRENCY',
|
||||||
'len' => 36
|
'len' => 36
|
||||||
),
|
),
|
||||||
'document_type' => array (
|
'document_type' => array(
|
||||||
'name' => 'document_type',
|
'name' => 'document_type',
|
||||||
'type' => 'enum',
|
'type' => 'enum',
|
||||||
'options' => 'document_type_enum',
|
'options' => 'document_type_enum',
|
||||||
'default'=>'k',
|
'default' => 'k',
|
||||||
'label' => 'Typ faktury',
|
'label' => 'Typ faktury',
|
||||||
'required'=>true,
|
'required' => true,
|
||||||
'len' => 45
|
'len' => 45
|
||||||
),
|
),
|
||||||
'transaction_type' => array (
|
'transaction_type' => array(
|
||||||
'name' => 'transaction_type',
|
'name' => 'transaction_type',
|
||||||
'type' => 'enum',
|
'type' => 'enum',
|
||||||
'options' => 'transaction_type3_dom',
|
'options' => 'transaction_type3_dom',
|
||||||
'size' => 3,
|
'size' => 3,
|
||||||
'default'=>'1',
|
'default' => '1',
|
||||||
'vname'=>'Typ transakcji',
|
'vname' => 'Typ transakcji',
|
||||||
'label' => 'Typ transakcji',
|
'label' => 'Typ transakcji',
|
||||||
'required'=>true,
|
'required' => true,
|
||||||
'len' => 45
|
'len' => 45
|
||||||
),
|
),
|
||||||
'currency_value' => array (
|
'currency_value' => array(
|
||||||
'name' => 'currency_value',
|
'name' => 'currency_value',
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
'vname' => 'LBL_CURRENCY_VALUE',
|
'vname' => 'LBL_CURRENCY_VALUE',
|
||||||
'reportable' => false,
|
'reportable' => false,
|
||||||
'required' => false
|
'required' => false
|
||||||
),
|
),
|
||||||
'parent_name' => array (
|
'parent_name' => array(
|
||||||
'name' => 'parent_name',
|
'name' => 'parent_name',
|
||||||
|
|
||||||
'type_name' => 'parent_type',
|
'type_name' => 'parent_type',
|
||||||
@@ -111,10 +111,10 @@ $dictionary ['Document'] = array (
|
|||||||
'source' => 'non-db',
|
'source' => 'non-db',
|
||||||
'options' => 'parent_type_display2'
|
'options' => 'parent_type_display2'
|
||||||
),
|
),
|
||||||
'corrected_document_name' => array (
|
'corrected_document_name' => array(
|
||||||
'name' => 'corrected_document_name',
|
'name' => 'corrected_document_name',
|
||||||
'vname' => 'Korekta do dokumentu',
|
'vname' => 'Korekta do dokumentu',
|
||||||
'rname'=>'document_name',
|
'rname' => 'document_name',
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
'group' => 'corrected_document_name',
|
'group' => 'corrected_document_name',
|
||||||
'dbtype' => 'varchar',
|
'dbtype' => 'varchar',
|
||||||
@@ -122,7 +122,7 @@ $dictionary ['Document'] = array (
|
|||||||
'massupdate' => false,
|
'massupdate' => false,
|
||||||
'required' => false
|
'required' => false
|
||||||
),
|
),
|
||||||
'parent_id' => array (
|
'parent_id' => array(
|
||||||
'name' => 'parent_id',
|
'name' => 'parent_id',
|
||||||
'type' => 'id',
|
'type' => 'id',
|
||||||
'group' => 'parent_name',
|
'group' => 'parent_name',
|
||||||
@@ -131,7 +131,7 @@ $dictionary ['Document'] = array (
|
|||||||
'vname' => 'LBL_PARENT_ID'
|
'vname' => 'LBL_PARENT_ID'
|
||||||
),
|
),
|
||||||
|
|
||||||
'document_name' => array (
|
'document_name' => array(
|
||||||
'name' => 'document_name',
|
'name' => 'document_name',
|
||||||
'vname' => 'LBL_NAME',
|
'vname' => 'LBL_NAME',
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
@@ -140,13 +140,18 @@ $dictionary ['Document'] = array (
|
|||||||
'required' => true,
|
'required' => true,
|
||||||
'importable' => 'required'
|
'importable' => 'required'
|
||||||
),
|
),
|
||||||
'name' => array (
|
'document_number' => array(
|
||||||
|
'name' => 'document_name',
|
||||||
|
'type' => 'varchar',
|
||||||
|
'len' => '45',
|
||||||
|
),
|
||||||
|
'name' => array(
|
||||||
'name' => 'name',
|
'name' => 'name',
|
||||||
'vname' => 'LBL_NAME',
|
'vname' => 'LBL_NAME',
|
||||||
'source' => 'non-db',
|
'source' => 'non-db',
|
||||||
'type' => 'varchar'
|
'type' => 'varchar'
|
||||||
),
|
),
|
||||||
'filename' => array (
|
'filename' => array(
|
||||||
'name' => 'filename',
|
'name' => 'filename',
|
||||||
'vname' => 'LBL_FILENAME',
|
'vname' => 'LBL_FILENAME',
|
||||||
'type' => 'file',
|
'type' => 'file',
|
||||||
@@ -155,7 +160,7 @@ $dictionary ['Document'] = array (
|
|||||||
'required' => false
|
'required' => false
|
||||||
),
|
),
|
||||||
|
|
||||||
'uploadfile' => array (
|
'uploadfile' => array(
|
||||||
'name' => 'uploadfile',
|
'name' => 'uploadfile',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'vname' => 'LBL_FILENAME',
|
'vname' => 'LBL_FILENAME',
|
||||||
@@ -163,7 +168,7 @@ $dictionary ['Document'] = array (
|
|||||||
'source' => 'non-db'
|
'source' => 'non-db'
|
||||||
),
|
),
|
||||||
|
|
||||||
'active_date' => array (
|
'active_date' => array(
|
||||||
'name' => 'active_date',
|
'name' => 'active_date',
|
||||||
'vname' => 'LBL_DOC_ACTIVE_DATE',
|
'vname' => 'LBL_DOC_ACTIVE_DATE',
|
||||||
'type' => 'date',
|
'type' => 'date',
|
||||||
@@ -171,13 +176,13 @@ $dictionary ['Document'] = array (
|
|||||||
'required' => true
|
'required' => true
|
||||||
),
|
),
|
||||||
|
|
||||||
'exp_date' => array (
|
'exp_date' => array(
|
||||||
'name' => 'exp_date',
|
'name' => 'exp_date',
|
||||||
'vname' => 'LBL_DOC_EXP_DATE',
|
'vname' => 'LBL_DOC_EXP_DATE',
|
||||||
'type' => 'date'
|
'type' => 'date'
|
||||||
),
|
),
|
||||||
|
|
||||||
'category_id' => array (
|
'category_id' => array(
|
||||||
'name' => 'category_id',
|
'name' => 'category_id',
|
||||||
'vname' => 'LBL_SF_CATEGORY',
|
'vname' => 'LBL_SF_CATEGORY',
|
||||||
'type' => 'enum',
|
'type' => 'enum',
|
||||||
@@ -186,7 +191,7 @@ $dictionary ['Document'] = array (
|
|||||||
'reportable' => false
|
'reportable' => false
|
||||||
),
|
),
|
||||||
|
|
||||||
'subcategory_id' => array (
|
'subcategory_id' => array(
|
||||||
'name' => 'subcategory_id',
|
'name' => 'subcategory_id',
|
||||||
'vname' => 'LBL_SF_SUBCATEGORY',
|
'vname' => 'LBL_SF_SUBCATEGORY',
|
||||||
'type' => 'enum',
|
'type' => 'enum',
|
||||||
@@ -194,7 +199,7 @@ $dictionary ['Document'] = array (
|
|||||||
'options' => 'document_subcategory_dom',
|
'options' => 'document_subcategory_dom',
|
||||||
'reportable' => false
|
'reportable' => false
|
||||||
),
|
),
|
||||||
'payment_date' => array (
|
'payment_date' => array(
|
||||||
'name' => 'payment_date',
|
'name' => 'payment_date',
|
||||||
'vname' => 'LBL_PAYMENT_DATE',
|
'vname' => 'LBL_PAYMENT_DATE',
|
||||||
'type' => 'date',
|
'type' => 'date',
|
||||||
@@ -203,7 +208,7 @@ $dictionary ['Document'] = array (
|
|||||||
'massupdate' => false,
|
'massupdate' => false,
|
||||||
'required' => false
|
'required' => false
|
||||||
),
|
),
|
||||||
'status_id' => array (
|
'status_id' => array(
|
||||||
'name' => 'status_id',
|
'name' => 'status_id',
|
||||||
'vname' => 'LBL_DOC_STATUS',
|
'vname' => 'LBL_DOC_STATUS',
|
||||||
'type' => 'enum',
|
'type' => 'enum',
|
||||||
@@ -214,7 +219,7 @@ $dictionary ['Document'] = array (
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
'document_revision_id' => array (
|
'document_revision_id' => array(
|
||||||
'name' => 'document_revision_id',
|
'name' => 'document_revision_id',
|
||||||
'vname' => 'LBL_LATEST_REVISION',
|
'vname' => 'LBL_LATEST_REVISION',
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
@@ -223,7 +228,7 @@ $dictionary ['Document'] = array (
|
|||||||
'required' => false
|
'required' => false
|
||||||
),
|
),
|
||||||
|
|
||||||
'revisions' => array (
|
'revisions' => array(
|
||||||
'name' => 'revisions',
|
'name' => 'revisions',
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'relationship' => 'document_revisions',
|
'relationship' => 'document_revisions',
|
||||||
@@ -232,7 +237,7 @@ $dictionary ['Document'] = array (
|
|||||||
'required' => false
|
'required' => false
|
||||||
),
|
),
|
||||||
|
|
||||||
'revision' => array (
|
'revision' => array(
|
||||||
'name' => 'revision',
|
'name' => 'revision',
|
||||||
'vname' => 'LBL_DOC_VERSION',
|
'vname' => 'LBL_DOC_VERSION',
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
@@ -243,14 +248,14 @@ $dictionary ['Document'] = array (
|
|||||||
'required' => true
|
'required' => true
|
||||||
),
|
),
|
||||||
|
|
||||||
'last_rev_created_name' => array (
|
'last_rev_created_name' => array(
|
||||||
'name' => 'last_rev_created_name',
|
'name' => 'last_rev_created_name',
|
||||||
'vname' => 'LBL_LAST_REV_CREATOR',
|
'vname' => 'LBL_LAST_REV_CREATOR',
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
'reportable' => false,
|
'reportable' => false,
|
||||||
'source' => 'non-db'
|
'source' => 'non-db'
|
||||||
),
|
),
|
||||||
'last_rev_mime_type' => array (
|
'last_rev_mime_type' => array(
|
||||||
'name' => 'last_rev_mime_type',
|
'name' => 'last_rev_mime_type',
|
||||||
'vname' => 'LBL_LAST_REV_MIME_TYPE',
|
'vname' => 'LBL_LAST_REV_MIME_TYPE',
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
@@ -258,14 +263,14 @@ $dictionary ['Document'] = array (
|
|||||||
'studio' => 'false',
|
'studio' => 'false',
|
||||||
'source' => 'non-db'
|
'source' => 'non-db'
|
||||||
),
|
),
|
||||||
'latest_revision' => array (
|
'latest_revision' => array(
|
||||||
'name' => 'latest_revision',
|
'name' => 'latest_revision',
|
||||||
'vname' => 'LBL_LATEST_REVISION',
|
'vname' => 'LBL_LATEST_REVISION',
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
'reportable' => false,
|
'reportable' => false,
|
||||||
'source' => 'non-db'
|
'source' => 'non-db'
|
||||||
),
|
),
|
||||||
'last_rev_create_date' => array (
|
'last_rev_create_date' => array(
|
||||||
'name' => 'last_rev_create_date',
|
'name' => 'last_rev_create_date',
|
||||||
'type' => 'date',
|
'type' => 'date',
|
||||||
'table' => 'document_revisions',
|
'table' => 'document_revisions',
|
||||||
@@ -276,7 +281,7 @@ $dictionary ['Document'] = array (
|
|||||||
'reportable' => false,
|
'reportable' => false,
|
||||||
'source' => 'non-db'
|
'source' => 'non-db'
|
||||||
),
|
),
|
||||||
'contracts' => array (
|
'contracts' => array(
|
||||||
'name' => 'contracts',
|
'name' => 'contracts',
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'relationship' => 'contracts_documents',
|
'relationship' => 'contracts_documents',
|
||||||
@@ -284,7 +289,7 @@ $dictionary ['Document'] = array (
|
|||||||
'vname' => 'LBL_CONTRACTS'
|
'vname' => 'LBL_CONTRACTS'
|
||||||
),
|
),
|
||||||
// todo remove
|
// todo remove
|
||||||
'leads' => array (
|
'leads' => array(
|
||||||
'name' => 'leads',
|
'name' => 'leads',
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'relationship' => 'leads_documents',
|
'relationship' => 'leads_documents',
|
||||||
@@ -292,7 +297,7 @@ $dictionary ['Document'] = array (
|
|||||||
'vname' => 'LBL_LEADS'
|
'vname' => 'LBL_LEADS'
|
||||||
),
|
),
|
||||||
|
|
||||||
'related_doc_id' => array (
|
'related_doc_id' => array(
|
||||||
'name' => 'related_doc_id',
|
'name' => 'related_doc_id',
|
||||||
'vname' => 'LBL_RELATED_DOCUMENT_ID',
|
'vname' => 'LBL_RELATED_DOCUMENT_ID',
|
||||||
'reportable' => false,
|
'reportable' => false,
|
||||||
@@ -301,7 +306,7 @@ $dictionary ['Document'] = array (
|
|||||||
'len' => '36'
|
'len' => '36'
|
||||||
),
|
),
|
||||||
|
|
||||||
'related_doc_name' => array (
|
'related_doc_name' => array(
|
||||||
'name' => 'related_doc_name',
|
'name' => 'related_doc_name',
|
||||||
'vname' => 'LBL_DET_RELATED_DOCUMENT',
|
'vname' => 'LBL_DET_RELATED_DOCUMENT',
|
||||||
'type' => 'relate',
|
'type' => 'relate',
|
||||||
@@ -312,7 +317,7 @@ $dictionary ['Document'] = array (
|
|||||||
'comment' => 'The related document name for Meta-Data framework'
|
'comment' => 'The related document name for Meta-Data framework'
|
||||||
),
|
),
|
||||||
|
|
||||||
'related_doc_rev_id' => array (
|
'related_doc_rev_id' => array(
|
||||||
'name' => 'related_doc_rev_id',
|
'name' => 'related_doc_rev_id',
|
||||||
'vname' => 'LBL_RELATED_DOCUMENT_REVISION_ID',
|
'vname' => 'LBL_RELATED_DOCUMENT_REVISION_ID',
|
||||||
'reportable' => false,
|
'reportable' => false,
|
||||||
@@ -321,7 +326,7 @@ $dictionary ['Document'] = array (
|
|||||||
'len' => '36'
|
'len' => '36'
|
||||||
),
|
),
|
||||||
|
|
||||||
'related_doc_rev_number' => array (
|
'related_doc_rev_number' => array(
|
||||||
'name' => 'related_doc_rev_number',
|
'name' => 'related_doc_rev_number',
|
||||||
'vname' => 'LBL_DET_RELATED_DOCUMENT_VERSION',
|
'vname' => 'LBL_DET_RELATED_DOCUMENT_VERSION',
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
@@ -329,14 +334,14 @@ $dictionary ['Document'] = array (
|
|||||||
'comment' => 'The related document version number for Meta-Data framework'
|
'comment' => 'The related document version number for Meta-Data framework'
|
||||||
),
|
),
|
||||||
|
|
||||||
'is_template' => array (
|
'is_template' => array(
|
||||||
'name' => 'is_template',
|
'name' => 'is_template',
|
||||||
'vname' => 'LBL_IS_TEMPLATE',
|
'vname' => 'LBL_IS_TEMPLATE',
|
||||||
'type' => 'bool',
|
'type' => 'bool',
|
||||||
'default' => 0,
|
'default' => 0,
|
||||||
'reportable' => false
|
'reportable' => false
|
||||||
),
|
),
|
||||||
'accepted' => array (
|
'accepted' => array(
|
||||||
'name' => 'accepted',
|
'name' => 'accepted',
|
||||||
'vname' => 'LBL_TO_ACCEPT',
|
'vname' => 'LBL_TO_ACCEPT',
|
||||||
'type' => 'enum',
|
'type' => 'enum',
|
||||||
@@ -345,16 +350,16 @@ $dictionary ['Document'] = array (
|
|||||||
'options' => 'document_user_status_dom',
|
'options' => 'document_user_status_dom',
|
||||||
'reportable' => false
|
'reportable' => false
|
||||||
),
|
),
|
||||||
'status' => array (
|
'status' => array(
|
||||||
'name' => 'status',
|
'name' => 'status',
|
||||||
'vname' => 'Status',
|
'vname' => 'Status',
|
||||||
'type' => 'enum',
|
'type' => 'enum',
|
||||||
|
|
||||||
'options' => 'status_user_status_dom',
|
'options' => 'status_user_status_dom',
|
||||||
'reportable' => false,
|
'reportable' => false,
|
||||||
'required'=>true
|
'required' => true
|
||||||
),
|
),
|
||||||
'date_start' => array (
|
'date_start' => array(
|
||||||
'name' => 'date_start',
|
'name' => 'date_start',
|
||||||
'vname' => 'LBL_DATE_START',
|
'vname' => 'LBL_DATE_START',
|
||||||
'type' => 'date',
|
'type' => 'date',
|
||||||
@@ -362,7 +367,7 @@ $dictionary ['Document'] = array (
|
|||||||
'default' => 0,
|
'default' => 0,
|
||||||
'reportable' => false
|
'reportable' => false
|
||||||
),
|
),
|
||||||
'date_end' => array (
|
'date_end' => array(
|
||||||
'name' => 'date_end',
|
'name' => 'date_end',
|
||||||
'vname' => 'LBL_DATE_END',
|
'vname' => 'LBL_DATE_END',
|
||||||
'type' => 'date',
|
'type' => 'date',
|
||||||
@@ -370,7 +375,7 @@ $dictionary ['Document'] = array (
|
|||||||
'default' => 0,
|
'default' => 0,
|
||||||
'reportable' => false
|
'reportable' => false
|
||||||
),
|
),
|
||||||
'template_type' => array (
|
'template_type' => array(
|
||||||
'name' => 'template_type',
|
'name' => 'template_type',
|
||||||
'vname' => 'LBL_TEMPLATE_TYPE',
|
'vname' => 'LBL_TEMPLATE_TYPE',
|
||||||
'type' => 'enum',
|
'type' => 'enum',
|
||||||
@@ -379,7 +384,7 @@ $dictionary ['Document'] = array (
|
|||||||
'reportable' => false
|
'reportable' => false
|
||||||
),
|
),
|
||||||
// BEGIN field used for contract document subpanel.
|
// BEGIN field used for contract document subpanel.
|
||||||
'latest_revision_name' => array (
|
'latest_revision_name' => array(
|
||||||
'name' => 'latest_revision_name',
|
'name' => 'latest_revision_name',
|
||||||
'vname' => 'LBL_LASTEST_REVISION_NAME',
|
'vname' => 'LBL_LASTEST_REVISION_NAME',
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
@@ -387,56 +392,56 @@ $dictionary ['Document'] = array (
|
|||||||
'source' => 'non-db'
|
'source' => 'non-db'
|
||||||
),
|
),
|
||||||
|
|
||||||
'selected_revision_name' => array (
|
'selected_revision_name' => array(
|
||||||
'name' => 'selected_revision_name',
|
'name' => 'selected_revision_name',
|
||||||
'vname' => 'LBL_SELECTED_REVISION_NAME',
|
'vname' => 'LBL_SELECTED_REVISION_NAME',
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
'reportable' => false,
|
'reportable' => false,
|
||||||
'source' => 'non-db'
|
'source' => 'non-db'
|
||||||
),
|
),
|
||||||
'contract_status' => array (
|
'contract_status' => array(
|
||||||
'name' => 'contract_status',
|
'name' => 'contract_status',
|
||||||
'vname' => 'LBL_CONTRACT_STATUS',
|
'vname' => 'LBL_CONTRACT_STATUS',
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
'reportable' => false,
|
'reportable' => false,
|
||||||
'source' => 'non-db'
|
'source' => 'non-db'
|
||||||
),
|
),
|
||||||
'contract_name' => array (
|
'contract_name' => array(
|
||||||
'name' => 'contract_name',
|
'name' => 'contract_name',
|
||||||
'vname' => 'LBL_CONTRACT_NAME',
|
'vname' => 'LBL_CONTRACT_NAME',
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
'reportable' => false,
|
'reportable' => false,
|
||||||
'source' => 'non-db'
|
'source' => 'non-db'
|
||||||
),
|
),
|
||||||
'linked_id' => array (
|
'linked_id' => array(
|
||||||
'name' => 'linked_id',
|
'name' => 'linked_id',
|
||||||
'vname' => 'LBL_LINKED_ID',
|
'vname' => 'LBL_LINKED_ID',
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
'reportable' => false,
|
'reportable' => false,
|
||||||
'source' => 'non-db'
|
'source' => 'non-db'
|
||||||
),
|
),
|
||||||
'selected_revision_id' => array (
|
'selected_revision_id' => array(
|
||||||
'name' => 'selected_revision_id',
|
'name' => 'selected_revision_id',
|
||||||
'vname' => 'LBL_SELECTED_REVISION_ID',
|
'vname' => 'LBL_SELECTED_REVISION_ID',
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
'reportable' => false,
|
'reportable' => false,
|
||||||
'source' => 'non-db'
|
'source' => 'non-db'
|
||||||
),
|
),
|
||||||
'latest_revision_id' => array (
|
'latest_revision_id' => array(
|
||||||
'name' => 'latest_revision_id',
|
'name' => 'latest_revision_id',
|
||||||
'vname' => 'LBL_LATEST_REVISION_ID',
|
'vname' => 'LBL_LATEST_REVISION_ID',
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
'reportable' => false,
|
'reportable' => false,
|
||||||
'source' => 'non-db'
|
'source' => 'non-db'
|
||||||
),
|
),
|
||||||
'selected_revision_filename' => array (
|
'selected_revision_filename' => array(
|
||||||
'name' => 'selected_revision_filename',
|
'name' => 'selected_revision_filename',
|
||||||
'vname' => 'LBL_SELECTED_REVISION_FILENAME',
|
'vname' => 'LBL_SELECTED_REVISION_FILENAME',
|
||||||
'type' => 'varchar',
|
'type' => 'varchar',
|
||||||
'reportable' => false,
|
'reportable' => false,
|
||||||
'source' => 'non-db'
|
'source' => 'non-db'
|
||||||
),
|
),
|
||||||
'document_date' => array (
|
'document_date' => array(
|
||||||
'name' => 'document_date',
|
'name' => 'document_date',
|
||||||
'vname' => 'LBL_DOCUMENT_DATE',
|
'vname' => 'LBL_DOCUMENT_DATE',
|
||||||
'type' => 'date',
|
'type' => 'date',
|
||||||
@@ -448,18 +453,18 @@ $dictionary ['Document'] = array (
|
|||||||
// END fields used for contract documents subpanel.
|
// END fields used for contract documents subpanel.
|
||||||
),
|
),
|
||||||
|
|
||||||
'indices' => array (
|
'indices' => array(
|
||||||
array (
|
array(
|
||||||
'name' => 'idx_doc_cat',
|
'name' => 'idx_doc_cat',
|
||||||
'type' => 'index',
|
'type' => 'index',
|
||||||
'fields' => array (
|
'fields' => array(
|
||||||
'category_id',
|
'category_id',
|
||||||
'subcategory_id'
|
'subcategory_id'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'relationships' => array (
|
'relationships' => array(
|
||||||
'document_revisions' => array (
|
'document_revisions' => array(
|
||||||
'lhs_module' => 'Documents',
|
'lhs_module' => 'Documents',
|
||||||
'lhs_table' => 'documents',
|
'lhs_table' => 'documents',
|
||||||
'lhs_key' => 'id',
|
'lhs_key' => 'id',
|
||||||
@@ -469,7 +474,7 @@ $dictionary ['Document'] = array (
|
|||||||
'relationship_type' => 'one-to-many'
|
'relationship_type' => 'one-to-many'
|
||||||
),
|
),
|
||||||
|
|
||||||
'documents_modified_user' => array (
|
'documents_modified_user' => array(
|
||||||
'lhs_module' => 'Users',
|
'lhs_module' => 'Users',
|
||||||
'lhs_table' => 'users',
|
'lhs_table' => 'users',
|
||||||
'lhs_key' => 'id',
|
'lhs_key' => 'id',
|
||||||
@@ -479,7 +484,7 @@ $dictionary ['Document'] = array (
|
|||||||
'relationship_type' => 'one-to-many'
|
'relationship_type' => 'one-to-many'
|
||||||
),
|
),
|
||||||
|
|
||||||
'documents_created_by' => array (
|
'documents_created_by' => array(
|
||||||
'lhs_module' => 'Users',
|
'lhs_module' => 'Users',
|
||||||
'lhs_table' => 'users',
|
'lhs_table' => 'users',
|
||||||
'lhs_key' => 'id',
|
'lhs_key' => 'id',
|
||||||
@@ -490,7 +495,6 @@ $dictionary ['Document'] = array (
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
VardefManager::createVardef ( 'Documents', 'Document', array (
|
VardefManager::createVardef('Documents', 'Document', array(
|
||||||
'default'
|
'default'
|
||||||
) );
|
));
|
||||||
?>
|
|
||||||
|
|||||||
@@ -104,6 +104,8 @@ src="modules/Documents/js/Documents13.js"></script><input type="hidden" id="dbas
|
|||||||
if(strtotime($this->bean->date_entered.'+1 hours')<strtotime("now")){
|
if(strtotime($this->bean->date_entered.'+1 hours')<strtotime("now")){
|
||||||
// die('Brak możliwości edycji');
|
// die('Brak możliwości edycji');
|
||||||
}
|
}
|
||||||
|
var_dump("TREST");
|
||||||
|
var_dump($this->bean->vats);
|
||||||
} else {
|
} else {
|
||||||
global $timedate;
|
global $timedate;
|
||||||
$format = $timedate->get_cal_date_format();
|
$format = $timedate->get_cal_date_format();
|
||||||
|
|||||||
@@ -24,22 +24,46 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function exportToRewizor(source, date, type) {
|
function exportToRewizor(source, date, type) {
|
||||||
|
if (type == undefined || type == null || type == "") {
|
||||||
|
alert("Wybierz rodzaj faktur (normalne lub korekty).");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (source == undefined || source == null || source == "") {
|
||||||
|
alert("Wybierz źródło faktur.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
blockUI("Trwa generowanie pliku...");
|
blockUI("Trwa generowanie pliku...");
|
||||||
$.ajax({
|
|
||||||
url: "index.php?module=EcmInvoiceOuts&action=ecommerce&ajax=exportToRewizor&to_pdf=1&source="+source+"&date="+date+"&type="+type,
|
var xhr = new XMLHttpRequest();
|
||||||
type: "GET",
|
xhr.open('GET', "index.php?module=EcmInvoiceOuts&action=ecommerce&ajax=exportToRewizor&to_pdf=1&source="+source+"&date="+date+"&type="+type, true);
|
||||||
success: function (data) {
|
xhr.responseType = 'arraybuffer';
|
||||||
|
|
||||||
|
xhr.onload = function() {
|
||||||
|
if (xhr.status === 200) {
|
||||||
|
var arrayBuffer = xhr.response;
|
||||||
|
var bytes = new Uint8Array(arrayBuffer);
|
||||||
|
var data = '';
|
||||||
|
for (var i = 0; i < bytes.length; i++) {
|
||||||
|
data += String.fromCharCode(bytes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
data = data.replace(/ {4}/g, "");
|
data = data.replace(/ {4}/g, "");
|
||||||
data = data.replace(/\n/g, "\r\n");
|
data = data.replace(/\n/g, "\r\n");
|
||||||
var bytes = new TextEncoder("windows-1252", { NONSTANDARD_allowLegacyEncoding: true }).encode(data);
|
|
||||||
var filename = "rewizor-allegro.epp";
|
var finalBytes = new Uint8Array(data.length);
|
||||||
var blob = new Blob([bytes], { type: "text/csv"});
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
finalBytes[i] = data.charCodeAt(i) & 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
var filename = `rewizor-${source}-${type}.epp`;
|
||||||
|
var blob = new Blob([finalBytes], { type: "text/plain;charset=iso-8859-2"});
|
||||||
|
|
||||||
if (navigator.msSaveBlob) { // IE 10+
|
if (navigator.msSaveBlob) { // IE 10+
|
||||||
navigator.msSaveBlob(blob, filename);
|
navigator.msSaveBlob(blob, filename);
|
||||||
} else {
|
} else {
|
||||||
var link = document.createElement("a");
|
var link = document.createElement("a");
|
||||||
if (link.download !== undefined) { // feature detection
|
if (link.download !== undefined) { // feature detection
|
||||||
// Browsers that support HTML5 download attribute
|
|
||||||
var url = URL.createObjectURL(blob);
|
var url = URL.createObjectURL(blob);
|
||||||
link.setAttribute("href", url);
|
link.setAttribute("href", url);
|
||||||
link.setAttribute("download", filename);
|
link.setAttribute("download", filename);
|
||||||
@@ -48,16 +72,21 @@ function exportToRewizor(source, date, type) {
|
|||||||
link.click();
|
link.click();
|
||||||
document.body.removeChild(link);
|
document.body.removeChild(link);
|
||||||
}
|
}
|
||||||
$.unblockUI();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$.unblockUI();
|
$.unblockUI();
|
||||||
},
|
|
||||||
error: function () {
|
} else {
|
||||||
window.alert("Błąd eksportu.");
|
window.alert("Błąd eksportu.");
|
||||||
$.unblockUI();
|
$.unblockUI();
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
xhr.onerror = function() {
|
||||||
|
window.alert("Błąd eksportu.");
|
||||||
|
$.unblockUI();
|
||||||
|
};
|
||||||
|
|
||||||
|
xhr.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
function blockUI($msg) {
|
function blockUI($msg) {
|
||||||
|
|||||||
@@ -53,14 +53,20 @@ function show()
|
|||||||
function getInvoices($source, $date, $type)
|
function getInvoices($source, $date, $type)
|
||||||
{
|
{
|
||||||
$db = $GLOBALS['db'];
|
$db = $GLOBALS['db'];
|
||||||
if ($source =='') $source = '%';
|
|
||||||
$date .= '%';
|
$date .= '%';
|
||||||
$query = "SELECT i.*, wz.document_no AS wz_document_no, wz.id AS wz_id FROM ecommerce_invoices AS i
|
$query = "SELECT i.*, wz.document_no AS wz_document_no, wz.id AS wz_id FROM ecommerce_invoices AS i
|
||||||
LEFT JOIN ecmstockdocouts AS wz on wz.id = i.ecmstockdocout_id
|
LEFT JOIN ecmstockdocouts AS wz on wz.id = i.ecmstockdocout_id
|
||||||
";
|
";
|
||||||
$query .= " WHERE i.origin LIKE '$source' AND i.register_date LIKE '$date'";
|
$query .= " WHERE i.register_date LIKE '$date'";
|
||||||
if ($type !='') {
|
if ($source != '') {
|
||||||
$query.=" AND i.type='$type'";
|
if ($source == 'baselinker') {
|
||||||
|
$query .= " AND i.origin IN ('allegro', 'shop')";
|
||||||
|
} else {
|
||||||
|
$query .= " AND i.origin = '$source'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($type != '') {
|
||||||
|
$query .= " AND i.type='$type'";
|
||||||
}
|
}
|
||||||
$query .= " ORDER BY i.register_date";
|
$query .= " ORDER BY i.register_date";
|
||||||
$result = $db->query($query);
|
$result = $db->query($query);
|
||||||
@@ -99,10 +105,11 @@ function getDates()
|
|||||||
function getSources() {
|
function getSources() {
|
||||||
$db = $GLOBALS['db'];
|
$db = $GLOBALS['db'];
|
||||||
$sources = array();
|
$sources = array();
|
||||||
$res = $db->query("SELECT DISTINCT origin FROM ecommerce_invoices");
|
$res = $db->query("SELECT DISTINCT origin FROM ecommerce_invoices WHERE origin NOT IN ('allegro', 'shop')");
|
||||||
while ($row = $db->fetchByAssoc($res)) {
|
while ($row = $db->fetchByAssoc($res)) {
|
||||||
$sources[]= $row['origin'];
|
$sources[]= $row['origin'];
|
||||||
}
|
}
|
||||||
|
$sources[] = 'baselinker';
|
||||||
return $sources;
|
return $sources;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,14 +132,13 @@ function exportToRewizor($source, $date, $type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$smarty->assign("data", $invoices);
|
$smarty->assign("data", $invoices);
|
||||||
|
$result = '';
|
||||||
if ($type == 'normal') {
|
if ($type == 'normal') {
|
||||||
$result = $smarty->display(getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor.tpl');
|
$result = $smarty->fetch(getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor.tpl');
|
||||||
} else {
|
} else {
|
||||||
$result = $smarty->display(getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor_fvkor.tpl');
|
$result = $smarty->fetch(getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor_fvkor.tpl');
|
||||||
}
|
}
|
||||||
// encode result as ansi
|
echo mb_convert_encoding($result, 'ISO-8859-2', 'UTF-8');
|
||||||
echo $result;
|
|
||||||
//echo mb_convert_encoding($result, 'ANSI', 'UTF-8');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function brecho($var)
|
function brecho($var)
|
||||||
|
|||||||
@@ -165,6 +165,8 @@ class EcmProduct extends SugarBean {
|
|||||||
var $position_list;
|
var $position_list;
|
||||||
var $th;
|
var $th;
|
||||||
var $ean;
|
var $ean;
|
||||||
|
var $position_list3;
|
||||||
|
var $modified_user_name;
|
||||||
// RELATED FIELDS
|
// RELATED FIELDS
|
||||||
var $created_by;
|
var $created_by;
|
||||||
var $created_by_name;
|
var $created_by_name;
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ class PurchaseCreator{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getPurchases($type){
|
public function getPurchases($type){
|
||||||
$query="select * from documents where document_date>='" . $this->date_from . "' and document_date<='" . $this->date_to . "' and category_id in ('invoice','compain_note','return_note') and deleted=0";
|
//$query = "SELECT * FROM documents WHERE id='790f2a4d-28d7-e135-9be2-68408ca7279a'";
|
||||||
|
//$query="select * from documents where document_date>='" . $this->date_from . "' and document_date<='" . $this->date_to . "' and category_id in ('invoice','compain_note','return_note') and deleted=0";
|
||||||
if ($type == "new") {
|
if ($type == "new") {
|
||||||
$query .= " and exported = 0";
|
$query .= " and exported = 0";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ class EcmSale extends SugarBean {
|
|||||||
var $pdf_type;
|
var $pdf_type;
|
||||||
var $pdf_text;
|
var $pdf_text;
|
||||||
var $ecommerce_invoices;
|
var $ecommerce_invoices;
|
||||||
|
var $vats_summary;
|
||||||
// SUBPANELS RELATED
|
// SUBPANELS RELATED
|
||||||
// MODULE OBJECT DETAILS
|
// MODULE OBJECT DETAILS
|
||||||
var $module_dir = "EcmSales";
|
var $module_dir = "EcmSales";
|
||||||
|
|||||||
@@ -77,6 +77,28 @@ class EcmStockDocIn extends SugarBean {
|
|||||||
var $stock_id;
|
var $stock_id;
|
||||||
var $parent_id;
|
var $parent_id;
|
||||||
var $parent_name;
|
var $parent_name;
|
||||||
|
var $parent_address_street;
|
||||||
|
var $parent_address_postalcode;
|
||||||
|
var $parent_address_city;
|
||||||
|
var $parent_address_country;
|
||||||
|
var $parent_nip;
|
||||||
|
var $status;
|
||||||
|
var $kind;
|
||||||
|
var $total_netto;
|
||||||
|
var $total_brutto;
|
||||||
|
var $canceled;
|
||||||
|
var $country_transport_val;
|
||||||
|
var $foreign_transport_val;
|
||||||
|
var $foreign_transport_cur_id;
|
||||||
|
var $country_transport_cur_id;
|
||||||
|
var $addition_cost_val;
|
||||||
|
var $addition_cost_cur_id;
|
||||||
|
var $currency_id;
|
||||||
|
var $currency_value;
|
||||||
|
var $currency_sad_value;
|
||||||
|
var $vats_summary;
|
||||||
|
var $date_fk;
|
||||||
|
var $fromREST;
|
||||||
// SUBPANELS RELATED
|
// SUBPANELS RELATED
|
||||||
// MODULE OBJECT DETAILS
|
// MODULE OBJECT DETAILS
|
||||||
var $module_dir = "EcmStockDocIns";
|
var $module_dir = "EcmStockDocIns";
|
||||||
|
|||||||
Reference in New Issue
Block a user