Advertisement
germanmary

custom update

Nov 16th, 2014
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 41.25 KB | None | 0 0
  1. <?php
  2. /**
  3. * PHP Grid Component
  4. *
  5. * @author Abu Ghufran <gridphp@gmail.com> - http://www.phpgrid.org
  6. * @version 1.5.2
  7. * @license: see license.txt included in package
  8. */
  9.  
  10. // include db config
  11. include_once("/phpgrid/config.php");
  12.  
  13. include('session.php');
  14.  
  15. // Establishing Connection with Server by passing server_name, user_id and password as a parameter
  16. //$connection = mysql_connect("localhost", "root", "");
  17. // Selecting Database
  18. //$db = mysql_select_db("invopo", $connection);
  19.  
  20. // SQL Query To Fetch Complete Information Of User
  21.  
  22.  
  23. mysql_connect(PHPGRID_DBHOST, PHPGRID_DBUSER, PHPGRID_DBPASS);
  24. mysql_select_db(PHPGRID_DBNAME);
  25. //print($user_check);
  26. // include and create object
  27. include(PHPGRID_LIBPATH."inc/jqgrid_dist.php");
  28.  
  29. //$ses_sql=mysql_query("select userid,roleid from invopo_user where username='$user_check'");
  30. //$row = mysql_fetch_assoc($ses_sql);
  31. //$user_id =$login_id;
  32. //$role_id = $row['roleid'];
  33.  
  34.  
  35. $sqlquery = mysql_query("select C,R,U,D from invopo_role_page_mast where roleid='$role_id' and pagename='invopo_user'");
  36. $rowq = mysql_fetch_assoc($sqlquery);
  37. $cr = $rowq['C'];
  38. $re = $rowq['R'];
  39. $up = $rowq['U'];
  40. $de = $rowq['D'];
  41. $uid =$login_id ;
  42.  
  43.  
  44. $g = new jqgrid();
  45. $today = date('Y-m-d H:i:s',time());
  46.  
  47.  
  48.  
  49. $col = array();
  50. $col["title"] = "Id"; // caption of column
  51. $col["name"] = "orderid";
  52. $col["width"] = "20";
  53. $col["editable"] = false;
  54. $cols[] = $col;
  55.  
  56. $col = array();
  57. $col["title"] = "Orderno";
  58. $col["name"] = "orderno";
  59. $col["width"] = "50";
  60. $col["editable"] = true;
  61. $col["editrules"] = array("required"=>true);// this column is editable
  62. $col["formoptions"] = array("rowpos"=>"1", "colpos"=>"1");
  63. $cols[] = $col;
  64.  
  65. $col = array();
  66. $col["title"] = "OrderDate";
  67. $col["name"] = "orderdate";
  68. $col["width"] = "60";
  69. $col["editable"] = true; // this column is editable
  70. $col["editoptions"] = array("size"=>20); // with default display of textbox with size 20
  71. $col["editrules"] = array("required"=>true); // required:true(false), number:true(false), minValue:val, maxValue:val
  72. $col["formatter"] = "date"; // format as date
  73. // format as date
  74. $col["formatoptions"] = array("srcformat"=>'Y-m-d',"newformat"=>'d/m/Y');
  75. $col["formoptions"] = array("rowpos"=>"1", "colpos"=>"2");
  76. $cols[] = $col;
  77.  
  78. $col = array();
  79. $col["title"] = "quotationno";
  80. $col["name"] = "quotationno";
  81. $col["dbname"] = "invopo_order_info.quotationno";
  82. $col["editable"] = true;
  83. $col["width"] = "80";
  84. $col["edittype"] = "select"; // render as select
  85. # fetch data from database, with alias k for key, v for value
  86. $str = $g->get_dropdown_values("select quotationid as k, quotationno as v from invopo_quotationmaster where status='quoted'");
  87. $col["editoptions"] = array(
  88. "value"=>$str,
  89. "onchange" => array(
  90. "sql"=>"select * from invopo_quotationmaster",
  91. "search_on"=>"quotationid",
  92. "callback" => "fill_form" )
  93. );
  94. $col["stype"] = "select"; // enable dropdown search
  95. $col["searchoptions"] = array("value" => ":;".$str);
  96. $col["formoptions"] = array("rowpos"=>"2", "colpos"=>"1");
  97. $cols[] = $col;
  98.  
  99.  
  100. $col = array();
  101. $col["title"] = "Ref.No";
  102. $col["name"] = "referenceno";
  103. $col["width"] = "50";
  104. $col["editable"] = true;
  105. $col["editrules"] = array("required"=>true);// this column is editable
  106. $col["formoptions"] = array("rowpos"=>"2", "colpos"=>"2");
  107. $cols[] = $col;
  108.  
  109. $col = array();
  110. $col["title"] = "Date";
  111. $col["name"] = "quotationdate";
  112. $col["width"] = "60";
  113. $col["editable"] = true; // this column is editable
  114. $col["editoptions"] = array("size"=>20); // with default display of textbox with size 20
  115. $col["editrules"] = array("required"=>true); // required:true(false), number:true(false), minValue:val, maxValue:val
  116. $col["formatter"] = "date"; // format as date
  117. // format as date
  118. //$col["formatoptions"] = array("srcformat"=>'Y-m-d',"newformat"=>'d/m/Y');
  119. $col["formoptions"] = array("rowpos"=>"2", "colpos"=>"3");
  120. $cols[] = $col;
  121.  
  122. $col = array();
  123. $col["title"] = "Datatype"; // caption of column
  124. $col["name"] = "datatype"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  125. $col["editable"] = true;
  126. $col["hidden"] = false;
  127. $col["width"] = "50";
  128. $col["edittype"] = "select";
  129. $col["editoptions"] = array("value" => "Quote:quote;invoice:Invoice;proformainvoice:proformainvoice");
  130. //$col["editrules"] = array("required"=>true, "readonly"=>true, "readonly-when"=>array("==","Received"));
  131. $col["show"] = array("list"=>true, "add"=>true, "edit"=>true, "view"=>true);
  132. $col["formoptions"] = array("rowpos"=>"3", "colpos"=>"1");
  133.  
  134. $cols[] = $col;
  135.  
  136.  
  137. $col = array();
  138. $col["title"] = "Vendor";
  139. $col["name"] = "billerid";
  140. $col["dbname"] = "invopo_order_info.billerid"; // this is required as we need to search in name field, not id
  141. $col["width"] = "70";
  142. $col["align"] = "left";
  143.  
  144. $col["editrules"] = array("required"=>true);
  145. # fetch data from database, with alias k for key, v for value
  146. $col["search"] = true;
  147. $col["editable"] = true;
  148. $col["edittype"] = "select"; // render as select
  149. # fetch data from database, with alias k for key, v for value
  150. //$str = $g->get_dropdown_values("select i.billerid as k, i.billername as v from invopo_biller i inner join invopo_quotationmaster q ON q.billerid=i.billerid and q.quotationid='{quotationid}' ");
  151. $col["editoptions"]["onload"]["sql"]="select i.billerid as k, i.billername as v from invopo_biller i inner join invopo_quotationmaster q ON q.billerid=i.billerid "; // and q.quotationid='{quotationid}'
  152. //$col["editoptions"] = array("value"=>$str);
  153. $col["formatter"] = "select"; // display label, not value
  154. $col["formoptions"] = array("rowpos"=>"3", "colpos"=>"2");
  155. $cols[] = $col;
  156.  
  157. $col = array();
  158. $col["title"] = "Company";
  159. $col["name"] = "companyid";
  160. $col["dbname"] = "invopo_order_info.companyid"; // this is required as we need to search in name field, not id
  161. $col["width"] = "50";
  162. $col["align"] = "left";
  163. $col["search"] = true;
  164. $col["editable"] = true;
  165. $col["edittype"] = "select"; // render as select
  166. # fetch data from database, with alias k for key, v for value
  167. //$str = $g->get_dropdown_values("select distinct compid as k, compname as v from invopo_company");
  168. $col["editoptions"]["onload"]["sql"]="select distinct i.compid as k, i.compname as v from invopo_company i inner join invopo_quotationmaster q ON q.companyid=i.compid";
  169. //$col["editoptions"] = array("value"=>$str);
  170. $col["formatter"] = "select"; // display label, not value
  171. $col["formoptions"] = array("rowpos"=>"3", "colpos"=>"3");
  172. $col["editrules"] = array("edithidden"=>true);
  173. $col["hidden"] = true;
  174. $cols[] = $col;
  175.  
  176.  
  177. $col = array();
  178. $col["title"] = "Level1";
  179. $col["name"] = "itemmastercode";
  180. $col["dbname"] = "invopo_order_info.itemmastercode"; // this is required as we need to search in name field, not id
  181. $col["width"] = "50";
  182. $col["align"] = "left";
  183. $col["search"] = true;
  184. $col["editable"] = true;
  185. $col["edittype"] = "select";
  186. $col["editoptions"]["onload"]["sql"] = "select distinct i.itemmastercode as k, i.itermasternamecategories as v from invopo_itemmastercode i inner join invopo_quotationmaster q ON q.itemmastercode=i.itemmastercode";
  187.  
  188. //$col["edittype"] = "select"; // render as select
  189. # fetch data from database, with alias k for key, v for value
  190. # on change, update other dropdown
  191. //$str = $g->get_dropdown_values("select distinct i.itemmastercode as k, i.itermasternamecategories as v from invopo_itemmastercode i inner join invopo_quotationmaster q where q.itemmastercode=i.itemmastercode and q.quotationno={quotationno}");
  192. //$col["editoptions"] = array(
  193. // "value"=>$str,
  194. // "onchange" => array("sql"=>"select distinct itemtypeid as k, itemtypename as v from invopo_itemtype_mast WHERE itemmastercode = '{itemmastercode}'",
  195. // "update_field" =>"itemtypeid" )
  196. // );
  197.  
  198. $col["formatter"] = "select"; // display label, not value
  199.  
  200. $col["stype"] = "select"; // enable dropdown search
  201. $col["searchoptions"] = array("value" => ":;".$str);
  202. $col["formoptions"] = array("rowpos"=>"4", "colpos"=>"1");
  203. $cols[] = $col;
  204.  
  205. $col = array();
  206. $col["title"] = "Level2";
  207. $col["name"] = "itemtypeid";
  208. $col["dbname"] = "itemtypeid"; // this is required as we need to search in name field, not id
  209. $col["width"] = "50";
  210. $col["align"] = "left";
  211. $col["search"] = true;
  212. $col["editable"] = true;
  213. $col["edittype"] = "select"; // render as select
  214. # fetch data from database, with alias k for key, v for value
  215.  
  216. # on change, update other dropdown
  217. $str = $g->get_dropdown_values("select itemtypeid as k, itemtypename as v from invopo_itemtype_mast");
  218. $col["editoptions"] = array(
  219. "value"=>$str,
  220. "onchange" => array("sql"=>"select distinct itemid as k, itemname as v from invopo_item_mast WHERE itemtypeid = '{itemtypeid}'",
  221. "update_field" => "itemid" )
  222.  
  223. );
  224.  
  225.  
  226.  
  227. $col["formatter"] = "select"; // display label, not value
  228. $col["stype"] = "select"; // enable dropdown search
  229. $col["searchoptions"] = array("value" => ":;".$str);
  230. $col["formoptions"] = array("rowpos"=>"4", "colpos"=>"2");
  231. $cols[] = $col;
  232.  
  233. $col = array();
  234. $col["title"] = "Level3";
  235. $col["name"] = "itemid";
  236. $col["dbname"] = "itemid";
  237. $col["width"] = "50";
  238. $col["search"] = true;
  239. $col["editable"] = true;
  240. $col["edittype"] = "select";
  241. $str = $g->get_dropdown_values("select itemid as k, itemname as v from invopo_item_mast");
  242. $col["editoptions"] = array(
  243. "value"=>$str,
  244. );
  245.  
  246. $col["formatter"] = "select"; // display label, not value
  247. $col["stype"] = "select"; // enable dropdown search
  248. $col["searchoptions"] = array("value" => ":;".$str);
  249. $col["formoptions"] = array("rowpos"=>"4", "colpos"=>"3");
  250. $cols[] = $col;
  251.  
  252. $col = array();
  253. $col["title"] = "Unit of Measurement";
  254. $col["name"] = "uomid";
  255. $col["dbname"] = "uomid";
  256. $col["width"] = "50";
  257. $col["search"] = true;
  258. $col["editable"] = true;
  259. $col["editrules"] = array("required"=>true);
  260. $col["edittype"] = "select";
  261. // render as select
  262. # fetch data from database, with alias k for key, v for value
  263. $str = $g->get_dropdown_values("select distinct uomid as k, uomtype as v from invopo_uom ");
  264. $col["editoptions"] = array("value"=>$str);
  265. $col["formatter"] = "select"; // display label, not value
  266. $col["formoptions"] = array("rowpos"=>"5", "colpos"=>"1");
  267. $col["editrules"] = array("edithidden"=>true);
  268. $col["hidden"] = true;
  269. $cols[] = $col;
  270.  
  271. $col = array();
  272. $col["title"] = "Quantity"; // caption of column
  273. $col["name"] = "qty"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  274. $col["editable"] = true;
  275. //$col["editrules"] = array("required"=>true);
  276. $col["editoptions"] = array("onblur" => "update_total()");
  277. $col["formoptions"] = array("rowpos"=>"5", "colpos"=>"2");
  278. $col["width"] = "50";
  279. $col["hidden"] = false;
  280. $cols[] = $col;
  281.  
  282. $col = array();
  283. $col["title"] = "Rate"; // caption of column
  284. $col["name"] = "rate"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  285. $col["editable"] = true;
  286. $col["width"] = "50";
  287. //$col["editrules"] = array("required"=>true);
  288. $col["editoptions"] = array("onblur" => "update_total()");
  289. $col["formoptions"] = array("rowpos"=>"5", "colpos"=>"3");
  290. $col["hidden"] = false;
  291. $cols[] = $col;
  292.  
  293. $col = array();
  294. $col["title"] = "Total Amount";
  295. $col["name"] = "totalamount";
  296. $col["id"] = "totalamount";
  297. $col["width"] = "50";
  298. $col["editable"] = true;
  299. //$col["editrules"] = array("edithidden"=>true);
  300. //array("onblur" => "jQuery('#totalamount').val( parseInt(jQuery('#qty').val()) * parseInt(jQuery('#rate').val()))");
  301. //$col["editrules"] = array("custom"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
  302. $col["editrules"] = array("edithidden"=>true);
  303. $col["formoptions"] = array("rowpos"=>"6", "colpos"=>"1");
  304. $col["formatter"] = "number";
  305. $col["formatoptions"] = array("thousandsSeparator" => ",",
  306. "decimalSeparator" => ".",
  307. "decimalPlaces" => 2);
  308. $col["hidden"] = true;
  309. $cols[] = $col;
  310.  
  311. $col["title"] = "Discount"; // caption of column
  312. $col["name"] = "disc"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  313. $col["editable"] = true;
  314. //$col["editrules"] = array("edithidden"=>true);//,"custom_func"=>"function(val,label){return my_validation(val,label);}");
  315. $col["width"] = "50";
  316. $col["editoptions"] = array("onblur" => "update_discount()"); ;
  317. $col["formoptions"] = array("rowpos"=>"6", "colpos"=>"2");
  318. $col["hidden"] = true;
  319. $cols[] = $col;
  320.  
  321. $col = array();
  322. $col["title"] = "DiscountAmount"; // caption of column
  323. $col["name"] = "discamount"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  324. $col["editable"] = true;
  325. $col["editrules"] = array("edithidden"=>true);//,"custom"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
  326. $col["hidden"] = false;
  327. $col["width"] = "50";
  328. $col["formoptions"] = array("rowpos"=>"6", "colpos"=>"3");
  329. $col["formatter"] = "currency";
  330. $col["formatoptions"] = array("thousandsSeparator" => ",",
  331. "decimalSeparator" => ".",
  332. "decimalPlaces" => 2);
  333. $cols[] = $col;
  334. //qty, rate, tax, disc, totalamount, taxamount, discamount, netamount, transportation, exciseduty, paymentterms, deliveryterms, validity, deliveryshedule, pf, for, specialinstruction, notes, commissioningcharges, labourchages, frieghtcharges, paymentstatus, datatype
  335.  
  336. $col = array();
  337. $col["title"] = "Tax"; // caption of column
  338. $col["name"] = "tax"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  339. $col["editable"] = true;
  340. $col["width"] = "50";
  341. //$col["editrules"] = array("required"=>true);
  342. $col["editoptions"] = array("onblur" => "update_tax()");
  343. $col["formoptions"] = array("rowpos"=>"7", "colpos"=>"1");
  344. $col["hidden"] = false;
  345. $cols[] = $col;
  346.  
  347. $col = array();
  348. $col["title"] = "Tax Amount"; // caption of column
  349. $col["name"] = "taxamount"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  350. $col["editable"] = true;
  351. //$col["editrules"] = array("custom"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
  352. $col["hidden"] = false;
  353. $col["width"] = "50";
  354. $col["formatter"] = "currency";
  355. $col["formatoptions"] = array("thousandsSeparator" => ",",
  356. "decimalSeparator" => ".",
  357. "decimalPlaces" => 2);
  358. $col["formoptions"] = array("rowpos"=>"7", "colpos"=>"2");
  359. $cols[] = $col;
  360.  
  361.  
  362. $col = array();
  363. $col["title"] = "NetAmount"; // caption of column
  364. $col["name"] = "netamount"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  365. $col["editable"] = true;
  366. $col["width"] = "50";
  367. //$col["editrules"] = array("custom"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
  368. $col["editoptions"] = array("onblur" => "update_cost()");
  369. $col["formatter"] = "currency";
  370. $col["formatoptions"] = array("thousandsSeparator" => ",",
  371. "decimalSeparator" => ".",
  372. "decimalPlaces" => 2);
  373.  
  374. $col["formoptions"] = array("rowpos"=>"7", "colpos"=>"3");
  375. $col["hidden"] = true;
  376. //$col["editoptions"] = array("onblur" => "update_cost()");
  377. $cols[] = $col;
  378.  
  379. $col = array();
  380. $col["title"] = "Transportation"; // caption of column
  381. $col["name"] = "transportation";
  382. $col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");// grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  383. $col["editable"] = true;
  384. $col["hidden"] = true;
  385. $col["width"] = "50";
  386. $col["editoptions"] = array("onblur" => "update_cost()");
  387. $col["formoptions"] = array("rowpos"=>"8", "colpos"=>"1");
  388. $cols[] = $col;
  389.  
  390. //exciseduty, paymentterms, deliveryterms, validity, deliveryshedule, pf, for, specialinstruction, notes, commissioningcharges, labourchages, frieghtcharges, paymentstatus, datatype
  391.  
  392. $col = array();
  393. $col["title"] = "Exciseduty"; // caption of column
  394. $col["name"] = "exciseduty"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  395. $col["editable"] = true;
  396. $col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
  397. $col["hidden"] = true;
  398. $col["width"] = "50";
  399. $col["editoptions"] = array("onblur" => "update_cost()");
  400. $col["formoptions"] = array("rowpos"=>"8", "colpos"=>"2");
  401.  
  402. $cols[] = $col;
  403.  
  404. $col = array();
  405. $col["title"] = "Commission Charges"; // caption of column
  406. $col["name"] = "commissioningcharges"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  407. $col["editable"] = true;
  408. $col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
  409. $col["hidden"] = true;
  410. $col["width"] = "50";
  411. $col["editoptions"] = array("onblur" => "update_cost()");
  412. $col["formoptions"] = array("rowpos"=>"8", "colpos"=>"3");
  413. $cols[] = $col;
  414.  
  415.  
  416. $col = array();
  417. $col["title"] = "LabourChages"; // caption of column
  418. $col["name"] = "labourchages"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  419. $col["editable"] = true;
  420. $col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}","edithidden"=>true);
  421. $col["hidden"] = true;
  422. $col["width"] = "50";
  423. $col["editoptions"] = array("onblur" => "update_cost()");
  424. $col["formoptions"] = array("rowpos"=>"9", "colpos"=>"1");
  425. $cols[] = $col;
  426.  
  427. /*$col = array();
  428. $col["title"] = "FrieghtCharges"; // caption of column
  429. $col["name"] = "frieghtcharges"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  430. $col["editable"] = true;
  431. $col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
  432. $col["hidden"] = true;
  433. $col["width"] = "50";
  434. $col["editoptions"] = array("onblur" => "update_cost()");
  435. //$col["editoptions"] = array("onblur" => "update_cost()");
  436. $col["formoptions"] = array("rowpos"=>"8", "colpos"=>"2");
  437. $cols[] = $col; */
  438. $col = array();
  439. $col["title"] = "Others"; // caption of column
  440. $col["name"] = "othercharges"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  441. $col["editable"] = true;
  442. $col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}","edithidden"=>true);
  443. $col["hidden"] = true;
  444. $col["width"] = "50";
  445. $col["formatter"] = "currency";
  446. $col["editoptions"] = array("onblur" => "update_cost()");
  447. $col["formoptions"] = array("rowpos"=>"9", "colpos"=>"2");
  448. $cols[] = $col;
  449.  
  450. $col = array();
  451. $col["title"] ="TotalCost"; // caption of column
  452. $col["name"]="totalcost"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  453. $col["editable"] = true;
  454. $col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
  455. $col["width"] = "50";
  456. $col["formatter"] = "currency";
  457. $col["formatoptions"] = array("thousandsSeparator" => ",",
  458. "decimalSeparator" => ".",
  459. "decimalPlaces" => 2);
  460. $col["formoptions"] = array("rowpos"=>"9", "colpos"=>"3");
  461. //$col["editoptions"] = array("onblur" => "update_tax()");
  462. $cols[] = $col;
  463. $col = array();
  464. $col["title"] = "F.O.R(location)"; // caption of column
  465. $col["name"] = "for"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  466. $col["editable"] = true;
  467. $col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
  468. $col["hidden"] = true;
  469. $col["width"] = "50";
  470. $col["formoptions"] = array("rowpos"=>"10", "colpos"=>"1");
  471. $cols[] = $col;
  472. $col = array();
  473.  
  474. $col = array();
  475. $col["title"] = "PaymentTerms"; // caption of column
  476. $col["name"] = "paymentterms"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  477. $col["editable"] = true;
  478. $col["hidden"] = true;
  479. $col["width"] = "50";
  480. $col["formoptions"] = array("rowpos"=>"10", "colpos"=>"2");
  481. $cols[] = $col;
  482.  
  483. $col = array();
  484. $col["title"] = "DeliveryTerms"; // caption of column
  485. $col["name"] = "deliveryterms"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  486. $col["editable"] = true;
  487. $col["editrules"] = array("edithidden"=>true);
  488. $col["hidden"] = true;
  489. $col["width"] = "50";
  490. $col["formoptions"] = array("rowpos"=>"10", "colpos"=>"3");
  491. $cols[] = $col;
  492.  
  493. $col = array();
  494. $col["title"] = "Validity"; // caption of column
  495. $col["name"] = "validity"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  496. $col["editable"] = true;
  497. $col["hidden"] = false;
  498. $col["width"] = "50";
  499. $col["formoptions"] = array("rowpos"=>"11", "colpos"=>"1");
  500. $col["hidden"] = true;
  501. $cols[] = $col;
  502. //deliveryshedule, pf, for, specialinstruction, notes, commissioningcharges, labourchages, frieghtcharges, paymentstatus, datatype
  503. $col = array();
  504. $col["title"] = "DeliveryShedule"; // caption of column
  505. $col["name"] = "deliveryshedule"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  506. $col["editable"] = true;
  507. $col["editrules"] = array("edithidden"=>true);
  508. $col["hidden"] = true;
  509. $col["width"] = "50";
  510. $col["formoptions"] = array("rowpos"=>"11", "colpos"=>"2");
  511. $cols[] = $col;
  512.  
  513. $col = array();
  514. $col["title"] = "Packing/Forwarding"; // caption of column
  515. $col["name"] = "pf"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  516. $col["editable"] = true;
  517. $col["editoptions"] = array("rows"=>2);
  518. $col["editrules"] = array("edithidden"=>true);
  519. $col["hidden"] = true;
  520. $col["formoptions"] = array("rowpos"=>"11", "colpos"=>"3");
  521. $cols[] = $col;
  522.  
  523. $col["title"] = "Charges Notes"; // caption of column
  524. $col["name"] = "chargesnotes"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  525. $col["editable"] = true;
  526. $col["edittype"] = "textarea";
  527. $col["editoptions"] = array("rows"=>1, "cols"=>30);
  528. //$col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
  529. $col["editrules"] = array("edithidden"=>true);
  530. $col["hidden"] = true;
  531. $col["width"] = "50";
  532. $col["formoptions"] = array("rowpos"=>"12", "colpos"=>"1");
  533. $cols[] = $col;
  534.  
  535.  
  536. $col = array();
  537. $col["title"] = "Specialinstruction"; // caption of column
  538. $col["name"] = "specialinstruction"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  539. $col["editable"] = true;
  540. $col["edittype"] = "textarea"; // render as textarea on edit
  541. $col["editoptions"] = array("rows"=>2, "cols"=>20);
  542. $col["width"] = "50";
  543. $col["formoptions"] = array("rowpos"=>"12", "colpos"=>"2");
  544. $col["editrules"] = array("edithidden"=>true);
  545. $col["hidden"] = true;
  546. $cols[] = $col;
  547.  
  548.  
  549. // notes, commissioningcharges, labourchages, frieghtcharges, paymentstatus, datatype
  550. $col = array();
  551. $col["title"] = "Notes"; // caption of column
  552. $col["name"] = "notes"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  553. $col["editable"] = true;
  554. $col["edittype"] = "textarea";
  555. $col["editoptions"] = array("rows"=>2, "cols"=>20);
  556. $col["width"] = "50";
  557. $col["formoptions"] = array("rowpos"=>"12", "colpos"=>"3");
  558. $col["hidden"] = false;
  559. $cols[] = $col;
  560.  
  561. $col = array();
  562. $col["title"] = "Payment Type"; // caption of column
  563. $col["name"] = "paymenttype"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  564. $col["editable"] = true;
  565. $col["edittype"] = "select";
  566. $col["editoptions"] = array("rows"=>1, "cols"=>30);
  567. //$col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
  568. $col["editrules"] = array("edithidden"=>true);
  569. $col["editoptions"] = array("value" => "Neft:NEFT;cash:Cash;RTGS:RTGS");
  570. $col["hidden"] = true;
  571. $col["width"] = "50";
  572. $col["formoptions"] = array("rowpos"=>"13", "colpos"=>"1");
  573. $cols[] = $col;
  574.  
  575. $col = array();
  576. $col["title"] = "PaymentStatus"; // caption of column
  577. $col["name"] = "paymentstatus"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  578. $col["editable"] = true;
  579. $col["editrules"] = array("edithidden"=>true);
  580. $col["hidden"] = false;
  581. $col["width"] = "50";
  582. $col["formoptions"] = array("rowpos"=>"13", "colpos"=>"2");
  583. $cols[] = $col;
  584.  
  585. $col = array();
  586. $col["title"] = "Status"; // caption of column
  587. $col["name"] = "status"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  588. $col["editable"] = true;
  589. $col["editrules"] = array("required"=>true);
  590. $col["edittype"] = "select";
  591. $col["editoptions"] = array("value" => "quoted:Quoted;ordered:Ordered;received:Received");
  592. $col["editrules"] = array("required"=>true, "readonly"=>true, "readonly-when"=>array("==","Received"));
  593. $col["show"] = array("list"=>true, "add"=>true, "edit"=>true, "view"=>true);
  594. $col["formoptions"] = array("rowpos"=>"13", "colpos"=>"3");
  595. $col["width"] = "50";
  596. $cols[] = $col;
  597.  
  598.  
  599.  
  600. $col = array();
  601. $col["title"] = "Delivery Completion"; // caption of column
  602. $col["name"] = "deliverycompletion"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  603. $col["editable"] = true;
  604. $col["edittype"] = "textarea";
  605. $col["editoptions"] = array("rows"=>1, "cols"=>30);
  606. //$col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
  607. $col["editrules"] = array("edithidden"=>true);
  608. $col["hidden"] = true;
  609. $col["width"] = "50";
  610. $col["formoptions"] = array("rowpos"=>"14", "colpos"=>"1");
  611. $cols[] = $col;
  612.  
  613.  
  614. $col = array();
  615. $col["title"] = "insertedby"; // caption of column
  616. $col["name"] = "insertedby"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  617. $col["editable"] = true;
  618. $col["editoptions"] = array("defaultValue" => "$uid");
  619. $col["hidden"] = true;
  620. $cols[] = $col;
  621.  
  622. $col = array();
  623. $col["title"] = "insertedat"; // caption of column
  624. $col["name"] = "insertedat"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  625. $col["editable"] = true;
  626. $col["editoptions"] = array("defaultValue" => "$today");
  627. $col["hidden"] = true;
  628. $cols[] = $col;
  629.  
  630. $col = array();
  631. $col["title"] = "updatedby"; // caption of column
  632. $col["name"] = "updatedby"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  633. $col["editable"] = true;
  634. $col["hidden"] = true;
  635. $cols[] = $col;
  636.  
  637. $col = array();
  638.  
  639. $col["title"] = "updatedat"; // caption of column
  640. $col["name"] = "updatedat"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  641. $col["editable"] = false;
  642. $col["hidden"] = true;
  643. //$col["editoptions"] = array("defaultValue" => '$today');
  644. $cols[] = $col;
  645.  
  646. $grid["sortname"] = 'orderid'; // by default sort grid by this field
  647. $grid["sortorder"] = "asc"; // ASC or DESC
  648. $grid["caption"] = "Order Details"; // caption of grid
  649. $grid["width"] = "1800";
  650. $grid["form"]["position"] = "top";
  651. $grid["add_options"] = array('width'=>'820');
  652. // $grid["add_options"]["afterShowForm"] = 'function(formid) { jQuery("#totalamount").mask("000.00"); }';
  653.  
  654. $grid["edit_options"] = array('width'=>'820');
  655. $grid["autowidth"] = true; // expand grid to screen width
  656. $grid["multiselect"] = true; // allow you to multi-select through checkboxes
  657. // allow you to multi-select through checkboxes
  658. //$col["formoptions"] = array("rowpos"=>"1", "colpos"=>"2");
  659. $grid["edit_options"]["beforeSubmit"] = "function(post,form){ return validate_form_once(post,form); }";
  660. //$grid["shrink_to_fit"] = true;
  661. $grid["export"] = array("format"=>"pdf", "filename"=>"my-file", "heading"=>"Invoice Details", "orientation"=>"landscape", "paper"=>"a4");
  662.  
  663. // Setting RTL will export pdf as RTL also
  664. // $grid["direction"] = "rtl";
  665.  
  666. // export filtered data or all data
  667. $grid["export"]["range"] = "filtered"; // or "all"
  668. $grid["export"]["paged"] = "1";
  669. $g->set_options($grid);
  670.  
  671. // params are array(<function-name>,<class-object> or <null-if-global-func>)
  672. $e["on_render_pdf"] = array("set_pdf_format", null);
  673. $e["on_update"] = array("update_by", null, true);
  674. $g->set_events($e);
  675.  
  676. function update_by($data)
  677. {
  678. //ob_start();
  679. //print_r($data);
  680. //$str = ob_get_clean();
  681. $str = "UPDATE invopo_quotationmaster SET status='ordered'
  682. WHERE quotationid = {$data["quotationid"]}";
  683. mysql_query($str);
  684. print_r($str);
  685.  
  686.  
  687. }
  688. function set_pdf_format($arr)
  689. {
  690. $pdf = $arr["pdf"];
  691. $data = $arr["data"];
  692.  
  693. // $pdf->SetFont('helvetica', '', 11);
  694. // $pdf->SetCellWidths(array(30,102,'auto'));
  695.  
  696. /*
  697. PDF format customization API available here
  698. -------------------------------------------
  699. http://www.tcpdf.org/examples.php
  700. http://www.tcpdf.org/doc/code/classTCPDF.html
  701.  
  702. More Custom Addons API (see inc/tcpdf/class.TCPDF.EasyTable.php & jqgrid_dist.php)
  703. ----------------------------------------------------------------
  704. public function SetCellMinimumHeight($height)
  705. public function SetCellFixedHeight($height)
  706. public function SetHeaderCellFixedHeight($height)
  707. public function SetTableHeaderPerPage($var)
  708. public function SetTableHeaderFirstTablePerPageOnly($var)
  709. public function SetCellAlignment($ArrayCellAlignment)
  710. public function SetCellWidths($ArrayCellWidths)
  711. public function SetCellFillStyle($int)
  712. public function SetFillImageCell($fill)
  713. public function SetHCellSpace($var)
  714. public function SetVCellSpace($var)
  715. public function SetHeaderCellsFillColor($R,$G,$B)
  716. public function SetTableRowFillColors(Array $colorsArray)
  717. public function SetHeaderCellsFontColor($R,$G,$B)
  718. public function SetHeaderCellsFontStyle($var)
  719. public function SetCellFontColor($R,$G,$B)
  720. public function SetFooterExclusionZone($float)
  721. public function SetTableX($x)
  722. public function SetTableY($y)
  723. public function Header()
  724. public function Footer()
  725. */
  726. }
  727.  
  728.  
  729.  
  730. $g->set_actions(array(
  731. "add"=>true, // allow/disallow add
  732. "edit"=>false, // allow/disallow edit
  733. "delete"=>false, // allow/disallow delete
  734. "rowactions"=>true, // show/hide row wise edit/del/save option
  735. "autofilter" => true,
  736. // show/hide autofilter for search
  737. "export"=>true,
  738. "search" => "advance"
  739. )
  740. );
  741.  
  742.  
  743. $g->select_command = "SELECT * FROM invopo.invopo_order_info" ;
  744. // // ";
  745.  
  746. // this db table will be used for add,edit,delete
  747. $g->table = "invopo.invopo_order_info";
  748.  
  749. $g->set_columns($cols);
  750.  
  751. // return last inserted id for further working
  752. //$e["on_update"] = array("update_by", null, true);
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759. // generate grid output, with unique grid name as 'list1'
  760. $out = $g->render("list1");
  761. ?>
  762. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  763. <html>
  764. <head>
  765. <link rel="stylesheet" type="text/css" media="screen" href="../phpgrid/lib/js/themes/redmond/jquery-ui.custom.css"></link>
  766. <link rel="stylesheet" type="text/css" media="screen" href="../phpgrid/lib/js/jqgrid/css/ui.jqgrid.css"></link>
  767.  
  768. <script src="../phpgrid/lib/js/jquery.mask.min.js" type="text/javascript"></script>
  769. <script src="../phpgrid/lib/js/jquery.min.js" type="text/javascript"></script>
  770. <script src="../phpgrid/lib/js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
  771. <script src="../phpgrid/lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
  772. <script src="../phpgrid/lib/js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
  773. </head>
  774. <body>
  775. <script>
  776. function my_validation(value,label)
  777. {
  778. if (value >=0)
  779. return [true,""];
  780. else
  781. return [false,label+": Should be Number"];
  782. }
  783. function validate_form_once(post,form)
  784. {
  785. var str=[];
  786.  
  787. if (post.quotationno == "")
  788. str[str.length] = "- quotationno are required";
  789.  
  790. if (parseInt(post.total) == 0)
  791. str[str.length] = "- Total should be non-zero";
  792.  
  793. str = str.join("<br>");
  794.  
  795. if (str.length == 0)
  796. return [true,""];
  797. else
  798. return [false,"Check following errors:<br>"+str];
  799. }
  800. </script>
  801.  
  802. <div style="margin:10px">
  803. <?php echo $out ?>
  804. </div>
  805.  
  806. <script>
  807.  
  808. function update_total()
  809. {
  810. jQuery('input[name="totalamount"]:visible').val(
  811. parseFloat(jQuery('input[name="qty"]:visible').val()) *
  812. parseFloat(jQuery('input[name="rate"]:visible').val())
  813. );
  814. }
  815. </script>
  816. <script>
  817. function update_discount()
  818. {
  819. jQuery('input[name="discamount"]:visible').val(
  820. parseFloat(jQuery('input[name="totalamount"]:visible').val()) *
  821. ( parseFloat(jQuery('input[name="disc"]:visible').val())/100
  822. )
  823. );
  824. }
  825. </script>
  826. <script>
  827. function update_tax()
  828. {
  829. jQuery('input[name="taxamount"]:visible').val(
  830. (parseFloat(jQuery('input[name="totalamount"]:visible').val())- parseFloat(jQuery('input[name="discamount"]:visible').val())) *
  831. (parseFloat(jQuery('input[name="tax"]:visible').val())/100)
  832. );
  833. jQuery('input[name="netamount"]:visible').val(
  834. ( parseFloat(jQuery('input[name="totalamount"]:visible').val())- parseFloat(jQuery('input[name="discamount"]:visible').val())) +
  835. (parseFloat(jQuery('input[name="taxamount"]:visible').val())
  836. )
  837. );
  838.  
  839. }
  840.  
  841.  
  842. </script>
  843. <script>
  844. function update_cost()
  845. {
  846. jQuery('input[name="totalcost"]:visible').val(
  847. (parseFloat(jQuery('input[name="netamount"]:visible').val())+ parseFloat(jQuery('input[name="transportation"]:visible').val())) +
  848. (parseFloat(jQuery('input[name="exciseduty"]:visible').val())+ parseFloat(jQuery('input[name="commissioningcharges"]:visible').val())+
  849. parseFloat(jQuery('input[name="labourchages"]:visible').val())+ parseFloat(jQuery('input[name="frieghtcharges"]:visible').val()))
  850. );
  851. }
  852.  
  853.  
  854. </script>
  855.  
  856. <script type="text/javascript">
  857. /*
  858. CUSTOM TOOLBAR BUTTON
  859. ---------------------
  860. caption: (string) the caption of the button, can be a empty string.
  861. buttonicon: (string) is the ui icon name from UI theme icon set. If this option is set to 'none' only the text appear.
  862. onClickButton: (function) action to be performed when a button is clicked. Default null.
  863. position: ('first' or 'last') the position where the button will be added (i.e., before or after the standard buttons).
  864. title: (string) a tooltip for the button.
  865. cursor : string (default pointer) determines the cursor when we mouseover the element
  866. id : string (optional) - if set defines the id of the button (actually the id of TD element) for future manipulation
  867. */
  868. jQuery(document).ready(function(){
  869.  
  870. jQuery('#list1').jqGrid('navButtonAdd', '#list1_pager',
  871. {
  872. 'caption' : 'Export Selected',
  873. 'buttonicon' : 'ui-icon-extlink',
  874. 'onClickButton': function()
  875. {
  876. // for all ids
  877. var allRowsOnCurrentPage = $('#list1').jqGrid('getDataIDs');
  878.  
  879. // for selected rows
  880. var selectedRows = jQuery('#list1').jqGrid('getGridParam','selarrrow');
  881. window.open("export.php?id="+selectedRows)
  882. },
  883. 'position': 'last'
  884. });
  885. });
  886. </script>
  887.  
  888. <script>
  889. function fill_form(data)
  890. {
  891. jQuery("input[name=quotationdate].FormElement").val(data[0].quotationdate);
  892. jQuery("input[name=referenceno].FormElement").val(data[0].referenceno);
  893. jQuery("select[name=datatype].FormElement").val(data[0].datatype);
  894. jQuery("select[name=billerid].FormElement").val(data[0].billerid);
  895. jQuery("select[name=companyid].FormElement").val(data[0].companyid);
  896. jQuery("select[name=itemmastercode].FormElement").val(data[0].itemmastercode);
  897. jQuery("select[name=itemtypeid].FormElement").val(data[0].itemtypeid);
  898. jQuery("select[name=itemid].FormElement").val(data[0].itemid);
  899. jQuery("select[name=uomid].FormElement").val(data[0].uomid);
  900. jQuery("input[name=qty].FormElement").val(data[0].qty);
  901. jQuery("input[name=rate].FormElement").val(data[0].rate);
  902. jQuery("input[name=totalamount].FormElement").val(data[0].totalamount);
  903. jQuery("input[name=disc].FormElement").val(data[0].disc);
  904. jQuery("input[name=discamount].FormElement").val(data[0].discamount);
  905. jQuery("input[name=tax].FormElement").val(data[0].tax);
  906. jQuery("input[name=taxamount].FormElement").val(data[0].taxamount);
  907. jQuery("input[name=netamount].FormElement").val(data[0].netamount);
  908. jQuery("input[name=transportation].FormElement").val(data[0].transportation);
  909. jQuery("input[name=exciseduty].FormElement").val(data[0].exciseduty);
  910. jQuery("input[name=commissioningcharges].FormElement").val(data[0].commissioningcharges);
  911.  
  912. jQuery("input[name=labourchages].FormElement").val(data[0].labourchages);
  913. jQuery("input[name=status].FormElement").val(data[0].status);
  914. jQuery("input[name=deliveryshedule].FormElement").val(data[0].deliveryshedule);
  915. jQuery("input[name=pf].FormElement").val(data[0].pf);
  916. jQuery("input[name=for].FormElement").val(data[0].for);
  917. jQuery("input[name=totalcost].FormElement").val(data[0].totalcost);
  918. jQuery("input[name=chargesnotes].FormElement").val(data[0].chargesnotes);
  919. jQuery("input[name=specialinstruction].FormElement").val(data[0].specialinstruction);
  920. jQuery("input[name=notes].FormElement").val(data[0].notes);
  921. jQuery("input[name=paymentstatus].FormElement").val(data[0].paymentstatus);
  922. jQuery("input[name=paymentterms].FormElement").val(data[0].paymentterms);
  923. jQuery("input[name=deliveryterms].FormElement").val(data[0].deliveryterms);
  924. jQuery("input[name=validity].FormElement").val(data[0].validity);
  925.  
  926.  
  927.  
  928.  
  929. jQuery("input[name=quotationdate].editable").val(data[0].quotationdate);
  930. jQuery("input[name=referenceno].editable").val(data[0].referenceno);
  931. jQuery("input[name=datatype].editable").val(data[0].datatype);
  932. jQuery("input[name=billerid].editable").val(data[0].billerid);
  933. jQuery("input[name=companyid].editable").val(data[0].companyid);
  934. jQuery("input[name=itemmastercode].editable").val(data[0].itemmastercode);
  935. jQuery("input[name=itemtypeid].editable").val(data[0].itemtypeid);
  936. jQuery("input[name=itemid].editable").val(data[0].itemid);
  937. jQuery("input[name=uomid].editable").val(data[0].uomid);
  938. jQuery("input[name=qty].editable").val(data[0].qty);
  939. jQuery("input[name=rate].editable").val(data[0].rate);
  940. jQuery("input[name=totalamount].editable").val(data[0].totalamount);
  941. jQuery("input[name=disc].editable").val(data[0].disc);
  942. jQuery("input[name=discamount].editable").val(data[0].discamount);
  943. jQuery("input[name=tax].editable").val(data[0].tax);
  944. jQuery("input[name=taxamount].editable").val(data[0].taxamount);
  945. jQuery("input[name=netamount].editable").val(data[0].netamount);
  946. jQuery("input[name=transportation].editable").val(data[0].transportation);
  947. jQuery("input[name=exciseduty].editable").val(data[0].exciseduty);
  948. jQuery("input[name=commissioningcharges].editable").val(data[0].commissioningcharges);
  949.  
  950. jQuery("input[name=labourchages].editable").val(data[0].labourchages);
  951. jQuery("input[name=status].editable").val(data[0].status);
  952. jQuery("input[name=deliveryshedule].editable").val(data[0].deliveryshedule);
  953. jQuery("input[name=pf].editable").val(data[0].pf);
  954. jQuery("input[name=for].editable").val(data[0].for);
  955. jQuery("input[name=totalcost].editable").val(data[0].totalcost);
  956. jQuery("input[name=chargesnotes].editable").val(data[0].chargesnotes);
  957. jQuery("input[name=specialinstruction].editable").val(data[0].specialinstruction);
  958. jQuery("input[name=notes].editable").val(data[0].notes);
  959. jQuery("input[name=paymentstatus].editable").val(data[0].paymentstatus);
  960. jQuery("input[name=paymentterms].editable").val(data[0].paymentterms);
  961. jQuery("input[name=deliveryterms].editable").val(data[0].deliveryterms);
  962. jQuery("input[name=validity].editable").val(data[0].validity);
  963.  
  964. }
  965. </script>
  966.  
  967. </body>
  968. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement