/application/views/js_init/js_common2.php
PHP | 1167 lines | 967 code | 57 blank | 143 comment | 85 complexity | 08139ea56d385b0a916643f662b2953d MD5 | raw file
Possible License(s): GPL-2.0, MIT, LGPL-3.0, LGPL-2.1, GPL-3.0
- <script>
- /* Cek nilai field is number */
- function is_number(){
- var passed= true;
- $(".is_number").each(function(){
- if( isNaN($(this).val()) == true ){
- $(this).css("backgroundColor","white");
- $(this).css("color","black");
-
- passed= false;
- $(this).css("backgroundColor","#f15c32");
- $(this).css("color","white");
- }
- });
-
- if( passed == false ){
- alert("<?php echo lang("abdi.alert_2") ?>"); //Nilai Salah
- }
-
- return passed;
- }
- /* DIGUNAKAN UNTUK CHECK PASSWORD PADA FORM ACCOUNT */
- function match_password(){
- password1= $('#Password').val();
- password2= $('#Password2').val();
-
- if( password1 == password2 ){
- return true;
- }else{
- alert("<?php echo lang("abdi.alert_18") ?>");
- return false;
- }
- }
-
- /* DIGUNAKAN UNTUK CHECK EMAIL PADA FORM ACCOUNT */
- function is_email(){
- email= $('#Email').val();
- var regexp= /^[a-z0-9\_\.]+[@]{1}[a-z]+\.[a-z]+$/;
- if( regexp.test(email) ){
- return true;
- }else{
- alert("<?php echo lang("abdi.alert_19") ?>");
- return false;
- }
- }
-
- function newKonsumenDetail(id)
- {
- $("#dialog4").dialog({
- title : '<?php echo lang("abdi.summary_information_detail") ?>',
- width: 'auto',
- height: 700,
- modal: true,
- show : "blind",
- hide : "blind",
- position: [200,0],
- buttons: {
- '<?php echo lang("abdi.close") ?>' : function(){
- $(this).dialog('close');
- }
- },
- close: function() {
- $(this).empty();
- $('#jqTable').trigger('reloadGrid');
- },
- open : function()
- {
- $(this).append("<center><span><img src='<?php echo $this->config->item("img_url") ?>/dialogload.gif' /></span><br /><?php echo lang("abdi.alert_21") ?> ....</center>");
- $(this).load("<?php echo $this->configlib->site_url() ?>/customer/dashboard/view_detail/" + id);
- }
- });
- //$("#dialog4").dialog("open");
- }
-
- function getDetail(id)
- {
- $("#dialog").dialog({
- title : '<?php echo lang("abdi.summary_information_detail") ?>',
- width: 900,
- height: 700,
- modal: true,
- show : "blind",
- hide : "blind",
- buttons: {
- '<?php echo lang("abdi.close") ?>' : function(){
- $(this).dialog('close');
- }
- },
- close: function() {
- $(this).empty();
- //$('#jqTable').trigger('reloadGrid');
- },
- open : function()
- {
- $(this).append("<center><span><img src='<?php echo $this->config->item("img_url") ?>/dialogload.gif' /></span><br /><?php echo lang("abdi.alert_21") ?> ....</center>");
- $(this).load("<?php echo $this->configlib->site_url() ?>/customer/dashboard/view_detail/" + id);
- }
- });
- //$('#dialog').load("<?php echo $this->configlib->site_url() ?>/customer/dashboard/view_detail/" + id);
- }
- /*
- ( function($){
- $('#fbox_jqTable_search').click( function(){
- alert("true");
- return false;
- });
- })(jQuery);
- */
-
- $(function(){
- /*
- var arrFrm = new Array("frmAddCus","frmAddOther"); //Untuk Customer Master aja
- initDialog("add","",arrFrm);
- $("#dialog").dialog("open");
- initDialog("add","","");
- $("#dialog").dialog("open");
- */
- /*
- getDetail('02001000000019');
- $("#dialog").dialog("open");
- */
- /*
- // Untuk Popup otomatis
- var arrFrm = new Array("frmAddCus","frmAddOther"); //Untuk Customer Master aja
- initDialog("add","",arrFrm);
- $("#dialog").dialog("open");
- */
- /*
- var arrFrm = new Array("frmAddCus","frmAddOther");
- initDialog("add","",arrFrm);
- $("#dialog").dialog("open");
-
- id= "02001000000543";
- var arrFrm = new Array("frmAddCus","frmAddOther");
- initDialog("edit", id, arrFrm);
- $("#dialog").dialog("open");
- */
- /*
- var arrFrm = new Array("frmAddCus","frmAddOther");
- initDialog("add","",arrFrm);
- $("#dialog").dialog("open");
- initDialog("add","","");
- $("#dialog").dialog("open");
- id= "INV-02001-0911-52";
- initDialog("edit",id,"");
- $("#cusDialog").dialog("open");
- */
- //
-
- /*
- $('#jqTable_TanggalLahir').remove();
- $("#jqTable tr").hide();
- */
-
- /* Menu untuk Klik Kanan View Detail */
- $('#jqTable').bind('contextmenu',function(e){
- var id= $('#jqTable').jqGrid('getGridParam','selrow');
- if( id != null ){
- $('<div class="overlay"> </div>').appendTo(document.body)
- .bind('contextmenu', function(overlay){
- return false;
- });
- $('#menu_detail').css({ left: e.pageX, top: e.pageY }).show();
- }
- return false;
- });
-
- $('.overlay').live('click', function(){
- $(this).remove();
- $('#menu_detail').hide();
- });
-
- $('#menu_detail a[href=#view_detail]').click( function(){
- var id= $('#jqTable').jqGrid('getGridParam','selrow');
- getDetail(id);
- $("#dialog").dialog("open");
- $('.overlay').remove();
- $('#menu_detail').hide();
- });
- /* Akhir Menu Klik Kanan */
-
- $('#btnCari').click( function(){
-
- /*
- var url= '<?php echo $this->configlib->site_url(); ?>' + '/' + modul + '/' + subModul + '/xml';
- $("#jqTable").jqGrid('setGridParam', { url: url });
- $("#jqTable").trigger("reloadGrid");
-
- console.log( $('tr#02007000000396').text() );
- $('tr#02007000000396').remove();
- grid= $("#jqTable");
- filterparams= '{"groupOp":"AND","rules":[{"field":"IdKonsumen","op":"eq","data":""}],"groups":[]}';
- grid.jqGrid('setGridParam',{search: true});
- var postData = grid.jqGrid('getGridParam','postData');
- $.extend(postData,{filters:filterparams});
- grid.trigger("reloadGrid",[{page:1}]);
- */
- modul= '<?php echo $this->uri->segment(2); ?>';
- subModul= '<?php echo $this->uri->segment(3); ?>';
- console.log(modul + "->" + subModul);
- var url= '<?php echo $this->configlib->site_url(); ?>' + '/' + modul + '/' + subModul + '/xml';
- $("#jqTable").jqGrid('setGridParam', { url: url });
- //$("#jqTable").trigger("reloadGrid");
- $("#jqTable").jqGrid('searchGrid', { multipleSearch: true, overlay: true,
- sopt:['cn','bw','eq','ne','lt','gt','ew'], onClose:function(){
- var grid = $("#jqTable");
- grid.jqGrid('setGridParam', { search:false } );
- }});
- $btnreset= '<td class="EditButton" style="text-align:left">' +
- '<a class="fm-button ui-state-default ui-corner-all fm-button-icon-left' +
- ' ui-search" id="fbox_jqTable_reset_new">' +
- '<span class="ui-icon ui-icon-arrowreturnthick-1-w"></span>Reset</a></td>';
- if( $('#fbox_jqTable_2 tr:eq(1)').find('#fbox_jqTable_reset_new').length == 0 ){
- $('#fbox_jqTable_2 tr:eq(1)').prepend($btnreset);
- $('#fbox_jqTable_reset').parent().remove();
- }
- });
-
- $('#fbox_jqTable_reset_new').live('click', function(){
- var url= '<?php echo $this->configlib->site_url(); ?>' + '/' + modul + '/' + subModul + '/xml';
- $("#jqTable").jqGrid('setGridParam', { url: url });
- $("#jqTable").trigger("reloadGrid");
- grid= $("#jqTable");
- filterparams= '{"groupOp":"AND","rules":[{"field":"IdKonsumen","op":"eq","data":""}],"groups":[]}';
- grid.jqGrid('setGridParam',{search: true});
- var postData = grid.jqGrid('getGridParam','postData');
- $.extend(postData,{filters:filterparams});
- grid.trigger("reloadGrid",[{page:1}]);
- });
- /*
- getDetail('02007000000468');
- $("#dialog").dialog("open");
- */
-
- $("#btnCustDetail")
- .click(function(){
- var id = $('#jqTable').jqGrid('getGridParam','selrow');
- if(id!=null)
- {
- getDetail(id);
- $("#dialog").dialog("open");
- }else{
- alert("<?php echo lang("abdi.alert_20") ?>");
- }
- })
-
- var Modme= '<?php echo $this->uri->segment("2"); ?>';
- var Funcme= '<?php echo $this->uri->segment("3"); ?>';
- $('#btnCusHistory,#btnJobHistory').click( function(e){
- UriMod= Modme+"/"+Funcme;
- regmodule= /^(customer\/history)$/;
- id = $('#jqTable').jqGrid('getGridParam','selrow');
- if( id != null ){
- if( e.target.id == "btnJobHistory" ){
- var UrlHistory= "<?php echo $this->configlib->site_url(); ?>/customer/jobcard_history/get/" +
- encodeURIComponent(id);
- window.open(UrlHistory);
- }else{
- if( regmodule.test(UriMod) ){
- var UrlHistory= "<?php echo $this->configlib->site_url(); ?>/customer/repair/purchase_history/" +
- encodeURIComponent(id);
- window.open(UrlHistory);
- }else{
- Idcustomer= $('tr#'+ id + ' td:eq(2)').attr('title');
- var UrlHistory= "<?php echo $this->configlib->site_url(); ?>/customer/repair/purchase_history/" +
- encodeURIComponent(Idcustomer);
- window.open(UrlHistory);
- }
- }
- }else{
- alert("<?php echo lang("abdi.alert_20") ?>");
- }
- });
-
- //Function when add button clicked
- var modul = "<?php echo $this->uri->segment(2); ?>";
- var subModul = "<?php echo $this->uri->segment(3); ?>";
- var modadd= modul + '/' + subModul;
- var IdAkses= '<?php echo $this->session->userdata('idAkses'); ?>';
- //var regmodadd= new RegExp("^(customer\/master|customer\/dashboard)$"); // Cara 1
- var regmodadd= /^(customer\/master|customer\/dashboard)$/; // Cara 2
-
- if( regmodadd.test(modadd) ) // Url customer/master atau customer/dashboard
- {
- //MGR sma MEX variable regakses gx ada yg make jadi gx masalah
- regakses= /^(CST|MGR|MEX|DPS)$/;
- if( regakses.test(IdAkses) ){
- regedit= /^(MGR|MEX|DPS)$/;
- if( regedit.test(IdAkses) ){
- // MGR dan MEX
- $('img[src*=delete_disable]').remove();
- }else{
- // CST
- $('img[src*=delete_disable], a img#btnEdit').remove();
- }
- }
-
- //Function when edit button clicked
- $("img#btnEdit").click(function(){
- var id = $('#jqTable').jqGrid('getGridParam','selrow');
- if(id == null)
- {
- alert("<?php echo lang("abdi.alert_20") ?>");
- }else{
- var arrFrm = new Array("frmAddCus","frmAddOther");
- initDialog("edit", id, arrFrm);
- $("#dialog").dialog("open");
- }
- })
-
- $("img#btnAdd").click(function(){
- var arrFrm = new Array("frmAddCus","frmAddOther");
- initDialog("add","",arrFrm);
- $("#dialog").dialog("open");
- });
- }else{
- $("img#btnAdd").click(function(){ //Defaut for submitting just one form in one time
- //alert("test");
- initDialog("add","","");
- $("#dialog").dialog("open");
- });
-
- $("img#btnEdit").click(function(){
- var id = $('#jqTable').jqGrid('getGridParam','selrow');
- if(id == null)
- {
- alert("<?php echo lang("abdi.alert_20") ?>");
- }else{
- if( modadd == "customer/invoice" ){ // Open Dialog jika Url customer/invoice
- status= $('#' + id + ' td:eq(7)').text();
- status= status.toLowerCase();
- if( status == "not fully paid" ){
- initDialog("edit",id,"");
- }
- }else{
- initDialog("edit",id,"");
- }
- //$("#cusDialog").dialog("open");
- }
- })
- }
-
- var regcusmaster= /^(customer\/master)$/;
- if( regmodadd.test(modadd) ) // Modify jqgrid dari customer/master
- {
- /*
- content= $('#jqgh_TanggalLahir').html();
- content= content.replace(/Tanggal Lahir/i, "");
- $('#jqgh_TanggalLahir').html(content);
- console.log(content);
- */
- <?php #echo $this->configlib->site_url() . '/' . modul . '/' . subModul . '/xml'; ?>
- var url= '<?php echo $this->configlib->site_url(); ?>' + '/' + modul + '/' + subModul + '/xml';
- $("#jqTable").jqGrid('setGridParam', { url: url });
- $('#refresh_jqTable,#search_jqTable').remove();
- $('.ui-jqgrid-sortable').click( function(){
- return false;
- });
- }
-
- //Function when delete button clicked
- $("img#btnDel").click(function(){
- var id = $('#jqTable').jqGrid('getGridParam','selrow');
- if(id == null)
- {
- alert("<?php echo lang("abdi.alert_20") ?>");
- }else{
- jDelete(id);
- }
- })
-
-
- //Init tipsy
- var regmodul= /^(audiogram|upload|report)$/;
- Modul='<?php echo $this->uri->segment(3); ?>';
- if( ! regmodul.test(Modul) ){
- $('#btnAdd, #btnEdit, #btnDel, #btnPrint, #btnExcel, img#btnDetail, #btnArrival, #btnCusHistory, #btnJobHistory, #btnCari,#btnLastVisit').tipsy({gravity: 'sw', fade: true});
- }
-
- })
-
- function jqGridSelected(obj,id)
- {
- $("#hiddenID").val(id);
- }
-
- function required(ignore)
- {
- var passed = true;
- $(".required").each(function(){
- if($.trim($(this).val())=="")
- {
- passed = false;
- $(this).css("backgroundColor","#f15c32");
- $(this).css("color","white");
- }
- });
-
- if(passed==false)
- {
- if(ignore==false)
- {
- alert("<?php echo lang("abdi.alert_3") ?>"); //Data Ga boleh kosong
- }
- return false;
- }else{
- return true;
- }
- }
- function confirmed()
- {
- if(required(false))
- {
- var passed = true;
- $(".confirmed").each(function(){
- if($.trim($(this).val())=="")
- {
- passed = false;
- $(this).css("backgroundColor","yellow");
- }
- });
-
- if(passed==false)
- {
- var ask = confirm("<?php echo lang("abdi.alert_6") ?>"); //Mengabaikan Beberapa Fields
- if(ask)
- {
- return true;
- }else{
- return false;
- }
- }else{
- return true;
- }
- }else{
- return true;
- }
- }
-
- function initDialog(act,id,frmID)
- {
- var isArray = false;
- var modul = '<?php echo $this->uri->segment("2"); ?>';
- var func = '<?php echo $this->uri->segment("3"); ?>';
- theUrl = "<?php echo $this->configlib->site_url(); ?>/" + modul + "/" + func + "/popup/" + act + "/" + encodeURIComponent(id);
- theSave = function(e){
-
- if(frmID.length==2)
- {
- isArray=true;
- var serial = new Array($("#" + frmID[0]).serialize(),$("#" + frmID[1]).serialize());
- }
-
- if(isArray) //Notice : this function is only submitted two form in same time
- {
- var allowBlank = confirmed();
- var mustFilled = required();
-
- if( allowBlank && mustFilled )
- {
- var success= true;
- var i= 0;
- //var idkonsumen= $('#IdKonsumen').val();
- data= new Array();
-
- regmodul= /^(customer)$/;
- if( regmodul.test(modul) ){
- $.post("<?php echo $this->configlib->site_url(); ?>/" + modul + "/master/save/" + act,serial[0],
- function(data){
- data= data.split(",");
- switch(data[0])
- {
- case "IdKonsumen":
- $("#IdKonsumen").val(data[1]);
- var idkonsumen= $('#IdKonsumen').val();
-
- $.post("<?php echo $this->configlib->site_url(); ?>/" + modul +
- "/master/save/" + act, $("#" + frmID[1]).serialize(),
- function(data){
- switch(data)
- {
- case "1" :
- success = true;
- $("img#imgLoad").show();
- break;
- case "0" :
- success = false;
- var msg = "<?php echo lang("abdi.alert_4") ?>"; //Data Gagal Simpan
- break;
- case "-1" :
- success = false;
- //Error Hanya Pada Data yg Di save aja
- var msg = "<?php echo lang("abdi.alert_7") ?>";
- break;
- default :
- var msg = "Error : " + data;
- success = false;
- break;
- }
-
- if( success==false ){
- alert(msg);
- }
- if( success==true ){
-
- alert("<?php echo lang("abdi.alert_5") ?>") //Data Berhasil Disimpan
- elname= $(e.target).text();
- }
- //$("#dialog").dialog("<img src='<?php echo $this->config->item("img_url") ?>/dialog.gif' />");
- $("img#imgLoad").show();
- $("#dialog").dialog("close");
-
- var modadd= modul + "/" + func;
- var regmodadd= /^(customer\/master|customer\/dashboard)$/;
- var regbtnname= /^(Proceed|Proses)$/;
- if( regmodadd.test(modadd) && regbtnname.test(elname) ){
- newKonsumenDetail(idkonsumen);
- //newKonsumenDetail('020010006');
- }else{
- //console.log("customer");
- var url= '<?php echo $this->configlib->site_url(); ?>' +
- '/' + modadd + '/xml/newcus/' + idkonsumen;
- $("#jqTable").jqGrid('setGridParam', { url: url });
- $("#jqTable").trigger("reloadGrid");
- }
- });
- break;
- case "1" :
- success = true;
- break;
- case "0" :
- success = false;
- var msg = "<?php echo lang("abdi.alert_4") ?>"; //Data Gagal Simpan
- break;
- case "-1" :
- success = false;
- var msg = "<?php echo lang("abdi.alert_7") ?>"; //Error Hanya Pada Data yg Di save aja
- break;
- default :
- var msg = "Error : " + data;
- success = false;
- break;
- }
- });
- }else{
- while(i<=1 && success==true )
- {
- /*
- $('#dialog').empty();
- $('#dialog').append("<center><span><img src='<?php echo $this->config->item("img_url") ?>/dialogload.gif' /><br />Sending Form "+i+1+"</span></center>");
- */
- $.post("<?php echo $this->configlib->site_url(); ?>/" + modul + "/master/save/" +
- act,serial[i],
- function(data){
- data= data.split(",");
- switch(data[0])
- {
- case "1" :
- success = true;
- break;
- case "0" :
- success = false;
- var msg = "<?php echo lang("abdi.alert_4") ?>"; //Data Gagal Simpan
- break;
- case "-1" :
- success = false;
- var msg = "<?php echo lang("abdi.alert_7") ?>"; //Error Hanya Pada Data yg Di save aja
- break;
- default :
- var msg = "Error : " + data;
- success = false;
- break;
- }
-
- });
- i = i +1;
-
- if( success==false ){
- alert(msg);
- }
- if( success==true ){
- alert("<?php echo lang("abdi.alert_5") ?>") //Data Berhasil Disimpan
- elname= $(e.target).text();
- }
- $(this).dialog("close");
-
- var modadd= modul + "/" + func;
- var regmodadd= /^(customer\/master|customer\/dashboard)$/;
- if( regmodadd.test(modadd) && elname == "Proceed"){
- newKonsumenDetail(idkonsumen);
- //newKonsumenDetail('020010006');
- }
-
- }
- }
- }
- }else{
- if(frmID=="")
- frmID = $("#frmID").val(); //Get the form name to be serialized
- var serialized = $("#" + frmID).serialize();
- var allowBlank = confirmed();
- //var mustFilled = true;
- var mustFilled = required();
-
- /* Pengecekan tambahan untuk test password sama dan email pada Form frmAddAcc */
- /* -------------------------------------------------------------------------- */
- if( frmID=="frmAddAcc"){
- if( act=="add" ){
- mustFilled= match_password();
- if( mustFilled == true ){
- mustFilled = is_email();
- }
- }else{
- mustFilled= is_email();
- }
- }
-
- //Pengecekan tambahan untuk authorization add new repair
- if(frmID=="frmAddRepair")
- {
- var printRepairReceipt = false;
- switch($("#Authorization").val())
- {
- case "c" :
- //JIka user memilih cost estimate
- printRepairReceipt = true;
- alert("<?php echo lang("abdi.alert_42") ?>");
- break;
- default :
- //JIka user memilih immediate repair atau cost estimate if rep over
- //JIka nilai DP kecil dari Rp. 50.000
- if($("#DP").val()<50000)
- {
- alert("<?php echo lang("abdi.alert_43") ?>")
- $("#DP").focus();
- }else{
- printRepairReceipt = true;
- }
- break;
- }
- }else{
- var printRepairReceipt = true;
- }
- /*---------------------------------------------------------*/
- //var serialized = $("#" + frmID).serialize();
- var field_number= is_number();
-
- if(allowBlank && mustFilled && field_number && printRepairReceipt)
- {
- mockup='<?php echo $this->uri->segment(2) . "/" . $this->uri->segment(3); ?>';
- mockreg= /^(hrd\/master|marketing\/sales)$/;
- if( ! mockreg.test(mockup) ){
- grant_edit= $('#grant_edit').val();
- if( mockup == "customer/invoice" && grant_edit != "on" ){
- alert("Press F5 to enter your supervise key !");
- }else{
- /*
- $(this).empty();
- $(this).append("<center><span><img src='<?php echo $this->config->item("img_url") ?>/dialogload.gif' /><br /><?php echo lang("abdi.alert_21") ?> ....</span></center>");
- */
- var stat_dialog= true;
- $.post("<?php echo $this->configlib->site_url(); ?>/" + modul + "/" + func + "/save/" + act,serialized,
- function(data){
- dataParsed = data.split("~");
- switch(dataParsed[0])
- {
- case "1" :
- alert("<?php echo lang("abdi.alert_5") ?>");
- break;
- case "0" :
- alert("<?php echo lang("abdi.alert_4") ?> ");
- break;
- case "-1" :
- alert("<?php echo lang("abdi.alert_7") ?> ");
- break;
- case "R-OK" : //Print receipt for added repair
- alert("<?php echo lang("abdi.alert_5") ?>");
- var frmObjArr = serialized.split("&"); //Pecah value dari variable serialized untuk mendapatkan id repair
- var idRepairArr = frmObjArr[1].split("="); //Pecah lagi dengan splitter string '='
- var idRepair = idRepairArr[1];
- window.open("<?php echo $this->configlib->site_url(); ?>/customer/repair/print_receipt/" + idRepair,"Repair Receipt");
- alert("<?php echo lang("abdi.alert_8") ?>");
- break;
- case "R-OK-NORECEIPT" :
- alert("<?php echo lang("abdi.alert_5") ?>");
- break;
- case "S-OK" : //Print shipment
- var frmObjArr = serialized.split("&"); //Pecah value dari variable serialized untuk mendapatkan id shipment
- var idShipmentArr = frmObjArr[1].split("="); //Pecah lagi dengan splitter string '='
- var IdShipment = idShipmentArr[1];
- alert("<?php echo lang("abdi.alert_5") ?>");
- break;
- case "INV-OK" :
- var frmObjArr = serialized.split("&"); //Pecah value dari variable serialized untuk mendapatkan id invoice
- var idInvoiceArr = frmObjArr[3].split("="); //Pecah lagi dengan splitter string '='
- var idInvoice = idInvoiceArr[1];
- window.open("<?php echo $this->configlib->site_url(); ?>/customer/invoice/print_invoice/" + idInvoice,"Invoice");
- alert("<?php echo lang("abdi.alert_9") ?>");
- break;
- case "INV-OK-EDIT":
- var tanya = confirm("Data Succesfully Saved, Print Invoice ?");
- if(tanya)
- {
- window.open("<?php echo $this->configlib->site_url(); ?>/customer/invoice/print_invoice/" + dataParsed[1],"Invoice");
- }
- break;
- case "U-XSIST" :
- alert("<?php echo lang("abdi.alert_9") ?>");
- break;
- case "aud_error" : // Audiogram
- //alert("<?php echo lang("abdi.alert_5") ?>");
- //add_elem("error_db",$obj_dest,data);
- $obj_dest= $('#frmAddAudiogram');
- $(".error_db").remove();
- $new_elem= '<div class="error_db"></div>';
- $obj_dest.prepend($new_elem);
- $(".error_db").html(dataParsed[1]);
- stat_dialog= false;
- break;
- default :
- alert("Error : " + data);
- break;
- }
- });
- //alert(stat_dialog);
- /*
- if( stat_dialog ){
- $(this).dialog("close");
- }
- */
- $("#dialog").dialog("close");
- $("#dialog").empty();
- $(this).dialog("close");
- }
- }else if( mockup == "marketing/sales" ){
- var records = $("#tblcart").getGridParam("records");
- if(records==0)
- {
- alert("<?php echo lang("abdi.alert_35") ?>")
- }else{
- var ask = confirm("<?php echo lang("abdi.alert_72") ?>");
- if(ask)
- {
- var IdKonsumen = $("#IdKonsumen").val();
- Diskon= $('#alldiscount').val(); // Diskon semua belanja
- Diskon2= Diskon;
- if( Diskon == '' || Diskon == undefined ){
- Diskon= 0;
- }
- Subtotal= $('#subtotal').val(); // SubTotal
- Total= $('#totalcart').val(); // Total Cart setelah diskon
- DP= $('#downpayment').val(); // DP
- typeDisc= $('#typeDisc').val(); // Type Discount
- isLunas= ( $('#pay').is(':checked') ) ? 1 : 0; // Lunas atau tidak
- IdPembayaran= $('#IdPembayaran option:selected').val();
- IdKlinik= $('#IdKlinik option:selected').val();
- //alert(IdPembayaran);
- varpost= { "IdKonsumen": IdKonsumen, "Diskon": Diskon, "Subtotal": Subtotal, "Total": Total,
- "DP": DP, "isLunas": isLunas, "IdPembayaran": IdPembayaran, "typeDisc": typeDisc,
- "IdKlinik": IdKlinik };
- $.post("<?php echo $this->configlib->site_url() ?>/marketing/sales/proceed_trans", varpost,
- function(data){
- if( data != "no-lunas" ){
- idInvoice= data;
- url_tujuan= "<?php echo $this->configlib->site_url(); ?>/customer/invoice/print_invoice/" +
- idInvoice;
- window.open(url_tujuan, "Invoice");
- /*
- $("#dialog").empty();
- $("#dialog").dialog("close");
- */
- }
- })
- }
- }
- }else{
- $("#dialog").parent().hide();
- url= "<?php echo $this->configlib->site_url(); ?>/" + modul + "/" + func + "/save/" + act;
- var fileopt = {
- url: url,
- success: function(data) {
- switch(data){
- case "1" :
- alert("<?php echo lang("abdi.alert_5") ?>");
- break;
- case "0" :
- alert("<?php echo lang("abdi.alert_4") ?> ");
- break;
- default :
- alert("Error : " + data);
- break;
- }
- $("#dialog").empty();
- $("#dialog").dialog("close");
- }
- }
- $("#frmAddKar").ajaxSubmit(fileopt);
- }
- }
- }
- }
-
- var modadd= modul + "/" + func;
- var regmodadd= /^(customer\/master|customer\/dashboard)$/;
- if( regmodadd.test(modadd) ){
- var theButton = {
- '<?php echo lang("abdi.simpan") ?>': theSave,
- '<?php echo lang("abdi.proceed") ?>': theSave,
- '<?php echo lang("abdi.cancel") ?>': function() {
- //$(this).empty();
- $(this).dialog('close');
- //$('#jqTable').trigger('reloadGrid');
- }
- }
- }else{
- var theButton = {
- '<?php echo lang("abdi.simpan") ?>': theSave,
- '<?php echo lang("abdi.cancel") ?>': function() {
- //$(this).empty();
- $(this).dialog('close');
- //$('#jqTable').trigger('reloadGrid');
- }
- }
- }
- var dialogOpt = modul + "/" + func;
- switch(dialogOpt)
- {
- case 'customer/master' :
- theWidth = 850;
- theHeight = 700;
- theTitle = "Add/Edit Customer Data";
- break;
- case 'customer/repair' :
- theWidth = 560;
- theHeight = 650;
- theTitle = "Form New Repair";
- break;
- case 'customer/shipment' :
- theWidth = 740;
- theHeight = 600;
- theTitle = "Add Delivery";
- break;
- case 'customer/invoice' :
- theWidth = 900;
- theHeight = "auto";
- theTitle = "Add/Edit Invoice";
- break;
- case 'marketing/product' :
- theWidth = 400;
- theHeight = 460;
- theTitle = "Add/Edit New Product";
- break;
- case 'calendar/calendar' :
- theWidth = 500;
- theHeight = 450;
- theTitle = "Add/Edit Booking";
- theButton = {
- Close : function(){
- $(this).dialog("close");
- }
- }
- break;
- case 'logistic/bo' :
- theWidth = 700;
- theHeight = 600;
- theTitle = "Branch Order - My Request";
- theButton = {
- Close : function(){
- $(this).dialog("close");
- }
- }
- break;
- case 'hrd/master' :
- theWidth = 750;
- theHeight = "auto";
- theTitle = "Add/Edit Employees";
- break;
- case 'marketing/vendor' :
- theWidth = 400;
- theHeight = 500;
- theTitle = "Add/Edit Vendor";
- break;
- case 'logistic/product_deliver' :
- theWidth = 600;
- theHeight = 530;
- theTitle = "Add/Edit Branch Delivery";
- break;
- case 'logistic/product_receive' :
- theWidth = 800;
- theHeight = 400;
- theTitle = "Add/Edit Branch Receive";
- break;
- case 'logistic/shipping_db' :
- theWidth = 500;
- theHeight = "auto";
- theTitle = "Add/Edit Shipping List";
- break;
- case 'customer/clinical' :
- theWidth = 600;
- theHeight = 700;
- theTitle = "Add/Edit Clinical Information";
- break;
- case 'customer/comment' :
- theWidth = 600;
- theHeight = 600;
- theTitle = "Add Comment Customer";
- break;
- case 'customer/area_difficulties' :
- theWidth = 600;
- theHeight = 600;
- theTitle = "Add Area of Difficulties";
- break;
- case 'customer/report_repair' :
- theTitle = "Select Branch"
- theWidth = 500;
- theHeight = "auto";
- theUrl = "<?php echo $this->configlib->site_url() . "/customer/report_repair/popup"; ?>";
- theButton = {
- "select and close" : function(){
- select_branch(); //Function ini ada di view vBrowseCabang
- $("#dialog").dialog("close");
- }
- }
- break;
- case 'settings/account' :
- theWidth = 480;
- theHeight = 440;
- theTitle = "Add/Edit User Account";
- break;
- case 'marketing/mediatype' :
- theWidth = 500;
- theHeight = 'auto';
- theTitle = "Add/Edit Media Type";
- break;
- case 'marketing/mediacat' :
- theWidth = 500;
- theHeight = 'auto';
- theTitle = "Add/Edit Media Category";
- break;
- case 'marketing/media' :
- theWidth = 500;
- theHeight = 'auto';
- theTitle = "Add/Edit Media";
- break;
- case 'marketing/mediaiklan' :
- theWidth = 500;
- theHeight = 'auto';
- theTitle = "Add/Edit Campaign";
- break;
- case 'marketing/event' :
- theWidth = 500;
- theHeight = 600;
- theTitle = "Add/Edit Event";
- break;
- case 'logistic/stock' :
- theWidth = 500;
- theHeight = 600;
- theTitle = "Add/Edit Stock";
- break;
- case 'customer/religion' :
- theWidth = 450;
- theHeight = 250;
- theTitle = "Add/Edit Religion";
- break;
- case 'settings/klinik' :
- theWidth = 450;
- theHeight = 'auto';
- theTitle = "Add/Edit Clinic";
- break;
- case 'customer/family' :
- theWidth = 450;
- theHeight = 250;
- theTitle = "Add/Edit Family";
- break;
- case 'customer/country' :
- theWidth = 500;
- theHeight = "auto";
- theTitle = "Add/Edit Country";
- break;
- case 'customer/region' :
- theWidth = 500;
- theHeight = "auto";
- theTitle = "Add/Edit Region";
- break;
- case 'customer/kota' :
- theWidth = 500;
- theHeight = "auto";
- theTitle = "Add/Edit City";
- break;
- case 'customer/sapaan' :
- theWidth = 450;
- theHeight = "auto";
- theTitle = "Add/Edit Salutation";
- break;
-
- case 'customer/pajak' :
- theWidth = 450;
- theHeight = "auto";
- theTitle = "Add/Edit Pajak";
- break;
- case 'hrd/department' :
- theWidth = 450;
- theHeight = "auto";
- theTitle = "Add/Edit Department";
- break;
- case 'hrd/leave_type' :
- theWidth = 450;
- theHeight = "auto";
- theTitle = "Add/Edit Leave Type";
- break;
- case 'hrd/assign_leave' :
- theWidth = 450;
- theHeight = "auto";
- theTitle = "Add/Edit Assign Leave";
- break;
- case "hrd/attendance" :
- theWidth = 400;
- theHeight = 400;
- theTitle = "Add Attendance Data";
- break;
- case 'hrd/occupation' :
- theWidth = 450;
- theHeight = "auto";
- theTitle = "Add/Edit Position";
- break;
- case 'customer/job' :
- theWidth = 450;
- theHeight = "auto";
- theTitle = "Add/Edit Occupation";
- break;
- case 'marketing/category' :
- theWidth = 450;
- theHeight = "auto";
- theTitle = "Add/Edit Product Category";
- break;
- case 'marketing/service' :
- theWidth = 450;
- theHeight = "auto";
- theTitle = "Add/Edit Service";
- break;
- case 'marketing/portfolio_product' :
- theWidth = 450;
- theHeight = "auto";
- theTitle = "Add/Edit Portfolio Product";
- break;
- case 'settings/user_akses' :
- theWidth = 450;
- theHeight = "auto";
- theTitle = "Add/Edit User Access";
- break;
- case 'settings/user_modul' :
- theWidth = 450;
- theHeight = "auto";
- theTitle = "Add/Edit User Modul";
- break;
- case 'master/user_hak_akses' :
- theWidth = 500;
- theHeight = "auto";
- theTitle = "Add/Edit User Privilege Access";
- break;
- case 'customer/dokter_referal' :
- theWidth = 500;
- theHeight = "auto";
- theTitle = "Add/Edit Doctor Referal";
- break;
- case 'logistic/inventory' :
- theWidth = 500;
- theHeight = 300;
- theTitle = "Add/Edit inventory";
- break;
- case 'marketing/sales' :
- theWidth = 900;
- theHeight = "auto";
- theTitle = "Add/Edit Sales Transaction";
- /*
- theButton = {
- "Save" : function
- "Cancel" : function(){
- $(this).dialog("close");
- }
- }
- */
- break;
- default :
- return;
- }
-
- $("#dialog").dialog({
- title : theTitle,
- width: theWidth,
- height: theHeight,
- modal: true,
- show : "blind",
- hide : "blind",
- position: "top",
- buttons: theButton
- ,
- close: function() {
- $(this).dialog("destroy");
- $(this).empty();
- var regmodtrig= /^(customer\/master)$/;
- //console.log(modadd);
- if( ! regmodtrig.test(modadd) ){
- //console.log('me');
- $('#jqTable').trigger('reloadGrid');
- }
- },
- open : function()
- {
- $(this).append("<center><span><img src='<?php echo $this->config->item("img_url") ?>/dialogload.gif' /></span><br /><?php echo lang("abdi.alert_21") ?> ....</center>");
- $(this).load(theUrl);
- }
- });
- }
-
- function jDelete(id)
- {
- modul= '<?php echo $this->uri->segment(2); ?>';
- subModul= '<?php echo $this->uri->segment(3); ?>';
- var ctrl = "<?php echo $this->uri->segment(2) . '/' . $this->uri->segment(3) ?>";
- switch(ctrl)
- {
- case 'marketing/product' :
- var MataUang = $("#" + id + " td:nth-child(5)").text();
- var varToPost = {"id":id,"MataUang": MataUang};
- break;
- default :
- var varToPost = {"id":encodeURIComponent(id)};
- break;
- }
- var ask = confirm("<?php echo lang("abdi.alert_10") ?> : " + id + ", <?php echo lang("abdi.alert_11") ?> ?");
- if(ask)
- {
- $.post("<?php echo $this->configlib->site_url() . "/" . $this->uri->segment(2) . "/" . $this->uri->segment(3); ?>/delete/",varToPost,function(data){
- switch(data)
- {
- case "1" :
- alert("<?php echo lang("abdi.alert_12") ?>");
- regmod= /^(customer\/master)$/;
- if( ! regmod.test(ctrl) ){
- $('#jqTable').trigger('reloadGrid');
- }else{
- $('#jqTable tr[id=' + id + ']').remove();
- }
- break;
- case "0" :
- alert("<?php echo lang("abdi.alert_13") ?>");
- $('#jqTable').trigger('reloadGrid');
- break;
- case "2" :
- alert("<?php echo lang("abdi.alert_14") ?>");
- $('#jqTable').trigger('reloadGrid');
- break;
- default :
- alert(data);
- break;
- }
- });
- }
- }
- </script>