Add php files

This commit is contained in:
2025-05-12 15:44:39 +00:00
parent c951760058
commit 82d5804ac4
9534 changed files with 2638137 additions and 0 deletions

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,153 @@
<?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';
$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()->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 %");
$i=2;
$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,ecmreceipt_id,currency_value from ecmreceipts where ".$where." order by type desc, register_date asc, name asc";
$w=$GLOBALS[db]->query($z);
//echo $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,ecmreceiptitem_id from ecmreceiptitems where ecmreceipt_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 ecmreceiptitems where id='".$rr['ecmreceiptitem_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($total_netto-$total_margin>0)$margin=100*$total_margin/($total_netto-$total_margin);
else $margin=0;
$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_netto-$total_margin));
$objPHPExcel->getActiveSheet()->SetCellValue("H".$i,$total_margin);
$objPHPExcel->getActiveSheet()->SetCellValue("I".$i,$margin);
$sum_total_netto+=$total_netto;
$sum_total_pur+=$total_pur;
$sum_total_brutto+=$total_brutto;
$sum_total_margin+=$total_margin;
$i++;
}
if($sum_total_netto-$sum_total_margin>0)$sum_margin=100*$sum_total_margin/($sum_total_netto-$sum_total_margin);
else $sum_margin=0;
$objPHPExcel->getActiveSheet()->SetCellValue("E".$i,$sum_total_brutto);
$objPHPExcel->getActiveSheet()->SetCellValue("F".$i,$sum_total_netto);
$objPHPExcel->getActiveSheet()->SetCellValue("G".$i,($sum_total_netto-$sum_total_margin));
$objPHPExcel->getActiveSheet()->SetCellValue("H".$i,$sum_total_margin);
$objPHPExcel->getActiveSheet()->SetCellValue("I".$i,$sum_margin);
$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/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 ecmreceiptitems.*,ecmreceipts.document_no as dno,ecmreceipts.id as sid,ecmreceipts.type as type from ecminvoiceoutitems inner join ecminvoiceouts on ecminvoiceoutitems.ecminvoiceout_id=ecminvoiceouts.id where ecminvoiceouts.deleted='0' and ecminvoiceouts.register_date>='".$date_from."' and ecminvoiceouts.register_date<='".$date_to."' and ecminvoiceoutitems.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 ecmreceiptitems where id='".$r['ecmreceiptitem_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);
?>

142
modules/EcmReceipts2/Delete.php Executable file
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/EcmReceipts/EcmInvoiceOut.php');
$focus = new EcmReceipt();
// 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,198 @@
<?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/EcmReceipts/EcmReceipt.php');
require_once('modules/EcmReceipts/Forms.php');
require_once('include/time.php');
require_once('include/json_config.php');
$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 EcmReceipt();
if (isset($_REQUEST['record'])) {
$focus->retrieve($_REQUEST['record']);
$focus->format_all_fields();
if (isset($_REQUEST['status']) && $_REQUEST['status'] != '') {
$focus->doNotAccepted();
}
// echo '<pre>' . var_export($focus->getPositionList(true), true);
// exit;
$focus->position_list = str_replace('&quot;', '\"', $focus->getPositionList());
$t = $focus->calculate($focus->getPositionList(true));
$to_paid = format_number($t['total']);
if (!$focus->prepaid) {
$focus->prepaid = 0;
}
if (!$focus->paid_val) {
$focus->paid_val = 0;
}
//echo $focus->prepaid.' '.$focus->paid_val;
$left = format_number($t['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');
$tmp = ".";
if (!isset($tmp) || $tmp == '' || $tmp == NULL) {
$tmp = $sugar_config['default_number_grouping_seperator'];
}
$OPT['sep_1000'] = $tmp;
$tmp = $current_user->getPreference('dec_sep');
$tmp = ",";
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_receipts');
$OPT['user']['confirm_receipts'] = ((isset($cq) && $cq) ? 1 : 0);
$json = getJSONobj();
$qw = 'select name,id,value from ecmvats where deleted = \'0\' order by name';
$w = $GLOBALS[db]->query($qw);
$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'];
}
$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;
require_once('include/MVC/View/SugarView.php');
require_once('modules/EcmReceipts/view/DetailView/view.detail.my.php');
$edit = new ViewDetailMy();
$edit->ss = new Sugar_Smarty();
$edit->module = 'EcmReceipts';
$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);
$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>Paragon</option><br /><br />';
$desc.='<input name="quote_pdf" id="quote_pdf" title="Show PDF" accessKey="" class="button" onclick="window.location = \'index.php?module=EcmReceipts&action=previewPDF&to_pdf=1&record='.$_REQUEST['record'].'\';" type="button" value="Pokaż PDF">';
$edit->ss->assign("CATALOGUE",$desc);
//$email_link_tab = '<script language="javascript">YAHOO.util.Event.addListener(window, "load", function(){setEMAIL = function(){' . $focus->createSendEmailLink() . '}});</script>';
//$edit->ss->assign('EMAIL_LINK_TAB', $email_link_tab);
$qr = 'select id from ecmstockdoccorrects where ecmreceipt_id = \'' . $focus->id . '\';';
$r = $GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query($qr));
if ($r['id']) {
$edit->ss->assign('hasCorrect', $r['id']);
}
$edit->ss->assign('OPT', $OPT);
echo $edit->display();
//echo '<div id="subpanels_div">';
//require_once('subpanels.php');
//echo '</div>';

File diff suppressed because it is too large Load Diff

521
modules/EcmReceipts2/EditView.php Executable file
View File

@@ -0,0 +1,521 @@
<?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.
* ****************************************************************************** */
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings, $current_user, $app_list_strings;
require_once('modules/EcmReceipts/EcmReceipt.php');
require_once('modules/EcmReceipts/Forms.php');
require_once('include/time.php');
require_once('include/json_config.php');
$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 ecmreceipts 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_receipts');
$OPT['user']['confirm_receipts'] = ((isset($cq) && $cq) ? 1 : 0);
$focus = new EcmReceipt();
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 . '/LoadEcmReceipts.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 receipt. This receipt 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();
// dump($focus->toArray());
// exit;
$focus->position_list = str_replace('&quot;', '\"', $focus->getPositionList());
//has wz?
$r = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT ecmstockdocout_id as wz FROM ecmreceiptitems WHERE ecmreceipt_id='" . $focus->id . "'"));
if ($r['wz'] && $r['wz'] != '') {
$OPT['from_wz'] = true;
}
}
} elseif ($_REQUEST['parent_doc_type']=='EcmSales') {
session_start();
$positions = $_SESSION[$_REQUEST['temp_id']];
$sales = array();
foreach ($positions as $v)
$sales[] = $v['parent_doc_id'];
$OPT['new_number'] = true;
$OPT['parent_doc_type'] = 'EcmSales';
$temp_id = $_REQUEST['temp_id'];
//set accounts information
$r = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT * FROM ecmsales 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 ecmsale_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 ecminvoiceouts AS i INNER JOIN ecminvoiceoutitems as ii ON i.id=ii.ecminvoiceout_id WHERE ii.parent_doc_id IN ('".implode("','", $sales)."')"));
$sum+=$old['s'];
$focus->prepaid=$sum;
//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 ecmsaleitems WHERE id ='" . $pos['parent_doc_item_id'] . "'"));
$t = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT type FROM ecmproducts WHERE id='".$pos['id']."'"));
$position = array();
$position['iid'] = create_guid();
$position['code'] = $pos['code'];
$position['name'] = $pos['name'];
$position['id'] = $pos['id'];
$position['quantity'] = $pos['quantity'];
//calculate currency
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['ecmsale_id'];
$position['parent_doc_type'] = 'EcmSales';
$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));
}
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;
}
}
if (isset($_REQUEST['isCorrect']) && $_REQUEST['isCorrect'] == 'true') {
$OPT['new_number'] = true;
$focus->type = 'correct';
$focus->name = '';
$focus->ecmreceipt_id = $focus->id;
$focus->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'];
}
$datef = 'd.m.Y';
//echo $datef;
$focus->register_date = date($datef);
$focus->payment_date = date($datef, mktime() + 30 * 24 * 60 * 60);
$focus->sell_date = date($datef);
}
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');
$tmp = ".";
if (!isset($tmp) || $tmp == '' || $tmp == NULL) {
$tmp = $sugar_config['default_number_grouping_seperator'];
}
$OPT['sep_1000'] = $tmp;
$tmp = $current_user->getPreference('dec_sep');
$tmp = ",";
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, 'EcmReceipts', $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();
$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>';
$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>';
echo $scriptOpt;
require_once('include/MVC/View/SugarView.php');
require_once('modules/EcmReceipts/view/EditView/view.edit.my.php');
$edit = new ViewEditMy();
$edit->ss = new Sugar_Smarty();
$edit->module = 'EcmReceipts';
$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');
$selectedId = $focus->stock_id ? : $app_list_strings['ecmreceipts_stock_id_dom'];
while ($r = $GLOBALS['db']->fetchByAssoc($w)) {
$stocks.='<option value="' . $r['id'] . '"';
if ($r['id'] == $selectedId) {
$stocks.=' selected';
}
$stocks.='>' . $r['name'] . '</option>';
}
$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);
$edit->preDisplay();
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());
echo $edit->display();

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=EcmReceipts&to_pdf=1&type=out&record=$return_id&receipt_id=".$_REQUEST['receipt_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/receipts
$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['receipt_id']) && $_REQUEST['receipt_id'] != '') {
require_once('modules/EcmReceipts/EcmInvoiceOut.php');
$off = new EcmReceipt();
$off->retrieve($_REQUEST['receipt_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['receipt_id']) && $_REQUEST['receipt_id'] != '') {
require_once('modules/EcmReceipts/EcmInvoiceOut.php');
$off = new EcmReceipt();
$off->retrieve($_REQUEST['receipt_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=EcmReceipts&to_pdf=1&type=out&receipt_id=".$_REQUEST['receipt_id']."&sended=1&pTypeFrom=Users&pIdFrom=".$_REQUEST['pIdFrom']."&pTypeTo=".$_REQUEST['pTypeTo']."&pIdTo=".$_REQUEST['pIdTo']."&bodyclass=".$_REQUEST['bodyclass']);
?>

889
modules/EcmReceipts2/Emails.php Executable file
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['receipt_id']) && $_REQUEST['receipt_id']!='') {
$OPT['receipt_id'] = $_REQUEST['receipt_id'];
} else $OPT['receipt_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 receiptAlert(method) {
if(OPT[\'receipt_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/EcmReceipts/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']);
$receiptd = '';
// cn: bug 9725: replies/forwards lose real content
$receiptdHtml = $ieMail->receiptHtmlEmail($ieMail->description_html);
// plain-text
$desc = nl2br(trim($ieMail->description));
$exDesc = explode('<br />', $desc);
foreach($exDesc as $k => $line) {
$receiptd .= '> '.trim($line)."\r";
}
// prefill empties with the other's contents
if(empty($receiptdHtml) && !empty($receiptd)) {
$receiptdHtml = nl2br($receiptd);
}
if(empty($receiptd) && !empty($receiptdHtml)) {
$receiptd = strip_tags(br2nl($receiptdHtml));
}
// 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();
}
$receiptd = br2nl($header.$receiptd);
$receiptdHtml = $header.$receiptdHtml;
// 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 = $receiptd; // don't know what i was thinking: ''; // this will be filled on save/send
$focus->description_html = $receiptdHtml; // 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['receipt_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/EcmReceipts/EcmInvoiceOut.php');
$m = new EcmReceipt();
$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();

65
modules/EcmReceipts2/Forms.php Executable file
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/EcmReceipts/EcmInvoiceOut.php');
$eio = new EcmReceipt();
$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,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=EcmReceipts&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,ecmreceipt_id,currency_value from ecmreceipts 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,ecmreceiptitem_id from ecmreceiptitems where ecmreceipt_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 ecmreceiptitems where id='".$rr['ecmreceiptitem_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 ecmreceiptitems where ecmreceipt_id='".$r['ecmreceipt_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=EcmReceipts&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>Invoices: Saled Products</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="EcmReceipts" />
<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">
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">
Category </td>
<td class="dataField" width="30%" nowrap="nowrap">
<select name="category_id">
<option value="">select</option>
<?php
?>
</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=EcmReceipts&action=ListProducts';"><?
echo '&nbsp;<input type="button" class="button" name="CreateXLS" value="Create XLS" onclick="location.href=\'index.php?module=EcmReceipts&action=CreateXLSProducts&to_pdf=1&date_from='.$date_from.'&date_to='.$date_to.'\';">';
?>
</form><br />
<h2>Date: <? 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.="Lp.";
$t.=$tde;
$t.=$tds1;
$t.="Index";
$t.=$tde;
$t.=$tds1;
$t.="Name";
$t.=$tde;
$t.=$tds1;
$t.="Invoice";
$t.=$tde;
$t.=$tds1;
$t.="Quantity";
$t.=$tde;
$t.=$tds1;
$t.="Price";
$t.=$tde;
$t.=$tds1;
$t.="Total netto";
$t.=$tde;
$t.=$tds1;
$t.="Total Vat";
$t.=$tde;
$t.=$tds1;
$t.="Total brutto";
$t.=$tde;
$t.=$tre;
$i=1;
$z="select ecmreceiptitems.*,ecmreceipts.document_no as dno,ecmreceipts.id as sid,ecmreceipts.type as type,ecminvoiceouts.currency_value as currency_value from ecminvoiceoutitems inner join ecminvoiceouts on ecminvoiceoutitems.ecminvoiceout_id=ecminvoiceouts.id where ecminvoiceouts.deleted='0' and ecminvoiceouts.register_date>='".$date_from."' and ecminvoiceouts.register_date<='".$date_to."' and ecminvoiceoutitems.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 ecmreceiptitems where id='".$r['ecmreceiptitem_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=EcmReceipts&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,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/EcmReceipts/EcmInvoiceOut.php');
require_once('modules/EcmReceipts/Forms.php');
require_once ('include/time.php');
require_once('include/json_config.php');
$json_config = new json_config();
$focus = new EcmReceipt();
if(isset($_REQUEST['record'])) {
$focus->retrieve($_REQUEST['record']);
}
else {}
require_once('include/MVC/View/SugarView.php');
if(file_exists('modules/EcmReceipts/views/view.list.php')) {
require_once('modules/EcmReceipts/views/view.list.php');
$list = new EcmReceiptsViewList();
}
else {
require_once('include/MVC/View/views/view.list.php');
$list = new ViewList();
}
$list->bean = $focus;
$list->module='EcmReceipts';
// 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/EcmReceipts/EcmInvoiceOut.php');
$source = new EcmReceipt();
$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/EcmReceipts/EcmInvoiceOut.php');
$source = new EcmReceipt();
$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 ecmreceiptitems 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;
}
?>

83
modules/EcmReceipts2/Menu.php Executable file
View File

@@ -0,0 +1,83 @@
<?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;
//echo '<pre>' . var_export($mod_strings, true);
//if (ACLController::checkAccess('EcmReceipts', 'edit', true)) {
$module_menu[] = array(
'index.php?module=EcmReceipts&action=EditView&return_module=EcmReceipts&return_action=DetailView',
translate('LNK_NEW_ECMRECEIPT', 'EcmReceipts'),
'CreateEcmReceipts',
'EcmReceipts');
//}
//if (ACLController::checkAccess('EcmReceipts', 'list', true)) {
$module_menu[] = array(
'index.php?module=EcmReceipts&action=index&return_module=EcmReceipts&return_action=DetailView',
translate('LNK_EcmReceipts_LIST', 'EcmReceipts'),
'EcmReceipts',
'EcmReceipts');
//}
//if (ACLController::checkAccess('EcmReceipts', 'list', true) && is_admin($current_user)) {
$module_menu[] = array(
'index.php?module=EcmReceipts&action=PDFLanguages&return_module=EcmReceipts&return_action=index',
$mod_strings['LNK_EcmReceipts_PDFLANGUAGES'],
'PDFlanguages',
'EcmReceipts',
);
//}

View File

@@ -0,0 +1,45 @@
<?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',
);

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,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/EcmReceipts/EcmInvoiceOut.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/EcmReceipts/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/EcmReceipts/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, "EcmReceipts", $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", EcmReceipt::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/EcmReceipts/EcmInvoiceOut.php');
$ecmreceipt = new EcmReceipt();
$xtpl->assign("MFP", $ecmreceipt->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['ecmreceipts_parent_dom'], ''));
echo "\n<p>\n";
echo get_module_title('EcmReceipts', $GLOBALS['mod_strings']['LBL_ECMINVOICEOUTS_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,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,'EcmReceipts',$key,$pdfll[$key]);
}
echo 'Saved';
}
?>

