From e4e7df6522b943b2a23b5db57a34fc84c2b4807b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Sun, 6 Jul 2025 08:39:16 +0000 Subject: [PATCH] update --- REST/functions.php | 359 ++++----- REST/index.php | 55 +- config_override.php | 1 + include/language/en_us.EcmDropdownEditor.php | 9 +- include/language/pl_pl.EcmDropdownEditor.php | 17 +- index.php | 2 - modules/EcmInvoiceOuts/EcmInvoiceOut.php | 2 + modules/EcmInvoiceOuts/Save.php | 70 +- modules/EcmInvoiceOuts/invoiceEdiXML.php | 36 +- modules/EcmProducts/EcmProduct.php | 3 +- .../productionSchedule/productionSchedule.js | 128 +++- .../productionSchedule/productionSchedule.php | 75 +- .../productionSchedule/productionSchedule.tpl | 69 +- .../productsBySales/productsBySales.js | 8 +- .../productsBySales/productsBySales.tpl | 2 +- modules/EcmSales/EcmSale.php | 23 +- modules/EcmSales/ListNewSales.php | 20 +- modules/EcmSales/tpls/ListNewSales.tpl | 692 ++++++++++-------- modules/EcmStockDocIns/EcmStockDocIn.php | 1 + modules/EcmStockDocIns/EcmStockDocIns44.js | 1 + modules/EcmStockDocIns/EditView.php | 4 +- 21 files changed, 990 insertions(+), 587 deletions(-) diff --git a/REST/functions.php b/REST/functions.php index 51ea0ba3..b8f0c774 100644 --- a/REST/functions.php +++ b/REST/functions.php @@ -1,185 +1,188 @@ retrieve($record); - $pl = $inv->getPositionList(); - $response = array ( - 'document_no' => $inv->document_no, - 'register_date' => $inv->register_date, - 'total_netto' => $inv->total_netto, - 'total_brutto' => $inv->total_brutto, - 'vats_summary' => $inv->vats_summary, - 'position_list' => $pl - ); - echo json_encode($response); +function sendInvoice($record) { + require_once('modules/EcmInvoiceOuts/EcmInvoiceOut.php'); + $inv = new EcmInvoiceOut(); + $inv->retrieve($record); + $pl = $inv->getPositionList(); + $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) { + require_once('modules/EcmProducts/EcmProduct.php'); + $prod = new EcmProduct(); + $prod->retrieve($record); + $response = array ( + 'name' => $prod->name, + 'code' => $prod->code, + 'ean' => $prod->ean, + 'vat' => $prod->vat_value, + 'unit_id' => $prod->unit_id, + 'product_category_id' => $prod->product_category_id, + 'product_category_name' => $prod->product_category_name + ); + echo json_encode($response); +} +function copySaleFromTwinpol($record) { + $db = $GLOBALS['db']; + + // check if sale exists + $exists = $db->fetchByAssoc($db->query("SELECT id, document_no FROM ecmsales WHERE edi_zs_id='$record'")); + if (isset($exists)) { + echo "ZS istnieje: "; + echo ''.$exists['document_no'].''; + die(); } - function sendProduct($record) { - require_once('modules/EcmProducts/EcmProduct.php'); - $prod = new EcmProduct(); - $prod->retrieve($record); - $response = array ( - 'name' => $prod->name, - 'code' => $prod->code, - 'ean' => $prod->ean, - 'vat' => $prod->vat_value, - 'unit_id' => $prod->unit_id, - 'product_category_id' => $prod->product_category_id, - 'product_category_name' => $prod->product_category_name - ); - echo json_encode($response); - } - function copySaleFromTwinpol($record) { - $db = $GLOBALS['db']; - // check if sale exists - $exists = $db->fetchByAssoc($db->query("SELECT id, document_no FROM ecmsales WHERE edi_zs_id='$record'")); - if (isset($exists)) { - echo "ZS istnieje: "; - echo ''.$exists['document_no'].''; - die(); - } + $res = makeCUrlRequest("https://crm.twinpol.com/REST/index.php?key=d68dac4c-f784-4e1b-8267-9ffcfa0eda4c&action=getSale&record=".$record); + $sale = json_decode($res); + $sale->position_list = json_decode($sale->position_list); + echo "Numer dokumentu TwinPol: ".$sale->document_no."
"; - $res = makeCUrlRequest("https://crm.twinpol.com/REST/index.php?key=d68dac4c-f784-4e1b-8267-9ffcfa0eda4c&action=getSale&record=".$record); - $sale = json_decode($res); - $sale->position_list = json_decode($sale->position_list); - echo "Numer dokumentu TwinPol: ".$sale->document_no."
"; - - $gotAllProducts = true; // hope :) - $newPositionList = array(); - $total_netto = 0; $total_brutto = 0; $total_discount = 0; $vats = array(); - foreach ( $sale->position_list as $product ) { - echo 'Produkt: '.$product->product_code; - $p = getProduct(trim($product->product_code)); - if (!$p) { - echo '  (produkt nie istnieje w bazie E5)
'; - $gotAllProducts = false; - continue; + $gotAllProducts = true; // hope :) + $newPositionList = array(); + $total_netto = 0; $total_brutto = 0; $total_discount = 0; $vats = array(); + foreach ( $sale->position_list as $product ) { + echo 'Produkt: '.$product->product_code; + $p = getProduct(trim($product->product_code)); + if (!$p) { + echo '  (produkt nie istnieje w bazie E5)
'; + $gotAllProducts = false; + continue; + } else { + // pricebook price? + $pricebookPrice = $db->fetchByAssoc($db->query(" + SELECT price FROM ecmpricebooks_ecmproducts + WHERE ecmpricebook_id = '3e78ac33-7c46-1b94-0a67-653a17c06f9e' + AND ecmproduct_id='$p->id' + AND deleted=0 LIMIT 0,1")); + if (isset($pricebookPrice)) { + $price_start = $pricebookPrice['price']; + echo " Cena: ".$price_start." (Amazon_2023)
"; } else { - // pricebook price? - $pricebookPrice = $db->fetchByAssoc($db->query(" - SELECT price FROM ecmpricebooks_ecmproducts - WHERE ecmpricebook_id = '3e78ac33-7c46-1b94-0a67-653a17c06f9e' - AND ecmproduct_id='$p->id' - AND deleted=0 LIMIT 0,1")); - if (isset($pricebookPrice)) { - $price_start = $pricebookPrice['price']; - echo " Cena: ".$price_start." (Amazon_2023)
"; - } else { - // invoice price? - $fvPrice = $db->fetchByAssoc($db->query(" - SELECT i.id, i.document_no, ii.price_start, ii.ecmvat_value, ii.ecmvat_name, ii.ecmvat_id - FROM ecminvoiceoutitems AS ii - INNER JOIN ecminvoiceouts AS i - ON i.id = ii.ecminvoiceout_id - WHERE - i.parent_id= '1b9643ca-5b1a-8f9b-b809-586b5619b068' AND - i.currency_id = 'PLN' AND - ii.ecmproduct_id = '$p->id' - ORDER BY i.register_date DESC - LIMIT 0,1 - ")); + // invoice price? + $fvPrice = $db->fetchByAssoc($db->query(" + SELECT i.id, i.document_no, ii.price_start, ii.ecmvat_value, ii.ecmvat_name, ii.ecmvat_id + FROM ecminvoiceoutitems AS ii + INNER JOIN ecminvoiceouts AS i + ON i.id = ii.ecminvoiceout_id + WHERE + i.parent_id= '1b9643ca-5b1a-8f9b-b809-586b5619b068' AND + i.currency_id = 'PLN' AND + ii.ecmproduct_id = '$p->id' + ORDER BY i.register_date DESC + LIMIT 0,1 + ")); - if (!isset($fvPrice)) { - $price_start = 0; - echo " Brak ceny
"; - } else { - $price_start = $fvPrice['price_start']; - echo " Cena: ".$price_start." (".$fvPrice['document_no'].")
"; - } - } - - $prod = array(); - - if (!isset($product->discount)) { - $product->discount = 0; - } - $prod['quantity'] = $product->quantity; - $prod['discount'] = $product->discount; - $prod['price_start'] = $price_start; - $prod['price_netto'] = round($price_start - ($price_start * ($product->discount / 100)),2); - $prod['ecmvat_id'] = $fvPrice['ecmvat_id']; - $prod['ecmvat_value'] = $fvPrice['ecmvat_value']; - $prod['ecmvat_name'] = $fvPrice['ecmvat_name']; - $prod['price_brutto'] = round($prod['price_netto']+($prod['price_netto']*($prod['ecmvat_value']/100)),2); - $prod['total_netto'] = round($prod['price_netto'] * $prod['quantity'], 2); - $prod['total_brutto'] = round($prod['total_netto']+($prod['total_netto']*($prod['ecmvat_value']/100)),2); - - $total_netto += $prod['total_netto']; - $total_brutto += $prod['total_brutto']; - $total_discount = ($prod['price_start'] - $prod['price_netto']) * $prod['quantity']; - - if (isset($vats[$prod['ecmvat_value']])) { - $vats[$prod['ecmvat_value']] += $prod['total_netto']; + if (!isset($fvPrice)) { + $price_start = 0; + echo " Brak ceny
"; } else { - $vats[$prod['ecmvat_value']] = $prod['total_netto']; + $price_start = $fvPrice['price_start']; + echo " Cena: ".$price_start." (".$fvPrice['document_no'].")
"; } + } - $prod['date_entered'] = date('Y-m-d H:i:s'); - $prod['date_modified'] = date('Y-m-d H:i:s'); - $prod['modified_user_id'] = null; - $prod['assigned_user_id'] = null; - $prod['created_by'] = null; - $prod['deleted'] = '0'; - $prod['product_id'] = $p->id; - $prod['position'] = $product->position; - $prod['product_code'] = $p->code; - $prod['name'] = $product->name; - $prod['unit_id'] = $product->unit_id; - $prod['unit_name'] = $product->unit_name; - $prod['category_id'] = $p->product_category_id; - $prod['recipient_code'] = $product->recipient_code; - $prod['ean'] = $p->ean; - array_push($newPositionList, $prod); + $prod = array(); + + if (!isset($product->discount)) { + $product->discount = 0; } - } - $vats_summary = ''; - foreach ($vats as $k=>$v ) { - $vats_summary .= $k.'%:'.$v.','; - } + $prod['quantity'] = $product->quantity; + $prod['discount'] = $product->discount; + $prod['price_start'] = $price_start; + $prod['price_netto'] = round($price_start - ($price_start * ($product->discount / 100)),2); + $prod['ecmvat_id'] = $fvPrice['ecmvat_id']; + $prod['ecmvat_value'] = $fvPrice['ecmvat_value']; + $prod['ecmvat_name'] = $fvPrice['ecmvat_name']; + $prod['price_brutto'] = round($prod['price_netto']+($prod['price_netto']*($prod['ecmvat_value']/100)),2); + $prod['total_netto'] = round($prod['price_netto'] * $prod['quantity'], 2); + $prod['total_brutto'] = round($prod['total_netto']+($prod['total_netto']*($prod['ecmvat_value']/100)),2); - if (!$gotAllProducts) { - echo 'Brak produktow w bazie E5. Dokument nie zostal skopiowany.'; - die(); - } + $total_netto += $prod['total_netto']; + $total_brutto += $prod['total_brutto']; + $total_discount = ($prod['price_start'] - $prod['price_netto']) * $prod['quantity']; - require_once('modules/EcmSales/EcmSale.php'); - $new = new EcmSale(); - $new->position_list = $newPositionList; - $new->parent_id = "1b9643ca-5b1a-8f9b-b809-586b5619b068"; - $new->parent_name = "Twinpol Sp. z o.o."; - $new->parent_address_street = "al. Lipowa 48"; - $new->parent_address_city = "Obrowo"; - $new->parent_address_postalcode = "87-126"; - $new->parent_address_country = "Polska"; - $new->parent_nip = "8792676609"; - $new->parent_iln = "5909000837119"; - $new->pricebook_id = "13b29aa1-48f0-de58-7630-59c22756c5e4"; - $new->status = "s30"; - $new->type = "sales_order"; - $new->name = $sale->name; - $new->ecmpaymentcondition_name = "90 dni"; - $new->ecmpaymentcondition_id = "28de9f83-abd3-9a5d-4df9-4df9b7e0031f"; - $new->parent_document_no = $sale->parent_document_no; - $new->register_date = $sale->register_date; - $new->send_date = $sale->send_date; - $new->delivery_date = $sale->delivery_date; - $new->ecmlanguage = "pl_pl"; - $new->currency_id = 'PLN'; - $new->total_netto = $total_netto; - $new->total_brutto = $total_brutto; - $new->discount = $total_discount; - $new->vats_summary = $vats_summary; - $new->shipping_address_name = $sale->parent_name; - $new->shipping_address_street = $sale->parent_address_street; - $new->shipping_address_postalcode = $sale->parent_address_postalcode; - $new->shipping_address_city = $sale->parent_address_city; - $new->shipping_address_country = $sale->parent_address_country; - $new->shipping_iln = $sale->parent_iln; - $new->shipping_nip = $sale->parent_nip; - $new->edi_zs_id = $sale->id; - $new->edi_zs_document_no = $sale->document_no; - $new->pdf_text = + if (isset($vats[$prod['ecmvat_value']])) { + $vats[$prod['ecmvat_value']] += $prod['total_netto']; + } else { + $vats[$prod['ecmvat_value']] = $prod['total_netto']; + } + + $prod['date_entered'] = date('Y-m-d H:i:s'); + $prod['date_modified'] = date('Y-m-d H:i:s'); + $prod['modified_user_id'] = null; + $prod['assigned_user_id'] = null; + $prod['created_by'] = null; + $prod['deleted'] = '0'; + $prod['product_id'] = $p->id; + $prod['position'] = $product->position; + $prod['product_code'] = $p->code; + $prod['name'] = $product->name; + $prod['unit_id'] = $product->unit_id; + $prod['unit_name'] = $product->unit_name; + $prod['category_id'] = $p->product_category_id; + $prod['recipient_code'] = $product->recipient_code; + $prod['ean'] = $p->ean; + array_push($newPositionList, $prod); + } + } + $vats_summary = ''; + foreach ($vats as $k=>$v ) { + $vats_summary .= $k.'%:'.$v.','; + } + + if (!$gotAllProducts) { + echo 'Brak produktow w bazie E5. Dokument nie zostal skopiowany.'; + die(); + } + + require_once('modules/EcmSales/EcmSale.php'); + $new = new EcmSale(); + $new->position_list = $newPositionList; + $new->parent_id = "1b9643ca-5b1a-8f9b-b809-586b5619b068"; + $new->parent_name = "Twinpol Sp. z o.o."; + $new->parent_address_street = "al. Lipowa 48"; + $new->parent_address_city = "Obrowo"; + $new->parent_address_postalcode = "87-126"; + $new->parent_address_country = "Polska"; + $new->parent_nip = "8792676609"; + $new->parent_iln = "5909000837119"; + $new->pricebook_id = "13b29aa1-48f0-de58-7630-59c22756c5e4"; + $new->status = "s30"; + $new->type = "sales_order"; + $new->name = $sale->name; + $new->ecmpaymentcondition_name = "90 dni"; + $new->ecmpaymentcondition_id = "28de9f83-abd3-9a5d-4df9-4df9b7e0031f"; + $new->parent_document_no = $sale->parent_document_no; + $new->register_date = $sale->register_date; + $new->send_date = $sale->send_date; + $new->delivery_date = $sale->delivery_date; + $new->ecmlanguage = "pl_pl"; + $new->currency_id = 'PLN'; + $new->total_netto = $total_netto; + $new->total_brutto = $total_brutto; + $new->discount = $total_discount; + $new->vats_summary = $vats_summary; + $new->shipping_address_name = $sale->parent_name; + $new->shipping_address_street = $sale->parent_address_street; + $new->shipping_address_postalcode = $sale->parent_address_postalcode; + $new->shipping_address_city = $sale->parent_address_city; + $new->shipping_address_country = $sale->parent_address_country; + $new->shipping_iln = $sale->parent_iln; + $new->shipping_nip = $sale->parent_nip; + $new->edi_zs_id = $sale->id; + $new->edi_zs_document_no = $sale->document_no; + $new->pdf_text = "Dostawa ".$sale->shipping_address_name." ".$sale->shipping_address_street." @@ -188,16 +191,16 @@ NIP: ".$sale->shipping_nip." ILN: ".$sale->shipping_iln; - $newId = $new->save(true); + $newId = $new->save(true); - //update E5 number in Twinpol - $res = $db->fetchByAssoc($db->query("SELECT document_no FROM ecmsales WHERE id='$newId'")); - $document_no = str_replace(" ", "%20", $res['document_no']); - makeCUrlRequest("https://crm.twinpol.com/REST/index.php?key=d68dac4c-f784-4e1b-8267-9ffcfa0eda4c&action=updateSaleE5Number&record=$record&e5_record=$newId&e5_document_no=$document_no"); + //update E5 number in Twinpol + $res = $db->fetchByAssoc($db->query("SELECT document_no FROM ecmsales WHERE id='$newId'")); + $document_no = str_replace(" ", "%20", $res['document_no']); + makeCUrlRequest("https://crm.twinpol.com/REST/index.php?key=d68dac4c-f784-4e1b-8267-9ffcfa0eda4c&action=updateSaleE5Number&record=$record&e5_record=$newId&e5_document_no=$document_no"); - echo 'Utworzono ZS.'; - die(); - } + echo 'Utworzono ZS.'; + die(); +} // local helpers function getProduct($code) { diff --git a/REST/index.php b/REST/index.php index a1a4b460..09a9e75c 100644 --- a/REST/index.php +++ b/REST/index.php @@ -12,11 +12,11 @@ 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"]) { - case 'getInvoice': + case 'getInvoice': sendInvoice($_GET['record']); break; case 'getProduct': @@ -25,5 +25,52 @@ switch ($_GET["action"]) { case 'copySaleFromTwinpol': copySaleFromTwinpol($_GET['record']); break; -} -?> \ No newline at end of file + 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; + } +} \ No newline at end of file diff --git a/config_override.php b/config_override.php index c1a66e01..9bbd1fdc 100644 --- a/config_override.php +++ b/config_override.php @@ -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ł'; diff --git a/include/language/en_us.EcmDropdownEditor.php b/include/language/en_us.EcmDropdownEditor.php index 8b2789ff..2a0b54da 100644 --- a/include/language/en_us.EcmDropdownEditor.php +++ b/include/language/en_us.EcmDropdownEditor.php @@ -1,5 +1,5 @@ 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 ( diff --git a/include/language/pl_pl.EcmDropdownEditor.php b/include/language/pl_pl.EcmDropdownEditor.php index b47643b5..3dc6eb9b 100644 --- a/include/language/pl_pl.EcmDropdownEditor.php +++ b/include/language/pl_pl.EcmDropdownEditor.php @@ -1,5 +1,5 @@ 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 ( diff --git a/index.php b/index.php index 5021c042..40c18535 100755 --- a/index.php +++ b/index.php @@ -1,6 +1,4 @@ retrieve($_POST['record']); +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; } +} - if(!$focus->ACLAccess('Save')){ - ACLController::displayNoAccess(true); - sugar_cleanup(true); +foreach ($focus->additional_column_fields as $field) { + if (isset($_POST[$field])) { + $value = $_POST[$field]; + $focus->$field = $value; } - $check_notify = FALSE; +} - foreach($focus->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); - foreach($focus->additional_column_fields as $field){ - if(isset($_POST[$field])){ - $value = $_POST[$field]; - $focus->$field = $value; - } - } +$return_id = $focus->id; - $focus->position_list = $json->decode(htmlspecialchars_decode($_POST['position_list'])); - // die(var_dump( $focus->position_list)); - $focus->save($check_notify); +// 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); +} - $return_id = $focus->id; +echo $return_id; - echo $return_id; - - handleRedirect($return_id,'EcmInvoiceOuts'); -?> \ No newline at end of file +handleRedirect($return_id, 'EcmInvoiceOuts'); diff --git a/modules/EcmInvoiceOuts/invoiceEdiXML.php b/modules/EcmInvoiceOuts/invoiceEdiXML.php index bc15099c..9755457a 100644 --- a/modules/EcmInvoiceOuts/invoiceEdiXML.php +++ b/modules/EcmInvoiceOuts/invoiceEdiXML.php @@ -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(); // $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(); // diff --git a/modules/EcmProducts/EcmProduct.php b/modules/EcmProducts/EcmProduct.php index 56ecc72c..dab9b789 100755 --- a/modules/EcmProducts/EcmProduct.php +++ b/modules/EcmProducts/EcmProduct.php @@ -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; diff --git a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.js b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.js index d01cbeb0..c9976690 100644 --- a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.js +++ b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.js @@ -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.append(""); + tr.append("" + (index + 1) + ""); + tr.append("" + el.code + ""); + tr.append("" + el.name + ""); + tr.append("" + el.quantity + ""); + tr.append("" + el.unit + ""); + tr.append("" + el.stockState + ""); + tr.append("" + el.stockAddress + ""); + $("#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 '
PozycjaIndeksNazwaIlośćJM.StanAdres magazynowy
'; +} +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 () { diff --git a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php index 1cf71130..a0902f15 100644 --- a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php +++ b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.php @@ -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']; diff --git a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.tpl b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.tpl index 4ff5f0da..c9e617c4 100644 --- a/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.tpl +++ b/modules/EcmReports/BimIT-Reports/productionSchedule/productionSchedule.tpl @@ -76,21 +76,67 @@ - -    - - -
+ + +
+
+ +     + + + - + @@ -205,3 +251,14 @@
  Indeks Nazwa Data produkcji
