<?php

  //================================================================================================
  
  require("../financeCompany/financeCompanySql.inc");

  class FinanceCompanySection extends Section {

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

    public function __construct($section) {

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

      // Define section table columns
      $section["sectionTable"]["sectionTableColumn"] = [
        ["id"=>"financeCompanyId", "header"=>"Id", "width"=>30],
        ["id"=>"financeCompanyInternalName", "header"=>"Name", "width"=>250],
        ["id"=>"financeCompanyPhone", "header"=>"Phone", "width"=>120],
        ["id"=>"financeCompanyFax", "header"=>"Fax", "width"=>120],
        ["id"=>"financeCompanyEmail", "header"=>"Email", "width"=>350],
        ["id"=>"financeCompanyWebsite", "header"=>"Website", "width"=>350]
      ];

      // Define section record fields
      $section["sectionRecord"]["sectionRecordStructure"] = [
        "financeCompanyId"=>["type"=>"int", "length"=>"" ],
        "financeCompanyInternalName"=>["type"=>"varchar", "length"=>"50" ],
        "financeCompanyName"=>["type"=>"varchar", "length"=>"50" ],
        "financeCompanyPhone"=>["type"=>"varchar", "length"=>"20" ],
        "financeCompanyFax"=>["type"=>"varchar", "length"=>"20" ],
        "financeCompanyEmail"=>["type"=>"varchar", "length"=>"100" ],
        "financeCompanyWebsite"=>["type"=>"varchar", "length"=>"100" ],
        "financeCompanySINote"=>["type"=>"varchar", "length"=>"" ]
      ];
      
      // Define section record summary items
      $section["sectionRecord"]["sectionRecordSummaryItem"] = [
        ["id"=>"financeCompanyInternalName", "label"=>"Name", "value"=>"Black Horse"]
      ];

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

      // Define section record form inputs
      $section["sectionRecord"]["sectionRecordInput"] = [
        ["attributes"=>[ "type"=>"hidden", "id"=>"financeCompanyId", "name"=>"financeCompanyId", "value"=>"0" ], "label"=>"", "groupId"=>"1" ], 
        ["attributes"=>[ "type"=>"text", "id"=>"financeCompanyInternalName", "name"=>"financeCompanyInternalName", "required"=>"", "maxlength"=>"50", "value"=>"" ], "label"=>"Internal Name", "groupId"=>"1" ],
        ["attributes"=>[ "type"=>"text", "id"=>"financeCompanyName", "name"=>"financeCompanyName", "required"=>"", "maxlength"=>"50", "value"=>"" ], "label"=>"Organisation", "groupId"=>"1" ],
        ["attributes"=>[ "type"=>"text", "id"=>"financeCompanyPhone", "name"=>"financeCompanyPhone", "maxlength"=>"20", "value"=>"" ], "label"=>"Phone", "groupId"=>"1" ],
        ["attributes"=>[ "type"=>"text", "id"=>"financeCompanyFax", "name"=>"financeCompanyFax", "maxlength"=>"20", "value"=>"" ], "label"=>"Fax", "groupId"=>"1" ],
        ["attributes"=>[ "type"=>"text", "id"=>"financeCompanyEmail", "name"=>"financeCompanyEmail", "maxlength"=>"100", "value"=>"" ], "label"=>"Email Address", "groupId"=>"1" ],
        ["attributes"=>[ "type"=>"text", "id"=>"financeCompanyWebsite", "name"=>"financeCompanyWebsite", "maxlength"=>"100", "value"=>"" ], "label"=>"Web Address", "groupId"=>"1" ],
        ["attributes"=>[ "type"=>"text", "id"=>"financeCompanySINote", "name"=>"financeCompanySINote", "value"=>"" ], "label"=>"SI Note", "groupId"=>"2" ]
      ];
        
      // Create the section's sql class
      $sectionSql = new FinanceCompanySql();

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

  }

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

?>