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,201 @@
<?php
$db=$GLOBALS['db'];
if(count($_REQUEST['mass']) > 0) {
$ids = $_REQUEST['mass'];
} else {
$settings = json_decode(base64_decode($_REQUEST['list_pdf_settigns']), true);
$where = base64_decode($settings['where']);
$res = $db->query("SELECT id FROM ecmsales WHERE deleted=0 AND ".$where);
$ids = array();
while ($row = $db->fetchByAssoc($res)) {
array_push($ids, $row['id']);
}
}
if (count($ids) > 0) {
global $app_list_strings;
$components_to_show=$_REQUEST['compid'];
$query='select i.ecmproduct_id,i.name,i.code,i.quantity,d.document_no from ecmsaleitems i
inner join ecmsales d on d.id=i.ecmsale_id
where i.ecmsale_id in ("'.implode('","',$ids) .'") and i.deleted=0 ORDER BY d.register_date';
$res = $db->query($query);
$orders=[];
$products=[];
$orderNo='';
$orderNr=[];
while($dane = $db->fetchByAssoc($res)){
$tmp = [];
$tmp['ecmproduct_id']=$dane['ecmproduct_id'];
$tmp['quantity']=(float)$dane['quantity'];
$tmp['name']=$dane['name'];
$tmp['code']=$dane['code'];
$orders[$dane['ecmsale_id']][]=$tmp;
$products[]=$dane['ecmproduct_id'];
if($orderNr[$dane['document_no']]==""){
$orderNr[$dane['document_no']]=1;
$orderNo.=' '.$dane['document_no'];
}
}
$products=array_unique($products);
$query="SELECT c.ecmproduct_id,c.ecmcomponent_id,c.code,c.name,c.quantity,p.product_category_name,p.group_ks,p.unit_id FROM ecmproductcomponents c
inner join ecmproducts p on p.id=c.ecmcomponent_id
where c.ecmproduct_id in ('".implode("','",$products)."') and c.deleted=0";
$res = $db->query($query);
$lists = return_app_list_strings_language('pl_pl');
$components=[];
$products_has_components=[];
while($dane = $db->fetchByAssoc($res)){
$products_has_components[$dane['ecmproduct_id']][]=$dane;
}
$total_components=0;
$total_in_stock=0;
$components_list=[];
foreach ($orders as $order){
foreach ($order as $product){
if(isset($products_has_components[$product['ecmproduct_id']])){
foreach ($products_has_components[$product['ecmproduct_id']] as $component){
if(count($components_to_show)>0){
if(!in_array($component['ecmcomponent_id'],$components_to_show))continue;
}
if($component['group_ks']=='4')continue;
if($component['product_category_name']=='Usługi')continue;
if($components_list[$component['ecmcomponent_id']]){
$components_list[$component['ecmcomponent_id']]['quantity']=bcadd(bcmul($component['quantity'],$product['quantity'],6),$components_list[$component['ecmcomponent_id']]['quantity'],6);
$total_components=bcadd(bcmul($component['quantity'],$product['quantity'],6),$total_components,6);
} else {
$components_list[$component['ecmcomponent_id']]['quantity']=bcmul ($component['quantity'],$product['quantity'],6);
$components_list[$component['ecmcomponent_id']]['code']=$component['code'];
$components_list[$component['ecmcomponent_id']]['name']=$component['name'];
$components_list[$component['ecmcomponent_id']]['id']=$component['ecmcomponent_id'];
$components_list[$component['ecmcomponent_id']]['product_category_name']=$component['product_category_name'];
$components_list[$component['ecmcomponent_id']]['group_ks_name']=$app_list_strings['ecmproducts_group_ks_dom'][$component['group_ks']];
$components_list[$component['ecmcomponent_id']]['unit_name'] = $lists['ecmproducts_unit_dom'][$component['unit_id']];
$ecmStockOperations = new EcmStockOperation();
$stock=round($ecmStockOperations->getRealStock($component['ecmcomponent_id']),2);
$total_components=bcadd($components_list[$component['ecmcomponent_id']]['quantity'],$total_components,6);
$total_in_stock=bcadd($stock,$total_in_stock,2);
$components_list[$component['ecmcomponent_id']]['stock']=$stock;
}
}
}
}
}
foreach ($products as $key=> $product){
foreach ($products_has_components as $key2=> $product2){
if($product==$key2){
unset($products[$key]);
}
}
}
$query="select p.id,p.code,p.name,p.product_category_name,p.group_ks,i.quantity,p.unit_id from ecmsaleitems i
inner join ecmproducts p on p.id = i.ecmproduct_id
where i.ecmsale_id in ('".implode("','",$ids) ."') and i.deleted=0
and i.ecmproduct_id in ('".implode("','",$products)."')";
$total=0;
$total_in_stock2=0;
$res = $db->query($query);
$products=[];
while($dane = $db->fetchByAssoc($res)){
if($dane['group_ks']=='4')continue;
if($dane['product_category_name']=='Usługi')continue;
$products[$dane['id']]['code']=$dane['code'];
$products[$dane['id']]['name']=$dane['name'];
// $products[$dane['id']]['name']=$dane['id'];
$products[$dane['id']]['quantity']=$products[$dane['id']]['quantity']+$dane['quantity'];
$products[$dane['id']]['product_category_name']=$dane['product_category_name'];
$products[$dane['id']]['group_ks_name']=$app_list_strings['ecmproducts_group_ks_dom'][$dane['group_ks']];
$products[$dane['id']]['unit_name']= $lists['ecmproducts_unit_dom'][$component['unit_id']];
$ecmStockOperations = new EcmStockOperation();
$stock=$ecmStockOperations->getRealStock($dane['id']);
$total=bcadd($dane['quantity'],$total,2);
$total_in_stock2=bcadd($stock,$total_in_stock2,2);
$products[$dane['id']]['stock']=$stock;
}
$query="select p.id,p.code,p.name,p.product_category_name,p.group_ks,i.quantity,p.pieces_per_carton,p.boxes_per_palette,p.packing_dimensions_1 as a1,p.packing_dimensions_2 as a2,p.packing_dimensions_3 as a3 from ecmsaleitems i
inner join ecmproducts p on p.id = i.ecmproduct_id
where i.ecmsale_id in ('".implode("','",$ids) ."') and i.deleted=0 ";
$res = $db->query($query);
$packing=[];
while($dane = $db->fetchByAssoc($res)){
if($dane['group_ks']=='4')continue;
if($dane['product_category_name']=='Usługi')continue;
$packing[$dane['a1'].'x'.$dane['a2'].'x'.$dane['a3']]['name']=$dane['a1'].'x'.$dane['a2'].'x'.$dane['a3'];
$packing[$dane['a1'].'x'.$dane['a2'].'x'.$dane['a3']]['box']=$packing[$dane['a1'].'x'.$dane['a2'].'x'.$dane['a3']]['box']+ceil($dane['quantity']/$dane['pieces_per_carton']);
$packing[$dane['a1'].'x'.$dane['a2'].'x'.$dane['a3']]['palet']=$packing[$dane['a1'].'x'.$dane['a2'].'x'.$dane['a3']]['palet']+ ceil(($dane['quantity']/$dane['pieces_per_carton'])/$dane['boxes_per_palette']);
$packing[$dane['a1'].'x'.$dane['a2'].'x'.$dane['a3']]['product_category_name']=$dane['product_category_name'];
$packing[$dane['a1'].'x'.$dane['a2'].'x'.$dane['a3']]['group_ks_name']=$app_list_strings['ecmproducts_group_ks_dom'][$dane['group_ks']];
$total_box=bcadd($packing[$dane['a1'].'x'.$dane['a2'].'x'.$dane['a3']]['box'],$total_box,2);
$total_palet=bcadd($packing[$dane['a1'].'x'.$dane['a2'].'x'.$dane['a3']]['palet'],$total_palet,2);
}
$ss = new Sugar_Smarty ();
global $mod_strings;
$ss->assign ( "total_box", ceil($total_box));
$ss->assign ( "total_total", $total_total);
$ss->assign ( "total_palet", ceil($total_palet));
$ss->assign ( "packing", $packing);
$ss->assign ( "orderNo", $orderNo);
$ss->assign ( "total_components", $total_components);
$ss->assign ( "total_in_stock", $total_in_stock);
$ss->assign ( "total", $total);
$ss->assign ( "total_in_stock2", $total_in_stock2);
$ss->assign ( "products", $products );
$ss->assign ( "components_list", $components_list);
$ss->assign ( 'MOD', $mod_strings);
$ss->assign ( "mass",$_REQUEST['mass']);
$ss->assign("orderSize", count($ids));
if($_REQUEST['to_pdf']==1){
include_once("include/MPDF57/mpdf.php");
$p = new mPDF('', 'A4', null, 'helvetica', 5, 5, 23, 5, 5, 5);
$p->setFooter('Strona {PAGENO} z {nbpg}');
$EcmSysInfos = new EcmSysInfo();
$p->SetHTMLHeader('<p style="text-align:left;font-size: 10px;">' . $EcmSysInfos->getName() . '<br>
Specyfikacja komponentów dla zamówienia: '.$orderNo.'<br>Data wydruku: '.date('d.m.Y'));
//$p->setTitle($mod_strings["LBL_REPORT_STOCKS_DOCS"]);
//echo $output;
$content=$ss-> fetch('modules/EcmSales/tpls/print/ComponentsList.html'); //4
$p->writeHTML($content);
$p->Output();
} else {
$ss-> display('modules/EcmSales/tpls/ComponentsList.html'); //4
}
}
?>

View File

@@ -0,0 +1,112 @@
<?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".
*/
global $current_user;
$dashletData['MyEcmSalesDashlet']['searchFields'] = array('name' => array('default' => ''),
'date_entered' => array('default' => ''),
'status' => array('default' => ''),
'assigned_user_id' => array('type' => 'assigned_user_name',
'default' => $current_user->name));
$dashletData['MyEcmSalesDashlet']['columns'] = array(
'STATUS' => array(
'width' => '1',
'label' => '&nbsp;',
'default' => true,
),
'DOCUMENT_NO' => array(
'width' => '8',
'label' => 'LBL_DOCUMENT_NO',
'sortable' => true,
'link' => true,
'default' => true,
),
'NAME' => array(
'width' => '15',
'label' => 'LBL_NAME',
'sortable' => true,
'link' => false,
//'customCode' => '<a href="index.php?module=EcmSales&action=EditView&record={$ID}">{$NAME}</a>',
'default' => true,
),
'REGISTER_DATE' => array(
'width' => 15,
'label' => 'LBL_REGISTER_DATE',
'default' => true,
'sortable' => true,
),
'PARENT_ID' => array(
'width' => 0,
'label' => '&nbsp;',
'customCode' => '&nbsp;',
'default' => true,
'sortable' => false,
),
'PARENT_NAME' => array(
'width' => '15',
'label' => 'LBL_PARENT_NAME',
'default' => true,
'id' => 'PARENT_ID',
'module' => 'Accounts',
'link' => true,
),
'TOTAL' => array(
'width' => '10',
'label' => 'LBL_TOTAL',
'default' => true,
'align' => 'left',
),
'ASSIGNED_USER_NAME' => array(
'width' => '10',
'label' => 'LBL_LIST_ASSIGNED_USER',
'default' => true
),
'OPTIONS' => array(
'width' => '5',
'label' => '&nbsp;',
'link' => false,
'default' => true,
'sortable' => false,
'align' => 'right',
),
'date_entered' => array('width' => '15',
'label' => 'LBL_DATE_ENTERED'),
);
k
?>

View File

@@ -0,0 +1,45 @@
<?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".
*/
global $app_strings;
$dashletMeta['MyEcmSalesDashlet'] = array('module' => 'EcmSales',
'title' => translate('LBL_DASHLET_MY_ECMNEWSALES', 'EcmSales'),
'description' => 'A customizable view into Quotes',
'category' => 'Module Views');
?>

View File

@@ -0,0 +1,59 @@
<?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".
*/
require_once('include/Dashlets/DashletGeneric.php');
require_once('modules/EcmSales/EcmSale.php');
class MyEcmSalesDashlet extends DashletGeneric {
function MyEcmSalesDashlet($id, $def = null) {
global $current_user, $app_strings;
require('modules/EcmSales/Dashlets/MyEcmSalesDashlet/MyEcmSalesDashlet.data.php');
parent::DashletGeneric($id, $def);
if (empty($def['title'])){
$this->title = translate('LBL_DASHLET_MY_ECMNEWSALES', 'EcmSales');
}
$this->searchFields = $dashletData['MyEcmSalesDashlet']['searchFields'];
$this->columns = $dashletData['MyEcmSalesDashlet']['columns'];
$this->seedBean = new EcmSale();
$this->lvs->quickViewLinks = false;
}
}
?>

135
modules/EcmSales/DetailView.php Executable file
View File

@@ -0,0 +1,135 @@
<?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/EcmSales/EcmSale.php');
require_once ('include/time.php');
require_once ('include/json_config.php');
echo '<script type="text/javascript" src="include/ECM/SearchProductTable.js"></script>';
$json_config = new json_config ();
$focus = new EcmSale ();
if (isset($_REQUEST ['record'])) {
$focus->retrieve($_REQUEST ['record']);
$focus->format_all_fields();
$OPT ['status'] = $focus->status;
}
require_once ('include/MVC/View/SugarView.php');
require_once ('modules/EcmSales/views/DetailView/view.detail.my.php');
//create position list table
$pl = $focus->getPositionList();
$edit = new ViewDetailMy ();
$edit->ss = new Sugar_Smarty ();
$edit->module = 'EcmSales';
$fk = '<input title="{$APP.LBL_CREATE_INVOICE}" accessKey="{$APP.LBL_CREATE_INVOICE|"
class="button" type="submit" name="create_fk" value="{$APP.LBL_CREATE_INVOICE}" id="create_fk">';
//add pdf buttons
$btn = '<input title="Generuj PDF" class="button" onclick="if($(\'#div_pdf\').css(\'display\') == \'none\'){$(\'#div_pdf\').show(\'slow\'); } else { $(\'#div_pdf\').hide(\'slow\'); }" type="button" name="productcard" id="productcard" value="PDF">';
$btn .= '<div id="div_pdf" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;">';
$btn .= 'Typ: <select name="pdf_images" id="pdf_type"><option value="1">Zamówienie sprzedaży</option>
<option value="0">Proforma</option><option value="2">Oferta</option></select><br /><br />';
$btn .= 'Pokaż rabat: <select name="discount_show" id="discount_show"><option value="1">Tak</option>
<option value="0">Nie</option></select><br /><br />';
$btn .= '<input name="quote_pdf" id="quote_pdf" title="Show PDF" accessKey="" class="button" onclick="window.open(\'index.php?module=EcmSales&action=createPDF&to_pdf=1&show_img=no&discount_show=\'+$(\'#discount_show\').val()+\'&pdf_type=\'+$(\'#pdf_type\').val()+\'&show_ean2=\'+$(\'#pdf_ean2\').val()+\'&show_recipient_code=\'+$(\'#pdf_recipient_code\').val()+\'&record=' . $_REQUEST['record'] . '\',\'_blank\');" type="button" value="Pokaż PDF"></div>';
$edit->ss->assign("CREATE_PDF", $btn);
$btn = '<input title="Generuj Katalog" class="button" onclick="if($(\'#div_cat\').css(\'display\') == \'none\'){$(\'#div_cat\').show(\'slow\'); } else { $(\'#div_cat\').hide(\'slow\'); }" type="button" name="productcat" id="productcat" value="Generuj Katalog">';
$btn .= '<div id="div_cat" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;">';
$btn .= 'EAN: <select name="cat_ean" id="cat_ean"><option value="1">1</option><option value="2">2</option><option value="0">Brak</option></select><br /><br />';
$btn .= '<input name="cat_pdf" id="cat_pdf" title="Show Cat" accessKey="" class="button" onclick="window.open(\'index.php?module=EcmSales&action=createCatalogue&to_pdf=1&show_ean=\'+$(\'#cat_ean\').val()+\'&record=' . $_REQUEST['record'] . '\',\'_blank\');" type="button" value="Pokaż Katalog"></div>';
$edit->ss->assign("CATALOGUE", $btn);
$btn = '<input name="quote_xls" id="quote_xls" title="Show XLS" accessKey="" class="button" onclick="window.open(\'index.php?module=EcmSales&action=createXLS&to_pdf=1&show_ean=\'+$(\'#pdf_ean\').val()+\'&show_ean2=\'+$(\'#pdf_ean2\').val()+\'&show_recipient_code=\'+$(\'#pdf_recipient_code\').val()+\'&record=' . $_REQUEST['record'] . '\',\'_blank\');" type="button" value="Pokaż XLS"></div>';
$edit->ss->assign("CREATE_XLS", $btn);
if ($focus->check_mail_addresses() == 1) {
//add pdf buttons
$btn = '<input title="Wyślij dokument" class="button" onclick="if($(\'#div_mail\').css(\'display\') == \'none\'){$(\'#div_mail\').show(\'slow\'); } else { $(\'#div_mail\').hide(\'slow\'); }" type="button" name="productcard" id="productcard" value="Wyślij dokument">';
$btn .= '<div id="div_mail" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;">';
$btn .= 'Typ: <select name="pdfs_type" id="pdfs_type"><option value="1">Zamówienie sprzedaży</option>
<option value="0">Proforma</option><option value="2">Oferta</option></select><br /><br />';
$btn.='<input name="send_mail" id="send_mail" class="button" type="button" value="' . $mod_strings['LBL_SEND_MAIL'] . '" onClick="SendMail(\'' . $focus->id . '\',$(\'#pdfs_type\').val(),\'' . $focus->parent_id . '\');"></div>';
$edit->ss->assign("SEND_PDF", $btn);
echo '<div id="sendreturn" style="display:none;"></div>';
}
$can_edit = true;
global $current_user;
if (($focus->created_by == $current_user->id || is_admin($current_user || $current_user->id=='6ff351c9-c340-7e81-4f29-59d5eb8c71c2')) && $focus->status != 's90')
$can_edit = true;
$can_prepaid=false;
$q=$GLOBALS['db']->query("select sum(prepaid_amount) as total from ecmprepaymentinvoices where ecmsale_id='".$focus->id."'");
$res=$GLOBALS['db']->fetchByAssoc($q);
if($res['total']<$focus->total_brutto){
$can_prepaid=true;
}
$create_code = '<input title="Utwórz" class="button" onclick="if($(\'#div_create\').css(\'display\') == \'none\'){$(\'#div_create\').show(\'slow\'); } else { $(\'#div_create\').hide(\'slow\'); }"
type="button" name="productcat" id="productcat" value="Utwórz dokument">';
$create_code .= '<div id="div_create" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;">';
$create_code .= 'Dokument: <select name="doc_type" id="doc_type">';
$create_code .= '<option value="EcmInvoiceOuts">Fakturę</option>';
$create_code .= '<option value="EcmReceipts">Paragon</option>';
if($can_prepaid==true){
$create_code .= '<option value="EcmPrepaymentInvoices">Fakturę zaliczkowa</option>';
}
$create_code .= '<option value="EcmStockDocOuts">WZ</option>';
$create_code .= '</select><br /><br />';
$create_code .= '<input name="cat_pdf" id="cat_pdf" title="Show Cat" accessKey="" class="button"
onclick="createDoc(\''.$focus->id.'\')" type="button" value="Utwórz"></div>';
$edit->ss->assign("CREATE_DOCS",$create_code);
$edit->ss->assign("CAN_EDIT", $can_edit);
$edit->ss->assign("CAN_PREPAID", $can_prepaid);
$edit->ss->assign("CREATE_FK", $fk);
$edit->ss->assign("CREATED_BY_NAME", $focus->created_by_name);
$edit->ss->assign("MODIFIED_BY_NAME", $focus->modified_by_name);
$a = new EcmStockDocOut();
$a->retrieve_by_string_fields(['so_id'=>$focus->id]);
$the_array ['WZ'] = "<a target='_blank' href='index.php?module=EcmStockDocOuts&action=DetailView&record=$a->id'>".$a->document_no."</a>";
$edit->ss->assign ( "wz_no", $the_array ['WZ'] );
$a = new EcmInvoiceOut();
$a->retrieve_by_string_fields(['so_id'=>$focus->id]);
$the_array ['FV'] = "<a target='_blank' href='index.php?module=EcmInvoiceOuts&action=DetailView&record=$a->id'>".$a->document_no."</a>";
$edit->ss->assign ( "fk_no", $the_array ['FV'] );
$edit->ss->assign("can_copy_to_e5", isset($focus->edi_zs_id) && strlen($focus->edi_zs_id) > 0 ? false : true);
$edit->bean = $focus;
$edit->tplFile = 'include/ECM/EcmViews/DetailView/Tabs/DetailView.tpl';
$edit->preDisplay();
//check number
$db = $GLOBALS['db'];
$res = $db->query("SELECT id FROM ecmsales WHERE document_no='$focus->document_no' and deleted='0'");
if ($res->num_rows > 1) {
echo '<h1 style="color: red;">Błąd numeracji, skontaktuj się z administratorem! Nie drukuj/publikuj dokumentu!</h1>';
}
echo $edit->display();
require_once ('include/SubPanel/SubPanelTiles.php');
$subpanel = new SubPanelTiles($focus, 'EcmSales');
echo $subpanel->display();
//loading view
echo '<link rel="stylesheet" type="text/css" href="modules/EcmSales/javascript/helper.css" media="screen" /><div class="loading_panel"></div>';
?>

1477
modules/EcmSales/EcmSale.php Executable file

File diff suppressed because it is too large Load Diff

170
modules/EcmSales/EditView.php Executable file
View File

@@ -0,0 +1,170 @@
<?php
if (! defined('sugarEntry') || ! sugarEntry)
die('NotAValidEntryPoint');
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings, $current_user, $app_list_strings;
$db = $GLOBALS['db'];
require_once('modules/EcmSales/EcmSale.php');
require_once('include/time.php');
//add jquery
echo '<link rel="stylesheet" type="text/css" href="include/jQuery/jquery-table/jquery.appendGrid-1.3.1.css"/>';
echo '<link rel="stylesheet" type="text/css" href="include/jQuery/jquery-ui/themes/base/jquery-ui.css"/>';
echo '<link rel="stylesheet" type="text/css" href="modules/EcmSales/css/autocomplete.css"/>';
echo '<script type="text/javascript"
src="include/jQuery/jquery-2.1.0.min.js"></script>';
echo '<script type="text/javascript"
src="include/jQuery/jquery-table/jquery.appendGrid-1.3.1.js"></script>';
echo '<script type="text/javascript"
src="include/jQuery/jquery-ui/ui/jquery-ui.js"></script>';
echo '<script type="text/javascript"
src="modules/EcmSales/javascript/searchcolumndefs.js"></script>';
echo '<script type="text/javascript"
src="include/ECM/tablenavigator.js"></script>';
echo '<script type="text/javascript"
src="include/ECM/SearchProductTable.js"></script>';
// $cq=$current_user->getPreference('confirm_quotes');
$new_number = false;
$duplicate = false;
$focus = new EcmSale();
require_once('include/MVC/View/SugarView.php');
require_once('modules/EcmSales/views/EditView/view.edit.ecmsales.php');
$edit = new ViewEditEcmSales();
$edit->ss = new Sugar_Smarty();
if (isset($_REQUEST['record']) && $_REQUEST['isDuplicate'] == "false") {
$focus->retrieve($_REQUEST['record']);
if (isset($focus->id) && $focus->id != '') {
$focus->format_all_fields();
}
} else if (isset($_REQUEST['ecommerceZS'])) {
$new_number = true;
$focus->stock_id = 'cf16804e-f698-5e09-2da3-6553588446ae';
$focus->register_date = date("d.m.Y");
$focus->parent_id = 'b5612f7f-85e5-f930-293e-62cead14b424';
$db = $GLOBALS['db'];
$invoiceIds = $_SESSION[$_REQUEST['ecommerceZS']];
$i = $db->fetchByAssoc($db->query("SELECT register_date FROM ecommerce_invoices WHERE id = '$invoiceIds[0]'"));
$focus->delivery_date = date("d.m.Y");
$focus->payment_date = date("d.m.Y");
$focus->send_date = date("d.m.Y");
$focus->payment_date_days = 0;
$focus->status = 's30';
$focus->order_source = 'baselinker';
$query = "
SELECT ip.ecmproduct_id, SUM(ip.quantity) AS quantity, ip.price_netto, p.code, p.name, p.unit_id
FROM ecommerce_invoices_products AS ip
INNER JOIN ecmproducts AS p ON ip.ecmproduct_id = p.id
WHERE invoice_id IN ('" . implode('\',\'', $invoiceIds) . "')
AND ip.ecmproduct_id NOT IN ('', '165f364e-9301-25ac-5906-58e38f1de4ca')
GROUP BY ip.ecmproduct_id, ip.price_netto;
";
$res = $db->query($query);
$products = array();
$position = 1;
while ($row = $db->fetchByAssoc($res)) {
$products[] = array(
'position' => $position++,
'product_id' => $row['ecmproduct_id'],
'product_code' => $row['code'],
'name' => $row['name'],
'quantity' => $row['quantity'],
'price_start' => $row['price_netto'],
'price_netto' => $row['price_netto'],
'unit_id' => $row['unit_id'],
'unit_name' => $app_list_strings['ecmproducts_unit_dom'][$row['unit_id']],
'ecmvat_name' => '23%',
'ecmvat_value' => 23,
'ecmvat_id' => '28079566-b825-e38f-9993-4ccc7b781de5',
);
}
$edit->ss->assign('ECOMMERCE_PRODUCTS', json_encode($products));
$edit->ss->assign('ECOMMERCE_INVOICES', json_encode($invoiceIds));
$query = "SELECT document_no FROM ecommerce_invoices WHERE id IN ('" . implode('\',\'', $invoiceIds) . "')";
$res = $db->query($query);
$documentNos = array();
while ($row = $db->fetchByAssoc($res)) {
$documentNos[] = $row['document_no'];
}
$focus->pdf_text = "Dotyczy faktur: " . implode(', ', $documentNos);
} else if ($_REQUEST['isDuplicate'] == "true") {
$new_number = true;
$duplicate = true;
//get data
$focus->retrieve($_REQUEST['return_id']);
$focus->id = null;
$focus->register_date = date("d.m.Y");
$focus->delivery_date = null;
$focus->send_date = null;
$focus->assigned_user_name = $current_user->full_name;
$focus->assigned_user_id = $current_user->id;
$focus->status = 's10';
} else if ($_REQUEST['ecmquote_id']) {
$new_number = true;
$ecmquote_id = $_REQUEST['ecmquote_id'];
$ecmquote = true;
$q = new EcmQuote();
//get data
$q->retrieve($_REQUEST['ecmquote_id']);
$focus->parent_id = $q->parent_id;
$focus->parent_name = $q->parent_name;
$focus->register_date = date("d.m.Y");
$focus->position_list = $q->getPositionList(true);
} else {
$new_number = true;
$focus->stock_id = $current_user->stock_id;
$focus->register_date = date("d.m.Y");
$focus->delivery_date = date("d.m.Y");
//for subpanels??
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;
}
}
//get stocks
$res = $db->query("SELECT id, name FROM ecmstocks WHERE deleted = '0' ORDER BY name");
$stock = '<select id="stock" name="stock"><option value=""></option>';
$stock_body = '';
while ($row = $db->fetchByAssoc($res)) {
if ($focus->stock_id != '' && $row['id'] == $focus->stock_id) {
$s = 'selected';
} else {
$s = '';
}
$stock_body .= '<option value="' . $row['id'] . '" ' . $s . '>' . $row['name'] . '</option>';
}
$stock .= $stock_body . '</select><input id="stock_id" name="stock_id" type="hidden" value="' . $focus->stock_id . '"/>';
//includ OO VAT
$v = new EcmVat();
$v->retrieve('a8c52d5e-15df-2a13-c934-5578307bebd2');
$oo = array('id' => 'a8c52d5e-15df-2a13-c934-5578307bebd2', 'name' => $v->name, 'value' => $v->value);
echo '<script> var OO=\'' . json_encode($oo) . '\'</script>';
$edit->module = 'EcmSales';
$edit->bean = $focus;
$edit->tplFile = 'include/ECM/EcmViews/EditView/Tabs/EditView.tpl';
$edit->preDisplay();
$edit->ss->assign("NEW_NUMBER", $new_number);
$edit->ss->assign("ECMQUOTE_ID", $ecmquote_id);
$edit->ss->assign("ECMQUOTE", $ecmquote);
$edit->ss->assign("STOCK", $stock);
$edit->ss->assign("DUPLICATE", $duplicate);
echo $edit->display();
//loading view
echo '<link rel="stylesheet" type="text/css" href="modules/EcmSales/javascript/helper.css" media="screen" />';

View File

@@ -0,0 +1,62 @@
<?php
if (! defined ( 'sugarEntry' ) || ! sugarEntry)
die ( 'Not A Valid Entry Point' );
// require_once('modules/EcmGroupSales/HeaderMenu.php');
ini_set('max_execution_time', 9999999999);
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings;
require_once ('include/time.php');
require_once ('include/json_config.php');
// add jquery
echo '<link rel="stylesheet" type="text/css" href="modules/EcmSales/css/style.css"/>';
echo '<script type="text/javascript"
src="include/jQuery/jquery.tablesorter.js"></script>';
echo '<script type="text/javascript"
src="include/jQuery/jquery.tablesorter.pager.js"></script>';
echo '<script type="text/javascript"
src="modules/EcmSales/javascript/ListNewSales.js"></script>';
$json_config = new json_config ();
$focus = new EcmSale ();
if($_GET['submit']){
$position_list=$focus->GetArrayResultFromQuery($focus->CreateQueryFromPost($_GET));
}
if($_GET['gets']){
$position_list=$focus->GetArrayResultFromQuery($focus->CreateQueryFromPost($_GET));
$link=$focus->CreateMultiPDF($_GET['selectedid']);
}
if($link!=''){
// header('Location: https://95.50.148.50/crm/pdftmp/'.$link);
}
$edit->ss = new Sugar_Smarty ();
$edit->module = 'EcmSales';
$currencies = [
'PLN'=>'PLN',
'3c8d317e-513b-9a9b-d0e6-511e2abee625'=>"GBP",
'98b2b752-b0be-37c2-d2eb-511e29f81cab'=>'USD',
'6336d9a0-ee5f-52e3-7d0c-4e6f1472b2bf'=>'EUR'
];
$edit->ss->assign ( "CREATED_BY_NAME", $focus->created_by_name );
$edit->ss->assign ( "MODIFIED_BY_NAME", $focus->modified_by_name );
$edit->ss->assign ( 'FOCUS', $focus);
$edit->ss->assign ( 'POST', $_GET);
$edit->ss->assign ( 'LINK', $link);
$edit->ss->assign ( "CURRENCIES", $currencies);
$edit->ss->assign('POSITION_LIST',$position_list);
$edit->ss->assign('POSITION_LIST_C',$position_list_c);
$edit->ss->assign ( 'MOD', $mod_strings);
$edit->ss-> display('modules/EcmSales/tpls/ListNewSales.tpl'); //4
// loading view
//echo '<link rel="stylesheet" type="text/css" href="modules/EcmInsideOrders/javascript/helper.css" media="screen" /><div class="loading_panel"></div>';
?>

113
modules/EcmSales/Menu.php Executable file
View File

@@ -0,0 +1,113 @@
<?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 $mod_strings, $current_user;
if(ACLController::checkAccess('EcmSales', "edit", true)) $module_menu [] = Array("index.php?module=".'EcmSales'."&action=EditView&return_module=".'EcmSales'."&return_action=DetailView", translate('LNK_NEW_'.'ECMSALE', 'EcmSales'),"CreateEcmSales", 'EcmSales');
if(ACLController::checkAccess('EcmSales', "list", true))
$module_menu [] = Array("index.php?action=index&module=EcmSales&saved_search_select=7cf8156f-0a62-c70b-4069-666da4de049a&saved_search_select_name=Standard&orderBy=DOCUMENT_AUTOINCREMENT&sortOrder=DESC&query=true&searchFormTab=advanced_search&showSSDIV=no", translate('LNK_ECMSALES_LIST','EcmSales'),"EcmSales", 'EcmSales');
if(ACLController::checkAccess('EcmSales', "list", true))
$module_menu [] = Array("index.php?action=index&module=EcmSales&saved_search_select=b086cbd2-1899-df5f-9327-666d967fe996&saved_search_select_name=E-Commerce&orderBy=DOCUMENT_AUTOINCREMENT&sortOrder=DESC&query=true&searchFormTab=advanced_search&showSSDIV=no", "Lista zamówień E-Commerce","EcmSales", 'EcmSales');
//if(ACLController::checkAccess('EcmSales', "list", true)) $module_menu [] = Array("index.php?module=EcmSales&action=ListNewSales", translate('LNL_NEW_RAPORT','EcmSales'),"EcmSales", 'EcmSales');
//if(ACLController::checkAccess('EcmSales', "list", true)) $module_menu [] = Array("index.php?module=EcmSales&action=bimit_importAllegroOrders", "Importuj zamówienia Allegro","EcmSales", 'EcmSales');
$module_menu [] = Array("index.php?module=EcmSales&action=eCommerceZS", "Utwórz ZS E-Commerce","EcmSales", 'EcmSales');
$module_menu [] = Array("index.php?module=EcmSales&action=bimit_salesSummary", "Analiza zamówień","EcmSales", 'EcmSales');
?>

View File

