[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [8353] Merge 8283:8352 from trunk
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [8353] Merge 8283:8352 from trunk |
Date: |
Fri, 16 Dec 2011 22:20:42 +0000 |
Revision: 8353
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8353
Author: sigurdne
Date: 2011-12-16 22:20:41 +0000 (Fri, 16 Dec 2011)
Log Message:
-----------
Merge 8283:8352 from trunk
Modified Paths:
--------------
branches/Version-1_0-branch/activitycalendarfrontend/inc/class.uiactivity.inc.php
branches/Version-1_0-branch/activitycalendarfrontend/setup/phpgw_no.lang
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/activity_new.php
branches/Version-1_0-branch/addressbook/inc/class.uiaddressbook.inc.php
branches/Version-1_0-branch/controller/images/arrow_left.png
branches/Version-1_0-branch/controller/images/status_icon_red.png
branches/Version-1_0-branch/controller/images/status_icon_yellow.png
branches/Version-1_0-branch/controller/inc/class.cat_hooks.inc.php
branches/Version-1_0-branch/controller/inc/class.menu.inc.php
branches/Version-1_0-branch/controller/inc/class.socheck_list.inc.php
branches/Version-1_0-branch/controller/inc/class.uicheck_list.inc.php
branches/Version-1_0-branch/controller/inc/class.uicheck_list_for_location.inc.php
branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php
branches/Version-1_0-branch/controller/inc/class.uilocation_check_list.inc.php
branches/Version-1_0-branch/controller/js/controller/ajax.js
branches/Version-1_0-branch/controller/js/controller/custom_ui.js
branches/Version-1_0-branch/controller/js/yahoo/common.js
branches/Version-1_0-branch/controller/js/yahoo/datatable.js
branches/Version-1_0-branch/controller/setup/phpgw_no.lang
branches/Version-1_0-branch/controller/setup/setup.inc.php
branches/Version-1_0-branch/controller/templates/base/common.xsl
branches/Version-1_0-branch/controller/templates/base/control.xsl
branches/Version-1_0-branch/controller/templates/base/css/base.css
branches/Version-1_0-branch/controller/templates/base/edit_check_list.xsl
branches/Version-1_0-branch/phpgwapi/setup/setup.inc.php
branches/Version-1_0-branch/phpgwapi/setup/tables_current.inc.php
branches/Version-1_0-branch/phpgwapi/setup/tables_update.inc.php
branches/Version-1_0-branch/phpgwapi/templates/portico/head.inc.php
branches/Version-1_0-branch/property/inc/class.bocommon.inc.php
branches/Version-1_0-branch/property/inc/class.bolookup.inc.php
branches/Version-1_0-branch/property/inc/class.boproject.inc.php
branches/Version-1_0-branch/property/inc/class.uientity.inc.php
branches/Version-1_0-branch/property/inc/class.uilocation.inc.php
branches/Version-1_0-branch/property/inc/class.uilookup.inc.php
branches/Version-1_0-branch/property/inc/class.uiproject.inc.php
branches/Version-1_0-branch/property/inc/class.uiworkorder.inc.php
branches/Version-1_0-branch/property/js/yahoo/lookup.vendor.index.js
branches/Version-1_0-branch/property/js/yahoo/project.edit.js
branches/Version-1_0-branch/property/js/yahoo/property2.js
branches/Version-1_0-branch/property/js/yahoo/tts.view.js
branches/Version-1_0-branch/property/setup/phpgw_no.lang
branches/Version-1_0-branch/property/templates/base/project.xsl
branches/Version-1_0-branch/property/templates/base/workorder.xsl
Added Paths:
-----------
branches/Version-1_0-branch/controller/images/arrow_right.png
branches/Version-1_0-branch/controller/images/status_icon_red_cross.png
branches/Version-1_0-branch/controller/images/status_icon_red_empty.png
branches/Version-1_0-branch/controller/images/status_icon_yellow.psd
branches/Version-1_0-branch/controller/inc/class.sodocument.inc.php
branches/Version-1_0-branch/controller/inc/class.uidocument.inc.php
branches/Version-1_0-branch/controller/inc/component/
branches/Version-1_0-branch/controller/inc/model/class.document.inc.php
branches/Version-1_0-branch/controller/js/controller/jquery-ui.custom.min.js
branches/Version-1_0-branch/controller/templates/base/add_check_list_for_location.xsl
branches/Version-1_0-branch/controller/templates/base/css/images/
branches/Version-1_0-branch/controller/templates/base/css/jquery-ui.custom.css
branches/Version-1_0-branch/controller/templates/base/view_calendar_month.xsl
branches/Version-1_0-branch/controller/templates/base/view_calendar_year.xsl
branches/Version-1_0-branch/property/inc/class.notify.inc.php
branches/Version-1_0-branch/property/js/yahoo/notify.js
branches/Version-1_0-branch/property/templates/base/event_view.xsl
Removed Paths:
-------------
branches/Version-1_0-branch/controller/js/yahoo/example_edit.js
branches/Version-1_0-branch/controller/js/yahoo/example_normal_tabs.js
branches/Version-1_0-branch/controller/js/yahoo/example_separate_tabs.js
branches/Version-1_0-branch/controller/templates/base/common.php
branches/Version-1_0-branch/controller/templates/base/view_agg_check_lists_for_location_month.xsl
branches/Version-1_0-branch/controller/templates/base/view_agg_check_lists_for_location_year.xsl
Property Changed:
----------------
branches/Version-1_0-branch/
Property changes on: branches/Version-1_0-branch
___________________________________________________________________
Modified: svn:mergeinfo
-
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264,7266-7273,7275-7279,7281-7332,7334-7338,7340-7348,7350,7352-7353,7355-7361,7363-7366,7368-7370,7372,7374,7376,7378,7380-7386,7388-7400,7402,7404-7433,7435-7439,7441-7446,7448-7458,7460-7469,7471-7483,7485-7487,7489-7490,7492,7494,7496-7497,7499,7501-7502,7504,7506-7507,7509-7511,7513-7517,7519-7521,7523,7525,7527-7529,7531,7533,7535-7538,7540-7542,7544-7549,7551-7552,7554-7561,7563,7565,7567-7573,7575-7578,7580-7584,7586-7591,7593-7624,7627-7636,7638-7656,7658-7718,7720-7732,7734,7736,7738-7750,7754-7759,7761-7767,7769-7780,7782,7784-7809,7811-7812,7814-7835,7837-7847,7849-7887,7889-7895,7897,7899,7901,7903-7905,7907-7921,7923-7925,7927-7933,7935,7937-7952,7954-7968,7970-7974,7976,7978-7979,7981-7982,7984-7988,7990-7992,7994-8041,8043-8066,8068-8087,8089,8091-8108,8110-8124,8126-8129,8131,8133-8150,8152-8154,8156-8162,8164-8167,8169-8170,8172-8179,8181,8183-8196,8198-8207,8209-8211,8213-8214,8216-8217,8219-8220,8222,8224-8225,8227-8247,8249,8251,8253-8282
+
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264,7266-7273,7275-7279,7281-7332,7334-7338,7340-7348,7350,7352-7353,7355-7361,7363-7366,7368-7370,7372,7374,7376,7378,7380-7386,7388-7400,7402,7404-7433,7435-7439,7441-7446,7448-7458,7460-7469,7471-7483,7485-7487,7489-7490,7492,7494,7496-7497,7499,7501-7502,7504,7506-7507,7509-7511,7513-7517,7519-7521,7523,7525,7527-7529,7531,7533,7535-7538,7540-7542,7544-7549,7551-7552,7554-7561,7563,7565,7567-7573,7575-7578,7580-7584,7586-7591,7593-7624,7627-7636,7638-7656,7658-7718,7720-7732,7734,7736,7738-7750,7754-7759,7761-7767,7769-7780,7782,7784-7809,7811-7812,7814-7835,7837-7847,7849-7887,7889-7895,7897,7899,7901,7903-7905,7907-7921,7923-7925,7927-7933,7935,7937-7952,7954-7968,7970-7974,7976,7978-7979,7981-7982,7984-7988,7990-7992,7994-8041,8043-8066,8068-8087,8089,8091-8108,8110-8124,8126-8129,8131,8133-8150,8152-8154,8156-8162,8164-8167,8169-8170,8172-8179,8181,8183-8196,8198-8207,8209-8211,8213-8214,8216-8217,8219-8220,8222,8224-8225,8227-8247,8249,8251,8253-8282,8284-8352
Modified:
branches/Version-1_0-branch/activitycalendarfrontend/inc/class.uiactivity.inc.php
===================================================================
---
branches/Version-1_0-branch/activitycalendarfrontend/inc/class.uiactivity.inc.php
2011-12-16 18:33:20 UTC (rev 8352)
+++
branches/Version-1_0-branch/activitycalendarfrontend/inc/class.uiactivity.inc.php
2011-12-16 22:20:41 UTC (rev 8353)
@@ -9,6 +9,7 @@
include_class('activitycalendar', 'activity', 'inc/model/');
include_class('activitycalendar', 'group', 'inc/model/');
include_class('activitycalendar', 'organization', 'inc/model/');
+ include_class('activitycalendar', 'arena', 'inc/model/');
class activitycalendarfrontend_uiactivity extends
activitycalendar_uiactivities
{
@@ -235,11 +236,33 @@
}
}
+ if(strlen($desc) > 254)
+ {
+ $desc = substr($desc,0,254);
+ }
+
+ $arena_id = phpgw::get_var('arena_id');
+ if($arena_id != null && $arena_id ==
'new_arena')
+ {
+ $arena = new activitycalendar_arena();
+ $arena_name =
phpgw::get_var('arena_name');
+ $arena_address =
phpgw::get_var('arena_address') . ' ' . phpgw::get_var('arena_number') . ', ' .
phpgw::get_var('arena_postaddress');
+
+ $arena->set_arena_name($arena_name);
+ $arena->set_address($arena_address);
+ $arena->set_active(true);
+
+ // All is good, store arena
+ if ($this->so_arena->store($arena)) {
+ $arena_id = $arena->get_id();
+ }
+ }
+
//... set all parameters
$activity->set_title(phpgw::get_var('title'));
$activity->set_organization_id($o_id);
$activity->set_group_id($g_id);
-
$activity->set_arena(phpgw::get_var('arena_id'));
+ $activity->set_arena($arena_id);
$activity->set_internal_arena(phpgw::get_var('internal_arena_id'));
$district_array = phpgw::get_var('district');
$activity->set_district(implode(",",
$district_array));
@@ -462,6 +485,10 @@
$desc =
$this->so_organization->get_description($activity->get_organization_id());
$person_ids =
$this->so_organization->get_contacts($activity->get_organization_id());
}
+ if(strlen($desc) > 254)
+ {
+ $desc = substr($desc,0,254);
+ }
$organization =
$this->so_organization->get_single($activity->get_organization_id());
if(isset($_POST['save_activity'])) //
The user has pressed the save button
Modified:
branches/Version-1_0-branch/activitycalendarfrontend/setup/phpgw_no.lang
===================================================================
--- branches/Version-1_0-branch/activitycalendarfrontend/setup/phpgw_no.lang
2011-12-16 18:33:20 UTC (rev 8352)
+++ branches/Version-1_0-branch/activitycalendarfrontend/setup/phpgw_no.lang
2011-12-16 22:20:41 UTC (rev 8353)
@@ -69,7 +69,8 @@
what activitycalendarfrontend no HVA
where_when activitycalendarfrontend no HVOR/NÅR
who activitycalendarfrontend no HVEM
-arena_helptext activitycalendarfrontend no Oppgi arena ved å velge
kommunalt bygg eller eksterne bygg.
+arena_helptext activitycalendarfrontend no Oppgi arena ved å velge
kommunalt bygg eller eksterne bygg.<br/>Dersom ikke arena som skal benyttes
finnes i listen, kan du registrere en ny.<br/>Velg "Ny arena" i nedtrekksmenyen
for Eksterne bygg og oppgi deretter riktig navn og adresse på arenaen.
+new_arena activitycalendarfrontend no Ny Arena
external_arena activitycalendarfrontend no Eksterne bygg
category_helptext activitycalendarfrontend no Velg kategori
target_helptext activitycalendarfrontend no Velg
målgruppe(r)
@@ -88,4 +89,5 @@
edit_activity activitycalendarfrontend no Endre aktivitet
activity_edit_helptext activitycalendarfrontend no Velg
aktiviteten du ønsker å endre fra listen under.
send_change_request activitycalendarfrontend no Send inn
endringsønske
-edit_organization activitycalendarfrontend no Rediger
organisasjonsinformasjon
\ No newline at end of file
+edit_organization activitycalendarfrontend no Rediger
organisasjonsinformasjon
+address activitycalendarfrontend no Adresse
\ No newline at end of file
Modified:
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/activity_new.php
===================================================================
---
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/activity_new.php
2011-12-16 18:33:20 UTC (rev 8352)
+++
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/activity_new.php
2011-12-16 22:20:41 UTC (rev 8353)
@@ -20,6 +20,19 @@
}
}
+function checkNewArena()
+{
+ var arena_selected = document.getElementById('arena_id').value;
+ if(arena_selected == 'new_arena')
+ {
+ document.getElementById('new_arena_fields').style.display =
"block";
+ }
+ else
+ {
+ document.getElementById('new_arena_fields').style.display =
"none";
+ }
+}
+
function get_address_search()
{
var address = document.getElementById('address_txt').value;
@@ -42,6 +55,28 @@
}
+function get_address_search_arena()
+{
+ var address = document.getElementById('arena_address_txt').value;
+ var div_address = document.getElementById('arena_address_container');
+
+ url =
"index.php?menuaction=activitycalendarfrontend.uiactivity.get_address_search&phpgw_return_as=json&search="
+ address;
+
+var divcontent_start = "<select name=\"arena_address\" id=\"arena_address\"
size\"5\">";
+var divcontent_end = "</select>";
+
+ var callback = {
+ success: function(response){
+ div_address.innerHTML =
divcontent_start + JSON.parse(response.responseText) + divcontent_end;
+ },
+ failure: function(o) {
+ alert("AJAX doesn't work"); //FAILURE
+ }
+ }
+ var trans = YAHOO.util.Connect.asyncRequest('GET', url, callback, null);
+
+}
+
function get_address_search_cp2()
{
var address = document.getElementById('contact2_address_txt').value;
@@ -64,12 +99,19 @@
}
+function run_checks()
+{
+ check_external();
+ checkNewArena();
+}
+
function check_internal()
{
if(document.getElementById('internal_arena_id').value != null &&
document.getElementById('internal_arena_id').value > 0)
{
//disable external arena drop-down
document.getElementById('arena_id').disabled="disabled";
+ document.getElementById('new_arena_fields').style.display =
"none";
}
else
{
@@ -80,7 +122,7 @@
function check_external()
{
- if(document.getElementById('arena_id').value != null &&
document.getElementById('arena_id').value > 0)
+ if(document.getElementById('arena_id').value != null &&
(document.getElementById('arena_id').value > 0 ||
document.getElementById('arena_id').value == 'new_arena'))
{
//disable internal arena drop-down
document.getElementById('internal_arena_id').disabled="disabled";
@@ -89,6 +131,7 @@
{
//enable internal arena drop-down
document.getElementById('internal_arena_id').disabled="";
+ document.getElementById('new_arena_fields').style.display =
"none";
}
}
@@ -236,8 +279,9 @@
<?php
$current_arena_id =
$activity->get_arena();
?>
- <select name="arena_id" id="arena_id"
onchange="javascript: check_external();">
+ <select name="arena_id" id="arena_id"
onchange="javascript: run_checks();">
<option value="0">Ingen arena
valgt</option>
+ <option value="new_arena">Ny
arena</option>
<?php
foreach($arenas as $arena)
{
@@ -246,6 +290,20 @@
?>
</select>
</dd>
+ <span id="new_arena_fields" style="display:
none;">
+ <dt>
+ <label for="new_arena"><?php
echo lang('new_arena') ?></label>
+ </dt>
+ <dt><label for="arena_name"><?php echo
lang('name') ?></label></dt>
+ <dd><input type="text"
name="arena_name" id="arena_name" /></dd>
+ <dt><label for="arena_address"><?php
echo lang('address') ?></label></dt>
+ <dd><input type="text"
name="arena_address_txt" id="arena_address_txt"
onkeyup="javascript:get_address_search_arena()"/>
+ <div id="arena_address_container"></div>
+ <label for="arena_number">Nummer</label>
+ <input type="text"
name="arena_number"/><br/>
+ <label
for="arena_postaddress">Postnummer og Sted</label>
+ <input type="text"
name="arena_postaddress"/></dd>
+ </span>
<dt>
<label for="time"><?php echo
lang('time') ?></label>
</dt>
Modified:
branches/Version-1_0-branch/addressbook/inc/class.uiaddressbook.inc.php
===================================================================
--- branches/Version-1_0-branch/addressbook/inc/class.uiaddressbook.inc.php
2011-12-16 18:33:20 UTC (rev 8352)
+++ branches/Version-1_0-branch/addressbook/inc/class.uiaddressbook.inc.php
2011-12-16 22:20:41 UTC (rev 8353)
@@ -136,7 +136,7 @@
$this->tab_address = lang('Address');
$this->tab_others = lang('Others');
$this->tab_extra = lang('More data');
-
+ $this->nonavbar =
phpgw::get_var('nonavbar','bool');
$this->_set_sessiondata();
}
@@ -202,11 +202,11 @@
$tabs = array();
$tabs[] = array(
'label' => lang('persons'),
- 'link' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction' =>
'addressbook.uiaddressbook.index', 'section' => $this->tab_main_persons))
+ 'link' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction' =>
'addressbook.uiaddressbook.index', 'section' => $this->tab_main_persons,
'nonavbar' => $this->nonavbar))
);
$tabs[] = array(
'label' => lang('Organizations'),
- 'link' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction' =>
'addressbook.uiaddressbook.index', 'section' => $this->tab_main_organizations))
+ 'link' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction' =>
'addressbook.uiaddressbook.index', 'section' => $this->tab_main_organizations,
'nonavbar' => $this->nonavbar))
);
switch($this->section)
@@ -306,7 +306,7 @@
$count_function = 'get_count_persons';
$get_data_function = 'get_persons';
- $this->template->set_var('add_url',
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'addressbook.uiaddressbook.add_person')));
+ $this->template->set_var('add_url',
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'addressbook.uiaddressbook.add_person', 'nonavbar' => $this->nonavbar)));
$search_obj=array('query' => $this->query,
'search_obj' => array(
@@ -336,7 +336,7 @@
$count_function = 'get_count_orgs';
$get_data_function = 'get_orgs';
-
$this->template->set_var('add_url',$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>'addressbook.uiaddressbook.add_org')));
+
$this->template->set_var('add_url',$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>'addressbook.uiaddressbook.add_org',
'nonavbar' => $this->nonavbar)));
$search_obj=array('query' => $this->query,
'search_obj' => array(
@@ -395,7 +395,7 @@
$cols .= '<td>';
$cols .=
$GLOBALS['phpgw']->nextmatchs->show_sort_order($this->sort,
$column[0],$this->order,"/index.php",$showcol,
-
'&menuaction=addressbook.uiaddressbook.index§ion='.$this->section.'&fcat_id='.$this->cat_id);
+
'&menuaction=addressbook.uiaddressbook.index§ion='.$this->section.'&fcat_id='.$this->cat_id.'&nonavbar='.$this->nonavbar);
$cols .= '</td>';
$cols .= "\n";
}
@@ -406,18 +406,18 @@
$cols .= '<td>';
$cols .=
$GLOBALS['phpgw']->nextmatchs->show_sort_order($this->sort,
$column[0],$this->order,"/index.php",$showcol,
-
'&menuaction=addressbook.uiaddressbook.index§ion='.$this->section.'&fcat_id='.$this->cat_id);
+
'&menuaction=addressbook.uiaddressbook.index§ion='.$this->section.'&fcat_id='.$this->cat_id
.'&nonavbar='.$this->nonavbar);
$cols .= '</td>';
$cols .= "\n";
}
/* set basic vars and parse the header */
//$this->template->set_var('principal_tab',$this->get_principal_tabs($this->section));
- $this->get_principal_tabs( array('menuaction' =>
'addressbook.uiaddressbook.index', 'section' => $this->tab_main_persons),
+ $this->get_principal_tabs( array('menuaction' =>
'addressbook.uiaddressbook.index', 'section' => $this->tab_main_persons,
'nonavbar' => $this->nonavbar),
$this->get_class_css($this->tab_main_persons, $this->section),
$this->tab_main_persons);
- $this->get_principal_tabs( array('menuaction' =>
'addressbook.uiaddressbook.index', 'section' => $this->tab_main_organizations),
+ $this->get_principal_tabs( array('menuaction' =>
'addressbook.uiaddressbook.index', 'section' => $this->tab_main_organizations,
'nonavbar' => $this->nonavbar),
$this->get_class_css($this->tab_main_organizations, $this->section),
$this->tab_main_organizations);
@@ -428,7 +428,7 @@
//FIXME make show_tpl stop using theme values
$search_filter = $this->nextmatchs->show_tpl(
'/index.php', $this->start, $total_all_persons,
- array('menuaction' =>
'addressbook.uiaddressbook.index', 'section' => $this->section),
+ array('menuaction' =>
'addressbook.uiaddressbook.index', 'section' => $this->section, 'nonavbar' =>
$this->nonavbar),
'90%', '',
$search_obj,1,True,array('filter'=>$this->filter,'yours'=>1),$this->cat_id);
$query = $filter = '';
@@ -457,22 +457,22 @@
$this->template->set_var('lang_showing',$lang_showing);
$this->template->set_var('search_filter',$search_filter);
$this->template->set_var('cats',lang('Category'));
-
$this->template->set_var('cats_url',$GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'addressbook.uiaddressbook.index', 'section' =>
$this->section)));
+
$this->template->set_var('cats_url',$GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'addressbook.uiaddressbook.index', 'section' =>
$this->section, 'nonavbar' => $this->nonavbar)));
/*
$this->template->set_var('cats_link',$this->cat_option($this->cat_id)); */
$this->template->set_var('lang_cats',lang('Select'));
//
$this->template->set_var('lang_addressbook',lang('Address book'));
$this->template->set_var('lang_add',lang('Add'));
$this->template->set_var('lang_cat_cont',lang('Categorize'));
- $this->template->set_var('cat_cont_url',
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'addressbook.uicategorize_contacts.index')));
+ $this->template->set_var('cat_cont_url',
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'addressbook.uicategorize_contacts.index', 'nonavbar' => $this->nonavbar)));
$this->template->set_var('lang_addvcard',lang('AddVCard'));
-
$this->template->set_var('vcard_url',$GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'addressbook.uivcard.in')));
+
$this->template->set_var('vcard_url',$GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'addressbook.uivcard.in', 'nonavbar' =>
$this->nonavbar)));
$this->template->set_var('lang_import',lang('Import Contacts'));
-
$this->template->set_var('import_url',$GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'addressbook.uiXport.import')));
+
$this->template->set_var('import_url',$GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'addressbook.uiXport.import', 'nonavbar' =>
$this->nonavbar)));
$this->template->set_var('lang_import_alt',lang('Alt. CSV
Import'));
$this->template->set_var('import_alt_url',$GLOBALS['phpgw']->link('/addressbook/csv_import.php'));
$this->template->set_var('lang_export',lang('Export Contacts'));
-
$this->template->set_var('export_url',$GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'addressbook.uiXport.export')));
+
$this->template->set_var('export_url',$GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'addressbook.uiXport.export', 'nonavbar' =>
$this->nonavbar)));
$export_vars = array
(
@@ -529,7 +529,7 @@
if ( is_array($org_data) &&
count($org_data) )
{
$ref = '<a href="' .
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>'addressbook.uiaddressbook.view_org',
-
'ab_id'=>$org_data[0]['my_org_id'])) . '">' ;
+
'ab_id'=>$org_data[0]['my_org_id'], 'nonavbar' => $this->nonavbar)) . '">' ;
}
else
{
@@ -539,7 +539,7 @@
else
{
$ref = '<a href="' .
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>'addressbook.uiaddressbook.view_org',
-
'ab_id'=>
$myid)) . '">' ;
+
'ab_id'=>
$myid, 'nonavbar' => $this->nonavbar)) . '">' ;
}
$data =
htmlspecialchars($coldata) . '</a>';
}
@@ -573,13 +573,13 @@
$this->template->set_var('col_data',$ref.$data);
$this->template->parse('columns','column',True);
}
-
$this->template->set_var('row_view_link',$GLOBALS['phpgw']->link('/index.php',
array('menuaction' => "addressbook.uiaddressbook.{$this->view_mode}", 'ab_id'
=> $entry['contact_id'] ) ) );
-
$this->template->set_var('row_vcard_link',$GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'addressbook.uivcard.out', 'ab_id' =>
$entry['contact_id'] ) ) );
+
$this->template->set_var('row_view_link',$GLOBALS['phpgw']->link('/index.php',
array('menuaction' => "addressbook.uiaddressbook.{$this->view_mode}", 'ab_id'
=> $entry['contact_id'], 'nonavbar' => $this->nonavbar ) ) );
+
$this->template->set_var('row_vcard_link',$GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'addressbook.uivcard.out', 'ab_id' =>
$entry['contact_id'], 'nonavbar' => $this->nonavbar ) ) );
if($this->bo->check_edit($entry['contact_id'],
$myowner))
{
$this->template->set_var('row_edit','<a href="'
- . $GLOBALS['phpgw']->link('/index.php',
array('menuaction' => "addressbook.uiaddressbook.{$this->edit_mode}", 'ab_id'
=> $entry['contact_id']) )
+ . $GLOBALS['phpgw']->link('/index.php',
array('menuaction' => "addressbook.uiaddressbook.{$this->edit_mode}", 'ab_id'
=> $entry['contact_id'], 'nonavbar' => $this->nonavbar) )
. '">' . lang('Edit') . '</a>');
}
else
@@ -615,7 +615,7 @@
{
$contact_id = phpgw::get_var('ab_id');
$new_contact_id = $this->bo->copy_contact($contact_id);
- $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'addressbook.uiaddressbook.edit_person', 'ab_id' =>
$new_contact_id));
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'addressbook.uiaddressbook.edit_person', 'ab_id' =>
$new_contact_id, 'nonavbar' => $this->nonavbar));
}
/*************************************************************\
@@ -633,8 +633,8 @@
//set some variables which will be used
$this->mode = 'add';
$this->section = $this->tab_main_persons;
- $this->form_action = array('menuaction' =>
'addressbook.uiaddressbook.add_person');
- $this->form_index = array('menuaction' =>
'addressbook.uiaddressbook.index', 'section' => $this->section);
+ $this->form_action = array('menuaction' =>
'addressbook.uiaddressbook.add_person', 'nonavbar' => $this->nonavbar);
+ $this->form_index = array('menuaction' =>
'addressbook.uiaddressbook.index', 'section' => $this->section, 'nonavbar' =>
$this->nonavbar);
//get all vars which was send in post or get
$this->get_vars();
@@ -666,6 +666,13 @@
{
case 'save':
$fields = $this->get_all_entry();
+
+
if(!$fields['tab_person_data']['per_first_name'] &&
!$fields['tab_person_data']['per_last_name'])
+ {
+ $message ='Need at least First Name or
Last Name';
+ phpgwapi_cache::message_set($message,
'error');
+ break;
+ }
$fields['owner'] =
$GLOBALS['phpgw_info']['user']['account_id'];
@@ -674,7 +681,7 @@
(
'menuaction' =>
'addressbook.uiaddressbook.view_person',
'ab_id' =>
$ab_id,
- 'referer' =>
$this->referer
+ 'referer' =>
$this->referer, 'nonavbar' => $this->nonavbar
));
$GLOBALS['phpgw']->common->phpgw_exit();
break;
@@ -712,8 +719,8 @@
//set some variables which will be used
$this->mode = 'edit';
$this->section = $this->tab_main_persons;
- $this->form_action = array('menuaction' =>
'addressbook.uiaddressbook.edit_person');
- $this->form_index = array('menuaction' =>
'addressbook.uiaddressbook.index', 'section' => $this->section);
+ $this->form_action = array('menuaction' =>
'addressbook.uiaddressbook.edit_person', 'nonavbar' => $this->nonavbar);
+ $this->form_index = array('menuaction' =>
'addressbook.uiaddressbook.index', 'section' => $this->section, 'nonavbar' =>
$this->nonavbar);
//get all vars which was send in post or get
$this->get_vars();
@@ -763,7 +770,8 @@
(
'menuaction' =>
'addressbook.uiaddressbook.view_person',
'ab_id' => $this->contact_id,
- 'referer' => $this->referer
+ 'referer' => $this->referer,
+ 'nonavbar' => $this->nonavbar
));
break;
case 'cancel':
@@ -774,7 +782,8 @@
array
(
'menuaction' =>
'addressbook.uiaddressbook.delete_person',
- 'ab_id' => $this->contact_id
+ 'ab_id' => $this->contact_id,
+ 'nonavbar' => $this->nonavbar
));
//$this->delete_person($this->contact_id);
break;
@@ -835,7 +844,8 @@
$GLOBALS['phpgw']->redirect_link('/index.php', array
(
'menuaction' =>
'addressbook.uiaddressbook.edit_person',
- 'ab_id' => $new_contact_id
+ 'ab_id' => $new_contact_id,
+ 'nonavbar' => $this->nonavbar
));
}
@@ -854,8 +864,8 @@
//set some variables which will be used
$this->mode = 'add';
$this->section = $this->tab_main_organizations;
- $this->form_action = array('menuaction' =>
'addressbook.uiaddressbook.add_org');
- $this->form_index = array('menuaction' =>
'addressbook.uiaddressbook.index', 'section' => $this->section);
+ $this->form_action = array('menuaction' =>
'addressbook.uiaddressbook.add_org', 'nonavbar' => $this->nonavbar);
+ $this->form_index = array('menuaction' =>
'addressbook.uiaddressbook.index', 'section' => $this->section, 'nonavbar' =>
$this->nonavbar);
//get all vars which was send in post or get
$this->get_vars();
@@ -893,7 +903,8 @@
$GLOBALS['phpgw']->redirect_link('/index.php',
array
(
'menuaction' =>
'addressbook.uiaddressbook.view_org',
- 'ab_id' =>
$ab_id
+ 'ab_id' =>
$ab_id,
+ 'nonavbar' => $this->nonavbar
));
break;
case 'cancel':
@@ -930,8 +941,8 @@
//set some variables which will be used
$this->mode = 'edit';
$this->section = $this->tab_main_organizations;
- $this->form_action =
array('menuaction'=>'addressbook.uiaddressbook.edit_org');
- $this->form_index =
array('menuaction'=>'addressbook.uiaddressbook.index','section'=>$this->section);
+ $this->form_action =
array('menuaction'=>'addressbook.uiaddressbook.edit_org', 'nonavbar' =>
$this->nonavbar);
+ $this->form_index =
array('menuaction'=>'addressbook.uiaddressbook.index','section'=>$this->section,
'nonavbar' => $this->nonavbar);
//get all vars which was send in post or get
$this->get_vars();
@@ -969,7 +980,8 @@
$GLOBALS['phpgw']->redirect_link('/index.php',
array
(
'menuaction' =>
'addressbook.uiaddressbook.view_org',
- 'ab_id' =>
$this->contact_id
+ 'ab_id' =>
$this->contact_id,
+ 'nonavbar' => $this->nonavbar
));
break;
case 'cancel':
@@ -979,7 +991,8 @@
$GLOBALS['phpgw']->redirect_link('/index.php',
array
(
'menuaction' =>
'addressbook.uiaddressbook.delete_org',
- 'ab_id' =>
$this->contact_id
+ 'ab_id' =>
$this->contact_id,
+ 'nonavbar' => $this->nonavbar
));
break;
case 'clear':
@@ -1050,7 +1063,8 @@
$GLOBALS['phpgw']->redirect_link('/index.php', array
(
'menuaction' =>
'addressbook.uiaddressbook.edit_org',
- 'ab_id' => $new_contact_id
+ 'ab_id' => $new_contact_id,
+ 'nonavbar' => $this->nonavbar
));
}
@@ -1068,6 +1082,7 @@
{
$this->jscal = CreateObject('phpgwapi.jscalendar'); //
before phpgw_header()
+ $GLOBALS['phpgw_info']['flags']['nonavbar'] =
phpgw::get_var('nonavbar','bool');
$GLOBALS['phpgw']->common->phpgw_header(true);
$this->template->set_root(PHPGW_APP_TPL);
@@ -1093,11 +1108,11 @@
$this->template->set_block('principal_tabs','principal_tab','principal_tab');
$this->template->set_block('principal_tabs',
'principal_button', 'principal_button');
- $this->get_principal_tabs( array('menuaction' =>
'addressbook.uiaddressbook.add_person'),
+ $this->get_principal_tabs( array('menuaction' =>
'addressbook.uiaddressbook.add_person', 'nonavbar' => $this->nonavbar),
$this->get_class_css($this->tab_main_persons, $this->section),
'principal_persons', $this->tab_main_persons);
- $this->get_principal_tabs( array('menuaction' =>
'addressbook.uiaddressbook.add_org'),
+ $this->get_principal_tabs( array('menuaction' =>
'addressbook.uiaddressbook.add_org', 'nonavbar' => $this->nonavbar),
$this->get_class_css($this->tab_main_organizations, $this->section),
'principal_orgs', $this->tab_main_organizations);
@@ -2751,7 +2766,8 @@
$GLOBALS['phpgw']->redirect_link('/index.php', array
(
'menuaction' =>
'addressbook.uiaddressbook.index',
- 'section' => $contact_type
+ 'section' => $contact_type,
+ 'nonavbar' => $this->nonavbar
));
}
//LEX: Calling the delete_addressbook hook to make
@@ -2781,7 +2797,7 @@
$this->template->set_var('lang_reason',lang('reason'));
$this->template->set_var('lang_go_back',lang('Go
back'));
$this->template->set_var('link_go_back',
-
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>'addressbook.uiaddressbook.index','section'=>$contact_type)));
+
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>'addressbook.uiaddressbook.index','section'=>$contact_type,
'nonavbar' => $this->nonavbar)));
$this->template->set_block('cant_delete_apps',
'apps',
'apps_l');
@@ -2805,11 +2821,12 @@
$GLOBALS['phpgw']->common->phpgw_header(true);
// echo parse_navbar();
$this->template->set_var('lang_sure',lang('Are you sure
you want to delete this entry ?'));
-
$this->template->set_var('no_link',$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>'addressbook.uiaddressbook.index','section'=>$contact_type)));
+
$this->template->set_var('no_link',$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>'addressbook.uiaddressbook.index','section'=>$contact_type,
'nonavbar' => $this->nonavbar)));
$this->template->set_var('lang_no',lang('NO'));
$this->template->set_var('yes_link',$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>'addressbook.uiaddressbook.delete_'
. $type,
'ab_id'=> $contact_id,
-
'confirm'=>'true')));
+
'confirm'=>'true',
+
'nonavbar' => $this->nonavbar)));
$this->template->set_var('lang_yes',lang('YES'));
$this->template->pparse('out','delete');
}
@@ -2819,7 +2836,8 @@
$GLOBALS['phpgw']->redirect_link('/index.php', array
(
'menuaction' =>
'addressbook.uiaddressbook.index',
- 'section' => $contact_type
+ 'section' => $contact_type,
+ 'nonavbar' => $this->nonavbar
));
}
@@ -2848,7 +2866,8 @@
array
(
'menuaction' =>
'addressbook.uiaddressbook.index',
- 'section' => 'Persons'
+ 'section' => 'Persons',
+ 'nonavbar' => $this->nonavbar
)
);
@@ -2861,7 +2880,8 @@
array
(
'menuaction' =>
'addressbook.uiaddressbook.index',
- 'section' => 'Organizations'
+ 'section' => 'Organizations',
+ 'nonavbar' => $this->nonavbar
)
);
$type = 'org';
@@ -2888,7 +2908,8 @@
$GLOBALS['phpgw']->redirect_link('/index.php', array
(
'menuaction' =>
'addressbook.uiaddressbook.index',
- 'section' => $contact_type
+ 'section' => $contact_type,
+ 'nonavbar' => $this->nonavbar
));
}
@@ -3018,7 +3039,7 @@
if($persons && is_array($persons))
{
$per_link =
$GLOBALS['phpgw']->link('/index.php',
- array('menuaction' =>
'addressbook.uiaddressbook.view_person'));
+ array('menuaction' =>
'addressbook.uiaddressbook.view_person', 'nonavbar' => $this->nonavbar));
$ppl = array();
@@ -3083,7 +3104,7 @@
if($this->bo->check_edit($contact_id))
{
$this->template->set_var('edit_button',$this->html_1button_form('edit','Edit',
- $GLOBALS['phpgw']->link('/index.php',
array('menuaction' => "addressbook.uiaddressbook.edit_{$type}", 'ab_id' =>
$contact_id) ) ) );
+ $GLOBALS['phpgw']->link('/index.php',
array('menuaction' => "addressbook.uiaddressbook.edit_{$type}", 'ab_id' =>
$contact_id, 'nonavbar' => $this->nonavbar) ) ) );
}
else
{
@@ -3091,12 +3112,12 @@
}
$this->template->set_var('copy_button',$this->html_1button_form('submit','copy',
- $GLOBALS['phpgw']->link('/index.php',
array('menuaction' => "addressbook.uiaddressbook.copy_{$type}", 'ab_id' =>
$contact_id) ) ) );
+ $GLOBALS['phpgw']->link('/index.php',
array('menuaction' => "addressbook.uiaddressbook.copy_{$type}", 'ab_id' =>
$contact_id, 'nonavbar' => $this->nonavbar) ) ) );
if ($contacts['per_first_name'] && $contacts['per_last_name'])
{
$this->template->set_var('vcard_button',$this->html_1button_form('VCardForm','VCard',
- $GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'addressbook.uivcard.out', 'ab_id' => $contact_id) ) ) );
+ $GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'addressbook.uivcard.out', 'ab_id' => $contact_id,
'nonavbar' => $this->nonavbar) ) ) );
}
else
{
@@ -3106,7 +3127,7 @@
$this->template->set_var('done_button',$this->html_1button_form('DoneForm','Done',
isset($referer) && $referer
? $referer
- : $GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'addressbook.uiaddressbook.index', 'action' =>
$contact_type) ) ) );
+ : $GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'addressbook.uiaddressbook.index', 'action' =>
$contact_type, 'nonavbar' => $this->nonavbar) ) ) );
$this->template->pparse('out','view_t');
@@ -3523,7 +3544,8 @@
(
'menuaction' =>
'addressbook.uiaddressbook.view_person',
'ab_id' => $contact_id,
- 'referer' => $referer
+ 'referer' => $referer,
+ 'nonavbar' => $this->nonavbar
));
}
}
Modified: branches/Version-1_0-branch/controller/images/arrow_left.png
===================================================================
(Binary files differ)
Copied: branches/Version-1_0-branch/controller/images/arrow_right.png (from rev
8352, trunk/controller/images/arrow_right.png)
===================================================================
(Binary files differ)
Modified: branches/Version-1_0-branch/controller/images/status_icon_red.png
===================================================================
(Binary files differ)
Copied: branches/Version-1_0-branch/controller/images/status_icon_red_cross.png
(from rev 8352, trunk/controller/images/status_icon_red_cross.png)
===================================================================
(Binary files differ)
Copied: branches/Version-1_0-branch/controller/images/status_icon_red_empty.png
(from rev 8352, trunk/controller/images/status_icon_red_empty.png)
===================================================================
(Binary files differ)
Modified: branches/Version-1_0-branch/controller/images/status_icon_yellow.png
===================================================================
(Binary files differ)
Copied: branches/Version-1_0-branch/controller/images/status_icon_yellow.psd
(from rev 8352, trunk/controller/images/status_icon_yellow.psd)
===================================================================
(Binary files differ)
Modified: branches/Version-1_0-branch/controller/inc/class.cat_hooks.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.cat_hooks.inc.php
2011-12-16 18:33:20 UTC (rev 8352)
+++ branches/Version-1_0-branch/controller/inc/class.cat_hooks.inc.php
2011-12-16 22:20:41 UTC (rev 8353)
@@ -3,7 +3,7 @@
* phpGroupWare - controller: a part of a Facilities Management System.
*
* @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software
Foundation, Inc. http://www.fsf.org/
+ * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc.
http://www.fsf.org/
* This file is part of phpGroupWare.
*
* phpGroupWare is free software; you can redistribute it and/or modify
@@ -33,7 +33,15 @@
*/
class controller_cat_hooks
{
-
+ protected $soresponsible;
+ protected $_db;
+
+ function __construct()
+ {
+ $this->_db =&
$GLOBALS['phpgw']->db;
+ $this->soresponsible =
CreateObject('property.soresponsible');
+ $this->soresponsible->appname = 'controller';
+ }
/**
* Handle a new category being added, create location to hold
ACL-data
*/
@@ -51,7 +59,16 @@
$location = $location_info['location'];
}
$GLOBALS['phpgw']->locations->add("{$location}.category.{$data['cat_id']}",
$data['cat_name'], 'controller');
-
+
+ $this->soresponsible->add_type(array
+ (
+ 'name' => $data['cat_name'],
+ 'descr' => $data['cat_name'],
+ 'location' =>
"{$location}.category.{$data['cat_id']}",
+ 'cat_id' => $data['cat_id'],
+ 'active' => true
+ )
+ );
}
/**
@@ -68,6 +85,7 @@
$location_info =
$GLOBALS['phpgw']->locations->get_name($data['location_id']);
$location =
"{$location_info['location']}.category.{$data['cat_id']}";
$GLOBALS['phpgw']->locations->delete('controller', $location, false);
+ $this->_db->query("DELETE FROM
fm_responsibility WHERE cat_id = " . (int) $data['cat_id'], __LINE__, __FILE__);
}
}
@@ -86,6 +104,12 @@
$location_info =
$GLOBALS['phpgw']->locations->get_name($data['location_id']);
$location =
"{$location_info['location']}.category.{$data['cat_id']}";
$GLOBALS['phpgw']->locations->update_description($location, $data['cat_name'],
'controller');
+
+ $value_set['name'] =
$this->_db->db_addslashes($data['cat_name']);
+ $value_set['descr'] =
$value_set['name'];
+
+ $value_set =
$this->_db->validate_update($value_set);
+ $this->_db->query("UPDATE fm_responsibility SET
$value_set WHERE cat_id = " . (int) $data['cat_id'], __LINE__, __FILE__);
}
}
}
Modified: branches/Version-1_0-branch/controller/inc/class.menu.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.menu.inc.php
2011-12-16 18:33:20 UTC (rev 8352)
+++ branches/Version-1_0-branch/controller/inc/class.menu.inc.php
2011-12-16 22:20:41 UTC (rev 8353)
@@ -102,10 +102,10 @@
'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=>
'controller.uicheck_list.index') ),
'image' => array('property',
'location_1'),
),
- 'location_check_list' => array
+ 'calendar_overview' => array
(
- 'text' =>
lang('Check_list_location'),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=>
'controller.uilocation_check_list.view_agg_check_lists_for_location', 'year' =>
'2011', 'month' => '10') ),
+ 'text' =>
lang('Calendar_overview'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=>
'controller.uilocation_check_list.view_calendar_for_month', 'year' => '2011',
'month' => '10') ),
'image' => array('property',
'location_1'),
)
);
@@ -149,11 +149,6 @@
'text' => lang('Control area'),
'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'admin.uicategories.index', 'appname' => 'controller', 'location' =>
'.control', 'global_cats' => 'true', 'menu_selection' =>
'admin::controller::control_cats') )
),
- 'responsible_matrix' => array
- (
- 'text' =>
lang('responsible matrix'),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uiresponsible.index', 'appname' => 'controller') )
- ),
'responsibility_role' => array
(
'text' => lang('responsibility
role'),
Modified: branches/Version-1_0-branch/controller/inc/class.socheck_list.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.socheck_list.inc.php
2011-12-16 18:33:20 UTC (rev 8352)
+++ branches/Version-1_0-branch/controller/inc/class.socheck_list.inc.php
2011-12-16 22:20:41 UTC (rev 8353)
@@ -1,507 +1,497 @@
-<?php
- /**
- * phpGroupWare - controller: a part of a Facilities Management System.
- *
- * @author Erink Holm-Larsen <address@hidden>
- * @author Torstein Vadla <address@hidden>
- * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc.
http://www.fsf.org/
- * This file is part of phpGroupWare.
- *
- * phpGroupWare is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * phpGroupWare is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with phpGroupWare; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
- *
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/
- * @package property
- * @subpackage controller
- * @version $Id$
- */
-
- phpgw::import_class('controller.socommon');
-
- include_class('controller', 'check_list', 'inc/model/');
-
- class controller_socheck_list extends controller_socommon
- {
- protected static $so;
-
- /**
- * Get a static reference to the storage object associated with
this model object
- *
- * @return controller_socontrol_group the storage object
- */
- public static function get_instance()
- {
- if (self::$so == null)
- {
- self::$so =
CreateObject('controller.socheck_list');
- }
- return self::$so;
- }
-
- public function get_single($check_list_id)
- {
- $sql = "SELECT cl.id as cl_id, cl.status as cl_status,
cl.comment as cl_comment, deadline, ci.id as ci_id, ci.status as ci_status,
control_item_id, ci.comment as ci_comment, check_list_id FROM
controller_check_list cl, controller_check_item ci WHERE cl.id = $check_list_id
AND cl.id = ci.check_list_id;";
- $this->db->query($sql);
-
- $counter = 0;
- $check_list = null;
- while ($this->db->next_record())
- {
- if($counter == 0)
- {
- $check_list = new
controller_check_list($this->unmarshal($this->db->f('cl_id', true), 'int'));
-
$check_list->set_status($this->unmarshal($this->db->f('cl_status', true),
'bool'));
-
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true),
'string'));
-
$check_list->set_deadline($this->unmarshal($this->db->f('deadline', true),
'int'));
- }
-
- $check_item = new
controller_check_item($this->unmarshal($this->db->f('ci_id', true), 'int'));
-
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id',
true), 'int'));
-
$check_item->set_status($this->unmarshal($this->db->f('ci_status', true),
'bool'));
-
$check_item->set_comment($this->unmarshal($this->db->f('ci_comment', true),
'string'));
-
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id',
true), 'int'));
-
- $check_items_array[] = $check_item->toArray();
-
- $counter++;
- }
-
- if($check_list != null)
- {
-
$check_list->set_check_item_array($check_items_array);
- return $check_list->toArray();
- }
- else
- {
- return null;
- }
- }
-
- public function get_single_with_control_items($check_list_id)
- {
- $sql = "SELECT cl.id as cl_id, cl.status as cl_status,
cl.comment as cl_comment, deadline, ";
- $sql .= "ci.id as ci_id, ci.status as ci_status,
control_item_id, ci.comment as ci_comment, check_list_id, ";
- $sql .= "coi.title as coi_id, coi.title as coi_title,
coi.required as coi_required, coi.required as coi_required, ";
- $sql .= "coi.what_to_do as coi_what_to_do,
coi.how_to_do as coi_how_to_do, coi.control_group_id as coi_control_group_id ";
- $sql .= "FROM controller_check_list cl,
controller_check_item ci, controller_control_item as coi ";
- $sql .= "WHERE cl.id = $check_list_id ";
- $sql .= "AND cl.id = ci.check_list_id ";
- $sql .= "AND ci.control_item_id=coi.id;";
-
- $this->db->query($sql);
-
- $counter = 0;
- $check_list = null;
- while ($this->db->next_record())
- {
- if($counter == 0)
- {
- $check_list = new
controller_check_list($this->unmarshal($this->db->f('cl_id', true), 'int'));
-
$check_list->set_status($this->unmarshal($this->db->f('cl_status', true),
'bool'));
-
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true),
'string'));
-
$check_list->set_deadline($this->unmarshal($this->db->f('deadline', true),
'int'));
- }
-
- $check_item = new
controller_check_item($this->unmarshal($this->db->f('ci_id', true), 'int'));
-
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id',
true), 'int'));
-
$check_item->set_status($this->unmarshal($this->db->f('ci_status', true),
'bool'));
-
$check_item->set_comment($this->unmarshal($this->db->f('ci_comment', true),
'string'));
-
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id',
true), 'int'));
-
- $control_item = new
controller_control_item($this->unmarshal($this->db->f('coi_id', true), 'int'));
-
$control_item->set_title($this->db->f('coi_title', true), 'string');
-
$control_item->set_required($this->db->f('coi_required', true), 'string');
-
$control_item->set_what_to_do($this->db->f('coi_what_to_do', true), 'string');
-
$control_item->set_how_to_do($this->db->f('coi_how_to_do', true), 'string');
-
$control_item->set_control_group_id($this->db->f('coi_control_group_id', true),
'string');
-
-
$check_item->set_control_item($control_item->toArray());
-
- $check_items_array[] = $check_item->toArray();
-
- $counter++;
- }
-
- if($check_list != null)
- {
-
$check_list->set_check_item_array($check_items_array);
- return $check_list->toArray();
- }
- else
- {
- return null;
- }
- }
-
- public function get_check_list()
- {
- $current_time = time();
-
- $buffer_in_days = 3600*24*7*5;
-
- $buffer_time = $current_time - $buffer_in_days;
-
- $sql = "SELECT p.* FROM controller_control p WHERE
$current_time >= p.start_date AND p.start_date > $buffer_time";
- $this->db->query($sql);
-
- while ($this->db->next_record())
- {
- $start_date = date("d.m.Y",
$this->db->f('start_date'));
- $end_date = date("d.m.Y",
$this->db->f('end_date'));
-
- $control = new
controller_control($this->unmarshal($this->db->f('id', true), 'int'));
-
-
$control->set_title($this->unmarshal($this->db->f('title', true), 'string'));
-
$control->set_description($this->unmarshal($this->db->f('description', true),
'boolean'));
- $control->set_start_date($start_date);
- $control->set_end_date($end_date);
-
$control->set_procedure_id($this->unmarshal($this->db->f('procedure_id', true),
'int'));
-
$control->set_procedure_name($this->unmarshal($this->db->f('procedure_name',
true), 'string'));
-
$control->set_requirement_id($this->unmarshal($this->db->f('requirement_id',
true), 'int'));
-
$control->set_costresponsibility_id($this->unmarshal($this->db->f('costresponsibility_id',
true), 'int'));
-
$control->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
true), 'int'));
-
$control->set_control_area_id($this->unmarshal($this->db->f('control_area_id',
true), 'int'));
-
$control->set_control_area_name($this->unmarshal($this->db->f('control_area_name',
true), 'string'));
-
$control->set_component_type_id($this->unmarshal($this->db->f('component_type_id',
true), 'int'));
-
$control->set_component_id($this->unmarshal($this->db->f('component_id', true),
'int'));
-
$control->set_location_code($this->unmarshal($this->db->f('location_code',
true), 'int'));
-
$control->set_repeat_type($this->unmarshal($this->db->f('repeat_type', true),
'int'));
-
$control->set_repeat_interval($this->unmarshal($this->db->f('repeat_interval',
true), 'int'));
-
- $results[] = $control->toArray();
- }
-
- return $results;
- }
-
- function get_check_lists_for_control($control_id)
- {
- $sql = "SELECT cl.id as cl_id, cl.status as cl_status,
cl.comment as cl_comment, deadline, ";
- $sql .= "ci.id as ci_id, ci.status as ci_status,
control_item_id, ci.comment as ci_comment, check_list_id ";
- $sql .= "FROM controller_check_list cl,
controller_check_item ci ";
- $sql .= "WHERE cl.control_id = $control_id ";
- $sql .= "AND cl.id = ci.check_list_id ";
- $sql .= "ORDER BY cl.id;";
- $this->db->query($sql);
-
- $check_list_id = 0;
- $check_list = null;
- while ($this->db->next_record())
- {
- if( $this->db->f('cl_id', true) !=
$check_list_id )
- {
- if($check_list_id != 0)
- {
-
$check_list->set_check_item_array($check_items_array);
- $check_list_array[] =
$check_list->toArray();
- }
-
- $check_list = new
controller_check_list($this->unmarshal($this->db->f('cl_id', true), 'int'));
-
$check_list->set_status($this->unmarshal($this->db->f('cl_status', true),
'bool'));
-
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true),
'string'));
-
$check_list->set_deadline($this->unmarshal($this->db->f('deadline', true),
'int'));
-
- $check_items_array = array();
- }
-
- $check_item = new
controller_check_item($this->unmarshal($this->db->f('ci_id', true), 'int'));
-
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id',
true), 'int'));
-
$check_item->set_status($this->unmarshal($this->db->f('ci_status', true),
'bool'));
-
$check_item->set_comment($this->unmarshal($this->db->f('ci_comment', true),
'string'));
-
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id',
true), 'int'));
-
- $check_items_array[] = $check_item->toArray();
-
- $check_list_id = $check_list->get_id();
- }
-
- if($check_list != null)
- {
-
$check_list->set_check_item_array($check_items_array);
- $check_list_array[] = $check_list->toArray();
-
- return $check_list_array;
- }
- else
- {
- return null;
- }
- }
-
- function get_agg_check_lists_for_location( $location_code,
$from_date, $to_date )
- {
- $sql = "SELECT c.id as c_id, title, cl.id as cl_id,
c.repeat_type, c.repeat_interval, deadline, count(ci.id) ";
- $sql .= "FROM controller_check_list cl,
controller_control c, controller_check_item ci ";
- $sql .= "WHERE cl.location_code = $location_code ";
- $sql .= "AND c.repeat_type < 2 ";
- $sql .= "AND cl.control_id = c.id ";
- $sql .= "AND cl.id = ci.check_list_id ";
- $sql .= "AND deadline BETWEEN $from_date AND $to_date ";
- $sql .= "GROUP BY c.id, title, cl.id, cl.deadline,
c.repeat_type, c.repeat_interval ";
- $sql .= "ORDER BY c.id";
-
- $this->db->query($sql);
-
- $control_id = 0;
- $controls_array = array();
- $check_list_array = array();
- while ($this->db->next_record())
- {
- if( $this->db->f('c_id', true) != $control_id )
- {
- if($control_id != 0)
- {
- $controls_array[] = array(
"control" => $control_array, "check_list" => $check_list_array);
- $check_list_array = array();
- }
-
- $control_array = array(
-
"id" => $this->unmarshal($this->db->f('c_id',
true), 'int'),
-
"title" => $this->unmarshal($this->db->f('title',
true), 'string'),
-
"repeat_type" => $this->unmarshal($this->db->f('repeat_type',
true), 'int'),
-
"repeat_interval" => $this->unmarshal($this->db->f('repeat_interval',
true), 'int')
-
);
- }
-
- $check_list_array[] = array(
-
"cl_id" => $this->db->f('cl_id', true),
-
"deadline" => $this->db->f('deadline', true),
-
"count" => $this->db->f('count', true)
-
);
-
- $control_id = $this->db->f('c_id', true);
- }
-
- if( !empty( $control_array ) )
- {
- $controls_array[] = array( "control" =>
$control_array, "check_list" => $check_list_array);
-
- return $controls_array;
- }
- else
- {
- return null;
- }
- }
-
- function get_check_lists_for_location( $location_code,
$from_date, $to_date, $repeat_type )
- {
- $sql = "SELECT c.id as c_id, cl.id as cl_id, cl.status
as cl_status, cl.comment as cl_comment, ";
- $sql .= "deadline, planned_date, completed_date,
cl.location_code as cl_loc, c.* ";
- $sql .= "FROM controller_check_list cl,
controller_control c ";
- $sql .= "WHERE cl.location_code = $location_code ";
- $sql .= "AND c.repeat_type = $repeat_type ";
- $sql .= "AND cl.control_id = c.id ";
- $sql .= "AND deadline BETWEEN $from_date AND $to_date";
- $sql .= "ORDER BY c.id;";
-
- $this->db->query($sql);
-
- $control_id = 0;
- $control = null;
- while ($this->db->next_record())
- {
- if( $this->db->f('c_id', true) != $control_id )
- {
- if($control_id != 0)
- {
-
$control->set_check_lists_array($check_lists_array);
- $controls_array[] = $control;
- }
-
- $control = new
controller_control($this->unmarshal($this->db->f('c_id', true), 'int'));
-
$control->set_title($this->unmarshal($this->db->f('title', true), 'string'));
-
$control->set_description($this->unmarshal($this->db->f('description', true),
'boolean'));
-
$control->set_start_date($this->unmarshal($this->db->f('start_date', true),
'int'));
-
$control->set_end_date($this->unmarshal($this->db->f('end_date', true), 'int'));
-
$control->set_procedure_id($this->unmarshal($this->db->f('procedure_id', true),
'int'));
-
$control->set_procedure_name($this->unmarshal($this->db->f('procedure_name',
true), 'string'));
-
$control->set_requirement_id($this->unmarshal($this->db->f('requirement_id',
true), 'int'));
-
$control->set_costresponsibility_id($this->unmarshal($this->db->f('costresponsibility_id',
true), 'int'));
-
$control->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
true), 'int'));
-
$control->set_control_area_id($this->unmarshal($this->db->f('control_area_id',
true), 'int'));
-
$control->set_control_area_name($this->unmarshal($this->db->f('control_area_name',
true), 'string'));
-
$control->set_component_type_id($this->unmarshal($this->db->f('component_type_id',
true), 'int'));
-
$control->set_component_id($this->unmarshal($this->db->f('component_id', true),
'int'));
-
$control->set_location_code($this->unmarshal($this->db->f('location_code',
true), 'int'));
-
$control->set_repeat_type($this->unmarshal($this->db->f('repeat_type', true),
'int'));
-
$control->set_repeat_interval($this->unmarshal($this->db->f('repeat_interval',
true), 'int'));
-
- $check_lists_array = array();
- }
-
- $check_list = new
controller_check_list($this->unmarshal($this->db->f('cl_id', true), 'int'));
-
$check_list->set_status($this->unmarshal($this->db->f('cl_status', true),
'string'));
-
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true),
'string'));
-
$check_list->set_deadline($this->unmarshal($this->db->f('deadline', true),
'int'));
-
$check_list->set_planned_date($this->unmarshal($this->db->f('planned_date',
true), 'int'));
-
$check_list->set_completed_date($this->unmarshal($this->db->f('completed_date',
true), 'int'));
-
$check_list->set_location_code($this->unmarshal($this->db->f('cl_loc', true),
'int'));
-
- $check_lists_array[] = $check_list;
-
- $control_id = $control->get_id();
- }
-
- if($control != null)
- {
-
$control->set_check_lists_array($check_lists_array);
- $controls_array[] = $control;
-
- return $controls_array;
- }
- else
- {
- return null;
- }
- }
-
- function get_query(string $sort_field, boolean $ascending,
string $search_for, string $search_type, array $filters, boolean $return_count)
- {
- $current_time = time();
- $buffer_in_days = 3600*24*7*5;
- $buffer_time = $current_time - $buffer_in_days;
-
- $clauses = array('1=1');
- $clauses[] = "{$current_time} >= p.start_date AND
p.start_date > {$buffer_time}";
-
- $filter_clauses = array();
-
- // Search for based on search type
- if($search_for)
- {
- $search_for =
$this->marshal($search_for,'field');
- $like_pattern = "'%".$search_for."%'";
- $like_clauses = array();
- switch($search_type){
- default:
- $like_clauses[] = "p.title
$this->like $like_pattern";
- break;
- }
-
- if(count($like_clauses))
- {
- $clauses[] = '(' . join(' OR ',
$like_clauses) . ')';
- }
- }
- //var_dump($filters);
- if(isset($filters[$this->get_id_field_name()]))
- {
- $filter_clauses[] = "p.id =
{$this->marshal($filters[$this->get_id_field_name()],'int')}";
- }
-
- if(count($filter_clauses))
- {
- $clauses[] = join(' AND ', $filter_clauses);
- }
-
- $condition = join(' AND ', $clauses);
-
- $tables = "controller_control p";
- //$joins = " {$this->left_join} rental_document_types
ON (rental_document.type_id = rental_document_types.id)";
- //$joins = " {$this->left_join} controller_control_area
ON (controller_control.control_area_id = controller_control_area.id)";
- //$joins .= " {$this->left_join} controller_procedure
ON (controller_control.procedure_id = controller_procedure.id)";
-
- if($return_count)
- {
- $cols = 'COUNT(DISTINCT(p.id)) AS count';
- }
- else
- {
- $cols = 'p.* ';
- }
-
- $dir = $ascending ? 'ASC' : 'DESC';
- if($sort_field == 'id')
- {
- $sort_field = 'p.id';
- }
- $order = $sort_field ? "ORDER BY
{$this->marshal($sort_field, 'field')} $dir ": '';
-
- return "SELECT {$cols} FROM {$tables} {$joins} WHERE
{$condition} {$order}";
- }
-
- function populate(int $control_id, &$control)
- {
- if($control == null)
- {
- $start_date = date("d.m.Y",
$this->db->f('start_date'));
- $end_date = date("d.m.Y",
$this->db->f('end_date'));
- $control = new controller_control((int)
$control_id);
-
-
$control->set_title($this->unmarshal($this->db->f('title', true), 'string'));
-
$control->set_description($this->unmarshal($this->db->f('description', true),
'boolean'));
- $control->set_start_date($start_date);
- $control->set_end_date($end_date);
-
$control->set_procedure_id($this->unmarshal($this->db->f('procedure_id', true),
'int'));
-
$control->set_procedure_name($this->unmarshal($this->db->f('procedure_name',
true), 'string'));
-
$control->set_requirement_id($this->unmarshal($this->db->f('requirement_id',
true), 'int'));
-
$control->set_costresponsibility_id($this->unmarshal($this->db->f('costresponsibility_id',
true), 'int'));
-
$control->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
true), 'int'));
-
$control->set_control_area_id($this->unmarshal($this->db->f('control_area_id',
true), 'int'));
-
$control->set_control_area_name($this->unmarshal($this->db->f('control_area_name',
true), 'string'));
- //
$control->set_control_group_id($this->unmarshal($this->db->f('control_group_id',
true), 'int'));
-
$control->set_component_type_id($this->unmarshal($this->db->f('component_type_id',
true), 'int'));
-
$control->set_component_id($this->unmarshal($this->db->f('component_id', true),
'int'));
-
$control->set_location_code($this->unmarshal($this->db->f('location_code',
true), 'int'));
-
$control->set_repeat_type($this->unmarshal($this->db->f('repeat_type', true),
'int'));
-
$control->set_repeat_interval($this->unmarshal($this->db->f('repeat_interval',
true), 'int'));
- }
-
- return $control;
- }
-
- function add(&$check_list)
- {
- $cols = array(
- 'control_id',
- 'status',
- 'comment',
- 'deadline'
- );
-
- $values = array(
- $this->marshal($check_list->get_control_id(),
'int'),
- $this->marshal($check_list->get_status(),
'bool'),
- $this->marshal($check_list->get_comment(),
'string'),
- $this->marshal($check_list->get_deadline(),
'int')
- );
-
- $result = $this->db->query('INSERT INTO
controller_check_list (' . join(',', $cols) . ') VALUES (' . join(',', $values)
. ')', __LINE__,__FILE__);
-
- return isset($result) ?
$this->db->get_last_insert_id('controller_check_list', 'id') : 0;
- }
-
- function update($object){}
-
- function get_id_field_name($extended_info = false)
- {
- if(!$extended_info)
- {
- $ret = 'id';
- }
- else
- {
- $ret = array
- (
- 'table' => 'control',
// alias
- 'field' => 'id',
- 'translated' => 'id'
- );
- }
-
- return $ret;
- }
- }
+<?php
+ /**
+ * phpGroupWare - controller: a part of a Facilities Management System.
+ *
+ * @author Erink Holm-Larsen <address@hidden>
+ * @author Torstein Vadla <address@hidden>
+ * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc.
http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/
+ * @package property
+ * @subpackage controller
+ * @version $Id$
+ */
+phpgw::import_class('controller.socommon');
+
+include_class('controller', 'check_list', 'inc/model/');
+include_class('controller', 'control_item', 'inc/model/');
+include_class('controller', 'check_item', 'inc/model/');
+
+class controller_socheck_list extends controller_socommon
+{
+ protected static $so;
+
+ /**
+ * Get a static reference to the storage object associated with this
model object
+ *
+ * @return controller_socontrol_group the storage object
+ */
+ public static function get_instance()
+ {
+ if (self::$so == null) {
+ self::$so = CreateObject('controller.socheck_list');
+ }
+ return self::$so;
+ }
+
+ public function get_single($check_list_id){
+ $sql = "SELECT cl.id as cl_id, cl.status as cl_status,
cl.comment as cl_comment, deadline, ci.id as ci_id, ci.status as ci_status,
control_item_id, ci.comment as ci_comment, check_list_id FROM
controller_check_list cl, controller_check_item ci WHERE cl.id = $check_list_id
AND cl.id = ci.check_list_id;";
+ $this->db->query($sql);
+
+ $counter = 0;
+ $check_list = null;
+ while ($this->db->next_record()) {
+
+ if($counter == 0){
+ $check_list = new
controller_check_list($this->unmarshal($this->db->f('cl_id', true), 'int'));
+
$check_list->set_status($this->unmarshal($this->db->f('cl_status', true),
'bool'));
+
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true),
'string'));
+
$check_list->set_deadline($this->unmarshal($this->db->f('deadline', true),
'int'));
+ }
+
+ $check_item = new
controller_check_item($this->unmarshal($this->db->f('ci_id', true), 'int'));
+
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id',
true), 'int'));
+
$check_item->set_status($this->unmarshal($this->db->f('ci_status', true),
'bool'));
+
$check_item->set_comment($this->unmarshal($this->db->f('ci_comment', true),
'string'));
+
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id',
true), 'int'));
+
+ $check_items_array[] = $check_item->toArray();
+
+ $counter++;
+ }
+
+ if($check_list != null){
+ $check_list->set_check_item_array($check_items_array);
+ return $check_list->toArray();
+ }else {
+ return null;
+ }
+ }
+
+ public function get_single_with_check_items($check_list_id){
+ $sql = "SELECT cl.id as cl_id, cl.status as cl_status,
cl.comment as cl_comment, deadline, planned_date, completed_date, ";
+ $sql .= "ci.id as ci_id, ci.status as ci_status,
control_item_id, ci.comment as ci_comment, check_list_id, ";
+ $sql .= "coi.title as coi_id, coi.title as coi_title,
coi.required as coi_required, coi.required as coi_required, ";
+ $sql .= "coi.what_to_do as coi_what_to_do, coi.how_to_do as
coi_how_to_do, coi.control_group_id as coi_control_group_id ";
+ $sql .= "FROM controller_check_list cl ";
+ $sql .= "LEFT JOIN controller_check_item as ci ON cl.id =
ci.check_list_id ";
+ $sql .= "LEFT JOIN controller_control_item as coi ON
ci.control_item_id=coi.id ";
+ $sql .= "WHERE cl.id = $check_list_id;";
+
+ $this->db->query($sql);
+
+ $counter = 0;
+ $check_list = null;
+
+ while ($this->db->next_record()) {
+
+ if($counter == 0){
+ $check_list = new
controller_check_list($this->unmarshal($this->db->f('cl_id', true), 'int'));
+
$check_list->set_status($this->unmarshal($this->db->f('cl_status', true),
'bool'));
+
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true),
'string'));
+
$check_list->set_deadline($this->unmarshal($this->db->f('deadline', true),
'int'));
+
$check_list->set_planned_date($this->unmarshal($this->db->f('planned_date',
true), 'int'));
+
$check_list->set_completed_date($this->unmarshal($this->db->f('completed_date',
true), 'int'));
+ }
+
+ if($this->db->f('ci_id', true) != ''){
+ $check_item = new
controller_check_item($this->unmarshal($this->db->f('ci_id', true), 'int'));
+
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id',
true), 'int'));
+
$check_item->set_status($this->unmarshal($this->db->f('ci_status', true),
'bool'));
+
$check_item->set_comment($this->unmarshal($this->db->f('ci_comment', true),
'string'));
+
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id',
true), 'int'));
+
+ $control_item = new
controller_control_item($this->unmarshal($this->db->f('coi_id', true), 'int'));
+
$control_item->set_title($this->db->f('coi_title', true), 'string');
+
$control_item->set_required($this->db->f('coi_required', true), 'string');
+
$control_item->set_what_to_do($this->db->f('coi_what_to_do', true), 'string');
+
$control_item->set_how_to_do($this->db->f('coi_how_to_do', true), 'string');
+
$control_item->set_control_group_id($this->db->f('coi_control_group_id', true),
'string');
+
+
$check_item->set_control_item($control_item->toArray());
+
+ $check_items_array[] = $check_item->toArray();
+ }
+
+ $counter++;
+ }
+
+ if($check_list != null){
+ $check_list->set_check_item_array($check_items_array);
+ return $check_list->toArray();
+ }else {
+ return null;
+ }
+ }
+
+ public function get_check_list(){
+
+ $current_time = time();
+
+ $buffer_in_days = 3600*24*7*5;
+
+ $buffer_time = $current_time - $buffer_in_days;
+
+ $sql = "SELECT p.* FROM controller_control p WHERE
$current_time >= p.start_date AND p.start_date > $buffer_time";
+ $this->db->query($sql);
+
+ while ($this->db->next_record()) {
+ $start_date = date("d.m.Y",
$this->db->f('start_date'));
+ $end_date = date("d.m.Y", $this->db->f('end_date'));
+
+ $control = new
controller_control($this->unmarshal($this->db->f('id', true), 'int'));
+
+
$control->set_title($this->unmarshal($this->db->f('title', true), 'string'));
+
$control->set_description($this->unmarshal($this->db->f('description', true),
'boolean'));
+ $control->set_start_date($start_date);
+ $control->set_end_date($end_date);
+
$control->set_procedure_id($this->unmarshal($this->db->f('procedure_id', true),
'int'));
+
$control->set_procedure_name($this->unmarshal($this->db->f('procedure_name',
true), 'string'));
+
$control->set_requirement_id($this->unmarshal($this->db->f('requirement_id',
true), 'int'));
+
$control->set_costresponsibility_id($this->unmarshal($this->db->f('costresponsibility_id',
true), 'int'));
+
$control->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
true), 'int'));
+
$control->set_control_area_id($this->unmarshal($this->db->f('control_area_id',
true), 'int'));
+
$control->set_control_area_name($this->unmarshal($this->db->f('control_area_name',
true), 'string'));
+
$control->set_equipment_type_id($this->unmarshal($this->db->f('equipment_type_id',
true), 'int'));
+
$control->set_equipment_id($this->unmarshal($this->db->f('equipment_id', true),
'int'));
+
$control->set_location_code($this->unmarshal($this->db->f('location_code',
true), 'int'));
+
$control->set_repeat_type($this->unmarshal($this->db->f('repeat_type', true),
'int'));
+
$control->set_repeat_interval($this->unmarshal($this->db->f('repeat_interval',
true), 'int'));
+
+ $results[] = $control->toArray();
+ }
+
+ return $results;
+ }
+
+ function get_check_lists_for_control($control_id){
+ $sql = "SELECT cl.id as cl_id, cl.status as cl_status,
cl.comment as cl_comment, deadline, ";
+ $sql .= "ci.id as ci_id, ci.status as ci_status,
control_item_id, ci.comment as ci_comment, check_list_id ";
+ $sql .= "FROM controller_check_list cl, controller_check_item
ci ";
+ $sql .= "WHERE cl.control_id = $control_id ";
+ $sql .= "AND cl.id = ci.check_list_id ";
+ $sql .= "ORDER BY cl.id;";
+ $this->db->query($sql);
+
+ $check_list_id = 0;
+ $check_list = null;
+ while ($this->db->next_record()) {
+
+ if( $this->db->f('cl_id', true) != $check_list_id ){
+
+ if($check_list_id != 0){
+
$check_list->set_check_item_array($check_items_array);
+ $check_list_array[] =
$check_list->toArray();
+ }
+
+ $check_list = new
controller_check_list($this->unmarshal($this->db->f('cl_id', true), 'int'));
+
$check_list->set_status($this->unmarshal($this->db->f('cl_status', true),
'bool'));
+
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true),
'string'));
+
$check_list->set_deadline($this->unmarshal($this->db->f('deadline', true),
'int'));
+
+ $check_items_array = array();
+ }
+
+ $check_item = new
controller_check_item($this->unmarshal($this->db->f('ci_id', true), 'int'));
+
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id',
true), 'int'));
+
$check_item->set_status($this->unmarshal($this->db->f('ci_status', true),
'bool'));
+
$check_item->set_comment($this->unmarshal($this->db->f('ci_comment', true),
'string'));
+
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id',
true), 'int'));
+
+ $check_items_array[] = $check_item->toArray();
+
+ $check_list_id = $check_list->get_id();
+ }
+
+ if($check_list != null){
+ $check_list->set_check_item_array($check_items_array);
+ $check_list_array[] = $check_list->toArray();
+
+ return $check_list_array;
+ }else {
+ return null;
+ }
+ }
+
+ function get_agg_check_lists_for_location( $location_code, $from_date,
$to_date ){
+
+ $sql = "SELECT c.id as c_id, title, start_date, end_date,
cl.id as cl_id, c.repeat_type, c.repeat_interval, cl.deadline, count(ci.id) ";
+ $sql .= "FROM controller_check_list cl, controller_control c,
controller_check_item ci ";
+ $sql .= "WHERE cl.location_code = $location_code ";
+ $sql .= "AND c.repeat_type < 2 ";
+ $sql .= "AND cl.control_id = c.id ";
+ $sql .= "AND cl.id = ci.check_list_id ";
+ $sql .= "AND deadline BETWEEN $from_date AND $to_date ";
+ $sql .= "GROUP BY c.id, title, start_date, end_date, cl.id,
cl.deadline, c.repeat_type, c.repeat_interval ";
+ $sql .= "ORDER BY c.id";
+
+ $this->db->query($sql);
+
+ $control_id = 0;
+ $controls_array = array();
+ $check_list_array = array();
+ while ($this->db->next_record()) {
+
+ if( $this->db->f('c_id', true) != $control_id ){
+ if($control_id != 0){
+ $controls_array[] = array( "control" =>
$control_array, "check_list" => $check_list_array);
+ $check_list_array = array();
+ }
+
+ $control_array = array(
+
"id" => $this->unmarshal($this->db->f('c_id', true),
'int'),
+
"title" => $this->unmarshal($this->db->f('title', true),
'string'),
+
"repeat_type" => $this->unmarshal($this->db->f('repeat_type', true), 'int'),
+
"repeat_interval" => $this->unmarshal($this->db->f('repeat_interval', true),
'int'),
+
"start_date" => $this->unmarshal($this->db->f('start_date', true), 'int'),
+
"end_date" => $this->unmarshal($this->db->f('end_date', true), 'int')
+ );
+ }
+
+ $check_list_array[] = array(
+
"cl_id" => $this->db->f('cl_id', true),
+
"deadline" => $this->db->f('deadline', true),
+
"count" => $this->db->f('count', true)
+ );
+
+ $control_id = $this->db->f('c_id', true);
+ }
+
+ if( !empty( $control_array ) ){
+ $controls_array[] = array( "control" => $control_array,
"check_list" => $check_list_array);
+
+ return $controls_array;
+ }else {
+ return null;
+ }
+ }
+
+ function get_check_lists_for_location( $location_code, $from_date,
$to_date, $repeat_type ){
+ $sql = "SELECT c.id as c_id, cl.id as cl_id, cl.status as
cl_status, cl.comment as cl_comment, ";
+ $sql .= "deadline, planned_date, completed_date,
cl.location_code as cl_loc, c.* ";
+ $sql .= "FROM controller_check_list cl, controller_control c ";
+ $sql .= "WHERE cl.location_code = $location_code ";
+ $sql .= "AND c.repeat_type = $repeat_type ";
+ $sql .= "AND cl.control_id = c.id ";
+ $sql .= "AND deadline BETWEEN $from_date AND $to_date";
+ $sql .= "ORDER BY c.id;";
+
+ $this->db->query($sql);
+
+ $control_id = 0;
+ $control = null;
+ while ($this->db->next_record()) {
+
+ if( $this->db->f('c_id', true) != $control_id ){
+
+ if($control_id != 0){
+
$control->set_check_lists_array($check_lists_array);
+ $controls_array[] = $control;
+ }
+
+ $control = new
controller_control($this->unmarshal($this->db->f('c_id', true), 'int'));
+
$control->set_title($this->unmarshal($this->db->f('title', true), 'string'));
+
$control->set_description($this->unmarshal($this->db->f('description', true),
'boolean'));
+
$control->set_start_date($this->unmarshal($this->db->f('start_date', true),
'int'));
+
$control->set_end_date($this->unmarshal($this->db->f('end_date', true), 'int'));
+
$control->set_procedure_id($this->unmarshal($this->db->f('procedure_id', true),
'int'));
+
$control->set_procedure_name($this->unmarshal($this->db->f('procedure_name',
true), 'string'));
+
$control->set_requirement_id($this->unmarshal($this->db->f('requirement_id',
true), 'int'));
+
$control->set_costresponsibility_id($this->unmarshal($this->db->f('costresponsibility_id',
true), 'int'));
+
$control->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
true), 'int'));
+
$control->set_control_area_id($this->unmarshal($this->db->f('control_area_id',
true), 'int'));
+
$control->set_control_area_name($this->unmarshal($this->db->f('control_area_name',
true), 'string'));
+
$control->set_component_type_id($this->unmarshal($this->db->f('component_type_id',
true), 'int'));
+
$control->set_component_id($this->unmarshal($this->db->f('component_id', true),
'int'));
+
$control->set_location_code($this->unmarshal($this->db->f('location_code',
true), 'int'));
+
$control->set_repeat_type($this->unmarshal($this->db->f('repeat_type', true),
'int'));
+
$control->set_repeat_interval($this->unmarshal($this->db->f('repeat_interval',
true), 'int'));
+
+ $check_lists_array = array();
+ }
+
+ $check_list = new
controller_check_list($this->unmarshal($this->db->f('cl_id', true), 'int'));
+
$check_list->set_status($this->unmarshal($this->db->f('cl_status', true),
'string'));
+
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true),
'string'));
+
$check_list->set_deadline($this->unmarshal($this->db->f('deadline', true),
'int'));
+
$check_list->set_planned_date($this->unmarshal($this->db->f('planned_date',
true), 'int'));
+
$check_list->set_completed_date($this->unmarshal($this->db->f('completed_date',
true), 'int'));
+
$check_list->set_location_code($this->unmarshal($this->db->f('cl_loc', true),
'int'));
+
+ $check_lists_array[] = $check_list;
+
+ $control_id = $control->get_id();
+ }
+
+ if($control != null){
+ $control->set_check_lists_array($check_lists_array);
+ $controls_array[] = $control;
+
+ return $controls_array;
+ }else {
+ return null;
+ }
+ }
+
+ function get_query(string $sort_field, boolean $ascending, string
$search_for, string $search_type, array $filters, boolean $return_count)
+ {
+ $current_time = time();
+ $buffer_in_days = 3600*24*7*5;
+ $buffer_time = $current_time - $buffer_in_days;
+
+ $clauses = array('1=1');
+ $clauses[] = "{$current_time} >= p.start_date AND p.start_date
> {$buffer_time}";
+
+ $filter_clauses = array();
+
+ // Search for based on search type
+ if($search_for)
+ {
+ $search_for = $this->marshal($search_for,'field');
+ $like_pattern = "'%".$search_for."%'";
+ $like_clauses = array();
+ switch($search_type){
+ default:
+ $like_clauses[] = "p.title $this->like
$like_pattern";
+ break;
+ }
+
+ if(count($like_clauses))
+ {
+ $clauses[] = '(' . join(' OR ', $like_clauses)
. ')';
+ }
+ }
+ //var_dump($filters);
+ if(isset($filters[$this->get_id_field_name()]))
+ {
+ $filter_clauses[] = "p.id =
{$this->marshal($filters[$this->get_id_field_name()],'int')}";
+ }
+
+ if(count($filter_clauses))
+ {
+ $clauses[] = join(' AND ', $filter_clauses);
+ }
+
+ $condition = join(' AND ', $clauses);
+
+ $tables = "controller_control p";
+ //$joins = " {$this->left_join} rental_document_types ON
(rental_document.type_id = rental_document_types.id)";
+ //$joins = " {$this->left_join} controller_control_area ON
(controller_control.control_area_id = controller_control_area.id)";
+ //$joins .= " {$this->left_join} controller_procedure ON
(controller_control.procedure_id = controller_procedure.id)";
+
+ if($return_count)
+ {
+ $cols = 'COUNT(DISTINCT(p.id)) AS count';
+ }
+ else
+ {
+ $cols = 'p.* ';
+ }
+
+ $dir = $ascending ? 'ASC' : 'DESC';
+ if($sort_field == 'id')
+ {
+ $sort_field = 'p.id';
+ }
+ $order = $sort_field ? "ORDER BY {$this->marshal($sort_field,
'field')} $dir ": '';
+
+ return "SELECT {$cols} FROM {$tables} {$joins} WHERE
{$condition} {$order}";
+ }
+
+ function populate(int $control_id, &$control)
+ {
+
+
+ if($control == null) {
+ $start_date = date("d.m.Y",
$this->db->f('start_date'));
+ $end_date = date("d.m.Y", $this->db->f('end_date'));
+ $control = new controller_control((int) $control_id);
+
+
$control->set_title($this->unmarshal($this->db->f('title', true), 'string'));
+
$control->set_description($this->unmarshal($this->db->f('description', true),
'boolean'));
+ $control->set_start_date($start_date);
+ $control->set_end_date($end_date);
+
$control->set_procedure_id($this->unmarshal($this->db->f('procedure_id', true),
'int'));
+
$control->set_procedure_name($this->unmarshal($this->db->f('procedure_name',
true), 'string'));
+
$control->set_requirement_id($this->unmarshal($this->db->f('requirement_id',
true), 'int'));
+
$control->set_costresponsibility_id($this->unmarshal($this->db->f('costresponsibility_id',
true), 'int'));
+
$control->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
true), 'int'));
+
$control->set_control_area_id($this->unmarshal($this->db->f('control_area_id',
true), 'int'));
+
$control->set_control_area_name($this->unmarshal($this->db->f('control_area_name',
true), 'string'));
+//
$control->set_control_group_id($this->unmarshal($this->db->f('control_group_id',
true), 'int'));
+
$control->set_equipment_type_id($this->unmarshal($this->db->f('equipment_type_id',
true), 'int'));
+
$control->set_equipment_id($this->unmarshal($this->db->f('equipment_id', true),
'int'));
+
$control->set_location_code($this->unmarshal($this->db->f('location_code',
true), 'int'));
+
$control->set_repeat_type($this->unmarshal($this->db->f('repeat_type', true),
'int'));
+
$control->set_repeat_interval($this->unmarshal($this->db->f('repeat_interval',
true), 'int'));
+ }
+
+ return $control;
+ }
+
+ function add(&$check_list)
+ {
+ $cols = array(
+ 'control_id',
+ 'status',
+ 'comment',
+ 'deadline',
+ 'planned_date',
+ 'completed_date',
+ 'location_code',
+ 'equipment_id'
+ );
+
+ $values = array(
+ $this->marshal($check_list->get_control_id(), 'int'),
+ $this->marshal($check_list->get_status(), 'bool'),
+ $this->marshal($check_list->get_comment(), 'string'),
+ $this->marshal($check_list->get_deadline(), 'int'),
+ $this->marshal($check_list->get_planned_date(), 'int'),
+ $this->marshal($check_list->get_completed_date(),
'int'),
+ $this->marshal($check_list->get_location_code(), 'int'),
+ $this->marshal($check_list->get_equipment_id(), 'int')
+ );
+
+ $result = $this->db->query('INSERT INTO controller_check_list
(' . join(',', $cols) . ') VALUES (' . join(',', $values) . ')',
__LINE__,__FILE__);
+
+ return isset($result) ?
$this->db->get_last_insert_id('controller_check_list', 'id') : 0;
+ }
+
+ function update($object){}
+
+ function get_id_field_name($extended_info = false)
+ {
+ if(!$extended_info)
+ {
+ $ret = 'id';
+ }
+ else
+ {
+ $ret = array
+ (
+ 'table' => 'control', // alias
+ 'field' => 'id',
+ 'translated' => 'id'
+ );
+ }
+
+ return $ret;
+ }
+}
\ No newline at end of file
Copied: branches/Version-1_0-branch/controller/inc/class.sodocument.inc.php
(from rev 8352, trunk/controller/inc/class.sodocument.inc.php)
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.sodocument.inc.php
(rev 0)
+++ branches/Version-1_0-branch/controller/inc/class.sodocument.inc.php
2011-12-16 22:20:41 UTC (rev 8353)
@@ -0,0 +1,353 @@
+<?php
+ /**
+ * phpGroupWare - controller: a part of a Facilities Management System.
+ *
+ * @author Erik Holm-Larsen <address@hidden>
+ * @author Torstein Vadla <address@hidden>
+ * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc.
http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/
+ * @package property
+ * @subpackage controller
+ * @version $Id$
+ */
+
+phpgw::import_class('controller.socommon');
+
+class controller_sodocument extends controller_socommon
+{
+ public static $ROOT_FOR_DOCUMENTS = 'controller';
+ public static $PROCEDURE_DOCUMENTS = 'procedures';
+
+ protected static $so;
+ protected $document_types; // Used for caching the values
+
+ /**
+ * Get a static reference to the storage object associated with this
model object
+ *
+ * @return the storage object
+ */
+ public static function get_instance()
+ {
+ if (self::$so == null) {
+ self::$so = CreateObject('controller.sodocument');
+ }
+ return self::$so;
+ }
+
+ public function get_id_field_name($extended_info = false)
+ {
+ if(!$extended_info)
+ {
+ $ret = 'document_id';
+ }
+ else
+ {
+ $ret = array
+ (
+ 'table' =>
'controller_document', // alias
+ 'field' => 'id',
+ 'translated' => 'document_id'
+ );
+ }
+ return $ret;
+ }
+
+ protected function get_query(string $sort_field, boolean $ascending,
string $search_for, string $search_type, array $filters, boolean $return_count)
+ {
+
+ $clauses = array('1=1');
+
+ $filter_clauses = array();
+
+ // Search for based on search type
+ if($search_for)
+ {
+ $search_for = $this->marshal($search_for,'field');
+ $like_pattern = "'%".$search_for."%'";
+ $like_clauses = array();
+ switch($search_type){
+ case "title":
+ $like_clauses[] =
"controller_document.title $this->like $like_pattern";
+ break;
+ case "name":
+ $like_clauses[] =
"controller_document.name $this->like $like_pattern";
+ break;
+ case "all":
+ $like_clauses[] =
"controller_document.title $this->like $like_pattern";
+ $like_clauses[] =
"controller_document.name $this->like $like_pattern";
+ break;
+ }
+
+ if(count($like_clauses))
+ {
+ $clauses[] = '(' . join(' OR ', $like_clauses)
. ')';
+ }
+ }
+
+ if(isset($filters[$this->get_id_field_name()]))
+ {
+ $filter_clauses[] = "controller_document.id =
{$this->marshal($filters[$this->get_id_field_name()],'int')}";
+ }
+
+ if(isset($filters['procedure_id']))
+ {
+ $filter_clauses[] = "controller_document.procedure_id =
{$this->marshal($filters['procedure_id'],'int')}";
+ }
+
+ if(isset($filters['document_type']) &&
$filters['document_type'] != 'all')
+ {
+ $filter_clauses[] = "controller_document.type_id =
{$this->marshal($filters['document_type'],'int')}";
+ }
+
+ if(count($filter_clauses))
+ {
+ $clauses[] = join(' AND ', $filter_clauses);
+ }
+
+
+ $condition = join(' AND ', $clauses);
+
+ $tables = "controller_document";
+ $joins = " {$this->left_join} controller_document_types ON
(controller_document.type_id = controller_document_types.id)";
+
+ if($return_count)
+ {
+ $cols = 'COUNT(DISTINCT(controller_document.id)) AS
count';
+ }
+ else
+ {
+ $cols = 'controller_document.id as document_id,
controller_document.title as document_title, description, name, contract_id,
party_id, controller_document_types.title as type_title';
+ }
+
+ $dir = $ascending ? 'ASC' : 'DESC';
+ if($sort_field == 'title')
+ {
+ $sort_field = 'controller_document.title';
+ }
+ else if($sort_field == 'type')
+ {
+ $sort_field = 'controller_document_types.title';
+ }
+ $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 $document_id, &$document)
+ {
+ if($document == null)
+ {
+ $document = new controller_document($document_id);
+
$document->set_title($this->unmarshal($this->db->f('document_title',true),'string'));
+
$document->set_description($this->unmarshal($this->db->f('description',true),'string'));
+
$document->set_name($this->unmarshal($this->db->f('name',true),'string'));
+
$document->set_type($this->unmarshal($this->db->f('type_title',true),'string'));
+
$document->set_contract_id($this->unmarshal($this->db->f('contract_id',true),'int'));
+ }
+ return $document;
+ }
+
+ public function add(&$document)
+ {
+ $cols = array(
+ 'title',
+ 'description',
+ 'name',
+ 'procedure_id',
+ 'type_id'
+ );
+
+ $procedure_id =
$this->marshal($document->get_procedure_id(),'int');
+ $contract_id = $contract_id > 0 ? $contract_id : 'NULL';
+
+
+ $values = array(
+ $this->marshal($document->get_title(),'string'),
+ $this->marshal($document->get_description(),'string'),
+ $this->marshal($document->get_name(),'string'),
+ $procedure_id,
+ $this->marshal($document->get_type_id(),'int')
+ );
+
+ $query = "INSERT INTO controller_document (".join(',',
$cols).") VALUES (".join(',',$values).")";
+ $result = $this->db->query($query);
+
+ $document_id =
$this->db->get_last_insert_id('controller_document','id');
+ $document->set_id($document_id);
+ return $document;
+ }
+
+ public function update($document)
+ {
+ $id = intval($document->get_id());
+
+ $name_value_pairs = array (
+ "title =
{$this->marshal($document->get_title(),'string')}",
+ "description =
{$this->marshal($document->get_description(),'string')}",
+ "name =
{$this->marshal($document->get_name(),'string')}",
+ "procedure_id =
{$this->marshal($document->get_procedure_id(),'int')}",
+ "type_id =
{$this->marshal($document->get_type_id(),'int')}"
+ );
+
+ $query = "UPDATE controller_document SET
".join(',',$name_value_pairs)." WHERE id = {$id}";
+ $result = $this->db->query($query);
+ return $result != null;
+ }
+
+ public function get_document_types()
+ {
+ if($this->document_types == null)
+ {
+ $sql = "SELECT id, title FROM
controller_document_types";
+ $this->db->query($sql, __LINE__, __FILE__);
+ $results = array();
+ while($this->db->next_record()){
+ $location_id = $this->db->f('id', true);
+ $results[$location_id] = $this->db->f('title',
true);
+ }
+ $this->document_types = $results;
+ }
+ return $this->document_types;
+
+ }
+
+ private function get_document_path(string $document_type, $id)
+ {
+ $root_directory = self::$ROOT_FOR_DOCUMENTS;
+ $type_directory;
+ if($document_type == self::$PROCEDURE_DOCUMENTS)
+ {
+ $type_directory = self::$PROCEDURE_DOCUMENTS;
+ }
+ else
+ {
+ return false;
+ }
+
+ $vfs = CreateObject('phpgwapi.vfs');
+ $vfs->override_acl = 1;
+
+ $path = "/{$root_directory}";
+ $dir = array('string' => $path, RELATIVE_NONE);
+ if(!$vfs->file_exists($dir)){
+ if(!$vfs->mkdir($dir))
+ {
+ return false;
+ }
+ }
+
+ $path .= "/{$type_directory}";
+ $dir = array('string' => $path, RELATIVE_NONE);
+ if(!$vfs->file_exists($dir)){
+ if(!$vfs->mkdir($dir))
+ {
+ return false;
+ }
+ }
+
+ $path .= "/{$id}";
+ $dir = array('string' => $path, RELATIVE_NONE);
+ if(!$vfs->file_exists($dir)){
+ if(!$vfs->mkdir($dir))
+ {
+ return false;
+ }
+ }
+
+ return "/{$root_directory}/{$type_directory}/{$id}";
+ }
+
+ public function write_document_to_vfs(string $document_type,
$temporary_name, $id, $name)
+ {
+
+ $path = $this->get_document_path($document_type,$id);
+
+ if(!$path)
+ {
+ return false;
+ }
+
+ $vfs = CreateObject('phpgwapi.vfs');
+ $vfs->override_acl = 1;
+ $path .= "/{$name}";
+ $file = array('string' => $path, RELATIVE_NONE);
+
+ return $vfs->write
+ (
+ array
+ (
+ 'string' => $path,
+ RELATIVE_NONE,
+ 'content' => file_get_contents($temporary_name)
+ )
+ );
+ }
+
+ public function read_document_from_vfs(string $document_type, $id,
$name)
+ {
+ $path = $this->get_document_path($document_type,$id);
+
+ $path .= "/{$name}";
+
+ $vfs = CreateObject('phpgwapi.vfs');
+ $vfs->override_acl = 1;
+
+ return $vfs->read
+ (
+ array
+ (
+ 'string' => $path,
+ RELATIVE_NONE
+ )
+ );
+ }
+
+ public function delete_document_from_vfs(string $document_type, $id,
$name)
+ {
+ $path = $this->get_document_path($document_type,$id);
+
+ $path .= "/{$name}";
+
+ $vfs = CreateObject('phpgwapi.vfs');
+ $vfs->override_acl = 1;
+
+ return $vfs->rm
+ (
+ array
+ (
+ 'string' => $path,
+ RELATIVE_NONE
+ )
+ );
+ }
+
+ public function delete_document($id)
+ {
+ $sql = "DELETE FROM controller_document WHERE id = {$id}";
+
+ $result = $this->db->query($sql, __LINE__, __FILE__);
+ if($result)
+ {
+ return true;
+ }
+ return false;
+ }
+}
Modified: branches/Version-1_0-branch/controller/inc/class.uicheck_list.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicheck_list.inc.php
2011-12-16 18:33:20 UTC (rev 8352)
+++ branches/Version-1_0-branch/controller/inc/class.uicheck_list.inc.php
2011-12-16 22:20:41 UTC (rev 8353)
@@ -192,7 +192,7 @@
public function get_check_list_info()
{
$check_list_id = phpgw::get_var('check_list_id');
- $check_list =
$this->so_check_list->get_single_with_control_items($check_list_id);
+ $check_list =
$this->so_check_list->get_single_with_check_items($check_list_id);
return json_encode( $check_list );
}
Modified:
branches/Version-1_0-branch/controller/inc/class.uicheck_list_for_location.inc.php
===================================================================
---
branches/Version-1_0-branch/controller/inc/class.uicheck_list_for_location.inc.php
2011-12-16 18:33:20 UTC (rev 8352)
+++
branches/Version-1_0-branch/controller/inc/class.uicheck_list_for_location.inc.php
2011-12-16 22:20:41 UTC (rev 8353)
@@ -1,329 +1,446 @@
-<?php
- /**
- * phpGroupWare - controller: a part of a Facilities Management System.
- *
- * @author Erink Holm-Larsen <address@hidden>
- * @author Torstein Vadla <address@hidden>
- * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc.
http://www.fsf.org/
- * This file is part of phpGroupWare.
- *
- * phpGroupWare is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * phpGroupWare is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with phpGroupWare; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
- *
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/
- * @package property
- * @subpackage controller
- * @version $Id$
- */
-
- phpgw::import_class('phpgwapi.yui');
- phpgw::import_class('controller.uicommon');
- phpgw::import_class('controller.socontrol_area');
-
- class controller_uicheck_list_for_location extends controller_uicommon
- {
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
- var $currentapp;
- var $type_id;
- var $location_code;
-
- private $so_control_area;
- private $so_control;
-
- var $public_functions = array(
-
'index' => true,
-
'add_location_to_control' => true
- );
-
- function __construct()
- {
- parent::__construct();
-
- $this->bo =
CreateObject('property.bolocation',true);
- $this->bocommon = &
$this->bo->bocommon;
- $this->so_control_area =
CreateObject('controller.socontrol_area');
- $this->so_control =
CreateObject('controller.socontrol');
-
- $this->type_id =
$this->bo->type_id;
-
- $this->start =
$this->bo->start;
- $this->query =
$this->bo->query;
- $this->sort =
$this->bo->sort;
- $this->order =
$this->bo->order;
- $this->filter =
$this->bo->filter;
- $this->cat_id =
$this->bo->cat_id;
- $this->part_of_town_id =
$this->bo->part_of_town_id;
- $this->district_id =
$this->bo->district_id;
- $this->status =
$this->bo->status;
- $this->allrows =
$this->bo->allrows;
- $this->lookup =
$this->bo->lookup;
- $this->location_code =
$this->bo->location_code;
-
-
self::set_active_menu('controller::control::location_for_check_list');
- }
-
- function index()
- {
- if(phpgw::get_var('phpgw_return_as') == 'json') {
- return $this->query();
- }
- $building_types =
execMethod('property.soadmin_location.read',array());
-
- $type_id = 1;
-
- $category_types =
$this->bocommon->select_category_list(array(
-
'format'=>'filter',
-
'selected' =>
$this->cat_id,
-
'type'
=>'location',
-
'type_id'
=>$type_id,
-
'order'=>'descr'
-
));
-
- $district_list =
$this->bocommon->select_district_list('filter',$this->district_id);
- $default_value = array ('id'=>'','name'=>lang('no
district'));
- array_unshift($district_list,$default_value);
-
- $part_of_town_list =
$this->bocommon->select_part_of_town('filter',$this->part_of_town_id,$this->district_id);
- $default_value = array ('id'=>'','name'=>lang('no part
of town'));
- array_unshift($part_of_town_list,$default_value);
-
- $_role_criteria = array
- (
- 'type' =>
'responsibility_role',
- 'filter' =>
array('location' => ".location.{$type_id}"),
- 'order' => 'name'
- );
-
- $responsibility_roles_list =
execMethod('property.sogeneric.get_list',$_role_criteria);
- $default_value = array ('id'=>'','name'=>lang('no
role'));
- array_unshift ($responsibility_roles,$default_value);
-
- $control_areas_array =
$this->so_control_area->get_control_areas_as_array();
- $controls_array =
$this->so_control->get_controls_by_control_area($control_areas_array[0]['id']);
- $control_id = $control_areas_array[0]['id'];
-
- if($control_id == null)
- $control_id = 0;
-
- $tabs = array( array(
- 'label' =>
lang('View_locations_for_control')
- ), array(
- 'label' =>
lang('Add_locations_for_control'),
- 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicheck_list_for_location.add_location_to_control'))
- ));
-
- $data = array(
- 'tabs' =>
$GLOBALS['phpgw']->common->create_tabs($tabs, 0),
- 'view' =>
"view_locations_for_control",
- 'control_area_array' => $control_areas_array,
- 'control_array' =>
$control_array,
- 'locations_table' => array(
- 'source' =>
self::link(array('menuaction' =>
'controller.uicontrol.get_locations_for_control', 'control_id' => $control_id
,'phpgw_return_as' => 'json')),
- 'field' => array(
- array(
- 'key' => 'id',
- 'label' =>
lang('ControlId'),
- 'sortable' => true,
- ),
- array(
- 'key' => 'title',
- 'label' =>
lang('Property name'),
- 'sortable' =>
false
- ),
- array(
- 'key' =>
'location_code',
- 'label' =>
lang('Address'),
- 'sortable' => false
- ),
- array(
- 'key' => 'loc1_name',
- 'label' =>
lang('Address'),
- 'sortable' => false
- )
- )
- )
- );
-
-
- phpgwapi_yui::load_widget('paginator');
-
- self::add_javascript('controller', 'yahoo',
'control_tabs.js');
- self::add_javascript('controller', 'controller',
'jquery.js');
- self::add_javascript('controller', 'controller',
'ajax.js');
-
-
self::render_template_xsl(array('control_location_tabs', 'common',
'view_locations_for_control'), $data);
- }
-
- function add_location_to_control()
- {
- if(phpgw::get_var('phpgw_return_as') == 'json') {
- return $this->query();
- }
- $building_types =
execMethod('property.soadmin_location.read',array());
-
- $type_id = 1;
-
- $category_types =
$this->bocommon->select_category_list(array(
-
'format'=>'filter',
-
'selected' =>
$this->cat_id,
-
'type'
=>'location',
-
'type_id'
=>$type_id,
-
'order'=>'descr'
-
));
-
- $district_list =
$this->bocommon->select_district_list('filter',$this->district_id);
- $default_value = array ('id'=>'','name'=>lang('no
district'));
- array_unshift($district_list,$default_value);
-
- $part_of_town_list =
$this->bocommon->select_part_of_town('filter',$this->part_of_town_id,$this->district_id);
- $default_value = array ('id'=>'','name'=>lang('no part
of town'));
- array_unshift($part_of_town_list,$default_value);
-
- $_role_criteria = array
- (
- 'type' =>
'responsibility_role',
- 'filter' =>
array('location' => ".location.{$type_id}"),
- 'order' => 'name'
- );
-
- $responsibility_roles_list =
execMethod('property.sogeneric.get_list',$_role_criteria);
- $default_value = array ('id'=>'','name'=>lang('no
role'));
- array_unshift ($responsibility_roles,$default_value);
-
- $control_areas_array =
$this->so_control_area->get_control_areas_as_array();
-
- $tabs = array( array(
- 'label' =>
lang('View_locations_for_control'),
- 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicheck_list_for_location.index'))
-
- ), array(
- 'label' =>
lang('Add_locations_for_control')
- ));
-
- $data = array(
- 'tabs'
=> $GLOBALS['phpgw']->common->create_tabs($tabs, 1),
- 'view'
=> "add_location_to_control",
- 'control_filters' =>
array(
- 'control_area_array' =>
$control_areas_array,
- 'control_array'
=> $control_array
- ),
- 'filter_form' =>
array(
- 'building_types'
=> $building_types,
- 'category_types'
=> $category_types,
- 'district_list'
=> $district_list,
- 'part_of_town_list' =>
$part_of_town_list
- ),
- 'datatable' => array(
- 'source' =>
self::link(array('menuaction' => 'controller.uicheck_list_for_location.index',
'phpgw_return_as' => 'json')),
- 'field' => array(
- array(
- 'key' =>
'location_code',
- 'label' =>
lang('Property'),
- 'sortable' => true,
- 'formatter' =>
'YAHOO.portico.formatLink'
- ),
- array(
- 'key' =>
'loc1_name',
- 'label' =>
lang('Property name'),
- 'sortable' =>
false
- ),
- array(
- 'key' => 'adresse1',
- 'label' =>
lang('Address'),
- 'sortable' => false
- ),
- array(
- 'key' => 'postnummer',
- 'label' => lang('Zip
code'),
- 'sortable' => false
- ),
- array(
- 'key' => 'actions',
- 'hidden' => true
- ),
- array(
- 'key' => 'labels',
- 'hidden' => true
- ),
- array(
- 'key' => 'ajax',
- 'hidden' => true
- )
- )
- )
- );
-
-
- phpgwapi_yui::load_widget('paginator');
-
- self::add_javascript('controller', 'yahoo',
'control_tabs.js');
- self::add_javascript('controller', 'controller',
'jquery.js');
- self::add_javascript('controller', 'controller',
'ajax.js');
-
-
self::render_template_xsl(array('control_location_tabs', 'common',
'add_location_to_control'), $data);
- }
-
- public function query()
- {
- $type_id = phpgw::get_var('type_id', 'int');
- $return_results = phpgw::get_var('results', 'int',
'REQUEST', 0);
-
- $type_id = $type_id ? $type_id : 1;
-
- $location_list = array();
-
- $this->bo->sort = "ASC";
- $this->bo->start = phpgw::get_var('startIndex');
-
- $location_list = $this->bo->read(array('user_id' =>
$user_id, 'role_id' =>$role_id,
'type_id'=>$type_id,'lookup_tenant'=>$lookup_tenant,
-
'lookup'=>$lookup,'allrows'=>$this->allrows,'dry_run'
=>$dry_run,'results' => $return_results));
-
- foreach($location_list as $location)
- {
- $results['results'][]= $location;
- }
-
- $results['total_records'] = $this->bo->total_records;
- $results['start'] = $this->start;
- $results['sort'] = 'location_code';
- $results['dir'] = "ASC";
-
- array_walk($results['results'], array($this,
'add_actions'), array($type));
-
- return $this->yui_results($results);
- }
-
- public function add_actions(&$value, $key, $params)
- {
- unset($value['query_location']);
-
- $value['ajax'] = array();
- $value['actions'] = array();
- $value['labels'] = array();
-
- $value['ajax'][] = false;
- $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'property.uilocation.view',
'location_code' => $value['location_code'])));
- $value['labels'][] = lang('show');
-
- $value['ajax'][] = true;
- $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'controller.uicontrol.add_location_to_control', 'location_code' =>
$value['location_code'])));
- $value['labels'][] = lang('add_location');
- }
- }
+<?php
+ /**
+ * phpGroupWare - controller: a part of a Facilities Management System.
+ *
+ * @author Erink Holm-Larsen <address@hidden>
+ * @author Torstein Vadla <address@hidden>
+ * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc.
http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/
+ * @package property
+ * @subpackage controller
+ * @version $Id$
+ */
+
+ phpgw::import_class('phpgwapi.yui');
+ phpgw::import_class('controller.uicommon');
+ phpgw::import_class('controller.socontrol_area');
+
+ include_class('controller', 'check_list', 'inc/model/');
+ include_class('controller', 'date_generator', 'inc/component/');
+
+ class controller_uicheck_list_for_location extends controller_uicommon
+ {
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+ var $currentapp;
+ var $type_id;
+ var $location_code;
+
+ private $so_control_area;
+ private $so_control;
+ private $so_check_list;
+
+ var $public_functions = array(
+
'index' => true,
+
'view_locations_for_control' => true,
+
'add_location_to_control' => true,
+
'add_check_list_for_location' => true,
+
'save_check_list_for_location' => true,
+
'edit_check_list_for_location' => true
+ );
+
+ function __construct()
+ {
+ parent::__construct();
+
+ $this->bo =
CreateObject('property.bolocation',true);
+ $this->bocommon = &
$this->bo->bocommon;
+ $this->so_control_area =
CreateObject('controller.socontrol_area');
+ $this->so_control =
CreateObject('controller.socontrol');
+ $this->so_check_list =
CreateObject('controller.socheck_list');
+
+ $this->type_id =
$this->bo->type_id;
+
+ $this->start =
$this->bo->start;
+ $this->query =
$this->bo->query;
+ $this->sort =
$this->bo->sort;
+ $this->order =
$this->bo->order;
+ $this->filter =
$this->bo->filter;
+ $this->cat_id =
$this->bo->cat_id;
+ $this->part_of_town_id =
$this->bo->part_of_town_id;
+ $this->district_id =
$this->bo->district_id;
+ $this->status =
$this->bo->status;
+ $this->allrows =
$this->bo->allrows;
+ $this->lookup =
$this->bo->lookup;
+ $this->location_code =
$this->bo->location_code;
+
+
self::set_active_menu('controller::control::location_for_check_list');
+ }
+
+ function index()
+ {
+ if(phpgw::get_var('phpgw_return_as') == 'json') {
+ return $this->query();
+ }
+ $building_types =
execMethod('property.soadmin_location.read',array());
+
+ $type_id = 1;
+
+ $category_types =
$this->bocommon->select_category_list(array(
+
'format'=>'filter',
+
'selected' =>
$this->cat_id,
+
'type'
=>'location',
+
'type_id'
=>$type_id,
+
'order'=>'descr'
+
));
+
+ $district_list =
$this->bocommon->select_district_list('filter',$this->district_id);
+ $default_value = array ('id'=>'','name'=>lang('no
district'));
+ array_unshift($district_list,$default_value);
+
+ $part_of_town_list =
$this->bocommon->select_part_of_town('filter',$this->part_of_town_id,$this->district_id);
+ $default_value = array ('id'=>'','name'=>lang('no part
of town'));
+ array_unshift($part_of_town_list,$default_value);
+
+ $_role_criteria = array
+ (
+ 'type' =>
'responsibility_role',
+ 'filter' =>
array('location' => ".location.{$type_id}"),
+ 'order' => 'name'
+ );
+
+ $responsibility_roles_list =
execMethod('property.sogeneric.get_list',$_role_criteria);
+ $default_value = array ('id'=>'','name'=>lang('no
role'));
+ array_unshift ($responsibility_roles,$default_value);
+
+ $control_areas_array =
$this->so_control_area->get_control_areas_as_array();
+ $controls_array =
$this->so_control->get_controls_by_control_area($control_areas_array[0]['id']);
+ $control_id = $control_areas_array[0]['id'];
+
+ if($control_id == null)
+ $control_id = 0;
+
+ $tabs = array( array(
+ 'label' =>
lang('View_locations_for_control')
+ ), array(
+ 'label' =>
lang('Add_locations_for_control'),
+ 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicheck_list_for_location.add_location_to_control'))
+ ));
+
+ $data = array(
+ 'tabs' =>
$GLOBALS['phpgw']->common->create_tabs($tabs, 0),
+ 'view' =>
"view_locations_for_control",
+ 'control_area_array' => $control_areas_array,
+ 'control_array' =>
$control_array,
+ 'locations_table' => array(
+ 'source' =>
self::link(array('menuaction' =>
'controller.uicontrol.get_locations_for_control', 'control_id' => $control_id
,'phpgw_return_as' => 'json')),
+ 'field' => array(
+ array(
+ 'key' => 'id',
+ 'label' =>
lang('ControlId'),
+ 'sortable' => true,
+ ),
+ array(
+ 'key' => 'title',
+ 'label' =>
lang('Property name'),
+ 'sortable' =>
false
+ ),
+ array(
+ 'key' =>
'location_code',
+ 'label' =>
lang('location_code'),
+ 'sortable' => false
+ ),
+ array(
+ 'key' => 'loc1_name',
+ 'label' =>
lang('Location_name'),
+ 'sortable' => false
+ ),
+ array(
+ 'key' => 'actions',
+ 'hidden' => true
+ ),
+ array(
+ 'key' => 'labels',
+ 'hidden' => true
+ ),
+ array(
+ 'key' => 'ajax',
+ 'hidden' => true
+ ),array(
+ 'key' => 'parameters',
+ 'hidden' => true
+ )
+ )
+ )
+ );
+
+ phpgwapi_yui::load_widget('paginator');
+
+ self::add_javascript('controller', 'yahoo',
'control_tabs.js');
+ self::add_javascript('controller', 'controller',
'jquery.js');
+ self::add_javascript('controller', 'controller',
'ajax.js');
+
+
self::render_template_xsl(array('control_location_tabs', 'common',
'view_locations_for_control'), $data);
+ }
+
+ function add_location_to_control()
+ {
+ if(phpgw::get_var('phpgw_return_as') == 'json') {
+ return $this->query();
+ }
+ $building_types =
execMethod('property.soadmin_location.read',array());
+
+ $type_id = 1;
+
+ $category_types =
$this->bocommon->select_category_list(array(
+
'format'=>'filter',
+
'selected' =>
$this->cat_id,
+
'type'
=>'location',
+
'type_id'
=>$type_id,
+
'order'=>'descr'
+
));
+
+ $district_list =
$this->bocommon->select_district_list('filter',$this->district_id);
+ $default_value = array ('id'=>'','name'=>lang('no
district'));
+ array_unshift($district_list,$default_value);
+
+ $part_of_town_list =
$this->bocommon->select_part_of_town('filter',$this->part_of_town_id,$this->district_id);
+ $default_value = array ('id'=>'','name'=>lang('no part
of town'));
+ array_unshift($part_of_town_list,$default_value);
+
+ $_role_criteria = array
+ (
+ 'type' =>
'responsibility_role',
+ 'filter' =>
array('location' => ".location.{$type_id}"),
+ 'order' => 'name'
+ );
+
+ $responsibility_roles_list =
execMethod('property.sogeneric.get_list',$_role_criteria);
+ $default_value = array ('id'=>'','name'=>lang('no
role'));
+ array_unshift ($responsibility_roles,$default_value);
+
+ $control_areas_array =
$this->so_control_area->get_control_areas_as_array();
+
+ $tabs = array( array(
+ 'label' =>
lang('View_locations_for_control'),
+ 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicheck_list_for_location.index'))
+
+ ), array(
+ 'label' =>
lang('Add_locations_for_control')
+ ));
+
+ $data = array(
+ 'tabs'
=> $GLOBALS['phpgw']->common->create_tabs($tabs, 1),
+ 'view'
=> "add_location_to_control",
+ 'control_filters' =>
array(
+ 'control_area_array' =>
$control_areas_array,
+ 'control_array'
=> $control_array
+ ),
+ 'filter_form' =>
array(
+ 'building_types'
=> $building_types,
+ 'category_types'
=> $category_types,
+ 'district_list'
=> $district_list,
+ 'part_of_town_list' =>
$part_of_town_list
+ ),
+ 'datatable' => array(
+ 'source' =>
self::link(array('menuaction' => 'controller.uicheck_list_for_location.index',
'phpgw_return_as' => 'json')),
+ 'field' => array(
+ array(
+ 'key' =>
'location_code',
+ 'label' =>
lang('Property'),
+ 'sortable' => true,
+ 'formatter' =>
'YAHOO.portico.formatLink'
+ ),
+ array(
+ 'key' =>
'loc1_name',
+ 'label' =>
lang('Property name'),
+ 'sortable' =>
false
+ ),
+ array(
+ 'key' => 'adresse1',
+ 'label' =>
lang('Address'),
+ 'sortable' => false
+ ),
+ array(
+ 'key' => 'postnummer',
+ 'label' => lang('Zip
code'),
+ 'sortable' => false
+ ),
+ array(
+ 'key' => 'actions',
+ 'hidden' => true
+ ),
+ array(
+ 'key' => 'labels',
+ 'hidden' => true
+ ),
+ array(
+ 'key' => 'ajax',
+ 'hidden' => true
+ ),array(
+ 'key' => 'parameters',
+ 'hidden' => true
+ )
+ )
+ )
+ );
+
+ phpgwapi_yui::load_widget('paginator');
+
+ self::add_javascript('controller', 'yahoo',
'control_tabs.js');
+ self::add_javascript('controller', 'controller',
'jquery.js');
+ self::add_javascript('controller', 'controller',
'ajax.js');
+
+
self::render_template_xsl(array('control_location_tabs', 'common',
'add_location_to_control'), $data);
+ }
+
+ function add_check_list_for_location(){
+ $location_code = phpgw::get_var('location_code');
+ $control_id = phpgw::get_var('control_id');
+ $date = phpgw::get_var('date');
+
+ $location_array =
execMethod('property.bolocation.read_single', array('location_code' =>
$location_code));
+ $control = $this->so_control->get_single($control_id);
+
+ if($date == null || $date == ''){
+ $todays_date = mktime(0,0,0, date("m"),
date("d"), date("Y"));
+ $period_start_date = $todays_date;
+
+ if( $control->get_repeat_type() == 1 )
+ {
+ $period_end_date = mktime(0,0,0,
date("m")+1, date("d"), date("Y"));
+ }else if( $control->get_repeat_type() == 2 )
+ {
+ $period_end_date = mktime(0,0,0,
date("m"), date("d"), date("Y") + 1);
+ }else if( $control->get_repeat_type() == 3 )
+ {
+ $period_end_date = mktime(0,0,0,
date("m"), date("d"), date("Y") + $control->get_repeat_interval());
+ }
+
+ $date_generator = new
date_generator($control->get_start_date(), $control->get_end_date(),
$period_start_date, $period_end_date, $control->get_repeat_type(),
$control->get_repeat_interval());
+
+ $calendar_array = $date_generator->get_dates();
+ }
+ else
+ {
+ $calendar_array[] = $date;
+ }
+
+ $data = array
+ (
+ 'location_array' => $location_array,
+ 'control_array' => $control->toArray(),
+ 'calendar_array' => $calendar_array,
+ 'date_format' => $date_format
+ );
+
+ self::add_javascript('controller', 'controller',
'jquery.js');
+ self::add_javascript('controller', 'controller',
'custom_ui.js');
+ self::add_javascript('controller', 'controller',
'jquery-ui.custom.min.js');
+
+
$GLOBALS['phpgw']->css->add_external_file('controller/templates/base/css/jquery-ui.custom.css');
+
+
self::render_template_xsl(array('add_check_list_for_location'), $data);
+ }
+
+ function edit_check_list_for_location(){
+ $check_list_id = phpgw::get_var('check_list_id');
+
+ $check_list =
$this->so_check_list->get_single_with_check_items($check_list_id);
+
+ $date_format =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ $data = array
+ (
+ 'check_list' => $check_list,
+ 'date_format' => $date_format
+ );
+
+ self::add_javascript('controller', 'controller',
'jquery.js');
+ self::add_javascript('controller', 'controller',
'jquery-ui.custom.min.js');
+ self::add_javascript('controller', 'controller',
'custom_ui.js');
+
+
$GLOBALS['phpgw']->css->add_external_file('controller/templates/base/css/jquery-ui.custom.css');
+
+ self::render_template_xsl('edit_check_list', $data);
+ }
+
+ function save_check_list_for_location(){
+ $location_code = phpgw::get_var('location_code');
+ $control_id = phpgw::get_var('control_id');
+ $status = phpgw::get_var('status');
+ $planned_date = strtotime(
phpgw::get_var('planned_date', 'string') );
+ $completed_date = strtotime(
phpgw::get_var('completed_date', 'string') );
+ $deadline_date = strtotime(
phpgw::get_var('deadline_date', 'string') );
+
+ $check_list = new controller_check_list();
+ $check_list->set_location_code($location_code);
+ $check_list->set_control_id($control_id);
+ $check_list->set_status($status);
+ $check_list->set_deadline( $deadline_date );
+ $check_list->set_planned_date($planned_date);
+ $check_list->set_completed_date($completed_date);
+ $check_list->set_equipment_id($equipment_id);
+
+ $this->so_check_list->add($check_list);
+
+ $this->redirect(array('menuaction' =>
'controller.uilocation_check_list.view_calendar', 'year'=>2011, 'month'=>10));
+ }
+
+ public function query(){
+ $type_id = phpgw::get_var('type_id');
+ $return_results = phpgw::get_var('results', 'int',
'REQUEST', 0);
+
+ $type_id = $type_id ? $type_id : 1;
+
+ $location_list = array();
+
+ $this->bo->sort = "ASC";
+ $this->bo->start = phpgw::get_var('startIndex');
+
+ $location_list = $this->bo->read(array('user_id' =>
$user_id, 'role_id' =>$role_id,
'type_id'=>$type_id,'lookup_tenant'=>$lookup_tenant,
+
'lookup'=>$lookup,'allrows'=>$this->allrows,'dry_run'
=>$dry_run));
+
+ $rows_total = $this->bo->read(array('type_id' =>
$type_id, 'allrows' => true));
+
+ foreach($location_list as $location)
+ {
+ $results['results'][]= $location;
+ }
+
+ $results['total_records'] = count($rows_total);
+ $results['start'] = $this->start;
+ $results['sort'] = 'location_code';
+ $results['dir'] = "ASC";
+
+ array_walk($results['results'], array($this,
'add_actions'), array($type));
+
+ return $this->yui_results($results);
+ }
+
+ public function add_actions(&$value, $key, $params)
+ {
+ unset($value['query_location']);
+
+ $value['ajax'] = array();
+ $value['actions'] = array();
+ $value['labels'] = array();
+ $value['parameters'] = array();
+
+ $value['ajax'][] = true;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'controller.uicontrol.add_location_to_control', 'location_code' =>
$value['location_code'])));
+ $value['labels'][] = lang('add_location');
+ $value['parameters'][] = "control_id";
+ }
+ }
Modified: branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php
2011-12-16 18:33:20 UTC (rev 8352)
+++ branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php
2011-12-16 22:20:41 UTC (rev 8353)
@@ -1,812 +1,820 @@
-<?php
- /**
- * phpGroupWare - controller: a part of a Facilities Management System.
- *
- * @author Erink Holm-Larsen <address@hidden>
- * @author Torstein Vadla <address@hidden>
- * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc.
http://www.fsf.org/
- * This file is part of phpGroupWare.
- *
- * phpGroupWare is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * phpGroupWare is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with phpGroupWare; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
- *
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/
- * @package property
- * @subpackage controller
- * @version $Id$
- */
-
- phpgw::import_class('controller.uicommon');
- phpgw::import_class('property.boevent');
- phpgw::import_class('controller.socontrol');
- phpgw::import_class('controller.socontrol_group');
- phpgw::import_class('controller.socontrol_area');
- phpgw::import_class('controller.socontrol_item');
- phpgw::import_class('controller.socontrol_item_list');
- phpgw::import_class('controller.soprocedure');
-
- include_class('controller', 'control', 'inc/model/');
- include_class('controller', 'control_area', 'inc/model/');
- include_class('controller', 'control_item_list', 'inc/model/');
- include_class('controller', 'control_group_list', 'inc/model/');
- include_class('controller', 'check_item', 'inc/model/');
-
- class controller_uicontrol extends controller_uicommon
- {
- private $bo;
- private $so;
- private $so_procedure;
- private $so_control_group;
- private $so_control_area;
- private $so_control_item;
- private $so_control_item_list;
- private $so_control_group_list;
- private $so_check_list_list;
- private $so_check_item;
- private $_category_acl;
-
- public $public_functions = array
- (
- 'index' => true,
- 'control_list' => true,
- 'view' => true,
- 'view_control_details' =>
true,
- 'save_control_details' =>
true,
- 'view_control_groups' =>
true,
- 'save_control_groups' =>
true,
- 'view_control_items' =>
true,
- 'save_control_items' =>
true,
- 'view_check_list'
=> true,
- 'generate_check_lists_for_control' => true,
- 'view_check_lists_for_control' => true,
- 'get_controls_by_control_area' => true,
- 'get_locations_for_control' =>
true,
- 'add_location_to_control' =>
true
- );
-
- public function __construct()
- {
- parent::__construct();
-
- $this->so = CreateObject('controller.socontrol');
- $this->bo = CreateObject('property.boevent',true);
- $this->so_procedure =
CreateObject('controller.soprocedure');
- $this->so_control_group =
CreateObject('controller.socontrol_group');
- $this->so_control_area =
CreateObject('controller.socontrol_area');
- $this->so_control_item =
CreateObject('controller.socontrol_item');
- $this->so_control_item_list =
CreateObject('controller.socontrol_item_list');
- $this->so_control_group_list =
CreateObject('controller.socontrol_group_list');
- $this->so_check_list =
CreateObject('controller.socheck_list');
- $this->so_check_item =
CreateObject('controller.socheck_item');
-
- $config = CreateObject('phpgwapi.config','controller');
- $config->read();
- $this->_category_acl =
isset($config->config_data['acl_at_control_area']) &&
$config->config_data['acl_at_control_area'] == 1 ? true : false;
-
- self::set_active_menu('controller::control');
- }
-
- public function control_list()
- {
- if(phpgw::get_var('phpgw_return_as') == 'json') {
- return $this->query();
- }
- self::add_javascript('controller', 'yahoo',
'datatable.js');
- phpgwapi_yui::load_widget('datatable');
- phpgwapi_yui::load_widget('paginator');
-
-
- // Sigurd: START as categories
- $cats = CreateObject('phpgwapi.categories', -1,
'controller', '.control');
- $cats->supress_info = true;
-
- $control_areas =
$cats->formatted_xslt_list(array('format'=>'filter','selected' =>
$control_area_id,'globals' => true,'use_acl' => $this->_category_acl));
- array_unshift($control_areas['cat_list'],array
('cat_id'=>'','name'=> lang('select value')));
- $control_areas_array2 = array();
- foreach($control_areas['cat_list'] as $cat_list)
- {
- $control_areas_array2[] = array
- (
- 'id' => $cat_list['cat_id'],
- 'name' => $cat_list['name'],
- );
- }
-
-
-
- $data = array(
- 'form' => array(
- 'toolbar' => array(
- 'item' => array(
- array('type' =>
'filter',
- 'name' =>
'status',
- 'text' =>
lang('Status'),
- 'list' => array(
- array(
-
'id' => 'none',
-
'name' => lang('Not selected')
- ),
- array(
-
'id' => 'NEW',
-
'name' => lang('NEW')
- ),
- array(
-
'id' => 'PENDING',
-
'name' => lang('PENDING')
- ),
- array(
-
'id' => 'REJECTED',
-
'name' => lang('REJECTED')
- ),
- array(
-
'id' => 'ACCEPTED',
-
'name' => lang('ACCEPTED')
- )
- )
- ),
- array('type' =>
'filter',
- 'name' =>
'control_areas',
- 'text' =>
lang('Control_area'),
- 'list' =>
$this->so_control_area->get_control_area_select_array(),
- ),
-
- //as categories
- array('type' =>
'filter',
- 'name' =>
'control_areas',
- 'text' =>
lang('Control_area') . 2,
- 'list' =>
$control_areas_array2,
- ),
- array('type' =>
'filter',
- 'name' =>
'responsibilities',
- 'text' =>
lang('Responsibility'),
- 'list' =>
$this->so->get_roles(),
- ),
- array('type' => 'text',
- 'text' =>
lang('searchfield'),
- 'name' =>
'query'
- ),
- array(
- 'type' =>
'submit',
- 'name' =>
'search',
- 'value' =>
lang('Search')
- ),
- array(
- 'type' =>
'link',
- 'value' =>
$_SESSION['showall'] ? lang('Show only active') : lang('Show all'),
- 'href' =>
self::link(array('menuaction' => $this->url_prefix.'.toggle_show_inactive'))
- ),
- array(
- 'type' =>
'link',
- 'value' =>
lang('New control'),
- 'href' =>
self::link(array('menuaction' => 'controller.uicontrol.view_control_details')),
- 'class' =>
'new_item'
- ),
- ),
- ),
- ),
- 'datatable' => array(
- 'source' =>
self::link(array('menuaction' => 'controller.uicontrol.control_list',
'phpgw_return_as' => 'json')),
- 'field' => array(
- array(
- 'key' => 'id',
- 'label' => lang('ID'),
- 'sortable' => true,
- 'formatter' =>
'YAHOO.portico.formatLink'
- ),
- array(
- 'key' => 'title',
- 'label' =>
lang('Control title'),
- 'sortable' =>
false
- ),
- array(
- 'key' => 'description',
- 'label' =>
lang('description'),
- 'sortable' => false
- ),
- array(
- 'key' =>
'control_area_name',
- 'label' =>
lang('Control area'),
- 'sortable' => false
- ),
- array(
- 'key' =>
'responsibility_name',
- 'label' =>
lang('Responsibility'),
- 'sortable' => false
- ),
- array(
- 'key' => 'link',
- 'hidden' => true
- )
- )
- ),
- );
-//_debug_array($data);
-
- self::render_template_xsl('datatable', $data);
- }
-
- public function view_control_details()
- {
- $control_id = phpgw::get_var('id');
-
- if(isset($control_id) && $control_id > 0)
- {
- $control = $this->so->get_single($control_id);
- }
-
- $control_areas_array =
$this->so_control_area->get_control_areas_as_array();
-
- // Sigurd: START as categories
- $cats = CreateObject('phpgwapi.categories', -1,
'controller', '.control');
- $cats->supress_info = true;
-
- $control_areas =
$cats->formatted_xslt_list(array('format'=>'filter','selected' =>
$control_area_id,'globals' => true,'use_acl' => $this->_category_acl));
- array_unshift($control_areas['cat_list'],array
('cat_id'=>'','name'=> lang('select value')));
- $control_areas_array2 = array();
- foreach($control_areas['cat_list'] as $cat_list)
- {
- $control_areas_array2[] = array
- (
- 'id' => $cat_list['cat_id'],
- 'name' => $cat_list['name'],
- );
- }
- // END as categories
-
-
- // Fetches prosedures that are related to first control
area in list
- $control_area_id = $control_areas_array[0]['id'];
- $procedures_array =
$this->so_procedure->get_procedures_by_control_area_id($control_area_id);
- $role_array = $this->so->get_roles();
-
- $tabs = array( array(
- 'label' => "1: " .
lang('Details')
- ), array(
- 'label' => "2: " .
lang('Choose_control_groups')
- ), array(
- 'label' => "3: " .
lang('Choose_control_items')
- ), array(
- 'label' => "4: " .
lang('Sort_check_list')
- ));
-
- $data = array
- (
- 'tabs'
=> $GLOBALS['phpgw']->common->create_tabs($tabs, 0),
- 'view'
=> "control_details",
- 'editable'
=> true,
- 'control'
=> (isset($control)) ? $control->toArray(): null,
- 'control_areas_array' =>
$control_areas_array,
- 'control_areas_array2' =>
array('options' => $control_areas_array2),
- 'procedures_array' =>
$procedures_array,
- 'role_array' =>
$role_array,
- 'start_date' =>
$GLOBALS['phpgw']->yuical->add_listener('start_date',date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],
time())),
- 'end_date'
=>
$GLOBALS['phpgw']->yuical->add_listener('end_date',date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],
''))
- );
-
- self::add_javascript('controller', 'yahoo',
'control_tabs.js');
- self::add_javascript('controller', 'controller',
'jquery.js');
- self::add_javascript('controller', 'controller',
'ajax.js');
- self::render_template_xsl(array('control_tabs',
'control'), $data);
-
- $this->use_yui_editor(array('description'));
- }
-
- public function save_control_details(){
- $control_id = phpgw::get_var('control_id');
-
- // Update control details
- if(isset($control_id) && $control_id > 0 )
- {
- $control = $this->so->get_single($control_id);
- }
- // Add details for control
- else {
- $control = new controller_control();
- }
-
- $control->populate();
-
- if( $control->get_title() == "" ){
- $this->redirect(array('menuaction' =>
'controller.uicontrol.view_control_details', 'control_id'=>$control_id,
'control_area_id'=>$control->get_control_area_id()));
- }
- else
- {
- $control_id = $this->so->store($control);
- $this->redirect(array('menuaction' =>
'controller.uicontrol.view_control_groups', 'control_id'=>$control_id,
'control_area_id'=>$control->get_control_area_id()));
- }
- }
-
- // Displays control groups based on previously chosen control
area
- public function view_control_groups(){
- $control_id = phpgw::get_var('control_id');
- $control = $this->so->get_single($control_id);
-
- // Fetches saved control groups from db
- $saved_control_groups =
$this->so_control_group_list->get_control_groups_by_control_id($control_id);
- $saved_control_group_ids = array();
-
- foreach($saved_control_groups as $control_group){
- $saved_control_group_ids[] =
$control_group->get_id();
- }
-
- // Fetches control groups based on selected control
area
- $control_area = $this->so_control_area->get_single(
$control->get_control_area_id );
- $control_groups_as_array =
$this->so_control_group->get_control_groups_as_array($control->get_control_area_id());
-
- $control_groups = array();
- foreach($control_groups_as_array as $control_group){
- $control_group_id = $control_group['id'];
-
- if( in_array($control_group_id,
$saved_control_group_ids )){
- $control_groups[] = array("checked" =>
1, "control_group" => $control_group);
- }
- else
- {
- $control_groups[] = array("checked" =>
0, "control_group" => $control_group);
- }
- }
-
- $tabs = array(
- array(
- 'label' => "1: " .
lang('Details'),
- 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol.view_control_details',
-
'view' => "view_control_details", 'id' => $control_id))
- ),
- array(
- 'label' => "2: " .
lang('Choose_control_groups')
- ),
- array(
- 'label' => "3: " .
lang('Choose_control_items')
- ),
- array(
- 'label' => "4: " .
lang('Sort_check_list')
- ));
-
- $data = array
- (
- 'tabs'
=> $GLOBALS['phpgw']->common->create_tabs($tabs, 1),
- 'view'
=> "control_groups",
- 'editable'
=> true,
- 'control'
=> $control->toArray(),
- 'control_area'
=> $control_area->toArray(),
- 'control_groups'
=> $control_groups,
- );
-
- self::add_javascript('controller', 'yahoo',
'control_tabs.js');
- self::render_template_xsl(array('control_tabs',
'control_groups'), $data);
- }
-
- public function save_control_groups(){
- $control_id = phpgw::get_var('control_id');
- $control_group_ids =
phpgw::get_var('control_group_ids');
-
- // Deleting earlier saved control groups
-
$this->so_control_group_list->delete_control_groups($control_id);
-
- $group_order_nr = 1;
-
- // Saving control groups
- foreach ($control_group_ids as $control_group_id)
- {
- $control_group_list = new
controller_control_group_list();
-
$control_group_list->set_control_id($control_id);
-
$control_group_list->set_control_group_id($control_group_id);
-
$control_group_list->set_order_nr($group_order_nr);
-
-
$this->so_control_group_list->add($control_group_list);
- $group_order_nr++;
- }
-
- // Redirect: view_control_items
- $this->redirect(array('menuaction' =>
'controller.uicontrol.view_control_items',
-
'control_id'=>$control_id, 'control_group_ids'=>$control_group_ids));
- }
-
- // Gets a comma separated list of control groups, and displays
control items for these groups
- public function view_control_items(){
- $control_id = phpgw::get_var('control_id', 'int');
- $control = $this->so->get_single($control_id);
-
- $control_group_ids =
phpgw::get_var('control_group_ids');
-
- // Fetches saved control items from db
- $saved_control_items =
$this->so_control_item->get_control_items_by_control_id($control_id);
- $saved_control_item_ids = array();
-
- foreach($saved_control_items as $control_item){
- $saved_control_item_ids[] =
$control_item->get_id();
- }
-
- // Array with selected control groups and items
- $groups_with_control_items = array();
-
- // Fetches control items for control group and
populates groups_with_control_items with groups and chosen control items
- foreach ($control_group_ids as $control_group_id)
- {
- $group_control_items_array =
$this->so_control_item->get_control_items_as_array($control_group_id);
-
- $control_items_for_group_array = array();
-
- foreach($group_control_items_array as
$control_item){
- $control_item_id = $control_item['id'];
-
- if( in_array($control_item_id,
$saved_control_item_ids )){
-
$control_items_for_group_array[] = array("checked" => 1, "control_item" =>
$control_item);
- }
- else
- {
-
$control_items_for_group_array[] = array("checked" => 0, "control_item" =>
$control_item);
- }
- }
-
- $control_group =
$this->so_control_group->get_single($control_group_id);
-
- $groups_with_control_items[] =
array("control_group" => $control_group->toArray(), "group_control_items" =>
$control_items_for_group_array);
- }
-
- //print_r( $groups_with_control_items[0] );
-
- $tabs = array(
- array(
- 'label' => "1: " .
lang('Details'),
- 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol.view_control_details', 'view' => "view_control_details",
-
'id' => $control_id))
- ),
- array(
- 'label' => "2: " .
lang('Choose_control_groups'),
- 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol.view_control_groups', 'view' => "view_control_groups",
-
'control_id' => $control_id, 'control_group_ids' => $control_group_ids,
-
'control_area_id' => $control->get_control_area_id()))
- ),
- array('label' => "3: " .
lang('Choose_control_items')),
- array(
- 'label' => "4: " .
lang('Sort_check_list')
- ));
-
- $data = array
- (
- 'tabs'
=> $GLOBALS['phpgw']->common->create_tabs($tabs, 2),
- 'view'
=> 'control_items',
- 'control_group_ids' =>
implode($control_group_ids, ","),
- 'control'
=> $control->toArray(),
- 'groups_with_control_items' =>
$groups_with_control_items
- );
-
- self::add_javascript('controller', 'yahoo',
'control_tabs.js');
- self::add_javascript('controller', 'controller',
'jquery.js');
- self::add_javascript('controller', 'controller',
'custom_ui.js');
- self::render_template_xsl(array('control_tabs',
'choose_control_items'), $data);
- }
-
- // Saves chosen control items through receiving a comma
separated list of control tags (1:2, control_group_id:control_item_id)
- public function save_control_items(){
- $control_id = phpgw::get_var('control_id');
- $control_group_ids = explode(",",
phpgw::get_var('control_group_ids'));
-
- // Fetching selected control items. Tags are on the
format 1:2 (group:item).
- $control_tag_ids = phpgw::get_var('control_tag_ids');
-
- // Deleting earlier saved control groups
-
$this->so_control_group_list->delete_control_groups($control_id);
-
- // Deleting earlier saved control items
-
$this->so_control_item_list->delete_control_items($control_id);
-
- $group_order_nr = 1;
-
- // Saving control groups
- foreach ($control_group_ids as $control_group_id)
- {
- $control_group_list = new
controller_control_group_list();
-
$control_group_list->set_control_id($control_id);
-
$control_group_list->set_control_group_id($control_group_id);
-
$control_group_list->set_order_nr($group_order_nr);
-
-
$this->so_control_group_list->add($control_group_list);
- $group_order_nr++;
- }
-
- // Saving control items if submit save control items is
clicked
- foreach ($control_tag_ids as $control_item_tag)
- {
- // Fetch control_item_id from tag string
- $control_item_id = substr($control_item_tag,
strpos($control_item_tag, ":")+1, strlen($control_item_tag));
-
- // Saves control item
- $control_item_list = new
controller_control_item_list();
- $control_item_list->set_control_id($control_id);
-
$control_item_list->set_control_item_id($control_item_id);
-
$this->so_control_item_list->add($control_item_list);
- }
-
- $this->redirect(array('menuaction' =>
'controller.uicontrol.view_check_list', 'control_id'=>$control_id,
'control_title'=>$control_title, 'control_group_ids'=>$control_group_ids,
'control_tag_ids'=>$control_tag_ids ));
- }
-
- public function view_check_list(){
- $control_id = phpgw::get_var('control_id');
- $control = $this->so->get_single($control_id);
-
- $control_group_ids =
phpgw::get_var('control_group_ids');
-
- // Fetching selected control tag items. Tags are on the
format 1:2 (control_group_id:control_item_id)
- $control_tag_ids = phpgw::get_var('control_tag_ids');
-
- $control_group_ids = array();
-
- //Putting control_group_ids in array control_group_ids
- foreach ($control_tag_ids as $control_tag)
- {
- // Fetching group id from tag
- $control_group_id = substr($control_tag, 0,
strpos($control_tag, ":"));
-
- if(!in_array($control_group_id,
$control_group_ids))
- $control_group_ids[] =
$control_group_id;
- }
-
- $saved_groups_with_items_array = array();
-
- //Populating array with saved control items for each
group
- foreach ($control_group_ids as $control_group_id)
- {
- $saved_control_items =
$this->so_control_item->get_control_items_by_control_id_and_group($control_id,
$control_group_id);
-
- $control_group =
$this->so_control_group->get_single($control_group_id);
-
- $control_item =
$this->so_control_item->get_single($control_item_id);
-
- $saved_groups_with_items_array[] =
array("control_group" => $control_group->toArray(), "control_items" =>
$saved_control_items);
- }
-
- $tabs = array(
- array(
- 'label' => "1: " .
lang('Details'),
- 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol.view_control_details',
-
'view' => "view_control_details", 'id' => $control_id))
- ),array(
- 'label' => "2: " .
lang('Choose_control_groups'),
- 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol.view_control_groups',
-
'view' => "view_control_groups", 'control_id' => $control_id,
-
'control_group_ids' => $control_group_ids,
-
'control_area_id' => $control->get_control_area_id()))
- ),array(
- 'label' => "3: " .
lang('Choose_control_items'),
- 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol.view_control_items',
-
'view' => "view_control_items", 'control_id' => $control_id,
-
'control_group_ids' => $control_group_ids))
- ),array('label' => "4: " .
lang('Sort_check_list')
- )
-
- );
-
- $data = array
- (
- 'tabs' =>
$GLOBALS['phpgw']->common->create_tabs($tabs, 3),
- 'view' =>
"sort_check_list",
- 'control' =>
$control->toArray(),
- 'saved_groups_with_items_array' =>
$saved_groups_with_items_array
- );
-
- self::add_javascript('controller', 'yahoo',
'control_tabs.js');
- self::add_javascript('controller', 'controller',
'jquery.js');
- self::add_javascript('controller', 'controller',
'custom_ui.js');
- self::add_javascript('controller', 'controller',
'yui_min_3_4_3.js');
- self::add_javascript('controller', 'controller',
'custom_drag_drop.js');
- self::add_javascript('controller', 'controller',
'ajax.js');
- self::render_template_xsl(array('control_tabs',
'sort_check_list'), $data);
- }
-
- public function generate_check_lists_for_control(){
- $control_id = phpgw::get_var('control_id');
- $control = $this->so->get_single($control_id);
-
- $start_date = $control->get_start_date();
- $end_date = $control->get_end_date();
- $repeat_type = $control->get_repeat_type();
- $repeat_interval = $control->get_repeat_interval();
-
- $status = FALSE;
- $comment = "Kommentar for sjekkliste";
- $deadline = $start_date;
-
- // Saving check_list
- $new_check_list = new controller_check_list();
- $new_check_list->set_control_id( $control_id );
- $new_check_list->set_status( $status );
- $new_check_list->set_comment( $comment );
- $new_check_list->set_deadline( $deadline );
-
- $check_list_id = $this->so_check_list->store(
$new_check_list );
-
- $control_items_list =
$this->so_control_item->get_control_items_by_control_id($control_id);
-
- foreach($control_items_list as $control_item){
-
- $status = '0';
- $comment = "Kommentar for sjekk item";
-
- // Saving check_items for a list
- $new_check_item = new controller_check_item();
- $new_check_item->set_check_list_id(
$check_list_id );
-
- $new_check_item->set_control_item_id(
$control_item->get_id() );
- $new_check_item->set_status( $status );
- $new_check_item->set_comment( $comment );
-
- $saved_check_item =
$this->so_check_item->store( $new_check_item );
- }
-
- $this->redirect(array('menuaction' =>
'controller.uicontrol.view_check_lists_for_control', 'control_id'=>$control_id
));
- }
-
- public function view_check_lists_for_control()
- {
- $control_id = phpgw::get_var('control_id');
- $control = $this->so->get_single($control_id);
-
- $date_format =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-
- $check_list_array =
$this->so_check_list->get_check_lists_for_control( $control_id );
-
- $tabs = array(
- array(
- 'label' => "1: " .
lang('Details'),
- 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol.view_control_details',
-
'view' => "view_control_details", 'id' => $control_id))
- ),array(
- 'label' => "2: " .
lang('Choose_control_groups'),
- 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol.view_control_groups',
-
'view' => "view_control_groups", 'control_id' => $control_id,
-
'control_group_ids' => $control_group_ids,
-
'control_area_id' => $control->get_control_area_id()))
- ),array(
- 'label' => "3: " .
lang('Choose_control_items'),
- 'link' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'controller.uicontrol.view_control_items',
-
'view' => "view_control_items", 'control_id' => $control_id,
-
'control_group_ids' => $control_group_ids))
- ),array('label' => "4: " .
lang('Sort_check_list')
- )
- );
-
- $data = array
- (
- 'tabs' =>
$GLOBALS['phpgw']->common->create_tabs($tabs, 4),
- 'view' =>
"view_check_lists",
- 'control_as_array' => $control->toArray(),
- 'check_list_array' => $check_list_array,
- 'date_format' => $date_format
- );
-
- self::render_template_xsl(array('control_tabs',
'tab_view_check_lists'), $data);
- self::add_javascript('controller', 'yahoo',
'control_tabs.js');
- }
-
- // Returns control list info as JSON
- public function get_controls_by_control_area()
- {
- $control_area_id = phpgw::get_var('control_area_id');
-
- $controls_array =
$this->so->get_controls_by_control_area($control_area_id);
-
- if(count($controls_array)>0)
- return json_encode( $controls_array );
- else
- return null;
- }
-
- // Returns locations for a control
- public function get_locations_for_control()
- {
- $control_id = phpgw::get_var('control_id');
- $locations_for_control_array =
$this->so->get_locations_for_control($control_id);
-
- foreach($locations_for_control_array as $location)
- {
- $results['results'][]= $location;
- }
-
- $results['total_records'] = count(
$locations_for_control_array );
- $results['start'] = 1;
- $results['sort'] = 'location_code';
-
- array_walk($results['results'], array($this,
'add_actions'), array($type));
-
- return $this->yui_results($results);
- }
-
- public function add_location_to_control()
- {
- $control_id = phpgw::get_var('control_id');
- $location_code = phpgw::get_var('location_code');
-
- $this->so->add_location_to_control($control_id,
$location_code);
- }
-
- public function get_bim_types()
- {
- return $this->so->get_bim_types();
- }
-
- public function query()
- {
- $params = array(
- 'start' => phpgw::get_var('startIndex', 'int',
'REQUEST', 0),
- 'results' => phpgw::get_var('results', 'int',
'REQUEST', null),
- 'query' => phpgw::get_var('query'),
- 'sort' => phpgw::get_var('sort'),
- 'dir' => phpgw::get_var('dir'),
- 'filters' => $filters
- );
-
- $ctrl_area = phpgw::get_var('control_areas');
- if(isset($ctrl_area) && $ctrl_area > 0)
- {
- $filters['control_areas'] = $ctrl_area;
- }
- $responsibility = phpgw::get_var('responsibilities');
- if(isset($responsibility) && $responsibility > 0)
- {
- $filters['responsibilities'] = $responsibility;
- }
-
- $search_for = phpgw::get_var('query');
-
-
if($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] > 0)
- {
- $user_rows_per_page =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else {
- $user_rows_per_page = 10;
- }
-
- // YUI variables for paging and sorting
- $start_index = phpgw::get_var('startIndex', 'int');
- $num_of_objects = phpgw::get_var('results', 'int',
'GET', $user_rows_per_page);
- $sort_field = phpgw::get_var('sort');
- if($sort_field == null)
- {
- $sort_field = 'control_group_id';
- }
- $sort_ascending = phpgw::get_var('dir') == 'desc' ?
false : true;
- //Create an empty result set
- $records = array();
-
- //Retrieve a contract identifier and load corresponding
contract
- $control_id = phpgw::get_var('control_id');
- if(isset($control_id))
- {
- $control = $this->so->get_single($control_id);
- }
-
- $result_objects = $this->so->get($start_index,
$num_of_objects, $sort_field, $sort_ascending, $search_for, $search_type,
$filters);
- $object_count = $this->so->get_count($search_for,
$search_type, $filters);
- //var_dump($result_objects);
-
- $results = array();
-
- foreach($result_objects as $control_obj)
- {
- $results['results'][] =
$control_obj->serialize();
- }
-
- $results['total_records'] = $object_count;
- $results['start'] = $params['start'];
- $results['sort'] = $params['sort'];
- $results['dir'] = $params['dir'];
-
- array_walk($results["results"], array($this,
"_add_links"), "controller.uicontrol.view_control_details");
-
- return $this->yui_results($results);
- }
- }
+<?php
+ /**
+ * phpGroupWare - controller: a part of a Facilities Management System.
+ *
+ * @author Erink Holm-Larsen <address@hidden>
+ * @author Torstein Vadla <address@hidden>
+ * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc.
http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/
+ * @package property
+ * @subpackage controller
+ * @version $Id$
+ */
+
+ phpgw::import_class('controller.uicommon');
+ phpgw::import_class('property.boevent');
+ phpgw::import_class('controller.socontrol');
+ phpgw::import_class('controller.socontrol_group');
+ phpgw::import_class('controller.socontrol_area');
+ phpgw::import_class('controller.socontrol_item');
+ phpgw::import_class('controller.socontrol_item_list');
+ phpgw::import_class('controller.soprocedure');
+
+ include_class('controller', 'control', 'inc/model/');
+ include_class('controller', 'control_area', 'inc/model/');
+ include_class('controller', 'control_item_list', 'inc/model/');
+ include_class('controller', 'control_group_list', 'inc/model/');
+ include_class('controller', 'check_item', 'inc/model/');
+
+ class controller_uicontrol extends controller_uicommon
+ {
+ private $bo;
+ private $so;
+ private $so_procedure;
+ private $so_control_group;
+ private $so_control_area;
+ private $so_control_item;
+ private $so_control_item_list;
+ private $so_control_group_list;
+ private $so_check_list_list;
+ private $so_check_item;
+ private $_category_acl;
+
+ public $public_functions = array
+ (
+ 'index' => true,
+ 'control_list' => true,
+ 'view' => true,
+ 'view_control_details' =>
true,
+ 'save_control_details' =>
true,
+ 'view_control_groups' =>
true,
+ 'save_control_groups' =>
true,
+ 'view_control_items' =>
true,
+ 'save_control_items' =>
true,
+ 'view_check_list'
=> true,
+ 'generate_check_lists_for_control' => true,
+ 'view_check_lists_for_control' => true,
+ 'get_controls_by_control_area' => true,
+ 'get_locations_for_control' =>
true,
+ 'add_location_to_control' =>
true
+ );
+
+ public function __construct()
+ {
+ parent::__construct();
+
+ $this->so = CreateObject('controller.socontrol');
+ $this->bo = CreateObject('property.boevent',true);
+ $this->so_procedure =
CreateObject('controller.soprocedure');
+ $this->so_control_group =
CreateObject('controller.socontrol_group');
+ $this->so_control_area =
CreateObject('controller.socontrol_area');
+ $this->so_control_item =
CreateObject('controller.socontrol_item');
+ $this->so_control_item_list =
CreateObject('controller.socontrol_item_list');
+ $this->so_control_group_list =
CreateObject('controller.socontrol_group_list');
+ $this->so_check_list =
CreateObject('controller.socheck_list');
+ $this->so_check_item =
CreateObject('controller.socheck_item');
+
+ $config = CreateObject('phpgwapi.config','controller');
+ $config->read();
+ $this->_category_acl =
isset($config->config_data['acl_at_control_area']) &&
$config->config_data['acl_at_control_area'] == 1 ? true : false;
+
+ self::set_active_menu('controller::control');
+ }
+
+ public function control_list()
+ {
+ if(phpgw::get_var('phpgw_return_as') == 'json') {
+ return $this->query();
+ }
+ self::add_javascript('controller', 'yahoo',
'datatable.js');
+ phpgwapi_yui::load_widget('datatable');
+ phpgwapi_yui::load_widget('paginator');
+
+ // Sigurd: Start categories
+ $cats = CreateObject('phpgwapi.categories', -1,
'controller', '.control');
+ $cats->supress_info = true;
+
+ $control_areas =
$cats->formatted_xslt_list(array('format'=>'filter','selected' =>
$control_area_id,'globals' => true,'use_acl' => $this->_category_acl));
+ array_unshift($control_areas['cat_list'],array
('cat_id'=>'','name'=> lang('select value')));
+ $control_areas_array2 = array();
+ foreach($control_areas['cat_list'] as $cat_list)
+ {
+ $control_areas_array2[] = array
+ (
+ 'id' => $cat_list['cat_id'],
+ 'name' => $cat_list['name'],
+ );
+ }
+ // END categories
+
+ $data = array(
+ 'form' => array(
+ 'toolbar' => array(
+ 'item' => array(
+ array('type' =>
'filter',
+ 'name' =>
'status',
+ 'text' => lang('Status'),
+ 'list' => array(
+ array(
@@ Diff output truncated at 153600 characters. @@
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [8353] Merge 8283:8352 from trunk,
Sigurd Nes <=