+ + + + diff --git a/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.js b/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.js index e1baf937..c0c358c5 100644 --- a/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.js +++ b/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.js @@ -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); diff --git a/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.tpl b/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.tpl index 5da83b0b..cf27b785 100644 --- a/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.tpl +++ b/modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.tpl @@ -139,7 +139,7 @@

- +
diff --git a/modules/EcmSales/EcmSale.php b/modules/EcmSales/EcmSale.php index ee2b310e..67f1554b 100644 --- a/modules/EcmSales/EcmSale.php +++ b/modules/EcmSales/EcmSale.php @@ -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; } diff --git a/modules/EcmSales/ListNewSales.php b/modules/EcmSales/ListNewSales.php index 7b8bbabb..05d42fcc 100644 --- a/modules/EcmSales/ListNewSales.php +++ b/modules/EcmSales/ListNewSales.php @@ -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 '
'; -?> \ No newline at end of file diff --git a/modules/EcmSales/tpls/ListNewSales.tpl b/modules/EcmSales/tpls/ListNewSales.tpl index 4f98e7ea..7cc18504 100644 --- a/modules/EcmSales/tpls/ListNewSales.tpl +++ b/modules/EcmSales/tpls/ListNewSales.tpl @@ -1,320 +1,398 @@ - - + + - - - - + + + +
EcmProducts