@@ -0,0 +1,111 @@
<?php
class ModuleFieldsParser
{
var $modules;
var $name;
function ModuleFieldsParser($name = 'mfp')
{
$this->modules = Array();
if (file_exists('modules/EcmSales/ModuleFieldsParser/config.php')) {
require_once('modules/EcmSales/ModuleFieldsParser/config.php');
$this->modules = $mfp_modules;
}
$this->name = $name;
}
function getModulesSelectOptions($fieldRealNames = false)
{
global $app_list_strings;
$arr = array();
if (count($this->modules) > 0) {
foreach ($this->modules as $key => $value) {
if (isset($value['name']) && $value['name'] != '')
if (isset($app_list_strings['moduleList'][$value['name']]) && $app_list_strings['moduleList'][$value['name']] != '')
$value['name'] = $app_list_strings['moduleList'][$value['name']];
$arr[$key]['name'] = $value['name'];
$arr[$key]['fields'] = $this->getModuleFieldsSelectOptions($key, $fieldRealNames);
}
}
return $arr;
}
function getModuleFieldsSelectOptions($module, $fieldRealNames = false)
{
global $beanList, $current_language, $GLOBALS;
$dict = null;
$file = 'cache/modules/' . $module . '/' . $beanList[$module] . 'vardefs.php';
if (file_exists($file)) {
include($file);
$dict = $GLOBALS['dictionary'][$beanList[$module]]['fields'];
} else {
$file = 'modules/' . $module . '/vardefs.php';
if (file_exists($file)) {
include($file);
$dict = $dictionary[$beanList[$module]]['fields'];
}
}
if ($dict) {
$mod = return_module_language($current_language, $module);
$arr = array();
foreach ($dict as $key => $value) {
$tmp = '$' . $this->modules[$module]['prefix'] . $value['name'];
if (!$fieldRealNames)
$arr[$tmp] = ((isset($mod[$value['vname']]) && $mod[$value['vname']] != '') ? $mod[$value['vname']] : $value['name']);
else
$arr[$tmp] = $value['name'];
}
return $arr;
}
return array();
}
function getJS()
{
$json = getJSONobj();
$js = '<script language="javascript">';
$js .= 'var ' . $this->name . '_data = ' . $json->encode($this->getModulesSelectOptions()) . ';';
$js .= 'function ' . $this->name . '_loadModules() { var ms = document.getElementById("' . $this->name . '_module"); for(x in ' . $this->name . '_data) { ms.options[ms.options.length] = new Option(' . $this->name . '_data[x]["name"],x,false); }; }';
$js .= 'function ' . $this->name . '_loadFields() { var ms = document.getElementById("' . $this->name . '_module"); var fs = document.getElementById("' . $this->name . '_fields"); while(fs.options.length>0) fs.remove(0); var fields = ' . $this->name . '_data[ms.value]["fields"]; for(x in fields) fs.options[fs.options.length] = new Option(fields[x],x,false); fs.onchange(); };';
$js .= 'function ' . $this->name . '_loadField() { var fs = document.getElementById("' . $this->name . '_fields"); var fe = document.getElementById("' . $this->name . '_field"); fe.value = fs.value; };';
$js .= $this->name . '_loadModules(); ' . $this->name . '_loadFields(); ' . $this->name . '_loadField();';
$js .= '</script>';
return $js;
}
function getFormHTML($smarty = false, $name = '')
{
if ($name != '')
$this->name = $name;
$html = '
<span>
<select id="' . $this->name . '_module" name="' . $this->name . '_module" onChange="' . $this->name . '_loadFields();"></select>&nbsp;
<select id="' . $this->name . '_fields" name="' . $this->name . '_fields" onChange="' . $this->name . '_loadField()"></select>&nbsp;
<input id="' . $this->name . '_field" name="' . $this->name . '_field" value="" size="40">' . ($smarty ? '{literal}' : '') . $this->getJS() . ($smarty ? '{/literal}' : '') . '</span>';
return $html;
}
function fillFocusToModules()
{
foreach ($this->modules as $key => $value) {
if ((!isset($value['focus']) || $value['focus'] == '') && (isset($value['id']) && $value['id'] != '')) {
global $beanFiles, $beanList;
$path = $beanFiles[$beanList[$key]];
if (file_exists($path)) {
require_once($path);
$this->modules[$key]['focus'] = new $beanList[$key]();
$this->modules[$key]['focus']->format_all_fields();
}
}
}
}
function parseText($text)
{
$this->fillFocusToModules();
$temp = $this->getModulesSelectOptions(true);
foreach ($this->modules as $module => $arr) {
if (isset($arr['focus']) && $arr['focus'] != '') {
foreach ($temp[$module]['fields'] as $field => $value) {
//$text = str_replace($field,((isset($this->modules[$module]['focus']->$value) && $this->modules[$module]['focus']->$value != '')?$this->modules[$module]['focus']->$value:''),$text);
}
}
}
return $text;
}
}
;
?>

View File

@@ -0,0 +1,75 @@
<?php
global $app_list_strings;
$mfp_modules = Array(
'EcmSales' => array(
'name' => $app_list_strings['moduleList']['EcmSales'],
'prefix' => 'off_',
'id' => '',
'focus' => ''
),
'EcmDocumentTemplates' => array(
'name' => $app_list_strings['moduleList']['EcmDocumentTemplates'],
'prefix' => 'dt_',
'id' => '',
'focus' => ''
),
'Accounts' => array(
'name' => $app_list_strings['moduleList']['Accounts'],
'prefix' => 'acc_',
'id' => '',
'focus' => ''
),
'Contacts' => array(
'name' => $app_list_strings['moduleList']['Contacts'],
'prefix' => 'con_',
'id' => '',
'focus' => ''
),
'Users' => array(
'name' => $app_list_strings['moduleList']['Users'],
'prefix' => 'us_',
'id' => '',
'focus' => ''
),
);
?>

View File

@@ -0,0 +1,419 @@
<?php
$w = "35"; // first column width
$w3 = "35";
$w2 = "20"; // second column width
if($_REQUEST['pdf_type']==1){
$content='<p style="text-align: center;font-size: 12pt;"><b>'.$labels['LBL_PDF_CONTENT_NAME'].' '.$focus->document_no.'</b></center>';
} else if($_REQUEST['pdf_type']==0){
$content='<p style="text-align: center;font-size: 12pt;"><b>Proforma nr '.$focus->document_no.'</b></center>';
} else if($_REQUEST['pdf_type']==2){
$content='<p style="text-align: center;font-size: 12pt;"><b>Oferta nr '.$focus->document_no.'</b></center>';
}
$content.= '
<table style="width: 100%; font-size: 8pt;">
<tr>
<td style="width: ' . $w . '%">
<b>ZAMAWIAJĄCY</b>
</td>
<td style="width: ' . $w3 . '%">';
if($focus->shipping_address_name!=''){
$content.= '<b>'.$labels['LBL_PDF_CONTENT_DELIVERY'].'</b>';
}
$content.= '</td>
<td style="width: ' . $w2 . '%">
</td>
<td style="text-align: right">
</td>
</tr>
<tr>
<td style="width: ' . $w . '%">
' . $focus->parent_name . '
</td>
<td style="width: ' . $w3 . '%">
'.$focus->shipping_address_name.'
</td>
<td style="width: ' . $w2 . '%">
</td>
<td style="text-align: right">
</td>
</tr>
<tr>
<td style="width: ' . $w . '%">
' . $focus->parent_address_street . '
</td>
<td style="width: ' . $w3 . '%">
' . $focus->shipping_address_street . '
</td>
<td style="width: ' . $w2 . '%"></td>
<td style="text-align: right">
</td>
</tr>
<tr>
<td style="width: ' . $w . '%">
'. $focus->parent_address_postalcode . ' ' . $focus->parent_address_city;
if (!is_null($focus->parent_address_country) & $focus->parent_address_country!='')
$content.=', '.$focus->parent_address_country;
$content.='
</td>
<td style="width: ' . $w3 . '%">
'. $focus->shipping_address_postalcode . ' ' . $focus->shipping_address_city;
if (!is_null($focus->shipping_address_country) & $focus->shipping_address_country!='')
$content.=', '.$focus->shipping_address_country;
$content.='
</td>
<td style="width: ' . $w2 . '%">
</td>
<td style="text-align: right">
</td>
</tr>';
$content.='
<tr>
<td valign="top" style="width: ' . $w . '%">';
if (!is_null($focus->parent_nip) && $focus->parent_nip) {
$content.=$labels['LBL_PDF_CONTENT_NIP'].' '.$focus->parent_nip;
$nip = true;
}
if (!is_null($focus->parent_iln) && $focus->parent_iln) {
if ($nip) $content.'<br>'; $nip = false;
$content.=$labels['LBL_PDF_CONTENT_ILN'].' '.$focus->parent_iln;
}
$content.='
</td>';
$content.='
<td valign="top" style="width: ' . $w3 . '%">';
if (!is_null($focus->shipping_nip) && $focus->shipping_nip) {
$content.=$labels['LBL_PDF_CONTENT_NIP'].' '.$focus->shipping_nip;
$nip = true;
}
if (!is_null($focus->shipping_iln) && $focus->shipping_iln) {
if ($nip) $content.'<br>'; $nip = false;
$content.=$labels['LBL_PDF_CONTENT_ILN'].' '.$focus->shipping_iln;
}
$content.='
</td>
<td valign="top" style="width: ' . $w2 . '%"></td>
<td colspan="0" valign="top" style="text-align: right">
</td>
</tr>';
$content.='
</table><br>
';
if ($focus->name && $focus->name != '') {
$content .= '
<table style="width: 100%; text-align: center">
<tr><td>
<b>' . $focus->name . '</b>
</td></tr>
</table>
';
}
if($_REQUEST['pdf_type']==1){
$labels['LBL_PDF_CONTENT_DELIVERY_DATE']='<br>'.$labels['LBL_PDF_CONTENT_DELIVERY_DATE'];
$focus->delivery_date='<br><b>' . $focus->delivery_date . '</b>';
$width='44';
} else {
$labels['LBL_PDF_CONTENT_DELIVERY_DATE']='';
$focus->delivery_date='';
$width='12';
}
$content .= '<br><table width="100%" style="font-size: 7pt;text-align:right;vertical-align:top;">
<tr><td width="'.$width.'%" >'.$labels['LBL_PDF_CONTENT_REGISTER_DATE'].''.$labels['LBL_PDF_CONTENT_DELIVERY_DATE'].'</td>
<td style="text-align: left;" width="20%"><b>' . $focus->register_date . '</b>' . $focus->delivery_date . '</td>
<td rowspan="2" style="text-align: left;vertical-align:top;">';
if($focus->parent_document_no!=''){
$content .=$labels['LBL_PDF_CONTENT_PARENT_DOCUMENT_NO'].'<br>';
}
$content.='</td>
<td rowspan="2" style="vertical-align:top;">';
if($focus->parent_document_no!=''){
$content .='<b>' . $focus->parent_document_no.'</b><br>';
}
$content.='</td></tr></table>';
$content .= '<br>';
// start items table
$columns = array ();
$columns ['position'] = array (
'field' => array (
'position'
),
'label' => $labels['LBL_PDF_CONTENT_LIST_POSITION'],
'align' => 'center'
);
if ($_REQUEST['show_img']=='1') {
$columns ['image'] = array (
'field' => array (
'image'
),
'label' => $labels['LBL_PDF_CONTENT_LIST_IMAGE'],
'align' => 'center'
);
}
$columns ['name'] = array (
'field' => array (
'name',
'product_code'
),
'label' => $labels['LBL_PDF_CONTENT_LIST_NAME'].'<br>'.$labels['LBL_PDF_CONTENT_LIST_CODE'],
'align' => 'left'
);
if ($_REQUEST ['show_ean'] == '1' || $_REQUEST ['show_ean2'] == '1' || $_REQUEST ['show_recipient_code'] == '1') {
$columns ['codes'] = array (
'align' => 'center'
);
$columns ['codes'] ['label'] = '';
if ($_REQUEST ['show_ean']) {
$columns ['codes'] ['label'] .= $labels['LBL_PDF_CONTENT_LIST_EAN'].'<br>';
$columns ['codes'] ['field'] [] = 'ean';
}
if ($_REQUEST ['show_ean2']) {
$columns ['codes'] ['label'] .= $labels['LBL_PDF_CONTENT_LIST_EAN2'].'<br>';
$columns ['codes'] ['field'] [] = 'ean2';
}
if ($_REQUEST ['show_recipient_code']) {
$columns ['codes'] ['label'] .= $labels['LBL_PDF_CONTENT_LIST_RECIPIENT_CODE'];
$columns ['codes'] ['field'] [] = 'recipient_code';
}
$codes = true;
}
$columns ['qty'] = array (
'field' => array (
'quantity',
'unit_name'
),
'label' => $labels['LBL_PDF_CONTENT_LIST_QTY'].'<br>'.$labels['LBL_PDF_CONTENT_LIST_UNIT'],
'align' => 'right'
);
if ($_REQUEST['discount_show']==1) {
$columns ['price_start'] = array (
'field' => array (
'price_start'
),
'label' => $labels['LBL_PDF_CONTENT_LIST_PRICE_START'],
'align' => 'right'
);
$columns ['discount'] = array (
'field' => array (
'discount'
),
'label' => $labels['LBL_PDF_CONTENT_LIST_DISCOUNT'],
'align' => 'right'
);
$columns ['price_netto'] = array (
'field' => array (
'price_netto'
),
'label' => $labels['LBL_PDF_CONTENT_LIST_PRICE_NETTO'],
'align' => 'right'
);
$discounts = true;
} else
$columns ['price_netto'] = array (
'field' => array (
'price_netto'
),
'label' => $labels['LBL_PDF_CONTENT_LIST_PRICE_NETTO'],
'align' => 'right'
);
$columns ['total_netto'] = array (
'field' => array (
'total_netto'
),
'label' => $labels['LBL_PDF_CONTENT_LIST_TOTAL_NETTO'],
'align' => 'right'
);
//set widths
$totals = array();
//1: no picture, no codes, no discounts
if ($_REQUEST['show_img']=='0' && $codes==false && $discounts==false) {
$columns['position']['width'] = '5';
$columns['name']['width'] = '45';
$columns['qty']['width'] = '10';
$columns['price_netto']['width'] = '20';
$columns['total_netto']['width'] = '20';
}
//2: no picture, codes, no discounts
else if ($_REQUEST['show_img']=='0' && $codes==true && $discounts==false) {
$columns['position']['width'] = '5';
$columns['name']['width'] = '40';
$columns['codes']['width'] = '15';
$columns['qty']['width'] = '10';
$columns['price_netto']['width'] = '15';
$columns['total_netto']['width'] = '15';
}
//3: no picture, no codes, discounts
else if ($_REQUEST['show_img']=='0' && $codes==false && $discounts==true) {
$columns['position']['width'] = '5';
$columns['name']['width'] = '40';
$columns['qty']['width'] = '10';
$columns['price_netto']['width'] = '12.5';
$columns['price_start']['width'] = '12.5';
$columns['discount']['width'] = '12.5';
$columns['total_netto']['width'] = '12.5';
}
//4: no picture, codes, discounts
else if ($_REQUEST['show_img']=='0' && $codes==true && $discounts==true) {
$columns['position']['width'] = '5';
$columns['name']['width'] = '30';
$columns['codes']['width'] = '15';
$columns['qty']['width'] = '7';
$columns['price_netto']['width'] = '8';
$columns['price_start']['width'] = '10';
$columns['discount']['width'] = '10';
$columns['total_netto']['width'] = '10';
}
//5: picture, no codes, no discounts
else if ($_REQUEST['show_img']=='1' && $codes==false && $discounts==false) {
$columns['position']['width'] = '5';
$columns['name']['width'] = '45';
$columns['image']['width'] = '20';
$columns['qty']['width'] = '10';
$columns['price_netto']['width'] = '10';
$columns['total_netto']['width'] = '10';
}
//6: picture, codes, no discounts
else if ($_REQUEST['show_img']=='1' && $codes==true && $discounts==false) {
$columns['position']['width'] = '5';
$columns['name']['width'] = '35';
$columns['codes']['width'] = '15';
$columns['image']['width'] = '15';
$columns['qty']['width'] = '10';
$columns['price_netto']['width'] = '10';
$columns['total_netto']['width'] = '10';
}
//7: pictures, codes, discounts
else if ($_REQUEST['show_img']=='1' && $codes==true && $discounts==true) {
$columns['position']['width'] = '5';
$columns['name']['width'] = '35';
$columns['codes']['width'] = '15';
$columns['image']['width'] = '15';
$columns['qty']['width'] = '10';
$columns['price_start']['width'] = '10';
$columns['discount']['width'] = '10';
$columns['price_netto']['width'] = '10';
$columns['total_netto']['width'] = '10';
}
// rysujemy :)
$content .= '
<table style="width: 100%; font-size: 7pt; border: 0.5 solid black; border-collapse: collapse"><thead>
<tr>
';
foreach ( $columns as $col ) {
$content .= '
<th style="border: 0.5 solid black; background: rgb(233,233,233); width: '.$col['width'].'%;">' . $col ['label'] . '</th>
';
}
$content .= '
</tr></thead><tbody>
';
foreach ( $positions as $pos ) {
$content .= '<tr>';
foreach ( $columns as $col ) {
$content .= '<td style="border: 0.5 solid black; text-align: ' . $col ['align'] . ';">';
foreach ( $col ['field'] as $f ) {
if ($f == 'image') {
$content.='<img width="40px" src="modules/EcmProducts/upload/images/'.$pos['image'].'"/>';
} else {
if (!$pos[$f] || $pos[$f]=='') $pos[$f]='-';
$content .= $pos [$f] . '<br>';
}
}
$content .= '</td>';
}
$content .= '</tr>';
}
$content .= '
</tbody></table>
';
//summary table
//get currency symbol
$c = new Currency();
$c->retrieve($focus->currency_id);
$symbol = $c->symbol;
unset($c);
$content.='
<br><br>
<table style="font-size: 9pt; border: 0.5 solid black; border-collapse: collapse; width: 350px; margin-left: 60%">
';
$content.='
<tr>
<td style="background: rgb(233,233,233); border: 0.5 solid black; width: 50%;">
'.$labels['LBL_PDF_CONTENT_TOTAL_NETTO'].'
</td>
<td style="border: 0.5 solid black; text-align: right;">
'.format_number($focus->total_netto).' '.$symbol.'
</td>
</tr>
';
if ($focus->no_tax=='0') {
$vats = explode(",", $focus->vats_summary);
foreach ($vats as $v) {
$vats2 = explode(":", $v);
if ($vats2[0]=='') continue;
$content.='
<tr>
<td style="background: rgb(233,233,233); border: 0.5 solid black; width: 50%;">
'.$vats2[0].'
</td>
<td style="border: 0.5 solid black; text-align: right;">
'.format_number($vats2[1]).' '.$symbol.'
</td>
</tr>
';
}
$content.='
<tr>
<td style="background: rgb(233,233,233); border: 0.5 solid black; width: 50%;">
'.$labels['LBL_PDF_CONTENT_TOTAL_BRUTTO'].'
</td>
<td style="border: 0.5 solid black; text-align: right;font-size: 8pt;">
<b>'.format_number($focus->total_brutto).' '.$symbol.'</b>
</td>
</tr>
';
}
$content.='
</table><br><p style="font-size: 7pt;">'.$labels['LBL_PDF_CONTENT_ISSUED_BY'].' <b>'.$user->full_name.'</b></p>
<br><br>
'.$focus->pdf_text.'
';
//echo $content; die();

View File

@@ -0,0 +1,85 @@
<?php
$w = "62"; //first column width
$w2 = "12"; //second column width
$footer = '
<hr>
<table style="width: 100%; font-size: 7pt;">
<tr>
<td style="width: '.$w.'%">
e5 Polska Sp. z o.o
</td>
<td style="width: '.$w2.'%">
<b>'.$labels['LBL_PDF_FOOTER_KRS'].'</b>
</td>
<td style="text-align: right">
28207
</td>
</tr>
<tr>
<td style="width: '.$w.'%">
ul. Wąwozowa 11
</td>
<td style="width: '.$w2.'%">
<b>'.$labels['LBL_PDF_FOOTER_NIP'].'</b>
</td>
<td style="text-align: right">
PL 525-21-73-990
</td>
</tr>
<tr>
<td style="width: '.$w.'%">
02-796 Warszawa
</td>
<td style="width: '.$w2.'%">
<b>'.$labels['LBL_PDF_FOOTER_REGON'].'</b>
</td>
<td style="text-align: right">
016280234
</td>
</tr>
<tr>
<td style="width: '.$w.'%">
Tel: +48 (22) 228 20 90
</td>
<td style="width: '.$w2.'%">
<b>'.$labels['LBL_PDF_FOOTER_BANK'].'</b>
</td>
<td style="text-align: right">
MILLENIUM
</td>
</tr>
<tr>
<td style="width: '.$w.'%">
Fax: +48 (56) 674 60 47
</td>
<td style="width: '.$w2.'%">
<b>'.$labels['LBL_PDF_FOOTER_BANK_ACCOUNT'].'</b>
</td>
<td style="text-align: right">
PL361160220200000000640080587
</td>
</tr>
<tr>
<td style="width: '.$w.'%">
'.$user->email1.'
</td>
<td style="width: '.$w2.'%">
<b>'.$labels['LBL_PDF_FOOTER_SWIFT'].'</b>
</td>
<td style="text-align: right">
BIGBPPLPW
</td>
</tr>
</table>
<br>
<table style="width: 100%; font-size: 7pt;">
<tr>
<td style="width: 50%;">
{PAGENO}/{nb}
</td>
<td style="width: 50%; text-align: right">
<b>'.$focus->document_no.'</b>
</td>
</tr>
</table>
';

View File

@@ -0,0 +1,2 @@
<?php
$footer = getFooterForModule('EcmSales');

View File

@@ -0,0 +1,18 @@
<?php
$header = '
<table style="font-size: 8pt; width: 100%"><tr>
<td width="15%">
<img style="width: 70px;" src="modules/EcmSales/PDFTemplate/saas.jpg"/>
</td>
<td width="45%" style="text-align: left; vertical-align: top;">
<b>DOSTAWCA</b><br />
Saas SystemS Sp. z o.o.<br />
ul. Lipnowska 21-23<br />
87-100 Toruń<br />
NIP: 9562307719
</td>
<td style="text-align: left; vertical-align: top;">
</td>
</tr></table>
<hr>
';

View File

@@ -0,0 +1,58 @@
<?php
function showDiscount($record) {
$db = $GLOBALS['db'];
$res = $db->fetchByAssoc($db->query("SELECT count(distinct discount) AS c FROM ecmsaleitems WHERE
ecmsale_id='$record'
AND discount!=0"));
if (isset($res['c']) && $res['c']>0)
return true;
else
return false;
}
function formatPDFPositions($positions, $focus) {
$result = array();
foreach ($positions as $pos) {
$pos['position'] = intval($pos['position'])+1;
$p = new EcmProduct();
$p -> retrieve($pos['product_id']);
$pos['ean'] = $p->ean;
$pos['ean2'] = $p->ean2;
$pos['image'] = $p->product_picture;
unset($p);
$c = new Currency();
$c->retrieve($focus->currency_id);
$pos['price_start']=format_number($pos['price_start']).' '.$c->symbol;
$pos['price_netto']=format_number($pos['price_netto']).' '.$c->symbol;
$pos['total_netto']=format_number($pos['total_netto']).' '.$c->symbol;
$pos['quantity']=number_format($pos['quantity'],$pos['unit_precision'],',','.');
unset($c);
/*
if ($focus->ecmlanguage=='en_ussss') {
//get names
$db = $GLOBALS['db'];
$r = $db->fetchByAssoc($db->query("SELECT short_description FROM ecmproduct_language WHERE ecmproduct_id='".$pos['product_id']."' AND language='en'"));
$pos['name'] = $r['short_description'];
$lists = return_app_list_strings_language($focus->ecmlanguage);
$pos['unit_name'] = $lists['ecmproducts_unit_dom'][$pos['unit_id']];
unset($lists);
}
*/
$pos['discount'].='%';
$result[] = $pos;
}
return $result;
}

View File

@@ -0,0 +1,12 @@
<?php
$pdf_types = array(
'0' => 'Proforma',
'1' => 'Zamówienie sprzedaży',
'2' => 'Oferta'
);
$pdf_options = array (
'showImages' => 'Pokaż obrazki',
'showCodes' => 'Pokaż kod produktu'
);
?>

View File

@@ -0,0 +1,124 @@
<?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/EcmInsideOrders/EcmInsideOrder.php');
require_once ('include/time.php');
require_once ('include/json_config.php');
// add jquery
echo '<link rel="stylesheet" type="text/css" href="modules/EcmSales/css/style.css"/>';
echo '<script type="text/javascript"
src="include/jQuery/jquery-lastes.js"></script>';
echo '<script type="text/javascript"
src="include/jQuery/jquery.tablesorter.pager.js"></script>';
echo '<script type="text/javascript"
src="modules/EcmSales/javascript/ProductSummary.js"></script>';
$json_config = new json_config ();
$focus = new EcmSale ();
$db = $GLOBALS ['db'];
$data = array();
$categoryArray=array();
$id_array= explode(",", $_GET['ids']) ;
//var_dump($id_array);
$where="and doc.id IN (";
$count=count($id_array);
$i=0;
foreach($id_array as $value){
$i++;
if($value=='1' || $value=='on')continue;
if($count!=$i)$where.="'".$value."',";
else
$where.="'".$value."'";
}$where.=")";
if($_GET['product_group']=='1')$where.=" and pr.group_ks=1";
if($_GET['product_group']=='2')$where.=" and pr.group_ks=2";
if($_GET['product_group']=='3')$where.=" and pr.group_ks=3";
$query= "SELECT
pr.id,
item.code,
item.name,
ROUND(sum(item.quantity),0) AS quantity,
ROUND(ifnull(x.stock, 0),0) AS stock,
pr.group_ks,
pr.product_category_name,
pr.product_category_id
FROM
ecmsaleitems as item
INNER JOIN
ecmsales as doc ON doc.id=item.ecmsale_id
INNER JOIN
ecmproducts as pr ON pr.id=item.ecmproduct_id
INNER JOIN
(SELECT sum(quantity) as stock ,product_id
FROM
ecmstockstates
GROUP BY product_id) x ON x.product_id=item.ecmproduct_id
WHERE doc.deleted='0' and doc.status!='s10' " . $where;
$query.=" AND NOT EXISTS
(
SELECT NULL
FROM ecmstockdocouts t1
WHERE t1.so_id = doc.id
) GROUP by item.ecmproduct_id
ORDER BY pr.group_ks DESC";
$rows = $db->query ($query);
while($r = $db->fetchByAssoc ( $rows ))
{
$row = array();
$row["id"] = $r["id"];
$row["code"] = $r["code"];
$row["name"] = $r["name"];
$row["quantity"] = $r["quantity"];
$row["stock"] = $r["stock"];
$row["product_category_name"]=$r["product_category_name"];
$row["group_ks"] = $r["group_ks"];
if($r["group_ks"]=='1')$daj='TH';
if($r["group_ks"]=='2')$daj='WG';
if($r["group_ks"]=='3')$daj='S';
$row["group_ks_name"] = $daj;
array_push($row, $r);
$data [] = $row;
$total+=$r['quantity'];
$stock+=$r['stock'];
}
$data['quantity']=$total;
$data['stock']=$stock;
//var_dump($data);
/// sumowanie
//var_dump($data);
$edit->ss = new Sugar_Smarty ();
$edit->module = 'EcmSales';
$edit->ss->assign ( "CREATED_BY_NAME", $focus->created_by_name );
$edit->ss->assign ( "MODIFIED_BY_NAME", $focus->modified_by_name );
$edit->ss->assign ( 'FOCUS', $focus);
$edit->ss->assign ( 'POST', $_POST);
$edit->ss->assign ( 'LINK', $link);
$edit->ss->assign ( 'IDS', $_GET['ids']);
$edit->ss->assign('POSITION_LIST',$data);
$edit->ss->assign ( 'MOD', $mod_strings);
$edit->ss-> display('modules/EcmSales/tpls/ProductSummary.tpl'); //4
// loading view
//echo '<link rel="stylesheet" type="text/css" href="modules/EcmInsideOrders/javascript/helper.css" media="screen" /><div class="loading_panel"></div>';
?>

135
modules/EcmSales/Save.php Executable file
View File

@@ -0,0 +1,135 @@
<?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();
require_once("modules/EcmSales/EcmSale.php");
require_once('include/formbase.php');
$focus = new EcmSale();
if (isset($_POST['record']) && $_POST['record'] != '') {
$focus->retrieve($_POST['record']);
}
$check_notify = FALSE;
foreach ($focus->column_fields as $field) {
if (isset($_POST[$field])) {
$value = $_POST[$field];
$focus->$field = $value;
}
}
foreach ($focus->additional_column_fields as $field) {
if (isset($_POST[$field])) {
$value = $_POST[$field];
$focus->$field = $value;
}
}
$focus->position_list = $json->decode(htmlspecialchars_decode($_POST['position_list']));
$return_id = $focus->save($check_notify);
$focus->ecommerce_invoices = $json->decode(htmlspecialchars_decode($_POST['ecommerce_invoices']));
if (isset($focus->ecommerce_invoices) && count($focus->ecommerce_invoices) > 0) {
$db = $GLOBALS['db'];
$db->query("UPDATE ecommerce_invoices SET ecmsale_id = '$return_id' WHERE id IN ('" . implode("','", $focus->ecommerce_invoices) . "')");
}
header("Location: index.php?action=DetailView&module=EcmSales&record=$return_id");

View File

@@ -0,0 +1,500 @@
<?php
$IMPORT_START_DATE = date('Y-m-dTH:i:s', strtotime("-20 days"));
$LIST_FILTER_DATE = date('Y-m-d H:i:s', strtotime("-7 days"));
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
ini_set('display_errors', 1);
global $sugar_config;
$allegro_config = loadConfiguration();
if (!isset($_GET['ajaxAction'])) {
// load last event_it from allegro_orders table
global $db;
$dbRes = $db->query("SELECT event_id FROM allegro_orders ORDER BY date_entered DESC LIMIT 1");
$lastEventId = $db->fetchByAssoc($dbRes)['event_id'];
$events = loadOrderEvents($allegro_config['token'], $lastEventId);
if (isset($events->error)) {
if (refreshToken($allegro_config['refreshToken'], $allegro_config['basicAuth']) == true) {
$allegro_config = loadConfiguration();
$events = loadOrderEvents($allegro_config['token'], $lastEventId);
} else {
die('Nie udało się odświeżyć tokena');
}
}
$orders = array();
usort($events->events, function ($a, $b) {
return strtotime($b->occurredAt) - strtotime($a->occurredAt);
});
if (count($events->events) > 0) {
global $db;
foreach ($events->events as $event) {
if (date('Y-m-dTH:i:s', strtotime($event->occurredAt)) > $IMPORT_START_DATE) {
$order = loadOrder($event->order->checkoutForm->id, $allegro_config['token']);
$parsedOrder = json_decode($order);
$date = date("Y-m-d H:i:s", strtotime($parsedOrder->updatedAt));
$db->query("INSERT INTO allegro_orders VALUES ('".$event->order->checkoutForm->id."', '".$event->id."', '".$date."', '".base64_encode($order)."')");
}
}
header('Location: index.php?module=EcmSales&action=bimit_importAllegroOrders');
} else {
$dbRes = $db->query("SELECT * FROM allegro_orders WHERE date_entered > '$LIST_FILTER_DATE' ORDER BY date_entered DESC");
$orders = array();
while ($row = $db->fetchByAssoc($dbRes)) {
$order = json_decode(base64_decode(($row['payload'])));
$order->buyer->exists = isAccountExists($order->buyer->email);
$order->exists = isOrderExists($order->id);
if ($order->exists) {
$e5Order = getOrder($order->id);
$order->e5Id = $e5Order['id'];
$order->e5Number = $e5Order['document_no'];
$inv = getInvoice($e5Order['id']);
$order->e5InvoiceId = $inv['id'];
$order->e5InvoiceNumber = $inv['document_no'];
}
if ($order->buyer->exists) {
$client = getClient($order->buyer->email);
$order->buyer->e5Id = $client['id'];
$order->buyer->e5Name = $client['name'];
}
$orders[] = $order;
}
$smarty = new Sugar_Smarty();
$smarty->assign('orders', $orders);
$smarty->display(getcwd() . '/modules/EcmSales/tpls/bimit_importAllegroOrders.tpl');
return;
}
} else {
if ($_GET['ajaxAction'] == 'createOrder') {
$order = loadOrder($_GET['orderId'], $allegro_config['token']);
brecho($order);
$respone = addOrder(json_decode($order));
brecho($respone);
return;
}
if ($_GET['ajaxAction'] == 'sendInvoice') {
die('createInvoice');
}
}
function addOrder($order)
{
$sale = new EcmSale();
$clientId = null;
if (!isAccountExists($order->buyer->email)) {
$clientId = createAccount($order);
} else {
$clientId = getClient($order->buyer->email)['id'];
}
$client = new Account();
$client->retrieve($clientId);
$sale->parent_id = $client->id;
$sale->parent_name = $client->name;
$sale->parent_name_copy = $client->name;
$sale->parent_nip = $client->to_vatid;
$sale->parent_address_street = $client->register_address_street;
$sale->parent_address_city = $client->register_address_city;
$sale->parent_address_postalcode = $client->register_address_postalcode;
$sale->parent_address_country = $client->register_address_country;
$sale->type = 'sales_order';
if (
$order->payment->paidAmount->amount != $order->summary->totalToPay->amount
&& $order->payment->type == 'ONLINE'
) {
$sale->status = 's20';
} else {
$sale->status = 's30';
}
$sale->ecmlanguage = 'pl_pl';
$sale->currency_id = 'PLN';
$sale->pdf_type = 'K';
$sale->order_source = 'allegro';
$sale->order_source_id = $order->id;
global $current_user;
$sale->assigned_user_id = $current_user->id;
$sale->register_date = date("d.m.Y", strtotime($order->updatedAt));
$sale->delivery_date = date("d.m.Y", strtotime($order->delivery->time->to));
$sale->send_date = date("d.m.Y", strtotime($order->delivery->time->dispatch->from));
if ($order->payment->type == 'ONLINE') {
$sale->payment_method = 'PRZEDPLATA';
$sale->payment_date = date("d.m.Y", strtotime($order->payment->finishedAt));
} else {
$sale->payment_method = 'ZA POBRANIEM';
}
if (isset($order->delivery->pickupPoint)) {
$sale->shipping_address_name = $order->delivery->pickupPoint->name . ' (' . $order->delivery->pickupPoint->description . ')';
$sale->shipping_address_street = $order->delivery->pickupPoint->address->street;
$sale->shipping_address_city = $order->delivery->pickupPoint->address->city;
$sale->shipping_address_postalcode = $order->delivery->pickupPoint->address->zipCode;
$sale->shipping_address_country = $order->delivery->pickupPoint->address->countryCode;
$sale->shipping_phone = $sale->shipping_phone = $order->delivery->address->phoneNumber;
} else {
if ($order->delivery->address->companyName) {
$sale->shipping_address_name = $order->delivery->address->companyName . ' ';
}
$sale->shipping_address_name .= $order->delivery->address->firstName . ' ' . $order->delivery->address->lastName;
$sale->shipping_address_street = $order->delivery->address->street;
$sale->shipping_address_city = $order->delivery->address->city;
$sale->shipping_address_postalcode = $order->delivery->address->zipCode;
$sale->shipping_address_country = $order->delivery->address->countryCode;
$sale->shipping_phone = $order->delivery->address->phoneNumber;
}
$sale->pdf_text =
$order->buyer->login
. PHP_EOL
. $order->delivery->method->name
. PHP_EOL
. $order->buyer->email;
$sale->position_list = array();
$counter = 0;
$sumNetto = 0;
foreach ($order->lineItems as $line) {
$productId = getProduct($line->offer->external->id);
$p = new EcmProduct();
$p->retrieve($productId);
$sale->position_list[$counter]['product_id'] = $p->id;
$sale->position_list[$counter]['position'] = $counter;
$sale->position_list[$counter]['product_code'] = $p->code;
$sale->position_list[$counter]['name'] = $p->name;
$sale->position_list[$counter]['discount'] = 0;
$sale->position_list[$counter]['unit_id'] = 1;
$sale->position_list[$counter]['unit_name'] = 'szt.';
$sale->position_list[$counter]['ecmvat_id'] = $p->vat_id;
$sale->position_list[$counter]['ecmvat_name'] = $p->vat_name;
$sale->position_list[$counter]['ecmvat_value'] = $p->vat_value;
$sale->position_list[$counter]['product_ean'] = $p->ean;
$sale->position_list[$counter]['quantity'] = $line->quantity;
$priceBrutto = $line->price->amount;
$priceNetto = round($priceBrutto / (1 + ($p->vat_value / 100)), 2);
$sale->position_list[$counter]['price_start'] = $priceNetto;
$sale->position_list[$counter]['price_netto'] = $priceNetto;
$sale->position_list[$counter]['total_netto'] = $priceNetto * $line->quantity;
$sumNetto += $sale->position_list[$counter]['total_netto'];
$counter++;
}
// delivery
if (floatval($order->delivery->cost->amount) > 0) {
$p = new EcmProduct();
$p->retrieve('165f364e-9301-25ac-5906-58e38f1de4ca');
$sale->position_list[$counter]['product_id'] = $p->id;
$sale->position_list[$counter]['position'] = $counter;
$sale->position_list[$counter]['product_code'] = $p->code;
$sale->position_list[$counter]['name'] = $p->name;
$sale->position_list[$counter]['discount'] = 0;
$sale->position_list[$counter]['unit_id'] = 1;
$sale->position_list[$counter]['unit_name'] = 'szt.';
$sale->position_list[$counter]['ecmvat_id'] = $p->vat_id;
$sale->position_list[$counter]['ecmvat_name'] = $p->vat_name;
$sale->position_list[$counter]['ecmvat_value'] = $p->vat_value;
$sale->position_list[$counter]['product_ean'] = $p->ean;
$sale->position_list[$counter]['quantity'] = 1;
$priceBrutto = $order->delivery->cost->amount;
$priceNetto = round($priceBrutto / (1 + ($p->vat_value / 100)), 2);
$sale->position_list[$counter]['price_start'] = $priceNetto;
$sale->position_list[$counter]['price_netto'] = $priceNetto;
$sale->position_list[$counter]['total_netto'] = $priceNetto;
$sumNetto += $sale->position_list[$counter]['total_netto'];
}
$sale->total_netto = $sumNetto;
$sale->save();
}
function createAccount($order)
{
require_once(getcwd() . "/include/SugarEmailAddress/SugarEmailAddress.php");
global $current_user;
$account = new Account();
$name = '';
if ($order->invoice->required) {
if ($order->invoice->address->company) {
$name = $order->invoice->address->company->name;
} else {
$name = $order->invoice->address->naturalPerson->firstName . ' ' . $order->invoice->address->naturalPerson->lastName;
}
$account->to_vatid = $order->invoice->address->company->taxId;
} else if ($order->buyer->firstName || $order->buyer->lastName) {
$name = $order->buyer->firstName . ' ' . $order->buyer->lastName;
} else {
$name = $order->buyer->email;
}
$account->name = $name;
$account->index_dbf = $name;
$account->description = $order->buyer->login;
$account->phone_office = $order->buyer->phoneNumber;
$account->assigned_user_id = $current_user->id;
$account->isAllegroUser = true;
$account->account_type = 'rec';
if ($order->invoice->required) {
$account->shop_user = 'b2b';
$account->register_address_street = $order->invoice->address->street;
$account->register_address_city = $order->invoice->address->city;
$account->register_address_postalcode = $order->invoice->address->postCode;
$account->register_address_country = $order->invoice->address->countryCode;
$account->billing_address_street = $order->buyer->address->street;
$account->billing_address_city = $order->buyer->address->city;
$account->billing_address_postalcode = $order->buyer->address->postCode;
$account->billing_address_country = $order->buyer->address->countryCode;
} else {
$account->shop_user = 'b2c';
$account->register_address_street = $order->buyer->address->street;
$account->register_address_city = $order->buyer->address->city;
$account->register_address_postalcode = $order->buyer->address->postCode;
$account->register_address_country = $order->buyer->address->countryCode;
}
$account->save();
$email = new SugarEmailAddress();
$email->addAddress($order->buyer->email, true);
$email->save($account->id, "Accounts");
return $account->id;
}
function isOrderExists($allegroOrderId)
{
global $db;
$dbRes = $db->query("SELECT id FROM ecmsales WHERE deleted = 0 AND order_source = 'allegro' AND order_source_id = '" . $allegroOrderId . "'");
if ($db->getRowCount($dbRes) > 0) {
return true;
} else {
return false;
}
}
function getOrder($allegroOrderId)
{
global $db;
$dbRes = $db->query("SELECT id, document_no FROM ecmsales WHERE deleted = 0 AND order_source = 'allegro' AND order_source_id = '" . $allegroOrderId . "'");
return $db->fetchByAssoc($dbRes);
}
function getInvoice($orderId)
{
global $db;
$dbRes = $db->query("SELECT id, document_no FROM ecminvoiceouts WHERE deleted = 0 AND canceled = 0 AND so_id = '" . $orderId . "'");
return $db->fetchByAssoc($dbRes);
}
function getProduct($code)
{
global $db;
$dbRes = $db->query("SELECT id FROM ecmproducts WHERE deleted = 0 AND code = '" . $code . "'");
return $db->fetchByAssoc($dbRes)['id'];
}
function isAccountExists($email)
{
global $db;
$dbRes = $db->query("
SELECT a.id FROM email_addr_bean_rel AS rel
INNER JOIN email_addresses AS e ON e.id = rel.email_address_id
INNER JOIN accounts AS a ON a.id = rel.bean_id
WHERE e.email_address = '" . $email . "' AND a.deleted = 0;
");
if ($db->getRowCount($dbRes) > 0) {
return true;
} else {
return false;
}
}
function getClient($email)
{
global $db;
$dbRes = $db->query("
SELECT a.id, a.name FROM email_addr_bean_rel AS rel
INNER JOIN email_addresses AS e ON e.id = rel.email_address_id
INNER JOIN accounts AS a ON a.id = rel.bean_id
WHERE e.email_address = '" . $email . "' AND a.deleted = 0;
");
return $db->fetchByAssoc($dbRes);
}
function loadOrder($orderId, $token)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token,
'Accept: application/vnd.allegro.public.v1+json',
]);
curl_setopt($curl, CURLOPT_URL, "https://api.allegro.pl/order/checkout-forms/" . $orderId);
return curl_exec($curl);
}
function loadOrderEvents($token, $lastEventId)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token,
'Accept: application/vnd.allegro.public.v1+json',
]);
curl_setopt($curl, CURLOPT_URL, "https://api.allegro.pl/order/events?type=READY_FOR_PROCESSING&limit=500&from=".$lastEventId);
return json_decode(curl_exec($curl));
}
function refreshToken($refreshToken, $baseCredentials)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization: Basic ' . $baseCredentials,
'Accept: application/vnd.allegro.public.v1+json',
]);
curl_setopt($curl, CURLOPT_URL, "https://allegro.pl/auth/oauth/token?grant_type=refresh_token&refresh_token=" . $refreshToken);
$res = json_decode(curl_exec($curl));
if (isset($res->error)) {
return false;
} else {
global $db;
$db->query("UPDATE config SET value='" . $res->access_token . "' WHERE category='allegro' AND name='token'");
$db->query("UPDATE config SET value='" . $res->refresh_token . "' WHERE category='allegro' AND name='refreshToken'");
return true;
}
}
function getToken()
{
}
function registerDevice()
{
}
function loadConfiguration()
{
global $db;
$dbRes = $db->query("SELECT * FROM config WHERE category='allegro'");
$config = [];
while ($row = $db->fetchByAssoc($dbRes)) {
$config[$row['name']] = $row['value'];
}
$config['basicAuth'] = base64_encode($config['clientId'] . ':' . $config['clientSecret']);
return $config;
}
function brecho()
{
$args = func_get_args();
echo '<pre>';
foreach ($args as $arg) {
var_dump($arg);
}
echo '</pre>';
}
function sendInvoiceToAllegro($invoiceId) {
global $db;
$dbRes = $db->query("SELECT * FROM ecminvoiceouts WHERE id='$invoiceId'");
// TODO Create invoice object in allegro
// TODO create iunvoice pdf
// TODO send invoice to allegro
}
function createInvoice($orderId, $document_no, $token) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token,
'Accept: application/vnd.allegro.public.v1+json',
]);
curl_setopt($curl, CURLOPT_URL, "https://api.{environment}/order/checkout-forms/".$orderId."/invoices");
// remove from document_no characters not allowed in filename
$name = preg_replace('/[^A-Za-z0-9\-]/', '', $document_no);
$body = array(
'file' => array(
'name' => $name.'.pdf',
),
'invoiceNumber' => $document_no
);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($body));
//return curl_exec($curl);
}
function getInvoicePdf($invoiceId) {
}
function sendInvoice($orderId, $allegroInvoiceId, $data, $token) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token,
'Accept: application/pdf',
]);
curl_setopt($curl, CURLOPT_URL, "https://api.{environment}/order/checkout-forms/".$orderId."/invoices//".$allegroInvoiceId."/file");
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
//$baseCredentials = base64_encode($sugar_config['allegro_client_id'].':'.$sugar_config['allegro_client_secret']);
/*
$deviceCode = 'nFSFN4KzFGkS8FTLp570WrznYkWTc6Ja';
$userCode = 'dvil0sfl9';
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET' );
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization: Bearer '.$token,
'Accept: application/vnd.allegro.public.v1+json',
]);
curl_setopt($curl, CURLOPT_URL, "https://api.allegro.pl/order/events");
$res = curl_exec($curl);
$ordersRes = json_decode($res);
echo '<pre>';
var_dump($ordersRes);
echo '</pre>';
/*
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST' );
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Basic '.$baseCredentials,
]);
curl_setopt($curl, CURLOPT_URL, "https://allegro.pl/auth/oauth/device?client_id=".$sugar_config['allegro_client_id']);
$res = curl_exec($curl);
$authRes = json_decode($res);
var_dump($authRes);
*/
/*
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST' );
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization: Basic '.$baseCredentials
]);
curl_setopt($curl, CURLOPT_URL, "https://allegro.pl/auth/oauth/token?grant_type=urn:ietf:params:oauth:grant-type:device_code&device_code=".$deviceCode);
$res = curl_exec($curl);
var_dump($res);
*/

