PageRenderTime 86ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/magehelp/application/views/procurement/quote/create/quote_create_grid.php

https://bitbucket.org/jit_bec/shopifine
PHP | 1086 lines | 890 code | 144 blank | 52 comment | 67 complexity | 43f8b99e4e3f5fdee3e33c7826c9696f MD5 | raw file
Possible License(s): LGPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. <html>
  2. <head>
  3. <?php $this->load->view("common/header"); ?>
  4. <style>
  5. .column {
  6. float: left;
  7. padding: 1em 1em 2em;
  8. width: 47%;
  9. }
  10. .base-column{
  11. padding: 1em 1em 1em;
  12. width: 100%;
  13. }
  14. .triple-column{
  15. padding: .5em .5em;
  16. width: 39%;
  17. }
  18. .field{
  19. width:100%;
  20. }
  21. .ui-widget-header {height:12px;}
  22. .item-column {
  23. width: 95%;
  24. padding:1em;
  25. }
  26. .table-column {
  27. width: 97%;
  28. padding:1em;
  29. }
  30. .ui-combobox-input{
  31. width:23em;
  32. }
  33. #supplierOp-input{
  34. width:10em;
  35. }
  36. #warehouseOp-input{
  37. width:10em;
  38. }
  39. .shopifine-ui-dialog{
  40. height:auto;
  41. }
  42. .ui-tabs {
  43. height: 20em;
  44. margin: 0 auto;
  45. width: 45%;
  46. left:0;
  47. }
  48. .calculated {
  49. color: green;
  50. font-size: 90%;
  51. }
  52. .ui-tabs-nav{
  53. height:22px;
  54. }
  55. .inithide{
  56. display:none;
  57. }
  58. #quoteForm .directlabel{
  59. width:30%;
  60. }
  61. #quoteForm .rolabel{
  62. width:40%;
  63. }
  64. #itemForm .labeldiv{
  65. width:30%;
  66. }
  67. #itemForm .centrelabel{
  68. width:18%;
  69. }
  70. #itemForm .directlabel{
  71. width:27%;
  72. }
  73. #content_area{
  74. width:95%;
  75. }
  76. </style>
  77. <script type="text/javascript">
  78. $(function() {
  79. //form validation
  80. $.fn.toggleDisabled = function(){
  81. return this.each(function(){
  82. this.disabled = !this.disabled;
  83. });
  84. };
  85. $("#quoteForm").validate({
  86. rules:{
  87. dir_disc_perc_quote:{
  88. number:true,
  89. minStrict:0
  90. },
  91. dir_disc_total_quote:{
  92. number:true,
  93. minStrict:0
  94. }}});
  95. $("#itemForm").validate({
  96. ignore:[],
  97. rules:{
  98. quantity:{
  99. required:true,
  100. digits:true,
  101. min:1
  102. },
  103. exPrice:{
  104. required:true,
  105. number:true
  106. },
  107. dir_disc_perc:{
  108. number:true,
  109. minStrict:0
  110. },
  111. dir_disc_amount:{
  112. number:true,
  113. minStrict:0
  114. },
  115. dir_disc_fg:{
  116. digits:true,
  117. min:1
  118. }
  119. }}
  120. );
  121. // datepicker for Add Form
  122. $( "#reqdate,#neededdate" ).datepicker({
  123. showOn: "button",
  124. buttonImage: "images/calendar.gif",
  125. buttonImageOnly: true,
  126. dateFormat:"dd/mm/yy",
  127. minDate:0
  128. });
  129. function quotegriddates(id){
  130. jQuery("#"+id+"_needed_by_date","#quotes").datepicker({dateFormat:"yy-mm-dd",minDate:0});
  131. }
  132. function quoteitemgriddates(id){
  133. jQuery("#"+id+"_needed_by_date","#lineItems").datepicker({dateFormat:"yy-mm-dd",minDate:0});
  134. }
  135. //end datepicker
  136. $("#productOp").combobox({customChange:initPriceRules($("#productOp").val())}
  137. );
  138. //end combox
  139. $( "#dialog-form" ).dialog({
  140. autoOpen: false,
  141. height: 'auto',
  142. width: '60%',
  143. position:[300,15],
  144. modal: true,
  145. buttons: {
  146. "DoneButton": {
  147. id:"doneBtn",
  148. text:"Create Quote",
  149. click:function() {
  150. var quote_id = $("#quoteId").val();
  151. var mode = $(this).data('grid_data').mode;
  152. if (mode=='edit'){
  153. quote_id = $(this).data('grid_data').quote_id;
  154. }
  155. var isValid = $("#quoteForm").valid();
  156. if (isValid){
  157. $.ajax({url:"index.php/procurement/createQuotes",
  158. type:"POST",
  159. data:{ quoteId:quote_id,
  160. form_data:$("#quoteForm").toObject(),
  161. total_before_discount:$("#lineItems").getGridParam("userData").final_total,
  162. total_discount:$("#discount_total_quote").text()
  163. },
  164. success:function(response)
  165. {
  166. if ($("#quoteId").val()==""){
  167. if (mode!='edit'){
  168. if (response !='error'){
  169. $("#quoteId").val(response);
  170. $("#pkdheader").show();
  171. $("#doneBtn > span").text("Done");
  172. var subgridSettingsObj ={grid_id:'lineItems',pager:'pagerPk',addFooter:true};
  173. prepareQuoteItemsGrid(subgridSettingsObj,{quoteId:response});
  174. $("#lineItems").navGrid("#pagerPk",{edit:false,add:false,del:true,search:false},{},{},{},{},{});
  175. addCustomButtonsInQuoteItemGrid(subgridSettingsObj, {add:true,edit:true,chooser:true,data:{quote_id:response}});
  176. $("#del_lineItems").insertAfter("#add_lineItems");
  177. //prepareQuoteItemsGrid("lineItems","pagerPk",response,true,true,true,true);
  178. $("#lineItems").jqGrid("setGridParam",
  179. {userDataOnFooter:true,gridComplete:initDiscountCntnr});
  180. }
  181. }
  182. }
  183. } //end success of Ajax
  184. }) //end ajax
  185. if ($("#quoteId").val()!=""){
  186. $( this ).dialog( "close" );
  187. }
  188. if (mode=="edit"){
  189. $( this ).dialog( "close" );
  190. }
  191. } //end ifvalid
  192. }}, //end of Create button
  193. Cancel: function() {
  194. $( this ).dialog( "close" );
  195. }
  196. },//end buttons
  197. open:function(event,ui){
  198. //reseting line item grids once again to be doubly sure
  199. $("#pkdheader").hide();
  200. $("#lineItems").jqGrid("GridUnload");
  201. $('#none_quote').attr('checked','checked');
  202. var quote_id = $(this).data('grid_data').quote_id;
  203. var mode = $(this).data('grid_data').mode;
  204. if (mode=='edit'){
  205. var subgridSettingsObj ={grid_id:'lineItems',pager:'pagerPk',addFooter:true};
  206. prepareQuoteItemsGrid(subgridSettingsObj,{quoteId:quote_id});
  207. $("#lineItems").navGrid("#pagerPk",{edit:false,add:false,del:true,search:false},{},{},{},{},{});
  208. addCustomButtonsInQuoteItemGrid(subgridSettingsObj, {add:true,edit:true,chooser:true,data:{quote_id:quote_id}});
  209. $("#del_lineItems").insertAfter("#add_lineItems");
  210. //prepareQuoteItemsGrid("lineItems","pagerPk",quote_id,true,true,true,true);
  211. $("#lineItems").jqGrid("setGridParam",
  212. {userDataOnFooter : true,gridComplete:initDiscountCntnr});
  213. $("#doneBtn > span").text("Done");
  214. $("#supval").val(myGrid.getCell(quote_id,'supplier_id'));
  215. var type =myGrid.getCell(quote_id,'discount_type');
  216. var val =myGrid.getCell(quote_id,'discount_value');
  217. console.log(type);
  218. if (type=='none'){
  219. $("#none_quote").attr("checked","checked");
  220. }
  221. else if (type=='directpercentage'){
  222. $("#dir_disc_perc_quote_radio").attr("checked","checked");
  223. $("#dir_disc_perc_quote").val(val);
  224. }
  225. else if (type=='directamounttotal'){
  226. $("#dir_disc_total_quote_radio").attr("checked","checked");
  227. $("#dir_disc_total_quote").val(val);
  228. }
  229. $("#amount_total_quote").text(myGrid.getCell(quote_id,'final_total'));
  230. $("#discount_total_quote").text(myGrid.getCell(quote_id,'discount_amount'));
  231. $("#warehouseval").val(myGrid.getCell(quote_id,'warehouse_id'));
  232. $("#pricelist_id_hidden").val(getPricelistId($("#supval").val()));
  233. var needDate = myGrid.getCell(quote_id,'needed_by_date');
  234. if (needDate!=null && needDate!=""){
  235. var d1 = Date.parse(needDate);
  236. $("#reqdateval").val(d1.toString('dd/MM/yyyy'));
  237. }
  238. }
  239. $("#tabs").tabs({
  240. load: function(event,ui){
  241. //console.log( ui);
  242. $( "#reqdate" ).datepicker({
  243. showOn: "button",
  244. buttonImage: "images/calendar.gif",
  245. buttonImageOnly: true,
  246. dateFormat:"dd/mm/yy",
  247. minDate:0
  248. });
  249. if (ui.tab.id=="base"){
  250. $("#supplierOp").val($("#supval").val());
  251. $("#warehouseOp").val($("#warehouseval").val());
  252. if (parseInt(myGrid.getCell(quote_id,'rfq_reference'))>0){
  253. $("#supplierOp, #warehouseOp").attr("disabled",true);
  254. }
  255. $("#reqdate").val($("#reqdateval").val());
  256. // reset
  257. $("#reqdateval").val("");
  258. $("#warehouseval").val("");
  259. $("#supval").val("");
  260. }
  261. else if (ui.tab.id=="notes"){
  262. $("#approveNotes").val($("#notesval").val());
  263. // reset
  264. $("#notesval").val("");
  265. }
  266. $("#supplierOp").change(function(){
  267. getPricelistId($("#supplierOp").val());
  268. });
  269. },
  270. beforeActivate: function (event,ui){
  271. if (ui.newTab[0].id=="notesLink"){
  272. // save old values
  273. $("#reqdateval").val($("#reqdate").val());
  274. $("#warehouseval").val($("#warehouseOp").val());
  275. $("#supval").val($("#supplierOp").val());
  276. }
  277. else if (ui.newTab[0].id=="baseLink"){
  278. $("#notesval").val($("#approveNotes").val());
  279. }
  280. }
  281. });
  282. // this should be registered only after the tabs are loaded.
  283. },
  284. close: function(event,ui) {
  285. //validate so that close button is not pressed while there is no line item
  286. var noOfRec =$("#lineItems").getGridParam("records");
  287. if (noOfRec<1){
  288. $.ajax({
  289. method:"POST",
  290. data:{id:$("#quoteId").val(),entity:'quote',items_count:noOfRec},
  291. url:'index.php/procurement/closeValidate'
  292. })
  293. };
  294. $("#quoteForm").data('validator').resetForm();
  295. $("#quoteForm .valuediv").text("");
  296. $('#quoteForm')[0].reset();
  297. $('input:radio[name=pricerule_quote]').removeAttr("checked")
  298. //reset line item grids
  299. $("#pkdheader").hide();
  300. $("#lineItems").jqGrid("GridUnload");
  301. $("#supplierOp, #warehouseOp").attr("disabled",false);
  302. //reload main grid
  303. $("#quotes").trigger("reloadGrid");
  304. //destrying the tab to bring it to the initial state while opening it next
  305. $("#tabs").tabs("destroy");
  306. //change Button Text To original
  307. $("#doneBtn > span").text("Create Quote");
  308. $("#status-message-li").empty();
  309. }
  310. });
  311. //Line Item Dialog
  312. $( "#dialog-form-item" ).dialog({
  313. autoOpen: false,
  314. height: 'auto',
  315. width: '60%',
  316. position:[300,15],
  317. modal: true,
  318. buttons: {
  319. "addupdateitem":{
  320. text:"Add",
  321. id:"add_update_item",
  322. click:function() {
  323. var isvalid = $("#itemForm").valid();
  324. var grid = $(this).data('grid_data').grid_id;
  325. var quote_id = $(this).data('grid_data').quote_id;
  326. var line_id = $(this).data('grid_data').line_id;
  327. var action = $(this).data('grid_data').action;
  328. var url = "index.php/procurement/addQuoteItem";
  329. if (action == 'edit'){
  330. url = "index.php/procurement/modifyQuoteItem";
  331. }
  332. // url="test";
  333. if (isvalid){
  334. $.ajax({
  335. url:url,
  336. type:"POST",
  337. data:{
  338. quoteid:quote_id,
  339. form_data:$("#itemForm").toObject(),
  340. unit_discount:$("#unit_price_discount").text(),
  341. free_items:$("#free_items").text(),
  342. id:line_id,
  343. pricelist_id:$("#pricelist_id_hidden").val()
  344. },
  345. success:function (response){
  346. //console.log("grid " + grid);
  347. $("#"+grid).trigger("reloadGrid");
  348. $("#status-message-li").empty();
  349. //reload Main Grid
  350. $("#quotes").trigger("reloadGrid");
  351. }
  352. })
  353. $( this ).dialog( "close" );
  354. }
  355. }
  356. }
  357. ,
  358. Cancel: function() {
  359. $( this ).dialog( "close" );
  360. }
  361. },
  362. open: function(event,ui){
  363. var grid = $(this).data('grid_data').grid_id;
  364. var line_id = $(this).data('grid_data').line_id;
  365. var action = $(this).data('grid_data').action;
  366. var product_id = $("#"+grid).getCell(line_id,'product_id');
  367. $("#line_id_hidden").val(line_id);
  368. $("#action_item_hidden").val(action);
  369. //prepare Rules Grid
  370. var settingsObj = {grid_id:'rules_grid',pager:'pagerRules'};
  371. prepareRulesGrid(settingsObj,$("#pricelist_id_hidden").val(),product_id);
  372. $("#rules_grid").setGridWidth("550");
  373. $("#rules_grid").setCaption("Existing Price Rules");
  374. $("#rules_grid").navGrid('#pagerRules',{add:false,edit:false,del:true,view:true,search:false},{}, {}, {}, {}, {});
  375. // by default assume action 'add'.So initially Check The None Checked and Existing PR disabled
  376. $('#nonePR').attr('checked','checked');
  377. $("#existingPR").attr('disabled','disabled');
  378. //check if any pricelist for this supplier exist or not
  379. if ($("#pricelist_id_hidden").val()!="" ){
  380. $("#pricelistNameCntnr").show();
  381. $("#existingPRCntnr").show();
  382. }
  383. // if Does not exist do not show the pricelist container or the pricerules
  384. else {
  385. $("#pricelistNameCntnr").hide();
  386. $("#existingPRCntnr").hide();
  387. }
  388. // if 'edit'
  389. if (action=='edit'){
  390. $("#add_update_item .ui-button-text").text("Update");
  391. var quoted_qty = parseInt($("#"+grid).getCell(line_id,'quoted_quantity'));
  392. $("#productOp-input").parent().hide();
  393. $("#productOp").val(product_id);
  394. $("#product_name_edit").show().text($("#"+grid).getCell(line_id,'name'));
  395. $("#quantity").val(quoted_qty);
  396. $("#exPrice").val($("#"+grid).getCell(line_id,'expected_price'));
  397. $("#estPrice").text($("#"+grid).getCell(line_id,'estimated_value'));
  398. $("#notes").val($("#"+grid).getCell(line_id,'comments'));
  399. var type = $("#"+grid).getCell(line_id,'pricerule_type');
  400. var val =$("#"+grid).getCell(line_id,'discount_value');
  401. if (type=='none'){
  402. $("#nonePR").attr("checked","checked");
  403. }
  404. else if (type=='directpercentage'){
  405. $("#dir_disc_perc_radio").attr("checked","checked");
  406. $("#dir_disc_perc").val(val);
  407. }
  408. else if (type=='directamounttotal'){
  409. $("#dir_disc_total_radio").attr("checked","checked");
  410. $("#dir_disc_total").val(val);
  411. }
  412. else if (type=='existing'){
  413. //if type existing then reload it with inherite dules and dir exactly the same way it was done during addition
  414. $("#existingPR").attr("checked","checked");
  415. initPriceRules(product_id);
  416. }
  417. var needDate = $("#"+grid).getCell(line_id,'needed_by_date');
  418. if (needDate!=null && needDate!=""){
  419. var d1 = Date.parse(needDate);
  420. $("#neededdate").val(d1.toString('dd/MM/yyyy'));
  421. }
  422. var free_items= parseInt($("#"+grid).getCell(line_id,'free_items'));
  423. if (isNaN(free_items)){
  424. free_items = parseInt("0");
  425. }
  426. $("#unit_price_final").text($("#"+grid).getCell(line_id,'final_unit_price'));
  427. $("#unit_price_discount").text($("#"+grid).getCell(line_id,'unit_price_discount'));;
  428. $("#free_items").text(free_items);
  429. $("#items_total").text(free_items + quoted_qty);
  430. $("#discount_total").text($("#"+grid).getCell(line_id,'total_discount'));
  431. $("#amount_total").text($("#"+grid).getCell(line_id,'final_total'));
  432. }
  433. },
  434. close: function(event,ui) {
  435. $("#itemForm").data('validator').resetForm();
  436. $("#itemForm .inithide").hide();
  437. $("#itemForm .initshow").show();
  438. $("#itemForm .valuediv:not(#pricelist_name)").text("");
  439. $('#itemForm')[0].reset();
  440. $("#estValue").text("");
  441. $("#curPrice").text("");
  442. //$("#exPrice").removeAttr("disabled");
  443. $("#exPrice").removeAttr("readonly");
  444. $("#existingPR").attr('disabled','disabled');
  445. $("#rules_grid").jqGrid("GridUnload");
  446. }
  447. });
  448. // Main Request For Quotation Grid
  449. var myGrid = $("#quotes");
  450. //discount_type:true,discount_value:true
  451. var postData={_status:['open','draft','waitingforapproval','rejected']}
  452. var settingsObj = {grid_id:'quotes',pager:'pager',multiselect:true};
  453. prepareQuotesGrid(settingsObj,postData,true,{},{},{});
  454. myGrid.navGrid("#pager",{edit:false,add:false,del:false,search:false,view:true},{},{},{},{});
  455. var buttons = {add:true,edit:true,po_direct:true,submit_approve:true,reopen:true,del:true,comments:true,load_owner_all:true};
  456. addCustomButtonsQuoteGrid(settingsObj,buttons);
  457. myGrid.jqGrid('filterToolbar', {stringResult: true, searchOnEnter: true, defaultSearch : "cn"});
  458. $("#del_quotes").insertAfter("#edit_quotes");
  459. //
  460. //warning dialogs
  461. $( "#dialog-modal" ).dialog({
  462. autoOpen:false,
  463. height: 140,
  464. modal: true
  465. });
  466. function getPricelistId(supplier_id){
  467. $.ajax({
  468. method:"POST",
  469. url:"index.php/procurement/getRelevantPriceListId",
  470. data: {supplier_id : supplier_id},
  471. success: function(response){
  472. var resObj = JSON.parse(response);
  473. console.log("response == " + resObj);
  474. console.log("id == " + resObj.id);
  475. $("#pricelist_id_hidden").val(resObj.id);
  476. $("#pricelist_name").text(resObj.name);
  477. $("#inherit_rules").val(resObj.inherit_rules);
  478. $("#inherit_rules_dir").val(resObj.inherit_rules_dir);
  479. //pricelist_name
  480. }
  481. });
  482. }
  483. $("#isOverride").change(function(){
  484. //$("#exPrice").toggleDisabled();
  485. if (this.checked){
  486. //$("#exPrice").removeAttr("disabled");
  487. $("#exPrice").removeAttr("readonly");
  488. }
  489. else {
  490. $("#exPrice").attr("readonly","readonly");
  491. }
  492. })
  493. $("input:radio[name=pricerule]").change(function(){
  494. var selected = $(this).val();
  495. if (selected=='existing'||selected=='nonePR'){
  496. $("#dir_disc_fg").attr("disabled","disabled");
  497. }
  498. else {
  499. $("#dir_disc_fg").removeAttr("disabled");
  500. }
  501. })
  502. //$("input:radio[name=pricerule]").change(function(){
  503. $("#applyBtn_quote").click(function(){
  504. var isvalid = $("#quoteForm").valid();
  505. if (isvalid){
  506. calculateQuoteDiscount();
  507. }
  508. });
  509. function calculateQuoteDiscount(){
  510. var selected = $("input:radio[name=pricerule_quote]:checked").val() ;
  511. var total = $("#lineItems").getGridParam("userData").final_total;
  512. var totalDisc = 0;
  513. if (selected=='directamounttotal'){
  514. totalDisc = parseFloat($("#dir_disc_total_quote").val()).toFixed(2);
  515. }
  516. else if (selected=='directpercentage'){
  517. var totalDiscPerc = parseFloat($("#dir_disc_perc_quote").val());
  518. var totalDisc = (total*totalDiscPerc/100).toFixed(2);
  519. }
  520. $("#discount_total_quote").text(totalDisc);
  521. var total_after = (total-totalDisc).toFixed(2);
  522. $("#amount_total_quote").text(total_after);
  523. }
  524. $("#applyBtn").click(function(){
  525. var isvalid = $("#itemForm").valid();
  526. //var selected = $(this).val();
  527. var selected = $("input:radio[name=pricerule]:checked").val() ;
  528. //console.log("this "+ $(this).val());
  529. if (isvalid){
  530. var unitPrice = parseFloat($("#exPrice").val());
  531. var quantity = parseInt($("#quantity").val());
  532. var unitDiscount;
  533. var finalUnitPrice;
  534. var freeItems;
  535. if (selected=='existing'){
  536. $.ajax({
  537. url:"index.php/procurement/applyPriceRules",
  538. method:"POST",
  539. data:{product_id:$("#productOp").val(),
  540. pricelist_id:$("#pricelist_id_hidden").val(),
  541. quantity:quantity,
  542. unit_price:unitPrice,
  543. inherit_rules:$("#inherit_rules").val(),
  544. inherit_rules_dir:$("#inherit_rules_dir").val()
  545. },
  546. success:function(response){
  547. console.log(response);
  548. var resJson = JSON.parse(response);
  549. finalUnitPrice = parseFloat(resJson.final_unit_price).toFixed(2);
  550. freeItems = parseInt(resJson.free_items);
  551. unitDiscount = (unitPrice - finalUnitPrice).toFixed(2);
  552. $("#unit_price_final").text(finalUnitPrice);
  553. $("#unit_price_discount").text(unitDiscount);;
  554. $("#free_items").text(freeItems);
  555. $("#items_total").text(quantity + freeItems);
  556. $("#discount_total").text(unitDiscount*quantity);
  557. $("#amount_total").text(finalUnitPrice*quantity);
  558. }
  559. })
  560. }
  561. else if (selected=='directamountunit'){
  562. unitDiscount = parseFloat($("#dir_disc_unit").val()).toFixed(2);
  563. freeItems = parseInt($("#dir_disc_fg").val());
  564. }
  565. else if (selected=='directamounttotal'){
  566. var totalDisc = parseFloat($("#dir_disc_total").val()).toFixed(2);
  567. unitDiscount = totalDisc/quantity;
  568. freeItems = parseInt($("#dir_disc_fg").val());
  569. }
  570. else if (selected=='directpercentage'){
  571. var totalDiscPerc = parseFloat($("#dir_disc_perc").val()).toFixed(2);
  572. unitDiscount = unitPrice*totalDiscPerc/100;
  573. freeItems = parseInt($("#dir_disc_fg").val());
  574. }
  575. if (isNaN(freeItems)){
  576. freeItems = 0;
  577. }
  578. finalUnitPrice = unitPrice-unitDiscount;
  579. var discTotal = unitDiscount*quantity;
  580. var amtTotal = finalUnitPrice*quantity;
  581. $("#unit_price_discount").text(unitDiscount.toFixed(2));
  582. $("#discount_total").text(discTotal.toFixed(2));
  583. $("#unit_price_final").text(finalUnitPrice.toFixed(2));
  584. $("#amount_total").text(amtTotal.toFixed(2));
  585. $("#free_items").text(freeItems);
  586. $("#items_total").text(quantity + freeItems);
  587. }
  588. })
  589. $("#pricelist_rule_fs input[type=text],#pricelist_rule_fs_quote input[type=text]").click(function(){
  590. $("#"+this.id+"_radio").attr("checked","checked");
  591. $("#pricelist_rule_fs input[type=text]:not(#this.id)").val("");
  592. });
  593. $("#pricelist_rule_fs_quote input[type=text]").click(function(){
  594. $("#"+this.id+"_radio").attr("checked","checked");
  595. $("#pricelist_rule_fs_quote input[type=text]:not(#this.id)").val("");
  596. })
  597. function initDiscountCntnr(){
  598. if (parseFloat($("#lineItems").getGridParam("userData").final_total)>0){
  599. $("#discountCntnr").show();
  600. calculateQuoteDiscount();
  601. // $("#lineItems").setGridParam({userDataOnFooter : true})
  602. }
  603. else {
  604. $("#discountCntnr").hide();
  605. }
  606. }
  607. function initPriceRules(product_id){
  608. if ($("#pricelist_id_hidden").val()!=""){
  609. $.ajax({
  610. type:"GET",
  611. url:'index.php/procurement/getPriceFromPricelist',
  612. data:{product_id:product_id,pricelist_id:$("#pricelist_id_hidden").val(),supplier_id:$("#supplierOp").val()},
  613. success:function (response){
  614. if (response!=null && response!=""){
  615. $("#exPrice").val(response );
  616. //$("#exPrice").attr("disabled","disabled");
  617. $("#exPrice").attr("readonly","readonly");
  618. $("#isOverride,#override-help").show();
  619. }
  620. else{
  621. $("#exPrice").val("" );
  622. //$("#exPrice").removeAttr("disabled");
  623. $("#exPrice").removeAttr("readonly");
  624. $("#isOverride,#override-help").hide();
  625. }
  626. }
  627. })
  628. $("#rules_grid").jqGrid('setGridParam',{url:"index.php/procurement/populatePriceRules?pricelist_id="+$("#pricelist_id_hidden").val()+"&product_id="+product_id+"&inherit_rules="+$("#inherit_rules").val()+"&inherit_rules_dir="+$("#inherit_rules_dir").val(),page:1});
  629. $("#rules_grid").jqGrid('setGridParam',{
  630. loadComplete:function(){
  631. var num = $("#rules_grid").jqGrid('getGridParam','records');
  632. //console.log("num = " + num);
  633. if (num>0){
  634. //$( "#existingPRCntnr").show();
  635. $("#existingPR").removeAttr('disabled');
  636. $("#existingPR").attr('checked','checked').change();
  637. }
  638. else{
  639. $("#existingPR").removeAttr('checked');
  640. $("#existingPR").attr('disabled','disabled');
  641. $("#nonePR").attr('checked','checked').change();
  642. //$( "#existingPRCntnr").hide();
  643. }
  644. }});
  645. $("#rules_grid").trigger("reloadGrid");
  646. }
  647. }
  648. });
  649. $(window).load(function(){
  650. var warningDialogs={one:true,none:true,morethanone:true,exactlyone:true};
  651. initDialogs(warningDialogs);
  652. initCommentsForQuote();
  653. initDeleteDialog();
  654. });
  655. </script>
  656. </head>
  657. <body>
  658. <?php $this->load->view("common/menubar"); ?>
  659. <?php $this->load->view("common/dialogs"); ?>
  660. <div id="dialog-modal" title="Error">
  661. <p>Reference Number(s) <span id="refIds" style="font-weight:bold;"></span> Does Not Have Estimated Value. Please Check The Quantity Or Price Of Line Items</p>
  662. </div>
  663. <div id ="dialog-form">
  664. <h1 id="formHeader">Quote # <span id="quoteRef"></span> Details</h1>
  665. <form id="quoteForm">
  666. <fieldset>
  667. <div id="tabs">
  668. <ul>
  669. <li id="baseLink"><a id="base" href="<?php echo site_url('procurement/loadCreateQuoteFormFragment') ?>">Basic Details</a></li>
  670. <li id="notesLink"><a id ="notes" href="<?php echo site_url('procurement/loadCreateQuoteNotesFragment') ?>">Notes</a></li>
  671. </ul>
  672. </div>
  673. <div id ="status-message-li" class="ui-corner-all" style="margin-top: 10px; width:15em;">
  674. </div>
  675. <input id="supval" type="hidden" value=""/>
  676. <input id="warehouseval" type="hidden" value=""/>
  677. <input id="pricelist_id_hidden" type="hidden" value=""/>
  678. <input id="inherit_rules" type="hidden" value=""/>
  679. <input id="inherit_rules_dir" type="hidden" value=""/>
  680. <input id="reqdateval" type="hidden" value=""/>
  681. <input id="notesval" type="hidden" value=""/>
  682. <div class="table-grid" style="padding-top:2em;">
  683. <h1 id="pkdheader">Add Line Items</h1>
  684. <table id="lineItems"><tr><td/></tr></table>
  685. <div id="pagerPk"></div>
  686. </div>
  687. <div id="discountCntnr" class="inithide">
  688. <fieldset style="border:1px solid #A6C9E2; margin-bottom:2em;" id="pricelist_rule_fs_quote">
  689. <legend style="color: #2E6E9E;font-size: 110%;font-weight: bold;margin-left: 15px;">
  690. Discounts On Total Quote </legend>
  691. <div class="row" style="width:100%;">
  692. <div class="column triple-column" >
  693. <div class="field">
  694. <label for="dir_disc_total_quote_radio" class="labeldiv directlabel">Discount Amount w/Total:</label>
  695. <input type="radio" id="dir_disc_total_quote_radio" name="pricerule_quote" value="directamounttotal" style="float:left; margin-right: 1em;">
  696. <input type="text" id="dir_disc_total_quote" name="dir_disc_total_quote" style="float:left; margin-right: 1em;" size="10">
  697. </div>
  698. </div>
  699. <div class="column triple-column" >
  700. <div class="field">
  701. <label for="dir_disc_perc_quote_radio" class="labeldiv directlabel">Discount % w/Total:</label>
  702. <input type="radio" id="dir_disc_perc_quote_radio" name="pricerule_quote" value="directpercentage" style="float:left; margin-right: 1em;">
  703. <input type="text" id="dir_disc_perc_quote" name="dir_disc_perc_quote" style="float:left; margin-right: 1em;" size="10">
  704. </div>
  705. </div>
  706. <div class="column triple-column" style="width:16%;float:right;">
  707. <div class="field">
  708. <label for="none_quote" class="labeldiv directlabel">None:</label>
  709. <input type="radio" id="none_quote" name="pricerule_quote" value="none_quote" style="float:left; margin-right: 1em;">
  710. </div>
  711. </div>
  712. </div>
  713. <div class="ui-dialog-buttonpane shopifine-ui-widget-content ui-helper-clearfix">
  714. <div class="shopifine-ui-dialog-buttonset">
  715. <button id="applyBtn_quote" 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" style="margin-top:2em;">
  716. <span class="ui-button-text">Apply Discounts</span>
  717. </button>
  718. </div>
  719. </div>
  720. </fieldset>
  721. <div class="row">
  722. <div class="column">
  723. <div class="field">
  724. <div class="labeldiv rolabel">Discount On Quote:</div>
  725. <div id="discount_total_quote" name="discount_total_quote" class="valuediv"></div>
  726. </div>
  727. </div>
  728. <div class="column">
  729. <div class="field">
  730. <div class="labeldiv rolabel">Total After Discount:</div>
  731. <div id="amount_total_quote" name="amount_total_quote" class="valuediv"></div>
  732. </div>
  733. </div>
  734. </div>
  735. </div>
  736. </fieldset>
  737. </form>
  738. </div>
  739. <input id="quoteSubgridId" name ="quoteSubgridId" type="hidden" value=""/>
  740. <div id ="dialog-form-item" title="Add/Edit Line Item">
  741. <!-- <h1 id="formHeader">Add New Line Item</h1> -->
  742. <form id="itemForm">
  743. <fieldset>
  744. <div class="row">
  745. <div class="column item-column initshow">
  746. <div class="field" style="margin:0 auto;width:60%">
  747. <label for="productOp" class="labeldiv centrelabel">Products:</label>
  748. <select name="productOp" id ="productOp" class="required">
  749. <option value="">Choose
  750. <?= $productOptions ?>
  751. </select>
  752. <div class="valuediv valuediv-edit inithide" id="product_name_edit" name ="product_name_edit" style="display:none"></div>
  753. </div>
  754. </div>
  755. </div>
  756. <div class="row inithide" id="pricelistNameCntnr">
  757. <div class="column item-column" >
  758. <div class="field" style="width:60%; margin:0 auto;">
  759. <div class="labeldiv centrelabel" id="pricelist_name_label" name ="pricelist_name">Pricelist:</div>
  760. <div class="valuediv" id="pricelist_name" name ="pricelist_name" style="width:55%"></div>
  761. </div>
  762. </div>
  763. </div>
  764. <div class="row">
  765. <div class="column initshow">
  766. <div class="field">
  767. <label for="quantity" class="labeldiv">Quantity:</label>
  768. <input id="quantity" name="quantity" class="calinput"/>
  769. </div>
  770. </div>
  771. <div class="column">
  772. <div class="field">
  773. <label for="exPrice" class="labeldiv">Price:</label>
  774. <input id="exPrice" name="exPrice" class="calinput"/>
  775. <input id="isOverride" name="isOverride" type="checkbox" class="inithide"/>
  776. <div id ="override-help" class="ui-corner-all help-message-left inithide">
  777. (Select The Checkbox To Override Pricelist Price)
  778. </div>
  779. </div>
  780. </div>
  781. </div>
  782. <fieldset style="border:1px solid #A6C9E2; margin-top:5px;" id="pricelist_rule_fs">
  783. <legend style="color: #2E6E9E;font-size: 110%;font-weight: bold;margin-left: 15px;">
  784. Price Rules </legend>
  785. <div class="row">
  786. <div class="column table-column inithide" id="existingPRCntnr">
  787. <div class="field">
  788. <label for="existingPR" class="labeldiv" style="width:13%">Existing Price Rule:</label>
  789. <input type="radio" id="existingPR" name="pricerule" value="existing" style="float:left;margin-right: 1em;"/>
  790. <div class="table-grid" style="width:80%; clear:none; float:left;">
  791. <table id="rules_grid"><tr><td/></tr></table>
  792. <div id="pagerRules"></div>
  793. </div>
  794. </div>
  795. </div>
  796. </div>
  797. <div class="row">
  798. <div class="column" >
  799. <div class="field">
  800. <label for="dir_disc_unit_radio" class="labeldiv directlabel">Direct Discount w/Unit:</label>
  801. <input type="radio" id="dir_disc_unit_radio" name="pricerule" value="directamountunit" style="float:left; margin-right: 1em;" >
  802. <input type="text" id="dir_disc_unit" name="dir_disc_unit" style="float:left; margin-right: 1em;">
  803. </div>
  804. </div>
  805. <div class="column" >
  806. <div class="field">
  807. <label for="dir_disc_total_radio" class="labeldiv directlabel">Direct Discount w/Total:</label>
  808. <input type="radio" id="dir_disc_total_radio" name="pricerule" value="directamounttotal" style="float:left; margin-right: 1em;">
  809. <input type="text" id="dir_disc_total" name="dir_disc_total" style="float:left; margin-right: 1em;">
  810. </div>
  811. </div>
  812. </div>
  813. <div class="row">
  814. <div class="column" >
  815. <div class="field">
  816. <label for="dir_disc_perc_radio" class="labeldiv directlabel">Direct Discount Percentage:</label>
  817. <input type="radio" id="dir_disc_perc_radio" name="pricerule" value="directpercentage" style="float:left; margin-right: 1em;">
  818. <input type="text" id="dir_disc_perc" name="dir_disc_perc" style="float:left; margin-right: 1em;">
  819. </div>
  820. </div>
  821. <div class="column " >
  822. <div class="field">
  823. <!-- <label for="dir_disc_fg_radio" class="labeldiv directlabel" >Free Items:</label>
  824. <input type="radio" id="dir_disc_fg_radio" name="pricerule" value="dirFG" style="float:left; margin-right: 1em;">
  825. <input type="text" id="dir_disc_fg" name="dir_disc_fg" style="float:left; margin-right: 1em;">-->
  826. <label for="nonePR" class="labeldiv directlabel">None:</label>
  827. <input type="radio" id="nonePR" name="pricerule" value="nonePR" style="float:left; margin-right: 1em;">
  828. </div>
  829. </div>
  830. </div>
  831. <div class="row">
  832. <div class="column table-column" >
  833. <div class="field" style="margin:0 auto;width:60%">
  834. <label for="dir_disc_fg" class="labeldiv centrelabel">Free Items:</label>
  835. <!-- <input type="radio" id="nonePR" name="pricerule" value="nonePR" style="float:left; margin-right: 1em;">-->
  836. <input type="text" id="dir_disc_fg" name="dir_disc_fg" style="float:left; margin-right: 1em;">
  837. </div>
  838. </div>
  839. </div>
  840. <div class="ui-dialog-buttonpane shopifine-ui-widget-content ui-helper-clearfix">
  841. <div class="shopifine-ui-dialog-buttonset">
  842. <button id="applyBtn" 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">
  843. <span class="ui-button-text">Apply Discounts</span>
  844. </button>
  845. </div>
  846. </div>
  847. </fieldset>
  848. <div class="row">
  849. <div class="column">
  850. <div class="field">
  851. <label for="unit_price_discount" class="labeldiv">Unit Price discount</label>
  852. <label id="unit_price_discount" name="unit_price_discount" class="valuediv"/>
  853. </div>
  854. </div>
  855. <div class="column">
  856. <div class="field">
  857. <label for="free_items" class="labeldiv">Free Items:</label>
  858. <label id="free_items" name="free_items" class="valuediv"/>
  859. </div>
  860. </div>
  861. </div>
  862. <div class="row">
  863. <div class="column">
  864. <div class="field">
  865. <label for="unit_price_final" class="labeldiv">Final Unit Price:</label>
  866. <label id="unit_price_final" name="finalUnitPrice" class="valuediv"/>
  867. </div>
  868. </div>
  869. <div class="column">
  870. <div class="field">
  871. <label for="discount_total" class="labeldiv">Discount Amount:</label>
  872. <label id="discount_total" name="discount_total" class="valuediv"/>
  873. </div>
  874. </div>
  875. </div>
  876. <div class="row">
  877. <div class="column">
  878. <div class="field">
  879. <label for="items_total" class="labeldiv">Total Items:</label>
  880. <label id="items_total" name="items_total" class="valuediv"/>
  881. </div>
  882. </div>
  883. <div class="column">
  884. <div class="field">
  885. <label for="amount_total" class="labeldiv">Total Price:</label>
  886. <label id="amount_total" name="amount_total" class="valuediv"/>
  887. </div>
  888. </div>
  889. </div>
  890. <div class="row ">
  891. <div class="column item-column ">
  892. <div class="field" style="width:50%; margin:0 auto;">
  893. <label for="neededdate" class="labeldiv centrelabel">Needed By Date:</label>
  894. <input id="neededdate" name ="neededdate" type="text"/>
  895. </div>
  896. </div>
  897. </div>
  898. <div class="row ">
  899. <div class="column item-column ">
  900. <div class="field" style="width:50%; margin:0 auto;">
  901. <label for="notes_item" class="labeldiv centrelabel">Notes:</label>
  902. <textarea id="notes_item" name ="notes_item" column="100" row="5"></textarea>
  903. </div>

Large files files are truncated, but you can click here to view the full file