338
modules/EcmReceipts2/Save.php Executable file
View File

@@ -0,0 +1,338 @@
<?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/EcmReceipts/EcmReceipt.php");
require_once('include/formbase.php');
$focus = new EcmReceipt();
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;
//echo var_export($_POST['document_no'], true);exit;
// ~
// array (
// 'module' => 'EcmReceipts',
// 'action' => 'Save',
// 'record' => '',
// 'to_pdf' => '1',
// 'cache' => 'fromJava',
// 'isDuplicate' => 'false',
// 'return_module' => 'EcmReceipts',
// 'return_action' => 'DetailView',
// 'return_id' => '',
// 'contact_role' => '',
// 'relate_to' => 'EcmReceipts',
// 'relate_id' => '',
// 'offset' => '1',
// 'position_list' =>
// array (
// 0 =>
// array (
// 'index' => '1',
// 'code' => '020099',
// 'id' => '7a571024-02c2-7c7c-2429-501aa098386e',
// 'category_id' => '',
// 'currency_id' => 'undefined',
// 'currency_symbol' => 'undefined',
// 'ecmstockdocout_id' => '',
// 'temp_item_id' => '',
// 'temp_date' => '',
// 'type' => '',
// 'parent_doc_id' => '',
// 'parent_doc_type' => '',
// 'parent_doc_item_id' => '',
// 'name' => 'IV53 TŁOK 82MM ACX83D',
// 'quantity' => 1,
// 'startprice' => 1,
// 'pricehelper' => 1.23,
// 'discount' => 0,
// 'vat_value' => '23.00',
// 'vat_id' => '9ec174d1-db5e-8db6-9195-4e6e4a041e40',
// 'subprice' => 1,
// 'price' => 1.23,
// 'unit_id' => 'undefined',
// 'unit_name' => 'undefined',
// 'subtotal' => 1,
// 'total' => 1.23,
// 'stock' => 3,
// 'reserved' => '1',
// 'parent_doc_rq' => '',
// ),
// ),
// 'parent_type' => 'Accounts',
// 'parent_doc_id' => '',
// 'temp_id' => 'bd271276-1487-8083-bb80-5237f29820ab',
// 'ecmlanguage' => 'pl_pl',
// 'button' => 'test',
// 'document_no' => '18/2013',
// 'number' => '2013091718',
// 'assigned_user_name' => 'Michał Zieliński',
// 'assigned_user_id' => '1',
// 'btn_assigned_user_name' => 'Wybierz',
// 'btn_clr_assigned_user_name' => 'Wyczyść',
// 'parent_name' => '"AGROPOL" CZĘŚCI ZAMIENNE WŁODZIMIERZ KAPUSTA',
// 'parent_id' => '2248712',
// 'btn_parent_name' => 'Wybierz',
// 'btn_clr_parent_name' => 'Wyczyść',
// 'type' => '0',
// 'template_id' => 'ef0c4dea-ddf3-de51-9d08-512257d4b675',
// 'template_name' => 'BSL Truck',
// 'register_date' => '17.09.2013',
// 'sell_date' => '17.09.2013',
// 'stock_id' => '2962f1ad-79f4-a1ad-385e-4f286ad7acb5',
// 'name' => '',
// 'payment_date_d' => '',
// 'prepaid' => '',
// 'payment_date' => '17.09.2013',
// 'prepaid_nr' => '',
// 'payment_method' => '',
// 'paid_val' => '',
// 'payment_method_paid' => '',
// 'parent_name_copy' => '"AGROPOL" CZĘŚCI ZAMIENNE WŁODZIMIERZ KAPUSTA',
// 'to_nip' => '754-006-99-44',
// 'parent_contact_name' => '',
// 'currency_id' => 'PLN',
// 'parent_contact_title' => '',
// 'currency_value' => '',
// 'parent_address_street' => 'WRZOSKI, UL. LEŚNA 2',
// 'pdf_type' => 'K',
// 'parent_address_postalcode' => '46-073',
// 'parent_address_city' => 'CHRÓŚCINA',
// 'parent_address_country' => '',
// 'parent_shipping_address_name' => '',
// 'parent_shipping_address_street' => '',
// 'parent_shipping_address_postalcode' => '',
// 'parent_shipping_address_city' => '',
// 'parent_shipping_address_country' => '',
// 'code_p' => '020099',
// 'id_p' => '7a571024-02c2-7c7c-2429-501aa098386e',
// 'category_id_p' => '',
// 'currency_id_p' => 'undefined',
// 'currency_symbol_p' => 'undefined',
// 'ecmstockdocout_id' => '',
// 'temp_item_id_p' => '',
// 'temp_date_p' => '',
// 'type_p' => '',
// 'parent_doc_type' => '',
// 'parent_doc_item_id' => '',
// 'name_p' => 'IV53 TŁOK 82MM ACX83D',
// 'quantity_p' => '1,00',
// 'vat_name_p' => '23%',
// 'vat_value_p' => '23.00',
// 'vat_id_p' => '9ec174d1-db5e-8db6-9195-4e6e4a041e40',
// 'unit_name_p' => 'undefined',
// 'unit_id_p' => 'undefined',
// 'stock_p' => '3,00',
// 'subtotal' => '1,00',
// 'total' => '1,23',
// 'footer_module' => 'EcmReceipts',
// 'footer_fields' => '$receipt_inside_inv_number',
// 'footer_field' => '$receipt_inside_inv_number',
// 'header_text' => '
// ',
// 'header_module' => 'EcmReceipts',
// 'header_fields' => '$receipt_inside_inv_number',
// 'header_field' => '$receipt_inside_inv_number',
// 'footer_text' => '
// ',
// 'ads_module' => 'EcmReceipts',
// 'ads_fields' => '$receipt_inside_inv_number',
// 'ads_field' => '$receipt_inside_inv_number',
// 'ads_text' => '
// ',
// );
// ~
// Weird unformat number ?
// $_POST['total'] = unformat_number(str_replace(array('.', ','), array('', '.'), $_POST['total']));
// $_POST['subtotal'] = unformat_number(str_replace(array('.', ','), array('', '.'), $_POST['subtotal']));
// dump($_POST);
// exit;
foreach ($focus->column_fields as $field) {
//echo var_export($field, true) . PHP_EOL;
//echo var_export($_POST[$field], true) . PHP_EOL;
//continue;
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;
}
$pl = $_POST['position_list'];
$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';
}
if(strlen($parent_name = $_POST['parent_name_copy'])) {
$focus->parent_name = $parent_name;
}
$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 ecmreceipts SET wz_id='" . $_POST['out_id'] . "' WHERE id='" . $focus->id . "'";
$GLOBALS['db']->query($query);
}
$return_id = $focus->id;
goto jump;
//$r = $GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select type,document_no from ecmreceipts where id='" . $return_id . "'"));
//$file = "modules/EcmReceipts/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);
}
jump:
echo $return_id;
die();
//header("Location: index.php?module=EcmReceipts&action=index");
//handleRedirect($return_id,'EcmReceipts');

View File

