This commit is contained in:
Paminger
2016-04-08 06:45:35 +02:00
parent 5e59fc3c17
commit 5b3d3c401d
4 changed files with 118 additions and 106 deletions
+35 -37
View File
@@ -1,6 +1,7 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class Examples extends CI_Controller {
class Examples extends CI_Controller
{
public function __construct()
{
@@ -14,7 +15,7 @@ class Examples extends CI_Controller {
public function _example_output($output = null)
{
$this->load->view('example.php',$output);
$this->load->view('example.php', $output);
}
public function offices()
@@ -38,12 +39,11 @@ class Examples extends CI_Controller {
$crud->set_table('offices');
$crud->set_subject('Office');
$crud->required_fields('city');
$crud->columns('city','country','phone','addressLine1','postalCode');
$crud->columns('city', 'country', 'phone', 'addressLine1', 'postalCode');
$output = $crud->render();
$this->_example_output($output);
}catch(Exception $e){
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
@@ -55,13 +55,13 @@ class Examples extends CI_Controller {
$crud->set_theme('datatables');
$crud->set_table('employees');
$crud->set_relation('officeCode','offices','city');
$crud->display_as('officeCode','Office City');
$crud->set_relation('officeCode', 'offices', 'city');
$crud->display_as('officeCode', 'Office City');
$crud->set_subject('Employee');
$crud->required_fields('lastName');
$crud->set_field_upload('file_url','assets/uploads/files');
$crud->set_field_upload('file_url', 'assets/uploads/files');
$output = $crud->render();
@@ -73,12 +73,12 @@ class Examples extends CI_Controller {
$crud = new grocery_CRUD();
$crud->set_table('customers');
$crud->columns('customername','contactlastname','phone','city','country','salesrepemployeenumber','creditlimit');
$crud->display_as('salesrepemployeenumber','from Employeer')
->display_as('customername','Name')
->display_as('contactlastname','Last Name');
$crud->columns('customername', 'contactlastname', 'phone', 'city', 'country', 'salesrepemployeenumber', 'creditlimit');
$crud->display_as('salesrepemployeenumber', 'from Employeer')
->display_as('customername', 'Name')
->display_as('contactlastname', 'Last Name');
$crud->set_subject('Customer');
$crud->set_relation('salesrepemployeenumber','employees','lastname');
$crud->set_relation('salesrepemployeenumber', 'employees', 'lastname');
$output = $crud->render();
@@ -89,8 +89,8 @@ class Examples extends CI_Controller {
{
$crud = new grocery_CRUD();
$crud->set_relation('customerNumber','customers','{contactLastName} {contactFirstName}');
$crud->display_as('customerNumber','Customer');
$crud->set_relation('customerNumber', 'customers', '{contactLastName} {contactFirstName}');
$crud->display_as('customerNumber', 'Customer');
$crud->set_table('orders');
$crud->set_subject('Order');
$crud->unset_add();
@@ -108,7 +108,7 @@ class Examples extends CI_Controller {
$crud->set_table('products');
$crud->set_subject('Product');
$crud->unset_columns('productDescription');
$crud->callback_column('buyPrice',array($this,'valueToEuro'));
$crud->callback_column('buyPrice', array($this,'valueToEuro'));
$output = $crud->render();
@@ -125,11 +125,11 @@ class Examples extends CI_Controller {
$crud = new grocery_CRUD();
$crud->set_table('film');
$crud->set_relation_n_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'fullname','priority');
$crud->set_relation_n_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'fullname', 'priority');
$crud->set_relation_n_n('category', 'film_category', 'category', 'film_id', 'category_id', 'name');
$crud->unset_columns('special_features','description','actors');
$crud->unset_columns('special_features', 'description', 'actors');
$crud->fields('title', 'description', 'actors' , 'category' ,'release_year', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features');
$crud->fields('title', 'description', 'actors', 'category', 'release_year', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features');
$output = $crud->render();
@@ -143,15 +143,14 @@ class Examples extends CI_Controller {
$crud->set_theme('twitter-bootstrap');
$crud->set_table('film');
$crud->set_relation_n_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'fullname','priority');
$crud->set_relation_n_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'fullname', 'priority');
$crud->set_relation_n_n('category', 'film_category', 'category', 'film_id', 'category_id', 'name');
$crud->unset_columns('special_features','description','actors');
$crud->unset_columns('special_features', 'description', 'actors');
$crud->fields('title', 'description', 'actors' , 'category' ,'release_year', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features');
$crud->fields('title', 'description', 'actors', 'category', 'release_year', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features');
$output = $crud->render();
$this->_example_output($output);
}catch(Exception $e){
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
@@ -160,8 +159,8 @@ class Examples extends CI_Controller {
function multigrids()
{
$this->config->load('grocery_crud');
$this->config->set_item('grocery_crud_dialog_forms',true);
$this->config->set_item('grocery_crud_default_per_page',10);
$this->config->set_item('grocery_crud_dialog_forms', true);
$this->config->set_item('grocery_crud_default_per_page', 10);
$output1 = $this->offices_management2();
@@ -186,7 +185,7 @@ class Examples extends CI_Controller {
$crud->set_table('offices');
$crud->set_subject('Office');
$crud->set_crud_url_path(site_url(strtolower(__CLASS__."/".__FUNCTION__)),site_url(strtolower(__CLASS__."/multigrids")));
$crud->set_crud_url_path(site_url(strtolower(__CLASS__."/".__FUNCTION__)), site_url(strtolower(__CLASS__."/multigrids")));
$output = $crud->render();
@@ -203,15 +202,15 @@ class Examples extends CI_Controller {
$crud->set_theme('datatables');
$crud->set_table('employees');
$crud->set_relation('officeCode','offices','city');
$crud->display_as('officeCode','Office City');
$crud->set_relation('officeCode', 'offices', 'city');
$crud->display_as('officeCode', 'Office City');
$crud->set_subject('Employee');
$crud->required_fields('lastName');
$crud->set_field_upload('file_url','assets/uploads/files');
$crud->set_field_upload('file_url', 'assets/uploads/files');
$crud->set_crud_url_path(site_url(strtolower(__CLASS__."/".__FUNCTION__)),site_url(strtolower(__CLASS__."/multigrids")));
$crud->set_crud_url_path(site_url(strtolower(__CLASS__."/".__FUNCTION__)), site_url(strtolower(__CLASS__."/multigrids")));
$output = $crud->render();
@@ -227,14 +226,14 @@ class Examples extends CI_Controller {
$crud = new grocery_CRUD();
$crud->set_table('customers');
$crud->columns('customerName','contactLastName','phone','city','country','salesRepEmployeeNumber','creditLimit');
$crud->display_as('salesRepEmployeeNumber','from Employeer')
->display_as('customerName','Name')
->display_as('contactLastName','Last Name');
$crud->columns('customerName', 'contactLastName', 'phone', 'city', 'country', 'salesRepEmployeeNumber', 'creditLimit');
$crud->display_as('salesRepEmployeeNumber', 'from Employeer')
->display_as('customerName', 'Name')
->display_as('contactLastName', 'Last Name');
$crud->set_subject('Customer');
$crud->set_relation('salesRepEmployeeNumber','employees','lastName');
$crud->set_relation('salesRepEmployeeNumber', 'employees', 'lastName');
$crud->set_crud_url_path(site_url(strtolower(__CLASS__."/".__FUNCTION__)),site_url(strtolower(__CLASS__."/multigrids")));
$crud->set_crud_url_path(site_url(strtolower(__CLASS__."/".__FUNCTION__)), site_url(strtolower(__CLASS__."/multigrids")));
$output = $crud->render();
@@ -244,5 +243,4 @@ class Examples extends CI_Controller {
return $output;
}
}
}
+12 -5
View File
@@ -1,7 +1,8 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
defined('BASEPATH') || exit('No direct script access allowed');
class Vilesci extends CI_Controller {
class Vilesci extends CI_Controller
{
/**
* Index Page for this controller.
@@ -17,10 +18,12 @@ class Vilesci extends CI_Controller {
* 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
* @return void
*/
public function index()
{
if (false)//$this->dbupdate())
// ToDo: check if update is needed
if (false && $this->dbupdate())
echo 'System-DB needs update!';
else
{
@@ -30,11 +33,15 @@ class Vilesci extends CI_Controller {
}
}
private function dbupdate()
/**
*
* @return bool
*/
private function __dbupdate()
{
// Check for update (codeigniter migration)
$this->load->library('migration');
if ($this->migration->current() === FALSE)
if ($this->migration->current() === false)
show_error($this->migration->error_string());
if ($this->migration->current() != $this->migration->latest())
return true;
+19 -29
View File
@@ -5,32 +5,22 @@ class Person_model extends DB_Model
public function __construct($uid = null)
{
parent::__construct($uid);
$this->dbTable = 'public.tbl_person';
parent::__construct($uid);
$this->dbTable = 'public.tbl_person';
}
public function getPerson($person_id = null)
{
if (is_null($person_id))
{
$query = $this->db->get_where('public.tbl_person', array());
return $query->result_object();
if (is_null($person_id))
{
$query = $this->db->get_where('public.tbl_person', array());
return $query->result_object();
}
$query = $this->db->get_where('public.tbl_person', array('person_id' => $person_id));
return $query->row_object();
}
$query = $this->db->get_where('public.tbl_person', array('person_id' => $person_id));
return $query->row_object();
}
public function getPersonByCode($code)
{
if ($this->fhc_db_acl->bb->isBerechtigt('person', 's'))
{
$query = $this->db->get_where('public.tbl_person', array('zugangscode' => $code));
return $query->result_object();
}
}
<<<<<<< HEAD
/**
* Laedt Personendaten einer Person mittels Code
* @param string $code DB-Attr: tbl_benutzer.zugangscode .
@@ -48,7 +38,8 @@ class Person_model extends DB_Model
return $this->_general_error($this->fhc_db_acl->bb->errormsg);
//return false;
}
=======
}
/**
* Laedt Personendaten eine BenutzerUID
* @param string $uid DB-Attr: tbl_benutzer.uid .
@@ -56,14 +47,13 @@ class Person_model extends DB_Model
*/
public function getPersonFromBenutzerUID($uid)
{
if (!$this->fhc_db_acl->bb->isBerechtigt('person', 's'))
{
$this->db->select('tbl_person.*');
$this->db->from('public.tbl_person JOIN public.tbl_benutzer USING (person_id)');
$query = $this->db->get_where(null, array('uid' => $uid));
return $query->result_object();
>>>>>>> 97ddc838a8c9e707d3bf5a6a700301252d2f5ed8
}
if (!$this->fhc_db_acl->bb->isBerechtigt('person', 's'))
{
$this->db->select('tbl_person.*');
$this->db->from('public.tbl_person JOIN public.tbl_benutzer USING (person_id)');
$query = $this->db->get_where(null, array('uid' => $uid));
return $query->result_object();
}
}
public function savePerson($person)
+52 -35
View File
@@ -21,26 +21,30 @@
*/
/**
* Implementation super class
*/
class basis
* Implementation super class
*/
class basis
{
/**
* Error message
* @var base_errors $msgs
*/
* Error message
* @var base_errors $msgs
*/
public $errormsg;
/**
* Constructor
*
* @access public
*/
public function __construct($db_system='pgsql')
* Constructor
*
* @param string $dbSystem Choose the DB-System.
* @access public
*/
public function __construct($dbSystem = 'pgsql')
{
//empty
}
/**
* @return string
*/
public function getErrorMsg()
{
return $this->errormsg;
@@ -52,26 +56,30 @@ class basis
* Zeichen mit Backslash versehen und das Ergbnis
* unter Hochkomma gesetzt.
*
* 12/2011 DEPRECATED use db_add_param
* ToDo: 12/2011 DEPRECATED use db_add_param
* @param string $var The String you want to be slashed.
* @return string
*/
public function addslashes($var)
{
return ($var!=''?"'".addslashes($var)."'":'null');
return ($var != ''?"'".addslashes($var)."'":'null');
}
/**
* Splittet ein Array auf um es zB in der IN Klausel eines SQL Befehles zu verwenden
* Die einzelnen Elemente werden unter Hochkomma gesetzt und mit Beistrich getrennt.
* @param $array
* ToDo: Its also deprecated
* @param array $array Array to be imploded.
* @return string
*/
public function implode4SQL($array)
{
$string = '';
foreach($array as $row)
foreach ($array as $row)
{
if($string!='')
$string.=',';
$string.="'".addslashes($row)."'";
if($string != '')
$string .= ',';
$string .= "'".addslashes($row)."'";
}
return $string;
}
@@ -79,40 +87,49 @@ class basis
/**
* Berechnet die Kalenderwoche eines gegebenen Datums
* Datum muss timestamp uebergeben werden
* @param $datum
* @param timestamp $datum Timestamp from which to calculate the CalendarWeek.
* @return int
*/
function kw($datum)
public function kw($datum)
{
//$woche=date("W",mktime($date[hours],$date[minutes],$date[seconds],$date[mon],$date[mday],$date[year]));
if (!date("w",$datum))
$datum+=86400;
if (!date("w", $datum))
$datum += 86400;
//echo date("l j.m.Y - W",$datum);
$woche=date("W",$datum);
//if ($woche==53)
// $woche=1;
$woche = date("W", $datum);
// ToDo: Every 4 year we have a Problem.
//if ($woche == 53)
// $woche = 1;
return $woche;
}
function jump_week($datum, $wochen)
/**
* Springt zur entsprechenden KW im aktuellen Jahr
*
* @param timestamp $datum Timestamp from which to start.
* @param signed int $wochen Number of Weeks to jump.
* @return int
*/
public function jump_week($datum, $wochen)
{
$stunde_vor=date("G",$datum);
$stundeVor = date("G", $datum);
// Eine Woche sind 604800 Sekunden
$datum+=604800*$wochen;
$stunde_nach=date("G",$datum);
if ($stunde_nach!=$stunde_vor)
$datum+=3600;
$datum += 604800 * $wochen;
$stundeNach = date("G", $datum);
if ($stundeNach != $stundeVor)
$datum += 3600;
return $datum;
}
/**
* Konvertiert eine Zeichenkette,
* Konvertiert eine Zeichenkette,
* damit diese in HTML Dokumenten sicher ausgegeben werden kann
*
* @param $value
*
* @param string $value The HTML-Chars to convert.
* @return string
*/
public function convert_html_chars($value)
{
return htmlspecialchars($value);
}
}
?>