[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [7615]
From: |
Erik Holm-Larsen |
Subject: |
[Fmsystem-commits] [7615] |
Date: |
Fri, 16 Sep 2011 08:15:15 +0000 |
Revision: 7615
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7615
Author: erikhl
Date: 2011-09-16 08:15:14 +0000 (Fri, 16 Sep 2011)
Log Message:
-----------
Modified Paths:
--------------
trunk/controller/inc/class.soprocedure.inc.php
trunk/controller/inc/model/class.procedure.inc.php
trunk/controller/setup/phpgw_no.lang
Added Paths:
-----------
trunk/controller/templates/base/procedure_item.xsl
Modified: trunk/controller/inc/class.soprocedure.inc.php
===================================================================
--- trunk/controller/inc/class.soprocedure.inc.php 2011-09-15 19:18:18 UTC
(rev 7614)
+++ trunk/controller/inc/class.soprocedure.inc.php 2011-09-16 08:15:14 UTC
(rev 7615)
@@ -28,21 +28,33 @@
*/
function add(&$procedure)
{
+ $cols = array(
+ 'title',
+ 'purpose',
+ 'responsibility',
+ 'description',
+ 'reference',
+ 'attachment'
+ );
+
+ $values = array(
+ $this->marshal($procedure->get_title(), 'string'),
+ $this->marshal($procedure->get_purpose(), 'string'),
+ $this->marshal($procedure->get_responsibility(),
'string'),
+ $this->marshal($procedure->get_description(), 'string'),
+ $this->marshal($procedure->get_reference(), 'string'),
+ $this->marshal($procedure->get_attachment(), 'string')
+ );
- $title = $procedure->get_title();
+ $result = $this->db->query('INSERT INTO controller_procedure ('
. join(',', $cols) . ') VALUES (' . join(',', $values) . ')',
__LINE__,__FILE__);
- $sql = "INSERT INTO controller_procedure (title) VALUES
('$title')";
- $result = $this->db->query($sql, __LINE__,__FILE__);
-
if(isset($result)) {
- // Set the new party ID
-
$procedure->set_id($this->db->get_last_insert_id('controller_procedure', 'id'));
- // Forward this request to the update method
- return $this->update($procedure);
+ // Get the new procedure ID and return it
+ return
$this->db->get_last_insert_id('controller_procedure', 'id');
}
else
{
- return false;
+ return 0;
}
}
@@ -60,13 +72,12 @@
$values = array(
'purpose = ' .
$this->marshal($procedure->get_purpose(), 'string'),
- 'responsibility = ' .
$this->marshal($procedure->get_responsibility(), 'int'),
- 'description = ' .
$this->marshal($procedure->get_description(), 'int'),
- 'reference = ' .
$this->marshal($procedure->get_reference(), 'int'),
- 'attachment = ' .
$this->marshal($procedure->get_attachment(), 'int')
+ 'responsibility = ' .
$this->marshal($procedure->get_responsibility(), 'string'),
+ 'description = ' .
$this->marshal($procedure->get_description(), 'string'),
+ 'reference = ' .
$this->marshal($procedure->get_reference(), 'string'),
+ 'attachment = ' .
$this->marshal($procedure->get_attachment(), 'string')
);
- //var_dump('UPDATE activity_activity SET ' . join(',', $values)
. " WHERE id=$id");
$result = $this->db->query('UPDATE controller_procedure SET ' .
join(',', $values) . " WHERE id=$id", __LINE__,__FILE__);
return isset($result);
@@ -155,35 +166,159 @@
protected function get_query(string $sort_field, boolean $ascending,
string $search_for, string $search_type, array $filters, boolean $return_count)
{
+ $clauses = array('1=1');
+ if($search_for)
+ {
+ $like_pattern = "'%" .
$this->db->db_addslashes($search_for) . "%'";
+ $like_clauses = array();
+ switch($search_type){
+ default:
+ $like_clauses[] = "controller_procedure
$this->like $like_pattern";
+ break;
+ }
+ if(count($like_clauses))
+ {
+ $clauses[] = '(' . join(' OR ', $like_clauses)
. ')';
+ }
+ }
+
+ $filter_clauses = array();
+ /*switch($filters['is_active']){
+ case "active":
+ $filter_clauses[] = "rental_composite.is_active
= TRUE";
+ break;
+ case "non_active":
+ $filter_clauses[] = "rental_composite.is_active
= FALSE";
+ break;
+ case "both":
+ break;
+ }*/
+ /*
+ $special_query = false; //specify if the query should use
distinct on rental_composite.id (used for selecting composites that has an
active or inactive contract)
+ $ts_query = strtotime(date('Y-m-d')); // timestamp for query
(today)
+ $availability_date_from = $ts_query;
+ $availability_date_to = $ts_query;
+ if(isset($filters['availability_date_from']) &&
$filters['availability_date_from'] != ''){
+ $availability_date_from =
strtotime($filters['availability_date_from']);
+ }
+ if(isset($filters['availability_date_to']) &&
$filters['availability_date_to'] != ''){
+ $availability_date_to =
strtotime($filters['availability_date_to']);
+ }
+ */
+ /*switch($filters['has_contract']){
+ case "has_contract":
+ $filter_clauses[] = "NOT
rental_contract_composite.contract_id IS NULL"; // Composite must have a
contract
+ $filter_clauses[] = "NOT
rental_contract.date_start IS NULL"; // The contract must have start date
+ */
+ /* The contract's start date not after the end
of the period if there is no end date */
+/* $filter_clauses[] = "
+ ((NOT rental_contract.date_start >
$availability_date_to AND rental_contract.date_end IS NULL)
+ OR
+ (NOT rental_contract.date_start >
$availability_date_to AND NOT rental_contract.date_end IS NULL AND NOT
rental_contract.date_end < $availability_date_from))";
+ $special_query=true;
+ break;
+ case "has_no_contract":
+ $filter_clauses[] = "
+ (
+ rental_contract_composite.contract_id
IS NULL OR
+ NOT rental_composite.id IN
+ (
+ SELECT rental_composite.id FROM
rental_composite
+ LEFT JOIN
rental_contract_composite ON (rental_contract_composite.composite_id =
rental_composite.id)
+ LEFT JOIN rental_contract ON
(rental_contract.id = rental_contract_composite.contract_id)
+ WHERE
+ (
+ NOT
rental_contract_composite.contract_id IS NULL AND
+ NOT
rental_contract.date_start IS NULL AND
+ ((NOT
rental_contract.date_start > $availability_date_to AND rental_contract.date_end
IS NULL)
+ OR
+ (NOT
rental_contract.date_start > $availability_date_to AND NOT
rental_contract.date_end IS NULL AND NOT rental_contract.date_end <
$availability_date_from))
+ )
+ )
+ )
+ ";
+ $special_query=true;
+ break;
+ case "both":
+ break;
+ }
+
+ // Furnished, partly furnished, not furnished, not specified
+ if(isset($filters['furnished_status']) &
$filters['furnished_status'] < 4){
+ // Not specified
+ if($filters['furnished_status'] == 0)
+ $filter_clauses[] =
"rental_composite.furnish_type_id IS NULL";
+ else
+ $filter_clauses[] =
"rental_composite.furnish_type_id=".$filters['furnished_status'];
+ }
+
+ if(isset($filters['not_in_contract'])){
+ $filter_clauses[] =
"(rental_contract_composite.contract_id != ".$filters['not_in_contract']." OR
rental_contract_composite.contract_id IS NULL)";
+ }
+
+ if(isset($filters['location_code'])){
+ $filter_clauses[] = "rental_unit.location_code = '".
$filters['location_code'] . "'";
+ }
+
+ if(isset($filters['contract_id']))
+ {
+ $filter_clauses[] = "contract_id =
{$this->marshal($filters['contract_id'],'int')}";
+ }
+
+ if(isset($filters[$this->get_id_field_name()]))
+ {
+ $filter_clauses[] = "rental_composite.id =
{$this->marshal($filters[$this->get_id_field_name()],'int')}";
+ }*/
+
+ if(isset($filters[$this->get_id_field_name()]))
+ {
+ $filter_clauses[] = "controller_procedure =
{$this->marshal($filters[$this->get_id_field_name()],'int')}";
+ }
+
+ if(count($filter_clauses))
+ {
+ $clauses[] = join(' AND ', $filter_clauses);
+ }
+
+ $condition = join(' AND ', $clauses);
+
+ $tables = "controller_procedure";
+ //$joins = " {$this->left_join} rental_unit ON
(rental_composite.id = rental_unit.composite_id)";
+ //$joins .= " {$this->left_join} rental_contract_composite ON
(rental_contract_composite.composite_id = rental_composite.id)";
+ //$joins .= " {$this->left_join} rental_contract ON
(rental_contract.id = rental_contract_composite.contract_id)";
+
+ if($return_count) // We should only return a count
+ {
+ $cols = 'COUNT(DISTINCT(controller_procedure.id)) AS
count';
+ }
+ else
+ {
+ $cols .= "controller_procedure.id AS procedure_id,
controller_procedure.title, controller_procedure.purpose,
controller_procedure.respontibility, controller_procedure.description,
controller_procedure.reference, controller_procedure.attachment ";
+ }
+ $dir = $ascending ? 'ASC' : 'DESC';
+ $order = $sort_field ? "ORDER BY {$this->marshal($sort_field,
'field')} $dir ": '';
+
+ //var_dump("SELECT {$cols} FROM {$tables} {$joins} WHERE
{$condition} {$order}");
+
+ return "SELECT {$cols} FROM {$tables} {$joins} WHERE
{$condition} {$order}";
}
function populate(int $procedure_id, &$procedure)
{
- /*
+
if($procedure == null) {
- $procedure = new activitycalendar_activity((int)
$activity_id);
+ $procedure = new controller_procedure((int)
$procedure_id);
$procedure->set_title($this->unmarshal($this->db->f('title'), 'string'));
-
$procedure->set_organization_id($this->unmarshal($this->db->f('organization_id'),
'int'));
-
$procedure->set_group_id($this->unmarshal($this->db->f('group_id'), 'int'));
-
$procedure->set_district($this->unmarshal($this->db->f('district'), 'int'));
-
$procedure->set_office($this->unmarshal($this->db->f('office'), 'int'));
-
$procedure->set_category($this->unmarshal($this->db->f('category'), 'int'));
-
$procedure->set_state($this->unmarshal($this->db->f('state'), 'int'));
-
$procedure->set_target($this->unmarshal($this->db->f('target'), 'string'));
+
$procedure->set_purpose($this->unmarshal($this->db->f('purpose'), 'string'));
+
$procedure->set_responsibility($this->unmarshal($this->db->f('responsibility'),
'string'));
$procedure->set_description($this->unmarshal($this->db->f('description'),
'string'));
-
$procedure->set_arena($this->unmarshal($this->db->f('arena'), 'string'));
-
$procedure->set_internal_arena($this->unmarshal($this->db->f('internal_arena'),
'string'));
-
$procedure->set_time($this->unmarshal($this->db->f('time'), 'string'));
-
$procedure->set_last_change_date($this->unmarshal($this->db->f('last_change_date'),
'int'));
-
$procedure->set_special_adaptation($this->unmarshal($this->db->f('special_adaptation',
'bool')));
-
$procedure->set_secret($this->unmarshal($this->db->f('secret'), 'string'));
-
-
+
$procedure->set_reference($this->unmarshal($this->db->f('reference'),
'string'));
+
$procedure->set_attachment($this->unmarshal($this->db->f('attachment'),
'string'));
}
- */
+
return $procedure;
}
Modified: trunk/controller/inc/model/class.procedure.inc.php
===================================================================
--- trunk/controller/inc/model/class.procedure.inc.php 2011-09-15 19:18:18 UTC
(rev 7614)
+++ trunk/controller/inc/model/class.procedure.inc.php 2011-09-16 08:15:14 UTC
(rev 7615)
@@ -81,10 +81,38 @@
public static function get_so()
{
if (self::$so == null) {
- self::$so =
CreateObject('controller.sopurpose');
+ self::$so =
CreateObject('controller.soprocedure');
}
return self::$so;
}
+
+ public function toArray()
+ {
+
+// Alternative 1
+// return get_object_vars($this);
+
+// Alternative 2
+ $exclude = array
+ (
+ 'get_field', // feiler (foreldreklassen)
+ 'get_so',//unødvendig
+ );
+
+ $class_methods = get_class_methods($this);
+ $procedure_arr = array();
+ foreach ($class_methods as $class_method)
+ {
+ if( stripos($class_method , 'get_' ) === 0 &&
!in_array($class_method, $exclude))
+ {
+ $_class_method_part = explode('get_',
$class_method);
+ $procedure_arr[$_class_method_part[1]]
= $this->$class_method();
+ }
+ }
+
+// _debug_array($procedure_arr);
+ return $procedure_arr;
+ }
}
?>
\ No newline at end of file
Modified: trunk/controller/setup/phpgw_no.lang
===================================================================
--- trunk/controller/setup/phpgw_no.lang 2011-09-15 19:18:18 UTC (rev
7614)
+++ trunk/controller/setup/phpgw_no.lang 2011-09-16 08:15:14 UTC (rev
7615)
@@ -628,4 +628,13 @@
your_notifications controller no Dine varsler
control_items controller no Kontrollpunkt
Control_item controller no Kontrollpunkt
-
+Procedure controller no Prosedyre
+Procedures controller no Prosedyrer
+Procedure title controller no Navn
+t_new_procedure controller no Ny prosedyre
+f_new_procedure controller no Legg til
+Procedure purpose controller no Formål
+Procedure responsibility controller no Ansvarlig
+Procedure description controller no Beskrivelse
+Procedure reference controller no Referanse
+Procedure attachment controller no Vedlegg
Added: trunk/controller/templates/base/procedure_item.xsl
===================================================================
--- trunk/controller/templates/base/procedure_item.xsl
(rev 0)
+++ trunk/controller/templates/base/procedure_item.xsl 2011-09-16 08:15:14 UTC
(rev 7615)
@@ -0,0 +1,114 @@
+<!-- item -->
+
+<xsl:template match="data" xmlns:php="http://php.net/xsl">
+
+<xsl:call-template name="yui_booking_i18n"/>
+<div class="identifier-header">
+<h1><img src="{img_go_home}" />
+ <xsl:value-of select="php:function('lang', 'Procedure')" />
+</h1>
+</div>
+
+<div class="yui-content">
+ <div id="details">
+ <form action="#" method="post">
+ <input type="hidden" name="id" value =
"{value_id}">
+ </input>
+ <dl class="proplist-col">
+ <dt>
+ <label
for="title"><xsl:value-of select="php:function('lang','Procedure title')"
/></label>
+ </dt>
+ <dd>
+ <xsl:choose>
+ <xsl:when test="editable">
+ <input type="text"
name="title" id="title" value="{procedure/title}" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of
select="procedure/title" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </dd>
+ <dt>
+ <label
for="purpose"><xsl:value-of select="php:function('lang','Procedure purpose')"
/></label>
+ </dt>
+ <dd>
+ <xsl:choose>
+ <xsl:when test="editable">
+ <textarea id="purpose"
name="purpose" rows="5" cols="60"><xsl:value-of select="procedure/purpose"
/></textarea>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of
select="procedure/purpose" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </dd>
+ <dt>
+ <label
for="responsibility"><xsl:value-of select="php:function('lang','Procedure
responsibility')" /></label>
+ </dt>
+ <dd>
+ <xsl:choose>
+ <xsl:when test="editable">
+ <textarea
id="responsibility" name="responsibility" rows="5" cols="60"><xsl:value-of
select="procedure/responsibility" /></textarea>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of
select="procedure/responsibility" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </dd>
+ <dt>
+ <label
for="description"><xsl:value-of select="php:function('lang','Procedure
description')" /></label>
+ </dt>
+ <dd>
+ <xsl:choose>
+ <xsl:when test="editable">
+ <textarea
id="description" name="description" rows="5" cols="60"><xsl:value-of
select="procedure/description" /></textarea>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of
select="procedure/description" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </dd>
+ <dt>
+ <label
for="reference"><xsl:value-of select="php:function('lang','Procedure
Reference')" /></label>
+ </dt>
+ <dd>
+ <xsl:choose>
+ <xsl:when test="editable">
+ <input type="text"
name="reference" id="reference" value="{procedure/reference}" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of
select="procedure/reference" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </dd>
+ <dt>
+ <label for="attachment"><xsl:value-of
select="php:function('lang','Procedure Attachment')" /></label>
+ </dt>
+ <dd>
+ <xsl:choose>
+ <xsl:when test="editable">
+ <input type="text"
name="attachment" id="attachment" value="{procedure/attachment}" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of
select="procedure/attachment" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </dd>
+ </dl>
+
+ <div class="form-buttons">
+ <xsl:choose>
+ <xsl:when test="editable">
+ <xsl:variable
name="lang_save"><xsl:value-of select="php:function('lang', 'save')"
/></xsl:variable>
+ <input type="submit"
name="save_procedure" value="{$lang_save}" title = "{$lang_save}" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable
name="lang_edit"><xsl:value-of select="php:function('lang', 'edit')"
/></xsl:variable>
+ <input type="submit"
name="edit_procedure" value="{$lang_edit}" title = "{$lang_edit}" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </div>
+ </form>
+
+ </div>
+ </div>
+</xsl:template>
\ No newline at end of file
Property changes on: trunk/controller/templates/base/procedure_item.xsl
___________________________________________________________________
Added: svn:mime-type
+ text/plain
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [7615],
Erik Holm-Larsen <=