@@ -0,0 +1,78 @@
<?php
require_once('modules/EcmStockDocOuts/EcmStockDocOut.php');
require_once('modules/EcmReceipts/EcmInvoiceOut.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 ecmreceipts 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 EcmReceipt();
$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 ecmreceipts 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 ecmreceipts 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 ecmreceipts 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 ecmreceiptitems where ecmreceipt_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,6 @@
<?php
$print_conf = array(
'default_com' => 'COM2',
'pass' => 't5',
);
?>

View File

@@ -0,0 +1,22 @@
<?php
error_reporting(LC_ALL);
ini_set('display_errors', 1);
//get configs
require_once('config.php');
require_once('./../../../config.php');
//auth :)
if ($_REQUEST['pass'] != $print_conf['pass'])
die ('Brak autoryzacji');
//create db connection
$db = mysql_connect($sugar_config['dbconfig']['db_host_name'],$sugar_config['dbconfig']['db_user_name'],$sugar_config['dbconfig']['db_password']);
mysql_query("USE ".$sugar_config['dbconfig']['db_name']);
$res = mysql_query("SELECT id, document_no FROM ecmreceipts WHERE deleted='0' AND printed='0'");
echo '<html><form action="print.php"><select id="receipt" name="receipt">';
echo '<OBJECT id=ThermalLib height=0 width=0
classid=clsid:904511D2-5407-4033-8DAD-07B33EC7317E><PARAM NAME="_Version" VALUE="65536"><PARAM NAME="_ExtentX" VALUE="26"><PARAM NAME="_ExtentY" VALUE="26"><PARAM NAME="_StockProps" VALUE="0"></OBJECT>';
while ($row = mysql_fetch_assoc($res)) {
echo '<option value="'.$row['id'].'">'.$row['document_no'].'</option>';
}
echo '</select>';
echo '&nbsp&nbsp<button type="submit">Wybierz</button></form></html>';

View File

@@ -0,0 +1,868 @@
=<HTML>
<HEAD>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-2">
<TITLE>Program testowy kontrolki ThermalLib.ocx</TITLE>
</HEAD>
<SCRIPT LANGUAGE="JavaScript1.1">
function OpenPort(form) {
data = (form.NrCom.options[form.NrCom.selectedIndex].text)
ThermalLib.THLOpenPort(data)
ThermalLib.THLSendBel()
form.BtOpen.disabled=true
form.info.value = ThermalLib.LBIDRQ()
}
function ClosePort(form)
{
ThermalLib.THLClosePort()
form.BtOpen.disabled=false
form.info.value = ""
}
function SendBel(form)
{
alert("SendBel : " + ThermalLib.THLSendBel())
}
function SendChar(form)
{
var txt = form.txt.value
var czycrc = (form.crc.options[form.crc.selectedIndex].text)
var ccrc
if (czycrc == "Tak")
ccrc = "1"
if (czycrc == "Nie")
ccrc = "0"
var czyfrm = (form.frm.options[form.frm.selectedIndex].text)
var cfrm
if (czyfrm == "Tak")
cfrm = "1"
if (czyfrm == "Nie")
cfrm = "0"
alert("SendChar : " + ThermalLib.THLSend(txt,cfrm,ccrc))
}
function GetChar(form)
{
form.odp.value = ThermalLib.THLReceive()
}
function Clean(form)
{
ThermalLib.THLCleanComBuf()
}
function GetTime(form)
{
var co = new String( ThermalLib.LBSENDCK())
co = co + ";"
//alert(co)
var time = new String(co)
var s1 = time.indexOf( ";" , 0 )
form.yy.value = ("20" + time.substring(0,s1))
var s2 = time.indexOf( ";" , (s1+1) )
form.mm.value = time.substring((s1+1) ,s2)
var s3 = time.indexOf( ";" , (s2+1) )
form.dd.value = time.substring((s2+1) ,s3)
var s4 = time.indexOf( ";" , (s3+1) )
form.hh.value = time.substring((s3+1) ,s4)
var s5 = time.indexOf( ";" , (s4+1) )
form.ms.value = time.substring((s4+1) ,s5)
}
function GetDle(form)
{
var dle = new String(ThermalLib.THLSendDLE())
alert(dle)
var r1 = dle.indexOf( "=" , 0 )
form.onl.value = dle.substring( (r1+1), (r1+2) )
var r2 = dle.indexOf( "=" , (r1+1) )
form.peakk.value = dle.substring( (r2+1) , (r2+2) )
var r3 = dle.indexOf( "=" , (r2+1) )
form.err.value = dle.substring( (r3+1) , (r3+2) )
}
function GetENQ(form)
{
var enq = new String(ThermalLib.THLSendENQ())
//alert(enq)
var r1 = enq.indexOf( "=" , 0 )
form.fsk.value = enq.substring( (r1+1), (r1+2) )
var r2 = enq.indexOf( "=" , (r1+1) )
form.cmd.value = enq.substring( (r2+1) , (r2+2) )
var r3 = enq.indexOf( "=" , (r2+1) )
form.par.value = enq.substring( (r3+1) , (r3+2) )
var r4 = enq.indexOf( "=" , (r3+1) )
form.trf.value = enq.substring( (r4+1) , (r4+2) )
}
function Login(form)
{
var login = ThermalLib.LBLOGIN(form.LoginKasjer.value, form.LoginKasa.value)
alert("LBLOGIN : " + login)
}
function Logout(form)
{
var logout = ThermalLib.LBLOGOUT(form.LogoutKasjer.value, form.LogoutKasa.value)
alert("LBLOGOUT: " + logout)
}
function Feed(form)
{
var ico = (ThermalLib.LBFEED(form.Illine.value))
alert("LBFEED : " + ico)
}
function Ndmd(form)
{
var co = (form.ndmd.options[form.ndmd.selectedIndex].text)
var data
if (co == "kopii")
data = "0"
if (co == "org. + kopia")
data = "1"
var ico = (ThermalLib.LBSNDMD(data))
alert("LBMDND : " + ico)
}
function LBSTOCSH(form)
{
var ico = ThermalLib.LBSTOCSH(form.tocash.value,form.tocashkasa.value,form.tocashkasjer.value)
alert("LBSTOCSH : " + ico)
}
function LBDECCSH(form)
{
var ico = ThermalLib.LBDECCSH(form.deccsh.value,form.deccshkasa.value,form.deccshkasjer.value)
alert("LBDECCSH : " + ico)
}
function LBINCCSH(form)
{
var ico = ThermalLib.LBINCCSH(form.inccsh.value,form.inccshkasa.value,form.inccshkasjer.value)
alert("LBINCCSH : " + ico)
}
function LBSERM(form)
{
var co = (form.lbserm.options[form.lbserm.selectedIndex].text)
var ico = ThermalLib.lbserm(co)
alert("LBSERM : " + ico)
}
function LBERNRQ(form)
{
form.lbernrq.value = ThermalLib.LBERNRQ()
}
function LBDAYREP(form)
{
var ico = ThermalLib.LBDAYREP(10000,form.dayrep.options[form.dayrep.selectedIndex].text ,form.dayrepkasa.value,form.dayrepkasjer.value)
alert("LBDAYREP : " + ico)
}
function THLSetCk(form)
{
var ico = ThermalLib.THLSetCk(form.setckgodzina.value,form.setckminuta.value, form.setckkasa.value, form.setckkasjer.value)
alert("THLSetCk : " + ico)
}
function LBTRSHDR(form)
{
var ico = ThermalLib.LBTRSHDR(form.hdrpi.value,form.hdrpn.value,form.hdrline1.value, form.hdrline2.value,form.hdrline3.value)
alert("LBTRSHDR: " + ico)
}
function LBTREXITCAN(form)
{
var ico = ThermalLib.LBTREXITCAN(form.canpns.value, form.cankasa.value, form.cankasjer.value, form.cannrsys.value)
alert("LBTREXITCAN : " + ico)
}
function LBTRSLN(form)
{
var ico = ThermalLib.LBTRSLN( form.trslnpi.value, form.trslnpr.value, form.trslnpo.value, form.trslnnazwa.value, form.trslnilosc.value, form.trslnptu.value, form.trslncena.value, form.trslnbrutto.value, form.trslnrabat.value, form.trslnopisrabatu.value)
alert( "LBTRSLN : " + ico)
}
function LBTREXIT(form)
{
var ico = ThermalLib.LBTREXIT(form.exitpr.value, form.exitpn.value, form.exitpx.value, form.exitkod.value, form.exitlinia1.value, form.exitlinia2.value, form.exitlinia3.value, form.exitwplata.value, form.exittotal.value, form.exitrabat.value)
alert("LBTREXIT : " + ico)
}
function LBTRXEND1(form)
{
var ico = ThermalLib.LBTRXEND1(form.end1pns.value,form.end1pr.value,form.end1pg.value,form.end1nrsys.value,form.end1total.value,
form.end1wplata.value,form.end1reszta.value,form.end1nrkasy.value,form.end1kasjer.value)
alert("LBTRXEND1: " + ico)
}
function LBDEP(form)
{
var co = (form.lbdepps.options[form.lbdepps.selectedIndex].text)
var data
if (co == "wydanie")
data = "10"
if (co == "przyjecie")
data = "6"
if (co == "storno przyjecia")
data = "7"
if (co == "storno wydania")
data = "11"
var ico = ThermalLib.LBDEP(data, form.lbdepnr.value,form.lbdepilosc.value,form.lbdepwartosc.value)
alert("LBDEP: " + ico)
}
function THLAddKaucje(form)
{
var co = (form.addkaucjeps.options[form.addkaucjeps.selectedIndex].text)
var data
if (co == "wydanie")
data = "1"
if (co == "przyjecie")
data = "0"
var ico = ThermalLib.THLAddKaucje(data, form.addkaucjenropak.value,form.addkaucjeilosc.value,form.addkaucjewartosc.value)
alert("THLAddKaucje : " + ico)
}
function THLAddRab(form)
{
var co = (form.addrabpx.options[form.addrabpx.selectedIndex].text)
var data
if (co == "brak")
data = 0
if (co == "rabat proc.")
data = 1
if (co == "rabat kwot.")
data = 3
if (co == "narzut proc.")
data = 2
if (co == "narzut kwot.")
data = 4
var co = (form.addrabpxs.options[form.addrabpxs.selectedIndex].text)
var data2
if (co == "tak")
data2 = 1
if (co == "nie")
data2 = 0
var ico = ThermalLib.THLAddRab(data, data2, form.addrabwartosc.value, form.addrabopis.value)
alert("THLAddRab: " + ico)
}
function THLAddFormPlat(form)
{
var co = (form.addformplattyp.options[form.addformplattyp.selectedIndex].text)
var data
if (co == "karta")
data = 1
if (co == "czek")
data = 2
if (co == "bon")
data = 3
if (co == "inna")
data = 4
var ico = ThermalLib.THLAddFormPlat(data, form.addformplatnazwa.value, form.addformplatwartosc.value)
alert("THLAddFormPlat: " + ico)
}
function LBFSKREP1(form)
{
var co = (form.fskrep1.options[form.fskrep1.selectedIndex].text)
var data
if (co == "miesięczny")
data = 6
if (co == "miesięczny podsum.")
data = 7
if (co == "okresowy")
data = 0
if (co == "okresowy podsum.")
data = 1
var ico = ThermalLib.LBFSKREP1(data, form.fskrepdatapocz.value, form.fskrepdatakon.value, form.fskrepkasa.value, form.fskrepkasjer.value)
alert("LBFSKREP1: " + ico)
}
function LBFSKREP2(form)
{
var co = (form.fskrep2.options[form.fskrep2.selectedIndex].text)
var data
if (co == "okresowy")
data = 16
if (co == "okresowy podsum.")
data = 17
var ico = ThermalLib.LBFSKREP2(data, form.fskrep2nrpocz.value, form.fskrep2nrkon.value, form.fskrep2kasa.value, form.fskrep2kasjer.value)
alert("LBFSKREP2: " + ico)
}
function THLAddCshRepFormPlat(form)
{
var co = (form.cshrepaddformplat.options[form.cshrepaddformplat.selectedIndex].text)
var data
if (co == "karta")
data =0
if (co == "czek")
data =1
if (co == "bon")
data =2
var ico = ThermalLib.THLAddCshRepFormPlat(data, form.cshrepaddformplatnazwa.value, form.cshrepaddformplatwartosc.value)
alert("THLAddCshRepFormPlat: " + ico)
}
function LBCSHREP1(form)
{
ico = ThermalLib.LBCSHREP1(
form.cshrepzmiana.value,
form.cshrepkasjer.value,
form.cshreppoczatek.value,
form.cshrepkoniec.value,
form.cshrepprzychod.value,
form.cshrepsprzedgot.value,
form.cshrepwplaty.value,
form.cshrepprzyjecia.value,
form.cshrepwyplaty.value,
form.cshrepwydania.value,
form.cshrepstankasy.value,
form.cshrepiloscparagonow.value,
form.cshrepiloscanulparagonow.value,
form.cshrepiloscstorno.value,
form.cshrepnrkasy.value)
alert("LBCSHREP1: " + ico)
}
function LBFSTRQ25(form)
{
ico = ThermalLib.LBFSTRQ25(
form.LBFSTRQ25YY.value,
form.LBFSTRQ25MC.value,
form.LBFSTRQ25DD.value,
form.LBFSTRQ25GG.value,
form.LBFSTRQ25MM.value
)
alert("LBFSTRQ25: " + ico)
form.RekordPoDatach.value = ThermalLib.LBFSTRQ(27)
}
function LBFSTRQ26(form)
{
ico = ThermalLib.LBFSTRQ26(form.LBFSTRQ26NR.value)
alert("LBFSTRQ26: " + ico)
form.RekordPoNR.value = ThermalLib.LBFSTRQ(27)
}
function LBFSTRQ(form)
{
ico = ThermalLib.LBFSTRQ(50)
form.Status50.value = ThermalLib.LBFSTRQ(50)
}
</SCRIPT>
<BODY bgcolor=black >
<OBJECT id=ThermalLib height=0 width=0
classid=clsid:904511D2-5407-4033-8DAD-07B33EC7317E><PARAM NAME="_Version" VALUE="65536"><PARAM NAME="_ExtentX" VALUE="26"><PARAM NAME="_ExtentY" VALUE="26"><PARAM NAME="_StockProps" VALUE="0"></OBJECT>
<FORM id=form1 name=form1>
<TABLE width="75%" border=1 align=center>
<TR>
<TD>
<SELECT NAME="NrCom">
<OPTION SELECTED>Com1
<OPTION>Com2
<OPTION>Com3
<OPTION>Com4
</OPTION>
</SELECT>
<INPUT TYPE="button" VALUE="Połącz" name=BtOpen onClick="OpenPort(this.form)" >
<INPUT TYPE="button" VALUE="Rozłącz" name=BtClose onClick="ClosePort(this.form)" >
<INPUT TYPE="button" VALUE="Bel" name=BtBel onClick="SendBel(this.form)">
<font color=white >Drukarka: </font></FONT><INPUT name=info style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; FONT-SIZE: medium; BORDER-LEFT: 0px; WIDTH: 252px; COLOR: red; BORDER-BOTTOM: 0px; HEIGHT: 22px; BACKGROUND-COLOR: black; TEXT-ALIGN: center" border=0 size=110>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" VALUE="Send" name=BtSendChar onClick="SendChar(this.form)">
<font color=white >Tekst</font><INPUT name=txt
style="WIDTH: 120px; HEIGHT: 22px" size=16>
<font color=white >CRC</font>
<SELECT NAME="crc">
<OPTION SELECTED>Tak
<OPTION>Nie
</OPTION>
</SELECT>
<font color=white >Ramka:</font>
<SELECT NAME="frm">
<OPTION SELECTED>Tak
<OPTION>Nie
</OPTION>
</SELECT>&nbsp;&nbsp;
<INPUT TYPE="button" VALUE="Receive" name=BtGetChar onClick="GetChar(this.form)" style="WIDTH: 60px; HEIGHT: 24px" size=16>
<INPUT name=odp style="WIDTH: 113px; HEIGHT: 22px"
size=15>&nbsp;&nbsp;&nbsp;
<INPUT TYPE="button" VALUE="Wyczyść" name=BtClean onClick="Clean(this.form)" style="WIDTH: 64px; HEIGHT: 24px" size=15>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" VALUE="Odczyt czasu" name=BtGetTime onClick="GetTime(this.form)" style="WIDTH: 97px; HEIGHT: 24px" size=23>
<font color=white >Rok: </font><INPUT name=yy style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; FONT-SIZE: medium; BORDER-LEFT: 0px; WIDTH: 43px; COLOR: red; BORDER-BOTTOM: 0px; HEIGHT: 22px; BACKGROUND-COLOR: black; TEXT-ALIGN: center" border=0 size=19>
<font color=white>Miesiąć: </font><INPUT name=mm style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; FONT-SIZE: medium; BORDER-LEFT: 0px; WIDTH: 35px; COLOR: red; BORDER-BOTTOM: 0px; HEIGHT: 22px; BACKGROUND-COLOR: black" border=0 size=15>
<font color=white>Dzień: </font><INPUT name=dd style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; FONT-SIZE: medium; BORDER-LEFT: 0px; WIDTH: 35px; COLOR: red; BORDER-BOTTOM: 0px; HEIGHT: 22px; BACKGROUND-COLOR: black" border=0 size=15>
<font color=white>Godzina: </font><INPUT name=hh style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; FONT-SIZE: medium; BORDER-LEFT: 0px; WIDTH: 38px; COLOR: red; BORDER-BOTTOM: 0px; HEIGHT: 22px; BACKGROUND-COLOR: black" border=0 size=16>
<font color=white>Minuta: </font><INPUT name=ms style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; FONT-SIZE: medium; BORDER-LEFT: 0px; WIDTH: 35px; COLOR: red; BORDER-BOTTOM: 0px; HEIGHT: 22px; BACKGROUND-COLOR: black" border=0 size=15>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" VALUE="DLE" name=BtGetDle onClick="GetDle(this.form)" style="WIDTH: 38px; HEIGHT: 24px" size=7>&nbsp;
<font color=white >ONL:</font>
<INPUT name=onl style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; FONT-SIZE: medium; BORDER-LEFT: 0px; WIDTH: 36px; COLOR: red; BORDER-BOTTOM: 0px; HEIGHT: 22px; BACKGROUND-COLOR: black" border=0 size=15>
<font color=white
>PE/AKK:</font>
<INPUT name=peakk style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; FONT-SIZE: medium; BORDER-LEFT: 0px; WIDTH: 35px; COLOR: red; BORDER-BOTTOM: 0px; HEIGHT: 22px; BACKGROUND-COLOR: black"
border=0 size=15>
<font color=white
>ERR:</font>
<INPUT name=err style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; FONT-SIZE: medium; BORDER-LEFT: 0px; WIDTH: 29px; COLOR: red; BORDER-BOTTOM: 0px; HEIGHT: 22px; BACKGROUND-COLOR: black" border=0 size=12>
<INPUT TYPE="button" VALUE="ENQ" name=BtGetEnq onClick="GetENQ(this.form)" style="WIDTH: 43px; HEIGHT: 24px" size=9>&nbsp;
<font color=white >FSK:</font>
<INPUT name=fsk style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; FONT-SIZE: medium; BORDER-LEFT: 0px; WIDTH: 35px; COLOR: red; BORDER-BOTTOM: 0px; HEIGHT: 22px; BACKGROUND-COLOR: black" border=0 size=15>
<font color=white
>CMD:</font>
<INPUT name=cmd style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; FONT-SIZE: medium; BORDER-LEFT: 0px; WIDTH: 33px; COLOR: red; BORDER-BOTTOM: 0px; HEIGHT: 22px; BACKGROUND-COLOR: black"
border=0 size=14>
<font color=white
>PAR:</font>
<INPUT name=par style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; FONT-SIZE: medium; BORDER-LEFT: 0px; WIDTH: 29px; COLOR: red; BORDER-BOTTOM: 0px; HEIGHT: 22px; BACKGROUND-COLOR: black"
border=0 size=12>
<font color=white
>TRF:</font>
<INPUT name=trf style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; FONT-SIZE: medium; BORDER-LEFT: 0px; WIDTH: 39px; COLOR: red; BORDER-BOTTOM: 0px; HEIGHT: 22px; BACKGROUND-COLOR: black"
border=0 size=17>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" VALUE="Obsługa błędów" name=BtLBSERM onClick="LBSERM(this.form)">
<font color=white >Sposób obsługi:</font>
<SELECT NAME="lbserm">
<OPTION SELECTED>2
<OPTION>3
</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" VALUE="Login" name=BtLogin onClick="Login(this.form)">
<font color=white > Kasjer: </font><INPUT value="Sebastian" name=LoginKasjer>
<font color=white >Kasa: </font><INPUT value="1975" name=LoginKasa>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" VALUE="Logout" name = BtLogout onClick="Logout(this.form)">
<font color=white > Kasjer: </font><INPUT value="Hania" name=LogoutKasjer>
<font color=white >Kasa: </font><INPUT value="1977" name=LogoutKasa>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" VALUE="Wysów papieru" name=BtFeed onClick="Feed(this.form)">
<font color=white >Ilość linii: </font><INPUT value="1" name="Illine" style="WIDTH: 64px; HEIGHT: 22px" size=8>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" VALUE="Oszcz. pap." name=BtNdmd onClick="Ndmd(this.form)">
<font color=white >Wydruki na:</font>
<SELECT NAME="ndmd">
<OPTION SELECTED>kopii
<OPTION>org. + kopia
</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" VALUE="Zwrot towru" name=BtLBSTOCSH onClick="LBSTOCSH(this.form)">
<font color=white >Kwota: </font><INPUT value="0.03" name="tocash" style="WIDTH: 64px; HEIGHT: 22px" size=8>
<font color=white >Kasa: </font><INPUT value="1977" name="tocashkasa" style="WIDTH: 64px; HEIGHT: 22px" size=8>
<font color=white
>Kasjer: </font><INPUT value="Hania" name="tocashkasjer" style="WIDTH: 64px; HEIGHT: 22px" size=8>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" VALUE="Wypłata z kasy" name=BtLBDECCSH onClick="LBDECCSH(this.form)">
<font color=white >Kwota: </font><INPUT value="111.11" name="deccsh" style="WIDTH: 64px; HEIGHT: 22px" size=8>
<font color=white >Kasa: </font><INPUT value="1975" name="deccshkasa" style="WIDTH: 64px; HEIGHT: 22px" size=8>
<font color=white
>Kasjer: </font><INPUT value="Sebastian" name="deccshkasjer" style="WIDTH: 64px; HEIGHT: 22px" size=8>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" VALUE="Wpłata do kasy" name=BtLBINCCSH onClick="LBINCCSH(this.form)">
<font color=white >Kwota: </font><INPUT value="99,99" name="inccsh" style="WIDTH: 64px; HEIGHT: 22px" size=8>
<font color=white >Kasa: </font><INPUT value="1975" name="inccshkasa" style="WIDTH: 64px; HEIGHT: 22px" size=8>
<font color=white
>Kasjer: </font><INPUT value="Sebastian" name="inccshkasjer" style="WIDTH: 64px; HEIGHT: 22px" size=8>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" VALUE="Ostatni rozkaz" name=BtGetLBERNRQ onClick=" LBERNRQ(this.form)" style="WIDTH: 106px; HEIGHT: 24px" size=25>
<font color=white > Status: </font><INPUT name=lbernrq style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; FONT-SIZE: medium; BORDER-LEFT: 0px; WIDTH: 43px; COLOR: red; BORDER-BOTTOM: 0px; HEIGHT: 22px; BACKGROUND-COLOR: black; TEXT-ALIGN: center" border=0 size=19>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" VALUE="Zmiana zegara" name=BtSetCk onClick="THLSetCk(this.form)">
<font color=white >Godzina: </font><INPUT name="setckgodzina"
style="WIDTH: 64px; HEIGHT: 22px" size=8>
<font color=white >Minuta:
<INPUT
name="setckminuta"
style="WIDTH: 64px; HEIGHT: 22px" size=8></font>
<font color=white >Kasa: </font><INPUT value="1975" name="setckkasa" style="WIDTH: 64px; HEIGHT: 22px" size=8>
<font color=white >Kasjer: </font><INPUT value="Sebastian" name="setckkasjer" style="WIDTH: 64px; HEIGHT: 22px" size=8>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" VALUE="Anuluj" name=BtSetCk onClick="LBTREXITCAN(this.form)">
<font color=white >Pns: </font><INPUT value="1" name="canpns" style="WIDTH: 36px; HEIGHT: 22px" size=4>
<font color=white >Kasa: <INPUT value="1975" name="cankasa" style="WIDTH: 64px; HEIGHT: 22px" size=8></font>
<font color=white >Kasjer:: </font><INPUT value="Sebastian" name="cankasjer" style="WIDTH: 64px; HEIGHT: 22px" size=8>
<font color=white >NrSys: </font><INPUT value="##1234#" name="cannrsys" style="WIDTH: 64px; HEIGHT: 22px"
size=8>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" VALUE="Początek transakcji" name=BtLBTRSHDR onClick="LBTRSHDR(this.form)" style="WIDTH: 130px; HEIGHT: 24px" size=13>
<font color=white >Tryb: </font><INPUT value=0 name="hdrpi" style="WIDTH: 20px; HEIGHT: 22px" size=2>
<font color=white
>Ilość dodatk.
linii: <INPUT value="0" name="hdrpn" style="WIDTH: 19px; HEIGHT: 22px" size=1></font>
<font color=white
>Linia 1: </font><INPUT value=" " name="hdrline1" style="WIDTH: 39px; HEIGHT: 22px" size=4>
<font color=white >Linia 2: </font><INPUT value=" " name="hdrline2" style="WIDTH: 37px; HEIGHT: 22px" size=4>
<font color=white
>Linia 3: </font><INPUT value=" " name="hdrline3" style="WIDTH: 38px; HEIGHT: 22px" size=4>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" VALUE="Linia transakcji" name=BtLBTRSLN onClick="LBTRSLN(this.form)" style="WIDTH: 130px; HEIGHT: 24px" size=13>
<font color=white >Nr linii: </font><INPUT value=1 name="trslnpi" style="WIDTH: 20px; HEIGHT: 22px" size=2>
<font color=white >Rodzaj rabatu: </font><INPUT value="2" name="trslnpr" style="WIDTH: 16px; HEIGHT: 22px" size=1>
<font color=white
>Opis rabatu: </font><INPUT value="16" name="trslnpo" style="WIDTH: 23px; HEIGHT: 22px" size=2>
<font color=white >Wart. rabatu: </font><INPUT value="10" name="trslnrabat" style="WIDTH: 29px; HEIGHT: 22px" size=3>
<font color=white
>Opis rabatu: </font><INPUT value="promocja POSNET" name="trslnopisrabatu" style="WIDTH: 95px; HEIGHT: 22px" size =11>
<font color=white >Nazwa towaru: </font><INPUT value="Woda mineralna" name="trslnnazwa" style="WIDTH: 69px; HEIGHT: 22px" size=7>
<font color=white
>Ilość: </font><INPUT value="2" name="trslnilosc" style="WIDTH: 37px; HEIGHT: 22px" size=4>
<font color=white >PTU: </font><INPUT value="A" name="trslnptu" style="WIDTH: 35px; HEIGHT: 22px" size=4>
<font color=white
>Cena: </font><INPUT value="2.5" name="trslncena" style="WIDTH: 38px; HEIGHT: 22px" size=4>
<font color=white >Brutto: </font><INPUT value="5" name="trslnbrutto" style="WIDTH: 37px; HEIGHT: 22px" size=4>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" VALUE="Koniec transakcji" name=BtLBTREXIT onClick="LBTREXIT(this.form)" style="WIDTH: 130px; HEIGHT: 24px" size=13>
<font color=white >Rabat%: </font><INPUT value="0" name="exitpr" style="WIDTH: 20px; HEIGHT: 22px" size=2>
<font color=white >Ilość dodatk. linii: </font><INPUT value="1" name="exitpn" style="WIDTH: 16px; HEIGHT: 22px" size=1>
<font color=white
>Rodzaj rabatu: </font><INPUT value="0" name="exitpx" style="WIDTH: 23px; HEIGHT: 22px" size=2>
<font color=white >Kod: </font><INPUT value="1SW" name="exitkod" style="WIDTH: 69px; HEIGHT: 22px" size=7>
<font color=white
>Linia1: </font><INPUT value="##BTV2005/05/05#" name="exitlinia1" style="WIDTH: 37px; HEIGHT: 22px" size=4>
<font color=white
>Linia2: </font><INPUT value=" " name="exitlinia2" style="WIDTH: 35px; HEIGHT: 22px" size=4>
<font color=white >Linia3: </font><INPUT value=" " name="exitlinia3" style="WIDTH: 38px; HEIGHT: 22px" size=4>
<font color=white
>Wpłata: </font><INPUT value="10" name="exitwplata" style="WIDTH: 37px; HEIGHT: 22px" size=4>
<font color=white >Total: </font><INPUT value="4.5" name="exittotal" style="WIDTH: 29px; HEIGHT: 22px" size=3>
<font color=white
>Wart. rabatu: </font><INPUT value="0" name="exitrabat" style="WIDTH: 64px; HEIGHT: 22px" size =8>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" VALUE="Obsługa kaucji" name=BtLBDEP onClick="LBDEP(this.form)" style="WIDTH: 121px; HEIGHT: 24px" size=11>
<font color=white >Ps: </font>
<SELECT NAME="lbdepps">
<OPTION SELECTED>wydanie
<OPTION>przyjecie
<OPTION>storno przyjęcia
<OPTION>storno wydania
</OPTION>
</SELECT>
<font color=white >Nr opak.: </font><INPUT value="1" name="lbdepnr" style="WIDTH: 42px; HEIGHT: 22px" size=3>
<font color=white >Ilość: </font><INPUT value="2" name="lbdepilosc" style="WIDTH: 32px; HEIGHT: 22px" size=2> Cena
<font color=white >ilość*cena: </font><INPUT value="2" name="lbdepwartosc" style="WIDTH: 41px; HEIGHT: 22px" size=3>
<tr>
<td>
<P align=center><font color=white size=4
><STRONG>Zakonczenie z formami platnosci
($y).</STRONG> </font> </P>
<tr>
<td>
<INPUT TYPE="button" VALUE="$y - Kaucje" name=BtTHLAddKaucje onClick="THLAddKaucje(this.form)" style="WIDTH: 121px; HEIGHT: 24px" size=11>
<SELECT NAME="addkaucjeps">
<OPTION SELECTED>wydanie
<OPTION>przyjecie
</OPTION>
</SELECT>
<font color=white >Nr opak</font><INPUT value="1" name="addkaucjenropak" style="WIDTH: 42px; HEIGHT: 22px" size=3>
<font color=white >Ilość</font><INPUT value="1" name="addkaucjeilosc" style="WIDTH: 42px; HEIGHT: 22px" size=3>
<font color=white >Wartość</font><INPUT value="1" name="addkaucjewartosc" style="WIDTH: 42px; HEIGHT: 22px" size=3>
<tr>
<td>
<INPUT TYPE="button" VALUE="$y - Rabat/narzut" name=BtTHLAddRab onClick="THLAddRab(this.form)" style="WIDTH: 121px; HEIGHT: 24px" size=11>
<SELECT NAME="addrabpx">
<OPTION SELECTED>rabat proc.
<OPTION>rabat kwot.
<OPTION>narzut proc.
<OPTION>narzut kwot.
<OPTION>brak
</OPTION>
</SELECT>
<font color=white >Opis rabatu: </font>
<SELECT NAME="addrabpxs">
<OPTION SELECTED>tak
<OPTION>nie
</OPTION>
</SELECT>
<font color=white >Wartosc: </font><INPUT value="10" name="addrabwartosc" style="WIDTH: 20px; HEIGHT: 22px" size=2>
<font color=white >Opis: </font><INPUT value="opisik" name="addrabopis" style="WIDTH: 110px; HEIGHT: 22px" size=11>
<tr>
<td>
<P>
<INPUT TYPE="button" VALUE="$y - Formy platnosci" name=BtTHLAddFormPlat onClick="THLAddFormPlat(this.form)" style="WIDTH: 146px; HEIGHT: 24px" size=12>
<font color=white >Typ: </font>
<SELECT NAME="addformplattyp">
<OPTION SELECTED>karta
<OPTION>czek
<OPTION>bon
<OPTION>inna
</OPTION>
</SELECT>
<font color=white >Nazwa: </font><INPUT value="VISA" name="addformplatnazwa" style="WIDTH: 95px; HEIGHT: 22px" size=7>
<font color=white >Kwota: </font><INPUT value="0" name="addformplatwartosc" style="WIDTH: 95px; HEIGHT: 22px" size=7> </P>
</td></tr>
<TR>
<TD>
<INPUT TYPE="button" VALUE="$y - Koniec" name=BtLBTRXEND1 onClick="LBTRXEND1(this.form)" style="WIDTH: 96px; HEIGHT: 24px" size=9>
<font color=white >Pns: </font><INPUT value="1" name="end1pns" style="WIDTH: 20px; HEIGHT: 22px" size=2>
<font color=white >Pr: </font><INPUT value="0" name="end1pr" style="WIDTH: 20px; HEIGHT: 22px" size=2>
<font color=white >Pg: </font><INPUT value="1" name="end1pg" style="WIDTH: 20px; HEIGHT: 22px" size=2>
<font color=white >Nr_sys: </font><INPUT value="1234567890" name="end1nrsys" style="WIDTH: 69px; HEIGHT: 22px" size=6>
<font color=white >Total: </font><INPUT value="4.5" name="end1total" style="WIDTH: 44px; HEIGHT: 22px" size=4>
<font color=white >Wplata: </font><INPUT value="5" name="end1wplata" style="WIDTH: 52px; HEIGHT: 22px" size=2>
<font color=white >Reszta: </font><INPUT value="0" name="end1reszta" style="WIDTH: 56px; HEIGHT: 22px" size=4>
<font color=white >Nr kasy: </font><INPUT value="Kasa1" name="end1nrkasy" style="WIDTH: 106px; HEIGHT: 22px" size=9>
<font color=white >Kasjer </font><INPUT value="Sebastian" name="end1kasjer" style="WIDTH: 95px; HEIGHT: 22px" size=7></TD></TR>
<tr>
<td>
<P align=center><FONT size=4><STRONG><font color=#ffffff
>Raporty fiskalne</font> </STRONG></FONT></P>
<TR>
<TD>
<INPUT TYPE="button" VALUE="Raport dobowy" name=BtLBINCCSH onClick="LBDAYREP(this.form)">
<font color=white >Data: </font>
<SELECT NAME="dayrep">
<OPTION SELECTED>0
<OPTION>1
</OPTION>
</SELECT>
<font color=white
>Kasa: </font><INPUT value="1975" name="dayrepkasa" style="WIDTH: 64px; HEIGHT: 22px"
size=8>
<font color=white >Kasjer: </font><INPUT value="Sebastian" name="dayrepkasjer" style="WIDTH: 64px; HEIGHT: 22px" size=8>
</TD>
</TR>
<TR>
<TD>
<P>
<INPUT TYPE="button" VALUE="Raport okres. wg dat" name=BtLBFSKREP1 onClick="LBFSKREP1(this.form)" style="WIDTH: 137px; HEIGHT: 24px" size=11>
<SELECT NAME="fskrep1"
style="WIDTH: 155px">
<OPTION SELECTED>miesięczny
<OPTION>miesięczny podsum.
<OPTION>okresowy
<OPTION>okresowy podsum.
</OPTION>
</SELECT> &nbsp;
<font color=white > Poczatek(yy/mm/dd) </font><INPUT name="fskrepdatapocz" style="WIDTH: 137px; HEIGHT: 22px" size =10>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color=white > Koniec(yy/mm/dd) </font><INPUT name="fskrepdatakon" style="WIDTH: 70px; HEIGHT: 22px" size =6>
<font color=white >Kasa: </font><INPUT value="1975" name="fskrepkasa" style="WIDTH: 53px; HEIGHT: 22px" size=5>
<font color=white >Kasjer: </font><INPUT value="Sebastian" name="fskrepkasjer" style="WIDTH: 120px; HEIGHT: 22px" size=12></P></TD>
<TR>
<TD>
<P>
<INPUT TYPE="button" VALUE="Raport okres. wg nr." name=BtLBFSKREP2 onClick="LBFSKREP2(this.form)" style="WIDTH: 155px; HEIGHT: 24px" size=14>
<SELECT NAME="fskrep2">
<OPTION SELECTED>okresowy
<OPTION>okresowy podsum.
</OPTION>
</SELECT> &nbsp;
<font color=white >Nr pocz.: </font><INPUT name="fskrep2nrpocz" style="WIDTH: 55px; HEIGHT: 22px" size =4>
<font color=white >Nr kon.: </font><INPUT name="fskrep2nrkon" style="WIDTH: 65px; HEIGHT: 22px" size =5>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color=white >Kasa: </font><INPUT value="1975" name="fskrep2kasa" style="WIDTH: 53px; HEIGHT: 22px" size=5>
<font color=white >Kasjer: </font><INPUT value="Sebastian" name="fskrep2kasjer" style="WIDTH: 120px; HEIGHT: 22px" size=12></P></TD></TR>
<tr>
<td>
<P align=center><FONT size=4><STRONG><font color=#ffffff
>Raport kasjera</font> </STRONG></FONT></P>
<tr>
<td>
<INPUT TYPE="button" VALUE="Formy płatn." name=Btcshrepaddformplat onClick="THLAddCshRepFormPlat(this.form)" style="WIDTH: 155px; HEIGHT: 24px" size=14>
<SELECT NAME="cshrepaddformplat">
<OPTION SELECTED>karta
<OPTION>czek
<OPTION>bon
</OPTION>
</SELECT> &nbsp;
<font color=white >Nazwa: </font><INPUT value=VISA name="cshrepaddformplatnazwa" style="WIDTH: 69px; HEIGHT: 22px" size =6>
<font color=white >Wartość: </font><INPUT value=999.99 name="cshrepaddformplatwartosc" style="WIDTH: 76px; HEIGHT: 22px" size =7>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<tr>
<td>
<INPUT TYPE="button" VALUE="Raport" name=Btcshrep onClick="LBCSHREP1(this.form)" style="WIDTH: 155px; HEIGHT: 24px" size=14>
<font color=white >Zmiana: </font><INPUT value=nocna name="cshrepzmiana" style="WIDTH: 69px; HEIGHT: 22px" size =6>
<font color=white >Kasjer: </font><INPUT value=Sebastian name="cshrepkasjer" style="WIDTH: 69px; HEIGHT: 22px" size =6>
<font color=white >Początek: </font><INPUT value=8:00 name="cshreppoczatek" style="WIDTH: 69px; HEIGHT: 22px" size =6>
<font color=white >Koniec: </font><INPUT value=16:00 name="cshrepkoniec" style="WIDTH: 69px; HEIGHT: 22px" size =6>
<font color=white >Przychód: </font><INPUT value=4567.00 name="cshrepprzychod" style="WIDTH: 69px; HEIGHT: 22px" size =6>
<font color=white >Sprzed.got.: </font><INPUT value=2367.00 name="cshrepsprzedgot" style="WIDTH: 69px; HEIGHT: 22px" size =6>
<font color=white >Wplaty: </font><INPUT value=267.00 name="cshrepwplaty" style="WIDTH: 69px; HEIGHT: 22px" size =6>
<font color=white >Przyjecia: </font><INPUT value=47.00 name="cshrepprzyjecia" style="WIDTH: 69px; HEIGHT: 22px" size =6>
<font color=white >Wyplaty: </font><INPUT value=10.00 name="cshrepwyplaty" style="WIDTH: 69px; HEIGHT: 22px" size =6>
<font color=white >Wydania: </font><INPUT value=25.00 name="cshrepwydania" style="WIDTH: 69px; HEIGHT: 22px" size =6>
<font color=white >Stan kasy: </font><INPUT value=6010.00 name="cshrepstankasy" style="WIDTH: 69px; HEIGHT: 22px" size =6>
<font color=white >Ilosc parag.: </font><INPUT value=87.00 name="cshrepiloscparagonow" style="WIDTH: 69px; HEIGHT: 22px" size =6>
<font color=white >Ilosc anul. parag.: </font><INPUT value=3 name="cshrepiloscanulparagonow" style="WIDTH: 69px; HEIGHT: 22px" size =6>
<font color=white >Ilosc storno: </font><INPUT value=23 name="cshrepiloscstorno" style="WIDTH: 69px; HEIGHT: 22px" size =6>
<font color=white >Nr kasy: </font><INPUT value=1975 name="cshrepnrkasy" style="WIDTH: 69px; HEIGHT: 22px" size =6></td></tr>
<tr>
<td>
<P>
<INPUT TYPE="button" VALUE="OdczytFM" name=BtFMRead onClick="LBFSTRQ25(this.form)" style="WIDTH: 74px; HEIGHT: 24px" size=6>
<font color=white >Rok(YY): </font><INPUT value=06 name="LBFSTRQ25YY" style="WIDTH: 30px; HEIGHT: 22px" size =2>
<font color=white >M-ce(MM): </font><INPUT value=06 name="LBFSTRQ25MC" style="WIDTH: 28px; HEIGHT: 22px" size =2>
<font color=white >Dzień(DD): </font><INPUT value=01 name="LBFSTRQ25DD" style="WIDTH: 28px; HEIGHT: 22px" size =2>
<font color=white >Godz(GG): </font><INPUT value=10 name="LBFSTRQ25GG" style="WIDTH: 27px; HEIGHT: 22px" size =2>
<font color=white >PMinuta(MM): </font><INPUT value=00 name="LBFSTRQ25MM" style="WIDTH: 31px; HEIGHT: 22px" size =2> </P>
<P><FONT color=white>Odczytany rekord: </FONT><INPUT name="RekordPoDatach" style="WIDTH: 515px; HEIGHT: 22px" size =38>&nbsp;
</P></td></tr>
<tr>
<td>
<P>
<INPUT TYPE="button" VALUE="OdczytFM" name=BtFMReadNR onClick="LBFSTRQ26(this.form)" style="WIDTH: 74px; HEIGHT: 24px" size=6>
<font color=white >Nr: </font><INPUT value=06 name="LBFSTRQ26NR" style="WIDTH: 30px; HEIGHT: 22px" size =2>
<P><FONT color=white>Odczytany rekord: </FONT><INPUT name="RekordPoNR" style="WIDTH: 515px; HEIGHT: 22px" size =38>&nbsp;
</P></td></tr>
<tr>
<td>
<P>
<INPUT TYPE="button" VALUE="Status #50" name=BtLBFSTRQ onClick="LBFSTRQ(this.form)" style="WIDTH: 74px; HEIGHT: 24px" size=6>
<FONT color=white>Status: </FONT><INPUT name="Status50" style="WIDTH: 515px; HEIGHT: 22px" size =38>&nbsp;</P></td></tr>
</TABLE>
</FORM>
</BODY>
</HTML>

View File

@@ -0,0 +1,10 @@
<?php
// ini_set('display_errors', '1');
// error_reporting(E_ALL);
//echo '<pre>' . var_export($GLOBALS['beanList'], true); exit;
class EcmReceiptsController extends SugarController {
}

View File

@@ -0,0 +1,163 @@
<?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 id,name,number,document_no,wz_id,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,currency_value from ecmreceipts where type!='correct' and register_date like '".$year."-".$month."%' and deleted='0' order by date_entered asc");
while($r=$db->fetchByAssoc($w)){
if($r['currency_value'])$waluta="USD";
else $waluta="PLN";
$r_nip=$db->fetchByAssoc($db->query("select vatid,sic_code from accounts where id='".$r['parent_id']."'"));
if($r_nip['vatid'])$nip=str_replace("-","",$r_nip['vatid']);
elseif($r_nip['sic_code'])$nip=str_replace("-","",$r_nip['sic_code']);
else $nip=str_replace("-","",$r['to_nip']);
$r_wz=$db->fetchByAssoc($db->query("select id,number,document_no from ecmstockdocouts where id='".$r['wz_id']."'"));
$xml.='<dokument rodzaj="FVS" id="'.$r['number'].'">
<data>'.$r['register_date'].'</data>
<dataWplywu>'.$r['register_date'].'</dataWplywu>
<dataOperacji>'.$r['register_date'].'</dataOperacji>
<numer>'.$r['document_no'].'</numer>
<idMagazynu>0</idMagazynu>
<kontrahent id="'.$r['parent_id'].'" kod="'.$nip.'">
<NIP>'.str_replace("-","",$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>';
$ww=$db->query("select quantity,price,ecmvat_value,ecmvat_name,ecmvat_id from ecmreceiptitems where ecmreceipt_id='".$r['id']."' and deleted='0'");
$sum_netto=0;
$sum_brutto=0;
$sum_vat=0;
$s_netto=array();
$s_brutto=array();
$s_vat=array();
while($rr=$db->fetchByAssoc($ww)){
$sum_netto+=$rr['quantity']*$rr['price'];
$sum_brutto+=$rr['quantity']*$rr['price']*(1+$rr['ecmvat_value']/100);
$sum_vat+=round($rr['quantity']*$rr['price']*$rr['ecmvat_value']/100,2);
$s_netto[$rr['ecmvat_name']]+=$rr['quantity']*$rr['price'];
$s_brutto[$rr['ecmvat_name']]+=$rr['quantity']*$rr['price']*(1+$rr['ecmvat_value']/100);
$s_vat[$rr['ecmvat_name']]+=round($rr['quantity']*$rr['price']*$rr['ecmvat_value']/100,2);
}
/*$xml.='
<platnosc>
<kwota>'.$sum_brutto.'</kwota>
<data>'.$r['payment_date'].'</data>
<forma>0</forma>
</platnosc>
';*/
$xml.='
<sumaNetto>'.$sum_netto.'</sumaNetto>
<sumaBrutto>'.round($sum_brutto,2).'</sumaBrutto>
<sumaVAT>'.(round($sum_brutto,2)-$sum_netto).'</sumaVAT>
<rejestr>';
foreach($s_netto as $key=>$value){
$xml.='
<rozbicie stawka="'.$key.'">
<netto>'.$s_netto[$key].'</netto>
<brutto>'.round($s_brutto[$key],2).'</brutto>
<VAT>'.round((round($s_brutto[$key],2)-$s_netto[$key]),2).'</VAT>
</rozbicie>';
}
$xml.='
</rejestr>
</dokument>';
}
//corrects
$w=$db->query("select 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,ecmreceipt_id,ecmreceipt_name from ecmreceipts where type='correct' and register_date like '".$year."-".$month."%' and deleted='0' order by date_entered asc");
while($r=$db->fetchByAssoc($w)){
$r_nip=$db->fetchByAssoc($db->query("select vatid,sic_code from accounts where id='".$r['parent_id']."'"));
if($r_nip['vatid'])$nip=str_replace("-","",$r_nip['vatid']);
elseif($r_nip['sic_code'])$nip=str_replace("-","",$r_nip['sic_code']);
else $nip=str_replace("-","",$r['to_nip']);
$xml.='<dokument rodzaj="FKS" id="'.$r['id'].'" idRel="'.$r['ecmreceipt_id'].'">
<data>'.$r['register_date'].'</data>
<dataWplywu>'.$r['register_date'].'</dataWplywu>
<dataOperacji>'.$r['register_date'].'</dataOperacji>
<numer>'.$r['document_no'].'</numer>
<numerRel>'.$r['ecmreceipt_name'].'</numerRel>
<idMagazynu>0</idMagazynu>
<kontrahent id="'.$r['parent_id'].'" kod="'.$nip.'">
<NIP>'.str_replace("-","",$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>
<opis>'.$r['name'].'</opis>
<dataPlatnosci>'.$r['payment_date'].'</dataPlatnosci>
<formaPlatnosci>0</formaPlatnosci>
<waluta>PLN</waluta>';
$ww=$db->query("select quantity,price,ecmvat_value,ecmvat_name,ecmvat_id,ecmreceiptitem_id from ecmreceiptitems where ecmreceipt_id='".$r['id']."' and deleted='0'");
$sum_netto=0;
$sum_brutto=0;
$sum_vat=0;
$s_netto=array();
$s_brutto=array();
$s_vat=array();
while($rr=$db->fetchByAssoc($ww)){
$sum_netto+=round($rr['quantity']*$rr['price'],2);
$sum_brutto+=round($rr['quantity']*$rr['price']*(1+$rr['ecmvat_value']/100),2);
$sum_vat+=round($rr['quantity']*$rr['price']*$rr['ecmvat_value']/100,2);
$s_netto[$rr['ecmvat_name']]+=round($rr['quantity']*$rr['price'],2);
$s_brutto[$rr['ecmvat_name']]+=round($rr['quantity']*$rr['price']*(1+$rr['ecmvat_value']/100),2);
$s_vat[$rr['ecmvat_name']]+=round($rr['quantity']*$rr['price']*$rr['ecmvat_value']/100,2);
$rrr=$db->fetchByAssoc($db->query("select price,quantity,ecmvat_value,ecmvat_name from ecmreceiptitems where id='".$rr['ecmreceiptitem_id']."'"));
$sum_netto-=round($rrr['quantity']*$rrr['price'],2);
$sum_brutto-=round($rrr['quantity']*$rrr['price']*(1+$rrr['ecmvat_value']/100),2);
$sum_vat-=round($rrr['quantity']*$rrr['price']*$rrr['ecmvat_value']/100,2);
$s_netto[$rrr['ecmvat_name']]-=round($rrr['quantity']*$rrr['price'],2);
$s_brutto[$rrr['ecmvat_name']]-=round($rrr['quantity']*$rrr['price']*(1+$rrr['ecmvat_value']/100),2);
$s_vat[$rrr['ecmvat_name']]-=round($rrr['quantity']*$rrr['price']*$rrr['ecmvat_value']/100,2);
}
/*$xml.='
<platnosc>
<kwota>'.$sum_brutto.'</kwota>
<data>'.$r['payment_date'].'</data>
<forma>0</forma>
</platnosc>
';*/
$xml.='
<sumaNetto>'.$sum_netto.'</sumaNetto>
<sumaBrutto>'.round($sum_brutto,2).'</sumaBrutto>
<sumaVAT>'.(round($sum_brutto,2)-$sum_netto).'</sumaVAT>
<rejestr>';
foreach($s_netto as $key=>$value){
$xml.='
<rozbicie stawka="'.$key.'">
<netto>'.$s_netto[$key].'</netto>
<brutto>'.round($s_brutto[$key],2).'</brutto>
<VAT>'.(round($s_brutto[$key],2)-$s_netto[$key]).'</VAT>
</rozbicie>';
}
$xml.='
</rejestr>
</dokument>';
}
$xml.='</paczka>';
return $xml;
}
//echo createDecree(2009,12)
?>

