PageRenderTime 52ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/application/views/js_init/js_common2.php

https://bitbucket.org/remobius/crm
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
  1. <script>
  2. /* Cek nilai field is number */
  3. function is_number(){
  4. var passed= true;
  5. $(".is_number").each(function(){
  6. if( isNaN($(this).val()) == true ){
  7. $(this).css("backgroundColor","white");
  8. $(this).css("color","black");
  9. passed= false;
  10. $(this).css("backgroundColor","#f15c32");
  11. $(this).css("color","white");
  12. }
  13. });
  14. if( passed == false ){
  15. alert("<?php echo lang("abdi.alert_2") ?>"); //Nilai Salah
  16. }
  17. return passed;
  18. }
  19. /* DIGUNAKAN UNTUK CHECK PASSWORD PADA FORM ACCOUNT */
  20. function match_password(){
  21. password1= $('#Password').val();
  22. password2= $('#Password2').val();
  23. if( password1 == password2 ){
  24. return true;
  25. }else{
  26. alert("<?php echo lang("abdi.alert_18") ?>");
  27. return false;
  28. }
  29. }
  30. /* DIGUNAKAN UNTUK CHECK EMAIL PADA FORM ACCOUNT */
  31. function is_email(){
  32. email= $('#Email').val();
  33. var regexp= /^[a-z0-9\_\.]+[@]{1}[a-z]+\.[a-z]+$/;
  34. if( regexp.test(email) ){
  35. return true;
  36. }else{
  37. alert("<?php echo lang("abdi.alert_19") ?>");
  38. return false;
  39. }
  40. }
  41. function newKonsumenDetail(id)
  42. {
  43. $("#dialog4").dialog({
  44. title : '<?php echo lang("abdi.summary_information_detail") ?>',
  45. width: 'auto',
  46. height: 700,
  47. modal: true,
  48. show : "blind",
  49. hide : "blind",
  50. position: [200,0],
  51. buttons: {
  52. '<?php echo lang("abdi.close") ?>' : function(){
  53. $(this).dialog('close');
  54. }
  55. },
  56. close: function() {
  57. $(this).empty();
  58. $('#jqTable').trigger('reloadGrid');
  59. },
  60. open : function()
  61. {
  62. $(this).append("<center><span><img src='<?php echo $this->config->item("img_url") ?>/dialogload.gif' /></span><br /><?php echo lang("abdi.alert_21") ?> ....</center>");
  63. $(this).load("<?php echo $this->configlib->site_url() ?>/customer/dashboard/view_detail/" + id);
  64. }
  65. });
  66. //$("#dialog4").dialog("open");
  67. }
  68. function getDetail(id)
  69. {
  70. $("#dialog").dialog({
  71. title : '<?php echo lang("abdi.summary_information_detail") ?>',
  72. width: 900,
  73. height: 700,
  74. modal: true,
  75. show : "blind",
  76. hide : "blind",
  77. buttons: {
  78. '<?php echo lang("abdi.close") ?>' : function(){
  79. $(this).dialog('close');
  80. }
  81. },
  82. close: function() {
  83. $(this).empty();
  84. //$('#jqTable').trigger('reloadGrid');
  85. },
  86. open : function()
  87. {
  88. $(this).append("<center><span><img src='<?php echo $this->config->item("img_url") ?>/dialogload.gif' /></span><br /><?php echo lang("abdi.alert_21") ?> ....</center>");
  89. $(this).load("<?php echo $this->configlib->site_url() ?>/customer/dashboard/view_detail/" + id);
  90. }
  91. });
  92. //$('#dialog').load("<?php echo $this->configlib->site_url() ?>/customer/dashboard/view_detail/" + id);
  93. }
  94. /*
  95. ( function($){
  96. $('#fbox_jqTable_search').click( function(){
  97. alert("true");
  98. return false;
  99. });
  100. })(jQuery);
  101. */
  102. $(function(){
  103. /*
  104. var arrFrm = new Array("frmAddCus","frmAddOther"); //Untuk Customer Master aja
  105. initDialog("add","",arrFrm);
  106. $("#dialog").dialog("open");
  107. initDialog("add","","");
  108. $("#dialog").dialog("open");
  109. */
  110. /*
  111. getDetail('02001000000019');
  112. $("#dialog").dialog("open");
  113. */
  114. /*
  115. // Untuk Popup otomatis
  116. var arrFrm = new Array("frmAddCus","frmAddOther"); //Untuk Customer Master aja
  117. initDialog("add","",arrFrm);
  118. $("#dialog").dialog("open");
  119. */
  120. /*
  121. var arrFrm = new Array("frmAddCus","frmAddOther");
  122. initDialog("add","",arrFrm);
  123. $("#dialog").dialog("open");
  124. id= "02001000000543";
  125. var arrFrm = new Array("frmAddCus","frmAddOther");
  126. initDialog("edit", id, arrFrm);
  127. $("#dialog").dialog("open");
  128. */
  129. /*
  130. var arrFrm = new Array("frmAddCus","frmAddOther");
  131. initDialog("add","",arrFrm);
  132. $("#dialog").dialog("open");
  133. initDialog("add","","");
  134. $("#dialog").dialog("open");
  135. id= "INV-02001-0911-52";
  136. initDialog("edit",id,"");
  137. $("#cusDialog").dialog("open");
  138. */
  139. //
  140. /*
  141. $('#jqTable_TanggalLahir').remove();
  142. $("#jqTable tr").hide();
  143. */
  144. /* Menu untuk Klik Kanan View Detail */
  145. $('#jqTable').bind('contextmenu',function(e){
  146. var id= $('#jqTable').jqGrid('getGridParam','selrow');
  147. if( id != null ){
  148. $('<div class="overlay">&nbsp;</div>').appendTo(document.body)
  149. .bind('contextmenu', function(overlay){
  150. return false;
  151. });
  152. $('#menu_detail').css({ left: e.pageX, top: e.pageY }).show();
  153. }
  154. return false;
  155. });
  156. $('.overlay').live('click', function(){
  157. $(this).remove();
  158. $('#menu_detail').hide();
  159. });
  160. $('#menu_detail a[href=#view_detail]').click( function(){
  161. var id= $('#jqTable').jqGrid('getGridParam','selrow');
  162. getDetail(id);
  163. $("#dialog").dialog("open");
  164. $('.overlay').remove();
  165. $('#menu_detail').hide();
  166. });
  167. /* Akhir Menu Klik Kanan */
  168. $('#btnCari').click( function(){
  169. /*
  170. var url= '<?php echo $this->configlib->site_url(); ?>' + '/' + modul + '/' + subModul + '/xml';
  171. $("#jqTable").jqGrid('setGridParam', { url: url });
  172. $("#jqTable").trigger("reloadGrid");
  173. console.log( $('tr#02007000000396').text() );
  174. $('tr#02007000000396').remove();
  175. grid= $("#jqTable");
  176. filterparams= '{"groupOp":"AND","rules":[{"field":"IdKonsumen","op":"eq","data":""}],"groups":[]}';
  177. grid.jqGrid('setGridParam',{search: true});
  178. var postData = grid.jqGrid('getGridParam','postData');
  179. $.extend(postData,{filters:filterparams});
  180. grid.trigger("reloadGrid",[{page:1}]);
  181. */
  182. modul= '<?php echo $this->uri->segment(2); ?>';
  183. subModul= '<?php echo $this->uri->segment(3); ?>';
  184. console.log(modul + "->" + subModul);
  185. var url= '<?php echo $this->configlib->site_url(); ?>' + '/' + modul + '/' + subModul + '/xml';
  186. $("#jqTable").jqGrid('setGridParam', { url: url });
  187. //$("#jqTable").trigger("reloadGrid");
  188. $("#jqTable").jqGrid('searchGrid', { multipleSearch: true, overlay: true,
  189. sopt:['cn','bw','eq','ne','lt','gt','ew'], onClose:function(){
  190. var grid = $("#jqTable");
  191. grid.jqGrid('setGridParam', { search:false } );
  192. }});
  193. $btnreset= '<td class="EditButton" style="text-align:left">' +
  194. '<a class="fm-button ui-state-default ui-corner-all fm-button-icon-left' +
  195. ' ui-search" id="fbox_jqTable_reset_new">' +
  196. '<span class="ui-icon ui-icon-arrowreturnthick-1-w"></span>Reset</a></td>';
  197. if( $('#fbox_jqTable_2 tr:eq(1)').find('#fbox_jqTable_reset_new').length == 0 ){
  198. $('#fbox_jqTable_2 tr:eq(1)').prepend($btnreset);
  199. $('#fbox_jqTable_reset').parent().remove();
  200. }
  201. });
  202. $('#fbox_jqTable_reset_new').live('click', function(){
  203. var url= '<?php echo $this->configlib->site_url(); ?>' + '/' + modul + '/' + subModul + '/xml';
  204. $("#jqTable").jqGrid('setGridParam', { url: url });
  205. $("#jqTable").trigger("reloadGrid");
  206. grid= $("#jqTable");
  207. filterparams= '{"groupOp":"AND","rules":[{"field":"IdKonsumen","op":"eq","data":""}],"groups":[]}';
  208. grid.jqGrid('setGridParam',{search: true});
  209. var postData = grid.jqGrid('getGridParam','postData');
  210. $.extend(postData,{filters:filterparams});
  211. grid.trigger("reloadGrid",[{page:1}]);
  212. });
  213. /*
  214. getDetail('02007000000468');
  215. $("#dialog").dialog("open");
  216. */
  217. $("#btnCustDetail")
  218. .click(function(){
  219. var id = $('#jqTable').jqGrid('getGridParam','selrow');
  220. if(id!=null)
  221. {
  222. getDetail(id);
  223. $("#dialog").dialog("open");
  224. }else{
  225. alert("<?php echo lang("abdi.alert_20") ?>");
  226. }
  227. })
  228. var Modme= '<?php echo $this->uri->segment("2"); ?>';
  229. var Funcme= '<?php echo $this->uri->segment("3"); ?>';
  230. $('#btnCusHistory,#btnJobHistory').click( function(e){
  231. UriMod= Modme+"/"+Funcme;
  232. regmodule= /^(customer\/history)$/;
  233. id = $('#jqTable').jqGrid('getGridParam','selrow');
  234. if( id != null ){
  235. if( e.target.id == "btnJobHistory" ){
  236. var UrlHistory= "<?php echo $this->configlib->site_url(); ?>/customer/jobcard_history/get/" +
  237. encodeURIComponent(id);
  238. window.open(UrlHistory);
  239. }else{
  240. if( regmodule.test(UriMod) ){
  241. var UrlHistory= "<?php echo $this->configlib->site_url(); ?>/customer/repair/purchase_history/" +
  242. encodeURIComponent(id);
  243. window.open(UrlHistory);
  244. }else{
  245. Idcustomer= $('tr#'+ id + ' td:eq(2)').attr('title');
  246. var UrlHistory= "<?php echo $this->configlib->site_url(); ?>/customer/repair/purchase_history/" +
  247. encodeURIComponent(Idcustomer);
  248. window.open(UrlHistory);
  249. }
  250. }
  251. }else{
  252. alert("<?php echo lang("abdi.alert_20") ?>");
  253. }
  254. });
  255. //Function when add button clicked
  256. var modul = "<?php echo $this->uri->segment(2); ?>";
  257. var subModul = "<?php echo $this->uri->segment(3); ?>";
  258. var modadd= modul + '/' + subModul;
  259. var IdAkses= '<?php echo $this->session->userdata('idAkses'); ?>';
  260. //var regmodadd= new RegExp("^(customer\/master|customer\/dashboard)$"); // Cara 1
  261. var regmodadd= /^(customer\/master|customer\/dashboard)$/; // Cara 2
  262. if( regmodadd.test(modadd) ) // Url customer/master atau customer/dashboard
  263. {
  264. //MGR sma MEX variable regakses gx ada yg make jadi gx masalah
  265. regakses= /^(CST|MGR|MEX|DPS)$/;
  266. if( regakses.test(IdAkses) ){
  267. regedit= /^(MGR|MEX|DPS)$/;
  268. if( regedit.test(IdAkses) ){
  269. // MGR dan MEX
  270. $('img[src*=delete_disable]').remove();
  271. }else{
  272. // CST
  273. $('img[src*=delete_disable], a img#btnEdit').remove();
  274. }
  275. }
  276. //Function when edit button clicked
  277. $("img#btnEdit").click(function(){
  278. var id = $('#jqTable').jqGrid('getGridParam','selrow');
  279. if(id == null)
  280. {
  281. alert("<?php echo lang("abdi.alert_20") ?>");
  282. }else{
  283. var arrFrm = new Array("frmAddCus","frmAddOther");
  284. initDialog("edit", id, arrFrm);
  285. $("#dialog").dialog("open");
  286. }
  287. })
  288. $("img#btnAdd").click(function(){
  289. var arrFrm = new Array("frmAddCus","frmAddOther");
  290. initDialog("add","",arrFrm);
  291. $("#dialog").dialog("open");
  292. });
  293. }else{
  294. $("img#btnAdd").click(function(){ //Defaut for submitting just one form in one time
  295. //alert("test");
  296. initDialog("add","","");
  297. $("#dialog").dialog("open");
  298. });
  299. $("img#btnEdit").click(function(){
  300. var id = $('#jqTable').jqGrid('getGridParam','selrow');
  301. if(id == null)
  302. {
  303. alert("<?php echo lang("abdi.alert_20") ?>");
  304. }else{
  305. if( modadd == "customer/invoice" ){ // Open Dialog jika Url customer/invoice
  306. status= $('#' + id + ' td:eq(7)').text();
  307. status= status.toLowerCase();
  308. if( status == "not fully paid" ){
  309. initDialog("edit",id,"");
  310. }
  311. }else{
  312. initDialog("edit",id,"");
  313. }
  314. //$("#cusDialog").dialog("open");
  315. }
  316. })
  317. }
  318. var regcusmaster= /^(customer\/master)$/;
  319. if( regmodadd.test(modadd) ) // Modify jqgrid dari customer/master
  320. {
  321. /*
  322. content= $('#jqgh_TanggalLahir').html();
  323. content= content.replace(/Tanggal Lahir/i, "");
  324. $('#jqgh_TanggalLahir').html(content);
  325. console.log(content);
  326. */
  327. <?php #echo $this->configlib->site_url() . '/' . modul . '/' . subModul . '/xml'; ?>
  328. var url= '<?php echo $this->configlib->site_url(); ?>' + '/' + modul + '/' + subModul + '/xml';
  329. $("#jqTable").jqGrid('setGridParam', { url: url });
  330. $('#refresh_jqTable,#search_jqTable').remove();
  331. $('.ui-jqgrid-sortable').click( function(){
  332. return false;
  333. });
  334. }
  335. //Function when delete button clicked
  336. $("img#btnDel").click(function(){
  337. var id = $('#jqTable').jqGrid('getGridParam','selrow');
  338. if(id == null)
  339. {
  340. alert("<?php echo lang("abdi.alert_20") ?>");
  341. }else{
  342. jDelete(id);
  343. }
  344. })
  345. //Init tipsy
  346. var regmodul= /^(audiogram|upload|report)$/;
  347. Modul='<?php echo $this->uri->segment(3); ?>';
  348. if( ! regmodul.test(Modul) ){
  349. $('#btnAdd, #btnEdit, #btnDel, #btnPrint, #btnExcel, img#btnDetail, #btnArrival, #btnCusHistory, #btnJobHistory, #btnCari,#btnLastVisit').tipsy({gravity: 'sw', fade: true});
  350. }
  351. })
  352. function jqGridSelected(obj,id)
  353. {
  354. $("#hiddenID").val(id);
  355. }
  356. function required(ignore)
  357. {
  358. var passed = true;
  359. $(".required").each(function(){
  360. if($.trim($(this).val())=="")
  361. {
  362. passed = false;
  363. $(this).css("backgroundColor","#f15c32");
  364. $(this).css("color","white");
  365. }
  366. });
  367. if(passed==false)
  368. {
  369. if(ignore==false)
  370. {
  371. alert("<?php echo lang("abdi.alert_3") ?>"); //Data Ga boleh kosong
  372. }
  373. return false;
  374. }else{
  375. return true;
  376. }
  377. }
  378. function confirmed()
  379. {
  380. if(required(false))
  381. {
  382. var passed = true;
  383. $(".confirmed").each(function(){
  384. if($.trim($(this).val())=="")
  385. {
  386. passed = false;
  387. $(this).css("backgroundColor","yellow");
  388. }
  389. });
  390. if(passed==false)
  391. {
  392. var ask = confirm("<?php echo lang("abdi.alert_6") ?>"); //Mengabaikan Beberapa Fields
  393. if(ask)
  394. {
  395. return true;
  396. }else{
  397. return false;
  398. }
  399. }else{
  400. return true;
  401. }
  402. }else{
  403. return true;
  404. }
  405. }
  406. function initDialog(act,id,frmID)
  407. {
  408. var isArray = false;
  409. var modul = '<?php echo $this->uri->segment("2"); ?>';
  410. var func = '<?php echo $this->uri->segment("3"); ?>';
  411. theUrl = "<?php echo $this->configlib->site_url(); ?>/" + modul + "/" + func + "/popup/" + act + "/" + encodeURIComponent(id);
  412. theSave = function(e){
  413. if(frmID.length==2)
  414. {
  415. isArray=true;
  416. var serial = new Array($("#" + frmID[0]).serialize(),$("#" + frmID[1]).serialize());
  417. }
  418. if(isArray) //Notice : this function is only submitted two form in same time
  419. {
  420. var allowBlank = confirmed();
  421. var mustFilled = required();
  422. if( allowBlank && mustFilled )
  423. {
  424. var success= true;
  425. var i= 0;
  426. //var idkonsumen= $('#IdKonsumen').val();
  427. data= new Array();
  428. regmodul= /^(customer)$/;
  429. if( regmodul.test(modul) ){
  430. $.post("<?php echo $this->configlib->site_url(); ?>/" + modul + "/master/save/" + act,serial[0],
  431. function(data){
  432. data= data.split(",");
  433. switch(data[0])
  434. {
  435. case "IdKonsumen":
  436. $("#IdKonsumen").val(data[1]);
  437. var idkonsumen= $('#IdKonsumen').val();
  438. $.post("<?php echo $this->configlib->site_url(); ?>/" + modul +
  439. "/master/save/" + act, $("#" + frmID[1]).serialize(),
  440. function(data){
  441. switch(data)
  442. {
  443. case "1" :
  444. success = true;
  445. $("img#imgLoad").show();
  446. break;
  447. case "0" :
  448. success = false;
  449. var msg = "<?php echo lang("abdi.alert_4") ?>"; //Data Gagal Simpan
  450. break;
  451. case "-1" :
  452. success = false;
  453. //Error Hanya Pada Data yg Di save aja
  454. var msg = "<?php echo lang("abdi.alert_7") ?>";
  455. break;
  456. default :
  457. var msg = "Error : " + data;
  458. success = false;
  459. break;
  460. }
  461. if( success==false ){
  462. alert(msg);
  463. }
  464. if( success==true ){
  465. alert("<?php echo lang("abdi.alert_5") ?>") //Data Berhasil Disimpan
  466. elname= $(e.target).text();
  467. }
  468. //$("#dialog").dialog("<img src='<?php echo $this->config->item("img_url") ?>/dialog.gif' />");
  469. $("img#imgLoad").show();
  470. $("#dialog").dialog("close");
  471. var modadd= modul + "/" + func;
  472. var regmodadd= /^(customer\/master|customer\/dashboard)$/;
  473. var regbtnname= /^(Proceed|Proses)$/;
  474. if( regmodadd.test(modadd) && regbtnname.test(elname) ){
  475. newKonsumenDetail(idkonsumen);
  476. //newKonsumenDetail('020010006');
  477. }else{
  478. //console.log("customer");
  479. var url= '<?php echo $this->configlib->site_url(); ?>' +
  480. '/' + modadd + '/xml/newcus/' + idkonsumen;
  481. $("#jqTable").jqGrid('setGridParam', { url: url });
  482. $("#jqTable").trigger("reloadGrid");
  483. }
  484. });
  485. break;
  486. case "1" :
  487. success = true;
  488. break;
  489. case "0" :
  490. success = false;
  491. var msg = "<?php echo lang("abdi.alert_4") ?>"; //Data Gagal Simpan
  492. break;
  493. case "-1" :
  494. success = false;
  495. var msg = "<?php echo lang("abdi.alert_7") ?>"; //Error Hanya Pada Data yg Di save aja
  496. break;
  497. default :
  498. var msg = "Error : " + data;
  499. success = false;
  500. break;
  501. }
  502. });
  503. }else{
  504. while(i<=1 && success==true )
  505. {
  506. /*
  507. $('#dialog').empty();
  508. $('#dialog').append("<center><span><img src='<?php echo $this->config->item("img_url") ?>/dialogload.gif' /><br />Sending Form "+i+1+"</span></center>");
  509. */
  510. $.post("<?php echo $this->configlib->site_url(); ?>/" + modul + "/master/save/" +
  511. act,serial[i],
  512. function(data){
  513. data= data.split(",");
  514. switch(data[0])
  515. {
  516. case "1" :
  517. success = true;
  518. break;
  519. case "0" :
  520. success = false;
  521. var msg = "<?php echo lang("abdi.alert_4") ?>"; //Data Gagal Simpan
  522. break;
  523. case "-1" :
  524. success = false;
  525. var msg = "<?php echo lang("abdi.alert_7") ?>"; //Error Hanya Pada Data yg Di save aja
  526. break;
  527. default :
  528. var msg = "Error : " + data;
  529. success = false;
  530. break;
  531. }
  532. });
  533. i = i +1;
  534. if( success==false ){
  535. alert(msg);
  536. }
  537. if( success==true ){
  538. alert("<?php echo lang("abdi.alert_5") ?>") //Data Berhasil Disimpan
  539. elname= $(e.target).text();
  540. }
  541. $(this).dialog("close");
  542. var modadd= modul + "/" + func;
  543. var regmodadd= /^(customer\/master|customer\/dashboard)$/;
  544. if( regmodadd.test(modadd) && elname == "Proceed"){
  545. newKonsumenDetail(idkonsumen);
  546. //newKonsumenDetail('020010006');
  547. }
  548. }
  549. }
  550. }
  551. }else{
  552. if(frmID=="")
  553. frmID = $("#frmID").val(); //Get the form name to be serialized
  554. var serialized = $("#" + frmID).serialize();
  555. var allowBlank = confirmed();
  556. //var mustFilled = true;
  557. var mustFilled = required();
  558. /* Pengecekan tambahan untuk test password sama dan email pada Form frmAddAcc */
  559. /* -------------------------------------------------------------------------- */
  560. if( frmID=="frmAddAcc"){
  561. if( act=="add" ){
  562. mustFilled= match_password();
  563. if( mustFilled == true ){
  564. mustFilled = is_email();
  565. }
  566. }else{
  567. mustFilled= is_email();
  568. }
  569. }
  570. //Pengecekan tambahan untuk authorization add new repair
  571. if(frmID=="frmAddRepair")
  572. {
  573. var printRepairReceipt = false;
  574. switch($("#Authorization").val())
  575. {
  576. case "c" :
  577. //JIka user memilih cost estimate
  578. printRepairReceipt = true;
  579. alert("<?php echo lang("abdi.alert_42") ?>");
  580. break;
  581. default :
  582. //JIka user memilih immediate repair atau cost estimate if rep over
  583. //JIka nilai DP kecil dari Rp. 50.000
  584. if($("#DP").val()<50000)
  585. {
  586. alert("<?php echo lang("abdi.alert_43") ?>")
  587. $("#DP").focus();
  588. }else{
  589. printRepairReceipt = true;
  590. }
  591. break;
  592. }
  593. }else{
  594. var printRepairReceipt = true;
  595. }
  596. /*---------------------------------------------------------*/
  597. //var serialized = $("#" + frmID).serialize();
  598. var field_number= is_number();
  599. if(allowBlank && mustFilled && field_number && printRepairReceipt)
  600. {
  601. mockup='<?php echo $this->uri->segment(2) . "/" . $this->uri->segment(3); ?>';
  602. mockreg= /^(hrd\/master|marketing\/sales)$/;
  603. if( ! mockreg.test(mockup) ){
  604. grant_edit= $('#grant_edit').val();
  605. if( mockup == "customer/invoice" && grant_edit != "on" ){
  606. alert("Press F5 to enter your supervise key !");
  607. }else{
  608. /*
  609. $(this).empty();
  610. $(this).append("<center><span><img src='<?php echo $this->config->item("img_url") ?>/dialogload.gif' /><br /><?php echo lang("abdi.alert_21") ?> ....</span></center>");
  611. */
  612. var stat_dialog= true;
  613. $.post("<?php echo $this->configlib->site_url(); ?>/" + modul + "/" + func + "/save/" + act,serialized,
  614. function(data){
  615. dataParsed = data.split("~");
  616. switch(dataParsed[0])
  617. {
  618. case "1" :
  619. alert("<?php echo lang("abdi.alert_5") ?>");
  620. break;
  621. case "0" :
  622. alert("<?php echo lang("abdi.alert_4") ?> ");
  623. break;
  624. case "-1" :
  625. alert("<?php echo lang("abdi.alert_7") ?> ");
  626. break;
  627. case "R-OK" : //Print receipt for added repair
  628. alert("<?php echo lang("abdi.alert_5") ?>");
  629. var frmObjArr = serialized.split("&"); //Pecah value dari variable serialized untuk mendapatkan id repair
  630. var idRepairArr = frmObjArr[1].split("="); //Pecah lagi dengan splitter string '='
  631. var idRepair = idRepairArr[1];
  632. window.open("<?php echo $this->configlib->site_url(); ?>/customer/repair/print_receipt/" + idRepair,"Repair Receipt");
  633. alert("<?php echo lang("abdi.alert_8") ?>");
  634. break;
  635. case "R-OK-NORECEIPT" :
  636. alert("<?php echo lang("abdi.alert_5") ?>");
  637. break;
  638. case "S-OK" : //Print shipment
  639. var frmObjArr = serialized.split("&"); //Pecah value dari variable serialized untuk mendapatkan id shipment
  640. var idShipmentArr = frmObjArr[1].split("="); //Pecah lagi dengan splitter string '='
  641. var IdShipment = idShipmentArr[1];
  642. alert("<?php echo lang("abdi.alert_5") ?>");
  643. break;
  644. case "INV-OK" :
  645. var frmObjArr = serialized.split("&"); //Pecah value dari variable serialized untuk mendapatkan id invoice
  646. var idInvoiceArr = frmObjArr[3].split("="); //Pecah lagi dengan splitter string '='
  647. var idInvoice = idInvoiceArr[1];
  648. window.open("<?php echo $this->configlib->site_url(); ?>/customer/invoice/print_invoice/" + idInvoice,"Invoice");
  649. alert("<?php echo lang("abdi.alert_9") ?>");
  650. break;
  651. case "INV-OK-EDIT":
  652. var tanya = confirm("Data Succesfully Saved, Print Invoice ?");
  653. if(tanya)
  654. {
  655. window.open("<?php echo $this->configlib->site_url(); ?>/customer/invoice/print_invoice/" + dataParsed[1],"Invoice");
  656. }
  657. break;
  658. case "U-XSIST" :
  659. alert("<?php echo lang("abdi.alert_9") ?>");
  660. break;
  661. case "aud_error" : // Audiogram
  662. //alert("<?php echo lang("abdi.alert_5") ?>");
  663. //add_elem("error_db",$obj_dest,data);
  664. $obj_dest= $('#frmAddAudiogram');
  665. $(".error_db").remove();
  666. $new_elem= '<div class="error_db"></div>';
  667. $obj_dest.prepend($new_elem);
  668. $(".error_db").html(dataParsed[1]);
  669. stat_dialog= false;
  670. break;
  671. default :
  672. alert("Error : " + data);
  673. break;
  674. }
  675. });
  676. //alert(stat_dialog);
  677. /*
  678. if( stat_dialog ){
  679. $(this).dialog("close");
  680. }
  681. */
  682. $("#dialog").dialog("close");
  683. $("#dialog").empty();
  684. $(this).dialog("close");
  685. }
  686. }else if( mockup == "marketing/sales" ){
  687. var records = $("#tblcart").getGridParam("records");
  688. if(records==0)
  689. {
  690. alert("<?php echo lang("abdi.alert_35") ?>")
  691. }else{
  692. var ask = confirm("<?php echo lang("abdi.alert_72") ?>");
  693. if(ask)
  694. {
  695. var IdKonsumen = $("#IdKonsumen").val();
  696. Diskon= $('#alldiscount').val(); // Diskon semua belanja
  697. Diskon2= Diskon;
  698. if( Diskon == '' || Diskon == undefined ){
  699. Diskon= 0;
  700. }
  701. Subtotal= $('#subtotal').val(); // SubTotal
  702. Total= $('#totalcart').val(); // Total Cart setelah diskon
  703. DP= $('#downpayment').val(); // DP
  704. typeDisc= $('#typeDisc').val(); // Type Discount
  705. isLunas= ( $('#pay').is(':checked') ) ? 1 : 0; // Lunas atau tidak
  706. IdPembayaran= $('#IdPembayaran option:selected').val();
  707. IdKlinik= $('#IdKlinik option:selected').val();
  708. //alert(IdPembayaran);
  709. varpost= { "IdKonsumen": IdKonsumen, "Diskon": Diskon, "Subtotal": Subtotal, "Total": Total,
  710. "DP": DP, "isLunas": isLunas, "IdPembayaran": IdPembayaran, "typeDisc": typeDisc,
  711. "IdKlinik": IdKlinik };
  712. $.post("<?php echo $this->configlib->site_url() ?>/marketing/sales/proceed_trans", varpost,
  713. function(data){
  714. if( data != "no-lunas" ){
  715. idInvoice= data;
  716. url_tujuan= "<?php echo $this->configlib->site_url(); ?>/customer/invoice/print_invoice/" +
  717. idInvoice;
  718. window.open(url_tujuan, "Invoice");
  719. /*
  720. $("#dialog").empty();
  721. $("#dialog").dialog("close");
  722. */
  723. }
  724. })
  725. }
  726. }
  727. }else{
  728. $("#dialog").parent().hide();
  729. url= "<?php echo $this->configlib->site_url(); ?>/" + modul + "/" + func + "/save/" + act;
  730. var fileopt = {
  731. url: url,
  732. success: function(data) {
  733. switch(data){
  734. case "1" :
  735. alert("<?php echo lang("abdi.alert_5") ?>");
  736. break;
  737. case "0" :
  738. alert("<?php echo lang("abdi.alert_4") ?> ");
  739. break;
  740. default :
  741. alert("Error : " + data);
  742. break;
  743. }
  744. $("#dialog").empty();
  745. $("#dialog").dialog("close");
  746. }
  747. }
  748. $("#frmAddKar").ajaxSubmit(fileopt);
  749. }
  750. }
  751. }
  752. }
  753. var modadd= modul + "/" + func;
  754. var regmodadd= /^(customer\/master|customer\/dashboard)$/;
  755. if( regmodadd.test(modadd) ){
  756. var theButton = {
  757. '<?php echo lang("abdi.simpan") ?>': theSave,
  758. '<?php echo lang("abdi.proceed") ?>': theSave,
  759. '<?php echo lang("abdi.cancel") ?>': function() {
  760. //$(this).empty();
  761. $(this).dialog('close');
  762. //$('#jqTable').trigger('reloadGrid');
  763. }
  764. }
  765. }else{
  766. var theButton = {
  767. '<?php echo lang("abdi.simpan") ?>': theSave,
  768. '<?php echo lang("abdi.cancel") ?>': function() {
  769. //$(this).empty();
  770. $(this).dialog('close');
  771. //$('#jqTable').trigger('reloadGrid');
  772. }
  773. }
  774. }
  775. var dialogOpt = modul + "/" + func;
  776. switch(dialogOpt)
  777. {
  778. case 'customer/master' :
  779. theWidth = 850;
  780. theHeight = 700;
  781. theTitle = "Add/Edit Customer Data";
  782. break;
  783. case 'customer/repair' :
  784. theWidth = 560;
  785. theHeight = 650;
  786. theTitle = "Form New Repair";
  787. break;
  788. case 'customer/shipment' :
  789. theWidth = 740;
  790. theHeight = 600;
  791. theTitle = "Add Delivery";
  792. break;
  793. case 'customer/invoice' :
  794. theWidth = 900;
  795. theHeight = "auto";
  796. theTitle = "Add/Edit Invoice";
  797. break;
  798. case 'marketing/product' :
  799. theWidth = 400;
  800. theHeight = 460;
  801. theTitle = "Add/Edit New Product";
  802. break;
  803. case 'calendar/calendar' :
  804. theWidth = 500;
  805. theHeight = 450;
  806. theTitle = "Add/Edit Booking";
  807. theButton = {
  808. Close : function(){
  809. $(this).dialog("close");
  810. }
  811. }
  812. break;
  813. case 'logistic/bo' :
  814. theWidth = 700;
  815. theHeight = 600;
  816. theTitle = "Branch Order - My Request";
  817. theButton = {
  818. Close : function(){
  819. $(this).dialog("close");
  820. }
  821. }
  822. break;
  823. case 'hrd/master' :
  824. theWidth = 750;
  825. theHeight = "auto";
  826. theTitle = "Add/Edit Employees";
  827. break;
  828. case 'marketing/vendor' :
  829. theWidth = 400;
  830. theHeight = 500;
  831. theTitle = "Add/Edit Vendor";
  832. break;
  833. case 'logistic/product_deliver' :
  834. theWidth = 600;
  835. theHeight = 530;
  836. theTitle = "Add/Edit Branch Delivery";
  837. break;
  838. case 'logistic/product_receive' :
  839. theWidth = 800;
  840. theHeight = 400;
  841. theTitle = "Add/Edit Branch Receive";
  842. break;
  843. case 'logistic/shipping_db' :
  844. theWidth = 500;
  845. theHeight = "auto";
  846. theTitle = "Add/Edit Shipping List";
  847. break;
  848. case 'customer/clinical' :
  849. theWidth = 600;
  850. theHeight = 700;
  851. theTitle = "Add/Edit Clinical Information";
  852. break;
  853. case 'customer/comment' :
  854. theWidth = 600;
  855. theHeight = 600;
  856. theTitle = "Add Comment Customer";
  857. break;
  858. case 'customer/area_difficulties' :
  859. theWidth = 600;
  860. theHeight = 600;
  861. theTitle = "Add Area of Difficulties";
  862. break;
  863. case 'customer/report_repair' :
  864. theTitle = "Select Branch"
  865. theWidth = 500;
  866. theHeight = "auto";
  867. theUrl = "<?php echo $this->configlib->site_url() . "/customer/report_repair/popup"; ?>";
  868. theButton = {
  869. "select and close" : function(){
  870. select_branch(); //Function ini ada di view vBrowseCabang
  871. $("#dialog").dialog("close");
  872. }
  873. }
  874. break;
  875. case 'settings/account' :
  876. theWidth = 480;
  877. theHeight = 440;
  878. theTitle = "Add/Edit User Account";
  879. break;
  880. case 'marketing/mediatype' :
  881. theWidth = 500;
  882. theHeight = 'auto';
  883. theTitle = "Add/Edit Media Type";
  884. break;
  885. case 'marketing/mediacat' :
  886. theWidth = 500;
  887. theHeight = 'auto';
  888. theTitle = "Add/Edit Media Category";
  889. break;
  890. case 'marketing/media' :
  891. theWidth = 500;
  892. theHeight = 'auto';
  893. theTitle = "Add/Edit Media";
  894. break;
  895. case 'marketing/mediaiklan' :
  896. theWidth = 500;
  897. theHeight = 'auto';
  898. theTitle = "Add/Edit Campaign";
  899. break;
  900. case 'marketing/event' :
  901. theWidth = 500;
  902. theHeight = 600;
  903. theTitle = "Add/Edit Event";
  904. break;
  905. case 'logistic/stock' :
  906. theWidth = 500;
  907. theHeight = 600;
  908. theTitle = "Add/Edit Stock";
  909. break;
  910. case 'customer/religion' :
  911. theWidth = 450;
  912. theHeight = 250;
  913. theTitle = "Add/Edit Religion";
  914. break;
  915. case 'settings/klinik' :
  916. theWidth = 450;
  917. theHeight = 'auto';
  918. theTitle = "Add/Edit Clinic";
  919. break;
  920. case 'customer/family' :
  921. theWidth = 450;
  922. theHeight = 250;
  923. theTitle = "Add/Edit Family";
  924. break;
  925. case 'customer/country' :
  926. theWidth = 500;
  927. theHeight = "auto";
  928. theTitle = "Add/Edit Country";
  929. break;
  930. case 'customer/region' :
  931. theWidth = 500;
  932. theHeight = "auto";
  933. theTitle = "Add/Edit Region";
  934. break;
  935. case 'customer/kota' :
  936. theWidth = 500;
  937. theHeight = "auto";
  938. theTitle = "Add/Edit City";
  939. break;
  940. case 'customer/sapaan' :
  941. theWidth = 450;
  942. theHeight = "auto";
  943. theTitle = "Add/Edit Salutation";
  944. break;
  945. case 'customer/pajak' :
  946. theWidth = 450;
  947. theHeight = "auto";
  948. theTitle = "Add/Edit Pajak";
  949. break;
  950. case 'hrd/department' :
  951. theWidth = 450;
  952. theHeight = "auto";
  953. theTitle = "Add/Edit Department";
  954. break;
  955. case 'hrd/leave_type' :
  956. theWidth = 450;
  957. theHeight = "auto";
  958. theTitle = "Add/Edit Leave Type";
  959. break;
  960. case 'hrd/assign_leave' :
  961. theWidth = 450;
  962. theHeight = "auto";
  963. theTitle = "Add/Edit Assign Leave";
  964. break;
  965. case "hrd/attendance" :
  966. theWidth = 400;
  967. theHeight = 400;
  968. theTitle = "Add Attendance Data";
  969. break;
  970. case 'hrd/occupation' :
  971. theWidth = 450;
  972. theHeight = "auto";
  973. theTitle = "Add/Edit Position";
  974. break;
  975. case 'customer/job' :
  976. theWidth = 450;
  977. theHeight = "auto";
  978. theTitle = "Add/Edit Occupation";
  979. break;
  980. case 'marketing/category' :
  981. theWidth = 450;
  982. theHeight = "auto";
  983. theTitle = "Add/Edit Product Category";
  984. break;
  985. case 'marketing/service' :
  986. theWidth = 450;
  987. theHeight = "auto";
  988. theTitle = "Add/Edit Service";
  989. break;
  990. case 'marketing/portfolio_product' :
  991. theWidth = 450;
  992. theHeight = "auto";
  993. theTitle = "Add/Edit Portfolio Product";
  994. break;
  995. case 'settings/user_akses' :
  996. theWidth = 450;
  997. theHeight = "auto";
  998. theTitle = "Add/Edit User Access";
  999. break;
  1000. case 'settings/user_modul' :
  1001. theWidth = 450;
  1002. theHeight = "auto";
  1003. theTitle = "Add/Edit User Modul";
  1004. break;
  1005. case 'master/user_hak_akses' :
  1006. theWidth = 500;
  1007. theHeight = "auto";
  1008. theTitle = "Add/Edit User Privilege Access";
  1009. break;
  1010. case 'customer/dokter_referal' :
  1011. theWidth = 500;
  1012. theHeight = "auto";
  1013. theTitle = "Add/Edit Doctor Referal";
  1014. break;
  1015. case 'logistic/inventory' :
  1016. theWidth = 500;
  1017. theHeight = 300;
  1018. theTitle = "Add/Edit inventory";
  1019. break;
  1020. case 'marketing/sales' :
  1021. theWidth = 900;
  1022. theHeight = "auto";
  1023. theTitle = "Add/Edit Sales Transaction";
  1024. /*
  1025. theButton = {
  1026. "Save" : function
  1027. "Cancel" : function(){
  1028. $(this).dialog("close");
  1029. }
  1030. }
  1031. */
  1032. break;
  1033. default :
  1034. return;
  1035. }
  1036. $("#dialog").dialog({
  1037. title : theTitle,
  1038. width: theWidth,
  1039. height: theHeight,
  1040. modal: true,
  1041. show : "blind",
  1042. hide : "blind",
  1043. position: "top",
  1044. buttons: theButton
  1045. ,
  1046. close: function() {
  1047. $(this).dialog("destroy");
  1048. $(this).empty();
  1049. var regmodtrig= /^(customer\/master)$/;
  1050. //console.log(modadd);
  1051. if( ! regmodtrig.test(modadd) ){
  1052. //console.log('me');
  1053. $('#jqTable').trigger('reloadGrid');
  1054. }
  1055. },
  1056. open : function()
  1057. {
  1058. $(this).append("<center><span><img src='<?php echo $this->config->item("img_url") ?>/dialogload.gif' /></span><br /><?php echo lang("abdi.alert_21") ?> ....</center>");
  1059. $(this).load(theUrl);
  1060. }
  1061. });
  1062. }
  1063. function jDelete(id)
  1064. {
  1065. modul= '<?php echo $this->uri->segment(2); ?>';
  1066. subModul= '<?php echo $this->uri->segment(3); ?>';
  1067. var ctrl = "<?php echo $this->uri->segment(2) . '/' . $this->uri->segment(3) ?>";
  1068. switch(ctrl)
  1069. {
  1070. case 'marketing/product' :
  1071. var MataUang = $("#" + id + " td:nth-child(5)").text();
  1072. var varToPost = {"id":id,"MataUang": MataUang};
  1073. break;
  1074. default :
  1075. var varToPost = {"id":encodeURIComponent(id)};
  1076. break;
  1077. }
  1078. var ask = confirm("<?php echo lang("abdi.alert_10") ?> : " + id + ", <?php echo lang("abdi.alert_11") ?> ?");
  1079. if(ask)
  1080. {
  1081. $.post("<?php echo $this->configlib->site_url() . "/" . $this->uri->segment(2) . "/" . $this->uri->segment(3); ?>/delete/",varToPost,function(data){
  1082. switch(data)
  1083. {
  1084. case "1" :
  1085. alert("<?php echo lang("abdi.alert_12") ?>");
  1086. regmod= /^(customer\/master)$/;
  1087. if( ! regmod.test(ctrl) ){
  1088. $('#jqTable').trigger('reloadGrid');
  1089. }else{
  1090. $('#jqTable tr[id=' + id + ']').remove();
  1091. }
  1092. break;
  1093. case "0" :
  1094. alert("<?php echo lang("abdi.alert_13") ?>");
  1095. $('#jqTable').trigger('reloadGrid');
  1096. break;
  1097. case "2" :
  1098. alert("<?php echo lang("abdi.alert_14") ?>");
  1099. $('#jqTable').trigger('reloadGrid');
  1100. break;
  1101. default :
  1102. alert(data);
  1103. break;
  1104. }
  1105. });
  1106. }
  1107. }
  1108. </script>