View File

@@ -0,0 +1,473 @@
<?php
$IMPORT_START_DATE = date('Y-m-dTH:i:s', strtotime("-20 days"));
$LIST_FILTER_DATE = date('Y-m-d H:i:s', strtotime("-7 days"));
global $sugar_config;
$allegro_config = loadConfiguration();
//registerDevice($allegro_config);
//getToken($allegro_config['basicAuth'], 'vCLvjGIHtkckM8CYj1VFRk5TAfpt5Bl0');
//UPDATE config SET value='eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiIxMTQ4ODUzMTYiLCJzY29wZSI6WyJhbGxlZ3JvOmFwaTpvcmRlcnM6cmVhZCIsImFsbGVncm86YXBpOnNoaXBtZW50czp3cml0ZSIsImFsbGVncm86YXBpOnNoaXBtZW50czpyZWFkIl0sImFsbGVncm9fYXBpIjp0cnVlLCJpc3MiOiJodHRwczovL2FsbGVncm8ucGwiLCJleHAiOjE3MTM4MTE5NzYsImp0aSI6IjIxNmFlYmZkLTFiMTAtNGRiYi05NWJhLThjYTc3NzE4MmUyNCIsImNsaWVudF9pZCI6IjA2OTM1ODMzNmRjMzQ2YzBhODgwMDNiZGE2YmFjN2QxIn0.gv0E_NdSnO-GrfRv01X4YGlEDsGJtv2QvahsgsJU9PDRqSOp2uoZtu5woF0SMkVHZaxPi2HmGvBzRmapIafzIghaB5sJ_kl6ncMUtqyUrWZKrCnsGnVOOtlyMOYSIKf3_VxwI58oS-12G8DoxEnhAgZkJvOYarBmO_7-GokDqLR7KSPuulpvQDsDhuoquMkdfvIn4WD7XmdjhSg-8tZmeDBsLlNLnhOJ06ORydjBEr7OltxqQ8Fz_G8kqfMfqUMsOJ1ljW0t2YKgjQuv9xkeKvVpQyXGsh1qMbn6v34_bsLSAUuCdC_urWtbhnqn83BUH3uH50njj2eas2UrN4CTSg' WHERE category='allegro' AND name='token';
//UPDATE config SET value='eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiIxMTQ4ODUzMTYiLCJzY29wZSI6WyJhbGxlZ3JvOmFwaTpvcmRlcnM6cmVhZCIsImFsbGVncm86YXBpOnNoaXBtZW50czp3cml0ZSIsImFsbGVncm86YXBpOnNoaXBtZW50czpyZWFkIl0sImFsbGVncm9fYXBpIjp0cnVlLCJhdGkiOiIyMTZhZWJmZC0xYjEwLTRkYmItOTViYS04Y2E3NzcxODJlMjQiLCJpc3MiOiJodHRwczovL2FsbGVncm8ucGwiLCJleHAiOjE3MjE1NDQ3NzYsImp0aSI6IjhiYWY1M2YyLTFiYzEtNDYxYi04NTVkLTI4MTJmNDViYjZiMCIsImNsaWVudF9pZCI6IjA2OTM1ODMzNmRjMzQ2YzBhODgwMDNiZGE2YmFjN2QxIn0.WL7kpDygTgIzSeIzZUPk24kW09Jmh3XqIZr-VJYc1_WreXjmGyKqRYzs36OJnSfp2mj5EkNxreyCe5XWmAg2SpMNF1YLqFo7DGBmutp5Zj9Yjjc-xfkz68pzhIP0Otb0-qvreKZfMPAg9oe1XLvW7F0x6Kcwvp0qk-5Rr6EsPR0VHVqYwNys2mSV2dkpCSamUJ7fqB12gAMLQ_pYwQLfveyoMgPyLx1ETq5F75231IbZYdXHOcdpPbqM9EuU5misqn0pC2-b3sfNhbI73lHmWXaJXdZ_3NDwDW_jSuqaMfEpkb60RQXwc7jTacSOsSettnw7dEOic2Q7d4vvFD7hFg' WHERE category='allegro' AND name='refreshToken';
//die();
$db = $GLOBALS['db'];
$dbRes = $db->query("SELECT event_id FROM allegro_orders ORDER BY date_entered DESC LIMIT 1");
$lastEventId = $db->fetchByAssoc($dbRes)['event_id'];
$events = loadOrderEvents($allegro_config['token'], $lastEventId);
if (isset($events->error)) {
if (refreshToken($allegro_config['refreshToken'], $allegro_config['basicAuth']) == true) {
$allegro_config = loadConfiguration();
$events = loadOrderEvents($allegro_config['token'], $lastEventId);
} else {
sendEmail('Nie udało się odświeżyć tokena. Skontaktuj się z Michałem Zielińskim');
die('Nie udało się odświeżyć tokena');
}
}
usort($events->events, function ($a, $b) {
return strtotime($b->occurredAt) - strtotime($a->occurredAt);
});
if (count($events->events) > 0) {
global $db;
foreach ($events->events as $event) {
if (date('Y-m-dTH:i:s', strtotime($event->occurredAt)) > $IMPORT_START_DATE) {
$order = loadOrder($event->order->checkoutForm->id, $allegro_config['token']);
$parsedOrder = json_decode($order);
$date = date("Y-m-d H:i:s", strtotime($parsedOrder->updatedAt));
$db->query("INSERT INTO allegro_orders VALUES ('".$event->order->checkoutForm->id."', '".$event->id."', '".$date."', '".base64_encode($order)."')");
}
}
}
$dbRes = $db->query("SELECT * FROM allegro_orders WHERE date_entered > '$LIST_FILTER_DATE' ORDER BY date_entered ASC");
$message = "";
while ($row = $db->fetchByAssoc($dbRes)) {
$order = json_decode(base64_decode(($row['payload'])));
$order->exists = isOrderExists($order->id);
if (!$order->exists) {
$order = loadOrder($order->id, $allegro_config['token']);
$sale = addOrder(json_decode($order));
$message .= "Dodano zamówienie Allegro <a href=\"https://crm.twinpol.com/index.php?module=EcmSales&action=DetailView&record=".$sale->id."\">ZS ".$sale->document_no."</a> <br><br>";
}
}
if (strlen($message)) {
sendEmail($message);
}
return;
function sendEmail($message) {
$mail = new PHPMailer2(true);
$mail->isSMTP();
$mail->setFrom('system@e5.pl', 'Twinpol CRM - usługa importu Allegro');
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'system@e5.pl';
$mail->Password = 'wqiz ekxn lysj zheu';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->CharSet = 'UTF-8';
$mail->addAddress('mz@bim-it.pl', 'Michał Zieliński');
$mail->addAddress('info@twinpol.com', 'Info');
$mail->isHTML(true);
$mail->Subject = "Import zamówienia Allegro";
$mail->Body = $message;
$mail->send();
}
function addOrder($order)
{
$sale = new EcmSale();
$clientId = null;
if (!isAccountExists($order->buyer->email)) {
$clientId = createAccount($order);
} else {
$clientId = getClient($order->buyer->email)['id'];
}
$client = new Account();
$client->retrieve($clientId);
$sale->parent_id = $client->id;
$sale->parent_name = $client->name;
$sale->parent_name_copy = $client->name;
$sale->parent_nip = $client->to_vatid;
$sale->parent_address_street = $client->register_address_street;
$sale->parent_address_city = $client->register_address_city;
$sale->parent_address_postalcode = $client->register_address_postalcode;
$sale->parent_address_country = $client->register_address_country;
$sale->type = 'sales_order';
if (
$order->payment->paidAmount->amount != $order->summary->totalToPay->amount
&& $order->payment->type == 'ONLINE'
) {
$sale->status = 's20';
} else {
$sale->status = 's30';
}
$sale->ecmlanguage = 'pl_pl';
$sale->currency_id = 'PLN';
$sale->pdf_type = 'K';
$sale->order_source = 'allegro';
$sale->order_source_id = $order->id;
$sale->assigned_user_id = '1';
//add mz@bim-it.pl
// change stock to allegro
$sale->stock_id = 'cf16804e-f698-5e09-2da3-6553588446ae';
$sale->register_date = date("d.m.Y", strtotime($order->updatedAt));
$sale->delivery_date = date("d.m.Y", strtotime($order->delivery->time->to));
$sale->send_date = date("d.m.Y", strtotime($order->delivery->time->dispatch->from));
if ($order->payment->type == 'ONLINE') {
$sale->payment_method = 'PRZEDPLATA';
$sale->payment_date = date("d.m.Y", strtotime($order->payment->finishedAt));
} else {
$sale->payment_method = 'ZA POBRANIEM';
}
if (isset($order->delivery->pickupPoint)) {
$sale->shipping_address_name = $order->delivery->pickupPoint->name . ' (' . $order->delivery->pickupPoint->description . ')';
$sale->shipping_address_street = $order->delivery->pickupPoint->address->street;
$sale->shipping_address_city = $order->delivery->pickupPoint->address->city;
$sale->shipping_address_postalcode = $order->delivery->pickupPoint->address->zipCode;
$sale->shipping_address_country = $order->delivery->pickupPoint->address->countryCode;
$sale->shipping_phone = $sale->shipping_phone = $order->delivery->address->phoneNumber;
} else {
if ($order->delivery->address->companyName) {
$sale->shipping_address_name = $order->delivery->address->companyName . ' ';
}
$sale->shipping_address_name .= $order->delivery->address->firstName . ' ' . $order->delivery->address->lastName;
$sale->shipping_address_street = $order->delivery->address->street;
$sale->shipping_address_city = $order->delivery->address->city;
$sale->shipping_address_postalcode = $order->delivery->address->zipCode;
$sale->shipping_address_country = $order->delivery->address->countryCode;
$sale->shipping_phone = $order->delivery->address->phoneNumber;
}
$sale->pdf_text =
$order->buyer->login
. PHP_EOL
. $order->delivery->method->name
. PHP_EOL
. $order->buyer->email;
$sale->position_list = array();
$counter = 0;
$sumNetto = 0;
foreach ($order->lineItems as $line) {
$productId = getProduct($line->offer->external->id);
$p = new EcmProduct();
$p->retrieve($productId);
$sale->position_list[$counter]['product_id'] = $p->id;
$sale->position_list[$counter]['position'] = $counter;
$sale->position_list[$counter]['product_code'] = $p->code;
$sale->position_list[$counter]['name'] = $p->name;
$sale->position_list[$counter]['discount'] = 0;
$sale->position_list[$counter]['unit_id'] = 1;
$sale->position_list[$counter]['unit_name'] = 'szt.';
$sale->position_list[$counter]['ecmvat_id'] = $p->vat_id;
$sale->position_list[$counter]['ecmvat_name'] = $p->vat_name;
$sale->position_list[$counter]['ecmvat_value'] = $p->vat_value;
$sale->position_list[$counter]['product_ean'] = $p->ean;
$sale->position_list[$counter]['quantity'] = $line->quantity;
$priceBrutto = $line->price->amount;
$priceNetto = round($priceBrutto / (1 + ($p->vat_value / 100)), 2);
$sale->position_list[$counter]['price_start'] = $priceNetto;
$sale->position_list[$counter]['price_netto'] = $priceNetto;
$sale->position_list[$counter]['total_netto'] = $priceNetto * $line->quantity;
$sumNetto += $sale->position_list[$counter]['total_netto'];
$counter++;
}
// delivery
if (floatval($order->delivery->cost->amount) > 0) {
$p = new EcmProduct();
$p->retrieve('165f364e-9301-25ac-5906-58e38f1de4ca');
$sale->position_list[$counter]['product_id'] = $p->id;
$sale->position_list[$counter]['position'] = $counter;
$sale->position_list[$counter]['product_code'] = $p->code;
$sale->position_list[$counter]['name'] = $p->name;
$sale->position_list[$counter]['discount'] = 0;
$sale->position_list[$counter]['unit_id'] = 1;
$sale->position_list[$counter]['unit_name'] = 'szt.';
$sale->position_list[$counter]['ecmvat_id'] = $p->vat_id;
$sale->position_list[$counter]['ecmvat_name'] = $p->vat_name;
$sale->position_list[$counter]['ecmvat_value'] = $p->vat_value;
$sale->position_list[$counter]['product_ean'] = $p->ean;
$sale->position_list[$counter]['quantity'] = 1;
$priceBrutto = $order->delivery->cost->amount;
$priceNetto = round($priceBrutto / (1 + ($p->vat_value / 100)), 2);
$sale->position_list[$counter]['price_start'] = $priceNetto;
$sale->position_list[$counter]['price_netto'] = $priceNetto;
$sale->position_list[$counter]['total_netto'] = $priceNetto;
$sumNetto += $sale->position_list[$counter]['total_netto'];
}
$sale->total_netto = $sumNetto;
$sale->save();
return $sale;
}
function createAccount($order)
{
require_once(getcwd() . "/include/SugarEmailAddress/SugarEmailAddress.php");
$account = new Account();
$name = '';
if ($order->invoice->required) {
if ($order->invoice->address->company) {
$name = $order->invoice->address->company->name;
} else {
$name = $order->invoice->address->naturalPerson->firstName . ' ' . $order->invoice->address->naturalPerson->lastName;
}
$account->to_vatid = $order->invoice->address->company->taxId;
} else if ($order->buyer->firstName || $order->buyer->lastName) {
$name = $order->buyer->firstName . ' ' . $order->buyer->lastName;
} else {
$name = $order->buyer->email;
}
$account->name = $name;
$account->index_dbf = $name;
$account->description = $order->buyer->login;
$account->phone_office = $order->buyer->phoneNumber;
$account->assigned_user_id = '1';
$account->isAllegroUser = true;
$account->account_type = 'rec';
$account->invoice_type = 'K';
if ($order->invoice->required) {
$account->shop_user = 'b2b';
$account->register_address_street = $order->invoice->address->street;
$account->register_address_city = $order->invoice->address->city;
$account->register_address_postalcode = $order->invoice->address->postCode;
$account->register_address_country = $order->invoice->address->countryCode;
$account->billing_address_street = $order->buyer->address->street;
$account->billing_address_city = $order->buyer->address->city;
$account->billing_address_postalcode = $order->buyer->address->postCode;
$account->billing_address_country = $order->buyer->address->countryCode;
} else {
$account->shop_user = 'b2c';
$account->register_address_street = $order->buyer->address->street;
$account->register_address_city = $order->buyer->address->city;
$account->register_address_postalcode = $order->buyer->address->postCode;
$account->register_address_country = $order->buyer->address->countryCode;
}
$account->save();
$email = new SugarEmailAddress();
$email->addAddress($order->buyer->email, true);
$email->save($account->id, "Accounts");
return $account->id;
}
function isOrderExists($allegroOrderId)
{
global $db;
$dbRes = $db->query("SELECT id FROM ecmsales WHERE deleted = 0 AND order_source = 'allegro' AND order_source_id = '" . $allegroOrderId . "'");
if ($db->getRowCount($dbRes) > 0) {
return true;
} else {
return false;
}
}
function getOrder($allegroOrderId)
{
global $db;
$dbRes = $db->query("SELECT id, document_no FROM ecmsales WHERE deleted = 0 AND order_source = 'allegro' AND order_source_id = '" . $allegroOrderId . "'");
return $db->fetchByAssoc($dbRes);
}
function getInvoice($orderId)
{
global $db;
$dbRes = $db->query("SELECT id, document_no FROM ecminvoiceouts WHERE deleted = 0 AND canceled = 0 AND so_id = '" . $orderId . "'");
return $db->fetchByAssoc($dbRes);
}
function getProduct($code)
{
global $db;
$dbRes = $db->query("SELECT id FROM ecmproducts WHERE deleted = 0 AND code = '" . $code . "'");
return $db->fetchByAssoc($dbRes)['id'];
}
function isAccountExists($email)
{
global $db;
$dbRes = $db->query("
SELECT a.id FROM email_addr_bean_rel AS rel
INNER JOIN email_addresses AS e ON e.id = rel.email_address_id
INNER JOIN accounts AS a ON a.id = rel.bean_id
WHERE e.email_address = '" . $email . "' AND a.deleted = 0;
");
if ($db->getRowCount($dbRes) > 0) {
return true;
} else {
return false;
}
}
function getClient($email)
{
global $db;
$dbRes = $db->query("
SELECT a.id, a.name FROM email_addr_bean_rel AS rel
INNER JOIN email_addresses AS e ON e.id = rel.email_address_id
INNER JOIN accounts AS a ON a.id = rel.bean_id
WHERE e.email_address = '" . $email . "' AND a.deleted = 0;
");
return $db->fetchByAssoc($dbRes);
}
function loadOrder($orderId, $token)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_VERBOSE, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token,
'Accept: application/vnd.allegro.public.v1+json',
]);
curl_setopt($curl, CURLOPT_URL, "https://api.allegro.pl/order/checkout-forms/" . $orderId);
return curl_exec($curl);
}
function loadOrderEvents($token, $lastEventId)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_VERBOSE, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token,
'Accept: application/vnd.allegro.public.v1+json',
]);
curl_setopt($curl, CURLOPT_URL, "https://api.allegro.pl/order/events?type=READY_FOR_PROCESSING&limit=500&from=".$lastEventId);
return json_decode(curl_exec($curl));
}
function refreshToken($refreshToken, $baseCredentials)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_VERBOSE, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization: Basic ' . $baseCredentials,
'Accept: application/vnd.allegro.public.v1+json',
]);
curl_setopt($curl, CURLOPT_URL, "https://allegro.pl/auth/oauth/token?grant_type=refresh_token&refresh_token=" . $refreshToken);
$res = json_decode(curl_exec($curl));
var_dump($res);
if (isset($res->error)) {
return false;
} else {
global $db;
$db->query("UPDATE config SET value='" . $res->access_token . "' WHERE category='allegro' AND name='token'");
$db->query("UPDATE config SET value='" . $res->refresh_token . "' WHERE category='allegro' AND name='refreshToken'");
return true;
}
}
function getToken($baseCredentials, $deviceCode)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST' );
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization: Basic '.$baseCredentials
]);
curl_setopt($curl, CURLOPT_URL, "https://allegro.pl/auth/oauth/token?grant_type=urn:ietf:params:oauth:grant-type:device_code&device_code=".$deviceCode);
$res = json_decode(curl_exec($curl));
var_dump($res);
echo '<br>';
echo 'Access: '.$res->access_token;
echo '<br>';
echo 'Refresh: '.$res->refresh_token;
}
function registerDevice($config)
{
$baseCredentials = $config['basicAuth'];
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST' );
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Basic '.$baseCredentials,
]);
curl_setopt($curl, CURLOPT_URL, "https://allegro.pl/auth/oauth/device?client_id=".$config['clientId']);
$res = curl_exec($curl);
$authRes = json_decode($res);
var_dump($authRes);
}
function loadConfiguration()
{
global $db;
$dbRes = $db->query("SELECT * FROM config WHERE category='allegro'");
$config = [];
while ($row = $db->fetchByAssoc($dbRes)) {
$config[$row['name']] = $row['value'];
}
$config['basicAuth'] = base64_encode($config['clientId'] . ':' . $config['clientSecret']);
return $config;
}
function brecho()
{
$args = func_get_args();
echo '<pre>';
foreach ($args as $arg) {
var_dump($arg);
}
echo '</pre>';
}
function sendInvoiceToAllegro($invoiceId) {
global $db;
$dbRes = $db->query("SELECT * FROM ecminvoiceouts WHERE id='$invoiceId'");
// TODO Create invoice object in allegro
// TODO create iunvoice pdf
// TODO send invoice to allegro
}
function createInvoice($orderId, $document_no, $token) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_VERBOSE, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token,
'Accept: application/vnd.allegro.public.v1+json',
]);
curl_setopt($curl, CURLOPT_URL, "https://api.{environment}/order/checkout-forms/".$orderId."/invoices");
// remove from document_no characters not allowed in filename
$name = preg_replace('/[^A-Za-z0-9\-]/', '', $document_no);
$body = array(
'file' => array(
'name' => $name.'.pdf',
),
'invoiceNumber' => $document_no
);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($body));
//return curl_exec($curl);
}
function getInvoicePdf($invoiceId) {
}
function sendInvoice($orderId, $allegroInvoiceId, $data, $token) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($curl, CURLOPT_VERBOSE, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token,
'Accept: application/pdf',
]);
curl_setopt($curl, CURLOPT_URL, "https://api.{environment}/order/checkout-forms/".$orderId."/invoices//".$allegroInvoiceId."/file");
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}

View File

@@ -0,0 +1,77 @@
<?php
$IMPORT_START_DATE = date('Y-m-dTH:i:s', strtotime("-1 days"));
global $sugar_config;
$baselinker_config = loadConfiguration();
brecho($baselinker_config);
$db = $GLOBALS['db'];
//last imported order
$dbRes = $db->query("SELECT date_entered FROM baselinker_orders ORDER BY date_entered DESC LIMIT 1");
$lastImportDate = strtotime($db->fetchByAssoc($dbRes)['date_entered']);
if ($lastImportDate == null) {
$lastImportDate = strtotime($IMPORT_START_DATE);
}
$ordersRes = loadOrders($baselinker_config['token'], $lastImportDate);
if ($ordersRes->status != 'SUCCESS') {
die('Błąd pobierania.');
}
$orders = $ordersRes->orders;
usort($orders, function ($a, $b) {
return $b->date_confirmed - $a->date_confirmed;
});
if (count($orders) > 0) {
foreach ($orders as $order) {
//brecho($order->order_id);
$parsedOrder = base64_encode(json_encode($order));
$unparsedOrder = json_decode(base64_decode($parsedOrder));
$date = date("Y-m-d H:i:s", $order->date_confirmed);
brecho($order->date_confirmed.' '.$date.' '.$order->order_id);
brecho($order->order_source);
brecho($order->products);
//$db->query("INSERT INTO baselinker_orders VALUES('$order->order_id', '$order->external_order_id', '$order->order_source', '$order->date_add', '$parsedOrder')");
}
}
brecho("Last: ".$lastImportDate.' '.date('Y-m-d H:i:s', $lastImportDate));
echo "Koniec.".PHP_EOL;
function loadConfiguration()
{
global $db;
$dbRes = $db->query("SELECT * FROM config WHERE category='baselinker'");
$config = [];
while ($row = $db->fetchByAssoc($dbRes)) {
$config[$row['name']] = $row['value'];
}
return $config;
}
function loadOrders($token, $lastImportDate) {
$methodParams = '{
"date_confirmed_from": '.$lastImportDate.',
"get_unconfirmed_orders": false
}';
$apiParams = [
"method" => "getOrders",
"parameters" => $methodParams
];
$curl = curl_init("https://api.baselinker.com/connector.php");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, ["X-BLToken: ".$token]);
curl_setopt($curl, CURLOPT_VERBOSE, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($apiParams));
return json_decode(curl_exec($curl));
}
function brecho($msg) {
//echo '<br><pre>';
var_dump($msg);
echo PHP_EOL;
//echo '</pre><br>';
}

View File

