Download FV asDocument from E5 CRM; E-Commerce: fix rewizor encoding
This commit is contained in:
@@ -1,37 +1,38 @@
|
||||
<?php
|
||||
// preDb_0dcc87940d3655fa574b253df04ca1c3
|
||||
// %g7!@fG
|
||||
function createPzFromInvoice($record, $stockId) {
|
||||
function createPzFromInvoice($record, $stockId)
|
||||
{
|
||||
global $app_list_strings;
|
||||
$db = $GLOBALS['db'];
|
||||
|
||||
if ($stockId == null) {
|
||||
die('Nie wskazano magazynu');
|
||||
} 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) {
|
||||
die("Wskazano błedny magazyn");
|
||||
}
|
||||
}
|
||||
|
||||
$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_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);
|
||||
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 PZ w Twinpol<br>';
|
||||
echo 'Numer faktury: '.$inv->document_no.'<br>';
|
||||
echo 'Na magazyn: '.$stock['name'].' (ID: '.$stock['id'].')<br><br>';
|
||||
echo 'Numer faktury: ' . $inv->document_no . '<br>';
|
||||
echo 'Na magazyn: ' . $stock['name'] . ' (ID: ' . $stock['id'] . ')<br><br>';
|
||||
|
||||
//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) {
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -74,14 +75,14 @@ function createPzFromInvoice($record, $stockId) {
|
||||
$pz->fromREST = true;
|
||||
|
||||
$gotAllProducts = true; // hope :)
|
||||
foreach ( $inv->position_list as $product ) {
|
||||
echo 'Produkt: '.$product->product_code.'<br>';
|
||||
foreach ($inv->position_list as $product) {
|
||||
echo 'Produkt: ' . $product->product_code . '<br>';
|
||||
$p = getProduct($product->product_code);
|
||||
if (!$p) {
|
||||
echo ' Produkt nie istnieje w bazie TWINPOL<br>';
|
||||
$gotAllProducts = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// add to pz
|
||||
$prod = array();
|
||||
$prod['date_entered'] = date('Y-m-d H:i:s');
|
||||
@@ -96,9 +97,9 @@ function createPzFromInvoice($record, $stockId) {
|
||||
$prod['product_code'] = $p->code;
|
||||
$prod['name'] = $p->name;
|
||||
$prod['quantity'] = $product->quantity;
|
||||
$prod['price'] = $product->price_netto;
|
||||
$prod['price_fk'] = $product->price_netto;
|
||||
$prod['total'] = $product->total_netto;
|
||||
$prod['price'] = $product->price_netto;
|
||||
$prod['price_fk'] = $product->price_netto;
|
||||
$prod['total'] = $product->total_netto;
|
||||
$prod['unit_id'] = $product->unit_id;
|
||||
$prod['unit_name'] = $product->unit_name;
|
||||
$prod['ecmproductcategory_id'] = $p->product_category_id;
|
||||
@@ -115,7 +116,7 @@ function createPzFromInvoice($record, $stockId) {
|
||||
die();
|
||||
} else {
|
||||
$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();
|
||||
}
|
||||
}
|
||||
@@ -133,12 +134,13 @@ function sendStocks()
|
||||
}
|
||||
echo json_encode($stocks);
|
||||
}
|
||||
function sendSale($record) {
|
||||
function sendSale($record)
|
||||
{
|
||||
require_once('modules/EcmSales/EcmSale.php');
|
||||
$sale = new EcmSale();
|
||||
$sale->retrieve($record);
|
||||
$pl = $sale->getPositionList();
|
||||
$response = array (
|
||||
$response = array(
|
||||
'document_no' => $sale->document_no,
|
||||
'name' => $sale->name,
|
||||
'parent_document_no' => $sale->parent_document_no,
|
||||
@@ -167,15 +169,86 @@ function sendSale($record) {
|
||||
);
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
function updateSaleE5Number($record, $e5_record, $e5_document_no) {
|
||||
function updateSaleE5Number($record, $e5_record, $e5_document_no)
|
||||
{
|
||||
$db = $GLOBALS['db'];
|
||||
$db->query("UPDATE ecmsales SET edi_zs_id='$e5_record', edi_zs_document_no='$e5_document_no' WHERE id='$record'");
|
||||
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
|
||||
function getProduct($code) {
|
||||
function getProduct($code)
|
||||
{
|
||||
$db = $GLOBALS['db'];
|
||||
$res = $db->fetchByAssoc($db->query("SELECT * FROM ecmproducts WHERE code='$code' AND deleted=0"));
|
||||
if (!$res) {
|
||||
@@ -187,6 +260,7 @@ function getProduct($code) {
|
||||
return $prod;
|
||||
}
|
||||
}
|
||||
/*
|
||||
function createProduct($record) {
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET' );
|
||||
@@ -221,11 +295,21 @@ function createProduct($record) {
|
||||
//$new->save();
|
||||
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>';
|
||||
var_dump($msg);
|
||||
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':
|
||||
updateSaleE5Number($_GET['record'], $_GET['e5_record'], $_GET['e5_document_no']);
|
||||
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 $is_template;
|
||||
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.
|
||||
var $revision;
|
||||
var $last_rev_create_date;
|
||||
@@ -354,6 +361,7 @@ class Document extends SugarBean {
|
||||
$return_array [] = $w;
|
||||
}
|
||||
$json = getJSONobj();
|
||||
var_dump($return_array);
|
||||
return $array ? $return_array : $json->encode($return_array);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
if (! defined ( 'sugarEntry' ) || ! sugarEntry)
|
||||
die ( 'Not A Valid Entry Point' );
|
||||
if (! defined('sugarEntry') || ! sugarEntry)
|
||||
die('Not A Valid Entry Point');
|
||||
/**
|
||||
* *******************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
@@ -38,459 +38,463 @@ if (! defined ( 'sugarEntry' ) || ! sugarEntry)
|
||||
* "Powered by SugarCRM".
|
||||
* ******************************************************************************
|
||||
*/
|
||||
$dictionary ['Document'] = array (
|
||||
'table' => 'documents',
|
||||
'fields' => array (
|
||||
|
||||
// add mz
|
||||
'value' => array (
|
||||
'name' => 'value',
|
||||
'vname' => 'LBL_VALUE',
|
||||
'type' => 'varchar',
|
||||
'required'=>true,
|
||||
|
||||
),
|
||||
'left_paid' => array (
|
||||
'name' => 'left_paid',
|
||||
'vname' => 'LBL_VALUE_PAID',
|
||||
'type' => 'varchar',
|
||||
|
||||
),
|
||||
'parent_type' => array (
|
||||
'name' => 'parent_type',
|
||||
'vname' => 'LBL_PARENT_NAME',
|
||||
'type' => 'varchar',
|
||||
'source' => 'non-db',
|
||||
'required' => false,
|
||||
'reportable' => false,
|
||||
'len' => '25',
|
||||
'comment' => 'The Sugar object to which the call is related'
|
||||
),
|
||||
'currency_id' => array (
|
||||
'name' => 'currency_id',
|
||||
'type' => 'enum',
|
||||
'options' => 'currency_dom',
|
||||
'label' => 'LBL_CURRENCY',
|
||||
'len' => 36
|
||||
),
|
||||
'document_type' => array (
|
||||
'name' => 'document_type',
|
||||
'type' => 'enum',
|
||||
'options' => 'document_type_enum',
|
||||
'default'=>'k',
|
||||
'label' => 'Typ faktury',
|
||||
'required'=>true,
|
||||
'len' => 45
|
||||
),
|
||||
'transaction_type' => array (
|
||||
'name' => 'transaction_type',
|
||||
'type' => 'enum',
|
||||
'options' => 'transaction_type3_dom',
|
||||
'size' => 3,
|
||||
'default'=>'1',
|
||||
'vname'=>'Typ transakcji',
|
||||
'label' => 'Typ transakcji',
|
||||
'required'=>true,
|
||||
'len' => 45
|
||||
),
|
||||
'currency_value' => array (
|
||||
'name' => 'currency_value',
|
||||
'type' => 'varchar',
|
||||
'vname' => 'LBL_CURRENCY_VALUE',
|
||||
'reportable' => false,
|
||||
'required' => false
|
||||
),
|
||||
'parent_name' => array (
|
||||
'name' => 'parent_name',
|
||||
|
||||
'type_name' => 'parent_type',
|
||||
'id_name' => 'parent_id',
|
||||
'vname' => 'LBL_LIST_RELATED_TO',
|
||||
'type' => 'parent',
|
||||
|
||||
'source' => 'non-db',
|
||||
'options' => 'parent_type_display2'
|
||||
),
|
||||
'corrected_document_name' => array (
|
||||
'name' => 'corrected_document_name',
|
||||
'vname' => 'Korekta do dokumentu',
|
||||
'rname'=>'document_name',
|
||||
'type' => 'varchar',
|
||||
'group' => 'corrected_document_name',
|
||||
'dbtype' => 'varchar',
|
||||
'len' => '255',
|
||||
'massupdate' => false,
|
||||
'required' => false
|
||||
),
|
||||
'parent_id' => array (
|
||||
'name' => 'parent_id',
|
||||
'type' => 'id',
|
||||
'group' => 'parent_name',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db',
|
||||
'vname' => 'LBL_PARENT_ID'
|
||||
),
|
||||
|
||||
'document_name' => array (
|
||||
'name' => 'document_name',
|
||||
'vname' => 'LBL_NAME',
|
||||
'type' => 'varchar',
|
||||
|
||||
'len' => '255',
|
||||
'required' => true,
|
||||
'importable' => 'required'
|
||||
),
|
||||
'name' => array (
|
||||
'name' => 'name',
|
||||
'vname' => 'LBL_NAME',
|
||||
'source' => 'non-db',
|
||||
'type' => 'varchar'
|
||||
),
|
||||
'filename' => array (
|
||||
'name' => 'filename',
|
||||
'vname' => 'LBL_FILENAME',
|
||||
'type' => 'file',
|
||||
'source' => 'non-db',
|
||||
'comment' => 'The filename of the document attachment',
|
||||
'required' => false
|
||||
),
|
||||
|
||||
'uploadfile' => array (
|
||||
'name' => 'uploadfile',
|
||||
'required' => false,
|
||||
'vname' => 'LBL_FILENAME',
|
||||
'type' => 'file',
|
||||
'source' => 'non-db'
|
||||
),
|
||||
|
||||
'active_date' => array (
|
||||
'name' => 'active_date',
|
||||
'vname' => 'LBL_DOC_ACTIVE_DATE',
|
||||
'type' => 'date',
|
||||
'importable' => 'required',
|
||||
'required' => true
|
||||
),
|
||||
|
||||
'exp_date' => array (
|
||||
'name' => 'exp_date',
|
||||
'vname' => 'LBL_DOC_EXP_DATE',
|
||||
'type' => 'date'
|
||||
),
|
||||
|
||||
'category_id' => array (
|
||||
'name' => 'category_id',
|
||||
'vname' => 'LBL_SF_CATEGORY',
|
||||
'type' => 'enum',
|
||||
'len' => '25',
|
||||
'options' => 'document_category_dom',
|
||||
'reportable' => false
|
||||
),
|
||||
|
||||
'subcategory_id' => array (
|
||||
'name' => 'subcategory_id',
|
||||
'vname' => 'LBL_SF_SUBCATEGORY',
|
||||
'type' => 'enum',
|
||||
'len' => '25',
|
||||
'options' => 'document_subcategory_dom',
|
||||
'reportable' => false
|
||||
),
|
||||
'payment_date' => array (
|
||||
'name' => 'payment_date',
|
||||
'vname' => 'LBL_PAYMENT_DATE',
|
||||
'type' => 'date',
|
||||
'reportable' => false,
|
||||
'showFormats' => true,
|
||||
'massupdate' => false,
|
||||
'required' => false
|
||||
),
|
||||
'status_id' => array (
|
||||
'name' => 'status_id',
|
||||
'vname' => 'LBL_DOC_STATUS',
|
||||
'type' => 'enum',
|
||||
'len' => '25',
|
||||
'options' => 'document_status_dom',
|
||||
'reportable' => false
|
||||
),
|
||||
|
||||
$dictionary['Document'] = array(
|
||||
'table' => 'documents',
|
||||
'fields' => array(
|
||||
|
||||
// add mz
|
||||
'value' => array(
|
||||
'name' => 'value',
|
||||
'vname' => 'LBL_VALUE',
|
||||
'type' => 'varchar',
|
||||
'required' => true,
|
||||
|
||||
|
||||
'document_revision_id' => array (
|
||||
'name' => 'document_revision_id',
|
||||
'vname' => 'LBL_LATEST_REVISION',
|
||||
'type' => 'varchar',
|
||||
'len' => '36',
|
||||
'reportable' => false,
|
||||
'required' => false
|
||||
),
|
||||
|
||||
'revisions' => array (
|
||||
'name' => 'revisions',
|
||||
'type' => 'link',
|
||||
'relationship' => 'document_revisions',
|
||||
'source' => 'non-db',
|
||||
'vname' => 'LBL_REVISIONS',
|
||||
'required' => false
|
||||
),
|
||||
|
||||
'revision' => array (
|
||||
'name' => 'revision',
|
||||
'vname' => 'LBL_DOC_VERSION',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'required' => true,
|
||||
'source' => 'non-db',
|
||||
'importable' => 'required',
|
||||
'required' => true
|
||||
),
|
||||
|
||||
'last_rev_created_name' => array (
|
||||
'name' => 'last_rev_created_name',
|
||||
'vname' => 'LBL_LAST_REV_CREATOR',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'last_rev_mime_type' => array (
|
||||
'name' => 'last_rev_mime_type',
|
||||
'vname' => 'LBL_LAST_REV_MIME_TYPE',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'studio' => 'false',
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'latest_revision' => array (
|
||||
'name' => 'latest_revision',
|
||||
'vname' => 'LBL_LATEST_REVISION',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'last_rev_create_date' => array (
|
||||
'name' => 'last_rev_create_date',
|
||||
'type' => 'date',
|
||||
'table' => 'document_revisions',
|
||||
'link' => 'revisions',
|
||||
'join_name' => 'document_revisions',
|
||||
'vname' => 'LBL_LAST_REV_CREATE_DATE',
|
||||
'rname' => 'date_entered',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'contracts' => array (
|
||||
'name' => 'contracts',
|
||||
'type' => 'link',
|
||||
'relationship' => 'contracts_documents',
|
||||
'source' => 'non-db',
|
||||
'vname' => 'LBL_CONTRACTS'
|
||||
),
|
||||
// todo remove
|
||||
'leads' => array (
|
||||
'name' => 'leads',
|
||||
'type' => 'link',
|
||||
'relationship' => 'leads_documents',
|
||||
'source' => 'non-db',
|
||||
'vname' => 'LBL_LEADS'
|
||||
),
|
||||
|
||||
'related_doc_id' => array (
|
||||
'name' => 'related_doc_id',
|
||||
'vname' => 'LBL_RELATED_DOCUMENT_ID',
|
||||
'reportable' => false,
|
||||
'dbType' => 'id',
|
||||
'type' => 'varchar',
|
||||
'len' => '36'
|
||||
),
|
||||
|
||||
'related_doc_name' => array (
|
||||
'name' => 'related_doc_name',
|
||||
'vname' => 'LBL_DET_RELATED_DOCUMENT',
|
||||
'type' => 'relate',
|
||||
'table' => 'documents',
|
||||
'id_name' => 'related_doc_id',
|
||||
'module' => 'Documents',
|
||||
'source' => 'non-db',
|
||||
'comment' => 'The related document name for Meta-Data framework'
|
||||
),
|
||||
|
||||
'related_doc_rev_id' => array (
|
||||
'name' => 'related_doc_rev_id',
|
||||
'vname' => 'LBL_RELATED_DOCUMENT_REVISION_ID',
|
||||
'reportable' => false,
|
||||
'dbType' => 'id',
|
||||
'type' => 'varchar',
|
||||
'len' => '36'
|
||||
),
|
||||
|
||||
'related_doc_rev_number' => array (
|
||||
'name' => 'related_doc_rev_number',
|
||||
'vname' => 'LBL_DET_RELATED_DOCUMENT_VERSION',
|
||||
'type' => 'varchar',
|
||||
'source' => 'non-db',
|
||||
'comment' => 'The related document version number for Meta-Data framework'
|
||||
),
|
||||
|
||||
'is_template' => array (
|
||||
'name' => 'is_template',
|
||||
'vname' => 'LBL_IS_TEMPLATE',
|
||||
'type' => 'bool',
|
||||
'default' => 0,
|
||||
'reportable' => false
|
||||
),
|
||||
'accepted' => array (
|
||||
'name' => 'accepted',
|
||||
'vname' => 'LBL_TO_ACCEPT',
|
||||
'type' => 'enum',
|
||||
'source' => 'non-db',
|
||||
'default' => 0,
|
||||
'options' => 'document_user_status_dom',
|
||||
'reportable' => false
|
||||
),
|
||||
'status' => array (
|
||||
'name' => 'status',
|
||||
'vname' => 'Status',
|
||||
'type' => 'enum',
|
||||
|
||||
'options' => 'status_user_status_dom',
|
||||
'reportable' => false,
|
||||
'required'=>true
|
||||
),
|
||||
'date_start' => array (
|
||||
'name' => 'date_start',
|
||||
'vname' => 'LBL_DATE_START',
|
||||
'type' => 'date',
|
||||
'source' => 'non-db',
|
||||
'default' => 0,
|
||||
'reportable' => false
|
||||
),
|
||||
'date_end' => array (
|
||||
'name' => 'date_end',
|
||||
'vname' => 'LBL_DATE_END',
|
||||
'type' => 'date',
|
||||
'source' => 'non-db',
|
||||
'default' => 0,
|
||||
'reportable' => false
|
||||
),
|
||||
'template_type' => array (
|
||||
'name' => 'template_type',
|
||||
'vname' => 'LBL_TEMPLATE_TYPE',
|
||||
'type' => 'enum',
|
||||
'len' => '25',
|
||||
'options' => 'document_template_type_dom',
|
||||
'reportable' => false
|
||||
),
|
||||
// BEGIN field used for contract document subpanel.
|
||||
'latest_revision_name' => array (
|
||||
'name' => 'latest_revision_name',
|
||||
'vname' => 'LBL_LASTEST_REVISION_NAME',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
|
||||
'selected_revision_name' => array (
|
||||
'name' => 'selected_revision_name',
|
||||
'vname' => 'LBL_SELECTED_REVISION_NAME',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'contract_status' => array (
|
||||
'name' => 'contract_status',
|
||||
'vname' => 'LBL_CONTRACT_STATUS',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'contract_name' => array (
|
||||
'name' => 'contract_name',
|
||||
'vname' => 'LBL_CONTRACT_NAME',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'linked_id' => array (
|
||||
'name' => 'linked_id',
|
||||
'vname' => 'LBL_LINKED_ID',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'selected_revision_id' => array (
|
||||
'name' => 'selected_revision_id',
|
||||
'vname' => 'LBL_SELECTED_REVISION_ID',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'latest_revision_id' => array (
|
||||
'name' => 'latest_revision_id',
|
||||
'vname' => 'LBL_LATEST_REVISION_ID',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'selected_revision_filename' => array (
|
||||
'name' => 'selected_revision_filename',
|
||||
'vname' => 'LBL_SELECTED_REVISION_FILENAME',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'document_date' => array (
|
||||
'name' => 'document_date',
|
||||
'vname' => 'LBL_DOCUMENT_DATE',
|
||||
'type' => 'date',
|
||||
'reportable' => false,
|
||||
'showFormats' => true,
|
||||
'massupdate' => false,
|
||||
'required' => true
|
||||
)
|
||||
// END fields used for contract documents subpanel.
|
||||
),
|
||||
|
||||
'indices' => array (
|
||||
array (
|
||||
'name' => 'idx_doc_cat',
|
||||
'type' => 'index',
|
||||
'fields' => array (
|
||||
'category_id',
|
||||
'subcategory_id'
|
||||
)
|
||||
)
|
||||
),
|
||||
'relationships' => array (
|
||||
'document_revisions' => array (
|
||||
'lhs_module' => 'Documents',
|
||||
'lhs_table' => 'documents',
|
||||
'lhs_key' => 'id',
|
||||
'rhs_module' => 'Documents',
|
||||
'rhs_table' => 'document_revisions',
|
||||
'rhs_key' => 'document_id',
|
||||
'relationship_type' => 'one-to-many'
|
||||
),
|
||||
|
||||
'documents_modified_user' => array (
|
||||
'lhs_module' => 'Users',
|
||||
'lhs_table' => 'users',
|
||||
'lhs_key' => 'id',
|
||||
'rhs_module' => 'Documents',
|
||||
'rhs_table' => 'documents',
|
||||
'rhs_key' => 'modified_user_id',
|
||||
'relationship_type' => 'one-to-many'
|
||||
),
|
||||
|
||||
'documents_created_by' => array (
|
||||
'lhs_module' => 'Users',
|
||||
'lhs_table' => 'users',
|
||||
'lhs_key' => 'id',
|
||||
'rhs_module' => 'Documents',
|
||||
'rhs_table' => 'documents',
|
||||
'rhs_key' => 'created_by',
|
||||
'relationship_type' => 'one-to-many'
|
||||
)
|
||||
)
|
||||
'left_paid' => array(
|
||||
'name' => 'left_paid',
|
||||
'vname' => 'LBL_VALUE_PAID',
|
||||
'type' => 'varchar',
|
||||
|
||||
),
|
||||
'parent_type' => array(
|
||||
'name' => 'parent_type',
|
||||
'vname' => 'LBL_PARENT_NAME',
|
||||
'type' => 'varchar',
|
||||
'source' => 'non-db',
|
||||
'required' => false,
|
||||
'reportable' => false,
|
||||
'len' => '25',
|
||||
'comment' => 'The Sugar object to which the call is related'
|
||||
),
|
||||
'currency_id' => array(
|
||||
'name' => 'currency_id',
|
||||
'type' => 'enum',
|
||||
'options' => 'currency_dom',
|
||||
'label' => 'LBL_CURRENCY',
|
||||
'len' => 36
|
||||
),
|
||||
'document_type' => array(
|
||||
'name' => 'document_type',
|
||||
'type' => 'enum',
|
||||
'options' => 'document_type_enum',
|
||||
'default' => 'k',
|
||||
'label' => 'Typ faktury',
|
||||
'required' => true,
|
||||
'len' => 45
|
||||
),
|
||||
'transaction_type' => array(
|
||||
'name' => 'transaction_type',
|
||||
'type' => 'enum',
|
||||
'options' => 'transaction_type3_dom',
|
||||
'size' => 3,
|
||||
'default' => '1',
|
||||
'vname' => 'Typ transakcji',
|
||||
'label' => 'Typ transakcji',
|
||||
'required' => true,
|
||||
'len' => 45
|
||||
),
|
||||
'currency_value' => array(
|
||||
'name' => 'currency_value',
|
||||
'type' => 'varchar',
|
||||
'vname' => 'LBL_CURRENCY_VALUE',
|
||||
'reportable' => false,
|
||||
'required' => false
|
||||
),
|
||||
'parent_name' => array(
|
||||
'name' => 'parent_name',
|
||||
|
||||
'type_name' => 'parent_type',
|
||||
'id_name' => 'parent_id',
|
||||
'vname' => 'LBL_LIST_RELATED_TO',
|
||||
'type' => 'parent',
|
||||
|
||||
'source' => 'non-db',
|
||||
'options' => 'parent_type_display2'
|
||||
),
|
||||
'corrected_document_name' => array(
|
||||
'name' => 'corrected_document_name',
|
||||
'vname' => 'Korekta do dokumentu',
|
||||
'rname' => 'document_name',
|
||||
'type' => 'varchar',
|
||||
'group' => 'corrected_document_name',
|
||||
'dbtype' => 'varchar',
|
||||
'len' => '255',
|
||||
'massupdate' => false,
|
||||
'required' => false
|
||||
),
|
||||
'parent_id' => array(
|
||||
'name' => 'parent_id',
|
||||
'type' => 'id',
|
||||
'group' => 'parent_name',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db',
|
||||
'vname' => 'LBL_PARENT_ID'
|
||||
),
|
||||
|
||||
'document_name' => array(
|
||||
'name' => 'document_name',
|
||||
'vname' => 'LBL_NAME',
|
||||
'type' => 'varchar',
|
||||
|
||||
'len' => '255',
|
||||
'required' => true,
|
||||
'importable' => 'required'
|
||||
),
|
||||
'document_number' => array(
|
||||
'name' => 'document_name',
|
||||
'type' => 'varchar',
|
||||
'len' => '45',
|
||||
),
|
||||
'name' => array(
|
||||
'name' => 'name',
|
||||
'vname' => 'LBL_NAME',
|
||||
'source' => 'non-db',
|
||||
'type' => 'varchar'
|
||||
),
|
||||
'filename' => array(
|
||||
'name' => 'filename',
|
||||
'vname' => 'LBL_FILENAME',
|
||||
'type' => 'file',
|
||||
'source' => 'non-db',
|
||||
'comment' => 'The filename of the document attachment',
|
||||
'required' => false
|
||||
),
|
||||
|
||||
'uploadfile' => array(
|
||||
'name' => 'uploadfile',
|
||||
'required' => false,
|
||||
'vname' => 'LBL_FILENAME',
|
||||
'type' => 'file',
|
||||
'source' => 'non-db'
|
||||
),
|
||||
|
||||
'active_date' => array(
|
||||
'name' => 'active_date',
|
||||
'vname' => 'LBL_DOC_ACTIVE_DATE',
|
||||
'type' => 'date',
|
||||
'importable' => 'required',
|
||||
'required' => true
|
||||
),
|
||||
|
||||
'exp_date' => array(
|
||||
'name' => 'exp_date',
|
||||
'vname' => 'LBL_DOC_EXP_DATE',
|
||||
'type' => 'date'
|
||||
),
|
||||
|
||||
'category_id' => array(
|
||||
'name' => 'category_id',
|
||||
'vname' => 'LBL_SF_CATEGORY',
|
||||
'type' => 'enum',
|
||||
'len' => '25',
|
||||
'options' => 'document_category_dom',
|
||||
'reportable' => false
|
||||
),
|
||||
|
||||
'subcategory_id' => array(
|
||||
'name' => 'subcategory_id',
|
||||
'vname' => 'LBL_SF_SUBCATEGORY',
|
||||
'type' => 'enum',
|
||||
'len' => '25',
|
||||
'options' => 'document_subcategory_dom',
|
||||
'reportable' => false
|
||||
),
|
||||
'payment_date' => array(
|
||||
'name' => 'payment_date',
|
||||
'vname' => 'LBL_PAYMENT_DATE',
|
||||
'type' => 'date',
|
||||
'reportable' => false,
|
||||
'showFormats' => true,
|
||||
'massupdate' => false,
|
||||
'required' => false
|
||||
),
|
||||
'status_id' => array(
|
||||
'name' => 'status_id',
|
||||
'vname' => 'LBL_DOC_STATUS',
|
||||
'type' => 'enum',
|
||||
'len' => '25',
|
||||
'options' => 'document_status_dom',
|
||||
'reportable' => false
|
||||
),
|
||||
|
||||
|
||||
|
||||
'document_revision_id' => array(
|
||||
'name' => 'document_revision_id',
|
||||
'vname' => 'LBL_LATEST_REVISION',
|
||||
'type' => 'varchar',
|
||||
'len' => '36',
|
||||
'reportable' => false,
|
||||
'required' => false
|
||||
),
|
||||
|
||||
'revisions' => array(
|
||||
'name' => 'revisions',
|
||||
'type' => 'link',
|
||||
'relationship' => 'document_revisions',
|
||||
'source' => 'non-db',
|
||||
'vname' => 'LBL_REVISIONS',
|
||||
'required' => false
|
||||
),
|
||||
|
||||
'revision' => array(
|
||||
'name' => 'revision',
|
||||
'vname' => 'LBL_DOC_VERSION',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'required' => true,
|
||||
'source' => 'non-db',
|
||||
'importable' => 'required',
|
||||
'required' => true
|
||||
),
|
||||
|
||||
'last_rev_created_name' => array(
|
||||
'name' => 'last_rev_created_name',
|
||||
'vname' => 'LBL_LAST_REV_CREATOR',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'last_rev_mime_type' => array(
|
||||
'name' => 'last_rev_mime_type',
|
||||
'vname' => 'LBL_LAST_REV_MIME_TYPE',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'studio' => 'false',
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'latest_revision' => array(
|
||||
'name' => 'latest_revision',
|
||||
'vname' => 'LBL_LATEST_REVISION',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'last_rev_create_date' => array(
|
||||
'name' => 'last_rev_create_date',
|
||||
'type' => 'date',
|
||||
'table' => 'document_revisions',
|
||||
'link' => 'revisions',
|
||||
'join_name' => 'document_revisions',
|
||||
'vname' => 'LBL_LAST_REV_CREATE_DATE',
|
||||
'rname' => 'date_entered',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'contracts' => array(
|
||||
'name' => 'contracts',
|
||||
'type' => 'link',
|
||||
'relationship' => 'contracts_documents',
|
||||
'source' => 'non-db',
|
||||
'vname' => 'LBL_CONTRACTS'
|
||||
),
|
||||
// todo remove
|
||||
'leads' => array(
|
||||
'name' => 'leads',
|
||||
'type' => 'link',
|
||||
'relationship' => 'leads_documents',
|
||||
'source' => 'non-db',
|
||||
'vname' => 'LBL_LEADS'
|
||||
),
|
||||
|
||||
'related_doc_id' => array(
|
||||
'name' => 'related_doc_id',
|
||||
'vname' => 'LBL_RELATED_DOCUMENT_ID',
|
||||
'reportable' => false,
|
||||
'dbType' => 'id',
|
||||
'type' => 'varchar',
|
||||
'len' => '36'
|
||||
),
|
||||
|
||||
'related_doc_name' => array(
|
||||
'name' => 'related_doc_name',
|
||||
'vname' => 'LBL_DET_RELATED_DOCUMENT',
|
||||
'type' => 'relate',
|
||||
'table' => 'documents',
|
||||
'id_name' => 'related_doc_id',
|
||||
'module' => 'Documents',
|
||||
'source' => 'non-db',
|
||||
'comment' => 'The related document name for Meta-Data framework'
|
||||
),
|
||||
|
||||
'related_doc_rev_id' => array(
|
||||
'name' => 'related_doc_rev_id',
|
||||
'vname' => 'LBL_RELATED_DOCUMENT_REVISION_ID',
|
||||
'reportable' => false,
|
||||
'dbType' => 'id',
|
||||
'type' => 'varchar',
|
||||
'len' => '36'
|
||||
),
|
||||
|
||||
'related_doc_rev_number' => array(
|
||||
'name' => 'related_doc_rev_number',
|
||||
'vname' => 'LBL_DET_RELATED_DOCUMENT_VERSION',
|
||||
'type' => 'varchar',
|
||||
'source' => 'non-db',
|
||||
'comment' => 'The related document version number for Meta-Data framework'
|
||||
),
|
||||
|
||||
'is_template' => array(
|
||||
'name' => 'is_template',
|
||||
'vname' => 'LBL_IS_TEMPLATE',
|
||||
'type' => 'bool',
|
||||
'default' => 0,
|
||||
'reportable' => false
|
||||
),
|
||||
'accepted' => array(
|
||||
'name' => 'accepted',
|
||||
'vname' => 'LBL_TO_ACCEPT',
|
||||
'type' => 'enum',
|
||||
'source' => 'non-db',
|
||||
'default' => 0,
|
||||
'options' => 'document_user_status_dom',
|
||||
'reportable' => false
|
||||
),
|
||||
'status' => array(
|
||||
'name' => 'status',
|
||||
'vname' => 'Status',
|
||||
'type' => 'enum',
|
||||
|
||||
'options' => 'status_user_status_dom',
|
||||
'reportable' => false,
|
||||
'required' => true
|
||||
),
|
||||
'date_start' => array(
|
||||
'name' => 'date_start',
|
||||
'vname' => 'LBL_DATE_START',
|
||||
'type' => 'date',
|
||||
'source' => 'non-db',
|
||||
'default' => 0,
|
||||
'reportable' => false
|
||||
),
|
||||
'date_end' => array(
|
||||
'name' => 'date_end',
|
||||
'vname' => 'LBL_DATE_END',
|
||||
'type' => 'date',
|
||||
'source' => 'non-db',
|
||||
'default' => 0,
|
||||
'reportable' => false
|
||||
),
|
||||
'template_type' => array(
|
||||
'name' => 'template_type',
|
||||
'vname' => 'LBL_TEMPLATE_TYPE',
|
||||
'type' => 'enum',
|
||||
'len' => '25',
|
||||
'options' => 'document_template_type_dom',
|
||||
'reportable' => false
|
||||
),
|
||||
// BEGIN field used for contract document subpanel.
|
||||
'latest_revision_name' => array(
|
||||
'name' => 'latest_revision_name',
|
||||
'vname' => 'LBL_LASTEST_REVISION_NAME',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
|
||||
'selected_revision_name' => array(
|
||||
'name' => 'selected_revision_name',
|
||||
'vname' => 'LBL_SELECTED_REVISION_NAME',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'contract_status' => array(
|
||||
'name' => 'contract_status',
|
||||
'vname' => 'LBL_CONTRACT_STATUS',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'contract_name' => array(
|
||||
'name' => 'contract_name',
|
||||
'vname' => 'LBL_CONTRACT_NAME',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'linked_id' => array(
|
||||
'name' => 'linked_id',
|
||||
'vname' => 'LBL_LINKED_ID',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'selected_revision_id' => array(
|
||||
'name' => 'selected_revision_id',
|
||||
'vname' => 'LBL_SELECTED_REVISION_ID',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'latest_revision_id' => array(
|
||||
'name' => 'latest_revision_id',
|
||||
'vname' => 'LBL_LATEST_REVISION_ID',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'selected_revision_filename' => array(
|
||||
'name' => 'selected_revision_filename',
|
||||
'vname' => 'LBL_SELECTED_REVISION_FILENAME',
|
||||
'type' => 'varchar',
|
||||
'reportable' => false,
|
||||
'source' => 'non-db'
|
||||
),
|
||||
'document_date' => array(
|
||||
'name' => 'document_date',
|
||||
'vname' => 'LBL_DOCUMENT_DATE',
|
||||
'type' => 'date',
|
||||
'reportable' => false,
|
||||
'showFormats' => true,
|
||||
'massupdate' => false,
|
||||
'required' => true
|
||||
)
|
||||
// END fields used for contract documents subpanel.
|
||||
),
|
||||
|
||||
'indices' => array(
|
||||
array(
|
||||
'name' => 'idx_doc_cat',
|
||||
'type' => 'index',
|
||||
'fields' => array(
|
||||
'category_id',
|
||||
'subcategory_id'
|
||||
)
|
||||
)
|
||||
),
|
||||
'relationships' => array(
|
||||
'document_revisions' => array(
|
||||
'lhs_module' => 'Documents',
|
||||
'lhs_table' => 'documents',
|
||||
'lhs_key' => 'id',
|
||||
'rhs_module' => 'Documents',
|
||||
'rhs_table' => 'document_revisions',
|
||||
'rhs_key' => 'document_id',
|
||||
'relationship_type' => 'one-to-many'
|
||||
),
|
||||
|
||||
'documents_modified_user' => array(
|
||||
'lhs_module' => 'Users',
|
||||
'lhs_table' => 'users',
|
||||
'lhs_key' => 'id',
|
||||
'rhs_module' => 'Documents',
|
||||
'rhs_table' => 'documents',
|
||||
'rhs_key' => 'modified_user_id',
|
||||
'relationship_type' => 'one-to-many'
|
||||
),
|
||||
|
||||
'documents_created_by' => array(
|
||||
'lhs_module' => 'Users',
|
||||
'lhs_table' => 'users',
|
||||
'lhs_key' => 'id',
|
||||
'rhs_module' => 'Documents',
|
||||
'rhs_table' => 'documents',
|
||||
'rhs_key' => 'created_by',
|
||||
'relationship_type' => 'one-to-many'
|
||||
)
|
||||
)
|
||||
);
|
||||
VardefManager::createVardef ( 'Documents', 'Document', array (
|
||||
'default'
|
||||
) );
|
||||
?>
|
||||
VardefManager::createVardef('Documents', 'Document', array(
|
||||
'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")){
|
||||
// die('Brak możliwości edycji');
|
||||
}
|
||||
var_dump("TREST");
|
||||
var_dump($this->bean->vats);
|
||||
} else {
|
||||
global $timedate;
|
||||
$format = $timedate->get_cal_date_format();
|
||||
|
||||
@@ -24,22 +24,46 @@ $(document).ready(function () {
|
||||
});
|
||||
|
||||
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...");
|
||||
$.ajax({
|
||||
url: "index.php?module=EcmInvoiceOuts&action=ecommerce&ajax=exportToRewizor&to_pdf=1&source="+source+"&date="+date+"&type="+type,
|
||||
type: "GET",
|
||||
success: function (data) {
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', "index.php?module=EcmInvoiceOuts&action=ecommerce&ajax=exportToRewizor&to_pdf=1&source="+source+"&date="+date+"&type="+type, true);
|
||||
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(/\n/g, "\r\n");
|
||||
var bytes = new TextEncoder("windows-1252", { NONSTANDARD_allowLegacyEncoding: true }).encode(data);
|
||||
var filename = "rewizor-allegro.epp";
|
||||
var blob = new Blob([bytes], { type: "text/csv"});
|
||||
|
||||
var finalBytes = new Uint8Array(data.length);
|
||||
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+
|
||||
navigator.msSaveBlob(blob, filename);
|
||||
} else {
|
||||
var link = document.createElement("a");
|
||||
if (link.download !== undefined) { // feature detection
|
||||
// Browsers that support HTML5 download attribute
|
||||
var url = URL.createObjectURL(blob);
|
||||
link.setAttribute("href", url);
|
||||
link.setAttribute("download", filename);
|
||||
@@ -48,16 +72,21 @@ function exportToRewizor(source, date, type) {
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
$.unblockUI();
|
||||
}
|
||||
|
||||
$.unblockUI();
|
||||
},
|
||||
error: function () {
|
||||
|
||||
} else {
|
||||
window.alert("Błąd eksportu.");
|
||||
$.unblockUI();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
xhr.onerror = function() {
|
||||
window.alert("Błąd eksportu.");
|
||||
$.unblockUI();
|
||||
};
|
||||
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
function blockUI($msg) {
|
||||
|
||||
@@ -53,14 +53,20 @@ function show()
|
||||
function getInvoices($source, $date, $type)
|
||||
{
|
||||
$db = $GLOBALS['db'];
|
||||
if ($source =='') $source = '%';
|
||||
$date .= '%';
|
||||
$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
|
||||
";
|
||||
$query .= " WHERE i.origin LIKE '$source' AND i.register_date LIKE '$date'";
|
||||
if ($type !='') {
|
||||
$query.=" AND i.type='$type'";
|
||||
$query .= " WHERE i.register_date LIKE '$date'";
|
||||
if ($source != '') {
|
||||
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";
|
||||
$result = $db->query($query);
|
||||
@@ -99,10 +105,11 @@ function getDates()
|
||||
function getSources() {
|
||||
$db = $GLOBALS['db'];
|
||||
$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)) {
|
||||
$sources[]= $row['origin'];
|
||||
}
|
||||
$sources[] = 'baselinker';
|
||||
return $sources;
|
||||
}
|
||||
|
||||
@@ -125,14 +132,13 @@ function exportToRewizor($source, $date, $type)
|
||||
}
|
||||
|
||||
$smarty->assign("data", $invoices);
|
||||
$result = '';
|
||||
if ($type == 'normal') {
|
||||
$result = $smarty->display(getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor.tpl');
|
||||
$result = $smarty->fetch(getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor.tpl');
|
||||
} 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 $result;
|
||||
//echo mb_convert_encoding($result, 'ANSI', 'UTF-8');
|
||||
echo mb_convert_encoding($result, 'ISO-8859-2', 'UTF-8');
|
||||
}
|
||||
|
||||
function brecho($var)
|
||||
|
||||
@@ -165,6 +165,8 @@ class EcmProduct extends SugarBean {
|
||||
var $position_list;
|
||||
var $th;
|
||||
var $ean;
|
||||
var $position_list3;
|
||||
var $modified_user_name;
|
||||
// RELATED FIELDS
|
||||
var $created_by;
|
||||
var $created_by_name;
|
||||
|
||||
@@ -14,7 +14,8 @@ class PurchaseCreator{
|
||||
}
|
||||
|
||||
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") {
|
||||
$query .= " and exported = 0";
|
||||
}
|
||||
|
||||
@@ -148,6 +148,7 @@ class EcmSale extends SugarBean {
|
||||
var $pdf_type;
|
||||
var $pdf_text;
|
||||
var $ecommerce_invoices;
|
||||
var $vats_summary;
|
||||
// SUBPANELS RELATED
|
||||
// MODULE OBJECT DETAILS
|
||||
var $module_dir = "EcmSales";
|
||||
|
||||
@@ -77,6 +77,28 @@ class EcmStockDocIn extends SugarBean {
|
||||
var $stock_id;
|
||||
var $parent_id;
|
||||
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
|
||||
// MODULE OBJECT DETAILS
|
||||
var $module_dir = "EcmStockDocIns";
|
||||
|
||||
Reference in New Issue
Block a user