Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Address functionality added.

  • Loading branch information...
commit ee56f59451f85a59248ba95b519c6ed7cb4572ce 1 parent c2ae983
@hquadrat authored
View
82 application/controllers/address.php
@@ -0,0 +1,82 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+class Address extends CI_Controller {
+
+ /**
+ * Index Page for this controller.
+ *
+ * Maps to the following URL
+ * http://example.com/index.php/welcome
+ * - or -
+ * http://example.com/index.php/welcome/index
+ * - or -
+ * Since this controller is set as the default controller in
+ * config/routes.php, it's displayed at http://example.com/
+ *
+ * So any other public methods not prefixed with an underscore will
+ * map to /index.php/welcome/<method_name>
+ * @see http://codeigniter.com/user_guide/general/urls.html
+ */
+ public function index()
+ {
+
+ $this->load->model('Addressmodel');
+
+ $data['tasks'] = $this->Addressmodel->get_active_entries();
+
+ $this->load->view('address_dashboard', $data);
+
+ }
+
+ public function add()
+ {
+
+ $this->load->model('Addressmodel');
+
+ $this->Addressmodel->insert_entry();;
+
+ redirect('address');
+
+ }
+
+ public function edit()
+ {
+
+ $this->load->model('Addressmodel');
+
+ $this->Addressmodel->update_entry();
+
+ redirect('address');
+
+ }
+
+
+ public function addressform()
+ {
+
+ $editID = $this->uri->segment(3, 0);
+
+ if( (!empty($editID)) && ($editID != 0) ) {
+
+ $this->load->model('Addressmodel');
+
+ $data['addressEditID'] = $editID;
+ $data['address'] = $this->Addressmodel->get_address( $editID );
+
+ $this->load->view('address_form', $data);
+
+ }
+ else {
+
+ $this->load->view('address_form');
+
+ }
+
+
+ }
+
+
+}
+
+/* End of file welcome.php */
+/* Location: ./application/controllers/welcome.php */
View
77 application/models/addressmodel.php
@@ -28,6 +28,83 @@ function get_active_entries()
}
+ function get_address( $requiredID )
+ {
+
+ $query = $this->db->get_where('t_address', array('idt_address' => $requiredID), 1, 0);
+
+ return $query->first_row();
+
+ }
+
+ function insert_entry()
+ {
+
+ $this->street = $_POST['street'];
+ $this->co = $_POST['co'];
+ $this->postalcode = $_POST['postalcode'];
+ $this->city = $_POST['city'];
+ $this->phoneprivate = $_POST['phoneprivate'];
+ $this->phonebusiness = $_POST['phonebusiness'];
+ $this->mobileprivate = $_POST['mobileprivate'];
+ $this->mobilebusiness = $_POST['mobilebusiness'];
+ $this->emailprivate = $_POST['emailprivate'];
+ $this->emailbusiness = $_POST['emailbusiness'];
+
+ $this->db->insert('t_address', $this);
+
+
+ if ($this->db->_error_message() != "")
+ {
+ // generate an error... or use the log_message() function to log your error
+ $this->session->set_flashdata('appmessage', 'Problem: ' . $this->db->_error_message());
+ } else {
+
+ $this->session->set_flashdata('appmessage', 'Neue Adresse angelegt.' );
+
+ }
+
+ }
+
+ function update_entry()
+ {
+
+ $data = array(
+ 'street' => $_POST['street'],
+ 'co' => $_POST['co'],
+ 'postalcode' => $_POST['postalcode'],
+ 'city' => $_POST['city'],
+ 'phoneprivate' => $_POST['phoneprivate'],
+ 'phonebusiness' => $_POST['phonebusiness'],
+ 'mobileprivate' => $_POST['mobileprivate'],
+ 'mobilebusiness' => $_POST['mobilebusiness'],
+ 'emailprivate' => $_POST['emailprivate'],
+ 'emailbusiness' => $_POST['emailbusiness']
+ );
+
+ $this->db->where('idt_address', $_POST['addresseditid']);
+ $this->db->update('t_address', $data);
+
+
+ if ($this->db->_error_message() != "")
+ {
+ // generate an error... or use the log_message() function to log your error
+ $this->session->set_flashdata('appmessage', 'Problem: ' . $this->db->_error_message());
+ } else {
+
+ $this->session->set_flashdata('appmessage', 'Neue Adresse angelegt.' );
+
+ }
+
+ }
+
+
+
+
+
+
+
+
}
?>
View
71 application/views/address_dashboard.php
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Adressen Dashboard</title>
+
+ <?php
+ $this->load->view('statics/css');
+ ?>
+
+</head>
+<body>
+
+<?php
+ $this->load->view('statics/flash_message');
+?>
+
+<h1>Adressen Dashboard</h1>
+
+<?php
+ $this->load->view('statics/navigation');
+?>
+
+<table cellpadding="4" cellspacing="2">
+
+<?php foreach ($tasks as $item) {?>
+
+<tr>
+ <td colpsan="6"><?php echo $item->idt_address;?> <?php echo anchor('address/addressform/'.$item->idt_address, 'Edit', array('class' => 'edit')); ?></td>
+</tr>
+<tr>
+ <td valign="top">
+ Straße:<br />
+ C/O:<br />
+ PLZ/Stadt:
+ </td>
+ <td valign="top">
+ <?php echo $item->street;?><br />
+ <?php echo $item->co;?><br />
+ <?php echo $item->postalcode;?> <?php echo $item->city;?>
+ </td>
+ <td valign="top">
+ E geschäftl.:<br />
+ E privat:
+ </td>
+ <td valign="top">
+ <?php echo $item->emailbusiness;?><br />
+ <?php echo $item->emailprivate;?>
+ </td>
+ <td valign="top">
+ T geschäftl.:<br />
+ T privat:<br />
+ M geschäftl.:<br />
+ M privat:
+ </td>
+ <td valign="top">
+ <?php echo $item->phonebusiness;?>
+ <?php echo $item->phoneprivate;?><br />
+ <?php echo $item->mobilebusiness;?><br />
+ <?php echo $item->mobileprivate;?>
+ </td>
+</tr>
+
+<?php } ?>
+
+</table>
+
+<p id="footer">Page rendered in {elapsed_time} seconds</p>
+
+</body>
+</html>
View
62 application/views/address_form.php
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Adresse anlegen/bearbeiten</title>
+
+ <?php
+ $this->load->view('statics/css');
+ ?>
+
+</head>
+<body>
+
+<?php
+ $this->load->view('statics/flash_message');
+?>
+
+<h1>Adresse anlegen/bearbeiten</h1>
+
+<?php
+ $this->load->view('statics/navigation');
+?>
+
+<?php
+
+if( (!empty($addressEditID)) && ($addressEditID != 0) ) {
+
+ echo form_open('address/edit');
+ echo form_hidden('addresseditid', $addressEditID);
+
+ echo "ID: ".$addressEditID;
+ echo "EDIT EDIT EDIT";
+
+}
+else {
+
+ echo form_open('address/add');
+
+}
+
+?>
+
+Strasse: <?php echo form_input('street', $address->street); ?><br />
+C/O: <?php echo form_input('co', $address->co); ?><br />
+PLZ/Stadt: <?php echo form_input('postalcode', $address->postalcode); ?> <?php echo form_input('city', $address->city); ?><br /><br />
+Telefon geschäftl.: <?php echo form_input('phonebusiness', $address->phonebusiness); ?><br />
+Telefon privat: <?php echo form_input('phoneprivate', $address->phoneprivate); ?><br /><br />
+Mobil geschäftl.: <?php echo form_input('mobilebusiness', $address->mobilebusiness); ?><br />
+Mobil privat: <?php echo form_input('mobileprivate', $address->mobileprivate); ?><br /><br />
+E-mail geschäftl.: <?php echo form_input('emailbusiness', $address->emailbusiness); ?><br />
+E-mail privat: <?php echo form_input('emailprivate', $address->emailprivate); ?><br />
+
+<?php
+if( (!empty($addressEditID)) && ($addressEditID != 0) ) echo form_submit('mysubmit', 'Adressänderungen speichern!');
+else echo form_submit('mysubmit', 'Adresse anlegen!');
+?>
+
+
+<p id="footer">Page rendered in {elapsed_time} seconds</p>
+
+</body>
+</html>
View
2  application/views/person_form.php
@@ -33,7 +33,7 @@
<select name="address" id="address">
<?php foreach ($addresses as $item) {?>
- <option value="<?php echo $item->idt_address;?>"><?php echo $item->street;?>, <?php echo $item->postalcode;?> <?php echo $item->city;?></option>
+ <option value="<?php echo $item->idt_address;?>"><?php echo $item->emailbusiness;?> <?php echo $item->street;?>, <?php echo $item->postalcode;?> <?php echo $item->city;?></option>
<?php } ?>
</select>
View
6 application/views/statics/navigation.php
@@ -33,5 +33,11 @@
<li><?php echo anchor('person/personform', 'Person hinzufügen', 'title="eine neue Person hinzufügen"'); ?></li>
</ul>
</li>
+ <li>Adressen
+ <ul>
+ <li><?php echo anchor('address', 'Adressen Übersicht'); ?></li>
+ <li><?php echo anchor('address/addressform', 'Adresse hinzufügen', 'title="eine neue Person hinzufügen"'); ?></li>
+ </ul>
+ </li>
</ul>
</div>
View
2  application/views/task_form.php
@@ -21,8 +21,6 @@
$this->load->view('statics/navigation');
?>
-<p>The page you are looking at is being generated dynamically by CodeIgniter.</p>
-
<?php echo form_open('task/add'); ?>
Name: <?php echo form_input('name'); ?><br />
Please sign in to comment.
Something went wrong with that request. Please try again.