PageRenderTime 104ms CodeModel.GetById 49ms RepoModel.GetById 0ms app.codeStats 0ms

/application/views/js_init/js_common_old.php

https://bitbucket.org/remobius/crm
PHP | 935 lines | 835 code | 42 blank | 58 comment | 68 complexity | 11212aa5dc51d85fcaf62934c2dc25cb 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("<?= 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("<?= 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("<?= lang("abdi.alert_19") ?>");
  38. return false;
  39. }
  40. }
  41. function newKonsumenDetail(id)
  42. {
  43. $("#dialog4").dialog({
  44. title : '<?= 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. "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 />Please Wait ....</center>");
  63. $(this).load("<?= $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 : '<?= lang("abdi.summary_information_detail") ?>',
  72. width: 900,
  73. height: 700,
  74. modal: true,
  75. show : "blind",
  76. hide : "blind",
  77. buttons: {
  78. "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 />Please Wait ....</center>");
  89. $(this).load("<?= $this->configlib->site_url() ?>/customer/dashboard/view_detail/" + id);
  90. }
  91. });
  92. //$('#dialog').load("<?= $this->configlib->site_url() ?>/customer/dashboard/view_detail/" + id);
  93. }
  94. $(function(){
  95. id= "INV-02001-0911-52";
  96. initDialog("edit",id,"");
  97. $("#cusDialog").dialog("open");
  98. /*
  99. initDialog("add","","");
  100. $("#dialog").dialog("open");
  101. id= "STF10003";
  102. initDialog("edit",id,"");
  103. $("#cusDialog").dialog("open");
  104. */
  105. //
  106. $('#btnCari').click( function(){
  107. $("#jqTable").jqGrid('searchGrid', { multipleSearch: true, overlay: true, sopt:['cn','bw','eq','ne','lt','gt','ew'], onClose:function(){
  108. var grid = $("#jqTable");
  109. grid.jqGrid('setGridParam',{search:false});
  110. }});
  111. $btnreset= '<td class="EditButton" style="text-align:left">'+
  112. '<a class="fm-button ui-state-default ui-corner-all fm-button-icon-left' +
  113. ' ui-search" id="fbox_jqTable_reset_new">' +
  114. '<span class="ui-icon ui-icon-arrowreturnthick-1-w"></span>Reset</a></td>';
  115. if( $('#fbox_jqTable_2 tr:eq(1)').find('#fbox_jqTable_reset_new').length == 0 ){
  116. $('#fbox_jqTable_2 tr:eq(1)').prepend($btnreset);
  117. $('#fbox_jqTable_reset').parent().remove();
  118. }
  119. });
  120. $('#fbox_jqTable_reset_new').live('click', function(){
  121. grid= $("#jqTable");
  122. filterparams= '{"groupOp":"AND","rules":[{"field":"IdKonsumen","op":"eq","data":""}],"groups":[]}';
  123. grid.jqGrid('setGridParam',{search: true});
  124. var postData = grid.jqGrid('getGridParam','postData');
  125. $.extend(postData,{filters:filterparams});
  126. grid.trigger("reloadGrid",[{page:1}]);
  127. });
  128. $('#fbox_jqTable_search').click( function(){
  129. alert('test');
  130. });
  131. $("#btnCustDetail")
  132. .click(function(){
  133. var id = $('#jqTable').jqGrid('getGridParam','selrow');
  134. if(id!=null)
  135. {
  136. getDetail(id);
  137. $("#dialog").dialog("open");
  138. }else{
  139. alert("<?= lang("abdi.alert_20") ?>");
  140. }
  141. })
  142. var Modme= '<?php echo $this->uri->segment("2"); ?>';
  143. var Funcme= '<?php echo $this->uri->segment("3"); ?>';
  144. $('#btnCusHistory,#btnJobHistory').click( function(e){
  145. UriMod= Modme+"/"+Funcme;
  146. regmodule= /^(customer\/history)$/;
  147. id = $('#jqTable').jqGrid('getGridParam','selrow');
  148. if( id != null ){
  149. if( e.target.id == "btnJobHistory" ){
  150. var UrlHistory= "<?php echo $this->configlib->site_url(); ?>/customer/jobcard_history/get/" +
  151. encodeURIComponent(id);
  152. window.open(UrlHistory);
  153. }else{
  154. if( regmodule.test(UriMod) ){
  155. var UrlHistory= "<?php echo $this->configlib->site_url(); ?>/customer/repair/purchase_history/" +
  156. encodeURIComponent(id);
  157. window.open(UrlHistory);
  158. }else{
  159. Idcustomer= $('tr#'+ id + ' td:eq(2)').attr('title');
  160. var UrlHistory= "<?php echo $this->configlib->site_url(); ?>/customer/repair/purchase_history/" +
  161. encodeURIComponent(Idcustomer);
  162. window.open(UrlHistory);
  163. }
  164. }
  165. }else{
  166. alert("<?= lang("abdi.alert_20") ?>");
  167. }
  168. });
  169. //Function when add button clicked
  170. var modul = "<?php echo $this->uri->segment(2); ?>";
  171. var subModul = "<?php echo $this->uri->segment(3); ?>";
  172. var modadd= modul + '/' + subModul;
  173. var IdAkses= '<?php echo $this->session->userdata('idAkses'); ?>';
  174. var regmodadd= /^(customer\/master|customer\/dashboard)$/;
  175. if( regmodadd.test(modadd) ) //Function for adding new customer master, this submodul use two form that need to submit together in one time
  176. {
  177. if( IdAkses=='CST' ){
  178. $('img[src*=delete_disable], a img#btnEdit').remove();
  179. }
  180. //Function when edit button clicked
  181. $("img#btnEdit").click(function(){
  182. var id = $('#jqTable').jqGrid('getGridParam','selrow');
  183. if(id == null)
  184. {
  185. alert("<?= lang("abdi.alert_20") ?>");
  186. }else{
  187. var arrFrm = new Array("frmAddCus","frmAddOther");
  188. initDialog("edit", id, arrFrm);
  189. $("#dialog").dialog("open");
  190. }
  191. })
  192. $("img#btnAdd").click(function(){
  193. var arrFrm = new Array("frmAddCus","frmAddOther");
  194. initDialog("add","",arrFrm);
  195. $("#dialog").dialog("open");
  196. });
  197. }else{
  198. $("img#btnAdd").click(function(){ //Defaut for submitting just one form in one time
  199. //alert("test");
  200. initDialog("add","","");
  201. $("#dialog").dialog("open");
  202. });
  203. $("img#btnEdit").click(function(){
  204. var id = $('#jqTable').jqGrid('getGridParam','selrow');
  205. if(id == null)
  206. {
  207. alert("<?= lang("abdi.alert_20") ?>");
  208. }else{
  209. initDialog("edit",id,"");
  210. //$("#cusDialog").dialog("open");
  211. }
  212. })
  213. }
  214. var regcusmaster= /^(customer\/master)$/;
  215. if( regmodadd.test(modadd) ) //Function for adding new customer master, this submodul use two form that need to submit together in one time
  216. {
  217. <?php #echo $this->configlib->site_url() . '/' . modul . '/' . subModul . '/xml'; ?>
  218. var url= '<?php echo $this->configlib->site_url(); ?>' + '/' + modul + '/' + subModul + '/xml';
  219. $("#jqTable").jqGrid('setGridParam', { url: url });
  220. $('#refresh_jqTable,#search_jqTable').remove();
  221. }
  222. //Function when delete button clicked
  223. $("img#btnDel").click(function(){
  224. var id = $('#jqTable').jqGrid('getGridParam','selrow');
  225. if(id == null)
  226. {
  227. alert("<?= lang("abdi.alert_20") ?>");
  228. }else{
  229. jDelete(id);
  230. }
  231. })
  232. //Init tipsy
  233. var regmodul= /^(audiogram|upload|report)$/;
  234. Modul='<?php echo $this->uri->segment(3); ?>';
  235. if( ! regmodul.test(Modul) ){
  236. $('#btnAdd, #btnEdit, #btnDel, #btnPrint, #btnExcel, img#btnDetail, #btnArrival, #btnCusHistory, #btnJobHistory, #btnCari,#btnLastVisit').tipsy({gravity: 'sw', fade: true});
  237. }
  238. })
  239. function jqGridSelected(obj,id)
  240. {
  241. $("#hiddenID").val(id);
  242. }
  243. function required(ignore)
  244. {
  245. var passed = true;
  246. $(".required").each(function(){
  247. if($.trim($(this).val())=="")
  248. {
  249. passed = false;
  250. $(this).css("backgroundColor","#f15c32");
  251. $(this).css("color","white");
  252. }
  253. });
  254. if(passed==false)
  255. {
  256. if(ignore==false)
  257. {
  258. alert("<?= lang("abdi.alert_3") ?>"); //Data Ga boleh kosong
  259. }
  260. return false;
  261. }else{
  262. return true;
  263. }
  264. }
  265. function confirmed()
  266. {
  267. if(required(false))
  268. {
  269. var passed = true;
  270. $(".confirmed").each(function(){
  271. if($.trim($(this).val())=="")
  272. {
  273. passed = false;
  274. $(this).css("backgroundColor","yellow");
  275. }
  276. });
  277. if(passed==false)
  278. {
  279. var ask = confirm("<?= lang("abdi.alert_6") ?>"); //Mengabaikan Beberapa Fields
  280. if(ask)
  281. {
  282. return true;
  283. }else{
  284. return false;
  285. }
  286. }else{
  287. return true;
  288. }
  289. }else{
  290. return true;
  291. }
  292. }
  293. function initDialog(act,id,frmID)
  294. {
  295. var isArray = false;
  296. var modul = '<?php echo $this->uri->segment("2"); ?>';
  297. var func = '<?php echo $this->uri->segment("3"); ?>';
  298. theUrl = "<?php echo $this->configlib->site_url(); ?>/" + modul + "/" + func + "/popup/" + act + "/" + encodeURIComponent(id);
  299. theSave = function(e){
  300. if(frmID.length==2)
  301. {
  302. isArray=true;
  303. var serial = new Array($("#" + frmID[0]).serialize(),$("#" + frmID[1]).serialize());
  304. }
  305. if(isArray) //Notice : this function is only submitted two form in same time
  306. {
  307. var allowBlank = confirmed();
  308. var mustFilled = required();
  309. //alert('test');
  310. if( allowBlank && mustFilled )
  311. {
  312. var success= true;
  313. var i =0;
  314. var idkonsumen= $('#IdKonsumen').val();
  315. while(i<=1 && success==true )
  316. {
  317. $(this).empty();
  318. $(this).append("<center><span><img src='<?php echo $this->config->item("img_url") ?>/dialogload.gif' /><br />Sending Form "+i+1+"</span></center>");
  319. $.post("<?php echo $this->configlib->site_url(); ?>/" + modul + "/master/save/" + act,serial[i],function(data){
  320. switch(data)
  321. {
  322. case "1" :
  323. success = true;
  324. break;
  325. case "0" :
  326. success = false;
  327. var msg = "<?= lang("abdi.alert_4") ?>"; //Data Gagal Simpan
  328. break;
  329. case "-1" :
  330. success = false;
  331. var msg = "<?= lang("abdi.alert_7") ?>"; //Error Hanya Pada Data yg Di save aja
  332. break;
  333. default :
  334. var msg = "Error : " + data;
  335. success = false;
  336. break;
  337. }
  338. });
  339. i = i +1;
  340. }
  341. if( success==false ){
  342. alert(msg);
  343. }
  344. if( success==true ){
  345. alert("<?= lang("abdi.alert_5") ?>") //Data Berhasil Disimpan
  346. elname= $(e.target).text();
  347. }
  348. $("#dialog").dialog("close");
  349. var modadd= modul + "/" + func;
  350. var regmodadd= /^(customer\/master|customer\/dashboard)$/;
  351. if( regmodadd.test(modadd) && elname == "Proceed"){
  352. //alert(idkonsumen);
  353. newKonsumenDetail(idkonsumen);
  354. //newKonsumenDetail('020010006');
  355. }
  356. }
  357. }else{
  358. if(frmID=="")
  359. frmID = $("#frmID").val(); //Get the form name to be serialized
  360. var serialized = $("#" + frmID).serialize();
  361. var allowBlank = confirmed();
  362. //var mustFilled = true;
  363. var mustFilled = required();
  364. /* Pengecekan tambahan untuk test password sama dan email pada Form frmAddAcc */
  365. /* -------------------------------------------------------------------------- */
  366. if( frmID=="frmAddAcc"){
  367. if( act=="add" ){
  368. mustFilled= match_password();
  369. if( mustFilled == true ){
  370. mustFilled = is_email();
  371. }
  372. }else{
  373. mustFilled= is_email();
  374. }
  375. }
  376. //Pengecekan tambahan untuk authorization add new repair
  377. if(frmID=="frmAddRepair")
  378. {
  379. var printRepairReceipt = false;
  380. switch($("#Authorization").val())
  381. {
  382. case "c" :
  383. //JIka user memilih cost estimate
  384. printRepairReceipt = true;
  385. alert("<?= lang("abdi.alert_42") ?>");
  386. break;
  387. default :
  388. //JIka user memilih immediate repair atau cost estimate if rep over
  389. //JIka nilai DP kecil dari Rp. 50.000
  390. if($("#DP").val()<50000)
  391. {
  392. alert("<?= lang("abdi.alert_43") ?>")
  393. $("#DP").focus();
  394. }else{
  395. printRepairReceipt = true;
  396. }
  397. break;
  398. }
  399. }else{
  400. var printRepairReceipt = true;
  401. }
  402. /*---------------------------------------------------------*/
  403. //var serialized = $("#" + frmID).serialize();
  404. var field_number= is_number();
  405. if(allowBlank && mustFilled && field_number && printRepairReceipt)
  406. {
  407. mockup='<?php echo $this->uri->segment(2) . "/" . $this->uri->segment(3); ?>';
  408. mockreg= /^(hrd\/master|marketing\/sales)$/;
  409. //if( mockup != "hrd/master" ){
  410. if( ! mockreg.test(mockup) ){
  411. grant_edit= $('#grant_edit').val();
  412. if( mockup == "customer/invoice" && grant_edit != "on" ){
  413. alert("Press F5 to enter your supervise key !");
  414. }else{
  415. /*
  416. $(this).empty();
  417. $(this).append("<center><span><img src='<?php echo $this->config->item("img_url") ?>/dialogload.gif' /><br /><?= lang("abdi.alert_21") ?> ....</span></center>");
  418. */
  419. var stat_dialog= true;
  420. $.post("<?php echo $this->configlib->site_url(); ?>/" + modul + "/" + func + "/save/" + act,serialized,function(data){
  421. dataParsed = data.split("~");
  422. switch(dataParsed[0])
  423. {
  424. case "1" :
  425. alert("<?= lang("abdi.alert_5") ?>");
  426. break;
  427. case "0" :
  428. alert("<?= lang("abdi.alert_4") ?> ");
  429. break;
  430. case "-1" :
  431. alert("<?= lang("abdi.alert_7") ?> ");
  432. break;
  433. case "R-OK" : //Print receipt for added repair
  434. alert("<?= lang("abdi.alert_5") ?>");
  435. var frmObjArr = serialized.split("&"); //Pecah value dari variable serialized untuk mendapatkan id repair
  436. var idRepairArr = frmObjArr[1].split("="); //Pecah lagi dengan splitter string '='
  437. var idRepair = idRepairArr[1];
  438. window.open("<?= $this->configlib->site_url(); ?>/customer/repair/print_receipt/" + idRepair,"Repair Receipt");
  439. alert("<?= lang("abdi.alert_8") ?>");
  440. break;
  441. case "R-OK-NORECEIPT" :
  442. alert("<?= lang("abdi.alert_5") ?>");
  443. break;
  444. case "S-OK" : //Print shipment
  445. var frmObjArr = serialized.split("&"); //Pecah value dari variable serialized untuk mendapatkan id shipment
  446. var idShipmentArr = frmObjArr[1].split("="); //Pecah lagi dengan splitter string '='
  447. var IdShipment = idShipmentArr[1];
  448. alert("<?= lang("abdi.alert_5") ?>");
  449. break;
  450. case "INV-OK" :
  451. var frmObjArr = serialized.split("&"); //Pecah value dari variable serialized untuk mendapatkan id invoice
  452. var idInvoiceArr = frmObjArr[3].split("="); //Pecah lagi dengan splitter string '='
  453. var idInvoice = idInvoiceArr[1];
  454. window.open("<?= $this->configlib->site_url(); ?>/customer/invoice/print_invoice/" + idInvoice,"Invoice");
  455. alert("<?= lang("abdi.alert_9") ?>");
  456. break;
  457. case "INV-OK-EDIT":
  458. var tanya = confirm("Data Succesfully Saved, Print Invoice ?");
  459. if(tanya)
  460. {
  461. window.open("<?= $this->configlib->site_url(); ?>/customer/invoice/print_invoice/" + dataParsed[1],"Invoice");
  462. }
  463. break;
  464. case "U-XSIST" :
  465. alert("<?= lang("abdi.alert_9") ?>");
  466. break;
  467. case "aud_error" : // Audiogram
  468. //alert("<?= lang("abdi.alert_5") ?>");
  469. //add_elem("error_db",$obj_dest,data);
  470. $obj_dest= $('#frmAddAudiogram');
  471. $(".error_db").remove();
  472. $new_elem= '<div class="error_db"></div>';
  473. $obj_dest.prepend($new_elem);
  474. $(".error_db").html(dataParsed[1]);
  475. stat_dialog= false;
  476. break;
  477. default :
  478. alert("Error : " + data);
  479. break;
  480. }
  481. });
  482. //alert(stat_dialog);
  483. /*
  484. if( stat_dialog ){
  485. $(this).dialog("close");
  486. }
  487. */
  488. /*
  489. $("#dialog").empty();
  490. $(this).dialog("close");
  491. */
  492. }
  493. }else if( mockup == "marketing/sales" ){
  494. var records = $("#tblcart").getGridParam("records");
  495. if(records==0)
  496. {
  497. alert("<?= lang("abdi.alert_35") ?>")
  498. }else{
  499. var ask = confirm("All changes cannot be undo after transaction proceeded, do you want to continue ?");
  500. if(ask)
  501. {
  502. var IdKonsumen = $("#IdKonsumen").val();
  503. Diskon= $('#alldiscount').val(); // Diskon semua belanja
  504. Subtotal= $('#subtotal').val(); // SubTotal
  505. Total= $('#totalcart').val(); // Total Cart setelah diskon
  506. DP= $('#downpayment').val(); // DP
  507. isLunas= ( $('#pay').is(':checked') ) ? 1 : 0; // Lunas atau tidak
  508. IdPembayaran= "CS";
  509. varpost= { "IdKonsumen": IdKonsumen, "Diskon": Diskon, "Subtotal": Subtotal, "Total": Total,
  510. "DP": DP, "isLunas": isLunas, "IdPembayaran": IdPembayaran };
  511. $.post("<?= $this->configlib->site_url() ?>/marketing/sales/proceed_trans", varpost,
  512. function(data){
  513. if( data != "no-lunas" ){
  514. idInvoice= data;
  515. url_tujuan= "<?= $this->configlib->site_url(); ?>/customer/invoice/print_invoice/" + idInvoice;
  516. //alert(url_tujuan);
  517. window.open(url_tujuan, "Invoice");
  518. $("#dialog").empty();
  519. $("#dialog").dialog("close");
  520. }
  521. })
  522. }
  523. }
  524. }else{
  525. alert("hrd");
  526. $("#dialog").parent().hide();
  527. url= "<?php echo $this->configlib->site_url(); ?>/" + modul + "/" + func + "/save/" + act;
  528. var fileopt = {
  529. url: url,
  530. success: function(data) {
  531. switch(data){
  532. case "1" :
  533. alert("<?= lang("abdi.alert_5") ?>");
  534. break;
  535. case "0" :
  536. alert("<?= lang("abdi.alert_4") ?> ");
  537. break;
  538. default :
  539. alert("Error : " + data);
  540. break;
  541. }
  542. $("#dialog").empty();
  543. $("#dialog").dialog("close");
  544. }
  545. }
  546. //alert(frmID);
  547. $("#frmAddKar").ajaxSubmit(fileopt);
  548. }
  549. }
  550. }
  551. }
  552. var modadd= modul + "/" + func;
  553. var regmodadd= /^(customer\/master|customer\/dashboard)$/;
  554. if( regmodadd.test(modadd) ){
  555. var theButton = {
  556. 'Save': theSave,
  557. 'Proceed': theSave,
  558. 'Cancel': function(e) {
  559. $(this).empty();
  560. $(this).dialog('close');
  561. $('#jqTable').trigger('reloadGrid');
  562. }
  563. }
  564. }else{
  565. var theButton = {
  566. Save: theSave,
  567. Cancel: function() {
  568. $(this).empty();
  569. $(this).dialog('close');
  570. $('#jqTable').trigger('reloadGrid');
  571. }
  572. }
  573. }
  574. var dialogOpt = modul + "/" + func;
  575. switch(dialogOpt)
  576. {
  577. case 'customer/master' :
  578. theWidth = 850;
  579. theHeight = 630;
  580. theTitle = "Add/Edit Customer Data";
  581. break;
  582. case 'customer/repair' :
  583. theWidth = 560;
  584. theHeight = 650;
  585. theTitle = "Form New Repair";
  586. break;
  587. case 'customer/shipment' :
  588. theWidth = 740;
  589. theHeight = 600;
  590. theTitle = "Add Delivery";
  591. break;
  592. case 'customer/invoice' :
  593. theWidth = 900;
  594. theHeight = "auto";
  595. theTitle = "Add/Edit Invoice";
  596. break;
  597. case 'marketing/product' :
  598. theWidth = 400;
  599. theHeight = 460;
  600. theTitle = "Add/Edit New Product";
  601. break;
  602. case 'calendar/calendar' :
  603. theWidth = 500;
  604. theHeight = 450;
  605. theTitle = "Add/Edit Booking";
  606. theButton = {
  607. Close : function(){
  608. $(this).dialog("close");
  609. }
  610. }
  611. break;
  612. case 'logistic/bo' :
  613. theWidth = 700;
  614. theHeight = 600;
  615. theTitle = "Branch Order - My Request";
  616. theButton = {
  617. Close : function(){
  618. $(this).dialog("close");
  619. }
  620. }
  621. break;
  622. case 'hrd/master' :
  623. theWidth = 750;
  624. theHeight = "auto";
  625. theTitle = "Add/Edit Employees";
  626. break;
  627. case 'marketing/vendor' :
  628. theWidth = 400;
  629. theHeight = 500;
  630. theTitle = "Add/Edit Vendor";
  631. break;
  632. case 'logistic/product_deliver' :
  633. theWidth = 700;
  634. theHeight = 530;
  635. theTitle = "Add/Edit Branch Delivery";
  636. break;
  637. case 'logistic/product_receive' :
  638. theWidth = 760;
  639. theHeight = 400;
  640. theTitle = "Add/Edit Branch Receive";
  641. break;
  642. case 'logistic/shipping_db' :
  643. theWidth = 500;
  644. theHeight = "auto";
  645. theTitle = "Add/Edit Shipping List";
  646. break;
  647. case 'customer/clinical' :
  648. theWidth = 600;
  649. theHeight = 700;
  650. theTitle = "Add/Edit Clinical Information";
  651. break;
  652. case 'customer/comment' :
  653. theWidth = 600;
  654. theHeight = 600;
  655. theTitle = "Add Comment Customer";
  656. break;
  657. case 'customer/area_difficulties' :
  658. theWidth = 600;
  659. theHeight = 600;
  660. theTitle = "Add Area of Difficulties";
  661. break;
  662. case 'customer/report_repair' :
  663. theTitle = "Select Branch"
  664. theWidth = 500;
  665. theHeight = "auto";
  666. theUrl = "<?= $this->configlib->site_url() . "/customer/report_repair/popup"; ?>";
  667. theButton = {
  668. "select and close" : function(){
  669. select_branch(); //Function ini ada di view vBrowseCabang
  670. $("#dialog").dialog("close");
  671. }
  672. }
  673. break;
  674. case 'settings/account' :
  675. theWidth = 480;
  676. theHeight = 440;
  677. theTitle = "Add/Edit User Account";
  678. break;
  679. case 'marketing/mediatype' :
  680. theWidth = 500;
  681. theHeight = 'auto';
  682. theTitle = "Add/Edit Media Type";
  683. break;
  684. case 'marketing/mediacat' :
  685. theWidth = 500;
  686. theHeight = 'auto';
  687. theTitle = "Add/Edit Media Category";
  688. break;
  689. case 'marketing/media' :
  690. theWidth = 500;
  691. theHeight = 'auto';
  692. theTitle = "Add/Edit Media";
  693. break;
  694. case 'marketing/mediaiklan' :
  695. theWidth = 500;
  696. theHeight = 'auto';
  697. theTitle = "Add/Edit Campaign";
  698. break;
  699. case 'marketing/event' :
  700. theWidth = 500;
  701. theHeight = 600;
  702. theTitle = "Add/Edit Event";
  703. break;
  704. case 'logistic/stock' :
  705. theWidth = 500;
  706. theHeight = 600;
  707. theTitle = "Add/Edit Stock";
  708. break;
  709. case 'customer/religion' :
  710. theWidth = 450;
  711. theHeight = 250;
  712. theTitle = "Add/Edit Religion";
  713. break;
  714. case 'settings/klinik' :
  715. theWidth = 450;
  716. theHeight = 'auto';
  717. theTitle = "Add/Edit Clinic";
  718. break;
  719. case 'customer/family' :
  720. theWidth = 450;
  721. theHeight = 250;
  722. theTitle = "Add/Edit Family";
  723. break;
  724. case 'customer/country' :
  725. theWidth = 500;
  726. theHeight = "auto";
  727. theTitle = "Add/Edit Country";
  728. break;
  729. case 'customer/region' :
  730. theWidth = 500;
  731. theHeight = "auto";
  732. theTitle = "Add/Edit Region";
  733. break;
  734. case 'customer/kota' :
  735. theWidth = 500;
  736. theHeight = "auto";
  737. theTitle = "Add/Edit City";
  738. break;
  739. case 'customer/sapaan' :
  740. theWidth = 450;
  741. theHeight = "auto";
  742. theTitle = "Add/Edit Salutation";
  743. break;
  744. case 'hrd/department' :
  745. theWidth = 450;
  746. theHeight = "auto";
  747. theTitle = "Add/Edit Department";
  748. break;
  749. case 'hrd/leave_type' :
  750. theWidth = 450;
  751. theHeight = "auto";
  752. theTitle = "Add/Edit Leave Type";
  753. break;
  754. case 'hrd/assign_leave' :
  755. theWidth = 450;
  756. theHeight = "auto";
  757. theTitle = "Add/Edit Assign Leave";
  758. break;
  759. case "hrd/attendance" :
  760. theWidth = 400;
  761. theHeight = 400;
  762. theTitle = "Add Attendance Data";
  763. break;
  764. case 'hrd/occupation' :
  765. theWidth = 450;
  766. theHeight = "auto";
  767. theTitle = "Add/Edit Position";
  768. break;
  769. case 'customer/job' :
  770. theWidth = 450;
  771. theHeight = "auto";
  772. theTitle = "Add/Edit Occupation";
  773. break;
  774. case 'marketing/category' :
  775. theWidth = 450;
  776. theHeight = "auto";
  777. theTitle = "Add/Edit Product Category";
  778. break;
  779. case 'marketing/service' :
  780. theWidth = 450;
  781. theHeight = "auto";
  782. theTitle = "Add/Edit Service";
  783. break;
  784. case 'marketing/portfolio_product' :
  785. theWidth = 450;
  786. theHeight = "auto";
  787. theTitle = "Add/Edit Portfolio Product";
  788. break;
  789. case 'master/user_akses' :
  790. theWidth = 450;
  791. theHeight = "auto";
  792. theTitle = "Add/Edit User Access";
  793. break;
  794. case 'master/user_modul' :
  795. theWidth = 450;
  796. theHeight = "auto";
  797. theTitle = "Add/Edit User Modul";
  798. break;
  799. case 'master/user_hak_akses' :
  800. theWidth = 500;
  801. theHeight = "auto";
  802. theTitle = "Add/Edit User Privilege Access";
  803. break;
  804. case 'customer/dokter_referal' :
  805. theWidth = 500;
  806. theHeight = "auto";
  807. theTitle = "Add/Edit Doctor Referal";
  808. break;
  809. case 'logistic/inventory' :
  810. theWidth = 500;
  811. theHeight = 300;
  812. theTitle = "Add/Edit inventory";
  813. break;
  814. case 'marketing/sales' :
  815. theWidth = 900;
  816. theHeight = "auto";
  817. theTitle = "Add/Edit Sales Transaction";
  818. /*
  819. theButton = {
  820. "Save" : function
  821. "Cancel" : function(){
  822. $(this).dialog("close");
  823. }
  824. }
  825. */
  826. break;
  827. default :
  828. return;
  829. }
  830. $("#dialog").dialog({
  831. title : theTitle,
  832. width: theWidth,
  833. height: theHeight,
  834. modal: true,
  835. show : "blind",
  836. hide : "blind",
  837. position: "top",
  838. buttons: theButton
  839. ,
  840. close: function() {
  841. $(this).dialog("destroy");
  842. $("#dialog").empty();
  843. var regmodtrig= /^(customer\/master)$/;
  844. if( ! regmodtrig.test(modadd) ){
  845. $('#jqTable').trigger('reloadGrid');
  846. }
  847. },
  848. open : function()
  849. {
  850. $(this).append("<center><span><img src='<?php echo $this->config->item("img_url") ?>/dialogload.gif' /></span><br /><?= lang("abdi.alert_21") ?> ....</center>");
  851. $(this).load(theUrl);
  852. }
  853. });
  854. }
  855. function jDelete(id)
  856. {
  857. var ctrl = "<?= $this->uri->segment(2) . '/' . $this->uri->segment(3) ?>";
  858. switch(ctrl)
  859. {
  860. case 'marketing/product' :
  861. var MataUang = $("#" + id + " td:nth-child(5)").text();
  862. var varToPost = {"id":id,"MataUang": MataUang};
  863. break;
  864. default :
  865. var varToPost = {"id":encodeURIComponent(id)};
  866. break;
  867. }
  868. var ask = confirm("<?= lang("abdi.alert_10") ?> : " + id + ", <?= lang("abdi.alert_11") ?> ?");
  869. if(ask)
  870. {
  871. $.post("<?php echo $this->configlib->site_url() . "/" . $this->uri->segment(2) . "/" . $this->uri->segment(3); ?>/delete/",varToPost,function(data){
  872. switch(data)
  873. {
  874. case "1" :
  875. alert("<?= lang("abdi.alert_12") ?>");
  876. $('#jqTable').trigger('reloadGrid');
  877. break;
  878. case "0" :
  879. alert("<?= lang("abdi.alert_13") ?>");
  880. $('#jqTable').trigger('reloadGrid');
  881. break;
  882. case "2" :
  883. alert("<?= lang("abdi.alert_14") ?>");
  884. $('#jqTable').trigger('reloadGrid');
  885. break;
  886. default :
  887. alert(data);
  888. break;
  889. }
  890. });
  891. }
  892. }
  893. </script>