View File

@@ -0,0 +1,467 @@
<?php
include_once("modules/EcmReceipts/EcmInvoiceOut.php");
function createInvoiceXml($id){
$r=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select * from ecmreceipts 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 from ecmsales where id='".$r_wz['so_id']."'"));
$r_so_acc=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select iln from accounts where id='".$r_wz['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=$r['order_no'];
$register_date=$r['register_date'];
$dp=$r['delivery_place'];
if($r['parent_id']==134)$codebybuyer="";
else $codebybuyer=$r['supplier_code'];
$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>'.str_replace(" ","",$r['order_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 ecmreceiptitems where deleted='0' and ecmreceipt_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 ean from ecmproduct_language_pl_view where ecmproduct_id='".$r['ecmproduct_id']."'"));
$ean=$rr['ean'];
$total_netto+=round($r['price']*$r['quantity'],2);
$total_vat+=round($r['price']*$r['quantity']*$r['ecmvat_value']/100,2);
$vats[$r['ecmvat_value']]=$r['ecmvat_value'];
$total_netto_arr[$r['ecmvat_value']]+=round($r['price']*$r['quantity'],2);
$total_vat_arr[$r['ecmvat_value']]+=round($r['price']*$r['quantity']*$r['ecmvat_value']/100,2);
$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>
<PackItemUnitOfMeasure>PCE</PackItemUnitOfMeasure>
<InvoiceUnitNetPrice>'.round($r['price'],2).'</InvoiceUnitNetPrice>
<TaxRate>'.$r['ecmvat_value'].'</TaxRate>
<TaxCategoryCode>S</TaxCategoryCode>
<TaxAmount>'.round(($r['quantity']*$r['price']*$r['ecmvat_value']/100),2).'</TaxAmount>
<NetAmount>'.round(($r['quantity']*$r['price']),2).'</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>'.EcmReceipt::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 * from ecmreceipts 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 ecmreceipts where id='".$r['ecmreceipt_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,order_no from ecmsales where id='".$r_wz['so_id']."'"));
$r_so_acc=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select iln from accounts where id='".$r_wz['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 ecmreceipts where id='".$r['ecmreceipt_id']."'"));
$cor_name=$rr['document_no'];
$cor_date=$rr['register_date'];
if($r['parent_id']==134)$codebybuyer="";
else $codebybuyer=23862;
$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>'.str_replace(" ","",$r_so['order_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 ecmreceiptitems where deleted='0' and ecmreceipt_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 ean from ecmproduct_language_pl_view where ecmproduct_id='".$r['ecmproduct_id']."'"));
$ean=$rr['ean'];
$rrr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select price,quantity,ecmvat_value from ecmreceiptitems where id='".$r['ecmreceiptitem_id']."'"));
$total_netto+=round($r['price']*$r['quantity'],2);
$total_vat+=round($r['price']*$r['quantity']*$r['ecmvat_value']/100,2);
$vats[$r['ecmvat_value']]=$r['ecmvat_value'];
$total_netto_arr[$r['ecmvat_value']]+=round($r['price']*$r['quantity'],2);
$total_vat_arr[$r['ecmvat_value']]+=round($r['price']*$r['quantity']*$r['ecmvat_value'],2);
$total_netto_c+=round($rrr['price']*$rrr['quantity'],2);
$total_vat_c+=round($rrr['price']*$rrr['quantity']*$rrr['ecmvat_value']/100,2);
$vats_c[$rrr['ecmvat_value']]=$rrr['ecmvat_value'];
$total_netto_arr_c[$rrr['ecmvat_value']]+=round($rrr['price']*$rrr['quantity'],2);
$total_vat_arr_c[$rrr['ecmvat_value']]+=round($rrr['price']*$rrr['quantity']*$rrr['ecmvat_value'],2);
if($rrr['price']==$r['price'] && $rrr['quantity']==$r['quantity'])continue;
$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['price'],2).'</InvoiceUnitNetPrice>
<TaxRate>'.$r['ecmvat_value'].'</TaxRate>
<TaxCategoryCode>S</TaxCategoryCode>
<TaxReference>
<ReferenceType></ReferenceType>
<ReferenceNumber></ReferenceNumber>
</TaxReference>
<TaxAmount>'.round(($r['quantity']*$r['price']*$r['ecmvat_value']/100),2).'</TaxAmount>
<NetAmount>'.round(($r['quantity']*$r['price']),2).'</NetAmount>
<PreviousInvoiceQuantity>'.$rrr['quantity'].'</PreviousInvoiceQuantity>
<PreviousInvoiceUnitNetPrice>'.$rrr['price'].'</PreviousInvoiceUnitNetPrice>
<PreviousTaxRate>'.$rrr['ecmvat_value'].'</PreviousTaxRate>
<PreviousTaxCategoryCode>S</PreviousTaxCategoryCode>
<PreviousTaxAmount>'.round(($rrr['price']*$rrr['quantity']*$rrr['ecmvat_value']/100),2).'</PreviousTaxAmount>
<PreviousNetAmount>'.round(($rrr['price']*$rrr['quantity']),2).'</PreviousNetAmount>
<CorrectionInvoiceQuantity>'.($r['quantity']-$rrr['quantity']).'</CorrectionInvoiceQuantity>
<CorrectionInvoiceUnitNetPrice>'.($r['price']-$rrr['price']).'</CorrectionInvoiceUnitNetPrice>
<CorrectionTaxAmount>'.(round(($r['price']*$r['quantity']*$r['ecmvat_value']/100),2)-round(($rrr['price']*$rrr['quantity']*$rrr['ecmvat_value']/100),2)).'</CorrectionTaxAmount>
<CorrectionNetAmount>'.(round(($r['price']*$r['quantity']),2)-round(($rrr['price']*$rrr['quantity']),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","",EcmReceipt::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,6 @@
<?php
if (!$_REQUEST['record']) return;
//create receipt info
$db = $GLOBALS['db'];
$r = $db->fetchByAssoc($db->query("UPDATE ecmreceipts SET printed='1' WHERE id='".$_REQUEST['record']."'"));

