<?php

  //================================================================================================
      
  require("../productList/productListSql.inc");

  class ProductListSection extends Section {

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

    public function __construct($section) {

      // Define section filter form inputs
      $section["sectionFilter"]["sectionFilterInput"] = [
        ["attributes"=>[ "type"=>"text", "id"=>"productListDescription", "value"=>"" ], "label"=>"Name" ]
      ];

      // Define section table columns
      $section["sectionTable"]["sectionTableColumn"] = [
        ["id"=>"productListId", "header"=>"Id", "width"=>30],
        ["id"=>"productListDescription", "header"=>"Name", "width"=>250]
      ];

      // Define section record fields
      $section["sectionRecord"]["sectionRecordStructure"] = [
        "productListId"=>["type"=>"int", "length"=>"" ],
        "productListDescription"=>["type"=>"varchar", "length"=>"50" ]
      ];

      // Define section record summary items
      $section["sectionRecord"]["sectionRecordSummaryItem"] = [
        ["id"=>"productListDescription", "label"=>"Name", "value"=>"Willerby Optional Extras"]
      ];

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

      // Define section record form inputs
      $section["sectionRecord"]["sectionRecordInput"] = [
        ["attributes"=>[ "type"=>"hidden", "id"=>"productListId", "name"=>"productListId", "value"=>"0" ], "label"=>"", "groupId"=>"1" ], 
        ["attributes"=>[ "type"=>"text", "id"=>"productListDescription", "name"=>"productListDescription", "required"=>"", "maxlength"=>"50", "value"=>"" ], "label"=>"Name", "groupId"=>"1" ],
        ["attributes"=>[ "type"=>"section", "id"=>"productListProduct" ], "label"=>"Products", "groupId"=>"2" ]
      ];

      // Define section record sections
      $section["sectionRecord"]["sectionRecordSection"] = [
        ["sectionId"=>"productListProduct", "sectionType"=>"product", "sectionTitle"=>"Products", "groupId"=>"2"]
      ];

      // Create the section's sql class
      $sectionSql = new ProductListSql();

			// 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["productListDescription"], 'filterValueType'=>'string', 'filterOperator'=>'', 'filterList'=>['productListDescription']]);			
      
      $this->set_sqlSelectWhere($sqlSelectWhere);
      $this->set_sqlSelectLimit($filters["productListLimit"]);
      
    }

  }

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

?>