<?php

  //================================================================================================
  
  require("../contactMethod/contactMethodSql.inc");

  class ContactMethodSection extends Section {

    //================================================================================================
    // Function Constructor()
    //================================================================================================

    public function __construct($section) {

      // Define contact method type select options
      $contactMethodTypeOptions = ["0"=>"All", "1"=>"Phone Number", "2"=>"Email Address", "3"=>"Website Address"];

      // Define section filter form inputs
      $section["sectionFilter"]["sectionFilterInput"] = [
        ["attributes"=>[ "type"=>"select", "id"=>"contactMethodTypeId", "value"=>"0" ], "label"=>"Type", "options"=>$contactMethodTypeOptions ]
      ];

      // Define section table columns
      $section["sectionTable"]["sectionTableColumn"] = [
        ["id"=>"contactMethodId", "header"=>"Id", "width"=>50],
        ["id"=>"contactMethodContactId", "header"=>"Contact Id", "width"=>50],
        ["id"=>"contactMethodTypeDescription", "header"=>"Type Id", "width"=>120],
        ["id"=>"contactMethodLabel", "header"=>"Label", "width"=>120],
        ["id"=>"contactMethodDescription", "header"=>"Description", "width"=>240]
      ];

      // Define section record fields
      $section["sectionRecord"]["sectionRecordStructure"] = [
        "contactMethodId"=>["type"=>"int", "length"=>""],
        "contactMethodContactId"=>["type"=>"int", "length"=>""],
        "contactMethodTypeId"=>["type"=>"int", "length"=>""],
        "contactMethodLabel"=>["type"=>"varchar", "length"=>"100"],
        "contactMethodDescription"=>["type"=>"varchar", "length"=>"100"]
      ];
      
      // Define section record summary items
      $section["sectionRecord"]["sectionRecordSummaryItem"] = [
        ["id"=>"contactMethodLabel", "label"=>"Label", "value"=>""]
      ];

      // Define section record form columns and groups
      $section["sectionRecord"]["sectionRecordTabColumn"] = [
        ["columnId"=>"1", "columnClass"=>"", "columnGroup"=>[["groupId"=>"1"]]]
      ];

      // Define section record form inputs
      $section["sectionRecord"]["sectionRecordInput"] = [
        ["attributes"=>[ "type"=>"hidden", "id"=>"contactMethodId", "name"=>"contactMethodId", "value"=>"0" ], "label"=>"", "groupId"=>"1" ], 
        ["attributes"=>[ "type"=>"hidden", "id"=>"contactMethodContactId", "name"=>"contactMethodContactId", "value"=>"0" ], "label"=>"", "groupId"=>"1" ], 
        ["attributes"=>[ "type"=>"select", "id"=>"contactMethodTypeId", "name"=>"contactMethodTypeId", "required"=>"", "value"=>"1" ], "label"=>"Type", "groupId"=>"1", "options"=>$contactMethodTypeOptions ],
        ["attributes"=>[ "type"=>"text", "id"=>"contactMethodLabel", "name"=>"contactMethodLabel", "required"=>"", "maxlength"=>"100", "value"=>"" ], "label"=>"Label", "groupId"=>"1" ],
        ["attributes"=>[ "type"=>"text", "id"=>"contactMethodDescription", "name"=>"contactMethodDescription", "maxlength"=>"100", "value"=>"" ], "label"=>"Description", "groupId"=>"1" ]
      ];
        
      // Create the section's sql class
      $sectionSql = new ContactMethodSql();

      // Create the parent section object
			parent :: __construct( $section, $sectionSql );

      // Set the section title, filter inputs, filter limit, menu buttons, table columns and table rows 
      $this->set_sectionTitle($section["sectionTitle"]);
      $this->set_sectionTableRecordset();
    }

    //================================================================================================
    // Function set_sqlSelect()
    //================================================================================================

    public function set_sqlSelectFilters($filters) {

    	$DBGeneric = new DBGeneric();

      $sqlSelectWhere = sprintf("WHERE 1");
      $sqlSelectWhere .= $DBGeneric->getFilterSql(['filterValue'=>$filters["contactMethodTypeId"], 'filterValueType'=>'integer', 'filterOperator'=>'=', 'filterList'=>['contactMethodTypeId']]);			
      
      $this->set_sqlSelectWhere($sqlSelectWhere);
      $this->set_sqlSelectLimit($filters["contactMethodLimit"]);
      
    }

  }

  //================================================================================================

?>