706 lines
24 KiB
PHP
Executable File
706 lines
24 KiB
PHP
Executable File
<?php
|
||
|
||
if (!defined('sugarEntry') || !sugarEntry)
|
||
die('Not A Valid Entry Point');
|
||
|
||
/* * *******************************************************************************
|
||
* SugarCRM is a customer relationship management program developed by
|
||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||
*
|
||
* This program is free software; you can redistribute it and/or modify it under
|
||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||
* Free Software Foundation with the addition of the following permission added
|
||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||
*
|
||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||
* details.
|
||
*
|
||
* You should have received a copy of the GNU Affero General Public License along with
|
||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||
* 02110-1301 USA.
|
||
*
|
||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||
*
|
||
* The interactive user interfaces in modified source and object code versions
|
||
* of this program must display Appropriate Legal Notices, as required under
|
||
* Section 5 of the GNU Affero General Public License version 3.
|
||
*
|
||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||
* technical reasons, the Appropriate Legal Notices must display the words
|
||
*
|
||
* "Powered by SugarCRM".
|
||
* ****************************************************************************** */
|
||
|
||
require_once 'include/upload_file.php';
|
||
|
||
class EcmFkVatTable extends SugarBean {
|
||
|
||
/**
|
||
* Table name.
|
||
*
|
||
* @var stiring
|
||
*/
|
||
var $table_name = "ecmfkvattables";
|
||
|
||
/**
|
||
* Object name.
|
||
*
|
||
* @var stiring
|
||
*/
|
||
var $object_name = "EcmFkVatTable";
|
||
|
||
/**
|
||
* Additional column fields.
|
||
*
|
||
* @var stiring
|
||
*/
|
||
var $additional_column_fields = array();
|
||
|
||
/**
|
||
* Module directory.
|
||
*
|
||
* @var stiring
|
||
*/
|
||
var $module_dir = 'EcmFkVatTables';
|
||
|
||
/**
|
||
* Relationship fields.
|
||
*
|
||
* @var stiring
|
||
*/
|
||
var $relationship_fields = array();
|
||
|
||
function EcmFkVatTable() {
|
||
parent::SugarBean();
|
||
$this->setupCustomFields('EcmFkVatTables');
|
||
}
|
||
|
||
function save($check_notify = false) {
|
||
if (empty($this->id) || $this->new_with_id) {
|
||
if (false) { //!empty($this->uploadfile))
|
||
$this->filename = $this->uploadfile;
|
||
|
||
if (empty($this->id)) {
|
||
$this->id = create_guid();
|
||
$this->new_with_id = true;
|
||
}
|
||
|
||
$Revision = new EcmFkVatTableRevision();
|
||
//save revision.
|
||
$Revision->change_log = translate('DEF_CREATE_LOG', 'EcmFkVatTables');
|
||
$Revision->revision = $this->revision;
|
||
$Revision->ecmfkvattable_id = $this->id;
|
||
$Revision->filename = $this->filename;
|
||
$Revision->file_ext = $this->file_ext;
|
||
$Revision->file_mime_type = $this->file_mime_type;
|
||
$Revision->save();
|
||
|
||
//Move file saved during populatefrompost to match the revision id rather than ecmfkvattable id
|
||
rename(UploadFile :: get_url($this->filename, $this->id), UploadFile :: get_url($this->filename, $Revision->id));
|
||
|
||
//update ecmfkvattable with latest revision id
|
||
$this->process_save_dates = false; //make sure that conversion does not happen again.
|
||
$this->ecmfkvattable_revision_id = $Revision->id;
|
||
}
|
||
|
||
//set relationship field values if contract_id is passed (via subpanel create)
|
||
if (!empty($_POST['contract_id'])) {
|
||
$save_revision['ecmfkvattable_revision_id'] = $this->document_revision_id;
|
||
$this->load_relationship('contracts');
|
||
$this->contracts->add($_POST['contract_id'], $save_revision);
|
||
}
|
||
|
||
if ((isset($_POST['load_signed_id']) and !empty($_POST['load_signed_id']))) {
|
||
$query = "update linked_ecmfkvattables set deleted=1 where id='" . $_POST['load_signed_id'] . "'";
|
||
$this->db->query($query);
|
||
}
|
||
|
||
}
|
||
|
||
$return_id = parent::save($check_notify);
|
||
$this->savePositions($return_id);
|
||
|
||
return $return_id;
|
||
}
|
||
|
||
function savePositions($id = null, $position_list = null) {
|
||
global $current_user, $timedate;
|
||
|
||
if ($position_list == null)
|
||
$position_list = $this->position_list;
|
||
|
||
if ($id == null)
|
||
$id = $this->id;
|
||
|
||
if (count($position_list) > 0)
|
||
$this->deleteAssignedPositions($id);
|
||
|
||
|
||
$arr = array();
|
||
$position = 0;
|
||
|
||
// dump($position_list);
|
||
// exit;
|
||
|
||
for ($i = 0; $i < count($position_list); $i++) {
|
||
$p = $position_list[$i];
|
||
|
||
$arr = array(
|
||
'id' => create_guid(),
|
||
'deleted' => '0',
|
||
'date_entered' => date('Y-m-d'),
|
||
// 'date_modified' => '',
|
||
'created_by' => 'd9c0007b-1247-5e82-31b6-4f168a01d290',
|
||
// 'modified_user_id' => '',
|
||
|
||
'ecmfkvattable_id' => $id,
|
||
'ecmfkvatkind_id' => $p['ecmfkvatkind_id'],
|
||
|
||
'acc_wn' => $wn = $p['i_acc_wn'],
|
||
'acc_ma' => $ma = $p['i_acc_ma'],
|
||
'account_acc_wn' => !$wn ? $p['i_account_acc_wn'] : '0',
|
||
'account_acc_ma' => !$ma ? $p['i_account_acc_ma'] : '0',
|
||
'zal_wn' => 0,
|
||
'zal_ma' => 0,
|
||
);
|
||
|
||
// dump($arr);
|
||
// exit;
|
||
$q = $this->constructInsertQuery($arr);
|
||
// 4389e866-abab-68bf-4b02-51ee268865c5
|
||
// dump($arr, $q);
|
||
// exit;
|
||
|
||
$this->db->query($q);
|
||
|
||
$position++;
|
||
}
|
||
|
||
return $position;
|
||
}
|
||
|
||
function constructInsertQuery($data, $table = '') {
|
||
|
||
if ($table == '' && isset($this->object_name) && $this->object_name != '') {
|
||
$table = strtolower($this->object_name) . "items";
|
||
}
|
||
else
|
||
return "";
|
||
|
||
$keys = array();
|
||
$values = array();
|
||
foreach ($data as $key => $value) {
|
||
$keys[] = $key;
|
||
if (is_array($value))
|
||
$values[] = $value[1] . str_replace("'", "\'", $value[0]) . $value[1];
|
||
else
|
||
$values[] = "'" . str_replace("'", "\'", $value) . "'";
|
||
}
|
||
|
||
$q = "insert into `$table` (`";
|
||
$q .= implode('`, `', $keys);
|
||
$q .= "`) values (";
|
||
$q .= implode(", ", $values);
|
||
$q .= ");";
|
||
return $q;
|
||
}
|
||
|
||
function deleteAssignedPositions() {
|
||
if (isset($this->id) && $this->id != '') {
|
||
//$query = "DELETE FROM `".strtolower($this->object_name)."itemsparams` WHERE `".strtolower($this->object_name)."_id`='".$this->id."'";
|
||
// $r = $this->db->query($query);
|
||
$query = "DELETE FROM `" . strtolower($this->object_name) . "items` WHERE `" . strtolower($this->object_name) . "_id`='" . $this->id . "'";
|
||
// echo $query;exit;
|
||
$r = $this->db->query($query);
|
||
|
||
if ($r) {
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
function DrawMainPDF($pdf, $type) {
|
||
global $mod_strings;
|
||
|
||
// echo $this->template->getTemplateFile('subheader_' . $type . '.php');
|
||
// exit;
|
||
// dump(get_class($pdf));exit;
|
||
// $pdf->SetAutoPageBreak(false);
|
||
$pdf->SetAutoPageBreak(true, $this->bMargin + $this->tMarign + 25);
|
||
|
||
switch (strtolower($type)) {
|
||
default:
|
||
include($this->template->getTemplateFile('subheader_d.php'));
|
||
include($this->template->getTemplateFile('subfooter_d.php'));
|
||
break;
|
||
|
||
case 'ac':
|
||
case 'r':
|
||
case 'd':
|
||
case 'pk1':
|
||
case 'pk2':
|
||
case 'pk3':
|
||
case 's_symbol1':
|
||
case 's_symbol2':
|
||
case 's_identifier1':
|
||
case 's_identifier2':
|
||
include($this->template->getTemplateFile('subheader_' . $type . '.php'));
|
||
include($this->template->getTemplateFile('subfooter_' . $type . '.php'));
|
||
|
||
break;
|
||
}
|
||
|
||
return;
|
||
}
|
||
|
||
/**
|
||
* Pdf getter.
|
||
*
|
||
* Retrieve pdf stream.
|
||
*/
|
||
function getPDF($id = null, $method = 'I', $name = null, $type = null) {
|
||
global $sugar_config;
|
||
|
||
// if ($id != null) {
|
||
// $this->retrieve($id);
|
||
// if ($this->id == '')
|
||
// return;
|
||
// }
|
||
|
||
global $mod_strings;
|
||
|
||
require_once('modules/EcmTexts/EcmText.php');
|
||
|
||
//echo '<pre>' . var_export($this->ecmlanguage, true) . '</pre>';exit;
|
||
// if (isset($this->ecmlanguage) && $this->ecmlanguage != '') {
|
||
// $data = EcmText::LoadText(null, null, "EcmServices", $this->ecmlanguage);
|
||
// if (isset($data[0]) && isset($data[0]['data']) && isset($data[0]['data']['labels'])) {
|
||
// $data = $data[0]['data']['labels'];
|
||
// foreach ($data as $key => $value) {
|
||
// $mod_strings[$value['label']] = $value['translation'];
|
||
// }
|
||
// }
|
||
// }
|
||
|
||
|
||
$this->format_all_fields();
|
||
|
||
// dump(__LINE__);
|
||
// exit;
|
||
|
||
$this->setTemplate();
|
||
|
||
|
||
$type = $type ? : @$_REQUEST['type'];
|
||
|
||
// if (isset($this->template->id) && $this->template->id != '') {
|
||
// dump($this->template_id);
|
||
// exit;
|
||
// dump($this->template_id);
|
||
// exit;
|
||
|
||
switch (strtolower($type)) {
|
||
default:
|
||
case 'ac':
|
||
case 'd':
|
||
$this->template->setPDF($this->template_id, array('L'));
|
||
break;
|
||
case 'r':
|
||
case 'pk1':
|
||
case 'pk2':
|
||
case 'pk3':
|
||
$this->template->setPDF($this->template_id, array('P'));
|
||
break;
|
||
}
|
||
|
||
// dump(__LINE__);
|
||
// exit;
|
||
// dump($this->template);
|
||
// exit;
|
||
// $this->template->pdf->SetAutoPageBreak(true, 40);
|
||
|
||
$this->DrawMainPDF($this->template->pdf, $type);
|
||
|
||
$this->template->outputPDF(1, $method);
|
||
// }
|
||
}
|
||
|
||
function setTemplate() {
|
||
|
||
// if (!isset($this->template_id) || $this->template_id == '')
|
||
// return null;
|
||
// if (isset($this->template))
|
||
// return $this->template;
|
||
|
||
|
||
require_once('modules/EcmDocumentTemplates/EcmDocumentTemplate.php');
|
||
|
||
$this->template = new EcmDocumentTemplate();
|
||
|
||
$this->template_id = "ef0c4dea-ddf3-de51-9d08-512257d4b675";
|
||
//$this->template->retrieve($this->template_id);
|
||
$this->template->retrieve($this->template_id, true, false);
|
||
|
||
if (isset($this->template->id) && $this->template->id != '') {
|
||
|
||
$this->template->format_all_fields();
|
||
}
|
||
else
|
||
$this->template = null;
|
||
|
||
|
||
// dump($this->template);
|
||
// exit;
|
||
|
||
return $this->template;
|
||
}
|
||
|
||
function get_summary_text() {
|
||
return "$this->ecmfkvattable_name";
|
||
}
|
||
|
||
function is_authenticated() {
|
||
return $this->authenticated;
|
||
}
|
||
|
||
function fill_in_additional_list_fields() {
|
||
$this->fill_in_additional_detail_fields();
|
||
}
|
||
|
||
function fill_in_additional_detail_fields() {
|
||
// $vatYear = DateTime::createFromFormat('Y-m-d', $this->date_document);
|
||
// $this->vat_year = $vatYear ? $bookYear->format('Y') : false;
|
||
|
||
goto jump;
|
||
|
||
global $theme;
|
||
global $current_language;
|
||
global $timedate;
|
||
global $locale;
|
||
|
||
parent::fill_in_additional_detail_fields();
|
||
|
||
$mod_strings = return_module_language($current_language, 'EcmFkVatTables');
|
||
|
||
$query = "SELECT filename,revision,file_ext FROM ecmfkvattable_revisions WHERE id='$this->document_revision_id'";
|
||
|
||
$result = $this->db->query($query);
|
||
$row = $this->db->fetchByAssoc($result);
|
||
|
||
//popuplate filename
|
||
if (isset($row['filename']))
|
||
$this->filename = $row['filename'];
|
||
//$this->latest_revision = $row['revision'];
|
||
if (isset($row['revision']))
|
||
$this->revision = $row['revision'];
|
||
|
||
//populate the file url.
|
||
//image is selected based on the extension name <ext>_icon_inline, extension is stored in ecmfkvattable_revisions.
|
||
//if file is not found then default image file will be used.
|
||
global $img_name;
|
||
global $img_name_bare;
|
||
if (!empty($row['file_ext'])) {
|
||
$img_name = SugarThemeRegistry::current()->getImageURL(strtolower($row['file_ext']) . "_image_inline.gif");
|
||
$img_name_bare = strtolower($row['file_ext']) . "_image_inline";
|
||
}
|
||
|
||
//set default file name.
|
||
if (!empty($img_name) && file_exists($img_name)) {
|
||
$img_name = $img_name_bare;
|
||
} else {
|
||
$img_name = "def_image_inline"; //todo change the default image.
|
||
}
|
||
if ($this->ACLAccess('DetailView')) {
|
||
$this->file_url = "<a href='index.php?entryPoint=download&id=" . basename(UploadFile :: get_url($this->filename, $this->ecmfkvattable_revision_id)) . "&type=EcmFkVatTables' target='_blank'>" . SugarThemeRegistry::current()->getImage($img_name, 'alt="' . $mod_strings['LBL_LIST_VIEW_DOCUMENT'] . '" border="0"') . "</a>";
|
||
$this->file_url_noimage = basename(UploadFile :: get_url($this->filename, $this->ecmfkvattable_revision_id));
|
||
} else {
|
||
$this->file_url = "";
|
||
$this->file_url_noimage = "";
|
||
}
|
||
|
||
//get last_rev_by user name.
|
||
$query = "SELECT first_name,last_name, ecmfkvattable_revisions.date_entered as rev_date FROM users, document_revisions WHERE users.id = document_revisions.created_by and document_revisions.id = '$this->document_revision_id'";
|
||
$result = $this->db->query($query, true, "Eror fetching user name: ");
|
||
$row = $this->db->fetchByAssoc($result);
|
||
if (!empty($row)) {
|
||
$this->last_rev_created_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name']);
|
||
|
||
$this->last_rev_create_date = $timedate->to_display_date_time($row['rev_date']);
|
||
}
|
||
|
||
global $app_list_strings;
|
||
if (!empty($this->status_id)) {
|
||
//_pp($this->status_id);
|
||
$this->status = $app_list_strings['ecmfkvattable_status_dom'][$this->status_id];
|
||
}
|
||
$this->related_doc_name = EcmFkVatTable::get_ecmfkvattable_name($this->related_doc_id);
|
||
$this->related_doc_rev_number = EcmFkVatTableRevision::get_ecmfkvattable_revision_name($this->related_doc_rev_id);
|
||
$this->save_file = basename($this->file_url_noimage);
|
||
|
||
jump:
|
||
}
|
||
|
||
function list_view_parse_additional_sections(& $list_form, $xTemplateSection) {
|
||
return $list_form;
|
||
}
|
||
|
||
function create_export_query(&$order_by, &$where, $relate_link_join = '') {
|
||
$custom_join = $this->custom_fields->getJOIN(true, true, $where);
|
||
if ($custom_join)
|
||
$custom_join['join'] .= $relate_link_join;
|
||
$query = "SELECT
|
||
ecmfkvattables.*";
|
||
if ($custom_join) {
|
||
$query .= $custom_join['select'];
|
||
}
|
||
$query .= " FROM ecmfkvattables ";
|
||
if ($custom_join) {
|
||
$query .= $custom_join['join'];
|
||
}
|
||
|
||
$where_auto = " ecmfkvattables.deleted = 0";
|
||
|
||
if ($where != "")
|
||
$query .= " WHERE $where AND " . $where_auto;
|
||
else
|
||
$query .= " WHERE " . $where_auto;
|
||
|
||
if ($order_by != "")
|
||
$query .= " ORDER BY $order_by";
|
||
else
|
||
$query .= " ORDER BY ecmfkvattables.document_name";
|
||
|
||
return $query;
|
||
}
|
||
|
||
/**
|
||
* getter method for ecmbanksymbolount record.
|
||
*/
|
||
function get_symbol_array($id, array $select = array()) {
|
||
global $db;
|
||
|
||
array_walk($select, function(&$value, $key) {
|
||
$value = 's.`' . $value . '`';
|
||
});
|
||
|
||
$selectStatement = implode(', ', $select);
|
||
|
||
$q = 'SELECT ' . (strlen($selectStatement) ? $selectStatement : 's.*') . ' FROM ecmsymbols AS s WHERE id = \'' . $id . '\' LIMIT 1;';
|
||
|
||
$r = $db->query($q);
|
||
$rr = $db->FetchByAssoc($r);
|
||
|
||
if ($rr) {
|
||
return $rr;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
/**
|
||
* Concentrate get_symbol_array method.
|
||
*/
|
||
function get_symbol_symbol($id) {
|
||
static $symbols = array();
|
||
return $symbols[$id] ? : ($symbols[$id] = end($this->get_symbol_array($id, array('symbol'))));
|
||
}
|
||
|
||
/**
|
||
* getter method for ecmbankaccount record.
|
||
*/
|
||
function get_acc_array($id, array $select = array()) {
|
||
global $db;
|
||
|
||
array_walk($select, function(&$value, $key) {
|
||
$value = 'ba.`' . $value . '`';
|
||
});
|
||
|
||
$selectStatement = implode(', ', $select);
|
||
|
||
$q = 'SELECT ' . (strlen($selectStatement) ? $selectStatement : 'ba.*') . ' FROM ecmbankaccounts AS ba WHERE id = \'' . $id . '\' LIMIT 1;';
|
||
|
||
$r = $db->query($q);
|
||
$rr = $db->FetchByAssoc($r);
|
||
|
||
if ($rr) {
|
||
return $rr;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
/**
|
||
* Concentrate get_acc_array method.
|
||
*/
|
||
function get_acc_code($id) {
|
||
static $codes = array();
|
||
return $codes[$id] ? : ($codes[$id] = end($this->get_acc_array($id, array('code'))));
|
||
}
|
||
|
||
/**
|
||
* Concentrate get_acc_array method.
|
||
*/
|
||
function get_acc_name($id) {
|
||
static $codes = array();
|
||
return $codes[$id] ? : ($codes[$id] = end($this->get_acc_array($id, array('name'))));
|
||
}
|
||
|
||
function get_list_view_data() {
|
||
$this->fill_in_additional_detail_fields();
|
||
|
||
$ecmfkvattable_fields = $this->get_list_view_array();
|
||
|
||
// $vatYear = DateTime::createFromFormat('d.m.Y', $this->date_document);
|
||
// $ecmfkvattable_fields['YEAR'] = $vatYear ? $bookYear->format('Y') : false;
|
||
|
||
$ecmfkvattable_fields['ACC_WN_ID'] = $ecmfkvattable_fields['ACC_WN'] ? : null;
|
||
$ecmfkvattable_fields['ACC_MA_ID'] = $ecmfkvattable_fields['ACC_MA'] ? : null;
|
||
|
||
$ecmfkvattable_fields['ACC_WN_NAME'] = $this->get_acc_name($ecmfkvattable_fields['ACC_WN']) ? : 'Brak';
|
||
$ecmfkvattable_fields['ACC_MA_NAME'] = $this->get_acc_name($ecmfkvattable_fields['ACC_MA']) ? : 'Brak';
|
||
|
||
$ecmfkvattable_fields['ACC_WN'] = $this->get_acc_code($ecmfkvattable_fields['ACC_WN_ID']) ? : '000';
|
||
$ecmfkvattable_fields['ACC_MA'] = $this->get_acc_code($ecmfkvattable_fields['ACC_MA_ID']) ? : '000';
|
||
|
||
$ecmfkvattable_fields['SYMBOL'] = $this->get_symbol_symbol($ecmfkvattable_fields['SYMBOL']) ? : '-';
|
||
|
||
$ecmfkvattable_fields['IDENTIFIER'] = $ecmfkvattable_fields['IDENTIFIER'] ? : '-';
|
||
|
||
// dump($ecmfkvattable_fields); exit;
|
||
|
||
// $ecmfkvattable_fields['ACC_MA_CODE'] = '';
|
||
// $ecmfkvattable_fields['ACC_MA_CODE'] = '';
|
||
// echo '<pre>' . var_export($this->field_defs, true) . '</pre>';
|
||
// echo '<pre>' . var_export($ecmfkvattable_fields, true) . '</pre>';
|
||
// exit;
|
||
|
||
return $ecmfkvattable_fields;
|
||
}
|
||
|
||
function mark_drelationships_deleted($id) {
|
||
//do nothing, this call is here to avoid default delete processing since
|
||
//delete.php handles deletion of ecmfkvattable revisions.
|
||
}
|
||
|
||
function bean_implements($interface) {
|
||
switch ($interface) {
|
||
case 'ACL' :
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
//static function.
|
||
function get_ecmfkvattable_name($doc_id) {
|
||
if (empty($doc_id))
|
||
return null;
|
||
|
||
$db = DBManagerFactory::getInstance();
|
||
$query = "select ecmfkvattable_name from documents where id='$doc_id'";
|
||
$result = $db->query($query);
|
||
if (!empty($result)) {
|
||
$row = $db->fetchByAssoc($result);
|
||
if (!empty($row)) {
|
||
return $row['ecmfkvattable_name'];
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
|
||
|
||
function getPosition($position, $stockOperations = false) {
|
||
if (!is_array($position))
|
||
return '';
|
||
|
||
$return_array = array();
|
||
|
||
// $return_array['id'] = $position['id'];
|
||
// $return_array['deleted'] = $position['deleted'];
|
||
// $return_array['date_entered'] = $position['date_entered'];
|
||
// $return_array['date_modified'] = $position['date_modified'];
|
||
// $return_array['created_by'] = $position['created_by'];
|
||
// $return_array['modified_user_id'] = $position['modified_user_id'];
|
||
// $return_array['ecmfkvattable_id'] = $position['ecmfkvattable_id'];
|
||
$return_array['ecmfkvatkind_id'] = $position['ecmfkvatkind_id'];
|
||
$return_array['i_acc_wn'] = $position['acc_wn'];
|
||
$return_array['i_acc_ma'] = $position['acc_ma'];
|
||
// $return_array['account_acc_wn'] = $position['account_acc_wn'];
|
||
// $return_array['account_acc_ma'] = $position['account_acc_ma'];
|
||
$return_array['zal_wn'] = $position['zal_wn'];
|
||
$return_array['zal_ma'] = $position['zal_ma'];
|
||
|
||
// Additional
|
||
$return_array['vr_name'] = $position['vr_name'];
|
||
$return_array['vr_position'] = $position['vr_position'];
|
||
//
|
||
$return_array['i_acc_wn_code'] = $position['acc_wn_code'];
|
||
$return_array['i_acc_ma_code'] = $position['acc_ma_code'];
|
||
//
|
||
$return_array['i_acc_wn_name'] = $position['acc_wn_name'];
|
||
$return_array['i_acc_ma_name'] = $position['acc_ma_name'];
|
||
|
||
return $return_array;
|
||
}
|
||
|
||
function getPositionList($array = false) {
|
||
if (isset($this->id) && $this->id != '') {
|
||
|
||
$query = '
|
||
SELECT
|
||
|
||
vri.*
|
||
, vr.`name` AS vr_name
|
||
, vr.`position` AS vr_position
|
||
, acc_wn.`code` AS acc_wn_code
|
||
, acc_ma.`code` AS acc_ma_code
|
||
, acc_wn.`name` AS acc_wn_name
|
||
, acc_ma.`name` AS acc_ma_name
|
||
|
||
FROM `ecmfkvattableitems` AS vri
|
||
|
||
LEFT JOIN `ecmfkvatkinds` AS vr
|
||
ON vr.`id` = vri.`ecmfkvatkind_id`
|
||
|
||
LEFT JOIN `ecmbankaccounts` AS acc_wn
|
||
ON acc_wn.`id` = vri.`acc_wn`
|
||
|
||
LEFT JOIN `ecmbankaccounts` AS acc_ma
|
||
ON acc_ma.`id` = vri.`acc_ma`
|
||
|
||
WHERE
|
||
vri.`ecmfkvattable_id` = \'' . $this->id . '\'
|
||
|
||
#ORDER BY
|
||
#vri.`position` ASC
|
||
;
|
||
';
|
||
|
||
// dump($query);
|
||
// exit;
|
||
|
||
$r = $this->db->query($query);
|
||
$return_array = array();
|
||
|
||
if ($r) {
|
||
while ($w = $this->db->fetchByAssoc($r)) {
|
||
$return_array [] = $this->getPosition($w, $stockOperations);
|
||
}
|
||
|
||
$json = getJSONobj();
|
||
return $array ? $return_array : $json->encode($return_array);
|
||
}
|
||
}
|
||
|
||
return $array ? false : '[]';
|
||
}
|
||
|
||
} |