{$MOD.LBL_LISTNEWSALES_NAME}

EcmProducts

{$MOD.LBL_LISTNEWSALES_NAME}

-
- - - - - - +
- {$MOD.LBL_LISTNEWSALES_DATE_START}: - - - Enter Date - +
+ + + + + + - - - - + + + + + + - {$MOD.LBL_LISTNEWSALES_DATE_END}: + + + + + + + + + - - Enter Date - - - - - - - - - - -
+ Data wysyłki od + + + Enter Date + - {$MOD.LBL_LISTNEWSALES_DATE_END}: + {$MOD.LBL_LISTNEWSALES_DATE_END}: - - Enter Date - - - {$MOD.LBL_LISTNEWSALES_ACCOUNT_NAME}: - - - - - - - {$MOD.LBL_LISTNEWSALES_DOCUMENT_CREATE_DATE_START}: - - - Enter Date - + + Enter Date + + Typ: + + Status: + + + {$MOD.LBL_LISTNEWSALES_ACCOUNT_NAME}: + + + + + + + {$MOD.LBL_LISTNEWSALES_NOT_ASSIGNED}: + + +
+ Data dostawy od: + + + Enter Date + + do: + + Enter Date + + + {$MOD.LBL_LISTNEWSALES_ORDER_NO}: + + +
- {$MOD.LBL_LISTNEWSALES_NOT_ASSIGNED}: - - -
- {$MOD.LBL_LISTNEWSALES_ORDER_NO}: - - - - {$MOD.LBL_LISTNEWSALES_ORDER_TYPE}: - - Data wysyłki od - - - Enter Date - +
- {$MOD.LBL_LISTNEWSALES_DATE_END}: +

