1
0
Fork 0
master
嘉祥 詹 2024-09-09 18:54:27 +08:00
parent 8e62dce8ab
commit fd83fea72c
2 changed files with 814 additions and 9 deletions

View File

@ -402,7 +402,7 @@
</div>
</div><!-- /.form-group -->
<div class="form-group">
<label for="quotation_sa">製作及維護服務協議條款 </label>
<label for="quotation_sa">製作及維護服務協議條款 (##客戶公司##m與##我們公司## 這兩串文字請勿異動) </label>
<textarea class="form-control" id="quotation_sa" rows="6" placeholder="製作及維護服務協議條款"></textarea>
<textarea class="form-control" id="quotation_sa_old" rows="6" style="display:none;" placeholder="製作及維護服務協議條款"></textarea>
</div>
@ -415,3 +415,105 @@
</div><!-- /.modal-dialog -->
</div>
</form><!-- /.modal -->
<!--主項目-->
<!-- .modal -->
<form id="clientModelMainItemForm" name="clientModelMainItemForm">
<div class="modal fade" id="modelMainItemModal" tabindex="-1" role="dialog" aria-labelledby="modelMainItemModalLabel" data-backdrop="static"
data-keyboard="false" aria-hidden="true">
<!-- .modal-dialog -->
<div class="modal-dialog" role="document">
<!-- .modal-content -->
<div class="modal-content">
<!-- .modal-header -->
<div class="modal-header">
<h6 id="modelMainItemModalLabel" class="modal-title inline-editable">
<span class="sr-only">主項目</span> <input id="group_mainitem" type="text" class="form-control form-control-lg" value="" placeholder="主項目" readonly="readonly" required="">
</h6>
</div><!-- /.modal-header -->
<!-- .modal-body -->
<div class="modal-body">
<input type="hidden" id="modelMainItem_method" />
<input type="hidden" id="modelMainItem_uid" />
<input type="hidden" id="parent_mainItem_uid" />
<!-- .form-group -->
<div class="form-group">
<label class="control-label" for="modelMainItem_name">主項目名稱</label> <input id="modelMainItem_name" maxlength="32" type="text" class="form-control" />
</div><!-- /.form-group -->
<div class="form-group">
<div class="form-label-group">
<input type="text" id="modelMainItem_ac" class="form-control" value="0" placeholder="AC" maxlength="5" required=""> <label for="modelSubItem_number">AC (輸入10代表 10% AC)</label>
</div>
</div>
</div><!-- /.modal-body -->
<!-- .modal-footer -->
<div class="modal-footer">
<button type="button" id="modelMainItemDialogSaveBtn" class="btn btn-primary">Save</button> <button type="button" class="btn btn-light" data-dismiss="modal">Close</button>
</div><!-- /.modal-footer -->
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
</form><!-- /.modal -->
<!--子項目-->
<!-- .modal -->
<form id="clientModelSubItemForm" name="clientModelSubItemForm">
<div class="modal fade" id="modelSubItemModal" tabindex="-1" role="dialog" aria-labelledby="modelSubItemModalLabel" data-backdrop="static"
data-keyboard="false" aria-hidden="true">
<!-- .modal-dialog -->
<div class="modal-dialog" role="document">
<!-- .modal-content -->
<div class="modal-content">
<!-- .modal-header -->
<div class="modal-header">
<h6 id="modelSubItemModalLabel" class="modal-title inline-editable">
<span class="sr-only">次項目</span> <input id="group_Subitem" type="text" class="form-control form-control-lg" value="" placeholder="次項目" readonly="readonly" required="">
</h6>
</div><!-- /.modal-header -->
<!-- .modal-body -->
<div class="modal-body">
<input type="hidden" id="modelSubItem_method" />
<input type="hidden" id="modelSubItem_uid" />
<input type="hidden" id="parent_Item_uid" />
<input type="hidden" id="model_parent_data_uid" />
<!-- .form-group -->
<div class="form-group">
<label class="control-label" for="modelSubItem_name">次項目名稱</label> <input id="modelSubItem_name" maxlength="32" type="text" class="form-control" />
</div><!-- /.form-group -->
<div class="form-group">
<label for="tf6">製作說明</label>
<textarea class="form-control" id="modelSubItem_descript" rows="5"></textarea>
</div>
<div class="form-group">
<label for="modal_subItem_price">單價</label> <!-- .input-group -->
<div class="input-group">
<label class="input-group-prepend" for="modelSubItem_price"><span class="badge">$</span></label> <input type="text" class="form-control" maxlength="8" id="modelSubItem_price">
</div><!-- /.input-group -->
</div>
<div class="form-group">
<div class="form-label-group">
<input type="text" id="modelSubItem_unitType" class="form-control" value="" placeholder="單位" maxlength="6" required=""> <label for="modelSubItem_unitType">單位</label>
</div>
</div>
<div class="form-group">
<div class="form-label-group">
<input type="text" id="modelSubItem_number" class="form-control" value="" placeholder="數量" maxlength="5" required=""> <label for="modelSubItem_number">數量</label>
</div>
</div>
<!-- .list-group-item -->
<div class="list-group-item d-flex justify-content-between align-items-center">
<span>是否加上AC</span> <!-- .switcher-control -->
<label class="switcher-control switcher-control-lg"><input type="checkbox" id="modelSubItem_hasAC" class="switcher-input"> <span class="switcher-indicator"></span> <span class="switcher-label-on">是</span> <span class="switcher-label-off">否</span></label> <!-- /.switcher-control -->
</div><!-- /.list-group-item -->
</div><!-- /.modal-body -->
<!-- .modal-footer -->
<div class="modal-footer">
<button type="button" id="modelSubItemDialogSaveBtn" class="btn btn-primary">Save</button> <button type="button" class="btn btn-light" data-dismiss="modal">Close</button>
</div><!-- /.modal-footer -->
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
</form><!-- /.modal -->

View File

@ -7,6 +7,12 @@ var quotationRowID;
var quotationPos;
var quotation_total;
var deledMainItems = [];
var deledSubItems = [];
var preSubItem_name = '';
var hasBind = 'N';
$(document).ready(function () {
deptList();
companyList();
@ -130,7 +136,7 @@ $(document).ready(function () {
quotation_total = 0;
$('#quotation_sa').val(service_text());
$('#quotation_method').val('add');
$('#clientModelQuotationModal').modal("toggle");
});
@ -199,6 +205,18 @@ $(document).ready(function () {
return;
}
var nowModelItem_count = 0;
$('#modelItem_div .card').each(function (index, obj) {
nowModelItem_count++;
});
if (nowModelItem_count > 0) {
if (confirm("確定要使用範本覆蓋目前報價項目資料?") == false) {
return;
}
}
var formData = {
dept_uid: dept_uid,
modelQuotation_uid: modelQuotation_uid,
@ -221,15 +239,11 @@ $(document).ready(function () {
htmlCode += mainItemHtml(item);
});
$('#quotation_noTaxTotal').val(quotation_total).trigger('change');
$('#quotation_tax').val(Math.round(quotation_total * 0.05)).trigger('change');
$('#quotation_grandTotal').val(quotation_total + Math.round(quotation_total * 0.05)).trigger('change');
$('#modelItem_div').html(htmlCode);
updateGrandTotal();
} else {
alert(data.message);
@ -259,6 +273,237 @@ $(document).ready(function () {
}
}
//優惠價格變更
$('#quotation_specTotal').on('change', function () {
var specTotal = $('#quotation_specTotal').val();
if (specTotal.isNumber() == false) {
alert('請輸入正確的數字!(不能有符號)');
$('#quotation_specTotal').val('');
} else {
updateGrandTotal();
}
});
//新增主項目鈕
$('#addModelMainItemBtn').on('click', function () {
$('#modelMainItem_name').typeahead('destroy');
loadMainItemTypeahead();
$('#modelMainItem_method').val('add');
$('#modelMainItemModal').modal('toggle');
});
//新增次項目對話框儲存鈕
$('#modelSubItemDialogSaveBtn').on('click', function () {
var method = $('#modelSubItem_method').val();
var subItem_uid = $('#modelSubItem_uid').val();
var modelSubItem_uid = $('#parent_Item_uid').val();
var modelSubItem_name = $('#modelSubItem_name').val();
var modelSubItem_descript = $('#modelSubItem_descript').val();
var modelSubItem_price = $('#modelSubItem_price').val();
var modelSubItem_unitType = $('#modelSubItem_unitType').val();
var modelSubItem_number = $('#modelSubItem_number').val();
var modelSubItem_hasAC = 'N';
var parent_data_uid = $('#model_parent_data_uid').val();
if ($('#modelSubItem_hasAC').prop("checked")) {
modelSubItem_hasAC = 'Y';
} else {
modelSubItem_hasAC = 'N';
}
var msg = '';
if (modelSubItem_price == '') {
msg += '請輸入單價!\n';
} else {
if (modelSubItem_price.isNumber() == false) {
msg += '單價必須為數字!\n';
}
}
if (modelSubItem_number == '') {
msg += '請輸入數量!\n';
} else {
if (modelSubItem_number.isNumber() == false) {
msg += '數量必須為數字!\n';
}
}
if (msg != '') {
alert(msg);
return;
}
var modelSubItem_subTotal = modelSubItem_price * modelSubItem_number;
if (method == 'edit') {
var datauid = $('#modelSubItem_uid').val();
var htmlObj = $('#modelItem_div').find('[data-uid="' + parent_data_uid + '"]').find('ol').find('[data-model-subitem-uid="' + datauid + '"]');
$(htmlObj).find('[data-name="subItem_uid"]').val(subItem_uid);
$(htmlObj).find('[data-name="quotationSubItem_uid"]').val(modelSubItem_uid);
$(htmlObj).find('[data-name="quotationSubItem_name"]').val(modelSubItem_name);
$(htmlObj).find('[data-name="quotationSubItem_price"]').val(modelSubItem_price);
$(htmlObj).find('[data-name="quotationSubItem_unitType"]').val(modelSubItem_unitType);
$(htmlObj).find('[data-name="quotationSubItem_number"]').val(modelSubItem_number);
$(htmlObj).find('[data-name="quotationSubItem_hasAC"]').val(modelSubItem_hasAC);
$(htmlObj).find('[data-name="quotationSubItem_subTotal"]').val(modelSubItem_subTotal);
$(htmlObj).find('[data-name="quotationSubItem_descript"]').val(modelSubItem_descript);
$(htmlObj).children().children().find('[data-name="subname"]').text(modelSubItem_name);
$(htmlObj).children().children().find('[data-name="subdesc"]').text(modelSubItem_descript);
var detailData = '';
detailData += '單價 NT$' + AppendComma(modelSubItem_price) + ', 數量 ' + modelSubItem_number + ', 單位 ' + modelSubItem_unitType + '\r\n';
detailData += '小計 NT$' + AppendComma(modelSubItem_subTotal) + '\r\n';
detailData += 'AC(' + modelSubItem_hasAC + ')';
$(htmlObj).children().children().find('[data-name="subsummy"]').text(detailData);
$('#modelSubItemModal').modal('toggle');
}
if (method == 'add') {
var datauid = Math.floor(Math.random() * 999999999);
var htmlCode = '';
htmlCode += ' <li class="dd-item dd-nodrag" data-model-subitem-uid="' + datauid + '" data-method="add">';
htmlCode += ' <textarea style="display:none;" data-name="subItem_uid">' + subItem_uid + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_uid">' + modelSubItem_uid + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_name">' + modelSubItem_name + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_price">' + modelSubItem_price + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_unitType">' + modelSubItem_unitType + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_number">' + modelSubItem_number + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_hasAC">' + modelSubItem_hasAC + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_subTotal">' + modelSubItem_subTotal + '</textarea>';
htmlCode += ' <textarea data-name="quotationSubItem_descript" style="display:none;">' + modelSubItem_descript + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="subItem_uid_old">' + subItem_uid + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_uid_old">' + modelSubItem_uid + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_name_old">' + modelSubItem_name + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_price_old">' + modelSubItem_price + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_unitType_old">' + modelSubItem_unitType + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_number_old">' + modelSubItem_number + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_hasAC_old">' + modelSubItem_hasAC + '</textarea>';
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_subTotal_old">' + modelSubItem_subTotal + '</textarea>';
htmlCode += ' <textarea data-name="quotationSubItem_descript_old" style="display:none;">' + modelSubItem_descript + '</textarea>';
htmlCode += ' <div class="dd-handle">';
htmlCode += ' <div class="list-group-item">';
htmlCode += ' <div class="list-group-item-figure">';
htmlCode += ' <span class="drag-indicator"></span>';
htmlCode += ' </div>';
htmlCode += ' <div class="list-group-item-body">';
htmlCode += ' <div class="team">';
htmlCode += ' <h4 data-name="subname" class="list-group-item-title">';
htmlCode += ' ' + modelSubItem_name;
htmlCode += ' </h4><br/>';
htmlCode += ' <p class="list-group-item-text" data-name="subdesc" style="white-space: pre-line;font-size: 13px;">';
htmlCode += ' ' + modelSubItem_descript;
htmlCode += ' </p><br/>';
htmlCode += ' <p class="list-group-item-text" data-name="subsummy" style="white-space: pre-line;font-size: 11px;">';
htmlCode += ' 單價 NT$' + AppendComma(modelSubItem_price) + ', 數量 ' + modelSubItem_number + ', 單位 ' + modelSubItem_unitType + '\r\n';
htmlCode += ' 小計 NT$' + AppendComma(modelSubItem_subTotal) + '\r\n';
htmlCode += ' AC(' + modelSubItem_hasAC + ')';
htmlCode += ' </p>';
htmlCode += ' </div>';
htmlCode += ' </div>';
htmlCode += ' </div>';
htmlCode += ' <div class="dd-nodrag btn-group ml-auto">';
htmlCode += ' <button type="button" onclick="editQuotationSubItemButton(this);" class="btn btn-sm btn-secondary">Edit</button> <button type="button" onclick="delQuotationSubItemButton(this);" class="btn btn-sm btn-secondary"><i class="far fa-trash-alt"></i></button>';
htmlCode += ' </div>';
htmlCode += ' </div> ';
htmlCode += ' </li>';
var htmlObj = $('#modelItem_div').find('[data-uid="' + parent_data_uid + '"]').find('ol');
//var htmlObj = $('#' + parent_data_uid).find('ol');
htmlObj.append(htmlCode);
$('#modelSubItemModal').modal('toggle');
}
updateGrandTotal();
});
//新增主項目對話框儲存鈕
$('#modelMainItemDialogSaveBtn').on('click', function () {
var modelMainItem_uid = $('#modelMainItem_uid').val();
var mainItem_uid = $('#parent_mainItem_uid').val();
var method = $('#modelMainItem_method').val();
var modelMainItem_name = $('#modelMainItem_name').val();
var modelMainItem_ac = $('#modelMainItem_ac').val();
if (modelMainItem_ac.isNumber() == false) {
alert('AC必須為數字!');
return;
}
if (modelMainItem_name == "") {
alert('主項目名稱不得為空白!');
return;
}
var ac_string = "";
if (modelMainItem_ac == 0) {
ac_string = "無";
} else {
ac_string = modelMainItem_ac + '%';
}
if (method == 'edit') {
var obj = $('#modelItem_div').find("[data-uid='" + modelMainItem_uid + "']");
$(obj).prop('data-main-uid', mainItem_uid);
$(obj).find("[data-name='quotationMainItem_name']").val(modelMainItem_name);
$(obj).find("[data-span='quotationMainItem_name']").text(modelMainItem_name);
$(obj).find("[data-name='quotationMainItem_ac']").val(modelMainItem_ac);
$('#modelMainItemModal').modal('toggle');
}
if (method == 'add') {
var datauid = Math.floor(Math.random() * 99999999);
var htmlCode = '';
htmlCode += '<!-- .card -->';
htmlCode += '<div class="card card-fluid" data-uid="' + datauid + '" data-main-uid="' + mainItem_uid + '" data-type="add">';
htmlCode += ' <div class="card-header border-bottom-0 btn-group">';
htmlCode += ' <input type="hidden" data-name="quotationMainItem_name" value="' + modelMainItem_name + '" />';
htmlCode += ' <input type="hidden" data-name="quotationMainItem_ac" value="' + modelMainItem_ac + '" />';
htmlCode += ' <input type="hidden" data-name="quotationMainItem_name_old" value="" />';
htmlCode += ' <input type="hidden" data-name="quotationMainItem_ac_old" value="" />';
htmlCode += ' <span data-span="quotationMainItem_name" style="width: 60%;">' + modelMainItem_name + '</span>';
htmlCode += ' <span data-span="quotationMainItem_ac" style="width: 10%;">AC:&nbsp;' + ac_string + '&nbsp;</span>';
htmlCode += ' <span data-span="quotationMainItem_subTotal" style="text-align: right;">項目合計:&nbsp;0</span>';
htmlCode += ' <div class="dd-nodrag btn-group ml-auto">';
htmlCode += ' <button type="button" class="btn btn-sm btn-secondary" onclick="editQuotationMainItem(this);">Edit</button> <button type="button" onclick="delQuotationMainItem(this);" class="btn btn-sm btn-secondary"><i class="far fa-trash-alt"></i></button>';
htmlCode += ' </div>';
htmlCode += ' ';
htmlCode += ' </div>';
htmlCode += ' <!-- .dd-list -->';
htmlCode += ' <ol class="dd-list">';
htmlCode += ' ';
htmlCode += ' </ol><!-- /.dd-list -->';
htmlCode += ' ';
htmlCode += ' <!-- .card-footer -->';
htmlCode += ' <div class="card-footer">';
htmlCode += ' <a href="javascript: void(0);" onclick="addQuotationSubItem(this);" class="card-footer-item justify-content-start"><span><i class="fa fa-plus-circle mr-1"></i> 添加子項目</span></a>';
htmlCode += ' </div><!-- /.card-footer -->';
htmlCode += '</div><!-- /.card -->';
$('#modelItem_div').append(htmlCode);
$('#modelMainItemModal').modal('toggle');
}
updateGrandTotal();
});
});
function loadContactPersion() {
@ -845,7 +1090,7 @@ function mainItemHtml(obj) {
htmlCode += ' <input type="hidden" data-name="quotationMainItem_name_old" value="" />';
htmlCode += ' <input type="hidden" data-name="quotationMainItem_ac_old" value="" />';
htmlCode += ' <span data-span="quotationMainItem_name" style="width: 60%;">' + obj.modelMainItem_name + '&nbsp;</span>';
htmlCode += ' <span data-span="quotationMainItem_name" style="width: 10%;">AC:&nbsp;' + ac_string + '&nbsp;</span>';
htmlCode += ' <span data-span="quotationMainItem_ac" style="width: 10%;">AC:&nbsp;' + ac_string + '&nbsp;</span>';
htmlCode += ' <span data-span="quotationMainItem_subTotal" style="text-align: right;">項目合計:&nbsp;' + AppendComma(mainItem_totalac) + '</span>';
htmlCode += ' <div class="dd-nodrag btn-group ml-auto">';
htmlCode += ' <button type="button" class="btn btn-sm btn-secondary" onclick="editQuotationMainItem(this);">Edit</button> <button type="button" onclick="delQuotationMainItem(this);" class="btn btn-sm btn-secondary"><i class="far fa-trash-alt"></i></button>';
@ -922,3 +1167,461 @@ function subItemHtml(obj) {
return htmlCode;
}
//計算專案總價
function noTaxCalcItemPrice() {
var tmpTotalPrice = 0;
$('#modelItem_div .card').each(function (index, obj) {
var quotationMainItem_ac = $(obj).find('[data-name="quotationMainItem_ac"').val();
var tmpTotal = 0;
$(obj).find('ol li').each(function (i, item) {
var quotationSubItem_subTotal = $(item).find('[data-name="quotationSubItem_subTotal"]').val();
var quotationSubItem_hasAC = $(item).find('[data-name="quotationSubItem_hasAC"]').val();
var tmpPrice = parseInt(quotationSubItem_subTotal);
if (quotationSubItem_hasAC == 'Y') {
quotationSubItem_subTotal = parseInt(quotationSubItem_subTotal) + (Math.round(quotationSubItem_subTotal * (quotationMainItem_ac / 100)));
tmpPrice = quotationSubItem_subTotal;
}
tmpTotalPrice += parseInt(quotationSubItem_subTotal);
tmpTotal += tmpPrice;
});
var ac_string = '';
if (quotationMainItem_ac == 0) {
ac_string = '無';
} else {
ac_string = quotationMainItem_ac + '%'
}
$(obj).find('[data-span="quotationMainItem_subTotal"]').html('項目合計:&nbsp;' + AppendComma(tmpTotal));
$(obj).find('[data-span="quotationMainItem_ac"]').html('AC:&nbsp;' + ac_string + '&nbsp;');
});
return tmpTotalPrice;
}
//更新總價與含稅價
function updateGrandTotal() {
var grandTotal = noTaxCalcItemPrice();
$('#quotation_noTaxTotal').val(grandTotal).trigger('change');
$('#quotation_tax').val(Math.round(grandTotal * 0.05)).trigger('change');
var specTotal = $('#quotation_specTotal').val();
if (specTotal != "") {
var specTotalNum = parseInt($('#quotation_specTotal').val());
$('#quotation_tax').val(Math.round(specTotalNum * 0.05)).trigger('change');
$('#quotation_grandTotal').val(specTotalNum + Math.round(specTotalNum * 0.05)).trigger('change');
} else {
$('#quotation_grandTotal').val(grandTotal + Math.round(grandTotal * 0.05)).trigger('change');
}
}
function loadSubItemTypeahead(mainItem_uid) {
var formData = {
dept_uid: $('#dept_select').val(),
mainItem_uid: mainItem_uid
}
$.ajax({
url: "/AuthApi/authSubItemList",
type: "post",
data: formData,
success: function (data, textStatus, jqXHR) {
if (data.ret == "yes") {
var obj = data.subItems;
subItem_items = [];
subItem_map = {};
$.each(obj, function (i, item) {
var id = item.subItem_uid;
var name = item.subItem_name;
var descript = item.subItem_descript;
var price = item.subItem_price;
var unitType = item.subItem_unitType;
subItem_map[name] = { id: id, name: name, descript: descript, price: price, unitType: unitType };
subItem_items.push(name);
});
var bh = new Bloodhound({
local: subItem_items,
queryTokenizer: Bloodhound.tokenizers.whitespace,
datumTokenizer: Bloodhound.tokenizers.whitespace
});
var nflTeamsWithDefaults = function nflTeamsWithDefaults(q, sync) {
if (q === '') {
sync(bh.index.all());
} else {
bh.search(q, sync);
}
};
$('#modelSubItem_name').typeahead(
{
minLength: 0,
highlight: false
},
{
source: nflTeamsWithDefaults
}
);
preSubItem_name = '';
if (hasBind == 'N') {
bindTypeHead();
hasBind = 'Y';
}
//$('#modelMainItem_name').bind('typeahead:autocomplete', function (ev, suggestion) {
// console.log('Selection: ' + suggestion);
// console.log('Selection key: ' + mainItem_map[suggestion].id);
// $('#parent_mainItem_uid').val(mainItem_map[suggestion].id);
//});
} else {
alert(data.message);
if (data.err_code == "99999") {
location.href = "/Root/Login";
}
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('網路或伺服器發生錯誤,請稍後重試!');
}
});
}
function bindTypeHead() {
$('#modelSubItem_name').bind('typeahead:select', function (ev, suggestion) {
var modelSubItem_descript = $('#modelSubItem_descript').val();
if (preSubItem_name != '') {
if (suggestion != preSubItem_name) {
if (confirm('確定要用新項目覆蓋目前資料?')) {
$('#parent_Item_uid').val(subItem_map[suggestion].id);
preSubItem_name = suggestion;
$('#modelSubItem_price').val(subItem_map[suggestion].price).trigger('change');
$('#modelSubItem_unitType').val(subItem_map[suggestion].unitType).trigger('change');
$('#modelSubItem_descript').val(subItem_map[suggestion].descript).trigger('change');
$('#modelSubItem_number').val('').trigger('change');
} else {
$('#modelSubItem_name').typeahead('val', preSubItem_name);
//suggestion = preSubItem_name;
//$('#modelSubItem_name').val(preSubItem_name).trigger('change');;
}
}
} else {
$('#parent_Item_uid').val(subItem_map[suggestion].id);
preSubItem_name = suggestion;
$('#modelSubItem_price').val(subItem_map[suggestion].price).trigger('change');
$('#modelSubItem_unitType').val(subItem_map[suggestion].unitType).trigger('change');
$('#modelSubItem_descript').val(subItem_map[suggestion].descript).trigger('change');
}
console.log('Selection: ' + suggestion);
console.log('Selection key: ' + subItem_map[suggestion].id);
});
}
function loadMainItemTypeahead() {
var formData = {
dept_uid: $('#dept_select').val()
}
$.ajax({
url: "/AuthApi/authMainItemList",
type: "post",
data: formData,
success: function (data, textStatus, jqXHR) {
if (data.ret == "yes") {
var obj = data.mainItems;
mainItem_items = [];
mainItem_map = {};
$.each(obj, function (i, item) {
var id = item.mainItem_uid;
var name = item.mainItem_name;
mainItem_map[name] = { id: id, name: name };
mainItem_items.push(name);
});
var bh = new Bloodhound({
local: mainItem_items,
queryTokenizer: Bloodhound.tokenizers.whitespace,
datumTokenizer: Bloodhound.tokenizers.whitespace
});
var nflTeamsWithDefaults = function nflTeamsWithDefaults(q, sync) {
if (q === '') {
sync(bh.index.all());
} else {
bh.search(q, sync);
}
};
$('#modelMainItem_name').typeahead(
{
minLength: 0,
highlight: false
},
{
source: nflTeamsWithDefaults
}
);
$('#modelMainItem_name').bind('typeahead:select', function (ev, suggestion) {
console.log('Selection: ' + suggestion);
console.log('Selection key: ' + mainItem_map[suggestion].id);
$('#parent_mainItem_uid').val(mainItem_map[suggestion].id);
});
$('#modelMainItem_name').bind('typeahead:autocomplete', function (ev, suggestion) {
console.log('Selection: ' + suggestion);
console.log('Selection key: ' + mainItem_map[suggestion].id);
$('#parent_mainItem_uid').val(mainItem_map[suggestion].id);
});
} else {
alert(data.message);
if (data.err_code == "99999") {
location.href = "/Root/Login";
}
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('網路或伺服器發生錯誤,請稍後重試!');
}
});
}
function addQuotationSubItem(obj) {
var modelMainItem_uid = $(obj).parent().parent().attr("data-uid");
var modelMainItem_name = $(obj).parent().parent().find("[data-name='mainItem_name']").val();
var parent_mainItem_uid = $(obj).parent().parent().attr("data-main-uid");
var ac = $(obj).parent().parent().find('[data-name="quotationMainItem_ac"]').val();
$('#modelSubItem_name').typeahead('destroy');
loadSubItemTypeahead(parent_mainItem_uid);
$('#modelSubItem_method').val('add');
$('#modelSubItem_uid').val('');
$('#parent_Item_uid').val('');
$('#model_parent_data_uid').val(modelMainItem_uid);
if (ac != '0') {
$('#modelSubItem_hasAC').prop("checked", true).trigger("change");
} else {
$('#modelSubItem_hasAC').prop("checked", false).trigger("change");
}
$('#modelSubItemModal').modal('toggle');
}
function editQuotationMainItem(obj) {
var modelMainItem_name = $(obj).parent().parent().find("[data-name='quotationMainItem_name']").val();
var parent_mainItem_uid = $(obj).parent().parent().parent().attr("data-main-uid");
var modelMainItem_uid = $(obj).parent().parent().parent().attr("data-uid");
var modelMainItem_ac = $(obj).parent().parent().find("[data-name='quotationMainItem_ac']").val();
$('#modelMainItem_name').typeahead('destroy');
loadMainItemTypeahead();
$('#modelMainItem_method').val('edit');
$('#modelMainItem_uid').val(modelMainItem_uid);
$('#modelMainItem_name').val(modelMainItem_name);
$('#modelMainItem_ac').val(modelMainItem_ac);
$('#parent_mainItem_uid').val(parent_mainItem_uid);
$('#modelMainItemModal').modal('toggle');
}
function delQuotationMainItem(obj) {
if (confirm('確定刪除此主項目資料? 所有子項目也會一併刪除~')) {
if (confirm('再次確認是否刪除所有此項目與子項目?')) {
var modelMainItem_uid = $(obj).parent().parent().parent().attr("data-uid");
var modelMainItem_name = $(obj).parent().parent().find("[data-name='quotationMainItem_name']").val();
var delItem = {
mainItem_uid: modelMainItem_uid,
mainItem_msg: '刪除主項目 - ' + modelMainItem_name
}
deledMainItems.push(delItem);
$(obj).parent().parent().parent().remove();
alert('預定刪除完成! 記得按下下方儲存鈕才是真的刪除喔~');
}
}
}
//次項目編輯鈕
function editQuotationSubItemButton(obj) {
var divObj = $(obj).parent().parent().parent();
var model_subitem_uid = $(obj).parent().parent().parent().attr('data-model-subitem-uid');
var subItem_name = $(divObj).find("[data-name='quotationSubItem_name']").val();
var parent_item_uid = $(divObj).find("[data-name='quotationSubItem_uid']").val();
var modelSubItem_price = $(divObj).find("[data-name='quotationSubItem_price']").val();
var modelSubItem_unitType = $(divObj).find("[data-name='quotationSubItem_unitType']").val();
var modelSubItem_number = $(divObj).find("[data-name='quotationSubItem_number']").val();
var modelSubItem_hasAC = $(divObj).find("[data-name='quotationSubItem_hasAC']").val();
var modelSubItem_descript = $(divObj).find("[data-name='quotationSubItem_descript']").val();
var modelMainItem_uid = $(divObj).parent().parent().attr("data-uid");
var parent_mainItem_uid = $(divObj).parent().parent().attr("data-main-uid");
$('#modelSubItem_method').val('edit');
$('#modelSubItem_uid').val(model_subitem_uid);
$('#parent_Item_uid').val(parent_item_uid);
$('#model_parent_data_uid').val(modelMainItem_uid).trigger('change');
$('#modelSubItem_name').val(subItem_name).trigger('change');
$('#modelSubItem_descript').val(modelSubItem_descript).trigger('change');
$('#modelSubItem_price').val(modelSubItem_price).trigger('change');
$('#modelSubItem_unitType').val(modelSubItem_unitType).trigger('change');
$('#modelSubItem_number').val(modelSubItem_number).trigger('change');
if (modelSubItem_hasAC == 'Y') {
$('#modelSubItem_hasAC').prop('checked', true).trigger('change');
} else {
$('#modelSubItem_hasAC').prop('checked', false).trigger('change');
}
$('#modelSubItem_name').typeahead('destroy');
loadSubItemTypeahead(parent_mainItem_uid);
setTimeout(function () { preSubItem_name = subItem_name; }, 1000);
$('#modelSubItemModal').modal('toggle');
}
//次項目刪除鈕
function delQuotationSubItemButton(obj) {
if (confirm('確定刪除此次項目資料? ')) {
var model_subitem_uid = $(obj).parent().parent().parent().attr('data-model-subitem-uid');
var divObj = $(obj).parent().parent().parent();
var subItem_name = $(divObj).find("[data-name='quotationSubItem_name']").val();
var delItem = {
subItem_uid: model_subitem_uid,
subItem_msg: '刪除次項目 - ' + subItem_name
}
deledSubItems.push(delItem);
$(obj).parent().parent().parent().remove();
updateGrandTotal();
alert('預定刪除完成! 記得按下下方儲存鈕才是真的刪除喔~');
}
}
function service_text() {
var serviceTxt = '';
serviceTxt += '1.以下簡稱##客戶公司##為甲方,##我們公司##為乙方。本契約係為甲方委託乙方進行本專案製作,且乙方同意承攬本專案工作之證明,經雙方於本契約簽章後,具有拘束雙方之法律效力。\n';
serviceTxt += '\n';
serviceTxt += '2.本專案之報價金額應自報價日起15日內有效如經雙方確認無誤後甲方應於本報價單上簽署同意乙方始得執行本專案。\n';
serviceTxt += '\n';
serviceTxt += '3.乙方保證履行本契約內所載明之各工作項目,實際製作內容以本專案製作說明之內容為準;如因甲方要求變更設計致工作項目之製作內容有變更或工作項目之數量有增減之情形時,該變更或增減之工作項目應另行議價後,併入本契約執行。\n';
serviceTxt += '\n';
serviceTxt += '4.專案經公開發表後視同甲方同意結案,除另有約定外,乙方得於結案後開立本專案報酬之發票向甲方請款。\n';
serviceTxt += '\n';
serviceTxt += '5.執行:\n';
serviceTxt += '(a)乙方開始設計製作前,應先就甲方提出之需求與甲方充分溝通。甲方得要求乙方提供功能說明及/或製作進度供甲方確認。\n';
serviceTxt += '(b)甲方應於受領乙方已完成之功能說明及製作進度後儘速審核完畢,並若甲方認為前項功能說明及/或製作進度有需修正者,應於受領功能說明及/或製作進度後,將應修改處通知乙方修改。如甲方未於受領功能說明及/或製作進度後3個工作天內通知乙方修改時即視為該功能說明及/或製作進度已經甲方之確認,乙方得依此進行本專案之設計製作。\n';
serviceTxt += '(c)甲方必須提供本專案工作所需之相關文案及圖片資料(以下稱「甲方製作素材」)供乙方執行本專案使用。除因天災等自然不可抗力因素,或經甲方同意延後進度外,如因甲方製作素材提供延遲所致之專案遲延者,乙方扣除延遲之時日後,仍應按本工作進度完成之。如因乙方延遲交付本專案之完成物致甲方受有損害時,乙方應負賠償之責任。\n';
serviceTxt += '(d)乙方對各工作項目之提案應各別經甲方同意後始得開始製作。乙方對一工作項目之提案經甲方同意並開始製作後,如因甲方或甲方其他配合廠商之原因無法履行本約,導致本專案停止製作或必須重新發展製作方向時,因此對於各工作項目中乙方已支出之成本及造成乙方之損害部分,甲方同意依乙方實際之支出或損失負賠償之責任。\n';
serviceTxt += '\n';
serviceTxt += '6.驗收:\n';
serviceTxt += '(a)乙方須依照雙方對各工作項目所協議之各完成期限內完成該工作項目,並將該工作項目之完成物(以下稱「製作物」)提供予甲方驗收。每一製作物,乙方應將其上傳至乙方之測試網站,並通知甲方進行測試。\n';
serviceTxt += '(b)如甲方認為乙方所完成之任一製作物與需求不符者,應於乙方交付製作物後十日內以書面通知乙方進行修改,乙方應於甲方限期之時間內將該製作物修正至符合甲方需求,並再次通知甲方依本條第(a)項方式進行驗收。\n';
serviceTxt += '(c)如乙方交付製作物後,甲方未於十日內通知乙方進行修改者,則視為甲方同意該製作物而驗收完成。\n';
serviceTxt += '(d)乙方應配合甲方之意見為各製作物必要之修改並於每製作物交付後經甲方認為有修改之必要時乙方得提出修改建議書並取得甲方對修改建議書之同意後依修改建議書進行修改若甲方提出非屬本契約所列之工作項目內之修改時則視為本契約第3條變更設計致工作項目之製作內容有變更或工作項目之數量有增減之情形雙方需另行議價。\n';
serviceTxt += '(e)自本專案下所有工作項目皆完成後ㄧ個月內,乙方須對本專案提供免費諮詢及維修/維護管理服務(但若因甲方不當使用、自行更動本專案設計或由甲方所使用之硬體異常所造成之本專案損壞者,則不在此限)。\n';
serviceTxt += '\n';
serviceTxt += '7.擔保事項:\n';
serviceTxt += '(a)甲方使乙方使用於本專案之任何素材,包括但不限於畫作、照片、肖像、商標圖樣、動態或平面廣告等畫面及文字(以下稱「甲方素材」),甲方應擔保其有權使用或事先均已依法取得權利人之同意進行本專案之使用。\n';
serviceTxt += '(b)若乙方因製作本專案而使用甲方素材,遭第三人對其主張侵害著作權或其他智慧財產權之情事時,甲方應協助處理,如因該第三人之主張致乙方受有任何損害時,甲方同意賠償乙方因此所生實際費用。\n';
serviceTxt += '(c)乙方向甲方保證其對本專案所提供的設計及本專案各工作項目之開發、組裝或為此所建造的設備、機器、工序、軟體或其他與本專案相關之任何事項皆沒有違反或侵害任何專利權、著作權、營業秘密或其他智慧財產權,乙方亦應保證其接受本專案之工作絕無違反其與其他任意第三人之契約義務或約定。\n';
serviceTxt += '(d)乙方擔保交付甲方之製作物及本專案所使用之程式並無侵害第三人之專利權、著作權、智慧財產權或其他任何權利,若甲方因乙方違反前述擔保而遭第三人對其主張侵害任何權利時,甲方應立即以書面通知乙方,並得提供有關資料予乙方,乙方應盡力協助甲方處理,並應償付甲方及第三人一切損失及相關費用(包括但不限於律師費用等)。\n';
serviceTxt += '\n';
serviceTxt += '8.智慧財產權:\n';
serviceTxt += '(a)除雙方另有協議外,乙方擁有本契約製作物之著作權、專利權等智慧財產權與其他權益。於乙方交付製作物資料後,甲方擁有上述權利之使用權以及合理範圍內修改之權利。\n';
serviceTxt += '(b)本專案之網頁原始檔(包括但不限於可用於重製修改之製作素材、程式設計碼及既有之製作物內容)之著作權、所有權、使用權及任何衍生之其他權利均歸乙方所有,甲方如需取得相關權利,雙方需另案議價訂約。\n';
serviceTxt += '(c)本契約製作物僅限台灣地區網路相關媒體使用,若需其它語文版本或將製作內容放置到其他媒體或國家地區使用,需另計價並取得乙方授權使用同意。\n';
serviceTxt += '(d)未經乙方同意,甲方不得逕自修改本約著作物或自行提供予第三人利用之,如甲方違背上述規定而使乙方利益受損時,甲方應損害賠償責任。\n';
serviceTxt += '(e)乙方應於結案後將本專案及各製作物之電子檔案提供予甲方,但不包含製作物相關原始檔。\n';
serviceTxt += '\n';
serviceTxt += '9.資料保密:\n';
serviceTxt += '(a)本契約所稱之營業秘密資料係指甲方因本契約提供乙方或由乙方交付予甲方之ㄧ切相關資訊、文件和資料(包括並不限於本契約內容、網頁設計、服務項目、行銷、銷售資訊、統計數字等)。\n';
serviceTxt += '(b)就營業秘密資料,非經甲方之事前書面同意,乙方不得交付、告知或以任何形式洩露予任意第三人,亦不得在非雙方合作目的之必要範圍外使用營業秘密資料。\n';
serviceTxt += '(c)乙方應確實保護營業秘密資料,並於乙方公司內部採取適當合理之保密措施以維護營業秘密資料,使其僅得洩露於與本契約相關且有必要知悉該營業秘密資料之乙方人員,且該等乙方人員應遵守本契約之保密義務,乙方人員違反本保密約定者視同乙方違約,乙方需負完全之賠償責任。\n';
serviceTxt += '(d)乙方明瞭所收受之營業秘密資料係屬甲方所有,除了本契約作為設計、評估、分析或討論用途外,該營業秘密資料不得用來做為生產、重製、轉讓、轉售、販賣或其他為圖利而使用之用途。\n';
serviceTxt += '(e)乙方在下列情形不負保密責任:\n';
serviceTxt += '(1)甲方自行主動公開、或於本契約簽定前乙眾所周知之文件、資訊或資料。\n';
serviceTxt += '(2)乙方合法所知悉之文件、資訊或資料。\n';
serviceTxt += '(3)乙方可提出證明係其自行獨立研究開發者。\n';
serviceTxt += '(4)經甲方書面同意者。\n';
serviceTxt += '(5)依法律、法院或其他政府機關之命令應揭示之資訊者。\n';
serviceTxt += '\n';
serviceTxt += '10.網站維護管理:\n';
serviceTxt += '(a)乙方可提供本專案網站空間及頻寬代管服務,代管服務包含網路環境一般性安全維護及網站檔案定期備份,詳細所需規格及費用需經專案評估後提供。\n';
serviceTxt += '(b)乙方進行網站維護管理時,網站連線異常故障處理方式如下:\n';
serviceTxt += '(1)乙方標準工作服務時間為週一~週五1000~1900如有發生網站連線異常上班時段接獲通知將於2小時內進行處理若網站異常發生於非乙方標準工作服務時間時乙方仍應進行網站維護管理之服務並應於接獲通知後6小時內進行處理例假日或是國定假日如有發生網站異常狀況時乙方應於接獲通報後12小時內進行處理。\n';
serviceTxt += '(2)如網站異常係因機房設備發生斷線時,則乙方將進行遠端連線檢查,如仍無法排除該異常情形時,始派員至機房做狀況排除。若因網路供應商(例:中華電信)之線路突發問題導致網站連線異常等乙方無法主動排除之異常,則乙方無須為該等異常負責,但乙方仍應主動連絡該網路供應商了解原因,並視情形提供甲方協助。\n';
serviceTxt += '(3)如非可歸責於乙方之原因而網路或主機發生異常等問題導致斷線而需至機房處理收費以工時計算星期例假日及夜間21:00~08:00每工時NTD4,000其餘每工時NTD1,500。\n';
serviceTxt += '\n';
serviceTxt += '11.網站移轉交接:\n';
serviceTxt += '(a)如甲方委託乙方進行非乙方製作之網站之維護管理時,為使該網站移轉順利,甲方需提供相關檔案資訊(包含但不限於網路位址之設定),以符合乙方做網站環境設定,惟乙方僅處理該網站網址之移轉與架設設定,不包含該網站相關之安全掃描作業,如甲方有此需要必須行計價。\n';
serviceTxt += '(b)如乙方所提供之網站維護管理服務終止時,乙方應將該網站檔案以光碟形式交予甲方;若甲方委託第三人進行本專案之網站維護管理服務時,乙方應提供相關之協助,促使網站移轉順利。\n';
serviceTxt += '\n';
serviceTxt += '12.契約終止:\n';
serviceTxt += '(a)本契約生效後,非有下列情事之一者,任一方不得任意終止本契約。\n';
serviceTxt += '(1)經雙方書面同意。\n';
serviceTxt += '(2)因有法律、政策變更或其他不可歸責於甲、乙雙方之事由,致乙方無法完成本契約執行工作,且前述不可歸責之事由持續三十日以上仍無法排除時,甲、乙任一方均得以書面通知對方終止本契約,甲方並應支付乙方已履行之義務或已到期之應付製作費及乙方依約辦理而於甲方有益事項所墊付之費用。\n';
serviceTxt += '(b)因可歸責於甲方之事由致遲延給付到期之製作費用及其他必要費用,或怠於提供關於製作本契約標的物內容所需之文件及其他資料,並經乙方以書面通知催告後仍不支付或提供者,乙方得終止本契約,並沒收已付款項,毋庸交付未完成之標的物,甲方並應賠償乙方因之所受之損失。\n';
serviceTxt += '(c)乙方無法履行或不完全履行或違反契約義務者,視為乙方違約,乙方同意負責因此所生之一切損害之賠償責任。\n';
serviceTxt += '\n';
serviceTxt += '13.其他約定事項:\n';
serviceTxt += '(a)乙方應依雙方所約定之進度交付本專案及/或製作物予甲方。惟若製作物或本專案之交付遲延係可歸責於甲方之事由造成時,不在此限。\n';
serviceTxt += '(b)本契約未約定事項,雙方得以書面方式另行約定,修正時亦同。\n';
return serviceTxt;
}