{
  "pluginname": "Stock",
  "version": "1",
  "table_def": [
    {
      "name": "stock",
      "fields": [
        {
          "name": "stockname",
          "type": "varchar(30)",
          "other": "NOT NULL"
        },
        {
          "name": "category",
          "type": "varchar(30)",
          "other": "NOT NULL"
        },
        {
          "name": "drug",
          "type": "varchar(300)",
          "other": "NOT NULL"
        },
        {
          "name": "packing",
          "type": "varchar(20)",
          "other": "NOT NULL"
        },
        {
          "name": "type",
          "type": "varchar(20)",
          "other": "NOT NULL"
        },
        {
          "name": "companyid",
          "type": "uniqueidentifier",
          "other": "NOT NULL"
        },
        {
          "name": "status",
          "type": "tinyint",
          "other": "NOT NULL DEFAULT 1"
        }
      ]
    }
  ],
  "sqlcommands_oninstall": [],
  "form": {
    "name": "stock",
    "formtype": "Default",
    "title": "Stock",
    "icon": "mif-apps",
    "saveButton": "true",
    "cancelButton": "true",
    "flex_row": "true",
    "flex_justify": "start",
    "width": "80%",
    "field": [
      {
        "name": "stockname",
        "label": "Stock Name",
        "fieldtype": "s",
        "type": "text",
        "option": "",
		"maxlength":"30"
      },
      {
        "name": "category",
        "label": "Category",
        "fieldtype": "s",
        "type": "text",
        "option": "",
		"maxlength":"30"
      },
      {
        "name": "drug",
        "label": "Drug",
        "fieldtype": "s",
        "type": "text",
        "option": "",
		"maxlength":"300"
      },
      {
        "name": "packing",
        "label": "Packing",
        "fieldtype": "s",
        "type": "select3",
        "option": "SELECT DISTINCT packing FROM stock ORDER BY packing",
		"maxlength":"20"
      },
      {
        "name": "type",
        "label": "Type",
        "fieldtype": "s",
        "type": "select3",
        "option": "SELECT DISTINCT type FROM stock ORDER BY type",
		"maxlength":"20"
      },
      {
        "name": "companyid",
        "label": "Company",
        "fieldtype": "u",
        "type": "select",
        "option": "SELECT id,company FROM company WHERE status=1 and recordstatus=1"
      }
    ]
  },
  "form_html": "",
  "navbutton": [
    {
      "customid": "1",
      "caption": "Stock",
      "icon": "mif-stack",
      "btntype": "ribbon-button",
      "btngroup": "Stock",
      "btntab": "Stock",
      "btnorder": "2",
      "onclick": "initializePlugin()"
    }
  ],
  "script": "",
  "formbuttons": [
    {
      "name": "addStock",
      "caption": "",
      "icon": "mif-plus fg-red",
      "onclick": "showNewForm('stock')"
    },
    {
      "name": "activeStock",
      "caption": "Active Stock",
      "icon": "mif-stack fg-green",
      "onclick": "getTableFromSqlStatement('1')"
    },
    {
      "name": "inactiveStock",
      "caption": "Inactive Stock",
      "icon": "mif-stack fg-orange",
      "onclick": "getTableFromSqlStatement('2')"
    },
    {
      "name": "deletedStock",
      "caption": "Deleted Stock",
      "icon": "mif-stack fg-red",
      "onclick": "getTableFromSqlStatement('3')"
    },
    {
      "name": "stockSummary",
      "caption": "Summary",
      "icon": "mif-stack fg-violet",
      "onclick": "getTableFromSqlStatement('4')"
    }
  ],
  "sqlstatement": [
    {
      "customid": "1",
      "name": "activeStock",
      "sql": {"action":"Get Table","fld":"a.stockname,a.category,a.drug,a.packing,a.type,b.company","tbl":"stock a","join":"INNER JOIN company b ON a.companyid=b.id","whr":"a.status=1 and a.recordstatus>=1"},
      "header": "Stock Name,Category,Drug,Packing,Type,Company",
      "edit_record": "1",
      "change_status": "0:Suspend:Stock Record is Suspended:Stock Record Suspension Failed",
      "filter": "1",
      "filter_fields": "category",
      "filter_fields_operator": "=",
      "filter_fields_caption": "Category",
      "filter_fields_type": "s",
      "filter_fields_inputtype": "select",
      "filter_fields_option": [
        {
          "fieldname": "category",
          "option": "SELECT DISTINCT category FROM stock WHERE status=1 and recordstatus=1 ORDER BY category"
        }
      ]
    },
    {
      "customid": "2",
      "name": "inactiveStock",
      "sql": {"action":"Get Table","fld":"a.stockname,a.category,a.drug,a.packing,a.type,b.company","tbl":"stock a","join":"INNER JOIN company b ON a.companyid=b.id","whr":"a.status=0 and a.recordstatus>=1"},
      "header": "Name,Category,Drug,Packing,Type,Company",
      "change_status": "1:Activate:Stock Record is Activated:Stock Record Activation Failed",
      "delete_record": "1",
      "filter": "",
      "filter_fields": "",
      "filter_fields_operator": "",
      "filter_fields_caption": "",
      "filter_fields_type": "",
      "filter_fields_inputtype": "",
      "filter_fields_option": ""
    },
    {
      "customid": "3",
      "name": "deletedStock",
      "sql": {"action":"Get Table","fld":"a.stockname,a.category,a.drug,a.packing,a.type,b.company","tbl":"stock a","join":"INNER JOIN company b ON a.companyid=b.id","whr":"a.recordstatus=0"},
      "header": "Name,Category,Drug,Packing,Type,Company",
      "restore_record": "1",
      "filter": "",
      "filter_fields": "",
      "filter_fields_operator": "",
      "filter_fields_caption": "",
      "filter_fields_type": "",
      "filter_fields_inputtype": "",
      "filter_fields_option": ""
    },
    {
      "customid": "4",
      "name": "stockSummary",
      "sql": {"action":"Get Table","fld":"category,count(id)","tbl":"stock","whr":"status=1 and recordstatus=1","grp":"category","srt":"category"},
      "header": "Category,Count",
      "set_appendix": "5:0",
      "filter": "",
      "filter_fields": "",
      "filter_fields_operator": "",
      "filter_fields_caption": "",
      "filter_fields_type": "",
      "filter_fields_inputtype": "",
      "filter_fields_option": ""
    },
    {
      "customid": "5",
      "name": "stockSummaryAppendix",
      "sql": {"action":"Get Table","fld":"a.stockname,a.category,a.drug,a.packing,a.type,b.company","tbl":"stock a","join":"INNER JOIN company b ON a.companyid=b.id","whr":"a.category='||0||' and a.status=1 and a.recordstatus>=1"},
      "header": "Stock Name,Category,Drug,Packing,Type,Company",
      "filter": "true",
      "filter_fields": "stockname",
      "filter_fields_operator": "like",
      "filter_fields_caption": "Stock Name",
      "filter_fields_type": "s",
      "filter_fields_inputtype": "text",
      "filter_fields_option": ""
    }
  ]
}