{
  "pluginname": "Online Course Users",
  "systemplugin": "0",
  "version": "1.6",
  "table_def": [
    {
      "name": "online_course_users",
      "fields": [
        {
          "name": "emailid",
          "type": "varchar(200)",
          "other": "UNIQUE NOT NULL"
        },
        {
          "name": "fullname",
          "type": "varchar(100)",
          "other": "NOT NULL"
        },
        {
          "name": "linked_to_institution",
          "type": "varchar(10)",
          "other": ""
        },
        {
          "name": "linked_to_program",
          "type": "varchar(30)"
        },{
          "name": "educationmode",
          "type": "varchar(11)"
        },
		{
          "name": "district",
          "type": "varchar(30)"
        },
        {
          "name": "state",
          "type": "varchar(30)"
        },
        {
          "name": "phoneno",
          "type": "char(10)"
        },
        {
          "name": "alternate_phoneno",
          "type": "char(10)"
        },
        {
          "name": "whatsappno",
          "type": "char(15)"
        },
        {
          "name": "recommendedby",
          "type": "varchar(50)"
        },
		{
          "name": "pass",
          "type": "varchar(20)",
		  "other":"NOT NULL DEFAULT ''"
        },
        {
          "name": "status",
          "type": "tinyint",
          "other": "NOT NULL DEFAULT 1"
        },{
          "name": "gender",
          "type": "varchar(6)",
          "other": ""
        },{
          "name": "isauthor",
          "type": "tinyint",
          "other": "NOT NULL DEFAULT 0"
        }
      ]
    },
	{"name":"online_course_user_wallet","fields":[{"name":"rowno","type":"int","other":""},{"name":"userid","type":"uniqueidentifier","other":"NOT NULL"},{"name":"amount","type":"int","other":"NOT NULL DEFAULT 0"},{"name":"balance","type":"int","other":"NOT NULL DEFAULT 0"},{"name":"remark","type":"varchar(500)"}]}
  ],
  "sqlcommands_oninstall": [],
  "form": {
    "name": "Online Course Users",
    "formtype": "Default",
    "title": "Online Course Users",
    "icon": "mif-user",
    "saveButton":true,
    "savecustomid":11,
    "getrecordcustomid":12,
    "cancelButton": "true",
    "flex_row": "true",
    "flex_justify": "start",
    "field": [
      {
        "name": "emailid",
        "label": "Email",
        "fieldtype": "s",
        "type": "text",
        "required": "Yes",
        "allownull": "0",
		"maxlength":"200"
      },
      {
        "name": "fullname",
        "label": "Full Name",
        "fieldtype": "s",
        "type": "text",
        "required": "Yes",
        "allownull": "0",
		"maxlength":"100"
      },
      {
        "name": "gender",
        "label": "Gender",
        "fieldtype": "s",
        "type": "select",
		"option":"Male,Female",
        "required": "Yes",
        "allownull": "0"
      },
      {
        "name": "linked_to_institution",
        "label": "Linked to Institution",
        "fieldtype": "s",
        "type": "select",
        "option": ":Select,NIBS,NBBI,NIBI,Other",
        "allownull": "1",
		"required":"Yes"
      },
      {
        "name": "linked_to_program",
        "label": "Program of Study",
        "fieldtype": "s",
        "type": "select",
        "option": ":None,Bachelor of Theology,Master of Divinity,Master of Theology,Diploma in Theology,Certificate in Theology",
        "allownull": "1",
		"required":"Yes"
      },{
        "name": "educationmode",
        "label": "Education Mode",
        "fieldtype": "s",
        "type": "select",
        "option": "Online,Residential",
        "allownull": "0",
		"required":"Yes"
      },
	  {
        "name": "district",
        "label": "District",
        "fieldtype": "s",
        "type": "text",
        "required": "Yes",
        "allownull": "1",
		"maxlength":"30"
      },
      {
        "name": "state",
        "label": "District",
        "fieldtype": "s",
        "type": "select",
        "option": "Andhra Pradesh,Arunachal Pradesh,Assam,Bihar,Chhattisgarh,Goa,Gujarat,Haryana,Himachal Pradesh,Jharkhand,Karnataka,Kerala,Madhya Pradesh,Maharashtra,Manipur,Meghalaya,Mizoram,Nagaland,Odisha,Punjab,Rajasthan,Sikkim,Tamil Nadu,Telangana,Tripura,Uttar Pradesh,Uttarakhand,West Bengal,Other",
        "required": "Yes",
        "allownull": "1"
      },
      {
        "name": "phoneno",
        "label": "Phone No (10 digit only)",
        "fieldtype": "s",
        "type": "text",
        "required": "Yes",
        "allownull": "1",
		"maxlength":"10"
      },
      {
        "name": "alternate_phoneno",
        "label": "Alternate Phone No (10 digit only)",
        "fieldtype": "s",
        "type": "text",
        "allownull": "1",
		"maxlength":"10"
      },
      {
        "name": "whatsappno",
        "label": "WhatsApp No",
        "fieldtype": "s",
        "type": "text",
        "allownull": "1",
		"maxlength":"15"
      },{
        "name": "recommendedby",
        "label": "Recommended By",
        "fieldtype": "s",
        "type": "text",
        "allownull": "1",
		"maxlength":"50"
      },{
        "name": "isauthor",
        "label": "Is Faculty",
        "fieldtype": "s",
        "type": "text",
        "allownull": "1",
		"maxlength":"50"
      }
    ]
  },
  "form_html": "",
  "navbutton": [
    {
      "customid": "1",
      "caption": "Online Course Users",
      "icon": "mif-user",
      "btntype": "ribbon-button",
      "btngroup": "Online Course",
      "btntab": "Online Education",
      "btnorder": "4",
      "onclick": "initializePlugin()"
    }
  ],
  "script": "",
  "formbuttons": [
    {
      "name": "addOnlineCourseUsers",
      "icon": "mif-plus",
      "onclick": "showNewForm()"
    },
    {
      "name": "activeUsers",
      "caption": "Active Users",
      "icon": "mif-user",
      "onclick": "getTableFromSqlStatement('1')"
    },
    {
      "name": "inactiveUsers",
      "caption": "Inactive Users",
      "icon": "mif-user",
      "onclick": "getTableFromSqlStatement('2')"
    },
    {
      "name": "deletedUsers",
      "caption": "Deleted Users",
      "icon": "mif-user",
      "onclick": "getTableFromSqlStatement('3')"
    },
    {
      "name": "SummaryInstituteWise",
      "caption": "Institute Wise Summary",
      "icon": "mif-user",
      "onclick": "getTableFromSqlStatement('13crPr-13cr1-13cr2-13cr3-13cr4')"
    },
    {
      "name": "SummaryStateWise",
      "caption": "State Wise Summary",
      "icon": "mif-user",
      "onclick": "getTableFromSqlStatement('5')"
    },{
      "name": "SummaryInstituteStateWise",
      "caption": "Institute State Wise Summary",
      "icon": "mif-user",
      "onclick": "getTableFromSqlStatement('6')"
    },{
      "name": "loggedInUserList",
      "caption": "Login History",
      "icon": "mif-user",
      "onclick": "getTableFromSqlStatement(10)"
    }
  ],
  "sqlstatement": [
    {
      "customid": "1",
      "name": "activeOnlineUsers",
      "sql": {"action":"Get Table","formname":"online_course_users","fld":"fullname,emailid,pass,gender,state,linked_to_program,linked_to_institution","tbl":"online_course_users","whr":"status=1"},
      "header": "Name,Email,Key,Gender,State,Course,Institute",
      "filter": "1",
      "filter_fields": "linked_to_institution,state",
      "filter_fields_operator": "=,=",
      "filter_fields_caption": "Linked to Institution,State",
      "filter_fields_type": "s,s",
      "filter_fields_inputtype": "select,select",
      "filter_fields_option": [
        {
          "fieldname": "linked_to_institution",
          "option": " SELECT DISTINCT linked_to_institution FROM online_course_users WHERE status=1"
        },
        {
          "fieldname": "state",
          "option": "SELECT DISTINCT state FROM online_course_users WHERE status=1"
        }
      ],
      "edit_record": "1",
      "delete_record": "0",
      "restore_record": "0",
      "change_status": "0:Suspend:Suspension Successful:Suspension Failed"
    },
    {
      "customid": "2",
      "name": "inactiveOnlineUsers",
      "sql": {"action":"Get Table","fld":"fullname,emailid,linked_to_institution","tbl":"online_course_users","whr":"status=0"},
      "header": "Name,Email,Institute",
      "filter": "1",
      "filter_fields": "linked_to_institution,state",
      "filter_fields_operator": "=,=",
      "filter_fields_caption": "Linked to Institution,State",
      "filter_fields_type": "s,s",
      "filter_fields_inputtype": "select,select",
      "filter_fields_option": [
        {
          "fieldname": "linked_to_institution",
          "option": "SELECT DISTINCT linked_to_institution FROM online_course_users WHERE status=0"
        },
        {
          "fieldname": "state",
          "option": "SELECT DISTINCT STATE from online_course_users WHERE status=0"
        }
      ],
      "edit_record": "0",
      "delete_record": "1",
      "restore_record": "0",
      "change_status": "1:Activate:Activation Successful:Activation Failed"
    },
    {
      "customid": "3",
      "name": "deletedOnlineUsers",
      "sql": {"action":"Get Table","fld":"fullname,emailid,linked_to_institution","tbl":"online_course_users","whr":"recordstatus=0"},
      "header": "Name,Email,Institute",
      "filter": "1",
      "filter_fields": "linked_to_institution,state",
      "filter_fields_operator": "=,=",
      "filter_fields_caption": "Linked to Institution,State",
      "filter_fields_type": "s,s",
      "filter_fields_inputtype": "select,select",
      "filter_fields_option": [
        {
          "fieldname": "linked_to_institution",
          "option": "SELECT DISTINCT linked_to_institution FROM online_course_users WHERE recordstatus=0"
        },
        {
          "fieldname": "state",
          "option": "SELECT DISTINCT STATE from online_course_users WHERE recordstatus=1"
        }
      ],
      "edit_record": "0",
      "delete_record": "0",
      "restore_record": "1"
    },
    {
      "customid": "4",
      "name": "institutionWiseSummary",
      "sql": {"action":"Get Table","fld":"linked_to_institution","tbl":"online_course_users","whr":"status=1","grp":"linked_to_institution","srt":"linked_to_institution"},
      "header": "Institute",
      "filter": "0",
      "edit_record": "0",
      "delete_record": "0",
      "restore_record": "1",
	  "set_appendix":"7:INSTITUTE:linked_to_institution:count(*):Count"
    },
    {
      "customid": "5",
      "name": "stateWiseSummary",
      "sql": {"action":"Get Table","fld":"state","tbl":"online_course_users","whr":"status=1","grp":"state","srt":"state"},
	  "header": "State",
      "filter": "0",
      "edit_record": "0",
      "delete_record": "0",
      "restore_record": "1",
	  "set_appendix":"8:STATE:state:count(id):Count"
    },
    {
      "customid": "6",
      "name": "institutionStateWiseSummary",
      "sql": {"action":"Get Table","fld":"linked_to_institution,state","tbl":"online_course_users","whr":"status=1","grp":"linked_to_institution,state","srt":"linked_to_institution,state"},
      "header": "Institute,State",
      "filter": "0",
      "edit_record": "0",
      "delete_record": "0",
      "restore_record": "1",
	  "set_appendix":"9:STATE,INSTITUTE:state,linked_to_institution:count(id):Count"
    },{
	  "customid": "7",
      "name": "institutionWiseStudentList",
      "sql": {"action":"Get Table","fld":"fullname,district,state,phoneno,alternate_phoneno,whatsappno,recommendedby","tbl":"online_course_users","whr":"linked_to_institution='||INSTITUTE||' and status=1"},
      "header": "Name,District,State,Phone No.,Alternate Phone No.,WhatsApp No.,Recommended by",
      "filter": "0"
	},{
	  "customid": "8",
      "name": "StateWiseStudentList",
      "sql": {"action":"Get Table","fld":"fullname,district,state,phoneno,alternate_phoneno,whatsappno,recommendedby","tbl":"online_course_users","whr":"state='||STATE||' and status=1"},
	  "header": "Name,District,State,Phone No.,Alternate Phone No.,WhatsApp No.,Recommended by",
      "filter": "0"
	}
	,{
	  "customid": "9",
      "name": "StateWiseStudentList",
      "sql": {"action":"Get Table","fld":"fullname,district,state,phoneno,alternate_phoneno,whatsappno,recommendedby","tbl":"online_course_users","whr":"linked_to_institution='||INSTITUTE||' and state='||STATE||' and status=1"},
	  "header": "Name,District,State,Phone No.,Alternate Phone No.,WhatsApp No.,Recommended by",
      "filter": "0"
	},{
	  "customid": "10",
      "name": "getLoggedInUserList",
      "sql": {"action":"Get Table","filter_append":" DAY","fld":"a.fullname,b.city,b.region,b.country,DATE_FORMAT(b.createdon,'%d-%m-%Y'),DATE_FORMAT(b.createdon,'%H:%i:%s'),DATE_FORMAT(b.modifiedon,'%H:%i:%s')","tbl":"online_course_user_tracker b","join":"LEFT JOIN online_course_users a ON a.id=b.createdby","srt":"b.createdon DESC"},
	  "header": "Name,City,Region,Country,Date,Login Time,Logout Time",
      "filter": "1",
	  "filter_fields": "b.createdon",
      "filter_fields_operator": ">= NOW() - INTERVAL ",
      "filter_fields_caption": "No. of days",
      "filter_fields_type": "n",
      "filter_fields_inputtype": "text"	  
	},{
		"customid":"11",
		"name":"saveCourseUsers",
		"sql":{"action":"Save Table","validate":"users","outputto":"html","output":"res","command":"insertorupdate","tbl":"online_course_users","fld":"emailid,fullname,gender,linked_to_institution,linked_to_program,educationmode,district,state,phoneno,alternate_phoneno,whatsappno,recommendedby,isfaculty","fldtype":"s,s,s,s,s,s,s,s,s,s,s,s,n","value":"||emailid||,||fullname||,||gender||,||linked_to_institution||,||linked_to_program||,||educationmode||,||district||,||state||,||phoneno||,||alternate_phoneno||,||whatsappno||,||recommendedby||,||isauthor||","whr":"id='||ID||'","param":"emailid,fullname,gender,linked_to_institution,linked_to_program,educationmode,district,state,phoneno,alternate_phoneno,whatsappno,recommendedby,isauthor,ID","successmsg":"Saving Successful","failuremsg":"Saving Failed"}
	},{
		"customid":"12",
		"name":"getCourseUsers",
		"sql":{"action":"Get Row","validate":"users","outputto":"html","output":"edit","tbl":"online_course_users","fld":"id,emailid,fullname,gender,linked_to_institution,linked_to_program,educationmode,district,state,phoneno,alternate_phoneno,whatsappno,recommendedby,isfaculty as isauthor","whr":"id='||ID||'","param":"ID"}
	},{
		"customid":"13crPr",
		"name":"Chart Preperation",
		"sql":{"action":"DOM","validate":"users","outputto":"html","elem":"#workareaTablebox","fun":"html","val":"<div class='mt-2 mb-2' id='chr0'></div><div class='mt-2 mb-2' id='chr1'></div><div class='mt-2 mb-2' id='chr2'></div><div class='mt-2 mb-2' id='chr3'></div>"}	
	},{
		"customid":"13cr1",
		"name":"Pie Chart Institute Wise Data",
		"sql":{"action":"Get Chart","validate":"users status>=1","outputto":"html","output":"chart","type":"doughnut","title":"Pie Chart Institute wise Student Count","elem":"#chr1","label":"linked_to_institution","value":"cnt","legend":"Total Student","tbl":"online_course_users","fld":"linked_to_institution,count(*) as cnt","whr":"status=1","grp":"linked_to_institution","srt":"linked_to_institution"}
	},{
		"customid":"13cr2",
		"name":"Bar Chart Institute Wise Data",
		"sql":{"action":"Get Chart","validate":"users status>=1","outputto":"html","output":"chart","type":"bar","title":"Institute wise Student Count","elem":"#chr2","label":"linked_to_institution","value":"cnt","legend":"Total Student","tbl":"online_course_users","fld":"linked_to_institution,count(*) as cnt","whr":"status=1","grp":"linked_to_institution","srt":"linked_to_institution","union":"UNION ALL (select 'Total' as linked_to_institution,count(*) cnt FROM online_course_users WHERE status=1)","dataset":"SELECT linked_to_institution,count(*) as cnt FROM online_course_users WHERE status=1 and linked_to_institution like '||LABEL||' and gender like '||DATAFILTER||'","datafilter":"Male,Female"}
	},{
		"customid":"13cr3",
		"name":"bar Chart Institute Wise Data",
		"sql":{"action":"Get Chart","validate":"users status>=1","outputto":"html","output":"chart","type":"horizontalBar","title":"State wise Student Count","elem":"#chr3","label":"state","value":"cnt","tbl":"online_course_users","fld":"state,count(*) as cnt","whr":"status=1","grp":"state","srt":"state","legend":"Total Students","dataset":"SELECT state,count(*) as cnt FROM online_course_users where status=1 and state='||LABEL||' and linked_to_institution='||DATAFILTER||'","datafilter":"NIBS,NBBI,Other"}
	},{
		"customid":"13cr4",
		"name":"General Information",
		"sql":{"action":"Get HTML","validate":"users status>=1","outputto":"html","output":"#chr0","tbl":"online_course_users a","fld":"count(*) as cnt1,(SELECT count(*) as cnt2 FROM online_author WHERE status=1)as cnt2,(SELECT count(*) FROM online_course WHERE status=1) as cnt3,(SELECT count(distinct state) FROM online_course_users ) as cnt4","whr":"status=1","parenttag":"div class='d-flex flex-justify-around'","template":"<div class='icon-box border bd-default'><div class='icon bg-cyan fg-white'><span class='mif-user'></span></div><div class='content p-4'><div class='text-upper'>Student Count</div><div class='text-upper text-bold text-lead'>||cnt1||</div></div></div><div class='icon-box border bd-default'><div class='icon bg-red fg-white'><span class='mif-pencil'></span></div><div class='content p-4'><div class='text-upper'>Author Count</div><div class='text-upper text-bold text-lead'>||cnt2||</div></div></div><div class='icon-box border bd-default'><div class='icon bg-green fg-white'><span class='mif-books'></span></div><div class='content p-4'><div class='text-upper'>Course Count</div><div class='text-upper text-bold text-lead'>||cnt3||</div></div></div><div class='icon-box border bd-default'><div class='icon bg-orange fg-white'><span class='mif-map'></span></div><div class='content p-4'><div class='text-upper'>State Represented</div><div class='text-upper text-bold text-lead'>||cnt4||</div></div></div>"}
	}
  ]
}