{if $POST.date_send_from!='' && $POST.date_from!=''}Proszę wybrać date dostawy lub datę wysyłki{/if}

+ + + + + + + +
{if $LINK!=''}{$LINK}{/if} - - Enter Date - -
+ + + + + + + + + + + + + + + + + + + + + + + {foreach from=$POSITION_LIST key="key" item="item" name="components"} + {if $item.id!=''} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{$MOD.LBL_LISTNEWSALES_POS}{$MOD.LBL_LISTNEWSALES_NUMBER}{$MOD.LBL_LISTNEWSALES_DESCRIPTION}{$MOD.LBL_LISTNEWSALES_PARENT_NAME}{$MOD.LBL_LISTNEWSALES_DELIVERY_DATE}Termin wysyłki{$MOD.LBL_LISTNEWSALES_QUANTITY}{$MOD.LBL_LISTNEWSALES_TOTAL_NETTO}{$MOD.LBL_LISTNEWSALES_TOTAL_VAT}{$MOD.LBL_LISTNEWSALES_TOTAL_BRUTTO}{$MOD.LBL_LISTNEWSALES_TOTAL_INVOICE}{$MOD.LBL_LISTNEWSALES_PERCENT}{$MOD.LBL_LISTNEWSALES_CURRENCY}{$MOD.LBL_LISTNEWSALES_PRINTED} 
{$item.position}{$item.document_no} + + {$item.parent_name} + {$item.delivery_date}{$item.send_date} {$item.quantity}{$item.total_netto|number_format:2:".":","}{$item.total_vat|number_format:2:".":","}{$item.total_brutto|number_format:2:".":","}{$item.total_invoice|number_format:2:".":","}{$item.percent} +
Total{$item.products.order_total|number_format:2:".":","}{$item.products.wz_total|number_format:2:".":","}
+ {$item.products.minus|number_format:2:".":","} +
+ {$item.products.plus|number_format:2:".":","} +
+
+ + {$CURRENCIES[$item.currency]} + + + {if $item.type!='gratis'} + {if $item.fv_switch=='yes'}'{/if} + {if $item.fv_switch=='no'}{/if} + {if $item.wz_switch=='disabled'} {/if} + {if $item.wz_switch=='enabled'}{/if} + {else} + {if $item.rw_switch=='disabled'} {/if} + {if $item.rw_switch=='enabled'}{/if} + {/if} + + + + {/if} -