View File

@@ -0,0 +1,11 @@
<?
$exp=explode("-",$_GET['date']);
include_once("modules/EcmReceipts/createDecree.php");
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/EcmReceipts/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 ecmreceipts 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,237 @@
<?php
require_once("./../../import/helper.php");
/* Prep. */
$sql = mysql_connect('localhost', 'root', '1ptimu6');
mysql_select_db('crm');
mysql_query('SET NAMES utf8;');
function buildStatement(array $array) {
$filteredArray = array_filter($array, 'strlen');
$statementParts = array(
'keys' => array(
//
),
'values' => array(
//
),
);
foreach($filteredArray as $key => $value) {
$statementKey = '`' . $key . '`';
$statementValue = '\'' . $value . '\'';
array_push($statementParts['keys'], $statementKey);
array_push($statementParts['values'], $statementValue);
}
return '(' . implode(', ', $statementParts['keys']) . ') values (' . implode(', ', $statementParts['values']) . ')';
}
/* Db structure. */
$data = array(
'ecmreceipts' => array(
'id' => null,
'name' => null,
'description' => null,
'date_entered' => null,
'date_modified' => null,
'modified_user_id' => null,
'assigned_user_id' => null,
'created_by' => null,
'deleted' => null,
'number' => null,
'parent_type' => null,
'parent_name' => null,
'parent_id' => null,
'type' => null,
'ecmreceipt_id' => null,
'ecmreceipt_name' => null,
'status' => null,
'register_date' => null,
'sell_date' => null,
'payment_date' => null,
'parent_address_street' => null,
'parent_address_city' => null,
'parent_address_postalcode' => null,
'parent_address_country' => null,
'to_nip' => null,
'subtotal' => null,
'total' => null,
'discount' => null,
'to_vatid' => null,
'to_is_vat_free' => null,
'header_text' => null,
'footer_text' => null,
'ads_text' => null,
'template_id' => null,
'template_name' => null,
'accepted' => null,
'email_id' => null,
'ecmlanguage' => null,
'ecmpaymentcondition_id' => null,
'ecmpaymentcondition_text' => null,
'wz_id' => null,
'document_no' => null,
'parent_contact_name' => null,
'parent_contact_title' => null,
'contact_id' => null,
'correct_id' => null,
'currency_id' => null,
'order_no' => null,
'supplier_code' => null,
'delivery_place' => null,
'order_qty' => null,
'currency_value' => null,
'paid' => null,
'wz_name' => null,
'correct_reason' => null,
'so_id' => null,
'netto_weight' => null,
'brutto_weight' => null,
'stock_id' => null,
'pdf_type' => null,
'parent_shipping_address_name' => null,
'parent_shipping_address_street' => null,
'parent_shipping_address_city' => null,
'parent_shipping_address_postalcode' => null,
'parent_shipping_address_country' => null,
'prepaid' => null,
'prepaid_nr' => null,
'paid_val' => null,
'payment_date_d' => null,
'payment_method' => null,
'payment_method_paid' => null,
'vats_summary' => null,
'inside_inv_number' => null,
'printed' => null,
),
'ecmreceiptitems' => array(
'id' => null,
'date_entered' => null,
'date_modified' => null,
'modified_user_id' => null,
'assigned_user_id' => null,
'created_by' => null,
'deleted' => null,
'ecmreceipt_id' => null,
'ecmproduct_id' => null,
'position' => null,
'code' => null,
'name' => null,
'quantity' => null,
'subprice' => null,
'price' => null,
'startprice' => null,
'discount' => null,
'subtotal' => null,
'total' => null,
'dd_unit_id' => null,
'dd_unit_name' => null,
'ecmvat_id' => null,
'ecmvat_name' => null,
'ecmvat_value' => null,
'ecmproductcategory_id' => null,
'currency_id' => null,
'currency_name' => null,
'tax_code' => null,
'purchase_price' => null,
'recipient_code' => null,
'ecmreceiptitem_id' => null,
'netto_weight' => null,
'brutto_weight' => null,
'sub_price' => null,
'ecmstockdocout_id' => null,
'product_type' => null,
'parent_doc_id' => null,
'parent_doc_type' => null,
'parent_doc_item_id' => null,
'old_subprice' => null,
'old_price' => null,
'old_quantity' => null,
'old_ecmvat_id' => null,
'old_ecmvat_name' => null,
'old_ecmvat_value' => null,
'old_discount' => null,
),
);
$duplicatedData = array(
'ecmreceipts' => array(
'parent_type' => 'Accounts',
'parent_name' => '"KARDAN" SP. Z O.O.',
'parent_id' => 3674695,
'type' => 0,
'status' => 'accepted',
'parent_address_street' => 'UL.ZIELONOGÓRSKA 36',
'parent_address_city' => 'SZCZECIN',
'parent_address_postalcode' => '71-084',
'subtotal' => 100,
'total' => 123,
'discount' => 0,
'template_id' => 'ef0c4dea-ddf3-de51-9d08-512257d4b675',
'template_name' => 'BSL Truck',
'ecmlanguage' => 'pl_pl',
'stock_id' => '2962f1ad-79f4-a1ad-385e-4f286ad7acb5',
'pdf_type' => 'K',
),
'ecmreceiptitems' => array(
'ecmproduct_id' => '75c7104b-816f-996a-9739-501aa06921d5',
'position' => 0,
'code' => '9ES120743001',
'name' => 'SC31 SZKŁO LAMPY GŁÓWNEJ',
'quantity' => 2,
'subprice' => 40.65,
'price' => 50,
'startprice' => 40.65,
'discount' => 0,
'subtotal' => 81.3,
'total' => 100,
'dd_unit_id' => 'SZT',
'ecmvat_id' => '9ec174d1-db5e-8db6-9195-4e6e4a041e40',
'ecmvat_name' => '23%',
'ecmvat_value' => 23,
'currency_id' => 'undefined',
'currency_name' => 'Polski Złoty',
'purchase_price' => 0,
'netto_weight' => 0.00,
'brutto_weight' => 0.00,
),
);
/* Main functionality. */
$startTime = microtime(true);
for($i = 0, $iCounter = 100000; $i < $iCounter; $i++) {
$date = date('Y-m-d');
$receiptId = create_guid();
$duplicatedData['ecmreceiptitems']['id'] = create_guid();
$duplicatedData['ecmreceipts']['document_no'] = ($i+1).'/2013';
$duplicatedData['ecmreceipts']['id'] = $duplicatedData['ecmreceiptitems']['ecmreceipt_id'] = $receiptId;
$duplicatedData['ecmreceipts']['date_entered'] = $duplicatedData['ecmreceiptitems']['date_entered'] = $date;
$duplicatedData['ecmreceipts']['date_modified'] = $duplicatedData['ecmreceiptitems']['date_modified'] = $date;
// dump(buildStatement($duplicatedData['ecmreceipts']));
// dump(buildStatement($duplicatedData['ecmreceiptitems']));
// exit;
$query1 = 'insert into `ecmreceipts` ' . buildStatement($duplicatedData['ecmreceipts']) . ';';
$query2 = 'insert into `ecmreceiptitems` ' . buildStatement($duplicatedData['ecmreceiptitems']) . ';';
// dump($query1);
// dump($query2);
// exit;
$res1 = mysql_query($query1);
$res2 = mysql_query($query2);
// dump($res1, $res2);
// exit;
}
$stopTime = microtime(true);

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['EcmReceipt'] = 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',
'ecmreceipt_id',
'ecmreceipt_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',
'ecmreceipt_id',
'ecmreceipt_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,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,34 @@
<?php
require_once('modules/EcmReceipts/EcmReceipt.php');
$focus = new EcmReceipt();
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("ecmreceipts", "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,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,4 @@
<?php
$days = $_REQUEST['days'];
echo date("d.m.Y",mktime(0,0,0,$_REQUEST['month'],$_REQUEST['day'],$_REQUEST['year'])+3600*24*$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 @@
Select month to decree <input type="date" value="<? echo date("Y-m");?>" name="date_decree" id="date_decree" /><input class="button" type="button" value="Create Decree" onclick="window.open('index.php?module=EcmReceipts&action=downloadDecree&date='+document.getElementById('date_decree').value,'_blank');" target="_blank" />

View File

@@ -0,0 +1,284 @@
<?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_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' => "Sale or shipping realization date",
// 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 termin',
'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_ECMRECEIPT_ID' => 'Correct Id',
'LBL_ECMRECEIPT_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_ECMRECEIPT' => 'Create Invoice',
'LNK_ECMRECEIPTS_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_ECMRECEIPTS' => '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_ECMRECEIPTS_PDFLANGUAGES' => 'PDF Languages',
'LBL_ECMLANGUAGE' => 'Language',
'LBL_ECMRECEIPTS_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,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_ECMINVOICEOUT_ID' => 'Correct Id',
'LBL_ECMINVOICEOUT_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_ECMINVOICEOUT' => 'Create Invoice',
'LNK_ECMINVOICEOUTS_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_ECMINVOICEOUTS' => '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_ECMINVOICEOUTS_PDFLANGUAGES' => 'PDF Languages',
'LBL_ECMLANGUAGE' => 'Language',
'LBL_ECMINVOICEOUTS_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,325 @@
<?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_SITE' => 'Strona',
'LBL_PDF_FOOTER_DOCUMENT_NAME' => 'Paragon',
//
'LBL_PDF_PAYMENT_METHOD_PATTERN' => 'w terminie <b>%s</b> dni do <b>%s</b> <b>%s</b>',
'LBL_PDF_INVOICE' => 'Paragon',
//
'LBL_TO_PAYMENTS' => 'Płatności',
'LBL_PDF_INVOICE' => 'Paragon',
'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' => 'Stawka (%)',
'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 dokonania, lub zakonczenia dostawy towarów, lub wykonania usługi",
// 080313 mh
'SERVICE_INVOICE_NAME' => 'Paragon 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' => 'Paragony',
'LBL_MODULE_TITLE' => 'Paragony: Strona Glówna',
'LBL_MODULE_ID' => 'EcmReceipts',
'LBL_SEARCH_FORM_TITLE' => 'Wyszukiwanie',
'LBL_LIST_FORM_TITLE' => 'Lista paragonów',
'LBL_NEW_FORM_TITLE' => 'Nowa paragon',
'LBL_DETAILS' => 'Szczególy paragonów',
'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_ECMRECEIPT_ID' => 'Id paragonu',
'LBL_ECMRECEIPT_NAME' => 'Paragon 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' => 'Ilość',
//
'LBL_EDITTABLE_TOTAL' => 'Wartość',
'LBL_EDITTABLE_PRICE' => 'Cena sprzedaży netto',
'LBL_EDITTABLE_PRICE_SUB' => 'Cena początkowa netto',
//
'LBL_EDITTABLE_TOTAL_EXT' => 'Wartość netto' . '<br/>' . 'Wartość brutto',
'LBL_EDITTABLE_PRICE_EXT' => 'Cena sprzedaży netto' . '<br/>' . 'Cena sprzedaży brutto',
'LBL_EDITTABLE_PRICE_SUB_EXT' => 'Cena początkowa netto' . '<br/>' . 'Cena początkowa brutto',
//
'LBL_EDITTABLE_VAT' => 'VAT',
'LBL_EDITTABLE_DISCOUNT' => 'Upust',
'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_ECMRECEIPT' => 'Utwórz paragon',
'LNK_EcmReceipts_LIST' => 'Lista paragonów',
'LBL_IMG_SEARCH' => 'Wyszukiwanie',
'LBL_IMG_NEW' => 'Nowy, dodaj do bazy',
'LBL_IMG_EDIT' => 'Edycja',
'LBL_CONFIRM_QUESTION' => 'Chcesz potwierdzic te paragon?',
'LBL_QUOTE_PDF' => 'Pokaz PDF',
'LBL_QUOTE_PDF_BUTTON_KEY' => 'Pokaz PDF [Alt+P]',
'LBL_QUOTE_PDF_BUTTON_TITLE' => 'Pokaz paragon w pliku PDF.',
'LBL_QUOTE_TO_INVOICE' => 'Stwórz paragon',
'LBL_QUOTE_TO_INVOICE_BUTTON_KEY' => 'Stwórz paragon [Alt+I]',
'LBL_QUOTE_TO_INVOICE_BUTTON_TITLE' => 'Stwórz paragon.',
'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 paragon.',
'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 paragonów [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' => 'Paragon nie został zapisany. Sprawdz czy wszytskie pola sa poprawne!',
'LBL_SAVED' => 'Paragon został zapisany 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' => 'Paragon 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_ECMRECEIPTS' => 'paragonów',
'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' => 'Paragon VAT',
'LBL_PDF_FILENAME' => 'FV_',
'LBL_PDF_CODE' => 'FV',
'LNK_ECMRECEIPTS_PDFLANGUAGES' => 'Ustawienia PDF',
'LBL_ECMRECEIPTS_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 paragonów ustawiony.",
'LBL_STATUS_s20_SET_MESSAGE' => "Paragon czeka na potwierdzenie.",
'LBL_STATUS_s30_SET_MESSAGE' => "Paragon jest potwierdzony.",
'LBL_STATUS_s40_SET_MESSAGE' => "Status paragonów 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 paragonów',
'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_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',
);

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['EcmReceipts'] = 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,451 @@
<?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".
* ****************************************************************************** */
$viewdefs['EcmReceipts']['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=\'EcmReceipts\'; 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' => '
<input title="Ufiskalnij" class="button" onclick="register_print();" type="button" name="register" id="register" value="Ufiskalnij paragon"><br><div id="print_link"></div>
',
),
// 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' => '{$CATALOGUE}'
),
// 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=EcmReceipts&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_receipts == 1}
// <input title="{$MOD.LBL_REPAIR_BUTTON_TITLE}" accessKey="{$MOD.LBL_REPAIR_BUTTON_KEY}" class="button" onclick="window.location = \'index.php?module=EcmReceipts&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=EcmReceipts&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=EcmReceipts&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=EcmReceipts&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/EcmReceipts/MyTable.js',
),
array(
'file' => 'include/ECM/EcmPreviewPDF/EcmPreviewPDF.js',
),
array(
'file' => 'modules/EcmReceipts/EcmReceiptsDetailView.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',
'',//'ecmreceipt_name',
),
array(
'payment_date',
'template_name',
),
array(
'name',
),
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_paid',
'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' =>
'
<link rel="stylesheet" type="text/css" href="modules/EcmReceipts/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}</td>
<td width="6%">{$MOD.LBL_EDITTABLE_VAT}</td>
<td width="10%">{$MOD.LBL_EDITTABLE_TOTAL}</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="">Paragon</option>
<option value="inv">Faktura</option>
<option value="exp">Lista rozchodowa</option>
</select>
<input type="button" class="button" onClick="setPREVIEW();" 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,480 @@
<?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".
* ****************************************************************************** */
$viewdefs['EcmReceipts']['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=EcmReceipts&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">
',
),
),
'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/EcmReceipts/AjaxSearch/AjaxSearch.js',
),
array(
'file' => 'modules/EcmReceipts/formloader.js',
),
array(
'file' => 'modules/EcmReceipts/MyTable.js',
),
array(
'file' => 'modules/EcmReceipts/EcmReceipts.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,
),
),
//'ecmreceipt_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(
// 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\');" >%
// ',
// )
),
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_paid',
'label' => 'LBL_TO_PAID',
'customCode' =>
'
<div id="to_paid"></div>
',
),
'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' =>
'
<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}" 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(
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/EcmReceipts/MyTable.css" />
<link rel="stylesheet" type="text/css" href="modules/EcmReceipts/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="3%">{$MOD.LBL_EDITTABLE_NO}</td>
<td width="8%">{$MOD.LBL_EDITTABLE_CODE}</td>
<td width="32%">{$MOD.LBL_EDITTABLE_NAME}</td>
<td width="5%">{$MOD.LBL_EDITTABLE_QUANTITY}</td>
<td width="15%">{$MOD.LBL_EDITTABLE_PRICE_SUB_EXT}</td>
<td width="5%">{$MOD.LBL_EDITTABLE_DISCOUNT}</td>
<td width="3%">{$MOD.LBL_EDITTABLE_VAT}</td>
<td width="14%">{$MOD.LBL_EDITTABLE_PRICE_EXT}</td>
<td width="4%">{$MOD.LBL_EDITTABLE_UNIT}</td>
<td width="10%">{$MOD.LBL_EDITTABLE_TOTAL_EXT}</td>
<td width="5%">{$MOD.LBL_EDITTABLE_STOCK}</td>
<td width="5%">{$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>
<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["EcmReceipts"] = array(
'NUMBER' =>
array (
'width' => '1%',
'label' => 'n',
'default' => true,
'sortable' => true,
),
'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,
),
'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,
),
'SUBTOTAL' => array(
'width' => '10',
'label' => 'Suma netto',
'default' => false,
),
'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=EcmReceipts&action=EditView&out_id={$ID}&out_module=EcmReceipts&return_module=EcmReceipts&return_action=index">
// <img border="0" src="modules/EcmReceipts/images/convert.gif" title="' . translate('LBL_LIST_TO_INVOICE', 'EcmReceipts') . '" />
// </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=EcmReceipts&offset=1&return_module=EcmReceipts&action=EditView&return_action=index&record={$ID}&isCorrect=true">
// <img border="0" src="modules/EcmReceipts/images/correct.jpg" title="Correct" />
// </a>
// ',
// 'sortable' => false,
// ),
// 'DUPLICATE' => array(
// 'width' => '2',
// 'label' => '&nbsp;',
// 'default' => true,
// 'customCode' =>
// '
// <a href="index.php?module=EcmReceipts&action=EditView&record={$ID}&isDuplicate=true">
// <img border="0" src="modules/EcmReceipts/images/duplicate.jpg" title="Duplicate" />
// </a>
// ',
// 'sortable' => false,
// ),
// 'OPTIONS' => array(
// 'label' => '&nbsp;',
// 'default' => true,
// 'sortable' => false,
// ),
);

