176 lines
7.9 KiB
PHP
Executable File
176 lines
7.9 KiB
PHP
Executable File
<?php
|
|
|
|
if (!defined('sugarEntry') || !sugarEntry)
|
|
die ('NotAValidEntryPoint');
|
|
|
|
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings, $current_user, $app_list_strings;
|
|
require_once('modules/EcmStockDocIns/EcmStockDocIn.php');
|
|
require_once('include/time.php');
|
|
|
|
$db = $GLOBALS['db'];
|
|
|
|
//add jquery
|
|
echo '<link rel="stylesheet" type="text/css" href="modules/EcmSales/css/autocomplete.css"/>';
|
|
|
|
echo '<script type="text/javascript" src="modules/EcmStockDocIns/javascript/searchcolumndefs.js"></script>';
|
|
echo '<script type="text/javascript" src="include/ECM/SearchProductTable.js"></script>';
|
|
echo '<script type="text/javascript" src="include/ECM/tablenavigator.js"></script>';
|
|
// $cq=$current_user->getPreference('confirm_quotes');
|
|
|
|
$new_number = false;
|
|
$duplicate = false;
|
|
$focus = new EcmStockDocIn();
|
|
|
|
if (isset ($_REQUEST ['record'])) {
|
|
$focus->retrieve($_REQUEST ['record']);
|
|
|
|
if ($focus->status == 'accepted') {
|
|
unset($focus);
|
|
die('Dokument zaakceptowany brak możliwości edycji');
|
|
}
|
|
//$focus->position_list = str_replace('"','\"',$focus->getPositionList());
|
|
if (isset ($focus->id) && $focus->id != '') {
|
|
$focus->format_all_fields();
|
|
}
|
|
} else if ($_REQUEST['isDuplicate'] == "true") {
|
|
$new_number = true;
|
|
$duplicate = true;
|
|
//get data
|
|
$focus->retrieve($_REQUEST['return_id']);
|
|
} else {
|
|
$new_number = true;
|
|
$focus->stock_id = $current_user->stock_id;
|
|
//dates
|
|
$focus->register_date = date("d.m.Y");
|
|
$focus->date_fk = date("d.m.Y");
|
|
$OPT ['check_parent_id'] = false;
|
|
}
|
|
if (isset($_REQUEST['out_module']) && $_REQUEST['out_module'] != '' && isset($_REQUEST['out_id']) && $_REQUEST['out_id'] != '') {
|
|
|
|
$outModule = $_REQUEST['out_module'];
|
|
$outId = $_REQUEST['out_id'];
|
|
$OPT['fromOutside'] = true;
|
|
$path = 'modules/' . $outModule . '/LoadEcmStockDocIns.php';
|
|
|
|
if (file_exists($path)) {
|
|
$out = '<input type="hidden" id="out_id" name="out_id" value="' . $outId . '"><input type="hidden" id="out_module" name="out_module" value="' . $outModule . '">';
|
|
|
|
require_once($path);
|
|
|
|
$_REQUEST['record'] = '';
|
|
$outside_create = true;
|
|
}
|
|
// $focus->setEcmPurchaseOrderStatus($outId);
|
|
}
|
|
//get stocks
|
|
$res = $db->query("SELECT id, name FROM ecmstocks WHERE deleted = '0' ORDER BY name");
|
|
$stock = '<select id="stock" name="stock"><option value=""></option>';
|
|
$stock_body = '';
|
|
while ($row = $db->fetchByAssoc($res)) {
|
|
if ($row['id'] == $focus->stock_id) {
|
|
$selected = 'selected';
|
|
} else {
|
|
$selected = '';
|
|
}
|
|
$stock_body .= '<option value="' . $row['id'] . '" ' . $selected . '>' . $row['name'] . '</option>';
|
|
}
|
|
$stock .= $stock_body . '</select><input id="stock_id" name="stock_id" type="hidden" value="' . $focus->stock_id . '"/>';
|
|
|
|
require_once('include/MVC/View/SugarView.php');
|
|
require_once('modules/EcmStockDocIns/views/EditView/view.edit.ecmstockdocins.php');
|
|
$edit = new ViewEditEcmStockDocIns ();
|
|
$edit->ss = new Sugar_Smarty ();
|
|
$edit->module = 'EcmStockDocIns';
|
|
$edit->bean = $focus;
|
|
$edit->tplFile = 'include/ECM/EcmViews/EditView/Tabs/EditView.tpl';
|
|
$edit->preDisplay();
|
|
$edit->ss->assign("NEW_NUMBER", $new_number);
|
|
$edit->ss->assign("DUPLICATE", $duplicate);
|
|
$edit->ss->assign("STOCK", $stock);
|
|
// import table
|
|
if ($focus->kind == 'other') {
|
|
$edit->ss->assign("IMPORT", "display:none;");
|
|
}
|
|
if ($focus->kind == 'import') {
|
|
$edit->ss->assign("IMPORT", "display:block;");
|
|
}
|
|
|
|
//import table
|
|
$import_table = '<table>
|
|
<tr>
|
|
<td class="dataLabel">' . $mod_strings['LBL_FOREIGN_TRANSPORT_VAL'] . '</td>
|
|
<td><input type="text" id="foreign_transport_val" name="foreign_transport_val"
|
|
onchange="$(this).val(FormatNumber($(this).val(),2));" onclick="$(this).select();" value="' . format_number($focus->foreign_transport_val) . '"/ ></td>
|
|
<td class="dataLabel">' . $mod_strings['LBL_FOREIGN_TRANSPORT_CUR_ID'] . '</td>
|
|
<td><select name="foreign_transport_cur_id" id="foreign_transport_cur_id"/>';
|
|
foreach ($app_list_strings['currency_dom'] as $k => $v) {
|
|
$import_table .= '<option value="' . $k . '"';
|
|
if ($k == $focus->foreign_transport_cur_id) $import_table .= ' selected';
|
|
$import_table .= '>' . $v . '</option>';
|
|
}
|
|
$import_table .= '</select></td>
|
|
<td><input type="text" id="foreign_transport_cur_val" onchange="$(this).val(FormatNumber($(this).val(),4));" onclick="$(this).select();" name="foreign_transport_cur_val" value="' . $focus->foreign_transport_cur_val . '"/></td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="dataLabel">' . $mod_strings['LBL_COUNTRY_TRANSPORT_VAL'] . '</td>
|
|
<td><input onchange="$(this).val(FormatNumber($(this).val(),2));" onclick="$(this).select();" type="text" id="country_transport_val" name="country_transport_val" value="' . format_number($focus->country_transport_val) . '"/></td>
|
|
<td class="dataLabel">' . $mod_strings['LBL_COUNTRY_TRANSPORT_CUR_ID'] . '</td>
|
|
<td><select name="country_transport_cur_id" id="country_transport_cur_id"/>';
|
|
foreach ($app_list_strings['currency_dom'] as $k => $v) {
|
|
$import_table .= '<option value="' . $k . '"';
|
|
if ($k == $focus->country_transport_cur_id) $import_table .= ' selected';
|
|
$import_table .= '>' . $v . '</option>';
|
|
}
|
|
$import_table .= '</select></td>
|
|
<td><input type="text" id="country_transport_cur_val" onchange="$(this).val(FormatNumber($(this).val(),4));" onclick="$(this).select();" name="country_transport_cur_val" value="' . $focus->country_transport_cur_val . '"/></td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="dataLabel">' . $mod_strings['LBL_ADDITION_COST_VAL'] . '</td>
|
|
<td><input type="text" id="addition_cost_val" name="addition_cost_val" onchange="$(this).val(FormatNumber($(this).val(),2));" onclick="$(this).select();" value="' . format_number($focus->addition_cost_val) . '"/></td>
|
|
<td class="dataLabel">' . $mod_strings['LBL_ADDITION_COST_CUR_ID'] . '</td>
|
|
<td><select name="addition_cost_cur_id" id="addition_cost_cur_id"/>';
|
|
foreach ($app_list_strings['currency_dom'] as $k => $v) {
|
|
$import_table .= '<option value="' . $k . '"';
|
|
if ($k == $focus->addition_cost_cur_id) $import_table .= ' selected';
|
|
$import_table .= '>' . $v . '</option>';
|
|
}
|
|
$import_table .= '</select></td>
|
|
<td><input type="text" id="addition_cost_cur_val" name="addition_cost_cur_val" onchange="$(this).val(FormatNumber($(this).val(),4));" onclick="$(this).select();" value="' . $focus->addition_cost_cur_val . '"/></td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="dataLabel">' . $mod_strings['LBL_CURRENCY_ID'] . '</td>
|
|
<td><select name="currency_id" id="currency_id"/>';
|
|
foreach ($app_list_strings['currency_dom'] as $k => $v) {
|
|
$import_table .= '<option value="' . $k . '"';
|
|
if ($k == $focus->currency_id) $import_table .= ' selected';
|
|
$import_table .= '>' . $v . '</option>';
|
|
}
|
|
$import_table .= '</select></td>
|
|
<td class="dataLabel">' . $mod_strings['LBL_CURRENCY_VALUE'] . '</td>
|
|
<td><input type="text" id="currency_value" onchange="$(this).val(FormatNumber($(this).val(),4));" onclick="$(this).select();" name="currency_value" value="' . format_number($focus->currency_value, 4, 4) . '"/></td>
|
|
<td class="dataLabel">' . $mod_strings['LBL_CURRENCY_SAD_VALUE'] . '</td>
|
|
<td><input type="text" id="currency_sad_value" onchange="$(this).val(FormatNumber($(this).val(),4));" onclick="$(this).select();" name="currency_sad_value" value="' . format_number($focus->currency_sad_value, 4, 4) . '"/></td>
|
|
</tr>
|
|
</table>
|
|
';
|
|
$edit->ss->assign("IMPORT_TABLE", $import_table);
|
|
|
|
//create oprions
|
|
require_once 'EcmConfig.php';
|
|
$json = getJSONobj();
|
|
$scriptOpt = '
|
|
<script language="javascript">
|
|
var EcmConfig = ' . str_replace('"', '\"', $json->encode($EcmConfig)) . ';
|
|
</script>';
|
|
echo $scriptOpt;
|
|
|
|
$edit->ss->assign("NEW_OUTIM", $out);
|
|
$edit->ss->assign("PO_ID", $focus->po_id);
|
|
$edit->ss->assign("OUT_STATUS", $out_status);
|
|
// end import
|
|
echo $edit->display();
|
|
//loading view
|
|
echo '<link rel="stylesheet" type="text/css" href="modules/EcmStockDocIns/javascript/helper.css" media="screen" /><div class="loading_panel"></div>'; |