This commit is contained in:
2025-07-06 08:39:16 +00:00
parent 9a455c1f2d
commit e4e7df6522
21 changed files with 990 additions and 587 deletions

View File

@@ -1,5 +1,5 @@
<?php
function sendInvoice($record) {
function sendInvoice($record) {
require_once('modules/EcmInvoiceOuts/EcmInvoiceOut.php');
$inv = new EcmInvoiceOut();
$inv->retrieve($record);
@@ -7,14 +7,17 @@
$response = array (
'document_no' => $inv->document_no,
'register_date' => $inv->register_date,
'payment_date' => $inv->payment_date,
'total_netto' => $inv->total_netto,
'total_brutto' => $inv->total_brutto,
'currency_id' => $inv->currency_id,
'currency_value' => $inv->currency_value,
'vats_summary' => $inv->vats_summary,
'position_list' => $pl
);
echo json_encode($response);
}
function sendProduct($record) {
}
function sendProduct($record) {
require_once('modules/EcmProducts/EcmProduct.php');
$prod = new EcmProduct();
$prod->retrieve($record);
@@ -28,8 +31,8 @@
'product_category_name' => $prod->product_category_name
);
echo json_encode($response);
}
function copySaleFromTwinpol($record) {
}
function copySaleFromTwinpol($record) {
$db = $GLOBALS['db'];
// check if sale exists
@@ -197,7 +200,7 @@ ILN: ".$sale->shipping_iln;
echo '<a target="new" href="https://crm.e5.pl/index.php?module=EcmSales&action=DetailView&record='.$newId.'">Utworzono ZS.</a>';
die();
}
}
// local helpers
function getProduct($code) {

View File

@@ -12,7 +12,7 @@ if ($_GET['key'] != $restConfig['e5Key']) {
exit;
}
// Enable SugarCRM features
if(!defined('sugarEntry'))define('sugarEntry', true);
if (!defined('sugarEntry')) define('sugarEntry', true);
require_once('./include/entryPoint.php');
// Make action
switch ($_GET["action"]) {
@@ -25,5 +25,52 @@ switch ($_GET["action"]) {
case 'copySaleFromTwinpol':
copySaleFromTwinpol($_GET['record']);
break;
case 'export.products.list':
if ($_GET['since'] == null) {
echo 'No since date';
exit;
}
$products = [];
$db = $GLOBALS['db'];
$sixMonthsAgo = (new DateTime())->modify('-6 months')->format('Y-m-d H:i:s');
$sinceDate = date('Y-m-d H:i:s', intval($_GET['since']));;
$query = "
SELECT
p.id,
p.name,
p.code,
p.ean,
GROUP_CONCAT(s.stock_address SEPARATOR ', ') AS stock_addresses
FROM ecmproducts p
LEFT JOIN ecmproducts_stock_addresses s ON p.id = s.ecmproduct_id
WHERE p.active = 1
AND p.deleted = 0
AND p.date_modified > '$sixMonthsAgo'
AND (p.exportedAt IS NULL OR p.exportedAt > '$sinceDate')
GROUP BY p.id, p.name, p.code
";
$r = $db->query($query);
while ($row = $db->fetchByAssoc($r)) {
$p = [];
$p['id'] = $row['id'];
$p['ean'] = $row['ean'];
$p['name'] = $row['name'];
$p['code'] = $row['code'];
$p['stock_addresses'] = $row['stock_addresses'];
array_push($products, $p);
}
echo json_encode($products);
break;
case 'export.products.setExportedAt':
{
if ($_GET['exportedAt'] == null || $_GET['id'] == null) {
echo 'Wrong parameters';
exit;
}
$db = $GLOBALS['db'];
$exportedAt = date('Y-m-d H:i:s', intval($_GET['exportedAt']));;
$id = $_GET['id'];
$db->query("UPDATE ecmproducts SET exportedAt='$exportedAt' WHERE id='$id'");
break;
}
}
?>

View File

@@ -5,6 +5,7 @@ $sugar_config['http_referer']['weak'] = true;
$sugar_config['http_referer']['list'][] = 'crm.twinpool.com';
$sugar_config['http_referer']['list'][] = 'www.google.com';
$sugar_config['http_referer']['list'][] = 'crm.e5.pl';
$sugar_config['http_referer']['list'][] = 'accounts.google.com';
$sugar_config['default_currency_iso4217'] = 'PLN';
$sugar_config['default_currency_name'] = 'PLN';
$sugar_config['default_currency_symbol'] = 'zł';

View File

@@ -1,5 +1,5 @@
<?php
// created: 2025-04-29 21:26:15
// created: 2025-07-06 08:19:35
$customDoms = array (
'ecmproducts_attribute_dom' =>
array (
@@ -77,6 +77,9 @@ $customDoms = array (
'e3e0c9da-6d08-e1e0-b9ba-67eaa437cb84' => 'Bottle B1_30ml',
'8bcf43bf-7b49-5dbf-6b86-67f6c12b82d7' => 'Softpack',
'd40c7d30-77bd-1f65-be9c-681142c7daf5' => 'LCD Liquid',
'1b7d6313-d7d4-4529-73d4-684a6d5ddde3' => 'Cellophane Bag',
'47fbe61c-20f4-5d48-118c-6851105ddc97' => 'Tablet',
'c1477582-33b9-529d-bdd2-685250fc18d4' => 'Blister tablets 6pcs 6,5g',
),
'ecmproducts_brand_dom' =>
array (
@@ -166,6 +169,10 @@ $customDoms = array (
'1f9d4c5d-670e-4c77-d4de-67cddc908559' => 'DeCal',
'5c883b90-f1fb-83d1-6347-67dbd49469f0' => 'EntertainME',
'b1df2c57-aef2-290f-c207-67f7916afed9' => 'Mistify',
'aa4a31f5-fd7b-7abb-546b-6822e453b107' => 'Mrs.Shiny',
'19b9cd31-f4d2-fd74-3cd4-6826d53b5245' => 'GAYA',
'11095313-0dd0-aa9b-df3a-682739877d33' => 'Coffix',
'd97b870b-86a1-1970-9cea-68527ecc5ad9' => 'Zenevo',
),
'ecmproducts_category_dom' =>
array (

View File

@@ -1,5 +1,5 @@
<?php
// created: 2025-04-29 21:26:15
// created: 2025-07-06 08:19:35
$customDoms = array (
'ecmproducts_attribute_dom' =>
array (
@@ -77,6 +77,9 @@ $customDoms = array (
'e3e0c9da-6d08-e1e0-b9ba-67eaa437cb84' => 'Butelka B1_30ml',
'8bcf43bf-7b49-5dbf-6b86-67f6c12b82d7' => 'Softpack',
'd40c7d30-77bd-1f65-be9c-681142c7daf5' => 'Płyn LCD',
'1b7d6313-d7d4-4529-73d4-684a6d5ddde3' => 'Woreczek celofanowy',
'47fbe61c-20f4-5d48-118c-6851105ddc97' => 'Tabletka',
'c1477582-33b9-529d-bdd2-685250fc18d4' => 'Blister, tabletki 6szt. 6,5g',
),
'ecmproducts_brand_dom' =>
array (
@@ -166,6 +169,10 @@ $customDoms = array (
'1f9d4c5d-670e-4c77-d4de-67cddc908559' => 'DeCal',
'5c883b90-f1fb-83d1-6347-67dbd49469f0' => 'EntertainME',
'b1df2c57-aef2-290f-c207-67f7916afed9' => 'Mistify',
'aa4a31f5-fd7b-7abb-546b-6822e453b107' => 'Mrs.Shiny',
'19b9cd31-f4d2-fd74-3cd4-6826d53b5245' => 'GAYA',
'11095313-0dd0-aa9b-df3a-682739877d33' => 'Coffix',
'd97b870b-86a1-1970-9cea-68527ecc5ad9' => 'Zenevo',
),
'ecmproducts_category_dom' =>
array (
@@ -217,10 +224,10 @@ $customDoms = array (
),
'ecmactions_category_dom' =>
array (
'dd4ddbad-c949-0ee5-fb73-54cb9b6c86ef' => 'Nal. zakr. etyk.',
'f87b0591-14fd-b35f-1da5-54d1d584fd25' => 'Nal. zakr.',
'8519dfc8-5eec-0233-7f84-54d1fe00e9fc' => 'Składanie zestawów',
'55020d96-73d5-7b29-3bab-654f4818e0cd' => 'Mieszanie płynów',
'dd4ddbad-c949-0ee5-fb73-54cb9b6c86ef' => 'NZE',
'f87b0591-14fd-b35f-1da5-54d1d584fd25' => 'NZ',
'8519dfc8-5eec-0233-7f84-54d1fe00e9fc' => 'Zestawy',
'55020d96-73d5-7b29-3bab-654f4818e0cd' => 'Mieszanie',
),
'payment_method_dom' =>
array (

View File

@@ -1,6 +1,4 @@
<?php
//die("Przerwa techniczna");
error_reporting(E_ERROR);
if(!defined('sugarEntry'))define('sugarEntry', true);

View File

@@ -119,6 +119,8 @@ class EcmInvoiceOut extends SugarBean {
var $total_netto;
var $total_brutto;
var $vats_summary;
var $payment_date;
var $currency_value;
// RELATED FIELDS
var $created_by;
var $created_by_name;

View File

@@ -1,6 +1,6 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*****************************************************************************
@@ -96,44 +96,52 @@ if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
********************************************************************************/
$json = getJSONobj();
require_once("modules/EcmInvoiceOuts/EcmInvoiceOut.php");
require_once('include/formbase.php');
$focus = new EcmInvoiceOut();
$json = getJSONobj();
require_once("modules/EcmInvoiceOuts/EcmInvoiceOut.php");
require_once('include/formbase.php');
$focus = new EcmInvoiceOut();
if(isset($_POST['record']) && $_POST['record'] != '') {
if (isset($_POST['record']) && $_POST['record'] != '') {
$focus->retrieve($_POST['record']);
}
}
if(!$focus->ACLAccess('Save')){
ACLController::displayNoAccess(true);
sugar_cleanup(true);
}
$check_notify = FALSE;
foreach($focus->column_fields as $field){
if(isset($_POST[$field])){
$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])){
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']));
// die(var_dump( $focus->position_list));
$focus->save($check_notify);
$focus->position_list = $json->decode(htmlspecialchars_decode($_POST['position_list']));
// die(var_dump( $focus->position_list));
$focus->save($check_notify);
$return_id = $focus->id;
$return_id = $focus->id;
echo $return_id;
// create document in twinpol crm
if ($focus->parent_id == '1b9643ca-5b1a-8f9b-b809-586b5619b068') {
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_URL, "https://crm.twinpol.com/REST/index.php?key=d68dac4c-f784-4e1b-8267-9ffcfa0eda4c&action=createCostDocumentFromInvoice&record=" . $return_id);
$res = curl_exec($curl);
}
handleRedirect($return_id,'EcmInvoiceOuts');
?>
echo $return_id;
handleRedirect($return_id, 'EcmInvoiceOuts');

View File

@@ -222,7 +222,7 @@ class invoiceEdiXML
$db = $GLOBALS['db'];
$i = $this->i;
$oldInvoice = $db->fetchByAssoc($db->query("
SELECT total_netto, total_brutto, total_vat, vats_summary, document_no, register_date
SELECT total_netto, total_brutto, total_vat, vats_summary, document_no, register_date, order_no
FROM ecminvoiceouts WHERE id='".$i->ecminvoiceout_id."'"));
$xml = new XMLWriter();
$name = str_replace('/', '_', $i->document_no);
@@ -232,12 +232,10 @@ class invoiceEdiXML
$xml->startDocument('1.0', 'UTF-8');
$xml->startElement('Document-Invoice');
$xml->startElement('Invoice-Header');
// FIX $xml->writeElement('InvoiceNumber', $i->document_no);
$xml->writeElement('InvoiceNumber', 'FVKOR 04/TEST/23');
// FIX $xml->writeElement('InvoiceDate',
// $timedate->to_db_date($i->register_date));
$xml->writeElement('InvoiceNumber', $i->document_no.'-TEST');
$xml->writeElement('InvoiceDate', $timedate->to_db_date($i->register_date));
$xml->writeElement('InvoiceDate', '2023-08-01');
// FIX $xml->writeElement('SalesDate', $timedate->to_db_date($i->sell_date));
$xml->writeElement('SalesDate', $timedate->to_db_date($i->sell_date));
$xml->writeElement('SalesDate', '2023-08-01');
$c = new Currency();
$c->retrieve($i->currency_id);
@@ -254,9 +252,8 @@ class invoiceEdiXML
$xml->writeElement('DocumentFunctionCode', 'C');
$xml->writeElement('CorrectionReason', 'zgł. rekl.030/19/P320');
$xml->startElement('Order');
$xml->writeElement('BuyerOrderNumber', end(explode(' ', $i->order_no)));
// FIX $xml->writeElement('BuyerOrderDate', $timedate->to_db_date($i->register_date));
$xml->writeElement('BuyerOrderDate', '2023-08-01');
$xml->writeElement('BuyerOrderNumber', $oldInvoice['order_no']);
$xml->writeElement('BuyerOrderDate', $timedate->to_db_date($i->register_date));
$xml->endElement(); // </Line-Order>
$xml->startElement('Reference');
$xml->writeElement('InvoiceReferenceNumber', $oldInvoice['document_no']);
@@ -334,23 +331,16 @@ class invoiceEdiXML
);
foreach ($e5_info as $val) {
$xml->startElement($val);
// FIX $xml->writeElement('ILN', '5909000035836');
$xml->writeElement('ILN', '5909000896239');
$xml->writeElement('ILN', '5909000035836');
if ($val != 'SellerHeadquarters')
// FIX $xml->writeElement('TaxID', '5252173990');
$xml->writeElement('TaxID', '8792676609');
// FIX $xml->writeElement('Name', 'e5 Polska Sp. z o.o.');
$xml->writeElement('Name', 'Twinpol Sp. z o.o.');
// FIX $xml->writeElement('StreetAndNumber', 'Wąwozowa 11');
$xml->writeElement('StreetAndNumber', 'Al. Lipowa 48');
// FIX $xml->writeElement('CityName', 'Warszawa');
$xml->writeElement('CityName', 'Obrowo');
// FIX $xml->writeElement('PostalCode', '02-796');
$xml->writeElement('PostalCode', '87-126');
$xml->writeElement('TaxID', '5252173990');
$xml->writeElement('Name', 'e5 Polska Sp. z o.o.');
$xml->writeElement('StreetAndNumber', 'Wąwozowa 11');
$xml->writeElement('CityName', 'Warszawa');
$xml->writeElement('PostalCode', '02-796');
$xml->writeElement('Country', 'PL');
if ($val == 'Seller')
// FIX $xml->writeElement('CodeByBuyer', '23862');
$xml->writeElement('CodeByBuyer', '017776');
$xml->writeElement('CodeByBuyer', '23862');
$xml->endElement();
}
$xml->endElement(); // </Invoice-Parties>

View File

@@ -628,7 +628,7 @@ class EcmProduct extends SugarBean
{
$db = $GLOBALS['db'];
$res = $db->query("
SELECT p.code, pc.quantity
SELECT p.code, pc.quantity, p.id
FROM ecmproductcomponents AS pc
INNER JOIN ecmproducts AS p
ON p.id = pc.ecmproduct_id
@@ -639,6 +639,7 @@ WHERE ecmcomponent_id='$this->id';
$products[] = array(
'code' => $row['code'],
'quantity' => $row['quantity'],
'id' => $row['id'],
);
}
return $products;

View File

@@ -1,5 +1,6 @@
/*jshint esversion: 6 */
var SelectedTab = "";
var TabsMainBlock = false;
var Components;
$(document).ready(function () {
$.tablesorter.addParser({
id: "production_date",
@@ -85,14 +86,134 @@ $(document).ready(function () {
} catch (e) { }
}
}, 500);
$("#selectAll").click(function () {
if (this.checked) {
$(".allCheck").prop("checked", true);
} else {
$(".allCheck").prop("checked", false);
}
});
$("#duplicateBtn").click(() => duplicatePositions());
$("#deleteBtn").click(() => { removePositions(); });
$("#excelBtn").click(() => { exportExcel(); });
$("#pdfBtn").click(() => { window.alert("In progress."); });
$("#productionBtn").click(() => { window.alert("In progress."); });
$("#createInsideOrder").click(createInsideOrder);
});
});
function SetTab(tab_name) {
if (TabsMainBlock) { return; }
var TabMenu = document.getElementById("groupTabsPanels");
var tabs = TabMenu.getElementsByTagName("li");
for (var i = 0; i < tabs.length; i++) {
if ((tab_name + "_menu") === tabs[i].id) {
tabs[i].className = "active";
tabs[i].getElementsByTagName("a")[0].className = "current";
} else {
tabs[i].className = "";
tabs[i].getElementsByTagName("a")[0].className = "";
}
}
var prev = document.getElementById(SelectedTab);
var curr = document.getElementById(tab_name);
prev.style.display = "none";
curr.style.display = "";
SelectedTab = tab_name;
if (SelectedTab === "3") {
}
if (SelectedTab === "2") {
getRawMaterials();
}
if (SelectedTab === "1") {
}
}
function getRawMaterials() {
var ids = [];
$("input.allCheck:checkbox:checked").each(function () {
// check if this element is visible on site
if ($(this).parent().parent().css("display") === "table-row") {
ids.push($(this).val());
}
});
if (ids.length === 0) {
window.alert("Wybierz pozycje zamówień");
SetTab("1");
return;
}
showLoader();
var url = $(location).attr("href") + "&to_pdf=1&ajaxAction=getRawMaterials";
$.ajax({
method: "post",
url: url,
data: {
ids
},
success: function (data) {
var result = JSON.parse(data);
Components = result;
drawRawMaterials(result);
//drawComponents(result);
//updateComponentsPositions();
hideLoader();
},
error: function () {
window.alert("Błąd ładowania surowców");
hideLoader();
}
});
}
function drawRawMaterials(data) {
$("#rawMaterialsTableContainer").html(rawMaterialsTablePrototype());
data.forEach((el, index) => {
var tr = $("<tr></tr>");
tr.append("<td><input type=\"checkbox\" value=" + el.id + " class=\"rawMaterialCheck\" /></td>");
tr.append("<td>" + (index + 1) + "</td>");
tr.append("<td><a target=\"_blank\" href=\"index.php?module=EcmProducts&action=DetailView&record=" + el.id + "\">" + el.code + "</a></td>");
tr.append("<td title=\""+ el.fullName +"\">" + el.name + "</td>");
tr.append("<td id=\"qty-" + el.id + "\">" + el.quantity + "</td>");
tr.append("<td>" + el.unit + "</td>");
tr.append("<td id=\"state-" + el.id + "\">" + el.stockState + "</td>");
tr.append("<td id=\"ordered-" + el.id + "\">" + el.stockAddress + "</td>");
$("#rawMaterialsTable > tbody").append(tr);
});
$("#rawMaterialsTable").tablesorter({
theme: "blue",
widthFixed: true,
widgets: ["filter", "stickyHeaders"],
sortList: [[2, 0]],
});
$("#rawMaterialsTable").bind("filterEnd", function (event, config) {
updateRawMaterialsPositions();
});
$("#rawMaterialsTable").bind("sortEnd", function (event, config) {
updateRawMaterialsPositions();
$("#rawMaterialsTable tfoot").find("td").each(function () {
$(this).css("background-color", "white");
});
});
$("#selectAllRawMaterials").attr('checked', false);
$("#selectAllRawMaterials").click(function () {
if (this.checked) {
$(".rawMaterialCheck").prop('checked', true);
} else {
$(".rawMaterialCheck").prop('checked', false);
}
});
}
function rawMaterialsTablePrototype() {
return '<table id="rawMaterialsTable"><thead><tr><th class="filter-false"><input type="checkbox" id="selectAllRawMaterials" /></th><th>Pozycja</th><th>Indeks</th><th>Nazwa</th><th>Ilość</th><th>JM.</th><th>Stan</th><th>Adres magazynowy</th></tr></thead><tbody aria-live="polite" aria-relevant="all"></tbody></table>';
}
function updateRawMaterialsPositions() {
var i = 0;
$("#rawMaterialsTable").find("tr").each(function (index) {
if (index >= 2 && $(this).css('display') === 'table-row' && $(this).find("td").length > 3) {
i++;
$($(this).find("td")[1]).html(i);
}
});
}
function editQty(id) {
$("#edit-" + id).css("display", "none");
$("#qty-" + id).css("display", "none");
@@ -212,7 +333,6 @@ function exportExcel() {
},
});
}
function createInsideOrder() {
var ids = [];
$('input.allCheck:checkbox:checked').each(function () {

View File

@@ -103,16 +103,88 @@ if (!isset($_GET['ajaxAction'])) {
case 'exportExcel':
exportExcel();
break;
case 'getRawMaterials':
getRawMaterials($_POST['ids']);
break;
}
}
function getRawMaterials($ids) {
$response = array();
$idsString = join("','", $ids);
$db = $GLOBALS['db'];
$res = $db->query("SELECT ecmproduct_id, SUM(quantity) AS quantity FROM productionScheduler WHERE id IN ('$idsString') GROUP BY ecmproduct_id");
$rawMaterials = array();
while ($p = $db->fetchByAssoc($res)) {
$rawMaterials = array_merge($rawMaterials, getProductRawMaterials($p['ecmproduct_id'], $p['quantity']));
}
$groupedRawMaterials = [];
foreach ($rawMaterials as $item) {
$productId = $item['ecmproduct_id'];
if (!isset($groupedRawMaterials[$productId])) {
$groupedRawMaterials[$productId] = 0;
}
$groupedRawMaterials[$productId] += $item['quantity'];
}
$rawMaterials = [];
foreach ($groupedRawMaterials as $productId => $quantity) {
$rawMaterials[] = ['ecmproduct_id' => $productId, 'quantity' => $quantity];
}
global $app_list_strings;
foreach ($rawMaterials as $raw) {
$product = $db->fetchByAssoc($db->query("
SELECT p.id, p.code, p.name, p.group_ks, p.unit_id, ss.quantity as stockState,
GROUP_CONCAT(s.stock_address SEPARATOR ', ') AS stock_addresses
FROM ecmproducts AS p
LEFT JOIN ecmstockstates AS ss
ON ss.product_id = p.id AND ss.stock_id = '368479db-22c5-0220-3a14-4bc426b1c709'
LEFT JOIN ecmproducts_stock_addresses s ON p.id = s.ecmproduct_id
WHERE p.id='" . $raw['ecmproduct_id'] . "'
GROUP BY p.id
"));
$result['id'] = $product['id'];
$result['name'] = strlen($product['name']) > 55 ? substr($product['name'], 0, 55) . "..." : $product['name'];
$result['fullName'] = $product['name'];
$result['code'] = strlen($product['code']) > 20 ? substr($product['code'], 0, 20) . "..." : $product['code'];
$result['fullCode'] = $product['code'];
$result['quantity'] = $raw['quantity'];
$result['unit'] = $app_list_strings['ecmproducts_unit_dom'][$product['unit_id']];
$result['stockState'] = (!empty($product['stockState'])) ? $product['stockState'] : 0;
$result['stockAddress'] = (!empty($product['stock_addresses'])) ? $product['stock_addresses'] : "";
$response[] = $result;
}
echo json_encode($response);
}
function getProductRawMaterials($productId, $quantity)
{
$db = $GLOBALS['db'];
$response = array();
$componentsQuery = "SELECT c.ecmcomponent_id, c.quantity
FROM ecmproductcomponents as c
WHERE c.ecmproduct_id = '$productId'";
$crows = $db->query($componentsQuery);
if ($crows->num_rows == 0) {
return array(
array(
'ecmproduct_id' => $productId,
'quantity' => $quantity
)
);
} else {
while ($c = $db->fetchByAssoc($crows)) {
$response = array_merge($response, getProductRawMaterials($c['ecmcomponent_id'], $quantity * $c['quantity']));
}
return $response;
}
}
function saveQty($id, $qty)
{
$db = $GLOBALS['db'];
$query = sprintf("UPDATE productionScheduler SET quantity='%d' WHERE id='%s'", $qty, $id);
$db->query($query);
}
function duplicatePositions($ids)
{
$db = $GLOBALS['db'];
@@ -126,7 +198,6 @@ function duplicatePositions($ids)
$db->query($query);
}
}
function removePositions($ids)
{
$db = $GLOBALS['db'];

View File

@@ -76,21 +76,67 @@
</table>
</form>
<input class="button" id="duplicateBtn" value="Duplikuj" type="button">
<input class="button" id="deleteBtn" value="Usuń" type="button">&nbsp;&nbsp;&nbsp;
<input class="button" id="excelBtn" value="Excel" type="button">
<input class="button" id="pdfBtn" value="PDF" type="button">
<input class="button" value="Utwórz zamówienie wewnętrzne" type="button" id="createInsideOrder"/>
<form action="index.php?module=EcmInsideOrders&action=EditView&fromProductsBySalesReport=true" method="post"
target="_blank" id="createInsideOrderForm">
<input id="insideOrderProducts" name="insideOrderProducts" type="hidden" value=""/>
</form>
<!-- TAB MENU -->
<ul class="subpanelTablist" style="margin-top:10px;" id="groupTabsPanels">
<li class="active" id="1_menu">
<script language="javascript">
{literal}
var set1 = function () {
SetTab('1');
};
SelectedTab = '1';
{/literal}
</script>
<a class="current" href="javascript:set1();">Produkty</a>
</li>
<li class="" id="2_menu">
<script language="javascript">
{literal}
var set2 = function () {
SetTab('2');
};
{/literal}
</script>
<a class="" href="javascript:set2();">Surowce</a>
</li>
<li class="" id="3_menu">
<script language="javascript">
{literal}
var set3 = function () {
SetTab('3');
};
{/literal}
</script>
<a class="" href="javascript:set3();">Receptury</a>
</li>
<li class="" id="4_menu">
<script language="javascript">
{literal}
var set4 = function () {
SetTab('4');
};
{/literal}
</script>
<a class="" href="javascript:set4();">Realizacja</a>
</li>
</ul>
<div id="1">
<br>
<input class="button" id="duplicateBtn" value="Duplikuj" type="button">
<input class="button" id="deleteBtn" value="Usuń" type="button">&nbsp;&nbsp;&nbsp;
<input class="button" id="excelBtn" value="Excel" type="button">
<input class="button" id="pdfBtn" value="PDF" type="button">
<input class="button" value="Utwórz przyjęcie produkcyjne" type="button" id="createInsideOrder"/>
<table id="allTable">
<thead>
<tr>
<th>&nbsp;</th>
<th class="filter-false"><input type="checkbox" id="selectAll"></th>
<th>Indeks</th>
<th>Nazwa</th>
<th>Data produkcji</th>
@@ -205,3 +251,14 @@
</tbody>
</table>
</div>
<div id="2" style="display: none">
<div id="rawMaterialsTableContainer">
</div>
</div>
<div id="3" style="display: none">
Receptury
</div>
<div id="4" style="display: none">
Realizacja
</div>

View File

@@ -1,9 +1,9 @@
$(document).ready(function () {
$("#allTable").tablesorter({
sortList: [[13, 1]],
theme: 'blue',
theme: "blue",
widthFixed: true,
widgets: ['filter', 'zebra', 'stickyHeaders'],
widgets: ["filter", "zebra", "stickyHeaders"],
fixedWidth: true,
widgetOptions: {
resizable: false,
@@ -70,9 +70,9 @@ $(document).ready(function () {
$("#selectAll").click(function () {
if (this.checked) {
$(".allCheck").prop('checked', true);
$(".allCheck").prop("checked", true);
} else {
$(".allCheck").prop('checked', false);
$(".allCheck").prop("checked", false);
}
});
$("#orderComponents").click(orderComponents);

View File

@@ -139,7 +139,7 @@
<!-- TABS -->
<div id="1">
<br>
<input class="button" name="submit" value="Utwórz zamówienie wewnętrzne" type="button" id="createInsideOrder"/>
<input class="button" name="submit" value="Utwórz przyjęcie produkcyjne" type="button" id="createInsideOrder"/>
<br>
<form action="index.php?module=EcmInsideOrders&action=EditView&fromProductsBySalesReport=true" method="post"
target="_blank" id="createInsideOrderForm">

View File

@@ -848,30 +848,23 @@ class EcmSale extends SugarBean
if ($array['date_to'] != '') $field_array[] = "delivery_date<='" . date("Y-m-d", strtotime($array['date_to'])) . "'";
if ($array['date_send_from'] != '') $field_array[] = "send_date>='" . date("Y-m-d", strtotime($array['date_send_from'])) . "'";
if ($array['date_send_to'] != '') $field_array[] = "send_date<='" . date("Y-m-d", strtotime($array['date_send_to'])) . "'";
if ($array['time_from'] != '') $field_array[] = "date_entered>='" . date("Y-m-d", strtotime($array['time_from'])) . "'";
if ($array['time_to'] != '') $field_array[] = "date_entered<='" . date("Y-m-d", strtotime($array['time_to'])) . "'";
if ($array['account_id'] != '') $field_array[] = "parent_id='" . $array['account_id'] . "'";
if ($array['account_name'] != '') $field_array[] = "parent_name like '" . $array['account_name'] . "'";
if ($array['parent_order_no'] != '') $field_array[] = "parent_document_no='" . $array['parent_order_no'] . "'";
switch ($array ['sale_type']) {
case 'all' :
$field_array[] = "type IN ('sales_order', 'gratis')";
break;
case 'sale' :
$field_array[] = "type='sales_order'";
break;
case 'gratis' :
$field_array[] = "type='gratis'";
break;
if ($array['sale_type'] != null) {
$field_array [] = "type IN ('" . implode($array['sale_type'], "','") . "')";
}
if ($array['sale_status'] != null) {
$field_array [] = "status IN ('" . implode($array['sale_status'], "','") . "')";
}
if (count($field_array) > 0)
$where = " and " . implode(" and ", $field_array);
else
$where = "";
$z = "select * from ecmsales where deleted='0' and status!='s10' " . $where;
if ($array['sale_type'] == 'all')
$z .= " ORDER BY type DESC";
$z = "select * from ecmsales where deleted='0' and status!='s10' " . $where . " ORDER BY send_date DESC";
return $z;
}

View File

@@ -25,6 +25,20 @@ $json_config = new json_config ();
$focus = new EcmSale ();
global $app_list_strings;
if ($_GET['sale_type'] == null || count($_GET['sale_type']) == 0) {
$_GET['sale_type'] = array();
foreach ($app_list_strings['ecmsales_type_dom'] as $key => $value) {
$_GET['sale_type'][] = $key;
}
}
if ($_GET['sale_status'] == null) {
$_GET['sale_status'] = array();
foreach ($app_list_strings['ecmsales_status_dom'] as $key => $value) {
$_GET['sale_status'][] = $key;
}
}
if($_GET['submit']){
$position_list=$focus->GetArrayResultFromQuery($focus->CreateQueryFromPost($_GET));
@@ -44,6 +58,11 @@ $currencies = [
'98b2b752-b0be-37c2-d2eb-511e29f81cab'=>'USD',
'6336d9a0-ee5f-52e3-7d0c-4e6f1472b2bf'=>'EUR'
];
$edit->ss->assign('SALE_TYPES', $app_list_strings['ecmsales_type_dom']);
$edit->ss->assign('SELECTED_TYPES', $_GET['sale_type']);
$edit->ss->assign('SALE_STATUSES', $app_list_strings['ecmsales_status_dom']);
$edit->ss->assign('SELECTED_STATUSES', $_GET['sale_status']);
$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);
@@ -57,4 +76,3 @@ $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>';
?>

View File

@@ -1,7 +1,7 @@
<script type="text/javascript"
src="include/ECM/EcmMultiPdf/EcmMultiPdf.js"></script>
src="include/ECM/EcmMultiPdf/EcmMultiPdf.js"></script>
<script type="text/javascript"
src="include/jQuery/jquery.blockUI.js"></script>
src="include/jQuery/jquery.blockUI.js"></script>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td><img src="themes/Sugar/images/EcmProducts.gif"
@@ -10,33 +10,38 @@ src="include/jQuery/jquery.blockUI.js"></script>
<td><h2>{$MOD.LBL_LISTNEWSALES_NAME}</h2></td>
</tr>
</table>
<br />
<form action="index.php?module=EcmSales&action=ListNewSales" method="get" name="SearchFormListNewSales"><ul class="tablist" style="width:100%;">
<input type="hidden" name="module" value="EcmSales">
<input type="hidden" name="action" value="ListNewSales">
<li>
<br/>
<form action="index.php?module=EcmSales&action=ListNewSales" method="get" name="SearchFormListNewSales">
<ul class="tablist" style="width:100%;">
<input type="hidden" name="module" value="EcmSales">
<input type="hidden" name="action" value="ListNewSales">
<li>
<a class="current" href="#">{$MOD.LBL_SEARCH}</a>
</li>
</ul>
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0" cellspacing="0">
</li>
</ul>
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td width="5%" nowrap="" >
{$MOD.LBL_LISTNEWSALES_DATE_START}:
<td nowrap="">
Data wysyłki od
</td>
<td width="30%" nowrap="" >
<input type="text" maxlength="10" size="11" tabindex="" title="" value="{if $POST.date_from!=''}{$POST.date_from}{else}{$smarty.now|date_format:"%d.%m.%Y"}{/if}" id="date_from" name="date_from" autocomplete="off">
<img align="absmiddle" border="0" id="date_from_trigger" name="date_from_trigger" alt="Enter Date" src="themes/default/images/jscalendar.gif">
<td nowrap="">
<input type="text" maxlength="10" size="11" tabindex="" title=""
value="{if $POST.date_send_from!=''}{$POST.date_send_from}{else}{$smarty.now|date_format:"%d.%m.%Y"}{/if}" id="date_send_from"
name="date_send_from" autocomplete="off">
<img align="absmiddle" border="0" id="date_send_from_trigger" name="date_send_from_trigger"
alt="Enter Date" src="themes/default/images/jscalendar.gif">
<script type="text/javascript">
{literal}
// musi być tu w pliku js nie chce działać
Calendar.setup ({
inputField : "date_from",
daFormat : "%d.%m.%Y",
button : "date_from_trigger",
singleClick : true,
dateStr : "",
step : 1,
weekNumbers:false
Calendar.setup({
inputField: "date_send_from",
daFormat: "%d.%m.%Y",
button: "date_send_from_trigger",
singleClick: true,
dateStr: "",
step: 1,
weekNumbers: false
}
);
{/literal}
@@ -44,203 +49,210 @@ src="include/jQuery/jquery.blockUI.js"></script>
{$MOD.LBL_LISTNEWSALES_DATE_END}:
<input type="text" maxlength="10" size="11" tabindex="" title="" value="{if $POST.date_to!=''}{$POST.date_to}{else}{$smarty.now|date_format:"%d.%m.%Y"}{/if}" id="date_to" name="date_to" autocomplete="off">
<img align="absmiddle" border="0" id="date_to_trigger" name="date_to_trigger" alt="Enter Date" src="themes/default/images/jscalendar.gif">
<input type="text" maxlength="10" size="11" tabindex="" title=""
value="{if $POST.date_send_to!=''}{$POST.date_send_to}{else}{$smarty.now|date_format:"%d.%m.%Y"}{/if}" id="date_send_to"
name="date_send_to" autocomplete="off">
<img align="absmiddle" border="0" id="date_send_to_trigger" name="date_send_to_trigger" alt="Enter Date"
src="themes/default/images/jscalendar.gif">
<script type="text/javascript">
{literal}
// musi być tu w pliku js nie chce działać
Calendar.setup ({
inputField : "date_to",
daFormat : "%d.%m.%Y",
button : "date_to_trigger",
singleClick : true,
dateStr : "",
step : 1,
weekNumbers:false
Calendar.setup({
inputField: "date_send_to",
daFormat: "%d.%m.%Y",
button: "date_send_to_trigger",
singleClick: true,
dateStr: "",
step: 1,
weekNumbers: false
}
);
{/literal}
</script>
</td>
<td width="5%" nowrap="" >
<td rowspan="2">Typ:</td>
<td rowspan="2">
<select id="sale_type" name="sale_type[]" multiple="true">
{foreach from=$SALE_TYPES key="key" item="value" name="sale_types"}
<option {if in_array($key, $SELECTED_TYPES)}selected="selected" {/if} value="{$key}">{$value}</option>
{/foreach}
</select>
</td>
<td rowspan="2">Status:</td>
<td rowspan="2">
<select id="sale_status" name="sale_status[]" multiple="true">
{foreach from=$SALE_STATUSES key="key" item="value" name="sale_statuses"}
<option {if in_array($key, $SELECTED_STATUSES)}selected="selected" {/if} value="{$key}">{$value}</option>
{/foreach}
</select>
</td>
<td nowrap="">
{$MOD.LBL_LISTNEWSALES_ACCOUNT_NAME}:
</td>
<td width="5%" nowrap="" >
<input type="text" title="" value="{if $POST.account_name!=''}{$POST.account_name}{/if}" size="" id="account_name" tabindex="" name="account_name">
<input type="hidden" value="{if $POST.account_id!=''}{$POST.account_id}{/if}" id="account_id" name="account_id">
<input type="button" onclick="{literal}open_popup(&quot;Accounts&quot;, 600, 400, &quot;&quot;, true, false, {&quot;call_back_function&quot;:&quot;set_return&quot;,&quot;form_name&quot;:&quot;SearchFormListNewSales&quot;,&quot;field_to_name_array&quot;:{&quot;id&quot;:&quot;account_id&quot;,&quot;name&quot;:&quot;account_name&quot;}}, &quot;single&quot;, true);{/literal}" value="Wybierz" class="button" accesskey="T" title="Select [Alt+T]" tabindex="" name="btn_account_name">
<button value="Wyczyść" onclick="this.form.account_name.value = ''; this.form.account_id.value = '';" class="button lastChild" accesskey="C" title="Wyczyść[Alt+C]" tabindex="" name="btn_clr_parent_name_basic" type="button"><img src="themes/default/images/id-ff-clear.png?s=bed8cd35065048ceebdc639ebe305e2c&amp;c=1"></button>
<td nowrap="">
<input type="text" title="" value="{if $POST.account_name!=''}{$POST.account_name}{/if}" size=""
id="account_name" tabindex="" name="account_name">
<input type="hidden" value="{if $POST.account_id!=''}{$POST.account_id}{/if}" id="account_id"
name="account_id">
<input type="button"
onclick="{literal}open_popup(&quot;Accounts&quot;, 600, 400, &quot;&quot;, true, false, {&quot;call_back_function&quot;:&quot;set_return&quot;,&quot;form_name&quot;:&quot;SearchFormListNewSales&quot;,&quot;field_to_name_array&quot;:{&quot;id&quot;:&quot;account_id&quot;,&quot;name&quot;:&quot;account_name&quot;}}, &quot;single&quot;, true);{/literal}"
value="Wybierz" class="button" accesskey="T" title="Select [Alt+T]" tabindex=""
name="btn_account_name">
<button value="Wyczyść" onclick="this.form.account_name.value = ''; this.form.account_id.value = '';"
class="button lastChild" accesskey="C" title="Wyczyść[Alt+C]" tabindex=""
name="btn_clr_parent_name_basic" type="button"><img
src="themes/default/images/id-ff-clear.png?s=bed8cd35065048ceebdc639ebe305e2c&amp;c=1">
</button>
</td>
<td width="5%" nowrap="" >
{$MOD.LBL_LISTNEWSALES_DOCUMENT_CREATE_DATE_START}:
</td>
<td width="30%" nowrap="" >
<input type="text" value="{if $POST.time_from!=''}{$POST.time_from}{/if}" id="time_from" name="time_from">
<img align="absmiddle" border="0" id="time_from_trigger" name="time_from_trigger" alt="Enter Date" src="themes/default/images/jscalendar.gif">
<script type="text/javascript">
{literal}
// musi być tu w pliku js nie chce działać
Calendar.setup ({
inputField : "time_from",
daFormat : "%d.%m.%Y",
button : "time_from_trigger",
singleClick : true,
dateStr : "",
step : 1,
weekNumbers:false
}
);
{/literal}
</script>
{$MOD.LBL_LISTNEWSALES_DATE_END}:
<input type="text" value="{if $POST.time_to!=''}{$POST.time_to}{/if}" id="time_to" name="time_to">
<img align="absmiddle" border="0" id="time_to_trigger" name="time_to_trigger" alt="Enter Date" src="themes/default/images/jscalendar.gif">
<script type="text/javascript">
{literal}
// musi być tu w pliku js nie chce działać
Calendar.setup ({
inputField : "time_to",
daFormat : "%d.%m.%Y",
button : "time_to_trigger",
singleClick : true,
dateStr : "",
step : 1,
weekNumbers:false
}
);
{/literal}
</script>
<td width="5%" nowrap="" >
<td nowrap="">
{$MOD.LBL_LISTNEWSALES_NOT_ASSIGNED}:
</td>
<td width="5%" nowrap="" >
<td nowrap="">
<input type="checkbox" name="wz" value="1" {if $POST.wz=='1'}checked{/if}>
</td>
</tr>
<tr>
<td width="5%" nowrap="" >
<td nowrap="">
Data dostawy od:
</td>
<td nowrap="">
<input type="text" maxlength="10" size="11" tabindex="" title=""
value="{if $POST.date_from!=''}{$POST.date_from}{/if}"
id="date_from" name="date_from" autocomplete="off">
<img align="absmiddle" border="0" id="date_from_trigger" name="date_from_trigger" alt="Enter Date"
src="themes/default/images/jscalendar.gif">
<script type="text/javascript">
{literal}
// musi być tu w pliku js nie chce działać
Calendar.setup({
inputField: "date_from",
daFormat: "%d.%m.%Y",
button: "date_from_trigger",
singleClick: true,
dateStr: "",
step: 1,
weekNumbers: false
}
);
{/literal}
</script>
do:
<input type="text" maxlength="10" size="11" tabindex="" title=""
value="{if $POST.date_to!=''}{$POST.date_to}{/if}"
id="date_to" name="date_to" autocomplete="off">
<img align="absmiddle" border="0" id="date_to_trigger" name="date_to_trigger" alt="Enter Date"
src="themes/default/images/jscalendar.gif">
<script type="text/javascript">
{literal}
// musi być tu w pliku js nie chce działać
Calendar.setup({
inputField: "date_to",
daFormat: "%d.%m.%Y",
button: "date_to_trigger",
singleClick: true,
dateStr: "",
step: 1,
weekNumbers: false
}
);
{/literal}
</script>
</td>
<td nowrap="">
{$MOD.LBL_LISTNEWSALES_ORDER_NO}:
</td>
<td width="5%" nowrap="" >
<input type="text" value="{if $POST.parent_order_no!=''}{$POST.parent_order_no}{/if}" name="parent_order_no">
</td>
<td width="5%" nowrap="" >
{$MOD.LBL_LISTNEWSALES_ORDER_TYPE}:
</td>
<td width="30%" nowrap="nowrap" class="dataField"><select id="sale_type" name="sale_type">
<option selected="" value="all" {if $POST.sale_type=='all'}selected{/if}>Wszystkie</option>
<option value="sale" {if $POST.sale_type=='sale'}selected{/if}>Zamówienie</option>
<option value="gratis" {if $POST.sale_type=='gratis'}selected{/if}>Próbki</option>
</select></td>
<td width="5%" nowrap="" >
Data wysyłki od
</td>
<td width="30%" nowrap="" >
<input type="text" maxlength="10" size="11" tabindex="" title="" value="{if $POST.date_send_from!=''}{$POST.date_send_from}{else}{/if}" id="date_send_from" name="date_send_from" autocomplete="off">
<img align="absmiddle" border="0" id="date_send_from_trigger" name="date_send_from_trigger" alt="Enter Date" src="themes/default/images/jscalendar.gif">
<script type="text/javascript">
{literal}
// musi być tu w pliku js nie chce działać
Calendar.setup ({
inputField : "date_send_from",
daFormat : "%d.%m.%Y",
button : "date_send_from_trigger",
singleClick : true,
dateStr : "",
step : 1,
weekNumbers:false
}
);
{/literal}
</script>
{$MOD.LBL_LISTNEWSALES_DATE_END}:
<input type="text" maxlength="10" size="11" tabindex="" title="" value="{if $POST.date_send_to!=''}{$POST.date_send_to}{else}{/if}" id="date_send_to" name="date_send_to" autocomplete="off">
<img align="absmiddle" border="0" id="date_send_to_trigger" name="date_send_to_trigger" alt="Enter Date" src="themes/default/images/jscalendar.gif">
<script type="text/javascript">
{literal}
// musi być tu w pliku js nie chce działać
Calendar.setup ({
inputField : "date_send_to",
daFormat : "%d.%m.%Y",
button : "date_send_to_trigger",
singleClick : true,
dateStr : "",
step : 1,
weekNumbers:false
}
);
{/literal}
</script>
<td nowrap="">
<input type="text" value="{if $POST.parent_order_no!=''}{$POST.parent_order_no}{/if}"
name="parent_order_no">
</td>
</tr>
</table>
</table>
<h3 style="color:red">{if $POST.date_send_from!='' && $POST.date_from!=''}Proszę wybrać date dostawy lub datę wysyłki{/if}</h3>
<input type="hidden" id="idss" value="">
<input type="submit" value="{$MOD.LBL_LISTNEWSALES_POST}" name="submit" class="button">
<input type="button" onclick="location.href='index.php?module=EcmSales&amp;action=ListNewSales';" value="{$MOD.LBL_LISTNEWSALES_CLEAR}" name="clear" class="button">
<input type="button" id="gets" class="button" name="gets" value="{$MOD.LBL_LISTNEWSALES_CREATE_PDFS}" onclick="createMultiPdf()">
<input type="button" id="products_list" class="button" name="products_list" value="{$MOD.LBL_LISTNEWSALES_PRODUCT_SUMMARY}" onclick="getSelected(); getList();">
<input type="button" id="products_list" class="button" name="products_list" value="{$MOD.LBL_LISTNEWSALES_PRODUCT_SUMMARY} 2" onclick="getSelected(); getList2();">
<input type="button" id="products_list" class="button" name="products_list" value="Lista komponentów" onclick="getSelected(); getList3();">
<br>{if $LINK!=''}<a href="https://95.50.148.50/crm/pdftmp/{$LINK}">{$LINK}</a>{/if}
<input type="hidden" id="idss" value="">
<input type="submit" value="{$MOD.LBL_LISTNEWSALES_POST}" name="submit" class="button">
<input type="button" onclick="location.href='index.php?module=EcmSales&amp;action=ListNewSales';"
value="{$MOD.LBL_LISTNEWSALES_CLEAR}" name="clear" class="button">
<input type="button" id="gets" class="button" name="gets" value="{$MOD.LBL_LISTNEWSALES_CREATE_PDFS}"
onclick="createMultiPdf()">
<input type="button" id="products_list" class="button" name="products_list"
value="{$MOD.LBL_LISTNEWSALES_PRODUCT_SUMMARY}" onclick="getSelected(); getList();">
<input type="button" id="products_list" class="button" name="products_list"
value="{$MOD.LBL_LISTNEWSALES_PRODUCT_SUMMARY} 2" onclick="getSelected(); getList2();">
<input type="button" id="products_list" class="button" name="products_list" value="Lista komponentów"
onclick="getSelected(); getList3();">
<br>{if $LINK!=''}<a href="https://95.50.148.50/crm/pdftmp/{$LINK}">{$LINK}</a>{/if}
<table cellspacing="0" cellpadding="0" border="0" style="width:100%;" id="myTable" class="tablesorter">
<thead>
<table cellspacing="0" cellpadding="0" border="0" style="width:100%;" id="myTable" class="tablesorter">
<thead>
<tr>
<th ><input type="checkbox" name="selectall" id="selectall"></th>
<th >{$MOD.LBL_LISTNEWSALES_POS}</th>
<th >{$MOD.LBL_LISTNEWSALES_NUMBER}</th>
<th >{$MOD.LBL_LISTNEWSALES_DESCRIPTION}</th>
<th >{$MOD.LBL_LISTNEWSALES_PARENT_NAME}</th>
<th >{$MOD.LBL_LISTNEWSALES_DELIVERY_DATE}</th>
<th ></th>
<th >Termin wysyłki</th>
<th >{$MOD.LBL_LISTNEWSALES_QUANTITY}</th>
<th >{$MOD.LBL_LISTNEWSALES_TOTAL_NETTO}</th>
<th >{$MOD.LBL_LISTNEWSALES_TOTAL_VAT}</th>
<th >{$MOD.LBL_LISTNEWSALES_TOTAL_BRUTTO}</th>
<th >{$MOD.LBL_LISTNEWSALES_TOTAL_INVOICE}</th>
<th >{$MOD.LBL_LISTNEWSALES_PERCENT}</th>
<th >{$MOD.LBL_LISTNEWSALES_CURRENCY}</th>
<th >{$MOD.LBL_LISTNEWSALES_PRINTED}</th>
<td >&nbsp;</td></tr>
<th><input type="checkbox" name="selectall" id="selectall"></th>
<th>{$MOD.LBL_LISTNEWSALES_POS}</th>
<th>{$MOD.LBL_LISTNEWSALES_NUMBER}</th>
<th>{$MOD.LBL_LISTNEWSALES_DESCRIPTION}</th>
<th>{$MOD.LBL_LISTNEWSALES_PARENT_NAME}</th>
<th>{$MOD.LBL_LISTNEWSALES_DELIVERY_DATE}</th>
<th></th>
<th>Termin wysyłki</th>
<th>{$MOD.LBL_LISTNEWSALES_QUANTITY}</th>
<th>{$MOD.LBL_LISTNEWSALES_TOTAL_NETTO}</th>
<th>{$MOD.LBL_LISTNEWSALES_TOTAL_VAT}</th>
<th>{$MOD.LBL_LISTNEWSALES_TOTAL_BRUTTO}</th>
<th>{$MOD.LBL_LISTNEWSALES_TOTAL_INVOICE}</th>
<th>{$MOD.LBL_LISTNEWSALES_PERCENT}</th>
<th>{$MOD.LBL_LISTNEWSALES_CURRENCY}</th>
<th>{$MOD.LBL_LISTNEWSALES_PRINTED}</th>
<td>&nbsp;</td>
</tr>
</thead>
<tbody>
{foreach from=$POSITION_LIST key="key" item="item" name="components"}
{if $item.id!=''}
<tr style="vertical-align:top;">
<td ><input type="checkbox" value="{$item.id}" class="make_pdf" id="make_pdf_{$item.position}" name="selectedid[]"></td>
<td >{$item.position}</td>
<td data-price="{$item.number}"><a href="index.php?module=EcmSales&action=DetailView&record={$item.id}">{$item.document_no}</a></td>
<td ></td>
<td ><a href="index.php?module=Accounts&action=DetailView&record={$item.parent_id}">{$item.parent_name}</a></td>
<td >{$item.delivery_date}</td>
<td><input type="checkbox" {if $item.send_accepted==true}checked="checked" {/if} disabled="disabled"></td>
<td >{$item.send_date} </td>
<td><input type="checkbox" value="{$item.id}" class="make_pdf" id="make_pdf_{$item.position}"
name="selectedid[]"></td>
<td>{$item.position}</td>
<td data-price="{$item.number}"><a
href="index.php?module=EcmSales&action=DetailView&record={$item.id}">{$item.document_no}</a>
</td>
<td></td>
<td>
<a href="index.php?module=Accounts&action=DetailView&record={$item.parent_id}">{$item.parent_name}</a>
</td>
<td>{$item.delivery_date}</td>
<td><input type="checkbox" {if $item.send_accepted==true}checked="checked" {/if}
disabled="disabled"></td>
<td>{$item.send_date} </td>
<td style="text-align: right">{$item.quantity}</td>
<td data-total="{$item.total_netto}" style="text-align: right">{$item.total_netto|number_format:2:".":","}</td>
<td data-total="{$item.total_vat}" style="text-align: right">{$item.total_vat|number_format:2:".":","}</td>
<td data-total="{$item.total_brutto}" style="text-align: right">{$item.total_brutto|number_format:2:".":","}</td>
<td data-total="{$item.total_invoice}" style="text-align: right">{$item.total_invoice|number_format:2:".":","}</td>
<td style="text-align: right">{$item.percent}<a style="cursor:pointer;" onclick="{literal}if(document.getElementById('div{/literal}{$item.id}{literal}').style.display=='none'){document.getElementById('div{/literal}{$item.id}{literal}').style.display='block';}else{document.getElementById('{/literal}div{$item.id}{literal}').style.display='none';}{/literal} "><img border="0" src="modules/EcmQuotes/images/search.gif"></a>
<td data-total="{$item.total_netto}"
style="text-align: right">{$item.total_netto|number_format:2:".":","}</td>
<td data-total="{$item.total_vat}"
style="text-align: right">{$item.total_vat|number_format:2:".":","}</td>
<td data-total="{$item.total_brutto}"
style="text-align: right">{$item.total_brutto|number_format:2:".":","}</td>
<td data-total="{$item.total_invoice}"
style="text-align: right">{$item.total_invoice|number_format:2:".":","}</td>
<td style="text-align: right">{$item.percent}<a style="cursor:pointer;"
onclick="{literal}if(document.getElementById('div{/literal}{$item.id}{literal}').style.display=='none'){document.getElementById('div{/literal}{$item.id}{literal}').style.display='block';}else{document.getElementById('{/literal}div{$item.id}{literal}').style.display='none';}{/literal} "><img
border="0" src="modules/EcmQuotes/images/search.gif"></a>
<div style="display:none; border: 1px solid #cccccc;background-color:#e6e6e6;padding:3px;"
id="div{$item.id}">
<table cellspacing="0" cellpadding="3" border="0">
<tbody><tr><td width="40%"><strong>Index</strong></td>
<td><strong>Order</strong></td><td><strong>WZ</strong></td>
<td><strong>ETA</strong></td></tr>
<tbody>
<tr>
<td width="40%"><strong>Index</strong></td>
<td><strong>Order</strong></td>
<td><strong>WZ</strong></td>
<td><strong>ETA</strong></td>
</tr>
{foreach from=$item.products key="ki" item="va" name="products"}
{if $va.code!=''}
<tr style="color:black;">
<td style="color:black;"><a href="index.php?module=EcmProducts&amp;action=DetailView&amp;record={$va.id}">{$va.code}</a></td>
<td style="color:black;"><a
href="index.php?module=EcmProducts&amp;action=DetailView&amp;record={$va.id}">{$va.code}</a>
</td>
{if $va.order>$va.wz}
<td style="color:red;">{$va.order|number_format:2:".":","}</td>
<td style="color:red;">{$va.wz|number_format:2:".":","}</td>
@@ -248,51 +260,96 @@ src="include/jQuery/jquery.blockUI.js"></script>
<td style="color:black;">{$va.order|number_format:2:".":","}</td>
<td style="color:black;">{$va.wz|number_format:2:".":","}</td>
{/if}
<td style="color:black;"></td></tr>
<td style="color:black;"></td>
</tr>
{/if}
{/foreach}
<tr style="color:black;font-weight:bold"><td>Total</td>
<td>{$item.products.order_total|number_format:2:".":","}</td><td>{$item.products.wz_total|number_format:2:".":","}</td></tr><tr><td></td><td></td>
<td><span style="color:red;font-weight:bold">{$item.products.minus|number_format:2:".":","}</span></td></tr>
<tr><td></td><td></td><td><span style="color:green;font-weight:bold">{$item.products.plus|number_format:2:".":","}</span></td></tr></tbody></table></div>
<tr style="color:black;font-weight:bold">
<td>Total</td>
<td>{$item.products.order_total|number_format:2:".":","}</td>
<td>{$item.products.wz_total|number_format:2:".":","}</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<span style="color:red;font-weight:bold">{$item.products.minus|number_format:2:".":","}</span>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<span style="color:green;font-weight:bold">{$item.products.plus|number_format:2:".":","}</span>
</td>
</tr>
</tbody>
</table>
</div>
</td>
<td style="text-align: right">{$CURRENCIES[$item.currency]}</td>
<td></td>
<td>
{if $item.type!='gratis'}
{if $item.fv_switch=='yes'}<img border="0" id="convert_to_invoice_{$item.id}" src="modules/EcmSales/images/convert_disabled.gif" title="{$item.fv_name}" style="cursor:pointer;" onClick="{literal}javascript:window.open('index.php?module=EcmInvoiceOuts&action=DetailView&record={/literal}{$item.fv_id}{literal}','_newtab');{/literal} " />'{/if}
{if $item.fv_switch=='no'}<img border="0" id="convert_to_invoice_{$item.id}" src="modules/EcmSales/images/convert_enabled.gif" title="Create Invoice" onClick="{literal}javascript:window.open('index.php?module=EcmInvoiceOuts&action=EditView&isWZ=true&wz_record={/literal}{$item.fv_id}{literal}','_newtab');{/literal}" style="cursor:pointer;" />{/if}
{if $item.wz_switch=='disabled'}<img src="modules/EcmSales/images/create_wz_disabled.gif" title="{$item.wz_name}" onclick="{literal}window.open('index.php?module=EcmStockDocOuts&action=DetailView&record={/literal}{$item.wz_id}{literal}','_newtab');{/literal}" style="cursor: pointer;" border="0">&nbsp;{/if}
{if $item.wz_switch=='enabled'}<img src="modules/EcmSales/images/create_wz_enabled.gif" title="{$MOD.LBL_LISTNEWSALES_CREATEWZ}" onclick="{literal}javascript:window.open('index.php?module=EcmStockDocOuts&amp;action=EditView&parent_doc_type=EcmSales&parent_doc_id={/literal}{$item.id}{literal}','_newtab');{/literal}" style="cursor: pointer;" border="0">{/if}
{if $item.fv_switch=='yes'}<img border="0" id="convert_to_invoice_{$item.id}"
src="modules/EcmSales/images/convert_disabled.gif"
title="{$item.fv_name}" style="cursor:pointer;"
onClick="{literal}javascript:window.open('index.php?module=EcmInvoiceOuts&action=DetailView&record={/literal}{$item.fv_id}{literal}','_newtab');{/literal} " />'{/if}
{if $item.fv_switch=='no'}<img border="0" id="convert_to_invoice_{$item.id}"
src="modules/EcmSales/images/convert_enabled.gif"
title="Create Invoice"
onClick="{literal}javascript:window.open('index.php?module=EcmInvoiceOuts&action=EditView&isWZ=true&wz_record={/literal}{$item.fv_id}{literal}','_newtab');{/literal}"
style="cursor:pointer;" />{/if}
{if $item.wz_switch=='disabled'}<img src="modules/EcmSales/images/create_wz_disabled.gif"
title="{$item.wz_name}"
onclick="{literal}window.open('index.php?module=EcmStockDocOuts&action=DetailView&record={/literal}{$item.wz_id}{literal}','_newtab');{/literal}"
style="cursor: pointer;" border="0">&nbsp;{/if}
{if $item.wz_switch=='enabled'}<img src="modules/EcmSales/images/create_wz_enabled.gif"
title="{$MOD.LBL_LISTNEWSALES_CREATEWZ}"
onclick="{literal}javascript:window.open('index.php?module=EcmStockDocOuts&amp;action=EditView&parent_doc_type=EcmSales&parent_doc_id={/literal}{$item.id}{literal}','_newtab');{/literal}"
style="cursor: pointer;" border="0">{/if}
{else}
{if $item.rw_switch=='disabled'}<img src="modules/EcmSales/images/create_wz_disabled.gif" title="{$item.rw_name}" onclick="{literal}window.open('index.php?module=EcmStockDocInsideOuts&action=DetailView&record={/literal}{$item.rw_id}{literal}','_newtab');{/literal}" style="cursor: pointer;" border="0">&nbsp;{/if}
{if $item.rw_switch=='enabled'}<img src="modules/EcmSales/images/create_wz_enabled.gif" title="{$MOD.LBL_LISTNEWSALES_CREATERW}" onclick="{literal}javascript:window.open('index.php?module=EcmStockDocInsideOuts&amp;action=EditView&parent_doc_type=EcmSales&parent_doc_id={/literal}{$item.id}{literal}','_newtab');{/literal}" style="cursor: pointer;" border="0">{/if}
{if $item.rw_switch=='disabled'}<img src="modules/EcmSales/images/create_wz_disabled.gif"
title="{$item.rw_name}"
onclick="{literal}window.open('index.php?module=EcmStockDocInsideOuts&action=DetailView&record={/literal}{$item.rw_id}{literal}','_newtab');{/literal}"
style="cursor: pointer;" border="0">&nbsp;{/if}
{if $item.rw_switch=='enabled'}<img src="modules/EcmSales/images/create_wz_enabled.gif"
title="{$MOD.LBL_LISTNEWSALES_CREATERW}"
onclick="{literal}javascript:window.open('index.php?module=EcmStockDocInsideOuts&amp;action=EditView&parent_doc_type=EcmSales&parent_doc_id={/literal}{$item.id}{literal}','_newtab');{/literal}"
style="cursor: pointer;" border="0">{/if}
{/if}
<img src="modules/EcmSales/images/pdf.gif" title="Preview Sale" onclick="{literal}EcmPreviewPDF('index.php?module=EcmSales&action=previewPDF&method=I&record={$item.id}&to_pdf=1',{zoom:75,toolbar:1});{/literal}" style="cursor: pointer;" border="0">
</td></tr>
<img src="modules/EcmSales/images/pdf.gif" title="Preview Sale"
onclick="{literal}EcmPreviewPDF('index.php?module=EcmSales&action=previewPDF&method=I&record={$item.id}&to_pdf=1',{zoom:75,toolbar:1});{/literal}"
style="cursor: pointer;" border="0">
</td>
</tr>
{/if}
{/foreach}
</tbody>
<tr style="vertical-align:top;">
<td ></td>
<td ></td>
<td ></td>
<td ></td>
<td ></td>
<td ></td>
<td ></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>{$MOD.LBL_LISTNEWSALES_SUMMARY}:</td>
<td style="text-align: right">{$POSITION_LIST.total_quantity}</td>
<td style="text-align: right">{$POSITION_LIST.total_netto|number_format:2:".":","}</td>
<td style="text-align: right">{$POSITION_LIST.total_vat|number_format:2:".":","}</td>
<td style="text-align: right">{$POSITION_LIST.total_brutto|number_format:2:".":","}</td>
<td style="text-align: right">{$POSITION_LIST.total_invoice|number_format:2:".":","}</td>
<td style="text-align: right">{$POSITION_LIST.total_percent|string_format:"%.2f"}%<a style="cursor:pointer;" onclick="{literal}if(document.getElementById('div_all').style.display=='none'){document.getElementById('div_all').style.display='block';}else{document.getElementById('div_all').style.display='none';}{/literal}"><img border="0" src="modules/EcmQuotes/images/search.gif"></a>
<td style="text-align: right">{$POSITION_LIST.total_percent|string_format:"%.2f"}%<a style="cursor:pointer;"
onclick="{literal}if(document.getElementById('div_all').style.display=='none'){document.getElementById('div_all').style.display='block';}else{document.getElementById('div_all').style.display='none';}{/literal}"><img
border="0" src="modules/EcmQuotes/images/search.gif"></a>
<div style="display:none; border: 1px solid #cccccc;background-color:#e6e6e6;padding:3px;" id="div_all">
<table cellspacing="0" cellpadding="3" border="0"><tbody>
<tr><td width="40%"><strong>Index</strong></td>
<table cellspacing="0" cellpadding="3" border="0">
<tbody>
<tr>
<td width="40%"><strong>Index</strong></td>
<td><strong>Order</strong></td>
<td><strong>WZ</strong></td>
<td><strong>ETA</strong></td>
@@ -301,7 +358,9 @@ src="include/jQuery/jquery.blockUI.js"></script>
<tr style="color:black;">
<td style="color:black;"><a href="index.php?module=EcmProducts&amp;action=DetailView&amp;record={$va.id}">{$va.code}</a></td>
<td style="color:black;"><a
href="index.php?module=EcmProducts&amp;action=DetailView&amp;record={$va.id}">{$va.code}</a>
</td>
{if $va.order>$va.wz}
<td style="color:red;">{$va.order|number_format:2:".":","}</td>
<td style="color:red;">{$va.wz|number_format:2:".":","}</td>
@@ -309,12 +368,31 @@ src="include/jQuery/jquery.blockUI.js"></script>
<td style="color:black;">{$va.order|number_format:2:".":","}</td>
<td style="color:black;">{$va.wz|number_format:2:".":","}</td>
{/if}
<td style="color:black;"></td></tr>
<td style="color:black;"></td>
</tr>
{/if}
{/foreach}
<tr style="color:black;font-weight:bold"><td>Total</td>
<td>{$POSITION_LIST.total_product.order_total|number_format:2:".":","}</td><td>{$POSITION_LIST.total_product.wz_total|number_format:2:".":","}</td></tr><tr><td></td><td></td>
<td><span style="color:red;font-weight:bold">{$POSITION_LIST.total_product.minus|number_format:2:".":","}</span></td></tr>
<tr><td></td><td></td><td><span style="color:green;font-weight:bold">{$POSITION_LIST.total_product.plus|number_format:2:".":","}</span></td></tr></tbody></table></div>
<tr style="color:black;font-weight:bold">
<td>Total</td>
<td>{$POSITION_LIST.total_product.order_total|number_format:2:".":","}</td>
<td>{$POSITION_LIST.total_product.wz_total|number_format:2:".":","}</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<span style="color:red;font-weight:bold">{$POSITION_LIST.total_product.minus|number_format:2:".":","}</span>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<span style="color:green;font-weight:bold">{$POSITION_LIST.total_product.plus|number_format:2:".":","}</span>
</td>
</tr>
</tbody>
</table>
</div>
</table>

View File

@@ -204,6 +204,7 @@ if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
var $correct_id;
var $correct_name;
var $kind;

View File

@@ -1434,6 +1434,7 @@ addEvent(
var arr = eval(result)[0];
document.getElementById('number').value = arr.number;
document.getElementById('document_no').value = arr.document_no;
document.getElementById('status').value ='accepted';
},
''
);

View File

@@ -92,7 +92,7 @@
$OPT['new_number'] = true;
$focus->kind='other';
$focus->status = "s10";
$focus->status = "accepted";
if(isset($cc)) {
//payment condition