@@ -0,0 +1,317 @@
<?php
require_once('modules/EcmSales/EcmSale.php');
require_once 'include/phpMailer2/class.phpmailer.php';
require_once 'include/phpMailer2/class.smtp.php';
$path = "/var/edi/twinpol/orders";
$folders = array('imported', 'temp', 'failed');
$allFiles = scandir($path);
//searchForOrderByNumber('195761101', "/var/edi/twinpol/orders/imported");
//searchForOrderILN('4335347169230', "/var/edi/twinpol/orders/imported");
//getSellerILN("/var/edi/twinpol/orders/imported");
//return;
if (is_array($allFiles)) {
$msg = array();
foreach ($allFiles as $file) {
if (!is_dir($file) && !in_array($file, $folders) && substr($file, -3) == 'xml') {
try {
$msg[] = importSale($path . '/' . $file);
rename($path . '/' . $file, $path . '/imported/' . $file);
} catch (Exception $e) {
echo 'Import error ' . $e->getMessage(), PHP_EOL;
}
}
}
$parents = array();
foreach ($msg as $m) {
$parents[] = $m['parent'];
}
$parents = array_unique($parents);
$orders = array();
foreach ($msg as $m) {
$orders[] = $m['number'];
}
sendEmail($parents, $orders);
echo 'Import finished: ' . $file . PHP_EOL;
return;
}
function importSale($file)
{
$db = $GLOBALS['db'];
$xml = simplexml_load_file($file);
if (!$xml) {
throw new Exception("Can't load (or parse) XML");
}
$sale = new EcmSale();
// AUCHAN
$buyerILN = $xml->{'Order-Parties'}->Buyer->ILN;
if ($xml->{'Order-Parties'}->BuyerHeadquarters->ILN == '5900014000001') {
$buyerILN = $xml->{'Order-Parties'}->BuyerHeadquarters->ILN;
}
$buyer = $db->fetchByAssoc($db->query("
SELECT to_vatid, register_address_street, register_address_city, register_address_postalcode,
register_address_country, id, assigned_user_id, name,parent_id,
supplier_code, ecmpaymentcondition_id, ecmpaymentcondition_name, payment_date_days,
assigned_user_id, parent_id, payment_date_days, supplier_code
FROM accounts where iln like '" . $buyerILN . "' AND deleted=0"));
$isCarrefour = false;
if ($xml->{'Order-Parties'}->Buyer->ILN == '5900000930015') {
$isCarrefour = true;
}
$isMM = false;
if ($buyer['parent_id'] == '1249') {
$isMM = true;
}
$isAuchan = false;
if ($buyer['id'] == '226a168c-2fef-b92f-0918-6200de91bb31') {
$isAuchan = true;
}
$sale->order_source = 'edi';
$sale->parent_id = $buyer['id'];
$sale->parent_name = $buyer['name'];
$sale->parent_iln = $xml->{'Order-Parties'}->Buyer->ILN;
$sale->parent_nip = $buyer['to_vatid'];
$sale->parent_address_street = $buyer['register_address_street'];
$sale->parent_address_city = $buyer['register_address_city'];
$sale->parent_address_postalcode = $buyer['register_address_postalcode'];
$sale->parent_address_country = $buyer['register_address_country'];
$sale->parent_document_no = $xml->{'Order-Header'}->OrderNumber;
$sale->stock_id = '754a59d6-979f-7006-a202-57c96a3eb06b';
if ($isMM) {
$address = $db->fetchByAssoc(
$db->query(
"SELECT * FROM account_addresses WHERE account_id='$sale->parent_id' AND deleted='0' ORDER BY position LIMIT 1"
)
);
$sale->shipping_address_name = $address['name'];
$sale->shipping_addresses = $address['name'];
$sale->shipping_address_street = $address['street'];
$sale->shipping_address_city = $address['city'];
$sale->shipping_address_postalcode = $address['postalcode'];
$sale->shipping_address_country = $address['country'];
$sale->shipping_iln = $xml->{'Order-Parties'}->DeliveryPoint->ILN;
$sale->shipping_nip = "";
if ($buyer['payment_date_days'])
$sale->payment_date_days = $buyer['payment_date_days'];
if ($buyer['supplier_code'])
$sale->supplier_code = $buyer['supplier_code'];
} else {
$delivery = $db->fetchByAssoc($db->query("
SELECT to_vatid, register_address_street, register_address_city, register_address_postalcode,
register_address_country, id, assigned_user_id, name,parent_id,
supplier_code, ecmpaymentcondition_id, ecmpaymentcondition_name, payment_date_days
FROM accounts where iln like '" . $xml->{'Order-Parties'}->DeliveryPoint->ILN . "' AND deleted=0"));
$sale->shipping_address_name = $delivery['name'];
$sale->shipping_addresses = $delivery['name'];
$sale->shipping_address_street = $delivery['register_address_street'];
$sale->shipping_address_city = $delivery['register_address_city'];
$sale->shipping_address_postalcode = $delivery['register_address_postalcode'];
$sale->shipping_address_country = $delivery['register_address_country'];
$sale->shipping_iln = $xml->{'Order-Parties'}->DeliveryPoint->ILN;
$sale->shipping_nip = $delivery['to_vatid'];
if ($delivery['payment_date_days'])
$sale->payment_date_days = $delivery['payment_date_days'];
if ($delivery['supplier_code'])
$sale->supplier_code = $delivery['supplier_code'];
}
$sale->register_date = date("d.m.Y", strtotime($xml->{'Order-Header'}->OrderDate));
$sale->delivery_date = date("d.m.Y", strtotime($xml->{'Order-Header'}->ExpectedDeliveryDate));
$date = new DateTime(date("d.m.Y", strtotime($xml->{'Order-Header'}->OrderDate)));
if ($sale->payment_date_days != "") {
$date->modify("+" . $sale->payment_date_days . " day");
}
$sale->payment_date = $date->format("d.m.Y");
$sale->payment_method = 'PRZELEW';
$sale->assigned_user_id = $buyer['assigned_user_id'];
$sale->edi_file = $file;
$sale->type = 'sales_order';
$sale->status = 's30';
$sale->ecmlanguage = 'pl_pl';
$sale->position_list = loadProducts($xml->{'Order-Lines'}->Line, $isCarrefour, $isAuchan);
$sum_netto = 0;
$sum_brutto = 0;
foreach ($sale->position_list as $p) {
$sum_netto += $p['total_netto'];
$sum_brutto += $p['total_brutto'];
}
$sale->total_netto = $sum_netto;
$sale->total_brutto = $sum_brutto;
$sale->save(false);
$parent = '';
if ($isMM) {
$parent = 'MediaMarkt';
} else if ($isAuchan) {
$parent = 'Auchan';
} else if ($isCarrefour) {
$parent = 'Carrefour';
}
$msg = array();
$msg['parent'] = $parent;
$msg['number'] = $sale->document_no;
return $msg;
}
function loadProducts($products, $isCarrefour = false, $isAuchan = false)
{
$db = $GLOBALS['db'];
$counter = 0;
foreach ($products as $prod) {
if ($isCarrefour) {
$pId = $db->fetchByAssoc($db->query("select p.id from ecmproducts as p where TRIM(p.ean2)='" . trim($prod->{'Line-Item'}->EAN) . "' and p.deleted='0'"));
} else if ($isAuchan) {
$pId = $db->fetchByAssoc($db->query("select p.id from ecmproducts as p where TRIM(p.ean2)='" . trim($prod->{'Line-Item'}->EAN) . "' and p.deleted='0'"));
if (!isset($pId) || $pId == null) {
$pId = $db->fetchByAssoc($db->query("select p.id from ecmproducts as p where TRIM(p.ean)='" . trim($prod->{'Line-Item'}->EAN) . "' and p.deleted='0'"));
}
} else {
$pId = $db->fetchByAssoc($db->query("select p.id from ecmproducts as p where (TRIM(p.ean)='" . trim($prod->{'Line-Item'}->EAN) . "' OR TRIM(p.ean2)='" . trim($prod->{'Line-Item'}->EAN) . "') and p.deleted='0'"));
}
if (!isset($pId) || $pId == null) {
sendEmail("Nie znaleziono produktu: " . trim($prod->{'Line-Item'}->EAN));
}
$p = new EcmProduct();
$p->retrieve($pId['id']);
$response[$counter]['product_id'] = $p->id;
$response[$counter]['position'] = (string) $prod->{'Line-Item'}->LineNumber;
$response[$counter]['product_code'] = $p->code;
$response[$counter]['name'] = $p->name;
$response[$counter]['quantity'] = (string) $prod->{'Line-Item'}->OrderedQuantity;
$response[$counter]['price_start'] = (string) $prod->{'Line-Item'}->OrderedUnitNetPrice;
$response[$counter]['price_netto'] = (string) $prod->{'Line-Item'}->OrderedUnitNetPrice;
$response[$counter]['discount'] = 0;
$response[$counter]['total_netto'] = (string) $prod->{'Line-Item'}->OrderedUnitNetPrice * $prod->{'Line-Item'}->OrderedQuantity;
$response[$counter]['unit_id'] = 1;
$response[$counter]['unit_name'] = 'szt.';
$response[$counter]['ecmvat_id'] = $p->vat_id;
$response[$counter]['ecmvat_name'] = $p->vat_name;
$response[$counter]['ecmvat_value'] = $p->vat_value;
$response[$counter]['recipient_code'] = (string) $prod->{'Line-Item'}->BuyerItemCode;
$response[$counter]['product_ean'] = (string) trim($prod->{'Line-Item'}->EAN);
$counter++;
}
return $response;
}
function searchForOrderByNumber($number, $path)
{
$allFiles = scandir($path);
$folders = array('imported', 'temp', 'failed');
if (is_array($allFiles)) {
foreach ($allFiles as $file) {
if (!is_dir($file) && !in_array($file, $folders) && substr($file, -3) == 'xml') {
$xml = simplexml_load_file($path . '/' . $file);
if (!$xml) {
throw new Exception("Can't load (or parse) XML");
}
if ($xml->{'Order-Header'}->OrderNumber == $number) {
echo 'Found: ' . $file . PHP_EOL;
return;
}
}
}
return;
}
}
function searchForOrderILN($number, $path)
{
$allFiles = scandir($path);
$folders = array('imported', 'temp', 'failed');
if (is_array($allFiles)) {
foreach ($allFiles as $file) {
if (!is_dir($file) && !in_array($file, $folders) && substr($file, -3) == 'xml') {
$xml = simplexml_load_file($path . '/' . $file);
if (!$xml) {
throw new Exception("Can't load (or parse) XML");
}
if ($xml->{'Order-Parties'}->Buyer->ILN == $number) {
echo 'Found (Buyer): ' . $file . PHP_EOL;
return;
}
if ($xml->{'Order-Parties'}->DeliveryPoint->ILN == $number) {
echo 'Found (DeliveryPoint): ' . $file . PHP_EOL;
return;
}
}
}
echo 'Not found: ' . $number . PHP_EOL;
return;
}
}
function getSellerILN($path)
{
$allFiles = scandir($path);
$folders = array('imported', 'temp', 'failed');
$media = array();
if (is_array($allFiles)) {
foreach ($allFiles as $file) {
if (!is_dir($file) && !in_array($file, $folders) && substr($file, -3) == 'xml') {
$xml = simplexml_load_file($path . '/' . $file);
if (!$xml) {
throw new Exception("Can't load (or parse) XML");
}
// create array with seller iln without duplicates
$iln = (string) $xml->{'Order-Parties'}->Seller->ILN;
if ($iln === '5909000896239') {
echo '5909000896239 ' . $file . PHP_EOL;
}
}
}
}
var_dump($media);
return;
}
function brecho($msg)
{
echo '<br><br>';
var_dump($msg);
echo '<br><br>';
}
function sendEmail($parents, $orders)
{
$mail = new PHPMailer2(true);
$mail->isSMTP();
$mail->setFrom('system@e5.pl', 'Twinpol CRM - usługa importu EDI');
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'system@e5.pl';
$mail->Password = 'wqiz ekxn lysj zheu';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->CharSet = 'UTF-8';
$mail->addAddress('mz@bim-it.pl', 'Michał Zieliński');
$mail->addAddress('mf@e5.pl', 'Małgorzata Franiewska');
if (in_array('Auchan', $parents) || in_array('Carrefour', $parents) || true) {
$mail->addAddress('justyna.pawlak@twinpol.com', 'Justyna Pawlak');
}
$mail->isHTML(true);
$mail->Subject = 'Twinpol: zaimportowano zamówienia EDI dla: ' . implode(', ', $parents);
$body = '';
foreach ($orders as $order) {
$body .= 'Zaimportowano zamówienie: ' . $order . '<br>';
}
$mail->Body = $body;
$mail->send();
}

View File

@@ -0,0 +1,66 @@
<?php
$db = $GLOBALS['db'];
$query = "
SELECT s.document_no, s.register_date, s.parent_name, s.total_netto, si.code, si.name, si.quantity, si.price_netto
FROM ecmsaleitems AS si
INNER JOIN ecmsales AS s ON si.ecmsale_id = s.id
WHERE s.register_date >= NOW() - INTERVAL 7 DAY
ORDER BY s.register_date DESC;
";
$res = $db->query($query);
$results = [];
if ($res) {
$columns = array_keys($db->fetchByAssoc($res));
$results[] = $columns;
mysqli_data_seek($res, 0);
while ($row = $db->fetchByAssoc($res)) {
$results[] = array_values($row);
}
}
$jsonData = json_encode($results);
$apiKey = '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';
$messages = [
[
"role" => "system",
"content" => "Jesteś analitykiem danych. Przygotuj szczegółowy raport sprzedaży na podstawie danych w formacie JSON (jest to lista zamówień z ostatnich 7 dni). Wygeneruj czysty kod HTML wewnątrz jednego <div>, bez <html>, <head> ani <body>. Raport powinien zawierać tabele, nagłówki, podsumowania, wnioski, rekomendacje i listę potencjalnych nieprawidłowości. Dane zachowaj w oryginale (nie tłumacz nazw). Zadbaj o estetyczny i uporządkowany układ raportu. Zwróć tylko kod HTML. Odpowiedz w języku polskim.",
],
[
"role" => "user",
"content" => "Oto dane sprzedaży w formacie JSON:\n\n$jsonData"
]
];
$payload = [
"model" => "gpt-4.1",
"messages" => $messages,
"temperature" => 0.3
];
$ch = curl_init('https://api.openai.com/v1/chat/completions');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Authorization: Bearer ' . $apiKey
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Błąd: ' . curl_error($ch);
exit;
}
$data = json_decode($response, true);
$htmlReport = $data['choices'][0]['message']['content'];
echo $htmlReport;

View File

@@ -0,0 +1,34 @@
<H2>Masowa zmiana statusu dokumentów </H2>
<form method="post" action="index.php">
<input type="hidden" value="change_status" name="action">
<input type="hidden" value="EcmSales" name="module">
<?php
global $app_list_strings;
if(count($_REQUEST['mass'])>0){
foreach ($_REQUEST['mass'] as $id){
?>
<input value="<?php echo $id;?>" type="hidden" name="selected[]">
<?php
}
}
?>
Wybierz status: <select name="status">
<?php
foreach ($app_list_strings['ecmsales_status_dom'] as $key=>$value){
?>
<option value="<?php echo $key;?>"><?php echo $value;?></option>
<?php
}
?>
<input type="submit" value="Zmień status">
</select>
</form>
<?php
if(count($_REQUEST['selected'])>0){
$db=$GLOBALS['db'];
foreach ($_REQUEST['selected'] as $id){
$db->query("update ecmsales set status='".$_POST['status']."' where id='".$id."'");
}
header("Location: index.php?module=EcmSales&action=index");
}
?>

View File

@@ -0,0 +1,35 @@
<?php
error_reporting(0);
set_time_limit (99999999);
ini_set('memory_limit', '-1');
include_once("modules/EcmProducts/productCardUltraNew.php");
include_once("include/MPDF57/mpdf.php");
$p=new mPDF('utf-8','A4-L', null, 'helvetica');
$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select c.iso4217 as s from currencies as c inner join ecmsales as q on q.currency_id=c.id where q.id='".$_REQUEST['record']."'"));
$symbol=$rr['s'];
$db = $GLOBALS['db'];
$focus = new EcmSale();
$focus->retrieve($_REQUEST['record']);
if ($focus->ecmlanguage=='pl_pl')
$lang = "pl";
if ($focus->ecmlanguage=='en_us')
$lang = "en";
$products = $db->query("SELECT id,ecmproduct_id FROM ecmsaleitems WHERE ecmsale_id='".$_REQUEST['record']."' AND deleted='0' ORDER BY position");
while ($prod = $db->fetchByAssoc($products)) {
$p=productCardNew($p,$prod['ecmproduct_id'],$lang,true,true,"",$symbol,true, $_REQUEST['show_ean'], $prod['id'], "EcmSales");
}
if($_REQUEST['create_img']==1){
$guid=create_guid();
$type="F";
$file="cache/upload/Catalogue".$guid.".pdf";
}
else{
$type="D";
$file="Catalogue".date("YmdHi").".pdf";
}
$p->Output($file,$type);

81
modules/EcmSales/createPDF.php Executable file
View File

@@ -0,0 +1,81 @@
<?php
// changed mz 2014-12-13
// auto create PDF only when action=createPDF are not empty
// otherise wait from function call
$type = isset($_REQUEST['file'])?'FILE':'BROSWER';
if ($_REQUEST['action']=='createPDF')
createEcmSalePdf($_REQUEST['record'], $type);
// outputtype:
// BROSWER - open doc in broswer - return true if OK
// FILE - save in uploads \
// EMAIL - save in emails temp dir > return file path if OK
// MULTIPDF - save in MultiPdf temp dir /
function createEcmSalePdf($record, $outputtype, $pdf_type = null) {
if (! $record || $record == '')
die ( 'Brak rekordu' );
if (isset($pdf_type)) {
$_REQUEST['pdf_type'] = $pdf_type;
}
include_once ("modules/EcmSales/PDFTemplate/helper.php");
include_once ("modules/EcmSysInfos/EcmSysInfo.php");
$focus = new EcmSale ();
$focus->retrieve ( $record );
$positions = formatPDFPositions ( $focus->getPositionList ( true ), $focus );
$user = new User ();
$user->retrieve ( $focus->assigned_user_id );
include_once ("include/MPDF57/mpdf.php");
$p = new mPDF ( '', 'A4', null, 'helvetica', 10, 10, 30, 45, 5, 5 );
$mpdf->mirrorMargins = 1;
// get languages
$labels = return_module_language ( $focus->ecmlanguage, 'EcmSales' );
// get header
// get footer
//$footer = '';
//include ("modules/EcmSales/PDFTemplate/footer-" . $focus->ecmlanguage . ".php");
//$p->SetHTMLFooter ( $footer );
// get content
$content = '';
include ("modules/EcmSales/PDFTemplate/content.php");
$EcmSysInfo = new EcmSysInfo();
$header = $EcmSysInfo->getHeaderForModule('EcmSales');
if($_REQUEST['pdf_type']=='0'){
$header = $EcmSysInfo->getHeaderForModule('EcmInvoiceOuts');
$p->SetHTMLHeader ( $header );
} else {
$p->SetHTMLHeader ( $header );
}
$p->WriteHTML ( $content );
$p->SetHTMLFooter ( $EcmSysInfo->getFooterForModule('EcmSales') );
switch ($outputtype) {
case "BROSWER" :
$p->Output ();
return true;
case "FILE" :
$path = 'upload/zs_' . str_replace("/", "-", $focus->document_no) . '.pdf';
break;
case "EMAIL" :
include_once 'include/ECM/EcmSendMail/EcmSendMail.inc';
$path = EcmSendMail::TEMP_DIR . 'ZS_' . $focus->number . '.pdf';
break;
case "MULTIPDF" :
include_once 'include/ECM/EcmMultiPdf/EcmMultiPdf.inc';
$path = EcmMultiPdf::TEMP_DIR . 'EcmSales_' . $focus->id. '_' . create_guid() . '.pdf';
break;
};
$p->Output ($path, "F" );
return $path;
}

View File

@@ -0,0 +1,3 @@
<?php
require_once('modules/EcmSales/eCommerceZS/eCommerceZS.php');

View File

@@ -0,0 +1,81 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
$db = $GLOBALS['db'];
global $app_list_strings;
$smarty = new Sugar_Smarty();
if (isset($_REQUEST['date_from'])) {
$DEBUG = $_REQUEST['debug'] == '1' ? true : false;
$smarty->assign('debug', $DEBUG ? '1' : '');
$invoices = getInvoices($_REQUEST['date_from'], $_REQUEST['date_to']);
$invoiceIds = array();
foreach ($invoices as $invoice) {
$invoiceIds[] = $invoice['id'];
}
$sessionId = create_guid();
$_SESSION[$sessionId] = $invoiceIds;
$smarty->assign('sessionId', $sessionId);
$invoiceNo = array();
foreach ($invoices as $invoice) {
$invoiceNo[] = $invoice['document_no'];
}
$smarty->assign('invoicesNo', join(", ", $invoiceNo));
$smarty->assign('date_from', $_REQUEST['date_from']);
$smarty->assign('date_to', $_REQUEST['date_to']);
echo $smarty->display(getcwd() . '/modules/EcmSales/eCommerceZS/eCommerceZS.tpl');
} else {
$smarty->assign('date_from', date('d.m.Y'));
$smarty->assign('date_to', date('d.m.Y'));
echo $smarty->display(getcwd() . '/modules/EcmSales/eCommerceZS/eCommerceZS.tpl');
}
function getInvoices($dateFrom, $dateTo) {
$db = $GLOBALS['db'];
$invoices = array();
$dateFrom = date('Y-m-d', strtotime($dateFrom));
$dateTo = date('Y-m-d', strtotime($dateTo));
$query = "SELECT ip.ecmproduct_id, ip.code, i.document_no, SUM(ip.quantity) AS quantity, i.register_date, i.id
FROM ecommerce_invoices_products AS ip
INNER JOIN ecommerce_invoices AS i ON ip.invoice_id = i.id AND i.register_date BETWEEN '$dateFrom' AND '$dateTo' AND i.type='normal'
AND i.origin IN ('allegro', 'shop')
WHERE ip.ecmproduct_id != '' AND ip.ecmproduct_id !='165f364e-9301-25ac-5906-58e38f1de4ca'
AND i.ecmstockdocout_id IS NULL AND i.ecmsale_id IS NULL
GROUP BY i.id, ip.ecmproduct_id
ORDER BY i.register_date;";
$res = $db->query($query);
while ($row = $db->fetchByAssoc($res)) {
if (!isset($invoices[$row['document_no']])) {
$invoices[$row['document_no']] = array();
$invoices[$row['document_no']]['document_no'] = $row['document_no'];
$invoices[$row['document_no']]['register_date'] = $row['register_date'];
$invoices[$row['document_no']]['id'] = $row['id'];
$invoices[$row['document_no']]['products'] = array();
$invoices[$row['document_no']]['products'][] = array (
'ecmproduct_id' => $row['ecmproduct_id'],
'code' => $row['code'],
'quantity' => $row['quantity'],
);
} else {
$invoices[$row['document_no']]['products'][] = array (
'ecmproduct_id' => $row['ecmproduct_id'],
'code' => $row['code'],
'quantity' => $row['quantity'],
);
}
}
$invoices = array_values($invoices);
usort($invoices, function($a, $b) {
return $a['id'] - $b['id'];
});
return $invoices;
}

45
modules/EcmSales/import.php Executable file
View File

@@ -0,0 +1,45 @@
<?php
require_once 'include/ECM/EcmDeleteDocument/EcmDeleteDocument.php';
$ids= [
# id
# id
'c5a20699-88d1-3e8d-ccb9-59d345e572a7','1fbd796e-56b8-5169-9deb-59d345938bc7','35b40fe6-ca75-68e0-dbb2-59d345d544d5','1baa4a5b-78a5-252c-4fa8-59d3455ee2a6','322b0ea9-9743-b181-3505-59d3452cbb4a','4de310ce-4e2e-5768-d22c-59d34528bb2e','684f352f-fd51-0a32-2dd0-59d345171a09','5323f65d-ed36-7351-3456-59d345b6cbae','75b90846-957d-9e3f-4a0e-59d345dd9c54','8cd1acb6-1e98-0d20-9991-59d345aa0092','a80ca8e9-290c-aed3-3b60-59d3459a158a','c45064e4-eefe-b7e9-022c-59d3459dda55','a97a21d8-7c0a-696f-441c-59d345e84b4d','c2e0fd73-d160-79ec-355d-59d345307d57','f1289bd1-47ee-fcbb-1f39-59d345e53f11','318baafb-c8fc-301c-1685-59d345da414c','6806f718-863d-d20f-e169-59d3457e2094','7f114403-6136-17cb-0da0-59d3458fb151','b5c548eb-5826-cb46-1311-59d345628c65','f0cb4373-aab2-f634-5869-59d345d4074b','35192066-502d-4844-19dd-59d345fd2c3e','5c571dab-d61c-775e-1453-59d3452cf3a1',
];
$module='EcmStockDocOuts';
foreach ($ids as $id){
$test= new EcmDeleteDocument($module,$id);
if($test->removeIsPossible()!=false){
$test->removeDoc();
} else {
}
}
$ids= [# id
# id
# id
'5c9ef1ec-b78e-e54b-eda6-59d345a464bd','1ac1a0a4-43d2-5ce4-fe4f-59d3451da054','d18b696c-528b-c98d-5c1a-59d345eebf3a','8fe27033-ae8e-ece9-06cc-59d345054c4e','52ef5813-8ddc-0d8b-7e8b-59d3458c7aaa','212b148b-effa-9efd-4fd2-59d3453071eb','a461f65e-2a4a-3ba6-c4a9-59d345bc9fb2','6dc967ee-cd1c-744e-b15a-59d34514e921','2fd2b685-27de-7bf0-393b-59d3451c377a','ef4ddeb5-fae6-8569-9a0c-59d345d2cf39','b8b92f92-ba3a-6291-1f06-59d345b29960','4e7f75e4-d9c0-8567-3605-59d345b66fec','18eab08d-7111-b58c-ece7-59d345202e0d','f30b2d38-c7eb-d997-42b6-59d34510450c','d33299f4-1a80-2166-b89b-59d3457797b9','b14c69a8-fef1-80e8-d737-59d345339d0c','5a582c9a-bbb4-c3dc-018f-59d345bbc5a3','408b7f76-7176-7833-0af7-59d345bee3e9','1bc1f961-202a-4512-75ad-59d345ca33fe','df406409-38f5-da09-0cbd-59d3452e47de','bbd9d17f-d64d-0409-e8ec-59d345b0c7d2','8b6af21b-162e-d63d-449d-59d3452c32cd','305fca60-21b0-2bd3-bb0f-59d3453248d2','92b906a5-b93d-7821-23eb-59d3454f03ea','d89b1a4a-c055-2ac9-412e-59d34565bbae','b1fc810a-2852-fce6-9c33-59d3452191b0','8ab79009-67ff-baeb-9573-59d3453a1848','33b30346-1cf8-dada-9e79-59d345197481','16c9c75d-2be7-ce58-4d80-59d34542a0ad','ec0a088a-e296-c060-41a5-59d3453317a1','cb3d87f2-334d-a66c-1a89-59d345979b51','acf2fcaa-f72a-d7a8-a76b-59d345c18ce6','5f55cdea-a151-51a1-9d24-59d345c67696','433933bd-3ab0-5fd0-33b2-59d345c99f0b','2c4c420b-d6d7-6505-f505-59d345d014de','1a20e8db-5952-59c1-bf5a-59d345e005f9','f409ab61-4b09-92ca-5863-59d34558cce3','de615847-9a83-d349-b445-59d345fd5977','96ba7f8e-f1da-3fb4-3c6d-59d345760f67','8a3ac7a4-4674-526f-4236-59d345624079','7b875533-0d02-f5a2-c690-59d345889ecd','681a9f36-b3b4-3bce-2619-59d3455cea9f','59e1b1f7-6dc4-786e-0e46-59d34534ad8e','1a3c7c99-14fc-08d0-92ab-59d345b7e240','ee990a4c-b4f2-4bab-d6db-59d34572c882','4fd3090e-c5c5-747b-cd7e-59d345bfee43','f13a7aaa-837c-b7ee-96a7-59d345d6ecbf','e8ed174b-795f-8b07-ed7e-59d345b1db46','ab262090-f68a-c71c-afc5-59d345f2eedd','a8ea7fab-6532-ef18-377f-59d34563d544','a7109d31-f23e-71ee-6c54-59d3454d5941','9b8606d5-6bf6-2ceb-c14c-59d345e08cf9','8d93d54c-858b-5f58-a331-59d34559f0fb','8ed0326f-05e1-f474-fe29-59d34574f7d4','5ca08d81-4439-32c4-8c48-59d3452d9570','5f45215c-164c-063f-ac77-59d34509878f','6b0613a8-7029-f822-ec92-59d3458c1692','73a7ee9a-f3f3-34ca-196d-59d3457f6d4d','778aa107-7a20-89cc-71f5-59d3452465ae','502a22fc-7287-6ff6-d512-59d3456d8347','5cc4c179-7257-574e-e2a9-59d345c830df','670f697f-aaab-d209-9b59-59d3455fc6a1','710461d3-5797-fc83-7a87-59d3454318b5','7d6e17c0-2815-f742-ab25-59d34582193b','64ed1d31-2de6-c366-17ff-59d3450f26e8','7bbb0862-3733-f01a-3f5c-59d345c1af44','969c272f-63b2-34a4-7055-59d345a79130','abf82fe9-121a-5aee-3a7d-59d34592ec83','c5d550c9-31b3-da09-48b1-59d345c79658','ae41d129-42ad-11fe-ae86-59d3454cc634','ce513e02-84bd-5b56-e979-59d345b9fdcc','f31cf829-2ab9-b218-0be9-59d34576682c','127488b3-e690-29ab-8ce4-59d345a2ba32','2e5c07a6-cd40-99fa-7a63-59d34567d9f0','4aa15b77-7994-6a3c-f100-59d3456c3ceb','31b65553-363b-98f0-16ee-59d3455a10be','4e3c1d11-3ab2-bcf4-49b1-59d345eb42f7','800bd6f1-3152-b8da-9053-59d345566fe6','b5211811-0c64-e995-1095-59d3452f2fbf','e8c5def5-a278-0c9c-9806-59d3450b3cfa','df130718-e94c-b29b-89b6-59d34565ad1a','463c99bf-4750-614e-a539-59d34542654a','7ed084ab-5d55-0b6e-42ce-59d345250042','b010c286-6ef5-f957-aaf9-59d3455c9c6e',
];
$module='EcmInvoiceOuts';
foreach ($ids as $id){
$test= new EcmDeleteDocument($module,$id);
if($test->removeIsPossible()!=false){
$test->removeDoc();
} else {
}
}
?>

View File

@@ -0,0 +1,361 @@
<?php
ini_set('display_errors',1);
if (! defined ( 'sugarEntry' ) || ! sugarEntry) die ( 'Not A Valid Entry Point' );
//importProduktow();
//importKontrahentow();
importZamowien();
//ecmprices_ecmproducts
function importVatow(){
global $current_user;
$db_presta = getConnectionPresta();
$db_saas = getConnectionSaas();
foreach($db_saas->query('SELECT id FROM ecmvats') as $old_row) {
$old_array[$old_row['id']] = true;
}
foreach($db_presta->query('
SELECT
ps_tax_rules_group.id_tax_rules_group,
ps_tax_rule.id_tax,
ps_tax_lang.name,
ps_tax.rate,
ps_tax_rules_group.date_add,
ps_tax_rules_group.date_upd
FROM
ps_tax_rules_group,
ps_tax_rule,
ps_tax_lang,
ps_tax
WHERE
ps_tax_rules_group.id_tax_rules_group = ps_tax_rule.id_tax_rules_group
AND ps_tax_rule.id_tax = ps_tax_lang.id_tax
AND ps_tax_rule.id_tax = ps_tax.id_tax
GROUP BY ps_tax_rules_group.id_tax_rules_group') as $category_row) {
$insert_array = array();
$insert_array['id'] = $category_row['id_tax_rules_group'];
$insert_array['date_entered'] = $category_row['date_add'];
$insert_array['date_modified'] = $category_row['date_upd'];
$insert_array['modified_user_id'] = $current_user->id;
$insert_array['assigned_user_id'] = $current_user->id;
$insert_array['created_by'] = $current_user->id;
$insert_array['deleted'] = 0;
$insert_array['name'] = $category_row['name'];
$insert_array['value'] = $category_row['rate'];
$insert_array['id'] = $category_row['id_tax_rules_group'];
if($old_array[$category_row['id_tax_rules_group']]){
$db_saas->query("DELETE FROM ecmvats WHERE id='" . $category_row['id_category'] ."'");
}
$insert_keys = array_keys($insert_array);
$insert_values = array_values($insert_array);
$insert_query = "INSERT INTO ecmvats (" . implode(",",$insert_keys) .") VALUES ('" . implode("','",$insert_values) . "');";
$db_saas->query($insert_query);
}
}
function importKategorii(){
global $current_user;
$db_presta = getConnectionPresta();
$db_saas = getConnectionSaas();
$old_array = array();
foreach($db_saas->query('SELECT id FROM ecmproductcategories') as $old_row) {
$old_array[$old_row['id']] = true;
}
foreach($db_presta->query('SELECT * FROM ps_category') as $category_row) {
$category_lang_result = $db_presta->query('SELECT * FROM ps_category_lang WHERE id_lang=2 AND id_category=' . $category_row['id_category']);
$category_lang = $category_lang_result->fetch();
$insert_array = array();
$insert_array['id'] = $category_row['id_category'];
$insert_array['date_entered'] = $category_row['date_add'];
$insert_array['date_modified'] = $category_row['date_upd'];
$insert_array['modified_user_id'] = $current_user->id;
$insert_array['assigned_user_id'] = $current_user->id;
$insert_array['created_by'] = $current_user->id;
$insert_array['deleted'] = 0;
$insert_array['name'] = $category_lang['name'];
$insert_array['to_module'] = 'EcmProducts';
if($old_array[$category_row['id_category']]){
$db_saas->query("DELETE FROM ecmproductcategories WHERE id='" . $category_row['id_category'] ."'");
}
$insert_keys = array_keys($insert_array);
$insert_values = array_values($insert_array);
$insert_query = "INSERT INTO ecmproductcategories (" . implode(",",$insert_keys) .") VALUES ('" . implode("','",$insert_values) . "');";
$db_saas->query($insert_query);
}
}
function importProduktow(){
importVatow();
importKategorii();
global $current_user;
$db_presta = getConnectionPresta();
$db_saas = getConnectionSaas();
$res = $db_saas->query("SELECT id FROM ecmprices WHERE name='Presta' LIMIT 1");
var_dump($res->num_rows);
if($res->num_rows == 0){
$db_saas->query("INSERT INTO ecmprices(id,name,deleted,active) VALUES ('" . uniqid ("ecmprice_",true) . "','Presta',0,1)");
}
foreach($db_saas->query("SELECT id FROM ecmprices WHERE name='Presta' LIMIT 1") as $tmp) {
$prceid = $tmp['id'];
}
foreach($db_saas->query("SELECT id,value,name FROM ecmvats") as $tmp) {
$vats[$tmp['id']] = $tmp;
}
foreach($db_presta->query('SELECT * FROM ps_product') as $product_row) {
//usuwanie starego rekordu produktu
$db_saas->query("DELETE FROM ecmproducts WHERE id='" . $product_row['id_product'] ."'");
//usuwanie starej ceny
$del_query = "DELETE FROM ecmprices_ecmproducts WHERE ecmprice_id='" . $prceid ."' AND ecmproduct_id='" . $product_row['id_product'] ."'";
$db_saas->query($del_query);
//pobieranie polskiej nazwy produktu
$product_lang_result = $db_presta->query('SELECT * FROM ps_product_lang WHERE id_product=' . $product_row['id_product']);
$product_lang = $product_lang_result->fetch();
$insert_array = array();
$insert_array['id'] = $product_row['id_product'];
$insert_array['date_entered'] = $product_row['date_add'];
$insert_array['date_modified'] = $product_row['date_upd'];
$insert_array['modified_user_id'] = $current_user->id;
$insert_array['assigned_user_id'] = $current_user->id;
$insert_array['created_by'] = $current_user->id;
$insert_array['deleted'] = 0;
$insert_array['name'] = $product_lang['name'];
$insert_array['code'] = $product_row['reference'];
$insert_array['product_active'] = 1;
$insert_array['unit_id'] = 1;
$insert_array['status'] = 1;
$insert_array['flag'] = 1;
$insert_array['product_active'] = $product_row['active'];
$insert_array['vat_id'] = $product_row['id_tax_rules_group'];
$insert_array['vat_value'] = $vats[$product_row['id_tax_rules_group']]['value'];
$insert_array['vat_name'] = $vats[$product_row['id_tax_rules_group']]['name'];
$insert_array['product_category_id'] = $product_row['id_category_default'];
$price_query = "INSERT INTO ecmprices_ecmproducts VALUES ('" . uniqid ("presta_price",true) . "','" . $prceid . "','". $product_row['id_product'] ."','" . $product_row['price'] . "')";
$db_saas->query($price_query);
$insert_keys = array_keys($insert_array);
$insert_values = array_values($insert_array);
$insert_query = "INSERT INTO ecmproducts (" . implode(",",$insert_keys) .") VALUES ('" . implode("','",$insert_values) . "');";
$db_saas->query($insert_query);
}
}
function importKontrahentow(){
global $current_user;
$db_presta = getConnectionPresta();
$db_saas = getConnectionSaas();
foreach($db_presta->query('SELECT * FROM ps_customer') as $customer_row) {
$db_saas->query("DELETE FROM accounts WHERE id='" . $customer_row['id_customer'] ."'");
$adress_result = $db_presta->query('SELECT * FROM ps_address WHERE id_customer=' . $customer_row['id_customer']);
$adress = $adress_result->fetch();
$insert_array = array();
$insert_array['id'] = $customer_row['id_customer'];
$insert_array['date_entered'] = $customer_row['date_add'];
$insert_array['date_modified'] = $customer_row['date_upd'];
$insert_array['modified_user_id'] = $current_user->id;
$insert_array['assigned_user_id'] = $current_user->id;
$insert_array['created_by'] = $current_user->id;
$insert_array['deleted'] = 0;
$insert_array['account_type'] = 'rec';
$insert_array['name'] = trim($customer_row['firstname'] . ' ' . $customer_row['lastname']);
$insert_array['billing_address_street'] = trim($adress['address1'] . ' ' .$adress['address2']);
$insert_array['billing_address_city'] = trim($adress['city']);
$insert_array['billing_address_postalcode'] = trim($adress['postcode']);
//$insert_array['billing_address_country'] = 'Polska';
$insert_array['register_address_street'] = trim($adress['address1'] . ' ' .$adress['address2']);
$insert_array['register_address_city'] = trim($adress['city']);
$insert_array['register_address_postalcode'] = trim($adress['postcode']);
//$insert_array['register_address_country'] = 'Polska';
//$insert_array['phone_office'] = round($order_row['total_products'],2);
//$insert_array['phone_alternate'] = round($order_row['total_products_wt'],2);
$insert_array['is_vat_free'] = 0;
$insert_array['currency_id'] = 'PLN';
$insert_array['invoice_type'] = 'K';
$insert_array['index_dbf'] = $customer_row['email'];
$insert_keys = array_keys($insert_array);
$insert_values = array_values($insert_array);
$insert_query = "INSERT INTO accounts (" . implode(",",$insert_keys) .") VALUES ('" . implode("','",$insert_values) . "');";
$db_saas->query($insert_query);
}
}
function importujStatusyZamowien(){
$db_presta = getConnectionPresta();
$db_saas = getConnectionSaas();
foreach($db_presta->query('SELECT * FROM ps_order_state_lang where id_lang=2') as $status_row) {
$db_saas->query("DELETE FROM dom_lists WHERE dom_name = 'ecmsales_status_dom' AND key='" . $status_row['id_order_state'] ."' AND lang='pl_pl'");
$db_saas->query("INSERT INTO dom_lists VALUES ('id_order_state_" . $status_row['id_order_state']. "', 'pl_pl','ecmsales_status_dom', '" . $status_row['id_order_state'] ."', '" .$status_row['name'] . "')");
}
}
function importujMetodyPlatnosci(){
$db_presta = getConnectionPresta();
$db_saas = getConnectionSaas();
foreach($db_presta->query('SELECT payment,module FROM ps_orders GROUP BY module') as $payment) {
$db_saas->query("DELETE FROM dom_lists WHERE dom_name = 'payment_method_dom' AND key='" . $payment['module'] ."' AND lang='pl_pl'");
$db_saas->query("INSERT INTO dom_lists VALUES ('payment_method_dom_" . $payment['module']. "', 'pl_pl','payment_method_dom', '" . $payment['module'] ."', '" .$payment['payment'] . "')");
}
}
function importZamowien(){
global $current_user;
$db_presta = getConnectionPresta();
$db_saas = getConnectionSaas();
$EcmSale = new EcmSale();
$EcmSysInfo = new EcmSysInfo();
$number_template = $EcmSysInfo->getFormatNumberForModule('EcmSales');
$stock_id = '9fc80fd4-fc09-f869-38f6-5641b962268d';
foreach($db_saas->query("SELECT id,value,name FROM ecmvats") as $tmp) {
$vats[$tmp['id']] = $tmp;
}
importujStatusyZamowien();
importujMetodyPlatnosci();
$db_saas->query("DELETE FROM ecmsales WHERE id != '9909730a-67ae-33c5-e22a-5658051e3fc0'");
$db_saas->query("DELETE FROM ecmsaleitems WHERE id != '2a8f7cd5-bfe9-8be9-b306-566947b9d743'");
foreach($db_presta->query('SELECT * FROM ps_orders') as $order_row) {
$customer = null;
$adress = null;
$customer_result = $db_presta->query('SELECT * FROM ps_customer WHERE id_customer=' . $order_row['id_customer']);
$customer = $customer_result->fetch();
$adress_invoice_result = $db_presta->query('SELECT * FROM ps_address WHERE id_address=' . $order_row['id_address_invoice']);
$adress_invoice = $adress_invoice_result->fetch();
$adress_delivery_result = $db_presta->query('SELECT * FROM ps_address WHERE id_address=' . $order_row['id_address_delivery']);
$adress_delivery = $adress_delivery_result->fetch();
$document_no = '';
if ($number_template != "") {
require_once('include/ECM/EcmDocumentNumberGenerator/EcmDocumentNumberGenerator.inc.php');
$dng = new EcmDocumentNumberGenerator('EcmSales');
$document_no = $dng->parseNumber($number_template, $stock_id);
}
$insert_array = array();
$insert_array['id'] = $order_row['id_order'];
$insert_array['date_entered'] = $order_row['date_add'];
$insert_array['date_modified'] = $order_row['date_upd'];
$insert_array['modified_user_id'] = $current_user->id;
$insert_array['assigned_user_id'] = $current_user->id;
$insert_array['created_by'] = $current_user->id;
$insert_array['parent_document_no'] = $order_row['reference'];
$insert_array['deleted'] = 0;
$insert_array['document_no'] = $document_no;
$insert_array['parent_id'] = $order_row['id_customer'];
$insert_array['parent_name'] = trim($customer['firstname'] . ' ' . $customer['lastname']);
$insert_array['parent_index_dbf'] = $customer['email'];
$insert_array['type'] = 'sales_order';
$insert_array['status'] = $order_row['current_state'];
$insert_array['register_date'] = $order_row['date_add'];
$insert_array['parent_address_street'] = trim($adress_invoice['address1'] . ' ' .$adress_invoice['address2']);
$insert_array['parent_address_city'] = trim($adress_invoice['city']);
$insert_array['parent_address_postalcode'] = trim($adress_invoice['postcode']);
$insert_array['parent_address_country'] = 'Polska';
$insert_array['total_netto'] = round($order_row['total_products'],2);
$insert_array['total_brutto'] = round($order_row['total_products_wt'],2);
$insert_array['discount'] = round($order_row['total_discounts'],2);
$insert_array['vats_summary'] = '';
$insert_array['no_tax'] = 0;
$insert_array['ecmpaymentcondition_text'] = $carrier['delay'];
$insert_array['currency_id'] = 'PLN';
$insert_array['delivery_date'] = substr($order_row['delivery_date'],0,10);
$insert_array['shipping_address_street'] = trim($adress_delivery['address1'] . ' ' . $adress_delivery['address2']);
$insert_array['shipping_address_city'] = trim($adress_delivery['city']);
$insert_array['shipping_address_postalcode'] = trim($adress_delivery['postcode']);
$insert_array['shipping_address_country'] = 'Polska';
$insert_array['payment_method'] = $order_row['module'];
$insert_keys = array_keys($insert_array);
$insert_values = array_values($insert_array);
$insert_query = "INSERT INTO ecmsales (" . implode(",",$insert_keys) .") VALUES ('" . implode("','",$insert_values) . "');";
$db_saas->query($insert_query);
foreach($db_presta->query('SELECT * FROM ps_order_detail WHERE id_order='. $order_row['id_order']) as $product_row) {
$insert_product_array = array();
$insert_product_array['id'] = $product_row['id_order_detail'];
$insert_product_array['date_entered'] = $insert_array['date_entered'];
$insert_product_array['date_modified'] = $insert_array['date_modified'];
$insert_product_array['modified_user_id'] = $current_user->id;
$insert_product_array['assigned_user_id'] = $current_user->id;
$insert_product_array['created_by'] = $current_user->id;
$insert_product_array['deleted'] = 0;
$insert_product_array['ecmsale_id'] = $product_row['id_order'];
$insert_product_array['ecmproduct_id'] = $product_row['product_id'];
$insert_product_array['code'] = $product_row['product_reference'];
$insert_product_array['name'] = $product_row['product_name'];
$insert_product_array['quantity'] = $product_row['product_quantity'];
$insert_product_array['ecmvat_id'] = $product_row['id_tax_rules_group'];
$insert_product_array['ecmvat_value'] = $vats[$product_row['id_tax_rules_group']]['value'];
$insert_product_array['ecmvat_name'] = $vats[$product_row['id_tax_rules_group']]['name'];
var_dump($product_row['id_tax_rules_group']); echo '<br>';
var_dump($vats[$product_row['id_tax_rules_group']]); echo '<br>';
//var_dump($product_row['id_tax_rules_group']); echo '<br>';
$insert_product_array['price_start'] = $product_row['original_product_price'];
$insert_product_array['price_netto'] = $product_row['unit_price_tax_excl'];
$insert_product_array['price_brutto'] = $product_row['unit_price_tax_incl'];
$insert_product_array['discount'] = $product_row['reduction_percent'];
$insert_product_array['total_netto'] = $product_row['total_price_tax_excl'];
$insert_product_array['total_brutto'] = $product_row['total_price_tax_incl'];
$insert_product_keys = array_keys($insert_product_array);
$insert_product_values = array_values($insert_product_array);
$insert_product_query = "INSERT INTO ecmsaleitems (" . implode(",",$insert_product_keys) .") VALUES ('" . implode("','",$insert_product_values) . "');";
$db_saas->query($insert_product_query);
}
}
}
function getConnectionPresta($host='localhost', $db_name='4ju', $user='root', $password='spire1234'){
static $presta;
if($presta == null){
try {
$presta = new PDO('mysql:host=' . $host.';dbname=' . $db_name .';charset=utf8', $user, $password);
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
$presta = null;
die();
}
}
return $presta;
}
function getConnectionSaas($host='localhost', $db_name='preDb_8a7e080a76ef97c3e304cf463118ef9b', $user='root', $password='spire1234'){
static $saas;
if($saas == null){
try {
$saas = new PDO('mysql:host=' . $host.';dbname=' . $db_name .';charset=utf8', $user, $password);
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
$saas = null;
die();
}
}
return $saas;
}

View File

@@ -0,0 +1 @@
<?php require_once('modules/EcmSales/javascript/helper.php');

View File

@@ -0,0 +1,507 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('-1');
if (!$_POST['job'] || $_POST['job']=='') die ('-1');
switch ($_POST['job']) {
case 'getParentInfo': getParentInfo($_POST['id'], $_POST['type']); break;
case 'generateNumber': generateNumber(); break;
case 'searchProducts': searchProducts($_POST['searchKey'], $_POST['searchCategory'], $_POST['searchStock'], $_POST['searchStockId'], $_POST['searchSort'], $_POST['searchStart'], $_POST['searchCount']); break;
case 'getProduct': getProduct($_POST['id'], $_POST['pricebook'], $_POST['account_id'], $_POST['language']); break;
case 'getItems': getItems($_POST['record']); break;
case 'getStockProductDetails': getStockProductDetails($_POST['record'],$_POST['stock_id']); break;
case 'getItemsFromSale': getItemsFromSale($_POST['record']); break;
case 'getCategoriesList': getCategoriesList(); break;
case 'getTranslation': getTranslation($_POST['product_id'], $_POST['language'], $_REQUEST['unit_id']); break;
case 'getPricesInfo': getPricesInfo($_POST['product_id'], $_POST['pricebook_id'], $_POST['account_id']); break;
case 'getStockArray' : getStockArray($_POST['product_id']); break;
case 'SendMail' : SendMail($_POST['id'],$_POST['modulee'],$_POST['parent_id']);break;
case 'getPurchaseArray' : getPurchaseArray($_POST['product_id']); break;
case 'calculatePaymentDate' : calculatePaymentDate($_POST['date'], $_POST['days']);break;
case 'calculateDateDiff' : calculateDateDiff($_POST['date1'], $_POST['date2']);break;
case 'calculateDate' : calculateDate($_POST['date']); break;
}
function calculateDate($date){
$date = new Datetime($date);
$date->modify('-1 day');
$tmp['date']=$date->format("d.m.Y");
echo json_encode($tmp);
return '';
}
/*
function getStockProductDetails($record,$stock_id){
$db = $GLOBALS['db'];
$r=$db->query("select * from ecmstockoperations where
product_id='".$record."'
and stock_id='".$stock_id."'
and in_id is null and used=0 and type=0");
$docs=array();
$l=0;
while($tmp=$db->fetchByAssoc($r)){
$ii=$db->query("select * from ecmstockoperations where in_id='".$tmp['id']."' and type=1");
if($ii->num_rows>0){
$quantity_tmp=$tmp['quantity'];
while($tmp2=$db->fetchByAssoc($ii)){
$quantity_tmp-=$tmp2['quantity'];
}
$doc['quantity']=$quantity_tmp;
$doc['parent_name']=$tmp['parent_name'];
$doc['price']=$tmp['price'];
$doc['parent_type']=$tmp['parent_type'];
$doc['parent_id']=$tmp['parent_id'];
$docs[]=$doc;
} else {
$doc['quantity']=$tmp['quantity'];
$doc['parent_name']=$tmp['parent_name'];
$doc['price']=$tmp['price'];
$doc['parent_type']=$tmp['parent_type'];
$doc['parent_id']=$tmp['parent_id'];
$docs[]=$doc;
}
}
echo json_encode($docs);
return;
}
*/
function SendMail($id,$pdf_type,$parent_id){
global $current_user;
$db=$GLOBALS['db'];
$uq=$db->query("select google_login,CAST(AES_DECRYPT(google_password, 'jakistamhash123') as CHAR)
AS google_password FROM users where id='".$current_user->id."'");
$rul=$db->fetchByAssoc($uq);
if($rul['google_login']!='' && $rul['google_password']!=''){
$_REQUEST['record'] = $id;
$_REQUEST['pdf_type'] = $pdf_type;
$_REQUEST['file']=1;
require_once ("modules/EcmSales/createPDF.php");
require_once ("include/phpmailer/class.phpmailer.php");
require_once ("include/phpmailer/class.smtp.php");
$mailClassS = new PHPMailer (2);
$mailClassS->SMTPDebug = 1;
$mailClassS->isSMTP (); // Set mailer to use SMTP
$mailClassS->SMTPDebug = 1;
$mailClassS->Host = 'smtp.gmail.com'; // Specify main and backup server
$mailClassS->SMTPAuth = true; // Enable SMTP authentication
$mailClassS->Username = $rul['google_login']; // SMTP username
$mailClassS->Password = $rul['google_password']; // SMTP password
$mailClassS->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mailClassS->Port = 587; // Set the SMTP port number - 587 for
// get email from accounts
$sea = new SugarEmailAddress;
// Grab the array of addresses
$addresses = $sea->getAddressesByGUID($parent_id, 'Accounts');
foreach ( $addresses as $address ) {
if($address['email_address']!='' && $address['opt_out']==1){
$mailClassS->addAddress ($address['email_address']); // Add address
}
}
// set sender
$mailClassS->Sender=$rul['google_login'];
$mailClassS->From =$rul['google_login'];
$mailClassS->FromName =$current_user->first_name.' '.$current_user->last_name;
$mailClassS->WordWrap = 50; // Set word wrap to 50 characters
$mailClassS->isHTML ( true ); // Set email format to HTML
$mailClassS->Subject = 'Dokument od Saas SystemS Sp. z o.o.';
$d=new EcmSale();
$d->retrieve($id);
$path=createEcmSalePdf($id,'FILE');
$mailClassS->Body = 'Witam,<br><br>Przesyłam w załączniku dokument '.$d->document_no.'.<br>Proszę o potwierdzenie otrzymania wiadomości e-mail z załączonym dokumentem.';
// załącznik
if(file_exists('/var/www/html/crm/upload/zs_'.$d->number.".pdf")){
$mailClassS->addAttachment('/var/www/html/crm/upload/zs_'.$d->number.".pdf");
}
// Read an HTML message body from an external file, convert
// referenced images to embedded,
// convert HTML into a basic plain-text alternative body
// $mailClassS->msgHTML(file_get_contents('contents.html'),
// dirname(__FILE__));
if(count($mailClassS->to)>0){
if (! $mailClassS->send ()) {
echo $mailClassS->ErrorInfo;
unlink('upload/fk_'.$d->number.".pdf");
echo '-1';
} else {
unlink('upload/fk_'.$d->number.".pdf");
echo '1';
}
} else {
echo '-1';
}
} else {
echo '-1';
}
}
function calculatePaymentDate($d, $days){
global $timedate;
$date = new DateTime($d);
$date->add(new DateInterval('P'.$days.'D'));
echo json_encode($date->format('d.m.Y'));return;
}
function calculateDateDiff($d1, $d2) {
$db = $GLOBALS['db'];
global $timedate;
$d1 = $timedate->to_db_date($d1);
$d2 = $timedate->to_db_date($d2);
$ret = $db->fetchByAssoc($db->query("SELECT TIMESTAMPDIFF(DAY, '$d1','$d2') AS diff;"));
echo json_encode($ret['diff']); return;
}
function getParentInfo($id, $type) {
if (!$id || $id == '') die('-1');
$a = new Account();
$a->retrieve($id);
$data = array();
$data['name'] = html_entity_decode($a->name);
$data['parent_nip'] = $a->to_vatid;
$data['parent_index_dbf'] = $a->index_dbf;
$data['parent_address_street'] = $a->register_address_street;
$data['parent_address_postalcode'] = $a->register_address_postalcode;
$data['parent_address_city'] = $a->register_address_city;
$data['parent_address_country'] = $a->register_address_country;
$data['invoice_type'] = $a->invoice_type;
$data['currency_id'] = $a->currency_id;
$data['payment_date_days'] = $a->payment_date_days;
$data['payment_method'] = $a->payment_method;
$data['iln'] = $a->iln;
$data['vat_payer'] = $a->vat_payer;
if ($a->ecmpaymentcondition_id && $a->ecmpaymentcondition_id!='') {
$pc = new EcmPaymentCondition();
$pc->retrieve($a->ecmpaymentcondition_id);
$data['ecmpaymentcondition_id'] = $pc->id;
$data['ecmpaymentcondition_name'] = $pc->name;
}
if ($a->ecmdeliverycondition_id && $a->ecmdeliverycondition_id!='') {
$pc = new EcmdeliveryCondition();
$pc->retrieve($a->ecmdeliverycondition_id);
$data['ecmdeliverycondition_id'] = $pc->id;
$data['ecmdeliverycondition_name'] = $pc->name;
}
if ($a->ecmprice_id && $a->ecmprice_id!='') {
$pr = new EcmPrice();
$pr->retrieve($a->ecmprice_id);
$data['ecmprice_id'] = $pr->id;
$data['ecmprice_name'] = $pr->name;
}
//get pricebooks, ownership pricebooks
$pricebooks = array();
$db=$GLOBALS['db'];
$res = $db->query("SELECT id, name FROM ecmpricebooks WHERE account_id IN ('".$a->id."','".$a->parent_id."') AND active='1' AND deleted='0'");
while ($row = $db->fetchByAssoc($res)) {
$tmp = array();
$tmp['id'] = $row['id'];
$tmp['name'] = $row['name'];
$pricebooks[] = $tmp;
unset($tmp);
}
$data['pricebooks'] = $pricebooks;
//document validation fields
$data['document_recipient_code'] = $a->document_recipient_code;
$data['document_parent_order_no'] = $a->document_parent_order_no;
$data['document_delivery_address'] = $a->document_delivery_address;
$data['document_parent_iln'] = $a->document_parent_iln;
$data['document_shipping_iln'] = $a->document_shipping_iln;
$data['document_parent_nip'] = $a->document_parent_nip;
$data['document_shipping_nip'] = $a->document_shipping_nip;
//delivery addresses && ownership addresses
$addresses = array();
//delivery
$delivery = $a->getPositionList(true);
foreach ($delivery as $d) {
$address = array();
$address['name'] = html_entity_decode($d['name']);
$address['street'] = $d['street'];
$address['postalcode'] = $d['postalcode'];
$address['city'] = $d['city'];
$address['country'] = $d['country'];
$address['iln'] = $r['fax'];
$address['nip'] = $r['phone'];
$addresses[] = $address;
unset($address);
}
//ownership
$res = $db->query("SELECT name, register_address_street, register_address_postalcode, register_address_city, register_address_country, iln, to_vatid FROM accounts WHERE parent_id='$a->id'");
while ($r = $db->fetchByAssoc($res)) {
$address = array();
$address['name'] = html_entity_decode($r['name']);
$address['street'] = $r['register_address_street'];
$address['postalcode'] = $r['register_address_postalcode'];
$address['city'] = $r['register_address_city'];
$address['country'] = $r['register_address_country'];
$address['iln'] = $r['iln'];
$address['nip'] = $r['to_vatid'];
$addresses[] = $address;
unset($address);
}
$data['addresses'] = $addresses;
unset($addresses);
echo json_encode($data);
unset($data);
unset($a);
unset($res);
return;
}
function generateNumber() {
$data = array();
$data['number'] = EcmSale::generateNumber();
$data['document_no'] = EcmSale::formatNumber($data['number']);
echo json_encode($data);
unset($data);
return;
}
/*
function searchProducts($searchKey, $searchCategory, $searchStock,$searchStockId, $searchSort,$searchStart,$searchCount) {
$db = $GLOBALS['db'];
$result = array();
global $app_list_strings;
$q = "SELECT p.id, p.code, p.name,p.unit_id FROM ecmproducts p";
if($searchCategory!='bf900339-6c7b-f278-2737-542023796730' && $searchStock==3){
$q.=' inner join ecmstockstates s on p.id=s.product_id';
}
$q.=" WHERE
(UPPER(p.code) LIKE '%$searchKey%' OR
UPPER(p.name) LIKE '%$searchKey%')
AND p.deleted='0' ";
if ($searchCategory && $searchCategory!="")
$q.="AND p.product_category_id='$searchCategory' ";
if($searchStock==3 && $searchCategory!='bf900339-6c7b-f278-2737-542023796730')
$q.="and s.stock_id='$searchStockId' and s.quantity>0 ";
if ($searchSort=='1')
$q.="ORDER BY p.code";
else if ($searchSort=='2')
$q.="ORDER BY p.code DESC";
else if ($searchSort=='3')
$q.="ORDER BY p.name";
else if ($searchSort=='4')
$q.="ORDER BY p.name DESC";
// pagination
$c=$db->query($q);
$result['count']=$c->num_rows;
if($searchStart==0){
$LIMIT1=0;
$LIMIT2=50;
} else if($searchStart>0){
$LIMIT1=$searchStart;
$LIMIT2=50;
}
//echo $LIMIT1. ' '.$LIMIT2;
// pagination end
$q.=" LIMIT ".$LIMIT1.",".$LIMIT2;
$res = $db->query($q);
while ($row = $db->fetchByAssoc($res)) {
$tmp = array();
$tmp['id'] = $row['id'];
$tmp['name'] = $row['name'];
$tmp['code'] = $row['code'];
$tmp['unit_name'] = $app_list_strings['ecmproducts_unit_dom'][$row['unit_id']];
//get stock if necessary
if ($searchStock!='1') {
$tmp['stock_state'] = EcmStockOperation::getStock($row['id'], $searchStockId);
}
if ($searchStock=='3' && $tmp['stock_state']==0) continue; //don't show null stock
$result[] = $tmp;
}
echo json_encode($result);
return;
}
*/
function getProduct($id, $pricebook_id, $account_id, $language) {
$db = $GLOBALS['db'];
$p = $db->fetchByAssoc($db->query("SELECT p.id, p.code,p.OO, p.name,p.product_category_id, v.id as ecmvat_id, v.name as ecmvat_name, v.value as ecmvat_value, p.ean, p.ean2, p.unit_id FROM ecmproducts as p INNER JOIN ecmvats as v ON v.id=p.vat_id WHERE p.id='$id'"));
global $app_list_strings;
$p['unit_name'] = $app_list_strings['ecmproducts_unit_dom'][$p['unit_id']];
$p['unit_precision'] = $app_list_strings['ecmproducts_unit_dom_precision'][$p['unit_id']];
//get discount
$dc = $db->fetchByAssoc($db->query("select d.discount from accounts_discounts d
where d.account_id='".$account_id."' and d.ecmproductcategory_id='".$p['product_category_id']."'"));
if($dc['discount']!='' && is_numeric($dc['discount'])){
$p['discount']=$p['discount']+$dc['discount'];
}
//try get recipient_code and price from pricebook
if ($pricebook_id && $pricebook_id!='') {
$pr = $db->fetchByAssoc($db->query("SELECT price, recipient_code FROM ecmpricebooks_ecmproducts WHERE ecmpricebook_id='$pricebook_id' AND ecmproduct_id='$id' AND deleted='0'"));
$p['price_start'] = $pr['price'];
$p['recipient_code'] = $pr['recipient_code'];
}
if (!$p['price_start'] || floatval($p['price_start'])==0) {
//try price from default prices
$pr = $db->fetchByAssoc($db->query("SELECT pp.price FROM ecmprices_ecmproducts AS pp INNER JOIN ecmprices AS p ON pp.ecmprice_id=p.id INNER JOIN accounts AS a ON p.id=a.ecmprice_id WHERE a.id='$account_id' AND pp.ecmproduct_id='$id'"));
$p['price_start'] = $pr['price'];
}
$a=new Account();
$a->retrieve($account_id);
if ($language=='en_us') {
$r = $db->fetchByAssoc($db->query("SELECT short_description FROM ecmproduct_language WHERE ecmproduct_id='$id' AND language='en'"));
$p['name'] = htmlspecialchars_decode($r['short_description']);
$lists = return_app_list_strings_language($language);
$p['unit_name'] = $lists['ecmproducts_unit_dom'][$p['unit_id']];
$p['unit_precision'] = $lists['ecmproducts_unit_dom_precision'][$p['unit_id']];
unset($lists);
}
echo json_encode($p);
return;
}
function getItems($record) {
$of = new EcmSale();
$of->retrieve($record);
$pl = $of->getPositionList(true);
unset($of);
echo json_encode($pl);
return;
}
function getItemsFromSale($record) {
$s = new EcmQuote();
$s->retrieve($record);
$pl = $s->getPositionList(true);
unset($s);
echo json_encode($pl);
return;
}
function getCategoriesList() {
$db = $GLOBALS['db'];
$res = $db->query("SELECT id, name FROM ecmproductcategories WHERE deleted='0'");
$result = array();
while ($row = $db->fetchByAssoc($res)) {
$tmp = array();
$tmp['id'] = $row['id'];
$tmp['name'] = $row['name'];
$result[] = $tmp;
}
echo json_encode($result);
return;
}
function getTranslation($product_id, $language, $unit_id) {
$db = $GLOBALS['db'];
$result = array();
if ($language=='en_us') {
$r = $db->fetchByAssoc($db->query("SELECT short_description FROM ecmproduct_language WHERE ecmproduct_id='$product_id' AND language='en'"));
$result['name'] = htmlspecialchars_decode($r['short_description']);
} else if ($language=='pl_pl') {
$p = new EcmProduct();
$p->retrieve($product_id);
$result['name'] = htmlspecialchars_decode($p->name);
unset($p);
}
$lists = return_app_list_strings_language($language);
$result['unit_name'] = $lists['ecmproducts_unit_dom'][$unit_id];
unset($lists);
echo json_encode($result);
return;
}
function getPricesInfo($product_id, $pricebook_id, $account_id) {
$db = $GLOBALS['db'];
$result = array();
if ($pricebook_id && $pricebook_id!='') {
//try get price from pricebook
$res = $db->fetchByAssoc($db->query("SELECT price FROM ecmpricebooks_ecmproducts WHERE ecmpricebook_id='$pricebook_id' AND ecmproduct_id='$product_id' AND deleted='0'"));
if ($res['price'] && $res['price']!='' && $res['price']!=0) {
$tmp = array();
$tmp['name'] = 'pricebook';
$tmp['price'] = $res['price'];
$result[] = $tmp;
}
}
//get from ecmprices
$res = $db->query("SELECT p.name, pp.price FROM ecmprices_ecmproducts AS pp
INNER JOIN ecmprices AS p
ON p.id=pp.ecmprice_id
WHERE
pp.ecmproduct_id='$product_id'
AND pp.price!=0");
while ($row = $db->fetchByAssoc($res)) {
$tmp = array();
$tmp['name'] = $row['name'];
$tmp['price'] = $row['price'];
$result[] = $tmp;
}
//get last invoice price
if ($account_id && $account_id!='') {
$res = $db->fetchByAssoc($db->query("SELECT ii.subprice, i.id, i.document_no FROM ecminvoiceoutitems AS ii
INNER JOIN ecminvoiceouts AS i
ON ii.ecminvoiceout_id=i.id
WHERE ii.ecmproduct_id='$product_id'
AND i.parent_id='$account_id'
AND ii.deleted='0'
AND i.deleted='0'
AND i.canceled='0'
ORDER BY i.register_date DESC
LIMIT 0,1"));
if ($res && $res['subprice']!='') {
$tmp = array();
$tmp['name'] = $res['document_no'];
$tmp['price'] = $res['subprice'];
$result[] = $tmp;
}
}
echo json_encode($result);
return;
}
/*
function getStockArray($product_id) {
$o = new EcmStockOperation();
echo json_encode($o->getStockArray($product_id));
unset($o);
return;
}
function getPurchaseArray($product_id) {
$o = new EcmStockOperation();
echo json_encode($o->getPurchaseArray($product_id));
unset($o);
return;
}

View File

@@ -0,0 +1,103 @@
<?php
/**
* mb_stripos all occurences
* based on http://www.php.net/manual/en/function.strpos.php#87061
*
* Find all occurrences of a needle in a haystack
*
* @param string $haystack
* @param string $needle
* @return array or false
*/
function mb_stripos_all($haystack, $needle) {
$s = 0;
$i = 0;
while(is_integer($i)) {
$i = mb_stripos($haystack, $needle, $s);
if(is_integer($i)) {
$aStrPos[] = $i;
$s = $i + mb_strlen($needle);
}
}
if(isset($aStrPos)) {
return $aStrPos;
} else {
return false;
}
}
/**
* Apply highlight to row label
*
* @param string $a_json json data
* @param array $parts strings to search
* @return array
*/
function apply_highlight($a_json, $parts) {
$p = count($parts);
$rows = count($a_json);
for($row = 0; $row < $rows; $row++) {
$label = $a_json[$row]["label"];
$a_label_match = array();
for($i = 0; $i < $p; $i++) {
$part_len = mb_strlen($parts[$i]);
$a_match_start = mb_stripos_all($label, $parts[$i]);
foreach($a_match_start as $part_pos) {
$overlap = false;
foreach($a_label_match as $pos => $len) {
if($part_pos - $pos >= 0 && $part_pos - $pos < $len) {
$overlap = true;
break;
}
}
if(!$overlap) {
$a_label_match[$part_pos] = $part_len;
}
}
}
if(count($a_label_match) > 0) {
ksort($a_label_match);
$label_highlight = '';
$start = 0;
$label_len = mb_strlen($label);
foreach($a_label_match as $pos => $len) {
if($pos - $start > 0) {
$no_highlight = mb_substr($label, $start, $pos - $start);
$label_highlight .= $no_highlight;
}
$highlight = '<span class="hl_results">' . mb_substr($label, $pos, $len) . '</span>';
$label_highlight .= $highlight;
$start = $pos + $len;
}
if($label_len - $start > 0) {
$no_highlight = mb_substr($label, $start);
$label_highlight .= $no_highlight;
}
$a_json[$row]["label"] = $label_highlight;
}
}
return $a_json;
}
?>

View File

@@ -0,0 +1,451 @@
<?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_SHIPPING_ADDRESS' => 'Shipping address',
'LBL_SHIPPING_ADDRESS_NAME' => 'Name',
'LBL_PARENT_ILN' => 'ILN number',
'LBL_PARENT_DOCUMENT_NO' => 'Customer order number',
'LBL_DELIVERY_DATE' => 'Delivery date',
'LBL_ECMPRICE' => 'B2B Prices',
'LBL_SEARCH' => 'Search',
'LBL_CATEGORY' => 'Category',
'LBL_PDF_TEXT' => 'PDF Text',
'LBL_PARENT_NIP' => 'VAT ID',
'LBL_NO_TAX' => 'No tax',
'LBL_PDF_DOCUMENT_NAME' => 'Quote',
'LBL_SITE' => 'Site',
'LBL_SHOW_EAN' => 'Show EAN',
'LBL_SHOW_EAN2' => 'Show EAN2',
// added 05.02.2009
'LBL_QUOTE_XLS' => 'Create XLS',
'LBL_QUOTE_XLS_BUTTON_KEY' => 'Show XLS [Alt+X]',
'LBL_QUOTE_XLS_BUTTON_TITLE' => 'Show Quote in XLS file.',
// added 01.09.2009
'LBL_PRICEBOOK' => 'Price Book',
// added 05.08.2009
'LBL_CURRENCY' => 'Currency',
'LBL_DETAIL_BUTTON' => 'Details',
// added 15.07.2009
'LBL_EDITTABLE_UNIT' => 'Unit',
// added 09.02.2009
'LBL_SHOW_IMAGES_ON_OFFERS' => 'Show images on offers',
'LBL_SHOW_RECIPIENT_CODE' => 'Show recipient code',
// FOR SYSTEM USE
'LBL_MODULE_NAME' => 'Quotes',
'LBL_MODULE_TITLE' => 'Quotes: Home',
'LBL_MODULE_ID' => 'EcmSales',
'LBL_SEARCH_FORM_TITLE' => 'Quotes Search',
'LBL_LIST_FORM_TITLE' => 'Quotes List',
'LBL_NEW_FORM_TITLE' => 'New Quote',
'LBL_DETAILS' => 'Quote 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' => 'Account',
'LBL_PARENT_ID' => 'Account Id',
'LBL_TYPE' => 'Type',
'LBL_ECMNEWSALE_ID' => 'Quote Id',
'LBL_ECMNEWSALE_NAME' => 'Quote 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' => 'Postalcode / 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_DELIVERYCONDITION_NAME' => 'Delivery Condition',
'LBL_DELIVERYCONDITION_ID' => 'Delivery 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_RECIPIENT_CODE' => 'Recipient Code',
'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',
'LBL_VALIDTILL_DATE' => 'Valid Till',
// FOR MENU LINKS
'LNK_NEW_ECMNEWSALE' => 'Create Quote',
'LNK_ECMNEWSALES_LIST' => 'Quotes 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 Quote?',
'LBL_QUOTE_PDF' => 'Show PDF',
'LBL_QUOTE_PDF_BUTTON_KEY' => 'Show PDF [Alt+P]',
'LBL_QUOTE_PDF_BUTTON_TITLE' => 'Show Quote in PDF file.',
'LBL_QUOTE_TO_INVOICE' => 'Create Invoice',
'LBL_QUOTE_TO_INVOICE_BUTTON_KEY' => 'Create Invoice [Alt+I]',
'LBL_QUOTE_TO_INVOICE_BUTTON_TITLE' => 'Create Invoice.',
'LBL_QUOTE_TO_SALE' => 'Create Sales Order',
'LBL_QUOTE_TO_SALE_BUTTON_KEY' => 'Create Sales Order [Alt+O]',
'LBL_QUOTE_TO_SALE_BUTTON_TITLE' => 'Create Sales Order.',
'LBL_SEND_TO_CONFIRM' => 'Send To Confirm',
'LBL_SEND_TO_CONFIRM_BUTTON_KEY' => 'Send To Confirm [Alt+C]',
'LBL_SEND_TO_CONFIRM_BUTTON_TITLE' => 'Send This Quote To Confirm.',
'LBL_LIST_TO_INVOICE' => 'Create Invoice.',
'LBL_LIST_TO_SALE' => 'Create Sales Order.',
// 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_ACCEPT_BUTTON_TITLE' => 'Accept [Alt+Z]',
'LBL_ACCEPT_BUTTON_KEY' => 'Z',
'LBL_ACCEPT_BUTTON_LABEL' => 'Accept',
'LBL_REJECT_BUTTON_TITLE' => 'Reject [Alt+R]',
'LBL_REJECT_BUTTON_KEY' => 'R',
'LBL_REJECT_BUTTON_LABEL' => 'Reject',
'LBL_GO_TO_LIST_BUTTON_TITLE' => 'Go to quotes list [Alt+G]',
'LBL_GO_TO_LIST_BUTTON_KEY' => 'G',
'LBL_GO_TO_LIST_BUTTON_LABEL' => 'Go to list',
'LBL_SENDEMAIL_BUTTON' => 'Send Email',
'LBL_NOT_SAVED' => 'Quote not saved. Please check all fields are correct!',
'LBL_SAVED' => 'Quote 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' => 'Oferta dla:',
'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_ECMNEWSALES' => 'Quotes',
'LNK_ECMNEWSALES_PDFLANGUAGES' => 'PDF Settings',
'LBL_ECMLANGUAGE' => 'Language',
'LBL_ECMNEWSALES_PDFLANGUAGES_TITLE' => 'PDF Languages Settings',
'LBL_ACCESS_UNAVAIBLE_DELETE_EMAIL' => "You don't have a permission to send Email, because this Quote is not accepted by Manager!",
'LBL_SEND_TO_CONFIRM_ERROR' => "Sending Quote to confirm error! Refresh site and try again.",
'LBL_STATUS_s10_SET_MESSAGE' => "Quote status is set.",
'LBL_STATUS_s20_SET_MESSAGE' => "Now Quote is waiting for confimations.",
'LBL_STATUS_s30_SET_MESSAGE' => "Quote is confirmed.",
'LBL_STATUS_s40_SET_MESSAGE' => "Quote status is set.",
'LBL_STATUS_s70_SET_MESSAGE' => "Quote status is set to Lost :(",
'LBL_STATUS_s20_FAIL_MESSAGE' => "Sending Quote to confirm error! Refresh site and try again.",
'LBL_LIST_SEND_TO_CONFIRM' => 'Send To Confirm',
'LBL_LIST_DUPLICATE' => 'Duplicate',
'LBL_LIST_PREVIEW_PDF' => 'Preview Quote',
'LBL_LIST_REJECT' => 'Reject',
'LBL_LIST_ACCEPT' => 'Accept',
'LBL_MODIFIED_USER' => 'Modified By',
'LBL_DEMO_VERSION_INFORMATION' => "This is only demo version.\nPlease contact us at ca@more7.com.",
'LBL_ORDER_ORIGIN' => 'Order Origin',
'LBL_PREVIEW_HEADER_NAME' => 'Preview',
'LBL_PREVIEW_HEADER_CLOSE' => 'Close',
'LBL_CONTACT_NAME' => 'Contact',
'LBL_CONTACT_ID' => 'Contact Id',
'LBL_PARENT_NAME_COPY' => 'Company Name',
'LBL_PARENT_CONTACT_NAME' => 'Contact Person',
'LBL_PARENT_CONTACT_TITLE' => 'Contact Title',
'LBL_ALERT_ECMLANGUAGE_CHANGE' => 'Would you like to load default texts correspondencing to this language?',
'LBL_LIST_DOWNLOAD_PDF' => 'Download PDF',
'LBL_CREATE_ECMINVOICEOUT_BUTTON_LABEL' => 'Create Invoice',
'LBL_ECMTEAM_NAME' => 'Team',
'LBL_ECMTEAM_ID' => 'Team ID',
'LBL_IMAGE_SIZE' => 'Images size (%)',
//mz new labels
'LBL_SEARCH' => 'Search',
'LBL_CATEGORY' => 'Category',
'LBL_SEARCH_STOCK' => 'Show stock states',
'LBL_SEARCH_STOCK_OPT_NO' => 'Don\'t show stock states',
'LBL_SEARCH_STOCK_OPT_YES' => 'Show stock states',
'LBL_SEARCH_STOCK_OPT_NOT_NULL' => 'Only products on stock',
'LBL_SEARCH_SORT' => 'Sort results by',
'LBL_SEARCH_SORT_CODE' => 'Code ASC',
'LBL_SEARCH_SORT_CODE_DESC' => 'Code DESC',
'LBL_SEARCH_SORT_NAME' => 'Name ASC',
'LBL_SEARCH_SORT_NAME_DESC' => 'Name DESC',
//PDF labels
'LBL_PDF_FOOTER_KRS' => 'KRS:',
'LBL_PDF_FOOTER_NIP' => 'VATID:',
'LBL_PDF_FOOTER_REGON' => 'REGON:',
'LBL_PDF_FOOTER_BANK' => 'Bank name:',
'LBL_PDF_FOOTER_BANK_ACCOUNT' => 'Bank account:',
'LBL_PDF_FOOTER_GIOS' => 'GIOS number:',
'LBL_PDF_FOOTER_SWIFT' => 'Bank SWIFT:',
'LBL_PDF_CONTENT_SALE_FOR' => 'Offer for:',
'LBL_PDF_CONTENT_REGISTER_DATE' => 'Register date:',
'LBL_PDF_CONTENT_DELIVERY_DATE' => 'Delivery date:',
'LBL_PDF_CONTENT_ISSUED_BY' => 'Issued by:',
'LBL_PDF_CONTENT_DELIVERY' => 'Delivery to:',
'LBL_PDF_CONTENT_ILN' => 'ILN:',
'LBL_PDF_CONTENT_NIP' => 'VATID:',
'LBL_PDF_CONTENT_PARENT_DOCUMENT_NO' => 'Buyer order numer:',
'LBL_PDF_CONTENT_NUMBER' => 'Number:',
'LBL_PDF_CONTENT_LIST_POSITION' => 'No.',
'LBL_PDF_CONTENT_LIST_IMAGE' => 'Picture',
'LBL_PDF_CONTENT_LIST_NAME' => 'Name',
'LBL_PDF_CONTENT_LIST_CODE' => 'Index',
'LBL_PDF_CONTENT_LIST_QTY' => 'Quantity',
'LBL_PDF_CONTENT_LIST_UNIT' => 'Unit',
'LBL_PDF_CONTENT_LIST_EAN' => 'Ean',
'LBL_PDF_CONTENT_LIST_EAN2' => 'Ean 2',
'LBL_PDF_CONTENT_LIST_RECIPIENT_CODE' => 'Recipient Code',
'LBL_PDF_CONTENT_LIST_PRICE_START' => 'Start price',
'LBL_PDF_CONTENT_LIST_PRICE_NETTO' => 'Price netto',
'LBL_PDF_CONTENT_LIST_DISCOUNT' => 'Discount',
'LBL_PDF_CONTENT_LIST_TOTAL_NETTO' => 'Total netto',
'LBL_PDF_CONTENT_TOTAL_NETTO' => 'Total netto',
'LBL_PDF_CONTENT_TOTAL_BRUTTO' => 'Total brutto',
)
;
?>

View File

@@ -0,0 +1,424 @@
<?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 (
// FOR SYSTEM USE
'LBL_MODULE_NAME' => 'Quotes',
'LBL_MODULE_TITLE' => 'Quotes: Home',
'LBL_MODULE_ID' => 'EcmSales',
'LBL_SEARCH_FORM_TITLE' => 'Quotes Search',
'LBL_LIST_FORM_TITLE' => 'Quotes List',
'LBL_NEW_FORM_TITLE' => 'New Quote',
'LBL_DETAILS' => 'Quote 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' => 'Account',
'LBL_PARENT_ID' => 'Account Id',
'LBL_TYPE' => 'Type',
'LBL_ECMNEWSALE_ID' => 'Quote Id',
'LBL_ECMNEWSALE_NAME' => 'Quote 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' => 'Postalcode / 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_DELIVERYCONDITION_NAME' => 'Delivery Condition',
'LBL_DELIVERYCONDITION_ID' => 'Delivery 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',
'LBL_VALIDTILL_DATE' => 'Valid Till',
// FOR MENU LINKS
'LNK_NEW_ECMNEWSALE' => 'Create Quote',
'LNK_ECMNEWSALES_LIST' => 'Quotes 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 Quote?',
'LBL_QUOTE_PDF' => 'Show PDF',
'LBL_QUOTE_PDF_BUTTON_KEY' => 'Show PDF [Alt+P]',
'LBL_QUOTE_PDF_BUTTON_TITLE' => 'Show Quote in PDF file.',
'LBL_QUOTE_TO_INVOICE' => 'Create Invoice',
'LBL_QUOTE_TO_INVOICE_BUTTON_KEY' => 'Create Invoice [Alt+I]',
'LBL_QUOTE_TO_INVOICE_BUTTON_TITLE' => 'Create Invoice.',
'LBL_QUOTE_TO_SALE' => 'Create Sales Order',
'LBL_QUOTE_TO_SALE_BUTTON_KEY' => 'Create Sales Order [Alt+O]',
'LBL_QUOTE_TO_SALE_BUTTON_TITLE' => 'Create Sales Order.',
'LBL_SEND_TO_CONFIRM' => 'Send To Confirm',
'LBL_SEND_TO_CONFIRM_BUTTON_KEY' => 'Send To Confirm [Alt+C]',
'LBL_SEND_TO_CONFIRM_BUTTON_TITLE' => 'Send This Quote To Confirm.',
'LBL_LIST_TO_INVOICE' => 'Create Invoice.',
'LBL_LIST_TO_SALE' => 'Create Sales Order.',
//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_ACCEPT_BUTTON_TITLE' => 'Accept [Alt+Z]',
'LBL_ACCEPT_BUTTON_KEY' => 'Z',
'LBL_ACCEPT_BUTTON_LABEL' => 'Accept',
'LBL_REJECT_BUTTON_TITLE' => 'Reject [Alt+R]',
'LBL_REJECT_BUTTON_KEY' => 'R',
'LBL_REJECT_BUTTON_LABEL' => 'Reject',
'LBL_GO_TO_LIST_BUTTON_TITLE' => 'Go to quotes list [Alt+G]',
'LBL_GO_TO_LIST_BUTTON_KEY' => 'G',
'LBL_GO_TO_LIST_BUTTON_LABEL' => 'Go to list',
'LBL_SENDEMAIL_BUTTON' => 'Send Email',
'LBL_NOT_SAVED' => 'Quote not saved. Please check all fields are correct!',
'LBL_SAVED' => 'Quote 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' => 'Oferta 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_ECMNEWSALES' => 'Quotes',
'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_VALIDTILL_DATE' => 'Waznosc oferty',
'LBL_PDF_OWNER' => 'Wystawil',
'LBL_PDF_DOCUMENT_NAME' => 'Oferta',
'LBL_PDF_FILENAME' => 'Quote_',
'LBL_PDF_CODE' => '',
'LNK_ECMNEWSALES_PDFLANGUAGES' => 'PDF Settings',
'LBL_ECMLANGUAGE' => 'Language',
'LBL_ECMNEWSALES_PDFLANGUAGES_TITLE' => 'PDF Languages Settings',
'LBL_ACCESS_UNAVAIBLE_DELETE_EMAIL' => "You don't have a permission to send Email, because this Quote is not accepted by Manager!",
'LBL_SEND_TO_CONFIRM_ERROR' => "Sending Quote to confirm error! Refresh site and try again.",
'LBL_STATUS_s10_SET_MESSAGE' => "Quote status is set.",
'LBL_STATUS_s20_SET_MESSAGE' => "Now Quote is waiting for confimations.",
'LBL_STATUS_s30_SET_MESSAGE' => "Quote is confirmed.",
'LBL_STATUS_s40_SET_MESSAGE' => "Quote status is set.",
'LBL_STATUS_s20_FAIL_MESSAGE' => "Sending Quote to confirm error! Refresh site and try again.",
'LBL_LIST_SEND_TO_CONFIRM' => 'Send To Confirm',
'LBL_LIST_DUPLICATE' => 'Duplicate',
'LBL_LIST_PREVIEW_PDF' => 'Preview Quote',
'LBL_LIST_REJECT' => 'Reject',
'LBL_LIST_ACCEPT' => 'Accept',
'LBL_MODIFIED_USER' => 'Modified By',
'LBL_DEMO_VERSION_INFORMATION' => "This is only demo version.\nPlease contact us at ca@more7.com.",
'LBL_ORDER_ORIGIN' => 'Order Origin',
'LBL_PREVIEW_HEADER_NAME' => 'Preview',
'LBL_PREVIEW_HEADER_CLOSE' => 'Close',
'LBL_CONTACT_NAME' => 'Contact',
'LBL_CONTACT_ID' => 'Contact Id',
'LBL_PARENT_NAME_COPY' => 'Company Name',
'LBL_PARENT_CONTACT_NAME' => 'Contact Person',
'LBL_PARENT_CONTACT_TITLE' => 'Contact Title',
'LBL_ALERT_ECMLANGUAGE_CHANGE' => 'Would you like to load default texts correspondencing to this language?',
'LBL_LIST_DOWNLOAD_PDF' => 'Download PDF',
'LBL_IMAGE_SIZE' => 'Images size (%)',
);
?>

View File

@@ -0,0 +1,491 @@
<?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_PARENT_INDEX_DBF' => 'Indeks',
'LBL_DAYS' => 'Dni',
'LBL_PAYMENT_METHOD' => 'Metoda płatności',
'LBL_SHIPPING_ADDRESS' => 'Adres dostawy',
'LBL_SHIPPING_ADDRESS_NAME' => 'Nazwa',
'LBL_PARENT_ILN' => 'Numer ILN',
'LBL_PARENT_DOCUMENT_NO' => 'Numer zamówienia klienta',
'LBL_DELIVERY_DATE' => 'Data dostawy',
'LBL_ECMPRICE' => 'Ceny B2B',
'LBL_SEARCH' => 'Wyszukaj',
'LBL_CATEGORY' => 'Kategoria',
'LBL_PDF_TEXT' => 'Uwagi',
'LBL_PARENT_NIP' => 'NIP',
'LBL_NO_TAX' => 'Bez Vatu',
'LBL_CREATE_PREPAID'=>'Utwórz Fakturę zaliczkową',
'LBL_SITE' => 'Strona',
'LBL_SHOW_EAN' => 'Pokaż EAN1',
'LBL_SHOW_EAN2' => 'Pokaż EAN2',
'LNK_ECMSALES_LIST'=>'Lista Zamówień sprzedaży',
'LNK_NEW_'.'ECMSALE'=>'Utwórz Zamówienie sprzedaży',
'LNL_NEW_RAPORT'=>'Lista realizacyjna',
// added 01.09.2009
'LBL_ECMLANGUAGE' => 'Język',
'LBL_PRICEBOOK' => 'Cennik',
'LBL_EDITTABLE_RECIPIENT_CODE' => 'Kod Odbiorcy',
// added 05.08.2009
'LBL_CURRENCY' => 'Waluta',
'LBL_DETAIL_BUTTON' => 'Szczegóły',
// added 15.07.2009
'LBL_CREATE_RECEIPT'=>'Utwórz paragon',
'LBL_EDITTABLE_UNIT' => 'J.m.',
// added 09.02.2009
'LBL_SHOW_IMAGES_ON_OFFERS' => 'Pokaż obrazki w PDFie',
'LBL_SHOW_RECIPIENT_CODE' => 'Pokaż kod odbiorcy',
// RAPORT NOWY listnewsales
'LBL_LISTNEWSALES_NAME'=>'Zamówienia sprzedaży: Lista realizacyjna',
'LBL_SEARCH'=>'Wyszukiwanie',
'LBL_LISTNEWSALES_DATE_START'=>'Data od',
'LBL_LISTNEWSALES_DATE_END'=>'do',
'LBL_LISTNEWSALES_PRODUCT_SUMMARY'=>'Lista zbiorcza produktów',
'LBL_LISTNEWSALES_ACCOUNT_NAME'=>'Kontrahent',
'LBL_LISTNEWSALES_DOCUMENT_CREATE_DATE_START'=>'Data utwórzenia od',
'LBL_LISTNEWSALES_NOT_ASSIGNED'=>'Bez Dokumentu WZ',
'LBL_LISTNEWSALES_ORDER_NO'=>'Nr. Zamówienia klienta',
'LBL_SEARCH_NUMBERS'=>'Numeruj',
'LBL_SEARCH_NUMBERS_NO'=>'Nie',
'LBL_SEARCH_NUMBERS_YES'=>'Tak',
'LBL_LISTNEWSALES_ORDER_TYPE'=>'Typ zamówienia',
'LBL_LISTNEWSALES_POST'=>'Szukaj',
'LBL_STOCK_NAME'=>'Magazyn',
'LBL_LISTNEWSALES_CLEAR'=>'Wyczyść',
'LBL_LISTNEWSALES_POS'=>'Pos.',
'LBL_LISTNEWSALES_DESCRIPTION'=>'Opis',
'LBL_LISTNEWSALES_PARENT_NAME'=>'Kontrahent',
'LBL_LISTNEWSALES_DELIVERY_DATE'=>'Data dostawy',
'LBL_SEND_MAIL'=>'Wyślij dokument',
'LBL_LISTNEWSALES_QUANTITY'=>"Ilość",
'LBL_LISTNEWSALES_TOTAL_NETTO'=>'Razem netto',
'LBL_LISTNEWSALES_TOTAL_BRUTTO'=>'Razem brutto',
'LBL_LISTNEWSALES_TOTAL_VAT'=>'Razem VAT',
'LBL_LISTNEWSALES_TOTAL_INVOICE'=>'Razem faktura',
'LBL_LISTNEWSALES_PERCENT'=>'%',
'LBL_LISTNEWSALES_PRINTED'=>'Wydrukowane',
'LBL_LISTNEWSALES_NUMBER'=>'Number',
'LBL_LISTNEWSALES_SUMMARY'=>'Razem',
'LBL_LISTNEWSALES_CREATEWZ'=>'Stwórz WZ',
'LBL_LISTNEWSALES_CREATE_PDFS'=>'Utwórz PDFy',
'LBL_LISTNEWSALES_PRODUCTCODE'=>'Indeks',
'LBL_LISTNEWSALES_PRODUCTNAME'=>'Nazwa produktu',
'LBL_LISTNEWSALES_STOCK'=>'Na magazynie',
'LBL_CREATE_INVOICE'=>'Utwórz Fakturę',
'LBL_LISTNEWSALES_GROUP_KS_1'=>'Towar handlowy',
'LBL_LISTNEWSALES_GROUP_KS_2'=>'Wyrób gotowy',
'LBL_LISTNEWSALES_GROUP_KS_3'=>'Surowiec',
'LBL_LISTNEWSALES_GROUP_KS'=>'Grupa KS',
'LBL_LISTNEWSALES_GROUP_PR'=>'Sortuj po',
'LBL_LISTNEWSALES_CATEGORY'=>'Kategoria',
// RAPORT end
// FOR SYSTEM USE
'LBL_MODULE_NAME' => 'Oferty',
'LBL_MODULE_TITLE' => 'Oferty: Strona Główna',
'LBL_MODULE_ID' => 'EcmSales',
'LBL_SEARCH_FORM_TITLE' => 'Wyszukiwanie',
'LBL_LIST_FORM_TITLE' => 'Lista Zamówień sprzedaży',
'LBL_PDF_CONTENT_NAME'=>'Zamówienie nr',
'LBL_NEW_FORM_TITLE' => 'Nowe Zamówienie sprzedaży',
'LBL_DETAILS' => 'ZS',
'LBL_ITEMS' => 'ZS',
'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' => 'Data modyfikacji',
'LBL_MODIFIED' => 'Ostatnio modyfikowane',
'LBL_STOCK_NAME'=>'Magazyn',
'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' => 'Kontrahent',
'LBL_PARENT_ID' => 'Firma Id',
'LBL_TYPE' => 'Typ',
'LBL_ECMNEWSALE_ID' => 'Id Oferty',
'LBL_ECMNEWSALE_NAME' => 'Nazwa Oferty',
'LBL_STATUS' => 'Status',
'LBL_REGISTER_DATE' => 'Data dokumentu',
'LBL_SELL_DATE' => 'Data Sprzedazy',
'LBL_PAYMENT_DATE' => 'Data płatnosci',
'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',
'LBL_TOTAL' => 'Suma',
'LBL_DISCOUNT' => 'Upust',
'LBL_VAT' => 'VAT',
'LBL_ACCEPTED' => 'Zaakceptowane',
'LBL_TEMPLATE_ID' => 'Id Szablonu',
'LBL_TEMPLATE_NAME' => 'Szablon',
'LBL_PAYMENTCONDITION_NAME' => 'Warunki Platnosci',
'LBL_PAYMENTCONDITION_ID' => 'Warunki Platnosci 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' => 'Kod',
'LBL_EDITTABLE_NAME' => 'Nazwa',
'LBL_EDITTABLE_QUANTITY' => 'Ilosc',
'LBL_EDITTABLE_PRICE' => 'Cena',
'LBL_EDITTABLE_VAT' => 'VAT',
'LBL_EDITTABLE_DISCOUNT' => 'Upust',
'LBL_EDITTABLE_TOTAL' => 'Suma',
'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_ECMNEWSALE' => 'Utwórz Ofertę',
'LNK_ECMNEWSALES_LIST' => 'Lista Ofert',
'LBL_IMG_SEARCH' => 'Wyszukiwanie',
'LBL_IMG_NEW' => 'Nowy, dodaj do bazy',
'LBL_IMG_EDIT' => 'Edycja',
'LBL_CONFIRM_QUESTION' => 'Chcesz potwierdzic tą Ofertę?',
'LBL_QUOTE_PDF' => 'Pokaz PDF',
'LBL_QUOTE_PDF_BUTTON_KEY' => 'Pokaz PDF [Alt+P]',
'LBL_QUOTE_PDF_BUTTON_TITLE' => 'Pokaz Ofertę w pliku PDF.',
'LBL_QUOTE_TO_INVOICE' => 'Stwórz Fakture',
'LBL_QUOTE_TO_INVOICE_BUTTON_KEY' => 'Stwórz Fakture [Alt+I]',
'LBL_QUOTE_TO_INVOICE_BUTTON_TITLE' => 'Stwórz Fakture.',
'LBL_QUOTE_TO_SALE' => 'Stwórz Zamówienie Sprzedazy',
'LBL_QUOTE_TO_SALE_BUTTON_KEY' => 'Stwórz Zamówienie Sprzedazy [Alt+O]',
'LBL_QUOTE_TO_SALE_BUTTON_TITLE' => 'Stwórz Zamówienie Sprzedazy.',
'LBL_SEND_TO_CONFIRM' => 'Wyslij Do Potwierdzenia',
'LBL_SEND_TO_CONFIRM_BUTTON_KEY' => 'Wyslij Do Potwierdzenia [Alt+C]',
'LBL_SEND_TO_CONFIRM_BUTTON_TITLE' => 'Wyslij Do Potwierdzenia.',
'LBL_LIST_TO_INVOICE' => 'Stwórz Fakture.',
'LBL_LIST_TO_SALE' => 'Stwórz Zamówienie Sprzedazy.',
// buttons
'LBL_SEND_BUTTON_TITLE' => 'Zapisz i Wyslij [Alt+D]',
'LBL_SEND_BUTTON_KEY' => 'D',
'LBL_SEND_BUTTON_LABEL' => 'Zapisz i Wyslij',
'LBL_REPAIR_BUTTON_TITLE' => 'Napraw [Alt+R]',
'LBL_REPAIR_BUTTON_KEY' => 'R',
'LBL_REPAIR_BUTTON_LABEL' => 'Napraw',
'LBL_ACCEPT_BUTTON_TITLE' => 'Zaakceptuj [Alt+Z]',
'LBL_ACCEPT_BUTTON_KEY' => 'Z',
'LBL_ACCEPT_BUTTON_LABEL' => 'Zaakceptuj',
'LBL_REJECT_BUTTON_TITLE' => 'Nie akceptuj [Alt+R]',
'LBL_REJECT_BUTTON_KEY' => 'R',
'LBL_REJECT_BUTTON_LABEL' => 'Nie akceptuj',
'LBL_GO_TO_LIST_BUTTON_TITLE' => 'Idz do listy Ofert [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' => 'Oferta nie została zapisana. Sprawdz czy wszytskie pola sa poprawne!',
'LBL_SAVED' => 'Oferta została zapisana pomyslnie.',
'LBL_DEFAULT_CONTACT_HEADER_TEXT' => 'Witaj $contact_full_name!',
'LBL_DEFAULT_CONTACT_FOOTER_TEXT' => 'Tekst pod tabelka dla Contact',
'LBL_DEFAULT_CONTACT_ADS_TEXT' => 'Tekst pogrubiony pod tabelka dla Contact',
'LBL_DEFAULT_ACCOUNT_HEADER_TEXT' => 'Oferta 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_ECMNEWSALES' => 'Oferty',
'LNK_ECMNEWSALES_PDFLANGUAGES' => 'Ustawienia PDF',
'LBL_ECMNEWSALES_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 Oferty ustawiony.",
'LBL_STATUS_s20_SET_MESSAGE' => "Oferta czeka na potwierdzenie.",
'LBL_STATUS_s30_SET_MESSAGE' => "Oferta jest potwierdzony.",
'LBL_STATUS_s40_SET_MESSAGE' => "Status Oferty 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 Oferty',
'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_INVOICE_DATE'=>'Data startowa',
'LBL_PERIODIC_INVOICE'=>'Ustawienia faktury okresowej',
'LBL_ALERT_ECMLANGUAGE_CHANGE' => 'Czy zaladowac domyslne teksty dla tego jezyka?',
'LBL_LIST_DOWNLOAD_PDF' => 'Pobierz PDF',
'LBL_IMAGE_SIZE' => 'Rozmiar obrazków (%)',
// mz new fields
'LBL_SEARCH' => 'Wyszukaj',
'LBL_CATEGORY' => 'Kategoria',
'LBL_SEARCH_STOCK' => 'Stan magazynowy',
'LBL_SEARCH_STOCK_OPT_NO' => 'Nie pokazuj',
'LBL_SEARCH_STOCK_OPT_YES' => 'Pokaż',
'LBL_SEARCH_STOCK_OPT_NOT_NULL' => 'Tylko produkty dostępne',
'LBL_SEARCH_SORT' => 'Sortuj wyniki wg.',
'LBL_SEARCH_SORT_CODE' => 'Kod rosnąco',
'LBL_SEARCH_SORT_CODE_DESC' => 'Kod malejąco',
'LBL_SEARCH_SORT_NAME' => 'Nazwa rosnąco',
'LBL_SEARCH_SORT_NAME_DESC' => 'Nazwa malejąco',
// PDF labels
'LBL_PDF_FOOTER_KRS' => 'KRS:',
'LBL_PDF_FOOTER_NIP' => 'NIP:',
'LBL_PDF_FOOTER_REGON' => 'REGON:',
'LBL_PDF_FOOTER_BANK' => 'Bank:',
'LBL_PDF_FOOTER_BANK_ACCOUNT' => 'Number konta:',
'LBL_PDF_FOOTER_GIOS' => 'Numer GIOS:',
'LBL_PDF_CONTENT_SALE_FOR' => 'NABYWCA:',
'LBL_PDF_CONTENT_ILN' => 'ILN:',
'LBL_PDF_CONTENT_NIP' => 'NIP:',
'LBL_PDF_CONTENT_PARENT_DOCUMENT_NO' => 'Numer zamówienia klienta:',
'LBL_PDF_CONTENT_REGISTER_DATE' => 'Data wystawienia:',
'LBL_PDF_CONTENT_DELIVERY_DATE' => 'Data dokonania lub zakończenia dostawy towarów lub wykonania usługi:',
'LBL_PDF_CONTENT_ISSUED_BY' => 'Wystawił:',
'LBL_PDF_CONTENT_DELIVERY' => 'DOSTAWA:',
'LBL_PDF_CONTENT_NUMBER' => 'Numer:',
'LBL_PDF_CONTENT_LIST_POSITION' => 'Lp.',
'LBL_PDF_CONTENT_LIST_IMAGE' => 'Zdjęcie',
'LBL_PDF_CONTENT_LIST_NAME' => 'Nazwa',
'LBL_PDF_CONTENT_LIST_CODE' => 'Indeks',
'LBL_PDF_CONTENT_LIST_QTY' => 'Ilość',
'LBL_PDF_CONTENT_LIST_UNIT' => 'j.m.',
'LBL_PDF_CONTENT_LIST_EAN' => 'Ean',
'LBL_PDF_CONTENT_LIST_EAN2' => 'Ean 2',
'LBL_PDF_CONTENT_LIST_RECIPIENT_CODE' => 'Kod odbiorcy',
'LBL_PDF_CONTENT_LIST_PRICE_START' => 'Cena początkowa',
'LBL_PDF_CONTENT_LIST_PRICE_NETTO' => 'Cena netto',
'LBL_PDF_CONTENT_LIST_DISCOUNT' => 'Rabat',
'LBL_PDF_CONTENT_LIST_TOTAL_NETTO' => 'Wartość netto',
'LBL_PDF_CONTENT_TOTAL_NETTO' => 'Razem wartość netto',
'LBL_PDF_CONTENT_TOTAL_BRUTTO' => 'Razem wartość brutto'
);
?>

View File

@@ -0,0 +1,20 @@
<?php
if (count ( $_REQUEST ['mass'] )) {
require_once('modules/EcmSales/createPDF.php');
$files = [];
foreach ($_REQUEST['mass'] as &$id) {
$files [] = createEcmSalePdf ( $id, 'FILE', '1' );
}
include 'PDFMerger.php';
if (count ( $files ) > 0) {
$pdf = new PDFMerger ();
foreach ( $files as $file ) {
$pdf->addPDF ( $file );
}
try {
$pdf->merge ( "file", 'zs.pdf' );
} catch ( Exception $e ) {
}
header ( "Location: zs.pdf" );
}
}

View File

@@ -0,0 +1,66 @@
<?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['EcmSales'] = array(
'name' => array('query_type' => 'default'),
'parent_document_no' => 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'),
'delivery_date' => array('query_type' => 'default'),
'parent_name' => array('query' => 'default'),
);

View File

@@ -0,0 +1,348 @@
<?php
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
* *******************************************************************************/
global $app_list_strings;
$viewdefs['EcmSales']['DetailView'] = array(
'templateMeta' => array(
'form' => array(
'buttons' => array(
array(
'customCode' => '{if $CAN_EDIT == true} <input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="button" onclick="this.form.return_module.value=\'EcmSales\'; 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="Duplikuj" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="button" onclick="this.form.return_module.value=\'EcmSales\'; 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="Duplikuj" id="duplicate_button">'
),
array(
'customCode' => '{$CREATE_PDF}'
),
array(
'customCode' => " {include_php file='include/ECM/EcmSendPdfButton/EcmSendPdfButtonController.php'}"
),
array(
'customCode' => '{$CREATE_DOCS}'
),
array(
'customCode' => '{if $can_copy_to_e5 == true} <input name="e5Sale" id="e5Sale" class="button" onclick="window.open(\'https://crm.e5.pl/REST/index.php?key=7e50a8a5-f01f-4fbc-8c1b-59f3fc474bb5&action=copySaleFromTwinpol&record={$fields.id.value}\');" type="button" value="Kopiuj zamówienie do E5">{/if}'
),
'DELETE'
),
'hidden' => array(
'<input type="hidden" name="vats_summary" id="vats_summary" value=\'{$fields.vats_summary.value}\'>',
'<input type="hidden" id="total_netto" value=\'{$fields.total_netto.value}\'>',
'<input type="hidden" id="total_brutto" value=\'{$fields.total_brutto.value}\'>',
'<input type="hidden" id="discount" value=\'{$fields.discount.value}\'>',
'<input type="hidden" id="no_tax" value=\'{$fields.no_tax.value}\'>'
)
),
'maxColumns' => '2',
'widths' => array(
array(
'label' => '10',
'field' => '30'
),
array(
'label' => '10',
'field' => '30'
)
),
'includes' => array(
array(
'file' => 'include/JSON.js'
),
array(
'file' => 'modules/EcmSales/javascript/EcmSalesDetail.js'
),
array(
'file' => 'modules/EcmSales/javascript/bimit_table4.js'
),
array(
'file' => 'modules/EcmSales/javascript/columndefs-detail.js'
)
)
),
'panels' => array(
'LBL_DETAILS_TAB' => array(
array(
'document_no',
'assigned_user_name'
),
array(
array(
'name' => 'parent_name',
'customCode' => '<a href="index.php?module=Accounts&action=DetailView&record={$fields.parent_id.value}">{$fields.parent_name.value}</a>'
),
'type'
),
array(
'register_date',
'status'
),
array(
'delivery_date',
'stock_name'
),
array(
'payment_date',
'parent_document_no'
),
array(
'payment_date_days',
''
),
array(
'send_date',
'send_accepted'
),
array(
'payment_method',
''
),
array(
array(
'name' => 'wz_no',
'label' => 'Dokument WZ',
'customCode' => '{$wz_no}'
),
array(
'name' => 'fv_no',
'label' => 'Dokument FV',
'customCode' => '{$fk_no}'
),
),
array (
'main_sale_number'
),
array(
array(
'name' => 'to_informations',
'allCols' => true,
'hideLabel' => true,
'customCode' => '<br><b>{$MOD.LBL_TO_INFORMATIONS}</b>'
)
),
array(
array(
'name' => 'parent_name_copy',
'customCode' => '{$fields.parent_name.value}'
),
array(
'name' => 'currency_id',
'label' => 'LBL_CURRENCY'
)
),
array(
'parent_nip'
),
array(
'parent_index_dbf',
),
array(
'parent_address_street',
),
array(
array(
'name' => 'parent_address_city',
'tabIndex' => '1',
'customCode' => '{$fields.parent_address_postalcode.value}&nbsp;&nbsp;{$fields.parent_address_city.value}'
)
),
array(
'parent_address_country'
),
array(
'parent_iln'
),
array(
array(
'name' => 'to_informations',
'allCols' => true,
'hideLabel' => true,
'customCode' => '<br><b>{$MOD.LBL_SHIPPING_ADDRESS}</b>'
)
),
array(
array(
'name' => 'shipping_address_name',
'customCode' => '{$fields.shipping_address_name.value}'
)
),
array(
array(
'name' => 'shipping_phone',
'customCode' => '{$fields.shipping_phone.value}'
)
),
array(
'shipping_address_street'
),
array(
array(
'name' => 'shipping_address_city',
'tabIndex' => 't',
'customCode' => '{$fields.shipping_address_postalcode.value}&nbsp;&nbsp;{$fields.shipping_address_city.value}'
)
),
array(
'shipping_address_country'
),
array(
array(
'name' => 'shipping_nip',
'tabIndex' => '1'
)
),
array(
'shipping_iln'
),
array(
'pdf_text'
),
array(
array(
'name' => 'to_informations',
'allCols' => true,
'hideLabel' => true,
'customCode' => '<br>'
)
),
array(
array(
'name' => 'date_modified',
'label' => 'LBL_DATE_MODIFIED',
'customCode' => '{$fields.date_modified.value} {$APP.LBL_BY} {$MODIFIED_BY_NAME}'
),
array(
'name' => 'date_entered',
'customCode' => '{$fields.date_entered.value} {$APP.LBL_BY} {$CREATED_BY_NAME}'
)
),
array(
array(
'allCols' => true,
'hideLabel' => true,
'customCode' => '<div class="tabForm" style="border-top:none;width:100%;height:1px;padding:0px;align:center;"></div><h4>{$MOD.LBL_PERIODIC_INVOICE}</h4>'
)
),
array(
array(
'name' => 'invoice_date',
'tabIndex' => '1'
), 'invoice_date_interval'
)
),
'LBL_ITEMS_TAB' => array(
array(
array(
'name' => 'items_list_panel',
'allCols' => true,
'hideLabel' => true,
'customCode' => '<div id="itemsTable"></div>'
)
)
)
)
);

View File

@@ -0,0 +1,380 @@
<?php
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
* *******************************************************************************/
global $sugar_config;
$viewdefs['EcmSales']['EditView'] = array(
'templateMeta' => array(
'form' => array(
'enctype' => 'multipart/form-data',
'buttons' => array(
array(
'customCode' => '<input class="button primary" type="submit" value="Zapisz" name="button" onclick="this.form.action.value=\'Save\'; return check_form(\'EditView\',event);" accesskey="S" title="Zapisz [Alt+S]">',
), 'CANCEL'
),
'hidden' => array(
'<input type="hidden" name="position_list" id="position_list" value=\'{$POSITION_LIST}\'>',
'<input type="hidden" name="new_number" id="new_number" value=\'{$NEW_NUMBER}\'>',
'<input type="hidden" name="vats_summary" id="vats_summary" value=\'\'>',
'<input type="hidden" id="total_netto" name="total_netto" value=\'{$fields.total_netto.value}\'>',
'<input type="hidden" id="total_brutto" name="total_brutto" value=\'{$fields.total_brutto.value}\'>',
'<input type="hidden" id="discount" name="discount" value=\'{$fields.discount.value}\'>',
'<input type="hidden" id="duplicate" name="duplicate" value=\'{$DUPLICATE}\'>',
'<input type="hidden" id="ecmquote_id" name="ecmquote_id" value=\'{$ECMQUOTE_ID}\'>',
'<input type="hidden" id="ecmsale_id" name="ecmsale_id" value=\'{$ECMSALE_ID}\'>',
'<input type="hidden" id="ecommerce_products" name="ecommerce_products" value=\'{$ECOMMERCE_PRODUCTS}\'>',
'<input type="hidden" id="ecommerce_invoices" name="ecommerce_invoices" value=\'{$ECOMMERCE_INVOICES}\'>',
)
),
'maxColumns' => '2',
'widths' => array(
array(
'label' => '10',
'field' => '30'
),
array(
'label' => '10',
'field' => '30'
)
),
'includes' => array(
array(
'file' => 'include/JSON.js'
),
array(
'file' => 'modules/EcmSales/javascript/EcmSales3.js'
),
array(
'file' => 'modules/EcmSales/javascript/bimit_table4.js'
),
array(
'file' => 'modules/EcmSales/javascript/columndefs2.js'
),
array(
'file' => 'include/ECM/EcmDocumentNumberGenerator/EcmDocumentNumberGenerator.js'
),
)
),
'panels' => array(
'LBL_DETAILS_TAB' => array(
array(
array(
'type' => 'tab',
'active' => true
)
),
array(
array(
'name' => 'document_no',
'tabIndex' => '1',
'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}\'>'
),
array(
'name' => 'assigned_user_name',
'tabIndex' => '1'
)
),
array(
array(
'name' => 'parent_name',
'tabIndex' => '1',
'displayParams' => array(
'required' => true,
'size' => 45
)
),
array(
'name' => 'type',
'tabIndex' => '1'
),
),
array(
array(
'name' => 'register_date',
'tabIndex' => '1',
'type' => 'datetime',
'displayParams' => array(
'showFormats' => true
)
),
array(
'name' => 'status',
'tabIndex' => '1'
),
),
array(
array(
'name' => 'delivery_date',
'tabIndex' => '1',
'type' => 'datetime',
'displayParams' => array(
'showFormats' => true
)
),
array(
'name' => 'stock_id',
'label' => 'LBL_STOCK_NAME',
'customCode' => '{$STOCK}'
)
),
array(
array(
'name' => 'payment_date',
'tabIndex' => '1',
'type' => 'datetime',
),
array(
'name' => 'parent_document_no',
'label' => 'LBL_PARENT_DOCUMENT_NO',
),
),
array(
array(
'name' => 'payment_date_days',
'label' => 'LBL_DAYS',
'customCode' => '<input type="number" min="0" id="payment_date_days" name="payment_date_days"/> '
)
),
array(
'send_date',
'send_accepted'
),
array(
'payment_method',
array(
'label' => 'Cennik',
'name' => 'pricebook',
'customCode' => ' <div id=\'pricebooks\'></div>'
)
),
array (
array (
'name' => 'main_sale_number',
'tabIndex' => '1'
),
''
),
array(
array(
'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}" style="width:450px" readOnly="readonly" size="30" />'
),
array(
'name' => 'currency_id',
'label' => 'LBL_CURRENCY'
),
),
array(
array(
'name' => 'parent_index_dbf',
'label' => 'LBL_PARENT_INDEX_DBF',
),
array(
'name' => 'pdf_type',
'label' => 'Typ pdf'
),
),
array(
array(
'name' => 'parent_nip',
'tabIndex' => '1'
),
),
array(
array(
'name' => 'parent_iln',
'tabIndex' => '1'
),
),
array(
array(
'name' => 'parent_address_street',
'tabIndex' => '1',
'customCode' => '<textarea tabindex="1" id="parent_address_street" name="parent_address_street" style="width:450px;height:50px;" maxlength="150" >{$fields.parent_address_street.value}</textarea>'
),
),
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'
),
),
//shipping address section
array(
array(
'allCols' => true,
'hideLabel' => true,
'customCode' => '<div class="tabForm" style="border-top:none;width:100%;height:1px;padding:0px;align:center;"></div><h4>{$MOD.LBL_SHIPPING_ADDRESS}</h4>'
)
),
array(
array(
'name' => 'shipping_address',
'label' => 'Lista',
'customCode' => '<div id=\'addresses\'></div>',
), '',
),
array(
array(
'name' => 'shipping_address_name',
'tabIndex' => '1',
'customCode' => '<input type="text" name="shipping_address_name" id="shipping_address_name" value="{$fields.shipping_address_name.value}" style="width:450px" size="30" />'
),
),
array(
array(
'name' => 'shipping_phone',
'tabIndex' => '1',
'customCode' => '<input type="text" name="shipping_phone" id="shipping_phone" value="{$fields.shipping_phone.value}" style="width:450px" size="30" />'
),
),
array(
array(
'name' => 'shipping_address_street',
'tabIndex' => '1',
'customCode' => '<textarea tabindex="1" id="shipping_address_street" name="shipping_address_street" style="width:450px;height:50px;" maxlength="150" >{$fields.shipping_address_street.value}</textarea>'
)
),
array(
array(
'name' => 'shipping_address_city',
'tabIndex' => '1',
'customCode' => '<input maxlength="8" type="text" name="shipping_address_postalcode" id="shipping_address_postalcode" value="{$fields.shipping_address_postalcode.value}" style="vertical-align:top;width:80px;" />&nbsp;&nbsp;<input type="text" name="shipping_address_city" id="shipping_address_city" value="{$fields.shipping_address_city.value}" style="vertical-align:top;width:150px;" />'
)
),
array(
array(
'name' => 'shipping_address_country',
'tabIndex' => '1'
)
),
array(
array(
'name' => 'shipping_nip',
'tabIndex' => '1'
)
),
array(
'shipping_iln'
),
array(
array(
'allCols' => true,
'hideLabel' => true,
'customCode' => '<div class="tabForm" style="border-top:none;width:100%;height:1px;padding:0px;align:center;"></div><h4>{$MOD.LBL_PERIODIC_INVOICE}</h4>'
)
),
array(
array(
'name' => 'invoice_date',
'tabIndex' => '1'
),
array(
'name' => 'invoice_date_interval',
'label' => 'Powtarzaj co',
'customCode' => '<input type="number" min="1" value="{$fields.invoice_date_interval.value}" max="12" id="invoice_date_interval" name="invoice_date_interval"/> Miesięcy'
)
),
array(
array(
'allCols' => true,
'hideLabel' => true,
'customCode' => '<div class="tabForm" style="border-top:none;width:100%;height:1px;padding:0px;align:center;"></div><h4>{$MOD.LBL_PDF_TEXT}</h4>'
)
),
array(
array(
'allCols' => true,
'hideLabel' => true,
'name' => 'pdf_text'
)
)
),
'LBL_ITEMS_TAB' => array(
array(
array(
'type' => 'tab'
)
),
array(
array(
'allCols' => true,
'hideLabel' => true,
'customCode' => '
<div id="searchProducts" class="edit view search basic">
<br>
<input type="hidden" id="searchStart" name="searchStart" value="0">
<input type="hidden" id="searchCount" name="searchCount" value="">
<input type="hidden" id="searchSort" name="searchSort" value="1">
{$MOD.LBL_SEARCH}:&nbsp;&nbsp;
<input type="text" value="" id="searchProductsInput"/>
<img onclick="$(\'#searchProductsInput\').val(\'%\');searchProducts();" src="modules/EcmSales/images/search.gif" style="cursor: pointer;">
{$MOD.LBL_CATEGORY}:&nbsp;&nbsp;
<select id="productSearchCategory"></select>
{$MOD.LBL_SEARCH_STOCK}:&nbsp;&nbsp;
<select id="productSearchStock" onchange="searchProducts();">
<option value="1">Produkty</option>
<option value="4">Magazyn </option>
<option value="3">Dostępne</option>
</select>
&nbsp;&nbsp;
<button onclick="createProduct();" class="button" type="button"><img src="themes/default/images/id-ff-add.png"></button>
<input type="hidden" id="newProductId" value=""/>
</div>
<div id="searchResultDiv"/></div>
<br><br><div id="itemsTable"></div>'
)
)
)
)
);

View File

@@ -0,0 +1,164 @@
<?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["EcmSales"] = array(
'STATUS' => array(
'width' => '2',
'label' => 'LBL_STATUS',
'default' => true,
'sortable' => true
),
'DOCUMENT_NO' => array(
'width' => '2',
'label' => 'LBL_DOCUMENT_NO',
'sortable' => true,
'link' => true,
'default' => true
),
'PARENT_NAME' => array(
'width' => '8',
'label' => 'LBL_PARENT_NAME',
'default' => true
),
'TOTAL_NETTO' => array(
'width' => '5',
'label' => 'Wartość netto',
'default' => true,
'align'=>'right',
'sumType' => 'sum',
),
'DOCUMENT_AUTOINCREMENT' => array(
'width' => '3',
'label' => 'Data dokumentu',
'default' => true,
),
'DELIVERY_DATE' => array(
'width' => '3',
'label' => 'Data dostawy',
'default' => true,
),
'PARENT_DOCUMENT_NO' => array(
'width' => '2',
'label' => 'Nr zamówienia kl.',
'default' => true,
'align'=>'left',
),
'SHOP_NUMBER' => array(
'width' => '2',
'label' => 'Nr sklepu',
'default' => true,
'sortable'=>false,
'align'=>'left',
),
'ASSIGNED_USER_NAME' => array(
'width' => '5',
'label' => 'LBL_CREATED_BY_USER',
'module' => 'Users',
'id' => 'USERS_ID',
'default' => true,
'sortable' => false,
'related_fields' => array(
'ASSIGNED_USER_ID'
),
),
'WZ' => array(
'width' => '3',
'label' => 'Dokument WZ',
'default' => true,
'sortable'=>false,
'align'=>'left',
'link' => false,
),
'FV' => array(
'width' => '3',
'label' => 'Faktura',
'default' => true,
'sortable'=>false,
'align'=>'left',
'link' => false,
),
'ZS' => array(
'width' => '3',
'label' => 'ZS e5',
'default' => true,
'sortable'=>false,
'align'=>'left',
'link' => false,
),
'OPTIONS' => array(
'width' => '2',
'label' => 'PDF',
'default' => true,
'sortable' => false,
'align' => 'center'
)
)
;
?>

View File

@@ -0,0 +1,109 @@
<?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['EcmSales'] = array(
'templateMeta' => array(
'maxColumns' => '3',
'widths' => array(
'label' => '10',
'field' => '30'
),
),
'layout' => array(
'basic_search' => array(
'document_no',
'status',
'type',
'parent_document_no',
'parent_name',
array('name' => 'current_user_only', 'label' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'),
'register_date',
'delivery_date',
'order_source'
),
'advanced_search' => array(
'document_no',
'status',
'type',
'parent_document_no',
'parent_name',
array('name' => 'current_user_only', 'label' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'),
'register_date',
'delivery_date',
'order_source'
),
),
);

View File

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

View File

@@ -0,0 +1,122 @@
<?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['EcmSales']['subpanel_setup'] = array (
'documents' => array(
'order' => 130,
'module' => 'Documents',
'subpanel_name' => 'default',
'get_subpanel_data' => 'documents',
'title_key' => 'Dokumenty',
),
'ecmprepaymentinvoice' => array(
'order' => 130,
'module' => 'EcmPrepaymentInvoices',
'subpanel_name' => 'default',
'get_subpanel_data' => 'ecmprepaymentinvoice',
'title_key' => 'Faktury zaliczkowe',
),
/*
'emails' => array (
'order' => 15,
'module' => 'Emails',
'sort_order' => 'asc',
'sort_by' => 'date_modified',
'get_subpanel_data' => 'emails',
'add_subpanel_data' => 'emails_id',
'subpanel_name' => 'ForEcmSales',
'title_key' => 'LBL_EMAILS_SUBPANEL_TITLE',
'top_buttons' => array(),
),
*/
);
?>

View File

@@ -0,0 +1,128 @@
<?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".
*/
$subpanel_layout = array(
'where' => '',
'list_fields' => array (
/*
'number' => array (
'name' => 'number',
'vname' => 'LBL_NUMBER',
'module' => 'EcmSales',
'usage' => 'query_only',
),
*/
'document_no' => array (
'name' => 'document_no',
'vname' => 'LBL_DOCUMENT_NO',
'module' => 'EcmSales',
'widget_class' => 'SubPanelDetailViewLink',
'width' => '5%',
),
'PARENT_NAME' => array(
'width' => '10%',
'vname' => 'Kontrahent',
'default' => true,
),
'register_date' => array (
'name' => 'register_date',
'vname' => 'LBL_REGISTER_DATE',
'module' => 'EcmSales',
'width' => '5%',
),
'QUANTITY' => array (
'name' => 'quantity',
'vname' => 'Ilość',
'align'=>'right',
'module' => 'EcmSales',
'width' => '5%',
),
'PRICE_NETTO' => array (
'name' => 'price_netto',
'vname' => 'Cena netto',
'align'=>'right',
'module' => 'EcmSales',
'width' => '5%',
),
'TOTAL_NETTO' => array (
'name' => 'total_netto',
'vname' => 'Wartość netto',
'align'=>'right',
'module' => 'EcmSales',
'width' => '5%',
),
'options' => array (
'name' => 'options',
'label' => '&nbsp;',
'default' => true,
'width' => '5%',
'sortable' => false,
),
'status' => array (
'name' => 'status',
'vname' => 'LBL_STATUS',
'module' => 'EcmSales',
'width' => '60%',
),
/*
'PDF_URL' => array(
'width' => '2%',
'label' => '&nbsp;',
'link' => true,
'default' => true,
'sortable' => false,
),
'edit_button'=>array(
'widget_class' => 'SubPanelEditButton',
'width' => '2%',
),
*/
),
);
?>

View File

@@ -0,0 +1,122 @@
<?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".
*/
$subpanel_layout = array(
'top_buttons' => array(
array('widget_class' => 'SubPanelTopCreateButton'),
array('widget_class' => 'SubPanelTopSelectButton', 'popup_module' => 'EcmSales'),
),
'where' => '',
'list_fields' => array (
/*
'number' => array (
'name' => 'number',
'vname' => 'LBL_NUMBER',
'module' => 'EcmSales',
'usage' => 'query_only',
),
*/
'document_no' => array (
'name' => 'document_no',
'vname' => 'LBL_DOCUMENT_NO',
'module' => 'EcmSales',
'widget_class' => 'SubPanelDetailViewLink',
'width' => '5%',
),
'register_date' => array (
'name' => 'register_date',
'vname' => 'LBL_REGISTER_DATE',
'module' => 'EcmSales',
'width' => '5%',
),
'total_netto' => array (
'name' => 'total_netto',
'vname' => 'Wartość netto',
'align'=>'right',
'module' => 'EcmSales',
'width' => '5%',
),
'total_brutto' => array (
'name' => 'total',
'vname' => 'Wartość brutto',
'align'=>'right',
'module' => 'EcmSales',
'width' => '5%',
),
'options' => array (
'name' => 'options',
'label' => '&nbsp;',
'default' => true,
'width' => '5%',
'sortable' => false,
),
'status' => array (
'name' => 'status',
'vname' => 'LBL_STATUS',
'module' => 'EcmSales',
'width' => '75%',
),
/*
'PDF_URL' => array(
'width' => '2%',
'label' => '&nbsp;',
'link' => true,
'default' => true,
'sortable' => false,
),
'edit_button'=>array(
'widget_class' => 'SubPanelEditButton',
'width' => '2%',
),
*/
),
);
?>

19
modules/EcmSales/multiPdf.php Executable file
View File

@@ -0,0 +1,19 @@
<?php
include "include/ECM/EcmMultiPdf/EcmMultiPdf.inc";
$db = $GLOBALS ['db'];
$docs = array ();
$res = $db->query ( "SELECT id FROM ecmsales ORDER BY date_entered DESC LIMIT 0,5" );
while ( $r = $db->fetchByAssoc ( $res ) ) {
$tmp = array ();
$tmp ['module'] = 'EcmSales';
$tmp ['record'] = $r ['id'];
$docs [] = $tmp;
}
var_dump($docs);
$mp = new EcmMultiPdf($docs, 'multi.pdf');
echo $r = $mp->process();
?>

View File

@@ -0,0 +1,55 @@
<?php
$db=$GLOBALS['db'];
//,'7e2d6029-cfd3-ca7b-587f-59ce2429601f'
$query="select id from ecmsales where deleted=0 and id in ('7e2d6029-cfd3-ca7b-587f-59ce2429601f')";
$zap=$db->query($query);
while($dane=$db->fetchByAssoc($zap)){
$query2="select id from ecmstockdocouts where so_id='".$dane['id']."' and deleted=0";
echo $query2;
$zap2=$db->query($query2);
$dane2=$db->fetchByAssoc($zap2);
if($dane2['id']!=""){
$cenaz=$db->query("select * from ecmstockoperations where parent_id='".$dane2['id']."'");
echo "select * from ecmstockoperations where parent_id='".$dane2['id']."'";
$ceny=[];
while($cenyz=$db->fetchByAssoc($cenaz)){
$ceny[]=$cenyz['price'];
}
var_dump($ceny);
$query3="select id from ecminvoiceouts where so_id='".$dane['id']."' and deleted=0";
$zap3=$db->query($query3);
$dane3=$db->fetchByAssoc($zap3);
if($dane3['id']!=""){
$query44="select id from ecminvoiceoutitems where deleted=0 and ecminvoiceout_id='".$dane3['id']."'";
$zap222=$db->query($query44);
$pos=0;
while($xx=$db->fetchByAssoc($zap222)){
$upate_q="update ecminvoiceoutitems set price_purchase='".$ceny[$pos]."' where id='".$xx['id']."'";
$db->query($upate_q);
$pos++;
}
$razem="update ecminvoiceouts set purchase_price=(select sum(quantity*price) as total from ecmstockoperations where parent_id='".$dane2['id']."' and deleted=0) where id='".$dane3['id']."'";
$db->query($razem);
}
}
}
?>

View File

@@ -0,0 +1,14 @@
<?php
$ids = explode(',',$_REQUEST['ids']);
$db = $GLOBALS['db'];
$res = $db->query("SELECT code, name, SUM(quantity) AS qty FROM ecmsaleitems WHERE ecmsale_id IN ('".implode("','", $ids)."') GROUP BY ecmproduct_id ORDER BY code");
$t = '<table style="border: 1px solid black; border-collapse: collapse;"><tr><td><b>Kod</b></td><td><b>Nazwa</b></td><td><b>Ilość</b></td></tr>';
while ($r = $db->fetchByAssoc($res))
$t.='<tr><td style="border: 1px solid black;">'.$r['code'].'</td><td style="border: 1px solid black;">'.$r['name'].'</td><td style="border: 1px solid black;">'.$r['qty'].'</td></tr>';
$t.='</table>';
echo $t;
?>

View File

@@ -0,0 +1,198 @@
<?php
ini_set ( 'display_errors', 1 );
/*
* Wgrywanie i czytanie plików XML do obiektu Autor: Dominik 'DranZi' Brzóska
*/
define ( "FILE_DIR", "/home/saas/invoice/" ); // ścieżka do katalogu z xml'kami
class readXML {
private $db;
private $file_name; // nazwa wgranego pliku
private $content; // zaladowany plik xml
private $nodes; // załadowane elementy
public $parent_iln;
public $parent_nip;
public $parent_id;
public $parent_name;
public $ecmpaymentcondition_id;
public $ecmpaymentcondition_name;
public $supplier_code;
public $register_date;
public $delivery_date;
public $assigned_user_id;
public $parent_document_no;
public $shipping_addresses;
public $parent_address_street;
public $parent_address_country;
public $parent_address_postalcode;
public $parent_address_city;
public $shipping_address_name;
public $shipping_address_street;
public $shipping_address_country;
public $shipping_address_postalcode;
public $shipping_address_city;
public $shipping_nip;
public $shipping_iln;
public $position_list;
private $c;
/*
* Wgrywa plik na serwer
*/
function UploadXMLFile() {
$allowedExts = array (
"xml"
);
$temp = explode ( ".", $_FILES ["file"] ["name"] );
$extension = end ( $temp );
$this->file_name = date ( "Y_d_m" ) . str_replace ( " ", "", str_replace ( "_", "", str_replace ( ".", "", microtime () ) ) ) . '.' . $extension;
if ($_FILES ["file"] ["error"] > 0) {
return '0';
} else {
if (file_exists ( FILE_DIR . $_FILES ["file"] ["name"] )) {
return '0';
} else {
move_uploaded_file ( $_FILES ["file"] ["tmp_name"], FILE_DIR . $this->file_name );
return $this->file_name;
}
}
}
//add mz 2014-10-15
//Pobiera jedynie nazwę składającego zamówienie
function loadAccount($file) {
$this->db = $GLOBALS ['db'];
if ($file == '')
$file = $this->file_name;
else
$this->file_name = $file;
$this->content = file_get_contents ( FILE_DIR . $this->file_name );
$this->nodes = new SimpleXMLElement ( $this->content );
$result = $this->db->fetchByAssoc ( $this->db->query ( "select name from accounts where iln like '" . $this->nodes->{'Order-Parties'}->Buyer->ILN . "'" ) );
return $result['name'];
}
/*
* Otwiera plik XML :)
*/
function loadXMLFile($file) {
$this->db = $GLOBALS ['db'];
if ($file == '')
$file = $this->file_name;
else
$this->file_name = $file;
$this->content = file_get_contents ( FILE_DIR . $this->file_name );
$this->nodes = new SimpleXMLElement ( $this->content );
// pobierz dane z klienta
$result = $this->db->fetchByAssoc ( $this->db->query ( "select to_vatid,register_address_street,register_address_city,register_address_postalcode,register_address_country,id,assigned_user_id,name,parent_id,supplier_code,ecmpaymentcondition_id,ecmpaymentcondition_name,payment_date_days from accounts where iln like '" . $this->nodes->{'Order-Parties'}->Buyer->ILN . "'" ) );
$this->parent_id = $result ['id'];
$this->parent_name = $result ['name'];
$this->parent_iln = $this->nodes->{'Order-Parties'}->Buyer->ILN;
$this->parent_nip = $result ['to_vatid'];
$this->parent_address_street = $result ['register_address_street'];
$this->parent_address_city = $result ['register_address_city'];
$this->parent_address_postalcode = $result ['register_address_postalcode'];
$this->parent_address_country = $result ['register_address_country'];
$this->parent_document_no = $this->nodes->{'Order-Header'}->OrderNumber;
// adres dostawy
// pobierz dane z klienta
$result3 = $this->db->fetchByAssoc ( $this->db->query ( "
SELECT
a.to_vatid,
dr.street as register_address_street,
dr.city as register_address_city,
dr.postalcode as register_address_postalcode,
dr.country as register_address_country,
a.id,
a.assigned_user_id,
a.name,
a.parent_id,
a.supplier_code,
a.ecmpaymentcondition_id,
a.ecmpaymentcondition_name,
a.payment_date_days
FROM
accounts a
inner join account_addresses dr on dr.account_id=a.id
WHERE
a.iln LIKE '" . $this->nodes->{'Order-Parties'}->DeliveryPoint->ILN . "' and a.deleted=0 and dr.deleted=0 order by dr. position asc" ) );
$this->shipping_address_name = $result3 ['name'];
$this->shipping_addresses = $result3 ['name'];
$this->shipping_address_street = $result3 ['register_address_street'];
$this->shipping_address_city = $result3 ['register_address_city'];
$this->shipping_address_postalcode = $result3 ['register_address_postalcode'];
$this->shipping_address_country = $result3 ['register_address_country'];
$this->shipping_iln = $this->nodes->{'Order-Parties'}->DeliveryPoint->ILN;
$this->shipping_nip = $result3 ['to_vatid'];
if ($result ['payment_date_days'])
$this->payment_date_days= $result ['payment_date_days'];
if ($result ['supplier_code'])
$this->supplier_code = $result ['supplier_code'];
if ($result2 ['supplier_code'])
$this->supplier_code = $result2 ['supplier_code'];
$this->register_date = date ( "d.m.Y", strtotime ( $this->nodes->{'Order-Header'}->OrderDate ) );
$this->delivery_date = date ( "d.m.Y", strtotime ( $this->nodes->{'Order-Header'}->ExpectedDeliveryDate ) );
$date = new DateTime(date ( "d.m.Y", strtotime ( $this->nodes->{'Order-Header'}->OrderDate )) );
if($this->payment_date_days!=""){
$date->modify("+".$this->payment_date_days." day");
}
$this->payment_date = $date->format("d.m.Y");
$this->assigned_user_id = $_SESSION ['authenticated_user_id'];
$this->position_list = array ();
}
/*
* Pobiera produkty z xml
*/
function getPositionList($array = false) {
$this->c = 0;
foreach ( $this->nodes->{'Order-Lines'}->Line as $prod ) {
$w = $this->db->query ( "select p.id from ecmproducts as p where (TRIM(p.ean)='" . trim ( $prod->{'Line-Item'}->EAN ) . "' OR TRIM(p.ean2)='" . trim ( $prod->{'Line-Item'}->EAN ) . "') and p.deleted='0'" );
$r = $GLOBALS ['db']->fetchByAssoc ( $w );
$ecmp = new EcmProduct ();
$ecmp->retrieve ( $r ['id'] );
$this->position_list [$this->c] ['product_id'] = $ecmp->id;
$this->position_list [$this->c] ['position'] = ( string ) $prod->{'Line-Item'}->LineNumber;
$this->position_list [$this->c] ['product_code'] = $ecmp->code;
$this->position_list [$this->c] ['name'] = $ecmp->name;
$this->position_list [$this->c] ['quantity'] = ( string ) $prod->{'Line-Item'}->OrderedQuantity;
$this->position_list [$this->c] ['price_start'] = ( string ) $prod->{'Line-Item'}->OrderedUnitNetPrice;
$this->position_list [$this->c] ['price_netto'] = ( string ) $prod->{'Line-Item'}->OrderedUnitNetPrice;
$this->position_list [$this->c] ['discount'] = 0;
$this->position_list [$this->c] ['total_netto'] = ( string ) $prod->{'Line-Item'}->OrderedUnitNetPrice * $prod->{'Line-Item'}->OrderedQuantity;
$this->position_list [$this->c] ['unit_id'] = 1;
$this->position_list [$this->c] ['unit_name'] = 'szt.';
$this->position_list [$this->c] ['ecmvat_id'] = $ecmp->vat_id;
$this->position_list [$this->c] ['ecmvat_name'] = $ecmp->vat_name;
$this->position_list [$this->c] ['ecmvat_value'] = $ecmp->vat_value;
$this->position_list [$this->c] ['recipient_code'] = ( string ) $prod->{'Line-Item'}->BuyerItemCode;
$this->position_list [$this->c] ['product_ean'] = ( string ) trim ( $prod->{'Line-Item'}->EAN );
$this->c ++;
}
$json = getJSONobj ();
return $array ? $this->position_list : $json->encode ( $this->position_list );
}
/*
* załaduj dane do zewnętrznej klasy
*/
function loader($klasa) {
foreach ( $this as $key => $value ) {
$rp = new ReflectionProperty ( $this, $key );
if ($rp->isPrivate () == 1)
continue;
$klasa->$key = $this->$key;
}
}
}
?>

111
modules/EcmSales/repairunits.php Executable file
View File

@@ -0,0 +1,111 @@
<?php
ini_set("display_errors",1);
error_reporting(E_ALL);
ini_set ( 'max_execution_time', 9999999999 );
$db=$GLOBALS['db'];
include 'PDFMerger.php';
$pdf = new PDFMerger ();
$query="select id from ecmstockdocouts where delivery_date='2017-10-04' and deleted=0";
$res = $db->query($query);
while($dane = $db->fetchByAssoc($res)){
$file = createEcmStockDocOutPdf($dane['id']);
$pdf->addPDF ($file);
$pdf->addPDF ($file);
}
$query="select id from ecminvoiceouts where register_date='2017-10-02' and deleted=0";
$res = $db->query($query);
while($dane = $db->fetchByAssoc($res)){
$file = createEcmInvoiceOutPdf($dane['id']);
$pdf->addPDF ($file);
}
try {
$pdf->merge ( "file", 'mojpdf.pdf' );
} catch (Exception $e) {
}
echo "skończyłem!";
function createEcmStockDocOutPdf($record) {
include_once ("modules/EcmStockDocOuts/PDFTemplate/helper.php");
$focus = new EcmStockDocOut ();
$focus->retrieve ( $record );
$user = new User ();
$user->retrieve ( $focus->assigned_user_id );
include_once ("include/MPDF57/mpdf.php");
$p = new mPDF ( '', 'A4', null, 'helvetica', 10, 10, 30, 45, 5, 5 );
$labels = return_module_language ( $focus->ecmlanguage, 'EcmStockDocOuts' );
$mpdf->mirrorMargins = 1;
$db = $GLOBALS ['db'];
$positions = formatPDFPositions22 ( $focus->getPositionList ( true ), $focus );
$quantity = getQuantity22 ( $focus->getPositionList ( true ), $focus );
$content = '';
include ("modules/EcmStockDocOuts/PDFTemplate/content.php");
$ec = new EcmSysInfo ();
$footer = $ec->getFooterForModule ( 'EcmStockDocOuts' );
$header = $ec->getHeaderForModule ( 'EcmStockDocOuts' );
$p->SetHTMLHeader ( $header );
$p->SetHTMLFooter ( $footer );
$p->WriteHTML ( $content );
$EcmSysInfo = new EcmSysInfo ();
$dir = 'upload/' . $EcmSysInfo->getDatabaseName () . '/pdf/EcmStockDocOuts/';
if (! is_dir ( $dir )) {
mkdir ( $dir, '755', true );
}
$file_name = create_guid () . '.pdf';
$p->Output ( $dir . $file_name, "F" );
return $dir . $file_name;
}
function createEcmInvoiceOutPdf($record, $outputtype) {
$EcmInvoiceOut = new EcmInvoiceOut ();
$EcmInvoiceOut->retrieve ( $record );
$file_location = $EcmInvoiceOut->get_PDF_file_path ( '0' );
$EcmSysInfo = new EcmSysInfo ();
if ($EcmSysInfo->getDatabaseName () == 'preDb_60b08fe051546309b61d2714d4a0438d') {
$file_location = newPDFCreator ( $record, $type, true );
}
// return;
switch ($outputtype) {
case "BROSWER" :
header ( "Location: " . $file_location );
return true;
case "FILE" :
$path = $file_location;
break;
case "EMAIL" :
include_once 'include/ECM/EcmSendMail/EcmSendMail.inc';
$path = EcmSendMail::TEMP_DIR . 'ZS_' . $EcmInvoiceOut->number . '.pdf';
copy ( $file_location, $path );
break;
case "MULTIPDF" :
include_once 'include/ECM/EcmMultiPdf/EcmMultiPdf.inc';
$path = EcmMultiPdf::TEMP_DIR . 'EcmSales_' . $focus->id . '_' . create_guid () . '.pdf';
copy ( $file_location, $path );
break;
}
;
return $file_location;
}
?>

View File

@@ -0,0 +1,257 @@
<?php
ini_set ( 'max_execution_time', 9999999999 );
ini_set ( 'memory_limit', - 1 );
$db = $GLOBALS ['db'];
if ($_GET ['ids'] != "") {
$moj_post = $_GET['ids'];
$files = [ ];
$i = 0;
foreach ( $moj_post as $moje_id ) {
unset ( $dane );
unset ( $ecmsale );
$query = "select so_id from ecmstockdocouts where so_id='" . $moje_id . "' and deleted=0";
$result = $db->query ( $query );
$dane = $db->fetchByAssoc ( $result );
$ecmsale = new EcmSale ();
$ecmsale->retrieve ( $moje_id );
if ($dane ['so_id'] == "") {
$positions = $ecmsale->getPositionList ( true );
$wz = new EcmStockDocOut ();
$wz->register_date = date ( 'd.m.Y' );
$wz->stock_id = $ecmsale->stock_id;
$wz->order_no = $ecmsale->parent_document_no;
$wz->currency_id = $ecmsale->currency_id;
$wz->delivery_date = $ecmsale->delivery_date;
$wz->parent_id = $ecmsale->parent_id;
$wz->parent_name = $ecmsale->parent_name;
$wz->created_by = $current_user->id;
$wz->assigned_user_id = $current_user->id;
$wz->parent_address_street = $ecmsale->parent_address_street;
$wz->parent_address_postalcode = $ecmsale->parent_address_postalcode;
$wz->parent_address_city = $ecmsale->parent_address_city;
$wz->parent_address_country = $ecmsale->parent_address_country;
$wz->parent_nip = $ecmsale->parent_nip;
$wz->parent_iln = $ecmsale->parent_iln;
$wz->currency_id = 'PLN';
$wz->category = 'wz_products';
$wz->shipping_address_name = $ecmsale->shipping_address_name;
$wz->shipping_address_postalcode = $ecmsale->shipping_address_postalcode;
$wz->shipping_address_city = $ecmsale->shipping_address_city;
$wz->shipping_address_country = $ecmsale->shipping_address_country;
$wz->shipping_address_street = $ecmsale->shipping_address_street;
$wz->shipping_nip = $ecmsale->shipping_nip;
$wz->shipping_iln = $ecmsale->shipping_iln;
$wz->position_list = $positions;
$wz->so_id = $ecmsale->id;
$wz->save ();
$files [] = createEcmStockDocOutPdf ( $wz->id, 'FILE' );
echo "Do zamówienia nr ZS " . $ecmsale->document_no . " został utworzony dokument WZ nr: <a href='index.php?module=EcmStockDocOuts&action=DetailView&record=" . $wz->id . "'>" . $wz->document_no . '</a><br>';
$invoice = new EcmInvoiceOut ();
$invoice->parent_id = $wz->parent_id;
$invoice->parent_name = $wz->parent_name;
$invoice->order_no = $wz->order_no;
// dates
$invoice->type = 'normal';
$invoice->stock_id = $wz->stock_id;
$invoice->register_date = date ( "d.m.Y" );
$invoice->sell_date = $wz->register_date;
$invoice->validtill_date = date ( "d.m.Y" );
$payment_date = new DateTime();
$payment_date->modify("+".$ecmsale->payment_date_days.' day');
$invoice->so_id = $ecmsale->id;
$invoice->payment_date = $payment_date->format("Y-m-d");
$invoice->payment_date_days = $ecmsale->payment_date_days;
// var_dump($ecmsale->payment_method);
$invoice->payment_method = 'PRZELEW';
$invoice->payment_method_paid = '0';
$invoice->parent_address_street = $ecmsale->parent_address_street;
$invoice->parent_address_postalcode = $ecmsale->parent_address_postalcode;
$invoice->parent_address_city = $ecmsale->parent_address_city;
$invoice->parent_address_country = $ecmsale->parent_address_country;
$invoice->parent_nip = $ecmsale->parent_nip;
$invoice->parent_iln = $ecmsale->parent_iln;
$invoice->parent_shipping_address_name = $ecmsale->shipping_address_name;
$invoice->parent_shipping_address_street = $ecmsale->shipping_address_street;
$invoice->parent_shipping_address_postalcode = $ecmsale->shipping_address_postalcode;
$invoice->parent_shipping_address_city = $ecmsale->shipping_address_city;
$invoice->parent_shipping_address_country = $ecmsale->shipping_address_country;
$invoice->parent_shipping_nip = $ecmsale->shipping_nip;
$invoice->parent_shipping_iln = $ecmsale->shipping_iln;
// saturn??
$tmp_a = new Account ();
$tmp_a->retrieve ( $wz->parent_id );
if ($tmp_a->parent_id == '1249') {
$a = new Account ();
$a->retrieve ( '1249' );
$invoice->supplier_code = '2503793';
$invoice->parent_payer_address_name = $a->name;
$invoice->parent_payer_address_street = $a->register_address_street;
$invoice->parent_payer_address_postalcode = $a->register_address_postalcode;
$invoice->parent_payer_address_city = $a->register_address_city;
$invoice->parent_payer_address_country = $a->register_address_country;
$invoice->parent_payer_nip = $a->to_vatid;
$invoice->parent_payer_iln = $a->iln;
$invoice->parent_address_street= 'Al. Jerozolimskie 179';
$invoice->parent_address_postalcode= '02-222';
$invoice->parent_address_city= 'Warszawa';
$invoice->parent_address_country= 'Polska';
}
$invoice->bankaccount=$tmp_a->invoice_bank_account ;
$invoice->pdf_text=$tmp_a->pdf_text;
if ($tmp_a->parent_id == '1249') {
$invoice->bankaccount=$a->invoice_bank_account ;
$invoice->pdf_text=$a->pdf_text;
}
$invoice->pdf_type = "K";
$invoice->currency_id = $ecmsale->currency_id;
$invoice->created_by = $current_user->id;
$invoice->assigned_user_id = $current_user->id;
$invoice->wz_id=$wz->id;
$invoice->wz_name=$wz->document_no;
$cenaz=$db->query("select * from ecmstockoperations where parent_id='".$wz->id."'");
$ceny=[];
while($cenyz=$db->fetchByAssoc($cenaz)){
$ceny[]=$cenyz['price'];
}
foreach ($positions as $key=>$position){
$positions[$key]['price_purchase']=$ceny[$key];
}
$invoice->position_list = $positions;
$invoice->save ();
$db->query("update ecminvoiceouts set purchase_price=(select sum(quantity*price) as total from ecmstockoperations where parent_id='".$wz->id."' and deleted=0) where id='".$invoice->id."'");
$files [] = createEcmInvoiceOutPdf ( $invoice->id, 'FILE' );
$query2 = "update ecmsales set status='s90' where id='" . $moje_id . "'";
$db->query ( $query2 );
echo "Do zamówienia nr ZS " . $ecmsale->document_no . " została utworzona faktura nr: <a href='index.php?module=EcmInvoiceOuts&action=DetailView&record=" . $invoice->id . "'>" . $invoice->document_no . '</a><br>';
} else {
echo "<span style='color:red'>UWAGA: Zamówienie nr: ZS " . $ecmsale->document_no . ' posiada już wystawiony dokument WZ!<br></span><br>';
}
$i++;
}
if (count ( $files ) > 0) {
unlink ( 'produkcja.pdf' );
include 'PDFMerger.php';
$pdf = new PDFMerger ();
foreach ( $files as $file ) {
$pdf->addPDF ( $file );
}
echo "Wygenerowano dokument zbiorczy, kliknij <a href='produkcja.pdf'>TUTAJ</a> aby pobrać!";
$pdf->merge ( "file", 'produkcja.pdf' );
die();
}
}
function createEcmStockDocOutPdf($record) {
include_once ("modules/EcmStockDocOuts/PDFTemplate/helper.php");
$focus = new EcmStockDocOut ();
$focus->retrieve ( $record );
$user = new User ();
$user->retrieve ( $focus->assigned_user_id );
include_once ("include/MPDF57/mpdf.php");
$p = new mPDF ( '', 'A4', null, 'helvetica', 10, 10, 30, 45, 5, 5 );
$labels = return_module_language ( $focus->ecmlanguage, 'EcmStockDocOuts' );
$mpdf->mirrorMargins = 1;
$db = $GLOBALS ['db'];
$positions = formatPDFPositions22 ( $focus->getPositionList ( true ), $focus );
$quantity = getQuantity22 ( $focus->getPositionList ( true ), $focus );
$content = '';
include ("modules/EcmStockDocOuts/PDFTemplate/content.php");
$ec = new EcmSysInfo ();
$footer = $ec->getFooterForModule ( 'EcmStockDocOuts' );
$header = $ec->getHeaderForModule ( 'EcmStockDocOuts' );
$p->SetHTMLHeader ( $header );
$p->SetHTMLFooter ( $footer );
$p->WriteHTML ( $content );
$EcmSysInfo = new EcmSysInfo ();
$dir = 'upload/' . $EcmSysInfo->getDatabaseName () . '/pdf/EcmStockDocOuts/';
if (! is_dir ( $dir )) {
mkdir ( $dir, '755', true );
}
$file_name = create_guid () . '.pdf';
$p->Output ( $dir . $file_name, "F" );
return $dir . $file_name;
}
function createEcmInvoiceOutPdf($record, $outputtype) {
$EcmInvoiceOut = new EcmInvoiceOut ();
$EcmInvoiceOut->retrieve ( $record );
$file_location = $EcmInvoiceOut->get_PDF_file_path ( '0' );
$EcmSysInfo = new EcmSysInfo ();
if ($EcmSysInfo->getDatabaseName () == 'preDb_60b08fe051546309b61d2714d4a0438d') {
$file_location = newPDFCreator ( $record, $type, true );
}
// return;
switch ($outputtype) {
case "BROSWER" :
header ( "Location: " . $file_location );
return true;
case "FILE" :
$path = $file_location;
break;
case "EMAIL" :
include_once 'include/ECM/EcmSendMail/EcmSendMail.inc';
$path = EcmSendMail::TEMP_DIR . 'ZS_' . $EcmInvoiceOut->number . '.pdf';
copy ( $file_location, $path );
break;
case "MULTIPDF" :
include_once 'include/ECM/EcmMultiPdf/EcmMultiPdf.inc';
$path = EcmMultiPdf::TEMP_DIR . 'EcmSales_' . $focus->id . '_' . create_guid () . '.pdf';
copy ( $file_location, $path );
break;
}
;
return $file_location;
}
?>

33
modules/EcmSales/sendEmail.php Executable file
View File

@@ -0,0 +1,33 @@
<?php
// create and save document pdf
require_once 'modules/EcmSales/createPDF.php';
$filename = createEcmSalePdf($_REQUEST['record'], 'EMAIL');
$filename = basename($filename);
// create mailService object
require_once 'include/ECM/EcmSendMail/EcmSendMail.inc';
$mS = new EcmSendMail (); // mS = mailService
$mS->setSubject ( "śśś" );
$mS->setMessage ( "śćźłó" );
$mS->setSender ( 'outtervision2@gmail.com', 'łóżś' );
$mS->setAddresses ( array (
'outtervision@gmail.com' => 'Michał Zieliński'
) );
$mS->setCCAddresses ( array (
'mz@bim-it.pl' => 'Michał Zieliński'
) );
$mS->setBCCAddresses ( array (
'mz@saas-systes.pl' => 'Michał Zieliński'
) );
// include PDF
$s = new EcmSale ();
$s->retrieve ( $_REQUEST ['record'] );
$mS->setAttachments ( array (
$filename
) );
//delete pdf after send
$mS->setClearTemp(true);
$mS->sendMail ();
echo $mS->getStatus ();
unset($mS); //cleaning
// jeśli status = 1 to można teraz np. dodać notatke pod kontrahentem i ZSem, że wiadomość została wysłana
?>

923
modules/EcmSales/vardefs.php Executable file
View File

@@ -0,0 +1,923 @@
<?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['EcmSale'] = array(
'table' => "ecmsales",
'comment' => 'EcmSales',
'duplicate_merge' => true,
'unified_search' => true,
// FIELDS SECTION
'fields' => array(
'document_autoincrement' => array(
'name' => 'document_autoincrement',
'vname' => 'Data dokumentu',
'type' => 'varchar',
'reportable' => true,
// 'source' => 'non-db',
'required' => false
),
'send_date' => array(
'name' => 'send_date',
'vname' => 'Data wysyłki',
'type' => 'date',
'reportable' => false,
'showFormats' => true,
'massupdate' => false,
'required' => true
),
'send_accepted' =>
array(
'massupdate' => false,
'name' => 'send_accepted',
'vname' => 'Termin niepotwierdzony',
'type' => 'bool',
'default' => '0',
),
// 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'
),
'status' => array(
'name' => 'status',
'vname' => 'LBL_STATUS',
'type' => 'enum',
'size' => '3',
'options' => 'ecmsales_status_dom',
'massupdate' => false,
),
'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'
),
'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',
'group' => 'stock_name',
'massupdate' => false,
'required' => false,
),
'stock_id' =>
array(
'name' => 'stock_id',
'type' => 'enum',
'module' => 'EcmStocks',
'table' => 'ecmstocks',
'vname' => 'LBL_STOCK_NAME',
'group' => 'stock_name',
'options' => 'ecmstocks_list_dom',
'required' => false,
'massupdate' => false,
),
'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
),
'payment_date' => array(
'name' => 'payment_date',
'vname' => 'LBL_PAYMENT_DATE',
'type' => 'date',
'reportable' => false,
'showFormats' => true,
'massupdate' => false,
'required' => false
),
'payment_date_days' => array(
'name' => 'payment_date_days',
'vname' => 'LBL_DAYS',
'type' => 'varchar',
'len' => 5
),
'invoice_date_interval' => array(
'name' => 'invoice_date_interval',
'vname' => 'Powtarzaj co',
'type' => 'varchar',
'len' => 5
),
'payment_method' => array(
'name' => 'payment_method',
'vname' => 'LBL_PAYMENT_METHOD',
'type' => 'enum',
'options' => 'payment_method_dom'
),
'invoice_date' => array(
'name' => 'invoice_date',
'vname' => 'LBL_INVOICE_DATE',
'type' => 'date',
'reportable' => false,
'showFormats' => true,
'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' => 'ecmsales' . '_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' => 'ecmsales' . '_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' => 'ecmsales' . '_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
'number' => array(
'name' => 'number',
'vname' => 'LBL_NUMBER',
'type' => 'varchar',
'required_option' => true,
'unified_search' => true,
'required' => false,
'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_document_no' => array(
'name' => 'parent_document_no',
'vname' => 'LBL_PARENT_DOCUMENT_NO',
'type' => 'varchar',
'len' => '50'
),
'parent_name' => array(
'name' => 'parent_name',
'id_name' => 'parent_id',
'vname' => 'LBL_PARENT_NAME',
'type' => 'relate',
'group' => 'parent_name',
'dbtype' => 'varchar',
'len' => '255',
'module' => 'Accounts',
'massupdate' => false,
'required' => true
),
'parent_id' => array(
'name' => 'parent_id',
'type' => 'id',
'module' => 'Accounts',
'vname' => 'LBL_PARENT_ID',
'group' => 'parent_name',
'massupdate' => false,
'reportable' => false,
'required' => true
),
'type' => array(
'name' => 'type',
'vname' => 'LBL_TYPE',
'required' => true,
'type' => 'enum',
'options' => 'ecmsales_type_dom',
'massupdate' => false
),
'register_date' => array(
'name' => 'register_date',
'vname' => 'LBL_REGISTER_DATE',
'type' => 'date',
'reportable' => false,
'showFormats' => true,
'massupdate' => false,
'required' => true
),
'delivery_date' => array(
'name' => 'delivery_date',
'vname' => 'LBL_DELIVERY_DATE',
'type' => 'date',
'reportable' => false,
'showFormats' => true,
'massupdate' => false,
),
'parent_name_copy' => array(
'name' => 'parent_name_copy',
'vname' => 'LBL_PARENT_NAME_COPY',
'type' => 'varchar',
'source' => 'non-db'
),
'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'
),
'parent_iln' => array(
'name' => 'parent_iln',
'vname' => 'LBL_PARENT_ILN',
'type' => 'varchar',
'group' => 'parent_address',
),
'shipping_address_name' => array(
'name' => 'parent_address_name',
'vname' => 'LBL_SHIPPING_ADDRESS_NAME',
'type' => 'varchar',
'len' => '205',
'group' => 'shipping_address',
'merge_filter' => 'enabled'
),
'shipping_address_street' => array(
'name' => 'shipping_address_street',
'vname' => 'LBL_PARENT_ADDRESS_STREET',
'type' => 'varchar',
'len' => '150',
'group' => 'shipping_address',
'merge_filter' => 'enabled'
),
'shipping_address_city' => array(
'name' => 'shipping_address_city',
'vname' => 'LBL_PARENT_ADDRESS_CITY',
'type' => 'varchar',
'len' => '100',
'group' => 'shipping_address',
'merge_filter' => 'enabled'
),
'edi_zs_id' => array(
'name' => 'edi_zs_id',
'vname' => '',
'type' => 'varchar',
'len' => 255,
),
'edi_zs_document_no' => array(
'name' => 'edi_zs_document_no',
'vname' => '',
'type' => 'varchar',
'len' => 255,
),
'shipping_address_postalcode' => array(
'name' => 'shipping_address_postalcode',
'vname' => 'LBL_PARENT_ADDRESS_POSTALCODE',
'type' => 'varchar',
'len' => '20',
'group' => 'shipping_address',
'merge_filter' => 'enabled'
),
'shipping_address_country' => array(
'name' => 'shipping_address_country',
'vname' => 'LBL_PARENT_ADDRESS_COUNTRY',
'type' => 'varchar',
'group' => 'shipping_address',
'merge_filter' => 'enabled'
),
'shipping_iln' => array(
'name' => 'shipping_iln',
'vname' => 'LBL_PARENT_ILN',
'type' => 'varchar',
'group' => 'parent_address',
),
'shipping_phone' => array(
'name' => 'shipping_phone',
'vname' => 'Numer telefonu',
'type' => 'varchar',
'len' => '50',
'group' => 'shipping_address',
'merge_filter' => 'enabled'
),
'order_source' => array(
'name' => 'order_source',
'vname' => 'Źródło zamówienia',
'type' => 'enum',
'size' => '50',
'options' => 'ecmsales_source_dom',
'massupdate' => false,
),
'order_source_id' => array(
'name' => 'order_source_id',
'vname' => 'ID zródła zamówienia',
'type' => 'varchar',
'len' => '36'
),
//enc shipping address
'total_netto' => array(
'name' => 'total_netto',
'vname' => 'LBL_SUBTOTAL',
'type' => 'decimal',
'len' => '15,2',
),
'total_brutto' =>
array(
'name' => 'total_brutto',
'vname' => 'LBL_TOTAL',
'type' => 'decimal',
'len' => '15,2',
),
'ecmproduct_id' =>
array(
'name' => 'ecmproduct_id',
'vname' => 'produkt',
'type' => 'varchar',
'len' => '244',
'source' => 'non-db'
),
'discount' =>
array(
'name' => 'discount',
'type' => 'decimal',
'len' => '15,2',
),
'vats_summary' =>
array(
'name' => 'vats_summary',
'type' => 'varchar',
'len' => '200',
),
'parent_nip' =>
array(
'name' => 'parent_nip',
'vname' => 'LBL_PARENT_NIP',
'type' => 'varchar',
'len' => 15,
),
'parent_index_dbf' =>
array(
'name' => 'parent_index_dbf',
'vname' => 'LBL_PARENT_INDEX_DBF',
'type' => 'varchar',
'len' => 50,
),
'shipping_nip' =>
array(
'name' => 'shipping_nip',
'vname' => 'LBL_PARENT_NIP',
'type' => 'varchar',
'len' => 15,
),
'parent_nip_unformated' =>
array(
'name' => 'parent_nip_unformated',
'vname' => 'LBL_PARENT_NIP',
'type' => 'varchar',
'len' => 15,
),
'pdf_text' => array(
'name' => 'pdf_text',
'vname' => 'LBL_PDF_TEXT',
'type' => 'text'
),
//prices
'pdf_type' => array(
'name' => 'pdf_type',
'type' => 'enum',
'options' => 'account_invoice_type_dom',
'label' => 'LBL_PDF_TYPE'
),
'ecmprice_id' => array(
'name' => 'ecmprice_id',
'type' => 'varchar',
'len' => '36',
'vname' => 'LBL_PRICE',
'source' => 'non_db'
),
'ecmprice_name' => array(
'name' => 'ecmprice_name',
'type' => 'relate',
'id_name' => 'ecmprice_id',
'module' => 'EcmPrices',
'len' => '30',
'vname' => 'LBL_PRICE',
'source' => 'non-db',
'rname' => 'name'
),
//end prices
'no_tax' =>
array(
'massupdate' => false,
'name' => 'no_tax',
'vname' => 'LBL_NO_TAX',
'type' => 'bool',
'default' => '0',
),
'currency_id' => array(
'name' => 'currency_id',
'type' => 'enum',
'options' => 'currency_dom',
'label' => 'LBL_CURRENCY'
),
'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,
'required' => false,
),
'ecmpaymentcondition_text' => array(
'name' => 'ecmpaymentcondition_text',
'vname' => 'LBL_PAYMENTCONDITION_TEXT',
'type' => 'text',
'reportable' => false,
'module' => 'EcmPaymentConditions',
'duplicate_merge' => 'disabled',
'massupdate' => false
),
'ecmdeliverycondition_id' => array(
'name' => 'ecmdeliverycondition_id',
'rname' => 'name',
'id_name' => 'ecmdeliverycondition_id',
'vname' => 'LBL_DELIVERYCONDITION_ID',
'group' => 'ecmdeliverycondition_name',
'type' => 'relate',
'table' => 'ecmdeliveryconditions',
'reportable' => true,
'Importable' => false,
'isnull' => 'false',
'dbType' => 'id',
'audited' => true,
'duplicate_merge' => 'disabled',
'massupdate' => false
),
'ecmdeliverycondition_name' => array(
'name' => 'ecmdeliverycondition_name',
'vname' => 'LBL_DELIVERYCONDITION_NAME',
'type' => 'relate',
'reportable' => false,
'source' => 'non-db',
'table' => 'ecmdeliverycondition',
'id_name' => 'ecmdeliverycondition_id',
'module' => 'EcmDeliveryConditions',
'duplicate_merge' => 'disabled',
'massupdate' => false,
'required' => false,
),
'ecmdeliverycondition_text' => array(
'name' => 'ecmdeliverycondition_text',
'vname' => 'LBL_DELIVERYCONDITION_TEXT',
'type' => 'text',
'reportable' => false,
'module' => 'EcmDeliveryConditions',
'duplicate_merge' => 'disabled',
'massupdate' => false
),
'pricebook_id' => array(
'name' => 'pricebook_id',
'vname' => 'LBL_PRICEBOOK_NAME',
'type' => 'id',
'source' => 'non-db',
),
'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'
),
'ecmlanguage' =>
array(
'name' => 'ecmlanguage',
'vname' => 'LBL_ECMLANGUAGE',
'type' => 'enum',
'options' => 'ecmlanguages_dom',
'len' => 35,
'massupdate' => false,
),
// Main sale, add mz@bim-it.pl 01.02.2024
'main_sale_number' => array(
'name' => 'main_sale_number',
'rname' => 'document_no',
'id_name' => 'main_sale_id',
'vname' => 'Zamówienie główne',
'type' => 'relate',
'group' => 'main_sale_number',
'dbtype' => 'varchar',
'len' => '50',
'module' => 'EcmSales',
'massupdate' => false,
'required' => false
),
'main_sale_id' => array(
'name' => 'main_sale_id',
'type' => 'id',
'module' => 'EcmSales',
//'vname' => 'LBL_PARENT_ID',
'group' => 'main_sale_number',
'massupdate' => false,
'reportable' => false,
'required' => false
),
// FOR SUBPANELS
'documents' => array(
'name' => 'documents',
'type' => 'link',
'relationship' => 'ecmsales_documents',
'source' => 'non-db',
'vname' => 'LBL_NOTES'
),
'account' => array(
'name' => 'account',
'type' => 'link',
'relationship' => 'ecmsales_account',
'source' => 'non-db',
'vname' => 'LBL_ACCOUNTS'
),
'ecmprepaymentinvoice' => array(
'name' => 'ecmprepaymentinvoice',
'type' => 'link',
'relationship' => 'ecmsales_ecmprepaymentinvoices',
'source' => 'non-db',
'vname' => 'Faktury przedpłatowe'
),
'contact' => array(
'name' => 'contact',
'type' => 'link',
'relationship' => 'ecmsales_contact',
'source' => 'non-db',
'vname' => 'LBL_CONTACTS'
),
'bugs' => array(
'name' => 'bugs',
'type' => 'link',
'relationship' => 'ecmsales_bug',
'source' => 'non-db',
'vname' => 'LBL_BUGS'
),
'notes' => array(
'name' => 'notes',
'type' => 'link',
'relationship' => 'ecmsales_notes',
'source' => 'non-db',
'vname' => 'LBL_NOTES'
),
'emails' => array(
'name' => 'emails',
'type' => 'link',
'relationship' => 'ecmsales_emails',
'source' => 'non-db',
'vname' => 'LBL_EMAILS'
),
'tasks' => array(
'name' => 'tasks',
'type' => 'link',
'relationship' => 'ecmsales_task',
'source' => 'non-db',
'vname' => 'LBL_TASKS'
)
),
// INDICES SECTION
'indices' => array(
array(
'name' => 'ecmsales' . 'pk',
'type' => 'primary',
'fields' => array(
'id'
)
),
array(
'name' => 'idx_' . 'ecmsales' . '_document_no',
'type' => 'index',
'fields' => array(
'document_no'
)
)
),
// RELATIONSHIPS SECTION
'relationships' => array(
'ecmsales' . '_assigned_user' => array(
'lhs_module' => 'Users',
'lhs_table' => 'users',
'lhs_key' => 'id',
'rhs_module' => 'EcmSales',
'rhs_table' => 'ecmsales',
'rhs_key' => 'assigned_user_id',
'relationship_type' => 'one-to-many'
),
'ecmsales_documents' => array(
'lhs_module' => 'EcmSales',
'lhs_table' => 'ecmsales',
'lhs_key' => 'id',
'rhs_module' => 'Documents',
'rhs_table' => 'documents',
'rhs_key' => 'id',
'relationship_type' => 'many-to-many',
'join_table' => 'documents_accounts',
'join_key_lhs' => 'parent_id',
'join_key_rhs' => 'document_id',
),
'ecmsales' . '_modified_user' => array(
'lhs_module' => 'Users',
'lhs_table' => 'users',
'lhs_key' => 'id',
'rhs_module' => 'EcmSales',
'rhs_table' => 'ecmsales',
'rhs_key' => 'modified_user_id',
'relationship_type' => 'one-to-many'
),
'ecmsales' . '_created_by' => array(
'lhs_module' => 'Users',
'lhs_table' => 'users',
'lhs_key' => 'id',
'rhs_module' => 'EcmSales',
'rhs_table' => 'ecmsales',
'rhs_key' => 'created_by',
'relationship_type' => 'one-to-many'
),
'ecmsales' . '_account' => array(
'lhs_module' => 'Accounts',
'lhs_table' => 'accounts',
'lhs_key' => 'id',
'rhs_module' => 'EcmSales',
'rhs_table' => 'ecmsales',
'rhs_key' => 'parent_id',
'relationship_type' => 'one-to-many'
),
'ecmsales' . '_contact' => array(
'lhs_module' => 'Contacts',
'lhs_table' => 'contacts',
'lhs_key' => 'id',
'rhs_module' => 'EcmSales',
'rhs_table' => 'ecmsales',
'rhs_key' => 'contact_id',
'relationship_type' => 'one-to-many'
),
'ecmsales' . '_project' => array(
'lhs_module' => 'Project',
'lhs_table' => 'project',
'lhs_key' => 'id',
'rhs_module' => 'EcmSales',
'rhs_table' => 'ecmsales',
'rhs_key' => 'parent_id',
'relationship_type' => 'one-to-many'
),
'ecmsales' . '_bug' => array(
'lhs_module' => 'Bugs',
'lhs_table' => 'bugs',
'lhs_key' => 'id',
'rhs_module' => 'EcmSales',
'rhs_table' => 'ecmsales',
'rhs_key' => 'parent_id',
'relationship_type' => 'one-to-many'
),
'ecmsales_notes' => array(
'lhs_module' => 'EcmSales',
'lhs_table' => 'ecmsales',
'lhs_key' => 'id',
'rhs_module' => 'Notes',
'rhs_table' => 'notes',
'rhs_key' => 'parent_id',
'relationship_type' => 'one-to-many',
'relationship_role_column' => 'parent_type',
'relationship_role_column_value' => 'EcmSales'
),
'ecmsales_ecmprepaymentinvoices' => array(
'lhs_module' => 'EcmSales',
'lhs_table' => 'ecmsales',
'lhs_key' => 'id',
'rhs_module' => 'EcmPrepaymentInvoices',
'rhs_table' => 'ecmprepaymentinvoices',
'rhs_key' => 'ecmsale_id',
'relationship_type' => 'one-to-many',
),
'ecmsales' . '_case' => array(
'lhs_module' => 'Cases',
'lhs_table' => 'cases',
'lhs_key' => 'id',
'rhs_module' => 'EcmSales',
'rhs_table' => 'ecmsales',
'rhs_key' => 'parent_id',
'relationship_type' => 'one-to-many'
),
'ecmsales' . '_task' => array(
'lhs_module' => 'Tasks',
'lhs_table' => 'tasks',
'lhs_key' => 'id',
'rhs_module' => 'EcmSales',
'rhs_table' => 'ecmsales',
'rhs_key' => 'parent_id',
'relationship_type' => 'one-to-many'
)
),
// THIS FLAG ENABLES OPTIMISTIC LOCKING FOR SAVES FROM EDITVIEW
'optimistic_locking' => true
);

View File

@@ -0,0 +1,94 @@
<?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,186 @@
<?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 ViewEditEcmSales 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 ViewEditEcmSales(){
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,242 @@
<?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 EcmSalesViewList extends ViewList
{
function EcmSalesViewList()
{
parent::ViewList();
}
function display()
{
if (!$this->bean->ACLAccess('list')) {
ACLController::displayNoAccess();
return;
}
$this->module = $module = "EcmSales";
$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();
}
}
}
?>

159
modules/EcmSales/wzCreator.php Executable file
View File

@@ -0,0 +1,159 @@
<?php
echo '<link rel="stylesheet" type="text/css" href="modules/EcmSales/css/style.css"/>';
echo '<script type="text/javascript"
src="include/jQuery/jquery.tablesorter.js"></script>';
echo '<script type="text/javascript"
src="include/jQuery/jquery.tablesorter.pager.js"></script>';
$db = $GLOBALS ['db'];
ini_set ( 'max_execution_time', 9999999999 );
ini_set ( 'memory_limit', - 1 );
global $current_user;
if (count ( $_REQUEST ['mass'] ) > 0) {
$query = "select document_no, stock_id from ecmsales where id in ('" . implode ( "','", $_REQUEST ['mass'] ) . "') and deleted=0";
$result = $db->query ( $query );
while ( $dane = $db->fetchByAssoc ( $result ) ) {
$documents_no [] = 'ZS ' . $dane ['document_no'];
$stocks [] = $dane ['stock_id'];
}
// merge duplicates in stocks
$stocks = array_unique ( $stocks );
if (count($stocks) > 1) {
die('Zamówienia są z różnych magazynów');
}
/*
if ($stocks[0] == null) {
die('Zamówienia nie mają przypisanego magazynu');
}
*/
$query = "select so_id from ecmstockdocouts where so_id in ('" . implode ( "','", $_REQUEST ['mass'] ) . "') and deleted=0";
$no_wz_sales = [ ];
$wz_sales = [ ];
$result = $db->query ( $query );
while ( $dane = $db->fetchByAssoc ( $result ) ) {
$no_wz_sales [] = $dane ['so_id'];
$wz_sales [] = $dane ['so_id'];
}
$query = "select document_no from ecmsales where id in ('" . implode ( "','", $wz_sales ) . "') and deleted=0";
$wz_documents_no = [ ];
$result = $db->query ( $query );
while ( $dane = $db->fetchByAssoc ( $result ) ) {
$wz_documents_no [] = 'ZS ' . $dane ['document_no'];
}
$no_wz_sales = array_diff ( $_REQUEST ['mass'], $no_wz_sales );
$query = "select sum(quantity) as quantity, ecmproduct_id,code,name from ecmsaleitems where ecmsale_id in ('" . implode ( "','", $no_wz_sales ) . "') and deleted=0 group by ecmproduct_id";
$result = $db->query ( $query );
$total_products = 0;
$product_id = [ ];
while ( $dane = $db->fetchByAssoc ( $result ) ) {
$product_id [] = $dane ['ecmproduct_id'];
$produkt [$dane ['ecmproduct_id']] = $dane;
$total_products = $total_products + $dane ['quantity'];
}
$query = "select * from ecmstockstates where product_id in ('" . implode ( "','", $product_id ) . "') and stock_id='".$stocks[0]."' and deleted=0";
$result = $db->query ( $query );
$error = false;
while ( $dane = $db->fetchByAssoc ( $result ) ) {
$produkt [$dane ['product_id']] ['stock'] = $dane ['quantity'];
if (round ( $produkt [$dane ['product_id']] ['quantity'], 2 ) > round ( $dane ['quantity'], 2 )) {
$produkt [$dane ['product_id']] ['error'] = true;
$error = true;
} else {
$produkt [$dane ['product_id']] ['error'] = false;
}
$total_in_stock = $total_in_stock + $dane ['quantity'];
}
$smarty = new Sugar_Smarty ();
$smarty->assign ( 'MOD', $mod_strings );
$smarty->assign ( "orderNo", implode ( ",", $documents_no ) );
$smarty->assign ( "wz_documents_no", implode ( ",", $wz_documents_no ) );
$smarty->assign ( 'total_products', $total_products );
$smarty->assign ( 'no_wz_sales', $no_wz_sales );
$smarty->assign ( 'error', $error );
$smarty->assign ( 'total_in_stock', $total_in_stock );
$smarty->assign ( 'products', $produkt );
$smarty->display ( 'modules/EcmSales/tpls/wzCreator.html.tpl' );
}
function createEcmStockDocOutPdf($record) {
include_once ("modules/EcmStockDocOuts/PDFTemplate/helper.php");
$focus = new EcmStockDocOut ();
$focus->retrieve ( $record );
$user = new User ();
$user->retrieve ( $focus->assigned_user_id );
include_once ("include/MPDF57/mpdf.php");
$p = new mPDF ( '', 'A4', null, 'helvetica', 10, 10, 30, 45, 5, 5 );
$labels = return_module_language ( $focus->ecmlanguage, 'EcmStockDocOuts' );
$mpdf->mirrorMargins = 1;
$db = $GLOBALS ['db'];
$positions = formatPDFPositions22 ( $focus->getPositionList ( true ), $focus );
$quantity = getQuantity22 ( $focus->getPositionList ( true ), $focus );
$content = '';
include ("modules/EcmStockDocOuts/PDFTemplate/content.php");
$ec = new EcmSysInfo ();
$footer = $ec->getFooterForModule ( 'EcmStockDocOuts' );
$header = $ec->getHeaderForModule ( 'EcmStockDocOuts' );
$p->SetHTMLHeader ( $header );
$p->SetHTMLFooter ( $footer );
$p->WriteHTML ( $content );
$EcmSysInfo = new EcmSysInfo ();
$dir = 'upload/' . $EcmSysInfo->getDatabaseName () . '/pdf/EcmStockDocOuts/';
if (! is_dir ( $dir )) {
mkdir ( $dir, '755', true );
}
$file_name = create_guid () . '.pdf';
$p->Output ( $dir . $file_name, "F" );
return $dir . $file_name;
}
function createEcmInvoiceOutPdf($record, $outputtype) {
$EcmInvoiceOut = new EcmInvoiceOut ();
$EcmInvoiceOut->retrieve ( $record );
$file_location = $EcmInvoiceOut->get_PDF_file_path ( '0' );
$EcmSysInfo = new EcmSysInfo ();
if ($EcmSysInfo->getDatabaseName () == 'preDb_60b08fe051546309b61d2714d4a0438d') {
$file_location = newPDFCreator ( $record, $type, true );
}
// return;
switch ($outputtype) {
case "BROSWER" :
header ( "Location: " . $file_location );
return true;
case "FILE" :
$path = $file_location;
break;
case "EMAIL" :
include_once 'include/ECM/EcmSendMail/EcmSendMail.inc';
$path = EcmSendMail::TEMP_DIR . 'ZS_' . $EcmInvoiceOut->number . '.pdf';
copy ( $file_location, $path );
break;
case "MULTIPDF" :
include_once 'include/ECM/EcmMultiPdf/EcmMultiPdf.inc';
$path = EcmMultiPdf::TEMP_DIR . 'EcmSales_' . $focus->id . '_' . create_guid () . '.pdf';
copy ( $file_location, $path );
break;
}
;
return $file_location;
}
?>