<?php

include_once 'lock.php';
//Classes
include_once 'Classes/Merchant.php';
include_once 'Classes/Filter.php';
// Variables
$id_merchant = '';
$lead = '';
$name = '';
//Objects
$merchant = new Merchant();
$filter = new Filter();
if (isset($_POST['id_merchant']) && !is_numeric($_POST['id_merchant'])) {
    $merchant->setLead($_POST['lead']);
    $merchant->setName($_POST['name']);
    $merchant->insertMerchant();
    $lastmerchant = $merchant->getIDMerchant();
    $filter->setIdMerchant($lastmerchant);
    $filter->insertFilter();
}
if (isset($_GET['edit'])) {
    $merchant->Merchant($_GET['edit']);
    $id_merchant = $merchant->getIDMerchant();
    $lead = $merchant->getLead();
    $name = $merchant->getName();
}
if (isset($_POST['id_merchant']) && is_numeric($_POST['id_merchant'])) {
    $merchant->setLead($_POST['lead']);
    $merchant->setName($_POST['name']);
    $merchant->updateMerchant();