View File

@@ -0,0 +1,137 @@
<?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['EcmReceipts'] = 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',
),
'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']['EcmReceipts'] = array(
'LBL_DETAILVIEW'=>array(
'template' => 'xtpl',
'template_file' => 'modules/EcmReceipts/DetailView.html',
'php_file' => 'modules/EcmReceipts/DetailView.php',
'type' => 'DetailView',
),
'LBL_EDITVIEW'=>array(
'template' => 'xtpl',
'template_file' => 'modules/EcmReceipts/EditView.html',
'php_file' => 'modules/EcmReceipts/EditView.php',
'type' => 'EditView',
),
'LBL_LISTVIEW'=>array(
'template' => 'listview',
'meta_file' => 'modules/EcmReceipts/listviewdefs.php',
'type' => 'ListView',
),
'LBL_SEARCHFORM'=>array(
'template' => 'xtpl',
'template_file' => 'modules/EcmReceipts/SearchForm.html',
'php_file' => 'modules/EcmReceipts/ListView.php',
'type' => 'SearchForm',
),
);

View File

@@ -0,0 +1,86 @@
<?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['EcmReceipts']['subpanel_setup'] = array (
);
?>

View File

@@ -0,0 +1,110 @@
<?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' => 'EcmReceipts'),
),*/
'where' => '',
'list_fields' => array (
'status' => array(
'vname' => '&nbsp;',
'width' => '1%',
'default' => true,
),
/*
'number' => array (
'name' => 'number',
'vname' => 'LBL_NUMBER',
'module' => 'EcmReceipts',
'usage' => 'query_only',
),
*/
'document_no' => array (
'name' => 'document_no',
'vname' => 'LBL_DOCUMENT_NO',
'module' => 'EcmReceipts',
'widget_class' => 'SubPanelDetailViewLink',
'width' => '15%',
),
'name' => array (
'name' => 'name',
'vname' => 'LBL_NAME',
'module' => 'EcmReceipts',
'width' => '40%'
),
'total' => array (
'name' => 'total',
'vname' => 'LBL_TOTAL',
'module' => 'EcmReceipts',
'width' => '15%',
),
'register_date' => array (
'name' => 'register_date',
'vname' => 'LBL_REGISTER_DATE',
'module' => 'EcmReceipts',
'width' => '10%',
),
'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,85 @@
<?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/EcmReceipts/EcmReceipt.php");
$focus = new EcmReceipt();
$method = (isset($_REQUEST['method']) && $_REQUEST['method'] != '') ? $_REQUEST['method'] : 'D';
$focus->getPDF($_REQUEST['record'], $method, null, @$_REQUEST['type']);
} else
if ($_REQUEST['cache'] == "fromJava" && $_GET['from'] != "EcmReceipts") {
$_SESSION['PDF_ECMReceiptS'] = $_POST;
} else
if ($_GET['from'] == "EcmReceipts") {
require_once("modules/EcmReceipts/EcmReceipt.php");
$focus = new EcmReceipt();
if (isset($_SESSION['PDF_ECMReceiptS']['record']) && $_SESSION['PDF_ECMReceiptS']['record'] != '') {
$focus->retrieve($_SESSION['PDF_ECMReceiptS']['record']);
}
if (!$focus->ACLAccess('Save')) {
ACLController::displayNoAccess(true);
sugar_cleanup(true);
}
foreach ($focus->column_fields as $field) {
if (isset($_SESSION['PDF_ECMReceiptS'][$field])) {
$value = $_SESSION['PDF_ECMReceiptS'][$field];
$focus->$field = $value;
}
}
foreach ($focus->additional_column_fields as $field) {
if (isset($_SESSION['PDF_ECMReceiptS'][$field])) {
$value = $_SESSION['PDF_ECMReceiptS'][$field];
$focus->$field = $value;
}
}
if (isset($_SESSION['PDF_ECMReceiptS']['to_is_vat_free']) && $_SESSION['PDF_ECMReceiptS']['to_is_vat_free'])
$focus->to_is_vat_free = 1;
else
$focus->to_is_vat_free = 0;
$json = getJSONobj();
$pl = $_SESSION['PDF_ECMReceiptS']['position_list'];
$focus->position_list = $pl;
$focus->document_no = $_SESSION['PDF_ECMReceiptS']['document_no'];
$focus->wz_id = $_SESSION['PDF_ECMReceiptS']['out_id'];
$focus->ecmpaymentcondition_text = EcmReceipt::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/EcmReceipts/EcmInvoiceOut.php");
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select document_no,id from ecmreceipts where id='".$_SESSION['cids'][$_REQUEST['no']]."'"));
$in=new EcmReceipt();
$in->retrieve($r['id']);
$ff="modules/EcmReceipts/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/EcmReceipts/files/archive'.date("YmdHis").'.zip';
$archive = new PclZip($f);
foreach($_SESSION['cids_files'] as $a)$archive->add($a,PCLZIP_OPT_REMOVE_PATH,"modules/EcmReceipts/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/EcmReceipts/files/archive'.date("YmdHis").'.pdf', 'D' );*/
}
else {
header("Location: index.php?module=EcmReceipts&action=printAll&to_pdf=1&no=".($_REQUEST['no']+1));
}
?>

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/EcmReceipts/EcmInvoiceOut.php');
$focus = new EcmReceipt();
$focus->retrieve($_REQUEST['record']);
$focus->format_all_fields();
}
require_once('include/SubPanel/SubPanelTiles.php');
$subpanel = new SubPanelTiles($focus, "EcmReceipts");
echo $subpanel->display();
}
?>

