JavaScript Downloading from the database to form PHP download database from server,database download,downloading file from database

I would like when adding "invoice" in my application could look the customer in the database, so I do not have to enter the entire name instead of just to a select input was where I would have taken clients on the fly, I have no idea how to solve accordance with the MVC.

Controller/invoice.php

<?php

include 'Controller/controller.php';

class InvoicesController extends Controller{
    public function index() {
        $view=$this->loadView('invoices');
        $view->index();
    }
    public function add() {
        $view=$this->loadView('invoices');
        $view->add();
    }
    public function insert() {
        $model=$this->loadModel('invoices');
        $model->insert($_POST);
        $this->redirect('?task=invoices&action=index');
    }
    public function delete() {
        $model=$this->loadModel('invoices');
        $model->delete($_GET['id']);;
        $this->redirect('?task=invoices&action=index');
    }
    public function edit() {
        $model=$this->loadView('invoices');
        $model->edit($_GET['id']);
    }
    public function getClients(){
        $model = $this->loadModel('clients');
        $model->getAll();        
    }
    public function editInvoice(){
        $model = $this->loadModel('invoices');
        $model->editInvoice($_POST);
        $this->redirect('?task=invoices&action=index');

    }

}

Model/invoices.php

<?php

include 'Model/model.php';


class InvoicesModel extends Model{


public function insert($data) {

    $ins=$this->pdo->prepare("INSERT INTO invoices (id,Number,Name,Service,Symbol,Unit, Tax, Value)"
            . " VALUES ('',:number,:name,:service,'szt','2',:tax,:value)");
    $ins->bindValue(':name', $data['name'], PDO::PARAM_STR);
    $ins->bindValue(':number', $data['number'], PDO::PARAM_STR);
    $ins->bindValue(':service', $data['service'], PDO::PARAM_STR);
    $ins->bindValue(':tax', $data['tax'], PDO::PARAM_STR);
    $ins->bindValue(':value', $data['value'], PDO::PARAM_STR);
    $ins->execute();
}
public function getAll() {
    return $this->select('invoices');
}
public function getId() {
    return $this->getLastId('invoices');
}
public function edit($id) {
    return $this->select('invoices',' * ',' id = '.$id.' ');
}
public function editInvoice($data){
    $edit=$this->pdo->prepare("UPDATE invoices SET Name = :name WHERE id = :id");
    $edit->bindValue(':name', $data['name']);
    $edit->bindValue(':id', $data['id']);
    $edit->execute();
}
public function delete($id) {
    $del=$this->pdo->prepare('DELETE FROM invoices where id=:id');
    $del->bindValue(':id', $id, PDO::PARAM_INT);
    $del->execute();
}

}

View/invoice.php

<?php

include 'View/view.php';

class InvoicesView extends View{
    public function  index() {
        $cat=$this->loadModel('invoices');
        $this->set('catsData', $cat->getAll());
        $this->render('indexCategory');
    }
    public function  add() {
        $inv=$this->loadModel('invoices');
        $this->set('invoicesData', $inv->getLastId('invoices'));

        $this->render('addCategory');  
    }
    public function getClients(){
        $get = $this->loadModel('clients');
        $this->set('clientsData', $get->getClients());
        $this->render('addCategory');
    }
    public function edit($id){
        $edit = $this->loadModel('invoices');
        $this->set('invoicesData', $edit->edit($_GET['id']));
        $this->render('editInvoice');
    }
}

and template/AddCategory.html.php

<?php include 'templates/header.html.php'; ?></pre>
<h1>Dodaj kontrahenta</h1>
<?php 

?>
<form action="?task=invoices&action=insert" method="post">
    Nazwa kontrahenta: <input type="text" name="name" /><br>
    NIP: <input type="text" name="nip" /><br>
    Adres: <input type="text" name="adress" /><br>
    Kod Pocztowy: <input type="text" name="postcode" /><br>
    Miasto: <input type="text" name="city" /><br>
    Telefon: <input type="text" name="phone" /><br>
    Email: <input type="text" name="email" /><br>
 <input type="submit" value="Dodaj" /></form>
<pre>
<?php include 'templates/footer.html.php'; ?>

If i do

<?php include 'templates/header.html.php'; ?></pre>
<h1>Dodaj kontrahenta</h1>
<?php 
$data = $this->set('clientsData', $get->getClients());
 var_dump($data);
?>
<form action="?task=invoices&action=insert" method="post">
    Nazwa kontrahenta: <input type="text" name="name" /><br>
    NIP: <input type="text" name="nip" /><br>
    Adres: <input type="text" name="adress" /><br>
    Kod Pocztowy: <input type="text" name="postcode" /><br>
    Miasto: <input type="text" name="city" /><br>
    Telefon: <input type="text" name="phone" /><br>
    Email: <input type="text" name="email" /><br>

 <input type="submit" value="Dodaj" /></form>
<pre>
<?php include 'templates/footer.html.php'; ?>

I get errors

Notice: Undefined variable: get in /home/krytykak/domains/jozwiak.edu.pl/public_html/templates/addCategory.html.php on line 4

Fatal error: Call to a member function getClients() on a non-object in /home/krytykak/domains/jozwiak.edu.pl/public_html/templates/addCategory.html.php on line 4
Answer:1

Everything works fine except one thing, I'd like it so when you have the .show class already visible, it will fade again when you click on another of the #c- divs. http://jsfiddle.net/7KdR6/1/ $('[...

Everything works fine except one thing, I'd like it so when you have the .show class already visible, it will fade again when you click on another of the #c- divs. http://jsfiddle.net/7KdR6/1/ $('[...

  1. jquery each fadein

I am using w2ui. I have a toolbar with one button. This button has the icon-image "icon-delete". When I click on the button, I want it to change the icon-image to "icon-add", but my code doesn't work....

I am using w2ui. I have a toolbar with one button. This button has the icon-image "icon-delete". When I click on the button, I want it to change the icon-image to "icon-add", but my code doesn't work....

  1. w2ui grid change toolbar
  2. w2ui grid toolbar

Im using wordpress theme that has different parts like for example footer.php or header.php. What I want to do is reload one part of the whole page using jquery so that the whole page does not refresh....

Im using wordpress theme that has different parts like for example footer.php or header.php. What I want to do is reload one part of the whole page using jquery so that the whole page does not refresh....

I've written the following code to understand class like implementations and closures in JavaScript. 1 function Person(name) { this.Name = name; console.log("Person Fired!!"); (function ...

I've written the following code to understand class like implementations and closures in JavaScript. 1 function Person(name) { this.Name = name; console.log("Person Fired!!"); (function ...

  1. javascript class closures