Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * PHP Grid Component
- *
- * @author Abu Ghufran <gridphp@gmail.com> - http://www.phpgrid.org
- * @version 1.5.2
- * @license: see license.txt included in package
- */
- // include db config
- include_once("/phpgrid/config.php");
- include('session.php');
- // Establishing Connection with Server by passing server_name, user_id and password as a parameter
- //$connection = mysql_connect("localhost", "root", "");
- // Selecting Database
- //$db = mysql_select_db("invopo", $connection);
- // SQL Query To Fetch Complete Information Of User
- mysql_connect(PHPGRID_DBHOST, PHPGRID_DBUSER, PHPGRID_DBPASS);
- mysql_select_db(PHPGRID_DBNAME);
- //print($user_check);
- // include and create object
- include(PHPGRID_LIBPATH."inc/jqgrid_dist.php");
- //$ses_sql=mysql_query("select userid,roleid from invopo_user where username='$user_check'");
- //$row = mysql_fetch_assoc($ses_sql);
- //$user_id =$login_id;
- //$role_id = $row['roleid'];
- $sqlquery = mysql_query("select C,R,U,D from invopo_role_page_mast where roleid='$role_id' and pagename='invopo_user'");
- $rowq = mysql_fetch_assoc($sqlquery);
- $cr = $rowq['C'];
- $re = $rowq['R'];
- $up = $rowq['U'];
- $de = $rowq['D'];
- $uid =$login_id ;
- $g = new jqgrid();
- $today = date('Y-m-d H:i:s',time());
- $col = array();
- $col["title"] = "Id"; // caption of column
- $col["name"] = "orderid";
- $col["width"] = "20";
- $col["editable"] = false;
- $cols[] = $col;
- $col = array();
- $col["title"] = "Orderno";
- $col["name"] = "orderno";
- $col["width"] = "50";
- $col["editable"] = true;
- $col["editrules"] = array("required"=>true);// this column is editable
- $col["formoptions"] = array("rowpos"=>"1", "colpos"=>"1");
- $cols[] = $col;
- $col = array();
- $col["title"] = "OrderDate";
- $col["name"] = "orderdate";
- $col["width"] = "60";
- $col["editable"] = true; // this column is editable
- $col["editoptions"] = array("size"=>20); // with default display of textbox with size 20
- $col["editrules"] = array("required"=>true); // required:true(false), number:true(false), minValue:val, maxValue:val
- $col["formatter"] = "date"; // format as date
- // format as date
- $col["formatoptions"] = array("srcformat"=>'Y-m-d',"newformat"=>'d/m/Y');
- $col["formoptions"] = array("rowpos"=>"1", "colpos"=>"2");
- $cols[] = $col;
- $col = array();
- $col["title"] = "quotationno";
- $col["name"] = "quotationno";
- $col["dbname"] = "invopo_order_info.quotationno";
- $col["editable"] = true;
- $col["width"] = "80";
- $col["edittype"] = "select"; // render as select
- # fetch data from database, with alias k for key, v for value
- $str = $g->get_dropdown_values("select quotationid as k, quotationno as v from invopo_quotationmaster where status='quoted'");
- $col["editoptions"] = array(
- "value"=>$str,
- "onchange" => array(
- "sql"=>"select * from invopo_quotationmaster",
- "search_on"=>"quotationid",
- "callback" => "fill_form" )
- );
- $col["stype"] = "select"; // enable dropdown search
- $col["searchoptions"] = array("value" => ":;".$str);
- $col["formoptions"] = array("rowpos"=>"2", "colpos"=>"1");
- $cols[] = $col;
- $col = array();
- $col["title"] = "Ref.No";
- $col["name"] = "referenceno";
- $col["width"] = "50";
- $col["editable"] = true;
- $col["editrules"] = array("required"=>true);// this column is editable
- $col["formoptions"] = array("rowpos"=>"2", "colpos"=>"2");
- $cols[] = $col;
- $col = array();
- $col["title"] = "Date";
- $col["name"] = "quotationdate";
- $col["width"] = "60";
- $col["editable"] = true; // this column is editable
- $col["editoptions"] = array("size"=>20); // with default display of textbox with size 20
- $col["editrules"] = array("required"=>true); // required:true(false), number:true(false), minValue:val, maxValue:val
- $col["formatter"] = "date"; // format as date
- // format as date
- //$col["formatoptions"] = array("srcformat"=>'Y-m-d',"newformat"=>'d/m/Y');
- $col["formoptions"] = array("rowpos"=>"2", "colpos"=>"3");
- $cols[] = $col;
- $col = array();
- $col["title"] = "Datatype"; // caption of column
- $col["name"] = "datatype"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["hidden"] = false;
- $col["width"] = "50";
- $col["edittype"] = "select";
- $col["editoptions"] = array("value" => "Quote:quote;invoice:Invoice;proformainvoice:proformainvoice");
- //$col["editrules"] = array("required"=>true, "readonly"=>true, "readonly-when"=>array("==","Received"));
- $col["show"] = array("list"=>true, "add"=>true, "edit"=>true, "view"=>true);
- $col["formoptions"] = array("rowpos"=>"3", "colpos"=>"1");
- $cols[] = $col;
- $col = array();
- $col["title"] = "Vendor";
- $col["name"] = "billerid";
- $col["dbname"] = "invopo_order_info.billerid"; // this is required as we need to search in name field, not id
- $col["width"] = "70";
- $col["align"] = "left";
- $col["editrules"] = array("required"=>true);
- # fetch data from database, with alias k for key, v for value
- $col["search"] = true;
- $col["editable"] = true;
- $col["edittype"] = "select"; // render as select
- # fetch data from database, with alias k for key, v for value
- //$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}' ");
- $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}'
- //$col["editoptions"] = array("value"=>$str);
- $col["formatter"] = "select"; // display label, not value
- $col["formoptions"] = array("rowpos"=>"3", "colpos"=>"2");
- $cols[] = $col;
- $col = array();
- $col["title"] = "Company";
- $col["name"] = "companyid";
- $col["dbname"] = "invopo_order_info.companyid"; // this is required as we need to search in name field, not id
- $col["width"] = "50";
- $col["align"] = "left";
- $col["search"] = true;
- $col["editable"] = true;
- $col["edittype"] = "select"; // render as select
- # fetch data from database, with alias k for key, v for value
- //$str = $g->get_dropdown_values("select distinct compid as k, compname as v from invopo_company");
- $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";
- //$col["editoptions"] = array("value"=>$str);
- $col["formatter"] = "select"; // display label, not value
- $col["formoptions"] = array("rowpos"=>"3", "colpos"=>"3");
- $col["editrules"] = array("edithidden"=>true);
- $col["hidden"] = true;
- $cols[] = $col;
- $col = array();
- $col["title"] = "Level1";
- $col["name"] = "itemmastercode";
- $col["dbname"] = "invopo_order_info.itemmastercode"; // this is required as we need to search in name field, not id
- $col["width"] = "50";
- $col["align"] = "left";
- $col["search"] = true;
- $col["editable"] = true;
- $col["edittype"] = "select";
- $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";
- //$col["edittype"] = "select"; // render as select
- # fetch data from database, with alias k for key, v for value
- # on change, update other dropdown
- //$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}");
- //$col["editoptions"] = array(
- // "value"=>$str,
- // "onchange" => array("sql"=>"select distinct itemtypeid as k, itemtypename as v from invopo_itemtype_mast WHERE itemmastercode = '{itemmastercode}'",
- // "update_field" =>"itemtypeid" )
- // );
- $col["formatter"] = "select"; // display label, not value
- $col["stype"] = "select"; // enable dropdown search
- $col["searchoptions"] = array("value" => ":;".$str);
- $col["formoptions"] = array("rowpos"=>"4", "colpos"=>"1");
- $cols[] = $col;
- $col = array();
- $col["title"] = "Level2";
- $col["name"] = "itemtypeid";
- $col["dbname"] = "itemtypeid"; // this is required as we need to search in name field, not id
- $col["width"] = "50";
- $col["align"] = "left";
- $col["search"] = true;
- $col["editable"] = true;
- $col["edittype"] = "select"; // render as select
- # fetch data from database, with alias k for key, v for value
- # on change, update other dropdown
- $str = $g->get_dropdown_values("select itemtypeid as k, itemtypename as v from invopo_itemtype_mast");
- $col["editoptions"] = array(
- "value"=>$str,
- "onchange" => array("sql"=>"select distinct itemid as k, itemname as v from invopo_item_mast WHERE itemtypeid = '{itemtypeid}'",
- "update_field" => "itemid" )
- );
- $col["formatter"] = "select"; // display label, not value
- $col["stype"] = "select"; // enable dropdown search
- $col["searchoptions"] = array("value" => ":;".$str);
- $col["formoptions"] = array("rowpos"=>"4", "colpos"=>"2");
- $cols[] = $col;
- $col = array();
- $col["title"] = "Level3";
- $col["name"] = "itemid";
- $col["dbname"] = "itemid";
- $col["width"] = "50";
- $col["search"] = true;
- $col["editable"] = true;
- $col["edittype"] = "select";
- $str = $g->get_dropdown_values("select itemid as k, itemname as v from invopo_item_mast");
- $col["editoptions"] = array(
- "value"=>$str,
- );
- $col["formatter"] = "select"; // display label, not value
- $col["stype"] = "select"; // enable dropdown search
- $col["searchoptions"] = array("value" => ":;".$str);
- $col["formoptions"] = array("rowpos"=>"4", "colpos"=>"3");
- $cols[] = $col;
- $col = array();
- $col["title"] = "Unit of Measurement";
- $col["name"] = "uomid";
- $col["dbname"] = "uomid";
- $col["width"] = "50";
- $col["search"] = true;
- $col["editable"] = true;
- $col["editrules"] = array("required"=>true);
- $col["edittype"] = "select";
- // render as select
- # fetch data from database, with alias k for key, v for value
- $str = $g->get_dropdown_values("select distinct uomid as k, uomtype as v from invopo_uom ");
- $col["editoptions"] = array("value"=>$str);
- $col["formatter"] = "select"; // display label, not value
- $col["formoptions"] = array("rowpos"=>"5", "colpos"=>"1");
- $col["editrules"] = array("edithidden"=>true);
- $col["hidden"] = true;
- $cols[] = $col;
- $col = array();
- $col["title"] = "Quantity"; // caption of column
- $col["name"] = "qty"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- //$col["editrules"] = array("required"=>true);
- $col["editoptions"] = array("onblur" => "update_total()");
- $col["formoptions"] = array("rowpos"=>"5", "colpos"=>"2");
- $col["width"] = "50";
- $col["hidden"] = false;
- $cols[] = $col;
- $col = array();
- $col["title"] = "Rate"; // caption of column
- $col["name"] = "rate"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["width"] = "50";
- //$col["editrules"] = array("required"=>true);
- $col["editoptions"] = array("onblur" => "update_total()");
- $col["formoptions"] = array("rowpos"=>"5", "colpos"=>"3");
- $col["hidden"] = false;
- $cols[] = $col;
- $col = array();
- $col["title"] = "Total Amount";
- $col["name"] = "totalamount";
- $col["id"] = "totalamount";
- $col["width"] = "50";
- $col["editable"] = true;
- //$col["editrules"] = array("edithidden"=>true);
- //array("onblur" => "jQuery('#totalamount').val( parseInt(jQuery('#qty').val()) * parseInt(jQuery('#rate').val()))");
- //$col["editrules"] = array("custom"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
- $col["editrules"] = array("edithidden"=>true);
- $col["formoptions"] = array("rowpos"=>"6", "colpos"=>"1");
- $col["formatter"] = "number";
- $col["formatoptions"] = array("thousandsSeparator" => ",",
- "decimalSeparator" => ".",
- "decimalPlaces" => 2);
- $col["hidden"] = true;
- $cols[] = $col;
- $col["title"] = "Discount"; // caption of column
- $col["name"] = "disc"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- //$col["editrules"] = array("edithidden"=>true);//,"custom_func"=>"function(val,label){return my_validation(val,label);}");
- $col["width"] = "50";
- $col["editoptions"] = array("onblur" => "update_discount()"); ;
- $col["formoptions"] = array("rowpos"=>"6", "colpos"=>"2");
- $col["hidden"] = true;
- $cols[] = $col;
- $col = array();
- $col["title"] = "DiscountAmount"; // caption of column
- $col["name"] = "discamount"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["editrules"] = array("edithidden"=>true);//,"custom"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
- $col["hidden"] = false;
- $col["width"] = "50";
- $col["formoptions"] = array("rowpos"=>"6", "colpos"=>"3");
- $col["formatter"] = "currency";
- $col["formatoptions"] = array("thousandsSeparator" => ",",
- "decimalSeparator" => ".",
- "decimalPlaces" => 2);
- $cols[] = $col;
- //qty, rate, tax, disc, totalamount, taxamount, discamount, netamount, transportation, exciseduty, paymentterms, deliveryterms, validity, deliveryshedule, pf, for, specialinstruction, notes, commissioningcharges, labourchages, frieghtcharges, paymentstatus, datatype
- $col = array();
- $col["title"] = "Tax"; // caption of column
- $col["name"] = "tax"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["width"] = "50";
- //$col["editrules"] = array("required"=>true);
- $col["editoptions"] = array("onblur" => "update_tax()");
- $col["formoptions"] = array("rowpos"=>"7", "colpos"=>"1");
- $col["hidden"] = false;
- $cols[] = $col;
- $col = array();
- $col["title"] = "Tax Amount"; // caption of column
- $col["name"] = "taxamount"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- //$col["editrules"] = array("custom"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
- $col["hidden"] = false;
- $col["width"] = "50";
- $col["formatter"] = "currency";
- $col["formatoptions"] = array("thousandsSeparator" => ",",
- "decimalSeparator" => ".",
- "decimalPlaces" => 2);
- $col["formoptions"] = array("rowpos"=>"7", "colpos"=>"2");
- $cols[] = $col;
- $col = array();
- $col["title"] = "NetAmount"; // caption of column
- $col["name"] = "netamount"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["width"] = "50";
- //$col["editrules"] = array("custom"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
- $col["editoptions"] = array("onblur" => "update_cost()");
- $col["formatter"] = "currency";
- $col["formatoptions"] = array("thousandsSeparator" => ",",
- "decimalSeparator" => ".",
- "decimalPlaces" => 2);
- $col["formoptions"] = array("rowpos"=>"7", "colpos"=>"3");
- $col["hidden"] = true;
- //$col["editoptions"] = array("onblur" => "update_cost()");
- $cols[] = $col;
- $col = array();
- $col["title"] = "Transportation"; // caption of column
- $col["name"] = "transportation";
- $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)
- $col["editable"] = true;
- $col["hidden"] = true;
- $col["width"] = "50";
- $col["editoptions"] = array("onblur" => "update_cost()");
- $col["formoptions"] = array("rowpos"=>"8", "colpos"=>"1");
- $cols[] = $col;
- //exciseduty, paymentterms, deliveryterms, validity, deliveryshedule, pf, for, specialinstruction, notes, commissioningcharges, labourchages, frieghtcharges, paymentstatus, datatype
- $col = array();
- $col["title"] = "Exciseduty"; // caption of column
- $col["name"] = "exciseduty"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
- $col["hidden"] = true;
- $col["width"] = "50";
- $col["editoptions"] = array("onblur" => "update_cost()");
- $col["formoptions"] = array("rowpos"=>"8", "colpos"=>"2");
- $cols[] = $col;
- $col = array();
- $col["title"] = "Commission Charges"; // caption of column
- $col["name"] = "commissioningcharges"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
- $col["hidden"] = true;
- $col["width"] = "50";
- $col["editoptions"] = array("onblur" => "update_cost()");
- $col["formoptions"] = array("rowpos"=>"8", "colpos"=>"3");
- $cols[] = $col;
- $col = array();
- $col["title"] = "LabourChages"; // caption of column
- $col["name"] = "labourchages"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}","edithidden"=>true);
- $col["hidden"] = true;
- $col["width"] = "50";
- $col["editoptions"] = array("onblur" => "update_cost()");
- $col["formoptions"] = array("rowpos"=>"9", "colpos"=>"1");
- $cols[] = $col;
- /*$col = array();
- $col["title"] = "FrieghtCharges"; // caption of column
- $col["name"] = "frieghtcharges"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
- $col["hidden"] = true;
- $col["width"] = "50";
- $col["editoptions"] = array("onblur" => "update_cost()");
- //$col["editoptions"] = array("onblur" => "update_cost()");
- $col["formoptions"] = array("rowpos"=>"8", "colpos"=>"2");
- $cols[] = $col; */
- $col = array();
- $col["title"] = "Others"; // caption of column
- $col["name"] = "othercharges"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}","edithidden"=>true);
- $col["hidden"] = true;
- $col["width"] = "50";
- $col["formatter"] = "currency";
- $col["editoptions"] = array("onblur" => "update_cost()");
- $col["formoptions"] = array("rowpos"=>"9", "colpos"=>"2");
- $cols[] = $col;
- $col = array();
- $col["title"] ="TotalCost"; // caption of column
- $col["name"]="totalcost"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
- $col["width"] = "50";
- $col["formatter"] = "currency";
- $col["formatoptions"] = array("thousandsSeparator" => ",",
- "decimalSeparator" => ".",
- "decimalPlaces" => 2);
- $col["formoptions"] = array("rowpos"=>"9", "colpos"=>"3");
- //$col["editoptions"] = array("onblur" => "update_tax()");
- $cols[] = $col;
- $col = array();
- $col["title"] = "F.O.R(location)"; // caption of column
- $col["name"] = "for"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
- $col["hidden"] = true;
- $col["width"] = "50";
- $col["formoptions"] = array("rowpos"=>"10", "colpos"=>"1");
- $cols[] = $col;
- $col = array();
- $col = array();
- $col["title"] = "PaymentTerms"; // caption of column
- $col["name"] = "paymentterms"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["hidden"] = true;
- $col["width"] = "50";
- $col["formoptions"] = array("rowpos"=>"10", "colpos"=>"2");
- $cols[] = $col;
- $col = array();
- $col["title"] = "DeliveryTerms"; // caption of column
- $col["name"] = "deliveryterms"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["editrules"] = array("edithidden"=>true);
- $col["hidden"] = true;
- $col["width"] = "50";
- $col["formoptions"] = array("rowpos"=>"10", "colpos"=>"3");
- $cols[] = $col;
- $col = array();
- $col["title"] = "Validity"; // caption of column
- $col["name"] = "validity"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["hidden"] = false;
- $col["width"] = "50";
- $col["formoptions"] = array("rowpos"=>"11", "colpos"=>"1");
- $col["hidden"] = true;
- $cols[] = $col;
- //deliveryshedule, pf, for, specialinstruction, notes, commissioningcharges, labourchages, frieghtcharges, paymentstatus, datatype
- $col = array();
- $col["title"] = "DeliveryShedule"; // caption of column
- $col["name"] = "deliveryshedule"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["editrules"] = array("edithidden"=>true);
- $col["hidden"] = true;
- $col["width"] = "50";
- $col["formoptions"] = array("rowpos"=>"11", "colpos"=>"2");
- $cols[] = $col;
- $col = array();
- $col["title"] = "Packing/Forwarding"; // caption of column
- $col["name"] = "pf"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["editoptions"] = array("rows"=>2);
- $col["editrules"] = array("edithidden"=>true);
- $col["hidden"] = true;
- $col["formoptions"] = array("rowpos"=>"11", "colpos"=>"3");
- $cols[] = $col;
- $col["title"] = "Charges Notes"; // caption of column
- $col["name"] = "chargesnotes"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["edittype"] = "textarea";
- $col["editoptions"] = array("rows"=>1, "cols"=>30);
- //$col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
- $col["editrules"] = array("edithidden"=>true);
- $col["hidden"] = true;
- $col["width"] = "50";
- $col["formoptions"] = array("rowpos"=>"12", "colpos"=>"1");
- $cols[] = $col;
- $col = array();
- $col["title"] = "Specialinstruction"; // caption of column
- $col["name"] = "specialinstruction"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["edittype"] = "textarea"; // render as textarea on edit
- $col["editoptions"] = array("rows"=>2, "cols"=>20);
- $col["width"] = "50";
- $col["formoptions"] = array("rowpos"=>"12", "colpos"=>"2");
- $col["editrules"] = array("edithidden"=>true);
- $col["hidden"] = true;
- $cols[] = $col;
- // notes, commissioningcharges, labourchages, frieghtcharges, paymentstatus, datatype
- $col = array();
- $col["title"] = "Notes"; // caption of column
- $col["name"] = "notes"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["edittype"] = "textarea";
- $col["editoptions"] = array("rows"=>2, "cols"=>20);
- $col["width"] = "50";
- $col["formoptions"] = array("rowpos"=>"12", "colpos"=>"3");
- $col["hidden"] = false;
- $cols[] = $col;
- $col = array();
- $col["title"] = "Payment Type"; // caption of column
- $col["name"] = "paymenttype"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["edittype"] = "select";
- $col["editoptions"] = array("rows"=>1, "cols"=>30);
- //$col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
- $col["editrules"] = array("edithidden"=>true);
- $col["editoptions"] = array("value" => "Neft:NEFT;cash:Cash;RTGS:RTGS");
- $col["hidden"] = true;
- $col["width"] = "50";
- $col["formoptions"] = array("rowpos"=>"13", "colpos"=>"1");
- $cols[] = $col;
- $col = array();
- $col["title"] = "PaymentStatus"; // caption of column
- $col["name"] = "paymentstatus"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["editrules"] = array("edithidden"=>true);
- $col["hidden"] = false;
- $col["width"] = "50";
- $col["formoptions"] = array("rowpos"=>"13", "colpos"=>"2");
- $cols[] = $col;
- $col = array();
- $col["title"] = "Status"; // caption of column
- $col["name"] = "status"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["editrules"] = array("required"=>true);
- $col["edittype"] = "select";
- $col["editoptions"] = array("value" => "quoted:Quoted;ordered:Ordered;received:Received");
- $col["editrules"] = array("required"=>true, "readonly"=>true, "readonly-when"=>array("==","Received"));
- $col["show"] = array("list"=>true, "add"=>true, "edit"=>true, "view"=>true);
- $col["formoptions"] = array("rowpos"=>"13", "colpos"=>"3");
- $col["width"] = "50";
- $cols[] = $col;
- $col = array();
- $col["title"] = "Delivery Completion"; // caption of column
- $col["name"] = "deliverycompletion"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["edittype"] = "textarea";
- $col["editoptions"] = array("rows"=>1, "cols"=>30);
- //$col["editrules"] = array("custom"=>true,"edithidden"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
- $col["editrules"] = array("edithidden"=>true);
- $col["hidden"] = true;
- $col["width"] = "50";
- $col["formoptions"] = array("rowpos"=>"14", "colpos"=>"1");
- $cols[] = $col;
- $col = array();
- $col["title"] = "insertedby"; // caption of column
- $col["name"] = "insertedby"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["editoptions"] = array("defaultValue" => "$uid");
- $col["hidden"] = true;
- $cols[] = $col;
- $col = array();
- $col["title"] = "insertedat"; // caption of column
- $col["name"] = "insertedat"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["editoptions"] = array("defaultValue" => "$today");
- $col["hidden"] = true;
- $cols[] = $col;
- $col = array();
- $col["title"] = "updatedby"; // caption of column
- $col["name"] = "updatedby"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = true;
- $col["hidden"] = true;
- $cols[] = $col;
- $col = array();
- $col["title"] = "updatedat"; // caption of column
- $col["name"] = "updatedat"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
- $col["editable"] = false;
- $col["hidden"] = true;
- //$col["editoptions"] = array("defaultValue" => '$today');
- $cols[] = $col;
- $grid["sortname"] = 'orderid'; // by default sort grid by this field
- $grid["sortorder"] = "asc"; // ASC or DESC
- $grid["caption"] = "Order Details"; // caption of grid
- $grid["width"] = "1800";
- $grid["form"]["position"] = "top";
- $grid["add_options"] = array('width'=>'820');
- // $grid["add_options"]["afterShowForm"] = 'function(formid) { jQuery("#totalamount").mask("000.00"); }';
- $grid["edit_options"] = array('width'=>'820');
- $grid["autowidth"] = true; // expand grid to screen width
- $grid["multiselect"] = true; // allow you to multi-select through checkboxes
- // allow you to multi-select through checkboxes
- //$col["formoptions"] = array("rowpos"=>"1", "colpos"=>"2");
- $grid["edit_options"]["beforeSubmit"] = "function(post,form){ return validate_form_once(post,form); }";
- //$grid["shrink_to_fit"] = true;
- $grid["export"] = array("format"=>"pdf", "filename"=>"my-file", "heading"=>"Invoice Details", "orientation"=>"landscape", "paper"=>"a4");
- // Setting RTL will export pdf as RTL also
- // $grid["direction"] = "rtl";
- // export filtered data or all data
- $grid["export"]["range"] = "filtered"; // or "all"
- $grid["export"]["paged"] = "1";
- $g->set_options($grid);
- // params are array(<function-name>,<class-object> or <null-if-global-func>)
- $e["on_render_pdf"] = array("set_pdf_format", null);
- $e["on_update"] = array("update_by", null, true);
- $g->set_events($e);
- function update_by($data)
- {
- //ob_start();
- //print_r($data);
- //$str = ob_get_clean();
- $str = "UPDATE invopo_quotationmaster SET status='ordered'
- WHERE quotationid = {$data["quotationid"]}";
- mysql_query($str);
- print_r($str);
- }
- function set_pdf_format($arr)
- {
- $pdf = $arr["pdf"];
- $data = $arr["data"];
- // $pdf->SetFont('helvetica', '', 11);
- // $pdf->SetCellWidths(array(30,102,'auto'));
- /*
- PDF format customization API available here
- -------------------------------------------
- http://www.tcpdf.org/examples.php
- http://www.tcpdf.org/doc/code/classTCPDF.html
- More Custom Addons API (see inc/tcpdf/class.TCPDF.EasyTable.php & jqgrid_dist.php)
- ----------------------------------------------------------------
- public function SetCellMinimumHeight($height)
- public function SetCellFixedHeight($height)
- public function SetHeaderCellFixedHeight($height)
- public function SetTableHeaderPerPage($var)
- public function SetTableHeaderFirstTablePerPageOnly($var)
- public function SetCellAlignment($ArrayCellAlignment)
- public function SetCellWidths($ArrayCellWidths)
- public function SetCellFillStyle($int)
- public function SetFillImageCell($fill)
- public function SetHCellSpace($var)
- public function SetVCellSpace($var)
- public function SetHeaderCellsFillColor($R,$G,$B)
- public function SetTableRowFillColors(Array $colorsArray)
- public function SetHeaderCellsFontColor($R,$G,$B)
- public function SetHeaderCellsFontStyle($var)
- public function SetCellFontColor($R,$G,$B)
- public function SetFooterExclusionZone($float)
- public function SetTableX($x)
- public function SetTableY($y)
- public function Header()
- public function Footer()
- */
- }
- $g->set_actions(array(
- "add"=>true, // allow/disallow add
- "edit"=>false, // allow/disallow edit
- "delete"=>false, // allow/disallow delete
- "rowactions"=>true, // show/hide row wise edit/del/save option
- "autofilter" => true,
- // show/hide autofilter for search
- "export"=>true,
- "search" => "advance"
- )
- );
- $g->select_command = "SELECT * FROM invopo.invopo_order_info" ;
- // // ";
- // this db table will be used for add,edit,delete
- $g->table = "invopo.invopo_order_info";
- $g->set_columns($cols);
- // return last inserted id for further working
- //$e["on_update"] = array("update_by", null, true);
- // generate grid output, with unique grid name as 'list1'
- $out = $g->render("list1");
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
- <html>
- <head>
- <link rel="stylesheet" type="text/css" media="screen" href="../phpgrid/lib/js/themes/redmond/jquery-ui.custom.css"></link>
- <link rel="stylesheet" type="text/css" media="screen" href="../phpgrid/lib/js/jqgrid/css/ui.jqgrid.css"></link>
- <script src="../phpgrid/lib/js/jquery.mask.min.js" type="text/javascript"></script>
- <script src="../phpgrid/lib/js/jquery.min.js" type="text/javascript"></script>
- <script src="../phpgrid/lib/js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
- <script src="../phpgrid/lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
- <script src="../phpgrid/lib/js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
- </head>
- <body>
- <script>
- function my_validation(value,label)
- {
- if (value >=0)
- return [true,""];
- else
- return [false,label+": Should be Number"];
- }
- function validate_form_once(post,form)
- {
- var str=[];
- if (post.quotationno == "")
- str[str.length] = "- quotationno are required";
- if (parseInt(post.total) == 0)
- str[str.length] = "- Total should be non-zero";
- str = str.join("<br>");
- if (str.length == 0)
- return [true,""];
- else
- return [false,"Check following errors:<br>"+str];
- }
- </script>
- <div style="margin:10px">
- <?php echo $out ?>
- </div>
- <script>
- function update_total()
- {
- jQuery('input[name="totalamount"]:visible').val(
- parseFloat(jQuery('input[name="qty"]:visible').val()) *
- parseFloat(jQuery('input[name="rate"]:visible').val())
- );
- }
- </script>
- <script>
- function update_discount()
- {
- jQuery('input[name="discamount"]:visible').val(
- parseFloat(jQuery('input[name="totalamount"]:visible').val()) *
- ( parseFloat(jQuery('input[name="disc"]:visible').val())/100
- )
- );
- }
- </script>
- <script>
- function update_tax()
- {
- jQuery('input[name="taxamount"]:visible').val(
- (parseFloat(jQuery('input[name="totalamount"]:visible').val())- parseFloat(jQuery('input[name="discamount"]:visible').val())) *
- (parseFloat(jQuery('input[name="tax"]:visible').val())/100)
- );
- jQuery('input[name="netamount"]:visible').val(
- ( parseFloat(jQuery('input[name="totalamount"]:visible').val())- parseFloat(jQuery('input[name="discamount"]:visible').val())) +
- (parseFloat(jQuery('input[name="taxamount"]:visible').val())
- )
- );
- }
- </script>
- <script>
- function update_cost()
- {
- jQuery('input[name="totalcost"]:visible').val(
- (parseFloat(jQuery('input[name="netamount"]:visible').val())+ parseFloat(jQuery('input[name="transportation"]:visible').val())) +
- (parseFloat(jQuery('input[name="exciseduty"]:visible').val())+ parseFloat(jQuery('input[name="commissioningcharges"]:visible').val())+
- parseFloat(jQuery('input[name="labourchages"]:visible').val())+ parseFloat(jQuery('input[name="frieghtcharges"]:visible').val()))
- );
- }
- </script>
- <script type="text/javascript">
- /*
- CUSTOM TOOLBAR BUTTON
- ---------------------
- caption: (string) the caption of the button, can be a empty string.
- buttonicon: (string) is the ui icon name from UI theme icon set. If this option is set to 'none' only the text appear.
- onClickButton: (function) action to be performed when a button is clicked. Default null.
- position: ('first' or 'last') the position where the button will be added (i.e., before or after the standard buttons).
- title: (string) a tooltip for the button.
- cursor : string (default pointer) determines the cursor when we mouseover the element
- id : string (optional) - if set defines the id of the button (actually the id of TD element) for future manipulation
- */
- jQuery(document).ready(function(){
- jQuery('#list1').jqGrid('navButtonAdd', '#list1_pager',
- {
- 'caption' : 'Export Selected',
- 'buttonicon' : 'ui-icon-extlink',
- 'onClickButton': function()
- {
- // for all ids
- var allRowsOnCurrentPage = $('#list1').jqGrid('getDataIDs');
- // for selected rows
- var selectedRows = jQuery('#list1').jqGrid('getGridParam','selarrrow');
- window.open("export.php?id="+selectedRows)
- },
- 'position': 'last'
- });
- });
- </script>
- <script>
- function fill_form(data)
- {
- jQuery("input[name=quotationdate].FormElement").val(data[0].quotationdate);
- jQuery("input[name=referenceno].FormElement").val(data[0].referenceno);
- jQuery("select[name=datatype].FormElement").val(data[0].datatype);
- jQuery("select[name=billerid].FormElement").val(data[0].billerid);
- jQuery("select[name=companyid].FormElement").val(data[0].companyid);
- jQuery("select[name=itemmastercode].FormElement").val(data[0].itemmastercode);
- jQuery("select[name=itemtypeid].FormElement").val(data[0].itemtypeid);
- jQuery("select[name=itemid].FormElement").val(data[0].itemid);
- jQuery("select[name=uomid].FormElement").val(data[0].uomid);
- jQuery("input[name=qty].FormElement").val(data[0].qty);
- jQuery("input[name=rate].FormElement").val(data[0].rate);
- jQuery("input[name=totalamount].FormElement").val(data[0].totalamount);
- jQuery("input[name=disc].FormElement").val(data[0].disc);
- jQuery("input[name=discamount].FormElement").val(data[0].discamount);
- jQuery("input[name=tax].FormElement").val(data[0].tax);
- jQuery("input[name=taxamount].FormElement").val(data[0].taxamount);
- jQuery("input[name=netamount].FormElement").val(data[0].netamount);
- jQuery("input[name=transportation].FormElement").val(data[0].transportation);
- jQuery("input[name=exciseduty].FormElement").val(data[0].exciseduty);
- jQuery("input[name=commissioningcharges].FormElement").val(data[0].commissioningcharges);
- jQuery("input[name=labourchages].FormElement").val(data[0].labourchages);
- jQuery("input[name=status].FormElement").val(data[0].status);
- jQuery("input[name=deliveryshedule].FormElement").val(data[0].deliveryshedule);
- jQuery("input[name=pf].FormElement").val(data[0].pf);
- jQuery("input[name=for].FormElement").val(data[0].for);
- jQuery("input[name=totalcost].FormElement").val(data[0].totalcost);
- jQuery("input[name=chargesnotes].FormElement").val(data[0].chargesnotes);
- jQuery("input[name=specialinstruction].FormElement").val(data[0].specialinstruction);
- jQuery("input[name=notes].FormElement").val(data[0].notes);
- jQuery("input[name=paymentstatus].FormElement").val(data[0].paymentstatus);
- jQuery("input[name=paymentterms].FormElement").val(data[0].paymentterms);
- jQuery("input[name=deliveryterms].FormElement").val(data[0].deliveryterms);
- jQuery("input[name=validity].FormElement").val(data[0].validity);
- jQuery("input[name=quotationdate].editable").val(data[0].quotationdate);
- jQuery("input[name=referenceno].editable").val(data[0].referenceno);
- jQuery("input[name=datatype].editable").val(data[0].datatype);
- jQuery("input[name=billerid].editable").val(data[0].billerid);
- jQuery("input[name=companyid].editable").val(data[0].companyid);
- jQuery("input[name=itemmastercode].editable").val(data[0].itemmastercode);
- jQuery("input[name=itemtypeid].editable").val(data[0].itemtypeid);
- jQuery("input[name=itemid].editable").val(data[0].itemid);
- jQuery("input[name=uomid].editable").val(data[0].uomid);
- jQuery("input[name=qty].editable").val(data[0].qty);
- jQuery("input[name=rate].editable").val(data[0].rate);
- jQuery("input[name=totalamount].editable").val(data[0].totalamount);
- jQuery("input[name=disc].editable").val(data[0].disc);
- jQuery("input[name=discamount].editable").val(data[0].discamount);
- jQuery("input[name=tax].editable").val(data[0].tax);
- jQuery("input[name=taxamount].editable").val(data[0].taxamount);
- jQuery("input[name=netamount].editable").val(data[0].netamount);
- jQuery("input[name=transportation].editable").val(data[0].transportation);
- jQuery("input[name=exciseduty].editable").val(data[0].exciseduty);
- jQuery("input[name=commissioningcharges].editable").val(data[0].commissioningcharges);
- jQuery("input[name=labourchages].editable").val(data[0].labourchages);
- jQuery("input[name=status].editable").val(data[0].status);
- jQuery("input[name=deliveryshedule].editable").val(data[0].deliveryshedule);
- jQuery("input[name=pf].editable").val(data[0].pf);
- jQuery("input[name=for].editable").val(data[0].for);
- jQuery("input[name=totalcost].editable").val(data[0].totalcost);
- jQuery("input[name=chargesnotes].editable").val(data[0].chargesnotes);
- jQuery("input[name=specialinstruction].editable").val(data[0].specialinstruction);
- jQuery("input[name=notes].editable").val(data[0].notes);
- jQuery("input[name=paymentstatus].editable").val(data[0].paymentstatus);
- jQuery("input[name=paymentterms].editable").val(data[0].paymentterms);
- jQuery("input[name=deliveryterms].editable").val(data[0].deliveryterms);
- jQuery("input[name=validity].editable").val(data[0].validity);
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement