This commit is contained in:
2024-04-27 09:23:34 +02:00
commit 11e713ca6f
11884 changed files with 3263371 additions and 0 deletions

View File

@@ -0,0 +1,415 @@
function addEvent(object,eventName,do_function) {
if(typeof(object) == "string") object = document.getElementById(object);
if(!object) { alert('No object in function addEvent!'); return; }
if(object.addEventListener) {
object.addEventListener(eventName, do_function, false);
} else {
object.attachEvent('on'+eventName, do_function);
}
}
function setSelectionRange(obj) {
if(obj && typeof(obj) == "object" && (obj.type == "text" || obj.type == "textarea")) {
if(obj.createTextRange) {
var range = obj.createTextRange();
range.moveStart("character", 0);
range.moveEnd("character", obj.value.lengh-1);
range.select();
} else {
if(obj.setSelectionRange) {
obj.setSelectionRange(0,obj.value.length);
}
}
obj.focus();
}
if(obj && typeof(obj) == "object" && obj.options) { obj.focus(); }
}
var AjaxSearchItems;
function AjaxSearch(div,displayNone) {
//fields
this.parentDIV = div; //pole w ktorym zawiera sie pole wyszukiwania
this.div; //pole glowne wyszukiwania
this.inputSearch; //input wyszukiwania
this.timeout; //wskaznik zwracany przez setTimeout przy wcisnieciu klawisza
this.searchDelay = 1000; //opoznienie wyszukiwania
this.divList; //pole w ktorym wyswietlana bedzie lista znalezionnych elementow
this.ajaxSearchItem; //unikalny identyfikator;
this.module = 'EcmInvoiceOutOlds';
this.inputCode;
this.positionSelected;
//functions
this.setInputCode = function(input) {
this.inputCode = input;
this.inputCode.previousCode = this.inputCode.value;
}
this.inputSearchOnKeyDown = function(e,other) {
var keynum;
if(typeof(e) == "number")
keynum = e;
else {
if(window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
}
if(keynum == 38) { this.selectPreviousPosition(); return false; }
if(keynum == 40) { this.selectNextPosition(); return false; }
if(keynum == 13 || keynum == 9) {
//if(parseInt(this.positionSelected.positionData['on_stock'])>0 && this.positionSelected.positionData['on_stock']!=""){
this.inputSearchEnterPressed(other);
return false;
//}
//else{
//// alert(MOD['LBL_NO_PRODUCTS_IN_STOCK']);
// this.div.style.display='block';
// return false;
//}
}
if(keynum == 27) { this.div.style.display = 'none'; }
if(this.timeout) { clearTimeout(this.timeout); this.timeout = null; }
this.timeout = setTimeout("document.getElementById('"+this.div.id+"').AjaxSearch.search();", 2000);
}
this.inputSearchEnterPressed = function(other) {
if(this.positionSelected) {
var row;
if(N.selectedRow) {
N.selectedRow.setData(this.positionSelected.positionData);
row = N.selectedRow;
}
else {
row = N.addRow().setData(this.positionSelected.positionData);
}
row.calculateTotal();
if((other && other == "clear") || OPT['quick_product_item_adding']==0) {
this.clearList();
this.div.style.display = 'none';
if(OPT['quick_product_item_adding'] == 0) if(N.selectedCell && N.selectedCell.index == 1) N.selectedCell.selectNext();
} else {
row.noHideASP = true;
if(N.selectedRow) row = row.myTable.addRow(row.index+1);
row.select();
row.cells.item(0).select();
setSelectionRange(this.inputSearch);
}
}
else if(N.selectedRow) {
if(this.inputSearch.value != this.inputCode.previousCode || this.inputCode.previousCode == '') {
var data = new Object();
N.selectedRow.setData(data);
N.selectedRow.cells.item(1).select();
}
}
//N.addRow();
}
this.selectNextPosition = function() {
if(this.positionSelected) {
if(this.positionSelected.nextSibling) {
this.positionSelect(this.positionSelected.nextSibling);
return;
}
}
this.positionSelect(this.divList.lastChild);
}
this.selectPreviousPosition = function() {
if(this.positionSelected) {
if(this.positionSelected.previousSibling) {
this.positionSelect(this.positionSelected.previousSibling);
return;
}
}
this.positionSelect(this.divList.firstChild);
}
this.search = function() {
if(this.inputSearch.value == '') { this.clearList(); return; }
var _ajax_search_process_search_ = this;
this.Display = function(result) { _ajax_search_process_search_.processSearch(result.responseText); }
this.Fail = function(result) { alert(result.responseText); }
YAHOO.util.Connect.asyncRequest('POST','index.php',{success:this.Display,failure:this.Fail},'module='+this.module+'&action=AjaxSearchQuery&to_pdf=1&as_inputSearch='+this.inputSearch.value+'&ecmlanguage='+document.forms.EditView.ecmlanguage.value+'&stock_id='+document.forms.EditView.stock_id.value);
}
this.processSearch = function(result) {
this.clearList();
var list = eval(result);
if(typeof(list) != "object") return;
this.fillList(list);
}
this.clearList = function() {
this.divList.innerHTML = '';
this.divList.style.height = '';
this.positionDeselect();
}
this.fillList = function(list) {
for(x in list) {
this.addPosition(list[x]);
}
this.positionSelect();
this.setScrolls();
}
this.setScrolls = function() {
var clientH = -1;
if(window.innerHeight && window.innerHeight > 0) clientH = window.innerHeight;
else if(document.documentElement && document.documentElement.clientHeight > 0) clientH = document.documentElement.clientHeight;
else if(document.body && document.body.clientHeight > 0) clientH = document.body.clientHeight;
var XY = YAHOO.util.Dom.getXY(this.div);
var divTop = (XY[1]+this.div.offsetHeight);
if((divTop - (clientH+document.body.scrollTop)) > 0) {
var newPos = divTop-clientH;
document.body.scrollTop = newPos;
}
}
this.positionSelect = function(div,noScroll) {
if(!div) {
if(!this.positionSelected) {
if(this.divList.firstChild) this.positionSelect(this.divList.firstChild);
}
return;
}
this.positionDeselect();
div.className = 'AjaxSearchPositionDivSelected';
this.positionSelected = div;
if(!noScroll) this.divList.scrollTop = div.offsetTop;
}
this.positionDeselect = function() {
if(this.positionSelected) {
this.positionSelected.className = '';
this.positionSelected = null;
}
}
this.addPosition = function(list) {
var position = document.createElement('div');
position.positionData = list;
//if(list['on_stock']>0)
position.onclick = function() {
this.parentNode.AjaxSearch.inputSearchEnterPressed(this); }
//else position.onclick = function() { alert(MOD['LBL_NO_PRODUCTS_IN_STOCK']); }
position.onmouseover = function() { this.parentNode.AjaxSearch.positionSelect(this,true); };
position.innerHTML = '<table width="100%" class="AjaxSearchPositionTable"><tr><td style="width:40%" class="AjaxSearchPositionTableCode">'+this.markElement(list['code'])+'</td><td style="width:20%" align="center" class="AjaxSearchPositionTablePrice">'+list['on_stock']+'</td><td style="width:40%" align="right" class="AjaxSearchPositionTablePrice">'+list['purchase_price']+' '+list['currency_symbol']+'<span style="color:black"> - </span><b>'+list['selling_price']+' '+list['currency_symbol']+'</b></td></tr><tr><td colspan="3" class="AjaxSearchPositionTableName">'+this.markElement(list['name'])+'</td></tr></table>';
this.divList.appendChild(position);
if((position.offsetTop+position.offsetHeight) > 300) this.divList.style.height = '300px'; else this.divList.style.height = '';
}
this.markElement = function(str) {
var s = "("+this.inputSearch.value+")";
var regExp = new RegExp(s,'gi');
return str.replace(regExp,"<b>$1</b>");
}
this.AjaxSearchFrozen = false;
this.AjaxSearchGetSettings = function () {
var AjaxSearchToReq = this;
YAHOO.util.Connect.asyncRequest(
'POST',
'index.php',
{
success: function(response) {
if(response.responseText) {
var str = response.responseText;
var obj = eval(str);
if(obj && obj[0]) {
obj = obj[0];
//if(obj.frozen) {
AjaxSearchToReq.div.style.left = obj.pos_left;
AjaxSearchToReq.div.style.top = obj.pos_top;
AjaxSearchToReq.AjaxSearchFrozen = !(obj.frozen == "true" ? true : false);
AjaxSearchToReq.AjaxSearchFreezePosition(true);
//}
}
}
},
failure: function(response) {}
},
'module=Home&action=EcmAjaxSearchSettings&function=GetSettings&to_pdf=1&from_module='+this.module
);
}
this.AjaxSearchSaveSettings = function () {
YAHOO.util.Connect.asyncRequest(
'POST',
'index.php',
{
success: function(response) {},
failure: function(response) {}
},
'module=Home&action=EcmAjaxSearchSettings&function=SaveSettings&to_pdf=1&from_module='+this.module+'&pos_top='+this.div.style.top+'&pos_left='+this.div.style.left+'&frozen='+this.AjaxSearchFrozen
);
}
this.AjaxSearchFreezePosition = function (dontSave) {
var img = document.getElementById('AjaxSearchPin');
if(this.AjaxSearchFrozen) {
img.src='modules/'+this.module+'/AjaxSearch/AjaxSearchPinOff.gif';
this.AjaxSearchFrozen = false;
} else {
img.src='modules/'+this.module+'/AjaxSearch/AjaxSearchPinOn.gif';
this.AjaxSearchFrozen = true;
}
if(!dontSave) this.AjaxSearchSaveSettings();
}
this.createForm = function() {
/*
var div = document.createElement('div');
div.className = 'AjaxSearch';
div.AjaxSearch = this;
*/
var tmp = document.createElement('div');
var div = "<div></div>";
tmp.innerHTML = div;
div = tmp.firstChild;
div.className = 'AjaxSearch';
div.AjaxSearch = this;
div.onMouseMoveEvent = function(ev) {
if(!this.isOnMouseDown) return;
ev = ev || window.event;
var x = 0; var y = 0;
if(ev.pageX || ev.pageY) {
x = ev.pageX;
y = ev.pageY;
} else {
x = ev.clientX + document.body.scrollLeft - document.body.clientLeft,
y = ev.clientY + document.body.scrollTop - document.body.clientTop
}
this.style.left = x-this.MouseX;
this.style.top = y-this.MouseY;
}
div.onMouseDownEvent = function(ev) {
if(this.noDrag) { this.noDrag = false; return; }
ev = ev || window.event;
var x = 0; var y = 0;
if(ev.pageX || ev.pageY) {
x = ev.pageX;
y = ev.pageY;
} else {
x = ev.clientX + document.body.scrollLeft - document.body.clientLeft,
y = ev.clientY + document.body.scrollTop - document.body.clientTop
}
this.MouseX = x-this.offsetLeft;
this.MouseY = y-this.offsetTop;
this.isOnMouseDown = true;
this.style.cursor = 'move';
}
div.onmouseup = function() {
this.isOnMouseDown = false;
this.style.cursor = '';
//this.AjaxSearch.AjaxSearchSaveSettings();
}
//div.onmouseout = function() { this.onmouseup(); }
ddiv = document.createElement('div');
ddiv.id = 'AjaxSearch_ddiv';
ddiv.className = 'AjaxSearch_ddiv';
ddiv.appendChild(document.createTextNode('Search Product:'));
ddiv.appendChild(document.createElement('br'));
div.appendChild(ddiv);
/*
var inputSearch = document.createElement('input');
inputSearch.type = 'text';
inputSearch.id = 'as_inputSearch';
inputSearch.className = 'AjaxSearchInputSearch';
inputSearch.AjaxSearch = this;
inputSearch.onkeydown = this.inputSearchOnKeyDown;
this.inputSearch = inputSearch;
div.appendChild(inputSearch);
*/
var img = '<img src="modules/'+this.module+'/AjaxSearch/AjaxSearchPinOff.gif" id="AjaxSearchPin" class="AjaxSearchPin" onclick="this.parentNode.AjaxSearch.AjaxSearchFreezePosition();" />';
img += '<img src="modules/'+this.module+'/AjaxSearch/AjaxSearchCloseIcon.gif" class="AjaxSearchCloseIcon" onclick="this.parentNode.AjaxSearch.inputSearchOnKeyDown(27);" />';
div.innerHTML += img;
var inputSearch = '<input type="text" id="as_inputSearch" class="AjaxSearchInputSearch" onKeyDown="return this.AjaxSearch.inputSearchOnKeyDown(event);">';
div.innerHTML = div.innerHTML + inputSearch;
this.inputSearch = div.lastChild;
this.inputSearch.AjaxSearch = this;
this.inputSearch.onmousedown = function() { this.parentNode.noDrag = true; }
div.appendChild(document.createElement('br'));
div.appendChild(document.createElement('br'));
/*
div.appendChild(document.createTextNode('List:'));
var separator = document.createElement('hr');
separator.className = 'AjaxSearchSeparator';
div.appendChild(separator);
*/
var divList = document.createElement('div');
divList.id = 'as_divList';
divList.className = 'AjaxSearchDivList';
divList.AjaxSearch = this;
this.divList = divList;
divList.onmousedown = function() { this.parentNode.noDrag = true; }
div.appendChild(divList);
var tmpDiv = document.createElement('div');
tmpDiv.style.height = '10px';
div.appendChild(tmpDiv);
this.parentDIV.appendChild(div);
this.div = div;
}
this.KeyDown = function(e) {
var keynum;
if(window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
}
//constructor
if(AjaxSearchItems) {
if(typeof(AjaxSearchItems) == "number")
AjaxSearchItem++;
else
AjaxSearchItem = 0;
this.ajaxSearchItem = AjaxSearchItem;
}
this.createForm();
this.div.AjaxSearch = this;
this.div.id = 'AjaxSearch_'+this.AjaxSearchItem;
var AjaxSearch_draganddrop = new YAHOO.util.DD(this.div.id);
AjaxSearch_draganddrop.AjaxSearch = this;
AjaxSearch_draganddrop.endDrag = function(e) {
this.AjaxSearch.AjaxSearchSaveSettings();
};
AjaxSearch_draganddrop.setHandleElId("AjaxSearch_ddiv");
this.div.style.left = (screen.availWidth - this.div.offsetWidth) / 2;
this.div.style.top = (screen.availHeight - this.div.offsetHeight) / 2;
if(displayNone == true) this.div.style.display = 'none';
this.AjaxSearchGetSettings();
};

View File

@@ -0,0 +1,8 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
?>

View File

@@ -0,0 +1,141 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
if(isset($_REQUEST['as_inputSearch']) && $_REQUEST['as_inputSearch'] != '') {
$AS_INPUTSEARCH = strtoupper($_REQUEST['as_inputSearch']);
$language_translate = array(
'en_us' => 'en',
'ge_ge' => 'de',
'pl_pl' => 'pl'
);
if(isset($_REQUEST['ecmlanguage']) && $_REQUEST['ecmlanguage'] != '') {
if(isset($language_translate[$_REQUEST['ecmlanguage']]) && $language_translate[$_REQUEST['ecmlanguage']] != '') {
$use_language = $language_translate[$_REQUEST['ecmlanguage']];
}
}
$query = "SELECT DISTINCT";
$query .= " `pr`.`id`";
$query .= ", `pr`.`code`";
$query .= ", `pr`.`unit_id` as unitid";
$query .= ", `pr`.`name`";
$query .= ", `pr`.`selling_price`";
$query .= ", `pr`.`purchase_price`";
$query .= ", `pr`.`vat_id`";
$query .= ", `pr`.`vat_name`";
$query .= ", `pr`.`vat_value`";
$query .= ", `pr`.`exchange_rate_id` as `currency_id`";
$query .= ", `pr`.`product_category_id` as `category_id`";
$query .= ", `pr`.`usage_unit_id` as `unit_id`";
/*if(isset($use_language)) {
$query .= ", `pr_lang`.`short_description`";
$query .= ", `pr_lang`.`long_description`";
}*/
$query .= " FROM";
$query .= " `ecmproducts` as `pr`";
//if(isset($use_language))
//$query .= " RIGHT JOIN `ecmproduct_language_".$use_language."_view` as `pr_lang` ON `pr`.`id` = `pr_lang`.`ecmproduct_id`";
$query .= " WHERE";
$query .= " (";
$query .= "UPPER(`pr`.`code`) LIKE '%$AS_INPUTSEARCH'";
$query .= " || UPPER(`pr`.`code`) LIKE '$AS_INPUTSEARCH%'";
$query .= " || UPPER(`pr`.`code`) LIKE '%$AS_INPUTSEARCH%'";
$query .= " || UPPER(`pr`.`name`) LIKE '%$AS_INPUTSEARCH'";
$query .= " || UPPER(`pr`.`name`) LIKE '$AS_INPUTSEARCH%'";
$query .= " || UPPER(`pr`.`name`) LIKE '%$AS_INPUTSEARCH%'";
/*if(isset($use_language)) {
$query .= " || UPPER(`pr_lang`.`long_description`) LIKE '%$AS_INPUTSEARCH'";
$query .= " || UPPER(`pr_lang`.`long_description`) LIKE '%$AS_INPUTSEARCH%'";
$query .= " || UPPER(`pr_lang`.`long_description`) LIKE '$AS_INPUTSEARCH%'";
$query .= " || UPPER(`pr_lang`.`short_description`) LIKE '%$AS_INPUTSEARCH'";
$query .= " || UPPER(`pr_lang`.`short_description`) LIKE '%$AS_INPUTSEARCH%'";
$query .= " || UPPER(`pr_lang`.`short_description`) LIKE '$AS_INPUTSEARCH%'";
}*/
$query .= ")";
$query .= " AND `pr`.`deleted`='0'";
$result = $GLOBALS['db']->query($query);
global $sugar_config;
$defaultCurrency = $sugar_config['default_currency_symbol'];
$currencies = array ( -99 => $defaultCurrency );
$arr = array();
if($result)
while($row = $GLOBALS['db']->fetchByAssoc($result)) {
$op = new EcmStockOperation();
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select quantity from ecmstockstates where product_id='".$row['id']."' and stock_id='".$_REQUEST['stock_id']."' and deleted='0'"));
$row['on_stock']=$op->getStock($row['id'], $_REQUEST['stock_id']);
if ($row['category_id']=='d7f876b0-1a3d-43a1-7c9b-511ba40df3d1') $row['on_stock'] ='-';
//$row['on_stock']=number_format($r['quantity'],0,"","");
//$row['on_stock']=5;
$row['unit_id']=$row['unitid'];
$row['unit_name']=$app_list_strings['ecmproducts_unit_dom'][$row['unitid']];
$row['price'] = $row['srp_price'];
if (!$row['price']) $row['price'] = 0;
$row['purchase_price'] = format_number($row['purchase_price']);
$row['selling_price'] = format_number($row['selling_price']);
if(array_key_exists($row['currency_id'],$currencies))
$row['currency_symbol'] = $currencies[$row['currency_id']];
else {
$query = "SELECT symbol FROM currencies WHERE id='".$row['currency_id']."' AND deleted=0;";
$result2 = $GLOBALS['db']->query($query);
if($result2) {
$row2 = $GLOBALS['db']->fetchByAssoc($result2);
if($row2) {
$currencies[$id] = $row2['symbol'];
$row['currency_symbol'] = $row2['symbol'];
} else $row['currency_symbol'] = '';
} else $row['currency_symbol'] = '';
}
/*
if(isset($use_language) && $use_language!="pl") {/*
if(strpos(strtoupper($row['long_description']), $AS_INPUTSEARCH) !== false)
$row['name'] = $row['long_description'];
else
if(strpos(strtoupper($row['short_description']), $AS_INPUTSEARCH) !== false)
$row['name'] = $row['short_description'];
else
if(strpos(strtoupper($row['name']), $AS_INPUTSEARCH) === false || strpos(strtoupper($row['code']), $AS_INPUTSEARCH) !== false) {
if(isset($row['long_description']) && $row['long_description'] != '')
$row['name'] = $row['long_description'];
else
if(isset($row['short_description']) && $row['short_description'] != '')
$row['name'] = $row['short_description'];
}
unset($row['long_description'], $row['short_description']);/
if($row['long_description'])$row['name']=$row['long_description'];
elseif(!$row['long_description'] && $row['short_description'])$row['name']=$row['short_description'];
elseif(!$row['long_description'] && !$row['short_description'])$row['name']=$row['name'];
unset($row['long_description'],$row['short_desciption']);
}
*/
$arr[] = $row;
}
if(count($arr) > 0) {
$json = getJSONobj();
echo str_replace("&quot;", '\"', $json->encode($arr));
}
}
?>

View File

@@ -0,0 +1,204 @@
<?php
$account=$_GET['account'];
$type=$_GET['type'];
$date_from=$_GET['date_from'];
$date_to=$_GET['date_to'];
set_include_path('include/PHPExcel/');
include 'PHPExcel.php';
include 'PHPExcel/Writer/Excel2007.php';
include 'PHPExcel/IOFactory.php';
$db = $GLOBALS['db'];
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setCreator("E5 CRM");
$objPHPExcel->getProperties()->setLastModifiedBy("E5 CRM");
$objPHPExcel->getProperties()->setTitle("Office 2007 ORDERED PRODUCTS");
$objPHPExcel->getProperties()->setSubject("Office 2007 ORDERED PRODUCTS");
$objPHPExcel->getProperties()->setDescription("ORDERED PRODUCTS");
$alf="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('J')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('K')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('L')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('M')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('N')->setWidth(20);
$objPHPExcel->getActiveSheet()->setTitle('Simple');
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->SetCellValue("A1","Invoice No");
$objPHPExcel->getActiveSheet()->SetCellValue("B1","Type");
$objPHPExcel->getActiveSheet()->SetCellValue("C1","Account");
$objPHPExcel->getActiveSheet()->SetCellValue("D1","Register Date");
$objPHPExcel->getActiveSheet()->SetCellValue("E1","Total Brutto");
$objPHPExcel->getActiveSheet()->SetCellValue("F1","Total Netto");
$objPHPExcel->getActiveSheet()->SetCellValue("G1","Cost");
$objPHPExcel->getActiveSheet()->SetCellValue("H1","PLN Margin");
$objPHPExcel->getActiveSheet()->SetCellValue("I1","PLN Margin %");
$objPHPExcel->getActiveSheet()->SetCellValue("J1","Typ");
$objPHPExcel->getActiveSheet()->SetCellValue("K1","Total VAT");
$objPHPExcel->getActiveSheet()->SetCellValue("L1","TH");
$objPHPExcel->getActiveSheet()->SetCellValue("M1","WG");
$objPHPExcel->getActiveSheet()->SetCellValue("N1","SUR");
$i=2;
$wh[]="deleted='0'";
$wh[]="canceled='0'";
if($type)$wh[]="type='".$type."'";
if($account)$wh[]="parent_id='".$account."'";
if($date_from)$wh[]="register_date>='".$date_from."'";
if($date_to)$wh[]="register_date<='".$date_to."'";
$where=implode(" and ",$wh);
$z="select id,pdf_type,purchase_price,total, subtotal,document_no,register_date,id,parent_id,parent_name,type,ecminvoiceoutold_id,currency_value from ecminvoiceoutolds where ".$where." order by type desc, register_date asc, name asc";
$w=$GLOBALS[db]->query($z);
//echo $z;echo mysql_error();
$sum_margin=0;
$sum_margin_pln=0;
$count_total=0;
while($r=$GLOBALS[db]->fetchByAssoc($w)){
if(!$r['currency_value'])$currency_value=1;
else {
$currency_value=$r['currency_value'];
//echo $currency_value;
}
$total_netto=$r['subtotal']*$currency_value;
$total_pur=$r['purchase_price'];
$total_brutto=$r['total']*$currency_value;
$total_margin=0;
if ($r['pdf_type']=='K')
$tt = 'Kraj';
elseif ($r['pdf_type']=='U')
$tt= 'Unia';
else
$tt = 'Eksport';
if($total_netto-$total_margin>0) {
$margin=100*$total_margin/($total_netto-$total_margin);
$margin_pln = $total_netto-$total_pur;
}
else {
$margin=0;
$margin_pln = 0;
}
//pozycje
$th = 0;
$wg = 0;
$sur = 0;
$pozycje = $db->query("
select sum(i.subtotal) as subtotal, p.group_ks, sum(i.quantity) as qty from ecminvoiceoutolditems as i
inner join ecmproducts as p
on p.id=i.ecmproduct_id
where i.ecminvoiceoutold_id='".$r['id']."'
group by p.group_ks;
");
while ($tmp = $db->fetchByAssoc($pozycje)) {
switch ($tmp['group_ks']) {
case '1': $th = $tmp['subtotal']; break;
case '2': $wg = $tmp['subtotal']; break;
case '3': $sur = $tmp['subtotal']; break;
}
}
if ($r['type']='normal') {
$total_margin = (($total_netto-$total_pur)/$total_netto)*100;
$count_normal++;
$sum_margin+=$margin;
$sum_margin_pln+=$margin_pln;
}
if($r['discount']>0){
$vr=$total_brutto/$total_netto;
$total_brutto=$total_brutto-$r['discount'];
$total_netto=$total_brutto/$vr;
}
$objPHPExcel->getActiveSheet()->SetCellValue("A".$i,$r['document_no']);
$objPHPExcel->getActiveSheet()->SetCellValue("B".$i,$r['type']);
$objPHPExcel->getActiveSheet()->SetCellValue("C".$i,$r['parent_name']);
$objPHPExcel->getActiveSheet()->SetCellValue("D".$i,$r['register_date']);
$objPHPExcel->getActiveSheet()->SetCellValue("E".$i,$total_brutto);
$objPHPExcel->getActiveSheet()->SetCellValue("F".$i,$total_netto);
$objPHPExcel->getActiveSheet()->SetCellValue("G".$i,($total_pur));
$objPHPExcel->getActiveSheet()->SetCellValue("H".$i,$margin_pln);
$objPHPExcel->getActiveSheet()->SetCellValue("I".$i,$total_margin);
$objPHPExcel->getActiveSheet()->SetCellValue("J".$i,$tt);
$objPHPExcel->getActiveSheet()->SetCellValue("K".$i,$total_brutto-$total_netto);
$objPHPExcel->getActiveSheet()->SetCellValue("L".$i,$th);
$objPHPExcel->getActiveSheet()->SetCellValue("M".$i,$wg);
$objPHPExcel->getActiveSheet()->SetCellValue("N".$i,$sur);
$sum_total_netto+=$total_netto;
$sum_total_pur+=$total_pur;
$sum_total_brutto+=$total_brutto;
$sum_total_vat+=($total_brutto-$total_netto);
$i++;
}
$objPHPExcel->getActiveSheet()->SetCellValue("E".$i,$sum_total_brutto);
$objPHPExcel->getActiveSheet()->SetCellValue("F".$i,$sum_total_netto);
$objPHPExcel->getActiveSheet()->SetCellValue("G".$i,($sum_total_pur));
$objPHPExcel->getActiveSheet()->SetCellValue("H".$i,$sum_margin_pln/$count_normal);
$objPHPExcel->getActiveSheet()->SetCellValue("I".$i,$sum_margin/$count_total);
$objPHPExcel->getActiveSheet()->SetCellValue("K".$i,$sum_total_vat);
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('argb' => 'F0F0F0')
),
'borders' => array(
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
)
),
"A1:J1"
);
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('argb' => 'F0F0F0')
),
'borders' => array(
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
)
),
"A".($i).":J".($i)
);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
chmod("cache/upload",0777);
$microtime=str_replace(".","",str_replace(" ","",microtime()));
$name="cache/upload/DailySales".$microtime.".xlsx";
$objWriter->save($name);
chmod($name,0777);
header("Location: ".$name);
?>

View File

@@ -0,0 +1,125 @@
<?php
$date_from=$_GET['date_from'];
$date_to=$_GET['date_to'];
if(!$date_from)$date_from=date("Y-m-d");
if(!$date_to)$date_to=date("Y-m-d");
set_include_path('include/PHPExcel/');
include 'PHPExcel.php';
include 'PHPExcel/Writer/Excel2007.php';
include 'PHPExcel/IOFactory.php';
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setCreator("E5 CRM");
$objPHPExcel->getProperties()->setLastModifiedBy("E5 CRM");
$objPHPExcel->getProperties()->setTitle("Office 2007 SALED PRODUCTS");
$objPHPExcel->getProperties()->setSubject("Office 2007 SALED PRODUCTS");
$objPHPExcel->getProperties()->setDescription("SALED PRODUCTS");
$alf="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(5);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(40);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(30);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(20);
$objPHPExcel->getActiveSheet()->setTitle('Simple');
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->SetCellValue("A1","Lp.");
$objPHPExcel->getActiveSheet()->SetCellValue("B1","Index");
$objPHPExcel->getActiveSheet()->SetCellValue("C1","Name");
$objPHPExcel->getActiveSheet()->SetCellValue("D1","Invoice");
$objPHPExcel->getActiveSheet()->SetCellValue("E1","Quantity");
$objPHPExcel->getActiveSheet()->SetCellValue("F1","Price");
$objPHPExcel->getActiveSheet()->SetCellValue("G1","Total netto");
$objPHPExcel->getActiveSheet()->SetCellValue("H1","Total Vat");
$objPHPExcel->getActiveSheet()->SetCellValue("I1","Total brutto");
$i=2;
$z="select ecminvoiceoutolditems.*,ecminvoiceoutolds.document_no as dno,ecminvoiceoutolds.id as sid,ecminvoiceoutolds.type as type from ecminvoiceoutolditems inner join ecminvoiceoutolds on ecminvoiceoutolditems.ecminvoiceoutold_id=ecminvoiceoutolds.id where ecminvoiceoutolds.deleted='0' and ecminvoiceoutolds.register_date>='".$date_from."' and ecminvoiceoutolds.register_date<='".$date_to."' and ecminvoiceoutolditems.deleted='0'";
echo $z;
$w=$GLOBALS[db]->query($z);
echo mysql_error();
while($r=$GLOBALS[db]->fetchByAssoc($w)){
$total_netto=$r['price']*$r['quantity'];
$total_vat=$r['price']*$r['quantity']*($r['ecmvat_value']/100);
$total_brutto=$r['price']*$r['quantity']*(1+$r['ecmvat_value']/100);
if($r['type']=="correct"){
$rr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select price,quantity,ecmvat_value from ecminvoiceoutolditems where id='".$r['ecminvoiceoutolditem_id']."'"));
$total_netto-=$rr['price']*$rr['quantity'];
$total_vat-=$rr['price']*$rr['quantity']*($rr['ecmvat_value']/100);
$total_brutto-=$rr['price']*$rr['quantity']*(1+$rr['ecmvat_value']/100);
$r['price']=$rr['price'];
$r['quantity']-=$rr['quantity'];
}
if($r['quantity']==0)continue;
$objPHPExcel->getActiveSheet()->SetCellValue("A".$i,($i-1));
$objPHPExcel->getActiveSheet()->SetCellValue("B".$i,$r['code']);
$objPHPExcel->getActiveSheet()->SetCellValue("C".$i,$r['name']);
$objPHPExcel->getActiveSheet()->SetCellValue("D".$i,$r['dno']);
$objPHPExcel->getActiveSheet()->SetCellValue("E".$i,$r['quantity']);
$objPHPExcel->getActiveSheet()->SetCellValue("F".$i,$r['price']);
$objPHPExcel->getActiveSheet()->SetCellValue("G".$i,($total_netto));
$objPHPExcel->getActiveSheet()->SetCellValue("H".$i,($total_vat));
$objPHPExcel->getActiveSheet()->SetCellValue("I".$i,($total_brutto));
$sum_total_netto+=$total_netto;
$sum_total_vat+=$total_vat;
$sum_total_brutto+=$total_brutto;
$sum_qty+=$r['quantity'];
$i++;
}
$objPHPExcel->getActiveSheet()->SetCellValue("E".$i,$sum_qty);
@$objPHPExcel->getActiveSheet()->SetCellValue("F".$i,($sum_total/$sum_qty));
$objPHPExcel->getActiveSheet()->SetCellValue("G".$i,$sum_total_netto);
$objPHPExcel->getActiveSheet()->SetCellValue("H".$i,$sum_total_vat);
$objPHPExcel->getActiveSheet()->SetCellValue("I".$i,$sum_total_brutto);
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('argb' => 'F0F0F0')
),
'borders' => array(
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
)
),
"A1:I1"
);
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('argb' => 'F0F0F0')
),
'borders' => array(
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
)
),
"A".($i).":I".($i)
);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
chmod("cache/upload",0777);
$microtime=str_replace(".","",str_replace(" ","",microtime()));
$name="cache/upload/SaledProducts".$microtime.".xlsx";
$objWriter->save($name);
chmod($name,0777);
header("Location: ".$name);
?>

View File

@@ -0,0 +1,142 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*****************************************************************************
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
* Version 1.1 ("License"); You may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/rpl.php. Software distributed under the
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
* either express or implied.
*
* You may:
* a) Use and distribute this code exactly as you received without payment or
* a royalty or other fee.
* b) Create extensions for this code, provided that you make the extensions
* publicly available and document your modifications clearly.
* c) Charge for a fee for warranty or support or for accepting liability
* obligations for your customers.
*
* You may NOT:
* a) Charge for the use of the original code or extensions, including in
* electronic distribution models, such as ASP (Application Service
* Provider).
* b) Charge for the original source code or your extensions other than a
* nominal fee to cover distribution costs where such distribution
* involves PHYSICAL media.
* c) Modify or delete any pre-existing copyright notices, change notices,
* or License text in the Licensed Software
* d) Assert any patent claims against the Licensor or Contributors, or
* which would in any way restrict the ability of any third party to use the
* Licensed Software.
*
* You must:
* a) Document any modifications you make to this code including the nature of
* the change, the authors of the change, and the date of the change.
* b) Make the source code for any extensions you deploy available via an
* Electronic Distribution Mechanism such as FTP or HTTP download.
* c) Notify the licensor of the availability of source code to your extensions
* and include instructions on how to acquire the source code and updates.
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
* reproduce, perform, modify, sublicense, and distribute your extensions.
*
* The Original Code is: CommuniCore
* Olavo Farias
* 2006-04-7 olavo.farias@gmail.com
*
* The Initial Developer of the Original Code is CommuniCore.
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
* All Rights Reserved.
********************************************************************************/
require_once('modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php');
$focus = new EcmInvoiceOutOld();
// PERFORM THE DELETE IF GIVEN A RECORD TO DELETE
if(!isset($_REQUEST['record']))
sugar_die("A record number must be specified to delete the record.");
$focus->retrieve($_REQUEST['record']);
if(!$focus->ACLAccess('Delete')) {
ACLController::displayNoAccess(true);
sugar_cleanup(true);
}
$focus->deleteAssignedPositions();
$focus->mark_deleted($_REQUEST['record']);
// NOW THAT THE DELETE HAS BEEN PERFORMED, RETURN TO GIVEN LOCATION
header("Location: index.php?module=".$_REQUEST['return_module']."&action=".$_REQUEST['return_action']."&record=".$_REQUEST['return_id']);
?>

View File

@@ -0,0 +1,360 @@
<?php
if (!defined('sugarEntry') || !sugarEntry)
die('Not A Valid Entry Point');
//require_once('modules/EcmGroupSales/HeaderMenu.php');
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings;
require_once('modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php');
require_once('modules/EcmInvoiceOutOlds/Forms.php');
require_once ('include/time.php');
require_once('include/json_config.php');
$json_config = new json_config();
$file = 'modules/EcmGroupSales/EcmGroupSale.php';
if (file_exists($file)) {
$cc = array();
require_once($file);
$cc = EcmGroupSale::loadSettings();
}
$OPT = array();
$OPT['row_item_height'] = $cc['row_item_height'];
$OPT['row_item_height_selected'] = $cc['row_item_height_selected'];
$OPT['rows_on_item_list'] = $cc['rows_on_item_list'];
$OPT['position_table_height'] = $OPT['row_item_height'] * $OPT['rows_on_item_list'] + 40 + $OPT['rows_on_item_list'] * 4;
$focus = new EcmInvoiceOutOld();
if (isset($_REQUEST['record'])) {
$focus->retrieve($_REQUEST['record']);
$focus->format_all_fields();
if (isset($_REQUEST['status']) && $_REQUEST['status'] != '') {
$focus->doNotAccepted();
}
//echo '<pre>PL:' . var_export($focus->getPositionList(true), true);
$focus->position_list = str_replace('&quot;', '\"', $focus->getPositionList());
$t = $focus->calculate($focus->getPositionList(true));
$to_paid = format_number($focus->total);
if (!$focus->prepaid) $focus->prepaid=0;
if (!$focus->paid_val) $focus->paid_val=0;
echo $focus->prepaid.' '.$focus->paid_val;
$left = format_number($focus->total - $focus->paid_val - $focus->prepaid);
$weight_netto = $t['weight_netto'];
$OPT['status'] = $focus->status;
} else {
$OPT['new_number'] = true;
$datef = $current_user->getPreference('datef');
if ($datef != '')
$sugar_config['datef'];
$focus->register_date = date($datef);
$focus->payment_date = date($datef, mktime() + 30 * 24 * 60 * 60);
$focus->sell_date = date($datef);
}
if (isset($_REQUEST['send_email']) && $_REQUEST['send_email'] == '1')
$OPT['setTab'] = 'EMAIL';
$tmp = $current_user->getPreference('num_grp_sep');
if (!isset($tmp) || $tmp == '' || $tmp == NULL)
$tmp = $sugar_config['default_number_grouping_seperator'];
$OPT['sep_1000'] = $tmp;
$tmp = $current_user->getPreference('dec_sep');
if (!isset($tmp) || $tmp == '' || $tmp == NULL)
$tmp = $sugar_config['default_decimal_seperator'];
$OPT['dec_sep'] = $tmp;
$tmp = $current_user->getPreference('default_currency_significant_digits');
if (!isset($tmp) || $tmp == '' || $tmp == NULL)
$tmp = $sugar_config['default_currency_significant_digits'];
$OPT['dec_len'] = $tmp;
$OPT['default_unit'] = "1";
$OPT['default_vat'] = "19.00";
$OPT['default_category'] = "";
$OPT['invoice']['type'] = $focus->type;
$OPT['to_is_vat_free'] = $focus->to_is_vat_free;
$cq = $current_user->getPreference('confirm_invoiceouts');
$OPT['user']['confirm_invoiceouts'] = ((isset($cq) && $cq) ? 1 : 0);
$json = getJSONobj();
$w = $GLOBALS[db]->query("select name,id,value from ecmvats where deleted='0' order by name");
$nvats = mysql_num_rows($w);
while ($r = $GLOBALS[db]->fetchByAssoc($w)) {
$VAT[$r['id']] = array(
"id" => $r['id'],
"name" => $r['name'],
"value" => $r['value']
);
}
$show_pdf = $current_user->getPreference('show_pdf_in_div');
if (!isset($show_pdf)) {
require_once('modules/EcmGroupSales/EcmGroupSale.php');
$cc = EcmGroupSale::loadSettings();
$show_pdf = $cc['show_pdf_in_div_global'];
}
global $mod_strings;
//check if errors
//add mz 2014-06-26
$error = false; //hope! always hope! :)
$what_error = array();
//check duplicate numbers
$db = $GLOBALS['db'];
$nr = $db->query("SELECT id FROM ecminvoiceoutolds WHERE deleted='0' AND canceled='0' AND document_no='$focus->document_no'");
if (intval($nr->num_rows)>1) {
$error = true;
$what_error[] = 'Duplikat numeru';
}
//check totals
if (floatval($focus->subtotal)==0 || floatval($focus->total)==0) {
$error = true;
$what_error[] = 'Zerowa wartość';
}
//correct subtotal > 0??
if ($focus->type=='correct' && (floatval($focus->subtotal>0) || floatval($focus->total)>0)) {
$error = true;
$what_error[] = 'Nieujemna korekta';
}
//check transaction
//double or not exists?
$trans = $db->query("SELECT id, value FROM ecmtransactions WHERE deleted='0' AND record_id='$focus->id'");
//echo "SELECT id, value FROM ecmtransactions WHERE deleted='0' AND record_id='$focus->id'<br>";
if (intval($trans->num_rows)!=1) {
if (floatval($focus->paid_val) != $focus->total) {
$error = true;
$what_error[] = 'Brak transakcji';
}
} else { //wrong transaction value
$t = $db->fetchByAssoc($trans);
if (floatval($t['value']) != floatval($focus->total)) {
$error = true;
$what_error[] = 'Zła wartość transakcji';
}
}
//admin can do all!
global $current_user;
if ($current_user->id=='1' || $current_user->id=='cc468949-70d1-18d4-36e7-52e785735f91') {
if ($error) var_dump($what_error);
$error = false;
}
//end mz
$scriptOpt = '<script language="javascript">
var SHOW_PDF_IN_DIV =' . $show_pdf . ';
var UNIT =' . str_replace('&quot;', '\"', $json->encode($GLOBALS['app_list_strings']['ecmproducts_unit_dom'])) . ';
var VAT = ' . str_replace('&quot;', '\"', $json->encode($VAT)) . ';
var OPT = ' . str_replace('&quot;', '\"', $json->encode($OPT)) . ';
var MOD = ' . str_replace('&quot;', '\"', $json->encode($mod_strings)) . ';
var INV_ERROR = '.($error == true ? '1':'0').';
var N;
</script>';
echo $scriptOpt;
require_once('include/MVC/View/SugarView.php');
require_once('modules/EcmInvoiceOutOlds/view/DetailView/view.detail.my.php');
$edit = new ViewDetailMy();
$edit->ss = new Sugar_Smarty();
$edit->module = 'EcmInvoiceOutOlds';
$edit->bean = $focus;
$edit->tplFile = 'include/ECM/EcmViews/DetailView/Tabs/DetailView.tpl';
$edit->bean->total = unformat_number($edit->bean->total);
$edit->preDisplay();
$arr_template = $focus->getTemplateList();
if (isset($focus->template_id))
$edit->ss->assign("DOCUMENT_TEMPLATES_OPTIONS", get_select_options_with_id($arr_template, $focus->template_id));
else
$edit->ss->assign("DOCUMENT_TEMPLATES_OPTIONS", get_select_options_with_id($arr_template, ''));
$edit->ss->assign("POSITION_LIST", $focus->position_list);
$edit->ss->assign("EMAIL_LINK", $focus->createSendEmailLink());
$edit->ss->assign("LEFT", $left);
$edit->ss->assign("TO_PAID", $to_paid);
$edit->ss->assign("WEIGHT_TOTAL", $weight_netto);
// get corrects or corrected invoices
$db = $GLOBALS['db'];
if ($focus->type == 'correct') {
$ret = $db->query ( "
SELECT distinct o.ecminvoiceout_id
FROM
ecminvoiceoutitems as ii
INNER JOIN ecminvoiceouts as i
ON ii.ecminvoiceout_id = i.id
INNER JOIN ecminvoiceoutitems AS o
ON o.id = ii.ecminvoiceoutitem_id
WHERE
ii.ecminvoiceout_id = '$focus->id'" );
$inv = "";
while ($row = $db->fetchByAssoc($ret)) {
$i = $db->fetchByAssoc($db->query("SELECT id, document_no FROM ecminvoiceouts WHERE id ='".$row['ecminvoiceout_id']."'"));
$inv.='<a href="index.php?module=EcmInvoiceOuts&action=DetailView&record='.$i['id'].'" target="new">'.$i['document_no'].'</a>,&nbsp';
}
} else if ($focus->type == 'normal') {
$ret = $db->query( "
SELECT DISTINCT c.document_no, c.id FROM
ecminvoiceoutitems as ic #items from correstc
INNER JOIN ecminvoiceouts AS c #correct
ON c.id = ic.ecminvoiceout_id
WHERE
ic.ecminvoiceoutitem_id IN (
SELECT id FROM ecminvoiceoutitems WHERE
ecminvoiceout_id='".$focus->id."'
)
AND c.deleted='0' AND c.canceled='0';
");
while ($i = $db->fetchByAssoc($ret)) {
$inv.='<a href="index.php?module=EcmInvoiceOuts&action=DetailView&record='.$i['id'].'" target="new">'.$i['document_no'].'</a>,&nbsp';
}
}
$edit->ss->assign ( "INVOICES_INFO", substr($inv,0,-6) );
$email_link_tab = '<script language="javascript">YAHOO.util.Event.addListener(window,"load",function(){setEMAIL = function(){' . $focus->createSendEmailLink() . '}});</script>';
$desc.='<input title="Generuj PDF" class="button" onclick="if(document.getElementById(\'div_desc\').style.display==\'none\')document.getElementById(\'div_desc\').style.display=\'block\';else document.getElementById(\'div_desc\').style.display=\'none\';" type="button" name="productcard" id="productcard" value="Generuj PDF">';
$desc .= '<div id="div_desc" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;">';
$desc .= 'Typ: <select name="preview_type" id="preview_type"><option value>Faktura</option><option value="exp">Lista rozchodowa</option><option value="pl">Specyfikacja wysyłki</option></select><br /><br />';
$desc.='<input name="quote_pdf" id="quote_pdf" title="Show PDF" accessKey="" class="button" onclick="window.open(\'index.php?module=EcmInvoiceOutOlds&action=previewPDF&to_pdf=1&preview_type=\'+document.getElementById(\'preview_type\').value+\'&record='.$_REQUEST['record'].'\',\'_blank\');" type="button" value="Pokaż PDF">';
$edit->ss->assign("CATALOGUE",$desc);
$edit->ss->assign("EMAIL_LINK_TAB", $email_link_tab);
$r = $GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select id from ecmstockdoccorrects where ecminvoiceoutold_id='" . $focus->id . "'"));
if ($r['id'])
$edit->ss->assign("hasCorrect", $r['id']);
$edit->ss->assign("OPT", $OPT);
echo $edit->display();
/*
$GLOBALS['focus'] = $focus;
require_once('include/SubPanel/SubPanelTiles.php');
$subpanel = new SubPanelTiles($this->bean, $this->module);
//get available list of subpanels
$alltabs=$subpanel->subpanel_definitions->get_available_tabs();
if (!empty($alltabs)) {
//iterate through list, and filter out all but 3 subpanels
foreach ($alltabs as $key=>$name) {
if ($name != 'prospectlists' && $name!='emailmarketing' && $name != 'tracked_urls') {
//exclude subpanels that are not prospectlists, emailmarketing, or tracked urls
$subpanel->subpanel_definitions->exclude_tab($name);
}
}
//only show email marketing subpanel for email/newsletter campaigns
if ($this->bean->campaign_type != 'Email' && $this->bean->campaign_type != 'NewsLetter' ) {
//exclude subpanels that are not prospectlists, emailmarketing, or tracked urls
$subpanel->subpanel_definitions->exclude_tab('emailmarketing');
}
}
//show filtered subpanel list
echo $subpanel->display();
*/
/*
$_REQUEST['type'] = 'out';
$_REQUEST['parent_id'] = (isset($focus->id) && $focus->id != '')? $focus->id : '';
$_REQUEST['parent_type'] = 'EcmInvoiceOutOlds';
$_REQUEST['record'] = '';
$ob = '';
ob_start();
require_once('modules/EcmInvoiceOutOlds/Emails.php');
$ob = ob_get_contents();
ob_end_clean();
$mod_strings = return_module_language($current_language, 'EcmInvoiceOutOlds');
$edit->ss->assign("EMAILS",$ob);
*/
/*
require_once('include/SubPanel/SubPanelTiles.php');
$subpanel = new SubPanelTiles($focus, 'EcmInvoiceOutOlds');
echo $subpanel->display();
*/
echo '<div id="subpanels_div">';
require_once('subpanels.php');
echo '</div>';

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,490 @@
function doRequest(where, post, doFunction, error) {
this.Display = function(result) {
doFunction(result.responseText);
}
this.Fail = function(result) {
if (error)
alert(error);
}
YAHOO.util.Connect.asyncRequest('POST', where, {
success: this.Display,
failure: this.Fail
}, post);
}
function changeValidateRequired(formname, name, required) {
for (var i = 0; i < validate[formname].length; i++)
if (validate[formname][i][0] == name) {
validate[formname][i][2] = required;
break;
}
}
function set_focus() {
document.getElementById('name').focus();
}
function my_popup(module, field_array, call_back_function, form_name) {
if (!call_back_function)
call_back_function = "set_return";
if (!form_name)
form_name = "EditView";
return open_popup(module, 600, 400, "", true, false, {
"call_back_function": call_back_function,
"form_name": form_name,
"field_to_name_array": field_array
});
}
function addEvent(object, eventName, do_function) {
if (typeof(object) == "string")
object = document.getElementById(object);
if (!object) {
alert('No object in function addEvent!');
return;
}
if (object.addEventListener) {
object.addEventListener(eventName, do_function, false);
} else {
object.attachEvent('on' + eventName, do_function);
}
}
function ItemListClear() {
while (N.rowCount() > 0)
N.row(0).deleteRow();
}
addEvent(
window,
'load',
function() {
//initialize table
N = new MyTable('itemsTable');
N.onRefreshRowIndex = function(row) {
var data = new Object();
data['index'] = (row.index + 1).toString();
row.cells.item(0).setData(data);
}
N.onCreateRow = function(row) {
row.newPos = false;
row.ondblclick = function() {
this.newPos = !this.newPos;
var img = this.cells.item(1).getElementsByTagName('img');
if (!this.newPos)
img[0].src = "modules/EcmInvoiceOutOlds/images/edit.gif";
else
img[0].src = "modules/EcmInvoiceOutOlds/images/editset.gif";
for (var i = 0; i < this.myTable.colCount(); i++)
this.cells.item(i).change(!this.newPos);
}
row.onSelect = function() {
for (var i = 0; i < this.myTable.colCount(); i++) {
this.cells.item(i).style.height = OPT['row_item_height_selected'];
this.cells.item(i).change(!this.newPos);
}
}
row.onDeselect = function() {
for (var i = 0; i < this.myTable.colCount(); i++) {
this.cells.item(i).style.height = OPT['row_item_height'];
this.cells.item(i).change(false);
}
}
row.calculateTotal = function() {
//do nothing :)
}
}
N.onCreateCell = function(cell) {
var i = cell.index;
cell.change = function(select) {};
//cell.style.height = OPT['row_item_height'];
cell.style.height = 50;
cell.noSelect = true;
if (i == 0) {
cell.setData = function(data) {
if (data.index)
cell.firstChild.value = data.index;
};
cell.getData = function(data) {
data.index = cell.firstChild.value;
}
cell.select = function() {
this.selectNext();
}
var edit = document.createElement('input');
edit.setAttribute('type', 'text');
edit.setAttribute('readOnly', 'readonly');
edit.setAttribute('tabIndex', 1);
edit.className = 'inputs';
cell.appendChild(edit);
}
if (i == 1) {
cell.getData = function(data) {
var cn = this.getElementsByTagName('input');
data.code = cn[0].value;
data.id = cn[1].value;
data.unit_name = cn[2].value;
data.vat_id = cn[3].value;
data.category_id = cn[4].value;
}
cell.setData = function(data) {
var cn = this.getElementsByTagName('input');
if (data.code)
cn[0].value = data.code;
if (data.id)
cn[1].value = data.id;
if (data.unit_name)
cn[2].value = data.unit_name;
if (data.vat_id)
cn[3].value = data.vat_id;
if (data.category_id)
cn[4].value = data.category_id;
}
var edit = '<input type="text" readonly="readonly" tabindex="1" class="inputs" autocomplete="off" >';
cell.innerHTML = edit;
cell.align = 'right';
var id = document.createElement('input');
id.setAttribute('type', 'hidden');
cell.appendChild(id);
var unit_id = document.createElement('input');
unit_id.setAttribute('type', 'hidden');
//unit_id.setAttribute('value',OPT['default_unit']);
unit_id.setAttribute('value', 'TMP');
cell.appendChild(unit_id);
var vat_id = document.createElement('input');
vat_id.setAttribute('type', 'hidden');
//vat_id.setAttribute('value',OPT['default_vat']);
vat_id.setAttribute('value', '23');
cell.appendChild(vat_id);
var category_id = document.createElement('input');
category_id.setAttribute('type', 'hidden');
category_id.setAttribute('value', '');
cell.appendChild(category_id);
}
if (i == 2) {
cell.getData = function(data) {
var cn = this.getElementsByTagName('textarea');
data.name = cn[0].value;
}
cell.setData = function(data) {
var cn = this.getElementsByTagName('textarea');
if (data.name)
cn[0].value = data.name;
}
var textarea = '<textarea tabindex="1" readonly="readonly" style="height:100%" class="inputs"></textarea>';
cell.innerHTML = textarea;
}
if (i == 3) {
cell.getData = function(data, noAlert) {
var tmp = UserFormatNumberToNumber(this.firstChild.value);
if (tmp == -1) {
ERROR = true;
//if(!noAlert)
//alert(MOD['LBL_FORMAT_NUMBER_ERROR']+' ('+this.firstChild.value+')');
data.quantity = 0;
this.firstChild.style.color = 'red';
} else {
data.quantity = tmp;
this.firstChild.style.color = 'black';
}
}
cell.setData = function(data) {
if (data.quantity)
this.firstChild.value = NumberToUserFormatNumber(data.quantity);
else
this.firstChild.value = NumberToUserFormatNumber(0);
}
var edit = '<input type="text" readonly="readonly" tabindex="1" style="text-align:right;" autocomplete="off" class="inputs" value="' + NumberToUserFormatNumber(1) + '">';
cell.innerHTML = edit;
}
if (i == 4) {
cell.getData = function(data, noAlert) {
data.unit_id = this.firstChild.value;
}
cell.setData = function(data) {
this.firstChild.value = data.unit_id;
}
var edit = '<input type="text" readonly="readonly" tabindex="1" class="inputs" style="text-align:right;" autocomplete="off" value="">';
cell.innerHTML = edit;
}
if (i == 5) {
cell.getData = function(data, noAlert) {
}
cell.setData = function(data) {
var value;
if (data.startprice)
value = data.startprice;
else
value = 0;
this.firstChild.value = NumberToUserFormatNumber(value);
}
var edit = '<input type="text" readonly="readonly" tabindex="1" class="inputs" style="text-align:right;" autocomplete="off" value="0">';
cell.innerHTML = edit;
}
if (i == 6) {
cell.getData = function(data, noAlert) {
var tmp = UserFormatNumberToNumber(this.firstChild.value, '%');
if (tmp == -1) {
ERROR = true;
if (!noAlert)
alert(MOD['LBL_FORMAT_NUMBER_ERROR'] + ' (' + this.firstChild.value + ')');
data.discount = 0;
this.firstChild.style.color = 'red';
} else {
data.discount = tmp;
this.firstChild.style.color = 'black';
}
}
cell.setData = function(data) {
if (data.discount)
this.firstChild.value = NumberToUserFormatNumber(data.discount, '%');
else
this.firstChild.value = NumberToUserFormatNumber(0, '%');
}
cell.selectNext = function() {
var row = this.parentNode.selectNext();
row.select();
row.cells.item(0).select();
};
var edit = '<input type="text" readonly="readonly" tabindex="1" class="inputs" style="text-align:right;" autocomplete="off" value="' + NumberToUserFormatNumber(0, '%') + '">';
cell.innerHTML = edit;
}
if (i == 7) {
cell.getData = function(data, noAlert) {
var tmp = UserFormatNumberToNumber(this.firstChild.value);
if (tmp == -1) {
ERROR = true;
if (!noAlert)
alert(MOD['LBL_FORMAT_NUMBER_ERROR'] + ' (' + this.firstChild.value + ')');
data.price = 0;
this.firstChild.style.color = 'red';
} else {
data.price = tmp;
this.firstChild.style.color = 'black';
}
}
cell.setData = function(data) {
var cn = this.getElementsByTagName('input');
if (data.subprice) cn[0].value = NumberToUserFormatNumber(data.subprice);
else cn[0].value = NumberToUserFormatNumber(0);
if (data.price) cn[1].value = NumberToUserFormatNumber(data.price);
else cn[1].value = NumberToUserFormatNumber(0);
}
var edit = '<input type="text" readonly="readonly" tabindex="1" class="inputs" style="text-align:right;" autocomplete="off" value="' + NumberToUserFormatNumber(0) + '"><br><input type="text" readonly="readonly" tabindex="1" class="inputs" style="text-align:right;" autocomplete="off" value="' + NumberToUserFormatNumber(0) + '">';
cell.innerHTML = edit;
}
if (i == 8) {
cell.getData = function(data, noAlert) {
var cn = this.getElementsByTagName('input');
data.vat_value = cn[0].value;
data.vat_id = cn[1].value;
if (VAT[cn[1].value])
data.vat_name = VAT[cn[1].value].name;
}
cell.setData = function(data) {
if (data.vat_value)
this.getElementsByTagName('input')[0].value = data.vat_value;
if (data.vat_id)
this.getElementsByTagName('input')[1].value = data.vat_id;
if (data.vat_name)
this.getElementsByTagName('input')[2].value = data.vat_name;
}
cell.onDeselect = function() {
ERROR = false;
var data = new Object();
this.getData(data);
if (!ERROR) {
data.vat_id = data.vat_id;
this.setData(data);
}
}
var inp = document.createElement('input');
inp.setAttribute('type', 'hidden');
cell.appendChild(inp);
var inp = document.createElement('input');
inp.setAttribute('type', 'hidden');
cell.appendChild(inp);
var inp;
inp = document.createElement('input');
inp.setAttribute('type', 'text');
inp.className = 'inputs';
inp.style.textAlign = "right";
inp.cell = cell;
cell.appendChild(inp);
}
if (i == 9) {
//cell.select = function() { };
cell.getData = function(data) {
var cn = this.getElementsByTagName('input');
if (cn[0]) data.subtotal = UserFormatNumberToNumber(cn[0].value);
else data.subtotal = 0;
if (cn[1]) data.total = UserFormatNumberToNumber(cn[1].value);
else data.total = 0;
}
cell.setData = function(data) {
var cn = this.getElementsByTagName('input');
if (data.subtotal) cn[0].value = NumberToUserFormatNumber(data.subtotal);
else cn[0].value = NumberToUserFormatNumber(0);
if (data.total) cn[1].value = NumberToUserFormatNumber(data.total);
else cn[1].value = NumberToUserFormatNumber(0);
}
var edit = '<input type="text" readonly="readonly" tabindex="1" class="inputs" style="text-align:right;" autocomplete="off" value="' + NumberToUserFormatNumber(0) + '"><br><input type="text" readonly="readonly" tabindex="1" class="inputs" style="text-align:right;" autocomplete="off" value="' + NumberToUserFormatNumber(0) + '">';
cell.innerHTML = edit;
}
}
N.onSetCellData = function(row, cell, data) {
if (cell.innerHTML == '')
cell.innerHTML = '&nbsp;';
}
var pl = document.getElementById('position_list').value;
if (pl && pl != '') {
try {
pl = eval(pl);
for (x in pl) {
if (typeof(pl[x].code) != "undefined") {
var pl_row = pl[x];
N.addRow().setData(pl_row);
}
}
} catch (err) {
pl = null;
};
}
if (N.rowCount() == 0)
N.addRow();
calculateTotal = function() {
var vats = new Object();
var subtotal = 0;
var total = 0;
//var cbm_total = 0;
for (var i = 0; i < N.rowCount(); i++) {
var data = N.row(i).getData();
console.log(data);
if (data.vat_id && data.name != '') {
if (typeof(vats[data.vat_id]) != "object") {
vats[data.vat_id] = new Object();
vats[data.vat_id]['vat'] = 0;
}
vats[data.vat_id]['vat'] += data.subtotal;
}
subtotal += data.subtotal;
//cbm_total += data.cbm;
}
console.log(subtotal);
total = subtotal;
var rt = document.getElementById('result_table');
for (var i = 1; i < rt.rows.length - 1; i++) {
if (!vats[rt.rows.item(i).id]) {
rt.deleteRow(i);
--i;
} else vats[rt.rows.item(i).id]['node'] = rt.rows.item(i);
}
for (var x in vats) {
if (VAT[x]) {
vats[x]['vat'] = vats[x]['vat'] * (parseFloat(VAT[x].value) / 100);
total += vats[x]['vat'];
var txL = MOD['LBL_VAT'] + ' (' + VAT[x].name + ')';
var txF = NumberToUserFormatNumber(vats[x]['vat']);
}
if (vats[x]['node']) {
vats[x]['node'].id = x;
vats[x]['node'].cells.item(0).innerHTML = txL;
vats[x]['node'].cells.item(1).innerHTML = "<input type='text' readonly='readonly' style='border:0px;font-weight:900;width:100%;text-align:right;' value='" + txF + "'>";
} else {
rt.insertRow(1);
rt.rows.item(1).id = x;
rt.rows.item(1).insertCell(0);
rt.rows.item(1).cells.item(0).className = 'positionsLabel';
rt.rows.item(1).cells.item(0).innerHTML = txL;
rt.rows.item(1).insertCell(1);
rt.rows.item(1).cells.item(1).className = 'positionsField';
rt.rows.item(1).cells.item(1).innerHTML = "<input type='text' readonly='readonly' style='border:0px;font-weight:900;width:100%;text-align:right;' value='" + txF + "'>";
}
}
var total2 = total;
var discount;
// if((discount = CheckDiscount(true)) == -1) discount = 0;
discount = 0;
var discount2 = subtotal * discount / 100;
total = total2 - discount2;
discount2 = NumberToUserFormatNumber(discount2).toString();
total2 = ((OPT['type'] == "correct") ? '-' : '') + NumberToUserFormatNumber(total2).toString();
total = ((OPT['type'] == "correct") ? '-' : '') + NumberToUserFormatNumber(total).toString();
document.getElementById('subtotal').value = NumberToUserFormatNumber(subtotal);
if (document.getElementById('total_2')) document.getElementById('total_2').value = total2;
//rt.rows.item(rt.rows.length-2).cells.item(0).innerHTML = MOD['LBL_DISCOUNT']+' ('+NumberToUserFormatNumber(discount,'%')+')';
//document.getElementById('discount_2').value = discount2;
document.getElementById('total').value = total2;
//document.getElementById('cbm_total').value = cbm_total;
}
calculateTotal();
function HideLoadingView() {
var slv = document.getElementById('ShowLoadingView');
if (slv)
slv.style.display = 'none';
}
setPREVIEW = function() {
if (SHOW_PDF_IN_DIV == 1) {
HideLoadingView();
//SetTab('preview_PREVIEW');
EcmPreviewPDF('index.php?module=EcmInvoiceOutOlds&action=previewPDF&to_pdf=1&method=I&record=' + document.forms.DetailView.record.value + '&type=' + type, {
zoom: 75
});
} else {
SetTab('panel_PREVIEW');
}
}
preview_pdf = function() {
console.log('test');
var type = document.getElementById('preview_type').value;
switch (type) {
default: type = '';
break;
case 'exp':
type = 'exp';
break;
case 'pl':
type = 'pl';
break;
}
console.log(type);
document.getElementById('previewPDF').innerHTML = '<iframe style="border:none;width:100%;height:1200px;" frameborder="no" src="index.php?module=EcmInvoiceOutOlds&action=previewPDF&type=' + type + '&to_pdf=1&method=I&record=' + document.forms.DetailView.record.value + '#zoom=75">Yours browser not accept iframes!</iframe>';
}
setEMAIL = function(noCheck) {
SetTab('panel_EMAIL');
document.getElementById('emailTAB').innerHTML = '<iframe id="emailIFRAME" style="border:none;width:100%;height:670px;" frameborder="no" src="index.php?module=EcmInvoiceOutOlds&action=Emails&to_pdf=1&type=out&pTypeTo=' + document.forms.DetailView.parent_type.value + '&pIdTo=' + document.forms.DetailView.parent_id.value + '&pTypeFrom=Users&pIdFrom=' + document.forms.DetailView.assigned_user_id.value + '&invoiceout_id=' + document.forms.DetailView.record.value + '&record=' + document.forms.DetailView.email_id.value + '&type=' + type + '">Yours browser not accept iframes!</iframe>';
}
setInterval(function() {
doRequest('index.php', "module=EcmInvoiceOutOlds&action=subpanels&to_pdf=1&record=" + document.forms.DetailView.record.value,
function(result) {
if (result != '' && document.getElementById('subpanels_div'))
document.getElementById('subpanels_div').innerHTML = result;
}
);
},
10000
);
//quick view
var main = document.getElementById('main');
if (main) {
var h2 = main.getElementsByTagName('h2')[0];
if (h2) {
h2.style.display = 'inline';
var quickInfoH2 = document.getElementById('quickInfoH2');
if (quickInfoH2) {
h2.parentNode.appendChild(quickInfoH2);
quickInfoH2.style.display = '';
}
}
}
if (OPT['setTab'] && OPT['setTab'] != '') {
if (OPT['setTab'] == 'EMAIL')
setEMAIL();
}
for (var i = 0; i < N.rowCount(); i++) {
//N.row(i).calculateTotal();
}
if (INV_ERROR == '1') {
//some error
// BRAK POWIĄZANEJ POZYCJI FAKTURY/korekty w zależności ile tam tego bylo Z KOREKTĄ!
console.log("BRAK POWIĄZANEJ POZYCJI FAKTURY/korekty w zależności ile tam tego bylo Z KOREKTĄ! Sprawdź w bazie pole ecminvoiceoutolditems.old_ecminvoiceoutolditem_id czy jest uzupełnione");
alert('Brak podglądu PDF. Skontaktuj się z Administratorem.');
document.getElementById('productcard').style.display = 'none';
//document.getElementById('create_correct').style.display='none';
}
}
);

View File

@@ -0,0 +1,822 @@
<?php
if (!defined('sugarEntry') || !sugarEntry)
die('Not A Valid Entry Point');
//require_once('modules/EcmGroupSales/HeaderMenu.php');
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings, $current_user, $app_list_strings;
require_once('modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php');
require_once('modules/EcmInvoiceOutOlds/Forms.php');
require_once ('include/time.php');
require_once('include/json_config.php');
$json_config = new json_config();
$file = 'modules/EcmGroupSales/EcmGroupSale.php';
if (file_exists($file)) {
$cc = array();
require_once($file);
$cc = EcmGroupSale::loadSettings();
}
$OPT = array();
$OPT['row_item_height'] = $cc['row_item_height'];
$OPT['row_item_height_selected'] = $cc['row_item_height_selected'];
$OPT['rows_on_item_list'] = $cc['rows_on_item_list'];
$OPT['position_table_height'] = $OPT['row_item_height'] * $OPT['rows_on_item_list'] + 40 + $OPT['rows_on_item_list'] * 4;
$OPT['quick_product_item_adding'] = $cc['quick_product_item_adding'];
if ($cc['checkbox_demo'] == 1) {
$query = "SELECT COUNT(id) as count FROM ecminvoiceoutolds WHERE deleted='0'";
$result = $GLOBALS['db']->query($query);
if (is_resource($result)) {
$row = $GLOBALS['db']->fetchByAssoc($result);
if (isset($row['count']) && is_numeric($row['count'] = intval($row['count'])) && $row['count'] >= 10)
$OPT['checkbox_demo'] = 1;
}
}
$OPT['check_parent_id'] = true;
$cq = $current_user->getPreference('confirm_invoiceouts');
$OPT['user']['confirm_invoiceouts'] = ((isset($cq) && $cq) ? 1 : 0);
$focus = new EcmInvoiceOutOld();
if (!$focus->id)
$temp_id = create_guid();
else
$temp_id = $focus->id;
//for outside modules
if (isset($_REQUEST['out_module']) && $_REQUEST['out_module'] != '' && isset($_REQUEST['out_id']) && $_REQUEST['out_id'] != '') {
// $focus->wz_id = $_REQUEST['out_id'];
$outModule = $_REQUEST['out_module'];
$outId = $_REQUEST['out_id'];
$OPT['fromOutside'] = true;
$path = 'modules/' . $outModule . '/LoadEcmInvoiceOutOlds.php';
if (file_exists($path)) {
require_once($path);
$_REQUEST['record'] = '';
$outside_create = true;
}
}
$pt = $pdid = null;
if (isset($_REQUEST['record']) && $_REQUEST['record'] != '') {
$focus->retrieve($_REQUEST['record']);
if (isset($focus->id) && $focus->id != '') {
if ($focus->accepted == 1) {
echo 'You cannot edit this invoiceout. This invoiceout is accepted. <a href="index.php?module=' . $_REQUEST['return_module'] . '&action=' . $_REQUEST['return_action'] . '&record=' . $_REQUEST['return_id'] . '">return</a>';
return;
}
$focus->format_all_fields();
$focus->position_list = str_replace('&quot;', '\"', $focus->getPositionList());
//has wz?
$r = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT ecmstockdocout_id as wz FROM ecminvoiceoutolditems WHERE ecminvoiceoutold_id='" . $focus->id . "'"));
if ($r['wz'] && $r['wz'] != '')
$OPT['from_wz'] = true;
}
} elseif ($_REQUEST['parent_doc_type'] == 'EcmStockDocOuts') {
//unset($_SESSION['temp_id']);
//add mz 2012-04-11
$OPT['new_number'] = true;
$OPT['from_wz'] = true;
//create products array
$r = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT * FROM ecmstockdocouts WHERE id='" . $_REQUEST['parent_doc_id'] . "'"));
$a = new Account();
$a->retrieve($r['parent_id']);
$focus->parent_id = $r['parent_id'];
$focus->parent_name = $r['parent_name'];
$focus->parent_address_street = $r['parent_address_street'];
$focus->parent_address_city = $r['parent_address_city'];
$focus->parent_address_postalcode = $r['parent_address_postalcode'];
$focus->parent_address_country = $r['parent_address_country'];
$focus->to_nip = $a->to_vatid;
$focus->ecmpaymentcondition_id = $a->ecmpaymentcondition_id;
$focus->supplier_code = $a->supplier_code;
//saturn??
if ($a->parent_id=='1249') {
$s = new Account();
$s->retrieve('1249');
$a->ecmpaymentcondition_id = $s->ecmpaymentcondition_id;
unset($s);
}
$pc = new EcmPaymentCondition();
$pc->retrieve($a->ecmpaymentcondition_id);
$focus->ecmpaymentcondition_id = $pc->id;
$focus->ecmpaymentcondition_name = $pc->name;
if ($a->parent_id!='1249')
$focus->payment_date=$GLOBALS['timedate']->to_display_date(date("Y-m-d",mktime()+3600*24*$pc->days));
else {
$s = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT delivery_date FROM ecmsales WHERE id='".$r['ecmsale_id']."'"));
$d = date('Y-m-t', strtotime($s['delivery_date']));
$focus->payment_date=$GLOBALS['timedate']->to_display_date(date("Y-m-d",mktime()+3600*24*60));
}
$s = new EcmSale();
$s->retrieve($r['ecmsale_id']);
//delivery address
$focus->parent_shipping_address_name = $s->shipping_address_name;
$focus->parent_shipping_address_street = $s->shipping_address_street;
$focus->parent_shipping_address_city = $s->shipping_address_city;
$focus->parent_shipping_address_postalcode = $s->shipping_address_postalcode;
$focus->parent_shipping_address_country = $s->shipping_address_country;
$focus->parent_contact_name = $r['parent_contact_name'];
$focus->parent_contact_title = $r['parent_contact_title'];
$focus->order_no = $r['parent_order_no'];
$focus->contact_id = $r['contact_id'];
$focus->name = $r['name'];
$focus->wz_id = $_REQUEST['parent_doc_id'];
//set possition list
$pl = array ();
$res = $GLOBALS ['db']->query ( "SELECT * FROM ecmstockdocoutitems WHERE ecmstockdocout_id ='" . $_REQUEST ['parent_doc_id'] . "' order by position" );
global $app_list_strings;
while ( $r = $GLOBALS ['db']->fetchByAssoc ( $res ) ) {
$t = $GLOBALS ['db']->fetchByAssoc ( $GLOBALS ['db']->query ( "SELECT unit_id,vat_value,vat_id,vat_name FROM ecmproducts WHERE id='" . $r['ecmproduct_id'] . "'" ) );
$subprice = $r['price_sell'];
$subtotal = $r['quantity'] * $subprice;
$vat = $subtotal * ($t['vat_value'] / 100);
$total = $subtotal + $vat;
$price = $total / $r['quantity'];
$position = array ();
$position ['iid'] = create_guid ();
$position ['code'] = $r ['code'];
$position ['name'] = $r ['name'];
$position ['id'] = $r ['ecmproduct_id'];
$position ['quantity'] = $r ['quantity'];
// calculate currency
$position ['startprice'] = $r ['price_sell'];
$position['subprice'] = $subprice;
$position['price'] = $price;
$position['subtotal'] = $subtotal;
$position['total'] = $total;
// $position['selling_price'] = $r['price'];
$position ['discount'] = $r ['discount'];
$position ['unit_id'] = $t['unit_id'];
$position ['unit_name'] = $app_list_strings['ecmproducts_unit_dom'][$t['unit_id']];
$position ['vat_id'] = $t ['vat_id'];
$position ['vat_name'] = $t ['vat_name'];
$position ['vat_value'] = $t ['vat_value'];
$position ['category_id'] = $r ['ecmproductcategory_id'];
$position ['currency_id'] = $r ['currency_id'];
$position ['currency_name'] = $r ['currency_name'];
$position ['recipient_code'] = $r ['supplier_code'];
$position ['type'] = $t ['type'];
$position ['parent_doc_id'] = $r ['ecmstockdocout_id'];
$position ['parent_doc_type'] = 'EcmStockDocOut';
$position ['parent_doc_item_id'] = $r ['id'];
$position ['temp_item_id'] = create_guid ();
$position ['temp_date'] = date ( "Y-m-d H:i:s" );
//include_once ("modules/EcmStockOperations/EcmStockOperation.php");
//$op = new EcmStockOperation ();
//$position ['stock'] = $op->getStock ( $r ['ecmproduct_id'], $focus->stock_id );
//$position ['parent_doc_rq'] = $op->getStockR ( $r ['ecmproduct_id'], $focus->stock_id );
$pl [] = $position;
}
$focus->position_list = str_replace ( '&quot;', '\"', $json->encode ( $pl ) );
} elseif ($_REQUEST['parent_doc_type'] == 'EcmQuotes') {
session_start();
$positions = $_SESSION[$_REQUEST['temp_id']];
//var_dump($_SESSION[$_REQUEST['temp_id']]);
$sales = array();
foreach ($positions as $v)
$sales[] = $v['parent_doc_id'];
$OPT['new_number'] = true;
$OPT['parent_doc_type'] = 'EcmQoutes';
$temp_id = $_REQUEST['temp_id'];
//set accounts information
$r = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT * FROM ecmquotes WHERE id='" . $positions[0]['parent_doc_id'] . "'"));
$focus->payment_method = $r['payment_method'];
//$focus->payment_date_d = $r['payment_deadline'];
$focus->parent_id = $r['parent_id'];
$focus->parent_name = $r['parent_name'];
$focus->parent_contact_name = $r['parent_contact_name'];
$focus->parent_contact_title = $r['parent_contact_title'];
$focus->parent_address_street = $r['parent_address_street'];
$focus->parent_address_city = $r['parent_address_city'];
$focus->parent_address_postalcode = $r['parent_address_postalcode'];
$focus->parent_address_country = $r['parent_address_country'];
$focus->order_no = $r['order_no'];
$focus->to_is_vat_free = $r['to_is_vat_free'];
$focus->contact_id = $r['contact_id'];
$focus->stock_id = $r['stock_id'];
$focus->to_nip = $r['to_vatid'];
$focus->currency_value = $r['currency_value'];
$focus->pdf_type = $r['invoice_type'];
$focus->currency_id = $r['currency_id'];
$focus->parent_shipping_address_name = $r['parent_shipping_address_name'];
$focus->parent_shipping_address_street = $r['parent_shipping_address_street'];
$focus->parent_shipping_address_city = $r['parent_shipping_address_city'];
$focus->parent_shipping_address_postalcode = $r['parent_shipping_address_postalcode'];
$focus->parent_shipping_address_country = $r['parent_shipping_address_country'];
//set possition list
//get prepayment informations
global $db;
$res = $db->query("SELECT document_no, inv_value, currency_id, currency_value FROM ecmprepaymentinvoices WHERE ecmquote_id IN ('".implode("','", $sales)."')");
$sum = 0;
while ($row = $db->fetchByAssoc($res)) {
$sum+=$row['inv_value'];
$focus->prepaid_nr.=$row['document_no'].' ';
//$focus->currency_id = $row['currency_id'];
//$focus->currency_value = $row['currency_value'];
}
//get older invoices prepaid
$old = $db->fetchByAssoc($db->query("SELECT sum(i.prepaid) as s FROM ecminvoiceoutolds AS i INNER JOIN ecminvoiceoutolditems as ii ON i.id=ii.ecminvoiceoutold_id WHERE ii.parent_doc_id IN ('".implode("','", $sales)."')"));
// echo '<pre>'. var_export($sum, true);
// exit;
$sum+=$old['s'];
$focus->prepaid=$sum;
// echo '<pre>'. var_export($sum, true);
// exit;
//get parent currency
$cur = $db->fetchByAssoc($db->query("SELECT currency_id as cid FROM accounts WHERE id='".$focus->parent_id."'"));
$c = new Currency();
$c->retrieve($cur['cid']);
$focus->currency_id = $cur['cid'];
$focus->currency_value = $c->conversion_rate;
unset($c);
$pl = array();
foreach ($positions as $pos) {
$r = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT * FROM ecmquoteitems WHERE id ='" . $pos['parent_doc_item_id'] . "'"));
$t = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT type FROM ecmproducts WHERE id='".$pos['id']."'"));
$position = array();
// echo '<pre>' . var_export($r, true) . '</pre>';
// echo '<pre>' . var_export($t, true) . '</pre>';
// exit;
$position['iid'] = create_guid();
$position['code'] = $pos['code'];
$position['name'] = $pos['name'];
$position['id'] = $pos['id'];
$position['quantity'] = $pos['quantity'];
//calculate currency
$position['startprice'] = $r['price'];
/*
if ($r['currency_id']==$focus->currency_id)
$position['startprice'] = $r['price'];
else {
$c = new Currency();
$c->retrieve($r['currency_id']);
if ($focus->currency_id=='PLN') {
$position['startprice'] = $r['price']*$c->conversion_rate;
} else {
$position['startprice'] = $r['price']/$focus->currency_value;
}
}
*/
//$position['selling_price'] = $r['price'];
$position['discount'] = $r['discount'];
$position['total'] = $r['total'];
$position['unit_id'] = $r['dd_unit_id'];
$position['unit_name'] = $r['dd_unit_name'];
$position['vat_id'] = $r['ecmvat_id'];
$position['vat_name'] = $r['ecmvat_name'];
$position['vat_value'] = $r['ecmvat_value'];
$position['category_id'] = $r['ecmproductcategory_id'];
$position['currency_id'] = $r['currency_id'];
$position['currency_name'] = $r['currency_name'];
$position['recipient_code'] = $r['recipient_code'];
$position['type'] = $t['type'];
$position['parent_doc_id'] = $r['ecmquote_id'];
$position['parent_doc_type'] = 'EcmQuotes';
$position['parent_doc_item_id'] = $pos['parent_doc_item_id'];
$position['temp_item_id'] = create_guid();
$position['temp_date'] = date("Y-m-d H:i:s");
include_once("modules/EcmStockOperations/EcmStockOperation.php");
$op = new EcmStockOperation();
$position['stock'] = $op->getStock($r['ecmproduct_id'], $focus->stock_id);
$position['parent_doc_rq'] = $op->getStockR($r['ecmproduct_id'], $focus->stock_id);
$pl[] = $position;
}
$focus->position_list = str_replace('&quot;', '\"', $json->encode($pl));
}
elseif ('EcmServices' == @$_REQUEST['parent_doc_type']) {
/* BOF: EcmServices. */
$pt = 'Service';
$pdid = $id = @$_REQUEST['uid'];
$OPT['new_number'] = true;
$OPT['from_sale'] = true;
$temp_id = $_REQUEST['temp_id'];
//set accounts information
$query = 'SELECT s.* FROM `ecmservices` AS s WHERE s.`id` = \'' . $id . '\';';
$result = $GLOBALS['db']->query($query);
$r = $GLOBALS['db']->fetchByAssoc($result);
//echo '<pre>' . var_export($_REQUEST, true) . PHP_EOL;
//echo '<pre>' . var_export($r, true) . PHP_EOL;
//echo '<pre>' . var_export($mod_strings, true) . PHP_EOL;
//exit;
$focus->parent_id = $r['parent_id'];
$focus->parent_name = $r['parent_name'];
$focus->parent_contact_name = $r['parent_contact_name'];
$focus->parent_contact_title = $r['parent_contact_title'];
$focus->parent_address_street = $r['parent_address_street'];
$focus->parent_address_city = $r['parent_address_city'];
$focus->parent_address_postalcode = $r['parent_address_postalcode'];
$focus->parent_address_country = $r['parent_address_country'];
$focus->order_no = $r['order_no'];
$focus->to_is_vat_free = $r['to_is_vat_free'];
$focus->contact_id = $r['contact_id'];
$focus->stock_id = $r['stock_id'];
$focus->name = sprintf(@$mod_strings['SERVICE_INVOICE_NAME'], $r['document_no']);
//get NIP
//$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT nip FROM accounts WHERE id='" . $focus->parent_id . "'"));
$focus->to_vatid = $r['nip'];
//set possition list
$pl = array();
$pQuery = 'SELECT si.* FROM `ecmserviceitems` AS si WHERE si.`ecmservice_id` = \'' . $id . '\' AND si.`product_type` != \'income\';';
$pResult = $GLOBALS['db']->query($pQuery);
while ($ir = $GLOBALS['db']->fetchByAssoc($pResult)) {
$position = array();
$position['iid'] = create_guid();
$position['code'] = $ir['code'];
$position['name'] = $ir['name'];
$position['id'] = $ir['ecmproduct_id'];
$position['quantity'] = $ir['quantity'];
$position['price'] = $ir['price'];
$position['selling_price'] = $ir['price'];
$position['discount'] = $ir['discount'];
$position['total'] = $ir['total'];
$position['unit_id'] = $ir['dd_unit_id'];
$position['unit_name'] = $ir['dd_unit_name'];
$position['vat_id'] = $ir['ecmvat_id'];
$position['vat_name'] = $ir['ecmvat_name'];
$position['vat_value'] = $ir['ecmvat_value'];
$position['category_id'] = $ir['ecmproductcategory_id'];
$position['currency_id'] = $ir['currency_id'];
$position['currency_name'] = $ir['currency_name'];
$position['recipient_code'] = $ir['recipient_code'];
$position['ecmstockdocout_id'] = $ir['ecmstockdocout_id'];
$position['type'] = $ir['product_type'];
$position['temp_item_id'] = $ir['temp_item_id'];
$position['temp_date'] = date("Y-m-d H:i:s");
//
$position['parent_doc_id'] = $id;
$position['parent_doc_type'] = 'EcmService';
include_once("modules/EcmStockOperations/EcmStockOperation.php");
$op = new EcmStockOperation();
$position['stock'] = $op->getStock($ir['ecmproduct_id'], $focus->stock_id);
$pl[] = $position;
}
//exit;
$focus->position_list = str_replace('&quot;', '\"', $json->encode($pl));
/* EOF: EcmServices. */
} elseif (isset($_REQUEST['ecmsale_id'])) {
$OPT['new_number'] = true;
$OPT['from_sale'] = true;
$s = new EcmSale();
$s->retrieve($_REQUEST['ecmsale_id']);
$a = new Account();
$a->retrieve($s->parent_id);
$focus->parent_id = $s->parent_id;
$focus->parent_name = $s->parent_name;
$focus->parent_address_street = $s->parent_address_street;
$focus->parent_address_city = $s->parent_address_city;
$focus->parent_address_postalcode = $s->parent_address_postalcode;
$focus->parent_address_country = $s->parent_address_country;
$focus->to_nip = $s->to_vatid;
$focus->ecmpaymentcondition_id = $s->ecmpaymentcondition_id;
$focus->supplier_code = $a->supplier_code;
$pc = new EcmPaymentCondition();
$pc->retrieve($s->ecmpaymentcondition_id);
$focus->ecmpaymentcondition_name = $pc->name;
//$focus->payment_date=$GLOBALS['timedate']->to_display_date(date("Y-m-d",mktime()+3600*24*$pc->days));
//delivery address
$focus->parent_shipping_address_name = $s->parent_shipping_address_name;
$focus->parent_shipping_address_street = $s->parent_shipping_address_street;
$focus->parent_shipping_address_city = $s->parent_shipping_address_city;
$focus->parent_shipping_address_postalcode = $s->parent_shipping_address_postalcode;
$focus->parent_shipping_address_country = $s->parent_shipping_address_country;
$focus->template_id = $s->template_id;
$focus->template_name = $s->template_name;
$focus->parent_contact_name = $s->parent_contact_name;
$focus->parent_contact_title = $s->parent_contact_title;
$focus->order_no = $s->parent_order_no;
$focus->contact_id = $s->contact_id;
$focus->name = $s->name;
$focus->register_date=$GLOBALS['timedate']->to_display_date(date("Y-m-d"));
$focus->sell_date=$GLOBALS['timedate']->to_display_date(date("Y-m-d"));
$focus->status="accepted";
$focus->type = "normal";
$focus->assigned_user_id=$s->assigned_user_id;
$focus->created_by=$s->created_by;
$focus->modified_user_id=$s->modified_user_id;
$focus->pdf_type=$s->pdf_type;
$focus->currency_id=$s->currency_id;
unset($s);
//set possition list
$pl = array ();
$res = $GLOBALS ['db']->query ( "SELECT * FROM ecmsaleitems WHERE ecmsale_id ='" . $_REQUEST['ecmsale_id'] . "' order by position" );
global $app_list_strings;
while ( $r = $GLOBALS ['db']->fetchByAssoc ( $res ) ) {
$t = $GLOBALS ['db']->fetchByAssoc ( $GLOBALS ['db']->query ( "SELECT id, unit_id FROM ecmproducts WHERE deleted='0' AND code='" . $r['code'] . "'" ) );
echo $r['code'].' - '.$t['id'].'<br>';
$subprice = $r['price'];
$subtotal = $r['quantity'] * $subprice;
$vat = $subtotal * ($r['ecmvat_value'] / 100);
$total = $subtotal + $vat;
$price = $total / $r['quantity'];
$position = array ();
$position ['iid'] = create_guid ();
$position ['code'] = $r ['code'];
$position ['name'] = $r ['name'];
$position ['id'] = $t ['id'];
$position ['quantity'] = $r ['quantity'];
// calculate currency
$position ['startprice'] = $r ['price'];
$position['subprice'] = $subprice;
$position['price'] = $price;
$position['subtotal'] = $subtotal;
$position['total'] = $total;
$position ['discount'] = $r ['discount'];
$position ['unit_id'] = $t['unit_id'];
$position ['unit_name'] = $app_list_strings['ecmproducts_unit_dom'][$t['unit_id']];
$position ['vat_id'] = $r ['ecmvat_id'];
$position ['vat_name'] = $r ['ecmvat_name'];
$position ['vat_value'] = $r ['ecmvat_value'];
$position ['category_id'] = $r ['ecmproductcategory_id'];
$position ['currency_id'] = $r ['currency_id'];
$position ['currency_name'] = $r ['currency_name'];
$position ['recipient_code'] = $r ['recipient_code'];
$position ['type'] = $t ['type'];
$position ['parent_doc_id'] = $r ['ecmsale_id'];
$position ['parent_doc_type'] = 'EcmSale';
$position ['parent_doc_item_id'] = $r ['id'];
$position ['temp_item_id'] = create_guid ();
$position ['temp_date'] = date ( "Y-m-d H:i:s" );
$pl [] = $position;
}
// var_dump($pl);
$focus->position_list = str_replace('&quot;', '\"', $json->encode($pl));
}
else {
if (isset($_REQUEST['contact_id']) && $_REQUEST['contact_id'] != '' && isset($_REQUEST['contact_name']) && $_REQUEST['contact_name'] != '') {
$_REQUEST['parent_type'] = 'Contacts';
$_REQUEST['parent_name'] = $_REQUEST['contact_name'];
$_REQUEST['parent_id'] = $_REQUEST['contact_id'];
$OPT['check_parent_id'] = false;
}
if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '' && isset($_REQUEST['account_name']) && $_REQUEST['account_name'] != '') {
$_REQUEST['parent_type'] = 'Accounts';
$_REQUEST['parent_name'] = $_REQUEST['account_name'];
$_REQUEST['parent_id'] = $_REQUEST['account_id'];
$OPT['check_parent_id'] = false;
}
$OPT['new_number'] = true;
if (isset($cc)) {
//payment condition
$cc_list = EcmGroupSale::getPositionList('ecmpaymentconditions');
//$focus->ecmpaymentcondition_id = $cc['default_payment_condition'];
//$focus->ecmpaymentcondition_name = $cc_list[$cc['default_payment_condition']];
//default template
$focus->template_id = $cc['default_document_template'];
$fftemplateid = $focus->template_id;
}
}
$OPT['old_status'] = (isset($focus->status) && $focus->status != '') ? $focus->status : 'not_accepted';
$OPT['invoice']['type'] = (isset($focus->type) && $focus->type != '') ? $focus->status : 'normal';
if ($_REQUEST['isDuplicate'] == 'true' || $outside_create == true) {
$_POST['isDuplicate'] = true;
$focus->id = '';
$OPT['isDuplicate'] = true;
$OPT['new_number'] = true;
}
if (!isset($focus->discount) || $focus->discount == '')
$focus->discount = '0.00';
if ($OPT['new_number'] == true) {
$datef = $current_user->getPreference('datef');
if ($datef != '')
$sugar_config['datef'];
$focus->register_date = date($datef);
//$focus->payment_date = date($datef, mktime() + 30 * 24 * 60 * 60);
$focus->sell_date = date($datef);
}
$cur = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select value from currency_nbp_archive where date<'".$focus->register_date."' and currency_id='".$focus->currency_id."' order by date desc limit 0,1;"));
if ($cur['value'])
$focus->currency_value_nbp = $cur['value'];
//echo "select value from currency_nbp_archive where date<'".$focus->register_date."' and currency_id='".$focus->currency_id."' order by date desc limit 0,1;";
if (isset($_REQUEST['out_module']) && $_REQUEST['out_module'] != '' && isset($_REQUEST['out_id']) && $_REQUEST['out_id'] != '') {
//todo dodać relację
//$focus->wz_id = $_REQUEST['out_id'];
}
$tmp = $current_user->getPreference('num_grp_sep');
if (!isset($tmp) || $tmp == '' || $tmp == NULL)
$tmp = $sugar_config['default_number_grouping_seperator'];
$OPT['sep_1000'] = $tmp;
$tmp = $current_user->getPreference('dec_sep');
if (!isset($tmp) || $tmp == '' || $tmp == NULL)
$tmp = $sugar_config['default_decimal_seperator'];
$OPT['dec_sep'] = $tmp;
$tmp = $current_user->getPreference('default_currency_significant_digits');
if (!isset($tmp) || $tmp == '' || $tmp == NULL)
$tmp = $sugar_config['default_currency_significant_digits'];
$OPT['dec_len'] = $tmp;
$OPT['default_unit'] = "1";
$OPT['default_vat'] = "23.00";
$OPT['default_category'] = "";
$OPT['default_currency'] = "-99";
$OPT['type'] = $focus->type;
$OPT['to_is_vat_free'] = $focus->to_is_vat_free;
require_once('modules/EcmTexts/EcmText.php');
foreach ($app_list_strings['ecmlanguages_dom'] as $key => $value) {
$data = EcmText::LoadText(null, null, "EcmInvoiceOutOlds", $key);
//var_dump($data);
if (isset($data[0]) && isset($data[0]['data']))
$d = $data[0]['data']; else {
$d = $PDFLL;
if (!isset($d['labels']))
$d['labels'] = $PDFLL['labels'];
if (!isset($d['texts']['Contacts']['header_text']))
$d['texts']['Contacts']['header_text'] = $mod_strings['LBL_DEFAULT_CONTACT_HEADER_TEXT'];
if (!isset($d['texts']['Contacts']['footer_text']))
$d['texts']['Contacts']['footer_text'] = $mod_strings['LBL_DEFAULT_CONTACT_FOOTER_TEXT'];
if (!isset($d['texts']['Contacts']['ads_text']))
$d['texts']['Contacts']['ads_text'] = $mod_strings['LBL_DEFAULT_CONTACT_ADS_TEXT'];
if (!isset($d['texts']['Accounts']['header_text']))
$d['texts']['Accounts']['header_text'] = $mod_strings['LBL_DEFAULT_ACCOUNT_HEADER_TEXT'];
if (!isset($d['texts']['Accounts']['footer_text']))
$d['texts']['Accounts']['footer_text'] = $mod_strings['LBL_DEFAULT_ACCOUNT_FOOTER_TEXT'];
if (!isset($d['texts']['Accounts']['ads_text']))
$d['texts']['Accounts']['ads_text'] = $mod_strings['LBL_DEFAULT_ACCOUNT_ADS_TEXT'];
}
$OPT['ecmlanguage'][$key]['texts'] = $d['texts'];
}
$w = $GLOBALS[db]->query("select name,id,value from ecmvats where deleted='0' order by name");
$nvats = mysql_num_rows($w);
while ($r = $GLOBALS[db]->fetchByAssoc($w)) {
$VAT[$r['id']] = array(
"id" => $r['id'],
"name" => $r['name'],
"value" => $r['value']
);
}
$show_pdf = $current_user->getPreference('show_pdf_in_div');
if (!isset($show_pdf)) {
require_once('modules/EcmGroupSales/EcmGroupSale.php');
$cc = EcmGroupSale::loadSettings();
$show_pdf = $cc['show_pdf_in_div_global'];
}
$json = getJSONobj();
$larr = array("en_us", "pl_pl", "ge_ge");
foreach ($larr as $la) {
$lv = return_app_list_strings_language($la);
$UNIT_LANG[$la] = $lv['ecmproducts_unit_dom'];
}
$scriptOpt.='<script language="javascript">
var UNIT_LANG=' . str_replace('&quot;', '\"', $json->encode($UNIT_LANG)) . ';
</script>';
require_once('include/MVC/View/SugarView.php');
require_once('modules/EcmInvoiceOutOlds/view/EditView/view.edit.my.php');
$edit = new ViewEditMy();
$edit->ss = new Sugar_Smarty();
$edit->module = 'EcmInvoiceOutOlds';
$edit->bean = $focus;
$edit->tplFile = 'include/ECM/EcmViews/EditView/Tabs/EditView.tpl';
$stocks = '<option value="">' . $GLOBALS['app_list_strings']['stock_select'] . '</option>';
$w = $GLOBALS['db']->query("select name,id from ecmstocks where deleted='0' order by name asc");
while ($r = $GLOBALS['db']->fetchByAssoc($w)) {
$stocks.='<option value="' . $r['id'] . '"';
if ($r['id'] == $focus->stock_id)
$stocks.=' selected';
if ((!$focus->stock_id || $focus->stock_id=='') && $r['id']=='2962f1ad-79f4-a1ad-385e-4f286ad7acb5')
$stocks.=' selected';
$stocks.='>' . $r['name'] . '</option>';
}
if (isset($_REQUEST['isCorrect']) && $_REQUEST['isCorrect'] == 'true') {
$OPT['new_number'] = true;
}
$edit->ss->assign("PARENT_TYPE", $pt ? : 'Accounts');
$edit->ss->assign("PARENT_DOC_ID", $pdid);
$edit->ss->assign("STOCK", $stocks);
$edit->ss->assign("OPT", $OPT);
$edit->ss->assign("TEMP_ID", $temp_id);
$scriptOpt = '<script language="javascript">
var SHOW_PDF_IN_DIV =' . $show_pdf . ';
var UNIT =' . str_replace('&quot;', '\"', $json->encode($GLOBALS['app_list_strings']['ecmproducts_unit_dom'])) . ';
var VAT = ' . str_replace('&quot;', '\"', $json->encode($VAT)) . ';
var OPT = ' . str_replace('&quot;', '\"', $json->encode($OPT)) . ';
var MOD = ' . str_replace('&quot;', '\"', $json->encode($mod_strings)) . ';
var N;
</script>';
echo $scriptOpt;
$edit->preDisplay();
if (isset($_REQUEST['isCorrect']) && $_REQUEST['isCorrect'] == 'true') {
$focus->type = 'correct';
$focus->name = '';
$focus->ecminvoiceoutold_id = $focus->id;
$focus->ecminvoiceoutold_name = $focus->document_no;
$focus->id = '';
$datef = $current_user->getPreference('datef');
if ($datef != '')
$sugar_config['datef'];
$focus->register_date = date($datef);
$focus->sell_date = date($datef);
}
if (isset($fftemplateid) && $fftemplateid != '')
$focus->template_id = $fftemplateid;
$arr_template = $focus->getTemplateList();
if (isset($outside_create) && $outside_create == true) {
$edit->ss->assign("OUT_MODULE", $_REQUEST['out_module']);
$edit->ss->assign("OUT_ID", $_REQUEST['out_id']);
}
$arr_template = $focus->getTemplateList();
$tt="";
foreach($arr_template as $k=>$v){
$tt.='<option value="'.$k.'"';
if($k==$focus->template_id)$tt.=' selected';
$tt.='>'.$v.'</option>';
}
$edit->ss->assign("DOCUMENT_TEMPLATES_OPTIONS", $tt);
$edit->ss->assign("POSITION_LIST", $focus->position_list);
$edit->ss->assign("MFP", $focus->loadParserArray());
if (isset($focus->id) && $focus->id!='' && $current_user->id!='1')
die ('NIE WOLNO SAMEMU EDYTOWAĆ FAKTUR!');
echo $edit->display();

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,369 @@
<?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 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU 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 General Public License for more
* details.
*
* You should have received a copy of the GNU 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 General Public License version 3.
*
* In accordance with Section 7(b) of the GNU 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".
* *******************************************************************************/
/*********************************************************************************
* Description:
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
* Reserved. Contributor(s): ______________________________________..
*********************************************************************************/
/*
if(isset($_REQUEST['type']) && $_REQUEST['type'] == "save_template_changes") {
require_once('modules/EmailTemplates/EmailTemplate.php');
$et = new EmailTemplate();
$et->retrieve($_REQUEST['email_template']);
if(isset($et->id) && $et->id != '') {
$et->name = $_REQUEST['new_template_name'];
$et->body = $_REQUEST['description'];
$et->body_html = $_REQUEST['descriptin_html'];
$et->save();
}
header("Location: index.php?action=Emails&module=EcmInvoiceOutOlds&to_pdf=1&type=out&record=$return_id&invoiceout_id=".$_REQUEST['invoiceout_id']."&sended=1&pTypeFrom=Users&pIdFrom=".$_REQUEST['pIdFrom']."&pTypeTo=".$_REQUEST['pTypeTo']."&pIdTo=".$_REQUEST['pIdTo']);
}
if(isset($_REQUEST['type']) && $_REQUEST['type'] == "save_template_as_new") {
echo "save_template_as_new";
die();
}
*/
//var_dump($_POST); die();
require_once('modules/Emails/Email.php');
$mod_strings = return_module_language($current_language, 'Emails');
///////////////////////////////////////////////////////////////////////////////
//// EMAIL SEND/SAVE SETUP
$focus = new Email();
if(!isset($prefix)) {
$prefix = '';
}
if(isset($_POST[$prefix.'meridiem']) && !empty($_POST[$prefix.'meridiem'])) {
$_POST[$prefix.'time_start'] = $timedate->merge_time_meridiem($_POST[$prefix.'time_start'], $timedate->get_time_format(true), $_POST[$prefix.'meridiem']);
}
//retrieve the record
if(isset($_POST['record']) && !empty($_POST['record'])) {
$focus->retrieve($_POST['record']);
}
if(isset($_REQUEST['user_id'])) {
$focus->assigned_user_id = $_REQUEST['user_id'];
}
if(!$focus->ACLAccess('Save')){
ACLController::displayNoAccess(true);
sugar_cleanup(true);
}
if(!empty($_POST['assigned_user_id']) && ($focus->assigned_user_id != $_POST['assigned_user_id']) && ($_POST['assigned_user_id'] != $current_user->id)) {
$check_notify = TRUE;
}
//populate the fields of this Email
$allfields = array_merge($focus->column_fields, $focus->additional_column_fields);
foreach($allfields as $field) {
if(isset($_POST[$field])) {
$value = $_POST[$field];
$focus->$field = $value;
}
}
if (!isset($_REQUEST['to_addrs'])) {
$_REQUEST['to_addrs'] = "";
}
if (!isset($_REQUEST['to_addrs_ids'])) {
$_REQUEST['to_addrs_ids'] = "";
}
if (!isset($_REQUEST['to_addrs_names'])) {
$_REQUEST['to_addrs_names'] = "";
}
if (!isset($_REQUEST['to_addrs_emails'])) {
$_REQUEST['to_addrs_emails'] = "";
}
//compare the 3 fields and return list of contact_ids to link:
$focus->to_addrs_arr = $focus->parse_addrs($_REQUEST['to_addrs'], $_REQUEST['to_addrs_ids'], $_REQUEST['to_addrs_names'], $_REQUEST['to_addrs_emails']);
// make sure the cc_* and bcc_* fields are at least empty if not set
$fields_to_check = array(
'cc_addrs',
'cc_addrs_ids',
'bcc_addrs',
'bcc_addrs_ids',
'cc_addrs_names',
'cc_addrs_emails',
'bcc_addrs_emails',
);
foreach ($fields_to_check as $field_to_check) {
if (!isset($_REQUEST[$field_to_check])) {
$_REQUEST[$field_to_check] = '';
}
}
$focus->cc_addrs_arr = $focus->parse_addrs($_REQUEST['cc_addrs'], $_REQUEST['cc_addrs_ids'], $_REQUEST['cc_addrs_names'], $_REQUEST['cc_addrs_emails']);
$focus->bcc_addrs_arr = $focus->parse_addrs($_REQUEST['bcc_addrs'], $_REQUEST['bcc_addrs_ids'], $_REQUEST['to_addrs_names'], $_REQUEST['bcc_addrs_emails']);
if(!empty($_REQUEST['type'])) {
$focus->type = $_REQUEST['type'];
} elseif(empty($focus->type)) { // cn: from drafts/invoiceouts
$focus->type = 'archived';
}
///////////////////////////////////////////////////////////////////////////////
//// PREP FOR ATTACHMENTS
if(empty($focus->id)){
$focus->id = create_guid();
$focus->new_with_id = true;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// ATTACHMENT HANDLING
$focus->handleAttachments();
if(isset($_REQUEST['invoiceout_id']) && $_REQUEST['invoiceout_id'] != '') {
require_once('modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php');
$off = new EcmInvoiceOutOld();
$off->retrieve($_REQUEST['invoiceout_id']);
$off->formatNumber();
if(isset($off->id) && $off->id != '') {
require_once('modules/Notes/Note.php');
$n = new Note();
$n->name = $mod_strings['LBL_EMAIL_ATTACHMENT'].': '.$off->createPdfFileName(false);
$n->filename = $off->createPdfFileName();
$n->file_mime_type = 'application/pdf';
$n->parent_id = $focus->id;
$n->parent_type = $focus->module_dir;
$n->parent_name = $focus->name;
$nid = $n->save();
if($nid) $off->getPDF(null,'F',$sugar_config['upload_dir'].$nid);
$focus->saved_attachments[] = $n;
}
$off->setTemplate();
$off->loadParser();
$focus->name = $off->template->mfp->parseText($focus->name);
$focus->description = $off->template->mfp->parseText($focus->description);
$focus->description_html = $off->template->mfp->parseText($focus->description_html);
}
///////////////////////////////////////////////////////////////////////////////
//// TEMPLATE PARSING
// cn: bug 7244 - need to pass an empty bean to parse email templates
$object_arr = array();
if(!empty($focus->parent_id)) {
$object_arr[$focus->parent_type] = $focus->parent_id;
}
if(isset($focus->to_addrs_arr[0]['contact_id'])) {
$object_arr['Contacts'] = $focus->to_addrs_arr[0]['contact_id'];
}
if(empty($object_arr)) {
$object_arr = array('Contacts' => '123');
}
// do not parse email templates if the email is being saved as draft....
if($focus->type != 'draft' && count($object_arr) > 0) {
require_once($beanFiles['EmailTemplate']);
$focus->name = EmailTemplate::parse_template($focus->name, $object_arr);
$focus->description = EmailTemplate::parse_template($focus->description, $object_arr);
$focus->description_html = EmailTemplate::parse_template($focus->description_html, $object_arr);
// if($focus->description == '') $focus->description = strip_tags(str_replace("<br>","\n",$focus->description_html));
// if($focus->description_html == '') $focus->description_html = str_replace("\n","<br>",$focus->description);
}
//// END TEMPLATE PARSING
///////////////////////////////////////////////////////////////////////////////
/*
var_dump($focus->parent_id);
var_dump($focus->saved_attachments[0]->name);
var_dump($focus->saved_attachments[0]->parent_name);
*/
//var_dump($focus->saved_attachments[0]->file);
//die();
//// END ATTACHMENT HANDLING
///////////////////////////////////////////////////////////////////////////////
$focus->status = 'draft';
if($focus->type == 'archived' ) {
$focus->status= 'archived';
} elseif(($focus->type == 'out' || $focus->type == 'forward') && isset($_REQUEST['send']) && $_REQUEST['send'] == '1') {
///////////////////////////////////////////////////////////////////////////
//// REPLY PROCESSING
$old = array('&lt;','&gt;');
$new = array('<','>');
if($_REQUEST['from_addr'] != $_REQUEST['from_addr_name'].' &lt;'.$_REQUEST['from_addr_email'].'&gt;') {
if(false === strpos($_REQUEST['from_addr'], '&lt;')) { // we have an email only?
$focus->from_addr = $_REQUEST['from_addr'];
$focus->from_name = '';
} else { // we have a compound string
$newFromAddr = str_replace($old, $new, $_REQUEST['from_addr']);
$focus->from_addr = substr($newFromAddr, (1 + strpos($newFromAddr, '<')), (strpos($newFromAddr, '>') - strpos($newFromAddr, '<')) -1 );
$focus->from_name = substr($newFromAddr, 0, (strpos($newFromAddr, '<') -1));
}
} elseif(!empty($_REQUEST['from_addr_email']) && isset($_REQUEST['from_addr_email'])) {
$focus->from_addr = $_REQUEST['from_addr_email'];
$focus->from_name = $_REQUEST['from_addr_name'];
} else {
$focus->from_addr = $focus->getSystemDefaultEmail();
}
//// REPLY PROCESSING
///////////////////////////////////////////////////////////////////////////
if($focus->send()) {
$focus->status = 'sent';
} else {
$focus->status = 'send_error';
}
}
$focus->to_addrs = $_REQUEST['to_addrs'];
// delete the existing relationship of all the email addresses with this email
$query = "update emails_email_addr_rel set deleted = 1 WHERE email_id = '{$focus->id}'";
$focus->db->query($query);
// delete al the relationship of this email with all the beans
$query = "update emails_beans set deleted = 1, bean_id = '', bean_module = '' WHERE email_id = '{$focus->id}'";
$focus->db->query($query);
if(isset($_REQUEST['object_type']) && !empty($_REQUEST['object_type']) && isset($_REQUEST['object_id']) && !empty($_REQUEST['object_id'])) {
//run linking code only if the object_id has not been linked as part of the contacts above
$GLOBALS['log']->debug("CESELY".$_REQUEST['object_type']);
if(!in_array($_REQUEST['object_id'],$exContactIds)){
$rel = strtolower($_REQUEST['object_type']);
$focus->load_relationship($rel);
$focus->$rel->add($_REQUEST['object_id']);
$GLOBALS['log']->debug("CESELY LOADED".$_REQUEST['object_type']);
}
}
//// handle legacy parent_id/parent_type relationship calls
elseif(isset($_REQUEST['parent_type']) && !empty($_REQUEST['parent_type']) && isset($_REQUEST['parent_id']) && !empty($_REQUEST['parent_id'])) {
//run linking code only if the object_id has not been linked as part of the contacts above
if(!isset($exContactIds) || !in_array($_REQUEST['parent_id'],$exContactIds)){
$rel = strtolower($_REQUEST['parent_type']);
$focus->load_relationship($rel);
$focus->$rel->add($_REQUEST['parent_id']);
}
}
//// END RELATIONSHIP LINKING
///////////////////////////////////////////////////////////////////////////////
// If came from email archiving edit view, this would have been set from form input.
if (!isset($focus->date_start))
{
$today = gmdate('Y-m-d H:i:s');
$focus->date_start = $timedate->to_display_date($today);
$focus->time_start = $timedate->to_display_time($today, true);
}
$focus->date_sent = "";
$focus->save(false);
//// END EMAIL SAVE/SEND SETUP
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// RELATIONSHIP LINKING
$focus->load_relationship('users');
$focus->users->add($current_user->id);
if(!empty($_REQUEST['to_addrs_ids'])) {
$focus->load_relationship('contacts');
$exContactIds = explode(';', $_REQUEST['to_addrs_ids']);
foreach($exContactIds as $contactId) {
$contactId = trim($contactId);
$focus->contacts->add($contactId);
}
}
///////////////////////////////////////////////////////////////////////////////
//// PAGE REDIRECTION
///////////////////////////////////////////////////////////////////////////////
$return_id = $focus->id;
if(empty($_POST['return_module'])) {
$return_module = "Emails";
} else {
$return_module = $_POST['return_module'];
}
if(empty($_POST['return_action'])) {
$return_action = "DetailView";
} else {
$return_action = $_POST['return_action'];
}
$GLOBALS['log']->debug("Saved record with id of ".$return_id);
require_once('include/formbase.php');
if($focus->type == 'draft') {
if($return_module == 'Emails') {
header("Location: index.php?module=$return_module&action=ListViewDrafts");
} else {
handleRedirect($return_id, 'Emails');
}
} elseif($focus->type == 'out') {
if($return_module == 'Home') {
header('Location: index.php?module='.$return_module.'&action=index');
}
if(!empty($_REQUEST['return_id'])) {
$return_id = $_REQUEST['return_id'];
}
header('Location: index.php?action='.$return_action.'&module='.$return_module.'&record='.$return_id.'&assigned_user_id='.$current_user->id.'&type=inbound');
} elseif(isset($_POST['return_id']) && $_POST['return_id'] != "") {
$return_id = $_POST['return_id'];
}
if(isset($_REQUEST['invoiceout_id']) && $_REQUEST['invoiceout_id'] != '') {
require_once('modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php');
$off = new EcmInvoiceOutOld();
$off->retrieve($_REQUEST['invoiceout_id']);
if(isset($off->id) && $off->id != '') {
$off->format_all_fields();
$off->email_id = $return_id;
$off->save();
}
}
header("Location: index.php?action=Emails&module=EcmInvoiceOutOlds&to_pdf=1&type=out&invoiceout_id=".$_REQUEST['invoiceout_id']."&sended=1&pTypeFrom=Users&pIdFrom=".$_REQUEST['pIdFrom']."&pTypeTo=".$_REQUEST['pTypeTo']."&pIdTo=".$_REQUEST['pIdTo']."&bodyclass=".$_REQUEST['bodyclass']);
?>

View File

@@ -0,0 +1,557 @@
<!--
/**
* EditView for Email
*
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU 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 General Public License for more
* details.
*
* You should have received a copy of the GNU 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 General Public License version 3.
*
* In accordance with Section 7(b) of the GNU 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".
*/
-->
<!-- BEGIN: main -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="">
<title></title>
<script type="text/javascript" src="include/javascript/sugar_grp1_yui.js?s=5.0.0c&c="></script>
<script type="text/javascript" src="include/javascript/sugar_grp1.js?s=5.0.0c&c="></script>
<script type="text/javascript" src="include/javascript/sugar_3.js?s=5.0.0c&c="></script>
<script type="text/javascript" src="include/javascript/sugar_grp1.js?s=5.0.0c&c="></script>
<script type="text/javascript" src="jscalendar/lang/calendar-en.js?s=5.0.0c&c="></script>
<script type="text/javascript" src="include/SugarFields/Fields/Address/SugarFieldAddress.js?s=5.0.0c&c="></script>
<script type="text/javascript" src="cache/jsLanguage/en_us.js?s=5.0.0c&c=&j=1">
</script><script type="text/javascript" src="cache/jsLanguage/Accounts/en_us.js?s=5.0.0c&c=&j=1"></script>
<script type="text/javascript" src="jssource/src_files/include/SugarEmailAddress/SugarEmailAddress.js?s=5.0.0c&c="></script>
<link rel="stylesheet" type="text/css" href="themes/Sugar/navigation.css?s=5.0.0c&c=" />
<link rel="stylesheet" type="text/css" href="themes/Sugar/style.css?s=5.0.0c&c=" />
<link rel="stylesheet" type="text/css" href="themes/Sugar/colors.sugar.css?s=5.0.0c&c=" id="current_color_style" />
<link rel="stylesheet" type="text/css" href="themes/Sugar/fonts.normal.css?s=5.0.0c&c=" id="current_font_style"/>
<script language="javascript" src="themes/default/SiteMapJS.js?s=5.0.0c&c="></script>
<script language="javascript" src="themes/menu.js?s=5.0.0c&c="></script>
<script language="javascript" src="themes/cookie.js?s=5.0.0c&c="></script>
<script language="javascript" src="themes/Sugar/style.js?s=5.0.0c&c="></script>
<script language="javascript" src="include/JSON.js?s=5.0.0c&c="></script>
<script type="text/javascript" language="Javascript">
{JS_VARS}
</script>
</head>
<body class="{BODYCLASS}" style="border:none;" onload="">
<script type="text/javascript" src="include/jsolait/init.js?s={SUGAR_VERSION}&amp;c={JS_CUSTOM_VERSION}"></script>
<script type="text/javascript" src="include/javascript/jsclass_base.js?s={SUGAR_VERSION}&amp;c={JS_CUSTOM_VERSION}"></script>
<script type="text/javascript" src="include/javascript/jsclass_async.js?s={SUGAR_VERSION}&amp;c={JS_CUSTOM_VERSION}"></script>
<script type="text/javascript" src="modules/EcmInvoiceOutOlds/Email.js?s={SUGAR_VERSION}&amp;c={JS_CUSTOM_VERSION}"></script>
<script type="text/javascript" src="modules/Documents/documents.js?s={SUGAR_VERSION}&amp;c={JS_CUSTOM_VERSION}"></script>
{MESSAGE}
<script language="javascript">
function doRequest(where,post,doFunction,error) {
this.Display = function(result) { doFunction(result.responseText); }
this.Fail = function(result){ if(error) alert(error);}
YAHOO.util.Connect.asyncRequest('POST',where,{success:this.Display,failure:this.Fail},post);
}
/*
function saveEmailTemplate() {
doRequest(
'index.php',
'module=EcmInvoiceOutOlds&action=saveEmailTemplate&template_id='+document.forms.EditView.email_template.value+'&template_name='+document.forms.EditView.new_template_name.value+'&name='+document.forms.EditView.name.value+'&'
);
}
*/
function saveTemplateChanges() {
document.forms.EditView.module.value="EcmInvoiceOutOlds";
document.forms.EditView.action.value="EmailSave";
document.forms.EditView.type.value="save_template_changes";
}
function saveTemplateAsNew() {
document.forms.EditView.module.value="EcmInvoiceOutOlds";
document.forms.EditView.action.value="EmailSave";
document.forms.EditView.type.value="save_template_as_new";
}
</script>
<form action="index.php" method="post" name="EditView" enctype="multipart/form-data">
<input type="hidden" name="module" value="EcmInvoiceOutOlds" />
<input type="hidden" name="action" value="EmailSave" />
<input type="hidden" name="to_pdf" value="1" />
<input type="hidden" name="contact_id" value="{CONTACT_ID}" />
<input type="hidden" name="user_id" value="{USER_ID}" />
<input type="hidden" name="return_module" value="{RETURN_MODULE}" />
<input type="hidden" name="return_id" value="{RETURN_ID}" />
<input type="hidden" name="send" value="" />
<input type="hidden" name="type" value="out" />
<input type="hidden" name="record" value="{ID}" />
<input type="hidden" name="return_action" value="{RETURN_ACTION}" />
<input type="hidden" name="inbound_email_id" value="{INBOUND_EMAIL_ID}" />
<input type="hidden" name="assigned_user_id" value="{ASSIGNED_USER_ID}" />
<input type="hidden" name="object_type" value="{OBJECT_TYPE}" />
<input type="hidden" name="object_id" value="{OBJECT_ID}" />
<input type="hidden" name="group" value="{GROUP}" />
<input type="hidden" name="origType" value="{TYPE}" />
<input type="hidden" name="invoiceout_id" value="{INVOICEOUT_ID}" />
<input type="hidden" name="pIdFrom" value="{PIDFROM}" />
<input type="hidden" name="pTypeFrom" value="{PTYPEFROM}" />
<input type="hidden" name="pIdTo" value="{PIDTO}" />
<input type="hidden" name="pTypeTo" value="{PTYPETO}" />
<input type="hidden" name="bodyclass" value="{BODYCLASS}" />
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="padding-bottom: 2px;">
<input type="submit" name="button" class="button" {disable_send} title="{MOD.LBL_SEND_BUTTON_TITLE}" accesskey="{MOD.LBL_SEND_BUTTON_KEY}" value=" {MOD.LBL_SEND_BUTTON_LABEL} " onclick="return invoiceoutAlert('save');" />
<!--
<input type="submit" name="button" class="button" title="{MOD.LBL_SAVE_AS_DRAFT_BUTTON_TITLE}" accesskey="{MOD.LBL_SAVE_AS_DRAFT_BUTTON_KEY}" value=" {MOD.LBL_SAVE_AS_DRAFT_BUTTON_LABEL} " onclick="return invoiceoutAlert('save_draft');" />
<input type="submit" name="button" class="button" title="{APP.LBL_CANCEL_BUTTON_TITLE}" accesskey="{APP.LBL_CANCEL_BUTTON_KEY}" value=" {APP.LBL_CANCEL_BUTTON_LABEL} " onclick="this.form.action.value='{RETURN_ACTION}'; this.form.module.value='{RETURN_MODULE}'; this.form.record.value='{RETURN_ID}'; {MYINBOX}" />
-->
</td>
<td align="right" nowrap>
</td>
<td align='right'>
{ADMIN_EDIT}
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<!-- BEGIN: open_source_1 -->
<td nowrap>
<slot>
</slot>
</td>
<td nowrap>
<slot>
</slot>
</td>
<!-- END: open_source_1 -->
<td nowrap>
<slot>
</slot>
</td>
<td class="dataLabel" valign="top" align="right">
<div style="display:none;">
<slot>
<select tabindex='2' name='parent_type' onchange=" document.EditView.parent_name.value='';
changeQS();
checkParentType(document.EditView.parent_type.value, document.EditView.change_parent);">
{TYPE_OPTIONS}</select>&nbsp;
</slot>
</div>
</td>
<td class="dataField" nowrap>
<div style="display:none;">
<slot>
<input id='parent_id' name='parent_id' type="hidden" value='{PARENT_ID}'>
<input class="sqsEnabled" id='parent_name' name='parent_name' tabindex='2' type='text' value="{PARENT_NAME}">
&nbsp;{CHANGE_PARENT_BUTTON}
</slot>
</div>
</td>
</tr>
<tr>
<td class="dataLabel">
<div style="display:none;">
<slot>
{APP.LBL_ASSIGNED_TO}&nbsp;
</slot>
</div>
</td>
<td class="dataField">
<div style="display:none;">
<slot>
<input class="sqsEnabled" tabindex='1' id="assigned_user_name" name='assigned_user_name' type="text" value="{ASSIGNED_USER_NAME}">
<input id='assigned_user_id' name='assigned_user_id' type="hidden" value="{ASSIGNED_USER_ID}" />
<input title="{APP.LBL_SELECT_BUTTON_TITLE}" accesskey="{APP.LBL_SELECT_BUTTON_KEY}" type="button" tabindex='1' class="button" value='{APP.LBL_SELECT_BUTTON_LABEL}' name="btn1" onclick='open_popup("Users", 600, 400, "", true, false, {encoded_users_popup_request_data});' />
</slot>
</div>
</td>
<td nowrap>
<slot>
</slot>
</td>
<td nowrap>
<slot>
</slot>
</td>
<td nowrap>
<slot>
</slot>
</td>
</tr>
<tr>
<td colspan="5">
&nbsp;
</td>
</tr>
<tr>
<td colspan="1">
&nbsp;
</td>
<td colspan="4">
{MOD.LBL_NOTE_SEMICOLON}
</td>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr valign="top">
<td class="dataLabel">
<slot>
{MOD.LBL_TO}
</slot>
</td>
<td colspan="4" class="dataField" nowrap="NOWRAP">
<slot>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<textarea id="to_addrs_field" name='to_addrs' tabindex='3' cols="80" rows="1" style="height: 1.6.em; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" value="{TO_ADDRS}">{TO_ADDRS}</textarea>
<input type="hidden" id="to_addrs_ids" name="to_addrs_ids" value="{TO_ADDRS_IDS}" />
<input type="hidden" id="to_addrs_emails" name="to_addrs_emails" value="{TO_ADDRS_EMAILS}" />
<input type="hidden" id="to_addrs_names" name="to_addrs_names" value="{TO_ADDRS_NAMES}" />
</td>
<td style="padding-left: 4px;">
{CHANGE_TO_ADDRS_BUTTON}
</td>
</tr>
</table>
</slot>
</td>
</tr>
<tr>
<td class="dataLabel">
<slot>
{MOD.LBL_CC}
</slot>
</td>
<td class="dataField" colspan="4" nowrap="NOWRAP">
<slot>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<textarea id="cc_addrs_field" name='cc_addrs' tabindex='3' cols="80" rows="1" style="height: 1.6.em; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" value="{CC_ADDRS}">{CC_ADDRS}</textarea>
<input type="hidden" id="cc_addrs_ids" name="cc_addrs_ids" value="{CC_ADDRS_IDS}" />
<input type="hidden" id="cc_addrs_emails" name="cc_addrs_emails" value="{CC_ADDRS_EMAILS}" />
<input type="hidden" id="cc_addrs_names" name="cc_addrs_names" value="{CC_ADDRS_NAMES}" />
</td>
<td style="padding-left: 4px;">
{CHANGE_CC_ADDRS_BUTTON}
</td>
</tr>
</table>
</slot>
</td>
</tr>
<tr valign="top">
<td class="dataLabel">
<slot>
{MOD.LBL_BCC}
</slot>
</td>
<td class="dataField" colspan="4" nowrap="NOWRAP">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<textarea id="bcc_addrs_field" name='bcc_addrs' tabindex='3' cols="80" rows="1" style="height: 1.6.em; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" value="{BCC_ADDRS}">{BCC_ADDRS}</textarea>
<input type="hidden" id="bcc_addrs_ids" name="bcc_addrs_ids" value="{BCC_ADDRS_IDS}" />
<input type="hidden" id="bcc_addrs_emails" name="bcc_addrs_emails" value="{BCC_ADDRS_EMAILS}" />
<input type="hidden" id="bcc_addrs_names" name="bcc_addrs_names" value="{BCC_ADDRS_NAMES}" />
</td>
<td style="padding-left: 4px;">
{CHANGE_BCC_ADDRS_BUTTON}
</td>
</tr>
</table>
</td>
</tr>
<tr valign="top">
<td class="dataLabel">
<slot>
{MOD.LBL_FROM}
</slot>
</td>
<td class="dataField" colspan="4" nowrap="NOWRAP">
<slot>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<textarea id="from_addr_field" name='from_addr' tabindex='3' cols="80" rows="1" style="height: 1.6.em; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" value="{FROM_ADDR}">{FROM_ADDR}</textarea> {FROM_ADDR_GROUP}
<input type="hidden" id="from_addr_email" name="from_addr_email" />
<input type="hidden" id="from_addr_name" name="from_addr_name" />
</td>
</tr>
</table>
</slot>
</td>
</tr>
<tr>
<td colspan="5">
&nbsp;
</td>
</tr>
<tr>
<td class="dataLabel">
<slot>
{MOD.LBL_SUBJECT}
</slot>
</td>
<td colspan='4' class="dataField">
<slot>
<textarea name='name' tabindex='4' cols="100" rows="1" style="height: 1.6.em; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" id="subjectfield">{NAME}</textarea>
</slot>
</td>
</tr>
<tr>
<td valign="top" class="dataLabel">
{MOD.LBL_BODY}
</td>
<!-- BEGIN: htmlarea -->
<td colspan="2" class="dataField">
<div style="display:none;">
<slot>
<div id="editor_select">
<input id="setEditor" name="setEditor" value="1" {EMAIL_EDITOR_OPTION} type="checkbox" onclick="toggle_textonly();" />
{MOD.LBL_EMAIL_EDITOR_OPTION}
</div>
</slot>
</div>
</td>
<td class="dataLabel" valign="top">
<slot>
{MOD.LBL_USE_TEMPLATE}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<select tabindex='2' name='email_template' onchange="fill_email(this.options[this.selectedIndex].value);">
{EMAIL_TEMPLATE_OPTIONS}
</select>
&nbsp;&nbsp;
<input type="button" class="button" name="clear" id="clear" value="Clear" onclick="fill_email('');">
&nbsp;&nbsp;
<input type="button" class="button" name="new_template" id="new_template" value="Template Fields" onclick="document.getElementById('template_fields').style.display='';" />
</slot>
</td>
<td class="dataField" nowrap width="1">
<slot>
</slot>
</td>
</tr>
<tr>
<td></td>
<td colspan="4">
<div id="template_fields" style="display:none">
<table>
<tr>
<td valign="top" class="dataLabel">
Templatate Fields:
</td>
<td colspan="5" class="dataField">
<slot>
{MFP}
<input type="button" class="button" name="cancel_template_fields" id="cancel_template_fields" value="Hide" onclick="document.getElementById('template_fields').style.display='none';">
</slot>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td valign="top" class="dataLabel">
&nbsp;
</td>
<td colspan="4" class="dataField">
{TINY}
<slot>
<div style="display:none;">
<div id="html_div">
<textarea id="description_html" onblur="">{DESCRIPTION_HTML}</textarea>
</div>
</div>
<div style="display:none;">
<div id="alt_text_div">
<input id="toggle_textarea_elem" onclick="toggle_textarea();" type="checkbox" name="toggle_html">
{MOD.LBL_EDIT_ALT_TEXT}
</div>
</div>
<div id="text_div" style="display: none;">
</div>
<textarea tabindex='5' id="description" name='description' cols="100" rows="20">{DESCRIPTION}</textarea>
</slot>
</td>
<!-- END: htmlarea -->
</tr>
<tr>
<td valign="top" class="dataLabel">
{MOD.LBL_ATTACHMENTS}
</td>
<td colspan="4">
{ATTACHMENTS_JAVASCRIPT} {ATTACHMENTS}
<div id="template_attachments">
</div>
<div id="uploads_div">
<div style="display: none" id="file0">
<input id='email_attachment0' name='email_attachment0' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('0');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file1">
<input id='email_attachment1' name='email_attachment1' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('1');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file2">
<input id='email_attachment2' name='email_attachment2' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('2');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file3">
<input id='email_attachment3' name='email_attachment3' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('3');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file4">
<input id='email_attachment4' name='email_attachment4' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('4');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file5">
<input id='email_attachment5' name='email_attachment5' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('5');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file6">
<input id='email_attachment6' name='email_attachment6' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('6');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file7">
<input id='email_attachment7' name='email_attachment7' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('7');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file8">
<input id='email_attachment8' name='email_attachment8' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('8');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file9">
<input id='email_attachment9' name='email_attachment9' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('9');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document0">
<input name='documentId0' id='documentId0' tabindex='0' type='hidden' />
<input name='documentName0' id='documentName0' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('0');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('0');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document1">
<input name='documentId1' id='documentId1' tabindex='1' type='hidden' />
<input name='documentName1' id='documentName1' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('1');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('1');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document2">
<input name='documentId2' id='documentId2' tabindex='2' type='hidden' />
<input name='documentName2' id='documentName2' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('2');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('2');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document3">
<input name='documentId3' id='documentId3' tabindex='3' type='hidden' />
<input name='documentName3' id='documentName3' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('3');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('3');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document4">
<input name='documentId4' id='documentId4' tabindex='4' type='hidden' />
<input name='documentName4' id='documentName4' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('4');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('4');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document5">
<input name='documentId5' id='documentId5' tabindex='5' type='hidden' />
<input name='documentName5' id='documentName5' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('5');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('5');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document6">
<input name='documentId6' id='documentId6' tabindex='6' type='hidden' />
<input name='documentName6' id='documentName6' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('6');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('6');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document7">
<input name='documentId7' id='documentId7' tabindex='7' type='hidden' />
<input name='documentName7' id='documentName7' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('7');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('7');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document8">
<input name='documentId8' id='documentId8' tabindex='8' type='hidden' />
<input name='documentName8' id='documentName8' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('8');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('8');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document9">
<input name='documentId9' id='documentId9' tabindex='9' type='hidden' />
<input name='documentName9' id='documentName9' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('9');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('9');" class="button" value="{APP.LBL_REMOVE}" />
</div>
</div>
<input type="button" name="add_file_button" onclick="addFile();" value="{MOD.LBL_ADD_FILE}" class="button" />
<input type="button" name="add_document_button" onclick="addDocument();" value="{MOD.LBL_ADD_DOCUMENT}" class="button" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
{JAVASCRIPT}
</body>
</html>
<!-- END: main -->

View File

@@ -0,0 +1,889 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
* EditView for Email
*
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU 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 General Public License for more
* details.
*
* You should have received a copy of the GNU 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 General Public License version 3.
*
* In accordance with Section 7(b) of the GNU 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".
*/
$toTemplate = '';
if(isset($_REQUEST['pTypeTo']) && $_REQUEST['pTypeTo']!='' && isset($_REQUEST['pIdTo']) && $_REQUEST['pIdTo']!='') {
if($_REQUEST['pTypeTo'] == "Accounts") {
require_once('modules/Accounts/Account.php');
$acc = new Account();
$acc->retrieve($_REQUEST['pIdTo']);
if(isset($acc->id) && $acc->id!='') {
$_REQUEST['to_addrs'] = $acc->name.' <'.$acc->email1.'>; ';
}
}
if($_REQUEST['pTypeTo'] == "Contacts") {
require_once('modules/Contacts/Contact.php');
$con = new Contact();
$con->retrieve($_REQUEST['pIdTo']);
if(isset($con->id) && $con->id!='') {
$_REQUEST['to_addrs'] = $con->name.' <'.$con->email1.'>; ';
}
}
}
if(isset($_REQUEST['pTypeTo']) && $_REQUEST['pTypeTo']!='')
if($_REQUEST['pTypeTo'] == "Accounts") $toTemplate = 'InvoiceTemplateAccount';
else
if($_REQUEST['pTypeTo'] == "Contacts") $toTemplate = 'InvoiceTemplateContact';
if(isset($_REQUEST['pTypeFrom']) && $_REQUEST['pTypeFrom']!='' && isset($_REQUEST['pIdFrom']) && $_REQUEST['pIdFrom']!='') {
if($_REQUEST['pTypeFrom'] == "Users") {
require_once('modules/Users/User.php');
$us = new User();
global $current_user;
$us->retrieve($current_user->id);//$_REQUEST['pIdFrom']);
if(isset($us->id) && $us->id!='') {
$_REQUEST['from_addr'] = $us->name.' <'.$us->email1.'>; ';
}
}
}
echo '<script type="text/javascript">var asynchronous_key = "'.$_SESSION['asynchronous_key'].'";</script>';
$GLOBALS['log']->info("Email edit view");
require_once('include/SugarTinyMCE.php');
require_once('modules/Emails/Email.php');
require_once('modules/EmailTemplates/EmailTemplate.php');
require_once('XTemplate/xtpl.php');
global $theme;
$theme_path="themes/".$theme."/";
$image_path=$theme_path."images/";
require_once($theme_path.'layout_utils.php');
global $app_strings;
global $app_list_strings;
global $current_user;
global $sugar_version, $sugar_config;
global $timedate;
$mod_strings = return_module_language($current_language, 'Emails');
$OPT = array();
if(isset($_REQUEST['invoiceout_id']) && $_REQUEST['invoiceout_id']!='') {
$OPT['invoiceout_id'] = $_REQUEST['invoiceout_id'];
} else $OPT['invoiceout_id'] = '';
if(isset($_REQUEST['sended']) && $_REQUEST['sended']!='') {
$OPT['sended'] = $_REQUEST['sended'];
} else $OPT['sended'] = '0';
$json = getJSONobj();
echo '<script language="javascript">
var OPT = '.$json->encode($OPT).';
function invoiceoutAlert(method) {
if(OPT[\'invoiceout_id\']==\'\') {
alert(\'Invoice not saved!\');
return false;
}
if(method == \'save\') {
prepSave(); document.forms.EditView.action.value=\'EmailSave\'; document.forms.EditView.send.value=\'1\'; document.forms.EditView.type.value=\'out\'; return fill_form(\'out\', \''.$mod_strings['ERR_NOT_ADDRESSED'].'\');
}
if(method == \'save_draft\') {
document.forms.EditView.action.value=\'EmailSave\'; document.forms.EditView.send.value=\'0\'; document.forms.EditView.type.value=\'draft\'; fill_form(\'draft\', \''.$mod_strings['ERR_NOT_ADDRESSED'].'\');
}
};
if(OPT[\'sended\']==\'1\') alert(\'Email was sended\');
</script>';
///////////////////////////////////////////////////////////////////////////////
//// PREPROCESS BEAN DATA FOR DISPLAY
$focus = new Email();
$email_type = 'archived';
if(isset($_REQUEST['record'])) {
$focus->retrieve($_REQUEST['record']);
}
if(!empty($_REQUEST['type'])) {
$email_type = $_REQUEST['type'];
} elseif(!empty($focus->id)) {
$email_type = $focus->type;
}
$focus->type = $email_type;
//needed when creating a new email with default values passed in
if(isset($_REQUEST['contact_name']) && is_null($focus->contact_name)) {
$focus->contact_name = $_REQUEST['contact_name'];
}
if(!empty($_REQUEST['load_id']) && !empty($beanList[$_REQUEST['load_module']])) {
$class_name = $beanList[$_REQUEST['load_module']];
require_once($beanFiles[$class_name]);
$contact = new $class_name();
if($contact->retrieve($_REQUEST['load_id'])) {
$link_id = $class_name . '_id';
$focus->$link_id = $_REQUEST['load_id'];
$focus->contact_name = (isset($contact->full_name)) ? $contact->full_name : $contact->name;
$focus->to_addrs_names = $focus->contact_name;
$focus->to_addrs_ids = $_REQUEST['load_id'];
//Retrieve the email address.
//If Opportunity or Case then Oppurtinity/Case->Accounts->(email_addr_bean_rel->email_addresses)
//If Contacts, Leads etc.. then Contact->(email_addr_bean_rel->email_addresses)
$sugarEmailAddress = new SugarEmailAddress();
if($class_name == 'Opportunity' || $class_name == 'aCase'){
$account = new Account();
if($contact->account_id != null && $account->retrieve($contact->account_id)){
$sugarEmailAddress->handleLegacyRetrieve($account);
if(isset($account->email1)){
$focus->to_addrs_emails = $account->email1;
$focus->to_addrs = "$focus->contact_name <$account->email1>";
}
}
}
else{
$sugarEmailAddress->handleLegacyRetrieve($contact);
if(isset($contact->email1)){
$focus->to_addrs_emails = $contact->email1;
$focus->to_addrs = "$focus->contact_name <$contact->email1>";
}
}
if(!empty($_REQUEST['parent_type']) && empty($app_list_strings['record_type_display'][$_REQUEST['parent_type']])){
if(!empty($app_list_strings['record_type_display'][$_REQUEST['load_module']])){
$_REQUEST['parent_type'] = $_REQUEST['load_module'];
$_REQUEST['parent_id'] = $focus->contact_id;
$_REQUEST['parent_name'] = $focus->to_addrs_names;
} else {
unset($_REQUEST['parent_type']);
unset($_REQUEST['parent_id']);
unset($_REQUEST['parent_name']);
}
}
}
}
if(isset($_REQUEST['contact_id']) && is_null($focus->contact_id)) {
$focus->contact_id = $_REQUEST['contact_id'];
}
if(isset($_REQUEST['parent_name'])) {
$focus->parent_name = $_REQUEST['parent_name'];
}
if(isset($_REQUEST['parent_id'])) {
$focus->parent_id = $_REQUEST['parent_id'];
}
if(isset($_REQUEST['parent_type'])) {
$focus->parent_type = $_REQUEST['parent_type'];
}
elseif(is_null($focus->parent_type)) {
$focus->parent_type = $app_list_strings['record_type_default_key'];
}
if(isset($_REQUEST['to_email_addrs'])) {
$focus->to_addrs = $_REQUEST['to_email_addrs'];
}
// needed when clicking through a Contacts detail view:
if(isset($_REQUEST['to_addrs_ids'])) {
$focus->to_addrs_ids = $_REQUEST['to_addrs_ids'];
}
if(isset($_REQUEST['to_addrs_emails'])) {
$focus->to_addrs_emails = $_REQUEST['to_addrs_emails'];
}
if(isset($_REQUEST['to_addrs_names'])) {
$focus->to_addrs_names = $_REQUEST['to_addrs_names'];
}
if(isset($_REQUEST['to_addrs'])) {
$focus->to_addrs = $_REQUEST['to_addrs'];
}// user's email, go through 3 levels of precedence:
if(isset($_REQUEST['from_addr'])) {
$focus->from_addr = $_REQUEST['from_addr'];
}// user's email, go through 3 levels of precedence:
$from = $current_user->getEmailInfo();
//// END PREPROCESSING
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// XTEMPLATE ASSIGNMENT
if($email_type == 'archived') {
// echo get_module_title('Emails', $mod_strings['LBL_ARCHIVED_MODULE_NAME'].":", true);
$xtpl=new XTemplate('modules/Emails/EditViewArchive.html');
} else {
// echo get_module_title('Emails', $mod_strings['LBL_COMPOSE_MODULE_NAME'].":", true);
$xtpl=new XTemplate('modules/EcmInvoiceOutOlds/Emails.html');
}
echo "\n</p>\n";
// CHECK USER'S EMAIL SETTINGS TO ENABLE/DISABLE 'SEND' BUTTON
if(!$focus->check_email_settings() &&($email_type == 'out' || $email_type == 'draft')) {
print "<font color='red'>".$mod_strings['WARNING_SETTINGS_NOT_CONF']." <a href='index.php?module=Users&action=EditView&record=".$current_user->id."&return_module=Emails&type=out&return_action=EditView'>".$mod_strings['LBL_EDIT_MY_SETTINGS']."</a></font>";
$xtpl->assign("DISABLE_SEND", 'DISABLED');
}
// CHECK THAT SERVER HAS A PLACE TO PUT UPLOADED TEMP FILES SO THAT ATTACHMENTS WILL WORK
// cn: Bug 5995
$tmpUploadDir = ini_get('upload_tmp_dir');
if(!empty($tmpUploadDir)) {
if(!is_writable($tmpUploadDir)) {
echo "<font color='red'>{$mod_strings['WARNING_UPLOAD_DIR_NOT_WRITABLE']}</font>";
}
} else {
//echo "<font color='red'>{$mod_strings['WARNING_NO_UPLOAD_DIR']}</font>";
}
///////////////////////////////////////////////////////////////////////////////
//// INBOUND EMAIL HANDLING
if(isset($_REQUEST['email_name'])) {
$name = str_replace('_',' ',$_REQUEST['email_name']);
}
if(isset($_REQUEST['inbound_email_id'])) {
$ieMail = new Email();
$ieMail->retrieve($_REQUEST['inbound_email_id']);
$invoiceoutd = '';
// cn: bug 9725: replies/forwards lose real content
$invoiceoutdHtml = $ieMail->invoiceoutHtmlEmail($ieMail->description_html);
// plain-text
$desc = nl2br(trim($ieMail->description));
$exDesc = explode('<br />', $desc);
foreach($exDesc as $k => $line) {
$invoiceoutd .= '> '.trim($line)."\r";
}
// prefill empties with the other's contents
if(empty($invoiceoutdHtml) && !empty($invoiceoutd)) {
$invoiceoutdHtml = nl2br($invoiceoutd);
}
if(empty($invoiceoutd) && !empty($invoiceoutdHtml)) {
$invoiceoutd = strip_tags(br2nl($invoiceoutdHtml));
}
// forwards have special text
if($_REQUEST['type'] == 'forward') {
$header = $ieMail->getForwardHeader();
// subject is handled in Subject line handling below
} else {
// we have a reply in focus
$header = $ieMail->getReplyHeader();
}
$invoiceoutd = br2nl($header.$invoiceoutd);
$invoiceoutdHtml = $header.$invoiceoutdHtml;
// if not a forward: it's a reply
if($_REQUEST['type'] != 'forward') {
$ieMailName = 'RE: '.$ieMail->name;
} else {
$ieMailName = $ieMail->name;
}
$focus->id = null; // nulling this to prevent overwriting a replied email(we're basically doing a "Duplicate" function)
$focus->to_addrs = $ieMail->from_addr;
$focus->description = $invoiceoutd; // don't know what i was thinking: ''; // this will be filled on save/send
$focus->description_html = $invoiceoutdHtml; // cn: bug 7357 - htmlentities() breaks FCKEditor
$focus->parent_type = $ieMail->parent_type;
$focus->parent_id = $ieMail->parent_id;
$focus->parent_name = $ieMail->parent_name;
$focus->name = $ieMailName;
$xtpl->assign('INBOUND_EMAIL_ID',$_REQUEST['inbound_email_id']);
// un/READ flags
if(!empty($ieMail->status)) {
// "Read" flag for InboundEmail
if($ieMail->status == 'unread') {
// creating a new instance here to avoid data corruption below
$e = new Email();
$e->retrieve($ieMail->id);
$e->status = 'read';
$e->save();
$email_type = $e->status;
}
}
///////////////////////////////////////////////////////////////////////////
//// PRIMARY PARENT LINKING
if(empty($focus->parent_type) && empty($focus->parent_id)) {
$focus->fillPrimaryParentFields();
}
//// END PRIMARY PARENT LINKING
///////////////////////////////////////////////////////////////////////////
// setup for my/mailbox email switcher
$mbox = $ieMail->getMailboxDefaultEmail();
$user = $current_user->getPreferredEmail();
$useGroup = '&nbsp;<input id="use_mbox" name="use_mbox" type="checkbox" CHECKED onClick="switchEmail()" >
<script type="text/javascript">
function switchEmail() {
var mboxName = "'.$mbox['name'].'";
var mboxAddr = "'.$mbox['email'].'";
var userName = "'.$user['name'].'";
var userAddr = "'.$user['email'].'";
if(document.getElementById("use_mbox").checked) {
document.getElementById("from_addr_field").value = mboxName + " <" + mboxAddr + ">";
document.getElementById("from_addr_name").value = mboxName;
document.getElementById("from_addr_email").value = mboxAddr;
} else {
document.getElementById("from_addr_field").value = userName + " <" + userAddr + ">";
document.getElementById("from_addr_name").value = userName;
document.getElementById("from_addr_email").value = userAddr;
}
}
</script>';
$useGroup .= $mod_strings['LBL_USE_MAILBOX_INFO'];
$xtpl->assign('FROM_ADDR_GROUP', $useGroup);
}
//// END INBOUND EMAIL HANDLING
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// SUBJECT FIELD MANIPULATION
$name = '';
if(!empty($_REQUEST['parent_id']) && !empty($_REQUEST['parent_type'])) {
$focus->parent_id = $_REQUEST['parent_id'];
$focus->parent_type = $_REQUEST['parent_type'];
}
if(!empty($focus->parent_id) && !empty($focus->parent_type)) {
if($focus->parent_type == 'Cases') {
require_once('modules/Cases/Case.php');
$myCase = new aCase();
$myCase->retrieve($focus->parent_id);
$myCaseMacro = $myCase->getEmailSubjectMacro();
if(isset($ieMail->name) && !empty($ieMail->name)) { // if replying directly to an InboundEmail
$oldEmailSubj = $ieMail->name;
} elseif(isset($_REQUEST['parent_name']) && !empty($_REQUEST['parent_name'])) {
$oldEmailSubj = $_REQUEST['parent_name'];
} else {
$oldEmailSubj = $focus->name; // replying to an email using old subject
}
if(!preg_match('/^re:/i', $oldEmailSubj)) {
$oldEmailSubj = 'RE: '.$oldEmailSubj;
}
$focus->name = $oldEmailSubj;
if(strpos($focus->name, str_replace('%1',$myCase->case_number,$myCaseMacro))) {
$name = $focus->name;
} else {
$name = $focus->name.' '.str_replace('%1',$myCase->case_number,$myCaseMacro);
}
} else {
$name = $focus->name;
}
} else {
if(empty($focus->name)) {
$name = '';
} else {
$name = $focus->name;
}
}
if($email_type == 'forward') {
$name = 'FW: '.$name;
}
//// END SUBJECT FIELD MANIPULATION
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// GENERAL TEMPLATE ASSIGNMENTS
$xtpl->assign('MOD', return_module_language($current_language, 'Emails'));
$xtpl->assign('APP', $app_strings);
if(!isset($focus->id)) $xtpl->assign('USER_ID', $current_user->id);
if(!isset($focus->id) && isset($_REQUEST['contact_id'])) $xtpl->assign('CONTACT_ID', $_REQUEST['contact_id']);
$xtpl->assign("INVOICEOUT_ID",$_REQUEST['invoiceout_id']);
if(isset($_REQUEST['return_module']) && !empty($_REQUEST['return_module'])) {
$xtpl->assign('RETURN_MODULE', $_REQUEST['return_module']);
} else {
$xtpl->assign('RETURN_MODULE', 'Emails');
}
if(isset($_REQUEST['return_action']) && !empty($_REQUEST['return_action']) && ($_REQUEST['return_action'] != 'SubPanelViewer')) {
$xtpl->assign('RETURN_ACTION', $_REQUEST['return_action']);
} else {
$xtpl->assign('RETURN_ACTION', 'DetailView');
}
if(isset($_REQUEST['return_id']) && !empty($_REQUEST['return_id'])) {
$xtpl->assign('RETURN_ID', $_REQUEST['return_id']);
}
// handle Create $module then Cancel
if(empty($_REQUEST['return_id']) && !isset($_REQUEST['type'])) {
$xtpl->assign('RETURN_ACTION', 'index');
}
$xtpl->assign('THEME', $theme);
$xtpl->assign('IMAGE_PATH', $image_path);$xtpl->assign('PRINT_URL', 'index.php?'.$GLOBALS['request_string']);
if(isset($_REQUEST['bodyclass']) && $_REQUEST['bodyclass'] != '') $xtpl->assign('BODYCLASS',$_REQUEST['bodyclass']);
require_once('modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php');
$m = new EcmInvoiceOutOld();
$mfp = $m->loadParserArray('email');
$xtpl->assign("MFP",$mfp);
///////////////////////////////////////////////////////////////////////////////
//// QUICKSEARCH CODE
require_once('include/QuickSearchDefaults.php');
$qsd = new QuickSearchDefaults();
$sqs_objects = array('parent_name' => $qsd->getQSParent(),
'assigned_user_name' => $qsd->getQSUser(),
);
$json = getJSONobj();
$quicksearch_js = $qsd->getQSScripts();
$sqs_objects_encoded = $json->encode($sqs_objects);
$quicksearch_js .= <<<EOQ
<script type="text/javascript" language="javascript">sqs_objects = $sqs_objects_encoded;
function changeQS() {
//new_module = document.getElementById('parent_type').value;
new_module = document.EditView.parent_type.value;
if(new_module == 'Contacts' || new_module == 'Leads' || typeof(disabledModules[new_module]) != 'undefined') {
sqs_objects['parent_name']['disable'] = true;
document.getElementById('parent_name').readOnly = true;
}
else {
sqs_objects['parent_name']['disable'] = false;
document.getElementById('parent_name').readOnly = false;
}
sqs_objects['parent_name']['module'] = new_module;
}
changeQS();
</script>
EOQ;
$xtpl->assign('JAVASCRIPT', get_set_focus_js().$quicksearch_js);
//// END QUICKSEARCH CODE
///////////////////////////////////////////////////////////////////////////////
// cn: bug 14191 - duping archive emails overwrites the original
if(!isset($_REQUEST['isDuplicate']) || $_REQUEST['isDuplicate'] != 'true') {
$xtpl->assign('ID', $focus->id);
}
if(isset($_REQUEST['parent_type']) && !empty($_REQUEST['parent_type']) && isset($_REQUEST['parent_id']) && !empty($_REQUEST['parent_id'])) {
$xtpl->assign('OBJECT_ID', $_REQUEST['parent_id']);
$xtpl->assign('OBJECT_TYPE', $_REQUEST['parent_type']);
}
$xtpl->assign('FROM_ADDR', $focus->from_addr);
//// prevent TO: prefill when type is 'forward'
if($email_type != 'forward') {
$xtpl->assign('TO_ADDRS', $focus->to_addrs);
$xtpl->assign('FROM_ADDRS', $focus->from_addrs);
$xtpl->assign('TO_ADDRS_IDS', $focus->to_addrs_ids);
$xtpl->assign('TO_ADDRS_NAMES', $focus->to_addrs_names);
$xtpl->assign('TO_ADDRS_EMAILS', $focus->to_addrs_emails);
$xtpl->assign('CC_ADDRS', $focus->cc_addrs);
$xtpl->assign('CC_ADDRS_IDS', $focus->cc_addrs_ids);
$xtpl->assign('CC_ADDRS_NAMES', $focus->cc_addrs_names);
$xtpl->assign('CC_ADDRS_EMAILS', $focus->cc_addrs_emails);
$xtpl->assign('BCC_ADDRS', $focus->bcc_addrs);
$xtpl->assign('BCC_ADDRS_IDS', $focus->bcc_addrs_ids);
$xtpl->assign('BCC_ADDRS_NAMES', $focus->bcc_addrs_names);
$xtpl->assign('BCC_ADDRS_EMAILS', $focus->bcc_addrs_emails);
}
//$xtpl->assign('FROM_ADDR', $from['name'].' <'.$from['email'].'>');
$xtpl->assign('FROM_ADDR_NAME', $from['name']);
$xtpl->assign('FROM_ADDR_EMAIL', $from['email']);
$xtpl->assign('NAME', from_html($name));
//$xtpl->assign('DESCRIPTION_HTML', from_html($focus->description_html));
$xtpl->assign('DESCRIPTION', $focus->description);
$xtpl->assign('TYPE',$email_type);
// Unimplemented until jscalendar language files are fixed
// $xtpl->assign('CALENDAR_LANG',((empty($cal_codes[$current_language])) ? $cal_codes[$default_language] : $cal_codes[$current_language]));
$xtpl->assign('CALENDAR_LANG', 'en');
$xtpl->assign('CALENDAR_DATEFORMAT', $timedate->get_cal_date_format());
$xtpl->assign('DATE_START', $focus->date_start);
$xtpl->assign('TIME_FORMAT', '('. $timedate->get_user_time_format().')');
$xtpl->assign('TIME_START', substr($focus->time_start,0,5));
$xtpl->assign('TIME_MERIDIEM', $timedate->AMPMMenu('',$focus->time_start));
$parent_types = $app_list_strings['record_type_display'];
$disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list');
foreach($disabled_parent_types as $disabled_parent_type){
if($disabled_parent_type != $focus->parent_type){
unset($parent_types[$disabled_parent_type]);
}
}
$xtpl->assign('TYPE_OPTIONS', get_select_options_with_id($parent_types, $focus->parent_type));
$xtpl->assign('USER_DATEFORMAT', '('. $timedate->get_user_date_format().')');
$xtpl->assign('PARENT_NAME', $focus->parent_name);
$xtpl->assign('PARENT_ID', $focus->parent_id);
if(empty($focus->parent_type)) {
$xtpl->assign('PARENT_RECORD_TYPE', '');
} else {
$xtpl->assign('PARENT_RECORD_TYPE', $focus->parent_type);
}
if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){
$record = '';
if(!empty($_REQUEST['record'])){
$record = $_REQUEST['record'];
}
$xtpl->assign('ADMIN_EDIT',"<a href='index.php?action=index&module=DynamicLayout&from_action=".$_REQUEST['action'] ."&from_module=".$_REQUEST['module'] ."&record=".$record. "'>".get_image($image_path."EditLayout","border='0' alt='Edit Layout' align='bottom'")."</a>");
}
//// END GENERAL TEMPLATE ASSIGNMENTS
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////
///
/// SETUP PARENT POPUP
$popup_request_data = array(
'call_back_function' => 'set_return',
'form_name' => 'EditView',
'field_to_name_array' => array(
'id' => 'parent_id',
'name' => 'parent_name',
),
);
$encoded_popup_request_data = $json->encode($popup_request_data);
/// Users Popup
$popup_request_data = array(
'call_back_function' => 'set_return',
'form_name' => 'EditView',
'field_to_name_array' => array(
'id' => 'assigned_user_id',
'user_name' => 'assigned_user_name',
),
);
$xtpl->assign('encoded_users_popup_request_data', $json->encode($popup_request_data));
//
///////////////////////////////////////
$change_parent_button = '<input type="button" name="button" tabindex="2" class="button" '
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
. 'value="' . $app_strings['LBL_SELECT_BUTTON_LABEL'] . '" '
. "onclick='open_popup(document.EditView.parent_type.value,600,400,\"&tree=ProductsProd\",true,false,$encoded_popup_request_data);' />\n";
$xtpl->assign("CHANGE_PARENT_BUTTON", $change_parent_button);
$button_attr = '';
if(!ACLController::checkAccess('Contacts', 'list', true)){
$button_attr = 'disabled="disabled"';
}
$change_to_addrs_button = '<input type="button" name="to_button" tabindex="3" class="button" '
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
. 'value="' . $mod_strings['LBL_EMAIL_SELECTOR'] . '" '
. "onclick='button_change_onclick(this);' $button_attr />\n";
$xtpl->assign("CHANGE_TO_ADDRS_BUTTON", $change_to_addrs_button);
$change_cc_addrs_button = '<input type="button" name="cc_button" tabindex="3" class="button" '
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
. 'value="' . $mod_strings['LBL_EMAIL_SELECTOR'] . '" '
. "onclick='button_change_onclick(this);' $button_attr />\n";
$xtpl->assign("CHANGE_CC_ADDRS_BUTTON", $change_cc_addrs_button);
$change_bcc_addrs_button = '<input type="button" name="bcc_button" tabindex="3" class="button" '
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
. 'value="' . $mod_strings['LBL_EMAIL_SELECTOR'] . '" '
. "onclick='button_change_onclick(this);' $button_attr />\n";
$xtpl->assign("CHANGE_BCC_ADDRS_BUTTON", $change_bcc_addrs_button);
///////////////////////////////////////
//// USER ASSIGNMENT
global $current_user;
if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) {
$record = '';
if(!empty($_REQUEST['record'])) {
$record = $_REQUEST['record'];
}
$xtpl->assign('ADMIN_EDIT',"<a href='index.php?action=index&module=DynamicLayout&from_action=".$_REQUEST['action'] ."&from_module=".$_REQUEST['module'] ."&record=".$record. "'>".get_image($image_path."EditLayout","border='0' alt='Edit Layout' align='bottom'")."</a>");
}
if(empty($focus->assigned_user_id) && empty($focus->id))
$focus->assigned_user_id = $current_user->id;
if(empty($focus->assigned_name) && empty($focus->id))
$focus->assigned_user_name = $current_user->user_name;
$xtpl->assign('ASSIGNED_USER_OPTIONS', get_select_options_with_id(get_user_array(TRUE, 'Active', $focus->assigned_user_id), $focus->assigned_user_id));
$xtpl->assign('ASSIGNED_USER_NAME', $focus->assigned_user_name);
$xtpl->assign('ASSIGNED_USER_ID', $focus->assigned_user_id);
$xtpl->assign('DURATION_HOURS', $focus->duration_hours);
$xtpl->assign('TYPE_OPTIONS', get_select_options_with_id($parent_types, $focus->parent_type));
$xtpl->assign("PIDFROM",$_REQUEST['pIdFrom']);
$xtpl->assign("PTYPEFROM",$_REQUEST['pTypeFrom']);
$xtpl->assign("PIDTO",$_REQUEST['pIdTo']);
$xtpl->assign("PTYPETO",$_REQUEST['pTypeTo']);
if(isset($focus->duration_minutes)) {
$xtpl->assign('DURATION_MINUTES_OPTIONS', get_select_options_with_id($focus->minutes_values,$focus->duration_minutes));
}
//// END USER ASSIGNMENT
///////////////////////////////////////
//Add Custom Fields
require_once('modules/DynamicFields/templates/Files/EditView.php');
require_once("modules/Notes/Note.php");
///////////////////////////////////////
//// ATTACHMENTS
$attachments = '';
if(!empty($focus->id) || (!empty($_REQUEST['record']) && $_REQUEST['type'] == 'forward')) {
$attachments = "<input type='hidden' name='removeAttachment' id='removeAttachment' value=''>\n";
$ids = '';
$focusId = empty($focus->id) ? $_REQUEST['record'] : $focus->id;
$note = new Note();
$where = "notes.parent_id='{$focusId}' AND notes.filename IS NOT NULL";
$notes_list = $note->get_full_list("", $where,true);
if(!isset($notes_list)) {
$notes_list = array();
}
for($i = 0;$i < count($notes_list);$i++) {
$the_note = $notes_list[$i];
if(empty($the_note->filename)) {
continue;
}
// cn: bug 8034 - attachments from forwards/replies lost when saving drafts
if(!empty($ids)) {
$ids .= ",";
}
$ids .= $the_note->id;
$attachments .= "
<div id='noteDiv{$the_note->id}'>
<img onclick='deletePriorAttachment(\"{$the_note->id}\");' src='themes/{$theme}/images/delete_inline.gif' value='{$the_note->id}'>&nbsp;";
$attachments .= '<a href="'.UploadFile::get_url($the_note->filename,$the_note->id).'" target="_blank">'. $the_note->filename .'</a></div>';
}
// cn: bug 8034 - attachments from forwards/replies lost when saving drafts
$attachments .= "<input type='hidden' name='prior_attachments' value='{$ids}'>";
// workaround $mod_strings being overriden by Note object instantiation above.
global $current_language, $mod_strings;
$mod_strings = return_module_language($current_language, 'Emails');
}
$attJs = '<script type="text/javascript">';
$attJs .= 'var file_path = "'.$sugar_config['site_url'].'/'.$sugar_config['upload_dir'].'";';
$attJs .= 'var lnk_remove = "'.$app_strings['LNK_REMOVE'].'";';
$attJs .= '</script>';
$xtpl->assign('ATTACHMENTS', $attachments);
$xtpl->assign('ATTACHMENTS_JAVASCRIPT', $attJs);
//// END ATTACHMENTS
///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// DOCUMENTS
$popup_request_data = array(
'call_back_function' => 'document_set_return',
'form_name' => 'EditView',
'field_to_name_array' => array(
'id' => 'related_doc_id',
'document_name' => 'related_document_name',
),
);
$json = getJSONobj();
$xtpl->assign('encoded_document_popup_request_data', $json->encode($popup_request_data));
//// END DOCUMENTS
///////////////////////////////////////////////////////////////////////////////
$parse_open = true;
if($parse_open) {
$xtpl->parse('main.open_source_1');
}
///////////////////////////////////////////////////////////////////////////////
//// EMAIL TEMPLATES
if(ACLController::checkAccess('EmailTemplates', 'list', true) && ACLController::checkAccess('EmailTemplates', 'view', true)) {
$et = new EmailTemplate();
$etResult = $focus->db->query($et->create_list_query('','',''));
$email_templates_arr[] = '';
$toTemplateId = '';
while($etA = $focus->db->fetchByAssoc($etResult)) {
if($toTemplate == $etA['name']) { $toTemplateId = $etA['id']; }
$email_templates_arr[$etA['id']] = $etA['name'];
}
} else {
$email_templates_arr = array('' => $app_strings['LBL_NONE']);
}
$xtpl->assign('EMAIL_TEMPLATE_OPTIONS', get_select_options_with_id($email_templates_arr, $toTemplateId));
//// END EMAIL TEMPLATES
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////
//// TEXT EDITOR
// cascade from User to Sys Default
$editor = $focus->getUserEditorPreference();
if($editor != 'plain') {
// this box is checked by Javascript on-load.
$xtpl->assign('EMAIL_EDITOR_OPTION', 'CHECKED');
}
$description_html = from_html($focus->description_html);
$description = $focus->description;
/////////////////////////////////////////////////
// signatures
if($sig = $current_user->getDefaultSignature()) {
if(!$focus->hasSignatureInBody($sig) && $focus->type != 'draft') {
if($current_user->getPreference('signature_prepend')) {
$description_html = '<br />'.from_html($sig['signature_html']).'<br /><br />'.$description_html;
$description = "\n".$sig['signature']."\n\n".$description;
} else {
$description_html .= '<br /><br />'.from_html($sig['signature_html']);
$description = $description."\n\n".$sig['signature'];
}
}
}
$xtpl->assign('DESCRIPTION', $description);
// sigs
/////////////////////////////////////////////////
$tiny = new SugarTinyMCE();
$ed = $tiny->getInstance("description_html");
$xtpl->assign("TINY", $ed);
$xtpl->assign("DESCRIPTION_HTML", $description_html);
if((!isset($_REQUEST['record']) || $_REQUEST['record'] == '') && isset($toTemplateId) && $toTemplateId != "") {
require_once('modules/EmailTemplates/EmailTemplate.php');
$et = new EmailTemplate();
$et->retrieve($toTemplateId);
if(isset($et->id) && $et->id != '') {
$xtpl->assign("NAME",$et->subject);
$xtpl->assign("DESCRIPTION",$et->body);
$xtpl->assign("DESCRIPTION_HTML",$et->body_html);
}
}
$xtpl->parse('main.htmlarea');
//// END TEXT EDITOR
///////////////////////////////////////
///////////////////////////////////////
//// SPECIAL INBOUND LANDING SCREEN ASSIGNS
if(!empty($_REQUEST['inbound_email_id'])) {
if(!empty($_REQUEST['start'])) {
$parts = $focus->getStartPage(base64_decode($_REQUEST['start']));
$xtpl->assign('RETURN_ACTION', $parts['action']);
$xtpl->assign('RETURN_MODULE', $parts['module']);
$xtpl->assign('GROUP', $parts['group']);
}
$xtpl->assign('ASSIGNED_USER_ID', $current_user->id);
$xtpl->assign('MYINBOX', 'this.form.type.value=\'inbound\';');
}
//// END SPECIAL INBOUND LANDING SCREEN ASSIGNS
///////////////////////////////////////
echo '<script>var disabledModules='. $json->encode($disabled_parent_types) . ';</script>';
$jsVars = 'var lbl_send_anyways = "'.$mod_strings['LBL_SEND_ANYWAYS'].'";';
$xtpl->assign('JS_VARS', $jsVars);
$xtpl->parse("main");
$xtpl->out("main");
echo '<script>checkParentType(document.EditView.parent_type.value, document.EditView.change_parent);</script>';
//// END XTEMPLATE ASSIGNMENT
///////////////////////////////////////////////////////////////////////////////
require_once('include/javascript/javascript.php');
$javascript = new javascript();
$javascript->setFormName('email_EditView');
$javascript->setSugarBean($focus);
$skip_fields = array();
if($email_type == 'out') {
$skip_fields['name'] = 1;
$skip_fields['date_start'] = 1;
}
$javascript->addAllFields('',$skip_fields);
$javascript->addToValidateBinaryDependency('parent_name', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $mod_strings['LBL_MEMBER_OF'], 'false', '', 'parent_id');
$javascript->addToValidateBinaryDependency('parent_type', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $mod_strings['LBL_MEMBER_OF'], 'false', '', 'parent_id');
$javascript->addToValidateBinaryDependency('user_name', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $app_strings['LBL_ASSIGNED_TO'], 'false', '', 'assigned_user_id');
if($email_type == 'archived') {
$javascript->addFieldIsValidDate('date_start', 'date', $mod_strings['LBL_DATE'], $mod_strings['ERR_DATE_START'], true);
$javascript->addFieldIsValidTime('time_start', 'time', $mod_strings['LBL_TIME'], $mod_strings['ERR_TIME_START'], true);
}
echo $javascript->getScript();

View File

@@ -0,0 +1,65 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*****************************************************************************
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
* Version 1.1 ("License"); You may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/rpl.php. Software distributed under the
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
* either express or implied.
*
* You may:
* a) Use and distribute this code exactly as you received without payment or
* a royalty or other fee.
* b) Create extensions for this code, provided that you make the extensions
* publicly available and document your modifications clearly.
* c) Charge for a fee for warranty or support or for accepting liability
* obligations for your customers.
*
* You may NOT:
* a) Charge for the use of the original code or extensions, including in
* electronic distribution models, such as ASP (Application Service
* Provider).
* b) Charge for the original source code or your extensions other than a
* nominal fee to cover distribution costs where such distribution
* involves PHYSICAL media.
* c) Modify or delete any pre-existing copyright notices, change notices,
* or License text in the Licensed Software
* d) Assert any patent claims against the Licensor or Contributors, or
* which would in any way restrict the ability of any third party to use the
* Licensed Software.
*
* You must:
* a) Document any modifications you make to this code including the nature of
* the change, the authors of the change, and the date of the change.
* b) Make the source code for any extensions you deploy available via an
* Electronic Distribution Mechanism such as FTP or HTTP download.
* c) Notify the licensor of the availability of source code to your extensions
* and include instructions on how to acquire the source code and updates.
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
* reproduce, perform, modify, sublicense, and distribute your extensions.
*
* The Original Code is: CommuniCore
* Olavo Farias
* 2006-04-7 olavo.farias@gmail.com
*
* The Initial Developer of the Original Code is CommuniCore.
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
* All Rights Reserved.
********************************************************************************/
/*******************************************************************************
* CREATE JAVASCRIPT TO VALIDATE THE DATA ENTERED INTO A RECORD.
*******************************************************************************/
function get_validate_record_js () {
}
/*******************************************************************************
* CREATE FORM FOR MENU RAPID CREATE
*******************************************************************************/
function get_new_record_form () {
}
?>

View File

@@ -0,0 +1,39 @@
<?php
if(isset($_REQUEST['record']) && $_REQUEST['record'] != '') {
require_once('modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php');
$eio = new EcmInvoiceOutOld();
$eio->retrieve($_REQUEST['record']);
if(isset($eio->id) && $eio->id != '') {
$json = getJSONobj();
$arr = array();
$arr['ecmlanguage'] = $eio->ecmlanguage;
$eio->format_all_fields();
$arr['template_id'] = $eio->template_id;
$arr['template_name'] = $eio->template_name;
$arr['parent_type'] = $eio->parent_type;
$arr['parent_id'] = $eio->parent_id;
$arr['parent_name'] = $eio->parent_name;
$arr['parent_address_street'] = $eio->parent_address_street;
$arr['parent_address_city'] = $eio->parent_address_city;
$arr['parent_address_postalcode'] = $eio->parent_address_postalcode;
$arr['parent_address_country'] = $eio->parent_address_country;
$arr['to_nip'] = $eio->to_nip;
$arr['to_is_vat_free'] = $eio->to_is_vat_free;
$arr['to_vatid'] = $eio->to_vatid;
$arr['header_text'] = $eio->header_text;
$arr['footer_text'] = $eio->footer_text;
$arr['ads_text'] = $eio->ads_text;
$arr['discount'] = $eio->discount;
$arr['position_list'] = str_replace('&quot;','\"',$eio->getPositionList());
$arr['total'] = $eio->total;
echo '['.$json->encode($arr).']';
return;
}
return;
}
?>

View File

@@ -0,0 +1,91 @@
<?php
$db = $GLOBALS['db'];
//Q3
$res = $db->query("
SELECT i.parent_id, i.parent_name, i.document_no FROM ecminvoiceoutolds AS i
INNER JOIN accounts AS a
ON a.id = i.parent_id
WHERE
YEAR(i.register_date) = '2014' AND
MONTH(i.register_date) IN ('7','8','9') AND
i.canceled='0' AND i.deleted='0' AND i.type='normal' AND
a.parent_id = '1249';
");
$inv = array();
while ($r = $db->fetchByAssoc($res)) {
$inv[$r['parent_id']]['inv'][] = $r['document_no'];
}
foreach ($inv as $parent=>$val) {
$i = new EcmInvoiceOutOld();
$a = new Account();
$a->retrieve($parent);
$i->parent_id = $a->id;
$i->parent_name = $a->name;
$i->parent_address_street = $a->billing_address_street;
$i->parent_address_city = $a->billing_address_city;
$i->parent_address_postalcode = $a->billing_address_postalcode;
$i->parent_address_country = $a->billing_address_country;
$i->to_nip = $a->to_vatid;
$i->ecmpaymentcondition_id = $a->ecmpaymentcondition_id;
$i->supplier_code = $a->supplier_code;
$pc = new EcmPaymentCondition();
$pc->retrieve($a->ecmpaymentcondition_id);
$i->ecmpaymentcondition_name = $pc->name;
$i->payment_date=$GLOBALS['timedate']->to_display_date(date("Y-m-d",mktime()+3600*24*30));
$i->register_date=$GLOBALS['timedate']->to_display_date(date("Y-m-d"));
$i->sell_date=$GLOBALS['timedate']->to_display_date(date("Y-m-d"));
$i->status="accepted";
$i->type = "correct";
$i->assigned_user_id='1';
$i->created_by='1';
$i->modified_user_id='1';
$i->pdf_type='K';
$i->currency_id='PLN';
$i->template_id = "97700b0d-fbe9-e366-4016-4b260f058a47";
$i->template_name = "e5 Polska Sp. z o. o.";
$i->ads_text = "Faktura wystawiona w programie excel";
$i->position_list = array();
$id = $i->save();
unset($i);
$fvkor = new EcmInvoiceOutOld();
$fvkor->retrieve($id);
echo '<h2>'.$a->name.'</h2><br>';
echo $a->billing_address_street.'<br>';
echo $a->billing_address_city.'<br>';
echo $a->billing_address_postalcode.'<br>';
echo $a->billing_address_country.'<br>';
echo $a->to_vatid.'<br><br>';
echo $fvkor->document_no.'<br>';
echo $fvkor->register_date.'<br>';
echo $fvkor->payment_date.'<br><br>';
echo 'Do faktur:<br>';
foreach ($val['inv'] as $v) {
echo $v.'<br>';
}
echo '-------------------------------------------<br><br><br>';
unset($a);
unset($fvkor);
}
echo '<br><br>Koniec!';
?>

View File

@@ -0,0 +1,255 @@
<?
$account=$_GET['account'];
$type=$_GET['type'];
if(!$_GET['date_from'])$date_from=date("Y-m-d");
else $date_from=$GLOBALS['timedate']->to_db_date($_GET['date_from']);
$exp=explode("-",$date_from);
$date_from=date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0])+24*3600);
if(!$date_from)$date_from=date("Y-m-d");
if(!$_GET['date_to'])$date_to=date("Y-m-d");
else $date_to=$GLOBALS['timedate']->to_db_date($_GET['date_to']);
$exp=explode("-",$date_to);
$date_to=date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0])+24*3600);
if(!$date_to)$date_to=date("Y-m-d");
?>
<table cellspacing="0" cellpadding="0" border="0"><tr><td><img src="themes/Sugar/images/EcmProducts.gif" style="margin-top: 3px; margin-right: 3px;" alt="EcmProducts" width="16" border="0" height="16"></td><td><h2>Invoices: Daily sales </h2></td></tr></table><br />
<ul class="tablist" style="width:100%;">
<li>
<a class="current" href="#">Basic Search</a>
</li>
</ul>
<form action="index.php" method="get">
<input type="hidden" name="module" value="EcmReports" />
<input type="hidden" name="action" value="ListDailySales" />
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="dataLabel" width="10%" nowrap="nowrap">
Date from </td>
<td class="dataField" width="30%" nowrap="nowrap">
<input autocomplete="off" name="date_from" id="date_from" value="<? echo $GLOBALS['timedate']->to_display_date($date_from);?>" title="" tabindex="" size="11" maxlength="10" type="text">
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_from_trigger" align="absmiddle" border="0">
<script type="text/javascript">
Calendar.setup ({
inputField : "date_from",
daFormat : "<? echo str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));?>",
button : "date_from_trigger",
singleClick : true,
dateStr : "",
step : 1
}
);
</script>
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Date to </td>
<td class="dataField" width="30%" nowrap="nowrap">
<input autocomplete="off" name="date_to" id="date_to" value="<? echo $GLOBALS['timedate']->to_display_date($date_to);?>" title="" tabindex="" size="11" maxlength="10" type="text">
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_to_trigger" align="absmiddle" border="0">
<script type="text/javascript">
Calendar.setup ({
inputField : "date_to",
daFormat : "<? echo str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));?>",
button : "date_to_trigger",
singleClick : true,
dateStr : "",
step : 1
}
);
</script>
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Account </td>
<td class="dataField" width="30%" nowrap="nowrap">
<select name="account">
<option value="">select</option>
<?php
$w=$GLOBALS[db]->query("select id,name from accounts where deleted='0' order by name asc");
while($r=$GLOBALS[db]->fetchByAssoc($w)){
echo '<option value="'.$r['id'].'"';
if($account==$r['id'])echo ' selected';
echo '>'.$r['name'].'</option>';
}
?>
</select>
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Document type </td>
<td class="dataField" width="30%" nowrap="nowrap">
<select name="type">
<option value="" <? if($type=="")echo 'selected';?>>normal and correct</option>
<option value="normal" <? if($type=="normal")echo 'selected';?>>normal</option>
<option value="correct" <? if($type=="correct")echo 'selected';?>>correct</option>
</select>
</td>
</tr>
</tbody>
</table>
<input class="button" name="submit" value="Search" type="submit">
<input class="button" name="clear" value="Clear" type="button" onclick="location.href='index.php?module=EcmReports&action=ListDailySales';"><?
echo '&nbsp;<input type="button" class="button" name="CreateXLS" value="Create XLS" onclick="location.href=\'index.php?module=EcmInvoiceOutOlds&action=CreateXLS&date_from='.$date_from.'&date_to='.$date_to.'&account='.$account.'&type='.$type.'\';">';
?>
</form><br />
<?php
$tds1='<td class="listViewThS1">';
$trs='<tr>';
$tre='</tr>';
$tds='<td class="oddListRowS1">';
$tde='</td>';
$tbs='<table cellpadding="0" cellspacing="0" border="0" class="ListView" style="width:100%;">';
$tbe='</table>';
$t.=$tbs;
$t.=$trs;
$t.=$tds1;
$t.="Invoice No";
$t.=$tde;
$t.=$tds1;
$t.="Type";
$t.=$tde;
$t.=$tds1;
$t.="Account";
$t.=$tde;
$t.=$tds1;
$t.="Register Date";
$t.=$tde;
$t.=$tds1;
$t.="Total Brutto";
$t.=$tde;
$t.=$tds1;
$t.="Total Netto";
$t.=$tde;
$t.=$tds1;
$t.="Cost";
$t.=$tde;
$t.=$tds1;
$t.="PLN Margin";
$t.=$tde;
$t.=$tre;
$i=1;
$wh[]="deleted='0'";
if($type)$wh[]="type='".$type."'";
if($account)$wh[]="parent_id='".$account."'";
if($date_from)$wh[]="register_date>='".$date_from."'";
if($date_to)$wh[]="register_date<='".$date_to."'";
$where=implode(" and ",$wh);
$z="select document_no,register_date,id,parent_id,parent_name,type,ecminvoiceoutold_id,currency_value from ecminvoiceoutolds where ".$where." order by type desc, register_date asc, name asc";
$w=$GLOBALS[db]->query($z);
echo mysql_error();
while($r=$GLOBALS[db]->fetchByAssoc($w)){
$total_netto=0;
$total_pur=0;
$total_brutto=0;
$total_margin=0;
if(!$r['currency_value'])$currency_value=1;
else $currency_value=$r['currency_value'];
$ww=$GLOBALS[db]->query("select price,ecmvat_value,quantity,purchase_price,ecmproduct_id,ecminvoiceoutolditem_id from ecminvoiceoutolditems where ecminvoiceoutold_id='".$r['id']."' and deleted='0'");
while($rr=$GLOBALS[db]->fetchByAssoc($ww)){
if($r['type']!="correct"){
$pprice=$rr['purchase_price'];
$total_netto+=$currency_value*$rr['price']*$rr['quantity'];
$total_pur+=$pprice*$rr['quantity'];
$total_brutto+=$currency_value*$rr['price']*$rr['quantity']*(1+$rr['ecmvat_value']/100);
$total_margin+=($currency_value*$rr['price']-$pprice)*$rr['quantity'];
}
else{
$rrrr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select price,quantity,purchase_price from ecminvoiceoutolditems where id='".$rr['ecminvoiceoutolditem_id']."'"));
$pprice=$rrrr['purchase_price'];
$total_netto+=$currency_value*$rr['price']*$rr['quantity']-$currency_value*$rrrr['price']*$rrrr['quantity'];
$total_pur+=$pprice*($rr['quantity']-$rrrr['quantity']);
$total_brutto+=($currency_value*$rr['price']*$rr['quantity']-$currency_value*$rrrr['price']*$rrrr['quantity'])*(1+$rr['ecmvat_value']/100);
$total_margin+=($currency_value*$rr['price']-$pprice)*$rr['quantity']-($currency_value*$rrrr['price']-$pprice)*$rrrr['quantity'];
}
}
/*
if($r['type']=="correct"){
//echo $total_margin.'<br>';
$ww=$GLOBALS[db]->query("select price,ecmvat_value,quantity,purchase_price,ecmproduct_id from ecminvoiceoutolditems where ecminvoiceoutold_id='".$r['ecminvoiceoutold_id']."' and deleted='0'");
while($rr=$GLOBALS[db]->fetchByAssoc($ww)){
if(mysql_num_rows($GLOBALS[db]->query("select id from ecmproducts where product_active='1' and id='".$rr['ecmproduct_id']."'"))==0)continue;
$total_netto-=$rr['price']*$rr['quantity'];
$total_pur-=$rr['purchase_price']*$rr['quantity'];
//echo $total_margin.'<br>';
$total_brutto-=$rr['price']*$rr['quantity']*(1+$rr['ecmvat_value']/100);
$total_margin-=($rr['price']-$rr['purchase_price'])*$rr['quantity'];
}
}*/
if($total_netto-$total_margin>0)$margin=100*$total_margin/($total_netto-$total_margin);
else $margin=0;
$t.=$trs;
$t.=$tds;
$t.='<a href="index.php?module=EcmInvoiceOutOlds&action=DetailView&record='.$r['id'].'">'.$r['document_no'].'</a>';
$t.=$tde;
$t.=$tds;
$t.=$r['type'];
$t.=$tde;
$t.=$tds;
$t.='<a href="index.php?module=Accounts&action=DetailView&record='.$r['parent_id'].'">'.$r['parent_name'].'</a>';
$t.=$tde;
$t.=$tds;
$t.=$GLOBALS['timedate']->to_display_date($r['register_date']);
$t.=$tde;
$t.=$tds;
$t.=number_format($total_brutto,2,",",".");
$t.=$tde;
$t.=$tds;
$t.=number_format($total_netto,2,",",".");
$t.=$tde;
$t.=$tds;
$t.=number_format(($total_netto-$total_margin),2,",",".");
$t.=$tde;
$t.=$tds;
$t.=number_format($total_margin,2,",",".")." (".number_format($margin,2,",",".")."%)";
$t.=$tde;
$t.=$tre;
$sum_total_netto+=$total_netto;
$sum_total_pur+=$total_pur;
$sum_total_brutto+=$total_brutto;
$sum_total_margin+=$total_margin;
$i++;
}
$t.=$trs;
if($sum_total_netto-$sum_total_margin>0)$sum_margin=100*$sum_total_margin/($sum_total_netto-$sum_total_margin);
else $sum_margin=0;
$t.=$tds1;
$t.="&nbsp;";
$t.=$tde;
$t.=$tds1;
$t.="&nbsp;";
$t.=$tde;
$t.=$tds1;
$t.="&nbsp;";
$t.=$tde;
$t.=$tds1;
$t.="&nbsp;";
$t.=$tde;
$t.=$tds1;
$t.=number_format($sum_total_brutto,2,",",".");
$t.=$tde;
$t.=$tds1;
$t.=number_format($sum_total_netto,2,",",".");
$t.=$tde;
$t.=$tds1;
$t.=number_format(($sum_total_netto-$sum_total_margin),2,",",".");
$t.=$tde;
$t.=$tds1;
$t.=number_format($sum_total_margin,2,",",".")."(".number_format($sum_margin,2,",",".")."%)";
$t.=$tde;
$t.=$tre;
$t.=$tbe;
echo $t;
?>

View File

@@ -0,0 +1,210 @@
<?
if(!$_GET['date_from'])$date_from=date("Y-m-d");
else $date_from=$GLOBALS['timedate']->to_db_date($_GET['date_from']);
$exp=explode("-",$date_from);
$date_from=date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0])+24*3600);
if(!$date_from)$date_from=date("Y-m-d");
if(!$_GET['date_to'])$date_to=date("Y-m-d");
else $date_to=$GLOBALS['timedate']->to_db_date($_GET['date_to']);
$exp=explode("-",$date_to);
$date_to=date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0])+24*3600);
if(!$date_to)$date_to=date("Y-m-d");
?>
<table cellspacing="0" cellpadding="0" border="0"><tr><td><img src="themes/Sugar/images/EcmProducts.gif" style="margin-top: 3px; margin-right: 3px;" alt="EcmProducts" width="16" border="0" height="16"></td><td><h2>Faktury: Sprzedane produkty</h2></td></tr></table><br />
<ul class="tablist" style="width:100%;">
<li>
<a class="current" href="#">Podstawowe wyszukiwanie</a>
</li>
</ul>
<form action="index.php" method="get">
<input type="hidden" name="module" value="EcmInvoiceOutOlds" />
<input type="hidden" name="action" value="ListProducts" />
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="dataLabel" width="10%" nowrap="nowrap">
Data od </td>
<td class="dataField" width="30%" nowrap="nowrap">
<input autocomplete="off" name="date_from" id="date_from" value="<? echo $GLOBALS['timedate']->to_display_date($date_from);?>" title="" tabindex="" size="11" maxlength="10" type="text">
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_from_trigger" align="absmiddle" border="0">
<script type="text/javascript">
Calendar.setup ({
inputField : "date_from",
daFormat : "<? echo str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));?>",
button : "date_from_trigger",
singleClick : true,
dateStr : "",
step : 1
}
);
</script>
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Data do </td>
<td class="dataField" width="30%" nowrap="nowrap">
<input autocomplete="off" name="date_to" id="date_to" value="<? echo $GLOBALS['timedate']->to_display_date($date_to);?>" title="" tabindex="" size="11" maxlength="10" type="text">
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_to_trigger" align="absmiddle" border="0">
<script type="text/javascript">
Calendar.setup ({
inputField : "date_to",
daFormat : "<? echo str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));?>",
button : "date_to_trigger",
singleClick : true,
dateStr : "",
step : 1
}
);
</script>
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Kategoria </td>
<td class="dataField" width="30%" nowrap="nowrap">
<select name="category_id">
<option value="">wybierz</option>
<?php
?>
</td>
</tr>
</tbody>
</table>
<input class="button" name="submit" value="Szukaj" type="submit">
<input class="button" name="clear" value="Wyczyść" type="button" onclick="location.href='index.php?module=EcmInvoiceOutOlds&action=ListProducts';"><?
echo '&nbsp;<input type="button" class="button" name="CreateXLS" value="Utwórz XLS" onclick="location.href=\'index.php?module=EcmInvoiceOutOlds&action=CreateXLSProducts&to_pdf=1&date_from='.$date_from.'&date_to='.$date_to.'\';">';
?>
</form><br />
<h2>Data: <? echo $GLOBALS['timedate']->to_display_date($date);?></h2>
<?php
$tds1='<td class="listViewThS1">';
$trs='<tr>';
$tre='</tr>';
$tds='<td class="oddListRowS1">';
$tde='</td>';
$tbs='<table cellpadding="0" cellspacing="0" border="0" class="ListView" style="width:100%;">';
$tbe='</table>';
$t.=$tbs;
$t.=$trs;
$t.=$tds1;
$t.="Nr.";
$t.=$tde;
$t.=$tds1;
$t.="Index";
$t.=$tde;
$t.=$tds1;
$t.="Nazwa";
$t.=$tde;
$t.=$tds1;
$t.="Faktura";
$t.=$tde;
$t.=$tds1;
$t.="Ilość";
$t.=$tde;
$t.=$tds1;
$t.="Cena";
$t.=$tde;
$t.=$tds1;
$t.="Razem netto";
$t.=$tde;
$t.=$tds1;
$t.="Razem Vat";
$t.=$tde;
$t.=$tds1;
$t.="Razem brutto";
$t.=$tde;
$t.=$tre;
$i=1;
$z="select ecminvoiceoutolditems.*,ecminvoiceoutolds.document_no as dno,ecminvoiceoutolds.id as sid,ecminvoiceoutolds.type as type,ecminvoiceoutolds.currency_value as currency_value from ecminvoiceoutolditems inner join ecminvoiceoutolds on ecminvoiceoutolditems.ecminvoiceoutold_id=ecminvoiceoutolds.id where ecminvoiceoutolds.deleted='0' and ecminvoiceoutolds.register_date>='".$date_from."' and ecminvoiceoutolds.register_date<='".$date_to."' and ecminvoiceoutolditems.deleted='0'";
$db = $GLOBALS['db'];
$w=$db->query($z);
echo $db->error;
while($r=$db->fetchByAssoc($w)){
if(!$r['currency_value'])$currency_value=1;
else $currency_value=$r['currency_value'];
$total_netto=$currency_value*$r['price']*$r['quantity'];
$total_vat=$currency_value*$r['price']*$r['quantity']*($r['ecmvat_value']/100);
$total_brutto=$currency_value*$r['price']*$r['quantity']*(1+$r['ecmvat_value']/100);
if($r['type']=="correct"){
$rr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select price,quantity,ecmvat_value from ecminvoiceoutolditems where id='".$r['ecminvoiceoutolditem_id']."'"));
$total_netto-=$currency_value*$rr['price']*$rr['quantity'];
$total_vat-=$currency_value*$rr['price']*$rr['quantity']*($rr['ecmvat_value']/100);
$total_brutto-=$currency_value*$rr['price']*$rr['quantity']*(1+$rr['ecmvat_value']/100);
$r['price']=$currency_value*$rr['price'];
$r['quantity']-=$rr['quantity'];
}
if($r['quantity']==0)continue;
$t.=$trs;
$t.=$tds;
$t.=$i;
$t.=$tde;
$t.=$tds;
$t.=$r['code'];
$t.=$tde;
$t.=$tds;
$t.='<a href="index.php?module=EcmProducts&action=DetailView&record='.$r['ecmproduct_id'].'">'.$r['name'].'</a>';
$t.=$tde;
$t.=$tds;
$t.='<a href="index.php?module=EcmInvoiceOutOlds&action=DetailView&record='.$r['sid'].'">'.$r['dno'].'</a>';
$t.=$tde;
$t.=$tds;
$t.=((int)$r['quantity']);
$t.=$tde;
$t.=$tds;
$t.=number_format($r['price'],2,",",".");
$t.=$tde;
$t.=$tds;
$t.=number_format($total_netto,2,",",".");
$t.=$tde;
$t.=$tds;
$t.=number_format($total_vat,2,",",".");
$t.=$tde;
$t.=$tds;
$t.=number_format($total_brutto,2,",",".");
$t.=$tde;
$t.=$tre;
//$sum_price+=$r['price'];
$sum_total_netto+=$total_netto;
$sum_total_vat+=$total_vat;
$sum_total_brutto+=$total_brutto;
$sum_qty+=$r['quantity'];
$i++;
}
$t.=$trs;
$t.=$tds1;
$t.=$tde;
$t.=$tds1;
$t.=$tde;
$t.=$tds1;
$t.=$tde;
$t.=$tds1;
$t.=$tde;
$t.=$tds1;
$t.=(int)$sum_qty;
$t.=$tde;
$t.=$tds1;
$t.=@number_format(($sum_total/$sum_qty),2,",",".");
$t.=$tde;
$t.=$tds1;
$t.=number_format($sum_total_netto,2,",",".");
$t.=$tde;
$t.=$tds1;
$t.=number_format($sum_total_vat,2,",",".");
$t.=$tde;
$t.=$tds1;
$t.=number_format($sum_total_brutto,2,",",".");
$t.=$tde;
$t.=$tre;
$t.=$tbe;
echo $t;
?>

View File

@@ -0,0 +1,130 @@
<table cellspacing="0" cellpadding="0" border="0"><tr><td><img src="themes/Sugar/images/EcmProducts.gif" style="margin-top: 3px; margin-right: 3px;" alt="EcmProducts" width="16" border="0" height="16"></td><td><h2>Faktury: Produkty na fakturach:</h2></td></tr></table><br />
<ul class="tablist" style="width:100%;">
<li>
<a class="current" href="#">Podstawowe wyszukiwanie</a>
</li>
</ul>
<form action="index.php" method="get" name="SearchFormSales">
<input type="hidden" name="module" value="EcmInvoiceOutOlds" />
<input type="hidden" name="action" value="ListSales" />
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="dataLabel" width="10%" nowrap="nowrap">
Rok
</td>
<td class="dataField" width="30%" nowrap="nowrap">
<input name="year" id="year" value="<? echo $_REQUEST['year'];?>" title="" tabindex="" size="11" type="text">
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Index
</td>
<td class="dataField" width="30%" nowrap="nowrap">
<input name="code" id="code" value="<? echo $_REQUEST['code'];?>" title="" tabindex="" size="11" type="text">
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Ilość
</td>
<td class="dataField" width="30%" nowrap="nowrap">
<input name="quantity" id="quantity" value="<? echo $_REQUEST['quantity'];?>" title="" tabindex="" size="11" type="text">
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Cena
</td>
<td class="dataField" width="30%" nowrap="nowrap">
<input name="price" id="price" value="<? echo $_REQUEST['price'];?>" title="" tabindex="" size="11" type="text">
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">Kontrahent</td>
<td class="dataField" nowrap="nowrap">
<input name="account_name" tabindex="" id="account_name" size="" value="<?php echo $_REQUEST['account_name'];?>" title="" type="text">
<input name="account_id" id="account_id" value="<?php echo $_REQUEST['account_id'];?>" type="hidden">
<input name="btn_account_name" tabindex="" title="Wybierz [Alt+T]" accesskey="T" class="button" value="Wybierz" onclick='open_popup("Accounts", 600, 400, "", true, false, {"call_back_function":"set_return","form_name":"SearchFormSales","field_to_name_array":{"id":"account_id","name":"account_name"}}, "single", true);' type="button"></td>
</tr>
</tbody>
</table>
<input class="button" name="submit" value="Szukaj" type="submit">
<input class="button" name="clear" value="Wyczyść" type="button" onclick="location.href='index.php?module=EcmInvoiceOutOlds&action=ListSales';"><?
?>
</form><br />
<?php
$tds1='<td class="listViewThS1">';
$trs='<tr style="vertical-align:top;">';
$tre='</tr>';
$tds='<td class="oddListRowS1" style="vertical-align:top;">';
$tde='</td>';
$tbs='<table cellpadding="0" cellspacing="0" border="0" class="ListView" style="width:100%;">';
$tbe='</table>';
$t.=$tbs;
$t.=$trs;
$t.=$tds1;
$t.="Index";
$t.=$tde;
$t.=$tds1;
$t.="Nazwa";
$t.=$tde;
$t.=$tds1;
$t.="Ilość";
$t.=$tde;
$t.=$tds1;
$t.="Cena";
$t.=$tde;
$t.=$tds1;
$t.="Nr dokumentu";
$t.=$tde;
$t.=$tds1;
$t.="Data rejestracji";
$t.=$tde;
$t.=$tre;
$i=1;
if($_REQUEST['year'])$wh[]="e.register_date like '".$_REQUEST['year']."%'";
if($_REQUEST['price'])$wh[]="p.price='".(float)str_replace(",",".",$_REQUEST['price'])."'";
if($_REQUEST['code'])$wh[]="p.code like '".$_REQUEST['code']."%'";
if($_REQUEST['quantity'])$wh[]="p.quantity>=".$_REQUEST['quantity']."";
if($_REQUEST['account_id'])$wh[]="e.parent_id='".$_REQUEST['account_id']."'";
if($_REQUEST['account_name'] && !$_REQUEST['account_id'])$wh[]="e.parent_name like '".$_REQUEST['account_name']."%'";
if(count($wh)>0)$where=" and ".implode(" and ",$wh);
else $where="";
if($_REQUEST['code'] && ($_REQUEST['account_name'] || $_REQUEST['account_id'])){
$z="select p.subprice, p.quantity,p.price,p.code,p.name,e.document_no,e.register_date,e.id as iid,p.ecmproduct_id as pid from ecminvoiceoutolds as e inner join ecminvoiceoutolditems as p on p.ecminvoiceoutold_id=e.id where e.deleted='0' and e.type!='correct' ".$where;
$w=$GLOBALS['db']->query($z);
echo mysql_error();//echo $z;
while($r=$GLOBALS['db']->fetchByAssoc($w)){
$t.=$trs;
$t.=$tds;
$t.=$r['code'];
$t.=$tde;
$t.=$tds;
$t.=$r['name'];
$t.=$tde;
$t.=$tds;
$t.=number_format($r['quantity'],0,"","");
$t.=$tde;
$t.=$tds;
$t.=number_format($r['subprice'],2,",",".");
$t.=$tde;
$t.=$tds;
$t.='<a href="index.php?module=EcmInvoiceOutOlds&action=DetailView&record='.$r['iid'].'">'.$r['document_no'].'</a>';
$t.=$tde;
$t.=$tds;
$t.=$GLOBALS['timedate']->to_display_date($r['register_date']);
$t.=$tde;
$t.=$tre;
$i++;
}
}
$t.=$tbe;
echo $t;
?>

View File

@@ -0,0 +1,39 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings;
require_once('modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php');
require_once('modules/EcmInvoiceOutOlds/Forms.php');
require_once ('include/time.php');
require_once('include/json_config.php');
$json_config = new json_config();
$focus = new EcmInvoiceOutOld();
if(isset($_REQUEST['record'])) {
$focus->retrieve($_REQUEST['record']);
}
else {}
require_once('include/MVC/View/SugarView.php');
if(file_exists('modules/EcmInvoiceOutOlds/views/view.list.php')) {
require_once('modules/EcmInvoiceOutOlds/views/view.list.php');
$list = new EcmInvoiceOutOldsViewList();
}
else {
require_once('include/MVC/View/views/view.list.php');
$list = new ViewList();
}
$list->bean = $focus;
$list->module='EcmInvoiceOutOlds';
// if(!isset($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] != "true") require_once('modules/EcmGroupSales/HeaderMenu.php');
$list->preDisplay();
$list->display();
?>

View File

@@ -0,0 +1,61 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php');
$source = new EcmInvoiceOutOld();
$source->retrieve($outId);
if(isset($source->id) && $source->id != '') {
$focus->name = $source->name;
$focus->position_list = $source->getPositionList(true);
$focus->template_id = $source->template_id;
$focus->template_name = $source->template_name;
$focus->total = $source->total;
$focus->subtotal = $source->subtotal;
$focus->to_parent = $source->parent_type;
$focus->to_id = $source->parent_id;
$focus->to_name = $source->parent_name;
$focus->invoice_type_id = 'normal';
$focus->to_address = $source->parent_address_street;
$focus->to_city = $source->parent_address_city;
$focus->to_postalcode = $source->parent_address_postalcode;
$focus->to_country = $source->parent_address_country;
$focus->to_nip = $source->to_nip;
$focus->to_vatid = $source->to_vatid;
$focus->to_is_vat_free = $source->to_is_vat_free;
}
?>

View File

@@ -0,0 +1,48 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php');
$source = new EcmInvoiceOutOld();
$source->retrieve($outId);
if(isset($source->id) && $source->id != '') {
$pos=$source->getPositionList(true);
$focus->name = $source->name;
/*echo '<pre>';
print_r($pos);
echo '</pre>';*/
foreach($pos as $pp){
$r=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select quantity,price from ecminvoiceoutolditems where id='".$pp['item_id']."'"));
if($pp['quantity']!=$r['quantity']){
$rprod=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select name from ecmproducts where id='".$pp['id']."'"));
$pname=$rprod['name'];
$pp['name']=$pname;
$pp['quantity']=$r['quantity']-$pp['quantity'];
$ppos[]=$pp;
}
}
/*echo '<pre>';
print_r($ppos);
echo '</pre>';*/
if(count($ppos) > 0) {
$json = getJSONobj();
$focus->position_list = str_replace('&quot;','\"',$json->encode($ppos));
}
$focus->template_id = $source->template_id;
$focus->template_name = $source->template_name;
}
?>

View File

@@ -0,0 +1,119 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*****************************************************************************
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
* Version 1.1 ("License"); You may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/rpl.php. Software distributed under the
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
* either express or implied.
*
* You may:
* a) Use and distribute this code exactly as you received without payment or
* a royalty or other fee.
* b) Create extensions for this code, provided that you make the extensions
* publicly available and document your modifications clearly.
* c) Charge for a fee for warranty or support or for accepting liability
* obligations for your customers.
*
* You may NOT:
* a) Charge for the use of the original code or extensions, including in
* electronic distribution models, such as ASP (Application Service
* Provider).
* b) Charge for the original source code or your extensions other than a
* nominal fee to cover distribution costs where such distribution
* involves PHYSICAL media.
* c) Modify or delete any pre-existing copyright notices, change notices,
* or License text in the Licensed Software
* d) Assert any patent claims against the Licensor or Contributors, or
* which would in any way restrict the ability of any third party to use the
* Licensed Software.
*
* You must:
* a) Document any modifications you make to this code including the nature of
* the change, the authors of the change, and the date of the change.
* b) Make the source code for any extensions you deploy available via an
* Electronic Distribution Mechanism such as FTP or HTTP download.
* c) Notify the licensor of the availability of source code to your extensions
* and include instructions on how to acquire the source code and updates.
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
* reproduce, perform, modify, sublicense, and distribute your extensions.
*
* The Original Code is: CommuniCore
* Olavo Farias
* 2006-04-7 olavo.farias@gmail.com
*
* The Initial Developer of the Original Code is CommuniCore.
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
* All Rights Reserved.
********************************************************************************/
// require_once('modules/EcmGroupSales/Menu.php');
global $mod_strings, $current_user;
if(ACLController::checkAccess('EcmInvoiceOutOlds', "edit", true))
$module_menu [] = Array("index.php?module=".'EcmInvoiceOutOlds'."&action=EditView&return_module=".'EcmInvoiceOutOlds'."&return_action=DetailView", translate('LNK_NEW_'.'ECMINVOICEOUTOLD', 'EcmInvoiceOutOlds'),"CreateEcmInvoiceOutOlds", 'EcmInvoiceOutOlds');
if(ACLController::checkAccess('EcmInvoiceOutOlds', "list", true)) $module_menu [] = Array("index.php?module=EcmInvoiceOutOlds&action=index&return_module=EcmInvoiceOutOlds&return_action=DetailView", translate('LNK_ECMINVOICEOUTOLDS_LIST','EcmInvoiceOutOlds'),"EcmInvoiceOutOlds", 'EcmInvoiceOutOlds');
if(ACLController::checkAccess('EcmInvoiceOutOlds', "list", true)) $module_menu [] = Array("index.php?module=EcmInvoiceOutOlds&action=indexDecree&return_module=EcmInvoiceOutOlds&return_action=DetailView", "Dekret","EcmInvoiceOutOlds", 'EcmInvoiceOutOlds');
if(ACLController::checkAccess('EcmInvoiceOutOlds', 'list', true) && is_admin($current_user))
$module_menu [] = Array("index.php?module=EcmInvoiceOutOlds&action=PDFLanguages&return_module=EcmInvoiceOutOlds&return_action=index", $mod_strings['LNK_ECMINVOICEOUTOLDS_PDFLANGUAGES'], "PDFlanguages", 'EcmInvoiceOutOlds');
if(ACLController::checkAccess('EcmInvoiceOutOlds', 'list', true))
$module_menu [] = Array("index.php?module=EcmInvoiceOutOlds&action=ListSales&return_module=EcmInvoiceOutOlds&return_action=index", "Products on invoices", "ProductsOnInvoices", 'EcmInvoiceOutOlds');
?>

View File

@@ -0,0 +1,193 @@
<table cellspacing="0" cellpadding="0" border="0"><tr><td><img src="themes/Sugar/images/EcmProducts.gif" style="margin-top: 3px; margin-right: 3px;" alt="EcmProducts" width="16" border="0" height="16"></td><td><h2>Faktury: Produkty na fakturach:</h2></td></tr></table><br />
<ul class="tablist" style="width:100%;">
<li>
<a class="current" href="#">Podstawowe wyszukiwanie</a>
</li>
</ul>
<form action="index.php" method="get" name="SearchFormSales">
<input type="hidden" name="module" value="EcmInvoiceOutOlds" />
<input type="hidden" name="action" value="ListSales" />
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="dataLabel" width="10%" nowrap="nowrap">
Rok
</td>
<td class="dataField" width="30%" nowrap="nowrap">
<input name="year" id="year" value="<? echo $_REQUEST['year'];?>" title="" tabindex="" size="11" type="text">
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Index
</td>
<td class="dataField" width="30%" nowrap="nowrap">
<input name="code" id="code" value="<? echo $_REQUEST['code'];?>" title="" tabindex="" size="11" type="text">
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Ilość
</td>
<td class="dataField" width="30%" nowrap="nowrap">
<input name="quantity" id="quantity" value="<? echo $_REQUEST['quantity'];?>" title="" tabindex="" size="11" type="text">
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Cena
</td>
<td class="dataField" width="30%" nowrap="nowrap">
<input name="price" id="price" value="<? echo $_REQUEST['price'];?>" title="" tabindex="" size="11" type="text">
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">Kontrahent</td>
<td class="dataField" nowrap="nowrap">
<input name="account_name" tabindex="" id="account_name" size="" value="<?php echo $_REQUEST['account_name'];?>" title="" type="text">
<input name="account_id" id="account_id" value="<?php echo $_REQUEST['account_id'];?>" type="hidden">
<input name="btn_account_name" tabindex="" title="Wybierz [Alt+T]" accesskey="T" class="button" value="Wybierz" onclick='open_popup("Accounts", 600, 400, "", true, false, {"call_back_function":"set_return","form_name":"SearchFormSales","field_to_name_array":{"id":"account_id","name":"account_name"}}, "single", true);' type="button"></td>
</tr>
</tbody>
</table>
<input class="button" name="submit" value="Szukaj" type="submit">
<input class="button" name="clear" value="Wyczyść" type="button" onclick="location.href='index.php?module=EcmInvoiceOutOlds&action=ListSales';"><?php
echo '&nbsp;<input type="button" class="button" name="gets" value="Utwórz PDFy" onclick="location.href=\'index.php?module=EcmInvoiceOutOlds&action=MultiCorPDF&year='.$_REQUEST['year'].'&account_id='.$_REQUEST['account_id'].'&account_name='.$_REQUEST['account_name'].'&parent_order_no='.$_REQUEST['parent_order_no'].'&submit=send&gets=1\';">';
?>
</form><br />
<?php
ini_set('display_errors',1);
set_time_limit(0);
$tds1='<td class="listViewThS1">';
$trs='<tr style="vertical-align:top;">';
$tre='</tr>';
$tds='<td class="oddListRowS1" style="vertical-align:top;">';
$tde='</td>';
$tbs='<table cellpadding="0" cellspacing="0" border="0" class="ListView" style="width:100%;">';
$tbe='</table>';
$t.=$tbs;
$t.=$trs;
$t.=$tds1;
$t.="Index";
$t.=$tde;
$t.=$tds1;
$t.="Nazwa";
$t.=$tde;
$t.=$tds1;
$t.="Ilość";
$t.=$tde;
$t.=$tds1;
$t.="Cena";
$t.=$tde;
$t.=$tds1;
$t.="Nr dokumentu";
$t.=$tde;
$t.=$tds1;
$t.="Data rejestracji";
$t.=$tde;
$t.=$tre;
$i=1;
if($_REQUEST['year'])$wh[]="e.register_date like '".$_REQUEST['year']."%'";
if($_REQUEST['price'])$wh[]="p.price='".(float)str_replace(",",".",$_REQUEST['price'])."'";
if($_REQUEST['code'])$wh[]="p.code like '".$_REQUEST['code']."%'";
if($_REQUEST['quantity'])$wh[]="p.quantity>=".$_REQUEST['quantity']."";
if($_REQUEST['account_id'])$wh[]="e.parent_id='".$_REQUEST['account_id']."'";
if($_REQUEST['account_name'] && !$_REQUEST['account_id'])$wh[]="e.parent_name like '".$_REQUEST['account_name']."%'";
if(count($wh)>0)$where=" and ".implode(" and ",$wh);
else $where="";
if($_REQUEST['submit']){
$z="select id as iid from ecminvoiceoutolds as e where e.deleted='0'
and e.type='correct' and e.register_date like '2014%' and e.parent_id='94'";
echo $z;
$w=$GLOBALS['db']->query($z);
echo mysql_error();//echo $z;
while($r=$GLOBALS['db']->fetchByAssoc($w)){
$t.=$trs;
$t.=$tds;
$t.=$r['code'];
$t.=$tde;
$t.=$tds;
$t.=$r['name'];
$t.=$tde;
$t.=$tds;
$t.=number_format($r['quantity'],0,"","");
$t.=$tde;
$t.=$tds;
$t.=number_format($r['subprice'],2,",",".");
$t.=$tde;
$t.=$tds;
$t.='<a href="index.php?module=EcmInvoiceOutOlds&action=DetailView&record='.$r['iid'].'">'.$r['document_no'].'</a>';
$t.=$tde;
$t.=$tds;
$t.=$GLOBALS['timedate']->to_display_date($r['register_date']);
$t.=$tde;
$t.=$tre;
$i++;
require_once('modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php');
if($_REQUEST['gets']==1){
$strPath = dirname(__FILE__) . "\\";
$s = new EcmInvoiceOutOld();
$s->retrieve($r['iid']);
//$pdf2 = new PDFMerger;
$ab[]=$s->createPdfFileName();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://192.168.1.130/crm/index.php?action=Authenticate&module=Users&return_module=Users&return_action=Login&user_name=db&user_password=rudemodz&login_theme=Sugar&login_language=en_us');
//curl_setopt($ch, CURLOPT_POSTFIELDS,'user_name=db&user_password='.$pass.'');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
$page = curl_exec($ch);
//echo $page;
//echo $pass = md5('rudemodz');
$up='http://192.168.1.130/crm/index.php?module=EcmInvoiceOutOlds&action=previewPDF&type=&to_pdf=1&record='.$r['iid'].'';
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $up);
$page = curl_exec($ch);
$fp = fopen('pdftmp/'.$s->createPdfFileName().'', 'w');
fwrite($fp, $page);
fclose($fp);
//$pdf2->addPDF('pdftmp/'.$s->createPdfFileName().'', 'all');
}
}
}
if($_REQUEST['gets']==1){
//$pdf2->merge('file', 'pdftmp/TEST2.pdf');
$fp = fopen('generatorfifi2.php', 'w');
$s="<?php\ninclude 'PDFMerger.php';\n\$pdf = new PDFMerger;\n\$pdf";
foreach($ab as $k){
$s.="->addPDF('pdftmp/".$k."', 'all')\n";
}
$s.="->merge('file', 'pdftmp/".$current_user->user_name.date("h:y");
$s.=".pdf');";
//$b=microtime();
fwrite($fp, $s);
fclose($fp);
//echo microtime();
$up='http://192.168.1.130/crm/generatorfifi2.php';
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $up);
$page = curl_exec($ch);
header("Location: pdftmp/".$current_user->user_name.date("h:y").".pdf");
}
$t.=$tbe;
echo $t;
?>

View File

@@ -0,0 +1,816 @@
var reg = /[\s]/g;
function findPos(obj) {
var curleft = curtop = 0;
if (obj.offsetParent)
do {
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
} while (obj = obj.offsetParent);
return [curleft, curtop];
}
function generateSelectOptions(arr, selected) {
var tmp = '';
for (x in arr) {
tmp += '<option value="' + x + '" ' + ((arr[x] === selected) ? 'selected' : '') + '>' + arr[x] + '</option>';
}
return tmp;
}
function NumberToUserFormatNumber(number, add) {
if (!number) number = 0;
number = parseFloat(number);
//var tmp = number.toFixed(OPT['dec_len']);
var tmp = number.toFixed(2);
//var s1 = tmp.substring(0,tmp.length-1-OPT['dec_len']);
var s1 = tmp.substring(0, tmp.length - 1 - 2);
//var s2 = tmp.substring(tmp.length-OPT['dec_len'],tmp.length);
var s2 = tmp.substring(tmp.length - 2, tmp.length);
var tmp = '';
for (var i = s1.length; i > 0; i -= 3) {
// tmp = ((i<=3)?"":OPT['sep_1000'])+s1.substring(i-3,i)+tmp;
tmp = s1.substring(i - 3, i) + tmp;
if (i > 3) tmp = '.' + tmp;
}
s1 = tmp;
//return (s1+OPT['dec_sep']+s2).toString()+((add)?add:'');
return (s1 + ',' + s2).toString() + ((add) ? add : '');
}
function UserFormatNumberToNumber(ufn, add) {
if (add) {
var match = /add/g;
ufn = ufn.replace(match, '');
}
var match = /Err/g;
ufn = ufn.replace(match, '');
if (!ufn) return parseFloat(0);
var pos = ufn.indexOf(OPT['dec_sep']);
var s1 = '',
s2 = '';
if (pos == -1) {
s1 = ufn;
s2 = '';
} else {
s1 = ufn.substring(0, pos);
s2 = ufn.substring(pos + 1, ufn.length);
}
/*
if(OPT['sep_1000'] != "")
for(var i=s1.length-4;i>=0;i-=4)
if(s1.charAt(i) != OPT['sep_1000']) { return -1; }
if(s1.charAt(0) == OPT['sep_1000']) return -1;
*/
var pos = -1;
while ((pos = s1.indexOf(OPT['sep_1000'])) != -1)
s1 = s1.substring(0, pos) + s1.substring(pos + 1, s1.length);
//alert(s1);
return parseFloat(s1 + "." + s2);
}
function keyPressedNumber(e) {
var keynum;
if (window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
return keynum;
}
function isEnterOrTabPressed(e) {
var keynum = keyPressedNumber(e);
if (keynum == 9 || keynum == 13) return true;
else return false;
}
function setSelectionRange(obj) {
if (obj && typeof(obj) == "object" && (obj.type == "text" || obj.type == "textarea")) {
if (obj.createTextRange) {
var range = obj.createTextRange();
range.moveStart("character", 0);
range.moveEnd("character", obj.value.lengh - 1);
range.select();
} else {
if (obj.setSelectionRange) {
obj.setSelectionRange(0, obj.value.length);
}
}
obj.focus();
}
if (obj && typeof(obj) == "object" && obj.options) {
obj.focus();
}
}
/*
function keyPressed = function(e, method) {
var keynumkey = PressedNumber(e);
if((keynum == 9) || (keynum == 13)) {
//this.calculateTotal();
//if(this.selectedCell.lp == 1) setTimeout( function() { N.selectNextCell(); } , 100);
//this.selectNextCell();
return false;
}
//if(keynum == 40) this.selectNextRow();
//if(keynum == 38) this.selectPreviousRow();
if(e.shiftKey && (method == "decimalNumber" || method == "onlyNumber")) return false;
if(method == "decimalNumber") return this.OnlyNumbers(keynum);
if(method == "onlyNumber") return this.OnlyNumbers(keynum, true);
return true;
}
this.OnlyNumbers = function(e, noInvoiceOut) {
var keynum = e, keychar, numcheck;
keychar = String.fromCharCode(keynum);
numcheck = /\d/;
return numcheck.test(keychar)
|| ((!noInvoiceOut)?(keynum == 190):false)
|| (keynum == 8) //backspace
|| (keynum == 13) //enter
|| (keynum == 0) //special keys with FF
|| (keynum == 37) //left arrow
|| (keynum == 39) //right arrow
|| (keynum == 188) //,
|| (keynum >= 95 && keynum <= 105) //numeric keyboard
|| (keynum == 110);
}
*/
function MyTable(name) {
this.myTableName = name;
this.table = document.getElementById(this.myTableName);
this.thead = this.table.tHead;
this.tbody = this.table.tBodies.item(0);
this.cellSelectedClass = 'selectedCell';
this.rowSelectedClass = 'selectedRow';
this.selectedRow;
this.selectedCell;
this.divParent;
this.rowCount = function() {
return this.tbody.rows.length;
}
this.colCount = function() {
return this.thead.rows.item(0).cells.length;
};
this.colWidth = function(i) {
return this.thead.rows.item(0).cells.item(i).width;
};
this.moveUpRow = function() {
if (this.selectedRow) this.selectedRow.moveUp();
};
this.moveDownRow = function() {
if (this.selectedRow) this.selectedRow.moveDown();
};
this.insertRow = function(row, newRow) {
if (!row)
if (this.rowCount())
if (typeof(row) == "number")
row = this.tbody.rows.item(row);
else
row = this.tbody.rows.item(this.tbody.rows.length - 1);
var row_tmp;
if ((newRow) && (row)) row_tmp = newRow;
else {
row_tmp = this.createRow();
this.fillWithDefaultData(row_tmp);
}
if (this.rowCount() > 0 && row.nextSibling)
this.tbody.insertBefore(row_tmp, row.nextSibling);
else
this.tbody.appendChild(row_tmp);
return row_tmp;
};
/*
this.deleteRow = function(row) {
if(!row)
if(this.rowCount())
if(typeof(row) == "number")
row = this.tbody.rows.item(row);
else
row = this.tbody.rows.item(this.tbody.rows.length-1);
if(!row) return;
if(row.nextSibling) this.selectNextRow();
else if(row.previousSibling) this.selectPreviousRow();
this.tbody.removeChild(row);
this.deselectRow();
this.deselectCell();
if(this.rowCount() == 0)
setTimeout( function() { N.insertRow(); } , 1000);
}
this.changeRowMode = function(row) {
row.isnew = !row.isnew;
this.setEditNames(row,!row.isnew);
var img = row.firstChild.nextSibling.lastChild.previousSibling.previousSibling;
if(row.isnew)
img.setAttribute('src','modules/EcmInvoiceOutOlds/images/newproductset.gif');
else
img.setAttribute('src','modules/EcmInvoiceOutOlds/images/newproduct.gif');
}
*/
this.refreshRowIndex = function() {
for (var i = 0; i < this.rowCount(); i++) {
this.tbody.rows.item(i).index = i;
if (this.onRefreshRowIndex) this.onRefreshRowIndex(this.tbody.rows.item(i));
}
}
this.onRefreshRowIndex;
this.addRow = function(i, data) {
if (this.rowCount() > 0) {
try {
if (typeof(i) != "undefined") {
var r = i;
if (typeof(i) == "object") {} else if (typeof(i) == "number") r = this.tbody.rows.item(i - 1);
if (this.isProductLoaded(r.cells.item(0)) == false) {
return 0;
}
}
} catch (e) {
return 0;
}
}
var row = this.createRow();
if (this.selectedRow) this.selectedRow.deselect();
if (this.selectedCell) this.selectedCell.deselect();
row.myTable = this;
if (typeof(i) == "number")
this.tbody.insertBefore(row, this.tbody.rows.item(i));
else
this.tbody.appendChild(row);
this.refreshRowIndex();
this.setRowData(row, data);
for (var i = 0; i < this.colCount(); i++) row.cells.item(i).afterCreate();
return row;
}
this.createRow = function(row) {
var row = document.createElement('tr');
row.myTable = this;
row.isnew = false;
row.onclick = function() {
this.select();
}
row.select = function() {
if (!this.myTable.selectedRow || this.myTable.selectedRow !== this) {
if (this.myTable.selectedRow) this.myTable.selectedRow.deselect();
this.myTable.selectedRow = this;
this.className = this.myTable.rowSelectedClass;
if (row.onSelect) row.onSelect();
if (this.myTable.divParent)
if (((this.offsetTop + this.offsetHeight - this.myTable.divParent.scrollTop) > (this.myTable.divParent.offsetHeight + 5)) || ((this.offsetTop - this.myTable.divParent.scrollTop) < (-10))) this.myTable.divParent.scrollTop = this.offsetTop;
}
}
row.deselect = function() {
if (this.myTable.selectedRow === this) {
this.className = '';
this.myTable.selectedRow = '';
if (row.onDeselect) row.onDeselect();
}
};
row.calculateTotal = function() {};
row.selectNext = function() {
if (this.index < this.myTable.rowCount() - 1) {
this.deselect();
this.nextSibling.select();
return this.nextSibling;
} else {
if (this.noAddNew) return this;
this.deselect();
var row = this.myTable.addRow();
return row;
}
}
row.selectPrevious = function() {
this.deselect();
if (this.previousSibling) {
this.previousSibling.select();
return this.previousSibling;
} else return this;
}
row.deleteRow = function(noNew) {
if (this.myTable.selectedCell) this.myTable.selectedCell.deselect();
if (this.myTable.selectedRow) this.myTable.selectedRow.deselect();
if (this.myTable.rowCount() == 1 && !noNew) {
var MyTaBlE = this.myTable;
setTimeout(function() {
MyTaBlE.addRow();
}, 1000);
}
this.myTable.tbody.removeChild(this);
this.myTable.refreshRowIndex();
calculateTotal();
}
row.moveUp = function() {
if (!this.previousSibling) return;
this.myTable.tbody.insertBefore(this, this.previousSibling);
this.myTable.refreshRowIndex();
}
row.moveDown = function() {
if (!this.nextSibling) this.myTable.addRow(row);
this.myTable.tbody.insertBefore(this.nextSibling, this);
this.myTable.refreshRowIndex();
}
row.setData = function(data) {
if (!data || typeof(data) != "object") {
return;
};
for (var i = 0; i < this.myTable.colCount(); i++) {
this.cells.item(i).setData(data);
}
}
row.getData = function() {
var data = new Object();
for (var i = 0; i < this.myTable.colCount(); i++) {
if (this.cells.item(i).getData) this.cells.item(i).getData(data, true);
}
return data;
}
for (var i = 0; i < this.colCount(); i++) {
var cell = this.createCell(i);
row.appendChild(cell);
}
if (this.onCreateRow) this.onCreateRow(row);
return row;
};
this.onCreateRow; //function(row) {}
this.cellCodeIndex = 1;
this.isProductLoaded = function(cell) {
if (this.selectedRow && typeof(this.selectedRow) != "undefined" && this.selectedRow === cell.parentNode) {
var data = this.selectedRow.getData();
if (data.id && data.id != "" && data.code && data.code != "") {} else {
if (this.selectedCell !== cell && cell === this.selectedRow.cells.item(1)) {
return true;
} else {}
if (cell.parentNode.cells.item(1).firstChild.focus && !cell.parentNode.cells.item(1).noSelect) setSelectionRange(cell.parentNode.cells.item(1).firstChild);
return false;
}
} else {
if (typeof(cell) != "undefined" && cell.index != this.cellCodeIndex) {
cell.parentNode.select();
cell.parentNode.cells.item(1).select();
return false;
}
}
return true;
}
this.createCell = function(i) {
var cell = document.createElement('td');
cell.index = i;
cell.myTable = this;
cell.onclick = function() {
this.select();
}
cell.select = function() {
if (this.myTable.isProductLoaded(this) == false) return;
if (!this.myTable.selectedCell || this.myTable.selectedCell !== this) {
if (this.myTable.selectedCell) this.myTable.selectedCell.deselect();
this.myTable.selectedCell = this;
if (this.firstChild.focus && !this.noSelect) setSelectionRange(this.firstChild);
if (this.onSelect) this.onSelect();
this.className = this.myTable.cellSelectedClass;
}
}
cell.deselect = function() {
if (this.myTable.selectedCell === this) {
if (cell.onDeselect) cell.onDeselect();
if (cell.onDeselect2) cell.onDeselect2();
this.className = '';
this.selected = false;
this.myTable.selectedCell = '';
this.parentNode.calculateTotal();
}
};
cell.selectNext = function() {
this.deselect();
if (this.nextSibling) this.nextSibling.select();
else {
if (!this.parentNode.nextSibling) this.myTable.addRow();
this.parentNode.nextSibling.select();
this.parentNode.nextSibling.firstChild.select();
}
}
cell.afterCreate = function() {}
cell.setData = function(data) {}
cell.getData = function(data) {}
if (this.onCreateCell) this.onCreateCell(cell);
return cell;
};
this.onCreateCell; //function(cell) {}
this.setRowData = function(row, data) {
for (var i = 0; i < this.colCount(); i++) {
this.setCellData(row, row.cells.item(i), data);
}
}
this.setCellData = function(row, cell, data) {
if (typeof(row) == "number")
if (this.tbody.rows.item(row)) row = this.tbody.rows.item(row);
if (typeof(cell) != "object")
if (typeof(cell) == "number" && typeof(row) == "object") {
if (row.cells.item(cell))
cell = row.cells.item(cell);
else return;
} else return;
if (this.onSetCellData) this.onSetCellData(row, cell, data);
}
this.onSetCellData; //function(row,cell,data) {}
this.setEditNames = function(row, isset) {
if (isset)
for (var i = 0; i < row.cells.length; i++) {
if (i != 0 && i != 6 && i != 7) {
var c = row.cells.item(i).firstChild;
if (c.parentNode.lp == 1) {
c.name = 'parent_wi';
c.id = 'parent_wi';
c = c.nextSibling.nextSibling.nextSibling.nextSibling;
c.name = 'parent_name_wi';
c.id = 'parent_name_wi';
c.className = 'sqsEnabled';
//alert(c);
c = c.nextSibling;
c.name = 'parent_id_wi';
c.id = 'parent_id_wi';
/*
c=c.nextSibling;
c.name = 'vat_id_p'; c.id = 'vat_id_p';
c=c.nextSibling;
c.name = 'category_id_p'; c.id = 'category_id_p';
*/
}
/*
if(c.parentNode.lp == 2) { c.name = 'name_p'; c.id = 'name_p'; c.className = 'sqsEnabled'; }
if(c.parentNode.lp == 3) { c.name = 'quantity_p'; c.id = 'quantity_p'; }
if(c.parentNode.lp == 4) { c.name = 'price_p'; c.id = 'price_p'; }
if(c.parentNode.lp == 5) { c.name = 'discount_p'; c.id = 'discount_p'; }
*/
}
} else
for (var i = 0; i < row.cells.length; i++) {
if (i != 0 && i != 5) {
var c = row.cells.item(i).firstChild;
c.name = '';
c.id = '';
if (i == 1) {
c = c.nextSibling.nextSibling.nextSibling.nextSibling;
c.name = '';
c.id = '';
c = c.nextSibling;
c.name = '';
c.id = '';
/*
c=c.nextSibling;
c.name = ''; c.id = '';
c=c.nextSibling;
c.name = ''; c.id = ''; */
}
}
}
}
this.deselectRow = function() {
if (!this.selectedRow) return;
this.setEditNames(this.selectedRow, false);
//this.selectedRow.className = '';
this.deselectCell();
this.selectedRow = null;
}
this.selectRow = function(row) {
if (this.selectedRow === row) return;
if (this.selectedRow) this.deselectRow();
this.selectedRow = row;
//this.selectedRow.className = this.rowSelectedClass;
this.setEditNames(this.selectedRow, !this.selectedRow.isnew);
}
this.selectNextRow = function() {
if (!this.selectedRow) return;
if (!this.selectedRow.nextSibling) this.insertRow();
var cell_id = this.selectedCell.lp;
this.selectRow(this.selectedRow.nextSibling);
this.selectCell(this.selectedRow.cells.item(cell_id));
}
this.selectPreviousRow = function() {
if (!this.selectedRow) return;
if (!this.selectedRow.previousSibling) return;
if (this.selectedRow === this.tbody.rows.item(0)) return;
var cell_id = this.selectedCell.lp;
this.selectRow(this.selectedRow.previousSibling);
this.selectCell(this.selectedRow.cells.item(cell_id));
}
this.calculateSubtotal = function(row, sub) {
if (!row)
if (this.selectedRow) row = this.selectedRow;
else return 0;
if (row.cells.item(4).err || row.cells.item(5).err) {
row.cells.item(6).firstChild.value = NumberToUserFormatNumber(0);
row.cells.item(6).firstChild.style.color = 'red';
row.title = 'Bad number format';
} else if (row.cells.item(2).firstChild.value == '' && UserFormatNumberToNumber(row.cells.item(4).firstChild.value) != 0 && !row.cells.item(4).err) {
row.cells.item(6).firstChild.style.color = 'red';
row.title = 'Position have price, but didin\'t have a description';
} else {
var quantity = parseInt(row.cells.item(3).firstChild.value);
if (row.cells.item(1).firstChild.nextSibling.nextSibling.value == 3)
quantity = 1;
var price = UserFormatNumberToNumber(tmp = row.cells.item(4).firstChild.value);
var discount = UserFormatNumberToNumber(row.cells.item(5).firstChild.value, "%");
var total = NumberToUserFormatNumber(quantity * price - quantity * price * (discount / 100));
row.cells.item(6).firstChild.value = total;
row.cells.item(6).firstChild.style.color = 'black';
row.title = '';
}
//if(!sub) this.calculateTotal();
}
this.calculateTotal = function() {
var vats = new Object();
var subtotal = 0;
var total = 0;
for (var i = 0; i < this.rowCount(); i++) {
if (!OPT['to_is_vat_free']) {
var v_tmp = this.tbody.rows.item(i).cells.item(1).firstChild.nextSibling.nextSibling.nextSibling.value;
if (v_tmp && this.tbody.rows.item(i).cells.item(2).firstChild.value != '') {
if (typeof(vats[v_tmp]) != "object") {
vats[v_tmp] = new Object();
vats[v_tmp]['vat'] = 0;
}
vats[v_tmp]['vat'] += UserFormatNumberToNumber(this.tbody.rows.item(i).cells.item(6).firstChild.value);
}
} else if (typeof(vats['0.00']) != "object") {
vats['0.00'] = new Object();
vats['0.00']['vat'] = 0;
}
subtotal += UserFormatNumberToNumber(this.tbody.rows.item(i).cells.item(6).firstChild.value);
}
total = subtotal;
var rt = document.getElementById('result_table');
for (var i = 1; i < rt.rows.length - 1; i++) {
if (!vats[rt.rows.item(i).id]) {
rt.deleteRow(i);
--i;
} else vats[rt.rows.item(i).id]['node'] = rt.rows.item(i);
}
for (x in vats) {
vats[x]['vat'] = vats[x]['vat'] * (parseFloat(x) / 100);
total += vats[x]['vat'];
var txL = 'VAT' + ' (' + NumberToUserFormatNumber(parseFloat(x), '%') + ')';
var txF = NumberToUserFormatNumber(vats[x]['vat']);
if (vats[x]['node']) {
vats[x]['node'].id = x;
vats[x]['node'].cells.item(0).innerHTML = txL;
vats[x]['node'].cells.item(1).innerHTML = txF;
} else {
rt.insertRow(1);
rt.rows.item(1).id = x;
rt.rows.item(1).insertCell(0);
rt.rows.item(1).cells.item(0).className = 'positionsLabel';
rt.rows.item(1).cells.item(0).innerHTML = txL;
rt.rows.item(1).insertCell(1);
rt.rows.item(1).cells.item(1).className = 'positionsField';
rt.rows.item(1).cells.item(1).innerHTML = txF;
}
}
document.getElementById('subtotal_span').innerHTML = NumberToUserFormatNumber(subtotal);
document.getElementById('subtotal').value = NumberToUserFormatNumber(subtotal);
total = ((iType == "correct") ? '-' : '') + NumberToUserFormatNumber(total).toString();
document.getElementById('total_span').innerHTML = total;
document.getElementById('total').value = total;
}
this.deselectCell = function() {
if (!this.selectedCell) return;
var tmp = 0;
var c = this.selectedCell;
/*
if(c.lp == 4)
if(c.firstChild.value != "") {
tmp = UserFormatNumberToNumber(this.selectedCell.firstChild.value);
if(tmp == -1) {
alert('Error with format number: '+c.firstChild.value);
c.err = true;
c.firstChild.style.color = 'red';
}
else {
c.firstChild.value = NumberToUserFormatNumber(tmp);
c.firstChild.style.color = 'black';
c.err = false;
}
}
if(c.lp == 5)
if(c.firstChild.value != "") {
tmp = UserFormatNumberToNumber(this.selectedCell.firstChild.value,"%");
if(tmp == -1) {
alert('Error with format number: '+c.firstChild.value);
c.err = true;
c.firstChild.style.color = 'red';
}
else {
c.firstChild.value = NumberToUserFormatNumber(tmp,"%");
c.firstChild.style.color = 'black';
c.err = false;
}
}
*/
//this.calculateSubtotal(c.parentNode);
this.selectedCell.className = '';
this.selectedCell = null;
}
this.selectCell = function(cell) {
if (this.selectedCell === cell) return;
if (this.selectedCell) this.deselectCell();
this.selectedCell = cell;
if (!cell.noSelect) {
this.selectedCell.className = this.cellSelectedClass;
this.setCellFocus(this.selectedCell);
}
}
this.selectNextCell = function() {
if (!this.selectedCell) return;
if (this.selectedCell.lp == 4) {
this.selectNextRow();
this.selectCell(this.selectedRow.firstChild.nextSibling);
} else
this.selectCell(this.selectedCell.nextSibling);
}
this.setCellFocus = function(cell, input) {
if (typeof(cell) == 'number') {
cell = this.selectedRow.cells.item(cell);
}
var edit = ((input) ? input : cell.firstChild);
if (edit && typeof(edit) == "object" && (edit.type == "text" || edit.type == "textarea")) {
if (edit.createTextRange) {
var range = edit.createTextRange();
range.moveStart("character", 0);
range.moveEnd("character", edit.value.lengh - 1);
range.select();
} else {
if (edit.setSelectionRange) {
edit.setSelectionRange(0, edit.value.length);
}
}
edit.focus();
}
if (edit && typeof(edit) == "object" && edit.options) {
edit.focus();
}
}
this.fillWithDefaultData = function(row) {
//this.setCellData(3,1,row);
//this.setCellData(5,0,row);
//this.setCellData(6,0,row);
}
this.refreshNumeration = function() {
for (var i = 0; i < this.tbody.rows.length; i++)
this.tbody.rows.item(i).cells.item(0).firstChild.value = i + 1;
}
/*
this.setCellData = function(i,data,row) {
if(!row) if(this.selectedRow) row = this.selectedRow; else return null;
//if(i == 3) { row.firstChild.nextSibling.nextSibling.nextSibling.firstChild.value = data; }
//if(i == 5) { row.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.value = NumberToUserFormatNumber(data,"%"); }
//if(i == 6) { row.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.value = NumberToUserFormatNumber(data); }
}
*/
this.insertRowFromArray = function(arr) {
var row = this.insertRow();
row.cells.item(1).firstChild.value = arr['code'];
row.cells.item(1).firstChild.nextSibling.value = arr['id'];
row.cells.item(1).firstChild.nextSibling.nextSibling.value = arr['unit_id'];
row.cells.item(1).firstChild.nextSibling.nextSibling.nextSibling.value = arr['vat_id'];
row.cells.item(1).firstChild.nextSibling.nextSibling.nextSibling.nextSibling.value = arr['category_id'];
row.cells.item(2).firstChild.value = arr['name'];
row.cells.item(3).firstChild.value = arr['quantity'];
row.cells.item(4).firstChild.value = NumberToUserFormatNumber(arr['price']);
row.cells.item(5).firstChild.value = NumberToUserFormatNumber(arr['discount'], '%');
row.cells.item(6).firstChild.value = NumberToUserFormatNumber(arr['total']);
}
this.getRowData = function(row) {
if (typeof(row) == "number") row = this.tbody.rows.item(row);
var rData = new Object();
rData['id'] = row.cells.item(1).firstChild.nextSibling.value;
rData['unit_id'] = row.cells.item(1).firstChild.nextSibling.nextSibling.value;
if (!rData['unit_id']) rData['unit_id'] = OPT['default_unit']; //szt
rData['vat_id'] = row.cells.item(1).firstChild.nextSibling.nextSibling.nextSibling.value;
if (!rData['vat_id']) rData['vat_id'] = OPT['default_vat']; //standard
rData['category_id'] = row.cells.item(1).firstChild.nextSibling.nextSibling.nextSibling.nextSibling.value;
if (!rData['category_id']) rData['category_id'] = OPT['default_category']; //no category
rData['code'] = row.cells.item(1).firstChild.value;
rData['name'] = row.cells.item(2).firstChild.value;
rData['quantity'] = row.cells.item(3).firstChild.value;
rData['price'] = UserFormatNumberToNumber(row.cells.item(4).firstChild.value);
rData['discount'] = UserFormatNumberToNumber(row.cells.item(5).firstChild.value, '%');
rData['total'] = UserFormatNumberToNumber(row.cells.item(6).firstChild.value);
if (rData['code'] == '' && rData['name'] == '') return '';
else return rData;
}
this.prepareToSend = function(json) {
var rData = new Object();
var l = 0,
tmp;
for (var i = 0; i < this.rowCount(); i++) {
//this.calculateSubtotal(this.tbody.rows.item(i),true);
tmp = this.getRowData(i);
if (tmp != '') {
rData[l.toString()] = tmp;
l++;
}
}
//this.calculateTotal();
if (!json)
return JSON.stringifyNoSecurity(rData);
else
return rData;
}
this.KeyPressedNumber = function(e) {
var keynum;
if (window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
return keynum;
}
this.KeyPressed = function(e, cell, method, noArrow) {
var keynum;
if (window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
if ((keynum == 9) || (keynum == 13 && cell.index != 2)) {
//this.calculateTotal();
//if(this.selectedCell.lp == 1) setTimeout( function() { N.selectNextCell(); } , 100);
//this.selectNextCell();
if (cell.index == 1 || cell.index == 2) cell.parentNode.calculateTotal();
cell.selectNext();
return false;
}
if (!noArrow) {
if (keynum == 40) {
var id = cell.index;
var row = cell.parentNode.selectNext();
if (row) {
row.select();
row.cells.item(id).select();
}
}
if (keynum == 38) {
var id = cell.index;
var row = cell.parentNode.selectPrevious();
if (row) {
row.select();
row.cells.item(id).select();
}
}
} else return true;
if (e.shiftKey && (method == "decimalNumber" || method == "onlyNumber")) return false;
if (method == "decimalNumber") return this.OnlyNumbers(keynum);
if (method == "onlyNumber") return this.OnlyNumbers(keynum, true);
return true;
}
this.OnlyNumbers = function(e, noInvoiceOut) {
var keynum = e,
keychar, numcheck;
keychar = String.fromCharCode(keynum);
numcheck = /\d/;
return numcheck.test(keychar) || ((!noInvoiceOut) ? (keynum == 190) : false) || (keynum == 8) //backspace
|| (keynum == 46) //delete
|| (keynum == 13) //enter
|| (keynum == 0) //special keys with FF
|| (keynum == 37) //left arrow
|| (keynum == 39) //right arrow
|| (keynum == 188) //,
|| (keynum >= 95 && keynum <= 105) //numeric keyboard
|| (keynum == 110);
}
this.row = function(i) {
if (this.tbody.rows.item(i)) return this.tbody.rows.item(i);
}
this.cells = function(i, j) {
if (this.tbody.rows.item(i).cells.item(i)) return this.tbody.rows.item(i).cells.item(i);
}
}
// var N;
var parent_options;
/*
function ItemListSave(json) {
if(N.selectedCell) N.selectedCell.deselect();
if(N.selectedRow) N.selectedRow.deselect();
var data = new Object();
for(var i=0; i<N.rowCount(); i++) {
data[i.toString()] = N.row(i).getData();
}
return json ? JSON.stringifyNoSecurity(data) : data;
}
function ItemListClear() {
while(N.rowCount()>0) N.row(0).deleteRow();
}
*/
function ItemListFill(list) {
/*
var start_list_count = 6;
var count = 0;
var arr = '';
if(list)
arr = list;
else
if(document.getElementById('position_list').value!="")
arr = eval(document.getElementById('position_list').value);
if(arr != '')
for(x in arr) {
N.insertRowFromArray(arr[x]);
count++;
}
for(var i=count; i<start_list_count; i++) N.insertRow();
N.calculateTotal();
*/
}

View File

@@ -0,0 +1,47 @@
<?php
$PDFLabelList = array(
'LBL_PDF_BUYER',
'LBL_PDF_CORRECT_REASON',
'LBL_PDF_DATE_REGISTER',
'LBL_PDF_DATE_SELL',
'LBL_PDF_DAYS',
'LBL_PDF_DELIVERY',
'LBL_PDF_DISCOUNT',
'LBL_PDF_DOCUMENT_NAME_CORRECT',
'LBL_PDF_DOCUMENT_NAME_CORRECT_TO',
'LBL_PDF_END_TOTAL',
'LBL_PDF_LIST_BRUTTO_TOTAL',
'LBL_PDF_LIST_DESCRIPTION',
'LBL_PDF_LIST_DISCOUNT',
'LBL_PDF_LIST_INDEX',
'LBL_PDF_LIST_NETTO_TOTAL',
'LBL_PDF_LIST_POSITION',
'LBL_PDF_LIST_QUANTITY',
'LBL_PDF_LIST_SUMMARY_TOTAL',
'LBL_PDF_LIST_TAX_CODE',
'LBL_PDF_LIST_TOTAL',
'LBL_PDF_LIST_UNIT',
'LBL_PDF_LIST_UNIT_PRICE',
'LBL_PDF_LIST_UNIT_PRICE_TOTAL',
'LBL_PDF_LIST_VAT_ID',
'LBL_PDF_LIST_VAT_RATE',
'LBL_PDF_LIST_VAT_TOTAL',
'LBL_PDF_LIST_VAT_VALUE',
'LBL_PDF_NIP',
'LBL_PDF_ORDER_NO',
'LBL_PDF_ORIGINAL_COPY',
'LBL_PDF_PAYMENT_METHOD',
'LBL_PDF_PAYMENT_TERMIN',
'LBL_PDF_PLACE_OF_REGISTER',
'LBL_PDF_SELLER',
'LBL_PDF_SUPPLIER_CODE',
'LBL_PDF_TOTAL',
'LBL_PDF_TO_WZ',
'LBL_PDF_VATID',
//
'LBL_PDF_SITE',
'LBL_PDF_FOOTER_DOCUMENT_NAME',
'LBL_PDF_INDEX_DBF',
'LBL_PDF_PARENT_SALE_NR',
);

View File

@@ -0,0 +1,51 @@
<?php
$PDFLabelList = array(
'LBL_PDF_LIST_POSITION',
'LBL_PDF_LIST_QUANTITY',
'LBL_PDF_LIST_UNIT',
'LBL_PDF_LIST_DESCRIPTION',
'LBL_PDF_LIST_PRICE',
'LBL_PDF_LIST_TOTAL_PRICE',
'LBL_PDF_LIST_DISCOUNT',
'LBL_PDF_LIST_VAT',
'LBL_PDF_LIST_VAT_VALUE',
'LBL_PDF_LIST_TAX_CODE',
'LBL_PDF_LIST_RECIPIENT_CODE',
'LBL_PDF_LIST_TOTAL',
'LBL_PDF_DAYS',
'LBL_PDF_TO_WZ',
'LBL_PDF_NIP',
'LBL_PDF_PLACE_OF_REGISTER',
'LBL_PDF_TOTAL',
'LBL_PDF_DISCOUNT',
'LBL_PDF_END_TOTAL',
'LBL_PDF_VAT',
'LBL_PDF_VATID',
'LBL_PDF_NUMBER',
'LBL_PDF_DATE_REGISTER',
'LBL_PDF_SELL_DATE',
'LBL_PDF_OWNER',
'LBL_PDF_DOCUMENT_NAME',
'LBL_PDF_DOCUMENT_NAME_CORRECT',
'LBL_PDF_DOCUMENT_NAME_CORRECT_TO',
'LBL_PDF_FILENAME',
'LBL_PDF_PAYMENT_METHOD',
'LBL_PDF_PAYMENT_TERMIN',
'LBL_PDF_TO_PAID',
'LBL_PDF_TO_PAID_BACK',
'LBL_PDF_TOTAL_BY_WORD',
'LBL_PDF_OWNER_SIGNATURE',
'LBL_PDF_RECEIVER_SIGNATURE',
'LBL_PDF_ORIGINAL_COPY',
'LBL_PDF_ORDER_NO',
'LBL_PDF_SUPPLIER_CODE',
'LBL_PDF_DELIVERY_PLACE',
'LBL_PDF_CODE',
'LBL_PDF_CODE_CORRECT',
'LBL_PDF_DOCUMENT_AFTER_CORRECT',
'LBL_PDF_DOCUMENT_BEFORE_CORRECT',
'LBL_PDF_DOCUMENT_CORRECT_DIFFERENCE',
'LBL_PDF_FILENAME',
'LBL_PDF_CORRECT_REASON',
);

View File

@@ -0,0 +1,137 @@
<!-- BEGIN: main -->
<script type="text/javascript" src="include/javascript/popup_parent_helper.js?s={SUGAR_VERSION}&c={JS_CUSTOM_VERSION}"></script>
<script type="text/javascript" src="include/JSON.js?s={SUGAR_VERSION}&c={JS_CUSTOM_VERSION}"></script>
<script type="text/javascript" src="modules/EcmInvoiceOutOlds/PDFLanguagesMT.js"></script>
<link rel="stylesheet" type="text/css" href="modules/EcmInvoiceOutOlds/MyTable.css" />
<script type="text/javascript" src="modules/EcmInvoiceOutOlds/PDFLanguages.js?s={SUGAR_VERSION}&c={JS_CUSTOM_VERSION}"></script>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<form name="PDFLanguages" onsubmit="return ItemListSave(true);" method="POST" action="index.php">
<input type="hidden" name="module" value="EcmInvoiceOutOlds">
<input type="hidden" name="action" value="PDFLanguagesSave">
<input type="hidden" name="return_module" value="{RETURN_MODULE}">
<input type="hidden" name="return_id" value="{RETURN_ID}">
<input type="hidden" name="return_action" value="{RETURN_ACTION}">
<input type="hidden" id="phone_list" name="phone_list" value='{PHONE_LIST}' >
<td style="padding-bottom: 2px;">
<input title="{APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{APP.LBL_SAVE_BUTTON_KEY}" tabindex="1" class="button"
onclick="ItemListSave(true);"
type="button" name="button" value=" {APP.LBL_SAVE_BUTTON_LABEL} " >
<input title="{APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{APP.LBL_CANCEL_BUTTON_KEY}" tabindex="1" class="button"
onclick="this.form.action.value='{RETURN_ACTION}'; this.form.module.value='{RETURN_MODULE}'; this.form.record.value='{RETURN_ID}'"
type="submit" name="button" value=" {APP.LBL_CANCEL_BUTTON_LABEL} ">
</td>
<td align="right" nowrap><span class="required">{APP.LBL_REQUIRED_SYMBOL}</span> {APP.NTC_REQUIRED}</td>
<td align='right'>{ADMIN_EDIT}</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tabForm">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="80%" valign="top" class="dataLabel">
<span sugar="slot4">{MOD.LBL_ECMLANGUAGE} <span class="required">{APP.LBL_REQUIRED_SYMBOL}</span>
</span sugar="slot">
&nbsp;&nbsp;
<span sugar="slot4b">
<select tabindex='1' id='ecmlanguage' name='ecmlanguage' onChange="ItemListClear(true,this.lastSelected);ItemListFill();">{ECMLANGUAGES_OPTIONS}</select>
</span sugar="slot">
</td>
<td width="20%" class="dataField">
</td>
</tr>
<tr>
<td width="80%" class="dataLabel" valign="top"><span sugar='slot1'> </span sugar='slot'>
<div style="width:100%;border: 1px solid rgb(48,192,255);background-color:white;height:400px;max-height:400px;overflow:auto;">
<table class="positions" style="width:100%;" id="PDFLanguagesTable">
<thead id="head">
<tr id="tr">
<td width="10%">No.</td>
<td width="50%">Label</td>
<td width="40%">Translation</td>
</tr>
</thead>
<tbody id="tbody">
</tbody>
</table>
</div>
</td>
<td width="20%" colspan="" valign="top" class="dataLabel"><span sugar="slot4"></span sugar="slot"></td>
</tr>
<tr>
<td width="80%" colspan="4" valign="top" class="dataLabel"><span sugar="slot4"><br /></span sugar="slot"></td>
<td width="20%" colspan="" valign="top" class="dataLabel"><span sugar="slot4"></span sugar="slot"></td>
</tr>
<tr>
<td width="80%" colspan="4" valign="top" class="dataLabel">
<table width="80%"><tr><td style="width:250px;" class="dataLabel">
<span sugar="slot4">{MOD.LBL_HEADER_TEXT} &nbsp;&nbsp;&nbsp;
</span sugar="slot">
</td><td align="right">
{MFP.header}<span style="display:none;"> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <select id="header_parent" onchange="FillText('header',this);">{PARENT_OPTIONS}</select></span>
</td></tr></table>
<textarea id="header_text" name="header_text" rows="5" style="width:80%;">{HEADER_TEXT}</textarea>
</td>
<td width="20%" colspan="" valign="top" class="dataLabel"><span sugar="slot4"></span sugar="slot"></td>
</tr>
<tr>
<td width="80%" colspan="4" valign="top" class="dataLabel">
<table width="80%"><tr><td style="width:250px;" class="dataLabel">
<span sugar="slot4">{MOD.LBL_FOOTER_TEXT} &nbsp;&nbsp;&nbsp;
</span sugar="slot">
</td><td align="right">
{MFP.footer}<span style="display:none;"> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <select id="footer_parent" onchange="FillText('footer',this);">{PARENT_OPTIONS}</select></span>
</td></tr></table>
<textarea id="footer_text" name="footer_text" rows="5" style="width:80%;">{FOOTER_TEXT}</textarea>
</td>
<td width="20%" colspan="" valign="top" class="dataLabel"><span sugar="slot4"></span sugar="slot"></td>
</tr>
<tr>
<td width="80%" colspan="4" valign="top" class="dataLabel">
<table width="80%"><tr><td style="width:250px;" class="dataLabel">
<span sugar="slot4">{MOD.LBL_ADS_TEXT} &nbsp;&nbsp;&nbsp;
</span sugar="slot">
</td><td align="right">
{MFP.ads}<span style="display:none;"> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <select id="ads_parent" onchange="FillText('ads',this);">{PARENT_OPTIONS}</select></span>
</td></tr></table>
<textarea id="ads_text" name="ads_text" rows="5" style="width:80%;">{ADS_TEXT}</textarea>
</td>
<td width="20%" colspan="" valign="top" class="dataLabel"><span sugar="slot4"></span sugar="slot"></td>
</tr>
</table>
</td>
</tr>
</table>
<div style="padding-top: 2px">
<input title="{APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{APP.LBL_SAVE_BUTTON_KEY}" tabindex="1" class="button"
onclick="ItemListSave(true);"
type="button" name="button" value=" {APP.LBL_SAVE_BUTTON_LABEL} " >
<input title="{APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{APP.LBL_CANCEL_BUTTON_KEY}" tabindex="1" class="button" onclick="this.form.action.value='{RETURN_ACTION}'; this.form.module.value='{RETURN_MODULE}'; this.form.record.value='{RETURN_ID}'" type="submit" name="button" value=" {APP.LBL_CANCEL_BUTTON_LABEL} ">
</div>
</form>
{JAVASCRIPT}
<!-- END: main -->

View File

@@ -0,0 +1,278 @@
function doRequest(where, post, doFunction, error) {
this.Display = function(result) {
doFunction(result.responseText);
}
this.Fail = function(result) {
if (error)
alert(error);
}
YAHOO.util.Connect.asyncRequest('POST', where, {success: this.Display, failure: this.Fail}, post);
}
function changeValidateRequired(formname, name, required) {
for (var i = 0; i < validate[formname].length; i++)
if (validate[formname][i][0] == name) {
validate[formname][i][2] = required;
break;
}
}
//function set_focus() { document.getElementById('name').focus(); }
function my_popup(module, field_array, call_back_function, form_name) {
if (!call_back_function)
call_back_function = "set_return";
if (!form_name)
form_name = "EditView";
return open_popup(module, 600, 400, "", true, false, {"call_back_function": call_back_function, "form_name": form_name, "field_to_name_array": field_array});
}
function addEvent(object, eventName, do_function) {
if (typeof(object) == "string")
object = document.getElementById(object);
if (!object) {
alert('No object in function addEvent!');
return;
}
if (object.addEventListener) {
object.addEventListener(eventName, do_function, false);
} else {
object.attachEvent('on' + eventName, do_function);
}
}
var tbody_;
var ItemListSave;
var ItemListClear;
var ItemListFil;
var FillText;
addEvent(
window,
'load',
function() {
var PDFLanguagesTable = new PDFLanguagesMT('PDFLanguagesTable');
PDFLanguagesTable.onRefreshRowIndex = function(row) {
var data = new Object();
data['index'] = (row.index + 1).toString();
row.cells.item(0).setData(data);
};
PDFLanguagesTable.onCreateRow = function(row) {
row.newPos = false;
row.noAddNew = true;
row.ondblclick = function() {
};
row.onSelect = function() {
for (var i = 0; i < this.myTable.colCount(); i++)
this.cells.item(i).change(!this.newPos);
};
row.onDeselect = function() {
for (var i = 0; i < this.myTable.colCount(); i++)
this.cells.item(i).change(false);
};
};
PDFLanguagesTable.onCreateCell = function(cell) {
var i = cell.index;
cell.change = function(select) {
};
if (i == 0) {
cell.setData = function(data) {
if (data.index)
cell.firstChild.value = data.index;
};
cell.getData = function(data) {
data.index = cell.firstChild.value;
};
cell.select = function() {
this.selectNext();
};
var edit = document.createElement('input');
edit.setAttribute('type', 'text');
edit.setAttribute('readOnly', 'readonly');
edit.setAttribute('tabIndex', 1);
edit.className = 'inputs';
cell.appendChild(edit);
}
;
if (i == 1) {
cell.change = function(select) {
};
cell.getData = function(data) {
var cn = this.getElementsByTagName('input');
data.label = cn[0].value;
};
cell.setData = function(data) {
var cn = this.getElementsByTagName('input');
if (data.label)
cn[0].value = data.label;
};
cell.select = function() {
this.selectNext();
};
var edit = document.createElement('input');
edit.setAttribute('type', 'text');
edit.setAttribute('readOnly', 'readonly');
edit.setAttribute('tabIndex', 1);
edit.className = 'inputs';
cell.appendChild(edit);
}
;
if (i == 2) {
cell.noNewAdd = true;
cell.getData = function(data) {
var cn = this.getElementsByTagName('input');
data.translation = cn[0].value;
};
cell.setData = function(data) {
var cn = this.getElementsByTagName('input');
if (data.translation)
cn[0].value = data.translation;
};
var edit = '<input type="text" onFocus="this.parentNode.select();" tabindex="1" class="inputs" style="height:16px;" autocomplete="off" onKeyDown="return this.parentNode.myTable.KeyPressed(event,this.parentNode);">';
cell.innerHTML = edit;
}
;
};
PDFLanguagesTable.onSetCellData = function(row, cell, data) {
if (cell.innerHTML == '')
cell.innerHTML = '&nbsp;';
};
ItemListSave = function(json, el) {
var data = new Object();
var tmp;
var ecmlanguage = document.getElementById('ecmlanguage').value;
if (typeof(el) == "string")
ecmlanguage = el;
if (!PDFLanguagesOptions.ecmlanguage)
PDFLanguagesOptions.ecmlanguage = new Object();
for (var i = 0; i < PDFLanguagesTable.rowCount(); i++) {
data[i.toString()] = PDFLanguagesTable.row(i).getData();
}
PDFLanguagesOptions['ecmlanguage'][ecmlanguage]['labels'] = data;
FillText('header', document.getElementById('header_parent'));
FillText('footer', document.getElementById('footer_parent'));
FillText('ads', document.getElementById('ads_parent'));
if (json) {
var r = JSON.stringifyNoSecurity(PDFLanguagesOptions['ecmlanguage']);
doRequest(
'index.php',
'module=EcmInvoiceOutOlds&action=PDFLanguagesSave&to_pdf=1&ecmlanguage=' + document.getElementById('ecmlanguage').value + '&pdflanguagelist=' + r,
function(result) {
if (result.indexOf("Saved") >= 0)
alert("Saving done!");
else
alert("Error with saving!");
}
);
}
};
ItemListClear = function(noNew, save) {
if (typeof(save) == "string")
ItemListSave(null, save);
while (PDFLanguagesTable.rowCount() > 0)
PDFLanguagesTable.row(0).deleteRow(noNew);
};
ItemListFill = function() {
var ecmlanguage = document.getElementById('ecmlanguage').value;
var pl;
if (PDFLanguagesOptions && PDFLanguagesOptions.ecmlanguage && PDFLanguagesOptions['ecmlanguage'][ecmlanguage]) {
pl = PDFLanguagesOptions['ecmlanguage'][ecmlanguage]['labels'];
}
console.log(ecmlanguage);
console.log(pl);
FillText('header', document.getElementById('header_parent'));
FillText('footer', document.getElementById('footer_parent'));
FillText('ads', document.getElementById('ads_parent'));
if (pl && pl != '') {
try {
pl = eval(pl);
for (x in pl) {
var pl_row = pl[x];
PDFLanguagesTable.addRow().setData(pl_row);
}
} catch (err) {
pl = null;
}
}
document.getElementById('ecmlanguage').lastSelected = document.getElementById('ecmlanguage').value;
//if(PDFLanguagesTable.rowCount() == 0) PDFLanguagesTable.addRow();
};
FillText = function(name, parent) {
var text = document.getElementById(name + '_text');
var el = document.getElementById('ecmlanguage');
if (!parent.lastSelected) {
parent.lastSelected = parent.value;
parent.lastSelectedEcmLanguage = el.value;
} else {
//PDFLanguagesOptions['ecmlanguage'][parent.lastSelectedEcmLanguage]['texts'][parent.lastSelected][name + '_text'] = text.value;
}
//text.value = PDFLanguagesOptions['ecmlanguage'][el.value]['texts'][parent.value][name + '_text'];
parent.lastSelected = parent.value;
parent.lastSelectedEcmLanguage = el.value;
};
//PDFLanguagesTable.addRow();
ItemListFill();
}
);

View File

@@ -0,0 +1,192 @@
<?php
/* * *******************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU 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 General Public License for more
* details.
*
* You should have received a copy of the GNU 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 General Public License version 3.
*
* In accordance with Section 7(b) of the GNU 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".
* ****************************************************************************** */
if (!defined('sugarEntry') || !sugarEntry)
die('Not A Valid Entry Point');
//require_once('modules/EcmGroupSales/HeaderMenu.php');
require_once('modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php');
require_once('modules/EcmTexts/EcmText.php');
//require_once ('include/time.php');
global $current_user, $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings, $app_list_strings, $theme;
if (!is_admin($current_user)) {
ACLController::displayNoAccess();
return;
}
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
require_once ($theme_path . 'layout_utils.php');
$xtpl = new XTemplate('modules/EcmInvoiceOutOlds/PDFLanguages.html');
$xtpl->assign("MOD", $mod_strings);
$xtpl->assign("APP", $app_strings);
if (isset($_REQUEST['return_module']))
$xtpl->assign("RETURN_MODULE", $_REQUEST['return_module']);
if (isset($_REQUEST['return_action']))
$xtpl->assign("RETURN_ACTION", $_REQUEST['return_action']);
if (isset($_REQUEST['return_id']))
$xtpl->assign("RETURN_ID", $_REQUEST['return_id']);
if (empty($_REQUEST['return_id']))
$xtpl->assign("RETURN_ACTION", 'index');
$PDFLanguagesOptions = array();
require_once('modules/EcmInvoiceOutOlds/PDFLabelList.php');
$PDFLL = array();
foreach ($PDFLabelList as $value) {
$PDFLL [] = array(
'label' => $value,
'translation' => '',
);
}
$PDFLanguagesOptions['PDFLabelList'] = $PDFLL;
$PDFLL = array(
'labels' => $PDFLL,
'texts' => array(
'Contacts' => array(
'header_text' => $mod_strings['LBL_DEFAULT_CONTACT_HEADER_TEXT'],
'footer_text' => $mod_strings['LBL_DEFAULT_CONTACT_FOOTER_TEXT'],
'ads_text' => $mod_strings['LBL_DEFAULT_CONTACT_ADS_TEXT'],
),
'Accounts' => array(
'header_text' => $mod_strings['LBL_DEFAULT_ACCOUNT_HEADER_TEXT'],
'footer_text' => $mod_strings['LBL_DEFAULT_ACCOUNT_FOOTER_TEXT'],
'ads_text' => $mod_strings['LBL_DEFAULT_ACCOUNT_ADS_TEXT'],
),
),
);
foreach ($app_list_strings['ecmlanguages_dom'] as $key => $value) {
$data = EcmText::LoadText(null, null, "EcmInvoiceOutOlds", $key);
//echo '<pre>' . var_export($data, true) . '</pre>';
//exit;
if (isset($data[0]) && isset($data[0]['data'])) {
$d = $data[0]['data'];
} else {
$d = $PDFLL;
if (!isset($d['labels']))
$d['labels'] = $PDFLL['labels'];
if (!isset($d['texts']['Contacts']['header_text']))
$d['texts']['Contacts']['header_text'] = $mod_strings['LBL_DEFAULT_CONTACT_HEADER_TEXT'];
if (!isset($d['texts']['Contacts']['footer_text']))
$d['texts']['Contacts']['footer_text'] = $mod_strings['LBL_DEFAULT_CONTACT_FOOTER_TEXT'];
if (!isset($d['texts']['Contacts']['ads_text']))
$d['texts']['Contacts']['ads_text'] = $mod_strings['LBL_DEFAULT_CONTACT_ADS_TEXT'];
if (!isset($d['texts']['Accounts']['header_text']))
$d['texts']['Accounts']['header_text'] = $mod_strings['LBL_DEFAULT_ACCOUNT_HEADER_TEXT'];
if (!isset($d['texts']['Accounts']['footer_text']))
$d['texts']['Accounts']['footer_text'] = $mod_strings['LBL_DEFAULT_ACCOUNT_FOOTER_TEXT'];
if (!isset($d['texts']['Accounts']['ads_text']))
$d['texts']['Accounts']['ads_text'] = $mod_strings['LBL_DEFAULT_ACCOUNT_ADS_TEXT'];
}
$tmp2 = array();
foreach ($d['labels'] as $k => $v) {
$tmp2[$v['label']] = $v['translation'];
}
$tmp = array();
$count = 0;
foreach ($PDFLanguagesOptions['PDFLabelList'] as $k => $v) {
$tmp[strval($count)] = array(
'index' => strval($count++),
'label' => $v['label'],
'translation' => $tmp2[$v['label']],
);
}
$d['labels'] = $tmp;
$PDFLanguagesOptions['ecmlanguage'][$key] = $d;
}
//$xtpl->assign("PHONE_LIST", EcmInvoiceOutOld::getPhoneList());
$json = getJSONobj();
$scriptOpt = '
<script language="javascript">
var PDFLanguagesOptions = ' . str_replace('&quot;', '\"', $json->encode($PDFLanguagesOptions)) . '
var MOD = ' . str_replace('&quot;', '\"', $json->encode($mod_strings)) . ';
</script>';
echo $scriptOpt;
require_once('modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php');
$ecminvoiceoutold = new EcmInvoiceOutOld();
$xtpl->assign("MFP", $ecminvoiceoutold->loadParserArray());
$xtpl->assign("ECMLANGUAGES_OPTIONS", get_select_options_with_id($app_list_strings['ecmlanguages_dom'], ''));
$xtpl->assign("PARENT_OPTIONS", get_select_options_with_id($app_list_strings['ecminvoiceoutolds_parent_dom'], ''));
echo "\n<p>\n";
echo get_module_title('EcmInvoiceOutOlds', $GLOBALS['mod_strings']['LBL_ECMINVOICEOUTOLDS_PDFLANGUAGES_TITLE'], true);
echo "\n</p>\n";
$xtpl->parse("main");
$xtpl->out("main");
require_once('include/javascript/javascript.php');
$javascript = new javascript();
$javascript->setFormName('PDFLanguages');
echo $javascript->getScript();

View File

@@ -0,0 +1,371 @@
function keyPressedNumber(e) {
var keynum;
if(window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
return keynum;
}
function isEnterOrTabPressed(e) {
var keynum = keyPressedNumber(e);
if(keynum == 9 || keynum == 13) return true; else return false;
}
function setSelectionRange(obj) {
if(obj && typeof(obj) == "object" && (obj.type == "text" || obj.type == "textarea")) {
if(obj.createTextRange) {
var range = obj.createTextRange();
range.moveStart("character", 0);
range.moveEnd("character", obj.value.lengh-1);
range.select();
} else {
if(obj.setSelectionRange) {
obj.setSelectionRange(0,obj.value.length);
}
}
obj.focus();
}
if(obj && typeof(obj) == "object" && obj.options) { obj.focus(); }
}
function PDFLanguagesMT(name) {
this.myTableName = name;
this.table = document.getElementById(this.myTableName);
this.thead = this.table.tHead;
this.tbody = this.table.tBodies.item(0);
this.cellSelectedClass = 'selectedCell';
this.rowSelectedClass = 'selectedRow';
this.selectedRow;
this.selectedCell;
this.rowCount = function() {
return this.tbody.rows.length;
}
this.colCount = function() {
return this.thead.rows.item(0).cells.length;
};
this.colWidth = function(i) {
return this.thead.rows.item(0).cells.item(i).width;
};
this.moveUpRow = function() {
if(this.selectedRow) this.selectedRow.moveUp();
};
this.moveDownRow = function() {
if(this.selectedRow) this.selectedRow.moveDown();
};
this.insertRow = function(row, newRow) {
if(!row)
if(this.rowCount())
if(typeof(row) == "number")
row = this.tbody.rows.item(row);
else
row = this.tbody.rows.item(this.tbody.rows.length-1);
var row_tmp;
if((newRow) && (row)) row_tmp = newRow; else { row_tmp = this.createRow(); this.fillWithDefaultData(row_tmp); }
if(this.rowCount() > 0 && row.nextSibling)
this.tbody.insertBefore(row_tmp, row.nextSibling);
else
this.tbody.appendChild(row_tmp);
return row_tmp;
};
this.refreshRowIndex = function() {
for(var i=0; i<this.rowCount(); i++) {
this.tbody.rows.item(i).index = i;
if(this.onRefreshRowIndex) this.onRefreshRowIndex(this.tbody.rows.item(i));
}
}
this.onRefreshRowIndex;
this.addRow = function(i,data) {
var row = this.createRow();
if(this.selectedRow) this.selectedRow.deselect();
if(this.selectedCell) this.selectedCell.deselect();
row.myTable = this;
if(i || i===0)
this.tbody.insertBefore(row,this.tbody.rows.item(i));
else
this.tbody.appendChild(row);
this.refreshRowIndex();
this.setRowData(row, data);
for(var i=0; i<this.colCount(); i++) row.cells.item(i).afterCreate();
return row;
}
this.createRow = function(row) {
var row = document.createElement('tr');
row.myTable = this;
row.isnew = false;
row.onclick = function() { this.select(); }
row.select = function() {
if(!this.myTable.selectedRow || this.myTable.selectedRow !== this) {
if(this.myTable.selectedRow) this.myTable.selectedRow.deselect();
this.myTable.selectedRow = this;
this.className = this.myTable.rowSelectedClass;
if(row.onSelect) row.onSelect();
}
}
row.deselect = function() {
if(this.myTable.selectedRow === this) {
this.className = '';
this.myTable.selectedRow = '';
if(row.onDeselect) row.onDeselect();
}
};
row.selectNext = function() {
if(this.index < this.myTable.rowCount()-1) { this.deselect(); this.nextSibling.select(); return this.nextSibling; }
else {
if(this.noAddNew) return this;
this.deselect();
var row = this.myTable.addRow(); return row;
}
}
row.selectPrevious = function() {
this.deselect();
if(this.previousSibling && this.index > 0) { this.previousSibling.select(); return this.previousSibling; }else return this;
}
row.deleteRow = function(noNew) {
if(this.myTable.selectedCell) this.myTable.selectedCell.deselect();
if(this.myTable.selectedRow) this.myTable.selectedRow.deselect();
if(this.myTable.rowCount() == 1 && !noNew) {
var MyTaBlE = this.myTable;
setTimeout( function() { MyTaBlE.addRow(); } , 1000);
}
this.myTable.tbody.removeChild(this);
this.myTable.refreshRowIndex();
}
row.moveUp = function() {
if(!this.previousSibling) return;
this.myTable.tbody.insertBefore(this,this.previousSibling);
this.myTable.refreshRowIndex();
}
row.moveDown = function() {
if(!this.nextSibling) this.myTable.addRow(row);
this.myTable.tbody.insertBefore(this.nextSibling,this);
this.myTable.refreshRowIndex();
}
row.setData = function(data) {
if(!data || typeof(data) != "object") { return; };
for(var i=0; i<this.myTable.colCount(); i++) {
this.cells.item(i).setData(data);
}
}
row.getData = function() {
var data = new Object();
for(var i=0; i<this.myTable.colCount(); i++) {
if(this.cells.item(i).getData) this.cells.item(i).getData(data,true);
}
return data;
}
for(var i=0; i<this.colCount(); i++) {
var cell = this.createCell(i);
row.appendChild(cell);
}
if(this.onCreateRow) this.onCreateRow(row);
return row;
};
this.onCreateRow; //function(row) {}
this.createCell = function(i) {
var cell = document.createElement('td');
cell.index = i;
cell.myTable = this;
cell.onclick = function() { this.select(); }
cell.select = function() {
if(!this.myTable.selectedCell || this.myTable.selectedCell !== this) {
if(this.myTable.selectedCell) this.myTable.selectedCell.deselect();
this.myTable.selectedCell = this;
if(this.firstChild.focus && !this.noSelect) setSelectionRange(this.firstChild);
if(this.onSelect) this.onSelect();
this.className = this.myTable.cellSelectedClass;
}
}
cell.deselect = function() {
if(this.myTable.selectedCell === this) {
if(cell.onDeselect) cell.onDeselect();
this.className = '';
this.selected = false;
this.myTable.selectedCell = '';
}
};
cell.selectNext = function() {
this.deselect();
if(this.nextSibling) this.nextSibling.select();
else {
if(!this.parentNode.nextSibling) { if(this.noNewAdd) return; else this.myTable.addRow(); }
this.parentNode.nextSibling.select();
this.parentNode.nextSibling.firstChild.select();
}
}
cell.afterCreate = function() {}
cell.setData = function(data) {}
cell.getData = function(data) {}
if(this.onCreateCell) this.onCreateCell(cell);
return cell;
};
this.onCreateCell; //function(cell) {}
this.setRowData = function(row,data) {
for(var i=0; i<this.colCount(); i++) {
this.setCellData(row,row.cells.item(i),data);
}
}
this.setCellData = function(row,cell,data) {
if(typeof(row) == "number")
if(this.tbody.rows.item(row)) row = this.tbody.rows.item(row);
if(typeof(cell) != "object")
if(typeof(cell) == "number" && typeof(row) == "object") {
if(row.cells.item(cell))
cell = row.cells.item(cell);
else return;
}
else return;
if(this.onSetCellData) this.onSetCellData(row,cell,data);
}
this.onSetCellData; //function(row,cell,data) {}
this.selectRow = function(row) {
if(this.selectedRow === row) return;
if(this.selectedRow) this.deselectRow();
this.selectedRow = row;
this.selectedRow.className = this.rowSelectedClass;
this.setEditNames(this.selectedRow,!this.selectedRow.isnew);
}
this.selectNextRow = function() {
if(!this.selectedRow) return;
if(!this.selectedRow.nextSibling) this.insertRow();
var cell_id = this.selectedCell.lp;
this.selectRow(this.selectedRow.nextSibling);
this.selectCell(this.selectedRow.cells.item(cell_id));
}
this.selectPreviousRow = function() {
if(!this.selectedRow) return;
if(!this.selectedRow.previousSibling) return;
if(this.selectedRow === this.tbody.rows.item(0)) return;
var cell_id = this.selectedCell.lp;
this.selectRow(this.selectedRow.previousSibling);
this.selectCell(this.selectedRow.cells.item(cell_id));
}
this.refreshNumeration = function() {
for(var i=0; i<this.tbody.rows.length; i++)
this.tbody.rows.item(i).cells.item(0).firstChild.value = i+1;
}
this.KeyPressedNumber = function(e) {
var keynum;
if(window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
return keynum;
}
this.KeyPressed = function(e, cell, method) {
var keynum;
if(window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
if((keynum == 9) || (keynum == 13)) {
cell.selectNext();
return false;
}
if(keynum == 40) { var id = cell.index; var row = cell.parentNode.selectNext(); if(row) { row.select(); row.cells.item(id).select(); } }
if(keynum == 38) { var id = cell.index; var row = cell.parentNode.selectPrevious(); if(row) { row.select(); row.cells.item(id).select(); } }
if(e.shiftKey && (method == "decimalNumber" || method == "onlyNumber")) return false;
if(method == "decimalNumber") return this.OnlyNumbers(keynum);
if(method == "onlyNumber") return this.OnlyNumbers(keynum, true);
return true;
}
this.OnlyNumbers = function(e, noQuote) { var keynum = e, keychar, numcheck;
keychar = String.fromCharCode(keynum);
numcheck = /\d/;
return numcheck.test(keychar) || ((!noQuote)?(keynum == 190):false)
|| (keynum == 8) //backspace
|| (keynum == 46) //delete
|| (keynum == 13) //enter || (keynum == 0) //special keys with FF
|| (keynum == 37) //left arrow
|| (keynum == 39) //right arrow
|| (keynum == 188) //,
|| (keynum >= 95 && keynum <= 105) //numeric keyboard
|| (keynum == 110);
}
this.row = function(i) { if(this.tbody.rows.item(i)) return this.tbody.rows.item(i); }
this.cells = function(i,j) { if(this.tbody.rows.item(i).cells.item(i)) return this.tbody.rows.item(i).cells.item(i); }
}

View File

@@ -0,0 +1,28 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
global $current_user;
if(!is_admin($current_user)) {
ACLController::displayNoAccess();
return;
}
if(isset($_REQUEST['ecmlanguage']) && $_REQUEST['ecmlanguage'] != '' && isset($_REQUEST['pdflanguagelist']) && $_REQUEST['pdflanguagelist'] != '') {
require_once('modules/EcmTexts/EcmText.php');
$json = getJSONobj();
$pdfll = $json->decode(htmlspecialchars_decode($_REQUEST['pdflanguagelist']));
global $app_list_strings;
foreach($app_list_strings['ecmlanguages_dom'] as $key => $value) {
if(isset($pdfll[$key]) && count($pdfll[$key]) > 0)
EcmText::SaveText(null,null,'EcmInvoiceOutOlds',$key,$pdfll[$key]);
}
echo 'Saved';
}
?>

View File

@@ -0,0 +1,173 @@
<?php
if (!defined('sugarEntry') || !sugarEntry)
die('Not A Valid Entry Point');
/* * ***************************************************************************
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
* Version 1.1 ("License"); You may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/rpl.php. Software distributed under the
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
* either express or implied.
*
* You may:
* a) Use and distribute this code exactly as you received without payment or
* a royalty or other fee.
* b) Create extensions for this code, provided that you make the extensions
* publicly available and document your modifications clearly.
* c) Charge for a fee for warranty or support or for accepting liability
* obligations for your customers.
*
* You may NOT:
* a) Charge for the use of the original code or extensions, including in
* electronic distribution models, such as ASP (Application Service
* Provider).
* b) Charge for the original source code or your extensions other than a
* nominal fee to cover distribution costs where such distribution
* involves PHYSICAL media.
* c) Modify or delete any pre-existing copyright notices, change notices,
* or License text in the Licensed Software
* d) Assert any patent claims against the Licensor or Contributors, or
* which would in any way restrict the ability of any third party to use the
* Licensed Software.
*
* You must:
* a) Document any modifications you make to this code including the nature of
* the change, the authors of the change, and the date of the change.
* b) Make the source code for any extensions you deploy available via an
* Electronic Distribution Mechanism such as FTP or HTTP download.
* c) Notify the licensor of the availability of source code to your extensions
* and include instructions on how to acquire the source code and updates.
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
* reproduce, perform, modify, sublicense, and distribute your extensions.
*
* The Original Code is: CommuniCore
* Olavo Farias
* 2006-04-7 olavo.farias@gmail.com
*
* The Initial Developer of the Original Code is CommuniCore.
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
*
* All Rights Reserved.
* ****************************************************************************** */
$json = getJSONobj();
$pll = array();
$i = 0;
while (isset($_POST['p_' . $i])) {
$pll[] = $json->decode(htmlspecialchars_decode($_POST['p_' . $i]));
$_POST['p_' . $i] = '';
$i++;
}
$_POST = $json->decode(htmlspecialchars_decode($_POST['otherFormData']));
$_POST['position_list'] = $pll;
$_REQUEST = $_POST;
require_once("modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php");
require_once('include/formbase.php');
$focus = new EcmInvoiceOutOld();
if ($pll[0]['parent_doc_type']=='EcmStockDocOut')
$focus->wz_id = $pll[0]['parent_doc_id'];
if (isset($_POST['record']) && $_POST['record'] != '') {
$focus->retrieve($_POST['record']);
//$focus->id = $_POST['record'];
}
if (isset($focus->id) && $focus->id != '') {
$_POST['email_id'] = $focus->email_id;
} else {
$new_invoice = true;
}
if (!$focus->ACLAccess('Save')) {
ACLController::displayNoAccess(true);
sugar_cleanup(true);
}
/*
if (!empty($_POST['assigned_user_id']) && ($focus->assigned_user_id != $_POST['assigned_user_id']) && ($_POST['assigned_user_id'] != $current_user->id)) {
$check_notify = TRUE;
}else{
$check_notify = FALSE;
}
*/
$check_notify = FALSE;
/*
$json = getJSONobj();
$wi = $json->decode(htmlspecialchars_decode($_POST['work_items']));
$focus->work_items = $wi;
*/
//var_dump($_POST);
foreach ($focus->column_fields as $field) {
if (isset($_POST[$field])) {
$value = $_POST[$field];
$focus->$field = $value;
}
}
foreach ($focus->additional_column_fields as $field) {
if (isset($_POST[$field])) {
$value = $_POST[$field];
$focus->$field = $value;
}
}
if (isset($_POST['to_is_vat_free']) && $_POST['to_is_vat_free'])
$focus->to_is_vat_free = 1;
else
$focus->to_is_vat_free = 0;
$json = getJSONobj();
$pl = $_POST['position_list'];
if ($focus->currency_id!='PLN')
$focus->currency_value = $focus->currency_value_nbp;
$focus->position_list = $pl;
//$focus->wz_id=$_POST['out_id'];
//$focus->paid_val = unformat_number($focus->paid_val);
//$focus->prepaid = unformat_number($focus->prepaid);
if ($focus->pdf_type=='K')
$focus->ecmlanguage='pl_pl';
else
$focus->ecmlanguage='en_us';
$focus->save($check_notify);
if (isset($_POST['out_module']) && $_POST['out_module'] == "EcmQuotes" && isset($_POST['out_id']) && $_POST['out_id'] != '') {
$query = "UPDATE ecmquotes SET status='s60' WHERE id='" . $_POST['out_id'] . "'";
$GLOBALS['db']->query($query);
}
if (isset($_POST['out_module']) && $_POST['out_module'] == "EcmStockDocOuts" && isset($_POST['out_id']) && $_POST['out_id'] != '') {
$query = "UPDATE ecminvoiceoutolds SET wz_id='" . $_POST['out_id'] . "' WHERE id='" . $focus->id . "'";
$GLOBALS['db']->query($query);
}
$return_id = $focus->id;
/*
$r=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select type,document_no from ecminvoiceoutolds where id='".$return_id."'"));
$file="modules/EcmInvoiceOutOlds/xml/".str_replace(" ","",str_replace("/","",$r['document_no'])).".xml";
fopen($file);
if($r['type']=="correct")$xml=createCorrectInvoiceXml($return_id);
else $xml=createInvoiceXml($return_id);
file_put_contents($file,$xml);
chmod($file,0777); */
$pt = @$_POST['parent_type'];
$pdid = @$_POST['parent_doc_id'];
// Close service.
if ($pt == 'Service') {
$usQuery = 'UPDATE `ecmservices` SET `status` = \'closed\' WHERE `id` = \'' . $pdid . '\';';
$GLOBALS['db']->query($usQuery);
$drQuery = 'DELETE FROM `ecmreservations` WHERE `doc_id` = \'' . $pdid . '\';';
$GLOBALS['db']->query($drQuery);
}
echo $return_id;
die();
//header("Location: index.php?module=EcmInvoiceOutOlds&action=index");
//handleRedirect($return_id,'EcmInvoiceOutOlds');

View File

@@ -0,0 +1,78 @@
<?php
require_once('modules/EcmStockDocOuts/EcmStockDocOut.php');
require_once('modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php');
$cids=explode(",",$_REQUEST['uid']);
$count=count($cids);
//echo $_REQUEST['uid'];
//die();
for($i=0;$i<$count;$i++){
if(mysql_num_rows($GLOBALS[db]->query("select id from ecminvoiceoutolds where wz_id='".$cids[$i]."' and deleted='0'"))>0)continue;
$source = new EcmStockDocOut();
$source->retrieve($cids[$i]);
if(isset($source->id) && $source->id != '') {
$focus=new EcmInvoiceOutOld();
$focus->name = $source->name;
$focus->position_list = $source->getPositionList(true);
$focus->template_id = $source->template_id;
$focus->template_name = $source->template_name;
$focus->total = $source->total;
$focus->subtotal = $source->subtotal;
$focus->type='normal';
$r=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select parent_id from accounts where id='".$source->parent_id."'"));
if($r['parent_id'])$parent_id=$r['parent_id'];
else $parent_id=$source->parent_id;
$r=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select name,billing_address_street,billing_address_city,billing_address_country,billing_address_postalcode,supplier_code,ecmpaymentcondition_id,ecmpaymentcondition_name,supplier_code from accounts where id='".$parent_id."'"));
$parent_name=$r['name'];
$parent_address_street=$r['billing_address_street'];
$parent_address_city=$r['billing_address_city'];
$parent_address_postalcode=$r['billing_address_postalcode'];
$parent_address_country=$r['billing_address_country'];
$supplier_code=$r['supplier_code'];
if(!$parent_id){
$parent_id=$source->parent_id;
$parent_name=$source->parent_name;
$parent_address_street = $source->parent_address_street;
$parent_address_postalcode = $source->parent_address_postalcode;
$parent_address_city = $source->parent_address_city;
$parent_address_country = $source->parent_address_country;
}
$focus->parent_type = $source->parent_type;
$focus->parent_id = $parent_id;
$focus->parent_name = $parent_name;
$focus->contact_id = $source->contact_id;
$focus->contact_name = $source->contact_name;
$focus->order_no=$source->order_no;
$focus->supplier_code=$source->supplier_code;
$focus->parent_address_street = $parent_address_street;
$focus->parent_address_postalcode = $parent_address_postalcode;
$focus->parent_address_city = $parent_address_city;
$focus->parent_address_country = $parent_address_country;
$focus->supplier_code=$supplier_code;
$focus->ecmpaymentcondition_id=$r['ecmpaymentcondition_id'];
$focus->ecmpaymentcondition_name=$r['ecmpaymentcondition_name'];
$focus->sell_date=$GLOBALS['timedate']->to_display_date(date($GLOBALS['timedate']->dbDayFormat));
$focus->register_date=$GLOBALS['timedate']->to_display_date(date($GLOBALS['timedate']->dbDayFormat));
$rrrrrr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select days from ecmpaymentconditions where id='".$r['ecmpaymentcondition_id']."'"));
$focus->payment_date=$GLOBALS['timedate']->to_display_date(date($GLOBALS['timedate']->dbDayFormat,mktime()+3600*24*$rrrrrr['days']));
$focus->status="accepted";
$focus->assigned_user_id=$_SESSION['authenticated_user_id'];
$r=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select sic_code,vatid from accounts where id='".$parent_id."'"));
$focus->to_nip = $r['vatid'];
$focus->ecmlanguage = $source->ecmlanguage;
$focus->wz_id=$cids[$i];
$return_id=$focus->save();
$GLOBALS[db]->query("update ecminvoiceoutolds set wz_id='".$cids[$i]."' where id='".$return_id."'");
}
}
header("Location: index.php?module=EcmStockDocOuts&action=index");
?>

View File

@@ -0,0 +1,7 @@
<?php
$w=$GLOBALS[db]->query("select id,document_no,status,register_date from ecmstockdocouts where status!='registered' and register_date like '2010-%' and deleted='0'");
while($r=$GLOBALS[db]->fetchByAssoc($w)){
$rr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select count(*) as cnt from ecminvoiceoutolds where register_date>'2010-%' and wz_id='".$r['id']."' and deleted='0'"));
if($rr['cnt']==0)echo $r['document_no']." ".$r['register_date']." ".$r['status']."<br>";
}
?>

View File

@@ -0,0 +1,30 @@
<?
$w=$GLOBALS[db]->query("select id,document_no from ecminvoiceoutolds where register_date>'2010-01-01' and type='normal'");
while($r=$GLOBALS[db]->fetchByAssoc($w)){
$ww=$GLOBALS[db]->query("select price,quantity,ecmvat_value from ecminvoiceoutolditems where ecminvoiceoutold_id='".$r['id']."'");
$total_vat=0;
$total_brutto=0;
$total_netto=0;
$total_vat_r=0;
$total_brutto_r=0;
$total_netto_r=0;
while($rr=$GLOBALS[db]->fetchByAssoc($ww)){
$total_vat+=$rr['price']*$rr['quantity']*$rr['ecmvat_value']/100;
$total_brutto+=$rr['price']*$rr['quantity']*(1+$rr['ecmvat_value']/100);
$total_netto+=$rr['price']*$rr['quantity'];
$total_vat_r+=round($rr['price']*$rr['quantity']*$rr['ecmvat_value']/100,2);
$total_brutto_r+=round($rr['price']*$rr['quantity']*(1+$rr['ecmvat_value']/100),2);
$total_netto_r+=round($rr['price']*$rr['quantity'],2);
//if(round($rr['price']*$rr['quantity']*(1+$rr['ecmvat_value']/100)-
}
//if(!eregi(((float)round($total_netto,2)+(float)round($total_vat,2)),((float)round($total_brutto,2))))
if(round($total_brutto-$total_netto,2)!=round($total_vat,2)){
echo $r['document_no']."<br>";
echo (round($total_brutto-$total_netto,2))." ".round($total_netto,2)." ".round($total_brutto,2)."<br>";
echo round($total_vat,2)." ".round($total_netto,2)." ".round($total_brutto,2)."<br>";
}
}
?>

View File

@@ -0,0 +1,11 @@
<?
$w=$GLOBALS[db]->query("select product_code,product_id,price,id from ecmstockoperations where price=131 and date_modified>'2010-01-01'");
while($r=$GLOBALS[db]->fetchByAssoc($w)){
$rr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select purchase_price from ecmproducts where id='".$r['product_id']."'"));
$rrr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select max(price) as max,min(price) as min from ecmstockoperations where product_id='".$r['product_id']."' order by date_entered desc"));
if($rr['purchase_price']<=$r['price'] and $rr['purchase_price']>0){
echo $r['product_code']." ".$r['price']." ".$rrr['max']." ".$rrr['min']." ".$rr['purchase_price']."<br>";
//if($rrr['price'])$GLOBALS[db]->query("update ecmstockoperations set price='".$rrr['price']."' where id='".$r['id']."'");
}
}
?>

View File

@@ -0,0 +1,65 @@
<?php
//ini_set('display_errors',1);
$date = "2013-11";
$fp2 = fopen('generatorfifi.php', 'w');
fwrite($fp2, "<?php\ninclude 'PDFMerger.php';\n\$pdf = new PDFMerger;\n\$pdf");
$db = $GLOBALS['db'];
$res = $db->query("SELECT id FROM ecminvoiceoutolds WHERE register_date like '2014-02%'");
//$res = $db->query("SELECT id, document_no, total, subtotal FROM ecminvoiceoutolds WHERE id='5a5074e6-689c-375c-07f4-529edd341c10'");
$b=0;
require_once("modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php");
while ($row = $db->fetchByAssoc($res)) {
$i = new EcmInvoiceOutOld();
$i->retrieve($row['id']);
echo 'bb';
if(file_exists('pdftmp2/'.$i->createPdfFileName())) { $b++; echo 'istnieje<br>'; } else {
//echo $i->createPdfFileName.' null<br>';
echo 'aa<br>'.$row['id'].'<br>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://192.168.1.131/crm/index.php?action=Authenticate&module=Users&return_module=Users&return_action=Login&user_name=db&user_password=rudemodz&login_theme=Sugar&login_language=en_us');
//curl_setopt($ch, CURLOPT_POSTFIELDS,'user_name=db&user_password='.$pass.'');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
$page = curl_exec($ch);
$up='https://192.168.1.131/crm/index.php?module=EcmInvoiceOutOlds&action=previewPDF&type=&to_pdf=1&record='.$row['id'].'';
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $up);
//echo $i.': '.$row['id'].'<br>';
$page = curl_exec($ch);
$fp = fopen('pdftmp2/'.$i->createPdfFileName().'', 'w');
fwrite($fp, $page);
$s="->addPDF('pdftmp/".$i->createPdfFileName()."', 'all')\n";
//$b=microtime();
fwrite($fp2, $s);
fclose($fp);
//repair in db
//$db->query("UPDATE ecminvoiceoutolds SET total=$total, subtotal=$subtotal WHERE id='".$row['id']."'");
//echo "UPDATE ecminvoiceoutolds SET total=$total, subtotal=$subtotal WHERE id='".$row['id']."'<br>";
// $db->query("UPDATE ecmpayments_ecminvoiceoutolds SET total=$total WHERE ecminvoiceoutold_id='".$row['id']."'");
//unset($i);
}
}
/*
$s="->merge('file', 'pdftmp/asd".date("h:y");
$s.=".pdf');";
fwrite($fp2, $s);
fclose($fp2);
echo 'Zrobione!';
*/
echo $b;
?>

View File

@@ -0,0 +1,260 @@
<?php
function createDecree($year, $month) {
$xml = '<?xml version="1.0" encoding="utf-8" ?>';
$xml .= '<paczka miesiac="' . $year . '-' . $month . '" firma="E5" opis="FVS ' . $year . '-' . $month . '" wersja="1.0">';
// normal
$db = $GLOBALS ['db'];
$w = $db->query ( "select pdf_type,currency_id,id,name,number,document_no,wz_id,register_date,payment_date,sell_date,to_nip,parent_id,parent_name,parent_address_street,parent_address_postalcode,parent_address_country,parent_address_city,currency_value, subtotal, total from ecminvoiceoutolds where type='normal' and register_date like '" . $year . "-" . $month . "%' and deleted='0' and canceled='0' order by date_entered asc" );
while ( $r = $db->fetchByAssoc ( $w ) ) {
if ($r ['currency_value']) {
$c = new Currency ();
$c->retrieve ( $r ['currency_id'] );
$waluta = $c->name;
unset ( $c );
$kurs = $r ['currency_value'];
} else {
$waluta = "PLN";
$kurs = 1;
}
if (! isset ( $r ['pdf_type'] ))
$r ['pdf_type'] = 'K';
$nip = str_replace ( "-", "", $r ['to_nip'] );
$r_wz = $db->fetchByAssoc ( $db->query ( "select id,number,document_no, register_date from ecmstockdocouts where id='" . $r ['wz_id'] . "'" ) );
$xml .= '<dokument rodzaj="FVS' . $r ['pdf_type'] . '" id="' . $r ['number'] . '">
<data>' . $r ['register_date'] . '</data>
<dataWplywu>' . $r ['register_date'] . '</dataWplywu>
<dataOperacji>' . $r ['register_date'] . '</dataOperacji>
<dataDostawy></dataDostawy>
<numer>' . $r ['document_no'] . '</numer>
<idMagazynu>0</idMagazynu>
<kontrahent id="' . $r ['parent_id'] . '" kod="' . $nip . '">
<NIP>' . $nip . '</NIP>
<nazwa>' . str_replace ( "<", "", str_replace ( ">", "", $r ['parent_name'] ) ) . '</nazwa>
<adres>' . $r ['parent_address_street'] . '</adres>
<kodPocztowy>' . $r ['parent_address_postalcode'] . '</kodPocztowy>
<miasto>' . $r ['parent_address_city'] . '</miasto>
</kontrahent>
<dokumentyMagazynowe>
<dokumentMagazynowy rodzaj="WZ" id="' . $r_wz ['number'] . '">
<numer>' . $r_wz ['document_no'] . '</numer>
</dokumentMagazynowy>
</dokumentyMagazynowe>
<opis>' . $r ['name'] . '</opis>
<dataPlatnosci>' . $r ['payment_date'] . '</dataPlatnosci>
<formaPlatnosci>0</formaPlatnosci>
<waluta>' . $waluta . '</waluta>';
$xml .= '
<sumaNetto>' . round ( $r ['subtotal'] * $kurs, 2 ) . '</sumaNetto>
<sumaBrutto>' . round ( $r ['total'] * $kurs, 2 ) . '</sumaBrutto>
<sumaVAT>' . round ( ($r ['total'] - $r ['subtotal']) * $kurs, 2 ) . '</sumaVAT>
<sumaWalNetto>' . round ( $r ['subtotal'], 2 ) . '</sumaWalNetto>
<sumaWalBrutto>' . round ( $r ['total'], 2 ) . '</sumaWalBrutto>
<sumaWalVAT>' . round ( ($r ['total'] - $r ['subtotal']), 2 ) . '</sumaWalVAT>
';
if ($r ['pdf_type'] != 'K') {
$xml.= '<kursy>
<kurs waluta="'.$waluta.'" zastosowanie="dataTransakcji" rodzaj="NBP">
<symbol></symbol>
<naDzien></naDzien>
<wartosc>'.$kurs.'</wartosc>
</kurs>
</kursy>
';
}
// rozbicie
$xml.='<rejestr>
';
$rozbicie = $db->query("
select sum(i.subtotal) as subtotal, sum(i.total) as total, v.name, v.value from ecminvoiceoutolditems as i
inner join ecmvats as v
on v.id = i.ecmvat_id
where
i.ecminvoiceoutold_id='".$r['id']."'
group by v.id;
");
while ($roz = $db->fetchByAssoc($rozbicie)) {
$xml .= '
<rozbicie stawka="' .$roz['name']. '">
<netto>' . round($roz['subtotal'],2) . '</netto>
<brutto>' . round($roz['total'],2) . '</brutto>
<VAT>' . round ($roz['total'] - $roz['subtotal'], 2 ) . '</VAT>
</rozbicie>
';
}
$xml .= '</rejestr>
';
//pozycje dokumentu
$xml.='<pozycjeDokumentu>
';
$pozycje = $db->query("
select sum(i.subtotal) as subtotal, p.group_ks, sum(i.quantity) as qty from ecminvoiceoutolditems as i
inner join ecmproducts as p
on p.id=i.ecmproduct_id
where i.ecminvoiceoutold_id='".$r['id']."'
group by p.group_ks;
");
$pp = 0;
global $app_list_strings;
while ($poz = $db->fetchByAssoc($pozycje)) {
$pp++;
if ($poz['group_ks']=='1')
$rodzaj = 'T';
else $rodzaj = 'P';
$xml.='
<pozycjaDokumentu lp="'.$pp.'" rodzaj="'.$rodzaj.'" id="" stawka="">
<kodAsortymentu>'.$app_list_strings['ecmproducts_group_ks_dom'][$poz['group_ks']].'</kodAsortymentu>
<grupaAsortymentu>'.$app_list_strings['ecmproducts_group_ks_dom'][$poz['group_ks']].'</grupaAsortymentu>
<tresc>'.$app_list_strings['ecmproducts_group_ks_dom'][$poz['group_ks']].'</tresc>
<ilosc>1</ilosc>
<jednostkaMiary>szt.</jednostkaMiary>
<cenaNetto>'.round($poz['subtotal'],2).'</cenaNetto>
<cenaBrutto></cenaBrutto>
<wartoscNetto>'.round($poz['subtotal'],2).'</wartoscNetto>
<wartoscBrutto></wartoscBrutto>
<wartoscVat></wartoscVat>
</pozycjaDokumentu>
';
}
$xml.='</pozycjeDokumentu>
';
$xml.='</dokument>
';
}
// corrects
$w = $db->query ( "selectt currency_id, currency_value,id,name,document_no,name,register_date,payment_date,sell_date,to_nip,parent_id,parent_name,parent_address_street,parent_address_postalcode,parent_address_country,parent_address_city,ecminvoiceoutold_id,ecminvoiceoutold_name from ecminvoiceoutolds where type='correct' and register_date like '" . $year . "-" . $month . "%' and deleted='0' and canceled='0' order by date_entered asc" );
while ( $r = $db->fetchByAssoc ( $w ) ) {
if ($r ['currency_value']) {
$c = new Currency ();
$c->retrieve ( $r ['currency_id'] );
$waluta = $c->name;
unset ( $c );
$kurs = $r ['currency_value'];
} else {
$waluta = "PLN";
$kurs = 1;
}
if (! isset ( $r ['pdf_type'] ))
$r ['pdf_type'] = 'K';
$nip = str_replace ( "-", "", $r ['to_nip'] );
$r_wz = $db->fetchByAssoc ( $db->query ( "select id,number,document_no, register_date from ecmstockdocouts where id='" . $r ['wz_id'] . "'" ) );
$xml .= '<dokument rodzaj="FVS' . $r ['pdf_type'] . '" id="' . $r ['number'] . '">
<data>' . $r ['register_date'] . '</data>
<dataWplywu>' . $r ['register_date'] . '</dataWplywu>
<dataOperacji>' . $r ['register_date'] . '</dataOperacji>
<dataDostawy></dataDostawy>
<numer>' . $r ['document_no'] . '</numer>
<idMagazynu>0</idMagazynu>
<kontrahent id="' . $r ['parent_id'] . '" kod="' . $nip . '">
<NIP>' . $nip . '</NIP>
<nazwa>' . str_replace ( "<", "", str_replace ( ">", "", $r ['parent_name'] ) ) . '</nazwa>
<adres>' . $r ['parent_address_street'] . '</adres>
<kodPocztowy>' . $r ['parent_address_postalcode'] . '</kodPocztowy>
<miasto>' . $r ['parent_address_city'] . '</miasto>
</kontrahent>
<dokumentyMagazynowe>
<dokumentMagazynowy rodzaj="WZ" id="' . $r_wz ['number'] . '">
<numer>' . $r_wz ['document_no'] . '</numer>
</dokumentMagazynowy>
</dokumentyMagazynowe>
<opis>' . $r ['name'] . '</opis>
<dataPlatnosci>' . $r ['payment_date'] . '</dataPlatnosci>
<formaPlatnosci>0</formaPlatnosci>
<waluta>' . $waluta . '</waluta>';
$xml .= '
<sumaNetto>' . round ( $r ['subtotal'] * $kurs, 2 ) . '</sumaNetto>
<sumaBrutto>' . round ( $r ['total'] * $kurs, 2 ) . '</sumaBrutto>
<sumaVAT>' . round ( ($r ['total'] - $r ['subtotal']) * $kurs, 2 ) . '</sumaVAT>
<sumaWalNetto>' . round ( $r ['subtotal'], 2 ) . '</sumaWalNetto>
<sumaWalBrutto>' . round ( $r ['total'], 2 ) . '</sumaWalBrutto>
<sumaWalVAT>' . round ( ($r ['total'] - $r ['subtotal']), 2 ) . '</sumaWalVAT>
';
if ($r ['pdf_type'] != 'K') {
$xml.= '<kursy>
<kurs waluta="'.$waluta.'" zastosowanie="dataTransakcji" rodzaj="NBP">
<symbol></symbol>
<naDzien></naDzien>
<wartosc>'.$kurs.'</wartosc>
</kurs>
</kursy>
';
}
// rozbicie
$xml.='<rejestr>
';
$rozbicie = $db->query("
select sum(i.subtotal) as subtotal, sum(i.total) as total, v.name, v.value from ecminvoiceoutolditems as i
inner join ecmvats as v
on v.id = i.ecmvat_id
where
i.ecminvoiceoutold_id='".$r['id']."'
group by v.id;
");
while ($roz = $db->fetchByAssoc($rozbicie)) {
$xml .= '
<rozbicie stawka="' .$roz['name']. '">
<netto>' . round($roz['subtotal'],2) . '</netto>
<brutto>' . round($roz['total'],2) . '</brutto>
<VAT>' . round ($roz['total'] - $roz['subtotal'], 2 ) . '</VAT>
</rozbicie>
';
}
$xml .= '</rejestr>
';
//pozycje dokumentu
$xml.='<pozycjeDokumentu>
';
$pozycje = $db->query("
select sum(i.subtotal) as subtotal, p.group_ks, sum(i.quantity) as qty from ecminvoiceoutolditems as i
inner join ecmproducts as p
on p.id=i.ecmproduct_id
where i.ecminvoiceoutold_id='".$r['id']."'
group by p.group_ks;
");
$pp = 0;
global $app_list_strings;
while ($poz = $db->fetchByAssoc($pozycje)) {
$pp++;
if ($poz['group_ks']=='1')
$rodzaj = 'T';
else $rodzaj = 'P';
$xml.='
<pozycjaDokumentu lp="'.$pp.'" rodzaj="'.$rodzaj.'" id="" stawka="">
<kodAsortymentu>'.$app_list_strings['ecmproducts_group_ks_dom'][$poz['group_ks']].'</kodAsortymentu>
<grupaAsortymentu>'.$app_list_strings['ecmproducts_group_ks_dom'][$poz['group_ks']].'</grupaAsortymentu>
<tresc>'.$app_list_strings['ecmproducts_group_ks_dom'][$poz['group_ks']].'</tresc>
<ilosc>1</ilosc>
<jednostkaMiary>szt.</jednostkaMiary>
<cenaNetto>'.round($poz['subtotal'],2).'</cenaNetto>
<cenaBrutto></cenaBrutto>
<wartoscNetto>'.round($poz['subtotal'],2).'</wartoscNetto>
<wartoscBrutto></wartoscBrutto>
<wartoscVat></wartoscVat>
</pozycjaDokumentu>
';
}
$xml.='</pozycjeDokumentu>
';
$xml.='</dokument>
';
}
return $xml;
}
// echo createDecree(2009,12)
?>

View File

@@ -0,0 +1,56 @@
<?php
class createEdiXML {
private $xml;
private $id;
//private $i; //EcmInvoiceOutOld object
function createEdiXML($id) {
$this->id = $id;
$this->i = new EcmInvoiceOutOld();
$this->i->retrieve($this->id);
}
public function getXML() {
$i = $this->i;
if ($i->type == 'normal')
$this->xml = $this->createInvoiceXML();
elseif ($i->type == 'correct')
$this->xml = $this->createInvoiceXML();
//$this->xml->flush ();
}
private function createInvoiceXML() {
$db = $GLOBALS['db'];
$i = $this->i;
//get data
//get WZ && Sale info
$wz = $db->fetchByAssoc($db->query("SELECT document_no, register_date, so_id FROM ecmstockdocouts WHERE id ='$i->wz_id'"));
$sale = $db->fetchByAssoc($db->query("SELECT docment_no, register_date, parent_document_no FROM ecmsales WHERE id = '".$wz['so_id']."'"));
//get ILNs
$shipping_iln = $db->fetchByAssoc($db->query("SELECT iln FROM "));
$xml = new XMLWriter ();
$xml->openURI ( 'php://output' );
// $this->p->openMemory();
$xml->startDocument ( '1.0', 'UTF-8' );
$xml->startElement ( 'Document-Invoice' );
$xml->startElement('Invoice-Header');
$xml->writeElement('InvoiceNumber' ,$i->document_no);
$xml->writeElement('InvoiceDate', $i->register_date);
$xml->writeElement('SalesDate', $i->sell_date);
$c = new Currency();
$c->retrieve($i->currency_id);
$xml->writeElement('InvoiceCurrency', $c->iso4217);
unset($c);
$xml->writeElement('InvoicePaymentDueDate', $i->payment_date);
$pc = new EcmPaymentCondition();
$pc->retrieve($i->ecmpaymentcondition_id);
$xml->writeElement('InvoicePaymentTerms', $pc->days);
unset($pc);
$xml->writeElement('DocumentFunctionCode', 'O');
$xml->endElement(); //</Invoice-Header>
$xml->endElement(); //</Document-Invoice>
return $xml;
}
}
?>

View File

@@ -0,0 +1,117 @@
<?php
require_once('modules/EcmAccounts/Account.php');
require_once('modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php');
require_once('modules/EcmSales/EcmSale.php');
function createInvoiceFromWz($id) {
$i = new EcmInvoiceOutOld();
//create products array
$r = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT * FROM ecmstockdocouts WHERE id='" . $id . "'"));
$a = new Account();
$a->retrieve($r['parent_id']);
$i->parent_id = $r['parent_id'];
$i->parent_name = $r['parent_name'];
$i->parent_address_street = $r['parent_address_street'];
$i->parent_address_city = $r['parent_address_city'];
$i->parent_address_postalcode = $r['parent_address_postalcode'];
$i->parent_address_country = $r['parent_address_country'];
$i->to_nip = $a->to_vatid;
$i->ecmpaymentcondition_id = $a->ecmpaymentcondition_id;
$i->supplier_code = $a->supplier_code;
$pc = new EcmPaymentCondition();
$pc->retrieve($a->ecmpaymentcondition_id);
$i->ecmpaymentcondition_name = $pc->name;
$i->payment_date=$GLOBALS['timedate']->to_display_date(date("Y-m-d",mktime()+3600*24*$pc->days));
$s = new EcmSale();
$s->retrieve($r['so_id']);
//delivery address
$i->parent_shipping_address_name = $s->parent_shipping_address_name;
$i->parent_shipping_address_street = $s->parent_shipping_address_street;
$i->parent_shipping_address_city = $s->parent_shipping_address_city;
$i->parent_shipping_address_postalcode = $s->parent_shipping_address_postalcode;
$i->parent_shipping_address_country = $s->parent_shipping_address_country;
$i->template_id = $r['template_id'];
$i->template_name = $r['template_name'];
$i->parent_contact_name = $r['parent_contact_name'];
$i->parent_contact_title = $r['parent_contact_title'];
$i->order_no = $r['order_no'];
$i->contact_id = $r['contact_id'];
$i->name = $r['name'];
$i->register_date=$GLOBALS['timedate']->to_display_date(date("Y-m-d"));
$i->sell_date=$GLOBALS['timedate']->to_display_date(date("Y-m-d"));
$i->wz_id = $id;
$i->status="accepted";
$i->type = "normal";
$i->assigned_user_id='c054ae2d-7d94-5a74-28a0-5236e3d1493e';
$i->created_by='c054ae2d-7d94-5a74-28a0-5236e3d1493e';
$i->modified_user_id='c054ae2d-7d94-5a74-28a0-5236e3d1493e';
$i->pdf_type=$s->$s->pdf_type;
$i->currency_id=$s->currency_id;
unset($s);
//set possition list
$pl = array ();
$res = $GLOBALS ['db']->query ( "SELECT * FROM ecmstockdocoutitems WHERE ecmstockdocout_id ='" . $id . "' order by position" );
global $app_list_strings;
while ( $r = $GLOBALS ['db']->fetchByAssoc ( $res ) ) {
$t = $GLOBALS ['db']->fetchByAssoc ( $GLOBALS ['db']->query ( "SELECT unit_id FROM ecmproducts WHERE id='" . $r['ecmproduct_id'] . "'" ) );
$subprice = $r['selling_price'];
$subtotal = $r['quantity'] * $subprice;
$vat = $subtotal * ($r['ecmvat_value'] / 100);
$total = $subtotal + $vat;
$price = $total / $r['quantity'];
$position = array ();
$position ['iid'] = create_guid ();
$position ['code'] = $r ['code'];
$position ['name'] = $r ['name'];
$position ['id'] = $r ['ecmproduct_id'];
$position ['quantity'] = $r ['quantity'];
// calculate currency
$position ['startprice'] = $r ['selling_price'];
$position['subprice'] = $subprice;
$position['price'] = $price;
$position['subtotal'] = $subtotal;
$position['total'] = $total;
$position ['discount'] = $r ['discount'];
$position ['unit_id'] = $t['unit_id'];
$position ['unit_name'] = $app_list_strings['ecmproducts_unit_dom'][$t['unit_id']];
$position ['vat_id'] = $r ['ecmvat_id'];
$position ['vat_name'] = $r ['ecmvat_name'];
$position ['vat_value'] = $r ['ecmvat_value'];
$position ['category_id'] = $r ['ecmproductcategory_id'];
$position ['currency_id'] = $r ['currency_id'];
$position ['currency_name'] = $r ['currency_name'];
$position ['recipient_code'] = $r ['recipient_code'];
$position ['type'] = $t ['type'];
$position ['parent_doc_id'] = $r ['ecmstockdocout_id'];
$position ['parent_doc_type'] = 'EcmStockDocOut';
$position ['parent_doc_item_id'] = $r ['id'];
$position ['temp_item_id'] = create_guid ();
$position ['temp_date'] = date ( "Y-m-d H:i:s" );
$pl [] = $position;
}
$i->position_list = $pl;
$i->save();
}
?>

View File

@@ -0,0 +1,496 @@
<?php
include_once("modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php");
function createInvoiceXml($id){
$r=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select *, TRIM(order_no) as o_no from ecminvoiceoutolds where id='".$id."'"));
$r_wz=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select document_no,so_id,parent_id from ecmstockdocouts where id='".$r['wz_id']."'"));
$r_so=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select register_date,parent_id, parent_shipping_address_name from ecmsales where id='".$r_wz['so_id']."'"));
$r_so_acc=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select iln from accounts where name like '".trim($r_so['parent_shipping_address_name'])."%'"));
if (!$r_so_acc || $r_so_acc['iln']=='') {
$r_so_acc=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select iln from accounts where id = '".trim($r_so['parent_id'])."'"));
}
$rr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select iln from accounts where id='".$r['parent_id']."'"));
$buyer_iln=$rr['iln'];
$rr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select account_id,account_number from ecmdocumenttemplates where id='".$r['template_id']."'"));
$seller_account_number=$rr['account_number'];
$rr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select iln,name,id,sic_code,billing_address_street,billing_address_city,billing_address_postalcode,billing_address_country from accounts where id='".$rr['account_id']."'"));
$seller_iln=$rr['iln'];
$seller_id=$rr['id'];
$seller_name=$rr['name'];
$seller_nip=$rr['sic_code'];
$seller_street=$rr['billing_address_street'];
$seller_city=$rr['billing_address_city'];
$seller_postalcode=$rr['billing_address_postalcode'];
$seller_country=$rr['billing_address_country'];
if(strlen($r['currency_id'])<36)$currency=$r['currency_id'];
else{
$rr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select iso4217 from currencies where id='".$r['currency_id']."'"));
$currency=$rr['iso4217'];
}
if(!$currency)$currency="PLN";
$rr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select days from ecmpaymentconditions where id='".$r['ecmpaymentcondition_id']."'"));
$days=$rr['days'];
$order_no=trim($r['o_no']);
$register_date=$r['register_date'];
$dp=$r['delivery_place'];
if($r['parent_id']==134)$codebybuyer="";
else $codebybuyer=$r['supplier_code'];
echo $r['o_no'].' - '.$r['document_no'].'<br>';
$dpp=array(
"10"=>"5900000900100",
"11"=>"5900000900117",
"12"=>"5900000900124",
"13"=>"5900000900131",
"14"=>"5900000900148",
"15"=>"5900000900155",
"16"=>"5900000900162",
"17"=>"5900000900179",
"18"=>"5900000900186",
"19"=>"5900000900193",
"20"=>"5900000900209",
"21"=>"5900000900216",
"22"=>"5900000900223",
"23"=>"5900000900230",
"24"=>"5900000900247",
"25"=>"5900000900254",
"26"=>"5900000900261",
"27"=>"5900000900278",
"28"=>"5900000900285",
"29"=>"5900000900292",
"30"=>"5900000900308",
"31"=>"5900000900315",
"32"=>"5900000900322",
"33"=>"5900000900339",
"34"=>"5900000900346",
"35"=>"5900000900353",
"36"=>"5900000900360",
"37"=>"5900000900377",
"38"=>"5900000900384",
"39"=>"5900000900391",
"41"=>"5900000900414",
"42"=>"5900000900421",
"43"=>"5900000900438",
"44"=>"5900000900445",
"45"=>"5900000900452",
"46"=>"5900000900469",
"47"=>"5900000900476",
"48"=>"5900000900483",
"49"=>"5900000900490",
"50"=>"5900000900506",
"51"=>"5900000900513",
"52"=>"5900000900520",
"53"=>"5900000900537",
"54"=>"5900000900544",
"55"=>"5900000900551",
"56"=>"5900000900568",
"57"=>"5900000900575",
"58"=>"5900000900582",
"59"=>"5900000900599",
"60"=>"5900000900605",
"61"=>"5900000900612",
"63"=>"5900000900636",
"64"=>"5900000900643",
"65"=>"5900000900650",
);
$prod_iln=$r_so_acc['iln'];
$xml='<Document-Invoice>
<Invoice-Header>
<InvoiceNumber>'.$r['document_no'].'</InvoiceNumber>
<InvoiceDate>'.$r['register_date'].'</InvoiceDate>
<SalesDate>'.$r['sell_date'].'</SalesDate>';
if($_REQUEST['duplicate']==1){
$xml.='<InvoiceDuplicateDate>'.date("Y-m-d").'</InvoiceDuplicateDate>';
$dfc="D";
}
else{
$dfc="O";
}
$xml.='<InvoiceCurrency>'.$currency.'</InvoiceCurrency>
<InvoicePaymentDueDate>'.$r['payment_date'].'</InvoicePaymentDueDate>
<InvoicePaymentTerms>'.$days.'</InvoicePaymentTerms>
<InvoicePostDate>'.$r['register_date'].'</InvoicePostDate>
<DocumentFunctionCode>'.$dfc.'</DocumentFunctionCode>
<Order>
<BuyerOrderNumber>'.trim($r['o_no']).'</BuyerOrderNumber>
<BuyerOrderDate>'.$r_so['register_date'].'</BuyerOrderDate>
</Order>
<Delivery>
<DeliveryLocationNumber>'.str_replace(" ","",$prod_iln).'</DeliveryLocationNumber>
<DespatchNumber>'.$r_wz['document_no'].'</DespatchNumber>
<DeliveryDate>'.$r['register_date'].'</DeliveryDate>
</Delivery>
</Invoice-Header>
<Invoice-Parties>
<Buyer>
<ILN>'.str_replace(" ","",$buyer_iln).'</ILN>
<TaxID>'.str_replace("-","",$r['to_nip']).'</TaxID>
<Name>'.$r['parent_name'].'</Name>
<StreetAndNumber>'.$r['parent_address_street'].'</StreetAndNumber>
<CityName>'.$r['parent_address_city'].'</CityName>
<PostalCode>'.$r['parent_address_postalcode'].'</PostalCode>
<Country>PL</Country>
</Buyer>
<Payer>
<ILN>'.str_replace(" ","",$buyer_iln).'</ILN>
<TaxID>'.str_replace("-","",$r['to_nip']).'</TaxID>
<Name>'.$r['parent_name'].'</Name>
<StreetAndNumber>'.$r['parent_address_street'].'</StreetAndNumber>
<CityName>'.$r['parent_address_city'].'</CityName>
<PostalCode>'.$r['parent_address_postalcode'].'</PostalCode>
<Country>PL</Country>
</Payer>
<Invoicee>
<ILN>'.str_replace(" ","",$buyer_iln).'</ILN>
<TaxID>'.str_replace("-","",$r['to_nip']).'</TaxID>
<Name>'.$r['parent_name'].'</Name>
<StreetAndNumber>'.$r['parent_address_street'].'</StreetAndNumber>
<CityName>'.$r['parent_address_city'].'</CityName>
<PostalCode>'.$r['parent_address_postalcode'].'</PostalCode>
<Country>PL</Country>
</Invoicee>
<Seller>
<ILN>'.str_replace(" ","",$seller_iln).'</ILN>
<TaxID>'.str_replace("-","",$seller_nip).'</TaxID>
<AccountNumber>'.$seller_account_number.'</AccountNumber>
<Name>'.$seller_name.'</Name>
<StreetAndNumber>'.$seller_street.'</StreetAndNumber>
<CityName>'.$seller_city.'</CityName>
<PostalCode>'.$seller_postalcode.'</PostalCode>
<Country>PL</Country>
<CodeByBuyer>'.$codebybuyer.'</CodeByBuyer>
<UtilizationRegisterNumber></UtilizationRegisterNumber>
</Seller>
<Payee>
<ILN>'.str_replace(" ","",$seller_iln).'</ILN>
<TaxID>'.str_replace("-","",$seller_nip).'</TaxID>
<AccountNumber>'.$seller_account_number.'</AccountNumber>
<Name>'.$seller_name.'</Name>
<StreetAndNumber>'.$seller_street.'</StreetAndNumber>
<CityName>'.$seller_city.'</CityName>
<PostalCode>'.$seller_postalcode.'</PostalCode>
<Country>PL</Country>
<CodeByBuyer>'.$codebybuyer.'</CodeByBuyer>
<UtilizationRegisterNumber></UtilizationRegisterNumber>
</Payee>
<SellerHeadquarters>
<ILN>'.str_replace(" ","",$seller_iln).'</ILN>
<TaxID>'.str_replace("-","",$seller_nip).'</TaxID>
<AccountNumber>'.$seller_account_number.'</AccountNumber>
<Name>'.$seller_name.'</Name>
<StreetAndNumber>'.$seller_street.'</StreetAndNumber>
<CityName>'.$seller_city.'</CityName>
<PostalCode>'.$seller_postalcode.'</PostalCode>
<Country>PL</Country>
<CodeByBuyer>'.$codebybuyer.'</CodeByBuyer>
<UtilizationRegisterNumber></UtilizationRegisterNumber>
</SellerHeadquarters>
</Invoice-Parties>
<Invoice-Lines>';
$w=$GLOBALS[db]->query("select * from ecminvoiceoutolditems where deleted='0' and ecminvoiceoutold_id='".$id."'");
$i=0;
$total_netto=0;
$total_vat=0;
$total_netto_arr=array();
$vats=array();
while($r=$GLOBALS[db]->fetchByAssoc($w)){
$rr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select TRIM(ean) as ean from ecmproduct_language_pl_view where ecmproduct_id='".$r['ecmproduct_id']."'"));
$ean=trim($rr['ean']);
if (strlen($ean) > 13)
$ean = substr($ean, 0,13);
$total_netto+=$r['subtotal'];
$total_vat+=($r['total']-$r['subtotal']);
$vats[$r['ecmvat_value']]=$r['ecmvat_value'];
$total_netto_arr[$r['ecmvat_value']]+=$r['subtotal'];
$total_vat_arr[$r['ecmvat_value']]+=($r['total']-$r['subtotal']);
if (strlen($r['name'])>=70)
$r['name'] = substr($r['name'], 0, 66).'...';
$i++;
$xml.='
<Line>
<Line-Item>
<LineNumber>'.$i.'</LineNumber>
<EAN>'.trim($ean).'</EAN>
<BuyerItemCode>'.$r['recipient_code'].'</BuyerItemCode>
<SupplierItemCode>'.$r['code'].'</SupplierItemCode>
<ItemDescription>'.$r['name'].'</ItemDescription>
<ItemType>CU</ItemType>
<InvoiceQuantity>'.$r['quantity'].'</InvoiceQuantity>
<UnitOfMeasure>PCE</UnitOfMeasure>
<InvoiceUnitPacksize>1.000</InvoiceUnitPacksize>
<PackItemUnitOfMeasure>PCE</PackItemUnitOfMeasure>
<InvoiceUnitNetPrice>'.$r['subprice'].'</InvoiceUnitNetPrice>
<TaxRate>'.$r['ecmvat_value'].'</TaxRate>
<TaxCategoryCode>S</TaxCategoryCode>
<TaxAmount>'.round($r['total']-$r['subtotal'],2).'</TaxAmount>
<NetAmount>'.$r['subtotal'].'</NetAmount>
</Line-Item>
<Line-Order>
<BuyerOrderNumber>'.$order_no.'</BuyerOrderNumber>
<BuyerOrderDate>'.$r_so['register_date'].'</BuyerOrderDate>
</Line-Order>
<Line-Delivery>
<DeliveryLocationNumber>'.$prod_iln.'</DeliveryLocationNumber>
<DespatchNumber>'.$r_wz['document_no'].'</DespatchNumber>
<DeliveryDate>'.$register_date.'</DeliveryDate>
</Line-Delivery>
</Line>';
}
$xml.='</Invoice-Lines>
<Invoice-Summary>
<TotalLines>'.$i.'</TotalLines>
<TotalNetAmount>'.round($total_netto,2).'</TotalNetAmount>
<TotalTaxableBasis>'.round($total_netto,2).'</TotalTaxableBasis>
<TotalTaxAmount>'.round($total_vat,2).'</TotalTaxAmount>
<TotalGrossAmount>'.round(($total_netto+$total_vat),2).'</TotalGrossAmount>
<GrossAmountInWords>'.EcmInvoiceOutOld::slowniePL(number_format(($total_netto+$total_vat),2,",",".")).'</GrossAmountInWords>
<Tax-Summary>';
foreach($vats as $vat){
$xml.='
<Tax-Summary-Line>
<TaxRate>'.$vat.'</TaxRate>
<TaxCategoryCode>S</TaxCategoryCode>
<TaxAmount>'.round(($total_vat_arr[$vat]),2).'</TaxAmount>
<TaxableBasis>'.round(($total_netto_arr[$vat]),2).'</TaxableBasis>
<TaxableAmount>'.round(($total_netto_arr[$vat]),2).'</TaxableAmount>
<GrossAmount>'.round(($total_netto_arr[$vat]+$total_vat_arr[$vat]),2).'</GrossAmount>
</Tax-Summary-Line>';
}
$xml.='
</Tax-Summary>
</Invoice-Summary>
</Document-Invoice>';
return $xml;
}
function createCorrectInvoiceXml($id){
$r=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select *, TRIM(order_no) as o_no from ecminvoiceoutolds where id='".$id."'"));
$supplier_code=$r['supplier_code'];
$rr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select iln from accounts where id='".$r['parent_id']."'"));
$buyer_iln=$rr['iln'];
$rr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select account_id,account_number from ecmdocumenttemplates where id='".$r['template_id']."'"));
$seller_account_numer=$rr['account_number'];
$rr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select iln,name,id,sic_code,billing_address_street,billing_address_city,billing_address_postalcode,billing_address_country from accounts where id='".$rr['account_id']."'"));
$seller_iln=$rr['iln'];
$seller_id=$rr['id'];
$seller_name=$rr['name'];
$seller_nip=$rr['sic_code'];
$seller_street=$rr['billing_address_street'];
$seller_city=$rr['billing_address_city'];
$seller_postalcode=$rr['billing_address_postalcode'];
$seller_country=$rr['billing_address_country'];
$r_inv=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select wz_id,register_date from ecminvoiceoutolds where id='".$r['ecminvoiceoutold_id']."'"));
$r_wz=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select document_no,so_id,parent_id from ecmstockdocouts where id='".$r_inv['wz_id']."'"));
$r_so=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select register_date,parent_id, parent_shipping_address_name from ecmsales where id='".$r_wz['so_id']."'"));
if ($r_so['parent_shipping_address_name'] && $r_so['parent_shipping_address_name']!='')
$r_so_acc=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select iln from accounts where name like '".trim($r_so['parent_shipping_address_name'])."%'"));
if (!$r_so_acc || $r_so_acc['iln']=='') {
$r_so_acc=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select iln from accounts where id = '".trim($r_so['parent_id'])."'"));
}
$prod_iln=$r_so_acc['iln'];
if(strlen($r['currency_id'])<36)$currency=$r['currency_id'];
else{
$rr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select iso4217 from currencies where id='".$r['currency_id']."'"));
$currency=$rr['iso4217'];
}
$rr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select days from ecmpaymentconditions where id='".$r['ecmpaymentcondition_id']."'"));
$days=$rr['days'];
$rr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select document_no,register_date from ecminvoiceoutolds where id='".$r['ecminvoiceoutold_id']."'"));
$cor_name=$rr['document_no'];
$cor_date=$rr['register_date'];
if($r['parent_id']==134)$codebybuyer="";
else $codebybuyer=23862;
echo $r['o_no'].' - '.$r['document_no'].'<br>';
$xml='<Document-Invoice>
<Invoice-Header>
<InvoiceNumber>'.$r['document_no'].'</InvoiceNumber>
<InvoiceDate>'.$r['register_date'].'</InvoiceDate>
<SalesDate>'.$r['sell_date'].'</SalesDate>';
if($r['parent_id']==134)$xml.='<CorrectionReason>KOREKTA CENOWA LUB ILOSCIOWA</CorrectionReason>';
if($_REQUEST['duplicate']==1){
$xml.='<InvoiceDuplicateDate>'.date("Y-m-d").'</InvoiceDuplicateDate>';
$dfc="R";
}
else{
$dfc="C";
}
$xml.='<InvoiceCurrency>'.$currency.'</InvoiceCurrency>
<InvoicePaymentDueDate>'.$r['payment_date'].'</InvoicePaymentDueDate>
<InvoicePaymentTerms>'.$days.'</InvoicePaymentTerms>
<InvoicePostDate>'.$r['register_date'].'</InvoicePostDate>
<DocumentFunctionCode>'.$dfc.'</DocumentFunctionCode>
<Reference>
<InvoiceReferenceNumber>'.$cor_name.'</InvoiceReferenceNumber>
<InvoiceReferenceDate>'.$cor_date.'</InvoiceReferenceDate>
</Reference>
<Delivery>
<DeliveryLocationNumber>'.str_replace(" ","",$prod_iln).'</DeliveryLocationNumber>
<DespatchNumber>'.$r_wz['document_no'].'</DespatchNumber>
<DeliveryDate>'.$r_inv['register_date'].'</DeliveryDate>
</Delivery>
<Order>
<BuyerOrderNumber>'.trim($r['o_no']).'</BuyerOrderNumber>
<BuyerOrderDate>'.$r_so['register_date'].'</BuyerOrderDate>
</Order>
</Invoice-Header>
<Invoice-Parties>
<Buyer>
<ILN>'.str_replace(" ","",$buyer_iln).'</ILN>
<TaxID>'.str_replace("-","",$r['to_nip']).'</TaxID>
<Name>'.$r['parent_name'].'</Name>
<StreetAndNumber>'.$r['parent_address_street'].'</StreetAndNumber>
<CityName>'.$r['parent_address_city'].'</CityName>
<PostalCode>'.$r['parent_address_postalcode'].'</PostalCode>
<Country>PL</Country>
</Buyer>
<Seller>
<ILN>'.str_replace(" ","",$seller_iln).'</ILN>
<TaxID>'.str_replace("-","",$seller_nip).'</TaxID>
<AccountNumber>'.$seller_account_number.'</AccountNumber>
<Name>'.$seller_name.'</Name>
<StreetAndNumber>'.$seller_street.'</StreetAndNumber>
<CityName>'.$seller_city.'</CityName>
<PostalCode>'.$seller_postalcode.'</PostalCode>
<Country>PL</Country>
<CodeByBuyer>'.$codebybuyer.'</CodeByBuyer>
</Seller>
</Invoice-Parties>
<Invoice-Lines>';
$w=$GLOBALS[db]->query("select * from ecminvoiceoutolditems where deleted='0' and ecminvoiceoutold_id='".$id."'");
$i=0;
$total_netto=0;
$total_vat=0;
$total_netto_arr=array();
$vats=array();
while($r=$GLOBALS[db]->fetchByAssoc($w)){
$rr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select TRIM(ean) as ean from ecmproducts where id='".$r['ecmproduct_id']."'"));
$ean=trim($rr['ean']);
// bazujemy na old_ecminvoiceoutolditem_id, zero dynamicznych faktur
if (is_null ( $r ['old_ecminvoiceoutolditem_id'] ) || $r ['old_ecminvoiceoutolditem_id'] == '')
continue; // ten produkt nie był korygowany
$oi = $GLOBALS ['db']->fetchByAssoc ( $GLOBALS ['db']->query ( "SELECT quantity, subtotal, total, ecmvat_value, discount, dd_unit_id, subprice, price, ecmvat_value, ecmvat_name, ecmvat_id FROM ecminvoiceoutolditems WHERE id='" . $r ['old_ecminvoiceoutolditem_id'] . "'" ) );
$rrr = $oi;
$total_netto+=round($r['subtotal'],2);
$total_vat+=round($r['subtotal']*$r['ecmvat_value']/100,2);
$vats[$r['ecmvat_value']]=$r['ecmvat_value'];
$total_netto_arr[$r['ecmvat_value']]+=round($r['subtotal'],2);
$total_vat_arr[$r['ecmvat_value']]+=round($r['subtotal']*$r['ecmvat_value'],2);
$total_netto_c+=round($rrr['subtotal'],2);
$total_vat_c+=round($rrr['subtotal']*$rrr['ecmvat_value']/100,2);
$vats_c[$rrr['ecmvat_value']]=$rrr['ecmvat_value'];
$total_netto_arr_c[$rrr['ecmvat_value']]+=round($rrr['subtotal'],2);
$total_vat_arr_c[$rrr['ecmvat_value']]+=round($rrr['subtotal']*$rrr['ecmvat_value'],2);
if (strlen($r['name'])>=70)
$r['name'] = substr($r['name'], 0, 66).'...';
$i++;
$xml.='
<Line>
<Line-Item>
<LineNumber>'.$i.'</LineNumber>
<EAN>'.$ean.'</EAN>
<BuyerItemCode>'.$r['recipient_code'].'</BuyerItemCode>
<SupplierItemCode>'.$r['code'].'</SupplierItemCode>
<ItemDescription>'.$r['name'].'</ItemDescription>
<ItemType>CU</ItemType>
<InvoiceQuantity>'.$r['quantity'].'</InvoiceQuantity>
<UnitOfMeasure>PCE</UnitOfMeasure>
<InvoiceUnitPacksize>1.000</InvoiceUnitPacksize>
<InvoiceUnitNetPrice>'.round($r['subprice'],2).'</InvoiceUnitNetPrice>
<TaxRate>'.$r['ecmvat_value'].'</TaxRate>
<TaxCategoryCode>S</TaxCategoryCode>
<TaxReference>
<ReferenceType></ReferenceType>
<ReferenceNumber></ReferenceNumber>
</TaxReference>
<TaxAmount>'.round(($r['subtotal']*$r['ecmvat_value']/100),2).'</TaxAmount>
<NetAmount>'.round(($r['subtotal']),2).'</NetAmount>
<PreviousInvoiceQuantity>'.$rrr['quantity'].'</PreviousInvoiceQuantity>
<PreviousInvoiceUnitNetPrice>'.$rrr['subprice'].'</PreviousInvoiceUnitNetPrice>
<PreviousTaxRate>'.$rrr['ecmvat_value'].'</PreviousTaxRate>
<PreviousTaxCategoryCode>S</PreviousTaxCategoryCode>
<PreviousTaxAmount>'.round(($rrr['subtotal']*$rrr['ecmvat_value']/100),2).'</PreviousTaxAmount>
<PreviousNetAmount>'.round(($rrr['subtotal']),2).'</PreviousNetAmount>
<CorrectionInvoiceQuantity>'.($r['quantity']-$rrr['quantity']).'</CorrectionInvoiceQuantity>
<CorrectionInvoiceUnitNetPrice>'.($r['subprice']-$rrr['subprice']).'</CorrectionInvoiceUnitNetPrice>
<CorrectionTaxAmount>'.(round(($r['subtotal']*$r['ecmvat_value']/100),2)-round(($rrr['subtotal']*$rrr['ecmvat_value']/100),2)).'</CorrectionTaxAmount>
<CorrectionNetAmount>'.(round(($r['subtotal']),2)-round(($rrr['subtotal']),2)).'</CorrectionNetAmount>
</Line-Item>
<Line-Order>
<BuyerOrderNumber></BuyerOrderNumber>
<BuyerOrderDate></BuyerOrderDate>
</Line-Order>
<Line-Delivery>
<DeliveryLocationNumber></DeliveryLocationNumber>
<DeliveryDate></DeliveryDate>
<DespatchNumber></DespatchNumber>
</Line-Delivery>
</Line>';
}
$xml.='</Invoice-Lines>
<Invoice-Summary>
<TotalLines>'.$i.'</TotalLines>
<TotalNetAmount>'.round($total_netto,2).'</TotalNetAmount>
<TotalTaxableBasis>'.round($total_netto,2).'</TotalTaxableBasis>
<TotalTaxAmount>'.round($total_vat,2).'</TotalTaxAmount>
<TotalGrossAmount>'.round(($total_netto+$total_vat),2).'</TotalGrossAmount>
<PreviousTotalNetAmount>'.round($total_netto_c,2).'</PreviousTotalNetAmount>
<PreviousTotalTaxableBasis>'.round($total_netto_c,2).'</PreviousTotalTaxableBasis>
<PreviousTotalTaxAmount>'.round($total_vat_c,2).'</PreviousTotalTaxAmount>
<PreviousTotalGrossAmount>'.round(($total_netto_c+$total_vat_c),2).'</PreviousTotalGrossAmount>
<CorrectionTotalNetAmount>'.round(($total_netto-$total_netto_c),2).'</CorrectionTotalNetAmount>
<CorrectionTotalTaxableBasis>'.round(($total_netto-$total_netto_c),2).'</CorrectionTotalTaxableBasis>
<CorrectionTotalTaxAmount>'.round(($total_vat-$total_vat_c),2).'</CorrectionTotalTaxAmount>
<CorrectionTotalGrossAmount>'.round((($total_netto+$total_vat)-($total_netto_c+$total_vat_c)),2).'</CorrectionTotalGrossAmount>
<GrossAmountInWords>'.str_replace("minus","",EcmInvoiceOutOld::slowniePL(number_format(($total_netto+$total_vat),2,",","."))).'</GrossAmountInWords>';
$xml.='<Tax-Summary>';
foreach($vats as $vat){
$xml.='
<Tax-Summary-Line>
<TaxRate>'.$vat.'</TaxRate>
<TaxCategoryCode>S</TaxCategoryCode>
<TaxAmount>'.round(($total_netto_arr[$vat]*$vat/100),2).'</TaxAmount>';
//<TaxableBasis>'.round(($total_netto_arr[$vat]),2).'</TaxableBasis>
$xml.='<TaxableAmount>'.round(($total_netto_arr[$vat]),2).'</TaxableAmount>';
//<GrossAmount>'.(round(($total_netto_arr[$vat]*$vat/100),2)+round(($total_netto_arr[$vat]),2)).'</GrossAmount>
$xml.='<PreviousTaxRate>'.$vat.'</PreviousTaxRate>
<PreviousTaxCategoryCode>S</PreviousTaxCategoryCode>
<PreviousTaxAmount>'.round(($total_netto_arr_c[$vat]*$vat/100),2).'</PreviousTaxAmount>
<PreviousTaxableAmount>'.round(($total_netto_arr_c[$vat]),2).'</PreviousTaxableAmount>
<CorrectionTaxAmount>'.round(round(($total_netto_arr[$vat]*$vat/100),2)-round(($total_netto_arr_c[$vat]*$vat/100),2),2).'</CorrectionTaxAmount>
<CorrectionTaxableAmount>'.round(round($total_netto_arr[$vat],2)-round($total_netto_arr_c[$vat],2),2).'</CorrectionTaxableAmount>
</Tax-Summary-Line>';
}
$xml.='
</Tax-Summary>
</Invoice-Summary>
</Document-Invoice>';
return $xml;
}
?>

View File

@@ -0,0 +1,16 @@
<?
include_once("modules/EcmInvoiceOutOlds/maksymaXML.php");
$mXML = new maksymaXML($_GET['date']);
$mXML->getInvoices();
$mXML->getCorrectInfoices();
$mXML->getXML();
die();
header('Content-type: application/xml');
header('Content-Disposition: attachment; filename="decree.xml"');
$file="cache/upload/decree".str_replace(" ","_",str_replace(".","_",microtime())).".xml";
fopen($file);
file_put_contents($file,createDecree($exp[0],$exp[1]));
chmod($file,0777);
header("Location: ".$file);
?>

View File

@@ -0,0 +1,29 @@
<?
//error_reporting(E_ALL);
include_once("modules/EcmInvoiceOutOlds/createXML.php");
//header('Content-type: application/xml');
//header('Content-Disposition: attachment; filename="invoice.xml"');
$file="cache/upload/invoice_xml_".str_replace(" ","_",str_replace(".","_",microtime())).".xml";
fopen($file);
$r=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select type,document_no from ecminvoiceoutolds where id='".$_GET['record']."'"));
if($r['type']=="correct")$xml=createCorrectInvoiceXml($_GET['record']);
else $xml=createInvoiceXml($_GET['record']);
file_put_contents($file,$xml);
chmod($file,0777);
//header("Location: ".$file);
if($_REQUEST['duplicate']){
$r['document_no']=str_replace("FV","FVDUP",$r['document_no']);
}
header("Pragma: public");
header("Cache-Control: maxage=1, post-check=0, pre-check=0");
header("Content-type: application/force-download");
header("Content-Length: " . filesize($file));
header("Content-disposition: attachment; filename=\"".str_replace(" ","",str_replace("/","",$r['document_no'])).".xml\";");
header("Expires: 0");
set_time_limit(0);
@ob_end_clean();
ob_start();
echo file_get_contents($file);
@ob_flush();
?>

View File

@@ -0,0 +1,294 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*****************************************************************************
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
* Version 1.1 ("License"); You may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/rpl.php. Software distributed under the
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
* either express or implied.
*
* You may:
* a) Use and distribute this code exactly as you received without payment or
* a royalty or other fee.
* b) Create extensions for this code, provided that you make the extensions
* publicly available and document your modifications clearly.
* c) Charge for a fee for warranty or support or for accepting liability
* obligations for your customers.
*
* You may NOT:
* a) Charge for the use of the original code or extensions, including in
* electronic distribution models, such as ASP (Application Service
* Provider).
* b) Charge for the original source code or your extensions other than a
* nominal fee to cover distribution costs where such distribution
* involves PHYSICAL media.
* c) Modify or delete any pre-existing copyright notices, change notices,
* or License text in the Licensed Software
* d) Assert any patent claims against the Licensor or Contributors, or
* which would in any way restrict the ability of any third party to use the
* Licensed Software.
*
* You must:
* a) Document any modifications you make to this code including the nature of
* the change, the authors of the change, and the date of the change.
* b) Make the source code for any extensions you deploy available via an
* Electronic Distribution Mechanism such as FTP or HTTP download.
* c) Notify the licensor of the availability of source code to your extensions
* and include instructions on how to acquire the source code and updates.
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
* reproduce, perform, modify, sublicense, and distribute your extensions.
*
* The Original Code is: CommuniCore
* Olavo Farias
* 2006-04-7 olavo.farias@gmail.com
*
* The Initial Developer of the Original Code is CommuniCore.
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
* All Rights Reserved.
********************************************************************************/
$fields_array['EcmInvoiceOutOld'] = array (
'column_fields' => Array (
'id',
'name',
'description',
'date_entered',
'date_modified',
'deleted',
'modified_user_id',
'assigned_user_id',
'created_by',
//NEW COLUMN FIELDS
'number',
'parent_type',
'parent_name',
'parent_id',
'type',
'ecminvoiceoutold_id',
'ecminvoiceoutold_name',
'status',
'register_date',
'sell_date',
'payment_date',
'parent_address_street',
'parent_address_city',
'parent_address_postalcode',
'parent_address_country',
'subtotal',
'total',
'discount',
'to_vatid',
'to_nip',
'ecmlanguage',
'to_is_vat_free',
'header_text',
'footer_text',
'ads_text',
'template_id',
'template_name',
'email_id',
'wz_id',
'order_no',
'delivery_place',
'supplier_code',
'ecmpaymentcondition_id',
'ecmpaymentcondition_name',
'ecmpaymentcondition_text',
'contact_id',
'contact_name',
'parent_name_copy',
'parent_contact_name',
'parent_contact_title',
'correct_reason',
'so_id',
),
'list_fields' => Array (
'number',
'document_no',
'parent_type',
'parent_name',
'parent_id',
'type',
'ecminvoiceoutold_id',
'ecminvoiceoutold_name',
'status',
'register_date',
'sell_date',
'payment_date',
'parent_address_street',
'parent_address_city',
'parent_address_postalcode',
'parent_address_country',
'subtotal',
'total',
'discount',
'to_vatid',
'to_nip',
'ecmlanguage',
'to_is_vat_free',
'header_text',
'footer_text',
'ads_text',
'template_id',
'template_name',
'email_id',
'wz_id',
'ecmpaymentcondition_id',
'ecmpaymentcondition_name',
'ecmpaymentcondition_text',
'contact_id',
'contact_name',
'parent_name_copy',
'parent_contact_name',
'parent_contact_title',
'correct_reason',
'so_id',
),
'required_fields' => array (
'number' => 1
),
);
?>

View File

@@ -0,0 +1,164 @@
function doRequest(where,post,doFunction,error) {
this.Display = function(result) { doFunction(result.responseText); }
this.Fail = function(result){ if(error) alert(error);}
YAHOO.util.Connect.asyncRequest('POST',where,{success:this.Display,failure:this.Fail},post);
}
function changeValidateRequired(formname,name,required) {
for(var i=0; i<validate[formname].length; i++)
if(validate[formname][i][0] == name) { validate[formname][i][2] = required; break; }
}
function my_popup(module, field_array, call_back_function, form_name) {
if(!call_back_function) call_back_function = "set_return";
if(!form_name) form_name = "EditView";
return open_popup(module, 900, 700, "", true, false, {"call_back_function":call_back_function,"form_name":form_name,"field_to_name_array":field_array});
}
function addEvent(object,eventName,do_function) {
if(typeof(object) == "string") object = document.getElementById(object);
if(!object) { alert('No object in function addEvent!'); return; }
if(object.addEventListener) {
object.addEventListener(eventName, do_function, false);
} else {
object.attachEvent('on'+eventName, do_function);
}
}
function FormLoader() {
this.module;
this.createModule;
this.fieldName;
this.buttonName = 'FormLoaderButton';
this.load = function(module,createModule,fieldName) {
this.module = module;
this.createModule = createModule;
this.fieldName = fieldName;
}
this.createButton = function() {
var b = document.createElement('input');
b.type = 'button';
b.className = 'button';
b.name = this.buttonName;
b.value = 'Create';
b.FL = this;
b.onclick = function() {
if(this.FL.createModule == '') return;
if(this.FL.onButtonClick) var data = this.FL.onButtonClick();
window.open("index.php?module="+this.FL.module+"&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName="+this.FL.fieldName+"&createModule="+this.FL.createModule+(data?data:''),"Create10"+this.FL.module,"resizable=yes,scrollbars=no,status=no,height=540,width=700").focus();
}
return b;
}
// this.setEditDblClick = function(edit) { edit.FL=this; edit.ondblclick=this.editDblClick; }
this.editDblClick = function() {
if(this.FL.createModule == '') return;
if(this.FL.onEditDblClick) var data = this.FL.onEditDblClick();
window.open("index.php?module="+this.FL.module+"&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName="+this.FL.fieldName+"&createModule="+this.FL.createModule+(data?data:''),"Create10"+this.FL.module,"resizable=yes,scrollbars=no,status=no,height=540,width=700").focus();
}
this.responseData = function(data) {
if(this.onResponseData) this.onResponseData(data);
}
this.onResponseData;
this.addPostData = function() {
if(this.onAddPostData)
return this.onAddPostData();
else
return '';
}
this.onAddPostData;
this.onButtonClick;
}

View File

@@ -0,0 +1,335 @@
<?php
$module = $_REQUEST['module'];
$cM = $_REQUEST['createModule'];
$lA = $_REQUEST['loaderAction'];
$fN = $_REQUEST['loaderFieldName'];
$record = $_REQUEST['record'];
if($lA == "EditView") {
ob_start();
$_REQUEST['module'] = $cM;
$_REQUEST['action'] = "EditView";
$_REQUEST['record'] = $record;
$_POST['module'] = $cM;
$_POST['action'] = "EditView";
$_POST['record'] = $record;
$_GET['record'] = $record;
include('index.php');
$out = ob_get_contents();
ob_end_clean();
echo $out;
return;
}
if($lA == "get_module_fields") {
global $beanList, $beanFiles;
$file = 'cache/modules/'.$cM.'/'.$beanList[$cM].'vardefs.php';
if(file_exists($file)) {
include($file);
$dict = $GLOBALS['dictionary'][$beanList[$cM]]['fields'];
}
else {
$file = 'modules/'.$cM.'/vardefs.php';
if(file_exists($file)) { include($file); $dict = $dictionary[$beanList[$cM]]['fields']; } else return;
}
$file = $beanFiles[$beanList[$cM]];
if(file_exists($file)) {
require_once($file);
$bean = new $beanList[$cM]();
$bean->retrieve($record);
if(isset($bean->id) && $bean->id != '') {
$arr = array();
foreach($dict as $key => $value) {
if(isset($bean->$value['name']) && (is_string($bean->$value['name']) || is_float($bean->$value['name']) || is_int($bean->$value['name']) || is_bool($bean->$value['name'])))
$arr[$value['name']] = $bean->$value['name'];
}
$json = getJSONobj();
echo '['.str_replace('&quot;','\"',$json->encode($arr)).']';
} else return;
}
return;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<title></title>
<script type="text/javascript" src="include/javascript/sugar_grp1_yui.js?s=5.0.0c&c="></script>
</head>
<body>
<div id="hidder" style="position:absolute;left:0;top:0;width:105%;height:100%;background-color:white;visibility:visible;text-align:center;padding:40px;"><img src="themes/default/images/loading.gif"/></div>
<script language="javascript">
function doRequest(where,post,success,error) {
this.Display = function(result) { success(result.responseText); }
this.Fail = function(result){ if(error) error(result); }
YAHOO.util.Connect.asyncRequest('POST',where,{success:this.Display,failure:this.Fail},post);
}
function iframeLoad() {
var frame = document.getElementById("input_create");
var doc = frame.contentDocument;
if(typeof(doc) == "undefined" || !doc)
doc = frame.contentWindow.document;
//alert(doc.forms.DetailView);
if(doc && doc.forms && ((doc.forms.EditView || doc.forms.DetailView || doc.forms.Save) || doc.return_module_fields)) {
if(doc.forms.EditView) {
} else
if(doc.forms.DetailView) {
var record = doc.forms.DetailView.record;
if(record && record.value != "") {
doRequest(
"index.php",
"module="+module+"&action=formloader&loaderAction=get_module_fields&createModule="+cM+"&to_pdf=1&record="+record.value,
function(result) {
if(result == '')
window.close();
else {
var obj = eval(result);
if(obj) {
obj = obj[0];
eval('window.opener.'+fN+'.responseData(obj)');
}
window.close();
}
},
function(result) {
window.close();
}
);
} else window.close();
} else
if(doc.forms.Save) {
}
} else { window.close(); return; }
var main = doc.getElementById('main');
if(main) {
var dd = doc.createElement('div');
dd.innerHTML = '<table style="width:100%;"><tr id="main2"></tr></table>';
doc.body.insertBefore(dd,doc.body.firstChild);
doc.getElementById('main2').appendChild(main);
main.style.position = 'absolute';
main.style.left = 0;
main.style.top = 0;
for(var i=1; i<doc.body.childNodes.length; i++) if(doc.body.childNodes[i] !== main && doc.body.childNodes[i].style) {
doc.body.childNodes[i].style.visibility = 'hidden';
}
if(doc && doc.forms && !doc.forms.DetailView) doc.body.FormLoader = true;
}
}
var oldLocation = '';
setInterval(function(){
var frame = document.getElementById("input_create");
if(frame) {
var doc = frame.contentDocument;
if(doc == undefined || doc == null)
doc = frame.contentWindow.document;
if(doc && doc.body && doc.body.FormLoader) {
if(hidder.style.visibility = "visible") hidder.style.visibility = "hidden";
} else {
if(hidder.style.visibility = "hidden") hidder.style.visibility = "visible"
}
}
},60);
</script>
<?php
if($lA == "ViewForm") {
echo '<script language="javascript">
var module = "'.$module.'";
var cM = "'.$cM.'";
var lA = "'.$lA.'";
var fN = "'.$fN.'";
</script>';
$data = '';
foreach($_REQUEST as $key=>$value) {
if(strpos($key,"fl_") === 0) {
$data .= "&".substr($key,3)."=".$value;
}
}
echo "<iframe onload='iframeLoad();' frameborder='no' width='100%' height='100%' id='input_create' name='input_create' src='index.php?module=$module&action=formloader&to_pdf=1&loaderAction=EditView&createModule=$cM".$data."'></iframe>";
}
?>
</body>
</html>

View File

@@ -0,0 +1,23 @@
<?php
require_once('modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php');
$focus = new EcmInvoiceOutOld();
if(isset($_REQUEST['generate']) && $_REQUEST['generate'] == '1') {
try {
if(isset($_REQUEST['record']) && $_REQUEST['record'] != '') $focus->retrieve($_REQUEST['record']);
$focus->template_id = $_REQUEST['template_id'];
$focus->type = $_REQUEST['type'];
$focus->setTemplate();
$arr = array();
$arr['number'] = (isset($focus->id) && $focus->id != '') ? $focus->number : $focus->generateNumber("ecminvoiceoutolds","numer");
$arr['document_no'] = $focus->formatNumber();
if($_REQUEST['type']=="correct"){
$arr['number'] = (isset($focus->id) && $focus->id != '') ? $focus->number : $focus->generateNumberCorrect();
$arr['document_no'] = $focus->formatNumberCorrect();
}
}
catch (Exception $e) { echo ''; return; }
$json = getJSONobj();
echo '['.$json->encode($arr).']';
return;
}
?>

View File

@@ -0,0 +1,4 @@
<?php
include 'PDFMerger.php';
$pdf = new PDFMerger;
$pdf

View File

@@ -0,0 +1,66 @@
<?php
//get formatted name and email from account by id
function getFormattedEmailFromAccounById($id) {
if(!isset($id) || $id == '') return false;
require_once('modules/Accounts/Account.php');
$acc = new Account();
$acc->retrieve($id);
if(isset($acc->id) && $acc->id != '') {
return $acc->name.' <'.$acc->email1.'>; ';
}
return '';
}
//get formatted name and email from user
function getFormattedEmailFromUserId($id) {
if(!isset($id) || $id == '') return false;
require_once('modules/Users/User.php');
$us = new User();
$us->retrieve($id);
if(isset($us->id) && $us->id != '') {
return $us->full_name.' <'.$us->email1.'>; ';
}
return '';
}
//get info from module by Id
function getInfoFromModuleById($module, $id, $arr = '') {
if(!isset($id) || $id == '') return false;
global $beanFiles, $beanList;
require_once($beanFiles[$beanList[$module]]);
$bean = new $beanList[$module]();
$bean->retrieve($id);
if(isset($bean->id) && $bean->id != '') {
$arr = explode('|', $arr);
$tmp = array();
for($i=0; $i<count($arr); $i++)
$tmp[$arr[$i]] = htmlspecialchars_decode($bean->$arr[$i]);
$json = getJSONobj();
return '['.$json->encode($tmp).']';
}
return '';
}
if(isset($_REQUEST['data']) && $_REQUEST['data'] == 'EFA' && isset($_REQUEST['id']) && $_REQUEST['id'] != '')
echo getFormattedEmailFromAccounById($_REQUEST['id']);
if(isset($_REQUEST['data']) && $_REQUEST['data'] == 'EFAUID' && isset($_REQUEST['id']) && $_REQUEST['id'] != '')
echo getFormattedEmailFromUserId($_REQUEST['id']);
if(isset($_REQUEST['gdData']) && $_REQUEST['gdData'] != '' && isset($_REQUEST['gdId']) && $_REQUEST['gdId'] != '' && isset($_REQUEST['gdData']) && $_REQUEST['gdData'] != '')
echo getInfoFromModuleById($_REQUEST['gdModule'],$_REQUEST['gdId'],$_REQUEST['gdData']);
?>

View File

@@ -0,0 +1,42 @@
<?php
include_once("modules/EcmInvoiceOutOlds/createXML.php");
//echo createCorrectInvoiceXml('887312d1-c5a3-7405-cb13-529c845fe5a5');
//return;
$db = $GLOBALS['db'];
$document_no = array();
$type = 'correct';
$res = $db->query("SELECT id, parent_name, document_no, date_entered FROM ecminvoiceoutolds where type='$type' and parent_name like 'Real%' and register_date>='2014-01-01' and document_no NOT IN (SELECT nr_faktury FROM nr_faktury) AND canceled='0' ORDER BY register_date");
//$res = $db->query("SELECT id, parent_name, document_no, date_entered FROM ecminvoiceoutolds where type='correct' and parent_name like 'Real%' and document_no in ('FVKOR 853/14')");
$i =0;
echo $res->num_rows.'<br>';
//die();
while ($row = $db->fetchByAssoc($res)) {
echo $row['parent_name'].' '.$row['document_no'].' '.$row['date_entered'].'<br>';
$i++;
$inv = new EcmInvoiceOutOld();
$inv->retrieve($row['id']);
if ($type == 'normal')
$xml=createInvoiceXml($inv->id);
if ($type == 'correct')
$xml=createCorrectInvoiceXml($inv->id);
//die();
//continue;
$file="/home/mz/edi/infinite-salesorders/invoice/".str_replace(" ","",str_replace("/","",$inv->document_no)).".xml";
fopen($file);
file_put_contents($file,$xml);
chmod($file,0777);
unset($inv);
}
echo '<br>'.$i.'<br>';
return;
?>

View File

@@ -0,0 +1,5 @@
<?php
$db = $GLOBALS['db'];
$r=$db->fetchByAssoc($db->query("select days from ecmpaymentconditions where id='".$_REQUEST['id']."'"));
echo date("d.m.Y",@mktime(0,0,0,$_REQUEST['month'],$_REQUEST['day'],$_REQUEST['year'])+3600*24*$r['days']);
?>

View File

@@ -0,0 +1,14 @@
<?php
if (!$_REQUEST['product_id']) {echo 'error'; return;}
$info = array();
$row = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT type FROM ecmproducts WHERE id='".trim($_REQUEST['product_id'])."'"));
if($row) {
$info[] = $row;
} else {echo 'no'; return;}
$json = getJSONobj();
echo str_replace(",", '.', $json->encode($info));
?>

View File

@@ -0,0 +1,36 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
echo '
<script language="javascript" src="modules/EcmProducts/helper.js"></script>
<script language="javascript">
function showDiv(obj,value,inv_id){
var div=document.getElementById("div_desc");
document.getElementById("desc").value="";
document.getElementById("desc").value=document.getElementById("desc"+inv_id).value;
document.getElementById("inv_id").value=inv_id;
div.style.display="";
var x=findPosX(obj);
var y=findPosY(obj);
moveDiv(div,y,(x+10));
}
</script>';
echo '<div id="div_desc" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;text-align:center;position:absolute;display:none;">';
echo '<textarea id="desc1" name="desc1" style="display:none;"></textarea><br />';
echo '<textarea id="desc" name="desc"></textarea><br />';
echo '<div id="result" style="display:none;"></div>';
echo '<input type="hidden" id="inv_id" />';
echo '<input type="button" class="button" value="Save" onclick="mintajaxget(\'index.php?to_pdf=1&module=EcmPaymentStates&action=saveDesc&id=\'+document.getElementById(\'inv_id\').value+\'&desc=\'+document.getElementById(\'desc\').value,\'desc\'+document.getElementById(\'inv_id\').value);" />&nbsp;';
echo '<input type="button" class="button" value="Close" onclick="document.getElementById(\'div_desc\').style.display=\'none\';" />';
echo '</div>';
echo '<script type="text/javascript" src="cache/jsLanguage/EcmCalls/'.$current_language.'.js"></script>';
echo '<img id="EcmCalls_image_assign" src="modules/EcmCalls/images/assign_call.gif" style="display:none;" />';
echo '<img id="EcmCalls_image_search" src="modules/EcmCalls/images/search_call.gif" style="display:none;" />';
echo '<script type="text/javascript" src="include/JSON.js"></script>';
echo '<script type="text/javascript" src="modules/EcmCalls/Hint.js"></script>';
echo '<script language="javascript" src="modules/EcmCalls/DoCall.js"></script>';
echo '<script language="javascript" src="modules/EcmCalls/ListView.js"></script>';
echo '<link rel="stylesheet" type="text/css" href="modules/EcmCalls/Hint.css" />';
require_once('modules/EcmInvoiceOutOlds/ListView.php');
?>

View File

@@ -0,0 +1 @@
Wybierz miesiąc do dekretu <input type="date" value="<? echo date("Y-m");?>" name="date_decree" id="date_decree" /><input class="button" type="button" value="Utwórz dekter" onclick="window.open('index.php?module=EcmInvoiceOutOlds&to_pdf=1&action=downloadDecree&date='+document.getElementById('date_decree').value,'_blank');" target="_blank" />

View File

@@ -0,0 +1,297 @@
<?php
if (!defined('sugarEntry') || !sugarEntry)
die('Not A Valid Entry Point');
/* * ***************************************************************************
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
* Version 1.1 ("License"); You may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/rpl.php. Software distributed under the
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
* either express or implied.
*
* You may:
* a) Use and distribute this code exactly as you received without payment or
* a royalty or other fee.
* b) Create extensions for this code, provided that you make the extensions
* publicly available and document your modifications clearly.
* c) Charge for a fee for warranty or support or for accepting liability
* obligations for your customers.
*
* You may NOT:
* a) Charge for the use of the original code or extensions, including in
* electronic distribution models, such as ASP (Application Service
* Provider).
* b) Charge for the original source code or your extensions other than a
* nominal fee to cover distribution costs where such distribution
* involves PHYSICAL media.
* c) Modify or delete any pre-existing copyright notices, change notices,
* or License text in the Licensed Software
* d) Assert any patent claims against the Licensor or Contributors, or
* which would in any way restrict the ability of any third party to use the
* Licensed Software.
*
* You must:
* a) Document any modifications you make to this code including the nature of
* the change, the authors of the change, and the date of the change.
* b) Make the source code for any extensions you deploy available via an
* Electronic Distribution Mechanism such as FTP or HTTP download.
* c) Notify the licensor of the availability of source code to your extensions
* and include instructions on how to acquire the source code and updates.
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
* reproduce, perform, modify, sublicense, and distribute your extensions.
*
* The Original Code is: CommuniCore
* Olavo Farias
* 2006-04-7 olavo.farias@gmail.com
*
* The Initial Developer of the Original Code is CommuniCore.
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
*
* All Rights Reserved.
* ****************************************************************************** */
$mod_strings = array(
'LBL_PDF_DOCUMENT_NAME_CORRECT_TO' => 'Correct to',
'LBL_PDF_CORRECT_REASON' => 'Complain note',
//mh 21-03-13
'LBL_PDF_INDEX_DBF'=> 'Counterparty index',
//
'LBL_CURRENCY_VALUE_NBP' => 'Kurs NBP',
'LBL_PDF_SITE' => 'Page',
'LBL_PDF_FOOTER_DOCUMENT_NAME' => 'Invoice',
//
'LBL_PDF_PAYMENT_METHOD_PATTERN' => 'in <b>%s</b> days until <b>%s</b> <b>%s</b>',
'LBL_PDF_INVOICE' => 'Faktura',
//
'LBL_TO_PAYMENTS' => 'Payments',
'LBL_PDF_INVOICE' => 'Invoice',
// Position list.
'LBL_PDF_LIST_POSITION' => '#',
'LBL_PDF_LIST_DESCRIPTION' => 'Name',
'LBL_PDF_LIST_INDEX' => 'Index',
'LBL_PDF_LIST_QUANTITY' => 'Quantity',
'LBL_PDF_LIST_UNIT' => 'Unit',
'LBL_PDF_LIST_UNIT_PRICE' => 'Price netto',
'LBL_PDF_LIST_UNIT_PRICE_TOTAL' => 'Total netto',
'LBL_PDF_LIST_DISCOUNT' => 'Discount (%)',
'LBL_PDF_LIST_VAT_ID' => 'VAT (%)',
'LBL_PDF_LIST_VAT_VALUE' => 'Total Vat',
'LBL_PDF_LIST_TOTAL' => 'Total brutto',
// Summary list.
'LBL_PDF_LIST_VAT_RATE' => 'Rate (%)',
'LBL_PDF_LIST_NETTO_TOTAL' => 'Total netto',
'LBL_PDF_LIST_VAT_TOTAL' => 'Total VAT',
'LBL_PDF_LIST_BRUTTO_TOTAL' => 'Total brutto',
'LBL_PDF_LIST_SUMMARY_TOTAL' => 'Total',
'LBL_PDF_LIST_WEIGHT' => 'Weight',
'LBL_PDF_LIST_COUNTRY_OF_ORIGIN' => 'Country of origin',
//
'LBL_PDF_PREPAID_DOCUMENTS' => 'Prepaid documents',
'LBL_PDF_PREPAID' => 'Prepaid',
//
'LBL_PDF_PAID' => 'Paid',
'LBL_PDF_DELIVERY' => 'Delivery',
'LBL_PDF_SELLER' => 'Seller',
'LBL_PDF_BUYER' => 'Buyer',
//
'LBL_CURRENCY_VALUE' => 'Currency value',
'LBL_PARENT_SHIPPING_ADDRESS' => 'Shipping address',
'LBL_PDF_TYPE' => 'Pdf type',
'LBL_STOCK_NAME' => 'Stock',
'LBL_PARENT_INDEX_DBF' => 'Index',
'LBL_PDF_DATE_REGISTER' => 'Register date',
'LBL_PDF_DATE_SELL' => "Selling date",
'LBL_PDF_ORDER_NO' => 'Order No',
// 080313 mh
'SERVICE_INVOICE_NAME' => 'Faktura zamówienia serwisowego %s',
//
//added 27.04.2010
'LBL_CORRECT_REASON' => 'Correct Reason',
//added 26.11.2009
'LBL_EDITTABLE_RECIPIENT_CODE' => 'Rec. Code',
'LBL_EDITTABLE_STOCK' => 'Stock',
'LBL_SUPPLIER_CODE' => 'Supplier Code',
'LBL_ORDER_NO' => 'Order No',
'LBL_DELIVERY_PLACE' => 'Delivery Place',
//added 05.08.2009
'LBL_DETAIL_BUTTON' => 'Details',
'LBL_LIST_PREVIEW_PDF' => 'Preview PDF',
'LBL_LIST_DUPLICATE' => 'Duplicate',
//added 20.07.2009
'LBL_CORRECT_TITLE' => 'Create Correct',
'LBL_CORRECT' => 'Create Correct',
//added 30.06.2009
'LBL_PDF_TO_WZ' => 'WZ Document',
'LBL_PDF_PLACE_OF_REGISTER' => 'Place of register',
'LBL_PDF_NIP' => 'Vat ID',
'LBL_TO_NIP' => 'Vat ID',
'LBL_PDF_SELL_DATE' => 'Sell Date',
'LBL_PDF_LIST_VAT_VALUE' => 'Vat value',
'LBL_PDF_LIST_TOTAL_PRICE' => 'Total Netto',
'LBL_PDF_LIST_TAX_CODE' => 'Tax Code',
'LBL_SELECT' => 'select',
'LBL_EDITTABLE_TAXCODE' => 'Tax Code',
'LBL_EDITTABLE_UNIT' => 'Unit',
//added 05.06.2009
'LBL_PDF_PAYMENT_METHOD' => 'Payment method',
'LBL_PDF_PAYMENT_TERMIN' => 'Payment date',
'LBL_PDF_DAYS' => 'Day(s)',
'LBL_PDF_TO_PAID' => 'To paid:',
'LBL_PDF_TO_PAID_BACK' => 'To paid back:',
'LBL_PDF_TOTAL_BY_WORD' => 'Total by word:',
'LBL_PDF_OWNER_SIGNATURE' => 'Owner signature:',
'LBL_PDF_RECEIVER_SIGNATURE' => 'Receiver signature:',
'LBL_PDF_ORIGINAL_COPY' => 'ORIGINAL / COPY',
'LBL_PDF_DOCUMENT_BEFORE_CORRECT' => 'Before correct:',
'LBL_PDF_DOCUMENT_AFTER_CORRECT' => 'After correct:',
//added 02.04.2009
'LBL_ECMSTOCKDOCOUTS_SUBPANEL_TITLE' => 'WZ Documents',
// FOR SYSTEM USE
'LBL_MODULE_NAME' => 'Invoices',
'LBL_MODULE_TITLE' => 'Invoices: Home',
'LBL_MODULE_ID' => 'EcmInvoices',
'LBL_SEARCH_FORM_TITLE' => 'Invoices Search',
'LBL_LIST_FORM_TITLE' => 'Invoices List',
'LBL_NEW_FORM_TITLE' => 'New Invoice',
'LBL_DETAILS' => 'Invoice details:',
'LBL_ITEMS' => 'Items included:',
'LBL_TEXTS' => 'Texts to PDF:',
'LBL_PREVIEW' => 'Preview PDF:',
'LBL_EMAIL' => 'Create Email:',
'LBL_TO_INFORMATIONS' => 'To Informations:',
'LBL_DETAILS_TAB' => 'Details',
'LBL_ITEMS_TAB' => 'Items',
'LBL_TEXTS_TAB' => 'Texts',
'LBL_PREVIEW_TAB' => 'Preview',
'LBL_EMAIL_TAB' => 'Email',
'LBL_ID' => 'Id',
'LBL_NAME' => 'Name',
'LBL_DESCRIPTION' => 'Description',
'LBL_DATE_ENTERED' => 'Date Entered',
'LBL_DATE_MODIFIED' => 'Date Modified',
'LBL_MODIFIED' => 'Last Modified',
'LBL_ASSIGNED_TO_ID' => 'Assigned To',
'LBL_ASSIGNED_TO' => 'Assigned To',
'LBL_CREATED' => 'Created by',
'LBL_CREATED_BY_USER' => 'Created by',
'LBL_MODIFIED_BY_USER' => 'Modified by',
'LBL_ASSIGNED_TO_USER' => 'Assigned To',
'LBL_DELETED_BY' => 'Deleted by',
'LBL_NUMBER' => 'Number',
'LBL_DOCUMENT_NO' => 'Number',
'LBL_PARENT' => 'To',
'LBL_PARENT_NAME' => 'To',
'LBL_PARENT_ID' => 'To Id',
'LBL_TYPE' => 'Type',
'LBL_ECMINVOICEOUTOLD_ID' => 'Correct Id',
'LBL_ECMINVOICEOUTOLD_NAME' => 'Invoice to Correct',
'LBL_STATUS' => 'Status',
'LBL_REGISTER_DATE' => 'Document Date',
'LBL_SELL_DATE' => 'Sell Date',
'LBL_PAYMENT_DATE' => 'Payment Date',
'LBL_PARENT_ADDRESS_STREET' => 'Street',
'LBL_PARENT_ADDRESS_CITY' => 'City',
'LBL_PARENT_ADDRESS_POSTALCODE' => 'Postalcode',
'LBL_PARENT_ADDRESS_COUNTRY' => 'Country',
'LBL_TO_VATID' => 'VAT-ID',
'LBL_TO_IS_VAT_FREE' => 'Is VAT Free?',
'LBL_HEADER_TEXT' => 'Header Text',
'LBL_FOOTER_TEXT' => 'Footer Text',
'LBL_ADS_TEXT' => 'Ads Text',
'LBL_SUBTOTAL' => 'Subtotal',
'LBL_TOTAL' => 'Total',
'LBL_DISCOUNT' => 'Discount',
'LBL_VAT' => 'VAT',
'LBL_ACCEPTED' => 'Accepted',
'LBL_TEMPLATE_ID' => 'Template Id',
'LBL_TEMPLATE_NAME' => 'Template',
'LBL_PAYMENTCONDITION_NAME' => 'Payment Condition',
'LBL_PAYMENTCONDITION_ID' => 'Payment Condition ID',
'LBL_FORMAT_NUMBER_ERROR' => 'Format Number Error!',
'LBL_SAVE_FORM_ERROR' => 'There are some errors on items list or in form!',
'LBL_DISCOUNT_ERROR' => 'Discount Format Number Error',
'LBL_EDITTABLE_NO' => 'Lp.',
'LBL_EDITTABLE_CODE' => 'Code',
'LBL_EDITTABLE_NAME' => 'Name',
'LBL_EDITTABLE_QUANTITY' => 'Quant',
'LBL_EDITTABLE_PRICE' => 'Price',
'LBL_EDITTABLE_VAT' => 'VAT',
'LBL_EDITTABLE_DISCOUNT' => 'Discount',
'LBL_EDITTABLE_TOTAL' => 'Total',
'LBL_EDITTABLE_OPTIONS' => 'Opt',
'LBL_MOVE_ROW_UP' => 'Move Up',
'LBL_MOVE_ROW_DOWN' => 'Move Down',
'LBL_INSERT_NEW_ROW' => 'Insert new row',
'LBL_DELETE_ROW' => 'Delete row',
// FOR MENU LINKS
'LNK_NEW_ECMINVOICEOUTOLD' => 'Create Invoice',
'LNK_ECMINVOICEOUTOLDS_LIST' => 'Invoices List',
'LBL_IMG_SEARCH' => 'Search',
'LBL_IMG_NEW' => 'New, add to base',
'LBL_IMG_EDIT' => 'Edit',
'LBL_CONFIRM_QUESTION' => 'Would you like to confirm this Invoice?',
'LBL_INVOICEOUT_PDF' => 'Show PDF',
'LBL_INVOICEOUT_PDF_BUTTON_KEY' => 'Show PDF [Alt+P]',
'LBL_INVOICEOUT_PDF_BUTTON_TITLE' => 'Show Invoice in PDF file.',
'LBL_INVOICEOUT_TO_INVOICE' => 'Make Invoice',
'LBL_INVOICEOUT_TO_INVOICE_BUTTON_KEY' => 'Make Invoice [Alt+I]',
'LBL_INVOICEOUT_TO_INVOICE_BUTTON_TITLE' => 'Make Invoice From Invoice.',
'LBL_LIST_TO_INVOICE' => 'Make Invoice From Invoice.',
//buttons
'LBL_SEND_BUTTON_TITLE' => 'Save & Send [Alt+D]',
'LBL_SEND_BUTTON_KEY' => 'D',
'LBL_SEND_BUTTON_LABEL' => 'Save & Send',
'LBL_REPAIR_BUTTON_TITLE' => 'Repair [Alt+R]',
'LBL_REPAIR_BUTTON_KEY' => 'R',
'LBL_REPAIR_BUTTON_LABEL' => 'Repair',
'LBL_GO_TO_LIST_BUTTON_TITLE' => 'Go to invoices list [Alt+G]',
'LBL_GO_TO_LIST_BUTTON_KEY' => 'G',
'LBL_GO_TO_LIST_BUTTON_LABEL' => 'Go to list',
'LBL_NOT_SAVED' => 'Invoice not saved. Please check all fields are correct!',
'LBL_SAVED' => 'Invoice saved successfully.',
'LBL_DEFAULT_CONTACT_HEADER_TEXT' => 'Witaj $contact_full_name!',
'LBL_DEFAULT_CONTACT_FOOTER_TEXT' => 'Tekst pod tabelka dla Contact',
'LBL_DEFAULT_CONTACT_ADS_TEXT' => 'Tekst pogrubiony pod tabelka dla Contact',
'LBL_DEFAULT_ACCOUNT_HEADER_TEXT' => 'Faktura dla $account_name.',
'LBL_DEFAULT_ACCOUNT_FOOTER_TEXT' => 'Tekst pod tabelka dla Account',
'LBL_DEFAULT_ACCOUNT_ADS_TEXT' => 'Tekst pogrubiony pod tabelka dla Account',
'LBL_NOTES_SUBPANEL_TITLE' => 'Notes',
'LBL_EMAILS_SUBPANEL_TITLE' => 'Emails',
'LBL_DASHLET_MY_ECMINVOICEOUTOLDS' => 'Invoices',
'LBL_PDF_TOTAL' => 'Total',
'LBL_PDF_DISCOUNT' => 'RABAT',
'LBL_PDF_END_TOTAL' => 'Total',
'LBL_PDF_VAT' => 'VAT',
'LBL_PDF_VATID' => 'VAT-ID',
'LBL_PDF_NUMBER' => 'Numer',
'LBL_PDF_OWNER' => 'Wystawil',
'LBL_PDF_DOCUMENT_NAME' => 'Faktura',
'LBL_PDF_DOCUMENT_NAME_CORRECT' => 'Correct',
'LBL_PDF_DOCUMENT_NAME_CORRECT_TO' => 'To invoice nr',
'LBL_PDF_CODE' => '',
'LBL_PDF_FILENAME' => 'Invoice_',
'LBL_PDF_DOCUMENT_AFTER_CORRECT' => 'Po korekcie: ',
'LBL_PDF_DOCUMENT_BEFORE_CORRECT' => 'Przed korekta: ',
'LBL_PDF_DOCUMENT_CORRECT_DIFFERENCE' => 'R<>znica: ',
'LNK_ECMINVOICEOUTOLDS_PDFLANGUAGES' => 'PDF Languages',
'LBL_ECMLANGUAGE' => 'Language',
'LBL_ZAM_NUM' => 'Order number e5',
'LBL_ZAM_KL' => 'Customer order',
'LBL_ZAM_DAT' => 'Date of order',
'LBL_ECMINVOICEOUTOLDS_PDFLANGUAGES_TITLE' => 'PDF Languages Settings',
'LBL_DEMO_VERSION_INFORMATION' => "This is only demo version.\nPlease contact us at ca@more7.com.",
'LBL_SENDEMAIL_BUTTON' => 'Send Email',
'LBL_CONTACT_NAME' => 'Contact',
'LBL_CONTACT_ID' => 'Contact Id',
'LBL_PARENT_NAME_COPY' => 'Company Name',
'LBL_PARENT_CONTACT_NAME' => 'Contact Person',
'LBL_PARENT_CONTACT_TITLE' => 'Contact Title',
'LBL_ALERT_ECMLANGUAGE_CHANGE' => 'Would you like to load default texts correspondencing to this language?',
'LBL_LIST_DOWNLOAD_PDF' => 'Download PDF',
'LBL_B_T' => 'Total Brutto',
'LBL_VAT_T' => 'Total Vat',
);

View File

@@ -0,0 +1,391 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*****************************************************************************
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
* Version 1.1 ("License"); You may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/rpl.php. Software distributed under the
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
* either express or implied.
*
* You may:
* a) Use and distribute this code exactly as you received without payment or
* a royalty or other fee.
* b) Create extensions for this code, provided that you make the extensions
* publicly available and document your modifications clearly.
* c) Charge for a fee for warranty or support or for accepting liability
* obligations for your customers.
*
* You may NOT:
* a) Charge for the use of the original code or extensions, including in
* electronic distribution models, such as ASP (Application Service
* Provider).
* b) Charge for the original source code or your extensions other than a
* nominal fee to cover distribution costs where such distribution
* involves PHYSICAL media.
* c) Modify or delete any pre-existing copyright notices, change notices,
* or License text in the Licensed Software
* d) Assert any patent claims against the Licensor or Contributors, or
* which would in any way restrict the ability of any third party to use the
* Licensed Software.
*
* You must:
* a) Document any modifications you make to this code including the nature of
* the change, the authors of the change, and the date of the change.
* b) Make the source code for any extensions you deploy available via an
* Electronic Distribution Mechanism such as FTP or HTTP download.
* c) Notify the licensor of the availability of source code to your extensions
* and include instructions on how to acquire the source code and updates.
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
* reproduce, perform, modify, sublicense, and distribute your extensions.
*
* The Original Code is: CommuniCore
* Olavo Farias
* 2006-04-7 olavo.farias@gmail.com
*
* The Initial Developer of the Original Code is CommuniCore.
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
* All Rights Reserved.
********************************************************************************/
$mod_strings = array (
// 080313 mh
'SERVICE_INVOICE_NAME' => 'Faktura zamówienia serwisowego %s',
//
// FOR SYSTEM USE
'LBL_MODULE_NAME' => 'Invoices',
'LBL_MODULE_TITLE' => 'Invoices: Home',
'LBL_MODULE_ID' => 'EcmInvoices',
'LBL_SEARCH_FORM_TITLE' => 'Invoices Search',
'LBL_LIST_FORM_TITLE' => 'Invoices List',
'LBL_NEW_FORM_TITLE' => 'New Invoice',
'LBL_DETAILS' => 'Invoice details:',
'LBL_ITEMS' => 'Items included:',
'LBL_TEXTS' => 'Texts to PDF:',
'LBL_PREVIEW' => 'Preview PDF:',
'LBL_EMAIL' => 'Create Email:',
'LBL_TO_INFORMATIONS' => 'To Informations:',
'LBL_DETAILS_TAB' => 'Details',
'LBL_ITEMS_TAB' => 'Items',
'LBL_TEXTS_TAB' => 'Texts',
'LBL_PREVIEW_TAB' => 'Preview',
'LBL_EMAIL_TAB' => 'Email',
'LBL_ID' => 'Id',
'LBL_NAME' => 'Name',
'LBL_DESCRIPTION' => 'Description',
'LBL_DATE_ENTERED' => 'Date Entered',
'LBL_DATE_MODIFIED' => 'Date Modified',
'LBL_MODIFIED' => 'Last Modified',
'LBL_ASSIGNED_TO_ID' => 'Assigned To',
'LBL_ASSIGNED_TO' => 'Assigned To',
'LBL_CREATED' => 'Created by',
'LBL_CREATED_BY_USER' => 'Created by',
'LBL_MODIFIED_BY_USER' => 'Modified by',
'LBL_ASSIGNED_TO_USER' => 'Assigned To',
'LBL_DELETED_BY' => 'Deleted by',
'LBL_NUMBER' => 'Number',
'LBL_DOCUMENT_NO' => 'Number',
'LBL_PARENT' => 'To',
'LBL_PARENT_NAME' => 'To',
'LBL_PARENT_ID' => 'To Id',
'LBL_TYPE' => 'Type',
'LBL_ECMINVOICEOUTOLD_ID' => 'Correct Id',
'LBL_ECMINVOICEOUTOLD_NAME' => 'Correct Name',
'LBL_STATUS' => 'Status',
'LBL_REGISTER_DATE' => 'Document Date',
'LBL_SELL_DATE' => 'Sell Date',
'LBL_PAYMENT_DATE' => 'Payment Date',
'LBL_PARENT_ADDRESS_STREET' => 'Street',
'LBL_PARENT_ADDRESS_CITY' => 'City',
'LBL_PARENT_ADDRESS_POSTALCODE' => 'Postalcode',
'LBL_PARENT_ADDRESS_COUNTRY' => 'Country',
'LBL_TO_VATID' => 'VAT-ID',
'LBL_TO_IS_VAT_FREE' => 'Is VAT Free?',
'LBL_HEADER_TEXT' => 'Header Text',
'LBL_FOOTER_TEXT' => 'Footer Text',
'LBL_ADS_TEXT' => 'Ads Text',
'LBL_SUBTOTAL' => 'Subtotal',
'LBL_TOTAL' => 'Total',
'LBL_DISCOUNT' => 'Discount',
'LBL_VAT' => 'VAT',
'LBL_ACCEPTED' => 'Accepted',
'LBL_TEMPLATE_ID' => 'Template Id',
'LBL_TEMPLATE_NAME' => 'Template',
'LBL_PAYMENTCONDITION_NAME' => 'Payment Condition',
'LBL_PAYMENTCONDITION_ID' => 'Payment Condition ID',
'LBL_FORMAT_NUMBER_ERROR' => 'Format Number Error!',
'LBL_SAVE_FORM_ERROR' => 'There are some errors on items list or in form!',
'LBL_DISCOUNT_ERROR' => 'Discount Format Number Error',
'LBL_EDITTABLE_NO' => 'Lp.',
'LBL_EDITTABLE_CODE' => 'Code',
'LBL_EDITTABLE_NAME' => 'Name',
'LBL_EDITTABLE_QUANTITY' => 'Quant',
'LBL_EDITTABLE_PRICE' => 'Price',
'LBL_EDITTABLE_VAT' => 'VAT',
'LBL_EDITTABLE_DISCOUNT' => 'Discount',
'LBL_EDITTABLE_TOTAL' => 'Total',
'LBL_EDITTABLE_OPTIONS' => 'Opt',
'LBL_MOVE_ROW_UP' => 'Move Up',
'LBL_MOVE_ROW_DOWN' => 'Move Down',
'LBL_INSERT_NEW_ROW' => 'Insert new row',
'LBL_DELETE_ROW' => 'Delete row',
// FOR MENU LINKS
'LNK_NEW_ECMINVOICEOUTOLD' => 'Create Invoice',
'LNK_ECMINVOICEOUTOLDS_LIST' => 'Invoices List',
'LBL_IMG_SEARCH' => 'Search',
'LBL_IMG_NEW' => 'New, add to base',
'LBL_IMG_EDIT' => 'Edit',
'LBL_CONFIRM_QUESTION' => 'Would you like to confirm this Invoice?',
'LBL_INVOICEOUT_PDF' => 'Show PDF',
'LBL_INVOICEOUT_PDF_BUTTON_KEY' => 'Show PDF [Alt+P]',
'LBL_INVOICEOUT_PDF_BUTTON_TITLE' => 'Show Invoice in PDF file.',
'LBL_INVOICEOUT_TO_INVOICE' => 'Make Invoice',
'LBL_INVOICEOUT_TO_INVOICE_BUTTON_KEY' => 'Make Invoice [Alt+I]',
'LBL_INVOICEOUT_TO_INVOICE_BUTTON_TITLE' => 'Make Invoice From Invoice.',
'LBL_LIST_TO_INVOICE' => 'Make Invoice From Invoice.',
//buttons
'LBL_SEND_BUTTON_TITLE' => 'Save & Send [Alt+D]',
'LBL_SEND_BUTTON_KEY' => 'D',
'LBL_SEND_BUTTON_LABEL' => 'Save & Send',
'LBL_REPAIR_BUTTON_TITLE' => 'Repair [Alt+R]',
'LBL_REPAIR_BUTTON_KEY' => 'R',
'LBL_REPAIR_BUTTON_LABEL' => 'Repair',
'LBL_GO_TO_LIST_BUTTON_TITLE' => 'Go to invoices list [Alt+G]',
'LBL_GO_TO_LIST_BUTTON_KEY' => 'G',
'LBL_GO_TO_LIST_BUTTON_LABEL' => 'Go to list',
'LBL_NOT_SAVED' => 'Invoice not saved. Please check all fields are correct!',
'LBL_SAVED' => 'Invoice saved successfully.',
'LBL_DEFAULT_CONTACT_HEADER_TEXT' => 'Witaj $contact_full_name!',
'LBL_DEFAULT_CONTACT_FOOTER_TEXT' => 'Tekst pod tabelka dla Contact',
'LBL_DEFAULT_CONTACT_ADS_TEXT' => 'Tekst pogrubiony pod tabelka dla Contact',
'LBL_DEFAULT_ACCOUNT_HEADER_TEXT' => 'Faktura dla $account_name.',
'LBL_DEFAULT_ACCOUNT_FOOTER_TEXT' => 'Tekst pod tabelka dla Account',
'LBL_DEFAULT_ACCOUNT_ADS_TEXT' => 'Tekst pogrubiony pod tabelka dla Account',
'LBL_NOTES_SUBPANEL_TITLE' => 'Notes',
'LBL_EMAILS_SUBPANEL_TITLE' => 'Emails',
'LBL_DASHLET_MY_ECMINVOICEOUTOLDS' => 'Invoices',
'LBL_PDF_LIST_POSITION' => 'Poz.',
'LBL_PDF_LIST_QUANTITY' => 'Ilosc',
'LBL_PDF_LIST_UNIT' => '',
'LBL_PDF_LIST_DESCRIPTION' => 'Opis',
'LBL_PDF_LIST_PRICE' => 'Cena',
'LBL_PDF_LIST_DISCOUNT' => 'Rabat',
'LBL_PDF_LIST_VAT' => 'VAT',
'LBL_PDF_LIST_TOTAL' => 'Suma',
'LBL_PDF_TOTAL' => 'Suma',
'LBL_PDF_DISCOUNT' => 'RABAT',
'LBL_PDF_END_TOTAL' => 'Suma koncowa',
'LBL_PDF_VAT' => 'VAT',
'LBL_PDF_VATID' => 'VAT-ID',
'LBL_PDF_NUMBER' => 'Numer',
'LBL_PDF_DATE_REGISTER' => 'Data wystawienia',
'LBL_PDF_OWNER' => 'Wystawil',
'LBL_PDF_DOCUMENT_NAME' => 'Faktura',
'LBL_PDF_DOCUMENT_NAME_CORRECT' => 'Korekta',
'LBL_PDF_DOCUMENT_NAME_CORRECT_TO' => 'Do faktury numer:',
'LBL_PDF_CODE' => '',
'LNK_ECMINVOICEOUTOLDS_PDFLANGUAGES' => 'PDF Languages',
'LBL_ECMLANGUAGE' => 'Language',
'LBL_ECMINVOICEOUTOLDS_PDFLANGUAGES_TITLE' => 'PDF Languages Settings',
'LBL_DEMO_VERSION_INFORMATION' => "This is only demo version.\nPlease contact us at ca@more7.com.",
'LBL_SENDEMAIL_BUTTON' => 'Send Email',
'LBL_CONTACT_NAME' => 'Contact',
'LBL_CONTACT_ID' => 'Contact Id',
'LBL_PARENT_NAME_COPY' => 'Company Name',
'LBL_PARENT_CONTACT_NAME' => 'Contact Person',
'LBL_PARENT_CONTACT_TITLE' => 'Contact Title',
'LBL_ALERT_ECMLANGUAGE_CHANGE' => 'Would you like to load default texts correspondencing to this language?',
'LBL_LIST_DOWNLOAD_PDF' => 'Download PDF',
);
?>

View File

@@ -0,0 +1,336 @@
<?php
if (!defined('sugarEntry') || !sugarEntry)
die('Not A Valid Entry Point');
/* * ***************************************************************************
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
* Version 1.1 ("License"); You may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/rpl.php. Software distributed under the
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
* either express or implied.
*
* You may:
* a) Use and distribute this code exactly as you received without payment or
* a royalty or other fee.
* b) Create extensions for this code, provided that you make the extensions
* publicly available and document your modifications clearly.
* c) Charge for a fee for warranty or support or for accepting liability
* obligations for your customers.
*
* You may NOT:
* a) Charge for the use of the original code or extensions, including in
* electronic distribution models, such as ASP (Application Service
* Provider).
* b) Charge for the original source code or your extensions other than a
* nominal fee to cover distribution costs where such distribution
* involves PHYSICAL media.
* c) Modify or delete any pre-existing copyright notices, change notices,
* or License text in the Licensed Software
* d) Assert any patent claims against the Licensor or Contributors, or
* which would in any way restrict the ability of any third party to use the
* Licensed Software.
*
* You must:
* a) Document any modifications you make to this code including the nature of
* the change, the authors of the change, and the date of the change.
* b) Make the source code for any extensions you deploy available via an
* Electronic Distribution Mechanism such as FTP or HTTP download.
* c) Notify the licensor of the availability of source code to your extensions
* and include instructions on how to acquire the source code and updates.
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
* reproduce, perform, modify, sublicense, and distribute your extensions.
*
* The Original Code is: CommuniCore
* Olavo Farias
* 2006-04-7 olavo.farias@gmail.com
*
* The Initial Developer of the Original Code is CommuniCore.
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
*
* All Rights Reserved.
* ****************************************************************************** */
$mod_strings = array(
//mh 21-03-13
'LBL_PDF_CORRECT_REASON' => 'Nota reklamacyjna',
'LBL_PDF_DOCUMENT_NAME_CORRECT_TO' => 'Korekta do',
'LBL_INVOICEOUT_PDF' => 'Wyświetl PDF',
'LBL_ORDER_NO' => 'Numer zamówienia',
'LBL_SUPPLIER_CODE' => 'Kod dostawcy',
'LBL_PDF_INDEX_DBF'=> 'Indeks kontrahenta',
//
'LBL_CURRENCY_VALUE_NBP' => 'Kurs NBP',
'LBL_PDF_SITE' => 'Strona',
'LBL_PDF_FOOTER_DOCUMENT_NAME' => 'Faktura',
//
'LBL_PDF_PAYMENT_METHOD_PATTERN' => 'w terminie <b>%s</b> dni do <b>%s</b> <b>%s</b>',
'LBL_PDF_INVOICE' => 'Faktura',
//
'LBL_TO_PAYMENTS' => 'Płatności',
'LBL_PDF_INVOICE' => 'Faktura',
'LBL_WEIGHT_NETTO' => 'Waga produktów',
'LBL_TO_PAID' => 'Do zapłaty',
'LBL_PREPAID' => 'Przedpłata',
'LBL_PREPAID_NR' => 'Numer FK przedpłatowej',
'LBL_PAID' => 'Zapłacono',
'LBL_LEFT' => 'Pozostało',
'LBL_DAYS' => 'Termin płatności (dni)',
'LBL_PAYMENT_METHOD' => 'Sposób zapłaty',
'LBL_PAYMENT_METHOD_PAID' => 'Sposób zapłaty (zapłacono)',
// Position list.
'LBL_PDF_LIST_POSITION' => 'Lp.',
'LBL_PDF_LIST_DESCRIPTION' => 'Nazwa',
'LBL_PDF_LIST_INDEX' => 'Indeks',
'LBL_PDF_LIST_QUANTITY' => 'Ilość',
'LBL_PDF_LIST_UNIT' => 'J.m.',
'LBL_PDF_LIST_UNIT_PRICE' => 'Cena netto',
'LBL_PDF_LIST_UNIT_PRICE_TOTAL' => 'Wartość netto',
'LBL_PDF_LIST_DISCOUNT' => 'Rabat (%)',
'LBL_PDF_LIST_VAT_ID' => 'VAT (%)',
'LBL_PDF_LIST_VAT_VALUE' => 'Wartość VAT',
'LBL_PDF_LIST_TOTAL' => 'Wartość brutto',
// Summary list.
'LBL_PDF_LIST_VAT_RATE' => 'VAT (%)',
'LBL_PDF_LIST_NETTO_TOTAL' => 'Wartość netto',
'LBL_PDF_LIST_VAT_TOTAL' => 'Wartość VAT',
'LBL_PDF_LIST_BRUTTO_TOTAL' => 'Wartość brutto',
'LBL_PDF_LIST_SUMMARY_TOTAL' => 'Razem',
'LBL_PDF_LIST_WEIGHT' => 'Waga',
'LBL_PDF_LIST_COUNTRY_OF_ORIGIN' => 'Kraj pochodzenia',
//
'LBL_PDF_PREPAID_DOCUMENTS' => 'Dokumenty przedpłatowe',
'LBL_PDF_PREPAID' => 'Przedpłata',
'LBL_PDF_PAID' => 'Zapłacono',
'LBL_PDF_DELIVERY' => 'Dostawa',
'LBL_PDF_SELLER' => 'Sprzedawca',
'LBL_PDF_BUYER' => 'Nabywca',
// Old values.
'LBL_PDF_LIST_TOTAL_PRICE' => 'Suma netto',
'LBL_PDF_LIST_TAX_CODE' => 'PKWiU',
'LBL_PDF_LIST_PRICE' => 'Cena',
'LBL_PDF_LIST_VAT' => 'VAT',
//
'LBL_CURRENCY_VALUE' => 'Kurs waluty',
'LBL_PARENT_SHIPPING_ADDRESS' => 'Adres wysyłki',
'LBL_PDF_TYPE' => 'Typ pdf',
'LBL_STOCK_NAME' => 'Magazyn',
'LBL_PARENT_INDEX_DBF' => 'Indeks',
'LBL_PDF_DATE_REGISTER' => 'Data wystawienia',
'LBL_PDF_DATE_SELL' => "Data sprzedaży",
'LBL_PDF_SUPPLIER_CODE' => "Kod dostawcy",
'LBL_PDF_ORDER_NO' => 'Nr zamówienia',
'LBL_PDF_RECIPIENT_CODE' => 'Kod Tow.',
// 080313 mh
'SERVICE_INVOICE_NAME' => 'Faktura zamówienia serwisowego %s',
//
'LBL_EDITTABLE_STOCK' => 'Mag.',
'LBL_CORRECT_REASON' => 'Powód korekty',
//added 01.09.2009
'LBL_ECMLANGUAGE' => 'Język',
'LBL_CURRENCY' => 'Waluta',
//added 05.08.2009
'LBL_DETAIL_BUTTON' => 'Szczegóły',
'LBL_LIST_PREVIEW_PDF' => 'Podgląd PDFa',
'LBL_LIST_DUPLICATE' => 'Duplikat',
//added 20.07.2009
'LBL_CORRECT_TITLE' => 'Stwórz Korektę',
'LBL_CORRECT' => 'Stwórz Korektę',
//added 30.06.2009
'LBL_PDF_TO_WZ' => 'Dokument WZ',
'LBL_PDF_PLACE_OF_REGISTER' => 'Miejsce wystawienia',
'LBL_PDF_NIP' => 'NIP',
'LBL_TO_NIP' => 'NIP',
'LBL_PDF_SELL_DATE' => 'Data sprzedaży',
'LBL_SELECT' => 'select',
'LBL_EDITTABLE_TAXCODE' => 'PKWiU',
'LBL_EDITTABLE_UNIT' => 'j.m.',
//added 05.06.2009
'LBL_PDF_PAYMENT_METHOD' => 'Metoda płatności',
'LBL_PDF_PAYMENT_TERMIN' => 'Termin płatności',
'LBL_PDF_DAYS' => 'Day(s)',
'LBL_PDF_TO_PAID' => 'Do zapłaty',
'LBL_PDF_TO_PAID_BACK' => 'Do wypłaty',
'LBL_PDF_TOTAL_BY_WORD' => 'Total by word',
'LBL_PDF_OWNER_SIGNATURE' => 'Podpis wystawcy',
'LBL_PDF_RECEIVER_SIGNATURE' => 'Podpis odbiorcy',
'LBL_PDF_ORIGINAL_COPY' => 'ORIGINAL / COPY',
'LBL_PDF_DOCUMENT_BEFORE_CORRECT' => 'Before correct',
'LBL_PDF_DOCUMENT_AFTER_CORRECT' => 'After correct',
//added 02.04.2009
'LBL_ECMSTOCKDOCOUTS_SUBPANEL_TITLE' => 'Dokumenty WZ',
// FOR SYSTEM USE
'LBL_MODULE_NAME' => 'Faktury',
'LBL_MODULE_TITLE' => 'Faktury: Strona Glówna',
'LBL_MODULE_ID' => 'EcmInvoiceOutOlds',
'LBL_SEARCH_FORM_TITLE' => 'Wyszukiwanie',
'LBL_LIST_FORM_TITLE' => 'Lista Faktur',
'LBL_NEW_FORM_TITLE' => 'Nowa Faktura',
'LBL_DETAILS' => 'Szczególy Faktury',
'LBL_ITEMS' => 'Zalaczone Produkty:',
'LBL_TEXTS' => 'Teksty do PDFa:',
'LBL_PREVIEW' => 'Podglad PDFa:',
'LBL_EMAIL' => 'Stwórz Email:',
'LBL_TO_INFORMATIONS' => 'Informacje o firmie:',
'LBL_DETAILS_TAB' => 'Szczególy',
'LBL_ITEMS_TAB' => 'Produkty',
'LBL_TEXTS_TAB' => 'Teksty',
'LBL_PREVIEW_TAB' => 'Podglad',
'LBL_EMAIL_TAB' => 'Email',
'LBL_ID' => 'Id',
'LBL_NAME' => 'Nazwa',
'LBL_DESCRIPTION' => 'Opis',
'LBL_DATE_ENTERED' => 'Data dodania',
'LBL_DATE_MODIFIED' => 'Date modyfikacji',
'LBL_MODIFIED' => 'Ostatnio modyfikowane',
'LBL_ASSIGNED_TO_ID' => 'Przypisane Do',
'LBL_ASSIGNED_TO' => 'Przypisane Do',
'LBL_CREATED' => 'Utworzone Przez',
'LBL_CREATED_BY_USER' => 'Utworzone Przez',
'LBL_MODIFIED_BY_USER' => 'Zmodyfikowane Przez',
'LBL_ASSIGNED_TO_USER' => 'Przypisane Do',
'LBL_DELETED_BY' => 'Usuniete Przez',
'LBL_NUMBER' => 'Numer',
'LBL_DOCUMENT_NO' => 'Numer',
'LBL_PARENT' => 'Do',
'LBL_PARENT_NAME' => 'Firma',
'LBL_PARENT_ID' => 'Firma Id',
'LBL_TYPE' => 'Typ',
'LBL_ECMINVOICEOUTOLD_ID' => 'Id Faktury',
'LBL_ECMINVOICEOUTOLD_NAME' => 'Faktura do korygowania',
'LBL_STATUS' => 'Status',
'LBL_REGISTER_DATE' => 'Data Dokumentu',
'LBL_SELL_DATE' => 'Data Sprzedaży',
'LBL_PAYMENT_DATE' => 'Termin Płatności',
'LBL_PARENT_ADDRESS_STREET' => 'Ulica',
'LBL_PARENT_ADDRESS_CITY' => 'Kod pocztowy / Miasto',
'LBL_PARENT_ADDRESS_POSTALCODE' => 'Kod pocztowy',
'LBL_PARENT_ADDRESS_COUNTRY' => 'Panstwo',
'LBL_TO_VATID' => 'VAT-ID',
'LBL_TO_IS_VAT_FREE' => 'Czy jest wolne od vatu?',
'LBL_HEADER_TEXT' => 'Tekst naglówka',
'LBL_FOOTER_TEXT' => 'Tekst stopki',
'LBL_ADS_TEXT' => 'Dodatkowy tekst',
'LBL_SUBTOTAL' => 'Suma netto',
'LBL_TOTAL' => 'Suma brutto',
'LBL_DISCOUNT' => 'Upust',
'LBL_VAT' => 'VAT',
'LBL_ACCEPTED' => 'Zaakceptowane',
'LBL_TEMPLATE_ID' => 'Id Szablonu',
'LBL_TEMPLATE_NAME' => 'Szablon',
'LBL_PAYMENTCONDITION_NAME' => 'Warunki Płatnosci',
'LBL_PAYMENTCONDITION_ID' => 'Warunki Płatnosci ID',
'LBL_DELIVERYCONDITION_NAME' => 'Warunki Dostawy',
'LBL_DELIVERYCONDITION_ID' => 'Warunki Dostawy ID',
'LBL_FORMAT_NUMBER_ERROR' => 'Blad formatu numeru!',
'LBL_SAVE_FORM_ERROR' => 'Wystepuja bledy na liscie produktów albo w formularzu!',
'LBL_DISCOUNT_ERROR' => 'Blad formatu upustu',
'LBL_EDITTABLE_NO' => 'Lp.',
'LBL_EDITTABLE_CODE' => 'Indeks',
'LBL_EDITTABLE_NAME' => 'Nazwa',
'LBL_EDITTABLE_QUANTITY' => 'Ilosc',
'LBL_EDITTABLE_PRICE' => 'Cena sprzedaży',
'LBL_EDITTABLE_PRICE_SUB' => 'Cena początkowa',
'LBL_EDITTABLE_VAT' => 'VAT',
'LBL_EDITTABLE_DISCOUNT' => 'Upust',
'LBL_EDITTABLE_TOTAL' => 'Wartość',
'LBL_EDITTABLE_OPTIONS' => 'Opcje',
'LBL_MOVE_ROW_UP' => 'W góre',
'LBL_MOVE_ROW_DOWN' => 'W dól',
'LBL_INSERT_NEW_ROW' => 'Wstaw nowy wiersz',
'LBL_DELETE_ROW' => 'Usun wiersz',
'LBL_VALIDTILL_DATE' => 'Wazne do',
// FOR MENU LINKS
'LNK_NEW_ECMINVOICEOUTOLD' => 'Utwórz Fakture',
'LNK_ECMINVOICEOUTOLDS_LIST' => 'Lista Faktur',
'LBL_IMG_SEARCH' => 'Wyszukiwanie',
'LBL_IMG_NEW' => 'Nowy, dodaj do bazy',
'LBL_IMG_EDIT' => 'Edycja',
'LBL_CONFIRM_QUESTION' => 'Chcesz potwierdzic te Fakture?',
'LBL_QUOTE_PDF' => 'Pokaz PDF',
'LBL_QUOTE_PDF_BUTTON_KEY' => 'Pokaz PDF [Alt+P]',
'LBL_QUOTE_PDF_BUTTON_TITLE' => 'Pokaz Fakture w pliku PDF.',
'LBL_QUOTE_TO_INVOICE' => 'Stwórz Fakture',
'LBL_QUOTE_TO_INVOICE_BUTTON_KEY' => 'Stwórz Fakture [Alt+I]',
'LBL_QUOTE_TO_INVOICE_BUTTON_TITLE' => 'Stwórz Fakture.',
'LBL_QUOTE_TO_SALE' => 'Stwórz Zamówienie Sprzedazy',
'LBL_QUOTE_TO_SALE_BUTTON_KEY' => 'Stwórz Zamówienie Sprzedazy [Alt+O]',
'LBL_QUOTE_TO_SALE_BUTTON_TITLE' => 'Stwórz Zamówienie Sprzedazy.',
'LBL_SEND_TO_CONFIRM' => 'Wyslij Do Potwierdzenia',
'LBL_SEND_TO_CONFIRM_BUTTON_KEY' => 'Wyslij Do Potwierdzenia [Alt+C]',
'LBL_SEND_TO_CONFIRM_BUTTON_TITLE' => 'Wyslij Do Potwierdzenia.',
'LBL_LIST_TO_INVOICE' => 'Stwórz Fakture.',
'LBL_LIST_TO_SALE' => 'Stwórz Zamówienie Sprzedazy.',
//buttons
'LBL_SEND_BUTTON_TITLE' => 'Zapisz i Wyslij [Alt+D]',
'LBL_SEND_BUTTON_KEY' => 'D',
'LBL_SEND_BUTTON_LABEL' => 'Zapisz i Wyslij',
'LBL_REPAIR_BUTTON_TITLE' => 'Napraw [Alt+R]',
'LBL_REPAIR_BUTTON_KEY' => 'R',
'LBL_REPAIR_BUTTON_LABEL' => 'Napraw',
'LBL_ACCEPT_BUTTON_TITLE' => 'Zaakceptuj [Alt+Z]',
'LBL_ACCEPT_BUTTON_KEY' => 'Z',
'LBL_ACCEPT_BUTTON_LABEL' => 'Zaakceptuj',
'LBL_REJECT_BUTTON_TITLE' => 'Nie akceptuj [Alt+R]',
'LBL_REJECT_BUTTON_KEY' => 'R',
'LBL_REJECT_BUTTON_LABEL' => 'Nie akceptuj',
'LBL_GO_TO_LIST_BUTTON_TITLE' => 'Idz do listy Faktur [Alt+G]',
'LBL_GO_TO_LIST_BUTTON_KEY' => 'G',
'LBL_GO_TO_LIST_BUTTON_LABEL' => 'Idz do listy',
'LBL_SENDEMAIL_BUTTON' => 'Wyslij Email',
'LBL_NOT_SAVED' => 'Faktura nie zostala zapisana. Sprawdz czy wszytskie pola sa poprawne!',
'LBL_SAVED' => 'Faktura zostala zapisana pomyslnie.',
'LBL_DEFAULT_CONTACT_HEADER_TEXT' => 'Witaj $contact_full_name!',
'LBL_DEFAULT_CONTACT_FOOTER_TEXT' => 'Tekst pod tabelka dla Contact',
'LBL_DEFAULT_CONTACT_ADS_TEXT' => 'Tekst pogrubiony pod tabelka dla Contact',
'LBL_DEFAULT_ACCOUNT_HEADER_TEXT' => 'Faktura dla $account_name.',
'LBL_DEFAULT_ACCOUNT_FOOTER_TEXT' => 'Tekst pod tabelka dla Account',
'LBL_DEFAULT_ACCOUNT_ADS_TEXT' => 'Tekst pogrubiony pod tabelka dla Account',
'LBL_NOTES_SUBPANEL_TITLE' => 'Notatki',
'LBL_EMAILS_SUBPANEL_TITLE' => 'Emaile',
'LBL_DASHLET_MY_ECMINVOICEOUTOLDS' => 'Faktury',
'LBL_PDF_TOTAL' => 'Suma',
'LBL_PDF_DISCOUNT' => 'RABAT',
'LBL_PDF_END_TOTAL' => 'Suma koncowa',
'LBL_PDF_VAT' => 'VAT',
'LBL_PDF_VATID' => 'VAT-ID',
'LBL_PDF_NUMBER' => 'Numer',
'LBL_PDF_VALIDTILL_DATE' => 'Waznosc oferty',
'LBL_PDF_OWNER' => 'Wystawil',
'LBL_PDF_DOCUMENT_NAME' => 'Faktura VAT',
'LBL_PDF_FILENAME' => 'FV_',
'LBL_PDF_CODE' => 'FV',
'LNK_ECMINVOICEOUTOLDS_PDFLANGUAGES' => 'Ustawienia PDF',
'LBL_ECMINVOICEOUTOLDS_PDFLANGUAGES_TITLE' => 'Ustawienia jezyków PDFa',
'LBL_ACCESS_UNAVAIBLE_DELETE_EMAIL' => "You don't have a permission to send Email, because this Correct Document is not accepted by Manager!",
'LBL_SEND_TO_CONFIRM_ERROR' => "Sending Correct Document to confirm error! Refresh site and try again.",
'LBL_STATUS_s10_SET_MESSAGE' => "Status Faktury ustawiony.",
'LBL_ZAM_DAT' => 'Data zamówienia',
'LBL_STATUS_s20_SET_MESSAGE' => "Faktura czeka na potwierdzenie.",
'LBL_STATUS_s30_SET_MESSAGE' => "Faktura jest potwierdzony.",
'LBL_STATUS_s40_SET_MESSAGE' => "Status Faktury ustawiony.",
'LBL_STATUS_s20_FAIL_MESSAGE' => "Blad wysylki do potwierdzenia! Odswiez strone i sprobuj ponownie.",
'LBL_LIST_SEND_TO_CONFIRM' => 'Wyslij do Potwierdzenia',
'LBL_LIST_DUPLICATE' => 'Duplikuj',
'LBL_LIST_PREVIEW_PDF' => 'Podglad Faktury',
'LBL_LIST_REJECT' => 'Nie akceptuj',
'LBL_LIST_ACCEPT' => 'Akceptuj',
'LBL_MODIFIED_USER' => 'Zmodyfikowane Przez',
'LBL_DEMO_VERSION_INFORMATION' => "This is only demo version.\nPlease contact us at ca@more7.com.",
'LBL_ORDER_ORIGIN' => 'Zródlo zamówienia',
'LBL_PREVIEW_HEADER_NAME' => 'Podglad',
'LBL_PREVIEW_HEADER_CLOSE' => 'Zamknij',
'LBL_CONTACT_NAME' => 'Kontakt',
'LBL_ZAM_NUM' => 'Numer zamówienia e5',
'LBL_ZAM_KL' => 'Zamówienie klienta',
'LBL_CONTACT_ID' => 'Id Kontaktu',
'LBL_PARENT_NAME_COPY' => 'Nazwa Firmy',
'LBL_PARENT_CONTACT_NAME' => 'Osoba Kontaktowa',
'LBL_PARENT_CONTACT_TITLE' => 'Tytul Kontaktu',
'LBL_ALERT_ECMLANGUAGE_CHANGE' => 'Czy zaladowac domyslne teksty dla tego jezyka?',
'LBL_LIST_DOWNLOAD_PDF' => 'Pobierz PDF',
'LBL_B_T' => 'Suma Brutto',
'LBL_VAT_T' => 'Suma Vat',
);

View File

@@ -0,0 +1,356 @@
<?php
class maksymaXML {
private $p; // paczka
private $date;
function maksymaXML($date) {
$this->date = $date;
$this->p = new XMLWriter ();
$this->p->openURI ( 'php://output' );
// $this->p->openMemory();
$this->p->startDocument ( '1.0', 'UTF-8' );
$this->p->startElement ( 'paczka' );
$this->p->writeAttribute ( 'firma', 'E5 Polska sp z o.o.' );
$this->p->writeAttribute ( 'wersja', '1' );
$this->p->writeAttribute ( 'miesiac', substr($this->date,5,6));
}
function getInvoices() {
// co z anulowanymi?? :(
$db = $GLOBALS ['db'];
$invoices = $db->query ( "SELECT * FROM ecminvoiceoutolds WHERE deleted='0' AND type='normal' AND register_date LIKE '$this->date%'" );
while ( $i = $db->fetchByAssoc ( $invoices ) ) {
$this->p->startElement ( 'dokument' );
$this->p->writeAttribute ( 'rodzaj', ($i['canceled']=='1'?'!':'').'FVS' . $i ['pdf_type'] );
$this->p->writeAttribute ( 'id', $i['id'] );
$this->p->writeElement ( 'data', $i ['register_date'] );
// dataOperacji = Data WZ? co jeśli WZ jest więcej
$this->p->writeElement ( 'dataOperacji', $i ['register_date'] );
// same story
$this->p->writeElement ( 'dataDostawy', $i ['register_date'] );
$this->p->writeElement ( 'dataWpływu', $i ['register_date'] );
$this->p->writeElement ( 'numer', $i ['document_no'] );
//platnosc
$this->p->startElement('platnosc');
$this->p->writeElement('kwota', $i['total']);
$this->p->writeElement('data', $i['payment_date']);
$this->p->endElement(); //</platnosc>
//kontrahent
$this->p->startElement ( 'kontrahent' );
$this->p->writeAttribute ( 'id', $i ['parent_id'] );
$this->p->writeElement('NIP', e(str_replace ( "-", "", $i ['to_nip'] )));
$this->p->writeElement('nazwa', htmlspecialchars($i['parent_name']));
$this->p->writeElement('adres', htmlspecialchars($i['parent_address_street']));
//jaki numer??
$this->p->writeElement('kodPocztowy', htmlspecialchars($i['parent_address_postalcode']));
$this->p->writeElement('miasto', htmlspecialchars($i['parent_address_city']));
$this->p->writeElement('kraj', htmlspecialchars($i['parent_address_country']));
$this->p->endElement (); // </kontrahent>
//WZ
//co dalej z wz
$wz = $db->fetchByAssoc($db->query("SELECT id, document_no, subtotal, register_date, so_id FROM ecmstockdocouts WHERE id = '".$i['wz_id']."'"));
$this->p->startElement('dokumentyPowiazane');
$this->p->startElement('dokumentPowiazany');
$this->p->writeAttribute('rodzaj', 'WZ');
$this->p->writeAttribute ( 'id', $wz['id'] );
$this->p->writeElement('numer', $wz['document_no']);
$this->p->writeElement('data', $wz['register_date']);
$this->p->writeElement('wartoscNetto', $wz['subtotal']);
$this->p->endElement(); // </dokumentPowiazany>
$this->p->endElement(); //</dokumentyPowiazane>
//pozycje dokumentu
$pozycje = $db->query("
select sum(i.subtotal) as subtotal, p.group_ks, sum(i.quantity) as qty from ecminvoiceoutolditems as i
inner join ecmproducts as p
on p.id=i.ecmproduct_id
where i.ecminvoiceoutold_id='".$i['id']."'
group by p.group_ks;
");
$pp = 0;
global $app_list_strings;
$this->p->startElement('pozycjeDokumentu');
while ($poz = $db->fetchByAssoc($pozycje)) {
$pp++;
if ($poz['group_ks']=='1') {
$rodzaj = 'T';
$tresc = 'TH';
} elseif ($poz['group_ks']=='2') {
$rodzaj = 'P';
$tresc = 'WG';
}
elseif (($poz['group_ks']=='3')) {
$rodzaj = 'S';
$tresc = 'SU';
}
$this->p->startElement('pozycjaDokumentu');
$this->p->writeElement('tresc', $tresc);
$this->p->writeElement('wartoscNetto', round($poz['subtotal'],2));
$this->p->endElement(); // </pozycjaDokumentu>
}
$this->p->endElement(); // </pozycjeDokumentu>
//rozbicie
$this->p->startElement('rejestr');
$rozbicie = $db->query("
select sum(i.subtotal) as subtotal, sum(i.total) as total, v.name, v.value from ecminvoiceoutolditems as i
inner join ecmvats as v
on v.id = i.ecmvat_id
where
i.ecminvoiceoutold_id='".$i['id']."'
group by v.id;
");
while ($roz = $db->fetchByAssoc($rozbicie)) {
$this->p->startElement('rozbicie');
$this->p->writeAttribute('stawka', $roz['name']);
$this->p->writeElement('netto', round($roz['subtotal'],2));
$this->p->writeElement('brutto', round($roz['total'],2));
$this->p->writeElement('VAT', round ($roz['total'] - $roz['subtotal'], 2 ));
$this->p->endElement(); // </rozbicie>
}
$this->p->endElement(); // </rejestr>
if ($i['pdf_type']=='K') {
$this->p->writeElement('sumaNetto', round($i['subtotal'],2));
$this->p->writeElement('sumaBrutto', round($i['total'],2));
$this->p->writeElement('sumaVat', round($i['total']-$i['subtotal'],2));
} else {
$this->p->writeElement('sumaNetto', round($i['subtotal']*$i['currency_value'],2));
$this->p->writeElement('sumaBrutto', round($i['total']*$i['currency_value'],2));
$this->p->writeElement('sumaVat', round(($i['total']-$i['subtotal'])*$i['currency_value'],2));
$this->p->writeElement('sumaWalNetto', round($i['subtotal'],2));
$this->p->writeElement('sumaWalBrutto', round($i['total'],2));
$this->p->writeElement('sumaWalVat', round($i['total']-$i['subtotal'],2));
//kursy
$this->p->startElement('kursy');
//data dostawy
$cur = $db->fetchByAssoc($db->query("
SELECT * FROM currency_nbp_archive
WHERE currency_id = '".$i['currency_id']."'
AND date < DATE_SUB((SELECT delivery_date FROM ecmsales WHERE id='".$wz['so_id']."'), INTERVAL 1 DAY)
ORDER BY date DESC
LIMIT 0,1;
"));
$this->p->startElement('kurs');
$this->p->writeElement('waluta', $cur['currency_name']);
$this->p->writeAttribute('zastosowanie', 'dataDostawy');
$this->p->writeElement('rodzaj', 'NBP');
$this->p->writeElement('naDzien', $cur['date']);
$this->p->writeElement('wartosc', $cur['value']);
$this->p->endElement(); // </kurs>
//data transakcji
$cur = $db->fetchByAssoc($db->query("
SELECT * FROM currency_nbp_archive
WHERE currency_id = '".$i['currency_id']."'
AND date < DATE_SUB('".$i['register_date']."', INTERVAL 1 DAY)
ORDER BY date DESC
LIMIT 0,1;
"));
$this->p->startElement('kurs');
$this->p->writeElement('waluta', $cur['currency_name']);
$this->p->writeAttribute('zastosowanie', 'dataTransakcji');
$this->p->writeElement('rodzaj', 'NBP');
$this->p->writeElement('naDzien', $cur['date']);
$this->p->writeElement('wartosc', $cur['value']);
$this->p->endElement(); // </kurs>
$this->p->endElement(); // </kursy>
}
$this->p->endElement (); // </dokument>
}
}
function getCorrectInfoices() {
$db = $GLOBALS ['db'];
$invoices = $db->query ( "SELECT * FROM ecminvoiceoutolds WHERE deleted='0' AND type='correct' AND register_date LIKE '$this->date%'" );
while ( $i = $db->fetchByAssoc ( $invoices ) ) {
$this->p->startElement ( 'dokument' );
$this->p->writeAttribute ( 'rodzaj', ($i['canceled']=='1'?'!':'').'FKS' . $i ['pdf_type'] );
$this->p->writeAttribute ( 'id', $i['id'] );
$this->p->writeElement ( 'data', $i ['register_date'] );
// dataOperacji = Data WZ? co jeśli WZ jest więcej
$this->p->writeElement ( 'dataOperacji', $i ['register_date'] );
// same story
$this->p->writeElement ( 'dataDostawy', $i ['register_date'] );
$this->p->writeElement ( 'dataWpływu', $i ['register_date'] );
$this->p->writeElement ( 'numer', $i ['document_no'] );
//kontrahent
$this->p->startElement ( 'kontrahent' );
$this->p->writeAttribute ( 'id', $i ['parent_id'] );
$this->p->writeElement('NIP', e(str_replace ( "-", "", $i ['to_nip'] )));
$this->p->writeElement('nazwa', htmlspecialchars($i['parent_name']));
$this->p->writeElement('adres', htmlspecialchars($i['parent_address_street']));
//jaki numer??
$this->p->writeElement('kodPocztowy', htmlspecialchars($i['parent_address_postalcode']));
$this->p->writeElement('miasto', htmlspecialchars($i['parent_address_city']));
$this->p->writeElement('kraj', htmlspecialchars($i['parent_address_country']));
$this->p->endElement (); // </kontrahent>
//platnosc
$this->p->startElement('platnosc');
$this->p->writeElement('kwota', $i['total']);
$this->p->writeElement('data', $i['payment_date']);
$this->p->endElement(); //</platnosc>
//multi correct?
$multi = $db->query ( "
SELECT distinct o.ecminvoiceoutold_id
FROM
ecminvoiceoutolditems as ii
INNER JOIN ecminvoiceoutolds as i
ON ii.ecminvoiceoutold_id = i.id
INNER JOIN ecminvoiceoutolditems AS o
ON o.id = ii.ecminvoiceoutolditem_id
WHERE
ii.ecminvoiceoutold_id = '".$i['id']."'");
$multi_correct = false;
if ($multi->num_rows > 1) $multi_correct = true;
if (!$multi_correct) {
//normal correct
$inv_id = $i['ecminvoiceoutold_id'];
$inv_nr = $db->fetchByAssoc($db->query("SELECT id, document_no, register_date FROM ecminvoiceoutolds WHERE id='".$inv_id."'"));
$this->p->startElement('dokumentKorygowany');
$this->p->writeAttribute('rodzaj', 'FVS');
$this->p->writeAttribute ( 'id', $inv_nr['id'] );
$this->p->writeElement('numer', $inv_nr['document_no']);
$this->p->writeElement('data', $inv_nr['register_date']);
$this->p->endElement(); //</dokumentKorygowany>
} else {
//multi correct
$this->p->startElement('dokumentyPowiazane');
while ($inv_id = $db->fetchByAssoc($multi)) {
$inv_nr = $db->fetchByAssoc($db->query("SELECT id, document_no, register_date FROM ecminvoiceoutolds WHERE id='".$inv_id['ecminvoiceoutold_id']."'"));
$this->p->startElement('dokumentPowiazany');
$this->p->writeAttribute('rodzaj', 'FVS');
$this->p->writeAttribute ( 'id', $inv_nr['id'] );
$this->p->writeElement('numer', $inv_nr['document_no']);
$this->p->writeElement('data', $inv_nr['register_date']);
$this->p->endElement(); // </dokumentPowiazany>
}
$this->p->endElement(); //<dokumentyPowiazane>
}
//pozycje dokumentu
$this->p->startElement('pozycjeDokumentu');
$pozycje = $db->query("
select sum(i.subtotal_corrected) as subtotal, p.group_ks, sum(i.quantity_corrected) as qty from ecminvoiceoutolditems as i
inner join ecmproducts as p
on p.id=i.ecmproduct_id
where i.ecminvoiceoutold_id='".$i['id']."'
group by p.group_ks;
");
$pp = 0;
global $app_list_strings;
while ($poz = $db->fetchByAssoc($pozycje)) {
$pp++;
if ($poz['group_ks']=='1') {
$rodzaj = 'T';
$tresc = 'TH';
} elseif ($poz['group_ks']=='2') {
$rodzaj = 'P';
$tresc = 'WG';
}
elseif (($poz['group_ks']=='3')) {
$rodzaj = 'S';
$tresc = 'SU';
}
$this->p->startElement('pozycjaDokumentu');
$this->p->writeElement('tresc', $tresc);
$this->p->writeElement('wartoscNetto', round($poz['subtotal'],2));
$this->p->endElement(); // </pozycjaDokumentu>
}
$this->p->endElement(); // </pozycjeDokumentu>
//rozbicie
$this->p->startElement('rejestr');
$rozbicie = $db->query("
select sum(i.subtotal_corrected) as subtotal, sum(i.total_corrected) as total, v.name, v.value from ecminvoiceoutolditems as i
inner join ecmvats as v
on v.id = i.ecmvat_id
where
i.ecminvoiceoutold_id='".$i['id']."'
group by v.id;
");
while ($roz = $db->fetchByAssoc($rozbicie)) {
$this->p->startElement('rozbicie');
$this->p->writeAttribute('stawka', $roz['name']);
$this->p->writeElement('netto', round($roz['subtotal'],2));
$this->p->writeElement('brutto', round($roz['total'],2));
$this->p->writeElement('VAT', round ($roz['total'] - $roz['subtotal'], 2 ));
$this->p->endElement(); // </rozbicie>
}
$this->p->endElement(); // </rejestr>
if ($i['pdf_type']=='K') {
$this->p->writeElement('sumaNetto', round($i['subtotal'],2));
$this->p->writeElement('sumaBrutto', round($i['total'],2));
$this->p->writeElement('sumaVat', round($i['total']-$i['subtotal'],2));
} else {
$this->p->writeElement('sumaNetto', round($i['subtotal']*$i['currency_value'],2));
$this->p->writeElement('sumaBrutto', round($i['total']*$i['currency_value'],2));
$this->p->writeElement('sumaVat', round(($i['total']-$i['subtotal'])*$i['currency_value'],2));
$this->p->writeElement('sumaWalNetto', round($i['subtotal'],2));
$this->p->writeElement('sumaWalBrutto', round($i['total'],2));
$this->p->writeElement('sumaWalVat', round($i['total']-$i['subtotal'],2));
//kursy
$this->p->startElement('kursy');
//data dostawy
$cur = $db->fetchByAssoc($db->query("
SELECT * FROM currency_nbp_archive
WHERE currency_id = '".$i['currency_id']."'
AND date < DATE_SUB((SELECT delivery_date FROM ecmsales WHERE id='".$wz['so_id']."'), INTERVAL 1 DAY)
ORDER BY date DESC
LIMIT 0,1;
"));
$this->p->startElement('kurs');
$this->p->writeElement('waluta', $cur['currency_name']);
$this->p->writeAttribute('zastosowanie', 'dataDostawy');
$this->p->writeElement('rodzaj', 'NBP');
$this->p->writeElement('naDzien', $cur['date']);
$this->p->writeElement('wartosc', $cur['value']);
$this->p->endElement(); // </kurs>
//data transakcji
$cur = $db->fetchByAssoc($db->query("
SELECT * FROM currency_nbp_archive
WHERE currency_id = '".$i['currency_id']."'
AND date < DATE_SUB('".$i['register_date']."', INTERVAL 1 DAY)
ORDER BY date DESC
LIMIT 0,1;
"));
$this->p->startElement('kurs');
$this->p->writeElement('waluta', $cur['currency_name']);
$this->p->writeElement('zastosowanie', 'dataTransakcji');
$this->p->writeElement('rodzaj', 'NBP');
$this->p->writeElement('naDzien', $cur['date']);
$this->p->writeElement('wartosc', $cur['value']);
$this->p->endElement(); // </kurs>
$this->p->endElement(); // </kursy>
}
$this->p->endElement (); // </dokument>
}
}
function getXML() {
$this->p->endElement (); // </paczka>
$this->p->flush ();
}
}
function e($value) {
if (!is_null($value) && $value!='')
return $value;
else
return ' ';
}
?>

View File

@@ -0,0 +1,346 @@
<?php
class maksymaXML {
private $p; // paczka
private $date;
function maksymaXML($date) {
$this->date = $date;
$this->p = new XMLWriter ();
$this->p->openURI ( 'php://output' );
// $this->p->openMemory();
$this->p->startDocument ( '1.0', 'UTF-8' );
$this->p->startElement ( 'paczka' );
$this->p->writeAttribute ( 'firma', 'E5 Polska sp z o.o.' );
$this->p->writeAttribute ( 'wersja', '1' );
$this->p->writeAttribute ( 'miesiac', substr($this->date,5,6));
}
function getInvoices() {
// co z anulowanymi?? :(
$db = $GLOBALS ['db'];
$invoices = $db->query ( "SELECT * FROM ecminvoiceoutolds WHERE deleted='0' AND type='normal' AND register_date LIKE '$this->date%'" );
while ( $i = $db->fetchByAssoc ( $invoices ) ) {
$this->p->startElement ( 'dokument' );
$this->p->writeAttribute ( 'rodzaj', ($i['canceled']=='1'?'!':'').'FVS' . $i ['pdf_type'] );
$this->p->writeAttribute ( 'id', $i['id'] );
$this->p->writeElement ( 'data', $i ['register_date'] );
// dataOperacji = Data WZ? co jeśli WZ jest więcej
$this->p->writeElement ( 'dataOperacji', $i ['register_date'] );
// same story
$this->p->writeElement ( 'dataDostawy', $i ['register_date'] );
$this->p->writeElement ( 'dataWpływu', $i ['register_date'] );
$this->p->writeElement ( 'numer', $i ['document_no'] );
//platnosc
$this->p->startElement('platnosc');
$this->p->writeElement('kwota', $i['total']);
$this->p->writeElement('data', $i['payment_date']);
$this->p->endElement(); //</platnosc>
//kontrahent
$this->p->startElement ( 'kontrahent' );
$this->p->writeAttribute ( 'id', $i ['parent_id'] );
$this->p->writeElement('NIP', e(str_replace ( "-", "", $i ['to_nip'] )));
$this->p->writeElement('nazwa', htmlspecialchars($i['parent_name']));
$this->p->writeElement('adres', htmlspecialchars($i['parent_address_street']));
//jaki numer??
$this->p->writeElement('kodPocztowy', htmlspecialchars($i['parent_address_postalcode']));
$this->p->writeElement('miasto', htmlspecialchars($i['parent_address_city']));
$this->p->writeElement('kraj', htmlspecialchars($i['parent_address_country']));
$this->p->endElement (); // </kontrahent>
//WZ
//co dalej z wz
$wz = $db->fetchByAssoc($db->query("SELECT id, document_no, subtotal, register_date, so_id FROM ecmstockdocouts WHERE id = '".$i['wz_id']."'"));
$this->p->startElement('dokumentyPowiazane');
$this->p->startElement('dokumentPowiazany');
$this->p->writeAttribute('rodzaj', 'WZ');
$this->p->writeAttribute ( 'id', $wz['id'] );
$this->p->writeElement('numer', $wz['document_no']);
$this->p->writeElement('data', $wz['register_date']);
$this->p->writeElement('wartoscNetto', $wz['subtotal']);
$this->p->endElement(); // </dokumentPowiazany>
$this->p->endElement(); //</dokumentyPowiazane>
//pozycje dokumentu
$pozycje = $db->query("
select sum(i.subtotal) as subtotal, p.group_ks, sum(i.quantity) as qty from ecminvoiceoutolditems as i
inner join ecmproducts as p
on p.id=i.ecmproduct_id
where i.ecminvoiceoutold_id='".$i['id']."'
group by p.group_ks;
");
$pp = 0;
global $app_list_strings;
$this->p->startElement('pozycjeDokumentu');
while ($poz = $db->fetchByAssoc($pozycje)) {
$pp++;
if ($poz['group_ks']=='1')
$rodzaj = 'T';
else $rodzaj = 'P';
$this->p->startElement('pozycjaDokumentu');
$this->p->writeElement('tresc', $app_list_strings['ecmproducts_group_ks_dom'][$poz['group_ks']]);
$this->p->writeElement('wartoscNetto', round($poz['subtotal'],2));
$this->p->writeElement('wartoscBrutto', '');
$this->p->writeElement('wartoscVAT', '');
$this->p->endElement(); // </pozycjaDokumentu>
}
$this->p->endElement(); // </pozycjeDokumentu>
//rozbicie
$this->p->startElement('rejestr');
$rozbicie = $db->query("
select sum(i.subtotal) as subtotal, sum(i.total) as total, v.name, v.value from ecminvoiceoutolditems as i
inner join ecmvats as v
on v.id = i.ecmvat_id
where
i.ecminvoiceoutold_id='".$i['id']."'
group by v.id;
");
while ($roz = $db->fetchByAssoc($rozbicie)) {
$this->p->startElement('rozbicie');
$this->p->writeAttribute('stawka', $roz['name']);
$this->p->writeElement('netto', round($roz['subtotal'],2));
$this->p->writeElement('brutto', round($roz['total'],2));
$this->p->writeElement('VAT', round ($roz['total'] - $roz['subtotal'], 2 ));
$this->p->endElement(); // </rozbicie>
}
$this->p->endElement(); // </rejestr>
if ($i['pdf_type']=='K') {
$this->p->writeElement('sumaNetto', round($i['subtotal'],2));
$this->p->writeElement('sumaBrutto', round($i['total'],2));
$this->p->writeElement('sumaVat', round($i['total']-$i['subtotal'],2));
} else {
$this->p->writeElement('sumaNetto', round($i['subtotal']*$i['currency_value'],2));
$this->p->writeElement('sumaBrutto', round($i['total']*$i['currency_value'],2));
$this->p->writeElement('sumaVat', round(($i['total']-$i['subtotal'])*$i['currency_value'],2));
$this->p->writeElement('sumaWalNetto', round($i['subtotal'],2));
$this->p->writeElement('sumaWalBrutto', round($i['total'],2));
$this->p->writeElement('sumaWalVat', round($i['total']-$i['subtotal'],2));
//kursy
$this->p->startElement('kursy');
//data dostawy
$cur = $db->fetchByAssoc($db->query("
SELECT * FROM currency_nbp_archive
WHERE currency_id = '".$i['currency_id']."'
AND date < DATE_SUB((SELECT delivery_date FROM ecmsales WHERE id='".$wz['so_id']."'), INTERVAL 1 DAY)
ORDER BY date DESC
LIMIT 0,1;
"));
$this->p->startElement('kurs');
$this->p->writeElement('waluta', $cur['currency_name']);
$this->p->writeAttribute('zastosowanie', 'dataDostawy');
$this->p->writeElement('rodzaj', 'NBP');
$this->p->writeElement('naDzien', $cur['date']);
$this->p->writeElement('wartosc', $cur['value']);
$this->p->endElement(); // </kurs>
//data transakcji
$cur = $db->fetchByAssoc($db->query("
SELECT * FROM currency_nbp_archive
WHERE currency_id = '".$i['currency_id']."'
AND date < DATE_SUB('".$i['register_date']."', INTERVAL 1 DAY)
ORDER BY date DESC
LIMIT 0,1;
"));
$this->p->startElement('kurs');
$this->p->writeElement('waluta', $cur['currency_name']);
$this->p->writeAttribute('zastosowanie', 'dataTransakcji');
$this->p->writeElement('rodzaj', 'NBP');
$this->p->writeElement('naDzien', $cur['date']);
$this->p->writeElement('wartosc', $cur['value']);
$this->p->endElement(); // </kurs>
$this->p->endElement(); // </kursy>
}
$this->p->endElement (); // </dokument>
}
}
function getCorrectInfoices() {
$db = $GLOBALS ['db'];
$invoices = $db->query ( "SELECT * FROM ecminvoiceoutolds WHERE deleted='0' AND type='correct' AND register_date LIKE '$this->date%'" );
while ( $i = $db->fetchByAssoc ( $invoices ) ) {
$this->p->startElement ( 'dokument' );
$this->p->writeAttribute ( 'rodzaj', ($i['canceled']=='1'?'!':'').'FKS' . $i ['pdf_type'] );
$this->p->writeAttribute ( 'id', $i['id'] );
$this->p->writeElement ( 'data', $i ['register_date'] );
// dataOperacji = Data WZ? co jeśli WZ jest więcej
$this->p->writeElement ( 'dataOperacji', $i ['register_date'] );
// same story
$this->p->writeElement ( 'dataDostawy', $i ['register_date'] );
$this->p->writeElement ( 'dataWpływu', $i ['register_date'] );
$this->p->writeElement ( 'numer', $i ['document_no'] );
//kontrahent
$this->p->startElement ( 'kontrahent' );
$this->p->writeAttribute ( 'id', $i ['parent_id'] );
$this->p->writeElement('NIP', e(str_replace ( "-", "", $i ['to_nip'] )));
$this->p->writeElement('nazwa', htmlspecialchars($i['parent_name']));
$this->p->writeElement('adres', htmlspecialchars($i['parent_address_street']));
//jaki numer??
$this->p->writeElement('kodPocztowy', htmlspecialchars($i['parent_address_postalcode']));
$this->p->writeElement('miasto', htmlspecialchars($i['parent_address_city']));
$this->p->writeElement('kraj', htmlspecialchars($i['parent_address_country']));
$this->p->endElement (); // </kontrahent>
//platnosc
$this->p->startElement('platnosc');
$this->p->writeElement('kwota', $i['total']);
$this->p->writeElement('data', $i['payment_date']);
$this->p->endElement(); //</platnosc>
//multi correct?
$multi = $db->query ( "
SELECT distinct o.ecminvoiceoutold_id
FROM
ecminvoiceoutolditems as ii
INNER JOIN ecminvoiceoutolds as i
ON ii.ecminvoiceoutold_id = i.id
INNER JOIN ecminvoiceoutolditems AS o
ON o.id = ii.ecminvoiceoutolditem_id
WHERE
ii.ecminvoiceoutold_id = '".$i['id']."'");
$multi_correct = false;
if ($multi->num_rows > 1) $multi_correct = true;
if (!$multi_correct) {
//normal correct
$inv_id = $i['ecminvoiceoutold_id'];
$inv_nr = $db->fetchByAssoc($db->query("SELECT id, document_no, register_date FROM ecminvoiceoutolds WHERE id='".$inv_id."'"));
$this->p->startElement('dokumentKorygowany');
$this->p->writeAttribute('rodzaj', 'FVS');
$this->p->writeAttribute ( 'id', $inv_nr['id'] );
$this->p->writeElement('numer', $inv_nr['document_no']);
$this->p->writeElement('data', $inv_nr['register_date']);
$this->p->endElement(); //</dokumentKorygowany>
} else {
//multi correct
$this->p->startElement('dokumentyPowiazane');
while ($inv_id = $db->fetchByAssoc($multi)) {
$inv_nr = $db->fetchByAssoc($db->query("SELECT id, document_no, register_date FROM ecminvoiceoutolds WHERE id='".$inv_id['ecminvoiceoutold_id']."'"));
$this->p->startElement('dokumentPowiazany');
$this->p->writeAttribute('rodzaj', 'FVS');
$this->p->writeAttribute ( 'id', $inv_nr['id'] );
$this->p->writeElement('numer', $inv_nr['document_no']);
$this->p->writeElement('data', $inv_nr['register_date']);
$this->p->endElement(); // </dokumentPowiazany>
}
$this->p->endElement(); //<dokumentyPowiazane>
}
//pozycje dokumentu
$this->p->startElement('pozycjeDokumentu');
$pozycje = $db->query("
select sum(i.subtotal_corrected) as subtotal, p.group_ks, sum(i.quantity_corrected) as qty from ecminvoiceoutolditems as i
inner join ecmproducts as p
on p.id=i.ecmproduct_id
where i.ecminvoiceoutold_id='".$i['id']."'
group by p.group_ks;
");
$pp = 0;
global $app_list_strings;
while ($poz = $db->fetchByAssoc($pozycje)) {
$pp++;
if ($poz['group_ks']=='1')
$rodzaj = 'T';
else $rodzaj = 'P';
$this->p->startElement('pozycjaDokumentu');
$this->p->writeElement('tresc', $app_list_strings['ecmproducts_group_ks_dom'][$poz['group_ks']]);
$this->p->writeElement('wartoscNetto', round($poz['subtotal'],2));
$this->p->writeElement('wartoscBrutto', '');
$this->p->writeElement('wartoscVAT', '');
$this->p->endElement(); // </pozycjaDokumentu>
}
$this->p->endElement(); // </pozycjeDokumentu>
//rozbicie
$this->p->startElement('rejestr');
$rozbicie = $db->query("
select sum(i.subtotal_corrected) as subtotal, sum(i.total_corrected) as total, v.name, v.value from ecminvoiceoutolditems as i
inner join ecmvats as v
on v.id = i.ecmvat_id
where
i.ecminvoiceoutold_id='".$i['id']."'
group by v.id;
");
while ($roz = $db->fetchByAssoc($rozbicie)) {
$this->p->startElement('rozbicie');
$this->p->writeAttribute('stawka', $roz['name']);
$this->p->writeElement('netto', round($roz['subtotal'],2));
$this->p->writeElement('brutto', round($roz['total'],2));
$this->p->writeElement('VAT', round ($roz['total'] - $roz['subtotal'], 2 ));
$this->p->endElement(); // </rozbicie>
}
$this->p->endElement(); // </rejestr>
if ($i['pdf_type']=='K') {
$this->p->writeElement('sumaNetto', round($i['subtotal'],2));
$this->p->writeElement('sumaBrutto', round($i['total'],2));
$this->p->writeElement('sumaVat', round($i['total']-$i['subtotal'],2));
} else {
$this->p->writeElement('sumaNetto', round($i['subtotal']*$i['currency_value'],2));
$this->p->writeElement('sumaBrutto', round($i['total']*$i['currency_value'],2));
$this->p->writeElement('sumaVat', round(($i['total']-$i['subtotal'])*$i['currency_value'],2));
$this->p->writeElement('sumaWalNetto', round($i['subtotal'],2));
$this->p->writeElement('sumaWalBrutto', round($i['total'],2));
$this->p->writeElement('sumaWalVat', round($i['total']-$i['subtotal'],2));
//kursy
$this->p->startElement('kursy');
//data dostawy
$cur = $db->fetchByAssoc($db->query("
SELECT * FROM currency_nbp_archive
WHERE currency_id = '".$i['currency_id']."'
AND date < DATE_SUB((SELECT delivery_date FROM ecmsales WHERE id='".$wz['so_id']."'), INTERVAL 1 DAY)
ORDER BY date DESC
LIMIT 0,1;
"));
$this->p->startElement('kurs');
$this->p->writeElement('waluta', $cur['currency_name']);
$this->p->writeAttribute('zastosowanie', 'dataDostawy');
$this->p->writeElement('rodzaj', 'NBP');
$this->p->writeElement('naDzien', $cur['date']);
$this->p->writeElement('wartosc', $cur['value']);
$this->p->endElement(); // </kurs>
//data transakcji
$cur = $db->fetchByAssoc($db->query("
SELECT * FROM currency_nbp_archive
WHERE currency_id = '".$i['currency_id']."'
AND date < DATE_SUB('".$i['register_date']."', INTERVAL 1 DAY)
ORDER BY date DESC
LIMIT 0,1;
"));
$this->p->startElement('kurs');
$this->p->writeElement('waluta', $cur['currency_name']);
$this->p->writeElement('zastosowanie', 'dataTransakcji');
$this->p->writeElement('rodzaj', 'NBP');
$this->p->writeElement('naDzien', $cur['date']);
$this->p->writeElement('wartosc', $cur['value']);
$this->p->endElement(); // </kurs>
$this->p->endElement(); // </kursy>
}
$this->p->endElement (); // </dokument>
}
}
function getXML() {
$this->p->endElement (); // </paczka>
$this->p->flush ();
}
}
function e($value) {
if (!is_null($value) && $value!='')
return $value;
else
return ' ';
}
$a=new maksymaXML('2014-05-01');
$a->getInvoices();
$a->getXML();
?>

View File

@@ -0,0 +1,124 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*****************************************************************************
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
* Version 1.1 ("License"); You may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/rpl.php. Software distributed under the
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
* either express or implied.
*
* You may:
* a) Use and distribute this code exactly as you received without payment or
* a royalty or other fee.
* b) Create extensions for this code, provided that you make the extensions
* publicly available and document your modifications clearly.
* c) Charge for a fee for warranty or support or for accepting liability
* obligations for your customers.
*
* You may NOT:
* a) Charge for the use of the original code or extensions, including in
* electronic distribution models, such as ASP (Application Service
* Provider).
* b) Charge for the original source code or your extensions other than a
* nominal fee to cover distribution costs where such distribution
* involves PHYSICAL media.
* c) Modify or delete any pre-existing copyright notices, change notices,
* or License text in the Licensed Software
* d) Assert any patent claims against the Licensor or Contributors, or
* which would in any way restrict the ability of any third party to use the
* Licensed Software.
*
* You must:
* a) Document any modifications you make to this code including the nature of
* the change, the authors of the change, and the date of the change.
* b) Make the source code for any extensions you deploy available via an
* Electronic Distribution Mechanism such as FTP or HTTP download.
* c) Notify the licensor of the availability of source code to your extensions
* and include instructions on how to acquire the source code and updates.
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
* reproduce, perform, modify, sublicense, and distribute your extensions.
*
* The Original Code is: CommuniCore
* Olavo Farias
* 2006-04-7 olavo.farias@gmail.com
*
* The Initial Developer of the Original Code is CommuniCore.
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
* All Rights Reserved.
********************************************************************************/
$searchFields['EcmInvoiceOutOlds'] = array (
'name' => array ( 'query_type' => 'default' ),
'description' => array ( 'query_type' => 'default' ),
'current_user_only' => array ( 'query_type' => 'default', 'db_field' => array ( 'assigned_user_id' ), 'my_items' => true ),
'assigned_user_id' => array ( 'query_type' => 'default' ),
'status' => array ( 'query_type' => 'default' ),
'register_date' => array ( 'query_type' => 'default' ),
'parent_name' => array( 'query' => 'default' ),
);
?>

View File

@@ -0,0 +1,336 @@
<?php
/* * *******************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU 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 General Public License for more
* details.
*
* You should have received a copy of the GNU 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 General Public License version 3.
*
* In accordance with Section 7(b) of the GNU 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".
* ****************************************************************************** */
global $app_list_strings;
$viewdefs['EcmInvoiceOutOlds']['DetailView'] = array(
'templateMeta' => array(
'form' => array(
'buttons' => array(
array(
'customCode' => '{if $bean->aclAccess("edit") && $bean->status=="registered"}<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="button" onclick="this.form.return_module.value=\'EcmInvoiceOutOlds\'; this.form.return_action.value=\'DetailView\'; this.form.return_id.value=\'{$id}\'; this.form.action.value=\'EditView\';" type="submit" name="Edit" id="edit_button" value="{$APP.LBL_EDIT_BUTTON_LABEL}">{/if}'
),
// array(
// 'customCode' => '{if $bean->aclAccess("edit") && $bean->status=="registered"}<input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="button" onclick="this.form.return_module.value=\'EcmQuestionnaires\'; this.form.return_action.value=\'DetailView\'; this.form.isDuplicate.value=true; this.form.action.value=\'EditView\'; this.form.return_id.value=\'{$id}\';" type="submit" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}" id="duplicate_button">{/if}'
// ),
// array(
// 'customCode' => '{if $bean->aclAccess("delete") && $bean->status=="registered"}<input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="button" onclick="this.form.return_module.value=\'EcmQuestionnaires\'; this.form.return_action.value=\'ListView\'; this.form.action.value=\'Delete\'; return confirm(\'{$APP.NTC_DELETE_CONFIRMATION}\');" type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}">{/if}'
// ),
/*
array(
'customCode' => '<input name="invoiceout_pdf" id="invoiceout_pdf" title="{$MOD.LBL_INVOICEOUT_PDF_BUTTON_TITLE}" accessKey="{$MOD.LBL_INVOICEOUT_PDF_BUTTON_KEY}" class="button" onclick="window.location = \'index.php?module=EcmInvoiceOutOlds&action=previewPDF&to_pdf=1&record={$fields.id.value}\';" type="button" value="{$MOD.LBL_INVOICEOUT_PDF}">'
), */
array(
'customCode' => '{$CATALOGUE}'
),
array(
'customCode' => '<input name="create_correct" id="create_correct" title="{$MOD.LBL_CORRECT_TITLE}" class="button" onclick="window.location = \'index.php?module=EcmInvoiceOuts&offset=1&return_module=EcmInvoiceOuts&action=EditView&return_action=index&record={$fields.id.value}&isCorrect=true\';" type="button" value="{$MOD.LBL_CORRECT}">'
),
// array(
// 'customCode' => '{if $bean->type=="correct" && !$hasCorrect}<input name="create_ks" id="create_ks" title="Create KS Document" class="button" onclick="window.location = \'index.php?module=EcmStockDocCorrects&out_module=EcmInvoiceOutOlds&action=EditView&out_id={$fields.id.value}\';" type="button" value="Create KS Document">{/if}'
// ),
// array(
// 'customCode' => '{if $bean->aclAccess("edit") && $fields.accepted.value == 1 && $OPT.user.confirm_invoiceouts == 1}<input title="{$MOD.LBL_REPAIR_BUTTON_TITLE}" accessKey="{$MOD.LBL_REPAIR_BUTTON_KEY}" class="button" onclick="window.location = \'index.php?module=EcmInvoiceOutOlds&action=DetailView&record={$fields.id.value}&status=not_accepted&return_module=\'+this.form.return_module.value+\'&return_action=\'+this.form.return_action.value+\'&return_id=\'+this.form.return_id.value;" type="button" name="Repair" id="repair_button" value="{$MOD.LBL_REPAIR_BUTTON_LABEL}">{/if}'
// ),
// array(
// 'customCode' => '<input title="" accessKey="" class="button" onclick="window.location = \'index.php?module=EcmInvoiceOutOlds&action=downloadXML&record={$fields.id.value}\'" type="button" name="Repair" id="repair_button" value="Create XML">'
// ),
// array(
// 'customCode' => '<input title="" accessKey="" class="button" onclick="window.location = \'index.php?module=EcmInvoiceOutOlds&action=downloadXML&record={$fields.id.value}&duplicate=1\'" type="button" name="c_dup_xml" id="c_dup_xml" value="Create Duplicate XML">'
// ),
// array(
// 'customCode' => '<input name="workreport_to_invoice" id="workreport_to_invoice" title="{$MOD.LBL_WORKREPORT_TO_INVOICE_BUTTON_TITLE}" accessKey="{$MOD.LBL_WORKREPORT_TO_INVOICE_BUTTON_KEY}" class="button" onclick="window.location = \'index.php?module=EcmInvoiceOutOlds&action=EditView&work_report_record={$fields.id.value}\';" type="button" value="{$MOD.LBL_WORKREPORT_TO_INVOICE}">'
// ),
),
'hidden' => array(
'<input type="hidden" name="position_list" id="position_list" value=\'{$POSITION_LIST}\'>',
//'<input type="hidden" name="discount" id="discount" value=\'{$fields.discount.value}\'>',
//'<input type="hidden" name="parent_type" id="parent_type" value="{$fields.parent_type.value}">',
'<input type="hidden" name="parent_id" id="parent_id" value="{$fields.parent_id.value}">',
'<input type="hidden" name="assigned_user_id" id="assigned_user_id" value="{$fields.assigned_user_id.value}">',
'<input type="hidden" name="email_id" id="email_id" value="">',
'<span id="quickInfoH2" style="display:none;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>{$fields.document_no.value}</span> - <span>{$fields.parent_name.value}</span> - <span>{$fields.parent_contact_name.value}</span> - <span>{$fields.parent_address_street.value}</span>&nbsp; &nbsp;<span>{$fields.parent_address_postalcode.value}</span>&nbsp;<span>{$fields.parent_address_city.value}</span>&nbsp; &nbsp;<span>{$fields.parent_address_country.value}</span> - <span id="total_h">{$fields.total.value}</span></span>'
),
),
'maxColumns' => '2',
'widths' => array(
array('label' => '10', 'field' => '30'),
array('label' => '10', 'field' => '30')
),
'includes' => array(
array('file' => 'include/JSON.js'),
array('file' => 'modules/EcmInvoiceOutOlds/MyTable.js'),
array('file' => 'include/ECM/EcmPreviewPDF/EcmPreviewPDF.js'),
array('file' => 'modules/EcmInvoiceOutOlds/EcmInvoiceOutOldsDetailView.js'),
),
),
'panels' => array(
'LBL_DETAILS_TAB' => array(
array(
'document_no',
'assigned_user_name'
),
array(
'parent_name',
'type'
),
array(
'register_date',
array(
'name' => 'ecmpaymentcondition_name',
'customCode' => '{$fields.ecmpaymentcondition_name.value}',
),
),
array(
'sell_date',
array (
'name' => 'ecminvoiceout_name',
'tabIndex' => '1',
'customCode' => '{$INVOICES_INFO}',
)
),
array(
'payment_date',
'template_name',
),
array('name', 'description'),
array(
'order_no',
'supplier_code',
),
array(
array(
'name' => 'to_informations',
'allCols' => true,
'hideLabel' => true,
'customCode' => '<div class="tabForm" style="border-top:none;width:100%;height:1px;padding:0px;align:center;"></div><h4>{$MOD.LBL_TO_PAYMENTS}</h4>'
),
),
array(
array(
'name' => 'to',
'label' => 'LBL_TO_PAID',
'customCode' => '{$TO_PAID}',
),
'payment_date_d',
),
array(
'prepaid',
'payment_date',
),
array(
'prepaid_nr',
'payment_method',
),
array(
'paid_val',
'payment_method_paid'
),
array(
array(
'name' => 'left',
'label' => 'LBL_LEFT',
'customCode' => '{$LEFT}',
),
array(
'name' => 'weight_total',
'label' => 'LBL_WEIGHT_NETTO',
'customCode' => '{$WEIGHT_TOTAL}',
),
),
array(
array(
'name' => 'to_informations',
'allCols' => true,
'hideLabel' => true,
'customCode' => '<div class="tabForm" style="border-top:none;width:100%;height:1px;padding:0px;align:center;"></div><h4>{$MOD.LBL_TO_INFORMATIONS}</h4>'
),
),
array(
'parent_name',
'to_nip'
),
array(
array(
'name' => 'parent_contact_name',
'customCode' => '{$fields.parent_contact_title.value} {$fields.parent_contact_name.value}'
),
array('name' => 'currency_id', 'label' => 'LBL_CURRENCY')
),
array(
'parent_address_street',
//'currency_value',
),
array(
array(
'name' => 'parent_address_city',
'customCode' => '{$fields.parent_address_postalcode.value} {$fields.parent_address_city.value}',
),
array('name' => 'pdf_type', 'label' => 'LBL_PDF_TYPE'),
),
array(
'parent_address_country'
),
array(
array(
'name' => 'to_informations',
'allCols' => true,
'hideLabel' => true,
'customCode' => '<div class="tabForm" style="border-top:none;width:100%;height:1px;padding:0px;align:center;"></div><h4>{$MOD.LBL_PARENT_SHIPPING_ADDRESS}</h4>'
),
),
array('parent_shipping_address_name'),
array('parent_shipping_address_street'),
array(
array(
'name' => 'parent_shipping_address_city',
'customCode' => '{$fields.parent_shipping_address_postalcode.value} {$fields.parent_shipping_address_city.value}'
),
),
array('parent_shipping_address_country'),
),
'LBL_ITEMS_TAB' => array(
array(
array(
'name' => 'items_list_panel',
'allCols' => true,
'hideLabel' => true,
'customCode' => '
'
// .'{literal}'.
// '<script language="javascript">var parent_options='.$json->encode($app_list_strings['ecmworkitems_parent_dom']).';</script>'
// .'{/literal}'.
. '
<link rel="stylesheet" type="text/css" href="modules/EcmInvoiceOutOlds/MyTable.css" />
<div style="width:100%;border: 1px solid rgb(48,192,255);background-color:white;height:{$OPT.position_table_height}px;max-height:{$OPT.position_table_height}px;overflow:auto;">
<table class="positions" style="width:100%;" id="itemsTable">
<thead id="head">
<tr id="tr">
<td width="4%">{$MOD.LBL_EDITTABLE_NO}</td>
<td width="10%">{$MOD.LBL_EDITTABLE_CODE}</td>
<td width="37%">{$MOD.LBL_EDITTABLE_NAME}</td>
<td width="5%">{$MOD.LBL_EDITTABLE_QUANTITY}</td>
<td width="8%">{$MOD.LBL_EDITTABLE_UNIT}</td>
<td width="10%">{$MOD.LBL_EDITTABLE_PRICE_SUB}</td>
<td width="6%">{$MOD.LBL_EDITTABLE_DISCOUNT}</td>
<td width="10%">{$MOD.LBL_EDITTABLE_PRICE}<br>(netto / brutto)</td>
<td width="6%">{$MOD.LBL_EDITTABLE_VAT}</td>
<td width="10%">{$MOD.LBL_EDITTABLE_TOTAL}<br>(netto / brutto)</td>
</tr>
</thead>
<tbody id="tbody">
</tbody>
</table>
</div>
<table width="100%"" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="55%" class="dataLabel" valign="top">
&nbsp;
</td> <!--color:#b3b9cf;-->
<td width="40%" class="dataField" style="text-align: left;">
<br>
<table id="result_table" cellpadding="0" cellspacing="0" style="width:100%; height:100%; border: 1px solid rgb(48,192,255);">
<tr id="subtotal_tr">
<td class="positionsLabel" style="border-top:0px;">{$MOD.LBL_SUBTOTAL}</td>
<td class="positionsField" style="border-top:0px;"><input type="text" style="border:0px;font-weight:900;width:100%;text-align:right;" readonly="readonly" name="subtotal" id="subtotal" value=\'{$fields.subtotal.value}\'></td>
</tr>
<tr id="total_tr">
<td class="positionsLabel">{$MOD.LBL_TOTAL}</td>
<td class="positionsField"><input type="text" readonly="readonly" style="border:0px;font-weight:900;width:100%;text-align:right;" name="total" id="total" value=\'{$fields.total.value}\'></td>
</tr>
</table>
</td>
<td width="5%" class="dataField" style="text-align: left;">&nbsp;</td>
</tr>
</table>
',
)
),
),
'LBL_TEXTS_TAB' => array(
array('header_text'),
array('footer_text'),
array('ads_text'),
),
// 'LBL_PREVIEW_TAB' => array(
// array(
// array(
// 'name' => 'preview_panel',
// 'allCols' => true,
// 'hideLabel' => true,
// 'customCode' => '<span id="previewPDF" width="100%" height="100%"></span>'
// ),
// ),
// ),
/*
'LBL_PREVIEW_TAB' => array(
array(
array(
'name' => 'preview_panel',
'allCols' => true,
'hideLabel' => true,
'customCode' =>
'
<select id="preview_type" name="preview_type">
<option value="">Faktura</option>
<option value="exp">Lista rozchodowa</option>
<option value="pl">Specyfikacja wysyłki</option>
</select>
<input type="button" class="button" onClick="preview_pdf();" value="Generuj"/>
<hr/>
<span id="previewPDF" width="100%" height="100%"></span>
',
),
),
),*/
// 'LBL_EMAIL_TAB' => array(
// array(
// array(
// 'name' => 'email_panel',
// 'allCols' => true,
// 'hideLabel' => true,
// 'customCode' => '{$EMAIL_LINK_TAB}<span id="emailTAB" width="100%" height="100%"></span>'
// ),
// ),
// ),
),
);
?>

View File

@@ -0,0 +1,364 @@
<?php
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU 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 General Public License for more
* details.
*
* You should have received a copy of the GNU 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 General Public License version 3.
*
* In accordance with Section 7(b) of the GNU 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".
* *******************************************************************************/
global $sugar_config;
/*
if((!isset($focus->footer_text) || $focus->footer_text == '') && (!isset($focus->name) || $focus->name == '') && (!isset($focus->id) || $focus->id == '')) $focus->footer_text = translate('LBL_DEFAULT_FOOTER_TEXT', 'EcmDocumentTemplates');
if((!isset($focus->header_text) || $focus->header_text == '') && (!isset($focus->name) || $focus->name == '') && (!isset($focus->id) || $focus->id == '')) $focus->header_text = translate('LBL_DEFAULT_HEADER_TEXT', 'EcmDocumentTemplates');
*/
$viewdefs['EcmInvoiceOutOlds']['EditView'] = array (
'templateMeta' => array (
'form' => array (
'enctype'=>'multipart/form-data',
'buttons'=>array(
array('customCode' => '<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button" onclick="return SaveForm();" type="button" name="button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">'),
array('customCode' => '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="window.location=\'index.php?module=EcmInvoiceOutOlds&action=index\';" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}">'),
array('customCode' => '<input class="button" onclick="test();" type="button" name="button" value="test">'),
//todo: create 'cancel function in js
),
'hidden'=>array(
'<input type="hidden" name="position_list" id="position_list" value=\'{$POSITION_LIST}\'>',
'<input type="hidden" name="parent_type" id="parent_type" value="{$PARENT_TYPE}">',
'<input type="hidden" name="parent_doc_id" id="parent_doc_id" value="{$PARENT_DOC_ID}">',
'<input type="hidden" name="temp_id" id="temp_id" value=\'{$TEMP_ID}\'>',
'<input type="hidden" name="ecmlanguage" id="ecmlanguage" value=\'\'>',
),
),
'maxColumns' => '2',
'widths' => array (
array('label' => '10', 'field' => '30'),
array('label' => '10', 'field' => '30'),
),
'includes' => array(
array('file'=>'include/JSON.js'),
array('file'=>'include/javascript/quicksearch.js'),
array('file'=>'include/ECM/EcmPreviewPDF/EcmPreviewPDF.js'),
array('file'=>'modules/EcmInvoiceOutOlds/AjaxSearch/AjaxSearch.js'),
array('file'=>'modules/EcmInvoiceOutOlds/formloader.js'),
array('file'=>'modules/EcmInvoiceOutOlds/MyTable.js'),
array('file'=>'modules/EcmInvoiceOutOlds/EcmInvoiceOutOlds.js'),
array('file'=>'modules/EcmProducts/mintajax.js'),
array('file'=>'modules/EcmProducts/helper.js'),
),
),
'panels' => array (
'LBL_DETAILS_TAB'=> array(
array(
array(
'name' => 'document_no',
'tabIndex' => 'f',
'customCode' => '<div id="tst" style="display:none;"></div><input readonly="readonly" type="text" name="document_no" id="document_no" value=\'{$fields.document_no.value}\'>
<input type="hidden" name="number" id="number" value=\'{$fields.number.value}\'>'
),
'assigned_user_name'
),
array (
'parent_name',
'type'
),
array(
array ( 'name' => 'parent_index_dbf',
'customCode' => '<div name=\'parent_index_dbf\' id=\'parent_index_dbf\'></div>',
),
array(
'name' => 'template_name',
'label'=>'LBL_TEMPLATE_NAME',
'customCode'=>'<select id="template_id" name="template_id" onChange="document.getElementById(\'template_name\').value=this.options[this.selectedIndex].text;">{$DOCUMENT_TEMPLATES_OPTIONS}</select><input type="hidden" id="template_name" name="template_name" value="{$fields.template_name.value}">'
),
),
array (
array (
'name' => 'register_date',
'type' => 'datetime',
'displayParams'=>array('showFormats'=>true)
),
'ecminvoiceoutold_name'
),
array (
array (
'name' => 'sell_date',
'type' => 'datetime',
'displayParams'=>array('showFormats'=>true)
),
array(
'label'=>'LBL_STOCK_NAME',
'name'=>'stock_id',
'customCode'=>'<select name="stock_id" id="stock_id">{$STOCK}</select>',
),
),
array (
array (
'name' => 'name',
'label' => 'LBL_NAME',
),
),
array(
'order_no',
'supplier_code',
),
array (
/*
array (
'name' => 'discount',
'tabindex' => 'd',
'customCode' => '<input type="text" name="discount" id="discount" value="{$fields.discount.value}" onChange="if(CheckDiscount() != -1) calculateTotal();" onKeyDown="return N.KeyPressed(event,this.parentNode,\'decimalNumber\');" >%',
)
*/
),
//payment 9informations
array(
array(
'name' => 'to_informations',
'allCols' => true,
'hideLabel' => true,
'customCode' => '<div class="tabForm" style="border-top:none;width:100%;height:1px;padding:0px;align:center;"></div><h4>{$MOD.LBL_TO_PAYMENTS}</h4>'
),
),
//end payment informations
array(
array(
'name' => 'to_paid',
'label'=> 'LBL_TO_PAID',
'customCode' => '<div id="to_paid"></div>',
),
'ecmpaymentcondition_name',
),
array(
'prepaid',
'payment_date',
),
array(
'prepaid_nr',
//'payment_method',
),
array(
'paid_val',
'payment_method_paid'
),
array(
array(
'name' => 'left',
'label' => 'LBL_LEFT',
'customCode' => '<div id="left"></div>',
),
),
array(
array(
'name' => 'to_informations',
'allCols' => true,
'hideLabel' => true,
'customCode' => '<div class="tabForm" style="border-top:none;width:100%;height:1px;padding:0px;align:center;"></div><h4>{$MOD.LBL_TO_INFORMATIONS}</h4>'
),
),
array (
array(
'name' => 'parent_name_copy',
'tabIndex' => '1',
'customCode' => '<input type="text" name="parent_name_copy" id="parent_name_copy" value="{$fields.parent_name.value}" readOnly="readonly" size="30" />'
),
array(
'name' => 'to_nip',
'tabIndex' => '1',
),
),
array (
array(
'name' => 'parent_contact_name',
'tabIndex' => '1',
),
array('name'=>'currency_id','label'=>'LBL_CURRENCY'),
),
array (
array(
'name' => 'parent_contact_title',
'tabIndex' => '1',
),
//array('name'=>'currency_value','label'=>'LBL_CURRENCY_VALUE'),
),
array (
array(
'name' => 'parent_address_street',
'tabIndex' => '1',
'customCode' => '<textarea tabindex="1" id="parent_address_street" name="parent_address_street" rows="2" cols="30" maxlength="150" >{$fields.parent_address_street.value}</textarea>',
),
array('name'=>'pdf_type','label'=>'LBL_PDF_TYPE'),
),
array (
array(
'name' => 'parent_address_city',
'tabIndex' => '1',
'customCode' => '<input maxlength="8" type="text" name="parent_address_postalcode" id="parent_address_postalcode" value="{$fields.parent_address_postalcode.value}" style="vertical-align:top;width:80px;" />&nbsp;&nbsp;<input type="text" name="parent_address_city" id="parent_address_city" value="{$fields.parent_address_city.value}" style="vertical-align:top;width:150px;" />'
),
array('name'=>'currency_value_nbp','label'=>'LBL_CURRENCY_VALUE_NBP'),
),
array (
array(
'name' => 'parent_address_country',
'tabIndex' => '1',
),
),
array(
array(
'name' => 'to_informations',
'allCols' => true,
'hideLabel' => true,
'customCode' => '<div class="tabForm" style="border-top:none;width:100%;height:1px;padding:0px;align:center;"></div><h4>{$MOD.LBL_PARENT_SHIPPING_ADDRESS}</h4>'
),
),
array(
array(
'name' => 'address',
'customCode' => '<div id=\'addresses\'></div>',
), '',
),
array('parent_shipping_address_name'),
array('parent_shipping_address_street'),
array (
array(
'name' => 'parent_shipping_address_city',
'tabIndex' => '1',
'customCode' => '<input maxlength="8" type="text" name="parent_shipping_address_postalcode" id="parent_shipping_address_postalcode" value="{$fields.parent_shipping_address_postalcode.value}" style="vertical-align:top;width:80px;" />&nbsp;&nbsp;<input type="text" name="parent_shipping_address_city" id="parent_shipping_address_city" value="{$fields.parent_shipping_address_city.value}" style="vertical-align:top;width:150px;" />'
),
),
array('parent_shipping_address_country'),
),
'LBL_ITEMS_TAB'=> array(
array(
array(
'name' => 'items_list_panel',
'allCols' => true,
'hideLabel' => true,
'customCode' => '
<link rel="stylesheet" type="text/css" href="modules/EcmInvoiceOutOlds/MyTable.css" />
<link rel="stylesheet" type="text/css" href="modules/EcmInvoiceOutOlds/AjaxSearch/AjaxSearch.css" />
<div style="width:100%;border: 1px solid rgb(48,192,255);background-color:white;height:{$OPT.position_table_height}px;max-height:{$OPT.position_table_height}px;overflow:auto;" id="itemsTableDIV">
<table class="positions" style="width:100%;" id="itemsTable">
<thead id="head">
<tr id="tr">
<td width="4%">{$MOD.LBL_EDITTABLE_NO}</td>
<td width="10%">{$MOD.LBL_EDITTABLE_CODE}</td>
<td width="37%">{$MOD.LBL_EDITTABLE_NAME}</td>
<td width="5%">{$MOD.LBL_EDITTABLE_QUANTITY}</td>
<td width="10%">{$MOD.LBL_EDITTABLE_PRICE_SUB}</td>
<td width="6%">{$MOD.LBL_EDITTABLE_DISCOUNT}</td>
<td width="6%">{$MOD.LBL_EDITTABLE_VAT}</td>
<td width="10%">{$MOD.LBL_EDITTABLE_PRICE}<br>(netto / brutto)</td>
<td width="8%">{$MOD.LBL_EDITTABLE_UNIT}</td>
<td width="10%">{$MOD.LBL_EDITTABLE_TOTAL}<br>(netto / brutto)</td>
<td width="8%">Kod odb.</td>
<td width="8%">{$MOD.LBL_EDITTABLE_STOCK}</td>
<td width="10%">{$MOD.LBL_EDITTABLE_OPTIONS}</td>
</tr>
</thead>
<tbody id="tbody">
</tbody>
</table>
</div>
<table width="100%"" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="55%" class="dataLabel" valign="top">
<a href="javascript: N.moveUpRow();" >{$MOD.LBL_MOVE_ROW_UP}</a> - <a href="javascript: N.moveDownRow();" >{$MOD.LBL_MOVE_ROW_DOWN}</a>
</td> <!--color:#b3b9cf;-->
<td width="40%" class="dataField" style="text-align: left;">
<br>
<table id="result_table" cellpadding="0" cellspacing="0" style="width:100%; height:100%; border: 1px solid rgb(48,192,255);">
<tr id="subtotal_tr">
<td class="positionsLabel" style="border-top:0px;">{$MOD.LBL_SUBTOTAL}</td>
<td class="positionsField" style="border-top:0px;"><input type="text" style="border:0px;font-weight:900;width:100%;text-align:right;" readonly="readonly" name="subtotal" id="subtotal" value=\'{$fields.subtotal.value}\'></td>
</tr>
<tr id="total_tr">
<td class="positionsLabel">{$MOD.LBL_TOTAL}</td>
<td class="positionsField"><input type="text" readonly="readonly" style="border:0px;font-weight:900;width:100%;text-align:right;" name="total" id="total" value=\'{$fields.total.value}\'></td>
</tr>
</table>
</td>
<td width="5%" class="dataField" style="text-align: left;">&nbsp;</td>
</tr>
</table>
',
)
),
),
'LBL_TEXTS_TAB'=> array(
array(array('name' => 'header_text', 'label' => 'LBL_HEADER_TEXT','customCode' => '{$MFP.footer}<br /><textarea id="header_text" name="header_text" rows="5" style="width:100%;">{$fields.header_text.value}</textarea>'),),
array(array('name' => 'footer_text', 'label' => 'LBL_FOOTER_TEXT','customCode' => '{$MFP.header}<br /><textarea id="footer_text" name="footer_text" rows="5" style="width:100%;">{$fields.footer_text.value}</textarea>'),),
array(array('name' => 'ads_text', 'label' => 'LBL_ADS_TEXT','customCode' => '{$MFP.ads}<br /><textarea id="ads_text" name="ads_text" rows="5" style="width:100%;">{$fields.ads_text.value}</textarea>'),),
),
),
);
?>

View File

@@ -0,0 +1,234 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*****************************************************************************
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
* Version 1.1 ("License"); You may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/rpl.php. Software distributed under the
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
* either express or implied.
*
* You may:
* a) Use and distribute this code exactly as you received without payment or
* a royalty or other fee.
* b) Create extensions for this code, provided that you make the extensions
* publicly available and document your modifications clearly.
* c) Charge for a fee for warranty or support or for accepting liability
* obligations for your customers.
*
* You may NOT:
* a) Charge for the use of the original code or extensions, including in
* electronic distribution models, such as ASP (Application Service
* Provider).
* b) Charge for the original source code or your extensions other than a
* nominal fee to cover distribution costs where such distribution
* involves PHYSICAL media.
* c) Modify or delete any pre-existing copyright notices, change notices,
* or License text in the Licensed Software
* d) Assert any patent claims against the Licensor or Contributors, or
* which would in any way restrict the ability of any third party to use the
* Licensed Software.
*
* You must:
* a) Document any modifications you make to this code including the nature of
* the change, the authors of the change, and the date of the change.
* b) Make the source code for any extensions you deploy available via an
* Electronic Distribution Mechanism such as FTP or HTTP download.
* c) Notify the licensor of the availability of source code to your extensions
* and include instructions on how to acquire the source code and updates.
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
* reproduce, perform, modify, sublicense, and distribute your extensions.
*
* The Original Code is: CommuniCore
* Olavo Farias
* 2006-04-7 olavo.farias@gmail.com
*
* The Initial Developer of the Original Code is CommuniCore.
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
* All Rights Reserved.
********************************************************************************/
$listViewDefs["EcmInvoiceOutOlds"] = array(
'ECMPAYMENTCONDITION_NAME'=>array(
'label'=>'LBL_PAYMENTCONDITION_NAME',
),
'CONTACT_NAME'=>array(
'label'=>'LBL_CONTACT_NAME',
),
'ECMLANGUAGE'=>array(
'label'=>'LBL_ECMLANGUAGE',
),
'DISCOUNT'=>array(
'label'=>'LBL_DISCOUNT',
),
'PARENT_NAME_COPY'=>array(
'label'=>'LBL_PARENT_NAME_COPY',
),
'PARENT_CONTACT_NAME'=>array(
'label'=>'LBL_PARENT_CONTACT_NAME',
),
'PARENT_CONTACT_TITLE'=>array(
'label'=>'LBL_PARENT_CONTACT_TITLE',
),
'TO_IS_VAT_FREE'=>array(
'label'=>'LBL_TO_IS_VAT_FREE',
),
'TO_VATID'=>array(
'label'=>'LBL_TO_VATID',
),
'PARENT_ADDRESS_STREET'=>array(
'label'=>'LBL_PARENT_ADDRESS_STREET',
),
'PARENT_ADDRESS_POSTALCODE'=>array(
'label'=>'LBL_PARENT_ADDRESS_POSTALCODE',
),
'PARENT_ADDRESS_COUNTRY'=>array(
'label'=>'LBL_PARENT_ADDRESS_COUNTRY',
),
'PARENT_ADDRESS_CITY'=>array(
'label'=>'LBL_PARENT_ADDRESS_CITY',
),
'STATUS' => array(
'width' => '3',
'label' => '&nbsp;',
'default' => true,
'sortable' => true,
),
'NUMBER' => array(
'width' => '12',
'label' => 'n',
'sortable' => true,
'default' => true,
),
'DOCUMENT_NO' => array(
'width' => '12',
'label' => 'LBL_DOCUMENT_NO',
'sortable' => true,
'link' => true,
'default' => true,
),
'TYPE' => array(
'width' => '10',
'label' => 'LBL_TYPE',
'default' => true,
),
'NAME' => array(
'width' => '20',
'label' => 'LBL_NAME',
'default' => true,
'link'=>true,
'sortable' => false),
'PARENT_ID' => array(
'width'=>'1',
'sortable'=>false,
'label'=>'&nbsp;',
'default'=>true,
'customCode'=>' ',
),
'PARENT_NAME' => array(
'width' => '15',
'label' => 'LBL_PARENT_NAME',
'default' => true,
'link'=>true,
'module'=>'Accounts',
'id'=>'PARENT_ID',
),
'TOTAL' => array(
'width' => '10',
'label' => 'LBL_TOTAL',
'default' => false,
),
'PDF_SUBTOTAL' => array(
'width' => '10',
'label' => 'Suma netto',
'default' => true,
),
'PAID' => array(
'width' => '3',
'label' => 'Paid',
'default' => false,
),
'MODIFIED_BY_NAME' => array(
'width' => '10',
'label' => 'LBL_MODIFIED_USER',
'module' => 'Users',
'id' => 'USERS_ID',
'default' => false,
'sortable' => false,
'related_fields' => array('modified_user_id'),
),
'REGISTER_DATE' => array(
'width' => '15',
'label' => 'LBL_REGISTER_DATE',
'default' => true,
'sortable' => true,
),
'CORRECT' => array(
'width' => '15',
'label' => 'Korekta',
'default' => true,
'sortable' => false,
),
'ASSIGNED_USER_NAME' => array(
'width' => '10',
'label' => 'LBL_LIST_ASSIGNED_USER',
'default' => true
),
/*
'CONVERT' => array(
'width' => '2',
'label' => '&nbsp;',
'link' => true,
'default' => true,
'sortable' => false,
'customCode' => '<a href="index.php?module=EcmInvoiceOutOlds&action=EditView&out_id={$ID}&out_module=EcmInvoiceOutOlds&return_module=EcmInvoiceOutOlds&return_action=index"><img border="0" src="modules/EcmInvoiceOutOlds/images/convert.gif" title="'.translate('LBL_LIST_TO_INVOICE','EcmInvoiceOutOlds').'" /></a>'
),
*/
/*
'PDF_URL' => array(
'width' => '2',
'label' => '&nbsp;',
'link' => false,
'default' => true,
'sortable' => false,
),
'CORRECT' => array(
'width' => '2',
'label' => '&nbsp;',
'default' => true,
'customCode' => '<a href="index.php?module=EcmInvoiceOutOlds&offset=1&return_module=EcmInvoiceOutOlds&action=EditView&return_action=index&record={$ID}&isCorrect=true"><img border="0" src="modules/EcmInvoiceOutOlds/images/correct.jpg" title="Correct" /></a>',
'sortable' => false,
),
'DUPLICATE' => array(
'width' => '2',
'label' => '&nbsp;',
'default' => true,
'customCode' => '<a href="index.php?module=EcmInvoiceOutOlds&action=EditView&record={$ID}&isDuplicate=true"><img border="0" src="modules/EcmInvoiceOutOlds/images/duplicate.jpg" title="Duplicate" /></a>',
'sortable' => false,
),
'OPTIONS' => array(
'label' => '&nbsp;',
'default' => true,
'sortable' => false,
)
*/
);
?>

View File

@@ -0,0 +1,139 @@
<?php
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU 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 General Public License for more
* details.
*
* You should have received a copy of the GNU 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 General Public License version 3.
*
* In accordance with Section 7(b) of the GNU 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".
********************************************************************************/
$searchdefs['EcmInvoiceOutOlds'] = array (
'templateMeta' => array (
'maxColumns' => '3',
'widths' => array (
'label' => '10',
'field' => '30'
),
),
'layout' => array (
'basic_search' => array (
'document_no',
'status',
'type',
'parent_name',
'register_date',
'wz_name',
'assigned_user_name',
'order_no',
'suppllier_code',
),
'advanced_search' => array (
'name',
'assigned_user_name',
'parent_name',
'ecmpaymentcondition_name',
'contact_name',
'status',
'type',
'ecmlanguage',
'register_date',
'discount',
'parent_name_copy',
'parent_contact_name',
'parent_contact_title',
'to_is_vat_free',
'show_images_on_offers',
'show_recipient_code',
'to_vatid',
'total',
'parent_address_street',
'parent_address_postalcode',
'parent_address_country',
'parent_address_city',
),
),
);
?>

View File

@@ -0,0 +1,152 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*****************************************************************************
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
* Version 1.1 ("License"); You may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/rpl.php. Software distributed under the
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
* either express or implied.
*
* You may:
* a) Use and distribute this code exactly as you received without payment or
* a royalty or other fee.
* b) Create extensions for this code, provided that you make the extensions
* publicly available and document your modifications clearly.
* c) Charge for a fee for warranty or support or for accepting liability
* obligations for your customers.
*
* You may NOT:
* a) Charge for the use of the original code or extensions, including in
* electronic distribution models, such as ASP (Application Service
* Provider).
* b) Charge for the original source code or your extensions other than a
* nominal fee to cover distribution costs where such distribution
* involves PHYSICAL media.
* c) Modify or delete any pre-existing copyright notices, change notices,
* or License text in the Licensed Software
* d) Assert any patent claims against the Licensor or Contributors, or
* which would in any way restrict the ability of any third party to use the
* Licensed Software.
*
* You must:
* a) Document any modifications you make to this code including the nature of
* the change, the authors of the change, and the date of the change.
* b) Make the source code for any extensions you deploy available via an
* Electronic Distribution Mechanism such as FTP or HTTP download.
* c) Notify the licensor of the availability of source code to your extensions
* and include instructions on how to acquire the source code and updates.
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
* reproduce, perform, modify, sublicense, and distribute your extensions.
*
* The Original Code is: CommuniCore
* Olavo Farias
* 2006-04-7 olavo.farias@gmail.com
*
* The Initial Developer of the Original Code is CommuniCore.
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
* All Rights Reserved.
********************************************************************************/
$GLOBALS['studioDefs']['EcmInvoiceOutOlds'] = array(
'LBL_DETAILVIEW'=>array(
'template' => 'xtpl',
'template_file' => 'modules/EcmInvoiceOutOlds/DetailView.html',
'php_file' => 'modules/EcmInvoiceOutOlds/DetailView.php',
'type' => 'DetailView',
),
'LBL_EDITVIEW'=>array(
'template' => 'xtpl',
'template_file' => 'modules/EcmInvoiceOutOlds/EditView.html',
'php_file' => 'modules/EcmInvoiceOutOlds/EditView.php',
'type' => 'EditView',
),
'LBL_LISTVIEW'=>array(
'template' => 'listview',
'meta_file' => 'modules/EcmInvoiceOutOlds/listviewdefs.php',
'type' => 'ListView',
),
'LBL_SEARCHFORM'=>array(
'template' => 'xtpl',
'template_file' => 'modules/EcmInvoiceOutOlds/SearchForm.html',
'php_file' => 'modules/EcmInvoiceOutOlds/ListView.php',
'type' => 'SearchForm',
),
);

View File

@@ -0,0 +1,120 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
* Layout definition for Accounts
*
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU 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 General Public License for more
* details.
*
* You should have received a copy of the GNU 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 General Public License version 3.
*
* In accordance with Section 7(b) of the GNU 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".
*/
$layout_defs['EcmInvoiceOutOlds']['subpanel_setup'] = array (
'ecmsalesw' => array(
'module'=>'EcmInvoiceOutOlds',
'order'=>0,
'sort_by'=>'',
'get_subpanel_data' => 'function:getEcmSalesSubPanel',
'generate_select' => false,
'title_key' => 'Zamówienia sprzedaży',
),
'notes' => array(
'order' => 110,
'module' => 'Notes',
'sort_order' => 'asc',
'sort_by' => 'date_entered',
'subpanel_name' => 'default',
'get_subpanel_data' => 'notes',
'add_subpanel_data' => 'note_id',
'title_key' => 'LBL_NOTES_SUBPANEL_TITLE',
'top_buttons' => array(
array('widget_class' => 'SubPanelTopCreateButton'),
),
),
'ecmstockdocouts' => array(
'order' => 80,
'module' => 'EcmStockDocOuts',
'subpanel_name' => 'default',
'get_subpanel_data' => 'ecmstockdocouts',
'add_subpanel_data' => 'ecmstockdocout_id',
'title_key' => 'Magazyn WZ',
'top_buttons' => array(
array('widget_class' => 'SubPanelTopCreateButton'),
),
),
);
?>

View File

@@ -0,0 +1,120 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
* Subpanel Layout definition for Contacts
*
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU 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 General Public License for more
* details.
*
* You should have received a copy of the GNU 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 General Public License version 3.
*
* In accordance with Section 7(b) of the GNU 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".
*/
error_reporting(0);
$subpanel_layout = array(
/*'top_buttons' => array(
array('widget_class' => 'SubPanelTopCreateButton'),
array('widget_class' => 'SubPanelTopSelectButton', 'popup_module' => 'EcmInvoiceOutOlds'),
),*/
'where' => '',
'list_fields' => array (
'status' => array(
'vname' => '&nbsp;',
'width' => '1%',
'default' => true,
),
/*
'number' => array (
'name' => 'number',
'vname' => 'LBL_NUMBER',
'module' => 'EcmInvoiceOutOlds',
'usage' => 'query_only',
),
*/
'document_no' => array (
'name' => 'document_no',
'vname' => 'LBL_DOCUMENT_NO',
'module' => 'EcmInvoiceOutOlds',
'widget_class' => 'SubPanelDetailViewLink',
'width' => '15%',
),
'parent_name' => array (
'name' => 'parent_name',
'vname' => 'Kontrahent',
'module' => 'EcmInvoiceOutOlds',
'width' => '40%'
),
'register_date' => array (
'name' => 'register_date',
'vname' => 'LBL_REGISTER_DATE',
'module' => 'EcmInvoiceOutOlds',
'width' => '10%',
),
'subprice' => array (
'name' => 'subprice',
'vname' => 'Cena netto',
'module' => 'EcmInvoiceOutOlds',
'width' => '5%',
),
'quantity' => array (
'name' => 'quantity',
'vname' => 'Ilość',
'module' => 'EcmStockDocIns',
'width' => '5%',
),
'wartosc' => array (
'name' => 'wartosc',
'vname' => 'Wartość',
'module' => 'EcmStockDocIns',
'width' => '5%',
),
'OPTIONS' => array(
'width' => '2%',
'label' => '&nbsp;',
'link' => false,
'default' => true,
'sortable' => false,
),
/*
'edit_button'=>array(
'widget_class' => 'SubPanelEditButton',
'width' => '2%',
),
*/
),
);
?>

View File

@@ -0,0 +1,28 @@
<?php
date_default_timezone_set('Europe/Warsaw');
mb_internal_encoding("UTF-8");
ini_set('display_errors',1);
//require_once("../../fkcsv/helper.php");
$inv='<table cellspacing="0" cellpadding="0" border="0" width="100%">';
$link = mysql_connect('localhost', 'root', '5z#JaL');
$db_selected = mysql_select_db('crm', $link);
mysql_query ("SET NAMES 'utf8'",$link);
mysql_query("set character set 'utf8'",$link);
$b=mysql_query("select id,record_id,name from ecmtransactions where deleted=0 and type=0",$link);
$i=0;
echo mysql_num_rows($b)."\n";
while($r=mysql_fetch_array($b)){
$ac=mysql_query("select id from ecminvoiceoutolds where document_no='".$r['name']."'",$link);
$i++;
if(mysql_num_rows($ac)==1){
$id=mysql_fetch_assoc($ac);
mysql_query("update ecmtransactions set record_id='".$id['id']."' where id='".$r['id']."'");
}
if($i%1000==0) echo $i."\n";
//s if($r['name']=='') echo $r['id'].' name empty<br>';
// if($r['ecminvoiceoutold_name']=='') echo $r['id'].'inv empty<br>';
}
//echo '<br>'.create_guid();
$inv.='</table>';
echo $i;
?>

View File

@@ -0,0 +1,86 @@
<?php
error_reporting(E_PARSE | E_WARNING);
$json = getJSONobj();
$pll = array();
$i = 0;
while (isset($_POST['p_' . $i])) {
$pll[] = $json->decode(htmlspecialchars_decode($_POST['p_' . $i]));
$_POST['p_' . $i] = '';
$i++;
}
$_POST = $json->decode(htmlspecialchars_decode($_POST['otherFormData']));
$_POST['position_list'] = $pll;
if (isset($_REQUEST['record']) && $_REQUEST['record'] != '' && $_REQUEST['cache'] != "fromJava") {
require_once("modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php");
$focus = new EcmInvoiceOutOld();
$method = (isset($_REQUEST['method']) && $_REQUEST['method'] != '') ? $_REQUEST['method'] : 'D';
$focus->getPDF($_REQUEST['record'], $method, null, $_REQUEST['preview_type']);
} else
if ($_REQUEST['cache'] == "fromJava" && $_GET['from'] != "EcmInvoiceOutOlds") {
$_SESSION['PDF_ECMINVOICEOUTOLDS'] = $_POST;
} else
if ($_GET['from'] == "EcmInvoiceOutOlds") {
require_once("modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php");
$focus = new EcmInvoiceOutOld();
if (isset($_SESSION['PDF_ECMINVOICEOUTOLDS']['record']) && $_SESSION['PDF_ECMINVOICEOUTOLDS']['record'] != '') {
$focus->retrieve($_SESSION['PDF_ECMINVOICEOUTOLDS']['record']);
}
if (!$focus->ACLAccess('Save')) {
ACLController::displayNoAccess(true);
sugar_cleanup(true);
}
foreach ($focus->column_fields as $field) {
if (isset($_SESSION['PDF_ECMINVOICEOUTOLDS'][$field])) {
$value = $_SESSION['PDF_ECMINVOICEOUTOLDS'][$field];
$focus->$field = $value;
}
}
foreach ($focus->additional_column_fields as $field) {
if (isset($_SESSION['PDF_ECMINVOICEOUTOLDS'][$field])) {
$value = $_SESSION['PDF_ECMINVOICEOUTOLDS'][$field];
$focus->$field = $value;
}
}
if (isset($_SESSION['PDF_ECMINVOICEOUTOLDS']['to_is_vat_free']) && $_SESSION['PDF_ECMINVOICEOUTOLDS']['to_is_vat_free'])
$focus->to_is_vat_free = 1;
else
$focus->to_is_vat_free = 0;
$json = getJSONobj();
$pl = $_SESSION['PDF_ECMINVOICEOUTOLDS']['position_list'];
$focus->position_list = $pl;
$focus->document_no = $_SESSION['PDF_ECMINVOICEOUTOLDS']['document_no'];
$focus->wz_id = $_SESSION['PDF_ECMINVOICEOUTOLDS']['out_id'];
$focus->ecmpaymentcondition_text = EcmInvoiceOutOld::getTranslation('EcmPaymentConditions', $focus->ecmpaymentcondition_id, $focus->ecmlanguage);
//die();
$focus->getPDF();
}

View File

@@ -0,0 +1,115 @@
<?php
error_reporting(E_PARSE | E_WARNING);
$json = getJSONobj();
$pll = array();
$i = 0;
while (isset($_POST['p_' . $i])) {
$pll[] = $json->decode(htmlspecialchars_decode($_POST['p_' . $i]));
$_POST['p_' . $i] = '';
$i++;
}
$_POST = $json->decode(htmlspecialchars_decode($_POST['otherFormData']));
$_POST['position_list'] = $pll;
if (isset($_REQUEST['record']) && $_REQUEST['record'] != '' && $_REQUEST['cache'] != "fromJava") {
require_once("modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php");
$focus = new EcmInvoiceOutOld();
$method = (isset($_REQUEST['method']) && $_REQUEST['method'] != '') ? $_REQUEST['method'] : 'D';
$i = new EcmInvoiceOutOld();
$i->retrieve($_REQUEST['record']);
/*
//echo $i->createPdfFileName.' null<br>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://192.168.1.130/crm/index.php?action=Authenticate&module=Users&return_module=Users&return_action=Login&user_name=db&user_password=rudemodz&login_theme=Sugar&login_language=en_us');
//curl_setopt($ch, CURLOPT_POSTFIELDS,'user_name=db&user_password='.$pass.'');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
$page = curl_exec($ch);
$up='https://192.168.1.130/crm/index.php?module=EcmInvoiceOutOlds&action=prdfg&type=&to_pdf=1&record='.$_REQUEST['record'].'';
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $up);
//echo $i.': '.$row['id'].'<br>';
$page = curl_exec($ch);
$date = new DateTime(date('Y-m-d'));
mkdir('pdfkopie/'.$date->format('Y-m-01'));
if (!file_exists('pdfkopie/'.$date->format('Y-m-01').'/'.$i->createPdfFileName())) {
$fp = fopen('pdfkopie/'.$date->format('Y-m-01').'/'.$i->createPdfFileName().'', 'w');
fwrite($fp, $page);
}
*/
$focus->getPDF($_REQUEST['record'], $method, null, $_REQUEST['preview_type']);
} else
if ($_REQUEST['cache'] == "fromJava" && $_GET['from'] != "EcmInvoiceOutOlds") {
$_SESSION['PDF_ECMINVOICEOUTOLDS'] = $_POST;
} else
if ($_GET['from'] == "EcmInvoiceOutOlds") {
require_once("modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php");
$focus = new EcmInvoiceOutOld();
if (isset($_SESSION['PDF_ECMINVOICEOUTOLDS']['record']) && $_SESSION['PDF_ECMINVOICEOUTOLDS']['record'] != '') {
$focus->retrieve($_SESSION['PDF_ECMINVOICEOUTOLDS']['record']);
}
if (!$focus->ACLAccess('Save')) {
ACLController::displayNoAccess(true);
sugar_cleanup(true);
}
foreach ($focus->column_fields as $field) {
if (isset($_SESSION['PDF_ECMINVOICEOUTOLDS'][$field])) {
$value = $_SESSION['PDF_ECMINVOICEOUTOLDS'][$field];
$focus->$field = $value;
}
}
foreach ($focus->additional_column_fields as $field) {
if (isset($_SESSION['PDF_ECMINVOICEOUTOLDS'][$field])) {
$value = $_SESSION['PDF_ECMINVOICEOUTOLDS'][$field];
$focus->$field = $value;
}
}
if (isset($_SESSION['PDF_ECMINVOICEOUTOLDS']['to_is_vat_free']) && $_SESSION['PDF_ECMINVOICEOUTOLDS']['to_is_vat_free'])
$focus->to_is_vat_free = 1;
else
$focus->to_is_vat_free = 0;
$json = getJSONobj();
$pl = $_SESSION['PDF_ECMINVOICEOUTOLDS']['position_list'];
$focus->position_list = $pl;
$focus->document_no = $_SESSION['PDF_ECMINVOICEOUTOLDS']['document_no'];
$focus->wz_id = $_SESSION['PDF_ECMINVOICEOUTOLDS']['out_id'];
$focus->ecmpaymentcondition_text = EcmInvoiceOutOld::getTranslation('EcmPaymentConditions', $focus->ecmpaymentcondition_id, $focus->ecmlanguage);
//die();
$focus->getPDF();
}

View File

@@ -0,0 +1,55 @@
<?php
set_time_limit(9999);
if($_REQUEST['uid']){
$_SESSION['cids_files']=array();
$_SESSION['cids']=explode(",",$_REQUEST['uid']);
}
if(!$_REQUEST['no'])$_REQUEST['no']=0;
include_once("modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php");
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select document_no,id from ecminvoiceoutolds where id='".$_SESSION['cids'][$_REQUEST['no']]."'"));
$in=new EcmInvoiceOutOld();
$in->retrieve($r['id']);
$ff="modules/EcmInvoiceOutOlds/files/".str_replace(" ","",str_replace("/","",$r['document_no'])).".pdf";
$in->getPDF($r['id'],"F",$ff);
$_SESSION['cids_files'][]=$ff;
chmod($ff,0777);
chown($ff,"e5crm.more7.com");
if(count($_SESSION['cids'])==$_REQUEST['no']-1){
/*include_once("include/fpdi/fpdi.php");
class Mao_FPDI extends FPDI {
var $files = array ();
function setFiles($files) {
$this->files = $files;
}
function concat() {
$this->setPrintHeader(false);
$this->setPrintFooter(false);
foreach ( $this->files as $file ) {
$pagecount = $this->setSourceFile ( $file );
for($i = 1; $i <= $pagecount; $i ++) {
$tplidx = $this->ImportPage ( $i );
$s = $this->getTemplatesize ( $tplidx );
$this->AddPage ( 'P', array ($s ['w'], $s ['h'] ) );
$this->useTemplate ( $tplidx );
}
}
}
}*/
require_once('include/pclzip/pclzip.lib.php');
$f='modules/EcmInvoiceOutOlds/files/archive'.date("YmdHis").'.zip';
$archive = new PclZip($f);
foreach($_SESSION['cids_files'] as $a)$archive->add($a,PCLZIP_OPT_REMOVE_PATH,"modules/EcmInvoiceOutOlds/files/");
$_SESSION['cids_files']=array();
chmod($f,0777);
header("Location: ".$f);
/*$pdf = new Mao_FPDF ( );
$pdf->setFiles ($_SESSION['cids_files']);
$pdf->concat ();
$pdf->Output ( 'modules/EcmInvoiceOutOlds/files/archive'.date("YmdHis").'.pdf', 'D' );*/
}
else {
header("Location: index.php?module=EcmInvoiceOutOlds&action=printAll&to_pdf=1&no=".($_REQUEST['no']+1));
}
?>

View File

@@ -0,0 +1,8 @@
<?php
$id = 'c44c1b48-2855-3325-38b7-528602609511';
$i = new EcmInvoiceOutOld();
$i->retrieve($id);
echo $i->getInvoiceSubtotal();
echo '<br>';
echo $i->getInvoiceTotal();
?>

View File

@@ -0,0 +1,65 @@
<?php
$db = $GLOBALS ['db'];
$inv = $db->query ( "SELECT * FROM ecminvoiceoutolds WHERE type='correct' AND register_date LIKE '2014-10%' and canceled='0' and deleted='0'" );
while ( $i = $db->fetchByAssoc ( $inv ) ) {
echo $i ['document_no'] . '<br>';
$items = $db->query ( "
SELECT ii2.code,ii.id, ii.total, ii.old_total, ii.subtotal, ii.old_subtotal, ii2.purchase_price, ii2.quantity as q1, ii.quantity as q2
FROM ecminvoiceoutolditems as ii
INNER JOIN ecminvoiceoutolditems AS ii2
ON ii2.id=ii.old_ecminvoiceoutolditem_id
WHERE
ii.ecminvoiceoutold_id='" . $i ['id'] . "' AND ii.deleted='0'" );
$sum = 0;
while ( $ii = $db->fetchByAssoc ( $items ) ) {
if (is_numeric ( $ii ['old_subtotal'] )) {
echo $ii['code'].'<br>';
$qty = (floatval($ii['q2'])-floatval($ii['q1']));
$st = (floatval($ii['subtotal'])-floatval($ii['old_subtotal']));
$t = (floatval($ii['total'])-floatval($ii['old_total']));
echo $qty.'<br>';
echo $st.'<br>';
echo $t.'<br>';
$q = "UPDATE ecminvoiceoutolditems SET subtotal_corrected='$st',total_corrected='$t',quantity_corrected='$qty' WHERE id ='".$ii['id']."'";
echo $q.'<br>';
$db->query($q);
}
}
echo '***************<br>';
}
return;
function microtime_float() {
list ( $usec, $sec ) = explode ( " ", microtime () );
return (( float ) $usec + ( float ) $sec);
}
$db = $GLOBALS ['db'];
$document_no = 'FV 1552/14';
$res = $db->query ( "SELECT id, register_date, type, document_no FROM ecminvoiceoutolds where document_no='" . $document_no . "'" );
$res = $db->query("SELECT id, register_date, type, document_no FROM ecminvoiceoutolds where type='correct' and register_date LIKE '2014-09%'");
$t = 0;
while ( $row = $res->fetch_assoc () ) {
$i = new EcmInvoiceOutOld ();
$i->retrieve ( $row ['id'] );
$i->CalculatePurchasePrices();
// $subtotal = $i->getInvoiceSubtotal(false);
// $total = $i->getInvoiceTotal();
echo $row['id'].'<br>';
// $db->query("UPDATE ecminvoiceoutolds SET subtotal='$subtotal', total='$total' WHERE id='".$row['id']."'");
// $db->query("UPDATE ecmtransactions SET value='$total' WHERE record_id='".$row['id']."'");
}
echo 'Zrobione!
';
return;
?>

View File

@@ -0,0 +1,39 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
if(isset($_REQUEST['record']) && $_REQUEST['record'] != '') {
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings;
if(!isset($focus)) {
require_once('modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php');
$focus = new EcmInvoiceOutOld();
$focus->retrieve($_REQUEST['record']);
$focus->format_all_fields();
}
require_once('include/SubPanel/SubPanelTiles.php');
$subpanel = new SubPanelTiles($focus, "EcmInvoiceOutOlds");
echo $subpanel->display();
}
?>

View File

@@ -0,0 +1,6 @@
<?php
$i = new EcmInvoiceOutOld();
$i->retrieve("6829c817-a89e-60ba-6ff6-537ca23257a2");
$i->getInvoiceSubtotal();
?>

View File

@@ -0,0 +1,82 @@
<?php
require_once("modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php");
class EcmInvoiceOutOldToTransfer extends EcmInvoiceOutOld {
function getPosition($id) {
if(!isset($id) || $id == '') return '';
require_once('modules/EcmProductsDocumentsRelations/EcmProductsDocumentsRelation.php');
$epdr = new EcmProductsDocumentsRelation();
$epdr->retrieve($id);
$return_array = array();
if(isset($epdr->id) && $epdr->id != '') {
$return_array['id'] = $epdr->product_id;
$return_array['code'] = $epdr->product_code;
$return_array['name'] = $epdr->product_name;
$return_array['quantity'] = $epdr->product_quantity;
$return_array['price'] = $epdr->product_price;
$return_array['discount'] = $epdr->product_discount;
$return_array['total'] = $epdr->product_total;
$return_array['unit_id'] = $epdr->product_unit_id;
$return_array['vat_id'] = $epdr->product_vat_id;
$return_array['category_id'] = $epdr->product_category_id;
$return_array['project_task_name'] = $epdr->project_task_name;
$return_array['project_task_id'] = $epdr->project_task_id;
$return_array['project_name'] = $epdr->project_name;
$return_array['project_id'] = $epdr->project_id;
$epdr->fill_in_additional_detail_fields();
$return_array['currency_id'] = $epdr->currency->id;
$return_array['currency_symbol'] = $epdr->currency->symbol;
$return_array['date'] = $epdr->d_date;
return $return_array;
}
return '';
}
function getPositionList($array = false) {
if(isset($this->id) && $this->id != '') {
$query = "SELECT `id` FROM `ecmproductsdocumentsrelations` WHERE `document_id`='".$this->id."' AND `document_type`='EcmInvoiceOutOlds' AND`deleted`='0' order by product_position asc";
$r = $this->db->query($query);
$return_array = array();
if($r) {
while($w = $this->db->fetchByAssoc($r)) {
$return_array [] = $this->getPosition($w['id']);
}
$json = getJSONobj();
return $array ? $return_array : $json->encode($return_array);
}
}
return $array ? false : '[]';
}
/*
function deleteAssignedPositions() {
if(isset($this->id) && $this->id != '') {
$query = "DELETE FROM `ecmproductsdocumentsrelations` WHERE `document_id`='".$this->id."' AND `document_type`='EcmInvoiceOutOlds'";
$r = $this->db->query($query);
if($r) return true;
}
return false;
}
*/
}
$query = "SELECT `id`, `deleted` FROM `ecminvoiceoutolds` WHERE `deleted`='0'";
$GLOBALS['db'] = new MysqlManager();
$GLOBALS['db']->connect();
$results = $GLOBALS['db']->query($query);
if(is_resource($results)) {
while($row = $GLOBALS['db']->fetchByAssoc($results)) {
if(isset($row['id']) && $row['id'] != '') {
$focus = new EcmInvoiceOutOldToTransfer();
$focus->retrieve($row['id']);
if(isset($focus->id) && $focus->id != '') {
echo $focus->id.' -> '.$focus->name.'<br />';
$focus->position_list = $focus->getPositionList(true);
$focus->savePositions($focus->id);
}
}
}
}
?>

View File

@@ -0,0 +1,7 @@
<?
$w=$GLOBALS[db]->query("select parent_id,id from ecminvoiceoutolds where register_date>'2010-01-01' and deleted='0'");
while($r=$GLOBALS[db]->fetchByAssoc($w)){
$rr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select * from accounts where id='".$r['parent_id']."'"));
echo "update ecminvoiceoutolds set parent_address_street='".$rr['billing_address_street']."',parent_address_city='".$rr['billing_address_city']."',parent_address_postalcode='".$rr['billing_address_postalcode']."',parent_address_country='".$rr['billing_address_country']."' where id='".$r['id']."';<br>";
}
?>

View File

@@ -0,0 +1,17 @@
<?php
$w=$GLOBALS[db]->query("SELECT *
FROM `ecmstockdoccorrects`
WHERE `date_modified` > '2010-03-10'
AND `modified_user_id` LIKE '708f958e-7e5a-e1f1-095b-4a02afc3a628'");
while($r=$GLOBALS[db]->fetchByAssoc($w)){
//echo $r['document_no']."<br>";
$ww=$GLOBALS[db]->query("select * from ecmstockdoccorrectitems where ecmstockdoccorrect_id='".$r['id']."'");
while($rr=$GLOBALS[db]->fetchByAssoc($ww)){
//echo $rr['quantity']." ".$rr['code']." <br>";
if($rr['quantity']<0)$type=0;
else $type=1;
echo "update ecmstockdoccorrectitems set quantity='".(-1*$rr['quantity'])."' where id='".$rr['id']."' and ecmproduct_id='".$rr['ecmproduct_id']."' and ecmstockdoccorrect_id='".$rr['ecmstockdoccorrect_id']."';<br>";
echo "update ecmstockoperations set type='".$type."' where parent_id='".$r['id']."' and product_id='".$rr['ecmproduct_id']."';<br>";
}
}
?>

View File

@@ -0,0 +1,10 @@
<?
$w=$GLOBALS[db]->query("select * from ecminvoiceoutolds where id='8aa03944-fc72-26ec-8eb4-4b718085454e'");
while($r=$GLOBALS[db]->fetchByAssoc($w)){
$ww=$GLOBALS[db]->query("select * from ecminvoiceoutolditems where ecminvoiceoutold_id='".$r['id']."'");
while($rr=$GLOBALS[db]->fetchByAssoc($ww)){
$rrr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select id from ecminvoiceoutolditems where ecminvoiceoutold_id='".$r['ecminvoiceoutold_id']."' and ecmproduct_id='".$rr['ecmproduct_id']."'"));
echo "update ecminvoiceoutolditems set ecminvoiceoutolditem_id='".$rrr['id']."' where id='".$rr['id']."';<br>";
}
}
?>

View File

@@ -0,0 +1,7 @@
<?php
$w=$GLOBALS[db]->query("select id,parent_id from ecminvoiceoutolds where register_date>='2010-01-01' and (to_nip is null or to_nip='')");
while($r=$GLOBALS[db]->fetchByAssoc($w)){
$rr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select sic_code from accounts where id='".$r['parent_id']."'"));
echo "update ecminvoiceoutolds set to_nip='".$rr['sic_code']."' where id='".$r['id']."';<br>";
}
?>

View File

@@ -0,0 +1,22 @@
<?php
global $db;
$w=$GLOBALS[db]->query("select id,wz_id,document_no,type,ecminvoiceoutold_id from ecminvoiceoutolds where register_date>='".$_REQUEST['date_from']."%' and register_date<='".$_REQUEST['date_to']."' and deleted='0'");
while($r=$GLOBALS[db]->fetchByAssoc($w)){
//echo $r['document_no'].'<br>';
$ww=$GLOBALS[db]->query("select id,ecmproduct_id from ecminvoiceoutolditems where ecminvoiceoutold_id='".$r['id']."'");
while($rr=$GLOBALS[db]->fetchByAssoc($ww)){
if($r['type']!="normal"){
$rcor=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select wz_id from ecminvoiceoutolds where id='".$r['ecminvoiceoutold_id']."'"));
$r['wz_id']=$rcor['wz_id'];
}
$rrr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select price from ecmstockoperations where parent_id='".$r['wz_id']."' and product_id='".$rr['ecmproduct_id']."'"));
$purchase_price=$rrr['price'];
echo $rr['code']."<br>";
//if($purchase_price<=0){
$GLOBALS[db]->query("update ecminvoiceoutolditems set purchase_price='".$purchase_price."' where ecminvoiceoutold_id='".$r['id']."' and ecmproduct_id='".$rr['ecmproduct_id']."';");
//echo $purchase_price."<br>";
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,355 @@
{*
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU 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 General Public License for more
* details.
*
* You should have received a copy of the GNU 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 General Public License version 3.
*
* In accordance with Section 7(b) of the GNU 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".
********************************************************************************/
*}
{{include file="modules/EcmInvoiceOutOlds/view/DetailView/header.tpl"}}
{sugar_include include=$includes}
{{* Render tag for VCR control if SHOW_VCR_CONTROL is true *}}
{{if $SHOW_VCR_CONTROL}}
<table width='100%' border='0' style="border-bottom:0px;" cellspacing='{$gridline}' cellpadding='0' class='tabDetailView'>
{$PAGINATION}
</table>
{{/if}}
{literal}
<script language="javascript">
var SelectedTab = "";
function SetTab(tab_name) {
var TabMenu = document.getElementById('groupTabsPanels');
var tabs = TabMenu.getElementsByTagName('li');
for(i=0;i<tabs.length;i++) {
if((tab_name+'_menu') === tabs[i].id) {
tabs[i].className = 'active';
tabs[i].getElementsByTagName('a')[0].className = 'current';
} else {
tabs[i].className = '';
tabs[i].getElementsByTagName('a')[0].className = '';
}
}
var prev = document.getElementById(SelectedTab);
var curr = document.getElementById(tab_name);
prev.style.display = 'none';
curr.style.display = '';
SelectedTab = tab_name;
}
</script>
{/literal}
<ul class="subpanelTablist" style="margin-top:10px;" id="groupTabsPanels">
{{foreach name=section from=$sectionPanels key=label item=panel}}
{{if $panel[0][0].field.type == 'tab'}}
{{if $label=='EMAIL'}}
{{else}}
<li class="{{if $panel[0][0].field.active}}active{{/if}}" id="panel_{{$label}}_menu">
<script language="javascript">
var set{{$label}} = function() {literal} { {/literal} SetTab('panel_{{$label}}'); {literal} }; {/literal}
{{if $panel[0][0].field.active}}SelectedTab="panel_{{$label}}";{{/if}}
</script>
<a class="{{if $panel[0][0].field.active}}current{{else}}other{{/if}}" href="javascript:set{{$label}}();">{sugar_translate label='LBL_{{$label}}_TAB' module='{{$module}}'}</a>
</li>
{{/if}}
{{/if}}
{{/foreach}}
<li class="" id="panel_EMAIL_menu">
<a class="" href="javascript:{$EMAIL_LINK}">{sugar_translate label='LBL_EMAIL_TAB' module='EcmQuotes'}</a>
</li>
</ul>
{{* Loop through all top level panels first *}}
{{counter name="panelCount" print=false start=0 assign="panelCount"}}
{{foreach name=section from=$sectionPanels key=label item=panel}}
{{assign var='panel_id' value=$panelCount}}
<div {{if $panel[0][0].field.active == false}}style="display:none"{{/if}} id='panel_{{$label}}'>
{counter name="panelFieldCount" start=0 print=false assign="panelFieldCount"}
{{* Print out the panel title if one exists*}}
{{* Check to see if the panel variable is an array, if not, we'll attempt an include with type param php *}}
{{* See function.sugar_include.php *}}
{{if !is_array($panel)}}
{sugar_include type='php' file='{{$panel}}'}
{{else}}
<!--
{{if !empty($label) && !is_int($label) && $label != 'DEFAULT'}}
<h4 class="dataLabel">{sugar_translate label='{{$label}}' module='{{$module}}'}</h4><br>
{{/if}}
-->
{{* Print out the table data *}}
<table width='100%' border='0' style="border-top:0px" cellspacing='{$gridline}' cellpadding='0' class='tabDetailView'>
{{if $panelCount == 0}}
{{counter name="panelCount" print=false}}
{{/if}}
{{foreach name=rowIteration from=$panel key=row item=rowData}}
<tr>
{{assign var='columnsInRow' value=$rowData|@count}}
{{assign var='columnsUsed' value=0}}
{{foreach name=colIteration from=$rowData key=col item=colData}}
{{if $colData.field.allCols == false}}
<td width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].label}}%' class='tabDetailViewDL' NOWRAP>
{{if isset($colData.field.customLabel)}}
{{$colData.field.customLabel}}
{{elseif isset($colData.field.label) && strpos($colData.field.label, '$')}}
{capture name="label" assign="label"}
{{$colData.field.label}}
{/capture}
{$label|strip_semicolon}:
{{elseif isset($colData.field.label)}}
{capture name="label" assign="label"}
{sugar_translate label='{{$colData.field.label}}' module='{{$module}}'}
{/capture}
{$label|strip_semicolon}:
{{elseif isset($fields[$colData.field.name])}}
{capture name="label" assign="label"}
{sugar_translate label='{{$fields[$colData.field.name].vname}}' module='{{$module}}'}
{/capture}
{$label|strip_semicolon}:
{{else}}
&nbsp;
{{/if}}
</td>
{{/if}}
<td width='{{if $colData.field.allCols == true}}100{{else}}{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].field}}{{/if}}%' class='tabDetailViewDF' {{if $colData.field.allCols == true}}colspan='4'{{else}}{{if $colData.colspan}}colspan='{{$colData.colspan}}'{{/if}}{{/if}}>
{{if $colData.field.customCode || $colData.field.assign}}
{counter name="panelFieldCount"}
{{sugar_evalcolumn var=$colData.field colData=$colData}}
{{elseif $fields[$colData.field.name] && !empty($colData.field.fields) }}
{{foreach from=$colData.field.fields item=subField}}
{{if $fields[$subField]}}
{counter name="panelFieldCount"}
{{sugar_field parentFieldArray='fields' tabindex=$tabIndex vardef=$fields[$subField] displayType='detailView'}}&nbsp;
{{else}}
{counter name="panelFieldCount"}
{{$subField}}
{{/if}}
{{/foreach}}
{{elseif $fields[$colData.field.name]}}
{counter name="panelFieldCount"}
{{sugar_field parentFieldArray='fields' vardef=$fields[$colData.field.name] displayType='detailView' displayParams=$colData.field.displayParams typeOverride=$colData.field.type}}
{{/if}}
&nbsp;
</td>
{{/foreach}}
</tr>
{{/foreach}}
</table>
{{/if}}
</div>
{if $panelFieldCount == 0}
<script>document.getElementById("panel_{{$panel_id}}").style.display='none';</script>
{/if}
{{/foreach}}
{{include file="modules/EcmInvoiceOutOlds/view/DetailView/footer.tpl"}}

View File

@@ -0,0 +1,37 @@
{*
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU 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 General Public License for more
* details.
*
* You should have received a copy of the GNU 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 General Public License version 3.
*
* In accordance with Section 7(b) of the GNU 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".
********************************************************************************/
*}
</form>

View File

@@ -0,0 +1,105 @@
{*
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU 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 General Public License for more
* details.
*
* You should have received a copy of the GNU 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 General Public License version 3.
*
* In accordance with Section 7(b) of the GNU 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".
********************************************************************************/
*}
{{* Add the preForm code if it is defined (used for vcards) *}}
{{if $preForm}}
{{$preForm}}
{{/if}}
<table cellpadding="1" cellspacing="0" border="0" width="100%">
<tr>
<td style="padding-bottom: 2px;" align="left" NOWRAP>
<form action="index.php" method="post" name="DetailView" id="form">
<input type="hidden" name="module" value="{$module}">
<input type="hidden" name="record" value="{$fields.id.value}">
<input type="hidden" name="return_action">
<input type="hidden" name="return_module">
<input type="hidden" name="return_id">
<input type="hidden" name="isDuplicate" value="false">
<input type="hidden" name="offset" value="{$offset}">
<input type="hidden" name="action" value="EditView">
{{if isset($form.hidden)}}
{{foreach from=$form.hidden item=field}}
{{$field}}
{{/foreach}}
{{/if}}
{{if !isset($form.buttons)}}
<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="button" onclick="this.form.return_module.value='{$module}'; this.form.return_action.value='DetailView'; this.form.return_id.value='{$id}'; this.form.action.value='EditView'" type="submit" name="Edit" id='edit_button' value=" {$APP.LBL_EDIT_BUTTON_LABEL} ">
<input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="button" onclick="this.form.return_module.value='{$module}'; this.form.return_action.value='index'; this.form.isDuplicate.value=true; this.form.action.value='EditView'" type="submit" name="Duplicate" value=" {$APP.LBL_DUPLICATE_BUTTON_LABEL} " id='duplicate_button'>
<input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="button" onclick="this.form.return_module.value='{$module}'; this.form.return_action.value='ListView'; this.form.action.value='Delete'; return confirm('{$APP.NTC_DELETE_CONFIRMATION}')" type="submit" name="Delete" value=" {$APP.LBL_DELETE_BUTTON_LABEL} " >
{{else}}
{{counter assign="num_buttons" start=0 print=false}}
{{foreach from=$form.buttons key=val item=button}}
{{if !is_array($button) && in_array($button, $built_in_buttons)}}
{{counter print=false}}
{{sugar_button module="$module" id="$button" view="EditView"}}
{{/if}}
{{/foreach}}
{{if isset($closeFormBeforeCustomButtons)}}
</form>
</td>
{{/if}}
{{if count($form.buttons) > $num_buttons}}
{{foreach from=$form.buttons key=val item=button}}
{{if is_array($button) && $button.customCode}}
<td style="padding-bottom: 2px;" align="left" NOWRAP>
{{sugar_button module="$module" id="$button" view="EditView"}}
</td>
{{/if}}
{{/foreach}}
{{/if}}
{{/if}}
{{if !isset($closeFormBeforeCustomButtons)}}
</form>
</td>
{{/if}}
{{if empty($form.hideAudit) || !$form.hideAudit}}
<td style="padding-bottom: 2px;" align="left" NOWRAP>
{{sugar_button module="$module" id="Audit" view="EditView"}}
</td>
{{/if}}
<td align="right" width="100%">{$ADMIN_EDIT}</td>
{{* Add $form.links if they are defined *}}
{{if !empty($form) && isset($form.links)}}
<td align="right" width="10%">&nbsp;</td>
<td align="right" width="100%" NOWRAP>
{{foreach from=$form.links item=link}}
{{$link}}&nbsp;
{{/foreach}}
</td>
{{/if}}
</tr>
</table>

View File

@@ -0,0 +1,95 @@
<?php
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU 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 General Public License for more
* details.
*
* You should have received a copy of the GNU 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 General Public License version 3.
*
* In accordance with Section 7(b) of the GNU 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".
* *******************************************************************************/
/*
* Created on Apr 13, 2007
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
require_once('include/DetailView/DetailView2.php');
class ViewDetailMy extends SugarView{
var $type ='detail';
var $dv;
var $tplFile = 'include/DetailView/DetailView.tpl';
function ViewDetailMy(){
$this->options['show_subpanels'] = true;
parent::SugarView();
}
function preDisplay(){
$metadataFile = null;
$foundViewDefs = false;
if(file_exists('custom/modules/' . $this->module . '/metadata/detailviewdefs.php')){
$metadataFile = 'custom/modules/' . $this->module . '/metadata/detailviewdefs.php';
$foundViewDefs = true;
}else{
if(file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')){
require_once('custom/modules/'.$this->module.'/metadata/metafiles.php');
if(!empty($metafiles[$this->module]['detailviewdefs'])){
$metadataFile = $metafiles[$this->module]['detailviewdefs'];
$foundViewDefs = true;
}
}elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){
require_once('modules/'.$this->module.'/metadata/metafiles.php');
if(!empty($metafiles[$this->module]['detailviewdefs'])){
$metadataFile = $metafiles[$this->module]['detailviewdefs'];
$foundViewDefs = true;
}
}
}
$GLOBALS['log']->debug("metadatafile=". $metadataFile);
if(!$foundViewDefs && file_exists('modules/'.$this->module.'/metadata/detailviewdefs.php')){
$metadataFile = 'modules/'.$this->module.'/metadata/detailviewdefs.php';
}
$this->dv = new DetailView2();
$this->dv->ss =& $this->ss;
$this->dv->setup($this->module, $this->bean, $metadataFile, $this->tplFile);
}
function display(){
if(empty($this->bean->id)){
global $app_strings;
sugar_die($app_strings['ERROR_NO_RECORD']);
}
$this->dv->process();
echo $this->dv->display();
}
}

View File

@@ -0,0 +1,421 @@
{*
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU 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 General Public License for more
* details.
*
* You should have received a copy of the GNU 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 General Public License version 3.
*
* In accordance with Section 7(b) of the GNU 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".
********************************************************************************/
*}
{literal}
<style type="text/css">
.dataLabel { padding: 2px; }
.dataField { padding: 2px; }
.tabEditViewDF { padding: 2px; }
td .dataLabel { padding: 2px; }
td .dataField { padding: 2px; }
td .tabEditViewDF { padding: 2px; }
.tabForm { border-top:none; }
</style>
{/literal}
{{include file='modules/EcmInvoiceOutOlds/view/EditView/header.tpl'}}
{sugar_include include=$includes}
<table width="100%" cellspacing="0" cellpadding="0" class='tabDetailView' id='tabFormPagination'>
{{if $panelCount == 0}}
{{* Render tag for VCR control if SHOW_VCR_CONTROL is true *}}
{{if $SHOW_VCR_CONTROL}}
{$PAGINATION}
{{/if}}
{{/if}}
</table>
{literal}
<script language="javascript">
var SelectedTab = "";
function SetTab(tab_name) {
var TabMenu = document.getElementById('groupTabs');
var tabs = TabMenu.getElementsByTagName('li');
for(i=0;i<tabs.length;i++) {
if((tab_name+'_menu') === tabs[i].id) {
tabs[i].className = 'active';
tabs[i].getElementsByTagName('a')[0].className = 'current';
} else {
tabs[i].className = '';
tabs[i].getElementsByTagName('a')[0].className = '';
}
}
var prev = document.getElementById(SelectedTab);
var curr = document.getElementById(tab_name);
prev.style.display = 'none';
curr.style.display = '';
SelectedTab = tab_name;
}
</script>
{/literal}
<ul class="tabList" style="margin-top:10px;" id="groupTabs">
{{foreach name=section from=$sectionPanels key=label item=panel}}
{{if $panel[0][0].field.type == 'tab'}}
<li class="{{if $panel[0][0].field.active}}active{{/if}}" id="{{$label}}_menu">
<script language="javascript">
var set{{$label}} = function() {literal} { {/literal} SetTab('{{$label}}'); {literal} }; {/literal}
{{if $panel[0][0].field.active}}SelectedTab="{{$label}}";{{/if}}
</script>
<a class="{{if $panel[0][0].field.active}}current{{/if}}" href="javascript:set{{$label}}();">{sugar_translate label='LBL_{{$label}}_TAB' module='{{$module}}'}</a>
</li>
{{/if}}
{{/foreach}}
</ul>
{{* Loop through all top level panels first *}}
{{counter name="panelCount" start=-1 print=false assign="panelCount"}}
{{foreach name=section from=$sectionPanels key=label item=panel}}
{{counter name="panelCount" print=false}}
{{* Print out the table data *}}
<div id="{{$label}}" style="display:{{if !$panel[0][0].field.active}}none{{/if}};">
{counter name="panelFieldCount" start=0 print=false assign="panelFieldCount"}
{{* Check to see if the panel variable is an array, if not, we'll attempt an include with type param php *}}
{{* See function.sugar_include.php *}}
{{if !is_array($panel)}}
{sugar_include type='php' file='{{$panel}}'}
{{else}}
<table width="100%" border="0" cellspacing="1" cellpadding="0" class="{$def.templateMeta.panelClass|default:tabForm}">
{{* Only show header if it is not default or an int value *}}
{{if !empty($label) && !is_int($label) && $label != 'DEFAULT'}}
<th class="dataLabel" align="left" colspan="8">
<h4>{sugar_translate label='LBL_{{$label}}' module='{{$module}}'}</h4>
</th>
{{/if}}
{{assign var='rowCount' value=0}}
{{foreach name=rowIteration from=$panel key=row item=rowData}}
<tr>
{{assign var='columnsInRow' value=$rowData|@count}}
{{assign var='columnsUsed' value=0}}
{{* Loop through each column and display *}}
{{counter name="colCount" start=0 print=false assign="colCount"}}
{{foreach name=colIteration from=$rowData key=col item=colData}}
{{counter name="colCount" print=false}}
{{math assign="tabIndex" equation="$panelCount * $maxColumns + $colCount"}}
{{if count($rowData) == $colCount}}
{{assign var="colCount" value=0}}
{{/if}}
{{if empty($def.templateMeta.labelsOnTop) && empty($colData.field.hideLabel)}}
<td valign="top" width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].label}}%' class="dataLabel" NOWRAP>
{{if isset($colData.field.customLabel)}}
{{$colData.field.customLabel}}
{{elseif isset($colData.field.label)}}
{capture name="label" assign="label}
{sugar_translate label='{{$colData.field.label}}' module='{{$module}}'}
{/capture}
{$label|strip_semicolon}:
{{elseif isset($fields[$colData.field.name])}}
{capture name="label" assign="label}
{sugar_translate label='{{$fields[$colData.field.name].vname}}' module='{{$module}}'}
{/capture}
{$label|strip_semicolon}:
{{/if}}
{{* Show the required symbol if field is required, but override not set. Or show if override is set *}}
{{if ($fields[$colData.field.name].required && (!isset($colData.field.displayParams.required) || $colData.field.displayParams.required)) ||
(isset($colData.field.displayParams.required) && $colData.field.displayParams.required)}}
<span class="required">{{$APP.LBL_REQUIRED_SYMBOL}}</span>
{{/if}}
</td>
{{/if}}
<td valign="top" width='{{if $colData.field.allCols}}100%{{else}}{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].field}}{{/if}}%' class='tabEditViewDF' {{if $colData.field.allCols}}colspan='8'{{else}}{{if $colData.colspan}}colspan='{{$colData.colspan}}'{{/if}}{{/if}} NOWRAP>
{{if !empty($def.templateMeta.labelsOnTop)}}
{{if isset($colData.field.label)}}
{{if !empty($colData.field.label)}}
{sugar_translate label='{{$colData.field.label}}' module='{{$module}}'}:
{{/if}}
{{elseif isset($fields[$colData.field.name])}}
{sugar_translate label='{{$fields[$colData.field.name].vname}}' module='{{$module}}'}:
{{/if}}
{{* Show the required symbol if field is required, but override not set. Or show if override is set *}}
{{if ($fields[$colData.field.name].required && (!isset($colData.field.displayParams.required) || $colData.field.displayParams.required)) ||
(isset($colData.field.displayParams.required) && $colData.field.displayParams.required)}}
<span class="required">{{$APP.LBL_REQUIRED_SYMBOL}}</span>
{{/if}}
{{if !isset($colData.field.label) || !empty($colData.field.label)}}
<br>
{{/if}}
{{/if}}
{{if $fields[$colData.field.name] && !empty($colData.field.fields) }}
{{foreach from=$colData.field.fields item=subField}}
{{if $fields[$subField.name]}}
{counter name="panelFieldCount"}
{{sugar_field parentFieldArray='fields' tabindex=$colData.field.tabindex vardef=$fields[$subField.name] displayType='editView' displayParams=$subField.displayParams formName=$form_name}}&nbsp;
{{/if}}
{{/foreach}}
{{elseif !empty($colData.field.customCode)}}
{counter name="panelFieldCount"}
{{sugar_evalcolumn var=$colData.field.customCode colData=$colData tabindex=$colData.field.tabindex}}
{{elseif $fields[$colData.field.name]}}
{counter name="panelFieldCount"}
{{$colData.displayParams}}
{{sugar_field parentFieldArray='fields' tabindex=$colData.field.tabindex vardef=$fields[$colData.field.name] displayType='editView' displayParams=$colData.field.displayParams typeOverride=$colData.field.type formName=$form_name}}
{{/if}}
{{/foreach}}
</tr>
{{/foreach}}
</table>
{{/if}}
</div>
{if $panelFieldCount == 0}
<script>document.getElementById("{{$label}}").style.display='none';</script>
{/if}
{{/foreach}}
{{include file='modules/EcmInvoiceOutOlds/view/EditView/footer.tpl'}}

View File

@@ -0,0 +1,61 @@
{*
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU 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 General Public License for more
* details.
*
* You should have received a copy of the GNU 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 General Public License version 3.
*
* In accordance with Section 7(b) of the GNU 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".
********************************************************************************/
*}
{{if empty($form.button_location) || $form.button_location == 'bottom'}}
<div style="padding-top: 2px">
{{if !empty($form) && !empty($form.buttons)}}
{{foreach from=$form.buttons key=val item=button}}
{{sugar_button module="$module" id="$button" view="$view"}}
{{/foreach}}
{{else}}
{{sugar_button module="$module" id="SAVE" view="$view"}}
{{sugar_button module="$module" id="CANCEL" view="$view"}}
{{/if}}
{{sugar_button module="$module" id="Audit" view="$view"}}
</div>
{{/if}}
</form>
{{if $externalJSFile}}
require_once("'".$externalJSFile."'");
{{/if}}
{$set_focus_block}
{{if isset($scriptBlocks)}}
<!-- Begin Meta-Data Javascript -->
{{$scriptBlocks}}
<!-- End Meta-Data Javascript -->
{{/if}}

View File

@@ -0,0 +1,79 @@
{*
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU 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 General Public License for more
* details.
*
* You should have received a copy of the GNU 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 General Public License version 3.
*
* In accordance with Section 7(b) of the GNU 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".
********************************************************************************/
*}
<form action="index.php" method="POST" name="{$form_name}" id="{$form_id}" {$enctype}>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="padding-bottom: 2px;">
<input type="hidden" name="module" value="{$module}">
{if isset($smarty.request.isDuplicate) && $smarty.request.isDuplicate eq "true"}
<input type="hidden" name="record" value="">
{else}
<input type="hidden" name="record" value="{$fields.id.value}">
{/if}
<input type="hidden" name="isDuplicate" value="false">
<input type="hidden" name="action">
<input type="hidden" name="return_module" value="{$smarty.request.return_module}">
<input type="hidden" name="return_action" value="{$smarty.request.return_action}">
<input type="hidden" name="return_id" value="{$smarty.request.return_id}">
<input type="hidden" name="contact_role">
{if !empty($smarty.request.return_module)}
<input type="hidden" name="relate_to" value="{$smarty.request.return_module}">
<input type="hidden" name="relate_id" value="{$smarty.request.return_id}">
{/if}
<input type="hidden" name="offset" value="{$offset}">
{{if isset($form.hidden)}}
{{foreach from=$form.hidden item=field}}
{{$field}}
{{/foreach}}
{{/if}}
{{if empty($form.button_location) || $form.button_location == 'top'}}
{{if !empty($form) && !empty($form.buttons)}}
{{foreach from=$form.buttons key=val item=button}}
{{sugar_button module="$module" id="$button" view="$view"}}
{{/foreach}}
{{else}}
{{sugar_button module="$module" id="SAVE" view="$view"}}
{{sugar_button module="$module" id="CANCEL" view="$view"}}
{{/if}}
{{if empty($form.hideAudit) || !$form.hideAudit}}
{{sugar_button module="$module" id="Audit" view="$view"}}
{{/if}}
{{/if}}
</td>
<td align='right'>{{$ADMIN_EDIT}}</td>
</tr>
</table>

View File

@@ -0,0 +1,93 @@
<?php
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU 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 General Public License for more
* details.
*
* You should have received a copy of the GNU 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 General Public License version 3.
*
* In accordance with Section 7(b) of the GNU 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".
* *******************************************************************************/
/*
* Created on Apr 13, 2007
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
require_once('include/EditView/EditView2.php');
class ViewEditMy extends SugarView{
var $ev;
var $type ='edit';
var $useForSubpanel = false; //boolean variable to determine whether view can be used for subpanel creates
var $showTitle = true;
var $tplFile = 'include/EditView/EditView.tpl';
function ViewEditMy(){
parent::SugarView();
}
function preDisplay(){
$metadataFile = null;
$foundViewDefs = false;
if(file_exists('custom/modules/' . $this->module . '/metadata/editviewdefs.php')){
$metadataFile = 'custom/modules/' . $this->module . '/metadata/editviewdefs.php';
$foundViewDefs = true;
}else{
if(file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')){
require_once('custom/modules/'.$this->module.'/metadata/metafiles.php');
if(!empty($metafiles[$this->module]['editviewdefs'])){
$metadataFile = $metafiles[$this->module]['editviewdefs'];
$foundViewDefs = true;
}
}elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){
require_once('modules/'.$this->module.'/metadata/metafiles.php');
if(!empty($metafiles[$this->module]['editviewdefs'])){
$metadataFile = $metafiles[$this->module]['editviewdefs'];
$foundViewDefs = true;
}
}
}
$GLOBALS['log']->debug("metadatafile=". $metadataFile);
if(!$foundViewDefs && file_exists('modules/'.$this->module.'/metadata/editviewdefs.php')){
$metadataFile = 'modules/'.$this->module.'/metadata/editviewdefs.php';
}
$this->ev = new EditView();
$this->ev->ss =& $this->ss;
$this->ev->setup($this->module, $this->bean, $metadataFile, $this->tplFile);
}
function display(){
$this->ev->process();
echo $this->ev->display($this->showTitle);
}
}
?>

View File

@@ -0,0 +1,251 @@
<?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 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU 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 General Public License for more
* details.
*
* You should have received a copy of the GNU 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 General Public License version 3.
*
* In accordance with Section 7(b) of the GNU 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".
********************************************************************************/
/*********************************************************************************
* Description: This file is used to override the default Meta-data EditView behavior
* to provide customization specific to the Calls module.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
********************************************************************************/
require_once('include/MVC/View/views/view.list.php');
class EcmInvoiceOutOldsViewList extends ViewList{
function EcmInvoiceOutOldsViewList(){
parent::ViewList();
}
function display(){
if(!$this->bean->ACLAccess('list')){
ACLController::displayNoAccess();
return;
}
$this->module=$module = "EcmInvoiceOutOlds";
$metadataFile = null;
$foundViewDefs = false;
if(file_exists('custom/modules/' . $module. '/metadata/listviewdefs.php')){
$metadataFile = 'custom/modules/' . $module . '/metadata/listviewdefs.php';
$foundViewDefs = true;
}else{
if(file_exists('custom/modules/'.$module.'/metadata/metafiles.php')){
require_once('custom/modules/'.$module.'/metadata/metafiles.php');
if(!empty($metafiles[$module]['listviewdefs'])){
$metadataFile = $metafiles[$module]['listviewdefs'];
$foundViewDefs = true;
}
}elseif(file_exists('modules/'.$module.'/metadata/metafiles.php')){
require_once('modules/'.$module.'/metadata/metafiles.php');
if(!empty($metafiles[$module]['listviewdefs'])){
$metadataFile = $metafiles[$module]['listviewdefs'];
$foundViewDefs = true;
}
}
}
if(!$foundViewDefs && file_exists('modules/'.$module.'/metadata/listviewdefs.php')){
$metadataFile = 'modules/'.$module.'/metadata/listviewdefs.php';
}
require_once($metadataFile);
if(!empty($_REQUEST['saved_search_select']) && $_REQUEST['saved_search_select']!='_none') {
if(empty($_REQUEST['button']) && (empty($_REQUEST['clear_query']) || $_REQUEST['clear_query']!='true')) {
$this->saved_search = loadBean('SavedSearch');
$this->saved_search->retrieveSavedSearch($_REQUEST['saved_search_select']);
$this->saved_search->populateRequest();
}
elseif(!empty($_REQUEST['button'])) { // click the search button, after retrieving from saved_search
$_SESSION['LastSavedView'][$_REQUEST['module']] = '';
unset($_REQUEST['saved_search_select']);
unset($_REQUEST['saved_search_select_name']);
}
}
$storeQuery = new StoreQuery();
if(!isset($_REQUEST['query'])){
$storeQuery->loadQuery($this->module);
$storeQuery->populateRequest();
}else{
$storeQuery->saveFromRequest($this->module);
}
$seed = $this->bean;
$lv = new ListViewSmarty();
$displayColumns = array();
if(!empty($_REQUEST['displayColumns'])) {
foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) {
if(!empty($listViewDefs[$module][$col]))
$displayColumns[$col] = $listViewDefs[$module][$col];
}
}
else {
foreach($listViewDefs[$module] as $col => $params) {
if(!empty($params['default']) && $params['default'])
$displayColumns[$col] = $params;
}
}
$params = array('massupdate' => true, 'export'=>false);
$lv->quickViewLinks = false;
$lv->export = false;
$lv->mergeduplicates = false;
if(!empty($_REQUEST['orderBy'])) {
$params['orderBy'] = $_REQUEST['orderBy'];
$params['overrideOrder'] = true;
if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder'];
}
$lv->displayColumns = $displayColumns;
$this->seed = $seed;
$this->module = $module;
$searchForm = null;
//search
$view = 'basic_search';
if(!empty($_REQUEST['search_form_view']))
$view = $_REQUEST['search_form_view'];
$headers = true;
if(!empty($_REQUEST['search_form_only']) && $_REQUEST['search_form_only'])
$headers = false;
elseif(!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
if(isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') {
$view = 'advanced_search';
}else {
$view = 'basic_search';
}
}
$use_old_search = true;
if(file_exists('modules/'.$this->module.'/SearchForm.html')){
require_once('include/SearchForm/SearchForm.php');
$searchForm = new SearchForm($this->module, $this->seed);
}else{
$use_old_search = false;
require_once('include/SearchForm/SearchForm2.php');
if(!empty($metafiles[$this->module]['searchdefs']))
require_once($metafiles[$this->module]['searchdefs']);
elseif(file_exists('modules/'.$this->module.'/metadata/searchdefs.php'))
require_once('modules/'.$this->module.'/metadata/searchdefs.php');
if (file_exists('custom/modules/'.$this->module.'/metadata/searchdefs.php'))
{
require_once('custom/modules/'.$this->module.'/metadata/searchdefs.php');
}
elseif (!empty($metafiles[$this->module]['searchdefs']))
{
require_once($metafiles[$this->module]['searchdefs']);
}
elseif (file_exists('modules/'.$this->module.'/metadata/searchdefs.php'))
{
require_once('modules/'.$this->module.'/metadata/searchdefs.php');
}
if(!empty($metafiles[$this->module]['searchfields']))
require_once($metafiles[$this->module]['searchfields']);
elseif(file_exists('modules/'.$this->module.'/metadata/SearchFields.php'))
require_once('modules/'.$this->module.'/metadata/SearchFields.php');
$searchForm = new SearchForm($this->seed, $this->module, $this->action);
$searchForm->setup($searchdefs, $searchFields, 'include/SearchForm/tpls/SearchFormGeneric.tpl', $view, $listViewDefs);
$searchForm->lv = $lv;
}
if(isset($this->options['show_title']) && $this->options['show_title'] && (!isset($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] != "true")) {
$moduleName = isset($this->seed->module_dir) ? $this->seed->module_dir : $GLOBALS['mod_strings']['LBL_MODULE_NAME'];
echo "\n<p>\n";
echo get_module_title($moduleName, $GLOBALS['mod_strings']['LBL_MODULE_TITLE'], true);
echo "\n</p>\n";
}
$where = '';
if(isset($_REQUEST['query']))
{
// we have a query
if(!empty($_SERVER['HTTP_REFERER']) && preg_match('/action=EditView/', $_SERVER['HTTP_REFERER'])) { // from EditView cancel
$searchForm->populateFromArray($storeQuery->query);
}
else {
$searchForm->populateFromRequest();
}
$where_clauses = $searchForm->generateSearchWhere(true, $this->seed->module_dir);
if (count($where_clauses) > 0 )$where = '('. implode(' ) AND ( ', $where_clauses) . ')';
$GLOBALS['log']->info("List View Where Clause: $where");
}
if($use_old_search){
switch($view) {
case 'basic_search':
$searchForm->setup();
$searchForm->displayBasic($headers);
break;
case 'advanced_search':
$searchForm->setup();
$searchForm->displayAdvanced($headers);
break;
case 'saved_views':
echo $searchForm->displaySavedViews($listViewDefs, $lv, $headers);
break;
}
}else{
echo $searchForm->display($headers);
}
if(!$headers)
return;
if(empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false){
// $this->processQuickSearch();
$lv->setup($seed, 'include/ListView/ListViewGeneric.tpl', $where, $params);
$savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' . $_REQUEST['saved_search_select_name']);
echo get_form_header($GLOBALS['mod_strings']['LBL_LIST_FORM_TITLE'] . $savedSearchName, '', false);
echo $lv->display();
}
}
}
?>