{if $POST.date_send_from!='' && $POST.date_from!=''}Proszę wybrać date dostawy lub datę wysyłki{/if}

- - - - - - - -
{if $LINK!=''}{$LINK}{/if} + {/foreach} + + + + + + + + + + {$MOD.LBL_LISTNEWSALES_SUMMARY}: + {$POSITION_LIST.total_quantity} + {$POSITION_LIST.total_netto|number_format:2:".":","} + {$POSITION_LIST.total_vat|number_format:2:".":","} + {$POSITION_LIST.total_brutto|number_format:2:".":","} + {$POSITION_LIST.total_invoice|number_format:2:".":","} + {$POSITION_LIST.total_percent|string_format:"%.2f"}% + - {/foreach} - - - - - - - - - - {$MOD.LBL_LISTNEWSALES_SUMMARY}: - {$POSITION_LIST.total_quantity} - {$POSITION_LIST.total_netto|number_format:2:".":","} - {$POSITION_LIST.total_vat|number_format:2:".":","} - {$POSITION_LIST.total_brutto|number_format:2:".":","} - {$POSITION_LIST.total_invoice|number_format:2:".":","} - {$POSITION_LIST.total_percent|string_format:"%.2f"}% - - - \ No newline at end of file + \ No newline at end of file diff --git a/modules/EcmStockDocIns/EcmStockDocIn.php b/modules/EcmStockDocIns/EcmStockDocIn.php index 299bcbe8..504796a3 100755 --- a/modules/EcmStockDocIns/EcmStockDocIn.php +++ b/modules/EcmStockDocIns/EcmStockDocIn.php @@ -204,6 +204,7 @@ if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); var $correct_id; var $correct_name; + var $kind; diff --git a/modules/EcmStockDocIns/EcmStockDocIns44.js b/modules/EcmStockDocIns/EcmStockDocIns44.js index 4fffb6e9..2ab7cab0 100755 --- a/modules/EcmStockDocIns/EcmStockDocIns44.js +++ b/modules/EcmStockDocIns/EcmStockDocIns44.js @@ -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'; }, '' ); diff --git a/modules/EcmStockDocIns/EditView.php b/modules/EcmStockDocIns/EditView.php index 8503030c..307ff0d2 100755 --- a/modules/EcmStockDocIns/EditView.php +++ b/modules/EcmStockDocIns/EditView.php @@ -91,8 +91,8 @@ } $OPT['new_number'] = true; - $focus->kind='other'; - $focus->status = "s10"; + $focus->kind='other'; + $focus->status = "accepted"; if(isset($cc)) { //payment condition