PageRenderTime 89ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/magehelp/application/views/pricelist/define_pricelist.php

https://bitbucket.org/jit_bec/shopifine
PHP | 1246 lines | 1038 code | 141 blank | 67 comment | 59 complexity | 673bbd6c39d48baba8711e8f54ca6ca6 MD5 | raw file
Possible License(s): LGPL-3.0
  1. <html>
  2. <head>
  3. <?php $this->load->view("common/header"); ?>
  4. <link rel="stylesheet" rev="stylesheet" href="<?php echo base_url();?>css/chosen.css" />
  5. <script src="<?php echo base_url();?>js/chosen.jquery.min.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
  6. <!-- <script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>-->
  7. <style>
  8. .column {
  9. float: left;
  10. padding: 1em;
  11. width:100%;
  12. }
  13. .extra-wide{
  14. width:95%;
  15. }
  16. .field{
  17. width:100%;
  18. }
  19. .ui-widget-header {height:12px;}
  20. .ui-combobox {
  21. width:14em;
  22. }
  23. .ui-combobox-input{
  24. width:12em;
  25. }
  26. #supplierOp-input{
  27. width:10em;
  28. }
  29. #warehouseOp-input{
  30. width:10em;
  31. }
  32. .calculated {
  33. color: green;
  34. font-size: 90%;
  35. }
  36. .row{
  37. width:100%;
  38. }
  39. .shopifine-ro-label {
  40. float: left;
  41. padding-right: 0.5em;
  42. width: 50%;
  43. word-wrap: break-word;
  44. color:#2E6E9E;
  45. font-size: 110%
  46. }
  47. .shopifine-output {
  48. float: right;
  49. width: 45%;
  50. word-wrap: break-word;
  51. font-weight:bold;
  52. }
  53. .ui-tabs {
  54. height: 80%;
  55. margin: 0 auto;
  56. width: 85%;
  57. left:0;
  58. }
  59. #notetab {
  60. height:30em;
  61. }
  62. #details {
  63. height:12em;
  64. }
  65. .ui-tabs-nav{
  66. height:22px;
  67. }
  68. .labeldiv {
  69. color: #2E6E9E;
  70. float: left;
  71. font-size: 110%;
  72. font-weight: bold;
  73. margin-right: .5em;
  74. width: 18%;
  75. word-wrap: break-word;
  76. }
  77. .valuediv {
  78. float: left;
  79. font-weight: bold;
  80. width: 45%;
  81. word-wrap: break-word;
  82. }
  83. label.error {
  84. width:8em ;
  85. margin-right: 0;
  86. }
  87. #status-message-li{
  88. color: red;
  89. font-size: 110%;
  90. font-style: italic;
  91. margin: 0 auto;
  92. width: 80%;
  93. }
  94. .help-message-left{
  95. color: green;
  96. font-size: 90%;
  97. font-style: italic;
  98. margin: 0 auto;
  99. width: 90%;
  100. float:left
  101. }
  102. .chzn-container{
  103. font-size:inherit;
  104. }
  105. fieldset{
  106. padding: 1em;
  107. margin-top: 0;
  108. }
  109. .single-column-row-item{
  110. margin-left:0;
  111. }
  112. .edit-column{
  113. width:46%;
  114. }
  115. .labeldiv-edit{width:25%}
  116. .valuediv-edit{width:70%}
  117. #content_area{width:80%}
  118. </style>
  119. <script type="text/javascript">
  120. $(function() {
  121. $.validator.addMethod('productrequired', function(value, element) {
  122. var products = $("#productOptions").val();
  123. value = $("#"+element.id).is(":checked");
  124. if (!value && products == null){
  125. return false;
  126. }
  127. return true;
  128. }, 'Select From Products Dropdownor Select Apply To All CheckBox ');
  129. $("#itemForm").validate({
  130. rules:{
  131. allCB:{productrequired:true}
  132. }
  133. });
  134. $("#pricelistForm").validate({});
  135. $("#pricelistFormEdit").validate({});
  136. $("#priceFormEdit").validate({});
  137. // datepicker for Add Form
  138. $( "#validfrom ,#validto ,#validfrom_edit, #validto_edit" ).datepicker({
  139. showOn: "button",
  140. buttonImage: "images/calendar.gif",
  141. buttonImageOnly: true,
  142. dateFormat:"dd/mm/yy",
  143. minDate:0
  144. });
  145. //end datepicker
  146. $( "#dialog-form" ).dialog({
  147. autoOpen: false,
  148. height: 'auto',
  149. width: '65%',
  150. position:[220,25],
  151. modal: true,
  152. buttons: {
  153. "DoneButton": {
  154. id:"doneBtn",
  155. text:"Done",
  156. click:function() {
  157. var isValid = $("#pricelistFormEdit").valid();
  158. //
  159. if (isValid){
  160. $.ajax({url:"index.php/procurement/createPricelist",
  161. type:"POST",
  162. data:{ pricelistId:myGrid.getGridParam('selrow'),
  163. isactive:$("#active_edit").val(),
  164. validfrom:$("#validfrom_edit").val(),
  165. validto:$("#validto_edit").val(),
  166. ischanged:$("#ischanged").val(),
  167. typeOp:$("#type_edit").text()
  168. },
  169. success:function(response)
  170. {
  171. } //end success of Ajax
  172. }) //end ajax
  173. $( this ).dialog( "close" );
  174. } //end ifvalid
  175. }}, //end of Create button
  176. Cancel: function() {
  177. //in cancel just recset notes
  178. $("#receivingNotes").val("");
  179. $( this ).dialog( "close" );
  180. }
  181. },//end buttons
  182. open: function(){
  183. var pricelist_id = myGrid.getGridParam('selrow');
  184. var supplier_id = myGrid.getCell(pricelist_id,'supplier_id');
  185. $("#pl_name_edit").text(myGrid.getCell(pricelist_id,'name'));
  186. $("#supplier_name_edit").text(myGrid.getCell(pricelist_id,'supplier_name'));
  187. $("#type_edit").text(myGrid.getCell(pricelist_id,'type'));
  188. $("#active_edit").val(myGrid.getCell(pricelist_id,'active'));
  189. if (myGrid.getCell(pricelist_id,'type')=='version'){
  190. $("#versionCntnrEdit").show();
  191. $("#bv_edit").text(myGrid.getCell(pricelist_id,'parent_name'));
  192. $("#vn_edit").text(myGrid.getCell(pricelist_id,'version'));
  193. var d1 =Date.parse(myGrid.getCell(pricelist_id,'valid_from'));
  194. $("#validfrom_edit").val(d1.toString('dd/MM/yyyy'));
  195. d1 =Date.parse(myGrid.getCell(pricelist_id,'valid_to'));
  196. $("#validto_edit").val(d1.toString('dd/MM/yyyy'));
  197. }
  198. //$("#pricelistRef").text(myGrid.getCell(pricelist_id,'name'));
  199. $("#price_grid").jqGrid({
  200. url:'index.php/procurement/populatePriceData',
  201. datatype: 'json',
  202. mtype: 'POST',
  203. postData:{pricelist_id: pricelist_id,supplier_id:supplier_id},
  204. colNames:['LI','Barcode','Product','Product Id','Manufacturer','Model','Base Price','Inherited'],
  205. colModel :[
  206. {name:'lineitem_id', index:'lineitem_id',hidden:true},
  207. {name:'barcode', index:'barcode',editable:false, width:100, align:'right'},
  208. {name:'product_name', index:'product_name',editable:false, width:100, align:'right'},
  209. {name:'product_id', index:'product_id',hidden:true},
  210. {name:'manufacturer', index:'manufacturer', editable:true,width:80, align:'right'},
  211. {name:'model',index:'model',editable:true, width:80, align:'right'},
  212. {name:'base_price',index:'base_price',editable:true, width:80, align:'right'},
  213. {name:'inherited',index:'inherited',editable:true, width:40, align:'right'},
  214. ],
  215. pager: '#pagerPk',
  216. rowNum:10,
  217. rowList:[5,10,20],
  218. sortname: 'id',
  219. sortorder: 'asc',
  220. viewrecords: true,
  221. gridview: true,
  222. ignoreCase:true,
  223. rownumbers:true,
  224. height:'auto',
  225. width:680,
  226. caption: 'Line Items',
  227. jsonReader : {
  228. root:"ratecontractdata",
  229. page: "page",
  230. total: "total",
  231. records: "records",
  232. cell: "dprow",
  233. id: "id"
  234. },
  235. onSelectRow: function(ids) {
  236. var product_id = $("#price_grid").getCell(ids,'product_id');
  237. var product_name = $("#price_grid").getCell(ids,'product_name');
  238. var pricelist_id= myGrid.getGridParam('selrow');
  239. if(ids == null) {
  240. if(jQuery("#rules_grid").jqGrid('getGridParam','records') >0 )
  241. {
  242. jQuery("#rules_grid").jqGrid('setGridParam',{url:"index.php/procurement/populatePriceRules?pricelist_id=0",page:1});
  243. jQuery("#rules_grid").jqGrid('setCaption',"Price Rules For The Product "+ids)
  244. .trigger('reloadGrid');
  245. }
  246. } else {
  247. jQuery("#rules_grid").jqGrid('setGridParam',{url:"index.php/procurement/populatePriceRules?pricelist_id="+pricelist_id+"&product_id="+product_id,page:1});
  248. jQuery("#rules_grid").jqGrid('setCaption',"Price Rules For The Product "+product_name)
  249. .trigger('reloadGrid');
  250. }
  251. },
  252. editurl:'index.php/procurement/modifyQuoteItem'
  253. }).navGrid("#pagerPk",{view:true,edit:false,add:false,del:false,search:false},{},{},{},{},{});
  254. $("#price_grid").jqGrid('filterToolbar', {stringResult: true, searchOnEnter: true, defaultSearch : "cn"});
  255. $("#price_grid").jqGrid('navButtonAdd','#pagerPk',{
  256. caption:"",
  257. title:"Add Pricing Details",
  258. buttonicon:"ui-icon-plus",
  259. id:"add_price_grid",
  260. onClickButton : function () {
  261. //need to pass grid id for dynamic reload;
  262. var gridData ={'grid_id':'price_grid','pricelist_id':myGrid.getGridParam('selrow'),'action':'add_price','url':'index.php/procurement/addSupplierRate'};
  263. $( "#dialog-form-item" ).data('grid_data',gridData).dialog( "open" );
  264. }
  265. });
  266. $("#price_grid").jqGrid('navButtonAdd','#pagerPk',{
  267. caption:"",
  268. title:"Edit Price",
  269. buttonicon:"ui-icon-pencil",
  270. id:"edit_price_grid",
  271. onClickButton : function () {
  272. //need to pass grid id for dynamic reload;
  273. var rowid = $("#price_grid").getGridParam('selrow');
  274. if (rowid !=null && rowid!=undefined){
  275. if ($("#price_grid").getCell(rowid,'inherited') == "No"){
  276. $( "#dialog-price-edit" ).dialog( "open" );
  277. }
  278. else {
  279. $( "#modal-warning-inherited" ).dialog( "open" );
  280. }
  281. }
  282. else {
  283. $( "#modal-warning" ).dialog( "open" );
  284. }
  285. }
  286. });
  287. $("#price_grid").jqGrid('navButtonAdd','#pagerPk',{
  288. caption:"",
  289. title:"Delete Price",
  290. buttonicon:"ui-icon-trash",
  291. id:"delete_price_grid",
  292. onClickButton : function () {
  293. //need to pass grid id for dynamic reload;
  294. var rowid = $("#price_grid").getGridParam('selrow');
  295. if (rowid !=null && rowid!=undefined){
  296. if ($("#price_grid").getCell(rowid,'inherited') == "No"){
  297. var gridData ={'grid_id':'price_grid',
  298. 'id':$("#price_grid").getCell(rowid,'lineitem_id'),'url':"index.php/procurement/deletePrice"}
  299. $( "#dialog-confirm" ).data('grid_data',gridData).dialog( "open" );
  300. }
  301. else {
  302. $( "#modal-warning-inherited" ).dialog( "open" );
  303. }
  304. }
  305. else {
  306. $( "#modal-warning" ).dialog( "open" );
  307. }
  308. }
  309. });
  310. $("#del_price_grid").insertAfter("#edit_price_grid");
  311. // jQuery("#rules_grid").jqGrid({
  312. // height: 'auto',
  313. // url:'index.php/procurement/populatePriceRules?pricelist_id=0',
  314. // datatype: "json",
  315. // colNames:[/*'Product ',*/'Rule Type', 'Inherited','Precedence', 'Qualifier','Condition', 'Discount Type','Value','Operator','Qual Val Frm','Qual Val To','Qual Val Pnt'],
  316. // colModel:[
  317. //// {name:'product_name',index:'product_name', width:55,editable:false},
  318. // {name:'rule_type',index:'rule_type', width:80},
  319. // {name:'inherited',index:'inherited', width:60},
  320. // {name:'precedence',index:'precedence', width:60, align:"right"},
  321. //
  322. // {name:'qualifier',index:'qualifier', width:60, align:"right"},
  323. // {name:'condition',index:'condition', width:180,align:"right", sortable:false, search:false,editable:false},
  324. // {name:'discount_type',index:'discount_type', width:80, align:"right"},
  325. // {name:'discount_value',index:'discount_value', width:80,align:"right", sortable:false, search:false,editable:false},
  326. // {name:'operator',index:'operator', hidden:true},
  327. // {name:'qualifier_value_from',index:'qualifier_value_from', hidden:true},
  328. // {name:'qualifier_value_to',index:'qualifier_value_to', hidden:true},
  329. // {name:'qualifier_value_point',index:'qualifier_value_point', hidden:true}
  330. // ],
  331. // rowNum:5,
  332. // rowList:[5,10,20],
  333. // pager: '#pagerRules',
  334. // sortname: 'product_name',
  335. // viewrecords: true,
  336. // sortorder: "asc",
  337. // multiselect: true,
  338. // caption:"Price Rules",
  339. // jsonReader : {
  340. // root:"rulesdata",
  341. // page: "page",
  342. // total: "total",
  343. // records: "records",
  344. // cell: "dprow",
  345. // id: "id"
  346. // }
  347. // }).navGrid('#pagerRules',{add:false,edit:false,del:false,view:true});
  348. var settingsObj = {grid_id:'rules_grid',pager:'pagerRules'};
  349. prepareRulesGrid(settingsObj);
  350. $("#rules_grid").navGrid('#pagerRules',{add:false,edit:false,del:false,view:true});
  351. $("#rules_grid").jqGrid('navButtonAdd','#pagerRules',{
  352. caption:"",
  353. title:"Add Rules",
  354. buttonicon:"ui-icon-plus",
  355. id:"add_rules_grid",
  356. onClickButton : function () {
  357. //need to pass grid id for dynamic reload;
  358. var gridData ={'grid_id':'rules_grid','action':'add_rule','pricelist_id':myGrid.getGridParam('selrow'),'url':'index.php/procurement/addSupplierRule'};
  359. $( "#dialog-form-item" ).data('grid_data',gridData).dialog( "open" );
  360. }
  361. });
  362. $("#rules_grid").jqGrid('navButtonAdd','#pagerRules',{
  363. caption:"",
  364. title:"Edit Rules",
  365. buttonicon:"ui-icon-pencil",
  366. id:"edit_rules_grid",
  367. onClickButton : function () {
  368. //need to pass grid id for dynamic reload;
  369. var rowid = $("#rules_grid").getGridParam('selrow');
  370. if (rowid !=null && rowid!=undefined){
  371. var gridData ={'grid_id':'rules_grid','action':'edit_rule','pricelist_id':myGrid.getGridParam('selrow'),'url':'index.php/procurement/addSupplierRule'};
  372. $( "#dialog-form-item" ).data('grid_data',gridData).dialog( "open" );
  373. }
  374. else {
  375. $( "#modal-warning" ).dialog( "open" );
  376. }
  377. }
  378. });
  379. },
  380. close: function() {
  381. $("#pricelistFormEdit").data('validator').resetForm();
  382. $('#pricelistFormEdit')[0].reset();
  383. $("#versionCntnrEdit").hide();
  384. $("#pricelistFormEdit .valuediv").text("");
  385. $("#price_grid").jqGrid("GridUnload");
  386. $("#rules_grid").jqGrid("GridUnload");
  387. $("#pricelist_grid").trigger("reloadGrid");
  388. }
  389. });
  390. // Main Request For Quotation Grid
  391. var myGrid = $("#pricelist_grid"),lastsel2;
  392. myGrid.jqGrid({
  393. url:'index.php/procurement/populatePriceLists',
  394. datatype: 'json',
  395. mtype: 'GET',
  396. colNames:['Name','Parent Name','Supplier Id','Supplier','Valid From','Valid Till','Active','Type','Version'],
  397. colModel :[
  398. {name:'name', index:'name', width:220, align:'right',editable:false,searchoptions: { sopt: ['cn','eq']}},
  399. {name:'parent_name', index:'parent_name', width:220, align:'right',editable:false,searchoptions: { sopt: ['cn','eq']}},
  400. {name:'supplier_id', index:'supplier_id',hidden:true},
  401. {name:'supplier_name', index:'supplier_name', width:100, align:'right',editable:false,searchoptions: { sopt: ['cn','eq']}},
  402. {name:'valid_from', index:'valid_from', width:80, align:'right',editable:true,sorttype:"date",searchoptions: { sopt: ['eq', 'ne','ge','lt','gt','le'],
  403. dataInit: function (elem) { $(elem).datepicker({ showButtonPanel: true,dateFormat:"yy-mm-dd" }) } }},
  404. {name:'valid_to', index:'valid_to', width:80, align:'right',editable:true,sorttype:"date",searchoptions: { sopt: ['eq', 'ne','ge','lt','gt','le'],
  405. dataInit: function (elem) { $(elem).datepicker({ showButtonPanel: true,dateFormat:"yy-mm-dd"}) } }},
  406. {name:'active', index:'active', width:40, align:'right',editable:true,edittype:"select", formatter:'select', editoptions:{value:"1:Yes;0:No"},searchoptions: { sopt: ['eq']}},
  407. {name:'type', index:'type',editable:false, width:40, align:'right',searchoptions: { sopt: ['eq']}},
  408. {name:'version', index:'version',editable:false, width:40,align:'center',searchoptions: { sopt: ['eq']}}
  409. ],
  410. pager: '#pager',
  411. rowNum:10,
  412. rowList:[5,10,20],
  413. sortname: 'id',
  414. sortorder: 'desc',
  415. viewrecords: true,
  416. gridview: true,
  417. ignoreCase:true,
  418. rownumbers:true,
  419. height:'auto',
  420. width:800,
  421. caption: 'Pricelists',
  422. jsonReader : {
  423. root:"pricelistdata",
  424. page: "page",
  425. total: "total",
  426. records: "records",
  427. cell: "dprow",
  428. id: "id"
  429. }
  430. }).navGrid("#pager",{edit:false,add:false,view:false,del:false,search:true},{},{},{},{multipleSearch:true},{});
  431. myGrid.jqGrid('navButtonAdd','#pager',{
  432. caption:"",
  433. title:"Edit Price List",
  434. buttonicon:"ui-icon-pencil",
  435. id:"add_pricelist_grid",
  436. onClickButton : function () {
  437. var rowid = myGrid.getGridParam('selrow');
  438. if (rowid!=null && rowid!=undefined){
  439. $( "#dialog-form" ).dialog('option', 'title', 'Details Of ' + myGrid.getCell(myGrid.getGridParam('selrow'),'name') + ' Pricelist');
  440. $( "#dialog-form" ).dialog( "open" );
  441. }
  442. else {
  443. $( "#modal-warning" ).dialog("open") ;
  444. }
  445. }
  446. });
  447. myGrid.jqGrid('filterToolbar', {stringResult: true, searchOnEnter: true, defaultSearch : "cn"});
  448. //line item dialog
  449. $( "#dialog-form-item" ).dialog({
  450. autoOpen: false,
  451. height: 'auto',
  452. width: '40%',
  453. position:[350,25],
  454. modal: true,
  455. buttons: {
  456. "Done": function() {
  457. var isvalid = $("#itemForm").valid();
  458. var grid = $(this).data('grid_data').grid_id;
  459. var pricelist_id = $(this).data('grid_data').pricelist_id;
  460. var url = $(this).data('grid_data').url;
  461. var action = $(this).data('grid_data').action;
  462. var isprecchnged = 1;
  463. var oldprecedence;
  464. if (action =='edit_rule'){
  465. oldprecedence=$("#rules_grid").getCell($("#rules_grid").getGridParam('selrow'),'precedence')
  466. if ($("#precedence").val()==oldprecedence){
  467. isprecchnged = 0;
  468. }
  469. }
  470. if (action=='edit_rule' && $("#ischangeditem").val()==0){
  471. //dont submit. Nothing has changed
  472. $( this ).dialog( "close" );
  473. }
  474. else {
  475. if (isvalid){
  476. $.ajax({
  477. url:url,
  478. type:"POST",
  479. data:{
  480. productOptions:$("#productOptions").val(),
  481. qualifier:$("#qualifier").val(),
  482. operator:$("#operator").val(),
  483. discount_type:$("#discount_type").val(),
  484. qualifier_value_from:$("#qualifier_value_from").val(),
  485. qualifier_value_to:$("#qualifier_value_to").val(),
  486. qualifier_value:$("#qualifier_value").val(),
  487. discount_value:$("#discount_value").val(),
  488. product_price:$("#product_price").val(),
  489. pricelist_id:pricelist_id,
  490. precedence:$("#precedence").val(),
  491. apply_to_all:$("#allCB").is(":checked"),
  492. action:action,
  493. precedencechanged:isprecchnged,
  494. oldprecedence:oldprecedence,
  495. rule_id:$("#"+grid).getGridParam('selrow'),
  496. product_id:$("#price_grid").getCell($("#price_grid").getGridParam('selrow'),'product_id')
  497. },
  498. success:function (response){
  499. //console.log("grid " + grid);
  500. $("#"+grid).trigger("reloadGrid");
  501. $("#status-message-li").empty();
  502. //reload Main Grid
  503. $("#quotes").trigger("reloadGrid");
  504. }
  505. })
  506. $( this ).dialog( "close" );
  507. }
  508. }
  509. },
  510. Cancel: function() {
  511. $( this ).dialog( "close" );
  512. }
  513. },
  514. open: function(event,ui){
  515. var grid_id = $(this).data('grid_data').grid_id;
  516. var action = $(this).data('grid_data').action;
  517. var rowid=$("#"+grid_id).getGridParam('selrow');
  518. var url="index.php/procurement/getProductsToAddRateDropDown";
  519. $("#productOptions").hide();
  520. if (action =='add_rule' || action =='edit_rule'){
  521. $("#priceCntnr").hide();
  522. $('#ruleCntnr').show();
  523. if (action =='add_rule'){
  524. $("#formHeaderItem").text("Add Rule");
  525. $('#allCBCntnr').show();
  526. url = "index.php/procurement/getAllProductsDropDownForSupplier";
  527. }
  528. else if (action =='edit_rule'){
  529. $("#formHeaderItem").text("Edit Rule");
  530. $("#product_rule_edit").show();
  531. $("#productOptions_chzn").hide();
  532. var op = $("#"+grid_id).getCell(rowid,'operator');
  533. var qualifier = $("#"+grid_id).getCell(rowid,'qualifier');
  534. if (qualifier!='product'){
  535. $("#operatorCntnr").show();
  536. if (op!="between"){
  537. $("#qualRangeCntnr").hide();
  538. $("#qualvalCntnr").show();
  539. }
  540. else {
  541. $("#qualRangeCntnr").show();
  542. $("#qualvalCntnr").hide();
  543. }
  544. }
  545. $("#product_rule_edit").text($("#price_grid").getCell($("#price_grid").getGridParam('selrow'),'product_name'));
  546. $("#qualifier").val(qualifier);
  547. $("#precedence").val($("#"+grid_id).getCell(rowid,'precedence'));
  548. $("#discount_type").val($("#"+grid_id).getCell(rowid,'discount_type'));
  549. $("#operator").val($("#"+grid_id).getCell(rowid,'operator'));
  550. $("#qualifier_value_from").val($("#"+grid_id).getCell(rowid,'qualifier_value_from'));
  551. $("#qualifier_value_to").val($("#"+grid_id).getCell(rowid,'qualifier_value_to'));
  552. $("#qualifier_value").val($("#"+grid_id).getCell(rowid,'qualifier_value_point'));
  553. $("#discount_value").val($("#"+grid_id).getCell(rowid,'discount_value'));
  554. }
  555. }
  556. else if (action =='add_price'){
  557. $("#formHeaderItem").text("Add Price & Rule");
  558. $("#priceCntnr").show();
  559. $('#ruleCntnr').hide();
  560. }
  561. if (action =='add_rule' || action =='add_price'){
  562. $.ajax({
  563. url:url,
  564. type:"POST",
  565. data:{
  566. pricelist_id:myGrid.getGridParam('selrow'),
  567. supplier_id:myGrid.getCell(myGrid.getGridParam('selrow'),'supplier_id')
  568. },
  569. success:function (response){
  570. $("#productOptions").children().remove();
  571. $("#productOptions").append(response);
  572. $('.chzn-select').trigger('liszt:updated');
  573. }
  574. });
  575. }
  576. },
  577. close: function(event,ui) {
  578. $("#itemForm").data('validator').resetForm();
  579. $('#itemForm')[0].reset();
  580. $('#itemForm .inithide').hide();
  581. $('#itemForm .initshow').show();
  582. $("#ischangeditem").val("0");
  583. $('#itemForm .valuediv').text("");
  584. $("#prodCntnr").show();
  585. $("#productOptions_chzn").show();
  586. $('.chzn-select').val('').trigger('liszt:updated');
  587. }
  588. });
  589. $( "#modal-warning" ).dialog({
  590. autoOpen:false,
  591. height: 90,
  592. modal: true
  593. });
  594. $( "#modal-warning-inherited" ).dialog({
  595. autoOpen:false,
  596. height: 120,
  597. modal: true
  598. });
  599. $( "#modal-warning-status" ).dialog({
  600. autoOpen:false,
  601. height: 120,
  602. modal: true
  603. });
  604. $( "#dialog-price-edit" ).dialog({
  605. autoOpen: false,
  606. height: 'auto',
  607. width: '30%',
  608. position:[500,25],
  609. modal: true,
  610. buttons: {
  611. "Edit": function() {
  612. var isvalid = $("#priceFormEdit").valid();
  613. if (isvalid){
  614. $.ajax({
  615. url:"index.php/procurement/editPrice",
  616. type:"POST",
  617. data:{
  618. lineitem_id:$("#price_grid").getCell($("#price_grid").getGridParam("selrow"),'lineitem_id'),
  619. price:$("#product_price_edit").val()
  620. },
  621. success:function (response){
  622. $("#price_grid").trigger("reloadGrid");
  623. }
  624. })
  625. $( this ).dialog( "close" );
  626. }
  627. },
  628. Cancel: function() {
  629. $( this ).dialog( "close" );
  630. }
  631. },
  632. close: function(event,ui) {
  633. $("#priceFormEdit").data('validator').resetForm();
  634. $('#priceFormEdit')[0].reset();
  635. }
  636. });
  637. $( "#dialog-confirm" ).dialog({
  638. resizable: false,
  639. height:150,
  640. width:500,
  641. modal: true,
  642. autoOpen:false,
  643. buttons: {
  644. "I Am Sure": function() {
  645. var grid = $(this).data('grid_data').grid_id;
  646. var url = $(this).data('grid_data').url;
  647. var id= $(this).data('grid_data').id;
  648. $.ajax({
  649. url:url,
  650. type:"POST",
  651. data:{
  652. id:id
  653. },
  654. success:function (response){
  655. $("#"+grid).trigger("reloadGrid");
  656. },
  657. error:function (response){
  658. emptyMessages();
  659. showErrorMessage("The Selected Orders Could Not Be Processed Due To Internal Error")
  660. }
  661. });
  662. $( this ).dialog( "close" );
  663. },
  664. Cancel: function() {
  665. $( this ).dialog( "close" );
  666. }
  667. }
  668. });
  669. $("#typeOp").change(function (){
  670. var val= $(this).val();
  671. if (val=='version'){
  672. $("#versionCntnr").show();
  673. $("#supplilerPricelistCntnr").hide();
  674. //$("#nameCntnr").hide();
  675. }
  676. else if (val=='supplierpl'){
  677. $("#versionCntnr").hide();
  678. $("#supplilerPricelistCntnr").show();
  679. //$("#nameCntnr").show();
  680. }
  681. // else {
  682. // $("#versionCntnr").hide();
  683. // $("#supplilerPricelistCntnr").hide();
  684. // $("#nameCntnr").show();
  685. // }
  686. }
  687. )
  688. $("#qualifier").change(function(){
  689. var val = $(this).val();
  690. if (val!='product'){
  691. $("#operatorCntnr").show();
  692. }
  693. else {
  694. $("#operatorCntnr").hide();
  695. }
  696. });
  697. $("#operator").change(function(){
  698. var val = $(this).val();
  699. console.log(val);
  700. if (val!="between"){
  701. $("#qualRangeCntnr").hide();
  702. $("#qualvalCntnr").show();
  703. }
  704. else {
  705. $("#qualRangeCntnr").show();
  706. $("#qualvalCntnr").hide();
  707. }
  708. });
  709. $("#ruleCB").change(function(){
  710. if (this.checked){
  711. $("#ruleCntnr").show();
  712. }
  713. else {
  714. $("#ruleCntnr").hide();
  715. }
  716. })
  717. $("#allCB").change(function(){
  718. if (this.checked){
  719. $("#prodCntnr").hide();
  720. //$("#allCB").val("all");
  721. }
  722. else {
  723. $("#prodCntnr").show();
  724. //$("#allCB").val("");
  725. }
  726. })
  727. $("#discount_type").change(function(){
  728. var val = $(this).val();
  729. if (val!="free"){
  730. $("#discount_value").addClass("number");
  731. $("#discount_value").removeClass("digits");
  732. }
  733. else {
  734. $("#discount_value").removeClass("number");
  735. $("#discount_value").addClass("digits");
  736. }
  737. });
  738. $("#addBtn").click(function(){
  739. var bValid = $("#pricelistForm").valid();
  740. if (bValid ){
  741. $.ajax({url:"index.php/procurement/createPricelist",
  742. type:"POST",
  743. data:{ pricelistId:$("#pricelistId").val(),
  744. typeOp:$("#typeOp").val(),
  745. name:$("#name").val(),
  746. supplierPriceListOp:$("#supplierPriceListOp").val(),
  747. supplierPriceListName:$("#supplierPriceListOp option:selected").text(),
  748. supplierOp:$("#supplierOp").val(),
  749. supplierName:$("#supplierOp option:selected").text(),
  750. validfrom:$("#validfrom").val(),
  751. validto:$("#validto").val(),
  752. rootPriceListOp:$("#rootPriceListOp").val()
  753. },
  754. success:function(response)
  755. {
  756. var successStatus = "Pricelist successfully added";
  757. emptyMessages ();
  758. showSuccessMessage(successStatus);
  759. myGrid.trigger("reloadGrid");
  760. },
  761. error:function(response)
  762. {
  763. emptyMessages ();
  764. var errorStatus = "Pricelist could not be added due to internal error";
  765. showErrorMessage(errorStatus);
  766. }
  767. })
  768. }
  769. });
  770. $("#active_edit,#validfrom_edit,#validto_edit").change(function (){
  771. $("#ischanged").val("1");
  772. })
  773. $(".chzn-select").chosen();
  774. $("#itemForm input,#itemForm select").change(function (){
  775. $("#ischangeditem").val("1");
  776. });
  777. });
  778. </script>
  779. </head>
  780. <body>
  781. <?php $this->load->view("common/menubar"); ?>
  782. <div id="modal-warning" title="Warning">
  783. <p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>Please Select Exactly One Row</p>
  784. </div>
  785. <div id="modal-warning-status" title="Error" class="ui-state-error" style="border:none;">
  786. <p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>Only Completely Received Orders i.e. With Status "Received"
  787. Can Be Readied For Invoice</p>
  788. </div>
  789. <div id="modal-warning-inherited" title="Warning">
  790. <p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>Inherited Prices Can Not Be Edited. Undefined Prices Should Be Added Using 'Add Pricing' Option </p>
  791. </div>
  792. <div id="dialog-confirm" title="Warning">
  793. <p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
  794. Once Deleted These Rates Con Not Be Recovered Again.Are You Sure?</p>
  795. </div>
  796. <div id="dialog-price-edit" title="Edit Price">
  797. <form id="priceFormEdit">
  798. <div class="column single-column" style="width:85%">
  799. <div class="field">
  800. <label for="product_price_edit" class="labeldiv">Price:</label>
  801. <input id="product_price_edit" id="product_price_edit" type="text" class="required number"/>
  802. </div>
  803. </div>
  804. </form>
  805. </div>
  806. <div id ="dialog-form">
  807. <form id="pricelistFormEdit" style="width:65%; margin:0 auto;">
  808. <fieldset style="border:1px solid #A6C9E2">
  809. <legend style="color: #2E6E9E;font-size: 110%;font-weight: bold;margin-left: 15px;">
  810. Price List Basic</legend>
  811. <div class="row">
  812. <div class="column edit-column">
  813. <div class="field">
  814. <div class="labeldiv labeldiv-edit">PriceList Name:</div>
  815. <div class="valuediv valuediv-edit" id="pl_name_edit" name ="pl_name_edit"></div>
  816. </div>
  817. </div>
  818. <div class="column edit-column">
  819. <div class="field">
  820. <div class="labeldiv labeldiv-edit">Supplier Name:</div>
  821. <div class="valuediv valuediv-edit" id="supplier_name_edit" name ="supplier_name_edit"></div>
  822. </div>
  823. </div>
  824. </div>
  825. <div class="row">
  826. <div class="column edit-column">
  827. <div class="field">
  828. <div class="labeldiv labeldiv-edit">Type:</div>
  829. <div class="valuediv valuediv-edit" id="type_edit" name ="type_edit"></div>
  830. </div>
  831. </div>
  832. <div class="column edit-column">
  833. <div class="field">
  834. <div class="labeldiv labeldiv-edit">Active:</div>
  835. <select name="active_edit" id ="active_edit" class="required">
  836. <option value="1">Yes
  837. <option value="0">No
  838. </select>
  839. </div>
  840. </div>
  841. </div>
  842. <div id="versionCntnrEdit" style="display:none">
  843. <div class="column edit-column">
  844. <div class="field">
  845. <div class="labeldiv labeldiv-edit">Base Version:</div>
  846. <div class="valuediv valuediv-edit" id="bv_edit" name ="bv_edit"></div>
  847. </div>
  848. </div>
  849. <div class="column edit-column">
  850. <div class="field">
  851. <div class="labeldiv labeldiv-edit">Version #:</div>
  852. <div class="valuediv valuediv-edit" id="vn_edit" name ="vn_edit"></div>
  853. </div>
  854. </div>
  855. <div class="column edit-column">
  856. <div class="field">
  857. <label for="validfrom_edit" class="labeldiv">Valid From Date:</label>
  858. <input id="validfrom_edit" name ="validfrom_edit" type="text" class="required dateValidate" style="width:12em;"/>
  859. </div>
  860. </div>
  861. <div class="column edit-column">
  862. <div class="field">
  863. <label for="validto_edit" class="labeldiv">Valid To Date:</label>
  864. <input id="validto_edit" name ="validto_edit" type="text" class="required dateValidate" style="width:12em;"/>
  865. </div>
  866. </div>
  867. </div>
  868. <input type="hidden" id="ischanged" name="ischanged" value="0"/>
  869. </fieldset>
  870. </form>
  871. <div class="table-grid" style="padding-top:2em;">
  872. <div>
  873. <h1 id="pkdheader">Product Prices And Rules </h1>
  874. </div>
  875. <table id="price_grid"><tr><td/></tr></table>
  876. <div id="pagerPk"></div>
  877. </div>
  878. <div class="table-grid" style="padding-top:2em;">
  879. <table id="rules_grid"><tr><td/></tr></table>
  880. <div id="pagerRules"></div>
  881. </div>
  882. </div>
  883. <div style="display: block;height: auto" class="shopifine-ui-dialog ui-widget ui-widget-content ui-corner-all" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-dialog-form">
  884. <div class="form-container single-column-form">
  885. <div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix">
  886. <span class="ui-dialog-title" id="ui-dialog-title-dialog-form">&nbsp;</span>
  887. <a href="#" class="ui-dialog-titlebar-close ui-corner-all" role="button">
  888. </a>
  889. </div>
  890. <div class="ui-dialog-content" style="width: auto;height: auto;" scrolltop="0" scrollleft="0">
  891. <h1 id="formHeader">Create Price List</h1>
  892. <form id="pricelistForm" class="single-column-form" style="width:90%">
  893. <fieldset>
  894. <!--<fieldset style="border:1px solid #A6C9E2">-->
  895. <!-- <legend style="color: #2E6E9E;font-size: 110%;font-weight: bold;margin-left: 15px;">
  896. Price List Informations</legend> -->
  897. <div class="row single-column-row">
  898. <div class="column single-column pricelist-col">
  899. <div class="field">
  900. <label for="typeOp" class="labeldiv">Pricelist Type</label>
  901. <select name="typeOp" id ="typeOp" class="required">
  902. <option value="">Choose
  903. <option value="supplierpl">Supplier Rate Contract
  904. <option value="version">Version
  905. </select>
  906. </div>
  907. </div>
  908. <div id="versionCntnr" style="display:none">
  909. <div class="column single-column pricelist-col">
  910. <div class="field">
  911. <label for="supplierPriceListOpsupplierPriceListOp" class="labeldiv">Version Of:</label>
  912. <select name="supplierPriceListOp" id ="supplierPriceListOp" class="required">
  913. <option value="">Choose
  914. <?=$supplierPriceListOptions ?>
  915. </select>
  916. </div>
  917. </div>
  918. <div class="column single-column pricelist-col">
  919. <div class="field">
  920. <label for="validfrom" class="labeldiv">Valid From Date:</label>
  921. <input id="validfrom" name ="validfrom" type="text" class="required dateValidate" style="width:12em;"/>
  922. </div>
  923. </div>
  924. <div class="column single-column pricelist-col">
  925. <div class="field">
  926. <label for="validto" class="labeldiv">Valid From Date:</label>
  927. <input id="validto" name ="validto" type="text" class=" required dateValidate" style="width:12em;"/>
  928. </div>
  929. </div>
  930. </div>
  931. <div id="supplilerPricelistCntnr" style="display:none">
  932. <div class="column single-column pricelist-col">
  933. <div class="field">
  934. <label for="supplierOp" class="labeldiv">Supplier</label>
  935. <select name="supplierOp" id ="supplierOp" class="required">
  936. <option value="">Choose
  937. <?=$supplierOptions ?>
  938. </select>
  939. </div>
  940. </div>
  941. </div>
  942. </div>
  943. </fieldset>
  944. </form>
  945. </div>
  946. <div class="ui-dialog-buttonpane shopifine-ui-widget-content ui-helper-clearfix">
  947. <div class="shopifine-ui-dialog-buttonset">
  948. <button id="addBtn" type="button" class="shopifine-ui-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false">
  949. <span class="ui-button-text">Create Rate Contract</span>
  950. </button>
  951. </div>
  952. </div>
  953. </div>
  954. <?php $this->load->view("common/message"); ?>
  955. <div class="table-grid" style="height:100%">
  956. <h1 id="table header">Pricelist Grid</h1>
  957. <table id="pricelist_grid"><tr><td/></tr></table>
  958. <div id="pager"></div>
  959. </div>
  960. </div>
  961. <div id ="dialog-form-item" style="overflow:hidden">
  962. <!-- <div id ="status-message-li" class="ui-corner-all">
  963. Note:You Can Define New Rules. These Rules Will Not Be ready To Use Unless The Sequence And Exclusivity Is Not Defined./n/
  964. Sequence And Rules Can Be Added In The "PriceList" Dialog.
  965. </div>-->
  966. <h1 id="formHeaderItem"></h1>
  967. <form id="itemForm" class="single-column-form" style="width:100%; margin-left: 0;">
  968. <fieldset>
  969. <div class="row single-column-row single-column-row-item" id="prodCntnr">
  970. <div class="column single-column">
  971. <div class="field">
  972. <label for="productOptions" class="labeldiv">Products:</label>
  973. <select name="productOptions[]" id ="productOptions" class="chzn-select required initshow" multiple="multiple" style="width:200px;height:20px;">
  974. <?=$productOptions?>
  975. </select>
  976. <div class="valuediv valuediv-edit inithide" id="product_rule_edit" name ="product_rule_edit" style="display:none"></div>
  977. </div>
  978. </div>
  979. </div>
  980. <div id="allCBCntnr"class="row single-column-row single-column-row-item inithide" style="display:none">
  981. <div class="column single-column">
  982. <div class="field">
  983. <label for="allCB" class="labeldiv">Apply To All Products?:</label>
  984. <input id="allCB" name="allCB" type="checkbox"/>
  985. <div id ="all-help" class="ui-corner-all help-message-left">
  986. (If Selected This Rule Will Be Applied To All The Products for This Supplier)
  987. </div>
  988. </div>
  989. </div>
  990. </div>
  991. <div id="priceCntnr" class="initshow">
  992. <div class="row single-column-row single-column-row-item">
  993. <div class="column single-column">
  994. <div class="field">
  995. <label for="product_price" class="labeldiv">Price:</label>
  996. <input id="product_price" id="product_price" type="text" class="required number "/>
  997. </div>
  998. </div>
  999. </div>
  1000. <div class="row single-column-row single-column-row-item">
  1001. <div class="column single-column">
  1002. <div class="field">
  1003. <label for="ruleCB" class="labeldiv">Define Rules?:</label>
  1004. <input id="ruleCB" id="ruleCB" type="checkbox"/>
  1005. </div>
  1006. </div>
  1007. </div>
  1008. </div>
  1009. <div id="ruleCntnr" style="display:none" class="inithide">
  1010. <div class="row single-column-row single-column-row-item">
  1011. <div class="column single-column">
  1012. <div class="field">
  1013. <label for="qualifier" class="labeldiv">Applicable On:</label>
  1014. <select name="qualifier" id ="qualifier" class="required" >
  1015. <option value="">Choose
  1016. <option value="product">Product
  1017. <option value="quantity">Quantity
  1018. <option value="amount">Amount
  1019. </select>
  1020. </div>
  1021. </div>
  1022. </div>
  1023. <div class="row single-column-row single-column-row-item">
  1024. <div class="column single-column">
  1025. <div class="field">
  1026. <label for="precedence" class="labeldiv">Precedence:</label>
  1027. <input id="precedence" id="precedence" type="text" class=""/>
  1028. <div id ="precedence-help" class="ui-corner-all help-message-left">
  1029. (Please Specify The Precedence If Known.If The Precedence Already Exists Then Next Lower Precedence Will Be Assigned .If Not Specified The Lowest Precedence Will Be Set)
  1030. </div>
  1031. </div>
  1032. </div>
  1033. </div>
  1034. <div class="row single-column-row single-column-row-item">
  1035. <div class="column single-column">
  1036. <div class="field">
  1037. <label for="discount_type" class="labeldiv">Discount Type:</label>
  1038. <select name="discount_type" id ="discount_type" class="required">
  1039. <option value="">Choose
  1040. <option value="percentage">Percentage
  1041. <option value="flat">Flat Amount
  1042. <option value="free">Free Goods
  1043. </select>
  1044. </div>
  1045. </div>
  1046. </div>
  1047. <div class="row single-column-row single-column-row-item inithide" id="operatorCntnr" style="display:none">
  1048. <div class="column single-column">
  1049. <div class="field">
  1050. <label for="operator" class="labeldiv">Operator:</label>
  1051. <select name="operator" id ="operator" class="required" >
  1052. <option value="">Choose
  1053. <option value="equal">Equal
  1054. <option value="more">More Than
  1055. <option value="less">Less Than
  1056. <option value="between">Between
  1057. </select>
  1058. </div>
  1059. </div>
  1060. </div>
  1061. <div id ="qualRangeCntnr" class="inithide" style="display:none">
  1062. <div class="row single-column-row single-column-row-item">
  1063. <div class="column single-column">
  1064. <div class="field">
  1065. <label for="qualifier_value_from" class="labeldiv" id="qualifier_value_point_lbl">Applicable Qty/Amount From:</label>
  1066. <input id="qualifier_value_from" id="qualifier_value_from" type="text" class="required"/>
  1067. </div>
  1068. </div>
  1069. </div>
  1070. <div class="row single-column-row single-column-row-item">
  1071. <div class="column single-column">
  1072. <div class="field">
  1073. <label for="qualifier_value_to" class="labeldiv" > Applicable Qty/Amount Till:</label>
  1074. <input id="qualifier_value_to" id="qualifier_value_to" type="text" class="required"/>
  1075. </div>
  1076. </div>
  1077. </div>
  1078. </div>
  1079. <div class="row single-column-row single-column-row-item inithide" id="qualvalCntnr" style="display:none">
  1080. <div class="column single-column">
  1081. <div class="field">
  1082. <label for="qualifier_value" class="labeldiv">Applicable Qty/Amount:</label>
  1083. <input id="qualifier_value" id="qualifier_value" type="text" class="required"/>
  1084. </div>
  1085. </div>
  1086. </div>
  1087. <div class="row single-column-row single-column-row-item">
  1088. <div class="column single-column">
  1089. <div class="field">
  1090. <label for="discount_value" class="labeldiv">Discount:</label>
  1091. <input id="discount_value" id="discount_value" type="text" class="required"/>
  1092. <div id ="discount-help" class="ui-corner-all help-message-left">
  1093. (Depends On The Discount Type. If "%" or "flat" Decimal. If "Free Goods" Only Digits)
  1094. </div>
  1095. </div>
  1096. </div>
  1097. </div>
  1098. </div>
  1099. <input id="ischangeditem" name="ischangeditem" type="hidden" value="0"/>
  1100. </fieldset>
  1101. </form>
  1102. </div>
  1103. <?php $this->load->view("partial/footer"); ?>
  1104. </body>
  1105. </html>