PageRenderTime 57ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/opensourcepos/application/views/products/products_grid.php

https://bitbucket.org/jit_bec/shopifine
PHP | 1009 lines | 808 code | 125 blank | 76 comment | 47 complexity | d5a4393716e720dc17e3b3c7158e0b2d MD5 | raw file
Possible License(s): LGPL-3.0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Product Details</title>
  5. <?php $this->load->view("common/header"); ?>
  6. <script type="text/javascript" src="http://static.jstree.com/v.1.0pre/jquery.jstree.js"></script>
  7. <style type="text/css">
  8. #menubar_admin_navigation {
  9. top:49px;
  10. }
  11. #content_area{
  12. width:95%;
  13. }
  14. .column{width:40em;padding:1em;}
  15. html {
  16. overflow-x:hidden;
  17. }
  18. </style>
  19. <!-- <style type="text/css">
  20. html {height:100%}
  21. body { font-size: 62.5%; height:100%}
  22. #content_area { left:-80px;top:30px; }
  23. #content_area_wrapper{height:100%;}
  24. label, input { display:inline; }
  25. input.text { margin-bottom:12px; width:95%; padding: .4em; }
  26. fieldset { padding:0; border:0; margin-top:25px; }
  27. h1 { font-size: 1.2em; margin: .6em 0; }
  28. div#users-contain { width: 350px; margin: 20px 0; }
  29. div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
  30. div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
  31. .ui-dialog .ui-state-error { padding: .3em; }
  32. .validateTips { border: 1px solid transparent; padding: 0.3em; }
  33. .reqBarcodeAC { position:absolute;left:230px;}
  34. * { font-family: Verdana; font-size: 96%; }
  35. label { width: 10em; float: left; }
  36. label.error { float: right; color: red; padding-left: .5em; vertical-align: top; position: relative;width:130px;}
  37. p , .column{ clear: both; padding: 1em; }
  38. .submit { margin-left: 12em; }
  39. em { font-weight: bold; padding-right: 1em; vertical-align: top; }
  40. .ui-combobox {
  41. position: relative;
  42. display: inline-block;
  43. }
  44. .ui-combobox-toggle {
  45. position: absolute;
  46. top: 0;
  47. bottom: 0;
  48. margin-left: -1px;
  49. padding: 0;
  50. }
  51. .ui-combobox-input {
  52. margin: 0;
  53. padding: 0.3em;
  54. }
  55. </style>-->
  56. <script>
  57. (function( $ ) {
  58. $.widget( "ui.combobox", {
  59. options: {
  60. strict: false,
  61. customChange:null
  62. },
  63. _create: function() {
  64. var input,
  65. self = this,
  66. id = this.element[0].id + "-input",
  67. select = this.element.hide(),
  68. selected = select.children( ":selected" ),
  69. value = selected.val() ? selected.text() : "",
  70. strict = this.options.strict,
  71. wrapper = this.wrapper = $( "<span>" )
  72. .addClass( "ui-combobox" )
  73. .insertAfter( select );
  74. input = $( "<input>" ).attr("id",id)
  75. .appendTo( wrapper )
  76. .val( value )
  77. .addClass( "ui-state-default ui-combobox-input" )
  78. .autocomplete({
  79. delay: 0,
  80. minLength: 0,
  81. source: function( request, response ) {
  82. var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
  83. response( select.children( "option" ).map(function() {
  84. var text = $( this ).text();
  85. if ( this.value && ( !request.term || matcher.test(text) ) )
  86. return {
  87. label: text.replace(
  88. new RegExp(
  89. "(?![^&;]+;)(?!<[^<>]*)(" +
  90. $.ui.autocomplete.escapeRegex(request.term) +
  91. ")(?![^<>]*>)(?![^&;]+;)", "gi"
  92. ), "<strong>$1</strong>" ),
  93. value: text,
  94. option: this
  95. };
  96. }) );
  97. },
  98. select: function( event, ui ) {
  99. ui.item.option.selected = true;
  100. self._trigger( "selected", event, {
  101. item: ui.item.option
  102. });
  103. },
  104. change: function( event, ui ) {
  105. //self.off();
  106. // console.log( "change");
  107. // console.log( event);
  108. if ( !ui.item ) {
  109. var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
  110. valid = false;
  111. select.children( "option" ).each(function() {
  112. if ( $( this ).text().match( matcher ) ) {
  113. this.selected = valid = true;
  114. return false;
  115. }
  116. });
  117. if ( !valid ) {
  118. // remove invalid value, as it didn't match anything
  119. select.val( "" );
  120. if (!strict) {
  121. callback = self.options.customChange;
  122. if ($.isFunction(callback)){
  123. callback();
  124. }
  125. return;
  126. }
  127. $( this ).val( "" );
  128. input.data( "autocomplete" ).term = "";
  129. return false;
  130. }
  131. }
  132. callback = self.options.customChange;
  133. if ($.isFunction(callback)){
  134. callback();
  135. }
  136. }
  137. })
  138. .addClass( "ui-widget ui-widget-content ui-corner-left" ).keypress(function (e){
  139. //console.log(e.which);
  140. if (e.which== 13){
  141. //$(".ui.combobox").trigger("autocompletechange");
  142. //autocomplete
  143. //$("#mfrOp").combobox().trigger("comboboxkeypress","");
  144. //console.log($("#mfrOp").combobox());
  145. //console.log( $(this).data( "autocomplete" ));
  146. $(this).data( "autocomplete" )._trigger("change");
  147. //$("#mfrOp").combobox("keypress");
  148. }
  149. });
  150. input.data( "autocomplete" )._renderItem = function( ul, item ) {
  151. return $( "<li></li>" )
  152. .data( "item.autocomplete", item )
  153. .append( "<a style>" + item.label + "</a>" )
  154. .appendTo( ul );
  155. };
  156. $( "<a>" )
  157. .css("left", "100px")
  158. .attr( "tabIndex", -1 )
  159. .attr( "title", "Show All Items" )
  160. .appendTo( wrapper )
  161. .button({
  162. icons: {
  163. primary: "ui-icon-triangle-1-s"
  164. },
  165. text: false
  166. })
  167. .removeClass( "ui-corner-all" )
  168. .addClass( "ui-corner-right ui-combobox-toggle" )
  169. .click(function() {
  170. // close if already visible
  171. if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
  172. input.autocomplete( "close" );
  173. return;
  174. }
  175. // work around a bug (likely same cause as #5265)
  176. $( this ).blur();
  177. // pass empty string as value to search for, displaying all results
  178. input.autocomplete( "search", "" );
  179. input.focus();
  180. });
  181. },
  182. keypress: function (e){
  183. //console.log(e.which);
  184. console.log('test');
  185. },
  186. destroy: function() {
  187. this.wrapper.remove();
  188. this.element.show();
  189. $.Widget.prototype.destroy.call( this );
  190. }
  191. });
  192. })( jQuery );
  193. </script>
  194. <script type="text/javascript">
  195. $(function(){
  196. $.validator.addMethod('comboBoxrequired', function(value, element) {
  197. var selectId = element.id;
  198. var inputIdSelector = "#" + selectId + "-input";
  199. if (value == ""){
  200. inputVal = $(inputIdSelector).val();
  201. if (inputVal == "" || inputVal == null){
  202. return false;
  203. }
  204. }
  205. return true;
  206. }, 'Please select from the dropdown or add new element in box');
  207. $( "#dialog:ui-dialog" ).dialog( "destroy" );
  208. $( "#productForm" ).validate({
  209. errorPlacement: function(error, element) {
  210. error.appendTo( element.parent());
  211. }//,
  212. // rules: {
  213. // mfrOp: {
  214. // comboBoxrequired: true
  215. // }
  216. // }
  217. }
  218. );
  219. $( "#dialog-form" ).dialog({
  220. autoOpen: false,
  221. height: 'auto',
  222. width: '70%',
  223. position:[200,25],
  224. modal: true,
  225. buttons: {
  226. "Create the Product": function() {
  227. var bValid = $("#productForm").valid();
  228. if (bValid ){
  229. var selectedIds = [];
  230. $('#treeViewDiv').jstree('get_selected').each(function(){
  231. selectedIds.push($(this).attr('id'));
  232. });
  233. $.ajax({
  234. url:"index.php/products/createBarcodeAndProduct",
  235. data: {barcodeData :{
  236. scannedBarcode : $("#productbarcode").val(),
  237. mfrOp : $("#mfrOp").val(),
  238. mfrIp: $("#mfrOp-input").val(),
  239. modelOp: $("#modelOp").val(),
  240. modelIp: $("#modelOp-input").val(),
  241. newModelIp: $("#newModelIp").val(),
  242. name: $("#name").val(),
  243. desc: $("#desc").val(),
  244. // categoryOp: $("#categoryOp").val(),
  245. // categoryIp: $("#categoryOp-input").val(),
  246. category:JSON.stringify(selectedIds),
  247. supplierOp: $("#supplierOp").val(),
  248. uomOp: $("#uomOp").val(),
  249. sizeOp: $("#sizeOp").val(),
  250. reorderLevel: $("#reorderLevel").val(),
  251. costPrice: $("#costPrice").val(),
  252. price: $("#price").val(),
  253. attributeSet:$("#attributeSetOp").val(),
  254. packageOp: $("#packageOp").val() }},
  255. type:"POST",
  256. success:function(serverresponse)
  257. {
  258. var response = JSON.parse(serverresponse);
  259. emptyMessages();
  260. if (response.status=='error'){
  261. showErrorMessage(response.message)
  262. }
  263. else {
  264. showSuccessMessage(response.message)
  265. $("#product").trigger("reloadGrid");
  266. }
  267. }
  268. });
  269. $( this ).dialog( "close" );
  270. }
  271. },
  272. Cancel: function() {
  273. $( this ).dialog( "close" );
  274. }
  275. },
  276. close: function() {
  277. //allFields.val( "" ).removeClass( "ui-state-error" );
  278. $("#productForm").data('validator').resetForm();
  279. $('#productForm')[0].reset();
  280. }
  281. });
  282. // $( "#create-product" )
  283. // .button()
  284. // .click(function() {
  285. // //if (!$("#newModelCtnr").parent().is(':hidden')){
  286. // $("#newModelCtnr").parent().css("display","none");
  287. // //}
  288. // //if (!$("#modelCtnr").parent().is(':hidden')){
  289. // $("#modelCtnr").parent().css("display","none");
  290. // //}
  291. // $( "#dialog-form" ).dialog( "open" );
  292. // });
  293. $("#mfrOp").combobox({
  294. customChange: function () {
  295. if ($("#mfrOp").val()!="") {
  296. $.ajax({
  297. type:"post",
  298. data:{mfrName:$("#mfrOp-input").val(),mfr: $("#mfrOp").val()},
  299. url:"index.php/products/populateModel",
  300. success: function(data){
  301. $("#modelOp").children('option:not(:first)').remove();
  302. $("#modelOp").append(data);
  303. $("#modelOp").combobox();
  304. $("#modelCtnr").parent().slideDown(50);
  305. if (!$("#newModelCtnr").parent().is(':hidden')){
  306. $("#newModelCtnr").parent().slideUp(50);
  307. }
  308. }
  309. });
  310. }
  311. else {
  312. $("#newModelCtnr").parent().slideDown(50);
  313. if (!$("#modelCtnr").parent().is(':hidden')){
  314. $("#modelCtnr").parent().slideUp(50);
  315. }
  316. }
  317. }
  318. });
  319. $("#categoryOp").combobox();
  320. var myGrid = $("#product"),lastsel2,selectedMfrId,selectedModelId,selectedPkgId,selectUom,selectedDenom;
  321. var editparameters = {
  322. "keys" : false,
  323. "oneditfunc" : null,
  324. "successfunc" : null,
  325. "url" : 'edittest',
  326. "extraparam" : {},
  327. "aftersavefunc" : null,
  328. "errorfunc": null,
  329. "afterrestorefunc" : null,
  330. "restoreAfterError" : true,
  331. "mtype" : "POST"
  332. };
  333. myGrid.jqGrid({
  334. url:'index.php/products/populateProductsInGrid',
  335. datatype: 'json',
  336. mtype: 'GET',
  337. colNames:['Barcode',/*'System Name',*/'Product','Description','manufacturer_id','model_id','Manufacturer','Model','Supplier','package_id','Package Type',/*'Category',*/'Unit','Size/Quantity','Action'],
  338. colModel :[
  339. //{name:'id', index:'id', width:55},
  340. {name:'barcode',index:'barcode',width:120,align:'right',editable:false},
  341. // {name:'system_name',index:'system_name',width:90,align:'right',editable:false},
  342. {name:'product_name', index:'product_name', width:80, align:'right',editable:true,editoptions:{size:"20",maxlength:"30"}},
  343. {name:'description', index:'description', width:80, align:'right',editable:true,editoptions:{size:"20",maxlength:"30"}},
  344. {name:'manufacturer_id', index:'manufacturer_id', hidden:true},
  345. {name:'model_id', index:'model_id', hidden:true},
  346. {name:'manufacturer', index:'manufacturer', width:80, align:'right',editable:true,edittype:"select",editoptions:{dataEvents: [
  347. { type: 'change',
  348. fn: function(e) {
  349. var val = $("#manufacturer").val();
  350. $.ajax({type:'post',
  351. data:{mfr:val},
  352. url:'index.php/products/populateModel',
  353. success: function(modelHtml){
  354. //console.log ("change mfr");
  355. $("#model").children('option:not(:first)').remove();
  356. $("#model").append(modelHtml);
  357. }
  358. });
  359. }
  360. }
  361. ],dataUrl:"index.php/products/populateMfrs",buildSelect:function(response)
  362. {
  363. var select = "<select name=" + "mfrOpEdit" + "id =" +"mfrOpEdit" +">" +
  364. "<option value=" + ">Select one..." + response + "</select>";
  365. $.ajax({type:'post',
  366. data:{mfr:selectedMfrId},
  367. url:'index.php/products/populateModel',
  368. success: function(modelHtml){
  369. //console.log("ajax mfr" + selectedModelId );
  370. $("#model").children('option:not(:first)').remove();
  371. $("#model").append(modelHtml);
  372. $("#model").val(selectedModelId);
  373. }
  374. });
  375. return select;
  376. }}},
  377. {name:'model', index:'model', width:80, align:'right',editable:true,edittype:"select",editoptions:{dataUrl:"index.php/products/doNothing",buildSelect:function(response)
  378. {
  379. //console.log("build select");
  380. var select = "<select name=" + "modelOpEdit" + "id =" +"modelOpEdit" +">" +
  381. "<option value=" + ">Select one..." + "</select>";
  382. return select;
  383. }}},
  384. {name:'supplier', index:'supplier', width:80, align:'right',editable:true,editoptions:{size:"20",maxlength:"30"}},
  385. {name:'package_id', index:'package_id', hidden:true},
  386. {name:'package_name', index:'package_name', width:80, align:'right',editable:true,edittype:"select",editoptions:{dataEvents: [
  387. { type: 'change',
  388. fn: function(e) {
  389. var val = $("#package_name").val();
  390. //console.log ("while changing" + val)
  391. $.ajax({type:"post",
  392. url:"index.php/products/populateMeasurementDropDowns",
  393. data: {pkgId : val},
  394. success: function(uomHtml){
  395. //console.log ("in success " + val);
  396. //console.log ("in success uomHtml " + uomHtml);
  397. $("#uom").children('option:not(:first)').remove();
  398. $("#uom").append(uomHtml);
  399. }
  400. });
  401. }
  402. }
  403. ],dataUrl:"index.php/products/populatePackages",buildSelect:function(response)
  404. {
  405. var select = "<select name=" + "mfrPkEdit" + "id =" +"mfrPkEdit" +">" +
  406. "<option value=" + ">Select one..." + response + "</select>";
  407. //console.log ("package type val " + selectedPkgId);
  408. $.ajax({type:"post",
  409. url:"index.php/products/populateMeasurementDropDowns",
  410. data: {pkgId : selectedPkgId},
  411. success: function(uomHtml){
  412. $("#uom").children('option:not(:first)').remove();
  413. $("#uom").append(uomHtml);
  414. //console.log ("before setting uom val " + selectUom);
  415. $("#uom").val(selectUom);
  416. }
  417. });
  418. return select;
  419. }}},
  420. // {name:'category', index:'category', width:100, align:'right',editable:false,editoptions:{size:"20",maxlength:"30"}},
  421. {name:'uom', index:'uom', width:40, align:'right',editable:true,edittype:"select",editoptions:{dataEvents: [
  422. { type: 'change',
  423. fn: function(e) {
  424. var val = $("#uom").val();
  425. //console.log ("while changing uom" + val)
  426. $.ajax({type:"post",
  427. url:"index.php/products/populateDenomDropdown",
  428. data: {uom : val},
  429. success: function(sizeHtml){
  430. if (sizeHtml!=null && sizeHtml!="") {
  431. if ($("#measurement_denomination").is(':disabled')){
  432. $("#measurement_denomination").attr('disabled','false');
  433. }
  434. $("#measurement_denomination").children('option:not(:first)').remove();
  435. $("#measurement_denomination").append(sizeHtml);
  436. }
  437. else {
  438. if (!$("#measurement_denomination").is(':disabled')){
  439. $("#measurement_denomination").attr('disabled','true');
  440. }
  441. }
  442. }
  443. });
  444. }
  445. }
  446. ],dataUrl:"index.php/products/populateMeasurementDropDowns",buildSelect:function(response)
  447. {
  448. var val = selectUom;
  449. //console.log("build uom" + val);
  450. var select = "<select name=" + "modelOpEdit" + "id =" +"modelOpEdit" +">" +
  451. "<option value=" + ">Select one..." + "</select>";
  452. return select;
  453. }}},
  454. {name:'measurement_denomination', index:'measurement_denomination', width:60, align:'right',editable:true,edittype:"select",editoptions:{dataUrl:"index.php/products/doNothing",buildSelect:function(response)
  455. {
  456. var val = selectUom;
  457. //console.log("build size" + val);
  458. var select = "<select name=" + "modelOpEdit" + "id =" +"modelOpEdit" +">" +
  459. "<option value=" + ">Select one..." + "</select>";
  460. $.ajax({type:"post",
  461. url:"index.php/products/populateDenomDropdown",
  462. data: {uom : val},
  463. success: function(sizeHtml){
  464. if (sizeHtml!=null && sizeHtml!="") {
  465. if ($("#measurement_denomination").is(':disabled')){
  466. $("#measurement_denomination").attr('disabled','false');
  467. }
  468. //console.log ("measurement denom " + sizeHtml);
  469. //console.log ("measurement denom sel " + selectedDenom);
  470. $("#measurement_denomination").children('option:not(:first)').remove();
  471. $("#measurement_denomination").append(sizeHtml);
  472. $("#measurement_denomination").val(selectedDenom);
  473. }
  474. else {
  475. if (!$("#measurement_denomination").is(':disabled')){
  476. $("#measurement_denomination").attr('disabled','true');
  477. }
  478. }
  479. }
  480. });
  481. return select;
  482. }}},
  483. //{name:'isactive', index:'isactive', width:30, align:'right',editable:true,edittype:"select", formatter:'select', editoptions:{value:"1:Yes;0:No"}}
  484. {name:'generate', index:'generate', width:80, align:'right',editable:false,search:false,formatter:'showlink', formatoptions:{baseLinkUrl:'index.php/products/printBarcode'},cellattr: function (rowId, val, rawObject, cm, rdata)
  485. {
  486. //console.log(rawObject[0]);
  487. return 'title="' + rawObject[0]+'"';
  488. }}
  489. ],
  490. pager: '#pager',
  491. rowNum:10,
  492. rowList:[5,10,20],
  493. sortname: 'id',
  494. sortorder: 'desc',
  495. viewrecords: true,
  496. gridview: true,
  497. ignoreCase:true,
  498. rownumbers:true,
  499. caption: 'Products',
  500. multiselect:true,
  501. height: '100%',
  502. width:'90%',
  503. jsonReader : {
  504. root:"productdata",
  505. page: "page",
  506. total: "total",
  507. records: "records",
  508. cell: "dprow",
  509. id: "id"
  510. },
  511. onSelectRow: function(id){
  512. lastsel2 = id;
  513. selectedMfrId = myGrid.jqGrid("getCell",id,"manufacturer_id");
  514. selectedModelId = myGrid.jqGrid("getCell",id,"model_id");
  515. selectedPkgId = myGrid.jqGrid("getCell",id,"package_id");
  516. selectUom = myGrid.jqGrid("getCell",id,"uom");
  517. selectedDenom = myGrid.jqGrid("getCell",id,"measurement_denomination");
  518. //console.log("sel mfr " + selectedMfrId);
  519. //console.log("sel model " + selectedModelId);
  520. //console.log("sel pkg " + selectedPkgId);
  521. //console.log("sel uom " + selectUom);
  522. //console.log("sel denom " + selectedDenom);
  523. },
  524. editurl:'index.php/products/editProduct',
  525. postData:{"test":"val"}
  526. }).navGrid("#pager",{edit:true,add:false,del:false,search:false},{height:280,reloadAfterSubmit:false,closeAfterEdit:true,recreateForm:true,checkOnSubmit:true},{},{},{},{});
  527. myGrid.jqGrid('navButtonAdd','#pager',{
  528. caption:"",
  529. title:"Export as csv",
  530. id:"export_product",
  531. onClickButton : function () {
  532. myGrid.jqGrid('excelExport',{tag:"csv","url":"index.php/products/exportProductsInGrid"});
  533. }
  534. });
  535. myGrid.jqGrid('navButtonAdd','#pager',{
  536. caption:"",
  537. title:"Create Product",
  538. buttonicon:"ui-icon-plus",
  539. id:"add_product",
  540. onClickButton : function () {
  541. //if (!$("#newModelCtnr").parent().is(':hidden')){
  542. $("#newModelCtnr").parent().css("display","none");
  543. //}
  544. //if (!$("#modelCtnr").parent().is(':hidden')){
  545. $("#modelCtnr").parent().css("display","none");
  546. //}
  547. $( "#dialog-form" ).dialog( "open" );
  548. }
  549. });
  550. myGrid.jqGrid('navButtonAdd','#pager',{
  551. caption:"",
  552. title:"Mark as inactive",
  553. id:"inactive_product",
  554. buttonicon:"ui-icon-locked",
  555. onClickButton : function (id) {
  556. var rowid = myGrid.jqGrid('getGridParam', 'selarrrow');
  557. $.ajax({type:"post",
  558. url:"index.php/products/deactivate",
  559. data: {ids : rowid},
  560. success: function(){
  561. $("#product").trigger("reloadGrid");
  562. }
  563. });
  564. }
  565. });
  566. myGrid.jqGrid('navButtonAdd','#pager',{
  567. caption:"",
  568. title:"Mark as active",
  569. id:"active_product",
  570. buttonicon:"ui-icon-unlocked",
  571. onClickButton : function (id) {
  572. var rowid = myGrid.jqGrid('getGridParam', 'selarrrow');
  573. var rowid = myGrid.jqGrid('getGridParam', 'selarrrow');
  574. $.ajax({type:"post",
  575. url:"index.php/products/activate",
  576. data: {ids : rowid},
  577. success: function(){
  578. $("#product").trigger("reloadGrid");
  579. }
  580. });
  581. }
  582. });
  583. myGrid.jqGrid('navButtonAdd','#pager',{
  584. caption:"",
  585. title:"Load all ",
  586. id:"load_product",
  587. buttonicon:"ui-icon-arrow-4-diag",
  588. onClickButton : function (id) {
  589. var rowid = myGrid.jqGrid('getGridParam', 'selarrrow');
  590. var rowid = myGrid.jqGrid('getGridParam', 'selarrrow');
  591. $.ajax({type:"post",
  592. url:"index.php/products/populateProductsInGrid",
  593. data: {loadall : true},
  594. success: function(response){
  595. //$("#product").trigger("reloadGrid");
  596. var grid = jQuery("#product")[0];
  597. var myjsongrid = eval("("+response+")");
  598. grid.addJSONData(myjsongrid);
  599. }
  600. });
  601. }
  602. });
  603. myGrid.jqGrid ('navButtonAdd', '#pager',
  604. { caption: "", buttonicon: "ui-icon-calculator",
  605. title: "Choose Columns",
  606. onClickButton: function() {
  607. myGrid.jqGrid('columnChooser');
  608. }
  609. });
  610. $("#add_product").insertBefore("#edit_product");
  611. myGrid.jqGrid('filterToolbar', {stringResult: true, searchOnEnter: true, defaultSearch : "cn"});
  612. $("#treeViewDiv")
  613. .jstree({
  614. "plugins" : ["themes", "json_data", "ui"],
  615. "json_data" : {
  616. "ajax" : {
  617. "type": 'GET',
  618. "url": function (node) {
  619. var nodeId = "";
  620. var url = ""
  621. if (node == -1)
  622. {
  623. url = "index.php/utilities/renderParents";
  624. }
  625. else
  626. {
  627. nodeId = node.attr('id');
  628. url = "index.php/utilities/renderChildren";
  629. }
  630. return url;
  631. },
  632. data : function(node) {
  633. if (node != -1){
  634. return {
  635. "nodeid":$.trim(node.attr('id'))
  636. }
  637. }
  638. },
  639. "success": function (new_data) {
  640. return new_data;
  641. }
  642. }
  643. }})
  644. });
  645. </script>
  646. </head>
  647. <body>
  648. <?php $this->load->view("common/menubar"); ?>
  649. <!-- <button id="create-product">Create New Product</button> -->
  650. <!--<button id="inv-management" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"><span class="ui-button-text"> Manage Inventory</span></button>-->
  651. <div id ="dialog-form">
  652. <h1 id="formHeader">Add New Product Entity</h1>
  653. <form id="productForm">
  654. <fieldset>
  655. <div class="row">
  656. <div class="column">
  657. <div class="field">
  658. <label for="hasBarcode">Product Do Not Have Barcode</label>
  659. <input id="hasBarcode" name ="hasBarcode" type="checkbox"/>
  660. </div>
  661. </div>
  662. <div class="column">
  663. <div class="field">
  664. <label for="productbarcode" >Scan/ Type Barcode:</label>
  665. <input id="productbarcode" name ="productbarcode" type="text" class="required"/>
  666. </div>
  667. </div>
  668. </div>
  669. <div class="row">
  670. <div class="column">
  671. <div class="field">
  672. <label for="name">Name of Product Entity:</label>
  673. <input id="name" name ="name" type="text" class="required"/>
  674. </div>
  675. </div>
  676. <div class="column">
  677. <div class="field">
  678. <label for="attributeSetOp">Attribute Set:</label>
  679. <select name="attributeSetOp" id ="attributeSetOp" class="required">
  680. <option value="">Choose
  681. <?= $attributeSetOptions ?>
  682. </select>
  683. </div>
  684. </div>
  685. </div>
  686. <div class="row">
  687. <div class="column">
  688. <div class="field">
  689. <label for="desc">Description:</label>
  690. <textarea id="desc" name ="desc" rows="10" cols="30" class="required"></textarea>
  691. </div>
  692. </div>
  693. <div class="column">
  694. <div class="field">
  695. <label for="desc">Meta Description:</label>
  696. <textarea id="metadesc" name ="metadesc" rows="10" cols="30"></textarea>
  697. </div>
  698. </div>
  699. </div>
  700. <div class="row">
  701. <div class="column">
  702. <div id="mfrCtnr">
  703. <div class="ui-widget field">
  704. <label for="mfrOp">Manufacturer:</label>
  705. <select name="mfrOp" id ="mfrOp">
  706. <option value="">Select one...
  707. <?= $mfrOptions?>
  708. </select>
  709. <input id="reqBarcodeMfr" name ="reqBarcodeMfr" type="checkbox" class="reqBarcode reqBarcodeAC"/>
  710. </div>
  711. </div>
  712. </div>
  713. <div class="column" style="display:none">
  714. <div id="modelCtnr">
  715. <div class="ui-widget field">
  716. <label for="modelOp">Model :</label>
  717. <select name="modelOp" id ="modelOp" >
  718. <option value="">Select one...
  719. <?= $modelOptions?>
  720. </select>
  721. <input id="reqBarcodeModel" name ="reqBarcodeModel" type="checkbox" class="reqBarcode reqBarcodeAC"/>
  722. </div>
  723. </div>
  724. </div>
  725. <div class="column" style="display:none">
  726. <div id="newModelCtnr">
  727. <div class="field">
  728. <label for="newModelIp">Specify New Model Type :</label>
  729. <input id="newModelIp" name ="newModelIp" type="text"/>
  730. </div>
  731. </div>
  732. </div>
  733. </div>
  734. <div class="row">
  735. <div class="column">
  736. <div class="field">
  737. <label for="categoryOp">Category:</label>
  738. <!-- <select name="categoryOp" id ="categoryOp" >
  739. <option value="">Choose
  740. <?= $categoryOptions ?>
  741. </select>-->
  742. <div id="treeViewDiv" style="display:inline-block">
  743. </div>
  744. <!--<input id="categoryReq" name ="reqBarcodeCat" type="checkbox" class="reqBarcodeAC "/>-->
  745. </div>
  746. </div>
  747. <div class="column">
  748. <div class="field">
  749. <label for="supplierOp">Supplier:</label>
  750. <select name="supplierOp" id ="supplierOp" class="opt required">
  751. <option value=0>Choose
  752. <?= $supplierOptions ?>
  753. </select>
  754. <input id="reqBarcodeSupp" name ="reqBarcodeSupp" type="checkbox" class="reqBarcode"/>
  755. </div>
  756. </div>
  757. </div>
  758. <div class="row">
  759. <div class="column">
  760. <div class="field">
  761. <label for="packageOp">Package:</label>
  762. <select name="packageOp" id ="packageOp" class="required">
  763. <option value="">Choose
  764. <?= $pkgOptions ?>
  765. </select>
  766. </div>
  767. </div>
  768. <div class="column">
  769. <div class="field">
  770. <label for="reorderLevel">Reorder Level :</label>
  771. <input id="reorderLevel" name="reorderLevel" type="text"/>
  772. </div>
  773. </div>
  774. </div>
  775. <div class="row">
  776. <div class="column">
  777. <div class="field">
  778. <label for="uomOp">Unit Of Measurement:</label>
  779. <select name="uomOp" id ="uomOp" class="required">
  780. <option value="">Choose
  781. </select>
  782. </div>
  783. </div>
  784. <div class="column">
  785. <div class="field" style="display:none">
  786. <label for="sizeOp">Measurement Denomination:</label>
  787. <select name="sizeOp" id ="sizeOp" class="required">
  788. <option value="">Choose
  789. </select>
  790. </div>
  791. </div>
  792. </div>
  793. <div class="row">
  794. <div class="column">
  795. <div class="field">
  796. <label for="costPrice">Cost Price :</label>
  797. <input id="costPrice" name="costPrice" type="text"/>
  798. </div>
  799. </div>
  800. <div class="column">
  801. <div class="field">
  802. <label for="price">Final Price :</label>
  803. <input id="price" name="price" type="text"/>
  804. </div>
  805. </div>
  806. </div>
  807. </fieldset>
  808. </form>
  809. </div>
  810. <div style="display: block;height: 100%;width:90%;left:0em;" class="shopifine-ui-dialog ui-widget ui-widget-content ui-corner-all" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-dialog-form">
  811. <?php $this->load->view("common/message"); ?>
  812. <table id="product"><tr><td/></tr></table>
  813. <div id="pager"></div>
  814. </div>
  815. <!-- <button id="create-product">Create New Product</button>-->
  816. <!-- <div id="feedback_bar"></div>-->
  817. <?php $this->load->view("partial/footer"); ?>
  818. </body>
  819. </html>
  820. <script type="text/javascript">
  821. $("#packageOp").change(function(){
  822. var val = $(this).val();
  823. $.ajax({type:"post",
  824. url:"index.php/products/populateMeasurementDropDowns",
  825. data: {pkgId : val},
  826. success: function(uomHtml){
  827. $("#uomOp").children('option:not(:first)').remove();
  828. $("#uomOp").append(uomHtml);
  829. }
  830. });
  831. });
  832. $("#uomOp").change(function(){
  833. var val = $(this).val();
  834. $.ajax({type:"post",
  835. url:"index.php/products/populateDenomDropdown",
  836. data: {uom : val},
  837. success: function(uomHtml){
  838. if (uomHtml!=null && uomHtml!="") {
  839. if ($("#sizeOp").parent().is(':hidden')){
  840. $("#sizeOp").parent().slideDown(50);
  841. }
  842. $("#sizeOp").children('option:not(:first)').remove();
  843. $("#sizeOp").append(uomHtml);
  844. }
  845. else {
  846. if (!$("#sizeOp").parent().is(':hidden')){
  847. $("#sizeOp").parent().slideUp(50);
  848. }
  849. }
  850. }
  851. });
  852. });
  853. $(".reqBarcodeAC").change(function (){
  854. var checked = $(this).is(':checked');
  855. if (checked){
  856. $(this).parent().find('select').addClass("comboBoxrequired");
  857. }
  858. else {
  859. $(this).parent().find('select').removeClass("comboBoxrequired");
  860. }
  861. })
  862. // $(".reqBarcodetree").change(function (){
  863. // var checked = $(this).is(':checked');
  864. // if (checked){
  865. // $(this).parent().find('select').addClass("comboBoxrequired");
  866. //
  867. // }
  868. // else {
  869. // $(this).parent().find('select').removeClass("comboBoxrequired");
  870. // }
  871. // })
  872. $("#hasBarcode").change(function (){
  873. var checked = $(this).is(':checked');
  874. if (checked){
  875. $("#productbarcode").attr('disabled',true)
  876. }
  877. else {
  878. $("#productbarcode").attr('disabled',false)
  879. }
  880. })
  881. $("#inv-management").click(function (){
  882. document.location.href="index.php/products/loadInventory";
  883. })
  884. </script>