16
modules/EcmReceipts2/test.php Executable file
View File

@@ -0,0 +1,16 @@
<?php
require_once('modules/EcmTexts/EcmText.php');
$r = EcmText::LoadText(null,'BeAn_Id','tekst','language_pack_name',true);
var_dump($r);
//$t = new EcmText();
/*
$t->name = 'Testowy';
$t->data = 'array("jeden" => "JEDEN", "dwa" => "DWA")';
$t->save();
*/
//$t->retrieve('9b32ddf7-7694-b71d-0dee-489c06986391');
//var_dump($t->data);
?>

View File

@@ -0,0 +1,82 @@
<?php
require_once("modules/EcmReceipts/EcmInvoiceOut.php");
class EcmReceiptToTransfer extends EcmInvoiceOut {
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`='EcmReceipts' 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`='EcmReceipts'";
$r = $this->db->query($query);
if($r) return true;
}
return false;
}
*/
}
$query = "SELECT `id`, `deleted` FROM `ecmreceipts` 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 EcmReceiptToTransfer();
$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 ecmreceipts 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 ecmreceipts 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 ecmreceipts where id='8aa03944-fc72-26ec-8eb4-4b718085454e'");
while($r=$GLOBALS[db]->fetchByAssoc($w)){
$ww=$GLOBALS[db]->query("select * from ecmreceiptitems where ecmreceipt_id='".$r['id']."'");
while($rr=$GLOBALS[db]->fetchByAssoc($ww)){
$rrr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select id from ecmreceiptitems where ecmreceipt_id='".$r['ecmreceipt_id']."' and ecmproduct_id='".$rr['ecmproduct_id']."'"));
echo "update ecmreceiptitems set ecmreceiptitem_id='".$rrr['id']."' where id='".$rr['id']."';<br>";
}
}
?>

View File

@@ -0,0 +1,7 @@
<?php
$w=$GLOBALS[db]->query("select id,parent_id from ecmreceipts 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 ecmreceipts 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,ecmreceipt_id from ecmreceipts 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 ecmreceiptitems where ecmreceipt_id='".$r['id']."'");
while($rr=$GLOBALS[db]->fetchByAssoc($ww)){
if($r['type']!="normal"){
$rcor=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select wz_id from ecmreceipts where id='".$r['ecmreceipt_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 ecmreceiptitems set purchase_price='".$purchase_price."' where ecmreceipt_id='".$r['id']."' and ecmproduct_id='".$rr['ecmproduct_id']."';");
//echo $purchase_price."<br>";
}
}
?>

925
modules/EcmReceipts2/vardefs.php Executable file
View File

