Commit old changes

This commit is contained in:
2024-09-30 08:44:00 +00:00
parent 01c92080cd
commit 6a37a77895
20 changed files with 581 additions and 956 deletions

View File

@@ -98,7 +98,6 @@ if($timestamp[0] < strtotime(date('H:i'))) {
$s = new Scheduler();
$s->flushDeadJobs();
$s->checkPendingJobs();
$GLOBALS['log']->info('Scheduler - tutaj dochodzę');
} else {
$GLOBALS['log']->fatal('Scheduler cannot write PID file. Please check permissions on '.$cachePath);
}
@@ -107,4 +106,3 @@ if($timestamp[0] < strtotime(date('H:i'))) {
}
$exit_on_cleanup = true;
sugar_cleanup($exit_on_cleanup);
?>

View File

@@ -42,8 +42,8 @@ $app_list_strings['moduleList']['EcmTexts']='Texts';
$app_list_strings['moduleList']['EcmInvoiceOuts'] = 'Invoices';
$app_list_strings['ecminvoiceouts_parent_dom'] = array (
'Accounts' => $app_list_strings['moduleList']['Accounts'],
'Contacts' => $app_list_strings['moduleList']['Contacts'],
//'Accounts' => $app_list_strings['moduleList']['Accounts'],
//'Contacts' => $app_list_strings['moduleList']['Contacts'],
);
$app_list_strings['ecminvoiceouts_status_dom'] = array (
'registered' => 'Registered',

View File

@@ -4,8 +4,8 @@
$app_list_strings['moduleList']['EcmInvoiceOuts'] = 'Faktury';
$app_list_strings['ecminvoiceouts_parent_dom'] = array (
'Accounts' => $app_list_strings['moduleList']['Accounts'],
'Contacts' => $app_list_strings['moduleList']['Contacts'],
//'Accounts' => $app_list_strings['moduleList']['Accounts'],
//'Contacts' => $app_list_strings['moduleList']['Contacts'],
);
$app_list_strings['ecminvoiceouts_type_dom'] = array (
'normal' => 'Normalna',
@@ -48,7 +48,7 @@ $app_list_strings['ecmproducts_product_brand_dom'] = array(
'brak' => 'Brak',
);
$app_list_strings['moduleList']['EcmDeliveryConditions'] = 'Warunki Przesy<73>ki';
$app_list_strings['moduleList']['EcmDeliveryConditions'] = 'Warunki Przesy<73>ki';
$app_list_strings['moduleList']['EcmDocumentTemplates']='Szablony Dokumentów';

View File

@@ -62,7 +62,7 @@ function checkEDISales()
$s->document_no = $s->formatNumber($number);
$s->edi_file = $order;
$s->type = 'sales_order';
$s->status = 's30';
$s->status = 's60';
$s->ecmlanguage = 'pl_pl';
$a = new Account();
$a->retrieve($s->parent_id);

View File

@@ -1,5 +1,5 @@
<?php
// created: 2024-04-26 08:00:00
// created: 2024-09-12 06:58:07
$customDoms = array (
'ecmproducts_attribute_dom' =>
array (
@@ -41,10 +41,14 @@ $customDoms = array (
'8f4fdd3c-44f9-103b-3f40-659f1c128319' => 'Bottle D22_500ml',
'307f61db-5fd9-3aa6-e701-65a04f4bba88' => 'B D23_500ml (nabłyszczacz)',
'5df47246-d0cd-4151-9bdd-65eede53aba5' => 'B D24_500ml (systemy mleczne)',
'ab74cd2c-7720-5875-7ca5-66bb55a3e075' => 'Bottle D25_500ml (Ula)',
'd7c10cb9-7459-1174-6315-661cdae38a39' => 'D11_1000ml',
'58664d9d-0295-3539-4662-659f18dc4b80' => 'Bottle',
'92a7ee9b-d953-fd7e-5c88-65c9bf1e144d' => 'B D22_1000ml (szyjka)',
'87a2b609-9b67-de82-8f41-65eedd4613c9' => 'D23_1000ml (systemy mleczne)',
'75980ea5-d89e-3923-2662-66bb55202244' => 'D24_1000ml (Ula)',
'ba4f06a8-f6fb-4969-d4b9-6683e6b6b372' => 'D11_2000ml ',
'cb8f5e45-43e1-b62d-05d7-669646b4eb10' => 'Bottle D12_5000ml (kanister)',
'820341fa-0db5-9d74-7544-659f17560658' => 'Kit ',
'567da064-cd31-0416-2ad3-6581cc870e96' => 'Doypack 110x180mm',
'edf38614-90c3-50a7-56e8-65dda2d891c2' => 'Doypack 130x220mm',
@@ -57,18 +61,22 @@ $customDoms = array (
'48369f61-18bd-53e6-070a-659f026773ac' => 'Box',
'37dbeaa1-f183-3b3e-1b54-65aa78a662a2' => 'Jar 500 ml',
'f13d7541-494d-75c7-2a35-65aa784b42a5' => 'Jar 1000 ml',
'e703a7f9-d27d-b445-d946-66727a3940d9' => 'Jar 1500 ml',
'da8d7be4-58dc-4f75-f547-65c310cd97dd' => 'Jar 65 ml',
'e1a16dbf-7216-d184-b9ed-65c310aff4d4' => 'Jar 150 ml',
'2a9454a6-b2a1-150f-c307-65c31102cb28' => 'Jar 250 ml',
'3acd80de-8dcc-ced9-c2fa-65eee6ae9949' => 'Foam 100 ml',
'3acd80de-8dcc-ced9-c2fa-65eee6ae9949' => 'Spray 100 ml',
'6014bd30-9be6-4348-5b3a-6603f015f392' => 'Bucket 2,75l',
'786f48d6-16e7-a0a4-4aec-6628a16a0f89' => 'Foam 100ml',
'349b50d1-0a7b-b3bd-e72e-662b42ca98ae' => 'Foam 400ml',
'cb66a685-53e1-5f87-0a25-66967c7cb63b' => 'Doypack 210x285mm',
'75f4bd2a-51a8-0767-635e-66dde15af79e' => 'Foam 200ml',
),
'ecmproducts_brand_dom' =>
array (
'6c5722f6-33b3-41c3-a878-e2f7628e8360' => 'None',
'3dc7c0bb-3d26-427c-9ff0-6319ead2e988' => 'Soyeco',
'33fb10ad-55f6-54ac-73e5-66bb6130d36f' => 'Soyeco amz',
'5820a5e7-8fd4-48bd-ab28-bfd60c321c15' => 'Frischer',
'2499563d-3671-c19a-c407-6628c97df75c' => 'Frischer amz',
'c0a6f467-9021-47cc-9b31-9398d9c2e898' => 'e5',
@@ -130,6 +138,17 @@ $customDoms = array (
'1ba0e21f-9a07-b93c-5e2f-65e8c7bb833d' => 'Purivita',
'5cc10610-e61e-846f-96a7-6613b79abce2' => 'Frischer Winner',
'8fb7cdf2-b9a9-ab07-d297-661670fb6120' => 'Aqualogis',
'd56c3876-c214-3829-f7b9-66618595d478' => 'Caffedelmondo',
'a7ca98eb-9a5d-660b-f483-666c350903c9' => 'Wilfa',
'2f641941-0ba1-b88b-2cb1-6684f93ef879' => 'Beko',
'89adb9a7-9d3e-1ec6-a4cf-668e2e46f158' => 'Aroca',
'26b07787-4207-7ab5-40fa-669527407b5a' => 'APM',
'47c4e190-198c-dcb6-612b-66978335a059' => 'Reus',
'a8a956e1-8288-2976-b71c-66bb3b8c3b8e' => 'Drekker',
'510f0cc2-1a76-3821-dbf2-66bb9e51bfc1' => 'NextProvider',
'd5f819ff-297b-c0d8-cfcd-66d0d0103806' => 'EcoExpert',
'4144e574-4870-fa26-25a0-66d85b094f7b' => 'Office Discount',
'e00b0e4a-ba66-796d-3bcb-66d89240c2cd' => 'Printus',
),
'ecmproducts_category_dom' =>
array (
@@ -257,7 +276,7 @@ $customDoms = array (
array (
'sales_order' => 'Sales Order',
'gratis' => 'Samples',
'b2c' => 'Stock states',
'b2c' => 'For stock',
'b2b' => 'Import',
'interval_order' => 'Zamówienie okresowe',
),
@@ -274,9 +293,7 @@ $customDoms = array (
's30' => 'Accepted',
's40' => 'Not Accepted',
's50' => 'Sent',
's60' => 'Won',
's70' => 'Lost',
's80' => 'Delivery Note',
's60' => 'From Stock',
'93cc9f90-9a94-5502-50a9-66264b2fd03a' => 'Closed',
),
);

View File

@@ -1,5 +1,5 @@
<?php
// created: 2024-04-26 08:00:00
// created: 2024-09-12 06:58:07
$customDoms = array (
'ecmproducts_attribute_dom' =>
array (
@@ -41,10 +41,14 @@ $customDoms = array (
'8f4fdd3c-44f9-103b-3f40-659f1c128319' => 'Butelka D22_500ml (szyjka)',
'307f61db-5fd9-3aa6-e701-65a04f4bba88' => 'Butelka D23_500ml (nabłyszczacz)',
'5df47246-d0cd-4151-9bdd-65eede53aba5' => 'Butelka D24_500ml (systemy mleczne)',
'ab74cd2c-7720-5875-7ca5-66bb55a3e075' => 'Butelka D25_500ml (Ula)',
'd7c10cb9-7459-1174-6315-661cdae38a39' => 'Butelka D11_1000ml (RPET)',
'58664d9d-0295-3539-4662-659f18dc4b80' => 'Butelka D21_1000ml (Odkamieniacz)',
'92a7ee9b-d953-fd7e-5c88-65c9bf1e144d' => 'Butelka D22_1000ml (szyjka)',
'87a2b609-9b67-de82-8f41-65eedd4613c9' => 'Butelka D23_1000ml (systemy mleczne)',
'75980ea5-d89e-3923-2662-66bb55202244' => 'Butelka D24_1000ml (Ula)',
'ba4f06a8-f6fb-4969-d4b9-6683e6b6b372' => 'Butelka D11_2000ml (płyn do prania)',
'cb8f5e45-43e1-b62d-05d7-669646b4eb10' => 'Butelka D12_5000ml (kanister)',
'820341fa-0db5-9d74-7544-659f17560658' => 'Zestaw D1_500ml+zapas',
'567da064-cd31-0416-2ad3-6581cc870e96' => 'Doypack 110x180mm',
'edf38614-90c3-50a7-56e8-65dda2d891c2' => 'Doypack 130x220mm',
@@ -57,18 +61,22 @@ $customDoms = array (
'48369f61-18bd-53e6-070a-659f026773ac' => 'Kartonik ',
'37dbeaa1-f183-3b3e-1b54-65aa78a662a2' => 'Słoik 500 ml',
'f13d7541-494d-75c7-2a35-65aa784b42a5' => 'Słoik 1000 ml',
'e703a7f9-d27d-b445-d946-66727a3940d9' => 'Słoik 1500 ml',
'da8d7be4-58dc-4f75-f547-65c310cd97dd' => 'Słoik 65 ml',
'e1a16dbf-7216-d184-b9ed-65c310aff4d4' => 'Słoik 150 ml',
'2a9454a6-b2a1-150f-c307-65c31102cb28' => 'Słoik 250 ml',
'3acd80de-8dcc-ced9-c2fa-65eee6ae9949' => 'Pianka 100 ml',
'3acd80de-8dcc-ced9-c2fa-65eee6ae9949' => 'Spray 100 ml',
'6014bd30-9be6-4348-5b3a-6603f015f392' => 'Wiadro 2,75l',
'786f48d6-16e7-a0a4-4aec-6628a16a0f89' => 'Pianka 100ml',
'349b50d1-0a7b-b3bd-e72e-662b42ca98ae' => 'Pianka 400ml',
'cb66a685-53e1-5f87-0a25-66967c7cb63b' => 'Doypack 210x285mm',
'75f4bd2a-51a8-0767-635e-66dde15af79e' => 'Pianka 200ml',
),
'ecmproducts_brand_dom' =>
array (
'6c5722f6-33b3-41c3-a878-e2f7628e8360' => 'None',
'3dc7c0bb-3d26-427c-9ff0-6319ead2e988' => 'Soyeco',
'33fb10ad-55f6-54ac-73e5-66bb6130d36f' => 'Soyeco amz',
'5820a5e7-8fd4-48bd-ab28-bfd60c321c15' => 'Frischer',
'2499563d-3671-c19a-c407-6628c97df75c' => 'Frischer amz',
'c0a6f467-9021-47cc-9b31-9398d9c2e898' => 'e5',
@@ -130,6 +138,17 @@ $customDoms = array (
'1ba0e21f-9a07-b93c-5e2f-65e8c7bb833d' => 'Purivita',
'5cc10610-e61e-846f-96a7-6613b79abce2' => 'Frischer Winner',
'8fb7cdf2-b9a9-ab07-d297-661670fb6120' => 'Aqualogis',
'd56c3876-c214-3829-f7b9-66618595d478' => 'Caffedelmondo',
'a7ca98eb-9a5d-660b-f483-666c350903c9' => 'Wilfa',
'2f641941-0ba1-b88b-2cb1-6684f93ef879' => 'Beko',
'89adb9a7-9d3e-1ec6-a4cf-668e2e46f158' => 'Aroca',
'26b07787-4207-7ab5-40fa-669527407b5a' => 'APM',
'47c4e190-198c-dcb6-612b-66978335a059' => 'Reus',
'a8a956e1-8288-2976-b71c-66bb3b8c3b8e' => 'Drekker',
'510f0cc2-1a76-3821-dbf2-66bb9e51bfc1' => 'NextProvider',
'd5f819ff-297b-c0d8-cfcd-66d0d0103806' => 'EcoExpert',
'4144e574-4870-fa26-25a0-66d85b094f7b' => 'Office Discount',
'e00b0e4a-ba66-796d-3bcb-66d89240c2cd' => 'Printus',
),
'ecmproducts_category_dom' =>
array (
@@ -258,7 +277,7 @@ $customDoms = array (
array (
'sales_order' => 'Zamówienie sprzedaży',
'gratis' => 'Próbki',
'b2c' => 'Stany magazynowe',
'b2c' => 'Produkcja na magazyn',
'b2b' => 'Import',
'interval_order' => 'Zamówienie okresowe',
),
@@ -270,14 +289,12 @@ $customDoms = array (
),
'ecmsales_status_dom' =>
array (
's10' => 'Zarejestrowany',
's10' => 'Planowany',
's20' => 'Oczekujący',
's30' => 'Zaakceptowany',
's40' => 'Niezaakceptowany',
's40' => 'Odrzucone',
's50' => 'Wysłany',
's60' => 'Wygrany',
's70' => 'Odrzucony',
's80' => 'Dokument Przewozowy',
's60' => 'Realizacja ze stanów magazynowych',
'93cc9f90-9a94-5502-50a9-66264b2fd03a' => 'Zrealizowany ',
),
);

View File

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

View File

@@ -1,4 +1,6 @@
<?php
/*
//crontab job - save currencies
set_time_limit(9999999999);
require_once("./../../config.php");
@@ -23,6 +25,7 @@ fclose($connect);
//download xml
$connect = fopen("http://www.nbp.pl/kursy/xml/".trim($xml_file).".xml", "r") or die("Błąd przy łączeniu");
echo "http://www.nbp.pl/kursy/xml/".trim($xml_file).".xml";
$download = fopen("./currencies.xml", "w") or die("Błąd przy łączeniu");
while (!feof ($connect)) {
$buffer = fgets($connect, 4096);//or die("Błąd przy odczyciee");
@@ -45,6 +48,7 @@ while ($r=mysql_fetch_array($result)) {
$doc = new DOMDocument();
$doc->load( 'currencies.xml' );
$tmp = $doc->getElementsByTagName("data_publikacji");
var_dump($tmp);
$cur_date = $tmp->item(0)->nodeValue;
$tmp = $doc->getElementsByTagName("numer_tabeli");
$table_name = $tmp->item(0)->nodeValue;
@@ -58,7 +62,7 @@ foreach ($poz as $p) {
$currencies[$kod]['kurs']=$kurs;
}
}
var_dump($currencies);
//var_dump($currencies);
//save values into db
foreach ($currencies as $key=>$value) {
mysql_query("INSERT INTO currency_nbp_archive VALUES ('".$cur_date."', '".$value['id']."', '".$key."', ".str_replace(",",".",$value['kurs']).",'".$table_name."')");
@@ -69,5 +73,4 @@ foreach ($currencies as $key=>$value) {
//delete xls
unlink("./currencies.xml");
?>
*/

View File

@@ -138,6 +138,29 @@ AND c.deleted='0' AND c.canceled='0';
}
$edit->ss->assign ( "INVOICES_INFO", substr($inv,0,-6) );
if ($focus->parent_id === '1b9643ca-5b1a-8f9b-b809-586b5619b068') {
require_once('REST/config.php');
$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?action=getStocks&key='.$restConfig['twinpolKey']);
$twinpolStocks = json_decode(curl_exec($curl));
$btn ='<input title="Utwórz PZ w Twinpol" class="button" onclick="if($(\'#div_pz\').css(\'display\') == \'none\'){$(\'#div_pz\').show(\'slow\'); } else { $(\'#div_pz\').hide(\'slow\'); }" type="button" name="create_pz" id="create_pz" value="Utwórz PZ w Twinpol">';
$btn .= '<div id="div_pz" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;">';
$btn .= 'Magazyn: <select name="pz_stock" id="pz_stock">';
foreach ($twinpolStocks as $s) {
$btn .= '<option value="'.$s->id.'">'.$s->name.'</option>';
}
$btn .= '</select><br /><br />';
$btn .= '<input name="pz_btn" id="pz_btn" title="Create" accessKey="" class="button" onclick="window.open(\'https://crm.twinpol.com/REST/index.php?action=createPzFromInvoice&stock_id=\'+$(\'#pz_stock\').val()+\'&record='.$_REQUEST['record'].'&key='.$restConfig['twinpolKey'].'\',\'blank\');" type="button" value="Utwórz"></div>';
$edit->ss->assign('CREATE_PZ', $btn);
}
$edit->bean = $focus;
$edit->tplFile = 'include/ECM/EcmViews/DetailView/Tabs/DetailView.tpl';

View File

@@ -91,7 +91,7 @@ $viewdefs ['EcmInvoiceOuts'] ['DetailView'] = array (
'customCode' => '<input name="edi" id="edi" class="button" onclick="window.open(\'index.php?module=EcmInvoiceOuts&record={$fields.id.value}&action=getEDI&to_pdf=1\');" type="button" value="EDI - wyślij fakturę">',
) ,
array (
'customCode' => '{if $CAN_CREATE_PZ == true} <input name="twinpolPZ" id="twinpolPZ" class="button" onclick="window.open(\'https://crm.twinpol.com/REST/index.php?key=d68dac4c-f784-4e1b-8267-9ffcfa0eda4c&action=createPzFromInvoice&record={$fields.id.value}\');" type="button" value="Utwórz PZ w Twinpol"> {/if}'
'customCode' => '{$CREATE_PZ}'
)
)
,

View File

@@ -44,7 +44,7 @@ $(document).ready(function () {
match: true
});
},
13: function ($cell, indx) {
12: function ($cell, indx) {
return $.tablesorter.filterFormatter.select2($cell, indx, {
match: true
});
@@ -52,7 +52,7 @@ $(document).ready(function () {
},
},
headers: {
17: { sorter: 'production_date' },
16: { sorter: 'production_date'},
},
});
$("#allTable").bind('filterEnd', function (event, config) {

View File

@@ -37,7 +37,7 @@ if (!isset($_GET['ajaxAction'])) {
ON si.ecmproduct_id = p.id
LEFT JOIN ecmstockstates AS ss
ON ss.product_id = si.ecmproduct_id AND ss.stock_id = 'c7afd71a-4c3a-bde4-138d-4acaee1644e4'
WHERE s.delivery_date > '$dateFrom' AND s.status IN ('s10', 's20', 's30')";
WHERE s.delivery_date > '$dateFrom'";
if (is_array($_GET['exclude']) && count($_GET['exclude']) > 0) {
foreach ($_GET['exclude'] as $name) {
if (strlen($name) > 0) {
@@ -88,6 +88,7 @@ if (!isset($_GET['ajaxAction'])) {
$row['orderNo'] = $r['document_no'];
$row['orderId'] = $r['id'];
$row['orderStatus'] = $app_list_strings['ecmsales_status_dom'][$r['status']];
$row['orderType'] = $app_list_strings['ecmsales_type_dom'][$r['type']];
$row['orderParent'] = $r['parent_name'];
$row['orderParentId'] = $r['parent_id'];
$row['orderRegisterDate'] = $r['register_date'];

View File

@@ -1,14 +1,14 @@
<script type="text/javascript" src="modules/EcmReports/javascript/jquery.js"></script>
<link rel="stylesheet" href="modules/EcmReports/BimIT-Reports/lib/tablesorter-2.31.3/dist/css/theme.blue.min.css">
<script type="text/javascript"
src="modules/EcmReports/BimIT-Reports/lib/tablesorter-2.31.3/dist/js/jquery.tablesorter.js"></script>
src="modules/EcmReports/BimIT-Reports/lib/tablesorter-2.31.3/dist/js/jquery.tablesorter.js"></script>
<script type="text/javascript"
src="modules/EcmReports/BimIT-Reports/lib/tablesorter-2.31.3/dist/js/jquery.tablesorter.widgets.js">
src="modules/EcmReports/BimIT-Reports/lib/tablesorter-2.31.3/dist/js/jquery.tablesorter.widgets.js">
</script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/3.4.6/select2.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/3.4.6/select2.min.js"></script>
<script type="text/javascript"
src="modules/EcmReports/BimIT-Reports/lib/tablesorter-2.31.3/dist/js/widgets/widget-filter-formatter-select2.min.js">
src="modules/EcmReports/BimIT-Reports/lib/tablesorter-2.31.3/dist/js/widgets/widget-filter-formatter-select2.min.js">
</script>
<script type="text/javascript" src="modules/EcmReports/javascript/jquery.blockUI.js"></script>
<script type="text/javascript" src="modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.js"></script>
@@ -16,58 +16,58 @@
<!-- HEADER -->
<table id="tableMenu" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<img src="themes/Sugar5/images/CaseReports.gif" style="margin-top: 3px; margin-right: 3px;" width="16"
height="16">
</td>
<td>
<h2>Produkcja</h2>
</td>
</tr>
<tr>
<td>
<img src="themes/Sugar5/images/CaseReports.gif" style="margin-top: 3px; margin-right: 3px;" width="16"
height="16">
</td>
<td>
<h2>Produkcja</h2>
</td>
</tr>
</table>
<!-- SEARCH -->
<form action="index.php" method="get" name="searchProductBySales">
<input type="hidden" name="module" value="EcmReports" />
<input type="hidden" name="action" value="index" />
<input type="hidden" name="reportName" value="productsBySales" />
<input type="hidden" name="hideReadyProducts" id="hideReadyProducts" value="{$hideReadyProducts}" />
<input type="hidden" name="module" value="EcmReports"/>
<input type="hidden" name="action" value="index"/>
<input type="hidden" name="reportName" value="productsBySales"/>
<input type="hidden" name="hideReadyProducts" id="hideReadyProducts" value="{$hideReadyProducts}"/>
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0"
cellspacing="0">
cellspacing="0">
<tr>
<td class="dataLabel" width="5%" nowrap="nowrap">
Data wysyłki: od
&nbsp;
<input id="date_from" name="date_from" type="text" maxlength="10" size="11" tabindex="" title=""
value="{$dateFrom}" autocomplete="off">
value="{$dateFrom}" autocomplete="off">
<img id="date_from_trigger" src="themes/default/images/jscalendar.gif">
<script language="JavaScript" type="text/javascript">
Calendar.setup ({ldelim}
inputField: "date_from",
Calendar.setup({ldelim}
inputField: "date_from",
daFormat: "%d.%m.%Y",
button: "date_from_trigger",
singleClick: true,
dateStr: "",
step: 1
{rdelim}
{rdelim}
);
</script>
&nbsp;
do
&nbsp;
<input autocomplete="off" name="date_to" id="date_to" value="{$dateTo}" title="" tabindex="" size="11"
maxlength="10" type="text">
maxlength="10" type="text">
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_to_trigger">
<script language="JavaScript" type="text/javascript">
Calendar.setup ({ldelim}
inputField: "date_to",
Calendar.setup({ldelim}
inputField: "date_to",
daFormat: "%d.%m.%Y",
button: "date_to_trigger",
singleClick: true,
dateStr: "",
step: 1
{rdelim}
{rdelim}
);
</script>
&nbsp;&nbsp;
@@ -75,7 +75,8 @@
<select name="exclude[]" size="3" style="width: 150px" multiple="true">
<option></option>
<option value="Media Markt" {if @in_array('Media Markt', $exclude)}selected="selected" {/if}>Media
Markt</option>
Markt
</option>
<option value="TwinPol" {if @in_array('TwinPol', $exclude)}selected="selected" {/if}>TwinPol
</option>
<option value="Euro-net" {if @in_array('Euro-net', $exclude)}selected="selected" {/if}>Euro-net
@@ -105,8 +106,10 @@
<li class="active" id="1_menu">
<script language="javascript">
{literal}
var set1 = function() { SetTab('1'); };
SelectedTab = '1';
var set1 = function () {
SetTab('1');
};
SelectedTab = '1';
{/literal}
</script>
<a class="current" href="javascript:set1();">Produkty</a>
@@ -114,7 +117,9 @@
<li class="" id="2_menu">
<script language="javascript">
{literal}
var set2 = function() { SetTab('2'); };
var set2 = function () {
SetTab('2');
};
{/literal}
</script>
<a class="" href="javascript:set2();">Komponenty</a>
@@ -122,7 +127,9 @@
<li class="" id="3_menu">
<script language="javascript">
{literal}
var set3 = function() { SetTab('3'); };
var set3 = function () {
SetTab('3');
};
{/literal}
</script>
<a class="" href="javascript:set3();">Surowce</a>
@@ -132,161 +139,158 @@
<!-- 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 zamówienie wewnętrzne" type="button" id="createInsideOrder"/>
<br>
<form action="index.php?module=EcmInsideOrders&action=EditView&fromProductsBySalesReport=true" method="post"
target="_blank" id="createInsideOrderForm">
<input id="insideOrderProducts" name="insideOrderProducts" type="hidden" value="" />
target="_blank" id="createInsideOrderForm">
<input id="insideOrderProducts" name="insideOrderProducts" type="hidden" value=""/>
</form>
<table id="allTable">
<thead>
<tr>
<th class="filter-false"><input type="checkbox" id="selectAll" /></th>
<th>Pozycja</th>
<th>Indeks</th>
<th>Nazwa</th>
<th>Ilość</th>
<th>Stan</th>
<th>ZS E5</th>
<th>Status</th>
<th>Zamawiający</th>
<th>Odbiorca</th>
<th>Rodzaj</th>
<th>Rozmiar</th>
<th>Forma</th>
<th>Marka</th>
<th>Data rejestracji</th>
<th>Data wysyłki</th>
<th>Data dostawy</th>
<th>Data produkcji</th>
<th>Uwagi</th>
</tr>
<tr>
<th class="filter-false"><input type="checkbox" id="selectAll"/></th>
<th>Pozycja</th>
<th>Indeks</th>
<th>Nazwa</th>
<th>Ilość</th>
<th>Stan</th>
<th>ZS E5</th>
<th>Typ</th>
<th>Status</th>
<th>Zamawiający</th>
<th>Odbiorca</th>
<th>Forma</th>
<th>Marka</th>
<th>Data rejestracji</th>
<th>Data wysyłki</th>
<th>Data dostawy</th>
<th>Data produkcji</th>
<th>Uwagi</th>
</tr>
</thead>
<tbody aria-live="polite" aria-relevant="all">
{foreach from=$allData item=ROW name=loop}
{foreach from=$allData item=ROW name=loop}
{if $smarty.foreach.loop.index % 2 == 1}
<tr>
{if $smarty.foreach.loop.index % 2 == 1}
<tr>
{else}
<tr style="background-color: #e6e6e6;" role="row">
{/if}
<td>
<input type="checkbox" value="{$ROW.orderItemId}" class="allCheck" />
<input type="hidden" id="productId-{$ROW.orderItemId}" value="{$ROW.productId}" />
</td>
<td>
{$ROW.position}
</td>
<td>
<a title="{$ROW.productFullCode}" target="_blank" href="index.php?module=EcmProducts&action=DetailView&record={$ROW.productId}">
{$ROW.productCode}
</a>
</td>
<td title="{$ROW.productFullName}">
{$ROW.productName}
</td>
<td id="productQty-{$ROW.orderItemId}">
{$ROW.productQty}
</td>
<td>
{$ROW.productStockState}
</td>
<td>
<a target="_blank" href="index.php?module=EcmSales&action=DetailView&record={$ROW.orderId}">
{$ROW.orderNo}
</a>
</td>
<td>
{$ROW.orderStatus}
</td>
<td>
<a target="_blank" href="index.php?module=Accounts&action=DetailView&record={$ROW.orderParentId}">
{$ROW.orderParent}
</a>
</td>
<td>
{$ROW.shippingTo}
</td>
<td>
{$ROW.productKind}
</td>
<td>
{$ROW.productSize}
</td>
<td>
{$ROW.productShape}
</td>
<td>
{$ROW.productBrand}
</td>
<td>
{$ROW.orderRegisterDate}
</td>
<td>
{$ROW.orderSendDate}
</td>
<td>
{$ROW.orderDeliveryDate}
</td>
<td>
<input id="production-date-{$ROW.orderItemId}" name="production-date-{$ROW.orderItemId}" type="text"
maxlength="10" size="11" tabindex="" title="" value="{$ROW.productionDate}" autocomplete="off"
id="production-date-{$ROW.orderItemId}" onchange="saveProductionDate('{$ROW.orderItemId}')">
<img id="production-date-trigger-{$ROW.orderItemId}" src="themes/default/images/jscalendar.gif"
style="width: 13px;">
<script language="JavaScript" type="text/javascript">
Calendar.setup ({ldelim}
inputField: "production-date-{$ROW.orderItemId}",
daFormat: "%Y-%m-%d",
button: "production-date-trigger-{$ROW.orderItemId}",
singleClick: true,
dateStr: "",
step: 1
{rdelim}
);
</script>
</td>
<td title="{$ROW.fullDescription}">
<div id="edit-{$ROW.orderItemId}" class="ui-icon ui-icon-pencil"
onclick="editComment('{$ROW.orderItemId}')" style="display: inline-block;"></div>
<div id="save-{$ROW.orderItemId}" class="ui-icon ui-icon-check"
onclick="saveComment('{$ROW.orderItemId}')" style="display: none;"></div>
<div id="description-{$ROW.orderItemId}" style="display: inline; width: 300px;">{$ROW.description}
</div>
<input id="descriptionInput-{$ROW.orderItemId}" type="text" value="{$ROW.fullDescription}"
style="width: 300px; display: none;" />
</td>
</tr>
{/foreach}
<tr style="background-color: #e6e6e6;" role="row">
{/if}
<td>
<input type="checkbox" value="{$ROW.orderItemId}" class="allCheck"/>
<input type="hidden" id="productId-{$ROW.orderItemId}" value="{$ROW.productId}"/>
</td>
<td>
{$ROW.position}
</td>
<td>
<a title="{$ROW.productFullCode}" target="_blank"
href="index.php?module=EcmProducts&action=DetailView&record={$ROW.productId}">
{$ROW.productCode}
</a>
</td>
<td title="{$ROW.productFullName}">
{$ROW.productName}
</td>
<td id="productQty-{$ROW.orderItemId}">
{$ROW.productQty}
</td>
<td>
{$ROW.productStockState}
</td>
<td>
<a target="_blank" href="index.php?module=EcmSales&action=DetailView&record={$ROW.orderId}">
{$ROW.orderNo}
</a>
</td>
<td>
{$ROW.orderType}
</td>
<td>
{$ROW.orderStatus}
</td>
<td>
<a target="_blank" href="index.php?module=Accounts&action=DetailView&record={$ROW.orderParentId}">
{$ROW.orderParent}
</a>
</td>
<td>
{$ROW.shippingTo}
</td>
<td>
{$ROW.productShape}
</td>
<td>
{$ROW.productBrand}
</td>
<td>
{$ROW.orderRegisterDate}
</td>
<td>
{$ROW.orderSendDate}
</td>
<td>
{$ROW.orderDeliveryDate}
</td>
<td>
<input id="production-date-{$ROW.orderItemId}" name="production-date-{$ROW.orderItemId}" type="text"
maxlength="10" size="11" tabindex="" title="" value="{$ROW.productionDate}" autocomplete="off"
id="production-date-{$ROW.orderItemId}" onchange="saveProductionDate('{$ROW.orderItemId}')">
<img id="production-date-trigger-{$ROW.orderItemId}" src="themes/default/images/jscalendar.gif"
style="width: 13px;">
<script language="JavaScript" type="text/javascript">
Calendar.setup({ldelim}
inputField: "production-date-{$ROW.orderItemId}",
daFormat: "%Y-%m-%d",
button: "production-date-trigger-{$ROW.orderItemId}",
singleClick: true,
dateStr: "",
step: 1
{rdelim}
);
</script>
</td>
<td title="{$ROW.fullDescription}">
<div id="edit-{$ROW.orderItemId}" class="ui-icon ui-icon-pencil"
onclick="editComment('{$ROW.orderItemId}')" style="display: inline-block;"></div>
<div id="save-{$ROW.orderItemId}" class="ui-icon ui-icon-check"
onclick="saveComment('{$ROW.orderItemId}')" style="display: none;"></div>
<div id="description-{$ROW.orderItemId}" style="display: inline; width: 300px;">{$ROW.description}
</div>
<input id="descriptionInput-{$ROW.orderItemId}" type="text" value="{$ROW.fullDescription}"
style="width: 300px; display: none;"/>
</td>
</tr>
{/foreach}
</tbody>
<tfoot>
<tr>
<td colspan=4></td>
<td id="allTableSum">0</td>
<td colspan="13"></td>
</tr>
<tr>
<td colspan=4></td>
<td id="allTableSum">0</td>
<td colspan="13"></td>
</tr>
</tfoot>
</table>
</div>
<div id="2" style="display: none">
<br>
<input class="button" name="submit" value="Zamówienie - komponenty" type="button" id="orderComponents" />
<input class="button" name="submit" value="Zamówienie - komponenty" type="button" id="orderComponents"/>
<br>
<form action="index.php?module=EcmPurchaseOrders&action=EditView&fromProductsBySalesReport=true" method="post"
target="_blank" id="orderComponentsForm">
<input id="componentsToOrder" name="componentsToOrder" type="hidden" value="" />
target="_blank" id="orderComponentsForm">
<input id="componentsToOrder" name="componentsToOrder" type="hidden" value=""/>
</form>
<div id="componentsTableContainer">
</div>
</div>
<div id="3" style="display: none">
<br>
<input class="button" name="submit" value="Zamówienie - surowce" type="button" id="orderRawMaterials" />
<input class="button" name="submit" value="Zamówienie - surowce" type="button" id="orderRawMaterials"/>
<br>
<form action="index.php?module=EcmPurchaseOrders&action=EditView&fromProductsBySalesReport=true" method="post"
target="_blank" id="orderRawMaterialsForm">
<input id="rawMaterialsToOrder" name="rawMaterialsToOrder" type="hidden" value="" />
target="_blank" id="orderRawMaterialsForm">
<input id="rawMaterialsToOrder" name="rawMaterialsToOrder" type="hidden" value=""/>
</form>
<div id="rawMaterialsTableContainer">
</div>

View File

@@ -438,8 +438,15 @@ class EcmSale extends SugarBean {
'ecmproductcategory_id' => $p ['category_id'],
'recipient_code' => $p ['recipient_code'],
'ean' => $p['product_ean'],
'brand_label' => $p['product_brand_label']
'brand_label' => $p['product_brand_label'],
'description' => $p['product_description'],
);
if (isset($p['product_production_date']) && strlen($p['product_production_date']) > 5) {
$arr['production_date'] = $p['product_production_date'];
}
// else {
// $arr['production_date'] = null;
//}
$this->db->query ( $this->constructInsertQuery ( $arr ) );
$this->db->query("INSERT INTO log VALUES ('".mysql_escape_string($this->constructInsertQuery ( $arr ))."')");
@@ -472,6 +479,8 @@ class EcmSale extends SugarBean {
$return_array ['product_supplier_code'] = $position ['recipient_code'];
$return_array ['product_ean'] = $position ['ean'];
$return_array ['product_brand_label'] = $position ['brand_label'];
$return_array ['product_description'] = $position ['description'];
$return_array ['product_production_date'] = $position ['production_date'];
$ecmStockOperations = new EcmStockOperation();
$return_array ['stock_state']=($ecmStockOperations->getRealStock($position ['ecmproduct_id']));

View File

@@ -114,7 +114,7 @@ function importSale($file)
$sale->assigned_user_id = $buyer['assigned_user_id'];
$sale->edi_file = $file;
$sale->type = 'sales_order';
$sale->status = 's30';
$sale->status = 's60';
$sale->ecmlanguage = 'pl_pl';
$sale->position_list = loadProducts($xml->{'Order-Lines'}->Line, $isCarrefour);

View File

@@ -18,8 +18,10 @@ columns[1] = {
};
columns[1]['content'][0] = {'name' : 'code', 'type': 'hidden', 'readonly' : true};
columns[1]['content'][1] = {'name' : 'id', 'type': 'hidden'};
columns[1]['content'][1] = {'name' : 'brand_label', 'type': 'hidden',};
columns[1]['content'][2] = {'name' : 'link', 'type': 'text', 'readonly' : true};
columns[1]['content'][2] = {'name' : 'brand_label', 'type': 'hidden',};
columns[1]['content'][3] = {'name' : 'link', 'type': 'text', 'readonly' : true};
columns[1]['content'][4] = {'name' : 'description', 'type': 'hidden',};
columns[1]['content'][5] = {'name' : 'production_date', 'type': 'hidden',};
//end: code
//begin: name
columns[2] = {

View File

@@ -29,6 +29,8 @@ if (isset($_GET['ids'])) {
order by date_entered");
}
brecho($codes);
//die();
while($r=$GLOBALS['db']->fetchByAssoc($w)){
if(!in_array($r['stock_id'],$sarr))$sarr[]=$r['stock_id'];

View File

@@ -59,491 +59,43 @@ if (! defined ( 'sugarEntry' ) || ! sugarEntry)
* dropdown menu.
*/
$job_strings = array (
0 => 'refreshJobs',
1 => 'pollMonitoredInboxes',
2 => 'runMassEmailCampaign',
5 => 'pollMonitoredInboxesForBouncedCampaignEmails',
3 => 'pruneDatabase',
4 => 'trimTracker',
6 => 'checkEDISales',
7 => 'mailingsE5'
)
;
0 => 'getNbpCurrencies',
);
/**
* Job 0 refreshes all job schedulers at midnight
* DEPRECATED
*/
function refreshJobs() {
return true;
}
function mailingsE5(){
require_once ('modules/Schedulers/MailingCron.php');
$mailingCron = new MailingCron ();
$mailingCron->getMalingToSend ();
return true;
}
/**
* Job 1
*/
function pollMonitoredInboxes() {
$GLOBALS ['log']->info ( '----->Scheduler fired job of type pollMonitoredInboxes()' );
global $dictionary;
global $app_strings;
require_once ('modules/Emails/EmailUI.php');
$ie = new InboundEmail ();
$emailUI = new EmailUI ();
$r = $ie->db->query ( 'SELECT id, name FROM inbound_email WHERE is_personal = 0 AND deleted=0 AND status=\'Active\' AND mailbox_type != \'bounce\'' );
$GLOBALS ['log']->debug ( 'Just got Result from get all Inbounds of Inbound Emails' );
while ( $a = $ie->db->fetchByAssoc ( $r ) ) {
$GLOBALS ['log']->debug ( 'In while loop of Inbound Emails' );
$ieX = new InboundEmail ();
$ieX->retrieve ( $a ['id'] );
$mailboxes = $ieX->mailboxarray;
foreach ( $mailboxes as $mbox ) {
$ieX->mailbox = $mbox;
$newMsgs = array ();
$msgNoToUIDL = array ();
$connectToMailServer = false;
if ($ieX->isPop3Protocol ()) {
$msgNoToUIDL = $ieX->getPop3NewMessagesToDownloadForCron ();
// get all the keys which are msgnos;
$newMsgs = array_keys ( $msgNoToUIDL );
}
if ($ieX->connectMailserver () == 'true') {
$connectToMailServer = true;
} // if
$GLOBALS ['log']->debug ( 'Trying to connect to mailserver for [ ' . $a ['name'] . ' ]' );
if ($connectToMailServer) {
$GLOBALS ['log']->debug ( 'Connected to mailserver' );
if (! $ieX->isPop3Protocol ()) {
$newMsgs = $ieX->getNewMessageIds ();
}
if (is_array ( $newMsgs )) {
$current = 1;
$total = count ( $newMsgs );
require_once ("include/SugarFolders/SugarFolders.php");
$sugarFolder = new SugarFolder ();
$groupFolderId = $ieX->groupfolder_id;
$isGroupFolderExists = false;
$users = array ();
if ($groupFolderId != null && $groupFolderId != "") {
$sugarFolder->retrieve ( $groupFolderId );
$isGroupFolderExists = true;
} // if
$messagesToDelete = array ();
if ($ieX->isMailBoxTypeCreateCase ()) {
$users [] = $sugarFolder->assign_to_id;
$distributionMethod = $ieX->get_stored_options ( "distrib_method", "" );
if ($distributionMethod != 'roundRobin') {
$counts = $emailUI->getAssignedEmailsCountForUsers ( $users );
} else {
$lastRobin = $emailUI->getLastRobin ( $ieX );
}
$GLOBALS ['log']->debug ( 'distribution method id [ ' . $distributionMethod . ' ]' );
}
foreach ( $newMsgs as $k => $msgNo ) {
$uid = $msgNo;
if ($ieX->isPop3Protocol ()) {
$uid = $msgNoToUIDL [$msgNo];
} else {
$uid = imap_uid ( $ieX->conn, $msgNo );
} // else
if ($isGroupFolderExists) {
if ($ieX->importOneEmail ( $msgNo, $uid )) {
// add to folder
$sugarFolder->addBean ( $ieX->email );
if ($ieX->isPop3Protocol ()) {
$messagesToDelete [] = $msgNo;
} else {
$messagesToDelete [] = $uid;
}
if ($ieX->isMailBoxTypeCreateCase ()) {
$userId = "";
if ($distributionMethod == 'roundRobin') {
if (sizeof ( $users ) == 1) {
$userId = $users [0];
$lastRobin = $users [0];
} else {
$userIdsKeys = array_flip ( $users ); // now keys are values
$thisRobinKey = $userIdsKeys [$lastRobin] + 1;
if (! empty ( $users [$thisRobinKey] )) {
$userId = $users [$thisRobinKey];
$lastRobin = $users [$thisRobinKey];
} else {
$userId = $users [0];
$lastRobin = $users [0];
}
} // else
} else {
if (sizeof ( $users ) == 1) {
foreach ( $users as $k => $value ) {
$userId = $value;
} // foreach
} else {
asort ( $counts ); // lowest to highest
$countsKeys = array_flip ( $counts ); // keys now the 'count of items'
$leastBusy = array_shift ( $countsKeys ); // user id of lowest item count
$userId = $leastBusy;
$counts [$leastBusy] = $counts [$leastBusy] + 1;
}
} // else
$GLOBALS ['log']->debug ( 'userId [ ' . $userId . ' ]' );
$ieX->handleCreateCase ( $ieX->email, $userId );
} // if
} // if
} else {
if ($ieX->isAutoImport ()) {
$ieX->importOneEmail ( $msgNo, $uid );
} else {
/*
* If the group folder doesn't exist then download only those messages
* which has caseid in message
*/
$ieX->getMessagesInEmailCache ( $msgNo, $uid );
$email = new Email ();
$header = imap_headerinfo ( $ieX->conn, $msgNo );
$email->name = $ieX->handleMimeHeaderDecode ( $header->subject );
$email->from_addr = $ieX->convertImapToSugarEmailAddress ( $header->from );
$email->reply_to_email = $ieX->convertImapToSugarEmailAddress ( $header->reply_to );
if (! empty ( $email->reply_to_email )) {
$contactAddr = $email->reply_to_email;
} else {
$contactAddr = $email->from_addr;
}
$mailBoxType = $ieX->mailbox_type;
$ieX->handleAutoresponse ( $email, $contactAddr );
} // else
} // else
$GLOBALS ['log']->debug ( '***** On message [ ' . $current . ' of ' . $total . ' ] *****' );
$current ++;
} // foreach
// update Inbound Account with last robin
if ($ieX->isMailBoxTypeCreateCase () && $distributionMethod == 'roundRobin') {
$emailUI->setLastRobin ( $ieX, $lastRobin );
} // if
} // if
if ($isGroupFolderExists) {
$leaveMessagesOnMailServer = $ieX->get_stored_options ( "leaveMessagesOnMailServer", 0 );
if (! $leaveMessagesOnMailServer) {
if ($ieX->isPop3Protocol ()) {
$ieX->deleteMessageOnMailServerForPop3 ( implode ( ",", $messagesToDelete ) );
} else {
$ieX->deleteMessageOnMailServer ( implode ( $app_strings ['LBL_EMAIL_DELIMITER'], $messagesToDelete ) );
}
}
}
function getNbpCurrencies() {
try {
$db = $GLOBALS['db'];
$currencies = $db->query("SELECT id, iso4217 FROM currencies WHERE deleted=0");
while ($c = $db->fetchByAssoc($currencies)) {
$nbpData = makeCUrlRequest("https://api.nbp.pl/api/exchangerates/rates/a/" . $c['iso4217'] . "?format=json");
if ($nbpData != null && is_array($nbpData->rates) && count($nbpData->rates) > 0) {
$db->query("UPDATE currencies SET conversion_rate=" . $nbpData->rates[0]->mid . ", date_modified = NOW() WHERE id = '" . $c['id'] . "'");
$db->query("INSERT INTO currency_nbp_archive VALUES('" . $nbpData->rates[0]->effectiveDate . "', '" . $c['id'] . "', '" . $c['iso4217'] . "', " . $nbpData->rates[0]->mid . ", '" . $nbpData->rates[0]->no . "')");
} else {
$GLOBALS ['log']->fatal ( "SCHEDULERS: could not get an IMAP connection resource for ID [ {$a['id']} ]. Skipping mailbox [ {$a['name']} ]." );
// cn: bug 9171 - continue while
} // else
} // foreach
imap_expunge ( $ieX->conn );
imap_close ( $ieX->conn, CL_EXPUNGE );
} // while
return true;
}
/**
* Job 2
*/
function runMassEmailCampaign() {
if (! class_exists ( 'LoggerManager' )) {
}
$GLOBALS ['log'] = LoggerManager::getLogger ( 'emailmandelivery' );
$GLOBALS ['log']->debug ( 'Called:runMassEmailCampaign' );
if (! class_exists ( 'DBManagerFactory' )) {
require ('include/database/DBManagerFactory.php');
}
global $beanList;
global $beanFiles;
require ("config.php");
require ('include/modules.php');
if (! class_exists ( 'AclController' )) {
require ('modules/ACL/ACLController.php');
}
require ('modules/EmailMan/EmailManDelivery.php');
return true;
}
/**
* Job 3
*/
function pruneDatabase() {
$GLOBALS ['log']->info ( '----->Scheduler fired job of type pruneDatabase()' );
$backupDir = $GLOBALS ['sugar_config'] ['cache_dir'] . 'backups';
$backupFile = 'backup-pruneDatabase-GMT0_' . gmdate ( 'Y_m_d-H_i_s', strtotime ( 'now' ) ) . '.php';
$db = DBManagerFactory::getInstance ();
$tables = $db->getTablesArray ();
// _ppd($tables);
if (! empty ( $tables )) {
foreach ( $tables as $kTable => $table ) {
// find tables with deleted=1
$qDel = 'SELECT * FROM ' . $table . ' WHERE deleted = 1';
$rDel = $db->query ( $qDel ); // OR continue; // continue if no 'deleted' column
// make a backup INSERT query if we are deleting.
while ( $aDel = $db->fetchByAssoc ( $rDel ) ) {
// build column names
$rCols = $db->query ( 'SHOW COLUMNS FROM ' . $table );
$colName = array ();
while ( $aCols = $db->fetchByAssoc ( $rCols ) ) {
$colName [] = $aCols ['Field'];
}
$query = 'INSERT INTO ' . $table . ' (';
$values = '';
foreach ( $colName as $kC => $column ) {
$query .= $column . ', ';
$values .= '"' . $aDel [$column] . '", ';
}
$query = substr ( $query, 0, (strlen ( $query ) - 2) );
$values = substr ( $values, 0, (strlen ( $values ) - 2) );
$query .= ') VALUES (' . str_replace ( "'", "&#039;", $values ) . ');';
$queryString [] = $query;
if (empty ( $colName )) {
$GLOBALS ['log']->fatal ( 'pruneDatabase() could not get the columns for table (' . $table . ')' );
}
} // end aDel while()
// now do the actual delete
$db->query ( 'DELETE FROM ' . $table . ' WHERE deleted = 1' );
} // foreach() tables
// now output file with SQL
if (! function_exists ( 'mkdir_recursive' )) {
return false;
}
}
if (! function_exists ( 'write_array_to_file' )) {
}
if (! file_exists ( $backupDir ) || ! file_exists ( $backupDir . '/' . $backupFile )) {
// create directory if not existent
mkdir_recursive ( $backupDir, false );
}
// write cache file
write_array_to_file ( 'pruneDatabase', $queryString, $backupDir . '/' . $backupFile );
$db->query("DELETE FROM currency_nbp_archive WHERE date < (NOW() - INTERVAL 100 DAY)");
return true;
} catch (Exception $e) {
return false;
}
return false;
}
// /**
// * Job 4
// */
// function securityAudit() {
// // do something
// return true;
// }
function trimTracker() {
global $sugar_config;
$GLOBALS ['log']->info ( '----->Scheduler fired job of type trimTracker()' );
$db = DBManagerFactory::getInstance ();
$admin = new Administration ();
$admin->retrieveSettings ( 'tracker' );
require ('modules/Trackers/config.php');
$trackerConfig = $tracker_config;
require_once ('include/utils/db_utils.php');
$prune_interval = ! empty ( $admin->settings ['tracker_prune_interval'] ) ? $admin->settings ['tracker_prune_interval'] : 30;
foreach ( $trackerConfig as $tableName => $tableConfig ) {
// Skip if table does not exist
if (! $db->tableExists ( $tableName )) {
continue;
}
$timeStamp = db_convert ( "'" . gmdate ( $GLOBALS ['timedate']->get_db_date_time_format (), time () + (86400 * - $prune_interval) ) . "'", "datetime" );
if ($tableName == 'tracker_sessions') {
$query = "DELETE FROM $tableName WHERE date_end < $timeStamp";
} else {
$query = "DELETE FROM $tableName WHERE date_modified < $timeStamp";
}
$GLOBALS ['log']->info ( "----->Scheduler is about to trim the $tableName table by running the query $query" );
$db->query ( $query );
} // foreach
return true;
// helpers
function brecho($msg) {
echo PHP_EOL;
var_dump($msg);
echo PHP_EOL.PHP_EOL;
}
/*
* Job 5
*
*/
function pollMonitoredInboxesForBouncedCampaignEmails() {
$GLOBALS ['log']->info ( '----->Scheduler job of type pollMonitoredInboxesForBouncedCampaignEmails()' );
global $dictionary;
$ie = new InboundEmail ();
$r = $ie->db->query ( 'SELECT id FROM inbound_email WHERE deleted=0 AND status=\'Active\' AND mailbox_type=\'bounce\'' );
while ( $a = $ie->db->fetchByAssoc ( $r ) ) {
$ieX = new InboundEmail ();
$ieX->retrieve ( $a ['id'] );
$ieX->connectMailserver ();
$newMsgs = array ();
if ($ieX->isPop3Protocol ()) {
$newMsgs = $ieX->getPop3NewMessagesToDownload ();
} else {
$newMsgs = $ieX->getNewMessageIds ();
}
// $newMsgs = $ieX->getNewMessageIds();
if (is_array ( $newMsgs )) {
foreach ( $newMsgs as $k => $msgNo ) {
$uid = $msgNo;
if ($ieX->isPop3Protocol ()) {
$uid = $ieX->getUIDLForMessage ( $msgNo );
} else {
$uid = imap_uid ( $ieX->conn, $msgNo );
} // else
$ieX->importOneEmail ( $msgNo, $uid, false, false );
}
}
imap_expunge ( $ieX->conn );
imap_close ( $ieX->conn );
}
return true;
function makeCUrlRequest($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET' );
curl_setopt($curl, CURLOPT_VERBOSE, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_URL, $url);
return json_decode(curl_exec($curl));
}
function checkEDISales() {
require_once ('modules/EcmSales/EcmSale.php');
require_once ('modules/EcmSales/readXML.php');
require_once 'include/phpMailer2/class.phpmailer.php';
require_once 'include/phpMailer2/class.smtp.php';
$path = '/var/edi/e5/orders';
$folders = array (
'archive',
'temp',
'confirm'
); // do not read this folders
$orders = array ();
if (is_dir ( $path )) {
if ($dh = opendir ( $path )) {
while ( ($file = readdir ( $dh )) !== false ) {
if (! is_dir ( $file ) && ! in_array ( $file, $folders )) {
$orders [] = $file;
}
}
}
}
// add orders
$mail_msg = array ();
foreach ( $orders as $order ) {
$s = new EcmSale ();
$reader = new readXML ();
$reader->loadXMLFile ( $order );
$reader->loader ( $s );
$s->position_list = $reader->getPositionList ( true );
$missedProducts = $reader->checkProducts($s->position_list);
$number = $s->generateNumber ();
$s->number = $number;
$s->document_no = $s->formatNumber ( $number );
$s->edi_file = $order;
$s->type = 'sales_order';
$s->status = 's30';
$s->ecmlanguage = 'pl_pl';
$a = new Account ();
$a->retrieve ( $s->parent_id );
$s->assigned_user_id = $a->assigned_user_id;
$s->assigned_user_name = $a->assigned_user_name;
// calculate totals
$sum_netto = 0;
$sum_brutto = 0;
foreach ( $s->position_list as $p ) {
$sum_netto += $p ['total_netto'];
$sum_brutto += $p ['total_brutto'];
}
$s->total_netto = $sum_netto;
if($s->parent_id==134 || $s->parent_id=='134'){
$s->shop_number = null;
}
$s->total_brutto = $sum_brutto;
$s->save ();
$s->sendSoap($s->id);
if (!is_array($mail_msg [$a->assigned_user_id]))
$mail_msg [$a->assigned_user_id] = array ();
if (!$s->parent_name || $s->parent_name=="")
$s->parent_name = 'Błąd! Brak kontrahenta!';
$msg =
'<b>Plik: '.$order.'</b><br>'.$s->document_no.', '.$s->parent_document_no.', '. $s->parent_name.'<br>';
if (count($missedProducts) == 0) {
$msg.='Status produktów: <b>OK</b>';
} else {
$msg.='<b>Zamówienie niekompletne: '.implode(', ', $missedProducts);
}
$msg.='<br><br><br>';
$mail_msg [$a->assigned_user_id][] = $msg;
unset($a);
// move files
rename ( $path . '/' . $order, $path . '/archive/' . $order );
}
//send messages
// require_once 'modules/Schedulers/phpMailer.php';
foreach ( $mail_msg as $user=>$msg ) {
$u = new User();
$u->retrieve($user);
$message = $date = date('Y-m-d H:i:s').' dodano zamówienie(a):<br>';
foreach ($msg as $m) {
$message .= $m.'<br>';
}
$mail = new PHPMailer2 ();
$mail->isSMTP();
$mail->setFrom('system@e5.pl', 'Usługa importu EDI');
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'system@e5.pl';
$mail->Password = 'eT4U>hyJe';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->CharSet = 'UTF-8';
$mail->addAddress('mz@bim-it.pl', 'Michał Zieliński');
$mail->addAddress('rl@e5.pl', 'Ryszard Lisiecki');
$mail->addAddress('mf@e5.pl', 'Małgorzata Franiewska');
$mail->isHTML(true);
$mail->Subject = "Import zamówienia EDI - E5" ;
$mail->Body = $message;
$mail->send();
unset ( $mS ); // cleaning
}
return true;
}
if (file_exists ( 'custom/modules/Schedulers/_AddJobsHere.php' )) {
require ('custom/modules/Schedulers/_AddJobsHere.php');
}
?>

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');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
@@ -36,61 +36,55 @@ if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description: TODO: To be written.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
********************************************************************************/
require_once('include/entryPoint.php');
require_once('include/entryPoint.php');
require_once('modules/Users/language/en_us.lang.php');
global $app_strings;
global $new_pwd;
require_once('modules/Users/language/en_us.lang.php');
global $app_strings;
global $new_pwd;
$mod_strings=return_module_language('','Users');
$res=$GLOBALS['sugar_config']['passwordsetting'];
$regexmail = "/^\w+(['\.\-\+]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+\$/";
$mod_strings = return_module_language('', 'Users');
$res = $GLOBALS['sugar_config']['passwordsetting'];
$regexmail = "/^\w+(['\.\-\+]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+\$/";
///////////////////////////////////////////////////
/////// Retrieve user
$usr= new user();
if(isset( $_POST['username']) && isset($_POST['user_email'] )){
if ($_POST['username'] != '' && $_POST['user_email'] != ''){
$usr_id=$usr->retrieve_user_id($_POST['username']);
$usr->retrieve($usr_id);
if ($usr->email1 != $_POST['user_email']){
echo $mod_strings['ERR_PASSWORD_USERNAME_MISSMATCH'];
return;
}
if ($usr->portal_only || $usr->is_group){
echo $mod_strings['LBL_PROVIDE_USERNAME_AND_EMAIL'];
return;
}
}
else
{
echo $mod_strings['LBL_PROVIDE_USERNAME_AND_EMAIL'];
return;
}
}
else{
if (isset($_POST['userId']) && $_POST['userId'] != ''){
$usr->retrieve($_POST['userId']);
$usr = new user();
if (isset($_POST['username']) && isset($_POST['user_email'])) {
if ($_POST['username'] != '' && $_POST['user_email'] != '') {
$usr_id = $usr->retrieve_user_id($_POST['username']);
$usr->retrieve($usr_id);
if ($usr->email1 != $_POST['user_email']) {
echo $mod_strings['ERR_PASSWORD_USERNAME_MISSMATCH'];
return;
}
else{
if(isset( $_POST['sugar_user_name']) && isset($_POST['sugar_user_name'] )){
$usr_id=$usr->retrieve_user_id($_POST['sugar_user_name']);
$usr->retrieve($usr_id);
}
else{
echo $mod_strings['ERR_USER_INFO_NOT_FOUND'];
return;
}
}
if ($usr->portal_only || $usr->is_group) {
echo $mod_strings['LBL_PROVIDE_USERNAME_AND_EMAIL'];
return;
}
} else {
echo $mod_strings['LBL_PROVIDE_USERNAME_AND_EMAIL'];
return;
}
} else {
if (isset($_POST['userId']) && $_POST['userId'] != '') {
$usr->retrieve($_POST['userId']);
} else {
if (isset($_POST['sugar_user_name']) && isset($_POST['sugar_user_name'])) {
$usr_id = $usr->retrieve_user_id($_POST['sugar_user_name']);
$usr->retrieve($usr_id);
} else {
echo $mod_strings['ERR_USER_INFO_NOT_FOUND'];
return;
}
}
}
///////
///////////////////////////////////////////////////
@@ -98,191 +92,192 @@ if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
///////////////////////////////////////////////////
/////// Check email address
if (!preg_match($regexmail, $usr->emailAddress->getPrimaryAddress($usr))){
echo 'Błąd poczty';
return;
}
if (!preg_match($regexmail, $usr->emailAddress->getPrimaryAddress($usr))) {
echo 'Błąd poczty';
return;
}
///////
///////////////////////////////////////////////////
// if i need to generate a password (not a link)
if (!isset($_POST['link'])){
$charBKT='';
//chars to select from
$LOWERCASE = "abcdefghijklmnpqrstuvwxyz";
$NUMBER = "0123456789";
$UPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$SPECIAL = '~!@#$%^&*()_+=-{}|';
$condition = 0;
$charBKT.=$UPPERCASE.$LOWERCASE.$NUMBER;
$password="";
// if i need to generate a password (not a link)
if (!isset($_POST['link'])) {
$charBKT = '';
//chars to select from
$LOWERCASE = "abcdefghijklmnpqrstuvwxyz";
$NUMBER = "0123456789";
$UPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$SPECIAL = '~!@#$%^&*()_+=-{}|';
$condition = 0;
$charBKT .= $UPPERCASE . $LOWERCASE . $NUMBER;
$password = "";
$lenght='6';
// Create random characters for the ones that doesnt have requirements
for ($i=0;$i<$lenght-$condition;$i++) // loop and create password
$password = $password . substr ($charBKT, rand() % strlen($charBKT), 1);
$lenght = '6';
// Create random characters for the ones that doesnt have requirements
for ($i = 0; $i < $lenght - $condition; $i++) // loop and create password
$password = $password . substr($charBKT, rand() % strlen($charBKT), 1);
}
}
///////////////////////////////////////////////////
/////// Create URL
// if i need to generate a link
if (isset($_POST['link']) && $_POST['link'] == '1'){
global $timedate;
$guid=create_guid();
$url=$GLOBALS['sugar_config']['site_url']."/index.php?entryPoint=Changenewpassword&guid=$guid";
$time_now=gmdate($GLOBALS['timedate']->get_db_date_time_format());
//$q2="UPDATE `users_password_link` SET `deleted` = '1' WHERE `username` = '".$_POST['username']."'";
//$usr->db->query($q2);
$q = "INSERT INTO users_password_link (id, username, date_generated) VALUES('".$guid."','".$_POST['username']."',' ".$time_now."' ) ";
$usr->db->query($q);
if (isset($_POST['link']) && $_POST['link'] == '1') {
global $timedate;
$guid = create_guid();
$url = $GLOBALS['sugar_config']['site_url'] . "/index.php?entryPoint=Changenewpassword&guid=$guid";
$time_now = gmdate($GLOBALS['timedate']->get_db_date_time_format());
//$q2="UPDATE `users_password_link` SET `deleted` = '1' WHERE `username` = '".$_POST['username']."'";
//$usr->db->query($q2);
$q = "INSERT INTO users_password_link (id, username, date_generated) VALUES('" . $guid . "','" . $_POST['username'] . "',' " . $time_now . "' ) ";
$usr->db->query($q);
}
///////
///////////////////////////////////////////////////
/////// Email creation
global $sugar_config, $current_user;
if (isset($_POST['link']) && $_POST['link'] == '1')
$emailTemp_id = $res['lostpasswordtmpl'];
else
$emailTemp_id = $res['generatepasswordtmpl'];
global $sugar_config, $current_user;
if (isset($_POST['link']) && $_POST['link'] == '1')
$emailTemp_id = $res['lostpasswordtmpl'];
else
$emailTemp_id = $res['generatepasswordtmpl'];
$emailTemp = new EmailTemplate();
$emailTemp->disable_row_level_security = true;
if ($emailTemp->retrieve($emailTemp_id) == ''){
echo $mod_strings['LBL_EMAIL_TEMPLATE_MISSING'];
$new_pwd='4';
return;}
//replace instance variables in email templates
$htmlBody = $emailTemp->body_html;
$body = $emailTemp->body;
if (isset($_POST['link']) && $_POST['link'] == '1'){
$htmlBody = str_replace('$contact_user_link_guid', $url, $htmlBody);
$body = str_replace('$contact_user_link_guid', $url, $body);
}
else{
$htmlBody = str_replace('$contact_user_user_hash', $password, $htmlBody);
$body = str_replace('$contact_user_user_hash', $password, $body);
}
$htmlBody = str_replace('$contact_user_user_name', $usr->user_name, $htmlBody);
$htmlBody = str_replace('$contact_user_pwd_last_changed', gmdate($GLOBALS['timedate']->get_db_date_time_format()), $htmlBody);
$body = str_replace('$contact_user_user_name', $usr->user_name, $body);
$body = str_replace('$contact_user_pwd_last_changed', gmdate($GLOBALS['timedate']->get_db_date_time_format()), $body);
$emailTemp->body_html = $htmlBody;
$emailTemp->body = $body;
require_once('include/SugarPHPMailer.php');
$itemail=$usr->emailAddress->getPrimaryAddress($usr);
//retrieve IT Admin Email
//_ppd( $emailTemp->body_html);
//retrieve email defaults
$emailObj = new Email();
$defaults = $emailObj->getSystemDefaultEmail();
require_once 'include/phpMailer2/class.phpmailer.php';
require_once 'include/phpMailer2/class.smtp.php';
$mail = new PHPMailer2 ();
//$mail->IsHTML(true);
$mail->From = $defaults['email'];
$mail->FromName = $defaults['name'];
$mail->isSMTP (); // Set mailer to use SMTP
$mail->Host = 'poczta.saas-systems.pl'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'biuro@saas-systems.pl'; // SMTP username
$mail->Password = '3g431r31!'; // SMTP password
$mail->CharSet = 'UTF-8';
$mail ->charSet = "UTF-8";
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;
$mail->Subject=from_html($emailTemp->subject);
if($emailTemp->text_only != 1){
$mail->IsHTML(true);
$mail->Body=from_html($emailTemp->body_html);
$mail->AltBody=from_html($emailTemp->body);
}
else {
$mail->Body_html=from_html($emailTemp->body_html);
$mail->Body=from_html($emailTemp->body);
}
if($mail->Body == '' && $current_user->is_admin){
echo $app_strings['LBL_EMAIL_TEMPLATE_EDIT_PLAIN_TEXT'];
$new_pwd='4';
return;}
if($mail->Mailer == 'smtp' && $mail->Host ==''&& $current_user->is_admin){
echo $mod_strings['ERR_SERVER_SMTP_EMPTY'];
$new_pwd='4';
return;}
// $mail->prepForOutbound();
$hasRecipients = false;
if (!empty($itemail)){
if($hasRecipients){
$mail->AddBCC($itemail);
}else{
$mail->AddAddress($itemail);
}
$hasRecipients = true;
}
$success = false;
if($hasRecipients){
$success = @$mail->Send();
}
$now=gmdate("Y-m-d H:i:s");
$user_hash = strtolower(md5($password));
//now create email
if($success){
$emailObj->team_id = 1;
$emailObj->to_addrs= '';
$emailObj->type= 'archived';
$emailObj->deleted = '0';
$emailObj->name = $mail->Subject ;
$emailObj->description = $mail->Body;
$emailObj->description_html =null;
$emailObj->from_addr = $mail->From;
$emailObj->parent_type = 'User';
$emailObj->date_sent =gmdate($GLOBALS['timedate']->get_db_date_time_format());
$emailObj->modified_user_id = '1';
$emailObj->created_by = '1';
$emailObj->status='sent';
$retId = $emailObj->save();
echo '1';
if (!isset($_POST['link'])){
$user_hash = strtolower(md5($password));
$usr->setPreference('loginexpiration','0');
$usr->setPreference('lockout','');
$usr->setPreference('loginfailed','0');
$usr->savePreferencesToDB();
//set new password
$now=gmdate("Y-m-d H:i:s");
$query = "UPDATE $usr->table_name SET user_hash='$user_hash', system_generated_password='1', pwd_last_changed='$now' where id='$usr->id'";
$usr->db->query($query, true, "Error setting new password for $usr->user_name: ");
//echo $password;
}
}else{
$new_pwd='4';
if ($current_user->is_admin){
$email_errors=$mod_strings['ERR_EMAIL_NOT_SENT_ADMIN'];
if ($mail->Mailer == 'smtp')
$email_errors.="\n-".$mod_strings['ERR_SMTP_URL_SMTP_PORT'];
if ($mail->SMTPAuth)
$email_errors.="\n-".$mod_strings['ERR_SMTP_USERNAME_SMTP_PASSWORD'];
$email_errors.="\n-".$mod_strings['ERR_RECIPIENT_EMAIL'];
$email_errors.="\n-".$mod_strings['ERR_SERVER_STATUS'];
echo $email_errors;
}
else
echo $mod_strings['LBL_EMAIL_NOT_SENT'];
}
$emailTemp = new EmailTemplate();
$emailTemp->disable_row_level_security = true;
if ($emailTemp->retrieve($emailTemp_id) == '') {
echo $mod_strings['LBL_EMAIL_TEMPLATE_MISSING'];
$new_pwd = '4';
return;
}
//replace instance variables in email templates
$htmlBody = $emailTemp->body_html;
$body = $emailTemp->body;
if (isset($_POST['link']) && $_POST['link'] == '1') {
$htmlBody = str_replace('$contact_user_link_guid', $url, $htmlBody);
$body = str_replace('$contact_user_link_guid', $url, $body);
} else {
$htmlBody = str_replace('$contact_user_user_hash', $password, $htmlBody);
$body = str_replace('$contact_user_user_hash', $password, $body);
}
$htmlBody = str_replace('$contact_user_user_name', $usr->user_name, $htmlBody);
$htmlBody = str_replace('$contact_user_pwd_last_changed', gmdate($GLOBALS['timedate']->get_db_date_time_format()), $htmlBody);
$body = str_replace('$contact_user_user_name', $usr->user_name, $body);
$body = str_replace('$contact_user_pwd_last_changed', gmdate($GLOBALS['timedate']->get_db_date_time_format()), $body);
$emailTemp->body_html = $htmlBody;
$emailTemp->body = $body;
require_once('include/SugarPHPMailer.php');
$itemail = $usr->emailAddress->getPrimaryAddress($usr);
//retrieve IT Admin Email
//_ppd( $emailTemp->body_html);
//retrieve email defaults
$emailObj = new Email();
$defaults = $emailObj->getSystemDefaultEmail();
require_once 'include/phpMailer2/class.phpmailer.php';
require_once 'include/phpMailer2/class.smtp.php';
$mail = new PHPMailer2 ();
//$mail->IsHTML(true);
$mail->From = $defaults['email'];
$mail->FromName = $defaults['name'];
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'system@e5.pl';
$mail->Password = 'wqiz ekxn lysj zheu';
$mail->CharSet = 'UTF-8';
$mail->charSet = "UTF-8";
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;
$mail->Subject = from_html($emailTemp->subject);
if ($emailTemp->text_only != 1) {
$mail->IsHTML(true);
$mail->Body = from_html($emailTemp->body_html);
$mail->AltBody = from_html($emailTemp->body);
} else {
$mail->Body_html = from_html($emailTemp->body_html);
$mail->Body = from_html($emailTemp->body);
}
if ($mail->Body == '' && $current_user->is_admin) {
echo $app_strings['LBL_EMAIL_TEMPLATE_EDIT_PLAIN_TEXT'];
$new_pwd = '4';
return;
}
if ($mail->Mailer == 'smtp' && $mail->Host == '' && $current_user->is_admin) {
echo $mod_strings['ERR_SERVER_SMTP_EMPTY'];
$new_pwd = '4';
return;
}
// $mail->prepForOutbound();
$hasRecipients = false;
if (!empty($itemail)) {
if ($hasRecipients) {
$mail->AddBCC($itemail);
} else {
$mail->AddAddress($itemail);
}
$hasRecipients = true;
}
$success = false;
if ($hasRecipients) {
$success = @$mail->Send();
}
$now = gmdate("Y-m-d H:i:s");
$user_hash = strtolower(md5($password));
//now create email
if ($success) {
$emailObj->team_id = 1;
$emailObj->to_addrs = '';
$emailObj->type = 'archived';
$emailObj->deleted = '0';
$emailObj->name = $mail->Subject;
$emailObj->description = $mail->Body;
$emailObj->description_html = null;
$emailObj->from_addr = $mail->From;
$emailObj->parent_type = 'User';
$emailObj->date_sent = gmdate($GLOBALS['timedate']->get_db_date_time_format());
$emailObj->modified_user_id = '1';
$emailObj->created_by = '1';
$emailObj->status = 'sent';
$retId = $emailObj->save();
echo '1';
if (!isset($_POST['link'])) {
$user_hash = strtolower(md5($password));
$usr->setPreference('loginexpiration', '0');
$usr->setPreference('lockout', '');
$usr->setPreference('loginfailed', '0');
$usr->savePreferencesToDB();
//set new password
$now = gmdate("Y-m-d H:i:s");
$query = "UPDATE $usr->table_name SET user_hash='$user_hash', system_generated_password='1', pwd_last_changed='$now' where id='$usr->id'";
$usr->db->query($query, true, "Error setting new password for $usr->user_name: ");
//echo $password;
}
} else {
$new_pwd = '4';
if ($current_user->is_admin) {
$email_errors = $mod_strings['ERR_EMAIL_NOT_SENT_ADMIN'];
if ($mail->Mailer == 'smtp')
$email_errors .= "\n-" . $mod_strings['ERR_SMTP_URL_SMTP_PORT'];
if ($mail->SMTPAuth)
$email_errors .= "\n-" . $mod_strings['ERR_SMTP_USERNAME_SMTP_PASSWORD'];
$email_errors .= "\n-" . $mod_strings['ERR_RECIPIENT_EMAIL'];
$email_errors .= "\n-" . $mod_strings['ERR_SERVER_STATUS'];
echo $email_errors;
} else
echo $mod_strings['LBL_EMAIL_NOT_SENT'];
}
return;
?>