function scJQGeneralAdd() { scLoadScInput('input:text.sc-js-input'); scLoadScInput('input:password.sc-js-input'); scLoadScInput('input:checkbox.sc-js-input'); scLoadScInput('input:radio.sc-js-input'); scLoadScInput('select.sc-js-input'); scLoadScInput('textarea.sc-js-input'); } // scJQGeneralAdd function scFocusField(sField) { var $oField = $('#id_sc_field_' + sField); if (0 == $oField.length) { $oField = $('input[name=' + sField + ']'); } if (0 == $oField.length && document.F1.elements[sField]) { $oField = $(document.F1.elements[sField]); } if ($oField.length > 0) { switch ($oField[0].name) { case 'status': case 'enabled': case 'client_id': case 'issue_date': case 'invoice_number': case 'due_date': case 'total_euro': case 'tax_euro': case 'notes': sc_exib_ocult_pag('form_invoices_form0'); break; case 'pdf_path': sc_exib_ocult_pag('form_invoices_form1'); break; } } if ($("#id_ac_" + sField).length > 0) { if ($oField.hasClass("select2-hidden-accessible")) { if (false == scSetFocusOnField($oField, sField)) { setTimeout(function() { scSetFocusOnField($oField, sField); }, 500); } } else { if (false == scSetFocusOnField($oField, sField)) { if (false == scSetFocusOnField($("#id_ac_" + sField, sField))) { setTimeout(function() { scSetFocusOnField($("#id_ac_" + sField, sField)); }, 500); } } else { setTimeout(function() { scSetFocusOnField($oField, sField); }, 500); } } } else { setTimeout(function() { scSetFocusOnField($oField, sField); }, 500); } } // scFocusField function scSetFocusOnField($oField, sField) { if ($oField.length > 0 && $oField[0].offsetHeight > 0 && $oField[0].offsetWidth > 0 && !$oField[0].disabled) { if (sField == 'client_id') { $oField.select2('open'); } else { $oField[0].focus(); } return true; } return false; } // scSetFocusOnField function scEventControl_init(iSeqRow) { scEventControl_data["status" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["enabled" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["client_id" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["issue_date" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["invoice_number" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["due_date" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["total_euro" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["tax_euro" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["notes" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["pdf_path" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; } function scEventControl_active(iSeqRow) { if (scEventControl_data["status" + iSeqRow] && scEventControl_data["status" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["status" + iSeqRow] && scEventControl_data["status" + iSeqRow]["change"]) { return true; } if (scEventControl_data["enabled" + iSeqRow] && scEventControl_data["enabled" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["enabled" + iSeqRow] && scEventControl_data["enabled" + iSeqRow]["change"]) { return true; } if (scEventControl_data["client_id" + iSeqRow] && scEventControl_data["client_id" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["client_id" + iSeqRow] && scEventControl_data["client_id" + iSeqRow]["change"]) { return true; } if (scEventControl_data["issue_date" + iSeqRow] && scEventControl_data["issue_date" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["issue_date" + iSeqRow] && scEventControl_data["issue_date" + iSeqRow]["change"]) { return true; } if (scEventControl_data["invoice_number" + iSeqRow] && scEventControl_data["invoice_number" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["invoice_number" + iSeqRow] && scEventControl_data["invoice_number" + iSeqRow]["change"]) { return true; } if (scEventControl_data["due_date" + iSeqRow] && scEventControl_data["due_date" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["due_date" + iSeqRow] && scEventControl_data["due_date" + iSeqRow]["change"]) { return true; } if (scEventControl_data["total_euro" + iSeqRow] && scEventControl_data["total_euro" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["total_euro" + iSeqRow] && scEventControl_data["total_euro" + iSeqRow]["change"]) { return true; } if (scEventControl_data["tax_euro" + iSeqRow] && scEventControl_data["tax_euro" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["tax_euro" + iSeqRow] && scEventControl_data["tax_euro" + iSeqRow]["change"]) { return true; } if (scEventControl_data["notes" + iSeqRow] && scEventControl_data["notes" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["notes" + iSeqRow] && scEventControl_data["notes" + iSeqRow]["change"]) { return true; } return false; } // scEventControl_active function scEventControl_onFocus(oField, iSeq) { var fieldId, fieldName; fieldId = $(oField).attr("id"); fieldName = fieldId.substr(12); scEventControl_data[fieldName]["blur"] = true; if ("client_id" + iSeq == fieldName) { scEventControl_data[fieldName]["blur"] = false; } if ("client_id" + iSeq == fieldName) { scEventControl_data[fieldName]["change"] = true; scEventControl_data[fieldName]["original"] = $(oField).val(); scEventControl_data[fieldName]["calculated"] = $(oField).val(); return; } scEventControl_data[fieldName]["change"] = false; } // scEventControl_onFocus function scEventControl_onBlur(sFieldName) { scEventControl_data[sFieldName]["blur"] = false; if (scEventControl_data[sFieldName]["change"]) { if (scEventControl_data[sFieldName]["original"] == $("#id_sc_field_" + sFieldName).val() || scEventControl_data[sFieldName]["calculated"] == $("#id_sc_field_" + sFieldName).val()) { scEventControl_data[sFieldName]["change"] = false; } } } // scEventControl_onBlur function scEventControl_onChange(sFieldName) { scEventControl_data[sFieldName]["change"] = false; } // scEventControl_onChange function scEventControl_onAutocomp(sFieldName) { scEventControl_data[sFieldName]["autocomp"] = false; } // scEventControl_onChange var scEventControl_data = {}; function scJQEventsAdd(iSeqRow) { $('#id_sc_field_invoice_id' + iSeqRow).bind('change', function() { sc_form_invoices_invoice_id_onchange(this, iSeqRow, event) }); $('#id_sc_field_client_id' + iSeqRow).bind('select2:close', function() { sc_form_invoices_client_id_onblur('#id_sc_field_client_id' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_invoices_client_id_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_invoices_client_id_onfocus(this, iSeqRow, event) }); $('#id_sc_field_invoice_number' + iSeqRow).bind('blur', function() { sc_form_invoices_invoice_number_onblur('#id_sc_field_invoice_number' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_invoices_invoice_number_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_invoices_invoice_number_onfocus(this, iSeqRow, event) }); $('#id_sc_field_issue_date' + iSeqRow).bind('blur', function() { setTimeout(function() {sc_form_invoices_issue_date_onblur('#id_sc_field_issue_date' + iSeqRow, iSeqRow, event);}, 300) }) .bind('change', function() { sc_form_invoices_issue_date_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_invoices_issue_date_onfocus(this, iSeqRow, event) }); $('#id_sc_field_due_date' + iSeqRow).bind('blur', function() { setTimeout(function() {sc_form_invoices_due_date_onblur('#id_sc_field_due_date' + iSeqRow, iSeqRow, event);}, 300) }) .bind('change', function() { sc_form_invoices_due_date_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_invoices_due_date_onfocus(this, iSeqRow, event) }); $('#id_sc_field_total_euro' + iSeqRow).bind('blur', function() { sc_form_invoices_total_euro_onblur('#id_sc_field_total_euro' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_invoices_total_euro_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_invoices_total_euro_onfocus(this, iSeqRow, event) }); $('#id_sc_field_tax_euro' + iSeqRow).bind('blur', function() { sc_form_invoices_tax_euro_onblur('#id_sc_field_tax_euro' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_invoices_tax_euro_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_invoices_tax_euro_onfocus(this, iSeqRow, event) }); $('#id_sc_field_status' + iSeqRow).bind('blur', function() { sc_form_invoices_status_onblur('#id_sc_field_status' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_invoices_status_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_invoices_status_onfocus(this, iSeqRow, event) }); $('#id_sc_field_notes' + iSeqRow).bind('blur', function() { sc_form_invoices_notes_onblur('#id_sc_field_notes' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_invoices_notes_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_invoices_notes_onfocus(this, iSeqRow, event) }); $('#id_sc_field_pdf_path' + iSeqRow).bind('blur', function() { sc_form_invoices_pdf_path_onblur('#id_sc_field_pdf_path' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_invoices_pdf_path_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_invoices_pdf_path_onfocus(this, iSeqRow, event) }); $('#id_sc_field_enabled' + iSeqRow).bind('blur', function() { sc_form_invoices_enabled_onblur('#id_sc_field_enabled' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_invoices_enabled_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_invoices_enabled_onfocus(this, iSeqRow, event) }); $('#id_sc_field_created_at' + iSeqRow).bind('change', function() { sc_form_invoices_created_at_onchange(this, iSeqRow, event) }); $('#id_sc_field_created_at_hora' + iSeqRow).bind('change', function() { sc_form_invoices_created_at_hora_onchange(this, iSeqRow, event) }); $('#id_sc_field_usr_login' + iSeqRow).bind('change', function() { sc_form_invoices_usr_login_onchange(this, iSeqRow, event) }); $('.sc-ui-radio-status' + iSeqRow).on('click', function() { scMarkFormAsChanged(); }); $('.sc-ui-checkbox-enabled' + iSeqRow).on('click', function() { scMarkFormAsChanged(); }); } // scJQEventsAdd Upload_Cancel = false; function sc_form_invoices_invoice_id_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_invoices_client_id_onblur(oThis, iSeqRow, event) { do_ajax_form_invoices_validate_client_id(); scCssBlur(oThis); } function sc_form_invoices_client_id_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); do_ajax_form_invoices_event_client_id_onchange(); } function sc_form_invoices_client_id_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_invoices_invoice_number_onblur(oThis, iSeqRow, event) { do_ajax_form_invoices_validate_invoice_number(); scCssBlur(oThis); } function sc_form_invoices_invoice_number_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_invoices_invoice_number_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_invoices_issue_date_onblur(oThis, iSeqRow, event) { do_ajax_form_invoices_validate_issue_date(); scCssBlur(oThis); } function sc_form_invoices_issue_date_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_invoices_issue_date_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_invoices_due_date_onblur(oThis, iSeqRow, event) { do_ajax_form_invoices_validate_due_date(); scCssBlur(oThis); } function sc_form_invoices_due_date_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_invoices_due_date_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_invoices_total_euro_onblur(oThis, iSeqRow, event) { do_ajax_form_invoices_validate_total_euro(); scCssBlur(oThis); } function sc_form_invoices_total_euro_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_invoices_total_euro_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_invoices_tax_euro_onblur(oThis, iSeqRow, event) { do_ajax_form_invoices_validate_tax_euro(); scCssBlur(oThis); } function sc_form_invoices_tax_euro_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_invoices_tax_euro_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_invoices_status_onblur(oThis, iSeqRow, event) { do_ajax_form_invoices_validate_status(); scCssBlur(oThis); } function sc_form_invoices_status_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_invoices_status_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_invoices_notes_onblur(oThis, iSeqRow, event) { do_ajax_form_invoices_validate_notes(); scCssBlur(oThis); } function sc_form_invoices_notes_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_invoices_notes_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_invoices_pdf_path_onblur(oThis, iSeqRow, event) { scCssBlur(oThis); } function sc_form_invoices_pdf_path_onchange(oThis, iSeqRow, event) { File_Event = event.target; File_Arr = File_Event.files; if (File_Arr.length > 0) { File_Name = File_Arr[0].name; if (File_Name.indexOf('*') != -1) { scJs_alert (File_Name + '