@@ -0,0 +1,925 @@
<?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.
* ****************************************************************************** */
$dictionary['EcmReceipt'] = array(
'table' => 'ecmreceipts',
'comment' => 'EcmReceipts',
'duplicate_merge' => true,
'unified_search' => true,
//FIELDS SECTION
'fields' => array(
'inside_inv_number' => array (
'name' => 'inside_inv_number',
//'vname' => 'INSIDE_INV_NUMBER',
'type' => 'varchar',
'len' => 30,
),
//STANDARD FIELDS SECTION
'id' => array(
'name' => 'id',
'vname' => 'LBL_ID',
'type' => 'id',
'required' => true,
'reportable' => false,
'comment' => 'Unique identifier',
),
'name' => array(
'name' => 'name',
'vname' => 'LBL_NAME',
'type' => 'name',
'required' => false,
'dbType' => 'varchar',
'len' => 255,
'unified_search' => true,
'comment' => 'The short description of the record contents',
'massupdate' => true,
'merge_filter' => 'selected',
),
'description' => array(
'type' => 'text',
'name' => 'description',
'vname' => 'LBL_DESCRIPTION',
'comment' => 'Description',
'unified_search' => true,
// 'required' => true,
),
'date_entered' => array(
'name' => 'date_entered',
'vname' => 'LBL_DATE_ENTERED',
'type' => 'datetime',
'required' => true,
'comment' => 'Date record created',
),
'date_modified' => array(
'name' => 'date_modified',
'vname' => 'LBL_DATE_MODIFIED',
'type' => 'datetime',
'required' => true,
'comment' => 'Date record last modified',
),
'modified_user_id' => array(
'name' => 'modified_user_id',
'rname' => 'user_name',
'id_name' => 'modified_user_id',
'vname' => 'LBL_MODIFIED',
'type' => 'assigned_user_name',
'table' => 'modified_user_id_users',
'isnull' => 'false',
'dbType' => 'varchar',
'len' => 36,
'required' => true,
'reportable' => true,
'comment' => 'User who last modified record'
),
'assigned_user_id' => array(
'name' => 'assigned_user_id',
'rname' => 'user_name',
'id_name' => 'assigned_user_id',
'vname' => 'LBL_ASSIGNED_TO_ID',
'group' => 'assigned_user_name',
'type' => 'relate',
'table' => 'users',
'reportable' => true,
'Importable' => false,
'isnull' => 'false',
'dbType' => 'id',
'audited' => true,
'comment' => 'User ID assigned to record',
'duplicate_merge' => 'disabled',
'massupdate' => false,
),
'assigned_user_name' => array(
'name' => 'assigned_user_name',
'vname' => 'LBL_ASSIGNED_TO',
'type' => 'relate',
'reportable' => false,
'source' => 'non-db',
'table' => 'users',
'id_name' => 'assigned_user_id',
'module' => 'Users',
'duplicate_merge' => 'disabled',
'massupdate' => false,
),
'created_by' => array(
'name' => 'created_by',
'rname' => 'user_name',
'id_name' => 'created_by',
'vname' => 'LBL_CREATED',
'type' => 'assigned_user_name',
'table' => 'created_by_users',
'isnull' => 'false',
'dbType' => 'varchar',
'len' => 36,
'comment' => 'User that created the record'
),
'created_by_link' => array(
'name' => 'created_by_link',
'type' => 'link',
'relationship' => 'ecmreceipts' . '_created_by',
'vname' => 'LBL_CREATED_BY_USER',
'link_type' => 'one',
'module' => 'Users',
'bean_name' => 'User',
'source' => 'non-db',
),
'modified_user_link' => array(
'name' => 'modified_user_link',
'type' => 'link',
'relationship' => 'ecmreceipts' . '_modified_user',
'vname' => 'LBL_MODIFIED_BY_USER',
'link_type' => 'one',
'module' => 'Users',
'bean_name' => 'User',
'source' => 'non-db',
),
'assigned_user_link' => array(
'name' => 'assigned_user_link',
'type' => 'link',
'relationship' => 'ecmreceipts' . '_assigned_user',
'vname' => 'LBL_ASSIGNED_TO_USER',
'link_type' => 'one',
'module' => 'Users',
'bean_name' => 'User',
'source' => 'non-db',
'duplicate_merge' => 'enabled',
'rname' => 'user_name',
'id_name' => 'assigned_user_id',
'table' => 'users',
),
'deleted' => array(
'name' => 'deleted',
'vname' => 'LBL_DELETED_BY',
'type' => 'bool',
'required' => true,
'reportable' => false,
'comment' => 'Record deletion indicator'
),
//NEW FIELDS SECTION
'stock_id' => array(
'name' => 'stock_id',
'rname' => 'name',
'id_name' => 'stock_id',
'vname' => 'LBL_STOCK_ID',
'group' => 'stock_name',
'type' => 'relate',
'table' => 'ecmstocks',
'reportable' => true,
'Importable' => false,
'isnull' => 'false',
'dbType' => 'id',
'audited' => true,
'duplicate_merge' => 'disabled',
'massupdate' => false,
'required' => false,
),
'stock_name' => array(
'name' => 'stock_name',
'vname' => 'LBL_STOCK_NAME',
'type' => 'relate',
'reportable' => false,
'source' => 'non-db',
'table' => 'ecmstocks',
'id_name' => 'stock_id',
'module' => 'EcmStocks',
'duplicate_merge' => 'disabled',
'massupdate' => false,
'required' => false,
),
'number' => array(
'name' => 'number',
'vname' => 'LBL_NUMBER',
'type' => 'varchar',
'required_option' => true,
'unified_search' => true,
'required' => true,
'len' => '20',
),
'document_no' => array(
'name' => 'document_no',
'vname' => 'LBL_DOCUMENT_NO',
'type' => 'varchar',
'required_option' => true,
'unified_search' => true,
'required' => true,
'len' => '30',
),
//
'parent_type' => array(
'name' => 'parent_type',
'vname' => 'LBL_PARENT',
'type' => 'varchar',
// 'group' => 'parent_name',
'required' => false,
'reportable' => false,
'len' => '25',
'comment' => 'The Sugar object to which the call is related',
'massupdate' => false,
),
'parent_name' => array(
'name' => 'parent_name',
'parent_type' => 'ecmquotes_parent_dom',
// 'type_name' => 'parent_type',
'id_name' => 'parent_id',
'vname' => 'LBL_PARENT_NAME',
'type' => 'relate',
'group' => 'parent_name',
'dbtype' => 'varchar',
'len' => '255',
// 'source'=>'non-db',
'module' => 'Accounts',
'massupdate' => false,
// 'options' => 'ecmquotes_parent_dom',
'required' => false,
),
'parent_id' => array(
'name' => 'parent_id',
'type' => 'id',
'module' => 'Accounts',
'vname' => 'LBL_PARENT_ID',
'group' => 'parent_name',
'massupdate' => false,
'reportable' => false,
'required' => false,
),
//
'type' => array(
'name' => 'type',
'vname' => 'LBL_TYPE',
'required' => true,
'type' => 'enum',
'options' => 'ecmreceipts_type_dom',
'massupdate' => false,
),
'pdf_type' => array(
'name' => 'pdf_type',
'type' => 'enum',
'options' => 'account_invoice_type_dom',
'label' => 'LBL_PDF_TYPE',
),
'ecmreceipt_id' => array(
'name' => 'ecmreceipt_id',
'type' => 'id',
'vname' => 'LBL_ECMINVOICEOUT_ID',
'group' => 'ecmreceipt_name',
'reportable' => false,
),
'ecmreceipt_name' => array(
'name' => 'ecmreceipt_name',
'rname' => 'document_no',
//'db_concat_fields'=> array(0=>'name'),
//'source' => 'non-db',
'dbType' => 'varchar',
'len' => '255',
'group' => 'ecmreceipt_name',
'vname' => 'LBL_ECMINVOICEOUT_NAME',
'reportable' => false,
'id_name' => 'ecmreceipt_id',
'join_name' => 'ecmreceipts',
'type' => 'relate',
'module' => 'EcmReceipts',
'link' => 'ecmreceipts',
),
'status' => array(
'name' => 'status',
'vname' => 'LBL_STATUS',
'type' => 'enum',
'size' => '3',
'options' => 'ecmreceipts_status_dom',
'massupdate' => false,
),
'register_date' => array(
'name' => 'register_date',
'vname' => 'LBL_REGISTER_DATE',
'type' => 'date',
'reportable' => false,
'showFormats' => true,
'massupdate' => false,
'required' => true,
),
'sell_date' => array(
'name' => 'sell_date',
'vname' => 'LBL_SELL_DATE',
'type' => 'date',
'reportable' => false,
'showFormats' => true,
'massupdate' => false,
'required' => true,
),
'payment_date' => array(
'name' => 'payment_date',
'vname' => 'LBL_PAYMENT_DATE',
'type' => 'date',
'reportable' => false,
'showFormats' => true,
'massupdate' => false,
'required' => false,
),
//
'parent_name_copy' => array(
'name' => 'parent_name_copy',
'vname' => 'LBL_PARENT_NAME_COPY',
'type' => 'varchar',
'source' => 'non-db',
),
'parent_contact_name' => array(
'name' => 'parent_contact_name',
'vname' => 'LBL_PARENT_CONTACT_NAME',
'type' => 'varchar',
'len' => '255',
'merge_filter' => 'enabled',
),
'parent_contact_title' => array(
'name' => 'parent_contact_title',
'vname' => 'LBL_PARENT_CONTACT_TITLE',
'type' => 'varchar',
'len' => '255',
'merge_filter' => 'enabled',
),
'parent_address_street' => array(
'name' => 'parent_address_street',
'vname' => 'LBL_PARENT_ADDRESS_STREET',
'type' => 'varchar',
'len' => '150',
'comment' => 'The street address used for parent address',
'group' => 'parent_address',
'merge_filter' => 'enabled',
),
'parent_address_city' => array(
'name' => 'parent_address_city',
'vname' => 'LBL_PARENT_ADDRESS_CITY',
'type' => 'varchar',
'len' => '100',
'comment' => 'The city used for parent address',
'group' => 'parent_address',
'merge_filter' => 'enabled',
),
'parent_address_postalcode' => array(
'name' => 'parent_address_postalcode',
'vname' => 'LBL_PARENT_ADDRESS_POSTALCODE',
'type' => 'varchar',
'len' => '20',
'group' => 'parent_address',
'comment' => 'The postal code used for parent address',
'merge_filter' => 'enabled',
),
'parent_address_country' => array(
'name' => 'parent_address_country',
'vname' => 'LBL_PARENT_ADDRESS_COUNTRY',
'type' => 'varchar',
'group' => 'parent_address',
'comment' => 'The country used for the parent address',
'merge_filter' => 'enabled',
),
//shipping address section
'parent_shipping_address_name' => array(
'name' => 'parent_shipping_address_name',
'vname' => 'LBL_PARENT_NAME',
'type' => 'varchar',
'len' => '100',
),
'parent_shipping_address_street' => array(
'name' => 'parent_shipping_address_street',
'vname' => 'LBL_PARENT_ADDRESS_STREET',
'type' => 'varchar',
'len' => '100',
),
'parent_shipping_address_city' => array(
'name' => 'parent_shipping_address_city',
'vname' => 'LBL_PARENT_ADDRESS_CITY',
'type' => 'varchar',
'len' => '100',
),
'parent_shipping_address_postalcode' => array(
'name' => 'parent_shipping_address_id',
'vname' => 'LBL_PARENT_ADDRESS_POSTALCODE',
'type' => 'varchar',
'len' => '100',
),
'parent_shipping_address_country' => array(
'name' => 'parent_shipping_address_country',
'vname' => 'LBL_PARENT_ADDRESS_COUNTRY',
'type' => 'varchar',
'len' => '100',
),
//end shipping address section
'subtotal' => array(
'name' => 'subtotal',
'vname' => 'LBL_SUBTOTAL',
'type' => 'decimal',
'len' => '15,2',
'required' => true,
),
'total' => array(
'name' => 'total',
'vname' => 'LBL_TOTAL',
'type' => 'decimal',
'len' => '15,2',
'required' => true,
),
'paid_val' => array(
'name' => 'paid_val',
'vname' => 'LBL_PAID',
'type' => 'decimal',
'len' => '15,2',
'required' => false,
),
'prepaid' => array(
'name' => 'prepaid',
'vname' => 'LBL_PREPAID',
'type' => 'decimal',
'len' => '15,2',
'required' => false,
),
'prepaid_nr' => array(
'name' => 'prepaid_nr',
'vname' => 'LBL_PREPAID_NR',
'type' => 'varchar',
'len' => 100,
),
'payment_date_d' => array(
'name' => 'payment_date_d',
'vname' => 'LBL_DAYS',
'type' => 'varchar',
'len' => 5,
),
'payment_method' => array(
'name' => 'payment_method',
'vname' => 'LBL_PAYMENT_METHOD',
'type' => 'enum',
'options' => 'payment_method_dom',
),
'payment_method_paid' => array(
'name' => 'payment_method_paid',
'vname' => 'LBL_PAYMENT_METHOD_PAID',
'type' => 'enum',
'options' => 'payment_method_dom',
'massupdate' => false,
),
'discount' => array(
'name' => 'discount',
'vname' => 'LBL_DISCOUNT',
'type' => 'decimal',
'len' => '15,2',
'default' => 0,
),
'to_vatid' => array(
'name' => 'to_vatid',
'vname' => 'LBL_TO_VATID',
'type' => 'varchar',
'len' => 15,
'comment' => 'VAT-ID',
),
'to_nip' => array(
'name' => 'to_nip',
'vname' => 'LBL_TO_NIP',
'type' => 'varchar',
'len' => 15,
'comment' => 'Nip',
),
'ecmlanguage' => array(
'name' => 'ecmlanguage',
'vname' => 'LBL_ECMLANGUAGE',
'type' => 'enum',
'options' => 'ecmlanguages_dom',
'required' => false,
'len' => 35,
'massupdate' => false,
),
'to_is_vat_free' => array(
'massupdate' => false,
'name' => 'to_is_vat_free',
'vname' => 'LBL_TO_IS_VAT_FREE',
'type' => 'bool',
'default' => '0',
'comment' => 'Is vat free?',
),
'header_text' => array(
'name' => 'header_text',
'vname' => 'LBL_HEADER_TEXT',
'type' => 'text',
),
'footer_text' => array(
'name' => 'footer_text',
'vname' => 'LBL_FOOTER_TEXT',
'type' => 'text',
),
'ads_text' => array(
'name' => 'ads_text',
'vname' => 'LBL_ADS_TEXT',
'type' => 'text',
),
'template_id' => array(
'name' => 'template_id',
'vname' => 'LBL_TEMPLATE_ID',
'type' => 'id',
'required_option' => true,
'required' => true,
),
'template_name' => array(
'name' => 'template_name',
'vname' => 'LBL_TEMPLATE_NAME',
'type' => 'varchar',
'len' => '100',
'required_option' => true,
'unified_search' => true,
'required' => true,
),
'contact_id' => array(
'name' => 'contact_id',
'rname' => 'name',
'id_name' => 'contact_id',
'vname' => 'LBL_CONTACT_ID',
'group' => 'contact_name',
'type' => 'relate',
'table' => 'contacts',
'reportable' => true,
'Importable' => false,
'isnull' => 'false',
'dbType' => 'id',
'audited' => false,
'duplicate_merge' => 'disabled',
'massupdate' => false,
),
'contact_name' => array(
'name' => 'contact_name',
'vname' => 'LBL_CONTACT_NAME',
'type' => 'relate',
'reportable' => false,
'source' => 'non-db',
'table' => 'contacts',
'id_name' => 'contact_id',
'module' => 'Contacts',
'duplicate_merge' => 'disabled',
'massupdate' => false,
'other_data' => array(
'from_relation' => array(
'module' => 'Accounts',
'rel_name' => 'contacts',
'rel_bean_name' => 'Contact',
'field_id_name' => 'parent_id',
'field_name' => 'parent_name',
'field_id_value' => '',
)
),
'initial_filter_fields' => array(
'account_name' => 'parent_name',
),
),
'accepted' => array('massupdate' => false,
'name' => 'accepted',
'vname' => 'LBL_ACCEPTED',
'type' => 'bool',
'default' => '0',
),
'email_id' => array(
'name' => 'email_id',
'type' => 'id',
'reportable' => false,
),
'ecmpaymentcondition_id' => array(
'name' => 'ecmpaymentcondition_id',
'rname' => 'name',
'id_name' => 'ecmpaymentcondition_id',
'vname' => 'LBL_PAYMENTCONDITION_ID',
'group' => 'ecmpaymentcondition_name',
'type' => 'relate',
'table' => 'ecmpaymentconditions',
'reportable' => true,
'Importable' => false,
'isnull' => 'false',
'dbType' => 'id',
'audited' => true,
'duplicate_merge' => 'disabled',
'massupdate' => false,
),
'ecmpaymentcondition_name' => array(
'name' => 'ecmpaymentcondition_name',
'vname' => 'LBL_PAYMENTCONDITION_NAME',
'type' => 'relate',
'reportable' => false,
'source' => 'non-db',
'table' => 'ecmpaymentcondition',
'id_name' => 'ecmpaymentcondition_id',
'module' => 'EcmPaymentConditions',
'duplicate_merge' => 'disabled',
'massupdate' => false,
),
'ecmpaymentcondition_text' => array(
'name' => 'ecmpaymentcondition_text',
'vname' => 'LBL_PAYMENTCONDITION_TEXT',
'type' => 'text',
'reportable' => false,
'module' => 'EcmPaymentConditions',
'duplicate_merge' => 'disabled',
'massupdate' => false,
),
'wz_name' => array(
'name' => 'wz_name',
'vname' => 'WZ',
'type' => 'varchar',
'dbType' => 'varchar',
'len' => '255',
),
'wz_id' => array(
'name' => 'wz_id',
'vname' => 'LBL_WZ_ID',
'type' => 'id',
),
'order_no' => array(
'name' => 'order_no',
'vname' => 'LBL_ORDER_NO',
'type' => 'varchar',
'len' => 255,
),
'delivery_place' => array(
'name' => 'delivery_place',
'vname' => 'LBL_DELIVERY_PLACE',
'type' => 'varchar',
'len' => 255,
),
'supplier_code' => array(
'name' => 'supplier_code',
'vname' => 'LBL_SUPPLIER_CODE',
'type' => 'varchar',
'len' => 255,
),
'to_informations' => array(
'name' => 'to_informations',
'vname' => 'LBL_TO_INFORMATIONS',
'type' => 'text',
'source' => 'non-db',
),
'items_list_panel' => array(
'name' => 'items_list_panel',
'vname' => 'LBL_ITEMS',
'type' => 'text',
'source' => 'non-db',
),
'preview_panel' => array(
'name' => 'preview_panel',
'vname' => 'LBL_PREVIEW',
'type' => 'text',
'source' => 'non-db',
),
'email_panel' => array(
'name' => 'email_panel',
'vname' => 'LBL_EMAILS',
'type' => 'text',
'source' => 'non-db',
),
'currency_id' => array(
'name' => 'currency_id',
'type' => 'enum',
'options' => 'currency_dom',
'label' => 'LBL_CURRENCY',
),
'currency_value' => array(
'name' => 'currency_value',
'type' => 'decimal',
'len' => '5,4',
'vname' => 'LBL_CURRENCY_VALUE',
'reportable' => false,
'required' => false,
),
'correct_reason' => array(
'name' => 'correct_reason',
'vname' => 'LBL_CORRECT_REASON',
'type' => 'varchar',
'massupdate' => false,
),
'so_id' => array(
'name' => 'so_id',
'type' => 'id',
'label' => 'LBL_SO',
),
'parent_index_dbf' => array(
'name' => 'parent_index_dbf',
'vname' => 'LBL_PARENT_INDEX_DBF',
'source' => 'non-db',
),
//FOR SUBPANELS
'ecmstockdocouts' => array(
'name' => 'ecmstockdocouts',
'type' => 'link',
'relationship' => 'ecmreceipts_ecmstockdocouts',
//'link_type' => 'one',
'source' => 'non-db',
'vname' => 'LBL_WZ',
'duplicate_merge' => 'disabled',
),
'account' => array(
'name' => 'account',
'type' => 'link',
'relationship' => 'ecmreceipts_account',
'source' => 'non-db',
'vname' => 'LBL_ACCOUNTS',
),
'contact' => array(
'name' => 'contact',
'type' => 'link',
'relationship' => 'ecmreceipts_contact',
'source' => 'non-db',
'vname' => 'LBL_CONTACTS',
),
'bugs' => array(
'name' => 'bugs',
'type' => 'link',
'relationship' => 'ecmreceipts_bug',
'source' => 'non-db',
'vname' => 'LBL_BUGS',
),
'notes' => array(
'name' => 'notes',
'type' => 'link',
'relationship' => 'ecmreceipts_notes',
'source' => 'non-db',
'vname' => 'LBL_NOTES',
),
'emails' => array(
'name' => 'emails',
'type' => 'link',
'relationship' => 'ecmreceipts_emails',
'source' => 'non-db',
'vname' => 'LBL_EMAILS',
),
'tasks' => array(
'name' => 'tasks',
'type' => 'link',
'relationship' => 'ecmreceipts_task',
'source' => 'non-db',
'vname' => 'LBL_TASKS',
),
),
//INDICES SECTION
'indices' => array(
array(
'name' => 'ecmreceipts' . 'pk',
'type' => 'primary',
'fields' => array(
'id',
),
),
array(
'name' => 'idx_' . 'ecmreceipts' . '_name',
'type' => 'index',
'fields' => array(
'name',
),
)
),
//RELATIONSHIPS SECTION
'relationships' => array(
'ecmreceipts_ecmstockdocouts' => array(
'lhs_module' => 'EcmStockDocOuts',
'lhs_table' => 'ecmstockdocouts',
'lhs_key' => 'id',
'rhs_module' => 'EcmReceipts',
'rhs_table' => 'ecmreceipts',
'rhs_key' => 'wz_id',
'relationship_type' => 'one-to-many',
),
'ecmreceipts' . '_assigned_user' => array(
'lhs_module' => 'Users',
'lhs_table' => 'users',
'lhs_key' => 'id',
'rhs_module' => 'EcmReceipts',
'rhs_table' => 'ecmreceipts',
'rhs_key' => 'assigned_user_id',
'relationship_type' => 'one-to-many',
),
'ecmreceipts' . '_modified_user' => array(
'lhs_module' => 'Users',
'lhs_table' => 'users',
'lhs_key' => 'id',
'rhs_module' => 'EcmReceipts',
'rhs_table' => 'ecmreceipts',
'rhs_key' => 'modified_user_id',
'relationship_type' => 'one-to-many',
),
'ecmreceipts' . '_created_by' => array(
'lhs_module' => 'Users',
'lhs_table' => 'users',
'lhs_key' => 'id',
'rhs_module' => 'EcmReceipts',
'rhs_table' => 'ecmreceipts',
'rhs_key' => 'created_by',
'relationship_type' => 'one-to-many',
),
'ecmreceipts' . '_account' => array(
'lhs_module' => 'Accounts',
'lhs_table' => 'accounts',
'lhs_key' => 'id',
'rhs_module' => 'EcmReceipts',
'rhs_table' => 'ecmreceipts',
'rhs_key' => 'parent_id',
'relationship_type' => 'one-to-many',
),
'ecmreceipts' . '_contact' => array(
'lhs_module' => 'Contacts',
'lhs_table' => 'contacts',
'lhs_key' => 'id',
'rhs_module' => 'EcmReceipts',
'rhs_table' => 'ecmreceipts',
'rhs_key' => 'contact_id',
'relationship_type' => 'one-to-many',
),
'ecmreceipts' . '_project' => array(
'lhs_module' => 'Project',
'lhs_table' => 'project',
'lhs_key' => 'id',
'rhs_module' => 'EcmReceipts',
'rhs_table' => 'ecmreceipts',
'rhs_key' => 'parent_id',
'relationship_type' => 'one-to-many',
),
'ecmreceipts' . '_bug' => array(
'lhs_module' => 'Bugs',
'lhs_table' => 'bugs',
'lhs_key' => 'id',
'rhs_module' => 'EcmReceipts',
'rhs_table' => 'ecmreceipts',
'rhs_key' => 'parent_id',
'relationship_type' => 'one-to-many',
),
'ecmreceipts' . '_case' => array(
'lhs_module' => 'Cases',
'lhs_table' => 'cases',
'lhs_key' => 'id',
'rhs_module' => 'EcmReceipts',
'rhs_table' => 'ecmreceipts',
'rhs_key' => 'parent_id',
'relationship_type' => 'one-to-many',
),
'ecmreceipts' . '_task' => array(
'lhs_module' => 'Tasks',
'lhs_table' => 'tasks',
'lhs_key' => 'id',
'rhs_module' => 'EcmReceipts',
'rhs_table' => 'ecmreceipts',
'rhs_key' => 'parent_id',
'relationship_type' => 'one-to-many',
),
'ecmworkitems' . '_ecmreceipt' => array(
'lhs_module' => 'EcmReceipts',
'lhs_table' => 'ecmreceipts',
'lhs_key' => 'id',
'rhs_module' => 'EcmWorkItems',
'rhs_table' => 'ecmworkitems',
'rhs_key' => 'ecmreceipt_id',
'relationship_type' => 'one-to-many',
),
),
//THIS FLAG ENABLES OPTIMISTIC LOCKING FOR SAVES FROM EDITVIEW
'optimistic_locking' => true,
);

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,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,246 @@
<?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 EcmReceiptsViewList extends ViewList {
function EcmReceiptsViewList() {
parent::ViewList();
}
function display() {
if (!$this->bean->ACLAccess('list')) {
ACLController::displayNoAccess();
return;
}
$this->module = $module = "EcmReceipts";
$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();
}
}
}
?>