public function delete($id)
 {
     $ps = new PreparedStatement("DELETE FROM cities WHERE id = ?");
     $ps->setInt(1, $id);
     if ($this->ds->execute($ps->getSql())) {
         $customerDAO = new CustomerDAO($this->ds);
         $customerDAO->updateCity($id, 'NULL');
         return TRUE;
     }
     return FALSE;
 }
 /**
  * @return array
  */
 public function getCustomer()
 {
     if (!isset($this->customer)) {
         $this->customer = CustomerDAO::getInstance()->getCustomer($this->customerId);
     }
     return $this->customer;
 }
Exemple #3
0
require_once 'main.php';
require_once 'Connection.class.php';
require_once 'CustomerDAO.class.php';
$action = isset($_GET['action']) ? $_GET['action'] : 'new';
$id = isset($_GET['id']) ? $_GET['id'] : -1;
if ($action !== 'update' && $action !== 'new') {
    die('opció invalida');
    exit;
}
if ($action === 'update') {
    /*if ($id <= 0) {
        die 'if no valid'; exit;    
      }*/
    $c = new Connection();
    $conn = $c->getConnection();
    $customerDAO = new CustomerDAO($conn);
    $customer = $customerDAO->select($id);
} else {
    $customer = array('id' => -1, 'name' => '', 'email' => '', 'phone' => '', 'date_end' => '', 'participants' => '', 'observations' => '');
}
$title = $action === 'new' ? 'Nova família' : 'Modificar família';
include 'head.php';
?>


<br>

<h1 class="text-center"><?php 
echo $title;
?>
</h1>
Exemple #4
0
    case 'new':
        $name = $_POST['name'] or die('nom de client no informat');
        $email = isset($_POST['email']) ? $_POST['email'] : '';
        $phone = isset($_POST['phone']) ? $_POST['phone'] : '';
        $participants = isset($_POST['participants']) ? $_POST['participants'] : '';
        $observations = isset($_POST['observations']) ? $_POST['observations'] : '';
        $customer = array('id' => $id, 'name' => $name, 'email' => $email, 'phone' => $phone, 'participants' => $participants, 'observations' => $observations);
}
/*
echo 'action: '.$action;
echo '$customer';
print_r($customer);
*/
$c = new Connection();
$conn = $c->getConnection();
$customerDAO = new CustomerDAO($conn);
switch ($action) {
    case 'new':
        $insert_id = $customerDAO->create($customer);
        break;
    case 'update':
        $customerDAO->update($customer);
        break;
    case 'delete':
        //echo 'delete dao'.$id; exit;
        $customerDAO->delete($id);
        break;
}
if ($isAjax) {
    echo json_encode($response);
    exit;
<?php

require_once './header.php';
require_once './customerDAO.php';
// Database connection and function defenition
?>
            <div id="content" class="clearfix">
                <div class="main" style="width: 660px;">
                    <?php 
try {
    $customerDAO = new CustomerDAO();
    $customers = $customerDAO->getCustomers();
    if ($customers) {
        echo "<table class='tableLists'>";
        echo '<thead><tr><th>Full Name</th><th>Email</th><th>Username</th><th>Phone</th></tr></thead><tbody>';
        foreach ($customers as $customer) {
            echo '<tr>';
            echo "<td style='width: 200px;'>" . $customer->getFirstName() . ' ' . $customer->getLastName() . '</td>';
            echo "<td style='width: 200px;'>" . $customer->getEmailAddress() . '</td>';
            echo "<td style='width: 120px;'>" . $customer->getUsername() . '</td>';
            echo "<td style='width: 120px;'>" . $customer->getPhoneNumber() . '</td>';
            echo '</tr>';
        }
        echo '</tbody></table>';
    }
} catch (Exception $e) {
    echo '<h3>Error on page.</h3>';
    echo '<p>' . $e->getMessage() . '</p>';
}
?>
                </div><!-- End Main -->
Exemple #6
0
 public function delete()
 {
     $customerDAO = new CustomerDAO(DataSource::getInstance());
     $customerDAO->delete((int) $_POST['del_cust_id']);
     echo '1';
 }
Exemple #7
0
     $emsg['refer'] = 'You should select one of referrals.';
     $error['refer'] = true;
 }
 // check if there are some errors
 $errcount = 0;
 foreach ($error as $er) {
     if ($er == true) {
         $errcount++;
         break;
     }
 }
 //if there are no errors, proceed to make a new CustomerDAO object and make insertions and queries
 if ($errcount == 0) {
     // The abstractDAO and customerDAO will throw exceptions if there is a problem with the database connection.
     try {
         $customerDAO = new CustomerDAO();
         // User can not have same Username.
         if (!$customerDAO->getCustomerByUsername($uname)) {
             // Customer ID is defined by MySql because it is auto increasement mode.
             //updated 18-04-2016: emails are hashed first ($cryptedEmail), and then inserted into the database:
             if ($customerDAO->insertCustomer($fname, $lname, $phone, $cryptedEmail, $uname, $refer)) {
                 echo "<p class='addedCustomer'>You successfully added {$fname} {$lname} to the database</p>";
             } else {
                 echo "<p class='error-text'> An error occured in adding {$fname} {$lname} to the database</p>";
             }
         } else {
             $emsg['uname'] = 'User name has already registered. Please use another user name.';
             $error['uname'] = true;
         }
         $target_file = $_FILES['myfile']['name'];
         $target_path = "file/";