[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] property inc/class.acl2.inc.php inc/class.boXpo...
From: |
Sigurd Nes |
Subject: |
[Phpgroupware-cvs] property inc/class.acl2.inc.php inc/class.boXpo... |
Date: |
Fri, 27 Jan 2006 14:06:02 +0000 |
CVSROOT: /sources/phpgroupware
Module name: property
Branch:
Changes by: Sigurd Nes <address@hidden> 06/01/27 14:05:59
Modified files:
inc : class.acl2.inc.php class.boXport.inc.php
class.boactor.inc.php class.boadmin.inc.php
class.boadmin_entity.inc.php
class.boadmin_location.inc.php
class.boagreement.inc.php class.boalarm.inc.php
class.boasync.inc.php class.bob_account.inc.php
class.bocategory.inc.php class.bocommon.inc.php
class.bocustom.inc.php class.bodocument.inc.php
class.boentity.inc.php class.bogab.inc.php
class.boinvestment.inc.php
class.boinvoice.inc.php
class.bolocation.inc.php class.bolookup.inc.php
class.bometer.inc.php class.bop_of_town.inc.php
class.bopricebook.inc.php
class.boproject.inc.php class.borequest.inc.php
class.bos_agreement.inc.php
class.bostandard_2.inc.php
class.bostandard_3.inc.php
class.bostandard_entity.inc.php
class.botemplate.inc.php
class.botenant_claim.inc.php
class.botts.inc.php class.bowo_hour.inc.php
class.boworkorder.inc.php
class.custom_functions.inc.php
class.excel.inc.php class.historylog.inc.php
class.menu.inc.php class.pdf.inc.php
class.soXport.inc.php class.soactor.inc.php
class.soadmin.inc.php
class.soadmin_entity.inc.php
class.soadmin_location.inc.php
class.soagreement.inc.php class.soalarm.inc.php
class.soasync.inc.php class.sob_account.inc.php
class.socategory.inc.php class.socommon.inc.php
class.socustom.inc.php class.sodocument.inc.php
class.soentity.inc.php class.sogab.inc.php
class.soinvestment.inc.php
class.soinvoice.inc.php
class.solocation.inc.php class.solookup.inc.php
class.someter.inc.php class.sop_of_town.inc.php
class.sopricebook.inc.php
class.soproject.inc.php class.sorequest.inc.php
class.sos_agreement.inc.php
class.sostandard_2.inc.php
class.sostandard_3.inc.php
class.sostandard_entity.inc.php
class.sotemplate.inc.php
class.sotenant_claim.inc.php
class.sotts.inc.php class.sotts2.inc.php
class.sowo_hour.inc.php
class.soworkorder.inc.php class.uiXport.inc.php
class.uiactor.inc.php class.uiadmin.inc.php
class.uiadmin_entity.inc.php
class.uiadmin_location.inc.php
class.uiagreement.inc.php class.uialarm.inc.php
class.uiasync.inc.php class.uib_account.inc.php
class.uicategory.inc.php class.uicustom.inc.php
class.uidocument.inc.php class.uientity.inc.php
class.uigab.inc.php class.uiinvestment.inc.php
class.uiinvoice.inc.php
class.uilocation.inc.php class.uilookup.inc.php
class.uimeter.inc.php class.uip_of_town.inc.php
class.uipricebook.inc.php
class.uiproject.inc.php class.uirequest.inc.php
class.uis_agreement.inc.php
class.uistandard_2.inc.php
class.uistandard_3.inc.php
class.uistandard_entity.inc.php
class.uitemplate.inc.php
class.uitenant_claim.inc.php
class.uitts.inc.php class.uiwo_hour.inc.php
class.uiworkorder.inc.php hook_admin.inc.php
hook_help.inc.php hook_home.inc.php
hook_manual.inc.php hook_preferences.inc.php
hook_settings.inc.php
templates/base : invoice.xsl
templates/default: invoice.xsl
Log message:
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.acl2.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.boXport.inc.php.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.boactor.inc.php.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.boadmin.inc.php.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.boadmin_entity.inc.php.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.boadmin_location.inc.php.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.boagreement.inc.php.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.boalarm.inc.php.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.boasync.inc.php.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.bob_account.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.bocategory.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.bocommon.inc.php.diff?tr1=1.19&tr2=1.20&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.bocustom.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.bodocument.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.boentity.inc.php.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.bogab.inc.php.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.boinvestment.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.boinvoice.inc.php.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.bolocation.inc.php.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.bolookup.inc.php.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.bometer.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.bop_of_town.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.bopricebook.inc.php.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.boproject.inc.php.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.borequest.inc.php.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.bos_agreement.inc.php.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.bostandard_2.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.bostandard_3.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.bostandard_entity.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.botemplate.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.botenant_claim.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.botts.inc.php.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.bowo_hour.inc.php.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.boworkorder.inc.php.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.custom_functions.inc.php.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.excel.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.historylog.inc.php.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.menu.inc.php.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.pdf.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.soXport.inc.php.diff?tr1=1.19&tr2=1.20&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.soactor.inc.php.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.soadmin.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.soadmin_entity.inc.php.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.soadmin_location.inc.php.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.soagreement.inc.php.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.soalarm.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.soasync.inc.php.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.sob_account.inc.php.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.socategory.inc.php.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.socommon.inc.php.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.socustom.inc.php.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.sodocument.inc.php.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.soentity.inc.php.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.sogab.inc.php.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.soinvestment.inc.php.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.soinvoice.inc.php.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.solocation.inc.php.diff?tr1=1.19&tr2=1.20&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.solookup.inc.php.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.someter.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.sop_of_town.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.sopricebook.inc.php.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.soproject.inc.php.diff?tr1=1.24&tr2=1.25&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.sorequest.inc.php.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.sos_agreement.inc.php.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.sostandard_2.inc.php.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.sostandard_3.inc.php.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.sostandard_entity.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.sotemplate.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.sotenant_claim.inc.php.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.sotts.inc.php.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.sotts2.inc.php.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.sowo_hour.inc.php.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.soworkorder.inc.php.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uiXport.inc.php.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uiactor.inc.php.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uiadmin.inc.php.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uiadmin_entity.inc.php.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uiadmin_location.inc.php.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uiagreement.inc.php.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uialarm.inc.php.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uiasync.inc.php.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uib_account.inc.php.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uicategory.inc.php.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uicustom.inc.php.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uidocument.inc.php.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uientity.inc.php.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uigab.inc.php.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uiinvestment.inc.php.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uiinvoice.inc.php.diff?tr1=1.20&tr2=1.21&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uilocation.inc.php.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uilookup.inc.php.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uimeter.inc.php.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uip_of_town.inc.php.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uipricebook.inc.php.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uiproject.inc.php.diff?tr1=1.22&tr2=1.23&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uirequest.inc.php.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uis_agreement.inc.php.diff?tr1=1.22&tr2=1.23&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uistandard_2.inc.php.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uistandard_3.inc.php.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uistandard_entity.inc.php.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uitemplate.inc.php.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uitenant_claim.inc.php.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uitts.inc.php.diff?tr1=1.27&tr2=1.28&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uiwo_hour.inc.php.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uiworkorder.inc.php.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/hook_admin.inc.php.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/hook_help.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/hook_home.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/hook_manual.inc.php.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/hook_preferences.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/hook_settings.inc.php.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/templates/base/invoice.xsl.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/templates/default/invoice.xsl.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
Patches:
Index: property/inc/class.acl2.inc.php
diff -u property/inc/class.acl2.inc.php:1.5 property/inc/class.acl2.inc.php:1.6
--- property/inc/class.acl2.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/class.acl2.inc.php Fri Jan 27 14:05:42 2006
@@ -1,670 +1,670 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage core
- * @version $Id: class.acl2.inc.php,v 1.5 2005/05/12 21:26:28 sigurdne
Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class acl2
- {
- var $account_id;
- var $host_id;
- var $app_id;
- var $memberships = Array(0=>1); //group 0 is for all users
- var $memberships_sql = ',0'; //group 0 is for all users
- var $rights_cache = Array();
- var $masks_cache = Array();
- var $previous_location; // used for inheritance
- var $db;
-
-
/*************************************************************************\
- * These lines load up the templates class and set some default
values *
-
\*************************************************************************/
- function acl2()
- {
- $expected_args[0] =
Array('name'=>'account_id','default'=>$GLOBALS['phpgw_info']['user']['account_id'],
'type'=>'number');
- $expected_args[1] =
Array('name'=>'host_id','default'=>0, 'type'=>'number');
- $expected_args[2] =
Array('name'=>'app_id','default'=>$GLOBALS['phpgw']->applications->data[$GLOBALS['phpgw_info']['flags']['currentapp']]['id'],
'type'=>'number');
- $recieved_args = func_get_args();
- $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account_id = $args['account_id'];
- $this->host_id = $args['host_id'];
- $this->app_id = $args['app_id'];
-
- if
($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
- {
- $this->like = "ILIKE";
- }
- else
- {
- $this->like = "LIKE";
- }
-
-
- }
-
- function get_memberships ()
- {
- $expected_args[0] =
Array('name'=>'account_id','default'=>$this->account_id, 'type'=>'number');
- $recieved_args = func_get_args();
- $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
-
- $sql = "SELECT acl_location,acl_rights FROM fm_acl2
- WHERE (
acl_host='".$this->host_id."' and acl_appid = 0 and acl_account =
".$args['account_id'].")";
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
-
if(!isset($this->memberships[$this->db->f('acl_location')]))
- {
-
$this->memberships[$this->db->f('acl_location')] = $this->db->f('acl_rights');
- $this->memberships_sql .=
','.$this->db->f('acl_location');
-
$this->get_memberships(Array('account_id'=>$this->db->f('acl_location')));
- }
- }
- }
-
-
- function cache_rights()
- {
- $expected_args[0] =
Array('name'=>'location','default'=>'##REQUIRED##', 'type'=>'alphanumeric');
- $expected_args[1] =
Array('name'=>'app_id','default'=>$this->app_id, 'type'=>'number');
- $expected_args[2] =
Array('name'=>'account_id','default'=>$this->account_id, 'type'=>'number');
- $expected_args[3] =
Array('name'=>'grantor','default'=>False, 'type'=>'any');
- $expected_args[4] =
Array('name'=>'no_effective','default'=>false, 'type'=>'any');
-
- $recieved_args = func_get_args();
- $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
-
-
if(isset($this->rights_cache[$args['app_id']][$args['account_id']][$args['location']]))
- {
- return;
- }
-
- $sql = "SELECT
acl_rights,acl_type,acl_data,acl_location FROM fm_acl2 WHERE (acl_appid =
'".$args['app_id']."' ";
- $sql .= " and (acl_account in
(".$args['account_id']."".$this->memberships_sql.'))';
- $sql .= " and acl_location = '". $args['location'] .
"'";
-
- if($args['grantor']>0)
- {
- $sql .= " and (grantor=" . $args['grantor'] .
")";
- }
- else
- {
- $sql .= " and (grantor is NULL)";
- }
-
- $sql .= ') ORDER BY acl_location, acl_type DESC';
-
- $this->db->query($sql,__LINE__,__FILE__);
- while($this->db->next_record())
- {
-
if($this->rights_cache[$args['app_id']][$args['account_id']][$args['location']]
== 0)
- {
-
$this->rights_cache[$args['app_id']][$args['account_id']][$this->db->f('acl_location')]
= 0;
- }
-
-
if($this->masks_cache[$args['app_id']][$args['account_id']][$args['location']]
== 0)
- {
-
$this->masks_cache[$args['app_id']][$args['account_id']][$this->db->f('acl_location')]
= 0;
- }
-
- if((int)$this->db->f('acl_type') == 0)
- {
-
$this->rights_cache[$args['app_id']][$args['account_id']][$this->db->f('acl_location')]
=
$this->bit_set($this->rights_cache[$args['app_id']][$args['account_id']][$this->db->f('acl_location')],(int)$this->db->f('acl_rights'));
- }
- else
- {
-
$this->masks_cache[$args['app_id']][$args['account_id']][$this->db->f('acl_location')]
=
$this->bit_set($this->rights_cache[$args['app_id']][$args['account_id']][$this->db->f('acl_location')],(int)$this->db->f('acl_rights'));
- }
-
- if(!$this->db->f('acl_rights'))
- {
-
$this->rights_cache[$args['app_id']][$args['account_id']][$args['location']]=0;
-
$this->masks_cache[$args['app_id']][$args['account_id']][$args['location']]=0;
- }
-
- if(!$args['no_effective'])
- {
-
$this->rights_cache[$args['app_id']][$args['account_id']][$this->db->f('acl_location')]
=
$this->bit_mask($this->rights_cache[$args['app_id']][$args['account_id']][$args['location']],
$this->masks_cache[$args['app_id']][$args['account_id']][$args['location']]);
- }
-
- }
- }
-
-
- function check_grant()
- {
- $expected_args[0] =
Array('name'=>'grantor','default'=>$this->account_id, 'type'=>'number');
- $expected_args[1] =
Array('name'=>'location','default'=>'##REQUIRED##', 'type'=>'alphanumeric');
- $expected_args[2] =
Array('name'=>'required','default'=>1, 'type'=>'number');
- $expected_args[3] =
Array('name'=>'account_id','default'=>$this->account_id, 'type'=>'number');
- $expected_args[4] =
Array('name'=>'app_id','default'=>$this->app_id, 'type'=>'number');
- $expected_args[5] =
Array('name'=>'no_membership','default'=>false, 'type'=>'number');
- $expected_args[6] =
Array('name'=>'acl_type','default'=>0, 'type'=>'number');
- $expected_args[7] =
Array('name'=>'no_effective','default'=>false, 'type'=>'any');
- $recieved_args = func_get_args();
- $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
-
- if(!$args['no_membership'])
- {
- $memberships =
$GLOBALS['phpgw']->accounts->membership($args['account_id']);
-
- while (is_array($memberships) &&
list(,$account) = each($memberships))
- {
- $member_of[] = $account['account_id'];
- }
-
- if($member_of)
- {
- $this->memberships_sql = ',' .
@implode(",",$member_of);
- }
- }
-
-
$this->cache_rights($args['location'],$args['app_id'],$args['account_id'],$args['grantor'],$args['no_effective']);
- if($args['acl_type']==0)
- {
- return
$this->bit_check($this->rights_cache[$args['app_id']][$args['account_id']][$args['location']],$args['required']);
- }
- else
- {
- return
$this->bit_check($this->masks_cache[$args['app_id']][$args['account_id']][$args['location']],$args['required']);
- }
- }
-
- function check()
- {
- $expected_args[0] =
Array('name'=>'location','default'=>'##REQUIRED##', 'type'=>'alphanumeric');
- $expected_args[1] =
Array('name'=>'required','default'=>1, 'type'=>'number');
- $expected_args[2] =
Array('name'=>'account_id','default'=>$this->account_id, 'type'=>'number');
- $expected_args[3] =
Array('name'=>'app_id','default'=>$this->app_id, 'type'=>'number');
- $expected_args[4] =
Array('name'=>'no_membership','default'=>false, 'type'=>'number');
- $expected_args[5] =
Array('name'=>'acl_type','default'=>0, 'type'=>'number');
- $expected_args[6] =
Array('name'=>'no_effective','default'=>false, 'type'=>'any');
- $recieved_args = func_get_args();
- $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
-
- if(!$args['no_membership'])
- {
- $memberships =
$GLOBALS['phpgw']->accounts->membership($args['account_id']);
-
- while (is_array($memberships) &&
list(,$account) = each($memberships))
- {
- $member_of[] = $account['account_id'];
- }
-
- if($member_of)
- {
- $this->memberships_sql = ',' .
@implode(",",$member_of);
- }
- }
-
-
$this->cache_rights($args['location'],$args['app_id'],$args['account_id'],False,$args['no_effective']);
- if($args['acl_type']==0)
- {
- return
$this->bit_check($this->rights_cache[$args['app_id']][$args['account_id']][$args['location']],$args['required']);
- }
- else
- {
- return
$this->bit_check($this->masks_cache[$args['app_id']][$args['account_id']][$args['location']],$args['required']);
- }
- }
-
- /*!
- @function add
- @abstract Adds ACL record to $acl->data
- @discussion Adds ACL record to $acl->data. <br>
- Syntax: array add() <br>
- Example1: acl->add();
- @param $appname default False derives value from
$phpgw_info['flags']['currentapp']
- @param $location location
- @param $rights rights
- */
- function add()
- {
- $expected_args[0] =
Array('name'=>'location','default'=>'##REQUIRED##', 'type'=>'alphanumeric');
- $expected_args[1] =
Array('name'=>'rights','default'=>1, 'type'=>'number');
- $expected_args[2] =
Array('name'=>'account_id','default'=>$this->account_id, 'type'=>'number');
- $expected_args[3] = Array('name'=>'type','default'=>0,
'type'=>'number');
- $expected_args[4] =
Array('name'=>'app_id','default'=>$this->app_id, 'type'=>'number');
- $expected_args[5] =
Array('name'=>'data','default'=>NULL, 'type'=>'any');
- $recieved_args = func_get_args();
- $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
-
- $sql = "SELECT acl_rights FROM fm_acl2 WHERE (acl_appid
= '".$args['app_id']."' ";
- $sql .= " and acl_account = ".$args['account_id'];
- $sql .= " and acl_location = '".$args['location']."'
and acl_type=".$args['type']." and grantor is NULL)";
- $this->db->query($sql,__LINE__,__FILE__);
- if($this->db->num_rows() != 0)
- {
- $this->db->next_record();
- $newrights = $this->bit_set($args['rights'],
(int)$this->db->f('acl_rights'));
- $sql = "UPDATE fm_acl2 SET acl_rights
=".$newrights;
- $sql .= " WHERE acl_host=".$this->host_id." AND
acl_appid=".$args['app_id']." AND acl_account=".$args['account_id']." AND
acl_location='".$args['location']."' AND acl_type=".$args['type'];
- }
- else
- {
- $sql = "INSERT INTO fm_acl2
(acl_host,acl_appid,acl_account,acl_location,acl_rights,acl_type,acl_data)
VALUES
(".$this->host_id.",".$args['app_id'].",".$args['account_id'].",'".$args['location']."',".$args['rights'].",".$args['type'].",'".$args['data']."')";
- }
- $this->db->query($sql,__LINE__,__FILE__);
- $this->rights_cache = Array();
- $this->masks_cache = Array();
- }
-
- function set_grant() //inheritance is saved to the database
- {
- $expected_args[0] =
Array('name'=>'location','default'=>'##REQUIRED##', 'type'=>'alphanumeric');
- $expected_args[1] =
Array('name'=>'rights','default'=>1, 'type'=>'number');
- $expected_args[2] =
Array('name'=>'account_id','default'=>$this->account_id, 'type'=>'number');
- $expected_args[3] = Array('name'=>'type','default'=>0,
'type'=>'number');
- $expected_args[4] =
Array('name'=>'grantor','default'=>NULL, 'type'=>'any');
- $expected_args[5] =
Array('name'=>'app_id','default'=>$this->app_id, 'type'=>'number');
- $expected_args[6] =
Array('name'=>'data','default'=>NULL, 'type'=>'any');
- $recieved_args = func_get_args();
- $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
- if($args['grantor'])
- {
- $grantor = $args['grantor'];
- $grantor_type = 'g';
- }
- else
- {
- $grantor =
$GLOBALS['phpgw_info']['user']['account_id'];
- }
-
- $sql = "SELECT acl_rights, acl_location FROM fm_acl2
WHERE (acl_appid = '".$args['app_id']."' ";
- $sql .= " and acl_account = ".$args['account_id'];
- $sql .= " and acl_location = '".$args['location']."'
and acl_type=".$args['type']." and grantor = $grantor)";
- $this->db->query($sql,__LINE__,__FILE__);
- while($this->db->next_record())
- {
- if((int)$args['rights'] == 0)
- {
- $sql = "DELETE FROM fm_acl2";
- }
- else
- {
- $sql = "UPDATE fm_acl2 SET acl_rights
=".$args['rights'];
- }
- $sql .= " WHERE acl_host=".$this->host_id." AND
acl_appid=".$args['app_id']." AND acl_account=".$args['account_id']." AND
acl_location='".$this->db->f('acl_location')."' AND acl_type=".$args['type'] .
" AND grantor = $grantor";
- $this->db2->query($sql,__LINE__,__FILE__);
-
-
$updated_locations[]=$this->db->f('acl_location');
- }
-
- $sql = "SELECT id FROM fm_acl_location WHERE (id
$this->like '%".$args['location']."%') AND allow_grant=1";
- $this->db->query($sql,__LINE__,__FILE__);
- while($this->db->next_record())
- {
-
- $add_locations[]=$this->db->f('id');
- }
-
- if($updated_locations)
- {
- $add_locations = array_diff($add_locations,
$updated_locations);
- }
- $add_locations =
explode("-",implode("-",$add_locations));
- if(is_array($add_locations) && count($add_locations)>0)
- {
- for ($i=0;$i<count($add_locations);$i++)
- {
-
- for ($j=0;$j<($i+1);$j++)
- {
- $location
=$add_locations[$j];
- }
-
-
if(strlen($location)>=strlen($args['location']))
- {
- if($args['rights'] != 0)
- {
- $sql = "SELECT
acl_rights FROM fm_acl2 WHERE (acl_appid = '".$args['app_id']."' ";
- $sql .= " and
acl_account = ".$args['account_id'];
- $sql .= " and
acl_location = '$location' and acl_type=".$args['type']. " AND grantor =
$grantor)";
-
$this->db->query($sql,__LINE__,__FILE__);
-
-
if($this->db->num_rows() == 0)
- {
- $sql = "INSERT
INTO fm_acl2
(acl_host,acl_appid,acl_account,acl_location,acl_rights,acl_type,acl_data,grantor,grantor_type)
VALUES
(".$this->host_id.",".$args['app_id'].",".$args['account_id'].",'".$location."',".$args['rights'].",".$args['type'].",'".$args['data']."',$grantor,'$grantor_type')";
-
-
$this->db2->query($sql,__LINE__,__FILE__);
- }
- else
- {
- $sql = "UPDATE
fm_acl2 SET acl_rights =".$args['rights'];
- $sql .= " WHERE
acl_host=".$this->host_id." AND acl_appid=".$args['app_id']." AND
acl_account=".$args['account_id']." AND acl_location='".$location."' AND
acl_type=".$args['type'] . " AND grantor = $grantor";
-
$this->db2->query($sql,__LINE__,__FILE__);
- }
- }
- }
- unset($location);
- }
- }
-
- $this->rights_cache = Array();
- $this->masks_cache = Array();
- }
-
- function set() //inheritance is saved to the database
- {
- $expected_args[0] =
Array('name'=>'location','default'=>'##REQUIRED##', 'type'=>'alphanumeric');
- $expected_args[1] =
Array('name'=>'rights','default'=>1, 'type'=>'number');
- $expected_args[2] =
Array('name'=>'account_id','default'=>$this->account_id, 'type'=>'number');
- $expected_args[3] = Array('name'=>'type','default'=>0,
'type'=>'number');
- $expected_args[4] =
Array('name'=>'app_id','default'=>$this->app_id, 'type'=>'number');
- $expected_args[5] =
Array('name'=>'data','default'=>NULL, 'type'=>'any');
- $recieved_args = func_get_args();
- $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
- $sql = "SELECT acl_rights, acl_location FROM fm_acl2
WHERE (acl_appid = '".$args['app_id']."' ";
- $sql .= " and acl_account = ".$args['account_id'];
- $sql .= " and acl_location = '".$args['location']."'
and acl_type=".$args['type']." AND grantor is NULL)";
- $this->db->query($sql,__LINE__,__FILE__);
- while($this->db->next_record())
- {
- if((int)$args['rights'] == 0)
- {
- $sql = "DELETE FROM fm_acl2";
- }
- else
- {
- $sql = "UPDATE fm_acl2 SET acl_rights
=".$args['rights'];
- }
- $sql .= " WHERE acl_host=".$this->host_id." AND
acl_appid=".$args['app_id']." AND acl_account=".$args['account_id']." AND
acl_location='".$this->db->f('acl_location')."' AND acl_type=".$args['type'] .
' AND grantor is NULL';
- $this->db2->query($sql,__LINE__,__FILE__);
-
-
$updated_locations[]=$this->db->f('acl_location');
- }
-
- $sql = "SELECT id FROM fm_acl_location WHERE (id
$this->like '%".$args['location']."%')";
- $this->db->query($sql,__LINE__,__FILE__);
- while($this->db->next_record())
- {
-
- $add_locations[]=$this->db->f('id');
- }
-
- if($updated_locations)
- {
- $add_locations = array_diff($add_locations,
$updated_locations);
- }
- $add_locations =
explode("-",implode("-",$add_locations));
- if(is_array($add_locations) && count($add_locations)>0)
- {
- for ($i=0;$i<count($add_locations);$i++)
- {
-
- for ($j=0;$j<($i+1);$j++)
- {
- $location
=$add_locations[$j];
- }
-
-
if(strlen($location)>=strlen($args['location']))
- {
- if($args['rights'] != 0)
- {
- $sql = "SELECT
acl_rights FROM fm_acl2 WHERE (acl_appid = '".$args['app_id']."' ";
- $sql .= " and
acl_account = ".$args['account_id'];
- $sql .= " and
acl_location = '$location' and acl_type=".$args['type']." AND grantor is NULL
)";
-
$this->db->query($sql,__LINE__,__FILE__);
-
if($this->db->num_rows() == 0)
- {
- $sql = "INSERT
INTO fm_acl2
(acl_host,acl_appid,acl_account,acl_location,acl_rights,acl_type,acl_data)
VALUES
(".$this->host_id.",".$args['app_id'].",".$args['account_id'].",'".$location."',".$args['rights'].",".$args['type'].",'".$args['data']."')";
-
-
$this->db2->query($sql,__LINE__,__FILE__);
- }
- else
- {
- $sql = "UPDATE
fm_acl2 SET acl_rights =".$args['rights'];
- $sql .= " WHERE
acl_host=".$this->host_id." AND acl_appid=".$args['app_id']." AND
acl_account=".$args['account_id']." AND acl_location='".$location."' AND
acl_type=".$args['type'] . ' AND grantor is NULL';
-
$this->db2->query($sql,__LINE__,__FILE__);
- }
- }
- }
- unset($location);
- }
- }
-
- $this->rights_cache = Array();
- $this->masks_cache = Array();
- }
-
- function remove()
- {
- $expected_args[0] =
Array('name'=>'location','default'=>'##REQUIRED##', 'type'=>'alphanumeric');
- $expected_args[1] =
Array('name'=>'rights','default'=>1, 'type'=>'number');
- $expected_args[2] =
Array('name'=>'account_id','default'=>$this->account_id, 'type'=>'number');
- $expected_args[3] = Array('name'=>'type','default'=>0,
'type'=>'number');
- $expected_args[4] =
Array('name'=>'app_id','default'=>$this->app_id, 'type'=>'number');
- $expected_args[5] =
Array('name'=>'data','default'=>NULL, 'type'=>'any');
- $recieved_args = func_get_args();
- $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
-
- $sql = "SELECT acl_rights FROM fm_acl2 WHERE (acl_appid
= '".$args['app_id']."' ";
- $sql .= " and acl_account = ".$args['account_id'];
- $sql .= " and acl_location = '".$args['location']."'
and acl_type=".$args['type']." and grantor is NULL)";
- $this->db->query($sql,__LINE__,__FILE__);
- if($this->db->num_rows() != 0)
- {
- $this->db->next_record();
- $newrights =
$this->bit_mask((int)$this->db->f('acl_rights'),$args['rights']);
- if ($newrights != 0)
- {
- $sql = "UPDATE fm_acl2 SET acl_rights
=".$newrights;
- }
- else
- {
- $sql = "DELETE FROM fm_acl2";
- }
- $sql .= " WHERE acl_host=".$this->host_id." AND
acl_appid=".$args['app_id']." AND acl_account=".$args['account_id']." AND
acl_location $this->like '%".$args['location']."%' AND acl_type=".$args['type']
. ' and grantor is NULL';
- $this->db->query($sql,__LINE__,__FILE__);
- $this->rights_cache = Array();
- $this->masks_cache = Array();
- }
- }
-
- function remove_grant()
- {
- $expected_args[0] =
Array('name'=>'location','default'=>'##REQUIRED##', 'type'=>'alphanumeric');
- $expected_args[1] =
Array('name'=>'rights','default'=>1, 'type'=>'number');
- $expected_args[2] =
Array('name'=>'account_id','default'=>$this->account_id, 'type'=>'number');
- $expected_args[3] = Array('name'=>'type','default'=>0,
'type'=>'number');
- $expected_args[4] =
Array('name'=>'grantor','default'=>NULL, 'type'=>'any');
- $expected_args[5] =
Array('name'=>'app_id','default'=>$this->app_id, 'type'=>'number');
- $expected_args[6] =
Array('name'=>'data','default'=>NULL, 'type'=>'any');
- $recieved_args = func_get_args();
- $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
-
- if($args['grantor'])
- {
- $grantor = $args['grantor'];
- }
- else
- {
- $grantor =
$GLOBALS['phpgw_info']['user']['account_id'];
- }
-
- $sql = "SELECT acl_rights FROM fm_acl2 WHERE (acl_appid
= '".$args['app_id']."' ";
- $sql .= " and acl_account = ".$args['account_id'];
- $sql .= " and acl_location = '".$args['location']."'
and acl_type=".$args['type']." and grantor = $grantor)";
- $this->db->query($sql,__LINE__,__FILE__);
- if($this->db->num_rows() != 0)
- {
- $this->db->next_record();
- $newrights =
$this->bit_mask((int)$this->db->f('acl_rights'),$args['rights']);
- if ($newrights != 0)
- {
- $sql = "UPDATE fm_acl2 SET acl_rights
=".$newrights;
- }
- else
- {
- $sql = "DELETE FROM fm_acl2";
- }
- $sql .= " WHERE acl_host=".$this->host_id." AND
acl_appid=".$args['app_id']." AND acl_account=".$args['account_id']." AND
acl_location $this->like '%".$args['location']."%' AND acl_type=".$args['type']
. " and grantor = $grantor";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->rights_cache = Array();
- $this->masks_cache = Array();
- }
- }
-
-
/*************************************************************************\
- * Non-standard functions. Should only be used for ACL
management needs *
-
\*************************************************************************/
- function check_specific()
- {
- $expected_args[0] =
Array('name'=>'location','default'=>'##REQUIRED##', 'type'=>'alphanumeric');
- $expected_args[1] =
Array('name'=>'required','default'=>1, 'type'=>'number');
- $expected_args[2] =
Array('name'=>'account_id','default'=>$this->account_id, 'type'=>'number');
- $expected_args[3] =
Array('name'=>'app_id','default'=>$this->app_id, 'type'=>'number');
- $recieved_args = func_get_args();
- $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
-
- $sql = "SELECT acl_rights,acl_type,acl_data FROM
fm_acl2 WHERE (acl_appid = '".$args['app_id']."' ";
- $sql .= " and acl_account = ".$args['account_id'];
- $sql .= " and acl_location = '".$args['location']."'
and acl_type=0)";
- $this->db->query($sql,__LINE__,__FILE__);
- $rights = 0;
- while ($this->db->next_record())
- {
- $rights =
$this->bit_set($rights,(int)$this->db->f('acl_rights'));
- }
- return $this->bit_check($rights,$args['required']);
- }
-
- /* I dont feel this function will be needed, and plan to remove
it when certain.
- function check_location()
- {
- $expected_args[0] =
Array('name'=>'location','default'=>'##REQUIRED##', 'type'=>'alphanumeric');
- $expected_args[1] =
Array('name'=>'required','default'=>1, 'type'=>'number');
- $expected_args[2] =
Array('name'=>'app_id','default'=>$this->app_id, 'type'=>'number');
- $recieved_args = func_get_args();
- $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
-
- $sql = "SELECT acl_rights,acl_type,acl_data FROM
fm_acl2 WHERE (acl_appid = '".$args['app_id']."' ";
- $sql .= " and (acl_account in
(".$this->account_id.",".$this->memberships_sql.'))';
- $sql .= " and acl_location = '".$args['location']."'
and acl_type=0)";
- $this->db->query($sql,__LINE__,__FILE__);
- $rights = 0;
- while ($this->db->next_record())
- {
- $rights =
$this->bit_set($rights,(int)$this->db->f('acl_rights'));
- }
- return $this->bit_check($rights,$args['required']);
- }
- */
- function get_grants($app='',$location='')
- {
- if ($app=='')
- {
- $app =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- }
-
- $app_id =
$GLOBALS['phpgw']->applications->data[$app]['id'];
-
- $sql = "select grantor,grantor_type, acl_rights from
fm_acl2 where acl_appid = $app_id AND acl_type=0 and acl_location =
'$location' AND grantor is NOT NULL AND"
- . " fm_acl2.acl_account in ";
- $security = "(". $this->account_id ."";
- $myaccounts = CreateObject('phpgwapi.accounts');
- $my_memberships =
$myaccounts->membership($this->account_id);
-
-// unset($myaccounts);
- @reset($my_memberships);
- while($my_memberships && list($key,$group) =
each($my_memberships))
- {
- $security .= "," . $group['account_id'];
- }
- $security .= ')';
- $this->db2->query($sql . $security ,__LINE__,__FILE__);
- $rights = 0;
- $accounts = Array();
- if ($this->db2->num_rows() == 0)
- {
-
$grants[$GLOBALS['phpgw_info']['user']['account_id']] = 31;
- return $grants;
- }
- while ($this->db2->next_record())
- {
- $grantor = $this->db2->f('grantor');
- $rights = $this->db2->f('acl_rights');
-
- $grantor_type = $this->db2->f('grantor_type');
-
- if($grantor_type =='g')
- {
- $grantor_members =
$myaccounts->member($grantor);
-
- foreach($grantor_members as $grantor)
- {
-
$accounts[$grantor['account_id']] = array($grantor['account_id']);
-
-
if(!isset($grants[$grantor['account_id']]))
- {
-
$grants[$grantor['account_id']] = 0;
- }
- $grants[$grantor['account_id']]
|= $rights;
-
reset($accounts[$grantor['account_id']]);
- }
- }
- else
- {
- $accounts[$grantor] = Array($grantor);
- foreach($accounts[$grantor] as
$grantors)
- {
- if(!isset($grants[$grantors]))
- {
- $grants[$grantors] = 0;
- }
- $grants[$grantors] |= $rights;
- }
- reset($accounts[$grantor]);
- }
- }
-
- $grants[$GLOBALS['phpgw_info']['user']['account_id']] =
31;
- return $grants;
- }
-
-
/*************************************************************************\
- * Support functions
*
-
\*************************************************************************/
- /*!
- @function bit_set
- @abstract add/turn_on new bit to current value
- */
- function bit_set($rights, $new)
- {
- return $rights |= $new;
- }
-
- /*!
- @function bit_mask
- @abstract mask/turn_off new bit from current value
- */
- function bit_mask($rights, $mask)
- {
- return $rights &= ~$mask;
- }
-
- /*!
- @function bit_check
- @abstract check if required bit is set/turned_on in the rights
- */
- function bit_check($rights, $required)
- {
- return ($rights & $required);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage core
+ * @version $Id: class.acl2.inc.php,v 1.6 2006/01/27 14:05:42 sigurdne
Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class acl2
+ {
+ var $account_id;
+ var $host_id;
+ var $app_id;
+ var $memberships = Array(0=>1); //group 0 is for all users
+ var $memberships_sql = ',0'; //group 0 is for all users
+ var $rights_cache = Array();
+ var $masks_cache = Array();
+ var $previous_location; // used for inheritance
+ var $db;
+
+
/*************************************************************************\
+ * These lines load up the templates class and set some default
values *
+
\*************************************************************************/
+ function acl2()
+ {
+ $expected_args[0] =
Array('name'=>'account_id','default'=>$GLOBALS['phpgw_info']['user']['account_id'],
'type'=>'number');
+ $expected_args[1] =
Array('name'=>'host_id','default'=>0, 'type'=>'number');
+ $expected_args[2] =
Array('name'=>'app_id','default'=>$GLOBALS['phpgw']->applications->data[$GLOBALS['phpgw_info']['flags']['currentapp']]['id'],
'type'=>'number');
+ $recieved_args = func_get_args();
+ $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
+ $this->db = $GLOBALS['phpgw']->db;
+ $this->db2 = $this->db;
+ $this->account_id = $args['account_id'];
+ $this->host_id = $args['host_id'];
+ $this->app_id = $args['app_id'];
+
+ if
($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
+ {
+ $this->like = "ILIKE";
+ }
+ else
+ {
+ $this->like = "LIKE";
+ }
+
+
+ }
+
+ function get_memberships ()
+ {
+ $expected_args[0] =
Array('name'=>'account_id','default'=>$this->account_id, 'type'=>'number');
+ $recieved_args = func_get_args();
+ $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
+
+ $sql = "SELECT acl_location,acl_rights FROM fm_acl2
+ WHERE (
acl_host='".$this->host_id."' and acl_appid = 0 and acl_account =
".$args['account_id'].")";
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+
if(!isset($this->memberships[$this->db->f('acl_location')]))
+ {
+
$this->memberships[$this->db->f('acl_location')] = $this->db->f('acl_rights');
+ $this->memberships_sql .=
','.$this->db->f('acl_location');
+
$this->get_memberships(Array('account_id'=>$this->db->f('acl_location')));
+ }
+ }
+ }
+
+
+ function cache_rights()
+ {
+ $expected_args[0] =
Array('name'=>'location','default'=>'##REQUIRED##', 'type'=>'alphanumeric');
+ $expected_args[1] =
Array('name'=>'app_id','default'=>$this->app_id, 'type'=>'number');
+ $expected_args[2] =
Array('name'=>'account_id','default'=>$this->account_id, 'type'=>'number');
+ $expected_args[3] =
Array('name'=>'grantor','default'=>False, 'type'=>'any');
+ $expected_args[4] =
Array('name'=>'no_effective','default'=>false, 'type'=>'any');
+
+ $recieved_args = func_get_args();
+ $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
+
+
if(isset($this->rights_cache[$args['app_id']][$args['account_id']][$args['location']]))
+ {
+ return;
+ }
+
+ $sql = "SELECT
acl_rights,acl_type,acl_data,acl_location FROM fm_acl2 WHERE (acl_appid =
'".$args['app_id']."' ";
+ $sql .= " and (acl_account in
(".$args['account_id']."".$this->memberships_sql.'))';
+ $sql .= " and acl_location = '". $args['location'] .
"'";
+
+ if($args['grantor']>0)
+ {
+ $sql .= " and (grantor=" . $args['grantor'] .
")";
+ }
+ else
+ {
+ $sql .= " and (grantor is NULL)";
+ }
+
+ $sql .= ') ORDER BY acl_location, acl_type DESC';
+
+ $this->db->query($sql,__LINE__,__FILE__);
+ while($this->db->next_record())
+ {
+
if($this->rights_cache[$args['app_id']][$args['account_id']][$args['location']]
== 0)
+ {
+
$this->rights_cache[$args['app_id']][$args['account_id']][$this->db->f('acl_location')]
= 0;
+ }
+
+
if($this->masks_cache[$args['app_id']][$args['account_id']][$args['location']]
== 0)
+ {
+
$this->masks_cache[$args['app_id']][$args['account_id']][$this->db->f('acl_location')]
= 0;
+ }
+
+ if((int)$this->db->f('acl_type') == 0)
+ {
+
$this->rights_cache[$args['app_id']][$args['account_id']][$this->db->f('acl_location')]
=
$this->bit_set($this->rights_cache[$args['app_id']][$args['account_id']][$this->db->f('acl_location')],(int)$this->db->f('acl_rights'));
+ }
+ else
+ {
+
$this->masks_cache[$args['app_id']][$args['account_id']][$this->db->f('acl_location')]
=
$this->bit_set($this->rights_cache[$args['app_id']][$args['account_id']][$this->db->f('acl_location')],(int)$this->db->f('acl_rights'));
+ }
+
+ if(!$this->db->f('acl_rights'))
+ {
+
$this->rights_cache[$args['app_id']][$args['account_id']][$args['location']]=0;
+
$this->masks_cache[$args['app_id']][$args['account_id']][$args['location']]=0;
+ }
+
+ if(!$args['no_effective'])
+ {
+
$this->rights_cache[$args['app_id']][$args['account_id']][$this->db->f('acl_location')]
=
$this->bit_mask($this->rights_cache[$args['app_id']][$args['account_id']][$args['location']],
$this->masks_cache[$args['app_id']][$args['account_id']][$args['location']]);
+ }
+
+ }
+ }
+
+
+ function check_grant()
+ {
+ $expected_args[0] =
Array('name'=>'grantor','default'=>$this->account_id, 'type'=>'number');
+ $expected_args[1] =
Array('name'=>'location','default'=>'##REQUIRED##', 'type'=>'alphanumeric');
+ $expected_args[2] =
Array('name'=>'required','default'=>1, 'type'=>'number');
+ $expected_args[3] =
Array('name'=>'account_id','default'=>$this->account_id, 'type'=>'number');
+ $expected_args[4] =
Array('name'=>'app_id','default'=>$this->app_id, 'type'=>'number');
+ $expected_args[5] =
Array('name'=>'no_membership','default'=>false, 'type'=>'number');
+ $expected_args[6] =
Array('name'=>'acl_type','default'=>0, 'type'=>'number');
+ $expected_args[7] =
Array('name'=>'no_effective','default'=>false, 'type'=>'any');
+ $recieved_args = func_get_args();
+ $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
+
+ if(!$args['no_membership'])
+ {
+ $memberships =
$GLOBALS['phpgw']->accounts->membership($args['account_id']);
+
+ while (is_array($memberships) &&
list(,$account) = each($memberships))
+ {
+ $member_of[] = $account['account_id'];
+ }
+
+ if($member_of)
+ {
+ $this->memberships_sql = ',' .
@implode(",",$member_of);
+ }
+ }
+
+
$this->cache_rights($args['location'],$args['app_id'],$args['account_id'],$args['grantor'],$args['no_effective']);
+ if($args['acl_type']==0)
+ {
+ return
$this->bit_check($this->rights_cache[$args['app_id']][$args['account_id']][$args['location']],$args['required']);
+ }
+ else
+ {
+ return
$this->bit_check($this->masks_cache[$args['app_id']][$args['account_id']][$args['location']],$args['required']);
+ }
+ }
+
+ function check()
+ {
+ $expected_args[0] =
Array('name'=>'location','default'=>'##REQUIRED##', 'type'=>'alphanumeric');
+ $expected_args[1] =
Array('name'=>'required','default'=>1, 'type'=>'number');
+ $expected_args[2] =
Array('name'=>'account_id','default'=>$this->account_id, 'type'=>'number');
+ $expected_args[3] =
Array('name'=>'app_id','default'=>$this->app_id, 'type'=>'number');
+ $expected_args[4] =
Array('name'=>'no_membership','default'=>false, 'type'=>'number');
+ $expected_args[5] =
Array('name'=>'acl_type','default'=>0, 'type'=>'number');
+ $expected_args[6] =
Array('name'=>'no_effective','default'=>false, 'type'=>'any');
+ $recieved_args = func_get_args();
+ $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
+
+ if(!$args['no_membership'])
+ {
+ $memberships =
$GLOBALS['phpgw']->accounts->membership($args['account_id']);
+
+ while (is_array($memberships) &&
list(,$account) = each($memberships))
+ {
+ $member_of[] = $account['account_id'];
+ }
+
+ if($member_of)
+ {
+ $this->memberships_sql = ',' .
@implode(",",$member_of);
+ }
+ }
+
+
$this->cache_rights($args['location'],$args['app_id'],$args['account_id'],False,$args['no_effective']);
+ if($args['acl_type']==0)
+ {
+ return
$this->bit_check($this->rights_cache[$args['app_id']][$args['account_id']][$args['location']],$args['required']);
+ }
+ else
+ {
+ return
$this->bit_check($this->masks_cache[$args['app_id']][$args['account_id']][$args['location']],$args['required']);
+ }
+ }
+
+ /*!
+ @function add
+ @abstract Adds ACL record to $acl->data
+ @discussion Adds ACL record to $acl->data. <br>
+ Syntax: array add() <br>
+ Example1: acl->add();
+ @param $appname default False derives value from
$phpgw_info['flags']['currentapp']
+ @param $location location
+ @param $rights rights
+ */
+ function add()
+ {
+ $expected_args[0] =
Array('name'=>'location','default'=>'##REQUIRED##', 'type'=>'alphanumeric');
+ $expected_args[1] =
Array('name'=>'rights','default'=>1, 'type'=>'number');
+ $expected_args[2] =
Array('name'=>'account_id','default'=>$this->account_id, 'type'=>'number');
+ $expected_args[3] = Array('name'=>'type','default'=>0,
'type'=>'number');
+ $expected_args[4] =
Array('name'=>'app_id','default'=>$this->app_id, 'type'=>'number');
+ $expected_args[5] =
Array('name'=>'data','default'=>NULL, 'type'=>'any');
+ $recieved_args = func_get_args();
+ $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
+
+ $sql = "SELECT acl_rights FROM fm_acl2 WHERE (acl_appid
= '".$args['app_id']."' ";
+ $sql .= " and acl_account = ".$args['account_id'];
+ $sql .= " and acl_location = '".$args['location']."'
and acl_type=".$args['type']." and grantor is NULL)";
+ $this->db->query($sql,__LINE__,__FILE__);
+ if($this->db->num_rows() != 0)
+ {
+ $this->db->next_record();
+ $newrights = $this->bit_set($args['rights'],
(int)$this->db->f('acl_rights'));
+ $sql = "UPDATE fm_acl2 SET acl_rights
=".$newrights;
+ $sql .= " WHERE acl_host=".$this->host_id." AND
acl_appid=".$args['app_id']." AND acl_account=".$args['account_id']." AND
acl_location='".$args['location']."' AND acl_type=".$args['type'];
+ }
+ else
+ {
+ $sql = "INSERT INTO fm_acl2
(acl_host,acl_appid,acl_account,acl_location,acl_rights,acl_type,acl_data)
VALUES
(".$this->host_id.",".$args['app_id'].",".$args['account_id'].",'".$args['location']."',".$args['rights'].",".$args['type'].",'".$args['data']."')";
+ }
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->rights_cache = Array();
+ $this->masks_cache = Array();
+ }
+
+ function set_grant() //inheritance is saved to the database
+ {
+ $expected_args[0] =
Array('name'=>'location','default'=>'##REQUIRED##', 'type'=>'alphanumeric');
+ $expected_args[1] =
Array('name'=>'rights','default'=>1, 'type'=>'number');
+ $expected_args[2] =
Array('name'=>'account_id','default'=>$this->account_id, 'type'=>'number');
+ $expected_args[3] = Array('name'=>'type','default'=>0,
'type'=>'number');
+ $expected_args[4] =
Array('name'=>'grantor','default'=>NULL, 'type'=>'any');
+ $expected_args[5] =
Array('name'=>'app_id','default'=>$this->app_id, 'type'=>'number');
+ $expected_args[6] =
Array('name'=>'data','default'=>NULL, 'type'=>'any');
+ $recieved_args = func_get_args();
+ $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
+ if($args['grantor'])
+ {
+ $grantor = $args['grantor'];
+ $grantor_type = 'g';
+ }
+ else
+ {
+ $grantor =
$GLOBALS['phpgw_info']['user']['account_id'];
+ }
+
+ $sql = "SELECT acl_rights, acl_location FROM fm_acl2
WHERE (acl_appid = '".$args['app_id']."' ";
+ $sql .= " and acl_account = ".$args['account_id'];
+ $sql .= " and acl_location = '".$args['location']."'
and acl_type=".$args['type']." and grantor = $grantor)";
+ $this->db->query($sql,__LINE__,__FILE__);
+ while($this->db->next_record())
+ {
+ if((int)$args['rights'] == 0)
+ {
+ $sql = "DELETE FROM fm_acl2";
+ }
+ else
+ {
+ $sql = "UPDATE fm_acl2 SET acl_rights
=".$args['rights'];
+ }
+ $sql .= " WHERE acl_host=".$this->host_id." AND
acl_appid=".$args['app_id']." AND acl_account=".$args['account_id']." AND
acl_location='".$this->db->f('acl_location')."' AND acl_type=".$args['type'] .
" AND grantor = $grantor";
+ $this->db2->query($sql,__LINE__,__FILE__);
+
+
$updated_locations[]=$this->db->f('acl_location');
+ }
+
+ $sql = "SELECT id FROM fm_acl_location WHERE (id
$this->like '%".$args['location']."%') AND allow_grant=1";
+ $this->db->query($sql,__LINE__,__FILE__);
+ while($this->db->next_record())
+ {
+
+ $add_locations[]=$this->db->f('id');
+ }
+
+ if($updated_locations)
+ {
+ $add_locations = array_diff($add_locations,
$updated_locations);
+ }
+ $add_locations =
explode("-",implode("-",$add_locations));
+ if(is_array($add_locations) && count($add_locations)>0)
+ {
+ for ($i=0;$i<count($add_locations);$i++)
+ {
+
+ for ($j=0;$j<($i+1);$j++)
+ {
+ $location
=$add_locations[$j];
+ }
+
+
if(strlen($location)>=strlen($args['location']))
+ {
+ if($args['rights'] != 0)
+ {
+ $sql = "SELECT
acl_rights FROM fm_acl2 WHERE (acl_appid = '".$args['app_id']."' ";
+ $sql .= " and
acl_account = ".$args['account_id'];
+ $sql .= " and
acl_location = '$location' and acl_type=".$args['type']. " AND grantor =
$grantor)";
+
$this->db->query($sql,__LINE__,__FILE__);
+
+
if($this->db->num_rows() == 0)
+ {
+ $sql = "INSERT
INTO fm_acl2
(acl_host,acl_appid,acl_account,acl_location,acl_rights,acl_type,acl_data,grantor,grantor_type)
VALUES
(".$this->host_id.",".$args['app_id'].",".$args['account_id'].",'".$location."',".$args['rights'].",".$args['type'].",'".$args['data']."',$grantor,'$grantor_type')";
+
+
$this->db2->query($sql,__LINE__,__FILE__);
+ }
+ else
+ {
+ $sql = "UPDATE
fm_acl2 SET acl_rights =".$args['rights'];
+ $sql .= " WHERE
acl_host=".$this->host_id." AND acl_appid=".$args['app_id']." AND
acl_account=".$args['account_id']." AND acl_location='".$location."' AND
acl_type=".$args['type'] . " AND grantor = $grantor";
+
$this->db2->query($sql,__LINE__,__FILE__);
+ }
+ }
+ }
+ unset($location);
+ }
+ }
+
+ $this->rights_cache = Array();
+ $this->masks_cache = Array();
+ }
+
+ function set() //inheritance is saved to the database
+ {
+ $expected_args[0] =
Array('name'=>'location','default'=>'##REQUIRED##', 'type'=>'alphanumeric');
+ $expected_args[1] =
Array('name'=>'rights','default'=>1, 'type'=>'number');
+ $expected_args[2] =
Array('name'=>'account_id','default'=>$this->account_id, 'type'=>'number');
+ $expected_args[3] = Array('name'=>'type','default'=>0,
'type'=>'number');
+ $expected_args[4] =
Array('name'=>'app_id','default'=>$this->app_id, 'type'=>'number');
+ $expected_args[5] =
Array('name'=>'data','default'=>NULL, 'type'=>'any');
+ $recieved_args = func_get_args();
+ $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
+ $sql = "SELECT acl_rights, acl_location FROM fm_acl2
WHERE (acl_appid = '".$args['app_id']."' ";
+ $sql .= " and acl_account = ".$args['account_id'];
+ $sql .= " and acl_location = '".$args['location']."'
and acl_type=".$args['type']." AND grantor is NULL)";
+ $this->db->query($sql,__LINE__,__FILE__);
+ while($this->db->next_record())
+ {
+ if((int)$args['rights'] == 0)
+ {
+ $sql = "DELETE FROM fm_acl2";
+ }
+ else
+ {
+ $sql = "UPDATE fm_acl2 SET acl_rights
=".$args['rights'];
+ }
+ $sql .= " WHERE acl_host=".$this->host_id." AND
acl_appid=".$args['app_id']." AND acl_account=".$args['account_id']." AND
acl_location='".$this->db->f('acl_location')."' AND acl_type=".$args['type'] .
' AND grantor is NULL';
+ $this->db2->query($sql,__LINE__,__FILE__);
+
+
$updated_locations[]=$this->db->f('acl_location');
+ }
+
+ $sql = "SELECT id FROM fm_acl_location WHERE (id
$this->like '%".$args['location']."%')";
+ $this->db->query($sql,__LINE__,__FILE__);
+ while($this->db->next_record())
+ {
+
+ $add_locations[]=$this->db->f('id');
+ }
+
+ if($updated_locations)
+ {
+ $add_locations = array_diff($add_locations,
$updated_locations);
+ }
+ $add_locations =
explode("-",implode("-",$add_locations));
+ if(is_array($add_locations) && count($add_locations)>0)
+ {
+ for ($i=0;$i<count($add_locations);$i++)
+ {
+
+ for ($j=0;$j<($i+1);$j++)
+ {
+ $location
=$add_locations[$j];
+ }
+
+
if(strlen($location)>=strlen($args['location']))
+ {
+ if($args['rights'] != 0)
+ {
+ $sql = "SELECT
acl_rights FROM fm_acl2 WHERE (acl_appid = '".$args['app_id']."' ";
+ $sql .= " and
acl_account = ".$args['account_id'];
+ $sql .= " and
acl_location = '$location' and acl_type=".$args['type']." AND grantor is NULL
)";
+
$this->db->query($sql,__LINE__,__FILE__);
+
if($this->db->num_rows() == 0)
+ {
+ $sql = "INSERT
INTO fm_acl2
(acl_host,acl_appid,acl_account,acl_location,acl_rights,acl_type,acl_data)
VALUES
(".$this->host_id.",".$args['app_id'].",".$args['account_id'].",'".$location."',".$args['rights'].",".$args['type'].",'".$args['data']."')";
+
+
$this->db2->query($sql,__LINE__,__FILE__);
+ }
+ else
+ {
+ $sql = "UPDATE
fm_acl2 SET acl_rights =".$args['rights'];
+ $sql .= " WHERE
acl_host=".$this->host_id." AND acl_appid=".$args['app_id']." AND
acl_account=".$args['account_id']." AND acl_location='".$location."' AND
acl_type=".$args['type'] . ' AND grantor is NULL';
+
$this->db2->query($sql,__LINE__,__FILE__);
+ }
+ }
+ }
+ unset($location);
+ }
+ }
+
+ $this->rights_cache = Array();
+ $this->masks_cache = Array();
+ }
+
+ function remove()
+ {
+ $expected_args[0] =
Array('name'=>'location','default'=>'##REQUIRED##', 'type'=>'alphanumeric');
+ $expected_args[1] =
Array('name'=>'rights','default'=>1, 'type'=>'number');
+ $expected_args[2] =
Array('name'=>'account_id','default'=>$this->account_id, 'type'=>'number');
+ $expected_args[3] = Array('name'=>'type','default'=>0,
'type'=>'number');
+ $expected_args[4] =
Array('name'=>'app_id','default'=>$this->app_id, 'type'=>'number');
+ $expected_args[5] =
Array('name'=>'data','default'=>NULL, 'type'=>'any');
+ $recieved_args = func_get_args();
+ $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
+
+ $sql = "SELECT acl_rights FROM fm_acl2 WHERE (acl_appid
= '".$args['app_id']."' ";
+ $sql .= " and acl_account = ".$args['account_id'];
+ $sql .= " and acl_location = '".$args['location']."'
and acl_type=".$args['type']." and grantor is NULL)";
+ $this->db->query($sql,__LINE__,__FILE__);
+ if($this->db->num_rows() != 0)
+ {
+ $this->db->next_record();
+ $newrights =
$this->bit_mask((int)$this->db->f('acl_rights'),$args['rights']);
+ if ($newrights != 0)
+ {
+ $sql = "UPDATE fm_acl2 SET acl_rights
=".$newrights;
+ }
+ else
+ {
+ $sql = "DELETE FROM fm_acl2";
+ }
+ $sql .= " WHERE acl_host=".$this->host_id." AND
acl_appid=".$args['app_id']." AND acl_account=".$args['account_id']." AND
acl_location $this->like '%".$args['location']."%' AND acl_type=".$args['type']
. ' and grantor is NULL';
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->rights_cache = Array();
+ $this->masks_cache = Array();
+ }
+ }
+
+ function remove_grant()
+ {
+ $expected_args[0] =
Array('name'=>'location','default'=>'##REQUIRED##', 'type'=>'alphanumeric');
+ $expected_args[1] =
Array('name'=>'rights','default'=>1, 'type'=>'number');
+ $expected_args[2] =
Array('name'=>'account_id','default'=>$this->account_id, 'type'=>'number');
+ $expected_args[3] = Array('name'=>'type','default'=>0,
'type'=>'number');
+ $expected_args[4] =
Array('name'=>'grantor','default'=>NULL, 'type'=>'any');
+ $expected_args[5] =
Array('name'=>'app_id','default'=>$this->app_id, 'type'=>'number');
+ $expected_args[6] =
Array('name'=>'data','default'=>NULL, 'type'=>'any');
+ $recieved_args = func_get_args();
+ $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
+
+ if($args['grantor'])
+ {
+ $grantor = $args['grantor'];
+ }
+ else
+ {
+ $grantor =
$GLOBALS['phpgw_info']['user']['account_id'];
+ }
+
+ $sql = "SELECT acl_rights FROM fm_acl2 WHERE (acl_appid
= '".$args['app_id']."' ";
+ $sql .= " and acl_account = ".$args['account_id'];
+ $sql .= " and acl_location = '".$args['location']."'
and acl_type=".$args['type']." and grantor = $grantor)";
+ $this->db->query($sql,__LINE__,__FILE__);
+ if($this->db->num_rows() != 0)
+ {
+ $this->db->next_record();
+ $newrights =
$this->bit_mask((int)$this->db->f('acl_rights'),$args['rights']);
+ if ($newrights != 0)
+ {
+ $sql = "UPDATE fm_acl2 SET acl_rights
=".$newrights;
+ }
+ else
+ {
+ $sql = "DELETE FROM fm_acl2";
+ }
+ $sql .= " WHERE acl_host=".$this->host_id." AND
acl_appid=".$args['app_id']." AND acl_account=".$args['account_id']." AND
acl_location $this->like '%".$args['location']."%' AND acl_type=".$args['type']
. " and grantor = $grantor";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->rights_cache = Array();
+ $this->masks_cache = Array();
+ }
+ }
+
+
/*************************************************************************\
+ * Non-standard functions. Should only be used for ACL
management needs *
+
\*************************************************************************/
+ function check_specific()
+ {
+ $expected_args[0] =
Array('name'=>'location','default'=>'##REQUIRED##', 'type'=>'alphanumeric');
+ $expected_args[1] =
Array('name'=>'required','default'=>1, 'type'=>'number');
+ $expected_args[2] =
Array('name'=>'account_id','default'=>$this->account_id, 'type'=>'number');
+ $expected_args[3] =
Array('name'=>'app_id','default'=>$this->app_id, 'type'=>'number');
+ $recieved_args = func_get_args();
+ $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
+
+ $sql = "SELECT acl_rights,acl_type,acl_data FROM
fm_acl2 WHERE (acl_appid = '".$args['app_id']."' ";
+ $sql .= " and acl_account = ".$args['account_id'];
+ $sql .= " and acl_location = '".$args['location']."'
and acl_type=0)";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $rights = 0;
+ while ($this->db->next_record())
+ {
+ $rights =
$this->bit_set($rights,(int)$this->db->f('acl_rights'));
+ }
+ return $this->bit_check($rights,$args['required']);
+ }
+
+ /* I dont feel this function will be needed, and plan to remove
it when certain.
+ function check_location()
+ {
+ $expected_args[0] =
Array('name'=>'location','default'=>'##REQUIRED##', 'type'=>'alphanumeric');
+ $expected_args[1] =
Array('name'=>'required','default'=>1, 'type'=>'number');
+ $expected_args[2] =
Array('name'=>'app_id','default'=>$this->app_id, 'type'=>'number');
+ $recieved_args = func_get_args();
+ $args = safe_args($expected_args,
$recieved_args,__LINE__,__FILE__);
+
+ $sql = "SELECT acl_rights,acl_type,acl_data FROM
fm_acl2 WHERE (acl_appid = '".$args['app_id']."' ";
+ $sql .= " and (acl_account in
(".$this->account_id.",".$this->memberships_sql.'))';
+ $sql .= " and acl_location = '".$args['location']."'
and acl_type=0)";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $rights = 0;
+ while ($this->db->next_record())
+ {
+ $rights =
$this->bit_set($rights,(int)$this->db->f('acl_rights'));
+ }
+ return $this->bit_check($rights,$args['required']);
+ }
+ */
+ function get_grants($app='',$location='')
+ {
+ if ($app=='')
+ {
+ $app =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ }
+
+ $app_id =
$GLOBALS['phpgw']->applications->data[$app]['id'];
+
+ $sql = "select grantor,grantor_type, acl_rights from
fm_acl2 where acl_appid = $app_id AND acl_type=0 and acl_location =
'$location' AND grantor is NOT NULL AND"
+ . " fm_acl2.acl_account in ";
+ $security = "(". $this->account_id ."";
+ $myaccounts = CreateObject('phpgwapi.accounts');
+ $my_memberships =
$myaccounts->membership($this->account_id);
+
+// unset($myaccounts);
+ @reset($my_memberships);
+ while($my_memberships && list($key,$group) =
each($my_memberships))
+ {
+ $security .= "," . $group['account_id'];
+ }
+ $security .= ')';
+ $this->db2->query($sql . $security ,__LINE__,__FILE__);
+ $rights = 0;
+ $accounts = Array();
+ if ($this->db2->num_rows() == 0)
+ {
+
$grants[$GLOBALS['phpgw_info']['user']['account_id']] = 31;
+ return $grants;
+ }
+ while ($this->db2->next_record())
+ {
+ $grantor = $this->db2->f('grantor');
+ $rights = $this->db2->f('acl_rights');
+
+ $grantor_type = $this->db2->f('grantor_type');
+
+ if($grantor_type =='g')
+ {
+ $grantor_members =
$myaccounts->member($grantor);
+
+ foreach($grantor_members as $grantor)
+ {
+
$accounts[$grantor['account_id']] = array($grantor['account_id']);
+
+
if(!isset($grants[$grantor['account_id']]))
+ {
+
$grants[$grantor['account_id']] = 0;
+ }
+ $grants[$grantor['account_id']]
|= $rights;
+
reset($accounts[$grantor['account_id']]);
+ }
+ }
+ else
+ {
+ $accounts[$grantor] = Array($grantor);
+ foreach($accounts[$grantor] as
$grantors)
+ {
+ if(!isset($grants[$grantors]))
+ {
+ $grants[$grantors] = 0;
+ }
+ $grants[$grantors] |= $rights;
+ }
+ reset($accounts[$grantor]);
+ }
+ }
+
+ $grants[$GLOBALS['phpgw_info']['user']['account_id']] =
31;
+ return $grants;
+ }
+
+
/*************************************************************************\
+ * Support functions
*
+
\*************************************************************************/
+ /*!
+ @function bit_set
+ @abstract add/turn_on new bit to current value
+ */
+ function bit_set($rights, $new)
+ {
+ return $rights |= $new;
+ }
+
+ /*!
+ @function bit_mask
+ @abstract mask/turn_off new bit from current value
+ */
+ function bit_mask($rights, $mask)
+ {
+ return $rights &= ~$mask;
+ }
+
+ /*!
+ @function bit_check
+ @abstract check if required bit is set/turned_on in the rights
+ */
+ function bit_check($rights, $required)
+ {
+ return ($rights & $required);
+ }
+ }
+?>
Index: property/inc/class.boXport.inc.php
diff -u property/inc/class.boXport.inc.php:1.10
property/inc/class.boXport.inc.php:1.11
--- property/inc/class.boXport.inc.php:1.10 Wed Jan 25 18:19:12 2006
+++ property/inc/class.boXport.inc.php Fri Jan 27 14:05:42 2006
@@ -1,282 +1,282 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.boXport.inc.php,v 1.10 2006/01/25 18:19:12
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class boXport
- {
- var $public_functions = array(
- 'import' => True,
- 'export' => True
- );
-
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
- var $cat_id;
-
- var $use_session = False;
-
- function boXport ($session=False)
- {
-
- $GLOBALS['phpgw_info']['flags']['currentapp'] =
'property';
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
-
- $this->config =
CreateObject('phpgwapi.config',$this->currentapp);
-
- if($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
-
- if($start || $start == 0) { $this->start = $start; }
- if($query) { $this->query = $query; }
- if($sort) { $this->sort = $sort; }
- if($order) { $this->order = $order; }
- if($filter) { $this->filter = $filter; }
- $this->cat_id = $cat_id;
- }
-
- function save_sessiondata()
- {
-
- if ($this->use_session)
- {
- $data = array(
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' => $this->filter,
- 'cat_id' => $this->cat_id
- );
- if($this->debug) { echo '<br>Save:';
_debug_array($data); }
-
$GLOBALS['phpgw']->session->appsession('session_data','export',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','export');
- if($this->debug) { echo '<br>Read:';
_debug_array($data); }
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->filter = $data['filter'];
- $this->cat_id = $data['cat_id'];
- }
-
- function select_import_conv($selected='')
- {
- $dir_handle = @opendir(PHPGW_APP_INC . SEP . 'import');
- $i=0; $myfilearray = '';
- while ($file = readdir($dir_handle))
- {
- if ((substr($file, 0, 1) != '.') &&
is_file(PHPGW_APP_INC . SEP . 'import' . SEP . $file) )
- {
- $myfilearray[$i] = $file;
- $i++;
- }
- }
- closedir($dir_handle);
- sort($myfilearray);
-
- for ($i=0;$i<count($myfilearray);$i++)
- {
- $fname = ereg_replace('_',' ',$myfilearray[$i]);
- $sel_file = '';
- if ($myfilearray[$i]==$selected)
- {
- $sel_file = 'selected';
- }
-
- $conv_list[] = array
- (
- 'id' => $myfilearray[$i],
- 'name' => $fname,
- 'selected' => $sel_file
- );
- }
-
- for ($i=0;$i<count($conv_list);$i++)
- {
- if ($conv_list[$i]['selected'] != 'selected')
- {
- unset($conv_list[$i]['selected']);
- }
- }
-
- return $conv_list;
-
- }
-
- function select_export_conv($selected='')
- {
- $dir_handle = @opendir(PHPGW_APP_INC . SEP . 'export');
- $i=0; $myfilearray = '';
- while ($file = readdir($dir_handle))
- {
- if ((substr($file, 0, 1) != '.') &&
is_file(PHPGW_APP_INC . SEP . 'export' . SEP . $file) )
- {
- $myfilearray[$i] = $file;
- $i++;
- }
- }
- closedir($dir_handle);
- sort($myfilearray);
-
- for ($i=0;$i<count($myfilearray);$i++)
- {
- $fname = ereg_replace('_',' ',$myfilearray[$i]);
- $sel_file = '';
- if ($myfilearray[$i]==$selected)
- {
- $sel_file = 'selected';
- }
-
- $conv_list[] = array
- (
- 'id' => $myfilearray[$i],
- 'name' => $fname,
- 'selected' => $sel_file
- );
- }
-
- for ($i=0;$i<count($conv_list);$i++)
- {
- if ($conv_list[$i]['selected'] != 'selected')
- {
- unset($conv_list[$i]['selected']);
- }
- }
-
- return $conv_list;
-
- }
-
- function select_rollback_file($selected='')
- {
- $this->config->read_repository();
- $file_catalog =
$this->config->config_data['export_path'];
-
- $dir_handle = @opendir($file_catalog);
- $i=0; $myfilearray = '';
- while ($file = readdir($dir_handle))
- {
- if ((substr($file, 0, 1) != '.') &&
is_file($file_catalog . SEP . $file) )
- {
- $myfilearray[$i] = $file;
- $i++;
- }
- }
- closedir($dir_handle);
- @sort($myfilearray);
-
- for ($i=0;$i<count($myfilearray);$i++)
- {
- $fname = ereg_replace('_',' ',$myfilearray[$i]);
- $sel_file = '';
- if ($myfilearray[$i]==$selected)
- {
- $sel_file = 'selected';
- }
-
- $rollback_list[] = array
- (
- 'id' => $myfilearray[$i],
- 'name' => $fname,
- 'selected' => $sel_file
- );
- }
-
- for ($i=0;$i<count($rollback_list);$i++)
- {
- if ($rollback_list[$i]['selected'] !=
'selected')
- {
- unset($rollback_list[$i]['selected']);
- }
- }
-
- return $rollback_list;
-
- }
-
- function import($invoice_common,$download)
- {
- include (PHPGW_APP_INC . '/import/' .
$invoice_common['conv_type']);
- $invoice = new import_conv;
-
- $buffer = $invoice->import($invoice_common,$download);
- if ($download)
- {
- $header = $invoice->header;
- $import = $invoice->import;
- $buffer= array(
- 'table' => $buffer,
- 'header' => $header,
- 'import' => $import
- );
- }
- return $buffer;
- }
-
- function export($data)
- {
- $conv_type = $data['conv_type'];
- $download = $data['download'];
- $pre_transfer = $data['pre_transfer'];
- $force_period_year = $data['force_period_year'];
-
- include(PHPGW_SERVER_ROOT.'/'.'property'.'/inc/export/'
. $conv_type);
- $invoice = new export_conv;
-
- $buffer =
$invoice->overfor($download,$pre_transfer,$force_period_year);
-
- return $buffer;
- }
-
- function rollback($conv_type,$role_back_date,$rollback_file)
- {
- include (PHPGW_APP_INC . '/export/' . $conv_type);
- $invoice = new export_conv;
- $buffer =
$invoice->RullTilbake($role_back_date,$rollback_file);
- return $buffer;
-
- }
-
- function export_cron($data)
- {
- if($data['enabled']==1)
- {
- $this->export($data);
- }
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.boXport.inc.php,v 1.11 2006/01/27 14:05:42
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class boXport
+ {
+ var $public_functions = array(
+ 'import' => True,
+ 'export' => True
+ );
+
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+ var $cat_id;
+
+ var $use_session = False;
+
+ function boXport ($session=False)
+ {
+
+ $GLOBALS['phpgw_info']['flags']['currentapp'] =
'property';
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+
+ $this->config =
CreateObject('phpgwapi.config',$this->currentapp);
+
+ if($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+
+ if($start || $start == 0) { $this->start = $start; }
+ if($query) { $this->query = $query; }
+ if($sort) { $this->sort = $sort; }
+ if($order) { $this->order = $order; }
+ if($filter) { $this->filter = $filter; }
+ $this->cat_id = $cat_id;
+ }
+
+ function save_sessiondata()
+ {
+
+ if ($this->use_session)
+ {
+ $data = array(
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' => $this->filter,
+ 'cat_id' => $this->cat_id
+ );
+ if($this->debug) { echo '<br>Save:';
_debug_array($data); }
+
$GLOBALS['phpgw']->session->appsession('session_data','export',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','export');
+ if($this->debug) { echo '<br>Read:';
_debug_array($data); }
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->filter = $data['filter'];
+ $this->cat_id = $data['cat_id'];
+ }
+
+ function select_import_conv($selected='')
+ {
+ $dir_handle = @opendir(PHPGW_APP_INC . SEP . 'import');
+ $i=0; $myfilearray = '';
+ while ($file = readdir($dir_handle))
+ {
+ if ((substr($file, 0, 1) != '.') &&
is_file(PHPGW_APP_INC . SEP . 'import' . SEP . $file) )
+ {
+ $myfilearray[$i] = $file;
+ $i++;
+ }
+ }
+ closedir($dir_handle);
+ sort($myfilearray);
+
+ for ($i=0;$i<count($myfilearray);$i++)
+ {
+ $fname = ereg_replace('_',' ',$myfilearray[$i]);
+ $sel_file = '';
+ if ($myfilearray[$i]==$selected)
+ {
+ $sel_file = 'selected';
+ }
+
+ $conv_list[] = array
+ (
+ 'id' => $myfilearray[$i],
+ 'name' => $fname,
+ 'selected' => $sel_file
+ );
+ }
+
+ for ($i=0;$i<count($conv_list);$i++)
+ {
+ if ($conv_list[$i]['selected'] != 'selected')
+ {
+ unset($conv_list[$i]['selected']);
+ }
+ }
+
+ return $conv_list;
+
+ }
+
+ function select_export_conv($selected='')
+ {
+ $dir_handle = @opendir(PHPGW_APP_INC . SEP . 'export');
+ $i=0; $myfilearray = '';
+ while ($file = readdir($dir_handle))
+ {
+ if ((substr($file, 0, 1) != '.') &&
is_file(PHPGW_APP_INC . SEP . 'export' . SEP . $file) )
+ {
+ $myfilearray[$i] = $file;
+ $i++;
+ }
+ }
+ closedir($dir_handle);
+ sort($myfilearray);
+
+ for ($i=0;$i<count($myfilearray);$i++)
+ {
+ $fname = ereg_replace('_',' ',$myfilearray[$i]);
+ $sel_file = '';
+ if ($myfilearray[$i]==$selected)
+ {
+ $sel_file = 'selected';
+ }
+
+ $conv_list[] = array
+ (
+ 'id' => $myfilearray[$i],
+ 'name' => $fname,
+ 'selected' => $sel_file
+ );
+ }
+
+ for ($i=0;$i<count($conv_list);$i++)
+ {
+ if ($conv_list[$i]['selected'] != 'selected')
+ {
+ unset($conv_list[$i]['selected']);
+ }
+ }
+
+ return $conv_list;
+
+ }
+
+ function select_rollback_file($selected='')
+ {
+ $this->config->read_repository();
+ $file_catalog =
$this->config->config_data['export_path'];
+
+ $dir_handle = @opendir($file_catalog);
+ $i=0; $myfilearray = '';
+ while ($file = readdir($dir_handle))
+ {
+ if ((substr($file, 0, 1) != '.') &&
is_file($file_catalog . SEP . $file) )
+ {
+ $myfilearray[$i] = $file;
+ $i++;
+ }
+ }
+ closedir($dir_handle);
+ @sort($myfilearray);
+
+ for ($i=0;$i<count($myfilearray);$i++)
+ {
+ $fname = ereg_replace('_',' ',$myfilearray[$i]);
+ $sel_file = '';
+ if ($myfilearray[$i]==$selected)
+ {
+ $sel_file = 'selected';
+ }
+
+ $rollback_list[] = array
+ (
+ 'id' => $myfilearray[$i],
+ 'name' => $fname,
+ 'selected' => $sel_file
+ );
+ }
+
+ for ($i=0;$i<count($rollback_list);$i++)
+ {
+ if ($rollback_list[$i]['selected'] !=
'selected')
+ {
+ unset($rollback_list[$i]['selected']);
+ }
+ }
+
+ return $rollback_list;
+
+ }
+
+ function import($invoice_common,$download)
+ {
+ include (PHPGW_APP_INC . '/import/' .
$invoice_common['conv_type']);
+ $invoice = new import_conv;
+
+ $buffer = $invoice->import($invoice_common,$download);
+ if ($download)
+ {
+ $header = $invoice->header;
+ $import = $invoice->import;
+ $buffer= array(
+ 'table' => $buffer,
+ 'header' => $header,
+ 'import' => $import
+ );
+ }
+ return $buffer;
+ }
+
+ function export($data)
+ {
+ $conv_type = $data['conv_type'];
+ $download = $data['download'];
+ $pre_transfer = $data['pre_transfer'];
+ $force_period_year = $data['force_period_year'];
+
+ include(PHPGW_SERVER_ROOT.'/'.'property'.'/inc/export/'
. $conv_type);
+ $invoice = new export_conv;
+
+ $buffer =
$invoice->overfor($download,$pre_transfer,$force_period_year);
+
+ return $buffer;
+ }
+
+ function rollback($conv_type,$role_back_date,$rollback_file)
+ {
+ include (PHPGW_APP_INC . '/export/' . $conv_type);
+ $invoice = new export_conv;
+ $buffer =
$invoice->RullTilbake($role_back_date,$rollback_file);
+ return $buffer;
+
+ }
+
+ function export_cron($data)
+ {
+ if($data['enabled']==1)
+ {
+ $this->export($data);
+ }
+ }
+
+ }
+?>
Index: property/inc/class.boactor.inc.php
diff -u property/inc/class.boactor.inc.php:1.6
property/inc/class.boactor.inc.php:1.7
--- property/inc/class.boactor.inc.php:1.6 Thu May 12 21:26:28 2005
+++ property/inc/class.boactor.inc.php Fri Jan 27 14:05:42 2006
@@ -1,416 +1,416 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.boactor.inc.php,v 1.6 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class boactor
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
- var $role;
- var $member_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- function boactor($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so = CreateObject($this->currentapp.'.soactor');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $allrows =
get_var('allrows',array('POST','GET'));
- $role = get_var('role',array('POST','GET'));
- $member_id =
get_var('member_id',array('POST','GET'));
-
-
- $this->role = $role;
- $this->so->role = $role;
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id) && !empty($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- else
- {
- unset($this->cat_id);
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
- if(isset($member_id))
- {
- $this->member_id = $member_id;
- }
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','actor_' .
$this->role,$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','actor_' . $this->role);
-
- //_debug_array($data);
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->member_id= $data['member_id'];
- $this->allrows = $data['allrows'];
- }
-
- function check_perms($has, $needed)
- {
- return (!!($has & $needed) == True);
- }
-
-
- function select_category_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
- $categories= $this->so->select_category_list();
-
- while (is_array($categories) && list(,$category) =
each($categories))
- {
- $sel_category = '';
- if ($category['id']==$selected)
- {
- $sel_category = 'selected';
- }
-
- $category_list[] = array
- (
- 'cat_id' => $category['id'],
- 'name' => $category['name'],
- 'selected' => $sel_category
- );
- }
-
- for ($i=0;$i<count($category_list);$i++)
- {
- if ($category_list[$i]['selected'] !=
'selected')
- {
- unset($category_list[$i]['selected']);
- }
- }
-
- return $category_list;
- }
-
- function read()
- {
- $actor = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows,'member_id'=>$this->member_id));
- $this->total_records = $this->so->total_records;
-
- $this->uicols = $this->so->uicols;
-
- for ($i=0; $i<count($actor); $i++)
- {
- $actor[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($actor[$i]['date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- }
- return $actor;
- }
-
- function read_single($data)
- {
- $contacts =
CreateObject('phpgwapi.contacts');
-
- $vendor = CreateObject($this->currentapp.'.soactor');
- $vendor->role = 'vendor';
-
-
- $actor = $this->so->read_single($data);
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-
- $input_type_array = array(
- 'R' => 'radio',
- 'CH' => 'checkbox',
- 'LB' => 'listbox'
- );
-
- $sep = '/';
- $dlarr[strpos($dateformat,'Y')] = 'Y';
- $dlarr[strpos($dateformat,'m')] = 'm';
- $dlarr[strpos($dateformat,'d')] = 'd';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- $m=0;
- for ($i=0;$i<count($actor['attributes']);$i++)
- {
- if($actor['attributes'][$i]['datatype']=='D' &&
$actor['attributes'][$i]['value'])
- {
- $timestamp_date=
mktime(0,0,0,date(m,strtotime($actor['attributes'][$i]['value'])),date(d,strtotime($actor['attributes'][$i]['value'])),date(y,strtotime($actor['attributes'][$i]['value'])));
- $actor['attributes'][$i]['value']
= $GLOBALS['phpgw']->common->show_date($timestamp_date,$dateformat);
- }
- if($actor['attributes'][$i]['datatype']=='AB')
- {
- if($actor['attributes'][$i]['value'])
- {
- $contact_data =
$contacts->read_single_entry($actor['attributes'][$i]['value'],array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
-
$actor['attributes'][$i]['contact_name'] = $contact_data[0]['n_family']
. ', ' . $contact_data[0]['n_given'];
- }
-
- $insert_record_actor[] =
$actor['attributes'][$i]['name'];
- $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.addressbook&column='
. $actor['attributes'][$i]['name']);
-
- $lookup_functions[$m]['name'] =
'lookup_'. $actor['attributes'][$i]['name'] .'()';
- $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
- $m++;
- }
-
if($actor['attributes'][$i]['datatype']=='VENDOR')
- {
- if($actor['attributes'][$i]['value'])
- {
- $vendor_data =
$vendor->read_single(array('actor_id'=>$actor['attributes'][$i]['value']));
-
- for
($n=0;$n<count($vendor_data['attributes']);$n++)
- {
-
if($vendor_data['attributes'][$n]['name'] == 'org_name')
- {
-
$actor['attributes'][$i]['vendor_name']=
$vendor_data['attributes'][$n]['value'];
- $n
=count($vendor_data['attributes']);
- }
- }
- }
-
- $insert_record_actor[] =
$actor['attributes'][$i]['name'];
- $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor&column='
. $actor['attributes'][$i]['name']);
-
- $lookup_functions[$m]['name'] =
'lookup_'. $actor['attributes'][$i]['name'] .'()';
- $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
- $m++;
- }
- if($actor['attributes'][$i]['datatype']=='R' ||
$actor['attributes'][$i]['datatype']=='CH' ||
$actor['attributes'][$i]['datatype']=='LB')
- {
- $actor['attributes'][$i]['choice']
= $this->so->read_attrib_choice($actor['attributes'][$i]['attrib_id']);
-
$input_type=$input_type_array[$actor['attributes'][$i]['datatype']];
-
-
if($actor['attributes'][$i]['datatype']=='CH')
- {
-
$actor['attributes'][$i]['value']=unserialize($actor['attributes'][$i]['value']);
-
$actor['attributes'][$i]['choice'] =
$this->bocommon->select_multi_list_2($actor['attributes'][$i]['value'],$actor['attributes'][$i]['choice'],$input_type);
-
- }
- else
- {
- for
($j=0;$j<count($actor['attributes'][$i]['choice']);$j++)
- {
-
$actor['attributes'][$i]['choice'][$j]['input_type']=$input_type;
-
if($actor['attributes'][$i]['choice'][$j]['id']==$actor['attributes'][$i]['value'])
- {
-
$actor['attributes'][$i]['choice'][$j]['checked']='checked';
- }
- }
- }
- }
-
- $actor['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($actor['attributes'][$i]['datatype']);
- $actor['attributes'][$i]['counter'] = $i;
- $actor['attributes'][$i]['type_id'] =
$data['type_id'];
- }
-
- for ($j=0;$j<count($lookup_functions);$j++)
- {
- $actor['lookup_functions'] .= 'function ' .
$lookup_functions[$j]['name'] ."\r\n";
- $actor['lookup_functions'] .= '{'."\r\n";
- $actor['lookup_functions'] .=
$lookup_functions[$j]['action'] ."\r\n";
- $actor['lookup_functions'] .= '}'."\r\n";
- }
-
-
$GLOBALS['phpgw']->session->appsession('insert_record_actor',$this->currentapp,$insert_record_actor);
-
-//html_print_r($actor);
- return $actor;
- }
-
- function save($actor,$values_attribute='')
- {
-
- for ($i=0;$i<count($values_attribute);$i++)
- {
- if($values_attribute[$i]['datatype']=='CH' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
serialize($values_attribute[$i]['value']);
- }
- if($values_attribute[$i]['datatype']=='R' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
$values_attribute[$i]['value'][0];
- }
-
- if($values_attribute[$i]['datatype']=='N' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
str_replace(",",".",$values_attribute[$i]['value']);
- }
-
- if($values_attribute[$i]['datatype']=='D' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
date($this->bocommon->dateformat,$this->bocommon->date_to_timestamp($values_attribute[$i]['value']));
- }
- }
-
- if ($actor['actor_id'])
- {
- if ($actor['actor_id'] != 0)
- {
- $actor_id = $actor['actor_id'];
-
$receipt=$this->so->edit($actor,$values_attribute);
- }
- }
- else
- {
- $receipt =
$this->so->add($actor,$values_attribute);
- }
- return $receipt;
- }
-
- function delete($actor_id='',$id='',$attrib='')
- {
- if ($attrib)
- {
- $this->so->delete_attrib($id);
- }
- else
- {
- $this->so->delete($actor_id);
- }
- }
-
- function read_attrib($type_id='')
- {
- $attrib = $this->so->read_attrib(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'allrows'=>$this->allrows));
-
- for ($i=0; $i<count($attrib); $i++)
- {
- $attrib[$i]['datatype'] =
$this->bocommon->translate_datatype($attrib[$i]['datatype']);
- }
-
- $this->total_records = $this->so->total_records;
-
- return $attrib;
- }
-
- function read_single_attrib($id)
- {
- return $this->so->read_single_attrib($id);
- }
-
- function resort_attrib($data)
- {
- $this->so->resort_attrib($data);
- }
-
- function save_attrib($attrib,$action='')
- {
- if ($action=='edit')
- {
- if ($attrib['id'] != '')
- {
-
- $receipt =
$this->so->edit_attrib($attrib);
- }
- }
- else
- {
- $receipt = $this->so->add_attrib($attrib);
- }
- return $receipt;
- }
-
- function column_list($selected='',$allrows='')
- {
- if(!$selected)
- {
-
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]["actor_columns_"
. $this->role];
- }
-
- $columns =
$this->so->read_attrib(array('allrows'=>$allrows,'column_list'=>True));
-
-
$column_list=$this->bocommon->select_multi_list($selected,$columns);
-
- return $column_list;
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.boactor.inc.php,v 1.7 2006/01/27 14:05:42
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class boactor
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+ var $role;
+ var $member_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ function boactor($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so = CreateObject($this->currentapp.'.soactor');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $allrows =
get_var('allrows',array('POST','GET'));
+ $role = get_var('role',array('POST','GET'));
+ $member_id =
get_var('member_id',array('POST','GET'));
+
+
+ $this->role = $role;
+ $this->so->role = $role;
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id) && !empty($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ else
+ {
+ unset($this->cat_id);
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+ if(isset($member_id))
+ {
+ $this->member_id = $member_id;
+ }
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','actor_' .
$this->role,$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','actor_' . $this->role);
+
+ //_debug_array($data);
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->member_id= $data['member_id'];
+ $this->allrows = $data['allrows'];
+ }
+
+ function check_perms($has, $needed)
+ {
+ return (!!($has & $needed) == True);
+ }
+
+
+ function select_category_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ break;
+ }
+
+ $categories= $this->so->select_category_list();
+
+ while (is_array($categories) && list(,$category) =
each($categories))
+ {
+ $sel_category = '';
+ if ($category['id']==$selected)
+ {
+ $sel_category = 'selected';
+ }
+
+ $category_list[] = array
+ (
+ 'cat_id' => $category['id'],
+ 'name' => $category['name'],
+ 'selected' => $sel_category
+ );
+ }
+
+ for ($i=0;$i<count($category_list);$i++)
+ {
+ if ($category_list[$i]['selected'] !=
'selected')
+ {
+ unset($category_list[$i]['selected']);
+ }
+ }
+
+ return $category_list;
+ }
+
+ function read()
+ {
+ $actor = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows,'member_id'=>$this->member_id));
+ $this->total_records = $this->so->total_records;
+
+ $this->uicols = $this->so->uicols;
+
+ for ($i=0; $i<count($actor); $i++)
+ {
+ $actor[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($actor[$i]['date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ }
+ return $actor;
+ }
+
+ function read_single($data)
+ {
+ $contacts =
CreateObject('phpgwapi.contacts');
+
+ $vendor = CreateObject($this->currentapp.'.soactor');
+ $vendor->role = 'vendor';
+
+
+ $actor = $this->so->read_single($data);
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ $input_type_array = array(
+ 'R' => 'radio',
+ 'CH' => 'checkbox',
+ 'LB' => 'listbox'
+ );
+
+ $sep = '/';
+ $dlarr[strpos($dateformat,'Y')] = 'Y';
+ $dlarr[strpos($dateformat,'m')] = 'm';
+ $dlarr[strpos($dateformat,'d')] = 'd';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ $m=0;
+ for ($i=0;$i<count($actor['attributes']);$i++)
+ {
+ if($actor['attributes'][$i]['datatype']=='D' &&
$actor['attributes'][$i]['value'])
+ {
+ $timestamp_date=
mktime(0,0,0,date(m,strtotime($actor['attributes'][$i]['value'])),date(d,strtotime($actor['attributes'][$i]['value'])),date(y,strtotime($actor['attributes'][$i]['value'])));
+ $actor['attributes'][$i]['value']
= $GLOBALS['phpgw']->common->show_date($timestamp_date,$dateformat);
+ }
+ if($actor['attributes'][$i]['datatype']=='AB')
+ {
+ if($actor['attributes'][$i]['value'])
+ {
+ $contact_data =
$contacts->read_single_entry($actor['attributes'][$i]['value'],array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
+
$actor['attributes'][$i]['contact_name'] = $contact_data[0]['n_family']
. ', ' . $contact_data[0]['n_given'];
+ }
+
+ $insert_record_actor[] =
$actor['attributes'][$i]['name'];
+ $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.addressbook&column='
. $actor['attributes'][$i]['name']);
+
+ $lookup_functions[$m]['name'] =
'lookup_'. $actor['attributes'][$i]['name'] .'()';
+ $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+ $m++;
+ }
+
if($actor['attributes'][$i]['datatype']=='VENDOR')
+ {
+ if($actor['attributes'][$i]['value'])
+ {
+ $vendor_data =
$vendor->read_single(array('actor_id'=>$actor['attributes'][$i]['value']));
+
+ for
($n=0;$n<count($vendor_data['attributes']);$n++)
+ {
+
if($vendor_data['attributes'][$n]['name'] == 'org_name')
+ {
+
$actor['attributes'][$i]['vendor_name']=
$vendor_data['attributes'][$n]['value'];
+ $n
=count($vendor_data['attributes']);
+ }
+ }
+ }
+
+ $insert_record_actor[] =
$actor['attributes'][$i]['name'];
+ $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor&column='
. $actor['attributes'][$i]['name']);
+
+ $lookup_functions[$m]['name'] =
'lookup_'. $actor['attributes'][$i]['name'] .'()';
+ $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+ $m++;
+ }
+ if($actor['attributes'][$i]['datatype']=='R' ||
$actor['attributes'][$i]['datatype']=='CH' ||
$actor['attributes'][$i]['datatype']=='LB')
+ {
+ $actor['attributes'][$i]['choice']
= $this->so->read_attrib_choice($actor['attributes'][$i]['attrib_id']);
+
$input_type=$input_type_array[$actor['attributes'][$i]['datatype']];
+
+
if($actor['attributes'][$i]['datatype']=='CH')
+ {
+
$actor['attributes'][$i]['value']=unserialize($actor['attributes'][$i]['value']);
+
$actor['attributes'][$i]['choice'] =
$this->bocommon->select_multi_list_2($actor['attributes'][$i]['value'],$actor['attributes'][$i]['choice'],$input_type);
+
+ }
+ else
+ {
+ for
($j=0;$j<count($actor['attributes'][$i]['choice']);$j++)
+ {
+
$actor['attributes'][$i]['choice'][$j]['input_type']=$input_type;
+
if($actor['attributes'][$i]['choice'][$j]['id']==$actor['attributes'][$i]['value'])
+ {
+
$actor['attributes'][$i]['choice'][$j]['checked']='checked';
+ }
+ }
+ }
+ }
+
+ $actor['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($actor['attributes'][$i]['datatype']);
+ $actor['attributes'][$i]['counter'] = $i;
+ $actor['attributes'][$i]['type_id'] =
$data['type_id'];
+ }
+
+ for ($j=0;$j<count($lookup_functions);$j++)
+ {
+ $actor['lookup_functions'] .= 'function ' .
$lookup_functions[$j]['name'] ."\r\n";
+ $actor['lookup_functions'] .= '{'."\r\n";
+ $actor['lookup_functions'] .=
$lookup_functions[$j]['action'] ."\r\n";
+ $actor['lookup_functions'] .= '}'."\r\n";
+ }
+
+
$GLOBALS['phpgw']->session->appsession('insert_record_actor',$this->currentapp,$insert_record_actor);
+
+//html_print_r($actor);
+ return $actor;
+ }
+
+ function save($actor,$values_attribute='')
+ {
+
+ for ($i=0;$i<count($values_attribute);$i++)
+ {
+ if($values_attribute[$i]['datatype']=='CH' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
serialize($values_attribute[$i]['value']);
+ }
+ if($values_attribute[$i]['datatype']=='R' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
$values_attribute[$i]['value'][0];
+ }
+
+ if($values_attribute[$i]['datatype']=='N' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
str_replace(",",".",$values_attribute[$i]['value']);
+ }
+
+ if($values_attribute[$i]['datatype']=='D' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
date($this->bocommon->dateformat,$this->bocommon->date_to_timestamp($values_attribute[$i]['value']));
+ }
+ }
+
+ if ($actor['actor_id'])
+ {
+ if ($actor['actor_id'] != 0)
+ {
+ $actor_id = $actor['actor_id'];
+
$receipt=$this->so->edit($actor,$values_attribute);
+ }
+ }
+ else
+ {
+ $receipt =
$this->so->add($actor,$values_attribute);
+ }
+ return $receipt;
+ }
+
+ function delete($actor_id='',$id='',$attrib='')
+ {
+ if ($attrib)
+ {
+ $this->so->delete_attrib($id);
+ }
+ else
+ {
+ $this->so->delete($actor_id);
+ }
+ }
+
+ function read_attrib($type_id='')
+ {
+ $attrib = $this->so->read_attrib(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'allrows'=>$this->allrows));
+
+ for ($i=0; $i<count($attrib); $i++)
+ {
+ $attrib[$i]['datatype'] =
$this->bocommon->translate_datatype($attrib[$i]['datatype']);
+ }
+
+ $this->total_records = $this->so->total_records;
+
+ return $attrib;
+ }
+
+ function read_single_attrib($id)
+ {
+ return $this->so->read_single_attrib($id);
+ }
+
+ function resort_attrib($data)
+ {
+ $this->so->resort_attrib($data);
+ }
+
+ function save_attrib($attrib,$action='')
+ {
+ if ($action=='edit')
+ {
+ if ($attrib['id'] != '')
+ {
+
+ $receipt =
$this->so->edit_attrib($attrib);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add_attrib($attrib);
+ }
+ return $receipt;
+ }
+
+ function column_list($selected='',$allrows='')
+ {
+ if(!$selected)
+ {
+
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]["actor_columns_"
. $this->role];
+ }
+
+ $columns =
$this->so->read_attrib(array('allrows'=>$allrows,'column_list'=>True));
+
+
$column_list=$this->bocommon->select_multi_list($selected,$columns);
+
+ return $column_list;
+ }
+ }
+?>
Index: property/inc/class.boadmin.inc.php
diff -u property/inc/class.boadmin.inc.php:1.6
property/inc/class.boadmin.inc.php:1.7
--- property/inc/class.boadmin.inc.php:1.6 Fri Nov 25 12:44:57 2005
+++ property/inc/class.boadmin.inc.php Fri Jan 27 14:05:43 2006
@@ -1,508 +1,508 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.boadmin.inc.php,v 1.6 2005/11/25 12:44:57
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class boadmin
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- function boadmin($session='')
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.soadmin');
- $this->acl2 =
CreateObject($this->currentapp.'.acl2','##DEFAULT##','##DEFAULT##');
- $this->right = array(1,2,4,8,16,32,64,128);
- $this->app_id
=$GLOBALS['phpgw']->applications->data[$GLOBALS['phpgw_info']['flags']['currentapp']]['id'];
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $permission =
get_var('permission',array('POST','GET'));
- // $location =
get_var('location',array('POST','GET')); // don't work for some reason...
- $module = get_var('module',array('POST','GET'));
- $granting_group =
get_var('granting_group',array('POST','GET'));
- $allrows =
get_var('allrows',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(isset($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- if(isset($module))
- {
- $this->location = $module;
- }
- if(isset($granting_group))
- {
- $this->granting_group = $granting_group;
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
-
- if ($this->allrows)
- {
- $this->start = -1;
- $this->offset = -1;
- }
- }
-
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','fm_admin');
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->location = $data['location'];
- $this->granting_group = $data['granting_group'];
- $this->allrows = $data['allrows'];
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','fm_admin',$data);
- }
- }
-
-
-
- function select_location($format='',$selected='',$grant='')
- {
-
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('select_location'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_location'));
- break;
- }
-
- $locations= $this->so->select_location($grant);
-
- while (is_array($locations) && list(,$loc) =
each($locations))
- {
- $sel_loc = '';
- if ($loc['id']==$selected)
- {
- $sel_loc = 'selected';
- }
-
- $location_list[] = array
- (
- 'id' => $loc['id'],
- 'descr' => $loc['id'] . ' [' .
$loc['descr'] . ']',
- 'selected' => $sel_loc
- );
- }
-
- for ($i=0;$i<count($location_list);$i++)
- {
- if ($location_list[$i]['selected'] !=
'selected')
- {
- unset($location_list[$i]['selected']);
- }
- }
-
- return $location_list;
- }
-
- function select_category_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
-
- $categories[0]['id'] = 'groups';
- $categories[0]['name'] = lang('Groups');
- $categories[1]['id'] = 'accounts';
- $categories[1]['name'] = lang('Users');
-
- while (is_array($categories) && list(,$category) =
each($categories))
- {
- $sel_category = '';
- if ($category['id']==$selected)
- {
- $sel_category = 'selected';
- }
-
- $category_list[] = array
- (
- 'cat_id' => $category['id'],
- 'name' => $category['name'],
- 'selected' => $sel_category
- );
- }
-
- for ($i=0;$i<count($category_list);$i++)
- {
- if ($category_list[$i]['selected'] !=
'selected')
- {
- unset($category_list[$i]['selected']);
- }
- }
-
- return $category_list;
- }
-
- function set_permission2($values,$r_processed,$type)
- {
- @reset($values);
- $totalacl = array();
- while(list($rowinfo,$perm) = each($values))
- {
- list($user_id,$rights) = split('_',$rowinfo);
- $totalacl[$user_id] += $rights;
- }
- @reset($totalacl);
- while(list($user_id,$rights) = @each($totalacl))
- {
- $user_checked[]=$user_id;
-
-
$this->acl2->set($this->location,$rights,$user_id,$type);
- }
-
- if(is_array($r_processed) && is_array($user_checked))
- {
- $user_delete = array_diff($r_processed,
$user_checked);
- }
- else
- {
- $user_delete = $r_processed;
- }
- if(is_array($user_delete) && count($user_delete)>0)
- {
- $user_delete= explode("_",implode("_",
$user_delete));
-
- $this->remove_permission($user_delete,$type);
- }
- }
-
- function set_permission($values,$r_processed,$initials)
- {
- if($initials)
- {
- $this->so->set_initials($initials);
- }
-
- $r_processed=explode("_",$r_processed);
-
- if(!$values['right'])
- {
- $values['right'] = array();
- }
- if(!$values['mask'])
- {
- $values['mask'] = array();
- }
-
- $this->set_permission2($values['right'],$r_processed,0);
- $this->set_permission2($values['mask'],$r_processed,1);
-
-// $this->acl2->check('.invoice.test', $rights,$user_id);
-// echo 'rights_cache:<pre>'; print_r($this->acl2->rights_cache); echo
'</pre>';
-
- $receipt['message'][] = array('msg' =>
lang('permissions are updated!'));
- return $receipt;
- }
-
- function set_grant2($values,$r_processed,$type)
- {
- @reset($values);
- $totalacl = array();
- while(list($rowinfo,$perm) = each($values))
- {
- list($user_id,$rights) = split('_',$rowinfo);
- $totalacl[$user_id] += $rights;
- }
- @reset($totalacl);
- while(list($user_id,$rights) = @each($totalacl))
- {
- $user_checked[]=$user_id;
-
-
$this->acl2->set_grant($this->location,$rights,$user_id,$type,$this->granting_group);
- }
-
- if(is_array($r_processed) && is_array($user_checked))
- {
- $user_delete = array_diff($r_processed,
$user_checked);
- }
- else
- {
- $user_delete = $r_processed;
- }
- if(is_array($user_delete) && count($user_delete)>0)
- {
- $user_delete= explode("_",implode("_",
$user_delete));
-
- $this->remove_grant($user_delete,$type);
- }
-
- }
-
- function set_grant($values,$r_processed)
- {
- $r_processed=explode("_",$r_processed);
-
- if(!$values['right'])
- {
- $values['right'] = array();
- }
- if(!$values['mask'])
- {
- $values['mask'] = array();
- }
-
- $this->set_grant2($values['right'],$r_processed,0);
- $this->set_grant2($values['mask'],$r_processed,1);
-
- $receipt['message'][] = array('msg' =>
lang('permissions are updated!'));
- return $receipt;
- }
-
- function remove_permission($user_delete,$type)
- {
-
- $right=$this->right;
-
- for ($i=0;$i<count($user_delete);$i++)
- {
- for ($j=0;$j<count($right);$j++)
- {
-
$this->acl2->remove($this->location,$right[$j],$user_delete[$i],$type);
- }
- }
- }
-
- function remove_grant($user_delete,$type)
- {
-
- $right=$this->right;
-
- for ($i=0;$i<count($user_delete);$i++)
- {
- for ($j=0;$j<count($right);$j++)
- {
-
$this->acl2->remove_grant($this->location,$right[$j],$user_delete[$i],$type,$this->granting_group);
- }
- }
- }
-
- function get_user_list($type='',$app_id='')
- {
- if($this->granting_group)
- {
- $owner = $this->granting_group;
- }
- else
- {
- $owner =
$GLOBALS['phpgw_info']['user']['account_id'];
- }
-
- $right=$this->right;
-
- $GLOBALS['phpgw']->accounts->account_id = $owner;
-
- $allusers =
$GLOBALS['phpgw']->accounts->get_list($type, $this->start,$this->sort,
$this->order, $this->query, $this->offset);
-
- if (isSet($allusers) AND is_array($allusers))
- {
- $j=0;
- foreach($allusers as $account)
- {
-
if($account['account_id']!=$GLOBALS['phpgw_info']['user']['account_id'] ||
$this->granting_group)
- {
- $user_list[$j]['account_id']
= $account['account_id'];
- $user_list[$j]['account_lid']
= $account['account_lid'];
-
$user_list[$j]['account_firstname'] = $account['account_firstname'];
-
$user_list[$j]['account_lastname'] = $account['account_lastname'];
- $user_list[$j]['initials']
= $this->so->get_initials($account['account_id']);
-
- $count_right=count($right);
- for ($i=0;$i<$count_right;$i++)
- {
-
if($this->acl2->check_grant($owner,$this->location,
$right[$i],$account['account_id'],$app_id,True,0,True))
- {
-
$user_list[$j]['right'][$right[$i]] = 'checked';
- }
-
if($this->acl2->check_grant($owner,$this->location,
$right[$i],$account['account_id'],$this->app_id,True,1,True))
- {
-
$user_list[$j]['mask'][$right[$i]] = 'checked';
- }
- }
-
- if
(isSet($user_list[$j]['mask']) AND is_array($user_list[$j]['mask']))
- {
- $result_temp =
@array_diff(array_keys($user_list[$j]['right']),
array_keys($user_list[$j]['mask']));
- if (isSet($result_temp)
AND is_array($result_temp))
- {
-
foreach($result_temp as $temp)
- {
-
$user_list[$j]['result'][$temp] = 'checked';
- }
- }
- }
- else
- {
-
$user_list[$j]['result'] = $user_list[$j]['right'];
- }
-
- $user_list[$j]['right']['type']
= 'right';
- $user_list[$j]['mask']['type']
= 'mask';
-
$user_list[$j]['result']['type'] = 'result';
-
- $j++;
- }
- }
- }
-
- $this->total_records =
$GLOBALS['phpgw']->accounts->total;
-
-//_debug_array($user_list);
-
- return $user_list;
- }
-
-
- function get_user_list2($type='',$app_id='')
- {
- $right=$this->right;
-
- $allusers =
$GLOBALS['phpgw']->accounts->get_list($type, $this->start,$this->sort,
$this->order, $this->query, $this->offset);
-
- if (isSet($allusers) AND is_array($allusers))
- {
- $j=0;
- foreach($allusers as $account)
- {
- $user_list[$j]['account_id']
= $account['account_id'];
- $user_list[$j]['account_lid']
= $account['account_lid'];
- $user_list[$j]['account_firstname'] =
$account['account_firstname'];
- $user_list[$j]['account_lastname']
= $account['account_lastname'];
- $user_list[$j]['initials']
= $this->so->get_initials($account['account_id']);
-
- $count_right=count($right);
- for ($i=0;$i<$count_right;$i++)
- {
-
if($this->acl2->check($this->location,
$right[$i],$account['account_id'],$this->app_id,True,0,True))
- {
-
$user_list[$j]['right'][$right[$i]] = 'checked';
- }
-
if($this->acl2->check($this->location,
$right[$i],$account['account_id'],$this->app_id,True,1,True))
- {
-
$user_list[$j]['mask'][$right[$i]] = 'checked';
- }
- }
-
- if (isSet($user_list[$j]['mask']) AND
is_array($user_list[$j]['mask']))
- {
- $result_temp =
@array_diff(array_keys($user_list[$j]['right']),
array_keys($user_list[$j]['mask']));
- if (isSet($result_temp) AND
is_array($result_temp))
- {
- foreach($result_temp as
$temp)
- {
-
$user_list[$j]['result'][$temp] = 'checked';
- }
- }
- }
- else
- {
- $user_list[$j]['result'] =
$user_list[$j]['right'];
- }
-
- $user_list[$j]['right']['type'] =
'right';
- $user_list[$j]['mask']['type'] = 'mask';
- $user_list[$j]['result']['type'] =
'result';
-
- $j++;
- }
- }
-
- $this->total_records =
$GLOBALS['phpgw']->accounts->total;
-
- return $user_list;
- }
-
- function read_fm_id()
- {
-
- $fm_ids = $this->so->read_fm_id();
- return $fm_ids;
-
- }
- function edit_id($values='')
- {
- return $this->so->edit_id($values);
-
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.boadmin.inc.php,v 1.7 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class boadmin
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ function boadmin($session='')
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.soadmin');
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2','##DEFAULT##','##DEFAULT##');
+ $this->right = array(1,2,4,8,16,32,64,128);
+ $this->app_id
=$GLOBALS['phpgw']->applications->data[$GLOBALS['phpgw_info']['flags']['currentapp']]['id'];
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $permission =
get_var('permission',array('POST','GET'));
+ // $location =
get_var('location',array('POST','GET')); // don't work for some reason...
+ $module = get_var('module',array('POST','GET'));
+ $granting_group =
get_var('granting_group',array('POST','GET'));
+ $allrows =
get_var('allrows',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(isset($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ if(isset($module))
+ {
+ $this->location = $module;
+ }
+ if(isset($granting_group))
+ {
+ $this->granting_group = $granting_group;
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+
+ if ($this->allrows)
+ {
+ $this->start = -1;
+ $this->offset = -1;
+ }
+ }
+
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','fm_admin');
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->location = $data['location'];
+ $this->granting_group = $data['granting_group'];
+ $this->allrows = $data['allrows'];
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','fm_admin',$data);
+ }
+ }
+
+
+
+ function select_location($format='',$selected='',$grant='')
+ {
+
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('select_location'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_location'));
+ break;
+ }
+
+ $locations= $this->so->select_location($grant);
+
+ while (is_array($locations) && list(,$loc) =
each($locations))
+ {
+ $sel_loc = '';
+ if ($loc['id']==$selected)
+ {
+ $sel_loc = 'selected';
+ }
+
+ $location_list[] = array
+ (
+ 'id' => $loc['id'],
+ 'descr' => $loc['id'] . ' [' .
$loc['descr'] . ']',
+ 'selected' => $sel_loc
+ );
+ }
+
+ for ($i=0;$i<count($location_list);$i++)
+ {
+ if ($location_list[$i]['selected'] !=
'selected')
+ {
+ unset($location_list[$i]['selected']);
+ }
+ }
+
+ return $location_list;
+ }
+
+ function select_category_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ break;
+ }
+
+
+ $categories[0]['id'] = 'groups';
+ $categories[0]['name'] = lang('Groups');
+ $categories[1]['id'] = 'accounts';
+ $categories[1]['name'] = lang('Users');
+
+ while (is_array($categories) && list(,$category) =
each($categories))
+ {
+ $sel_category = '';
+ if ($category['id']==$selected)
+ {
+ $sel_category = 'selected';
+ }
+
+ $category_list[] = array
+ (
+ 'cat_id' => $category['id'],
+ 'name' => $category['name'],
+ 'selected' => $sel_category
+ );
+ }
+
+ for ($i=0;$i<count($category_list);$i++)
+ {
+ if ($category_list[$i]['selected'] !=
'selected')
+ {
+ unset($category_list[$i]['selected']);
+ }
+ }
+
+ return $category_list;
+ }
+
+ function set_permission2($values,$r_processed,$type)
+ {
+ @reset($values);
+ $totalacl = array();
+ while(list($rowinfo,$perm) = each($values))
+ {
+ list($user_id,$rights) = split('_',$rowinfo);
+ $totalacl[$user_id] += $rights;
+ }
+ @reset($totalacl);
+ while(list($user_id,$rights) = @each($totalacl))
+ {
+ $user_checked[]=$user_id;
+
+
$this->acl2->set($this->location,$rights,$user_id,$type);
+ }
+
+ if(is_array($r_processed) && is_array($user_checked))
+ {
+ $user_delete = array_diff($r_processed,
$user_checked);
+ }
+ else
+ {
+ $user_delete = $r_processed;
+ }
+ if(is_array($user_delete) && count($user_delete)>0)
+ {
+ $user_delete= explode("_",implode("_",
$user_delete));
+
+ $this->remove_permission($user_delete,$type);
+ }
+ }
+
+ function set_permission($values,$r_processed,$initials)
+ {
+ if($initials)
+ {
+ $this->so->set_initials($initials);
+ }
+
+ $r_processed=explode("_",$r_processed);
+
+ if(!$values['right'])
+ {
+ $values['right'] = array();
+ }
+ if(!$values['mask'])
+ {
+ $values['mask'] = array();
+ }
+
+ $this->set_permission2($values['right'],$r_processed,0);
+ $this->set_permission2($values['mask'],$r_processed,1);
+
+// $this->acl2->check('.invoice.test', $rights,$user_id);
+// echo 'rights_cache:<pre>'; print_r($this->acl2->rights_cache); echo
'</pre>';
+
+ $receipt['message'][] = array('msg' =>
lang('permissions are updated!'));
+ return $receipt;
+ }
+
+ function set_grant2($values,$r_processed,$type)
+ {
+ @reset($values);
+ $totalacl = array();
+ while(list($rowinfo,$perm) = each($values))
+ {
+ list($user_id,$rights) = split('_',$rowinfo);
+ $totalacl[$user_id] += $rights;
+ }
+ @reset($totalacl);
+ while(list($user_id,$rights) = @each($totalacl))
+ {
+ $user_checked[]=$user_id;
+
+
$this->acl2->set_grant($this->location,$rights,$user_id,$type,$this->granting_group);
+ }
+
+ if(is_array($r_processed) && is_array($user_checked))
+ {
+ $user_delete = array_diff($r_processed,
$user_checked);
+ }
+ else
+ {
+ $user_delete = $r_processed;
+ }
+ if(is_array($user_delete) && count($user_delete)>0)
+ {
+ $user_delete= explode("_",implode("_",
$user_delete));
+
+ $this->remove_grant($user_delete,$type);
+ }
+
+ }
+
+ function set_grant($values,$r_processed)
+ {
+ $r_processed=explode("_",$r_processed);
+
+ if(!$values['right'])
+ {
+ $values['right'] = array();
+ }
+ if(!$values['mask'])
+ {
+ $values['mask'] = array();
+ }
+
+ $this->set_grant2($values['right'],$r_processed,0);
+ $this->set_grant2($values['mask'],$r_processed,1);
+
+ $receipt['message'][] = array('msg' =>
lang('permissions are updated!'));
+ return $receipt;
+ }
+
+ function remove_permission($user_delete,$type)
+ {
+
+ $right=$this->right;
+
+ for ($i=0;$i<count($user_delete);$i++)
+ {
+ for ($j=0;$j<count($right);$j++)
+ {
+
$this->acl2->remove($this->location,$right[$j],$user_delete[$i],$type);
+ }
+ }
+ }
+
+ function remove_grant($user_delete,$type)
+ {
+
+ $right=$this->right;
+
+ for ($i=0;$i<count($user_delete);$i++)
+ {
+ for ($j=0;$j<count($right);$j++)
+ {
+
$this->acl2->remove_grant($this->location,$right[$j],$user_delete[$i],$type,$this->granting_group);
+ }
+ }
+ }
+
+ function get_user_list($type='',$app_id='')
+ {
+ if($this->granting_group)
+ {
+ $owner = $this->granting_group;
+ }
+ else
+ {
+ $owner =
$GLOBALS['phpgw_info']['user']['account_id'];
+ }
+
+ $right=$this->right;
+
+ $GLOBALS['phpgw']->accounts->account_id = $owner;
+
+ $allusers =
$GLOBALS['phpgw']->accounts->get_list($type, $this->start,$this->sort,
$this->order, $this->query, $this->offset);
+
+ if (isSet($allusers) AND is_array($allusers))
+ {
+ $j=0;
+ foreach($allusers as $account)
+ {
+
if($account['account_id']!=$GLOBALS['phpgw_info']['user']['account_id'] ||
$this->granting_group)
+ {
+ $user_list[$j]['account_id']
= $account['account_id'];
+ $user_list[$j]['account_lid']
= $account['account_lid'];
+
$user_list[$j]['account_firstname'] = $account['account_firstname'];
+
$user_list[$j]['account_lastname'] = $account['account_lastname'];
+ $user_list[$j]['initials']
= $this->so->get_initials($account['account_id']);
+
+ $count_right=count($right);
+ for ($i=0;$i<$count_right;$i++)
+ {
+
if($this->acl2->check_grant($owner,$this->location,
$right[$i],$account['account_id'],$app_id,True,0,True))
+ {
+
$user_list[$j]['right'][$right[$i]] = 'checked';
+ }
+
if($this->acl2->check_grant($owner,$this->location,
$right[$i],$account['account_id'],$this->app_id,True,1,True))
+ {
+
$user_list[$j]['mask'][$right[$i]] = 'checked';
+ }
+ }
+
+ if
(isSet($user_list[$j]['mask']) AND is_array($user_list[$j]['mask']))
+ {
+ $result_temp =
@array_diff(array_keys($user_list[$j]['right']),
array_keys($user_list[$j]['mask']));
+ if (isSet($result_temp)
AND is_array($result_temp))
+ {
+
foreach($result_temp as $temp)
+ {
+
$user_list[$j]['result'][$temp] = 'checked';
+ }
+ }
+ }
+ else
+ {
+
$user_list[$j]['result'] = $user_list[$j]['right'];
+ }
+
+ $user_list[$j]['right']['type']
= 'right';
+ $user_list[$j]['mask']['type']
= 'mask';
+
$user_list[$j]['result']['type'] = 'result';
+
+ $j++;
+ }
+ }
+ }
+
+ $this->total_records =
$GLOBALS['phpgw']->accounts->total;
+
+//_debug_array($user_list);
+
+ return $user_list;
+ }
+
+
+ function get_user_list2($type='',$app_id='')
+ {
+ $right=$this->right;
+
+ $allusers =
$GLOBALS['phpgw']->accounts->get_list($type, $this->start,$this->sort,
$this->order, $this->query, $this->offset);
+
+ if (isSet($allusers) AND is_array($allusers))
+ {
+ $j=0;
+ foreach($allusers as $account)
+ {
+ $user_list[$j]['account_id']
= $account['account_id'];
+ $user_list[$j]['account_lid']
= $account['account_lid'];
+ $user_list[$j]['account_firstname'] =
$account['account_firstname'];
+ $user_list[$j]['account_lastname']
= $account['account_lastname'];
+ $user_list[$j]['initials']
= $this->so->get_initials($account['account_id']);
+
+ $count_right=count($right);
+ for ($i=0;$i<$count_right;$i++)
+ {
+
if($this->acl2->check($this->location,
$right[$i],$account['account_id'],$this->app_id,True,0,True))
+ {
+
$user_list[$j]['right'][$right[$i]] = 'checked';
+ }
+
if($this->acl2->check($this->location,
$right[$i],$account['account_id'],$this->app_id,True,1,True))
+ {
+
$user_list[$j]['mask'][$right[$i]] = 'checked';
+ }
+ }
+
+ if (isSet($user_list[$j]['mask']) AND
is_array($user_list[$j]['mask']))
+ {
+ $result_temp =
@array_diff(array_keys($user_list[$j]['right']),
array_keys($user_list[$j]['mask']));
+ if (isSet($result_temp) AND
is_array($result_temp))
+ {
+ foreach($result_temp as
$temp)
+ {
+
$user_list[$j]['result'][$temp] = 'checked';
+ }
+ }
+ }
+ else
+ {
+ $user_list[$j]['result'] =
$user_list[$j]['right'];
+ }
+
+ $user_list[$j]['right']['type'] =
'right';
+ $user_list[$j]['mask']['type'] = 'mask';
+ $user_list[$j]['result']['type'] =
'result';
+
+ $j++;
+ }
+ }
+
+ $this->total_records =
$GLOBALS['phpgw']->accounts->total;
+
+ return $user_list;
+ }
+
+ function read_fm_id()
+ {
+
+ $fm_ids = $this->so->read_fm_id();
+ return $fm_ids;
+
+ }
+ function edit_id($values='')
+ {
+ return $this->so->edit_id($values);
+
+ }
+ }
+?>
Index: property/inc/class.boadmin_entity.inc.php
diff -u property/inc/class.boadmin_entity.inc.php:1.8
property/inc/class.boadmin_entity.inc.php:1.9
--- property/inc/class.boadmin_entity.inc.php:1.8 Mon Oct 24 10:43:29 2005
+++ property/inc/class.boadmin_entity.inc.php Fri Jan 27 14:05:43 2006
@@ -1,475 +1,475 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.boadmin_entity.inc.php,v 1.8 2005/10/24 10:43:29
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class boadmin_entity
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
- var $entity_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- var $soap_functions = array(
- 'list' => array(
- 'in' =>
array('int','int','struct','string','int'),
- 'out' => array('array')
- ),
- 'read' => array(
- 'in' => array('int','struct'),
- 'out' => array('array')
- ),
- 'save' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- ),
- 'delete' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- )
- );
-
- function boadmin_entity($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.soadmin_entity');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $allrows =
get_var('allrows',array('POST','GET'));
- $entity_id =
get_var('entity_id',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- if(isset($entity_id))
- {
- $this->entity_id = $entity_id;
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
- }
-
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','standard_e',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','standard_e');
-
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->entity_id = $data['entity_id'];
- $this->allrows = $data['allrows'];
- }
-
- function reset_fm_cache()
- {
- $this->so->reset_fm_cache();
- }
-
-
- function get_location_level_list($selected='')
- {
-
- $soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
- $location_types =
$soadmin_location->select_location_type();
- $max_location_type=count($location_types);
-
- for ($i=1; $i<=$max_location_type; $i++)
- {
- $location[$i][id] = $i;
- $location[$i][name] = $i . '-' .
$location_types[($i-1)]['name'];
- }
-
- return
$this->bocommon->select_list($selected,$location);
-
- }
-
- function get_entity_list($selected='')
- {
- $list = $this->so->read(array('allrows'=>True));
- return
$this->bocommon->select_multi_list($selected,$list);
- }
-
- function get_entity_list_2($selected='')
- {
- $list[0]['id']='project';
- $list[0]['name']='project';
- $list[1]['id']='ticket';
- $list[1]['name']='ticket';
- $list[2]['id']='document';
- $list[2]['name']='document';
- $list[3]['id']='request';
- $list[3]['name']='request';
- $list[4]['id']='investment';
- $list[4]['name']='investment';
- $list[5]['id']='s_agreement';
- $list[5]['name']='service agreement';
- return
$this->bocommon->select_multi_list($selected,$list);
- }
-
- function get_entity_list_3($selected='')
- {
- $list[0]['id']='ticket';
- $list[0]['name']='ticket';
- $list[1]['id']='request';
- $list[1]['name']='request';
- return
$this->bocommon->select_multi_list($selected,$list);
- }
-
- function read()
- {
- $entity = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,'allrows'=>$this->allrows));
-
- $this->total_records = $this->so->total_records;
- return $entity;
- }
-
- function read_category($entity_id)
- {
- $category = $this->so->read_category(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,
- 'order' =>
$this->order,'allrows'=>$this->allrows,'entity_id'=>$entity_id));
-
- $this->total_records = $this->so->total_records;
-
- return $category;
- }
-
- function read_status()
- {
- $status = $this->so->read_status(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,
- 'order' =>
$this->order,'allrows'=>$this->allrows,'entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id));
-
- $this->total_records = $this->so->total_records;
-
- return $status;
- }
-
- function read_config()
- {
- $standard = $this->so->read_config(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order));
-
- $this->total_records = $this->so->total_records;
-
-
- return $standard;
- }
-
- function read_config_single($column_name)
- {
- return $this->so->read_config_single($column_name);
- }
-
- function read_single($id)
- {
- return $this->so->read_single($id);
- }
-
- function read_single_category($entity_id,$cat_id)
- {
- return
$this->so->read_single_category($entity_id,$cat_id);
- }
-
- function read_single_status($id)
- {
- return
$this->so->read_single_status($this->entity_id,$this->cat_id,$id);
- }
-
- function save($values,$action='')
- {
- if ($action=='edit')
- {
- if ($values['id'] != '')
- {
- $receipt =
$this->so->edit_entity($values);
- }
- }
- else
- {
- $receipt = $this->so->add_entity($values);
- }
- return $receipt;
- }
-
- function save_category($values,$action='')
- {
- if ($action=='edit')
- {
- if ($values['id'] != '')
- {
- $receipt =
$this->so->edit_category($values);
- }
- }
- else
- {
- $receipt = $this->so->add_category($values);
- }
- return $receipt;
- }
-
- function save_status($values,$action='')
- {
- if ($action=='edit')
- {
- if ($values['id'] != '')
- {
- $receipt =
$this->so->edit_status($values,$this->entity_id,$this->cat_id);
- }
- }
- else
- {
- $receipt =
$this->so->add_status($values,$this->entity_id,$this->cat_id);
- }
- return $receipt;
- }
-
- function
delete($cat_id='',$entity_id='',$attrib_id='',$status_id='',$acl_location='',$custom_function_id='')
- {
- if(!$status_id && !$attrib_id && !$cat_id && $entity_id
&& !$custom_function_id):
- {
- $this->so->delete_entity($entity_id);
- }
- elseif(!$status_id && !$attrib_id && $cat_id &&
$entity_id && !$custom_function_id):
- {
- $this->so->delete_category($cat_id,$entity_id);
- }
- elseif(!$status_id && $attrib_id && $cat_id &&
$entity_id && !$custom_function_id):
- {
-
$this->so->delete_attrib($cat_id,$entity_id,$attrib_id);
- }
- elseif($status_id && !$attrib_id && $cat_id &&
$entity_id && !$custom_function_id):
- {
-
$this->so->delete_status($cat_id,$entity_id,$status_id);
- }
- elseif(!$status_id && $custom_function_id &&
$acl_location):
- {
-
$this->so->delete_custom_function($acl_location,$custom_function_id);
- }
- endif;
-
-
- }
-
- function read_attrib($entity_id='',$cat_id='',$allrows='')
- {
- if($allrows)
- {
- $this->allrows = $allrows;
- }
-
- $attrib = $this->so->read_attrib(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'cat_id' => $cat_id,'entity_id' =>
$entity_id,'allrows'=>$this->allrows));
-
- for ($i=0; $i<count($attrib); $i++)
- {
- $attrib[$i]['datatype'] =
$this->bocommon->translate_datatype($attrib[$i]['datatype']);
- }
-
- $this->total_records = $this->so->total_records;
-
- return $attrib;
- }
-
- function read_single_attrib($entity_id,$cat_id,$id)
- {
- return
$this->so->read_single_attrib($entity_id,$cat_id,$id);
- }
-
- function resort_attrib($id,$resort)
- {
-
$this->so->resort_attrib(array('resort'=>$resort,'entity_id' =>
$this->entity_id,'cat_id' => $this->cat_id,'id'=>$id));
- }
-
- function save_attrib($attrib,$action='')
- {
- if ($action=='edit')
- {
- if ($attrib['id'] != '')
- {
-
- $receipt =
$this->so->edit_attrib($attrib);
- }
- }
- else
- {
- $receipt = $this->so->add_attrib($attrib);
- }
- return $receipt;
- }
-
- function save_config($values='',$column_name='')
- {
- return
$this->so->save_config($values,$column_name);
- }
-
- function
read_custom_function($entity_id='',$cat_id='',$allrows='', $acl_location='')
- {
- if($allrows)
- {
- $this->allrows = $allrows;
- }
-
- if (!$acl_location && $entity_id && $cat_id)
- {
- $acl_location = '.entity.' . $entity_id . '.' .
$cat_id;
- }
-
- $custom_function =
$this->so->read_custom_function(array('start' => $this->start,'query' =>
$this->query,'sort' => $this->sort,'order' => $this->order,
-
'acl_location' => $acl_location,'allrows'=>$this->allrows));
-
- $this->total_records = $this->so->total_records;
-
- return $custom_function;
- }
-
- function resort_custom_function($id,$resort)
- {
-
$this->so->resort_custom_function(array('resort'=>$resort,'entity_id' =>
$this->entity_id,'cat_id' => $this->cat_id,'id'=>$id));
- }
-
- function save_custom_function($custom_function,$action='')
- {
- if ($action=='edit')
- {
- if ($custom_function['id'] != '')
- {
-
- $receipt =
$this->so->edit_custom_function($custom_function);
- }
- }
- else
- {
- $receipt =
$this->so->add_custom_function($custom_function);
- }
- return $receipt;
- }
-
- function select_custom_function($selected='')
- {
-
- $dir_handle = @opendir(PHPGW_APP_INC . SEP . 'custom');
- $i=0; $myfilearray = '';
- while ($file = readdir($dir_handle))
- {
- if ((substr($file, 0, 1) != '.') &&
is_file(PHPGW_APP_INC . SEP . 'custom' . SEP . $file) )
- {
- $myfilearray[$i] = $file;
- $i++;
- }
- }
- closedir($dir_handle);
- sort($myfilearray);
-
- for ($i=0;$i<count($myfilearray);$i++)
- {
- $fname = ereg_replace('_',' ',$myfilearray[$i]);
- $sel_file = '';
- if ($myfilearray[$i]==$selected)
- {
- $sel_file = 'selected';
- }
-
- $file_list[] = array
- (
- 'id' => $myfilearray[$i],
- 'name' => $fname,
- 'selected' => $sel_file
- );
- }
-
- for ($i=0;$i<count($file_list);$i++)
- {
- if ($file_list[$i]['selected'] != 'selected')
- {
- unset($conv_list[$i]['selected']);
- }
- }
-
- return $file_list;
- }
- function
read_single_custom_function($entity_id='',$cat_id='',$id,$acl_location='')
- {
- if (!$acl_location && $entity_id && $cat_id)
- {
- $acl_location = '.entity.' . $entity_id . '.' .
$cat_id;
- }
- return
$this->so->read_single_custom_function($acl_location,$id);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.boadmin_entity.inc.php,v 1.9 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class boadmin_entity
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+ var $entity_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ var $soap_functions = array(
+ 'list' => array(
+ 'in' =>
array('int','int','struct','string','int'),
+ 'out' => array('array')
+ ),
+ 'read' => array(
+ 'in' => array('int','struct'),
+ 'out' => array('array')
+ ),
+ 'save' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ ),
+ 'delete' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ )
+ );
+
+ function boadmin_entity($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.soadmin_entity');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $allrows =
get_var('allrows',array('POST','GET'));
+ $entity_id =
get_var('entity_id',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ if(isset($entity_id))
+ {
+ $this->entity_id = $entity_id;
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+ }
+
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','standard_e',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','standard_e');
+
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->entity_id = $data['entity_id'];
+ $this->allrows = $data['allrows'];
+ }
+
+ function reset_fm_cache()
+ {
+ $this->so->reset_fm_cache();
+ }
+
+
+ function get_location_level_list($selected='')
+ {
+
+ $soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
+ $location_types =
$soadmin_location->select_location_type();
+ $max_location_type=count($location_types);
+
+ for ($i=1; $i<=$max_location_type; $i++)
+ {
+ $location[$i][id] = $i;
+ $location[$i][name] = $i . '-' .
$location_types[($i-1)]['name'];
+ }
+
+ return
$this->bocommon->select_list($selected,$location);
+
+ }
+
+ function get_entity_list($selected='')
+ {
+ $list = $this->so->read(array('allrows'=>True));
+ return
$this->bocommon->select_multi_list($selected,$list);
+ }
+
+ function get_entity_list_2($selected='')
+ {
+ $list[0]['id']='project';
+ $list[0]['name']='project';
+ $list[1]['id']='ticket';
+ $list[1]['name']='ticket';
+ $list[2]['id']='document';
+ $list[2]['name']='document';
+ $list[3]['id']='request';
+ $list[3]['name']='request';
+ $list[4]['id']='investment';
+ $list[4]['name']='investment';
+ $list[5]['id']='s_agreement';
+ $list[5]['name']='service agreement';
+ return
$this->bocommon->select_multi_list($selected,$list);
+ }
+
+ function get_entity_list_3($selected='')
+ {
+ $list[0]['id']='ticket';
+ $list[0]['name']='ticket';
+ $list[1]['id']='request';
+ $list[1]['name']='request';
+ return
$this->bocommon->select_multi_list($selected,$list);
+ }
+
+ function read()
+ {
+ $entity = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,'allrows'=>$this->allrows));
+
+ $this->total_records = $this->so->total_records;
+ return $entity;
+ }
+
+ function read_category($entity_id)
+ {
+ $category = $this->so->read_category(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,
+ 'order' =>
$this->order,'allrows'=>$this->allrows,'entity_id'=>$entity_id));
+
+ $this->total_records = $this->so->total_records;
+
+ return $category;
+ }
+
+ function read_status()
+ {
+ $status = $this->so->read_status(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,
+ 'order' =>
$this->order,'allrows'=>$this->allrows,'entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id));
+
+ $this->total_records = $this->so->total_records;
+
+ return $status;
+ }
+
+ function read_config()
+ {
+ $standard = $this->so->read_config(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order));
+
+ $this->total_records = $this->so->total_records;
+
+
+ return $standard;
+ }
+
+ function read_config_single($column_name)
+ {
+ return $this->so->read_config_single($column_name);
+ }
+
+ function read_single($id)
+ {
+ return $this->so->read_single($id);
+ }
+
+ function read_single_category($entity_id,$cat_id)
+ {
+ return
$this->so->read_single_category($entity_id,$cat_id);
+ }
+
+ function read_single_status($id)
+ {
+ return
$this->so->read_single_status($this->entity_id,$this->cat_id,$id);
+ }
+
+ function save($values,$action='')
+ {
+ if ($action=='edit')
+ {
+ if ($values['id'] != '')
+ {
+ $receipt =
$this->so->edit_entity($values);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add_entity($values);
+ }
+ return $receipt;
+ }
+
+ function save_category($values,$action='')
+ {
+ if ($action=='edit')
+ {
+ if ($values['id'] != '')
+ {
+ $receipt =
$this->so->edit_category($values);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add_category($values);
+ }
+ return $receipt;
+ }
+
+ function save_status($values,$action='')
+ {
+ if ($action=='edit')
+ {
+ if ($values['id'] != '')
+ {
+ $receipt =
$this->so->edit_status($values,$this->entity_id,$this->cat_id);
+ }
+ }
+ else
+ {
+ $receipt =
$this->so->add_status($values,$this->entity_id,$this->cat_id);
+ }
+ return $receipt;
+ }
+
+ function
delete($cat_id='',$entity_id='',$attrib_id='',$status_id='',$acl_location='',$custom_function_id='')
+ {
+ if(!$status_id && !$attrib_id && !$cat_id && $entity_id
&& !$custom_function_id):
+ {
+ $this->so->delete_entity($entity_id);
+ }
+ elseif(!$status_id && !$attrib_id && $cat_id &&
$entity_id && !$custom_function_id):
+ {
+ $this->so->delete_category($cat_id,$entity_id);
+ }
+ elseif(!$status_id && $attrib_id && $cat_id &&
$entity_id && !$custom_function_id):
+ {
+
$this->so->delete_attrib($cat_id,$entity_id,$attrib_id);
+ }
+ elseif($status_id && !$attrib_id && $cat_id &&
$entity_id && !$custom_function_id):
+ {
+
$this->so->delete_status($cat_id,$entity_id,$status_id);
+ }
+ elseif(!$status_id && $custom_function_id &&
$acl_location):
+ {
+
$this->so->delete_custom_function($acl_location,$custom_function_id);
+ }
+ endif;
+
+
+ }
+
+ function read_attrib($entity_id='',$cat_id='',$allrows='')
+ {
+ if($allrows)
+ {
+ $this->allrows = $allrows;
+ }
+
+ $attrib = $this->so->read_attrib(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'cat_id' => $cat_id,'entity_id' =>
$entity_id,'allrows'=>$this->allrows));
+
+ for ($i=0; $i<count($attrib); $i++)
+ {
+ $attrib[$i]['datatype'] =
$this->bocommon->translate_datatype($attrib[$i]['datatype']);
+ }
+
+ $this->total_records = $this->so->total_records;
+
+ return $attrib;
+ }
+
+ function read_single_attrib($entity_id,$cat_id,$id)
+ {
+ return
$this->so->read_single_attrib($entity_id,$cat_id,$id);
+ }
+
+ function resort_attrib($id,$resort)
+ {
+
$this->so->resort_attrib(array('resort'=>$resort,'entity_id' =>
$this->entity_id,'cat_id' => $this->cat_id,'id'=>$id));
+ }
+
+ function save_attrib($attrib,$action='')
+ {
+ if ($action=='edit')
+ {
+ if ($attrib['id'] != '')
+ {
+
+ $receipt =
$this->so->edit_attrib($attrib);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add_attrib($attrib);
+ }
+ return $receipt;
+ }
+
+ function save_config($values='',$column_name='')
+ {
+ return
$this->so->save_config($values,$column_name);
+ }
+
+ function
read_custom_function($entity_id='',$cat_id='',$allrows='', $acl_location='')
+ {
+ if($allrows)
+ {
+ $this->allrows = $allrows;
+ }
+
+ if (!$acl_location && $entity_id && $cat_id)
+ {
+ $acl_location = '.entity.' . $entity_id . '.' .
$cat_id;
+ }
+
+ $custom_function =
$this->so->read_custom_function(array('start' => $this->start,'query' =>
$this->query,'sort' => $this->sort,'order' => $this->order,
+
'acl_location' => $acl_location,'allrows'=>$this->allrows));
+
+ $this->total_records = $this->so->total_records;
+
+ return $custom_function;
+ }
+
+ function resort_custom_function($id,$resort)
+ {
+
$this->so->resort_custom_function(array('resort'=>$resort,'entity_id' =>
$this->entity_id,'cat_id' => $this->cat_id,'id'=>$id));
+ }
+
+ function save_custom_function($custom_function,$action='')
+ {
+ if ($action=='edit')
+ {
+ if ($custom_function['id'] != '')
+ {
+
+ $receipt =
$this->so->edit_custom_function($custom_function);
+ }
+ }
+ else
+ {
+ $receipt =
$this->so->add_custom_function($custom_function);
+ }
+ return $receipt;
+ }
+
+ function select_custom_function($selected='')
+ {
+
+ $dir_handle = @opendir(PHPGW_APP_INC . SEP . 'custom');
+ $i=0; $myfilearray = '';
+ while ($file = readdir($dir_handle))
+ {
+ if ((substr($file, 0, 1) != '.') &&
is_file(PHPGW_APP_INC . SEP . 'custom' . SEP . $file) )
+ {
+ $myfilearray[$i] = $file;
+ $i++;
+ }
+ }
+ closedir($dir_handle);
+ sort($myfilearray);
+
+ for ($i=0;$i<count($myfilearray);$i++)
+ {
+ $fname = ereg_replace('_',' ',$myfilearray[$i]);
+ $sel_file = '';
+ if ($myfilearray[$i]==$selected)
+ {
+ $sel_file = 'selected';
+ }
+
+ $file_list[] = array
+ (
+ 'id' => $myfilearray[$i],
+ 'name' => $fname,
+ 'selected' => $sel_file
+ );
+ }
+
+ for ($i=0;$i<count($file_list);$i++)
+ {
+ if ($file_list[$i]['selected'] != 'selected')
+ {
+ unset($conv_list[$i]['selected']);
+ }
+ }
+
+ return $file_list;
+ }
+ function
read_single_custom_function($entity_id='',$cat_id='',$id,$acl_location='')
+ {
+ if (!$acl_location && $entity_id && $cat_id)
+ {
+ $acl_location = '.entity.' . $entity_id . '.' .
$cat_id;
+ }
+ return
$this->so->read_single_custom_function($acl_location,$id);
+ }
+ }
+?>
Index: property/inc/class.boadmin_location.inc.php
diff -u property/inc/class.boadmin_location.inc.php:1.6
property/inc/class.boadmin_location.inc.php:1.7
--- property/inc/class.boadmin_location.inc.php:1.6 Wed May 18 16:05:55 2005
+++ property/inc/class.boadmin_location.inc.php Fri Jan 27 14:05:43 2006
@@ -1,306 +1,306 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.boadmin_location.inc.php,v 1.6 2005/05/18
16:05:55 sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class boadmin_location
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- var $soap_functions = array(
- 'list' => array(
- 'in' =>
array('int','int','struct','string','int'),
- 'out' => array('array')
- ),
- 'read' => array(
- 'in' => array('int','struct'),
- 'out' => array('array')
- ),
- 'save' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- ),
- 'delete' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- )
- );
-
- function boadmin_location($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.soadmin_location');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $allrows =
get_var('allrows',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
- }
-
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','standard_e',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','standard_e');
-
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- }
-
- function reset_fm_cache()
- {
- $this->so->reset_fm_cache();
- }
-
-
- function read()
- {
- $standard = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order));
-
- $this->total_records = $this->so->total_records;
-
-
- return $standard;
- }
-
- function read_config()
- {
- $standard = $this->so->read_config(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order));
-
- $this->total_records = $this->so->total_records;
-
-
- return $standard;
- }
-
- function read_config_single($column_name)
- {
- return $this->so->read_config_single($column_name);
- }
-
- function read_single($id)
- {
- return $this->so->read_single($id);
- }
-
- function save($standard,$action='')
- {
- if ($action=='edit')
- {
- if ($standard['id'] != '')
- {
-
- $receipt = $this->so->edit($standard);
- }
- }
- else
- {
- $receipt = $this->so->add($standard);
- }
- return $receipt;
-
- }
-
- function delete($type_id,$id,$attrib)
- {
- $this->so->delete($type_id,$id,$attrib);
- }
-
- function read_attrib($type_id='')
- {
- $attrib = $this->so->read_attrib(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'type_id' => $type_id,'allrows'=>$this->allrows));
-
- for ($i=0; $i<count($attrib); $i++)
- {
- $attrib[$i]['datatype'] =
$this->bocommon->translate_datatype($attrib[$i]['datatype']);
- }
-
- $this->total_records = $this->so->total_records;
-
- return $attrib;
- }
-
- function read_single_attrib($type_id,$id)
- {
- return $this->so->read_single_attrib($type_id,$id);
- }
-
- function resort_attrib($data)
- {
- $this->so->resort_attrib($data);
- }
-
- function save_attrib($attrib,$action='')
- {
- if ($action=='edit')
- {
- if ($attrib['id'] != '')
- {
-
- $receipt =
$this->so->edit_attrib($attrib);
- }
- }
- else
- {
- $receipt = $this->so->add_attrib($attrib);
- }
- return $receipt;
- }
-
- function save_config($values='',$column_name='')
- {
- return
$this->so->save_config($values,$column_name);
- }
-
- function select_location_type($selected='')
- {
- $location_types= $this->so->select_location_type();
-
- while (is_array($location_types) && list(,$type) =
each($location_types))
- {
- $sel_type = '';
- if ($type['id']==$selected)
- {
- $sel_type = 'selected';
- }
-
- $location_type_list[] = array
- (
- 'id' => $type['id'],
- 'name' => $type['name'],
- 'selected' => $sel_type
- );
- }
-
- for ($i=0;$i<count($location_type_list);$i++)
- {
- if ($location_type_list[$i]['selected'] !=
'selected')
- {
-
unset($location_type_list[$i]['selected']);
- }
- }
-
-//_debug_array($location_type_list);
- return $location_type_list;
- }
-
- function select_nullable($selected='')
- {
- $nullable[0]['id']= 'True';
- $nullable[0]['name']= lang('True');
- $nullable[1]['id']= 'False';
- $nullable[1]['name']= lang('False');
-
- while (is_array($nullable) && list(,$type) =
each($nullable))
- {
- $sel_type = '';
- if ($type['id']==$selected)
- {
- $sel_type = 'selected';
- }
-
- $nullable_list[] = array
- (
- 'id' => $type['id'],
- 'name' => $type['name'],
- 'selected' => $sel_type
- );
- }
-
- for ($i=0;$i<count($nullable_list);$i++)
- {
- if ($nullable_list[$i]['selected'] !=
'selected')
- {
- unset($nullable_list[$i]['selected']);
- }
- }
- return $nullable_list;
- }
-
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.boadmin_location.inc.php,v 1.7 2006/01/27
14:05:43 sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class boadmin_location
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ var $soap_functions = array(
+ 'list' => array(
+ 'in' =>
array('int','int','struct','string','int'),
+ 'out' => array('array')
+ ),
+ 'read' => array(
+ 'in' => array('int','struct'),
+ 'out' => array('array')
+ ),
+ 'save' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ ),
+ 'delete' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ )
+ );
+
+ function boadmin_location($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.soadmin_location');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $allrows =
get_var('allrows',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+ }
+
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','standard_e',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','standard_e');
+
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ }
+
+ function reset_fm_cache()
+ {
+ $this->so->reset_fm_cache();
+ }
+
+
+ function read()
+ {
+ $standard = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order));
+
+ $this->total_records = $this->so->total_records;
+
+
+ return $standard;
+ }
+
+ function read_config()
+ {
+ $standard = $this->so->read_config(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order));
+
+ $this->total_records = $this->so->total_records;
+
+
+ return $standard;
+ }
+
+ function read_config_single($column_name)
+ {
+ return $this->so->read_config_single($column_name);
+ }
+
+ function read_single($id)
+ {
+ return $this->so->read_single($id);
+ }
+
+ function save($standard,$action='')
+ {
+ if ($action=='edit')
+ {
+ if ($standard['id'] != '')
+ {
+
+ $receipt = $this->so->edit($standard);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add($standard);
+ }
+ return $receipt;
+
+ }
+
+ function delete($type_id,$id,$attrib)
+ {
+ $this->so->delete($type_id,$id,$attrib);
+ }
+
+ function read_attrib($type_id='')
+ {
+ $attrib = $this->so->read_attrib(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'type_id' => $type_id,'allrows'=>$this->allrows));
+
+ for ($i=0; $i<count($attrib); $i++)
+ {
+ $attrib[$i]['datatype'] =
$this->bocommon->translate_datatype($attrib[$i]['datatype']);
+ }
+
+ $this->total_records = $this->so->total_records;
+
+ return $attrib;
+ }
+
+ function read_single_attrib($type_id,$id)
+ {
+ return $this->so->read_single_attrib($type_id,$id);
+ }
+
+ function resort_attrib($data)
+ {
+ $this->so->resort_attrib($data);
+ }
+
+ function save_attrib($attrib,$action='')
+ {
+ if ($action=='edit')
+ {
+ if ($attrib['id'] != '')
+ {
+
+ $receipt =
$this->so->edit_attrib($attrib);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add_attrib($attrib);
+ }
+ return $receipt;
+ }
+
+ function save_config($values='',$column_name='')
+ {
+ return
$this->so->save_config($values,$column_name);
+ }
+
+ function select_location_type($selected='')
+ {
+ $location_types= $this->so->select_location_type();
+
+ while (is_array($location_types) && list(,$type) =
each($location_types))
+ {
+ $sel_type = '';
+ if ($type['id']==$selected)
+ {
+ $sel_type = 'selected';
+ }
+
+ $location_type_list[] = array
+ (
+ 'id' => $type['id'],
+ 'name' => $type['name'],
+ 'selected' => $sel_type
+ );
+ }
+
+ for ($i=0;$i<count($location_type_list);$i++)
+ {
+ if ($location_type_list[$i]['selected'] !=
'selected')
+ {
+
unset($location_type_list[$i]['selected']);
+ }
+ }
+
+//_debug_array($location_type_list);
+ return $location_type_list;
+ }
+
+ function select_nullable($selected='')
+ {
+ $nullable[0]['id']= 'True';
+ $nullable[0]['name']= lang('True');
+ $nullable[1]['id']= 'False';
+ $nullable[1]['name']= lang('False');
+
+ while (is_array($nullable) && list(,$type) =
each($nullable))
+ {
+ $sel_type = '';
+ if ($type['id']==$selected)
+ {
+ $sel_type = 'selected';
+ }
+
+ $nullable_list[] = array
+ (
+ 'id' => $type['id'],
+ 'name' => $type['name'],
+ 'selected' => $sel_type
+ );
+ }
+
+ for ($i=0;$i<count($nullable_list);$i++)
+ {
+ if ($nullable_list[$i]['selected'] !=
'selected')
+ {
+ unset($nullable_list[$i]['selected']);
+ }
+ }
+ return $nullable_list;
+ }
+
+
+ }
+?>
Index: property/inc/class.boagreement.inc.php
diff -u property/inc/class.boagreement.inc.php:1.6
property/inc/class.boagreement.inc.php:1.7
--- property/inc/class.boagreement.inc.php:1.6 Tue Jun 28 13:23:07 2005
+++ property/inc/class.boagreement.inc.php Fri Jan 27 14:05:43 2006
@@ -1,767 +1,767 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage agreement
- * @version $Id: class.boagreement.inc.php,v 1.6 2005/06/28 13:23:07
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class boagreement
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
- var $role;
- var $member_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- function boagreement($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.soagreement');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->vfs =
CreateObject('phpgwapi.vfs');
- $this->rootdir = $this->vfs->basedir;
- $this->fakebase = $this->vfs->fakebase;
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $vendor_id =
get_var('vendor_id',array('POST','GET'));
- $allrows =
get_var('allrows',array('POST','GET'));
- $role = get_var('role',array('POST','GET'));
- $member_id =
get_var('member_id',array('POST','GET'));
-
-
- $this->role = $role;
- $this->so->role = $role;
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id) && !empty($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- else
- {
- unset($this->cat_id);
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
- if(isset($member_id))
- {
- $this->member_id = $member_id;
- }
- if(isset($vendor_id))
- {
- $this->vendor_id = $vendor_id;
- }
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','agreement',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','agreement');
-
- //_debug_array($data);
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->vendor_id= $data['vendor_id'];
- $this->member_id= $data['member_id'];
- $this->allrows = $data['allrows'];
- }
-
- function check_perms($has, $needed)
- {
- return (!!($has & $needed) == True);
- }
-
-
- function select_category_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
- $categories= $this->so->select_category_list();
-
- while (is_array($categories) && list(,$category) =
each($categories))
- {
- $sel_category = '';
- if ($category['id']==$selected)
- {
- $sel_category = 'selected';
- }
-
- $category_list[] = array
- (
- 'cat_id' => $category['id'],
- 'name' => $category['name'],
- 'selected' => $sel_category
- );
- }
-
- for ($i=0;$i<count($category_list);$i++)
- {
- if ($category_list[$i]['selected'] !=
'selected')
- {
- unset($category_list[$i]['selected']);
- }
- }
-
- return $category_list;
- }
-
- function select_vendor_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('select_vendor'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_vendor'));
- break;
- }
-
- $input_list= $this->so->select_vendor_list();
- $vendor_list=
$this->bocommon->select_list($selected,$input_list);
-
- return $vendor_list;
- }
-
- function read()
- {
- $agreement = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows,'member_id'=>$this->member_id,
-
'vendor_id'=>$this->vendor_id));
- $this->total_records = $this->so->total_records;
-
- $this->uicols = $this->so->uicols;
-
- for ($i=0; $i<count($agreement); $i++)
- {
- if($agreement[$i]['start_date'])
- {
- $agreement[$i]['start_date'] =
$GLOBALS['phpgw']->common->show_date($agreement[$i]['start_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- }
- if($agreement[$i]['end_date'])
- {
- $agreement[$i]['end_date'] =
$GLOBALS['phpgw']->common->show_date($agreement[$i]['end_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- }
-
- $agreement[$i]['status'] =
lang($agreement[$i]['status']);
-
- }
- return $agreement;
- }
-
- function read_details($id)
- {
- $list = $this->so->read_details(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows,'member_id'=>$this->member_id,
-
'agreement_id'=>$id));
- $this->total_records = $this->so->total_records;
-
- $this->uicols = $this->so->uicols;
-
- return $list;
- }
-
- function read_prizing($data)
- {
- $list = $this->so->read_prizing($data);
- $this->total_records = $this->so->total_records;
-
- $this->uicols = $this->so->uicols;
-
- for ($i=0; $i<count($list); $i++)
- {
- $list[$i]['index_date'] =
$GLOBALS['phpgw']->common->show_date($list[$i]['index_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- }
-
- return $list;
- }
-
- function read_event($data)
- {
- $boalarm =
CreateObject($this->currentapp.'.boalarm');
- $event = $this->so->read_single($data);
- $event['alarm_date']=$event['termination_date'];
- $event['alarm'] =
$boalarm->read_alarms($type='agreement',$data['agreement_id']);
- return $event;
- }
-
- function read_single($data)
- {
- $agreement = $this->so->read_single($data);
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $agreement['start_date'] =
$GLOBALS['phpgw']->common->show_date($agreement['start_date'],$dateformat);
- $agreement['end_date'] =
$GLOBALS['phpgw']->common->show_date($agreement['end_date'],$dateformat);
- if($agreement['termination_date'])
- {
- $agreement['termination_date']=
$GLOBALS['phpgw']->common->show_date($agreement['termination_date'],$dateformat);
- }
-
- $agreement = $this->convert_attribute($agreement);
-
- $this->vfs->override_acl = 1;
-
- $agreement['files'] = $this->vfs->ls (array(
- 'string' => $this->fakebase. '/' . 'agreement' .
'/' . $data['agreement_id'],
- 'relatives' => array(RELATIVE_NONE)));
-
- $this->vfs->override_acl = 0;
-
- if(!$agreement['files'][0]['file_id'])
- {
- unset($agreement['files']);
- }
-
- return $agreement;
-
- }
-
- function read_single_item($data)
- {
- $item = $this->so->read_single_item($data);
-//_debug_array($item);
- $item = $this->convert_attribute($item,True);
- return $item;
- }
-
- function convert_attribute($list,$detail='')
- {
- if($detail)
- {
- $this->so->role = 'detail';
- }
- $contacts =
CreateObject('phpgwapi.contacts');
-
- $vendor = CreateObject($this->currentapp.'.soactor');
- $vendor->role = 'vendor';
-
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-
- $input_type_array = array(
- 'R' => 'radio',
- 'CH' => 'checkbox',
- 'LB' => 'listbox'
- );
-
- $sep = '/';
- $dlarr[strpos($dateformat,'Y')] = 'Y';
- $dlarr[strpos($dateformat,'m')] = 'm';
- $dlarr[strpos($dateformat,'d')] = 'd';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
-//html_print_r($list);
- $m=0;
- for ($i=0;$i<count($list['attributes']);$i++)
- {
- if($list['attributes'][$i]['datatype']=='D' &&
$list['attributes'][$i]['value'])
- {
- $timestamp_date=
mktime(0,0,0,date(m,strtotime($list['attributes'][$i]['value'])),date(d,strtotime($list['attributes'][$i]['value'])),date(y,strtotime($list['attributes'][$i]['value'])));
- $list['attributes'][$i]['value']
= $GLOBALS['phpgw']->common->show_date($timestamp_date,$dateformat);
- }
- if($list['attributes'][$i]['datatype']=='AB')
- {
- if($list['attributes'][$i]['value'])
- {
- $contact_data =
$contacts->read_single_entry($list['attributes'][$i]['value'],array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
-
$list['attributes'][$i]['contact_name'] = $contact_data[0]['n_family'] . ', ' .
$contact_data[0]['n_given'];
- }
-
- $insert_record_list[] =
$list['attributes'][$i]['name'];
- $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.addressbook&column='
. $list['attributes'][$i]['name']);
-
- $lookup_functions[$m]['name'] =
'lookup_'. $list['attributes'][$i]['name'] .'()';
- $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
- $m++;
- }
-
if($list['attributes'][$i]['datatype']=='VENDOR')
- {
- if($list['attributes'][$i]['value'])
- {
- $vendor_data =
$vendor->read_single(array('actor_id'=>$list['attributes'][$i]['value']));
-
- for
($n=0;$n<count($vendor_data['attributes']);$n++)
- {
-
if($vendor_data['attributes'][$n]['name'] == 'org_name')
- {
-
$list['attributes'][$i]['vendor_name']= $vendor_data['attributes'][$n]['value'];
- $n
=count($vendor_data['attributes']);
- }
- }
- }
-
- $insert_record_list[] =
$list['attributes'][$i]['name'];
- $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor&column='
. $list['attributes'][$i]['name']);
-
- $lookup_functions[$m]['name'] =
'lookup_'. $list['attributes'][$i]['name'] .'()';
- $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
- $m++;
- }
-
- if($list['attributes'][$i]['datatype']=='R' ||
$list['attributes'][$i]['datatype']=='CH' ||
$list['attributes'][$i]['datatype']=='LB')
- {
- $list['attributes'][$i]['choice']
= $this->so->read_attrib_choice($list['attributes'][$i]['attrib_id']);
-
$input_type=$input_type_array[$list['attributes'][$i]['datatype']];
-
-
if($list['attributes'][$i]['datatype']=='CH')
- {
-
$list['attributes'][$i]['value']=unserialize($list['attributes'][$i]['value']);
-
$list['attributes'][$i]['choice'] =
$this->bocommon->select_multi_list_2($list['attributes'][$i]['value'],$list['attributes'][$i]['choice'],$input_type);
-
- }
- else
- {
- for
($j=0;$j<count($list['attributes'][$i]['choice']);$j++)
- {
-
$list['attributes'][$i]['choice'][$j]['input_type']=$input_type;
-
if($list['attributes'][$i]['choice'][$j]['id']==$list['attributes'][$i]['value'])
- {
-
$list['attributes'][$i]['choice'][$j]['checked']='checked';
- }
- }
- }
- }
-
- $list['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($list['attributes'][$i]['datatype']);
- $list['attributes'][$i]['counter'] = $i;
- $list['attributes'][$i]['type_id'] =
$data['type_id'];
- }
-
- for ($j=0;$j<count($lookup_functions);$j++)
- {
- $list['lookup_functions'] .= 'function ' .
$lookup_functions[$j]['name'] ."\r\n";
- $list['lookup_functions'] .= '{'."\r\n";
- $list['lookup_functions'] .=
$lookup_functions[$j]['action'] ."\r\n";
- $list['lookup_functions'] .= '}'."\r\n";
- }
-
-
$GLOBALS['phpgw']->session->appsession('insert_record_agreement' .
!!$detail,$this->currentapp,$insert_record_list);
-
-//html_print_r($list);
- return $list;
-
- }
-
- function convert_attribute_save($values_attribute='')
- {
-
- for ($i=0;$i<count($values_attribute);$i++)
- {
- if($values_attribute[$i]['datatype']=='CH' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
serialize($values_attribute[$i]['value']);
- }
- if($values_attribute[$i]['datatype']=='R' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
$values_attribute[$i]['value'][0];
- }
-
- if($values_attribute[$i]['datatype']=='N' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
str_replace(",",".",$values_attribute[$i]['value']);
- }
-
- if($values_attribute[$i]['datatype']=='D' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
date($this->bocommon->dateformat,$this->bocommon->date_to_timestamp($values_attribute[$i]['value']));
- }
- }
-
- return $values_attribute;
- }
-
- function save($values,$values_attribute='',$action='')
- {
-
- $values['start_date'] =
$this->bocommon->date_to_timestamp($values['start_date']);
- $values['end_date'] =
$this->bocommon->date_to_timestamp($values['end_date']);
- $values['termination_date'] =
$this->bocommon->date_to_timestamp($values['termination_date']);
-
- $values_attribute =
$this->convert_attribute_save($values_attribute);
-
- if ($action=='edit')
-// if ($values['agreement_id'])
- {
- if ($values['agreement_id'] != 0)
- {
-
$receipt=$this->so->edit($values,$values_attribute);
-
- if($values['delete_file'])
- {
- for
($i=0;$i<count($values['delete_file']);$i++)
- {
- $file =
$this->fakebase. SEP . 'agreement' . SEP . $values['agreement_id'] . SEP .
$values['delete_file'][$i];
-
-
if($this->vfs->file_exists(array(
-
'string' => $file,
-
'relatives' => Array(RELATIVE_NONE)
- )))
- {
-
$this->vfs->override_acl = 1;
-
-
if(!$this->vfs->rm (array(
-
'string' => $file,
-
'relatives' => array(
-
RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to delete file') . ' :'.
$this->fakebase. SEP . 'agreement'. SEP . $values['agreement_id'] . SEP
.$values['delete_file'][$i]);
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('file deleted') . ' :'.
$this->fakebase. SEP . 'agreement'. SEP . $values['id'] . SEP .
$values['delete_file'][$i]);
- }
-
$this->vfs->override_acl = 0;
- }
- }
- }
- }
- }
- else
- {
- $receipt =
$this->so->add($values,$values_attribute);
- }
- return $receipt;
- }
-
- function save_item($values,$values_attribute='')
- {
-//_debug_array($values);
- $values['m_cost'] =
str_replace(",",".",$values['m_cost']);
- $values['w_cost'] =
str_replace(",",".",$values['w_cost']);
- $values['total_cost'] = $values['m_cost'] +
$values['w_cost'];
-
- if ($values['index_count'] > 0)
- {
- if ($values['id'] != 0)
- {
- $receipt=$this->so->edit_item($values);
- }
- }
- else
- {
- $receipt = $this->so->add_item($values);
- }
- return $receipt;
- }
-
-
- function update($values)
- {
- $values['date'] =
$this->bocommon->date_to_timestamp($values['date']);
-
- return $this->so->update($values);
- }
-
- function delete_last_index($agreement_id,$id)
- {
- $this->so->delete_last_index($agreement_id,$id);
- }
-
-
- function delete_item($agreement_id,$activity_id)
- {
- $this->so->delete_item($agreement_id,$activity_id);
- }
-
- function delete($agreement_id='',$id='',$attrib='')
- {
- if ($attrib)
- {
- $this->so->delete_attrib($id);
- }
- else
- {
- $this->so->delete($agreement_id);
- }
- }
-
- function read_attrib($type_id='')
- {
- $attrib = $this->so->read_attrib(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'allrows'=>$this->allrows));
-
- for ($i=0; $i<count($attrib); $i++)
- {
- $attrib[$i]['datatype'] =
$this->bocommon->translate_datatype($attrib[$i]['datatype']);
- }
-
- $this->total_records = $this->so->total_records;
-
- return $attrib;
- }
-
- function read_single_attrib($id)
- {
- return $this->so->read_single_attrib($id);
- }
-
- function resort_attrib($data)
- {
- $this->so->resort_attrib($data);
- }
-
- function save_attrib($attrib,$action='')
- {
- if ($action=='edit')
- {
- if ($attrib['id'] != '')
- {
-
- $receipt =
$this->so->edit_attrib($attrib);
- }
- }
- else
- {
- $receipt = $this->so->add_attrib($attrib);
- }
- return $receipt;
- }
-
- function column_list($selected='',$allrows='')
- {
- if(!$selected)
- {
-
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]["agreement_columns"];
- }
-
- $columns =
$this->so->read_attrib(array('allrows'=>$allrows,'column_list'=>True));
-
-
$column_list=$this->bocommon->select_multi_list($selected,$columns);
-
- return $column_list;
- }
-
- function request_next_id()
- {
- return $this->so->request_next_id();
- }
-
- function create_home_dir($receipt='')
- {
- if(!$this->vfs->file_exists(array(
- 'string' => $this->fakebase. SEP .
'agreement',
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
- $this->vfs->override_acl = 1;
-
- if(!$this->vfs->mkdir (array(
- 'string' => $this->fakebase. SEP .
'agreement',
- 'relatives' => array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'agreement');
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'agreement');
- }
- $this->vfs->override_acl = 0;
- }
-
- return $receipt;
- }
-
- function create_document_dir($id='')
- {
-
- if(!$this->vfs->file_exists(array(
- 'string' => $this->fakebase. SEP .
'agreement' . SEP . $id,
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
- $this->vfs->override_acl = 1;
- if(!$this->vfs->mkdir (array(
- 'string' => $this->fakebase. SEP .
'agreement' . SEP . $id,
- 'relatives' => array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'agreement' . SEP . $id);
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'agreement' . SEP . $id);
- }
- $this->vfs->override_acl = 0;
- }
-
-//_debug_array($receipt);
- return $receipt;
- }
-
- function get_agreement_group_list($selected='')
- {
- $agreement_groups=
$this->so->get_agreement_group_list();
-
- while (is_array($agreement_groups) &&
list(,$agreement_group_entry) = each($agreement_groups))
- {
- $sel_agreement_group_entry = '';
- if ($agreement_group_entry['id']==$selected)
- {
- $sel_agreement_group_entry = 'selected';
- }
-
- $agreement_group_list[] = array
- (
- 'id' => $agreement_group_entry['id'],
- 'name' =>
$agreement_group_entry['name'],
- 'selected' =>
$sel_agreement_group_entry
- );
- }
-
- for ($i=0;$i<count($agreement_group_list);$i++)
- {
- if ($agreement_group_list[$i]['selected'] !=
'selected')
- {
-
unset($agreement_group_list[$i]['selected']);
- }
- }
-
- return $agreement_group_list;
- }
-
- function read_group_activity($group_id='',$agreement_id='')
- {
- $activity_list =
$this->so->read_group_activity($group_id,$agreement_id);
- $this->uicols = $this->so->uicols;
- return $activity_list;
- }
-
- function add_activity($values='',$agreement_id='')
- {
- return $this->so->add_activity($values,$agreement_id);
- }
-
- function select_status_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('status_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('status_filter'));
- break;
- }
-
- $status_entries= $this->so->select_status_list();
-
- while (is_array($status_entries) && list(,$status) =
each($status_entries))
- {
- $sel_status = '';
- if ($status['id']==$selected)
- {
- $sel_status = 'selected';
- }
-
- $status_list[] = array
- (
- 'id' => $status['id'],
- 'name' => $status['name'],
- 'selected' => $sel_status
- );
- }
-
- for ($i=0;$i<count($status_list);$i++)
- {
- if ($status_list[$i]['selected'] != 'selected')
- {
- unset($status_list[$i]['selected']);
- }
- }
-
- return $status_list;
- }
-
- function get_activity_descr($id)
- {
- return $this->so->get_activity_descr($id);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage agreement
+ * @version $Id: class.boagreement.inc.php,v 1.7 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class boagreement
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+ var $role;
+ var $member_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ function boagreement($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.soagreement');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->vfs =
CreateObject('phpgwapi.vfs');
+ $this->rootdir = $this->vfs->basedir;
+ $this->fakebase = $this->vfs->fakebase;
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $vendor_id =
get_var('vendor_id',array('POST','GET'));
+ $allrows =
get_var('allrows',array('POST','GET'));
+ $role = get_var('role',array('POST','GET'));
+ $member_id =
get_var('member_id',array('POST','GET'));
+
+
+ $this->role = $role;
+ $this->so->role = $role;
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id) && !empty($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ else
+ {
+ unset($this->cat_id);
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+ if(isset($member_id))
+ {
+ $this->member_id = $member_id;
+ }
+ if(isset($vendor_id))
+ {
+ $this->vendor_id = $vendor_id;
+ }
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','agreement',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','agreement');
+
+ //_debug_array($data);
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->vendor_id= $data['vendor_id'];
+ $this->member_id= $data['member_id'];
+ $this->allrows = $data['allrows'];
+ }
+
+ function check_perms($has, $needed)
+ {
+ return (!!($has & $needed) == True);
+ }
+
+
+ function select_category_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ break;
+ }
+
+ $categories= $this->so->select_category_list();
+
+ while (is_array($categories) && list(,$category) =
each($categories))
+ {
+ $sel_category = '';
+ if ($category['id']==$selected)
+ {
+ $sel_category = 'selected';
+ }
+
+ $category_list[] = array
+ (
+ 'cat_id' => $category['id'],
+ 'name' => $category['name'],
+ 'selected' => $sel_category
+ );
+ }
+
+ for ($i=0;$i<count($category_list);$i++)
+ {
+ if ($category_list[$i]['selected'] !=
'selected')
+ {
+ unset($category_list[$i]['selected']);
+ }
+ }
+
+ return $category_list;
+ }
+
+ function select_vendor_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('select_vendor'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_vendor'));
+ break;
+ }
+
+ $input_list= $this->so->select_vendor_list();
+ $vendor_list=
$this->bocommon->select_list($selected,$input_list);
+
+ return $vendor_list;
+ }
+
+ function read()
+ {
+ $agreement = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows,'member_id'=>$this->member_id,
+
'vendor_id'=>$this->vendor_id));
+ $this->total_records = $this->so->total_records;
+
+ $this->uicols = $this->so->uicols;
+
+ for ($i=0; $i<count($agreement); $i++)
+ {
+ if($agreement[$i]['start_date'])
+ {
+ $agreement[$i]['start_date'] =
$GLOBALS['phpgw']->common->show_date($agreement[$i]['start_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ }
+ if($agreement[$i]['end_date'])
+ {
+ $agreement[$i]['end_date'] =
$GLOBALS['phpgw']->common->show_date($agreement[$i]['end_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ }
+
+ $agreement[$i]['status'] =
lang($agreement[$i]['status']);
+
+ }
+ return $agreement;
+ }
+
+ function read_details($id)
+ {
+ $list = $this->so->read_details(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows,'member_id'=>$this->member_id,
+
'agreement_id'=>$id));
+ $this->total_records = $this->so->total_records;
+
+ $this->uicols = $this->so->uicols;
+
+ return $list;
+ }
+
+ function read_prizing($data)
+ {
+ $list = $this->so->read_prizing($data);
+ $this->total_records = $this->so->total_records;
+
+ $this->uicols = $this->so->uicols;
+
+ for ($i=0; $i<count($list); $i++)
+ {
+ $list[$i]['index_date'] =
$GLOBALS['phpgw']->common->show_date($list[$i]['index_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ }
+
+ return $list;
+ }
+
+ function read_event($data)
+ {
+ $boalarm =
CreateObject($this->currentapp.'.boalarm');
+ $event = $this->so->read_single($data);
+ $event['alarm_date']=$event['termination_date'];
+ $event['alarm'] =
$boalarm->read_alarms($type='agreement',$data['agreement_id']);
+ return $event;
+ }
+
+ function read_single($data)
+ {
+ $agreement = $this->so->read_single($data);
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $agreement['start_date'] =
$GLOBALS['phpgw']->common->show_date($agreement['start_date'],$dateformat);
+ $agreement['end_date'] =
$GLOBALS['phpgw']->common->show_date($agreement['end_date'],$dateformat);
+ if($agreement['termination_date'])
+ {
+ $agreement['termination_date']=
$GLOBALS['phpgw']->common->show_date($agreement['termination_date'],$dateformat);
+ }
+
+ $agreement = $this->convert_attribute($agreement);
+
+ $this->vfs->override_acl = 1;
+
+ $agreement['files'] = $this->vfs->ls (array(
+ 'string' => $this->fakebase. '/' . 'agreement' .
'/' . $data['agreement_id'],
+ 'relatives' => array(RELATIVE_NONE)));
+
+ $this->vfs->override_acl = 0;
+
+ if(!$agreement['files'][0]['file_id'])
+ {
+ unset($agreement['files']);
+ }
+
+ return $agreement;
+
+ }
+
+ function read_single_item($data)
+ {
+ $item = $this->so->read_single_item($data);
+//_debug_array($item);
+ $item = $this->convert_attribute($item,True);
+ return $item;
+ }
+
+ function convert_attribute($list,$detail='')
+ {
+ if($detail)
+ {
+ $this->so->role = 'detail';
+ }
+ $contacts =
CreateObject('phpgwapi.contacts');
+
+ $vendor = CreateObject($this->currentapp.'.soactor');
+ $vendor->role = 'vendor';
+
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ $input_type_array = array(
+ 'R' => 'radio',
+ 'CH' => 'checkbox',
+ 'LB' => 'listbox'
+ );
+
+ $sep = '/';
+ $dlarr[strpos($dateformat,'Y')] = 'Y';
+ $dlarr[strpos($dateformat,'m')] = 'm';
+ $dlarr[strpos($dateformat,'d')] = 'd';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+//html_print_r($list);
+ $m=0;
+ for ($i=0;$i<count($list['attributes']);$i++)
+ {
+ if($list['attributes'][$i]['datatype']=='D' &&
$list['attributes'][$i]['value'])
+ {
+ $timestamp_date=
mktime(0,0,0,date(m,strtotime($list['attributes'][$i]['value'])),date(d,strtotime($list['attributes'][$i]['value'])),date(y,strtotime($list['attributes'][$i]['value'])));
+ $list['attributes'][$i]['value']
= $GLOBALS['phpgw']->common->show_date($timestamp_date,$dateformat);
+ }
+ if($list['attributes'][$i]['datatype']=='AB')
+ {
+ if($list['attributes'][$i]['value'])
+ {
+ $contact_data =
$contacts->read_single_entry($list['attributes'][$i]['value'],array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
+
$list['attributes'][$i]['contact_name'] = $contact_data[0]['n_family'] . ', ' .
$contact_data[0]['n_given'];
+ }
+
+ $insert_record_list[] =
$list['attributes'][$i]['name'];
+ $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.addressbook&column='
. $list['attributes'][$i]['name']);
+
+ $lookup_functions[$m]['name'] =
'lookup_'. $list['attributes'][$i]['name'] .'()';
+ $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+ $m++;
+ }
+
if($list['attributes'][$i]['datatype']=='VENDOR')
+ {
+ if($list['attributes'][$i]['value'])
+ {
+ $vendor_data =
$vendor->read_single(array('actor_id'=>$list['attributes'][$i]['value']));
+
+ for
($n=0;$n<count($vendor_data['attributes']);$n++)
+ {
+
if($vendor_data['attributes'][$n]['name'] == 'org_name')
+ {
+
$list['attributes'][$i]['vendor_name']= $vendor_data['attributes'][$n]['value'];
+ $n
=count($vendor_data['attributes']);
+ }
+ }
+ }
+
+ $insert_record_list[] =
$list['attributes'][$i]['name'];
+ $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor&column='
. $list['attributes'][$i]['name']);
+
+ $lookup_functions[$m]['name'] =
'lookup_'. $list['attributes'][$i]['name'] .'()';
+ $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+ $m++;
+ }
+
+ if($list['attributes'][$i]['datatype']=='R' ||
$list['attributes'][$i]['datatype']=='CH' ||
$list['attributes'][$i]['datatype']=='LB')
+ {
+ $list['attributes'][$i]['choice']
= $this->so->read_attrib_choice($list['attributes'][$i]['attrib_id']);
+
$input_type=$input_type_array[$list['attributes'][$i]['datatype']];
+
+
if($list['attributes'][$i]['datatype']=='CH')
+ {
+
$list['attributes'][$i]['value']=unserialize($list['attributes'][$i]['value']);
+
$list['attributes'][$i]['choice'] =
$this->bocommon->select_multi_list_2($list['attributes'][$i]['value'],$list['attributes'][$i]['choice'],$input_type);
+
+ }
+ else
+ {
+ for
($j=0;$j<count($list['attributes'][$i]['choice']);$j++)
+ {
+
$list['attributes'][$i]['choice'][$j]['input_type']=$input_type;
+
if($list['attributes'][$i]['choice'][$j]['id']==$list['attributes'][$i]['value'])
+ {
+
$list['attributes'][$i]['choice'][$j]['checked']='checked';
+ }
+ }
+ }
+ }
+
+ $list['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($list['attributes'][$i]['datatype']);
+ $list['attributes'][$i]['counter'] = $i;
+ $list['attributes'][$i]['type_id'] =
$data['type_id'];
+ }
+
+ for ($j=0;$j<count($lookup_functions);$j++)
+ {
+ $list['lookup_functions'] .= 'function ' .
$lookup_functions[$j]['name'] ."\r\n";
+ $list['lookup_functions'] .= '{'."\r\n";
+ $list['lookup_functions'] .=
$lookup_functions[$j]['action'] ."\r\n";
+ $list['lookup_functions'] .= '}'."\r\n";
+ }
+
+
$GLOBALS['phpgw']->session->appsession('insert_record_agreement' .
!!$detail,$this->currentapp,$insert_record_list);
+
+//html_print_r($list);
+ return $list;
+
+ }
+
+ function convert_attribute_save($values_attribute='')
+ {
+
+ for ($i=0;$i<count($values_attribute);$i++)
+ {
+ if($values_attribute[$i]['datatype']=='CH' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
serialize($values_attribute[$i]['value']);
+ }
+ if($values_attribute[$i]['datatype']=='R' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
$values_attribute[$i]['value'][0];
+ }
+
+ if($values_attribute[$i]['datatype']=='N' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
str_replace(",",".",$values_attribute[$i]['value']);
+ }
+
+ if($values_attribute[$i]['datatype']=='D' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
date($this->bocommon->dateformat,$this->bocommon->date_to_timestamp($values_attribute[$i]['value']));
+ }
+ }
+
+ return $values_attribute;
+ }
+
+ function save($values,$values_attribute='',$action='')
+ {
+
+ $values['start_date'] =
$this->bocommon->date_to_timestamp($values['start_date']);
+ $values['end_date'] =
$this->bocommon->date_to_timestamp($values['end_date']);
+ $values['termination_date'] =
$this->bocommon->date_to_timestamp($values['termination_date']);
+
+ $values_attribute =
$this->convert_attribute_save($values_attribute);
+
+ if ($action=='edit')
+// if ($values['agreement_id'])
+ {
+ if ($values['agreement_id'] != 0)
+ {
+
$receipt=$this->so->edit($values,$values_attribute);
+
+ if($values['delete_file'])
+ {
+ for
($i=0;$i<count($values['delete_file']);$i++)
+ {
+ $file =
$this->fakebase. SEP . 'agreement' . SEP . $values['agreement_id'] . SEP .
$values['delete_file'][$i];
+
+
if($this->vfs->file_exists(array(
+
'string' => $file,
+
'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+
$this->vfs->override_acl = 1;
+
+
if(!$this->vfs->rm (array(
+
'string' => $file,
+
'relatives' => array(
+
RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to delete file') . ' :'.
$this->fakebase. SEP . 'agreement'. SEP . $values['agreement_id'] . SEP
.$values['delete_file'][$i]);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('file deleted') . ' :'.
$this->fakebase. SEP . 'agreement'. SEP . $values['id'] . SEP .
$values['delete_file'][$i]);
+ }
+
$this->vfs->override_acl = 0;
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ $receipt =
$this->so->add($values,$values_attribute);
+ }
+ return $receipt;
+ }
+
+ function save_item($values,$values_attribute='')
+ {
+//_debug_array($values);
+ $values['m_cost'] =
str_replace(",",".",$values['m_cost']);
+ $values['w_cost'] =
str_replace(",",".",$values['w_cost']);
+ $values['total_cost'] = $values['m_cost'] +
$values['w_cost'];
+
+ if ($values['index_count'] > 0)
+ {
+ if ($values['id'] != 0)
+ {
+ $receipt=$this->so->edit_item($values);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add_item($values);
+ }
+ return $receipt;
+ }
+
+
+ function update($values)
+ {
+ $values['date'] =
$this->bocommon->date_to_timestamp($values['date']);
+
+ return $this->so->update($values);
+ }
+
+ function delete_last_index($agreement_id,$id)
+ {
+ $this->so->delete_last_index($agreement_id,$id);
+ }
+
+
+ function delete_item($agreement_id,$activity_id)
+ {
+ $this->so->delete_item($agreement_id,$activity_id);
+ }
+
+ function delete($agreement_id='',$id='',$attrib='')
+ {
+ if ($attrib)
+ {
+ $this->so->delete_attrib($id);
+ }
+ else
+ {
+ $this->so->delete($agreement_id);
+ }
+ }
+
+ function read_attrib($type_id='')
+ {
+ $attrib = $this->so->read_attrib(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'allrows'=>$this->allrows));
+
+ for ($i=0; $i<count($attrib); $i++)
+ {
+ $attrib[$i]['datatype'] =
$this->bocommon->translate_datatype($attrib[$i]['datatype']);
+ }
+
+ $this->total_records = $this->so->total_records;
+
+ return $attrib;
+ }
+
+ function read_single_attrib($id)
+ {
+ return $this->so->read_single_attrib($id);
+ }
+
+ function resort_attrib($data)
+ {
+ $this->so->resort_attrib($data);
+ }
+
+ function save_attrib($attrib,$action='')
+ {
+ if ($action=='edit')
+ {
+ if ($attrib['id'] != '')
+ {
+
+ $receipt =
$this->so->edit_attrib($attrib);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add_attrib($attrib);
+ }
+ return $receipt;
+ }
+
+ function column_list($selected='',$allrows='')
+ {
+ if(!$selected)
+ {
+
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]["agreement_columns"];
+ }
+
+ $columns =
$this->so->read_attrib(array('allrows'=>$allrows,'column_list'=>True));
+
+
$column_list=$this->bocommon->select_multi_list($selected,$columns);
+
+ return $column_list;
+ }
+
+ function request_next_id()
+ {
+ return $this->so->request_next_id();
+ }
+
+ function create_home_dir($receipt='')
+ {
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase. SEP .
'agreement',
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $this->vfs->override_acl = 1;
+
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase. SEP .
'agreement',
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'agreement');
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'agreement');
+ }
+ $this->vfs->override_acl = 0;
+ }
+
+ return $receipt;
+ }
+
+ function create_document_dir($id='')
+ {
+
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase. SEP .
'agreement' . SEP . $id,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $this->vfs->override_acl = 1;
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase. SEP .
'agreement' . SEP . $id,
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'agreement' . SEP . $id);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'agreement' . SEP . $id);
+ }
+ $this->vfs->override_acl = 0;
+ }
+
+//_debug_array($receipt);
+ return $receipt;
+ }
+
+ function get_agreement_group_list($selected='')
+ {
+ $agreement_groups=
$this->so->get_agreement_group_list();
+
+ while (is_array($agreement_groups) &&
list(,$agreement_group_entry) = each($agreement_groups))
+ {
+ $sel_agreement_group_entry = '';
+ if ($agreement_group_entry['id']==$selected)
+ {
+ $sel_agreement_group_entry = 'selected';
+ }
+
+ $agreement_group_list[] = array
+ (
+ 'id' => $agreement_group_entry['id'],
+ 'name' =>
$agreement_group_entry['name'],
+ 'selected' =>
$sel_agreement_group_entry
+ );
+ }
+
+ for ($i=0;$i<count($agreement_group_list);$i++)
+ {
+ if ($agreement_group_list[$i]['selected'] !=
'selected')
+ {
+
unset($agreement_group_list[$i]['selected']);
+ }
+ }
+
+ return $agreement_group_list;
+ }
+
+ function read_group_activity($group_id='',$agreement_id='')
+ {
+ $activity_list =
$this->so->read_group_activity($group_id,$agreement_id);
+ $this->uicols = $this->so->uicols;
+ return $activity_list;
+ }
+
+ function add_activity($values='',$agreement_id='')
+ {
+ return $this->so->add_activity($values,$agreement_id);
+ }
+
+ function select_status_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('status_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('status_filter'));
+ break;
+ }
+
+ $status_entries= $this->so->select_status_list();
+
+ while (is_array($status_entries) && list(,$status) =
each($status_entries))
+ {
+ $sel_status = '';
+ if ($status['id']==$selected)
+ {
+ $sel_status = 'selected';
+ }
+
+ $status_list[] = array
+ (
+ 'id' => $status['id'],
+ 'name' => $status['name'],
+ 'selected' => $sel_status
+ );
+ }
+
+ for ($i=0;$i<count($status_list);$i++)
+ {
+ if ($status_list[$i]['selected'] != 'selected')
+ {
+ unset($status_list[$i]['selected']);
+ }
+ }
+
+ return $status_list;
+ }
+
+ function get_activity_descr($id)
+ {
+ return $this->so->get_activity_descr($id);
+ }
+ }
+?>
Index: property/inc/class.boalarm.inc.php
diff -u property/inc/class.boalarm.inc.php:1.10
property/inc/class.boalarm.inc.php:1.11
--- property/inc/class.boalarm.inc.php:1.10 Thu May 12 21:26:28 2005
+++ property/inc/class.boalarm.inc.php Fri Jan 27 14:05:43 2006
@@ -1,481 +1,481 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.boalarm.inc.php,v 1.10 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class boalarm
- {
-
- var $public_functions = array
- (
- 'send_alarm' => True
- );
-
- function boalarm()
- {
-
- $GLOBALS['phpgw_info']['flags']['currentapp'] =
'property';
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- if (!is_object($GLOBALS['phpgw']->asyncservice))
- {
- $GLOBALS['phpgw']->asyncservice =
CreateObject('phpgwapi.asyncservice');
- }
- $this->async = &$GLOBALS['phpgw']->asyncservice;
- $this->so =
CreateObject($this->currentapp.'.soalarm');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $method_id =
get_var('method_id',array('POST','GET'));
- $allrows =
get_var('allrows',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id) && !empty($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- else
- {
- unset($this->cat_id);
- }
- if(isset($method_id) && !empty($method_id))
- {
- $this->method_id = $method_id;
- }
- else
- {
- unset($this->method_id);
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','owner',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','owner');
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->method_id = $data['method_id'];
- }
-
-
- function select_method_list($selected='')
- {
- $list = $this->so->select_method_list();
- $list = $this->bocommon->select_list($selected,$list);
- return $list;
- }
-
- function read_single_method($id)
- {
- return $this->so->read_single_method($id);
- }
-
- function read()
- {
- $jobs = $this->so->read(array(id=>'%','start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'allrows'=>$this->allrows));
- $this->total_records = $this->so->total_records;
- return $jobs;
- }
-
- /*!
- @function read_alarms
- @abstract read the alarms of a calendar-event specified by
$cal_id
- @returns array of alarms with alarm-id as key
- @note the alarm-id is a string of 'cal:'.$cal_id.':'.$alarm_nr,
it is used as the job-id too
- */
- function read_alarms($type='',$input_id,$text='')
- {
- $alarms = array();
-
- if ($jobs = $this->async->read($type .
':'.intval($input_id).':%'))
- {
- foreach($jobs as $id => $job)
- {
- $alarm =
$job['data']; // text, enabled
- $alarm['alarm_id'] = $id;
- $alarm['time'] =
$GLOBALS['phpgw']->common->show_date($job['next']);
- $alarm['user'] =
$GLOBALS['phpgw']->accounts->id2name($alarm['owner']);
- $alarm['text'] = $text;
-
- $alarms[] = $alarm;
- }
- }
- return $alarms;
- }
-
- /*!
- @function read_alarm
- @abstract read a single alarm specified by it's $id
- @returns array with data of the alarm
- @note the alarm-id is a string of 'cal:'.$cal_id.':'.$alarm_nr,
it is used as the job-id too
- */
- function read_alarm($alarm_type,$id)
- {
- if (!($jobs = $this->async->read($id)))
- {
- return False;
- }
-
- $alarm = $jobs[$id]['data']; // text, enabled
- $alarm['id'] = $id;
- $alarm['time'] = $jobs[$id]['next'];
- $alarm['times'] = $jobs[$id]['times'];
-
-// echo "<p>read_alarm('$id')="; print_r($alarm); echo
"</p>\n";
- return $alarm;
- }
-
-
-
- /*!
- @function enable
- @abstract enable or disable one or more alarms identified by
its ids
- @syntax enable($ids,$enable=True)
- @param $ids array with alarm ids as keys (!)
- @returns the number of alarms enabled or -1 for insuficent
permission to do so
- @note Not found alarms or insuficent perms stop the enableing
of multiple alarms
- */
- function enable_alarm($alarm_type,$alarms,$enable=True)
- {
- $enabled = 0;
- foreach ($alarms as $id => $field)
- {
- $temp = explode(':',$id);
- $alarm_type = $temp[0];
-
- if (!($alarm =
$this->read_alarm($alarm_type,$id)))
- {
- return 0; // alarm not found
- }
- if (!$alarm['enabled'] == !$enable)
- {
- continue; // nothing to do
- }
-/* if ($enable &&
!$this->check_perms(PHPGW_ACL_SETALARM,$alarm['owner']) ||
- !$enable &&
!$this->check_perms(PHPGW_ACL_DELETEALARM,$alarm['owner']))
- {
- return -1;
- }
-*/
- $alarm['enabled'] = intval(!$alarm['enabled']);
-
- if
($this->save_alarm($alarm_type,$alarm['event_id'],$alarm))
- {
- ++$enabled;
- }
- }
- return $enabled;
- }
-
-
- /*!
- @function save_alarm
- @abstract saves a new or updated alarm
- @syntax save_alarm($cal_id,$alarm,$id=False)
- @param $cal_id Id of the calendar-entry
- @param $alarm array with fields: text, owner, enabled, ..
- */
- function save_alarm($alarm_type,$event_id,$alarm,$method='')
- {
- if(!$method)
- {
- $method = $this->currentapp
.'.boalarm.send_alarm';
- }
-// echo "<p>save_alarm(event_id=$event_id, alarm=";
print_r($alarm); echo ")</p>\n";
-
- if (!$alarm['id'])
- {
- $alarms =
$this->read_alarms($alarm_type,$event_id); // find a free alarm#
- $n = count($alarms);
- do
- {
- $id = $alarm_type
.':'.intval($event_id).':'.$n;
- ++$n;
- }
- while (@isset($alarms[$id]));
-
- $alarm[$alarm_type.'_id'] = $event_id;
// we need the back-reference
-
- $alarm['id'] = $id;
-
- if
(!$this->async->set_timer($alarm['times'],$id,$method,$alarm))
- {
- return False;
- }
- return $id;
- }
- else
- {
- $this->async->cancel_timer($alarm['id']);
-
$this->async->set_timer($alarm['times'],$alarm['id'],$method,$alarm);
- return $alarm['id'];
- }
- }
-
- /*!
- @function add_alarm
- @abstract adds a new alarm to an event
- @syntax add(&$event,$time,$login_id)
- @param &$event event to add the alarm too
- @param $time for the alarm in sec before the starttime of the
event
- @param $login_id user to alarm
- @returns the alarm or False
- */
- function add_alarm($alarm_type,&$event,$time,$owner)
- {
-/* if (!$this->check_perms(PHPGW_ACL_SETALARM,$owner) ||
!($cal_id = $event['id']))
- {
- return False;
- }
-*/
- if(!$owner>0)
- {
- $receipt['error'][]=array('msg'=>lang('No user
selected'));
- return $receipt;
- }
-
- $alarm = Array(
- 'time' => ($event['alarm_date'] - $time),
//($etime=$this->bo->maketime($event['start'])) - $time,
- 'offset' => $time,
- 'owner' => $owner,
- 'enabled' => 1,
- 'event_id' => $event['id'],
- 'event_name' => $event['name']
- );
-
- $alarm['times'] = $alarm['time'];
- $alarm['id'] =
$this->save_alarm($alarm_type,$event['id'],$alarm);
-
- $event['alarm'][$alarm['id']] = $alarm;
-
- return $alarm;
- }
-
-
- /*!
- @function delete
- @abstract delete one or more alarms identified by its ids
- @syntax delete($ids)
- @param $ids array with alarm ids as keys (!)
- @returns the number of alarms deleted or -1 for insuficent
permission to do so
- @note Not found alarms or insuficent perms stop the deleting of
multiple alarms
- */
- function delete_alarm($alarm_type,$alarms)
- {
- $deleted = 0;
- foreach ($alarms as $id => $field)
- {
- if (!($alarm =
$this->read_alarm($alarm_type,$id)))
- {
- return 0; // alarm not found
- }
-/* if
(!$this->check_perms(PHPGW_ACL_DELETEALARM,$alarm['owner']))
- {
- return -1;
- }
-*/
- if ($this->async->cancel_timer($id))
- {
- ++$deleted;
- }
- }
- return $deleted;
- }
-
-
- function test_cron()
- {
- $this->async->check_run('crontab');
- }
-
-
- function send_alarm($alarm)
- {
-
- // echo "<p>boalarm::send_alarm("; print_r($alarm); echo
")</p>\n";
- $GLOBALS['phpgw_info']['user']['account_id'] =
$this->owner = $alarm['owner'];
-
- if (!$alarm['enabled'] || !$alarm['owner'])
- {
- return False; // event not found
- }
-
- $this->config =
CreateObject('phpgwapi.config');
- $this->config->read_repository();
- $this->send =
CreateObject('phpgwapi.send');
-
- $members = array();
-
- // build subject
- $subject = lang('Alarm').': '.$alarm['event_name'];
-
- $prefs_user =
$this->bocommon->create_preferences($this->currentapp,$alarm['owner']);
-
- $from_address=$prefs_user['email'];
-
- //-----------from--------
-
-
-
$current_user_id=$GLOBALS['phpgw_info']['user']['account_id'];
-
- $current_user_firstname = 'FM';
-
- $current_user_lastname = 'System';
-
- $current_user_name= $user_firstname . " "
.$user_lastname ;
-
- $current_prefs_user =
$this->bocommon->create_preferences($this->currentapp,$alarm['owner']);
- $current_user_address=$current_prefs_user['email'];
-
- $headers = "Return-Path: <". $current_user_address
.">\r\n";
- $headers .= "From: " . $current_user_name . "<" .
$current_user_address .">\r\n";
-// $headers .= "Bcc: " . $current_user_name . "<" .
$current_user_address .">\r\n";
- $headers .= "Content-type: text/html;
charset=iso-8859-1\r\n";
- $headers .= "MIME-Version: 1.0\r\n";
-
- //-----------from--------
- // build body
- $body = '';
- $body .= lang('Alarm').' #'.$alarm['event_id']."\n";
- $body .= lang('Name').': '.$alarm['event_name']."\n";
- if(!is_array($alarm['time']))
- {
- $body .= lang('Deadline').': '.
$GLOBALS['phpgw']->common->show_date(($alarm['time']+$alarm['offset'])) ."\n";
- }
- $body .= lang('Assigned To').':
'.$GLOBALS['phpgw']->accounts->id2name($alarm['owner'])."\n";
-
- // add assigned to recipients
- $members[] = array('account_id' => $alarm['owner'],
'account_name' => $GLOBALS['phpgw']->accounts->id2name($alarm['owner']));
-
- $error = Array();
- $toarray = Array();
- $i=0;
- for ($i=0;$i<count($members);$i++)
- {
- if ($members[$i]['account_id'])
- {
- $prefs =
$this->bocommon->create_preferences($this->currentapp,$members[$i]['account_id']);
- if (strlen($prefs['email'])>
(strlen($members[$i]['account_name'])+1))
- {
- $toarray[$prefs['email']] =
$prefs['email'];
- }
- else
- {
- $receipt['error'][] =
array('msg'=> lang('Your message could not be sent!'));
- $receipt['error'][] =
array('msg'=>lang('This user has not defined an email address !') . ' : ' .
$members[$i]['account_name']);
- }
- }
- }
-
- if(count($toarray) > 1)
- {
- $to = implode(',',$toarray);
- }
- else
- {
- $to = current($toarray);
- }
-
- $mail_method=
$this->config->config_data['fmwrkorder_mail'];
-// echo 'mail_method: '.$mail_method .'<BR>';
-
- if ($mail_method=='smtp'):
- {
- $rc = $this->send->msg('email', $to, $subject,
stripslashes($body), '', $cc,
$bcc,$current_user_address,$current_user_name,'txt');
- }
- elseif ($mail_method=='sendmail'):
- {
- $rc= @mail($to,$subject,stripslashes($body),
$headers);
- }
- else:
- {
- $receipt['error'][] = array('msg'=>
lang('Mailing method is not chosen! (admin section)'));
- }
- endif;
-
- // $rc=1;
- if (!$rc)
- {
- $receipt['error'][] = array('msg'=> lang('Your
message could not be sent by mail!'));
- $receipt['error'][] = array('msg'=> lang('The
mail server returned'));
- $receipt['error'][] = array('msg'=> 'From :' .
$current_user_name . '<' . $current_user_address .'>');
- $receipt['error'][] = array('msg'=> 'to: '.$to);
- $receipt['error'][] = array('msg'=> 'subject:
'.$subject);
- $receipt['error'][] = array('msg'=> $body );
- // $receipt['error'][] = array('msg'=> 'cc: ' .
$cc);
- // $receipt['error'][] = array('msg'=> 'bcc:
'.$bcc);
- $receipt['error'][] = array('msg'=> 'group:
'.$group_name);
- $receipt['error'][] = array('msg'=> 'err_code:
'.$this->send->err['code']);
- $receipt['error'][] = array('msg'=> 'err_msg:
'. htmlspecialchars($this->send->err['msg']));
- $receipt['error'][] = array('msg'=> 'err_desc:
'. $GLOBALS['phpgw']->err['desc']);
- }
-
-//_debug_array($receipt);
-// return $receipt;
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.boalarm.inc.php,v 1.11 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class boalarm
+ {
+
+ var $public_functions = array
+ (
+ 'send_alarm' => True
+ );
+
+ function boalarm()
+ {
+
+ $GLOBALS['phpgw_info']['flags']['currentapp'] =
'property';
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ if (!is_object($GLOBALS['phpgw']->asyncservice))
+ {
+ $GLOBALS['phpgw']->asyncservice =
CreateObject('phpgwapi.asyncservice');
+ }
+ $this->async = &$GLOBALS['phpgw']->asyncservice;
+ $this->so =
CreateObject($this->currentapp.'.soalarm');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $method_id =
get_var('method_id',array('POST','GET'));
+ $allrows =
get_var('allrows',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id) && !empty($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ else
+ {
+ unset($this->cat_id);
+ }
+ if(isset($method_id) && !empty($method_id))
+ {
+ $this->method_id = $method_id;
+ }
+ else
+ {
+ unset($this->method_id);
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','owner',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','owner');
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->method_id = $data['method_id'];
+ }
+
+
+ function select_method_list($selected='')
+ {
+ $list = $this->so->select_method_list();
+ $list = $this->bocommon->select_list($selected,$list);
+ return $list;
+ }
+
+ function read_single_method($id)
+ {
+ return $this->so->read_single_method($id);
+ }
+
+ function read()
+ {
+ $jobs = $this->so->read(array(id=>'%','start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'allrows'=>$this->allrows));
+ $this->total_records = $this->so->total_records;
+ return $jobs;
+ }
+
+ /*!
+ @function read_alarms
+ @abstract read the alarms of a calendar-event specified by
$cal_id
+ @returns array of alarms with alarm-id as key
+ @note the alarm-id is a string of 'cal:'.$cal_id.':'.$alarm_nr,
it is used as the job-id too
+ */
+ function read_alarms($type='',$input_id,$text='')
+ {
+ $alarms = array();
+
+ if ($jobs = $this->async->read($type .
':'.intval($input_id).':%'))
+ {
+ foreach($jobs as $id => $job)
+ {
+ $alarm =
$job['data']; // text, enabled
+ $alarm['alarm_id'] = $id;
+ $alarm['time'] =
$GLOBALS['phpgw']->common->show_date($job['next']);
+ $alarm['user'] =
$GLOBALS['phpgw']->accounts->id2name($alarm['owner']);
+ $alarm['text'] = $text;
+
+ $alarms[] = $alarm;
+ }
+ }
+ return $alarms;
+ }
+
+ /*!
+ @function read_alarm
+ @abstract read a single alarm specified by it's $id
+ @returns array with data of the alarm
+ @note the alarm-id is a string of 'cal:'.$cal_id.':'.$alarm_nr,
it is used as the job-id too
+ */
+ function read_alarm($alarm_type,$id)
+ {
+ if (!($jobs = $this->async->read($id)))
+ {
+ return False;
+ }
+
+ $alarm = $jobs[$id]['data']; // text, enabled
+ $alarm['id'] = $id;
+ $alarm['time'] = $jobs[$id]['next'];
+ $alarm['times'] = $jobs[$id]['times'];
+
+// echo "<p>read_alarm('$id')="; print_r($alarm); echo
"</p>\n";
+ return $alarm;
+ }
+
+
+
+ /*!
+ @function enable
+ @abstract enable or disable one or more alarms identified by
its ids
+ @syntax enable($ids,$enable=True)
+ @param $ids array with alarm ids as keys (!)
+ @returns the number of alarms enabled or -1 for insuficent
permission to do so
+ @note Not found alarms or insuficent perms stop the enableing
of multiple alarms
+ */
+ function enable_alarm($alarm_type,$alarms,$enable=True)
+ {
+ $enabled = 0;
+ foreach ($alarms as $id => $field)
+ {
+ $temp = explode(':',$id);
+ $alarm_type = $temp[0];
+
+ if (!($alarm =
$this->read_alarm($alarm_type,$id)))
+ {
+ return 0; // alarm not found
+ }
+ if (!$alarm['enabled'] == !$enable)
+ {
+ continue; // nothing to do
+ }
+/* if ($enable &&
!$this->check_perms(PHPGW_ACL_SETALARM,$alarm['owner']) ||
+ !$enable &&
!$this->check_perms(PHPGW_ACL_DELETEALARM,$alarm['owner']))
+ {
+ return -1;
+ }
+*/
+ $alarm['enabled'] = intval(!$alarm['enabled']);
+
+ if
($this->save_alarm($alarm_type,$alarm['event_id'],$alarm))
+ {
+ ++$enabled;
+ }
+ }
+ return $enabled;
+ }
+
+
+ /*!
+ @function save_alarm
+ @abstract saves a new or updated alarm
+ @syntax save_alarm($cal_id,$alarm,$id=False)
+ @param $cal_id Id of the calendar-entry
+ @param $alarm array with fields: text, owner, enabled, ..
+ */
+ function save_alarm($alarm_type,$event_id,$alarm,$method='')
+ {
+ if(!$method)
+ {
+ $method = $this->currentapp
.'.boalarm.send_alarm';
+ }
+// echo "<p>save_alarm(event_id=$event_id, alarm=";
print_r($alarm); echo ")</p>\n";
+
+ if (!$alarm['id'])
+ {
+ $alarms =
$this->read_alarms($alarm_type,$event_id); // find a free alarm#
+ $n = count($alarms);
+ do
+ {
+ $id = $alarm_type
.':'.intval($event_id).':'.$n;
+ ++$n;
+ }
+ while (@isset($alarms[$id]));
+
+ $alarm[$alarm_type.'_id'] = $event_id;
// we need the back-reference
+
+ $alarm['id'] = $id;
+
+ if
(!$this->async->set_timer($alarm['times'],$id,$method,$alarm))
+ {
+ return False;
+ }
+ return $id;
+ }
+ else
+ {
+ $this->async->cancel_timer($alarm['id']);
+
$this->async->set_timer($alarm['times'],$alarm['id'],$method,$alarm);
+ return $alarm['id'];
+ }
+ }
+
+ /*!
+ @function add_alarm
+ @abstract adds a new alarm to an event
+ @syntax add(&$event,$time,$login_id)
+ @param &$event event to add the alarm too
+ @param $time for the alarm in sec before the starttime of the
event
+ @param $login_id user to alarm
+ @returns the alarm or False
+ */
+ function add_alarm($alarm_type,&$event,$time,$owner)
+ {
+/* if (!$this->check_perms(PHPGW_ACL_SETALARM,$owner) ||
!($cal_id = $event['id']))
+ {
+ return False;
+ }
+*/
+ if(!$owner>0)
+ {
+ $receipt['error'][]=array('msg'=>lang('No user
selected'));
+ return $receipt;
+ }
+
+ $alarm = Array(
+ 'time' => ($event['alarm_date'] - $time),
//($etime=$this->bo->maketime($event['start'])) - $time,
+ 'offset' => $time,
+ 'owner' => $owner,
+ 'enabled' => 1,
+ 'event_id' => $event['id'],
+ 'event_name' => $event['name']
+ );
+
+ $alarm['times'] = $alarm['time'];
+ $alarm['id'] =
$this->save_alarm($alarm_type,$event['id'],$alarm);
+
+ $event['alarm'][$alarm['id']] = $alarm;
+
+ return $alarm;
+ }
+
+
+ /*!
+ @function delete
+ @abstract delete one or more alarms identified by its ids
+ @syntax delete($ids)
+ @param $ids array with alarm ids as keys (!)
+ @returns the number of alarms deleted or -1 for insuficent
permission to do so
+ @note Not found alarms or insuficent perms stop the deleting of
multiple alarms
+ */
+ function delete_alarm($alarm_type,$alarms)
+ {
+ $deleted = 0;
+ foreach ($alarms as $id => $field)
+ {
+ if (!($alarm =
$this->read_alarm($alarm_type,$id)))
+ {
+ return 0; // alarm not found
+ }
+/* if
(!$this->check_perms(PHPGW_ACL_DELETEALARM,$alarm['owner']))
+ {
+ return -1;
+ }
+*/
+ if ($this->async->cancel_timer($id))
+ {
+ ++$deleted;
+ }
+ }
+ return $deleted;
+ }
+
+
+ function test_cron()
+ {
+ $this->async->check_run('crontab');
+ }
+
+
+ function send_alarm($alarm)
+ {
+
+ // echo "<p>boalarm::send_alarm("; print_r($alarm); echo
")</p>\n";
+ $GLOBALS['phpgw_info']['user']['account_id'] =
$this->owner = $alarm['owner'];
+
+ if (!$alarm['enabled'] || !$alarm['owner'])
+ {
+ return False; // event not found
+ }
+
+ $this->config =
CreateObject('phpgwapi.config');
+ $this->config->read_repository();
+ $this->send =
CreateObject('phpgwapi.send');
+
+ $members = array();
+
+ // build subject
+ $subject = lang('Alarm').': '.$alarm['event_name'];
+
+ $prefs_user =
$this->bocommon->create_preferences($this->currentapp,$alarm['owner']);
+
+ $from_address=$prefs_user['email'];
+
+ //-----------from--------
+
+
+
$current_user_id=$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $current_user_firstname = 'FM';
+
+ $current_user_lastname = 'System';
+
+ $current_user_name= $user_firstname . " "
.$user_lastname ;
+
+ $current_prefs_user =
$this->bocommon->create_preferences($this->currentapp,$alarm['owner']);
+ $current_user_address=$current_prefs_user['email'];
+
+ $headers = "Return-Path: <". $current_user_address
.">\r\n";
+ $headers .= "From: " . $current_user_name . "<" .
$current_user_address .">\r\n";
+// $headers .= "Bcc: " . $current_user_name . "<" .
$current_user_address .">\r\n";
+ $headers .= "Content-type: text/html;
charset=iso-8859-1\r\n";
+ $headers .= "MIME-Version: 1.0\r\n";
+
+ //-----------from--------
+ // build body
+ $body = '';
+ $body .= lang('Alarm').' #'.$alarm['event_id']."\n";
+ $body .= lang('Name').': '.$alarm['event_name']."\n";
+ if(!is_array($alarm['time']))
+ {
+ $body .= lang('Deadline').': '.
$GLOBALS['phpgw']->common->show_date(($alarm['time']+$alarm['offset'])) ."\n";
+ }
+ $body .= lang('Assigned To').':
'.$GLOBALS['phpgw']->accounts->id2name($alarm['owner'])."\n";
+
+ // add assigned to recipients
+ $members[] = array('account_id' => $alarm['owner'],
'account_name' => $GLOBALS['phpgw']->accounts->id2name($alarm['owner']));
+
+ $error = Array();
+ $toarray = Array();
+ $i=0;
+ for ($i=0;$i<count($members);$i++)
+ {
+ if ($members[$i]['account_id'])
+ {
+ $prefs =
$this->bocommon->create_preferences($this->currentapp,$members[$i]['account_id']);
+ if (strlen($prefs['email'])>
(strlen($members[$i]['account_name'])+1))
+ {
+ $toarray[$prefs['email']] =
$prefs['email'];
+ }
+ else
+ {
+ $receipt['error'][] =
array('msg'=> lang('Your message could not be sent!'));
+ $receipt['error'][] =
array('msg'=>lang('This user has not defined an email address !') . ' : ' .
$members[$i]['account_name']);
+ }
+ }
+ }
+
+ if(count($toarray) > 1)
+ {
+ $to = implode(',',$toarray);
+ }
+ else
+ {
+ $to = current($toarray);
+ }
+
+ $mail_method=
$this->config->config_data['fmwrkorder_mail'];
+// echo 'mail_method: '.$mail_method .'<BR>';
+
+ if ($mail_method=='smtp'):
+ {
+ $rc = $this->send->msg('email', $to, $subject,
stripslashes($body), '', $cc,
$bcc,$current_user_address,$current_user_name,'txt');
+ }
+ elseif ($mail_method=='sendmail'):
+ {
+ $rc= @mail($to,$subject,stripslashes($body),
$headers);
+ }
+ else:
+ {
+ $receipt['error'][] = array('msg'=>
lang('Mailing method is not chosen! (admin section)'));
+ }
+ endif;
+
+ // $rc=1;
+ if (!$rc)
+ {
+ $receipt['error'][] = array('msg'=> lang('Your
message could not be sent by mail!'));
+ $receipt['error'][] = array('msg'=> lang('The
mail server returned'));
+ $receipt['error'][] = array('msg'=> 'From :' .
$current_user_name . '<' . $current_user_address .'>');
+ $receipt['error'][] = array('msg'=> 'to: '.$to);
+ $receipt['error'][] = array('msg'=> 'subject:
'.$subject);
+ $receipt['error'][] = array('msg'=> $body );
+ // $receipt['error'][] = array('msg'=> 'cc: ' .
$cc);
+ // $receipt['error'][] = array('msg'=> 'bcc:
'.$bcc);
+ $receipt['error'][] = array('msg'=> 'group:
'.$group_name);
+ $receipt['error'][] = array('msg'=> 'err_code:
'.$this->send->err['code']);
+ $receipt['error'][] = array('msg'=> 'err_msg:
'. htmlspecialchars($this->send->err['msg']));
+ $receipt['error'][] = array('msg'=> 'err_desc:
'. $GLOBALS['phpgw']->err['desc']);
+ }
+
+//_debug_array($receipt);
+// return $receipt;
+ }
+
+ }
+?>
Index: property/inc/class.boasync.inc.php
diff -u property/inc/class.boasync.inc.php:1.4
property/inc/class.boasync.inc.php:1.5
--- property/inc/class.boasync.inc.php:1.4 Thu May 12 21:26:28 2005
+++ property/inc/class.boasync.inc.php Fri Jan 27 14:05:43 2006
@@ -1,164 +1,164 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.boasync.inc.php,v 1.4 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class boasync
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- var $soap_functions = array(
- 'list' => array(
- 'in' =>
array('int','int','struct','string','int'),
- 'out' => array('array')
- ),
- 'read' => array(
- 'in' => array('int','struct'),
- 'out' => array('array')
- ),
- 'save' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- ),
- 'delete' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- )
- );
-
- function boasync($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.soasync');
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','async',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','async');
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- }
-
-
- function read()
- {
- $method = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order));
-
- $this->total_records = $this->so->total_records;
-
- return $method;
- }
-
- function read_single($id)
- {
- return $this->so->read_single($id);
- }
-
- function save($method,$action='')
- {
- if ($action=='edit')
- {
- if ($method['id'] != '')
- {
-
- $receipt = $this->so->edit($method);
- }
- }
- else
- {
- $receipt = $this->so->add($method);
- }
- return $receipt;
-
- }
-
- function delete($id)
- {
- $this->so->delete($id);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.boasync.inc.php,v 1.5 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class boasync
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ var $soap_functions = array(
+ 'list' => array(
+ 'in' =>
array('int','int','struct','string','int'),
+ 'out' => array('array')
+ ),
+ 'read' => array(
+ 'in' => array('int','struct'),
+ 'out' => array('array')
+ ),
+ 'save' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ ),
+ 'delete' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ )
+ );
+
+ function boasync($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.soasync');
+ $this->socommon =
CreateObject($this->currentapp.'.socommon');
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','async',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','async');
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ }
+
+
+ function read()
+ {
+ $method = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order));
+
+ $this->total_records = $this->so->total_records;
+
+ return $method;
+ }
+
+ function read_single($id)
+ {
+ return $this->so->read_single($id);
+ }
+
+ function save($method,$action='')
+ {
+ if ($action=='edit')
+ {
+ if ($method['id'] != '')
+ {
+
+ $receipt = $this->so->edit($method);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add($method);
+ }
+ return $receipt;
+
+ }
+
+ function delete($id)
+ {
+ $this->so->delete($id);
+ }
+ }
+?>
Index: property/inc/class.bob_account.inc.php
diff -u property/inc/class.bob_account.inc.php:1.5
property/inc/class.bob_account.inc.php:1.6
--- property/inc/class.bob_account.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/class.bob_account.inc.php Fri Jan 27 14:05:43 2006
@@ -1,179 +1,179 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.bob_account.inc.php,v 1.5 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class bob_account
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- var $soap_functions = array(
- 'list' => array(
- 'in' =>
array('int','int','struct','string','int'),
- 'out' => array('array')
- ),
- 'read' => array(
- 'in' => array('int','struct'),
- 'out' => array('array')
- ),
- 'save' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- ),
- 'delete' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- )
- );
-
- function bob_account($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.sob_account');
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $allrows= get_var('allrows',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
- }
-
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','b_account',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','b_account');
-
- //_debug_array($data);
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->allrows = $data['allrows'];
- }
-
-
- function read()
- {
- $b_account = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'allrows'=>$this->allrows));
-
- $this->total_records = $this->so->total_records;
-
- return $b_account;
- }
-
- function read_single($id)
- {
- return $this->so->read_single($id);
- }
-
- function select_part_of_town($part_of_town_id)
- {
- return
$this->socommon->select_part_of_town($part_of_town_id);
- }
-
- function save($b_account,$action='')
- {
- if ($action=='edit')
- {
- if ($b_account['id'] != '')
- {
-
- $receipt = $this->so->edit($b_account);
- }
- }
- else
- {
- $receipt = $this->so->add($b_account);
- }
-
- return $receipt;
- }
-
- function delete($id)
- {
- $this->so->delete($id);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.bob_account.inc.php,v 1.6 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class bob_account
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ var $soap_functions = array(
+ 'list' => array(
+ 'in' =>
array('int','int','struct','string','int'),
+ 'out' => array('array')
+ ),
+ 'read' => array(
+ 'in' => array('int','struct'),
+ 'out' => array('array')
+ ),
+ 'save' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ ),
+ 'delete' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ )
+ );
+
+ function bob_account($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.sob_account');
+ $this->socommon =
CreateObject($this->currentapp.'.socommon');
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $allrows= get_var('allrows',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+ }
+
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','b_account',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','b_account');
+
+ //_debug_array($data);
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->allrows = $data['allrows'];
+ }
+
+
+ function read()
+ {
+ $b_account = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'allrows'=>$this->allrows));
+
+ $this->total_records = $this->so->total_records;
+
+ return $b_account;
+ }
+
+ function read_single($id)
+ {
+ return $this->so->read_single($id);
+ }
+
+ function select_part_of_town($part_of_town_id)
+ {
+ return
$this->socommon->select_part_of_town($part_of_town_id);
+ }
+
+ function save($b_account,$action='')
+ {
+ if ($action=='edit')
+ {
+ if ($b_account['id'] != '')
+ {
+
+ $receipt = $this->so->edit($b_account);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add($b_account);
+ }
+
+ return $receipt;
+ }
+
+ function delete($id)
+ {
+ $this->so->delete($id);
+ }
+ }
+?>
Index: property/inc/class.bocategory.inc.php
diff -u property/inc/class.bocategory.inc.php:1.5
property/inc/class.bocategory.inc.php:1.6
--- property/inc/class.bocategory.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/class.bocategory.inc.php Fri Jan 27 14:05:43 2006
@@ -1,179 +1,179 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.bocategory.inc.php,v 1.5 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class bocategory
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- var $soap_functions = array(
- 'list' => array(
- 'in' =>
array('int','int','struct','string','int'),
- 'out' => array('array')
- ),
- 'read' => array(
- 'in' => array('int','struct'),
- 'out' => array('array')
- ),
- 'save' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- ),
- 'delete' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- )
- );
-
- function bocategory($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.socategory');
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $allrows= get_var('allrows',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
- }
-
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','category',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','category');
-
- //_debug_array($data);
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->allrows = $data['allrows'];
- }
-
-
- function read($type='',$type_id='')
- {
- $category = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'type' => $type,type_id=>$type_id,'allrows'=>$this->allrows));
-
- $this->total_records = $this->so->total_records;
-
- return $category;
- }
-
- function read_single($id,$type,$type_id)
- {
- return $this->so->read_single($id,$type,$type_id);
- }
-
- function select_part_of_town($part_of_town_id)
- {
- return
$this->socommon->select_part_of_town($part_of_town_id);
- }
-
- function save($category,$action='',$type ='',$type_id)
- {
- if ($action=='edit')
- {
- if ($category['id'] != '')
- {
-
- $receipt =
$this->so->edit($category,$type,$type_id);
- }
- }
- else
- {
- $receipt =
$this->so->add($category,$type,$type_id);
- }
-
- return $receipt;
- }
-
- function delete($id,$type,$type_id)
- {
- $this->so->delete($id,$type,$type_id);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.bocategory.inc.php,v 1.6 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class bocategory
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ var $soap_functions = array(
+ 'list' => array(
+ 'in' =>
array('int','int','struct','string','int'),
+ 'out' => array('array')
+ ),
+ 'read' => array(
+ 'in' => array('int','struct'),
+ 'out' => array('array')
+ ),
+ 'save' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ ),
+ 'delete' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ )
+ );
+
+ function bocategory($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.socategory');
+ $this->socommon =
CreateObject($this->currentapp.'.socommon');
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $allrows= get_var('allrows',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+ }
+
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','category',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','category');
+
+ //_debug_array($data);
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->allrows = $data['allrows'];
+ }
+
+
+ function read($type='',$type_id='')
+ {
+ $category = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'type' => $type,type_id=>$type_id,'allrows'=>$this->allrows));
+
+ $this->total_records = $this->so->total_records;
+
+ return $category;
+ }
+
+ function read_single($id,$type,$type_id)
+ {
+ return $this->so->read_single($id,$type,$type_id);
+ }
+
+ function select_part_of_town($part_of_town_id)
+ {
+ return
$this->socommon->select_part_of_town($part_of_town_id);
+ }
+
+ function save($category,$action='',$type ='',$type_id)
+ {
+ if ($action=='edit')
+ {
+ if ($category['id'] != '')
+ {
+
+ $receipt =
$this->so->edit($category,$type,$type_id);
+ }
+ }
+ else
+ {
+ $receipt =
$this->so->add($category,$type,$type_id);
+ }
+
+ return $receipt;
+ }
+
+ function delete($id,$type,$type_id)
+ {
+ $this->so->delete($id,$type,$type_id);
+ }
+ }
+?>
Index: property/inc/class.bocommon.inc.php
diff -u property/inc/class.bocommon.inc.php:1.19
property/inc/class.bocommon.inc.php:1.20
--- property/inc/class.bocommon.inc.php:1.19 Tue Nov 22 13:41:54 2005
+++ property/inc/class.bocommon.inc.php Fri Jan 27 14:05:43 2006
@@ -1,1382 +1,1384 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage core
- * @version $Id: class.bocommon.inc.php,v 1.19 2005/11/22 13:41:54
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class bocommon
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
- var $district_id;
-
-
- var $public_functions = array
- (
- 'select_part_of_town' => True,
- 'menu' => True,
- );
-
- var $soap_functions = array(
- 'list' => array(
- 'in' =>
array('int','int','struct','string','int'),
- 'out' => array('array')
- ),
- 'read' => array(
- 'in' => array('int','struct'),
- 'out' => array('array')
- ),
- 'save' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- ),
- 'delete' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- )
- );
-
- function bocommon()
- {
-
- $GLOBALS['phpgw_info']['flags']['currentapp'] =
'property';
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- if (!is_object($GLOBALS['phpgw']->asyncservice))
- {
- $GLOBALS['phpgw']->asyncservice =
CreateObject('phpgwapi.asyncservice');
- }
- $this->async = &$GLOBALS['phpgw']->asyncservice;
-
- $this->join = $this->socommon->join;
- $this->left_join = $this->socommon->left_join;
- $this->like = $this->socommon->like;
-
- switch($GLOBALS['phpgw_info']['server']['db_type'])
- {
- case 'mssql':
- $this->dateformat = "M d
Y";
- $this->datetimeformat = "M d Y g:iA";
- break;
- case 'mysql':
- $this->dateformat =
"Y-m-d";
- $this->datetimeformat = "Y-m-d G:i:s";
- break;
- case 'pgsql':
- $this->dateformat =
"Y-m-d";
- $this->datetimeformat = "Y-m-d G:i:s";
-// $this->dateformat = "F j,
Y";
-// $this->datetimeformat = "F j, Y g:iA";
- break;
- }
-
- /* if
($GLOBALS['phpgw_info']['server']['db_type']=='mssql')
- {
- $this->dateformat = "M d Y";
- $this->datetimeformat = "M d Y g:iA";
- }
- else
- {
- $this->dateformat = "Y-m-d";
- $this->datetimeformat = "Y-m-d G:i:s";
- }
-
-
- if(!$GLOBALS['phpgw_info']['flags']['css'])
- {
- $GLOBALS['phpgw_info']['flags']['css'] .=
"-->\n</style>\n"
- . '<link rel="stylesheet"
type="text/css" media="all" href="'
- .
$GLOBALS['phpgw_info']['server']['webserver_url'].'/' . $this->currentapp .
'/templates/'
- .
$GLOBALS['phpgw_info']['server']['template_set']
- .
'/css/'.$GLOBALS['phpgw_info']['server']['template_set'].'.css"
title="'.$GLOBALS['phpgw_info']['server']['template_set'].'" />'
- . "\n<style type=\"text/css\">\n<!--\n";
- }
-*/
- }
-
- function jscalendar()
- {
- $phpgw_js_url =
$GLOBALS['phpgw_info']['server']['webserver_url'].'/phpgwapi/js';
-// $img =
$GLOBALS['phpgw']->common->get_image_path('phpgwapi','default').'/cal.png';
- $img =
$GLOBALS['phpgw_info']['server']['webserver_url'] .
'/phpgwapi/templates/default/images/cal.png';
-
-// $img = $phpgw_js_url.'/jscalendar/img.gif';
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $jsDateFormat = str_replace(array('d', 'm', 'M', 'Y'),
array('%d', '%m', '%b', '%Y'), $dateformat);
-
- $GLOBALS['phpgw_info']['flags']['java_script']
.='</script>
- <link rel="stylesheet" type="text/css" media="all"
href="'.$phpgw_js_url.'/jscalendar/calendar-win2k-cold-1.css"
title="win2k-cold-1" >
- <script type="text/javascript"
src="'.$phpgw_js_url.'/jscalendar/calendar.js"></script>
- <script type="text/javascript"
src="'.$phpgw_js_url.'/jscalendar/calendar-setup.js"></script>
- <script type="text/javascript"
src="'.$phpgw_js_url.'/jscalendar/lang/calendar-'.substr($GLOBALS['phpgw_info']['user']['preferences']['common']['lang'],0,2)
.'.js"></script>
- ';
-
-
-// <script type="text/javascript"
src="'.ereg_replace('[?&]*click_history=[0-9a-f]*','',$GLOBALS['phpgw']->link('/phpgwapi/js/jscalendar/jscalendar-setup.php')).'"></script>
-
- $cal_info=array(
-// 'stylesheet'
=> $phpgw_js_url.'/jscalendar/calendar-win2k-cold-1.css',
-// 'calendar_source'
=> $phpgw_js_url.'/jscalendar/calendar.js',
-// 'calendar_setup_source' =>
$phpgw_js_url.'/jscalendar/calendar-setup.js',
-// 'calendar_lang'
=>
$phpgw_js_url.'/jscalendar/lang/calendar-'.substr($GLOBALS['phpgw_info']['user']['preferences']['common']['lang'],0,2)
.'.js',
- 'jsDateFormat'
=> $jsDateFormat,
- 'img'
=> $img,
- );
- return $cal_info;
- }
-
- function check_perms($rights, $required)
- {
- // return (!!($rights & $required) == True);
- return ($rights & $required);
- }
-
- function create_preferences($app='',$user_id='')
- {
- return
$this->socommon->create_preferences($app,$user_id);
- }
-
- function get_lookup_entity($location='')
- {
- return $this->socommon->get_lookup_entity($location);
- }
-
- function get_start_entity($location='')
- {
- return $this->socommon->get_start_entity($location);
- }
-
- function msgbox_data($receipt)
- {
- $msgbox_data_error=array();
- if (isSet($receipt['error']) AND
is_array($receipt['error']))
- {
- foreach($receipt['error'] as $errors)
- {
- $msgbox_data_error +=
array($errors['msg']=> False);
- }
- }
-
- $msgbox_data_message=array();
-
- if (isSet($receipt['message']) AND
is_array($receipt['message']))
- {
- foreach($receipt['message'] as $messages)
- {
- $msgbox_data_message +=
array($messages['msg']=> True);
- }
- }
-
- $msgbox_data = $msgbox_data_error +
$msgbox_data_message;
-
- return $msgbox_data;
- }
-
- function moneyformat($amount)
- {
- if
($GLOBALS['phpgw_info']['server']['db_type']=='mssql')
- {
- $moneyformat =
"CONVERT(MONEY,"."'$amount'".",0)";
- }
- else
- {
- $moneyformat = "'" . $amount . "'";
- }
-
- return $moneyformat;
- }
-
-
- function date_array($date)
- {
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $dateformat = str_replace(".","",$dateformat);
- $dateformat = str_replace("-","",$dateformat);
- $dateformat = str_replace("/","",$dateformat);
- $y=strpos($dateformat,'y');
- $d=strpos($dateformat,'d');
- $m=strpos($dateformat,'m');
-
- $dateparts = explode('/', $date);
- $date_array['day'] = $dateparts[$d];
- $date_array['month'] = $dateparts[$m];
- $date_array['year'] = $dateparts[$y];
-
- return $date_array;
- }
-
- function date_to_timestamp($date)
- {
- if($date)
- {
- $date_array = $this->date_array($date);
- $date = mktime
(8,0,0,$date_array['month'],$date_array['day'],$date_array['year']);
- }
- return $date;
- }
-
-
- function
column_list($selected='',$entity_type='',$cat_id,$allrows='')
- {
- $bostandard_entity =
CreateObject($this->currentapp.'.bostandard_entity',True);
-
- if(!$selected)
- {
-
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp][$entity_type.'_columns_'.$cat_id];
- }
-
- $columns =
$bostandard_entity->read_attrib($entity_type,$cat_id,$allrows);
-//_debug_array($columns);
-
-
$column_list=$this->select_multi_list($selected,$columns);
-
- return $column_list;
-
- }
-
- function select_multi_list($selected='',$input_list)
- {
- $j=0;
- if (isset($input_list) AND is_array($input_list))
- {
- foreach($input_list as $entry)
- {
- $output_list[$j]['id'] = $entry['id'];
- $output_list[$j]['name'] =
$entry['name'];
-
- for ($i=0;$i<count($selected);$i++)
- {
- if($selected[$i] ==
$entry['id'])
- {
-
$output_list[$j]['selected'] = 'selected';
- }
- }
- $j++;
- }
- }
-
- for ($i=0;$i<count($output_list);$i++)
- {
- if ($output_list[$i]['selected'] != 'selected')
- {
- unset($output_list[$i]['selected']);
- }
- }
-
- return $output_list;
- }
-
-
-
- function select_list($selected='',$input_list='')
- {
- if (isset($input_list) AND is_array($input_list))
- {
- foreach($input_list as $entry)
- {
- $sel_entry = '';
- if ($entry['id']==$selected)
- {
- $sel_entry = 'selected';
- }
- $entry_list[] = array
- (
- 'id' => $entry['id'],
- 'name' =>
$entry['name'],
- 'selected' => $sel_entry
- );
- }
- for ($i=0;$i<count($entry_list);$i++)
- {
- if ($entry_list[$i]['selected'] !=
'selected')
- {
-
unset($entry_list[$i]['selected']);
- }
- }
- }
- return $entry_list;
- }
-
-
- function
get_user_list($format='',$selected='',$extra='',$default='',$start='',
$sort='', $order='', $query='',$offset='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('user_id_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('user_id_filter'));
- break;
- }
-
- if(!$selected && $default)
- {
- $selected = $default;
- }
-
- if (is_array($extra))
- {
- foreach($extra as $extra_user)
- {
- $users_extra[]=array
- (
- 'account_id' => $extra_user,
- 'account_firstname' =>
lang($extra_user)
- );
- }
- }
-
- $accounts = CreateObject('phpgwapi.accounts');
- $users = $accounts->get_list('accounts', $start, $sort,
$order, $query,$offset);
- unset($accounts);
- if (is_array($users_extra) && is_array($users))
- {
- $users = $users_extra + $users;
- }
-
- if (isSet($users) AND is_array($users))
- {
- foreach($users as $user)
- {
- $sel_user = '';
- if ($user['account_id']==$selected)
- {
- $sel_user = 'selected';
- }
-
- $user_list[] = array
- (
- 'user_id' =>
$user['account_id'],
- 'name' =>
$user['account_lastname'].' '.$user['account_firstname'],
- 'selected' => $sel_user
- );
- }
- }
-
- $user_count= count($user_list);
- for ($i=0;$i<$user_count;$i++)
- {
- if ($user_list[$i]['selected'] != 'selected')
- {
- unset($user_list[$i]['selected']);
- }
- }
-
-//_debug_array($user_list);
- return $user_list;
- }
-
- function get_group_list($format='',$selected='',$start='',
$sort='', $order='', $query='',$offset='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('group_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('group_filter'));
- break;
- }
-
- $accounts = CreateObject('phpgwapi.accounts');
- $users = $accounts->get_list('groups', $start, $sort,
$order, $query,$offset);
- unset($accounts);
- if (isSet($users) AND is_array($users))
- {
- foreach($users as $user)
- {
- $sel_user = '';
- if ($user['account_id']==$selected)
- {
- $sel_user = 'selected';
- }
-
- $user_list[] = array
- (
- 'id' => $user['account_id'],
- 'name' =>
$user['account_firstname'],
- 'selected' => $sel_user
- );
- }
- }
-
- $user_count= count($user_list);
- for ($i=0;$i<$user_count;$i++)
- {
- if ($user_list[$i]['selected'] != 'selected')
- {
- unset($user_list[$i]['selected']);
- }
- }
-
-//_debug_array($user_list);
- return $user_list;
- }
-
-
- function
get_user_list_right($right='',$selected='',$acl_location='')
- {
-
$employees=$this->socommon->get_user_list_right($right,$acl_location);
- while (is_array($employees) && list(,$user) =
each($employees))
- {
- $sel_user = '';
- if ($user['account_lid']==$selected)
- {
- $sel_user = 'selected';
- }
-
- $user_list[] = array
- (
- 'lid' =>
$user['account_lid'],
- 'firstname' =>
$user['account_firstname'],
- 'lastname' =>
$user['account_lastname'],
- 'selected' => $sel_user
- );
- }
-
- for ($i=0;$i<count($user_list);$i++)
- {
- if ($user_list[$i]['selected'] != 'selected')
- {
- unset($user_list[$i]['selected']);
- }
- }
-
- return $user_list;
- }
-
- function
get_user_list_right2($format='',$right='',$selected='',$acl_location='',$extra='',$default='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('user_id_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('user_id_filter'));
- break;
- }
-
- if(!$selected && $default)
- {
- $selected = $default;
- }
-
- if (isset($extra) AND is_array($extra))
- {
- foreach($extra as $extra_user)
- {
- $users_extra[]=array
- (
- 'account_id' => $extra_user,
- 'account_firstname' =>
lang($extra_user)
- );
- }
- }
-
-
-
$users=$this->socommon->get_user_list_right($right,$acl_location);
-
- if (is_array($users_extra) && is_array($users))
- {
- foreach($users as $users_entry)
- {
- array_push($users_extra,$users_entry);
- }
- $users=$users_extra;
- }
-
- while (is_array($users) && list(,$user) = each($users))
- {
- $sel_user = '';
- if ($user['account_id']==$selected)
- {
- $sel_user = 'selected';
- }
-
- $user_list[] = array
- (
- 'user_id' =>
$user['account_id'],
- 'name' =>
$user['account_lastname'].' '.$user['account_firstname'],
- 'selected' => $sel_user
- );
- }
-
- for ($i=0;$i<count($user_list);$i++)
- {
- if ($user_list[$i]['selected'] != 'selected')
- {
- unset($user_list[$i]['selected']);
- }
- }
-
- return $user_list;
- }
-
-
- function initiate_ui_vendorlookup($data)
- {
-//_debug_array($data);
-
- $contacts =
CreateObject($this->currentapp.'.soactor');
- $contacts->role='vendor';
-
- if($data['type']=='view')
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('vendor_view'));
- }
- else
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('vendor_form'));
- }
-
- $vendor['value_vendor_id']
= $data['vendor_id'];
- $vendor['value_vendor_name'] =
$data['vendor_name'];
-
- if($data['vendor_id'] && !$data['vendor_name'])
- {
- $vendor_data
= $contacts->read_single(array('actor_id'=>$data['vendor_id']));
- if(is_array($vendor_data))
- {
- foreach($vendor_data['attributes'] as
$attribute)
- {
-
if($attribute['name']=='org_name')
- {
-
$vendor['value_vendor_name']=$attribute['value'];
- break;
- }
- }
- }
- }
-
- $vendor['vendor_link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor');
- $vendor['lang_vendor']
= lang('Vendor');
- $vendor['lang_select_vendor_help'] =
lang('Klick this link to select vendor');
- $vendor['lang_vendor_name']
= lang('Vendor Name');
-
- unset($contacts);
-//_debug_array($vendor);
- return $vendor;
- }
-
-
- function initiate_ui_budget_account_lookup($data)
- {
- if($data['type']=='view')
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('b_account_view'));
- }
- else
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('b_account_form'));
- }
-
- $b_account['value_b_account_id']
= $data['b_account_id'];
- $b_account['value_b_account_name']
= $data['b_account_name'];
- $b_account['b_account_link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.b_account');
- $b_account['lang_b_account']
= lang('b_account');
- $b_account['lang_select_b_account_help'] =
lang('Klick this link to select budget account');
- $b_account['lang_b_account']
= lang('Budget account');
- if($data['b_account_id'] && !$data['b_account_name'])
- {
- $b_account_object =
CreateObject($this->currentapp.'.sob_account');
- $b_account_data =
$b_account_object->read_single($data['b_account_id']);
- $b_account['value_b_account_name'] =
$b_account_data['descr'];
- }
-
-//_debug_array($b_account);
- return $b_account;
- }
-
-
- function initiate_ui_alarm($data)
- {
- $boalarm =
CreateObject($this->currentapp.'.boalarm');
-
- if($data['type']=='view')
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('alarm_view'));
- }
- else
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('alarm_form'));
- }
-
- $alarm['header'][] = array
- (
- 'lang_time' => lang('Time'),
- 'lang_text' => lang('Text'),
- 'lang_user' => lang('User'),
- 'lang_enabled' => lang('Enabled'),
- 'lang_select' => lang('Select')
- );
-
- $alarm['values'] =
$boalarm->read_alarms($data['alarm_type'],$data['id'],$data['text']);
- if(!count($alarm['values'])>0)
- {
- unset($alarm['values']);
- }
-
- if($data['type']=='form')
- {
- $alarm['alter_alarm'][] = array
- (
- 'lang_enable' =>
lang('Enable'),
- 'lang_disable' =>
lang('Disable'),
- 'lang_delete' =>
lang('Delete')
- );
-
- for ($i=1; $i<=31; $i++)
- {
-
$alarm['add_alarm']['day_list'][($i-1)][id] = $i;
- }
- $alarm['add_alarm']['lang_day']
= lang('Day');
- $alarm['add_alarm']['lang_day_statustext']
= lang('Day');
-
- for ($i=1; $i<=24; $i++)
- {
-
$alarm['add_alarm']['hour_list'][($i-1)][id] = $i;
- }
- $alarm['add_alarm']['lang_hour']
= lang('Hour');
- $alarm['add_alarm']['lang_hour_statustext']
= lang('Hour');
-
- for ($i=1; $i<=60; $i++)
- {
-
$alarm['add_alarm']['minute_list'][($i-1)][id] = $i;
- }
- $alarm['add_alarm']['lang_minute']
= lang('Minutes before the event');
- $alarm['add_alarm']['lang_minute_statustext']
= lang('Minutes before the event');
-
- $alarm['add_alarm']['user_list'] =
$this->get_user_list_right2('select',4,False,$data['acl_location'],False,$default=$this->account);
-
- $alarm['add_alarm']['lang_user']
= lang('User');
- $alarm['add_alarm']['lang_user_statustext']
= lang('Select the user the alarm belongs to.');
- $alarm['add_alarm']['lang_no_user']
= lang('No user');
- $alarm['add_alarm']['lang_add']
= lang('Add');
- $alarm['add_alarm']['lang_add_alarm']
= lang('Add alarm');
- $alarm['add_alarm']['lang_add_statustext']
= lang('Add alarm for selected user');
-
- }
-
-//_debug_array($alarm['values']);
- return $alarm;
- }
-
-
- function
select_multi_list_2($selected='',$input_list,$input_type='')
- {
- $j=0;
- if (isset($input_list) AND is_array($input_list))
- {
- foreach($input_list as $entry)
- {
- $output_list[$j]['id'] = $entry['id'];
- $output_list[$j]['value'] =
$entry['value'];
- $output_list[$j]['input_type'] =
$input_type;
-
- for ($i=0;$i<count($selected);$i++)
- {
- if($selected[$i] ==
$entry['id'])
- {
-
$output_list[$j]['checked'] = 'checked';
- }
- }
- $j++;
- }
- }
-
- for ($i=0;$i<count($output_list);$i++)
- {
- if ($output_list[$i]['checked'] != 'checked')
- {
- unset($output_list[$i]['checked']);
- }
- }
-
- return $output_list;
- }
-
- function translate_datatype($datatype)
- {
- $datatype_text = array(
- 'V' => 'Varchar',
- 'I' => 'Integer',
- 'C' => 'char',
- 'N' => 'Float',
- 'D' => 'Date',
- 'T' => 'Memo',
- 'R' => 'Muliple radio',
- 'CH' => 'Muliple checkbox',
- 'LB' => 'Listbox',
- 'AB' => 'Contact',
- 'VENDOR' => 'Vendor',
- 'email' => 'Email'
- );
-
- $datatype = lang($datatype_text[$datatype]);
-
- return $datatype;
- }
-
- function translate_datatype_insert($datatype)
- {
- $datatype_text = array(
- 'V' => 'varchar',
- 'I' => 'int',
- 'C' => 'char',
- 'N' => 'decimal',
- 'D' => 'timestamp',
- 'T' => 'text',
- 'R' => 'int',
- 'CH' => 'text',
- 'LB' => 'int',
- 'AB' => 'int',
- 'VENDOR' => 'int',
- 'email' => 'varchar'
- );
-
- return $datatype_text[$datatype];
- }
-
- function translate_datatype_precision($datatype)
- {
- $datatype_precision = array(
- 'R' => 4,
- 'LB' => 4,
- 'AB' => 4,
- 'VENDOR' => 4,
- 'email' => 64
- );
-
- return $datatype_precision[$datatype];
- }
-
- function save_attributes($values_attribute,$type)
- {
-
- for ($i=0;$i<count($values_attribute);$i++)
- {
- if($values_attribute[$i]['datatype']=='CH' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
serialize($values_attribute[$i]['value']);
- }
- if($values_attribute[$i]['datatype']=='R' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
$values_attribute[$i]['value'][0];
- }
-
- if($values_attribute[$i]['datatype']=='N' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
str_replace(",",".",$values_attribute[$i]['value']);
- }
-
- if($values_attribute[$i]['datatype']=='D' &&
$values_attribute[$i]['value'])
- {
- $dateformat=
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $dateformat =
str_replace(".","",$dateformat);
- $dateformat =
str_replace("-","",$dateformat);
- $dateformat =
str_replace("/","",$dateformat);
- $y=strpos($dateformat,'Y');
- $d=strpos($dateformat,'d');
- $m=strpos($dateformat,'m');
-
- $dateparts = explode('/',
$values_attribute[$i]['value']);
- $day = $dateparts[$d];
- $month = $dateparts[$m];
- $year = $dateparts[$y];
- $values_attribute[$i]['value'] =
date($this->dateformat,mktime(2,0,0,$month,$day,$year));
- }
- }
-
-
$this->socommon->save_attributes($values_attribute,$type);
- }
-
- function list_methods($_type='xmlrpc')
- {
- /*
- This handles introspection or discovery by the logged
in client,
- in which case the input might be an array. The
server always calls
- this function to fill the server dispatch map using a
string.
- */
- if (is_array($_type))
- {
- $_type = $_type['type'] ? $_type['type'] :
$_type[0];
- }
- switch($_type)
- {
- case 'xmlrpc':
- $xml_functions = array(
- 'read' => array(
- 'function' => 'read',
- 'signature' =>
array(array(xmlrpcInt,xmlrpcStruct)),
- 'docstring' =>
lang('Read a single entry by passing the id and fieldlist.')
- ),
- 'save' => array(
- 'function' => 'save',
- 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
- 'docstring' =>
lang('Update a single entry by passing the fields.')
- ),
- 'delete' => array(
- 'function' => 'delete',
- 'signature' =>
array(array(xmlrpcBoolean,xmlrpcInt)),
- 'docstring' =>
lang('Delete a single entry by passing the id.')
- ),
- 'list' => array(
- 'function' => '_list',
- 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
- 'docstring' =>
lang('Read a list of entries.')
- ),
- 'list_methods' => array(
- 'function' =>
'list_methods',
- 'signature' =>
array(array(xmlrpcStruct,xmlrpcString)),
- 'docstring' =>
lang('Read this list of methods.')
- )
- );
- return $xml_functions;
- break;
- case 'soap':
- return $this->soap_functions;
- break;
- default:
- return array();
- break;
- }
- }
-
- function add_leading_zero($num)
- {
-
- if ($id_type == "hex")
- {
- $num = hexdec($num);
- $num++;
- $num = dechex($num);
- }
- else
- {
- $num++;
- }
-
- if (strlen($num) == 4)
- $return = $num;
- if (strlen($num) == 3)
- $return = "0$num";
- if (strlen($num) == 2)
- $return = "00$num";
- if (strlen($num) == 1)
- $return = "000$num";
- if (strlen($num) == 0)
- $return = "0001";
-
- return strtoupper($return);
- }
-
-
- function read_location_data($location_code)
- {
- $soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
-
- $location_types =
$soadmin_location->select_location_type();
- unset($soadmin_location);
-
- return
$this->socommon->read_location_data($location_code,$location_types);
- }
-
- function read_single_tenant($tenant_id)
- {
- return $this->socommon->read_single_tenant($tenant_id);
- }
-
- function check_location($location_code='',$type_id='')
- {
- return
$this->socommon->check_location($location_code,$type_id);
- }
-
- function generate_sql($data)
- {
-//_debug_array($data);
-
- $cols =
(isset($data['cols'])?$data['cols']:'');
- $entity_table =
(isset($data['entity_table'])?$data['entity_table']:'');
- $cols_return =
(isset($data['cols_return'])?$data['cols_return']:'');
- $uicols =
(isset($data['uicols'])?$data['uicols']:'');
- $joinmethod =
(isset($data['joinmethod'])?$data['joinmethod']:'');
- $paranthesis =
(isset($data['paranthesis'])?$data['paranthesis']:'');
- $lookup =
(isset($data['lookup'])?$data['lookup']:'');
- $location_level =
(isset($data['location_level'])?$data['location_level']:'');
- $no_address =
(isset($data['no_address'])?$data['no_address']:'');
-
- $this->join = $this->socommon->join;
-
- $joinmethod .= " $this->join fm_location1 ON
($entity_table.loc1 = fm_location1.loc1))";
- $paranthesis .='(';
- $joinmethod .= " $this->join fm_part_of_town ON
(fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id))";
- $paranthesis .='(';
- $joinmethod .= " $this->join fm_owner ON
(fm_location1.owner_id = fm_owner.id))";
- $paranthesis .='(';
-
- $soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
- $location_types =
$soadmin_location->select_location_type();
- $config = $soadmin_location->read_config('');
-
- if($location_level)
- {
- $type_id=$location_level;
- }
- else
- {
- $type_id = count($location_types);
- }
- $this->type_id = $type_id;
-
- for ($i=0; $i<$type_id; $i++)
- {
-
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'loc'
. $location_types[$i]['id'];
- $uicols['descr'][] =
$location_types[$i]['name'];
- $uicols['statustext'][] =
$location_types[$i]['descr'];
- }
-/*
- $fm_location_cols =
$soadmin_location->read_attrib(array('type_id'=>$type_id,'lookup_type'=>$type_id));
- $location_cols_count = count($fm_location_cols);
-
- for ($i=0;$i<$location_cols_count;$i++)
- {
- if($fm_location_cols[$i]['list']==1)
- {
- $cols_extra[]
= $fm_location_cols[$i]['column_name']; // only for lookup
- $cols_return[]
= $fm_location_cols[$i]['column_name'];
- $uicols['input_type'][] =
'text';
- $uicols['name'][]
= $fm_location_cols[$i]['column_name'];
- $uicols['descr'][]
= $fm_location_cols[$i]['input_text'];
- $uicols['statustext'][] =
$fm_location_cols[$i]['statustext'];
- }
- }
-
-*/
- unset($soadmin_location);
-
- for ($i=0; $i< $this->type_id; $i++)
- {
- $cols_return[] = 'loc' .
$location_types[$i]['id'];
- }
-
- if($lookup)
- {
- $cols_return[] =
'loc1_name';
- $cols_extra[] =
'loc1_name';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'loc1_name';
- $uicols['descr'][] =
lang('Property Name');
- $uicols['statustext'][] =
lang('Property Name');
-
- for ($i=2;$i<($type_id+1);$i++)
- {
- $cols_return_lookup[] = 'loc'
. $i . '_name';
- $uicols['input_type'][] =
'hidden';
- $uicols['name'][]
= 'loc' . $i . '_name';
- $uicols['descr'][]
= '';
- $uicols['statustext'][] = '';
- }
- }
-
- if(!$no_address)
- {
- $cols.= ",$entity_table.address";
- $cols_return[] =
'address';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'address';
- $uicols['descr'][] =
lang('address');
- $uicols['statustext'][] =
lang('address');
- }
-
-
- $config_count = count($config);
- for ($i=0;$i<$config_count;$i++)
- {
-
- if (($config[$i]['location_type'] <= $type_id)
&& ($config[$i]['query_value'] ==1))
- {
-
-
if($config[$i]['column_name']=='street_id')
- {
-
- $cols_return[]
= 'street_name';
- $uicols['input_type'][]
= 'hidden';
- $uicols['name'][]
= 'street_name';
- $uicols['descr'][]
= lang('street name');
- $uicols['statustext'][]
= lang('street name');
-
- $cols_return[]
= 'street_number';
- $uicols['input_type'][]
= 'hidden';
- $uicols['name'][]
= 'street_number';
- $uicols['descr'][]
= lang('street number');
- $uicols['statustext'][]
= lang('street number');
-
- $cols_return[]
= $config[$i]['column_name'];
- $uicols['input_type'][]
= 'hidden';
- $uicols['name'][]
= $config[$i]['column_name'];
- $uicols['descr'][]
= lang($config[$i]['input_text']);
- $uicols['statustext'][]
= lang($config[$i]['input_text']);
- if($lookup)
- {
- $cols_extra[]
= 'street_name';
- $cols_extra[]
= 'street_number';
- $cols_extra[]
= $config[$i]['column_name'];
- }
-
- }
- else
- {
- $cols_return[]
= $config[$i]['column_name'];
- $uicols['input_type'][]
= 'text';
- $uicols['name'][]
= $config[$i]['column_name'];
- $uicols['descr'][]
= $config[$i]['input_text'];
- $uicols['statustext'][]
= $config[$i]['input_text'];
-
- if($lookup)
- {
- $cols_extra[]
= $config[$i]['column_name'];
- }
- }
- }
- }
-
- $this->uicols = $uicols;
- $this->cols_return = $cols_return;
- $this->cols_extra = $cols_extra;
- $this->cols_return_lookup = $cols_return_lookup;
-
- $from .= " FROM $paranthesis $entity_table ";
-
- $sql = "SELECT $cols $from $joinmethod";
-
- return $sql;
-
- }
-
- function select_part_of_town($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('select_part_of_town'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_part_of_town'));
- break;
- }
-
- $parts= $this->socommon->select_part_of_town();
-
- while (is_array($parts) && list(,$part) = each($parts))
- {
- $sel_part = '';
- if ($part['id']==$selected)
- {
- $sel_part = 'selected';
- }
-
- $part_of_town_list[] = array
- (
- 'id' => $part['id'],
- 'name' => $part['name'],
- 'selected' => $sel_part
- );
- }
-
- for ($i=0;$i<count($part_of_town_list);$i++)
- {
- if ($part_of_town_list[$i]['selected'] !=
'selected')
- {
-
unset($part_of_town_list[$i]['selected']);
- }
- }
-
- return $part_of_town_list;
- }
-
- function select_category_property_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
- $categories=
$this->socommon->select_category_property_list();
-
- while (is_array($categories) && list(,$category) =
each($categories))
- {
- $sel_category = '';
- if ($category['id']==$selected)
- {
- $sel_category = 'selected';
- }
-
- $category_list[] = array
- (
- 'cat_id' => $category['id'],
- 'name' => $category['name'],
- 'selected' => $sel_category
- );
- }
-
- for ($i=0;$i<count($category_list);$i++)
- {
- if ($category_list[$i]['selected'] !=
'selected')
- {
- unset($category_list[$i]['selected']);
- }
- }
-
- return $category_list;
- }
-
- function select_district_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('select_district'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_district'));
- break;
- }
-
- $districts= $this->socommon->select_district_list();
-
- while (is_array($districts) && list(,$district) =
each($districts))
- {
- $sel_district = '';
- if ($district['id']==$selected)
- {
- $sel_district = 'selected';
- }
-
- $district_list[] = array
- (
- 'id' => $district['id'],
- 'name' => $district['name'],
- 'selected' => $sel_district
- );
- }
-
- for ($i=0;$i<count($district_list);$i++)
- {
- if ($district_list[$i]['selected'] !=
'selected')
- {
- unset($district_list[$i]['selected']);
- }
- }
-
- return $district_list;
- }
-
-
- function validate_db_insert($values)
- {
- foreach($values as $value)
- {
- if($value || $value === 0)
- {
- $insert_value[] = "'".$value."'";
- }
- else
- {
- $insert_value[] = 'NULL';
- }
- }
-
- $values = implode(",", $insert_value);
- return $values;
- }
-
- function validate_db_update($value_set)
- {
- while (is_array($value_set) && list($field,$value) =
each($value_set))
- {
- if($value || $value === 0)
- {
- $value_entry[]= "$field='$value'";
- }
- else
- {
- $value_entry[]= "$field=NULL";
- }
- }
-
- $value_set = implode(",", $value_entry);
- return $value_set;
- }
-
- function fm_cache($name='',$value='')
- {
- return $this->socommon->fm_cache($name,$value);
- }
-
- function next_id($table,$key='')
- {
- return $this->socommon->next_id($table,$key);
- }
-
- function select_datatype($selected='')
- {
- $datatypes[0]['id']= 'V';
- $datatypes[0]['name']= lang('varchar');
- $datatypes[1]['id']= 'C';
- $datatypes[1]['name']= lang('Character');
- $datatypes[2]['id']= 'I';
- $datatypes[2]['name']= lang('Integer');
- $datatypes[3]['id']= 'N';
- $datatypes[3]['name']= lang('Decimal');
- $datatypes[4]['id']= 'D';
- $datatypes[4]['name']= lang('Date');
- $datatypes[5]['id']= 'T';
- $datatypes[5]['name']= lang('Memo');
- $datatypes[6]['id']= 'R';
- $datatypes[6]['name']= lang('Multiple radio');
- $datatypes[7]['id']= 'CH';
- $datatypes[7]['name']= lang('Multiple Checkbox');
- $datatypes[8]['id']= 'LB';
- $datatypes[8]['name']= lang('ListBox');
- $datatypes[9]['id']= 'AB';
- $datatypes[9]['name']= lang('Contact');
- $datatypes[10]['id']= 'VENDOR';
- $datatypes[10]['name']= lang('Vendor');
- $datatypes[11]['id']= 'email';
- $datatypes[11]['name']= lang('Email');
-
- return $this->select_list($selected,$datatypes);
-
- }
-
- function select_nullable($selected='')
- {
- $nullable[0]['id']= 'True';
- $nullable[0]['name']= lang('True');
- $nullable[1]['id']= 'False';
- $nullable[1]['name']= lang('False');
-
- return $this->select_list($selected,$nullable);
- }
-
-
- function excel($list,$name,$descr,$input_type='')
- {
- $GLOBALS['phpgw_info']['flags'][noheader] = True;
- $GLOBALS['phpgw_info']['flags'][nofooter] = True;
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
-
- $filename=
$GLOBALS['phpgw_info']['user']['account_lid'].'.xls';
-
- $workbook =
CreateObject($this->currentapp.'.excel',"-");
- $browser = CreateObject('phpgwapi.browser');
-
$browser->content_header($filename,'application/vnd.ms-excel');
-
- $count_uicols_name=count($name);
-
- $worksheet1 =& $workbook->add_worksheet('First One');
-
- $j=0;
- if (isset($list) AND is_array($list))
- {
- foreach($list as $entry)
- {
- $m=0;
- for ($k=0;$k<$count_uicols_name;$k++)
- {
- if($input_type[$k]!='hidden')
- {
- $content[$j][$m]
= str_replace("\r\n"," ",$entry[$name[$k]]);
-
$worksheet1->write_string(0, $m, $descr[$k]);
- $m++;
- }
- }
- $j++;
- }
-
- foreach($content as $row)
- {
- $line++;
- for ($i=0; $i<count($row); $i++)
- {
-
$worksheet1->write($line,$i,$row[$i]);
- }
- }
- }
- $workbook->close();
-
- }
-
- function increment_id($name)
- {
- return $this->socommon->increment_id($name);
- }
-
- function get_origin_link($type)
- {
- if($type=='tts'):
- {
- $link = '.uitts.view';
- }
- elseif($type=='request'):
- {
- $link = '.uirequest.view';
- }
- elseif($type=='project'):
- {
- $link = '.uiproject.view';
- }
- elseif(substr($type,0,6)=='entity'):
- {
-
- $type = explode("_",$type);
- $entity_id = $type[1];
- $cat_id = $type[2];
- $link =
".uientity.view&entity_id=$entity_id&cat_id=$cat_id";
- }
- endif;
-
- return $link;
- }
-
- function select_wo_hours_category_list($selected='')
- {
- $category_list=
$this->socommon->select_wo_hours_category_list();
- if($selected)
- {
- $category_list =
$this->select_list($selected,$category_list);
- }
-
- return $category_list;
- }
-
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage core
+ * @version $Id: class.bocommon.inc.php,v 1.20 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class bocommon
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+ var $district_id;
+
+
+ var $public_functions = array
+ (
+ 'select_part_of_town' => True,
+ 'menu' => True,
+ );
+
+ var $soap_functions = array(
+ 'list' => array(
+ 'in' =>
array('int','int','struct','string','int'),
+ 'out' => array('array')
+ ),
+ 'read' => array(
+ 'in' => array('int','struct'),
+ 'out' => array('array')
+ ),
+ 'save' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ ),
+ 'delete' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ )
+ );
+
+ function bocommon()
+ {
+
+ $GLOBALS['phpgw_info']['flags']['currentapp'] =
'property';
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->socommon =
CreateObject($this->currentapp.'.socommon');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ if (!is_object($GLOBALS['phpgw']->asyncservice))
+ {
+ $GLOBALS['phpgw']->asyncservice =
CreateObject('phpgwapi.asyncservice');
+ }
+ $this->async = &$GLOBALS['phpgw']->asyncservice;
+
+ $this->join = $this->socommon->join;
+ $this->left_join = $this->socommon->left_join;
+ $this->like = $this->socommon->like;
+
+ switch($GLOBALS['phpgw_info']['server']['db_type'])
+ {
+ case 'mssql':
+ $this->dateformat = "M d
Y";
+ $this->datetimeformat = "M d Y g:iA";
+ break;
+ case 'mysql':
+ $this->dateformat =
"Y-m-d";
+ $this->datetimeformat = "Y-m-d G:i:s";
+ break;
+ case 'pgsql':
+ $this->dateformat =
"Y-m-d";
+ $this->datetimeformat = "Y-m-d G:i:s";
+// $this->dateformat = "F j,
Y";
+// $this->datetimeformat = "F j, Y g:iA";
+ break;
+ }
+
+ /* if
($GLOBALS['phpgw_info']['server']['db_type']=='mssql')
+ {
+ $this->dateformat = "M d Y";
+ $this->datetimeformat = "M d Y g:iA";
+ }
+ else
+ {
+ $this->dateformat = "Y-m-d";
+ $this->datetimeformat = "Y-m-d G:i:s";
+ }
+
+
+ if(!$GLOBALS['phpgw_info']['flags']['css'])
+ {
+ $GLOBALS['phpgw_info']['flags']['css'] .=
"-->\n</style>\n"
+ . '<link rel="stylesheet"
type="text/css" media="all" href="'
+ .
$GLOBALS['phpgw_info']['server']['webserver_url'].'/' . $this->currentapp .
'/templates/'
+ .
$GLOBALS['phpgw_info']['server']['template_set']
+ .
'/css/'.$GLOBALS['phpgw_info']['server']['template_set'].'.css"
title="'.$GLOBALS['phpgw_info']['server']['template_set'].'" />'
+ . "\n<style type=\"text/css\">\n<!--\n";
+ }
+*/
+ }
+
+ function jscalendar()
+ {
+ $phpgw_js_url =
$GLOBALS['phpgw_info']['server']['webserver_url'].'/phpgwapi/js';
+// $img =
$GLOBALS['phpgw']->common->get_image_path('phpgwapi','default').'/cal.png';
+ $img =
$GLOBALS['phpgw_info']['server']['webserver_url'] .
'/phpgwapi/templates/default/images/cal.png';
+
+// $img = $phpgw_js_url.'/jscalendar/img.gif';
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $jsDateFormat = str_replace(array('d', 'm', 'M', 'Y'),
array('%d', '%m', '%b', '%Y'), $dateformat);
+
+ $GLOBALS['phpgw_info']['flags']['java_script']
.='</script>
+ <link rel="stylesheet" type="text/css" media="all"
href="'.$phpgw_js_url.'/jscalendar/calendar-win2k-cold-1.css"
title="win2k-cold-1" >
+ <script type="text/javascript"
src="'.$phpgw_js_url.'/jscalendar/calendar.js"></script>
+ <script type="text/javascript"
src="'.$phpgw_js_url.'/jscalendar/calendar-setup.js"></script>
+ <script type="text/javascript"
src="'.$phpgw_js_url.'/jscalendar/lang/calendar-'.substr($GLOBALS['phpgw_info']['user']['preferences']['common']['lang'],0,2)
.'.js"></script>
+ ';
+
+
+// <script type="text/javascript"
src="'.ereg_replace('[?&]*click_history=[0-9a-f]*','',$GLOBALS['phpgw']->link('/phpgwapi/js/jscalendar/jscalendar-setup.php')).'"></script>
+
+ $cal_info=array(
+// 'stylesheet'
=> $phpgw_js_url.'/jscalendar/calendar-win2k-cold-1.css',
+// 'calendar_source'
=> $phpgw_js_url.'/jscalendar/calendar.js',
+// 'calendar_setup_source' =>
$phpgw_js_url.'/jscalendar/calendar-setup.js',
+// 'calendar_lang'
=>
$phpgw_js_url.'/jscalendar/lang/calendar-'.substr($GLOBALS['phpgw_info']['user']['preferences']['common']['lang'],0,2)
.'.js',
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'img'
=> $img,
+ );
+ return $cal_info;
+ }
+
+ function check_perms($rights, $required)
+ {
+ // return (!!($rights & $required) == True);
+ return ($rights & $required);
+ }
+
+ function create_preferences($app='',$user_id='')
+ {
+ return
$this->socommon->create_preferences($app,$user_id);
+ }
+
+ function get_lookup_entity($location='')
+ {
+ return $this->socommon->get_lookup_entity($location);
+ }
+
+ function get_start_entity($location='')
+ {
+ return $this->socommon->get_start_entity($location);
+ }
+
+ function msgbox_data($receipt)
+ {
+ $msgbox_data_error=array();
+ if (isSet($receipt['error']) AND
is_array($receipt['error']))
+ {
+ foreach($receipt['error'] as $errors)
+ {
+ $msgbox_data_error +=
array($errors['msg']=> False);
+ }
+ }
+
+ $msgbox_data_message=array();
+
+ if (isSet($receipt['message']) AND
is_array($receipt['message']))
+ {
+ foreach($receipt['message'] as $messages)
+ {
+ $msgbox_data_message +=
array($messages['msg']=> True);
+ }
+ }
+
+ $msgbox_data = $msgbox_data_error +
$msgbox_data_message;
+
+ return $msgbox_data;
+ }
+
+ function moneyformat($amount)
+ {
+ if
($GLOBALS['phpgw_info']['server']['db_type']=='mssql')
+ {
+ $moneyformat =
"CONVERT(MONEY,"."'$amount'".",0)";
+ }
+ else
+ {
+ $moneyformat = "'" . $amount . "'";
+ }
+
+ return $moneyformat;
+ }
+
+
+ function date_array($date)
+ {
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $dateformat = str_replace(".","",$dateformat);
+ $dateformat = str_replace("-","",$dateformat);
+ $dateformat = str_replace("/","",$dateformat);
+ $y=strpos($dateformat,'y');
+ $d=strpos($dateformat,'d');
+ $m=strpos($dateformat,'m');
+
+ $dateparts = explode('/', $date);
+ $date_array['day'] = $dateparts[$d];
+ $date_array['month'] = $dateparts[$m];
+ $date_array['year'] = $dateparts[$y];
+
+ return $date_array;
+ }
+
+ function date_to_timestamp($date)
+ {
+ if($date)
+ {
+ $date_array = $this->date_array($date);
+ $date = mktime
(8,0,0,$date_array['month'],$date_array['day'],$date_array['year']);
+ }
+ return $date;
+ }
+
+
+ function
column_list($selected='',$entity_type='',$cat_id,$allrows='')
+ {
+ $bostandard_entity =
CreateObject($this->currentapp.'.bostandard_entity',True);
+
+ if(!$selected)
+ {
+
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp][$entity_type.'_columns_'.$cat_id];
+ }
+
+ $columns =
$bostandard_entity->read_attrib($entity_type,$cat_id,$allrows);
+//_debug_array($columns);
+
+
$column_list=$this->select_multi_list($selected,$columns);
+
+ return $column_list;
+
+ }
+
+ function select_multi_list($selected='',$input_list)
+ {
+ $j=0;
+ if (isset($input_list) AND is_array($input_list))
+ {
+ foreach($input_list as $entry)
+ {
+ $output_list[$j]['id'] = $entry['id'];
+ $output_list[$j]['name'] =
$entry['name'];
+
+ for ($i=0;$i<count($selected);$i++)
+ {
+ if($selected[$i] ==
$entry['id'])
+ {
+
$output_list[$j]['selected'] = 'selected';
+ }
+ }
+ $j++;
+ }
+ }
+
+ for ($i=0;$i<count($output_list);$i++)
+ {
+ if ($output_list[$i]['selected'] != 'selected')
+ {
+ unset($output_list[$i]['selected']);
+ }
+ }
+
+ return $output_list;
+ }
+
+
+
+ function select_list($selected='',$input_list='')
+ {
+ if (isset($input_list) AND is_array($input_list))
+ {
+ foreach($input_list as $entry)
+ {
+ $sel_entry = '';
+ if ($entry['id']==$selected)
+ {
+ $sel_entry = 'selected';
+ }
+ $entry_list[] = array
+ (
+ 'id' => $entry['id'],
+ 'name' =>
$entry['name'],
+ 'selected' => $sel_entry
+ );
+ }
+ for ($i=0;$i<count($entry_list);$i++)
+ {
+ if ($entry_list[$i]['selected'] !=
'selected')
+ {
+
unset($entry_list[$i]['selected']);
+ }
+ }
+ }
+ return $entry_list;
+ }
+
+
+ function
get_user_list($format='',$selected='',$extra='',$default='',$start='',
$sort='', $order='', $query='',$offset='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('user_id_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('user_id_filter'));
+ break;
+ }
+
+ if(!$selected && $default)
+ {
+ $selected = $default;
+ }
+
+ if (is_array($extra))
+ {
+ foreach($extra as $extra_user)
+ {
+ $users_extra[]=array
+ (
+ 'account_id' => $extra_user,
+ 'account_firstname' =>
lang($extra_user)
+ );
+ }
+ }
+
+ $accounts = CreateObject('phpgwapi.accounts');
+ $users = $accounts->get_list('accounts', $start, $sort,
$order, $query,$offset);
+ unset($accounts);
+ if (is_array($users_extra) && is_array($users))
+ {
+ $users = $users_extra + $users;
+ }
+
+ if (isSet($users) AND is_array($users))
+ {
+ foreach($users as $user)
+ {
+ $sel_user = '';
+ if ($user['account_id']==$selected)
+ {
+ $sel_user = 'selected';
+ }
+
+ $user_list[] = array
+ (
+ 'user_id' =>
$user['account_id'],
+ 'name' =>
$user['account_lastname'].' '.$user['account_firstname'],
+ 'selected' => $sel_user
+ );
+ }
+ }
+
+ $user_count= count($user_list);
+ for ($i=0;$i<$user_count;$i++)
+ {
+ if ($user_list[$i]['selected'] != 'selected')
+ {
+ unset($user_list[$i]['selected']);
+ }
+ }
+
+//_debug_array($user_list);
+ return $user_list;
+ }
+
+ function get_group_list($format='',$selected='',$start='',
$sort='', $order='', $query='',$offset='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('group_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('group_filter'));
+ break;
+ }
+
+ $accounts = CreateObject('phpgwapi.accounts');
+ $users = $accounts->get_list('groups', $start, $sort,
$order, $query,$offset);
+ unset($accounts);
+ if (isSet($users) AND is_array($users))
+ {
+ foreach($users as $user)
+ {
+ $sel_user = '';
+ if ($user['account_id']==$selected)
+ {
+ $sel_user = 'selected';
+ }
+
+ $user_list[] = array
+ (
+ 'id' => $user['account_id'],
+ 'name' =>
$user['account_firstname'],
+ 'selected' => $sel_user
+ );
+ }
+ }
+
+ $user_count= count($user_list);
+ for ($i=0;$i<$user_count;$i++)
+ {
+ if ($user_list[$i]['selected'] != 'selected')
+ {
+ unset($user_list[$i]['selected']);
+ }
+ }
+
+//_debug_array($user_list);
+ return $user_list;
+ }
+
+
+ function
get_user_list_right($right='',$selected='',$acl_location='')
+ {
+
$employees=$this->socommon->get_user_list_right($right,$acl_location);
+ while (is_array($employees) && list(,$user) =
each($employees))
+ {
+ $sel_user = '';
+ if ($user['account_lid']==$selected)
+ {
+ $sel_user = 'selected';
+ }
+
+ $user_list[] = array
+ (
+ 'lid' =>
$user['account_lid'],
+ 'firstname' =>
$user['account_firstname'],
+ 'lastname' =>
$user['account_lastname'],
+ 'selected' => $sel_user
+ );
+ }
+
+ for ($i=0;$i<count($user_list);$i++)
+ {
+ if ($user_list[$i]['selected'] != 'selected')
+ {
+ unset($user_list[$i]['selected']);
+ }
+ }
+
+ return $user_list;
+ }
+
+ function
get_user_list_right2($format='',$right='',$selected='',$acl_location='',$extra='',$default='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('user_id_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('user_id_filter'));
+ break;
+ }
+
+ if(!$selected && $default)
+ {
+ $selected = $default;
+ }
+
+ if (isset($extra) AND is_array($extra))
+ {
+ foreach($extra as $extra_user)
+ {
+ $users_extra[]=array
+ (
+ 'account_id' => $extra_user,
+ 'account_firstname' =>
lang($extra_user)
+ );
+ }
+ }
+
+
$users=$this->socommon->get_user_list_right($right,$acl_location);
+
+ if (is_array($users_extra) && is_array($users))
+ {
+ foreach($users as $users_entry)
+ {
+ array_push($users_extra,$users_entry);
+ }
+ $users=$users_extra;
+ }
+
+ while (is_array($users) && list(,$user) = each($users))
+ {
+ $sel_user = '';
+ if ($user['account_id']==$selected)
+ {
+ $sel_user = 'selected';
+ }
+
+ $user_list[] = array
+ (
+ 'user_id' =>
$user['account_id'],
+ 'name' =>
$user['account_lastname'].' '.$user['account_firstname'],
+ 'selected' => $sel_user
+ );
+ }
+
+ for ($i=0;$i<count($user_list);$i++)
+ {
+ if ($user_list[$i]['selected'] != 'selected')
+ {
+ unset($user_list[$i]['selected']);
+ }
+ }
+
+ return $user_list;
+ }
+
+
+ function initiate_ui_vendorlookup($data)
+ {
+//_debug_array($data);
+
+ $contacts =
CreateObject($this->currentapp.'.soactor');
+ $contacts->role='vendor';
+
+ if($data['type']=='view')
+ {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('vendor_view'));
+ }
+ else
+ {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('vendor_form'));
+ }
+
+ $vendor['value_vendor_id']
= $data['vendor_id'];
+ $vendor['value_vendor_name'] =
$data['vendor_name'];
+
+ if($data['vendor_id'] && !$data['vendor_name'])
+ {
+ $vendor_data
= $contacts->read_single(array('actor_id'=>$data['vendor_id']));
+ if(is_array($vendor_data))
+ {
+ foreach($vendor_data['attributes'] as
$attribute)
+ {
+
if($attribute['name']=='org_name')
+ {
+
$vendor['value_vendor_name']=$attribute['value'];
+ break;
+ }
+ }
+ }
+ }
+
+ $vendor['vendor_link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor');
+ $vendor['lang_vendor']
= lang('Vendor');
+ $vendor['lang_select_vendor_help'] =
lang('Klick this link to select vendor');
+ $vendor['lang_vendor_name']
= lang('Vendor Name');
+
+ unset($contacts);
+//_debug_array($vendor);
+ return $vendor;
+ }
+
+
+ function initiate_ui_budget_account_lookup($data)
+ {
+ if($data['type']=='view')
+ {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('b_account_view'));
+ }
+ else
+ {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('b_account_form'));
+ }
+
+ $b_account['value_b_account_id']
= $data['b_account_id'];
+ $b_account['value_b_account_name']
= $data['b_account_name'];
+ $b_account['b_account_link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.b_account');
+ $b_account['lang_b_account']
= lang('b_account');
+ $b_account['lang_select_b_account_help'] =
lang('Klick this link to select budget account');
+ $b_account['lang_b_account']
= lang('Budget account');
+ if($data['b_account_id'] && !$data['b_account_name'])
+ {
+ $b_account_object =
CreateObject($this->currentapp.'.sob_account');
+ $b_account_data =
$b_account_object->read_single($data['b_account_id']);
+ $b_account['value_b_account_name'] =
$b_account_data['descr'];
+ }
+
+//_debug_array($b_account);
+ return $b_account;
+ }
+
+
+ function initiate_ui_alarm($data)
+ {
+ $boalarm =
CreateObject($this->currentapp.'.boalarm');
+
+ if($data['type']=='view')
+ {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('alarm_view'));
+ }
+ else
+ {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('alarm_form'));
+ }
+
+ $alarm['header'][] = array
+ (
+ 'lang_time' => lang('Time'),
+ 'lang_text' => lang('Text'),
+ 'lang_user' => lang('User'),
+ 'lang_enabled' => lang('Enabled'),
+ 'lang_select' => lang('Select')
+ );
+
+ $alarm['values'] =
$boalarm->read_alarms($data['alarm_type'],$data['id'],$data['text']);
+ if(!count($alarm['values'])>0)
+ {
+ unset($alarm['values']);
+ }
+
+ if($data['type']=='form')
+ {
+ $alarm['alter_alarm'][] = array
+ (
+ 'lang_enable' =>
lang('Enable'),
+ 'lang_disable' =>
lang('Disable'),
+ 'lang_delete' =>
lang('Delete')
+ );
+
+ for ($i=1; $i<=31; $i++)
+ {
+
$alarm['add_alarm']['day_list'][($i-1)][id] = $i;
+ }
+ $alarm['add_alarm']['lang_day']
= lang('Day');
+ $alarm['add_alarm']['lang_day_statustext']
= lang('Day');
+
+ for ($i=1; $i<=24; $i++)
+ {
+
$alarm['add_alarm']['hour_list'][($i-1)][id] = $i;
+ }
+ $alarm['add_alarm']['lang_hour']
= lang('Hour');
+ $alarm['add_alarm']['lang_hour_statustext']
= lang('Hour');
+
+ for ($i=1; $i<=60; $i++)
+ {
+
$alarm['add_alarm']['minute_list'][($i-1)][id] = $i;
+ }
+ $alarm['add_alarm']['lang_minute']
= lang('Minutes before the event');
+ $alarm['add_alarm']['lang_minute_statustext']
= lang('Minutes before the event');
+
+ $alarm['add_alarm']['user_list'] =
$this->get_user_list_right2('select',4,False,$data['acl_location'],False,$default=$this->account);
+
+ $alarm['add_alarm']['lang_user']
= lang('User');
+ $alarm['add_alarm']['lang_user_statustext']
= lang('Select the user the alarm belongs to.');
+ $alarm['add_alarm']['lang_no_user']
= lang('No user');
+ $alarm['add_alarm']['lang_add']
= lang('Add');
+ $alarm['add_alarm']['lang_add_alarm']
= lang('Add alarm');
+ $alarm['add_alarm']['lang_add_statustext']
= lang('Add alarm for selected user');
+
+ }
+
+//_debug_array($alarm['values']);
+ return $alarm;
+ }
+
+
+ function
select_multi_list_2($selected='',$input_list,$input_type='')
+ {
+ $j=0;
+ if (isset($input_list) AND is_array($input_list))
+ {
+ foreach($input_list as $entry)
+ {
+ $output_list[$j]['id'] = $entry['id'];
+ $output_list[$j]['value'] =
$entry['value'];
+ $output_list[$j]['input_type'] =
$input_type;
+
+ for ($i=0;$i<count($selected);$i++)
+ {
+ if($selected[$i] ==
$entry['id'])
+ {
+
$output_list[$j]['checked'] = 'checked';
+ }
+ }
+ $j++;
+ }
+ }
+
+ for ($i=0;$i<count($output_list);$i++)
+ {
+ if ($output_list[$i]['checked'] != 'checked')
+ {
+ unset($output_list[$i]['checked']);
+ }
+ }
+
+ return $output_list;
+ }
+
+ function translate_datatype($datatype)
+ {
+ $datatype_text = array(
+ 'V' => 'Varchar',
+ 'I' => 'Integer',
+ 'C' => 'char',
+ 'N' => 'Float',
+ 'D' => 'Date',
+ 'T' => 'Memo',
+ 'R' => 'Muliple radio',
+ 'CH' => 'Muliple checkbox',
+ 'LB' => 'Listbox',
+ 'AB' => 'Contact',
+ 'VENDOR' => 'Vendor',
+ 'email' => 'Email'
+ );
+
+ $datatype = lang($datatype_text[$datatype]);
+
+ return $datatype;
+ }
+
+ function translate_datatype_insert($datatype)
+ {
+ $datatype_text = array(
+ 'V' => 'varchar',
+ 'I' => 'int',
+ 'C' => 'char',
+ 'N' => 'decimal',
+ 'D' => 'timestamp',
+ 'T' => 'text',
+ 'R' => 'int',
+ 'CH' => 'text',
+ 'LB' => 'int',
+ 'AB' => 'int',
+ 'VENDOR' => 'int',
+ 'email' => 'varchar'
+ );
+
+ return $datatype_text[$datatype];
+ }
+
+ function translate_datatype_precision($datatype)
+ {
+ $datatype_precision = array(
+ 'R' => 4,
+ 'LB' => 4,
+ 'AB' => 4,
+ 'VENDOR' => 4,
+ 'email' => 64
+ );
+
+ return $datatype_precision[$datatype];
+ }
+
+ function save_attributes($values_attribute,$type)
+ {
+
+ for ($i=0;$i<count($values_attribute);$i++)
+ {
+ if($values_attribute[$i]['datatype']=='CH' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
serialize($values_attribute[$i]['value']);
+ }
+ if($values_attribute[$i]['datatype']=='R' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
$values_attribute[$i]['value'][0];
+ }
+
+ if($values_attribute[$i]['datatype']=='N' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
str_replace(",",".",$values_attribute[$i]['value']);
+ }
+
+ if($values_attribute[$i]['datatype']=='D' &&
$values_attribute[$i]['value'])
+ {
+ $dateformat=
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $dateformat =
str_replace(".","",$dateformat);
+ $dateformat =
str_replace("-","",$dateformat);
+ $dateformat =
str_replace("/","",$dateformat);
+ $y=strpos($dateformat,'Y');
+ $d=strpos($dateformat,'d');
+ $m=strpos($dateformat,'m');
+
+ $dateparts = explode('/',
$values_attribute[$i]['value']);
+ $day = $dateparts[$d];
+ $month = $dateparts[$m];
+ $year = $dateparts[$y];
+ $values_attribute[$i]['value'] =
date($this->dateformat,mktime(2,0,0,$month,$day,$year));
+ }
+ }
+
+
$this->socommon->save_attributes($values_attribute,$type);
+ }
+
+ function list_methods($_type='xmlrpc')
+ {
+ /*
+ This handles introspection or discovery by the logged
in client,
+ in which case the input might be an array. The
server always calls
+ this function to fill the server dispatch map using a
string.
+ */
+ if (is_array($_type))
+ {
+ $_type = $_type['type'] ? $_type['type'] :
$_type[0];
+ }
+ switch($_type)
+ {
+ case 'xmlrpc':
+ $xml_functions = array(
+ 'read' => array(
+ 'function' => 'read',
+ 'signature' =>
array(array(xmlrpcInt,xmlrpcStruct)),
+ 'docstring' =>
lang('Read a single entry by passing the id and fieldlist.')
+ ),
+ 'save' => array(
+ 'function' => 'save',
+ 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
+ 'docstring' =>
lang('Update a single entry by passing the fields.')
+ ),
+ 'delete' => array(
+ 'function' => 'delete',
+ 'signature' =>
array(array(xmlrpcBoolean,xmlrpcInt)),
+ 'docstring' =>
lang('Delete a single entry by passing the id.')
+ ),
+ 'list' => array(
+ 'function' => '_list',
+ 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
+ 'docstring' =>
lang('Read a list of entries.')
+ ),
+ 'list_methods' => array(
+ 'function' =>
'list_methods',
+ 'signature' =>
array(array(xmlrpcStruct,xmlrpcString)),
+ 'docstring' =>
lang('Read this list of methods.')
+ )
+ );
+ return $xml_functions;
+ break;
+ case 'soap':
+ return $this->soap_functions;
+ break;
+ default:
+ return array();
+ break;
+ }
+ }
+
+ function add_leading_zero($num)
+ {
+
+ if ($id_type == "hex")
+ {
+ $num = hexdec($num);
+ $num++;
+ $num = dechex($num);
+ }
+ else
+ {
+ $num++;
+ }
+
+ if (strlen($num) == 4)
+ $return = $num;
+ if (strlen($num) == 3)
+ $return = "0$num";
+ if (strlen($num) == 2)
+ $return = "00$num";
+ if (strlen($num) == 1)
+ $return = "000$num";
+ if (strlen($num) == 0)
+ $return = "0001";
+
+ return strtoupper($return);
+ }
+
+
+ function read_location_data($location_code)
+ {
+ $soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
+
+ $location_types =
$soadmin_location->select_location_type();
+ unset($soadmin_location);
+
+ return
$this->socommon->read_location_data($location_code,$location_types);
+ }
+
+ function read_single_tenant($tenant_id)
+ {
+ return $this->socommon->read_single_tenant($tenant_id);
+ }
+
+ function check_location($location_code='',$type_id='')
+ {
+ return
$this->socommon->check_location($location_code,$type_id);
+ }
+
+ function generate_sql($data)
+ {
+//_debug_array($data);
+
+ $cols =
(isset($data['cols'])?$data['cols']:'');
+ $entity_table =
(isset($data['entity_table'])?$data['entity_table']:'');
+ $cols_return =
(isset($data['cols_return'])?$data['cols_return']:'');
+ $uicols =
(isset($data['uicols'])?$data['uicols']:'');
+ $joinmethod =
(isset($data['joinmethod'])?$data['joinmethod']:'');
+ $paranthesis =
(isset($data['paranthesis'])?$data['paranthesis']:'');
+ $lookup =
(isset($data['lookup'])?$data['lookup']:'');
+ $location_level =
(isset($data['location_level'])?$data['location_level']:'');
+ $no_address =
(isset($data['no_address'])?$data['no_address']:'');
+
+ $this->join = $this->socommon->join;
+
+ $joinmethod .= " $this->join fm_location1 ON
($entity_table.loc1 = fm_location1.loc1))";
+ $paranthesis .='(';
+ $joinmethod .= " $this->join fm_part_of_town ON
(fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id))";
+ $paranthesis .='(';
+ $joinmethod .= " $this->join fm_owner ON
(fm_location1.owner_id = fm_owner.id))";
+ $paranthesis .='(';
+
+ $soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
+ $location_types =
$soadmin_location->select_location_type();
+ $config = $soadmin_location->read_config('');
+
+ if($location_level)
+ {
+ $type_id=$location_level;
+ }
+ else
+ {
+ $type_id = count($location_types);
+ }
+ $this->type_id = $type_id;
+
+ for ($i=0; $i<$type_id; $i++)
+ {
+
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'loc'
. $location_types[$i]['id'];
+ $uicols['descr'][] =
$location_types[$i]['name'];
+ $uicols['statustext'][] =
$location_types[$i]['descr'];
+ }
+/*
+ $fm_location_cols =
$soadmin_location->read_attrib(array('type_id'=>$type_id,'lookup_type'=>$type_id));
+ $location_cols_count = count($fm_location_cols);
+
+ for ($i=0;$i<$location_cols_count;$i++)
+ {
+ if($fm_location_cols[$i]['list']==1)
+ {
+ $cols_extra[]
= $fm_location_cols[$i]['column_name']; // only for lookup
+ $cols_return[]
= $fm_location_cols[$i]['column_name'];
+ $uicols['input_type'][] =
'text';
+ $uicols['name'][]
= $fm_location_cols[$i]['column_name'];
+ $uicols['descr'][]
= $fm_location_cols[$i]['input_text'];
+ $uicols['statustext'][] =
$fm_location_cols[$i]['statustext'];
+ }
+ }
+
+*/
+ unset($soadmin_location);
+
+ for ($i=0; $i< $this->type_id; $i++)
+ {
+ $cols_return[] = 'loc' .
$location_types[$i]['id'];
+ }
+
+ if($lookup)
+ {
+ $cols_return[] =
'loc1_name';
+ $cols_extra[] =
'loc1_name';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'loc1_name';
+ $uicols['descr'][] =
lang('Property Name');
+ $uicols['statustext'][] =
lang('Property Name');
+
+ for ($i=2;$i<($type_id+1);$i++)
+ {
+ $cols_return_lookup[] = 'loc'
. $i . '_name';
+ $uicols['input_type'][] =
'hidden';
+ $uicols['name'][]
= 'loc' . $i . '_name';
+ $uicols['descr'][]
= '';
+ $uicols['statustext'][] = '';
+ }
+ }
+
+ if(!$no_address)
+ {
+ $cols.= ",$entity_table.address";
+ $cols_return[] =
'address';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'address';
+ $uicols['descr'][] =
lang('address');
+ $uicols['statustext'][] =
lang('address');
+ }
+
+
+ $config_count = count($config);
+ for ($i=0;$i<$config_count;$i++)
+ {
+
+ if (($config[$i]['location_type'] <= $type_id)
&& ($config[$i]['query_value'] ==1))
+ {
+
+
if($config[$i]['column_name']=='street_id')
+ {
+
+ $cols_return[]
= 'street_name';
+ $uicols['input_type'][]
= 'hidden';
+ $uicols['name'][]
= 'street_name';
+ $uicols['descr'][]
= lang('street name');
+ $uicols['statustext'][]
= lang('street name');
+
+ $cols_return[]
= 'street_number';
+ $uicols['input_type'][]
= 'hidden';
+ $uicols['name'][]
= 'street_number';
+ $uicols['descr'][]
= lang('street number');
+ $uicols['statustext'][]
= lang('street number');
+
+ $cols_return[]
= $config[$i]['column_name'];
+ $uicols['input_type'][]
= 'hidden';
+ $uicols['name'][]
= $config[$i]['column_name'];
+ $uicols['descr'][]
= lang($config[$i]['input_text']);
+ $uicols['statustext'][]
= lang($config[$i]['input_text']);
+ if($lookup)
+ {
+ $cols_extra[]
= 'street_name';
+ $cols_extra[]
= 'street_number';
+ $cols_extra[]
= $config[$i]['column_name'];
+ }
+
+ }
+ else
+ {
+ $cols_return[]
= $config[$i]['column_name'];
+ $uicols['input_type'][]
= 'text';
+ $uicols['name'][]
= $config[$i]['column_name'];
+ $uicols['descr'][]
= $config[$i]['input_text'];
+ $uicols['statustext'][]
= $config[$i]['input_text'];
+
+ if($lookup)
+ {
+ $cols_extra[]
= $config[$i]['column_name'];
+ }
+ }
+ }
+ }
+
+ $this->uicols = $uicols;
+ $this->cols_return = $cols_return;
+ $this->cols_extra = $cols_extra;
+ $this->cols_return_lookup = $cols_return_lookup;
+
+ $from .= " FROM $paranthesis $entity_table ";
+
+ $sql = "SELECT $cols $from $joinmethod";
+
+ return $sql;
+
+ }
+
+ function select_part_of_town($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('select_part_of_town'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_part_of_town'));
+ break;
+ }
+
+ $parts= $this->socommon->select_part_of_town();
+
+ while (is_array($parts) && list(,$part) = each($parts))
+ {
+ $sel_part = '';
+ if ($part['id']==$selected)
+ {
+ $sel_part = 'selected';
+ }
+
+ $part_of_town_list[] = array
+ (
+ 'id' => $part['id'],
+ 'name' => $part['name'],
+ 'selected' => $sel_part
+ );
+ }
+
+ for ($i=0;$i<count($part_of_town_list);$i++)
+ {
+ if ($part_of_town_list[$i]['selected'] !=
'selected')
+ {
+
unset($part_of_town_list[$i]['selected']);
+ }
+ }
+
+ return $part_of_town_list;
+ }
+
+ function select_category_property_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ break;
+ }
+
+ $categories=
$this->socommon->select_category_property_list();
+
+ while (is_array($categories) && list(,$category) =
each($categories))
+ {
+ $sel_category = '';
+ if ($category['id']==$selected)
+ {
+ $sel_category = 'selected';
+ }
+
+ $category_list[] = array
+ (
+ 'cat_id' => $category['id'],
+ 'name' => $category['name'],
+ 'selected' => $sel_category
+ );
+ }
+
+ for ($i=0;$i<count($category_list);$i++)
+ {
+ if ($category_list[$i]['selected'] !=
'selected')
+ {
+ unset($category_list[$i]['selected']);
+ }
+ }
+
+ return $category_list;
+ }
+
+ function select_district_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('select_district'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_district'));
+ break;
+ }
+
+ $districts= $this->socommon->select_district_list();
+
+ while (is_array($districts) && list(,$district) =
each($districts))
+ {
+ $sel_district = '';
+ if ($district['id']==$selected)
+ {
+ $sel_district = 'selected';
+ }
+
+ $district_list[] = array
+ (
+ 'id' => $district['id'],
+ 'name' => $district['name'],
+ 'selected' => $sel_district
+ );
+ }
+
+ for ($i=0;$i<count($district_list);$i++)
+ {
+ if ($district_list[$i]['selected'] !=
'selected')
+ {
+ unset($district_list[$i]['selected']);
+ }
+ }
+
+ return $district_list;
+ }
+
+
+ function validate_db_insert($values)
+ {
+ foreach($values as $value)
+ {
+ if($value || $value === 0)
+ {
+ $insert_value[] = "'".$value."'";
+ }
+ else
+ {
+ $insert_value[] = 'NULL';
+ }
+ }
+
+ $values = implode(",", $insert_value);
+ return $values;
+ }
+
+ function validate_db_update($value_set)
+ {
+ while (is_array($value_set) && list($field,$value) =
each($value_set))
+ {
+ if($value || $value === 0)
+ {
+ $value_entry[]= "$field='$value'";
+ }
+ else
+ {
+ $value_entry[]= "$field=NULL";
+ }
+ }
+
+ $value_set = implode(",", $value_entry);
+ return $value_set;
+ }
+
+ function fm_cache($name='',$value='')
+ {
+ return $this->socommon->fm_cache($name,$value);
+ }
+
+ function next_id($table,$key='')
+ {
+ return $this->socommon->next_id($table,$key);
+ }
+
+ function select_datatype($selected='')
+ {
+ $datatypes[0]['id']= 'V';
+ $datatypes[0]['name']= lang('varchar');
+ $datatypes[1]['id']= 'C';
+ $datatypes[1]['name']= lang('Character');
+ $datatypes[2]['id']= 'I';
+ $datatypes[2]['name']= lang('Integer');
+ $datatypes[3]['id']= 'N';
+ $datatypes[3]['name']= lang('Decimal');
+ $datatypes[4]['id']= 'D';
+ $datatypes[4]['name']= lang('Date');
+ $datatypes[5]['id']= 'T';
+ $datatypes[5]['name']= lang('Memo');
+ $datatypes[6]['id']= 'R';
+ $datatypes[6]['name']= lang('Multiple radio');
+ $datatypes[7]['id']= 'CH';
+ $datatypes[7]['name']= lang('Multiple Checkbox');
+ $datatypes[8]['id']= 'LB';
+ $datatypes[8]['name']= lang('ListBox');
+ $datatypes[9]['id']= 'AB';
+ $datatypes[9]['name']= lang('Contact');
+ $datatypes[10]['id']= 'VENDOR';
+ $datatypes[10]['name']= lang('Vendor');
+ $datatypes[11]['id']= 'email';
+ $datatypes[11]['name']= lang('Email');
+
+ return $this->select_list($selected,$datatypes);
+
+ }
+
+ function select_nullable($selected='')
+ {
+ $nullable[0]['id']= 'True';
+ $nullable[0]['name']= lang('True');
+ $nullable[1]['id']= 'False';
+ $nullable[1]['name']= lang('False');
+
+ return $this->select_list($selected,$nullable);
+ }
+
+
+ function excel($list,$name,$descr,$input_type='')
+ {
+ $GLOBALS['phpgw_info']['flags'][noheader] = True;
+ $GLOBALS['phpgw_info']['flags'][nofooter] = True;
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
+
+ $filename=
$GLOBALS['phpgw_info']['user']['account_lid'].'.xls';
+
+ $workbook =
CreateObject($this->currentapp.'.excel',"-");
+ $browser = CreateObject('phpgwapi.browser');
+
$browser->content_header($filename,'application/vnd.ms-excel');
+
+ $count_uicols_name=count($name);
+
+ $worksheet1 =& $workbook->add_worksheet('First One');
+
+ $j=0;
+ if (isset($list) AND is_array($list))
+ {
+ foreach($list as $entry)
+ {
+ $m=0;
+ for ($k=0;$k<$count_uicols_name;$k++)
+ {
+ if($input_type[$k]!='hidden')
+ {
+ $content[$j][$m]
= str_replace("\r\n"," ",$entry[$name[$k]]);
+
$worksheet1->write_string(0, $m, $descr[$k]);
+ $m++;
+ }
+ }
+ $j++;
+ }
+
+ foreach($content as $row)
+ {
+ $line++;
+ for ($i=0; $i<count($row); $i++)
+ {
+
$worksheet1->write($line,$i,$row[$i]);
+ }
+ }
+ }
+ $workbook->close();
+
+ }
+
+ function increment_id($name)
+ {
+ return $this->socommon->increment_id($name);
+ }
+
+ function get_origin_link($type)
+ {
+ if($type=='tts'):
+ {
+ $link = '.uitts.view';
+ }
+ elseif($type=='request'):
+ {
+ $link = '.uirequest.view';
+ }
+ elseif($type=='project'):
+ {
+ $link = '.uiproject.view';
+ }
+ elseif(substr($type,0,6)=='entity'):
+ {
+
+ $type = explode("_",$type);
+ $entity_id = $type[1];
+ $cat_id = $type[2];
+ $link =
".uientity.view&entity_id=$entity_id&cat_id=$cat_id";
+ }
+ endif;
+
+ return $link;
+ }
+
+ function select_wo_hours_category_list($selected='')
+ {
+ $category_list=
$this->socommon->select_wo_hours_category_list();
+ if($selected)
+ {
+ $category_list =
$this->select_list($selected,$category_list);
+ }
+
+ return $category_list;
+ }
+
+ function new_db()
+ {
return $this->socommon->new_db();
+ }
+
+ }
+?>
Index: property/inc/class.bocustom.inc.php
diff -u property/inc/class.bocustom.inc.php:1.5
property/inc/class.bocustom.inc.php:1.6
--- property/inc/class.bocustom.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/class.bocustom.inc.php Fri Jan 27 14:05:43 2006
@@ -1,195 +1,195 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage custom
- * @version $Id: class.bocustom.inc.php,v 1.5 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class bocustom
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- function bocustom($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so = CreateObject($this->currentapp.'.socustom');
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $allrows =
get_var('allrows',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id) && !empty($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- else
- {
- unset($this->cat_id);
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
- }
-
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','custom',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','custom');
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- }
-
- function check_perms($has, $needed)
- {
- return (!!($has & $needed) == True);
- }
-
-
- function read()
- {
- $custom = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows));
- $this->total_records = $this->so->total_records;
-
- for ($i=0; $i<count($custom); $i++)
- {
- $custom[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($custom[$i]['entry_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- }
- return $custom;
- }
-
- function read_single($custom_id)
- {
- return $this->so->read_single($custom_id);
- }
-
- function read_custom_name($custom_id)
- {
- return $this->so->read_custom_name($custom_id);
- }
-
- function save($custom)
- {
-
- if ($custom['custom_id'])
- {
- if ($custom['custom_id'] != 0)
- {
- $custom_id = $custom['custom_id'];
- $receipt=$this->so->edit($custom);
- }
- }
- else
- {
- $receipt = $this->so->add($custom);
- }
- return $receipt;
- }
-
- function delete($params)
- {
- if (is_array($params))
- {
- $this->so->delete($params[0]);
- }
- else
- {
- $this->so->delete($params);
- }
- }
-
- function resort($data)
- {
- $this->so->resort($data);
- }
-
-
- function read_custom($custom_id,$allrows='')
- {
- if($allrows)
- {
- $this->allrows=$allrows;
- }
- $custom = $this->so->read_custom(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'custom_id' =>
$custom_id,'allrows'=>$this->allrows));
- $this->uicols = $this->so->uicols;
- $this->total_records = $this->so->total_records;
- return $custom;
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage custom
+ * @version $Id: class.bocustom.inc.php,v 1.6 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class bocustom
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ function bocustom($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so = CreateObject($this->currentapp.'.socustom');
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $allrows =
get_var('allrows',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id) && !empty($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ else
+ {
+ unset($this->cat_id);
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+ }
+
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','custom',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','custom');
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ }
+
+ function check_perms($has, $needed)
+ {
+ return (!!($has & $needed) == True);
+ }
+
+
+ function read()
+ {
+ $custom = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows));
+ $this->total_records = $this->so->total_records;
+
+ for ($i=0; $i<count($custom); $i++)
+ {
+ $custom[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($custom[$i]['entry_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ }
+ return $custom;
+ }
+
+ function read_single($custom_id)
+ {
+ return $this->so->read_single($custom_id);
+ }
+
+ function read_custom_name($custom_id)
+ {
+ return $this->so->read_custom_name($custom_id);
+ }
+
+ function save($custom)
+ {
+
+ if ($custom['custom_id'])
+ {
+ if ($custom['custom_id'] != 0)
+ {
+ $custom_id = $custom['custom_id'];
+ $receipt=$this->so->edit($custom);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add($custom);
+ }
+ return $receipt;
+ }
+
+ function delete($params)
+ {
+ if (is_array($params))
+ {
+ $this->so->delete($params[0]);
+ }
+ else
+ {
+ $this->so->delete($params);
+ }
+ }
+
+ function resort($data)
+ {
+ $this->so->resort($data);
+ }
+
+
+ function read_custom($custom_id,$allrows='')
+ {
+ if($allrows)
+ {
+ $this->allrows=$allrows;
+ }
+ $custom = $this->so->read_custom(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'custom_id' =>
$custom_id,'allrows'=>$this->allrows));
+ $this->uicols = $this->so->uicols;
+ $this->total_records = $this->so->total_records;
+ return $custom;
+ }
+
+ }
+?>
Index: property/inc/class.bodocument.inc.php
diff -u property/inc/class.bodocument.inc.php:1.5
property/inc/class.bodocument.inc.php:1.6
--- property/inc/class.bodocument.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/class.bodocument.inc.php Fri Jan 27 14:05:43 2006
@@ -1,640 +1,640 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage document
- * @version $Id: class.bodocument.inc.php,v 1.5 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class bodocument
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- function bodocument($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.sodocument');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->solocation =
CreateObject($this->currentapp.'.solocation');
- $this->historylog =
CreateObject($this->currentapp.'.historylog','document');
- $this->contacts =
CreateObject($this->currentapp.'.soactor');
- $this->contacts->role='vendor';
-
- $this->vfs =
CreateObject('phpgwapi.vfs');
- $this->rootdir = $this->vfs->basedir;
- $this->fakebase = $this->vfs->fakebase;
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $status_id =
get_var('status_id',array('POST','GET'));
- $entity_id =
get_var('entity_id',array('POST','GET'));
- $doc_type =
get_var('doc_type',array('POST','GET'));
- $query_location =
get_var('query_location',array('POST','GET'));
-
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(isset($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- if(isset($status_id))
- {
- $this->status_id = $status_id;
- }
- if(isset($entity_id))
- {
- $this->entity_id = $entity_id;
- }
- if(isset($doc_type))
- {
- $this->doc_type = $doc_type;
- }
- if(isset($query_location))
- {
- $this->query_location = $query_location;
- }
-
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','document',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','document');
-
- //_debug_array($data);
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->entity_id = $data['entity_id'];
- $this->doc_type = $data['doc_type'];
- $this->query_location = $data['query_location'];
- }
-
- function select_status_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('status_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('status_filter'));
- break;
- }
-
- $status_entries= $this->so->select_status_list();
-
- while (is_array($status_entries) && list(,$status) =
each($status_entries))
- {
- $sel_status = '';
- if ($status['id']==$selected)
- {
- $sel_status = 'selected';
- }
-
- $status_list[] = array
- (
- 'id' => $status['id'],
- 'name' => $status['name'],
- 'selected' => $sel_status
- );
- }
-
- for ($i=0;$i<count($status_list);$i++)
- {
- if ($status_list[$i]['selected'] != 'selected')
- {
- unset($status_list[$i]['selected']);
- }
- }
-
- return $status_list;
- }
-
- function select_branch_list($selected='')
- {
-
- $branch_entries= $this->so->select_branch_list();
-
- while (is_array($branch_entries) && list(,$branch) =
each($branch_entries))
- {
- $sel_branch = '';
- if ($branch['id']==$selected)
- {
- $sel_branch = 'selected';
- }
-
- $branch_list[] = array
- (
- 'id' => $branch['id'],
- 'name' => $branch['name'],
- 'selected' => $sel_branch
- );
- }
-
- for ($i=0;$i<count($branch_list);$i++)
- {
- if ($branch_list[$i]['selected'] != 'selected')
- {
- unset($branch_list[$i]['selected']);
- }
- }
-
- return $branch_list;
- }
-
-
- function select_doc_type_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
- $categories= $this->so->select_doc_type_list();
-
- while (is_array($categories) && list(,$category) =
each($categories))
- {
- $sel_category = '';
- if ($category['id']==$selected)
- {
- $sel_category = 'selected';
- }
-
- $category_list[] = array
- (
- 'cat_id' => $category['id'],
- 'name' => $category['name'],
- 'selected' => $sel_category
- );
- }
-
- for ($i=0;$i<count($category_list);$i++)
- {
- if ($category_list[$i]['selected'] !=
'selected')
- {
- unset($category_list[$i]['selected']);
- }
- }
-
- return $category_list;
- }
-
-
- function read()
- {
- $document = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' => $this->cat_id,'entity_id' =>
$this->entity_id,'doc_type'=>$this->doc_type));
- $this->total_records = $this->so->total_records;
-
- $this->uicols = $this->so->uicols;
- $cols_extra = $this->so->cols_extra;
-
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- for ($i=0; $i<count($document); $i++)
- {
-
$location_data=$this->solocation->read_single($document[$i]['location_code']);
-
- for ($j=0;$j<count($cols_extra);$j++)
- {
- $document[$i][$cols_extra[$j]] =
$location_data[$cols_extra[$j]];
- }
- }
-
- return $document;
- }
-
- function read_at_location($location_code='')
- {
- $document = $this->so->read_at_location(array('start'
=> $this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' => $this->cat_id,'entity_id' =>
$this->entity_id,
-
'location_code' => $location_code,'doc_type'=>$this->doc_type));
- $this->total_records = $this->so->total_records;
-
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-
- for ($i=0; $i<count($document); $i++)
- {
- $document[$i]['user'] =
$GLOBALS['phpgw']->accounts->id2name($document[$i]['user_id']);
- $document[$i]['document_date'] =
$GLOBALS['phpgw']->common->show_date($document[$i]['start_date'],$dateformat);
- $document[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($document[$i]['entry_date'],$dateformat);
- }
-
- return $document;
- }
-
- function read_single($document_id)
- {
- $document
= $this->so->read_single($document_id);
- $dateformat
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $document['document_date'] =
$GLOBALS['phpgw']->common->show_date($document['document_date'],$dateformat);
- $vendor
= $this->contacts->read_single(array('actor_id'=>$document['vendor_id']));
-
- if(is_array($vendor))
- {
- foreach($vendor['attributes'] as $attribute)
- {
- if($attribute['name']=='org_name')
- {
-
$document['vendor_name']=$attribute['value'];
- break;
- }
- }
- }
-
- if($document['location_code'])
- {
- $document['location_data']
=$this->solocation->read_single($document['location_code']);
- }
-
- if($document['p_num'])
- {
- $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
- $category =
$soadmin_entity->read_single_category($document['p_entity_id'],$document['p_cat_id']);
-
-
$document['p'][$document['p_entity_id']]['p_num']=$document['p_num'];
-
$document['p'][$document['p_entity_id']]['p_entity_id']=$document['p_entity_id'];
-
$document['p'][$document['p_entity_id']]['p_cat_id']=$document['p_cat_id'];
-
$document['p'][$document['p_entity_id']]['p_cat_name'] = $category['name'];
- }
-
- return $document;
- }
-
- function read_location_data($location_code)
- {
- $location_data=
$this->solocation->read_single($location_code);
-
- return $location_data;
- }
-
- function select_category_list($format='',$selected='')
- {
-/* switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
-
-*/
-
- $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
- $categories =
$soadmin_entity->read_category(array('allrows'=>True,'entity_id'=>$this->entity_id));
-
- $category_list =
$this->bocommon->select_multi_list($selected,$categories);
-
-/* while (is_array($categories) && list(,$category) =
each($categories))
- {
- $sel_category = '';
- if ($category['id']==$selected)
- {
- $sel_category = 'selected';
- }
-
- $category_list[] = array
- (
- 'cat_id' => $category['id'],
- 'name' => $category['name'],
- 'selected' => $sel_category
- );
- }
-
- for ($i=0;$i<count($category_list);$i++)
- {
- if ($category_list[$i]['selected'] !=
'selected')
- {
- unset($category_list[$i]['selected']);
- }
- }
-*/
- return $category_list;
- }
-
-
-
- function read_record_history($id)
- {
- $history_array =
$this->historylog->return_array(array('O'),array(),'','',$id);
- $i=0;
- while (is_array($history_array) && list(,$value) =
each($history_array))
- {
-
- $record_history[$i]['value_date'] =
$GLOBALS['phpgw']->common->show_date($value['datetime']);
- $record_history[$i]['value_user'] =
$value['owner'];
-
- switch ($value['status'])
- {
- case 'R': $type = lang('Re-opened');
break;
- case 'X': $type = lang('Closed');
break;
- case 'O': $type = lang('Opened');
break;
- case 'A': $type = lang('Re-assigned');
break;
- case 'P': $type = lang('Priority
changed'); break;
- case 'CO': $type = lang('Initial
Coordinator'); break;
- case 'C': $type = lang('Coordinator
changed'); break;
- case 'TO': $type = lang('Initial
Category'); break;
- case 'T': $type = lang('Category
changed'); break;
- case 'SO': $type = lang('Initial
Status'); break;
- case 'S': $type = lang('Status
changed'); break;
- case 'FO': $type = lang('Initial
File'); break;
- case 'F': $type = lang('File changed');
break;
- case 'LO': $type = lang('Initial
Link'); break;
- case 'L': $type = lang('Link changed');
break;
- default: break;
- }
-
-
if($value['new_value']=='O'){$value['new_value']=lang('Opened');}
-
if($value['new_value']=='X'){$value['new_value']=lang('Closed');}
-
-
- $record_history[$i]['value_action'] =
$type?$type:'';
- unset($type);
-
- if ($value['status'] == 'A')
- {
- if (! $value['new_value'])
- {
-
$record_history[$i]['value_new_value'] = lang('None');
- }
- else
- {
-
$record_history[$i]['value_new_value'] =
$GLOBALS['phpgw']->accounts->id2name($value['new_value']);
- }
- }
- else if ($value['status'] == 'C' ||
$value['status'] == 'CO')
- {
- $record_history[$i]['value_new_value']
= $GLOBALS['phpgw']->accounts->id2name($value['new_value']);
- }
- else if ($value['status'] == 'T' ||
$value['status'] == 'TO')
- {
- $record_history[$i]['value_new_value']
= $this->so->read_single_category($value['new_value']);
- }
- else if ($value['status'] != 'O' &&
$value['new_value'])
- {
- $record_history[$i]['value_new_value']
= $value['new_value'];
- }
- else
- {
- $record_history[$i]['value_new_value']
= '';
- }
-
- $i++;
- }
-
- return $record_history;
- }
-
-
- function create_home_dir()
- {
- if(!$this->vfs->file_exists(array(
- 'string' => $this->fakebase. SEP .
'document',
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
- $this->vfs->override_acl = 1;
-
- if(!$this->vfs->mkdir (array(
- 'string' => $this->fakebase. SEP .
'document',
- 'relatives' => array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'document');
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'document');
- }
- $this->vfs->override_acl = 0;
- }
- return $receipt;
- }
-
-
- function create_document_dir($data,$receipt)
- {
- if(is_array($data))
- {
- $loc1 =
(isset($data['loc1'])?$data['loc1']:'');
- $entity_name =
(isset($data['entity_name'])?$data['entity_name']:'');
- $category_name =
(isset($data['category_name'])?$data['category_name']:'');
- $p_num =
(isset($data['p_num'])?$data['p_num']:'');
- }
-
- $this->vfs->override_acl = 1;
-//_debug_array($data);
- if(!$this->vfs->file_exists(array(
- 'string' => $this->fakebase. SEP .
'document' . SEP . $loc1,
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
- if(!$this->vfs->mkdir (array(
- 'string' => $this->fakebase. SEP .
'document' . SEP . $loc1,
- 'relatives' => array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'document' . SEP . $loc1);
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'document' . SEP . $loc1);
- }
- $this->vfs->override_acl = 0;
- }
-
- if($entity_name)
- {
- if(!$this->vfs->file_exists(array(
- 'string' => $this->fakebase.
SEP . 'document' . SEP . $loc1 . SEP . $entity_name,
- 'relatives' =>
Array(RELATIVE_NONE)
- )))
- {
-
- if(!$this->vfs->mkdir (array(
- 'string' => $this->fakebase.
SEP . 'document' . SEP . $loc1 . SEP . $entity_name,
- 'relatives' => array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'document' . SEP . $loc1 . SEP . $entity_name);
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'document' . SEP . $loc1 . SEP . $entity_name);
- }
- }
- }
- if($category_name)
- {
- if(!$this->vfs->file_exists(array(
- 'string' => $this->fakebase.
SEP . 'document' . SEP . $loc1 . SEP . $entity_name . SEP . $category_name,
- 'relatives' =>
Array(RELATIVE_NONE)
- )))
- {
-
- if(!$this->vfs->mkdir (array(
- 'string' => $this->fakebase.
SEP . 'document' . SEP . $loc1 . SEP . $entity_name . SEP . $category_name,
- 'relatives' => array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'document' . SEP . $loc1 . SEP . $entity_name . SEP
. $category_name);
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'document' . SEP . $loc1 . SEP . $entity_name . SEP
. $category_name);
- }
- }
- }
- if($p_num)
- {
- if(!$this->vfs->file_exists(array(
- 'string' => $this->fakebase.
SEP . 'document' . SEP . $loc1 . SEP . $entity_name . SEP . $category_name .
SEP . $p_num,
- 'relatives' =>
Array(RELATIVE_NONE)
- )))
- {
-
- if(!$this->vfs->mkdir (array(
- 'string' => $this->fakebase.
SEP . 'document' . SEP . $loc1 . SEP . $entity_name . SEP . $category_name .
SEP . $p_num,
- 'relatives' => array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'document' . SEP . $loc1 . SEP . $entity_name . SEP
. $category_name . SEP . $p_num);
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'document' . SEP . $loc1 . SEP . $entity_name . SEP
. $category_name . SEP . $p_num);
- }
- }
- }
-
- $this->vfs->override_acl = 0;
-
-//_debug_array($receipt);
- return $receipt;
- }
-
-
- function save($values)
- {
-
- $document_date =
$this->bocommon->date_array($values['document_date']);
- $values['document_date'] = mktime
(2,0,0,$document_date['month'],$document_date['day'],$document_date['year']);
-
- while (is_array($values['location']) && list(,$value) =
each($values['location']))
- {
- if($value)
- {
- $location[] = $value;
- }
- }
-
- $values['location_code']=implode("-", $location);
-
-//_debug_array($values);
- if ($values['document_id'])
- {
- if ($values['document_id'] != 0)
- {
- $receipt = $this->so->edit($values);
- }
- }
- else
- {
- $receipt = $this->so->add($values);
- }
- return $receipt;
- }
-
- function delete($document_id)
- {
- $this->so->delete($document_id);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage document
+ * @version $Id: class.bodocument.inc.php,v 1.6 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class bodocument
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ function bodocument($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.sodocument');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->solocation =
CreateObject($this->currentapp.'.solocation');
+ $this->historylog =
CreateObject($this->currentapp.'.historylog','document');
+ $this->contacts =
CreateObject($this->currentapp.'.soactor');
+ $this->contacts->role='vendor';
+
+ $this->vfs =
CreateObject('phpgwapi.vfs');
+ $this->rootdir = $this->vfs->basedir;
+ $this->fakebase = $this->vfs->fakebase;
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $status_id =
get_var('status_id',array('POST','GET'));
+ $entity_id =
get_var('entity_id',array('POST','GET'));
+ $doc_type =
get_var('doc_type',array('POST','GET'));
+ $query_location =
get_var('query_location',array('POST','GET'));
+
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(isset($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ if(isset($status_id))
+ {
+ $this->status_id = $status_id;
+ }
+ if(isset($entity_id))
+ {
+ $this->entity_id = $entity_id;
+ }
+ if(isset($doc_type))
+ {
+ $this->doc_type = $doc_type;
+ }
+ if(isset($query_location))
+ {
+ $this->query_location = $query_location;
+ }
+
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','document',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','document');
+
+ //_debug_array($data);
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->entity_id = $data['entity_id'];
+ $this->doc_type = $data['doc_type'];
+ $this->query_location = $data['query_location'];
+ }
+
+ function select_status_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('status_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('status_filter'));
+ break;
+ }
+
+ $status_entries= $this->so->select_status_list();
+
+ while (is_array($status_entries) && list(,$status) =
each($status_entries))
+ {
+ $sel_status = '';
+ if ($status['id']==$selected)
+ {
+ $sel_status = 'selected';
+ }
+
+ $status_list[] = array
+ (
+ 'id' => $status['id'],
+ 'name' => $status['name'],
+ 'selected' => $sel_status
+ );
+ }
+
+ for ($i=0;$i<count($status_list);$i++)
+ {
+ if ($status_list[$i]['selected'] != 'selected')
+ {
+ unset($status_list[$i]['selected']);
+ }
+ }
+
+ return $status_list;
+ }
+
+ function select_branch_list($selected='')
+ {
+
+ $branch_entries= $this->so->select_branch_list();
+
+ while (is_array($branch_entries) && list(,$branch) =
each($branch_entries))
+ {
+ $sel_branch = '';
+ if ($branch['id']==$selected)
+ {
+ $sel_branch = 'selected';
+ }
+
+ $branch_list[] = array
+ (
+ 'id' => $branch['id'],
+ 'name' => $branch['name'],
+ 'selected' => $sel_branch
+ );
+ }
+
+ for ($i=0;$i<count($branch_list);$i++)
+ {
+ if ($branch_list[$i]['selected'] != 'selected')
+ {
+ unset($branch_list[$i]['selected']);
+ }
+ }
+
+ return $branch_list;
+ }
+
+
+ function select_doc_type_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ break;
+ }
+
+ $categories= $this->so->select_doc_type_list();
+
+ while (is_array($categories) && list(,$category) =
each($categories))
+ {
+ $sel_category = '';
+ if ($category['id']==$selected)
+ {
+ $sel_category = 'selected';
+ }
+
+ $category_list[] = array
+ (
+ 'cat_id' => $category['id'],
+ 'name' => $category['name'],
+ 'selected' => $sel_category
+ );
+ }
+
+ for ($i=0;$i<count($category_list);$i++)
+ {
+ if ($category_list[$i]['selected'] !=
'selected')
+ {
+ unset($category_list[$i]['selected']);
+ }
+ }
+
+ return $category_list;
+ }
+
+
+ function read()
+ {
+ $document = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' => $this->cat_id,'entity_id' =>
$this->entity_id,'doc_type'=>$this->doc_type));
+ $this->total_records = $this->so->total_records;
+
+ $this->uicols = $this->so->uicols;
+ $cols_extra = $this->so->cols_extra;
+
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ for ($i=0; $i<count($document); $i++)
+ {
+
$location_data=$this->solocation->read_single($document[$i]['location_code']);
+
+ for ($j=0;$j<count($cols_extra);$j++)
+ {
+ $document[$i][$cols_extra[$j]] =
$location_data[$cols_extra[$j]];
+ }
+ }
+
+ return $document;
+ }
+
+ function read_at_location($location_code='')
+ {
+ $document = $this->so->read_at_location(array('start'
=> $this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' => $this->cat_id,'entity_id' =>
$this->entity_id,
+
'location_code' => $location_code,'doc_type'=>$this->doc_type));
+ $this->total_records = $this->so->total_records;
+
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ for ($i=0; $i<count($document); $i++)
+ {
+ $document[$i]['user'] =
$GLOBALS['phpgw']->accounts->id2name($document[$i]['user_id']);
+ $document[$i]['document_date'] =
$GLOBALS['phpgw']->common->show_date($document[$i]['start_date'],$dateformat);
+ $document[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($document[$i]['entry_date'],$dateformat);
+ }
+
+ return $document;
+ }
+
+ function read_single($document_id)
+ {
+ $document
= $this->so->read_single($document_id);
+ $dateformat
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $document['document_date'] =
$GLOBALS['phpgw']->common->show_date($document['document_date'],$dateformat);
+ $vendor
= $this->contacts->read_single(array('actor_id'=>$document['vendor_id']));
+
+ if(is_array($vendor))
+ {
+ foreach($vendor['attributes'] as $attribute)
+ {
+ if($attribute['name']=='org_name')
+ {
+
$document['vendor_name']=$attribute['value'];
+ break;
+ }
+ }
+ }
+
+ if($document['location_code'])
+ {
+ $document['location_data']
=$this->solocation->read_single($document['location_code']);
+ }
+
+ if($document['p_num'])
+ {
+ $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
+ $category =
$soadmin_entity->read_single_category($document['p_entity_id'],$document['p_cat_id']);
+
+
$document['p'][$document['p_entity_id']]['p_num']=$document['p_num'];
+
$document['p'][$document['p_entity_id']]['p_entity_id']=$document['p_entity_id'];
+
$document['p'][$document['p_entity_id']]['p_cat_id']=$document['p_cat_id'];
+
$document['p'][$document['p_entity_id']]['p_cat_name'] = $category['name'];
+ }
+
+ return $document;
+ }
+
+ function read_location_data($location_code)
+ {
+ $location_data=
$this->solocation->read_single($location_code);
+
+ return $location_data;
+ }
+
+ function select_category_list($format='',$selected='')
+ {
+/* switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ break;
+ }
+
+
+*/
+
+ $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
+ $categories =
$soadmin_entity->read_category(array('allrows'=>True,'entity_id'=>$this->entity_id));
+
+ $category_list =
$this->bocommon->select_multi_list($selected,$categories);
+
+/* while (is_array($categories) && list(,$category) =
each($categories))
+ {
+ $sel_category = '';
+ if ($category['id']==$selected)
+ {
+ $sel_category = 'selected';
+ }
+
+ $category_list[] = array
+ (
+ 'cat_id' => $category['id'],
+ 'name' => $category['name'],
+ 'selected' => $sel_category
+ );
+ }
+
+ for ($i=0;$i<count($category_list);$i++)
+ {
+ if ($category_list[$i]['selected'] !=
'selected')
+ {
+ unset($category_list[$i]['selected']);
+ }
+ }
+*/
+ return $category_list;
+ }
+
+
+
+ function read_record_history($id)
+ {
+ $history_array =
$this->historylog->return_array(array('O'),array(),'','',$id);
+ $i=0;
+ while (is_array($history_array) && list(,$value) =
each($history_array))
+ {
+
+ $record_history[$i]['value_date'] =
$GLOBALS['phpgw']->common->show_date($value['datetime']);
+ $record_history[$i]['value_user'] =
$value['owner'];
+
+ switch ($value['status'])
+ {
+ case 'R': $type = lang('Re-opened');
break;
+ case 'X': $type = lang('Closed');
break;
+ case 'O': $type = lang('Opened');
break;
+ case 'A': $type = lang('Re-assigned');
break;
+ case 'P': $type = lang('Priority
changed'); break;
+ case 'CO': $type = lang('Initial
Coordinator'); break;
+ case 'C': $type = lang('Coordinator
changed'); break;
+ case 'TO': $type = lang('Initial
Category'); break;
+ case 'T': $type = lang('Category
changed'); break;
+ case 'SO': $type = lang('Initial
Status'); break;
+ case 'S': $type = lang('Status
changed'); break;
+ case 'FO': $type = lang('Initial
File'); break;
+ case 'F': $type = lang('File changed');
break;
+ case 'LO': $type = lang('Initial
Link'); break;
+ case 'L': $type = lang('Link changed');
break;
+ default: break;
+ }
+
+
if($value['new_value']=='O'){$value['new_value']=lang('Opened');}
+
if($value['new_value']=='X'){$value['new_value']=lang('Closed');}
+
+
+ $record_history[$i]['value_action'] =
$type?$type:'';
+ unset($type);
+
+ if ($value['status'] == 'A')
+ {
+ if (! $value['new_value'])
+ {
+
$record_history[$i]['value_new_value'] = lang('None');
+ }
+ else
+ {
+
$record_history[$i]['value_new_value'] =
$GLOBALS['phpgw']->accounts->id2name($value['new_value']);
+ }
+ }
+ else if ($value['status'] == 'C' ||
$value['status'] == 'CO')
+ {
+ $record_history[$i]['value_new_value']
= $GLOBALS['phpgw']->accounts->id2name($value['new_value']);
+ }
+ else if ($value['status'] == 'T' ||
$value['status'] == 'TO')
+ {
+ $record_history[$i]['value_new_value']
= $this->so->read_single_category($value['new_value']);
+ }
+ else if ($value['status'] != 'O' &&
$value['new_value'])
+ {
+ $record_history[$i]['value_new_value']
= $value['new_value'];
+ }
+ else
+ {
+ $record_history[$i]['value_new_value']
= '';
+ }
+
+ $i++;
+ }
+
+ return $record_history;
+ }
+
+
+ function create_home_dir()
+ {
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase. SEP .
'document',
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $this->vfs->override_acl = 1;
+
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase. SEP .
'document',
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'document');
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'document');
+ }
+ $this->vfs->override_acl = 0;
+ }
+ return $receipt;
+ }
+
+
+ function create_document_dir($data,$receipt)
+ {
+ if(is_array($data))
+ {
+ $loc1 =
(isset($data['loc1'])?$data['loc1']:'');
+ $entity_name =
(isset($data['entity_name'])?$data['entity_name']:'');
+ $category_name =
(isset($data['category_name'])?$data['category_name']:'');
+ $p_num =
(isset($data['p_num'])?$data['p_num']:'');
+ }
+
+ $this->vfs->override_acl = 1;
+//_debug_array($data);
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase. SEP .
'document' . SEP . $loc1,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase. SEP .
'document' . SEP . $loc1,
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'document' . SEP . $loc1);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'document' . SEP . $loc1);
+ }
+ $this->vfs->override_acl = 0;
+ }
+
+ if($entity_name)
+ {
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase.
SEP . 'document' . SEP . $loc1 . SEP . $entity_name,
+ 'relatives' =>
Array(RELATIVE_NONE)
+ )))
+ {
+
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase.
SEP . 'document' . SEP . $loc1 . SEP . $entity_name,
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'document' . SEP . $loc1 . SEP . $entity_name);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'document' . SEP . $loc1 . SEP . $entity_name);
+ }
+ }
+ }
+ if($category_name)
+ {
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase.
SEP . 'document' . SEP . $loc1 . SEP . $entity_name . SEP . $category_name,
+ 'relatives' =>
Array(RELATIVE_NONE)
+ )))
+ {
+
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase.
SEP . 'document' . SEP . $loc1 . SEP . $entity_name . SEP . $category_name,
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'document' . SEP . $loc1 . SEP . $entity_name . SEP
. $category_name);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'document' . SEP . $loc1 . SEP . $entity_name . SEP
. $category_name);
+ }
+ }
+ }
+ if($p_num)
+ {
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase.
SEP . 'document' . SEP . $loc1 . SEP . $entity_name . SEP . $category_name .
SEP . $p_num,
+ 'relatives' =>
Array(RELATIVE_NONE)
+ )))
+ {
+
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase.
SEP . 'document' . SEP . $loc1 . SEP . $entity_name . SEP . $category_name .
SEP . $p_num,
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'document' . SEP . $loc1 . SEP . $entity_name . SEP
. $category_name . SEP . $p_num);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'document' . SEP . $loc1 . SEP . $entity_name . SEP
. $category_name . SEP . $p_num);
+ }
+ }
+ }
+
+ $this->vfs->override_acl = 0;
+
+//_debug_array($receipt);
+ return $receipt;
+ }
+
+
+ function save($values)
+ {
+
+ $document_date =
$this->bocommon->date_array($values['document_date']);
+ $values['document_date'] = mktime
(2,0,0,$document_date['month'],$document_date['day'],$document_date['year']);
+
+ while (is_array($values['location']) && list(,$value) =
each($values['location']))
+ {
+ if($value)
+ {
+ $location[] = $value;
+ }
+ }
+
+ $values['location_code']=implode("-", $location);
+
+//_debug_array($values);
+ if ($values['document_id'])
+ {
+ if ($values['document_id'] != 0)
+ {
+ $receipt = $this->so->edit($values);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add($values);
+ }
+ return $receipt;
+ }
+
+ function delete($document_id)
+ {
+ $this->so->delete($document_id);
+ }
+ }
+?>
Index: property/inc/class.boentity.inc.php
diff -u property/inc/class.boentity.inc.php:1.13
property/inc/class.boentity.inc.php:1.14
--- property/inc/class.boentity.inc.php:1.13 Fri Nov 25 13:05:52 2005
+++ property/inc/class.boentity.inc.php Fri Jan 27 14:05:43 2006
@@ -1,636 +1,636 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage entity
- * @version $Id: class.boentity.inc.php,v 1.13 2005/11/25 13:05:52
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class boentity
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- var $soap_functions = array(
- 'list' => array(
- 'in' =>
array('int','int','struct','string','int'),
- 'out' => array('array')
- ),
- 'read' => array(
- 'in' => array('int','struct'),
- 'out' => array('array')
- ),
- 'save' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- ),
- 'delete' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- )
- );
-
- function boentity($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.soentity');
-
- $this->solocation =
CreateObject($this->currentapp.'.solocation');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->vfs =
CreateObject('phpgwapi.vfs');
- $this->rootdir = $this->vfs->basedir;
- $this->fakebase = $this->vfs->fakebase;
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $district_id =
get_var('district_id',array('POST','GET'));
- $entity_id =
get_var('entity_id',array('POST','GET'));
- $status = get_var('status',array('POST','GET'));
- $start_date =
get_var('start_date',array('POST','GET'));
- $end_date =
get_var('end_date',array('POST','GET'));
-
- $this->soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity',$entity_id,$cat_id);
-
- $this->category_name =
$this->soadmin_entity->category_name;
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
- if(array_key_exists('query',$_POST) ||
array_key_exists('query',$_GET) )
- {
- $this->query = $query;
- }
- if(array_key_exists('filter',$_POST))
- {
- $this->filter = $filter;
- }
- if(array_key_exists('sort',$_POST))
- {
- $this->sort = $sort;
- }
- if(array_key_exists('order',$_POST))
- {
- $this->order = $order;
- }
- // if(array_key_exists('cat_id',$_POST) ||
array_key_exists('cat_id',$_GET) )
- if($cat_id)
- {
- $this->cat_id = $cat_id;
- }
- if(array_key_exists('district_id',$_POST))
- {
- $this->district_id = $district_id;
- }
- if($entity_id)
- {
- $this->entity_id = $entity_id;
- }
- if(array_key_exists('status',$_POST))
- {
- $this->status = $status;
- }
- if(array_key_exists('start_date',$_POST))
- {
- $this->start_date = $start_date;
- }
- if(array_key_exists('end_date',$_POST))
- {
- $this->end_date = $end_date;
- }
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','entity',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','entity');
- //_debug_array($data);
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- // $this->cat_id = $data['cat_id'];
- $this->district_id = $data['district_id'];
- // $this->entity_id = $data['entity_id'];
- $this->status = $data['status'];
- $this->start_date = $data['start_date'];
- $this->end_date = $data['end_date'];
- }
-
- function
column_list($selected='',$entity_id='',$cat_id,$allrows='')
- {
- $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
-
- if(!$selected)
- {
-
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]["entity_columns_"
. $this->entity_id . '_' . $this->cat_id];
- }
-
- $columns =
$soadmin_entity->read_attrib(array('entity_id'=>$entity_id,'cat_id'=>$cat_id,'allrows'=>$allrows));
-
$column_list=$this->bocommon->select_multi_list($selected,$columns);
-
- return $column_list;
- }
-
- function select_category_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
- $categories=
$this->soadmin_entity->read_category(array('allrows'=>True,'entity_id'=>$this->entity_id));
-
- while (is_array($categories) && list(,$category) =
each($categories))
- {
- $sel_category = '';
- if ($category['id']==$selected)
- {
- $sel_category = 'selected';
- }
-
- $category_list[] = array
- (
- 'cat_id' => $category['id'],
- 'name' => $category['name'],
- 'selected' => $sel_category
- );
- }
-
- for ($i=0;$i<count($category_list);$i++)
- {
- if ($category_list[$i]['selected'] !=
'selected')
- {
- unset($category_list[$i]['selected']);
- }
- }
-
- return $category_list;
- }
-
-
- function select_status_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('status_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('status_filter'));
- break;
- }
-
- $status_entries=
$this->so->select_status_list($this->entity_id,$this->cat_id);
-
- while (is_array($status_entries) && list(,$status) =
each($status_entries))
- {
- $sel_status = '';
- if ($status['id']==$selected)
- {
- $sel_status = 'selected';
- }
-
- $status_list[] = array
- (
- 'id' => $status['id'],
- 'name' => $status['name'],
- 'selected' => $sel_status
- );
- }
-
- for ($i=0;$i<count($status_list);$i++)
- {
- if ($status_list[$i]['selected'] != 'selected')
- {
- unset($status_list[$i]['selected']);
- }
- }
-
- return $status_list;
- }
-
- function read($data='')
- {
- $entity = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' => $this->cat_id,'district_id' =>
$this->district_id,
-
'lookup'=>$data['lookup'],'allrows'=>$data['allrows'],'entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'status'=>$this->status,
-
'start_date'=>$this->bocommon->date_to_timestamp($data['start_date']),'end_date'=>$this->bocommon->date_to_timestamp($data['end_date']),
-
'allrows'=>$data['allrows']));
-
- $this->total_records = $this->so->total_records;
- $this->uicols = $this->so->uicols;
- $cols_extra = $this->so->cols_extra;
- $cols_return_lookup =
$this->so->cols_return_lookup;
-//_debug_array($entity);
-//_debug_array($cols_extra);
-//_debug_array($cols_return_lookup);
-
- if($data['lookup'])
- {
- for ($i=0;$i<count($entity);$i++)
- {
-
$location_data=$this->solocation->read_single($entity[$i]['location_code']);
- for ($j=0;$j<count($cols_extra);$j++)
- {
- $entity[$i][$cols_extra[$j]] =
$location_data[$cols_extra[$j]];
- }
-
- if($cols_return_lookup)
- {
- for
($k=0;$k<count($cols_return_lookup);$k++)
- {
-
$entity[$i][$cols_return_lookup[$k]] = $location_data[$cols_return_lookup[$k]];
- }
- }
- }
- }
-
- return $entity;
- }
-
- function read_single($data)
- {
- $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
- $contacts =
CreateObject('phpgwapi.contacts');
- $vendor = CreateObject($this->currentapp.'.soactor');
- $vendor->role = 'vendor';
-
- $entity = $this->so->read_single($data);
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $entity['date'] =
$GLOBALS['phpgw']->common->show_date($entity['date'],$dateformat);
-
- if($entity['location_code'])
- {
-
$entity['location_data']=$this->solocation->read_single($entity['location_code']);
- if($entity['tenant_id'])
- {
-
$tenant_data=$this->bocommon->read_single_tenant($entity['tenant_id']);
- $entity['location_data']['tenant_id']
= $entity['tenant_id'];
-
$entity['location_data']['contact_phone']= $entity['contact_phone'];
- $entity['location_data']['last_name']
= $tenant_data['last_name'];
- $entity['location_data']['first_name']
= $tenant_data['first_name'];
- }
- }
-
- if($entity['p_num'])
- {
- $category =
$soadmin_entity->read_single_category($entity['p_entity_id'],$entity['p_cat_id']);
-
$entity['p'][$entity['p_entity_id']]['p_num']=$entity['p_num'];
-
$entity['p'][$entity['p_entity_id']]['p_entity_id']=$entity['p_entity_id'];
-
$entity['p'][$entity['p_entity_id']]['p_cat_id']=$entity['p_cat_id'];
-
$entity['p'][$entity['p_entity_id']]['p_cat_name'] = $category['name'];
- }
-
- $input_type_array = array(
- 'R' => 'radio',
- 'CH' => 'checkbox',
- 'LB' => 'listbox'
- );
-
- $sep = '/';
-
- $dlarr[strpos($dateformat,'Y')] = 'Y';
- $dlarr[strpos($dateformat,'m')] = 'm';
- $dlarr[strpos($dateformat,'d')] = 'd';
- ksort($dlarr);
- $dateformat= (implode($sep,$dlarr));
- $m=0;
-
- for ($i=0;$i<count($entity['attributes']);$i++)
- {
- if($entity['attributes'][$i]['datatype']=='D'
&& $entity['attributes'][$i]['value'])
- {
- $timestamp_date=
mktime(0,0,0,date(m,strtotime($entity['attributes'][$i]['value'])),date(d,strtotime($entity['attributes'][$i]['value'])),date(y,strtotime($entity['attributes'][$i]['value'])));
- $entity['attributes'][$i]['value']
= $GLOBALS['phpgw']->common->show_date($timestamp_date,$dateformat);
- }
-
- if($entity['attributes'][$i]['datatype']=='AB')
- {
- if($entity['attributes'][$i]['value'])
- {
- $contact_data
=
$contacts->read_single_entry($entity['attributes'][$i]['value'],array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
-
$entity['attributes'][$i]['contact_name'] = $contact_data[0]['n_family']
. ', ' . $contact_data[0]['n_given'];
- }
-
- $insert_record_entity[] =
$entity['attributes'][$i]['name'];
- $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.addressbook&column='
. $entity['attributes'][$i]['name']);
- $lookup_functions[$m]['name'] =
'lookup_'. $entity['attributes'][$i]['name'] .'()';
- $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
- $m++;
- }
-
-
if($entity['attributes'][$i]['datatype']=='VENDOR')
- {
- if($entity['attributes'][$i]['value'])
- {
- $vendor_data =
$vendor->read_single(array('actor_id'=>$entity['attributes'][$i]['value']));
- for
($n=0;$n<count($vendor_data['attributes']);$n++)
- {
-
if($vendor_data['attributes'][$n]['name'] == 'org_name')
- {
-
$entity['attributes'][$i]['vendor_name']=
$vendor_data['attributes'][$n]['value'];
- $n
=count($vendor_data['attributes']);
- }
- }
- }
-
- $insert_record_entity[] =
$entity['attributes'][$i]['name'];
- $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor&column='
. $entity['attributes'][$i]['name']);
- $lookup_functions[$m]['name'] =
'lookup_'. $entity['attributes'][$i]['name'] .'()';
- $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
- $m++;
- }
-
- if($entity['attributes'][$i]['datatype']=='R'
|| $entity['attributes'][$i]['datatype']=='CH' ||
$entity['attributes'][$i]['datatype']=='LB')
- {
- $entity['attributes'][$i]['choice']
=
$soadmin_entity->read_attrib_choice($data['entity_id'],$data['cat_id'],$entity['attributes'][$i]['attrib_id']);
-
$input_type=$input_type_array[$entity['attributes'][$i]['datatype']];
-
-
if($entity['attributes'][$i]['datatype']=='CH')
- {
-
$entity['attributes'][$i]['value']=unserialize($entity['attributes'][$i]['value']);
-
$entity['attributes'][$i]['choice'] =
$this->bocommon->select_multi_list_2($entity['attributes'][$i]['value'],$entity['attributes'][$i]['choice'],$input_type);
- }
- else
- {
- for
($j=0;$j<count($entity['attributes'][$i]['choice']);$j++)
- {
-
$entity['attributes'][$i]['choice'][$j]['input_type']=$input_type;
-
if($entity['attributes'][$i]['choice'][$j]['id']==$entity['attributes'][$i]['value'])
- {
-
$entity['attributes'][$i]['choice'][$j]['checked']='checked';
- }
- }
- }
- }
-
- $entity['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($entity['attributes'][$i]['datatype']);
- $entity['attributes'][$i]['counter'] = $i;
- $entity['attributes'][$i]['type_id'] =
$data['type_id'];
- }
-
- for ($j=0;$j<count($lookup_functions);$j++)
- {
- $entity['lookup_functions'] .= 'function ' .
$lookup_functions[$j]['name'] ."\r\n";
- $entity['lookup_functions'] .= '{'."\r\n";
- $entity['lookup_functions'] .=
$lookup_functions[$j]['action'] ."\r\n";
- $entity['lookup_functions'] .= '}'."\r\n";
- }
-
- $this->vfs->override_acl = 1;
-
- $entity['files'] = $this->vfs->ls (array(
- 'string' => $this->fakebase. '/' .
$this->category_name . '/' . $entity['location_data']['loc1'] . '/' .
$data['id'],
- 'relatives' => array(RELATIVE_NONE)));
-
- $this->vfs->override_acl = 0;
-
- if(!$entity['files'][0]['file_id'])
- {
- unset($entity['files']);
- }
-
-
-
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp,$insert_record_entity);
-
-//_debug_array($insert_record_entity);
- return $entity;
- }
-
-
- function create_home_dir($receipt='')
- {
- if(!$this->vfs->file_exists(array(
- 'string' => $this->fakebase. SEP .
$this->category_name,
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
- $this->vfs->override_acl = 1;
-
- if(!$this->vfs->mkdir (array(
- 'string' => $this->fakebase. SEP .
$this->category_name,
- 'relatives' => array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . $this->category_name);
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . $this->category_name);
- }
- $this->vfs->override_acl = 0;
- }
-
- return $receipt;
- }
-
- function create_document_dir($loc1='',$id='')
- {
- if(!$this->vfs->file_exists(array(
- 'string' => $this->fakebase. SEP .
$this->category_name . SEP . $loc1,
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
- $this->vfs->override_acl = 1;
- if(!$this->vfs->mkdir (array(
- 'string' => $this->fakebase. SEP .
$this->category_name . SEP . $loc1,
- 'relatives' => array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $loc1);
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $loc1);
- }
- $this->vfs->override_acl = 0;
- }
-
-
- if(!$this->vfs->file_exists(array(
- 'string' => $this->fakebase. SEP .
$this->category_name . SEP . $loc1 . SEP . $id,
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
- $this->vfs->override_acl = 1;
- if(!$this->vfs->mkdir (array(
- 'string' => $this->fakebase. SEP .
$this->category_name . SEP . $loc1 . SEP . $id,
- 'relatives' => array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $loc1 . SEP . $id);
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $loc1 . SEP . $id);
- }
- $this->vfs->override_acl = 0;
- }
-
-//_debug_array($receipt);
- return $receipt;
- }
-
- function
save($values,$values_attribute,$action='',$entity_id,$cat_id)
- {
- while (is_array($values['location']) && list(,$value) =
each($values['location']))
- {
- if($value)
- {
- $location[] = $value;
- }
- }
-
- $values['location_code']=implode("-", $location);
-
- $values['date'] =
$this->bocommon->date_to_timestamp($values['date']);
-
- for ($i=0;$i<count($values_attribute);$i++)
- {
- if($values_attribute[$i]['datatype']=='CH' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
serialize($values_attribute[$i]['value']);
- }
- if($values_attribute[$i]['datatype']=='R' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
$values_attribute[$i]['value'][0];
- }
-
- if($values_attribute[$i]['datatype']=='N' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
str_replace(",",".",$values_attribute[$i]['value']);
- }
-
- if($values_attribute[$i]['datatype']=='D' &&
$values_attribute[$i]['value'])
- {
-
- $values_attribute[$i]['value'] =
date($this->bocommon->dateformat,$this->bocommon->date_to_timestamp($values_attribute[$i]['value']));
- }
- }
-
- if ($action=='edit')
- {
- $receipt =
$this->so->edit($values,$values_attribute,$entity_id,$cat_id);
-
- if($values['delete_file'])
- {
- for
($i=0;$i<count($values['delete_file']);$i++)
- {
- $file = $this->fakebase. SEP .
$this->category_name . SEP . $location[0] . SEP . $values['id'] . SEP .
$values['delete_file'][$i];
-
-
if($this->vfs->file_exists(array(
- 'string' =>
$file,
- 'relatives' =>
Array(RELATIVE_NONE)
- )))
- {
-
$this->vfs->override_acl = 1;
-
- if(!$this->vfs->rm
(array(
- 'string' =>
$file,
- 'relatives' =>
array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to delete file') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $location[0]. SEP .
$values['id'] . SEP .$values['delete_file'][$i]);
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('file deleted') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $location[0]. SEP .
$values['id'] . SEP . $values['delete_file'][$i]);
- }
-
$this->vfs->override_acl = 0;
- }
- }
- }
- }
- else
- {
- $receipt =
$this->so->add($values,$values_attribute,$entity_id,$cat_id);
- }
-
- $acl_location = '.entity.' . $entity_id . '.' . $cat_id;
- $custom_functions =
$this->soadmin_entity->read_custom_function(array('acl_location' =>
$acl_location,'allrows'=>True));
-
- if (isSet($custom_functions) AND
is_array($custom_functions))
- {
- foreach($custom_functions as $entry)
- {
- if (is_file(PHPGW_APP_INC . SEP .
'custom' . SEP . $entry['file_name']) && $entry['active'])
- include (PHPGW_APP_INC . SEP . 'custom'
. SEP . $entry['file_name']);
- }
- }
- return receipt;
- }
-
-
- function delete($id )
- {
- $this->so->delete($this->entity_id,$this->cat_id,$id);
- }
-
- function generate_id($data )
- {
- if($data['cat_id'])
- {
- return $this->so->generate_id($data);
- }
- }
- }
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage entity
+ * @version $Id: class.boentity.inc.php,v 1.14 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class boentity
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ var $soap_functions = array(
+ 'list' => array(
+ 'in' =>
array('int','int','struct','string','int'),
+ 'out' => array('array')
+ ),
+ 'read' => array(
+ 'in' => array('int','struct'),
+ 'out' => array('array')
+ ),
+ 'save' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ ),
+ 'delete' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ )
+ );
+
+ function boentity($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.soentity');
+
+ $this->solocation =
CreateObject($this->currentapp.'.solocation');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->vfs =
CreateObject('phpgwapi.vfs');
+ $this->rootdir = $this->vfs->basedir;
+ $this->fakebase = $this->vfs->fakebase;
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $district_id =
get_var('district_id',array('POST','GET'));
+ $entity_id =
get_var('entity_id',array('POST','GET'));
+ $status = get_var('status',array('POST','GET'));
+ $start_date =
get_var('start_date',array('POST','GET'));
+ $end_date =
get_var('end_date',array('POST','GET'));
+
+ $this->soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity',$entity_id,$cat_id);
+
+ $this->category_name =
$this->soadmin_entity->category_name;
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+ if(array_key_exists('query',$_POST) ||
array_key_exists('query',$_GET) )
+ {
+ $this->query = $query;
+ }
+ if(array_key_exists('filter',$_POST))
+ {
+ $this->filter = $filter;
+ }
+ if(array_key_exists('sort',$_POST))
+ {
+ $this->sort = $sort;
+ }
+ if(array_key_exists('order',$_POST))
+ {
+ $this->order = $order;
+ }
+ // if(array_key_exists('cat_id',$_POST) ||
array_key_exists('cat_id',$_GET) )
+ if($cat_id)
+ {
+ $this->cat_id = $cat_id;
+ }
+ if(array_key_exists('district_id',$_POST))
+ {
+ $this->district_id = $district_id;
+ }
+ if($entity_id)
+ {
+ $this->entity_id = $entity_id;
+ }
+ if(array_key_exists('status',$_POST))
+ {
+ $this->status = $status;
+ }
+ if(array_key_exists('start_date',$_POST))
+ {
+ $this->start_date = $start_date;
+ }
+ if(array_key_exists('end_date',$_POST))
+ {
+ $this->end_date = $end_date;
+ }
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','entity',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','entity');
+ //_debug_array($data);
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ // $this->cat_id = $data['cat_id'];
+ $this->district_id = $data['district_id'];
+ // $this->entity_id = $data['entity_id'];
+ $this->status = $data['status'];
+ $this->start_date = $data['start_date'];
+ $this->end_date = $data['end_date'];
+ }
+
+ function
column_list($selected='',$entity_id='',$cat_id,$allrows='')
+ {
+ $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
+
+ if(!$selected)
+ {
+
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]["entity_columns_"
. $this->entity_id . '_' . $this->cat_id];
+ }
+
+ $columns =
$soadmin_entity->read_attrib(array('entity_id'=>$entity_id,'cat_id'=>$cat_id,'allrows'=>$allrows));
+
$column_list=$this->bocommon->select_multi_list($selected,$columns);
+
+ return $column_list;
+ }
+
+ function select_category_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ break;
+ }
+
+ $categories=
$this->soadmin_entity->read_category(array('allrows'=>True,'entity_id'=>$this->entity_id));
+
+ while (is_array($categories) && list(,$category) =
each($categories))
+ {
+ $sel_category = '';
+ if ($category['id']==$selected)
+ {
+ $sel_category = 'selected';
+ }
+
+ $category_list[] = array
+ (
+ 'cat_id' => $category['id'],
+ 'name' => $category['name'],
+ 'selected' => $sel_category
+ );
+ }
+
+ for ($i=0;$i<count($category_list);$i++)
+ {
+ if ($category_list[$i]['selected'] !=
'selected')
+ {
+ unset($category_list[$i]['selected']);
+ }
+ }
+
+ return $category_list;
+ }
+
+
+ function select_status_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('status_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('status_filter'));
+ break;
+ }
+
+ $status_entries=
$this->so->select_status_list($this->entity_id,$this->cat_id);
+
+ while (is_array($status_entries) && list(,$status) =
each($status_entries))
+ {
+ $sel_status = '';
+ if ($status['id']==$selected)
+ {
+ $sel_status = 'selected';
+ }
+
+ $status_list[] = array
+ (
+ 'id' => $status['id'],
+ 'name' => $status['name'],
+ 'selected' => $sel_status
+ );
+ }
+
+ for ($i=0;$i<count($status_list);$i++)
+ {
+ if ($status_list[$i]['selected'] != 'selected')
+ {
+ unset($status_list[$i]['selected']);
+ }
+ }
+
+ return $status_list;
+ }
+
+ function read($data='')
+ {
+ $entity = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' => $this->cat_id,'district_id' =>
$this->district_id,
+
'lookup'=>$data['lookup'],'allrows'=>$data['allrows'],'entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'status'=>$this->status,
+
'start_date'=>$this->bocommon->date_to_timestamp($data['start_date']),'end_date'=>$this->bocommon->date_to_timestamp($data['end_date']),
+
'allrows'=>$data['allrows']));
+
+ $this->total_records = $this->so->total_records;
+ $this->uicols = $this->so->uicols;
+ $cols_extra = $this->so->cols_extra;
+ $cols_return_lookup =
$this->so->cols_return_lookup;
+//_debug_array($entity);
+//_debug_array($cols_extra);
+//_debug_array($cols_return_lookup);
+
+ if($data['lookup'])
+ {
+ for ($i=0;$i<count($entity);$i++)
+ {
+
$location_data=$this->solocation->read_single($entity[$i]['location_code']);
+ for ($j=0;$j<count($cols_extra);$j++)
+ {
+ $entity[$i][$cols_extra[$j]] =
$location_data[$cols_extra[$j]];
+ }
+
+ if($cols_return_lookup)
+ {
+ for
($k=0;$k<count($cols_return_lookup);$k++)
+ {
+
$entity[$i][$cols_return_lookup[$k]] = $location_data[$cols_return_lookup[$k]];
+ }
+ }
+ }
+ }
+
+ return $entity;
+ }
+
+ function read_single($data)
+ {
+ $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
+ $contacts =
CreateObject('phpgwapi.contacts');
+ $vendor = CreateObject($this->currentapp.'.soactor');
+ $vendor->role = 'vendor';
+
+ $entity = $this->so->read_single($data);
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $entity['date'] =
$GLOBALS['phpgw']->common->show_date($entity['date'],$dateformat);
+
+ if($entity['location_code'])
+ {
+
$entity['location_data']=$this->solocation->read_single($entity['location_code']);
+ if($entity['tenant_id'])
+ {
+
$tenant_data=$this->bocommon->read_single_tenant($entity['tenant_id']);
+ $entity['location_data']['tenant_id']
= $entity['tenant_id'];
+
$entity['location_data']['contact_phone']= $entity['contact_phone'];
+ $entity['location_data']['last_name']
= $tenant_data['last_name'];
+ $entity['location_data']['first_name']
= $tenant_data['first_name'];
+ }
+ }
+
+ if($entity['p_num'])
+ {
+ $category =
$soadmin_entity->read_single_category($entity['p_entity_id'],$entity['p_cat_id']);
+
$entity['p'][$entity['p_entity_id']]['p_num']=$entity['p_num'];
+
$entity['p'][$entity['p_entity_id']]['p_entity_id']=$entity['p_entity_id'];
+
$entity['p'][$entity['p_entity_id']]['p_cat_id']=$entity['p_cat_id'];
+
$entity['p'][$entity['p_entity_id']]['p_cat_name'] = $category['name'];
+ }
+
+ $input_type_array = array(
+ 'R' => 'radio',
+ 'CH' => 'checkbox',
+ 'LB' => 'listbox'
+ );
+
+ $sep = '/';
+
+ $dlarr[strpos($dateformat,'Y')] = 'Y';
+ $dlarr[strpos($dateformat,'m')] = 'm';
+ $dlarr[strpos($dateformat,'d')] = 'd';
+ ksort($dlarr);
+ $dateformat= (implode($sep,$dlarr));
+ $m=0;
+
+ for ($i=0;$i<count($entity['attributes']);$i++)
+ {
+ if($entity['attributes'][$i]['datatype']=='D'
&& $entity['attributes'][$i]['value'])
+ {
+ $timestamp_date=
mktime(0,0,0,date(m,strtotime($entity['attributes'][$i]['value'])),date(d,strtotime($entity['attributes'][$i]['value'])),date(y,strtotime($entity['attributes'][$i]['value'])));
+ $entity['attributes'][$i]['value']
= $GLOBALS['phpgw']->common->show_date($timestamp_date,$dateformat);
+ }
+
+ if($entity['attributes'][$i]['datatype']=='AB')
+ {
+ if($entity['attributes'][$i]['value'])
+ {
+ $contact_data
=
$contacts->read_single_entry($entity['attributes'][$i]['value'],array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
+
$entity['attributes'][$i]['contact_name'] = $contact_data[0]['n_family']
. ', ' . $contact_data[0]['n_given'];
+ }
+
+ $insert_record_entity[] =
$entity['attributes'][$i]['name'];
+ $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.addressbook&column='
. $entity['attributes'][$i]['name']);
+ $lookup_functions[$m]['name'] =
'lookup_'. $entity['attributes'][$i]['name'] .'()';
+ $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+ $m++;
+ }
+
+
if($entity['attributes'][$i]['datatype']=='VENDOR')
+ {
+ if($entity['attributes'][$i]['value'])
+ {
+ $vendor_data =
$vendor->read_single(array('actor_id'=>$entity['attributes'][$i]['value']));
+ for
($n=0;$n<count($vendor_data['attributes']);$n++)
+ {
+
if($vendor_data['attributes'][$n]['name'] == 'org_name')
+ {
+
$entity['attributes'][$i]['vendor_name']=
$vendor_data['attributes'][$n]['value'];
+ $n
=count($vendor_data['attributes']);
+ }
+ }
+ }
+
+ $insert_record_entity[] =
$entity['attributes'][$i]['name'];
+ $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor&column='
. $entity['attributes'][$i]['name']);
+ $lookup_functions[$m]['name'] =
'lookup_'. $entity['attributes'][$i]['name'] .'()';
+ $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+ $m++;
+ }
+
+ if($entity['attributes'][$i]['datatype']=='R'
|| $entity['attributes'][$i]['datatype']=='CH' ||
$entity['attributes'][$i]['datatype']=='LB')
+ {
+ $entity['attributes'][$i]['choice']
=
$soadmin_entity->read_attrib_choice($data['entity_id'],$data['cat_id'],$entity['attributes'][$i]['attrib_id']);
+
$input_type=$input_type_array[$entity['attributes'][$i]['datatype']];
+
+
if($entity['attributes'][$i]['datatype']=='CH')
+ {
+
$entity['attributes'][$i]['value']=unserialize($entity['attributes'][$i]['value']);
+
$entity['attributes'][$i]['choice'] =
$this->bocommon->select_multi_list_2($entity['attributes'][$i]['value'],$entity['attributes'][$i]['choice'],$input_type);
+ }
+ else
+ {
+ for
($j=0;$j<count($entity['attributes'][$i]['choice']);$j++)
+ {
+
$entity['attributes'][$i]['choice'][$j]['input_type']=$input_type;
+
if($entity['attributes'][$i]['choice'][$j]['id']==$entity['attributes'][$i]['value'])
+ {
+
$entity['attributes'][$i]['choice'][$j]['checked']='checked';
+ }
+ }
+ }
+ }
+
+ $entity['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($entity['attributes'][$i]['datatype']);
+ $entity['attributes'][$i]['counter'] = $i;
+ $entity['attributes'][$i]['type_id'] =
$data['type_id'];
+ }
+
+ for ($j=0;$j<count($lookup_functions);$j++)
+ {
+ $entity['lookup_functions'] .= 'function ' .
$lookup_functions[$j]['name'] ."\r\n";
+ $entity['lookup_functions'] .= '{'."\r\n";
+ $entity['lookup_functions'] .=
$lookup_functions[$j]['action'] ."\r\n";
+ $entity['lookup_functions'] .= '}'."\r\n";
+ }
+
+ $this->vfs->override_acl = 1;
+
+ $entity['files'] = $this->vfs->ls (array(
+ 'string' => $this->fakebase. '/' .
$this->category_name . '/' . $entity['location_data']['loc1'] . '/' .
$data['id'],
+ 'relatives' => array(RELATIVE_NONE)));
+
+ $this->vfs->override_acl = 0;
+
+ if(!$entity['files'][0]['file_id'])
+ {
+ unset($entity['files']);
+ }
+
+
+
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp,$insert_record_entity);
+
+//_debug_array($insert_record_entity);
+ return $entity;
+ }
+
+
+ function create_home_dir($receipt='')
+ {
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase. SEP .
$this->category_name,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $this->vfs->override_acl = 1;
+
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase. SEP .
$this->category_name,
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . $this->category_name);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . $this->category_name);
+ }
+ $this->vfs->override_acl = 0;
+ }
+
+ return $receipt;
+ }
+
+ function create_document_dir($loc1='',$id='')
+ {
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase. SEP .
$this->category_name . SEP . $loc1,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $this->vfs->override_acl = 1;
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase. SEP .
$this->category_name . SEP . $loc1,
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $loc1);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $loc1);
+ }
+ $this->vfs->override_acl = 0;
+ }
+
+
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase. SEP .
$this->category_name . SEP . $loc1 . SEP . $id,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $this->vfs->override_acl = 1;
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase. SEP .
$this->category_name . SEP . $loc1 . SEP . $id,
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $loc1 . SEP . $id);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $loc1 . SEP . $id);
+ }
+ $this->vfs->override_acl = 0;
+ }
+
+//_debug_array($receipt);
+ return $receipt;
+ }
+
+ function
save($values,$values_attribute,$action='',$entity_id,$cat_id)
+ {
+ while (is_array($values['location']) && list(,$value) =
each($values['location']))
+ {
+ if($value)
+ {
+ $location[] = $value;
+ }
+ }
+
+ $values['location_code']=implode("-", $location);
+
+ $values['date'] =
$this->bocommon->date_to_timestamp($values['date']);
+
+ for ($i=0;$i<count($values_attribute);$i++)
+ {
+ if($values_attribute[$i]['datatype']=='CH' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
serialize($values_attribute[$i]['value']);
+ }
+ if($values_attribute[$i]['datatype']=='R' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
$values_attribute[$i]['value'][0];
+ }
+
+ if($values_attribute[$i]['datatype']=='N' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
str_replace(",",".",$values_attribute[$i]['value']);
+ }
+
+ if($values_attribute[$i]['datatype']=='D' &&
$values_attribute[$i]['value'])
+ {
+
+ $values_attribute[$i]['value'] =
date($this->bocommon->dateformat,$this->bocommon->date_to_timestamp($values_attribute[$i]['value']));
+ }
+ }
+
+ if ($action=='edit')
+ {
+ $receipt =
$this->so->edit($values,$values_attribute,$entity_id,$cat_id);
+
+ if($values['delete_file'])
+ {
+ for
($i=0;$i<count($values['delete_file']);$i++)
+ {
+ $file = $this->fakebase. SEP .
$this->category_name . SEP . $location[0] . SEP . $values['id'] . SEP .
$values['delete_file'][$i];
+
+
if($this->vfs->file_exists(array(
+ 'string' =>
$file,
+ 'relatives' =>
Array(RELATIVE_NONE)
+ )))
+ {
+
$this->vfs->override_acl = 1;
+
+ if(!$this->vfs->rm
(array(
+ 'string' =>
$file,
+ 'relatives' =>
array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to delete file') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $location[0]. SEP .
$values['id'] . SEP .$values['delete_file'][$i]);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('file deleted') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $location[0]. SEP .
$values['id'] . SEP . $values['delete_file'][$i]);
+ }
+
$this->vfs->override_acl = 0;
+ }
+ }
+ }
+ }
+ else
+ {
+ $receipt =
$this->so->add($values,$values_attribute,$entity_id,$cat_id);
+ }
+
+ $acl_location = '.entity.' . $entity_id . '.' . $cat_id;
+ $custom_functions =
$this->soadmin_entity->read_custom_function(array('acl_location' =>
$acl_location,'allrows'=>True));
+
+ if (isSet($custom_functions) AND
is_array($custom_functions))
+ {
+ foreach($custom_functions as $entry)
+ {
+ if (is_file(PHPGW_APP_INC . SEP .
'custom' . SEP . $entry['file_name']) && $entry['active'])
+ include (PHPGW_APP_INC . SEP . 'custom'
. SEP . $entry['file_name']);
+ }
+ }
+ return receipt;
+ }
+
+
+ function delete($id )
+ {
+ $this->so->delete($this->entity_id,$this->cat_id,$id);
+ }
+
+ function generate_id($data )
+ {
+ if($data['cat_id'])
+ {
+ return $this->so->generate_id($data);
+ }
+ }
+ }
?>
\ No newline at end of file
Index: property/inc/class.bogab.inc.php
diff -u property/inc/class.bogab.inc.php:1.6
property/inc/class.bogab.inc.php:1.7
--- property/inc/class.bogab.inc.php:1.6 Thu Aug 18 13:23:16 2005
+++ property/inc/class.bogab.inc.php Fri Jan 27 14:05:43 2006
@@ -1,208 +1,208 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage location
- * @version $Id: class.bogab.inc.php,v 1.6 2005/08/18 13:23:16 sigurdne
Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class bogab
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- function bogab($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->solocation =
CreateObject($this->currentapp.'.solocation');
- $this->config =
CreateObject('phpgwapi.config');
- $this->config->read_repository();
- $gab_insert_level =
$this->config->config_data['gab_insert_level'];
-
- if (! $gab_insert_level)
- {
- $gab_insert_level = 3;
- }
-
- $this->gab_insert_level = $gab_insert_level;
-
- $this->so =
CreateObject($this->currentapp.'.sogab',$this->gab_insert_level);
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $allrows =
get_var('allrows',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
- }
-
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','gab',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','gab');
-
- //_debug_array($data);
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->allrows = $data['allrows'];
- }
-
-
- function
read($loc1='',$gaards_nr='',$bruksnr='',$feste_nr='',$seksjons_nr='',$address='')
- {
- $gab = $this->so->read(array('start' =>
$this->start,'sort' => $this->sort,'order' =>
$this->order,'allrows'=>$this->allrows,
-
'cat_id' => $this->cat_id,'loc1' => $loc1,
-
'gaards_nr' => $gaards_nr,'bruksnr' => $bruksnr,'feste_nr' => $feste_nr,
-
'seksjons_nr' => $seksjons_nr,'address' => $address));
- $this->total_records = $this->so->total_records;
- return $gab;
- }
-
- function read_detail($gab_id='')
- {
- $gab = $this->so->read_detail(array('start' =>
$this->start,'sort' => $this->sort,'order' => $this->order,
-
'cat_id' => $this->cat_id,'gab_id' =>
$gab_id,'allrows'=>$this->allrows));
- $this->total_records = $this->so->total_records;
-
- $this->uicols = $this->so->uicols;
- $cols_extra = $this->so->cols_extra;
-
-
- for ($i=0; $i<count($gab); $i++)
- {
-
$location_data=$this->solocation->read_single($gab[$i]['location_code']);
-
- for ($j=0;$j<count($cols_extra);$j++)
- {
- $gab[$i][$cols_extra[$j]] =
$location_data[$cols_extra[$j]];
- }
- }
-
- return $gab;
- }
-
- function read_single($gab_id='',$location_code='')
- {
- $gab = $this->so->read_single($gab_id,$location_code);
-
- if($gab['location_code'])
- {
- $gab['location_data']
=$this->solocation->read_single($gab['location_code']);
- }
-
- return $gab;
- }
-
-
- function save($values)
- {
- if(!$values['location_code'])
- {
- while (is_array($values['location']) &&
list(,$value) = each($values['location']))
- {
- if($value)
- {
- $location[] = $value;
- }
- }
-
- $values['location_code']=implode("-",
$location);
- }
-
- if ($values['action']=='edit')
- {
- $receipt = $this->so->edit($values);
- }
- else
- {
- $receipt = $this->so->add($values);
- }
-
- $receipt['location_code']=$values['location_code'];
- return $receipt;
- }
-
- function delete($gab_id='',$location_code='')
- {
- $this->so->delete($gab_id,$location_code);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage location
+ * @version $Id: class.bogab.inc.php,v 1.7 2006/01/27 14:05:43 sigurdne
Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class bogab
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ function bogab($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->solocation =
CreateObject($this->currentapp.'.solocation');
+ $this->config =
CreateObject('phpgwapi.config');
+ $this->config->read_repository();
+ $gab_insert_level =
$this->config->config_data['gab_insert_level'];
+
+ if (! $gab_insert_level)
+ {
+ $gab_insert_level = 3;
+ }
+
+ $this->gab_insert_level = $gab_insert_level;
+
+ $this->so =
CreateObject($this->currentapp.'.sogab',$this->gab_insert_level);
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $allrows =
get_var('allrows',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+ }
+
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','gab',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','gab');
+
+ //_debug_array($data);
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->allrows = $data['allrows'];
+ }
+
+
+ function
read($loc1='',$gaards_nr='',$bruksnr='',$feste_nr='',$seksjons_nr='',$address='')
+ {
+ $gab = $this->so->read(array('start' =>
$this->start,'sort' => $this->sort,'order' =>
$this->order,'allrows'=>$this->allrows,
+
'cat_id' => $this->cat_id,'loc1' => $loc1,
+
'gaards_nr' => $gaards_nr,'bruksnr' => $bruksnr,'feste_nr' => $feste_nr,
+
'seksjons_nr' => $seksjons_nr,'address' => $address));
+ $this->total_records = $this->so->total_records;
+ return $gab;
+ }
+
+ function read_detail($gab_id='')
+ {
+ $gab = $this->so->read_detail(array('start' =>
$this->start,'sort' => $this->sort,'order' => $this->order,
+
'cat_id' => $this->cat_id,'gab_id' =>
$gab_id,'allrows'=>$this->allrows));
+ $this->total_records = $this->so->total_records;
+
+ $this->uicols = $this->so->uicols;
+ $cols_extra = $this->so->cols_extra;
+
+
+ for ($i=0; $i<count($gab); $i++)
+ {
+
$location_data=$this->solocation->read_single($gab[$i]['location_code']);
+
+ for ($j=0;$j<count($cols_extra);$j++)
+ {
+ $gab[$i][$cols_extra[$j]] =
$location_data[$cols_extra[$j]];
+ }
+ }
+
+ return $gab;
+ }
+
+ function read_single($gab_id='',$location_code='')
+ {
+ $gab = $this->so->read_single($gab_id,$location_code);
+
+ if($gab['location_code'])
+ {
+ $gab['location_data']
=$this->solocation->read_single($gab['location_code']);
+ }
+
+ return $gab;
+ }
+
+
+ function save($values)
+ {
+ if(!$values['location_code'])
+ {
+ while (is_array($values['location']) &&
list(,$value) = each($values['location']))
+ {
+ if($value)
+ {
+ $location[] = $value;
+ }
+ }
+
+ $values['location_code']=implode("-",
$location);
+ }
+
+ if ($values['action']=='edit')
+ {
+ $receipt = $this->so->edit($values);
+ }
+ else
+ {
+ $receipt = $this->so->add($values);
+ }
+
+ $receipt['location_code']=$values['location_code'];
+ return $receipt;
+ }
+
+ function delete($gab_id='',$location_code='')
+ {
+ $this->so->delete($gab_id,$location_code);
+ }
+ }
+?>
Index: property/inc/class.boinvestment.inc.php
diff -u property/inc/class.boinvestment.inc.php:1.5
property/inc/class.boinvestment.inc.php:1.6
--- property/inc/class.boinvestment.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/class.boinvestment.inc.php Fri Jan 27 14:05:43 2006
@@ -1,393 +1,393 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage eco
- * @version $Id: class.boinvestment.inc.php,v 1.5 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class boinvestment
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-// var $part_of_town_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- var $soap_functions = array(
- 'list' => array(
- 'in' =>
array('int','int','struct','string','int'),
- 'out' => array('array')
- ),
- 'read' => array(
- 'in' => array('int','struct'),
- 'out' => array('array')
- ),
- 'save' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- ),
- 'delete' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- )
- );
-
- function boinvestment($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.soinvestment');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start =
get_var('start',array('POST','GET'));
- $query =
get_var('query',array('POST','GET'));
- $sort =
get_var('sort',array('POST','GET'));
- $order =
get_var('order',array('POST','GET'));
- $filter =
get_var('filter',array('POST','GET'));
- $cat_id =
get_var('cat_id',array('POST','GET'));
- $part_of_town_id =
get_var('part_of_town_id',array('POST','GET'));
- $allrows =
get_var('allrows',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(isset($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- if(isset($part_of_town_id))
- {
- $this->part_of_town_id = $part_of_town_id;
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
-
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','investment');
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->part_of_town_id = $data['part_of_town_id'];
- $this->allrows = $data['allrows'];
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','investment',$data);
- }
- }
-
- function read()
- {
-
- $investment = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' => $this->cat_id,'part_of_town_id'
=> $this->part_of_town_id,'allrows'=>$this->allrows));
- $this->total_records = $this->so->total_records;
-
- /* for ($i=0; $i<count($investment); $i++)
- {
- $investment[$i]['date'] =
$GLOBALS['phpgw']->common->show_date($investment[$i]['date']);
- }
- */
- return $investment;
- }
-
-
- function select_category($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
- $categories= $this->so->get_type_list();
-
- while (is_array($categories) && list(,$category) =
each($categories))
- {
- $sel_category = '';
- if ($category['id']==$selected)
- {
- $sel_category = 'selected';
- }
-
- $category_list[] = array
- (
- 'cat_id' => $category['id'],
- 'name' => $category['num'],
- 'selected' => $sel_category
- );
- }
-
- for ($i=0;$i<count($category_list);$i++)
- {
- if ($category_list[$i]['selected'] !=
'selected')
- {
- unset($category_list[$i]['selected']);
- }
- }
-
- return $category_list;
- }
-
- function write_off_period_list($selected='')
- {
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
-
-
- $categories= $this->so->write_off_period_list();
-
- while (is_array($categories) && list(,$category) =
each($categories))
- {
- $sel_category = '';
- if ($category['period']==$selected)
- {
- $sel_category = 'selected';
- }
-
- $category_list[] = array
- (
- 'cat_id' => $category['period'],
- 'name' => $category['period'],
- 'selected' => $sel_category
- );
- }
-
- for ($i=0;$i<count($category_list);$i++)
- {
- if ($category_list[$i]['selected'] !=
'selected')
- {
- unset($category_list[$i]['selected']);
- }
- }
-
- return $category_list;
- }
-
-
-
-
- function save_investment($values)
- {
- while (is_array($values['location']) && list(,$value) =
each($values['location']))
- {
- if($value)
- {
- $location[] = $value;
- }
- }
-
- $values['location_code']=implode("-", $location);
-
-//_debug_array($values);
-
- $values['date'] =
$this->bocommon->date_to_timestamp($values['date']);
- $values['date']=
date($this->bocommon->dateformat,$values['date']);
-
- $values['initial_value'] =
abs($values['initial_value']);
-
- if($values['type']=='funding')
- {
- $values['initial_value'] =
-$values['initial_value'];
- }
-
- if($values['new_period'])
- {
- $values['period'] = $values['new_period'];
- unset($values['new_period']);
- }
-
- if($values['extra']['p_num'])
- {
- $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
- $category =
$boadmin_entity->read_single_category($values['extra']['p_entity_id'],$values['extra']['p_cat_id']);
- $values['entity_id'] =
$values['extra']['p_num'];
- $values['entity_type'] =$category['name'];
-
- }
- else
- {
- $values['entity_id'] =
$values['location_code'];
- $values['entity_type'] ='property';
- }
-
-
- $receipt=$this->so->save_investment($values);
-
- return $receipt;
- }
-
-
- function update_investment($values)
- {
-
-
$date_array=$this->bocommon->date_array($values['date']);
-
- $date = mktime
(2,0,0,$date_array['month'],$date_array['day'],$date_array['year']);
- $date= date($this->bocommon->dateformat,$date);
-
- $new_index=str_replace(",",".",$values['new_index']);
-
- while($entry=each($values['update']))
- {
- $local_error='';
- $n=$entry[0];
-
- if ($values['value'][$n])
- {
- if ((abs($values['value'][$n])-
abs(($values['initial_value'][$n]*$new_index)))<0)
- {
- $new_value=0;
-
$new_index=$values['value'][$n]/$values['initial_value'][$n];
- }
- else
- {
-
$new_value=$values['value'][$n]-($values['initial_value'][$n]*$new_index);
- }
-
- $update[]=array(
- 'entity_id'
=>$values['entity_id'][$n],
- 'invest_id'
=>$values['investment_id'][$n],
- 'new_index'
=>$new_index,
- 'new_value'
=>$new_value,
- 'initial_value'
=>$values['initial_value'][$n],
- 'date' =>$date
- );
- }
- }
- $this->so->update_investment($update);
- }
-
-
- function filter($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_filter'));
- break;
- }
-
- $filters[0][id]='investment';
- $filters[0][name]=lang('Investment');
- $filters[1][id]='funding';
- $filters[1][name]=lang('Funding');
-
- while (is_array($filters) && list(,$filter) =
each($filters))
- {
- $sel_filter = '';
- if ($filter['id']==$selected)
- {
- $sel_filter = 'selected';
- }
-
- $filter_list[] = array
- (
- 'id' => $filter['id'],
- 'name' => $filter['name'],
- 'selected' => $sel_filter
- );
- }
-
- for ($i=0;$i<count($filter_list);$i++)
- {
- if ($filter_list[$i]['selected'] != 'selected')
- {
- unset($filter_list[$i]['selected']);
- }
- }
-
- return $filter_list;
- }
-
-
- function read_single($entity_id,$investment_id)
- {
- $history =
$this->so->read_single($entity_id,$investment_id,$this->start,$this->allrows);
-
- $this->total_records = $this->so->total_records;
-
- return $history;
- }
-
-
- function select_part_of_town($part_of_town_id)
- {
- return
$this->socommon->select_part_of_town($part_of_town_id);
- }
-
-
- function delete($entity_id,$investment_id,$index_count)
- {
-
$this->so->delete($entity_id,$investment_id,$index_count);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage eco
+ * @version $Id: class.boinvestment.inc.php,v 1.6 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class boinvestment
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+// var $part_of_town_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ var $soap_functions = array(
+ 'list' => array(
+ 'in' =>
array('int','int','struct','string','int'),
+ 'out' => array('array')
+ ),
+ 'read' => array(
+ 'in' => array('int','struct'),
+ 'out' => array('array')
+ ),
+ 'save' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ ),
+ 'delete' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ )
+ );
+
+ function boinvestment($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.soinvestment');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->socommon =
CreateObject($this->currentapp.'.socommon');
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start =
get_var('start',array('POST','GET'));
+ $query =
get_var('query',array('POST','GET'));
+ $sort =
get_var('sort',array('POST','GET'));
+ $order =
get_var('order',array('POST','GET'));
+ $filter =
get_var('filter',array('POST','GET'));
+ $cat_id =
get_var('cat_id',array('POST','GET'));
+ $part_of_town_id =
get_var('part_of_town_id',array('POST','GET'));
+ $allrows =
get_var('allrows',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(isset($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ if(isset($part_of_town_id))
+ {
+ $this->part_of_town_id = $part_of_town_id;
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','investment');
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->part_of_town_id = $data['part_of_town_id'];
+ $this->allrows = $data['allrows'];
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','investment',$data);
+ }
+ }
+
+ function read()
+ {
+
+ $investment = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' => $this->cat_id,'part_of_town_id'
=> $this->part_of_town_id,'allrows'=>$this->allrows));
+ $this->total_records = $this->so->total_records;
+
+ /* for ($i=0; $i<count($investment); $i++)
+ {
+ $investment[$i]['date'] =
$GLOBALS['phpgw']->common->show_date($investment[$i]['date']);
+ }
+ */
+ return $investment;
+ }
+
+
+ function select_category($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ break;
+ }
+
+ $categories= $this->so->get_type_list();
+
+ while (is_array($categories) && list(,$category) =
each($categories))
+ {
+ $sel_category = '';
+ if ($category['id']==$selected)
+ {
+ $sel_category = 'selected';
+ }
+
+ $category_list[] = array
+ (
+ 'cat_id' => $category['id'],
+ 'name' => $category['num'],
+ 'selected' => $sel_category
+ );
+ }
+
+ for ($i=0;$i<count($category_list);$i++)
+ {
+ if ($category_list[$i]['selected'] !=
'selected')
+ {
+ unset($category_list[$i]['selected']);
+ }
+ }
+
+ return $category_list;
+ }
+
+ function write_off_period_list($selected='')
+ {
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+
+
+ $categories= $this->so->write_off_period_list();
+
+ while (is_array($categories) && list(,$category) =
each($categories))
+ {
+ $sel_category = '';
+ if ($category['period']==$selected)
+ {
+ $sel_category = 'selected';
+ }
+
+ $category_list[] = array
+ (
+ 'cat_id' => $category['period'],
+ 'name' => $category['period'],
+ 'selected' => $sel_category
+ );
+ }
+
+ for ($i=0;$i<count($category_list);$i++)
+ {
+ if ($category_list[$i]['selected'] !=
'selected')
+ {
+ unset($category_list[$i]['selected']);
+ }
+ }
+
+ return $category_list;
+ }
+
+
+
+
+ function save_investment($values)
+ {
+ while (is_array($values['location']) && list(,$value) =
each($values['location']))
+ {
+ if($value)
+ {
+ $location[] = $value;
+ }
+ }
+
+ $values['location_code']=implode("-", $location);
+
+//_debug_array($values);
+
+ $values['date'] =
$this->bocommon->date_to_timestamp($values['date']);
+ $values['date']=
date($this->bocommon->dateformat,$values['date']);
+
+ $values['initial_value'] =
abs($values['initial_value']);
+
+ if($values['type']=='funding')
+ {
+ $values['initial_value'] =
-$values['initial_value'];
+ }
+
+ if($values['new_period'])
+ {
+ $values['period'] = $values['new_period'];
+ unset($values['new_period']);
+ }
+
+ if($values['extra']['p_num'])
+ {
+ $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
+ $category =
$boadmin_entity->read_single_category($values['extra']['p_entity_id'],$values['extra']['p_cat_id']);
+ $values['entity_id'] =
$values['extra']['p_num'];
+ $values['entity_type'] =$category['name'];
+
+ }
+ else
+ {
+ $values['entity_id'] =
$values['location_code'];
+ $values['entity_type'] ='property';
+ }
+
+
+ $receipt=$this->so->save_investment($values);
+
+ return $receipt;
+ }
+
+
+ function update_investment($values)
+ {
+
+
$date_array=$this->bocommon->date_array($values['date']);
+
+ $date = mktime
(2,0,0,$date_array['month'],$date_array['day'],$date_array['year']);
+ $date= date($this->bocommon->dateformat,$date);
+
+ $new_index=str_replace(",",".",$values['new_index']);
+
+ while($entry=each($values['update']))
+ {
+ $local_error='';
+ $n=$entry[0];
+
+ if ($values['value'][$n])
+ {
+ if ((abs($values['value'][$n])-
abs(($values['initial_value'][$n]*$new_index)))<0)
+ {
+ $new_value=0;
+
$new_index=$values['value'][$n]/$values['initial_value'][$n];
+ }
+ else
+ {
+
$new_value=$values['value'][$n]-($values['initial_value'][$n]*$new_index);
+ }
+
+ $update[]=array(
+ 'entity_id'
=>$values['entity_id'][$n],
+ 'invest_id'
=>$values['investment_id'][$n],
+ 'new_index'
=>$new_index,
+ 'new_value'
=>$new_value,
+ 'initial_value'
=>$values['initial_value'][$n],
+ 'date' =>$date
+ );
+ }
+ }
+ $this->so->update_investment($update);
+ }
+
+
+ function filter($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_filter'));
+ break;
+ }
+
+ $filters[0][id]='investment';
+ $filters[0][name]=lang('Investment');
+ $filters[1][id]='funding';
+ $filters[1][name]=lang('Funding');
+
+ while (is_array($filters) && list(,$filter) =
each($filters))
+ {
+ $sel_filter = '';
+ if ($filter['id']==$selected)
+ {
+ $sel_filter = 'selected';
+ }
+
+ $filter_list[] = array
+ (
+ 'id' => $filter['id'],
+ 'name' => $filter['name'],
+ 'selected' => $sel_filter
+ );
+ }
+
+ for ($i=0;$i<count($filter_list);$i++)
+ {
+ if ($filter_list[$i]['selected'] != 'selected')
+ {
+ unset($filter_list[$i]['selected']);
+ }
+ }
+
+ return $filter_list;
+ }
+
+
+ function read_single($entity_id,$investment_id)
+ {
+ $history =
$this->so->read_single($entity_id,$investment_id,$this->start,$this->allrows);
+
+ $this->total_records = $this->so->total_records;
+
+ return $history;
+ }
+
+
+ function select_part_of_town($part_of_town_id)
+ {
+ return
$this->socommon->select_part_of_town($part_of_town_id);
+ }
+
+
+ function delete($entity_id,$investment_id,$index_count)
+ {
+
$this->so->delete($entity_id,$investment_id,$index_count);
+ }
+ }
+?>
Index: property/inc/class.boinvoice.inc.php
diff -u property/inc/class.boinvoice.inc.php:1.15
property/inc/class.boinvoice.inc.php:1.16
--- property/inc/class.boinvoice.inc.php:1.15 Fri Aug 26 12:03:56 2005
+++ property/inc/class.boinvoice.inc.php Fri Jan 27 14:05:43 2006
@@ -1,725 +1,725 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage eco
- * @version $Id: class.boinvoice.inc.php,v 1.15 2005/08/26 12:03:56
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class boinvoice
- {
- var $db = '';
-
- function boinvoice($session=False)
- {
- $this->db = $GLOBALS['phpgw']->db;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.soinvoice',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->account_id =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start =
get_var('start',array('POST','GET'));
- $query =
get_var('query',array('POST','GET'));
- $sort =
get_var('sort',array('POST','GET'));
- $order =
get_var('order',array('POST','GET'));
- $filter =
get_var('filter',array('POST','GET'));
- $cat_id =
get_var('cat_id',array('POST','GET'));
- $user_lid =
get_var('user_lid',array('POST','GET'));
- $allrows =
get_var('allrows',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- if(isset($user_lid))
- {
- $this->user_lid = $user_lid;
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
- }
-
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','invoice',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data',invoice);
-
-// _debug_array($data);
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->user_lid = $data['user_lid'];
- $this->sub = $data['sub'];
- $this->allrows = $data['allrows'];
- }
-
- function
read_invoice($paid='',$start_date='',$end_date='',$vendor_id='',$loc1='',$workorder_id='',$voucher_id='')
- {
- $invoice = $this->so->read_invoice(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'user_lid' => $this->user_lid,'cat_id' => $this->cat_id, 'paid' =>
$paid,
-
'start_date'=>$start_date,'end_date'=>$end_date,'vendor_id'=>$vendor_id,
-
'loc1'=>$loc1,'workorder_id'=>$workorder_id,'allrows'=>$this->allrows,
-
'voucher_id'=>$voucher_id));
-
- $this->total_records = $this->so->total_records;
- $this->end_time = $this->so->end_time;
-
- return $invoice;
- }
-
- function read_invoice_sub($voucher_id='',$paid='')
- {
- $invoice = $this->so->read_invoice_sub(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'user_lid' => $this->user_lid,'cat_id' =>
$this->cat_id,'voucher_id'=>$voucher_id,'paid' => $paid));
- $this->total_records = $this->so->total_records;
- return $invoice;
- }
-
- function read_remark($id='',$paid='')
- {
- return $remark = $this->so->read_remark($id,$paid);
- }
-
-
- function
read_consume($start_date='',$end_date='',$vendor_id='',$loc1='',$workorder_id='',$b_account_class='',$district_id='')
- {
- $invoice = $this->so->read_consume(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'user_lid' => $this->user_lid,'cat_id' => $this->cat_id,
-
'start_date'=>$start_date,'end_date'=>$end_date,'vendor_id'=>$vendor_id,
-
'loc1'=>$loc1,'workorder_id'=>$workorder_id,'b_account_class'
=>$b_account_class,
-
'district_id' => $district_id ));
-
- $this->total_records = $this->so->total_records;
-
- return $invoice;
- }
-
-
- function update_invoice($values)
- {
-
- return $this->so->update_invoice($values);
-
- }
-
-
- function update_invoice_sub($values)
- {
- return $this->so->update_invoice_sub($values);
- }
-
- function select_account_class($selected='')
- {
-
- $b_account_class_list=
$this->so->select_account_class();
-
- while (is_array($b_account_class_list) && list(,$class)
= each($b_account_class_list))
- {
- $sel_class = '';
- if ($class['id']==$selected)
- {
- $sel_class = 'selected';
- }
-
- $class_list[] = array
- (
- 'id' => $class['id'],
- 'name' => $class['name'],
- 'selected' => $sel_class
- );
- }
-
- for ($i=0;$i<count($class_list);$i++)
- {
- if ($class_list[$i]['selected'] != 'selected')
- {
- unset($class_list[$i]['selected']);
- }
- }
-
- return $class_list;
- }
-
-
-
- function period_list($selected='')
- {
- for ($i=1; $i<=12; $i++)
- {
- $period_list[$i]['id'] = $i;
- $period_list[$i]['name'] = $i;
- if($i==$selected)
- {
- $period_list[$i]['selected'] =
'selected';
- }
- }
- return $period_list;
- }
-
- function tax_code_list($selected='')
- {
- $tax_codes=$this->so->tax_code_list();
-
- while (is_array($tax_codes) && list(,$code) =
each($tax_codes))
- {
- $sel_code = '';
- if ($code['id']==$selected)
- {
- $sel_code = 'selected';
- }
-
- $tax_code_list[] = array
- (
- 'id' => $code['id'],
- 'selected' => $sel_code
- );
- }
-
- for ($i=0;$i<count($tax_code_list);$i++)
- {
- if ($tax_code_list[$i]['selected'] !=
'selected')
- {
- unset($tax_code_list[$i]['selected']);
- }
- }
-
- return $tax_code_list;
- }
-
- function update_period($voucher_id='',$period='')
- {
- return $this->so->update_period($voucher_id,$period);
- }
-
- function increment_bilagsnr()
- {
-
- return $this->so->increment_bilagsnr();
-
- }
-
- function next_bilagsnr()
- {
- return $this->so->next_bilagsnr();
- }
-
- function check_vendor($vendor_id)
- {
-
- return $this->so->check_vendor($vendor_id);
- }
-
-
- function get_lisfm_ecoart($selected='')
- {
- $arts=$this->so->get_lisfm_ecoart();
-
- while (is_array($arts) && list(,$art) = each($arts))
- {
- $sel_art = '';
- if ($art['id']==$selected)
- {
- $sel_art = 'selected';
- }
-
- $art_list[] = array
- (
- 'id' => $art['id'],
- 'num' => $art['num'],
- 'selected' => $sel_art
- );
- }
-
- for ($i=0;$i<count($art_list);$i++)
- {
- if ($art_list[$i]['selected'] != 'selected')
- {
- unset($art_list[$i]['selected']);
- }
- }
-
- return $art_list;
- }
- //----------
-
- function select_category($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
- $categories= $this->so->get_type_list();
-
- while (is_array($categories) && list(,$category) =
each($categories))
- {
- $sel_category = '';
- if ($category['id']==$selected)
- {
- $sel_category = 'selected';
- }
-
- $category_list[] = array
- (
- 'cat_id' => $category['id'],
- 'name' => $category['num'],
- 'selected' => $sel_category
- );
- }
-
- for ($i=0;$i<count($category_list);$i++)
- {
- if ($category_list[$i]['selected'] !=
'selected')
- {
- unset($category_list[$i]['selected']);
- }
- }
-
- return $category_list;
- }
-
-
- function
get_invoice_user_list($format='',$selected='',$extra='',$default='')
- {
- if(!$selected && $default)
- {
- $selected = $default;
- }
-
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('user_lid_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('user_lid_filter'));
- break;
- }
-
- if (is_array($extra))
- {
- foreach($extra as $extra_user)
- {
- $users_extra[]=array
- (
- 'account_lid' => $extra_user,
- 'account_firstname' =>
lang($extra_user)
- );
- }
- }
-
- $users= $this->so->get_invoice_user_list();
- if (is_array($users_extra) && is_array($users))
- {
- $users = $users_extra + $users;
- }
-
- while (is_array($users) && list(,$user) = each($users))
- {
- $sel_user = '';
- if ($user['account_lid']==$selected)
- {
- $sel_user = 'selected';
- }
-
- $user_list[] = array
- (
- 'user_lid' => $user['account_lid'],
- 'name' =>
$user['account_lastname'].' '.$user['account_firstname'],
- 'selected' => $sel_user
- );
- }
-
- for ($i=0;$i<count($user_list);$i++)
- {
- if ($user_list[$i]['selected'] != 'selected')
- {
- unset($user_list[$i]['selected']);
- }
- }
-
-//_debug_array($user_list);
- return $user_list;
- }
-
-
-
- function get_type_list($selected='')
- {
- $types=$this->so->get_type_list();
-
- while (is_array($types) && list(,$type) = each($types))
- {
- $sel_type = '';
- if ($type['id']==$selected)
- {
- $sel_type = 'selected';
- }
-
- $type_list[] = array
- (
- 'id' => $type['id'],
- 'num' => $type['num'],
- 'selected' => $sel_type
- );
- }
-
- for ($i=0;$i<count($type_list);$i++)
- {
- if ($type_list[$i]['selected'] != 'selected')
- {
- unset($type_list[$i]['selected']);
- }
- }
-
- return $type_list;
- }
-
- //----------
- function select_dimb_list($selected='')
- {
- $dimbs=$this->so->select_dimb_list();
-
- while (is_array($dimbs) && list(,$dimb) = each($dimbs))
- {
- $sel_dimb = '';
- if ($dimb['id']==$selected)
- {
- $sel_dimb = 'selected';
- }
-
- $dimb_list[] = array
- (
- 'id' => $dimb['id'],
- 'num' => $dimb['num'],
- 'selected' => $sel_dimb
- );
- }
-
- for ($i=0;$i<count($dimb_list);$i++)
- {
- if ($dimb_list[$i]['selected'] != 'selected')
- {
- unset($dimb_list[$i]['selected']);
- }
- }
-
- return $dimb_list;
- }
-
- //-------------------
- function select_dimd_list($selected='')
- {
- $dimds=$this->so->select_dimd_list();
-
- while (is_array($dimds) && list(,$dimd) = each($dimds))
- {
- $sel_dimd = '';
- if ($dimd['id']==$selected)
- {
- $sel_dimd = 'selected';
- }
-
- $dimd_list[] = array
- (
- 'id' => $dimd['id'],
- 'num' => $dimd['num'],
- 'selected' => $sel_dimd
- );
- }
-
- for ($i=0;$i<count($dimd_list);$i++)
- {
- if ($dimd_list[$i]['selected'] != 'selected')
- {
- unset($dimd_list[$i]['selected']);
- }
- }
-
- return $dimd_list;
- }
-
- function select_tax_code_list($selected='')
- {
- $tax_codes=$this->so->select_tax_code_list();
-
- while (is_array($tax_codes) && list(,$tax_code) =
each($tax_codes))
- {
- $sel_tax_code = '';
- if ($tax_code['id']==$selected)
- {
- $sel_tax_code = 'selected';
- }
-
- $tax_code_list[] = array
- (
- 'id' => $tax_code['id'],
- 'num' => $tax_code['num'],
- 'selected' => $sel_tax_code
- );
- }
-
- for ($i=0;$i<count($tax_code_list);$i++)
- {
- if ($tax_code_list[$i]['selected'] !=
'selected')
- {
- unset($tax_code_list[$i]['selected']);
- }
- }
- return $tax_code_list;
- }
-
- function delete($params)
- {
- if (is_array($params))
- {
- $this->so->delete($params[0]);
- }
- else
- {
- $this->so->delete($params);
- }
- }
-
- function add($values,$debug='')
- {
- $this->soXport =
CreateObject($this->currentapp.'.soXport');
- if($values['loc1']=$values['location']['loc1'])
- {
- $values['dima']=implode('',$values['location']);
- }
-
- $values['spbudact_code']=$values['b_account_id'];
- $values['fakturanr']=$values['invoice_num'];
- $values['spvend_code']=$values['vendor_id'];
-
- $values['belop'] =
str_replace('kr','',$values['amount']);
- $values['belop'] = str_replace(' ','',$values['belop']);
- $values['belop'] =
str_replace(',','.',$values['belop']);
- $values['godkjentbelop']=$values['belop'];
-
- $values['fakturadato'] =
date($this->bocommon->dateformat,mktime(2,0,0,$values['smonth'],$values['sday'],$values['syear']));
-
- if($values['num_days'])
- {
- $values['forfallsdato'] =
date($this->bocommon->dateformat,mktime(2,0,0,$values['smonth'],$values['sday'],$values['syear'])+(86400*$values['num_days']));
- }
- else
- {
- $values['forfallsdato'] =
date($this->bocommon->dateformat,mktime(2,0,0,$values['emonth'],$values['eday'],$values['eyear']));
- }
-
- $values['artid'] =
$values['art'];
- $values['periode'] =
$values['smonth'];
- $values['dimb'] =
$values['dim_b'];
- $values['oppsynsmannid'] = $values['janitor'];
- $values['saksbehandlerid'] = $values['supervisor'];
- $values['budsjettansvarligid'] =
$values['budget_responsible'];
- $values['kildeid'] = 1;
- $values['kidnr'] =
$values['kid_nr'];
- $values['typeid'] =
$values['type'];
- if($order_type =
$this->soXport->check_order(intval($values['order'])))
- {
- if($order_type=='workorder')
- {
- $soworkorder =
CreateObject($this->currentapp.'.soworkorder');
- $soproject =
CreateObject($this->currentapp.'.soproject');
- $workorder =
$soworkorder->read_single($values['order']);
- $project =
$soproject->read_single($workorder['project_id']);
-
- $values['spvend_code'] =
$workorder['vendor_id'];
- $values['spbudact_code'] =
$workorder['b_account_id'];
- $values['location_code']
=$project['location_code'];
- $values['dima']
=str_replace('-','',$project['location_code']);
- $values['vendor_name'] =
$this->get_vendor_name($workorder['vendor_id']);
- $values['pmwrkord_code'] =
$values['order'];
- $values['project_id']
= $workorder['project_id'];
-
- $values =
$this->set_responsible($values,$workorder['user_id'],$workorder['b_account_id']);
-
- if($values['auto_tax'])
- {
- $values['mvakode'] =
$this->soXport->auto_tax($values['dima']);
- $values['mvakode'] =
$this->soXport->tax_b_account_override($values['mvakode'],$values['spbudact_code']);
- $values['mvakode'] =
$this->soXport->tax_vendor_override($values['mvakode'],$values['spvend_code']);
- $values['kostra_id'] =
$this->soXport->get_kostra_id($values['dima']);
- }
-
- $buffer[0]=$values;
- }
-
- if($order_type=='s_agreement')
- {
- $sos_agreement =
CreateObject($this->currentapp.'.sos_agreement');
- $s_agreement =
$sos_agreement->read_single(array('s_agreement_id'=>$values['order']));
-
- $values['spvend_code'] =
$s_agreement['vendor_id'];
- $values['spbudact_code'] =
$s_agreement['b_account_id'];
- $values['vendor_name'] =
$this->get_vendor_name($s_agreement['vendor_id']);
- $values['pmwrkord_code'] =
intval($values['order']);
- $values =
$this->set_responsible($values,$s_agreement['user_id'],$s_agreement['b_account_id']);
-
-
- $s_agreement_detail =
$sos_agreement->read(array('allrows'=>True,'s_agreement_id'=>$values['order'],'detail'=>True));
-
- $sum_agreement=0;
- for
($i=0;$i<count($s_agreement_detail);$i++)
- {
- $sum_agreement = $sum_agreement
+ $s_agreement_detail[$i]['cost'];
- }
-
-
- for
($i=0;$i<count($s_agreement_detail);$i++)
- {
- $buffer[$i]=$values;
-
- $buffer[$i]['location_code']
=$s_agreement_detail[$i]['location_code'];
- $buffer[$i]['dima']
=str_replace('-','',$s_agreement_detail[$i]['location_code']);
-
-
- $buffer[$i]['belop'] =
round($values['belop'] / $sum_agreement * $s_agreement_detail[$i]['cost'],2);
- $buffer[$i]['godkjentbelop']
=$buffer[$i]['belop'];
-
- if($values['auto_tax'])
- {
- $buffer[$i]['mvakode']
= $this->soXport->auto_tax($buffer[$i]['dima']);
- $buffer[$i]['mvakode']
=
$this->soXport->tax_b_account_override($buffer[$i]['mvakode'],$buffer[$i]['spbudact_code']);
- $buffer[$i]['mvakode']
=
$this->soXport->tax_vendor_override($buffer[$i]['mvakode'],$buffer[$i]['spvend_code']);
-
$buffer[$i]['kostra_id'] = $this->soXport->get_kostra_id($buffer[$i]['dima']);
- }
- }
- }
- }
- else
- {
- if($values['auto_tax'])
- {
- $values['mvakode'] =
$this->soXport->auto_tax($values['loc1']);
- $values['mvakode'] =
$this->soXport->tax_b_account_override($values['mvakode'],$values['spbudact_code']);
- $values['mvakode'] =
$this->soXport->tax_vendor_override($values['mvakode'],$values['spvend_code']);
- $values['kostra_id'] =
$this->soXport->get_kostra_id($values['loc1']);
- }
-
- $buffer[0]=$values;
- }
-
- if($debug)
- {
- return $buffer;
- }
-
- if($this->soXport->add($buffer)>0)
- {
- $receipt['message'][] =
array('msg'=>lang('Invoice %1 is added',$values['bilagsnr']));
- }
- else
- {
- $receipt['error'][] =
array('msg'=>lang('Invoice is NOT added!'));
- }
- return $receipt;
- }
-
- function get_vendor_name($vendor_id='')
- {
- $contacts =
CreateObject($this->currentapp.'.soactor');
- $contacts->role='vendor';
-
- $vendor_data =
$contacts->read_single(array('actor_id'=>$vendor_id));
- if(is_array($vendor_data))
- {
- foreach($vendor_data['attributes'] as
$attribute)
- {
- if($attribute['name']=='org_name')
- {
- return $attribute['value'];
- }
- }
- }
- }
-
- function set_responsible($values,$user_id='',$b_account_id='')
- {
- if (!$values['budget_responsible'])
- {
- $values['budget_responsible'] =
$this->soXport->get_responsible($b_account_id);
- $values['budsjettansvarligid'] =
$values['budget_responsible'];
- }
-
- $acl2 =
CreateObject($this->currentapp.'.acl2',$user_id);
- if($acl2->check('.invoice',32) &&
!$acl2->check('.invoice',64)):
- {
- $values['janitor'] =
$GLOBALS['phpgw']->accounts->id2name($user_id);
- $values['oppsynsmannid'] =
$values['janitor'];
- }
- // elseif((!$acl2->check('.invoice',32) &&
$acl2->check('.invoice',64)) || ($acl2->check('.invoice',32) &&
$acl2->check('.invoice',64))):
- elseif($acl2->check('.invoice',64)):
- {
- $values['supervisor'] =
$GLOBALS['phpgw']->accounts->id2name($user_id);
- $values['saksbehandlerid'] =
$values['supervisor'];
- }
- endif;
-
- return $values;
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage eco
+ * @version $Id: class.boinvoice.inc.php,v 1.16 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class boinvoice
+ {
+ var $db = '';
+
+ function boinvoice($session=False)
+ {
+ $this->db = $GLOBALS['phpgw']->db;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.soinvoice',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->account_id =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start =
get_var('start',array('POST','GET'));
+ $query =
get_var('query',array('POST','GET'));
+ $sort =
get_var('sort',array('POST','GET'));
+ $order =
get_var('order',array('POST','GET'));
+ $filter =
get_var('filter',array('POST','GET'));
+ $cat_id =
get_var('cat_id',array('POST','GET'));
+ $user_lid =
get_var('user_lid',array('POST','GET'));
+ $allrows =
get_var('allrows',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ if(isset($user_lid))
+ {
+ $this->user_lid = $user_lid;
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+ }
+
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','invoice',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data',invoice);
+
+// _debug_array($data);
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->user_lid = $data['user_lid'];
+ $this->sub = $data['sub'];
+ $this->allrows = $data['allrows'];
+ }
+
+ function
read_invoice($paid='',$start_date='',$end_date='',$vendor_id='',$loc1='',$workorder_id='',$voucher_id='')
+ {
+ $invoice = $this->so->read_invoice(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'user_lid' => $this->user_lid,'cat_id' => $this->cat_id, 'paid' =>
$paid,
+
'start_date'=>$start_date,'end_date'=>$end_date,'vendor_id'=>$vendor_id,
+
'loc1'=>$loc1,'workorder_id'=>$workorder_id,'allrows'=>$this->allrows,
+
'voucher_id'=>$voucher_id));
+
+ $this->total_records = $this->so->total_records;
+ $this->end_time = $this->so->end_time;
+
+ return $invoice;
+ }
+
+ function read_invoice_sub($voucher_id='',$paid='')
+ {
+ $invoice = $this->so->read_invoice_sub(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'user_lid' => $this->user_lid,'cat_id' =>
$this->cat_id,'voucher_id'=>$voucher_id,'paid' => $paid));
+ $this->total_records = $this->so->total_records;
+ return $invoice;
+ }
+
+ function read_remark($id='',$paid='')
+ {
+ return $remark = $this->so->read_remark($id,$paid);
+ }
+
+
+ function
read_consume($start_date='',$end_date='',$vendor_id='',$loc1='',$workorder_id='',$b_account_class='',$district_id='')
+ {
+ $invoice = $this->so->read_consume(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'user_lid' => $this->user_lid,'cat_id' => $this->cat_id,
+
'start_date'=>$start_date,'end_date'=>$end_date,'vendor_id'=>$vendor_id,
+
'loc1'=>$loc1,'workorder_id'=>$workorder_id,'b_account_class'
=>$b_account_class,
+
'district_id' => $district_id ));
+
+ $this->total_records = $this->so->total_records;
+
+ return $invoice;
+ }
+
+
+ function update_invoice($values)
+ {
+
+ return $this->so->update_invoice($values);
+
+ }
+
+
+ function update_invoice_sub($values)
+ {
+ return $this->so->update_invoice_sub($values);
+ }
+
+ function select_account_class($selected='')
+ {
+
+ $b_account_class_list=
$this->so->select_account_class();
+
+ while (is_array($b_account_class_list) && list(,$class)
= each($b_account_class_list))
+ {
+ $sel_class = '';
+ if ($class['id']==$selected)
+ {
+ $sel_class = 'selected';
+ }
+
+ $class_list[] = array
+ (
+ 'id' => $class['id'],
+ 'name' => $class['name'],
+ 'selected' => $sel_class
+ );
+ }
+
+ for ($i=0;$i<count($class_list);$i++)
+ {
+ if ($class_list[$i]['selected'] != 'selected')
+ {
+ unset($class_list[$i]['selected']);
+ }
+ }
+
+ return $class_list;
+ }
+
+
+
+ function period_list($selected='')
+ {
+ for ($i=1; $i<=12; $i++)
+ {
+ $period_list[$i]['id'] = $i;
+ $period_list[$i]['name'] = $i;
+ if($i==$selected)
+ {
+ $period_list[$i]['selected'] =
'selected';
+ }
+ }
+ return $period_list;
+ }
+
+ function tax_code_list($selected='')
+ {
+ $tax_codes=$this->so->tax_code_list();
+
+ while (is_array($tax_codes) && list(,$code) =
each($tax_codes))
+ {
+ $sel_code = '';
+ if ($code['id']==$selected)
+ {
+ $sel_code = 'selected';
+ }
+
+ $tax_code_list[] = array
+ (
+ 'id' => $code['id'],
+ 'selected' => $sel_code
+ );
+ }
+
+ for ($i=0;$i<count($tax_code_list);$i++)
+ {
+ if ($tax_code_list[$i]['selected'] !=
'selected')
+ {
+ unset($tax_code_list[$i]['selected']);
+ }
+ }
+
+ return $tax_code_list;
+ }
+
+ function update_period($voucher_id='',$period='')
+ {
+ return $this->so->update_period($voucher_id,$period);
+ }
+
+ function increment_bilagsnr()
+ {
+
+ return $this->so->increment_bilagsnr();
+
+ }
+
+ function next_bilagsnr()
+ {
+ return $this->so->next_bilagsnr();
+ }
+
+ function check_vendor($vendor_id)
+ {
+
+ return $this->so->check_vendor($vendor_id);
+ }
+
+
+ function get_lisfm_ecoart($selected='')
+ {
+ $arts=$this->so->get_lisfm_ecoart();
+
+ while (is_array($arts) && list(,$art) = each($arts))
+ {
+ $sel_art = '';
+ if ($art['id']==$selected)
+ {
+ $sel_art = 'selected';
+ }
+
+ $art_list[] = array
+ (
+ 'id' => $art['id'],
+ 'num' => $art['num'],
+ 'selected' => $sel_art
+ );
+ }
+
+ for ($i=0;$i<count($art_list);$i++)
+ {
+ if ($art_list[$i]['selected'] != 'selected')
+ {
+ unset($art_list[$i]['selected']);
+ }
+ }
+
+ return $art_list;
+ }
+ //----------
+
+ function select_category($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ break;
+ }
+
+ $categories= $this->so->get_type_list();
+
+ while (is_array($categories) && list(,$category) =
each($categories))
+ {
+ $sel_category = '';
+ if ($category['id']==$selected)
+ {
+ $sel_category = 'selected';
+ }
+
+ $category_list[] = array
+ (
+ 'cat_id' => $category['id'],
+ 'name' => $category['num'],
+ 'selected' => $sel_category
+ );
+ }
+
+ for ($i=0;$i<count($category_list);$i++)
+ {
+ if ($category_list[$i]['selected'] !=
'selected')
+ {
+ unset($category_list[$i]['selected']);
+ }
+ }
+
+ return $category_list;
+ }
+
+
+ function
get_invoice_user_list($format='',$selected='',$extra='',$default='')
+ {
+ if(!$selected && $default)
+ {
+ $selected = $default;
+ }
+
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('user_lid_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('user_lid_filter'));
+ break;
+ }
+
+ if (is_array($extra))
+ {
+ foreach($extra as $extra_user)
+ {
+ $users_extra[]=array
+ (
+ 'account_lid' => $extra_user,
+ 'account_firstname' =>
lang($extra_user)
+ );
+ }
+ }
+
+ $users= $this->so->get_invoice_user_list();
+ if (is_array($users_extra) && is_array($users))
+ {
+ $users = $users_extra + $users;
+ }
+
+ while (is_array($users) && list(,$user) = each($users))
+ {
+ $sel_user = '';
+ if ($user['account_lid']==$selected)
+ {
+ $sel_user = 'selected';
+ }
+
+ $user_list[] = array
+ (
+ 'user_lid' => $user['account_lid'],
+ 'name' =>
$user['account_lastname'].' '.$user['account_firstname'],
+ 'selected' => $sel_user
+ );
+ }
+
+ for ($i=0;$i<count($user_list);$i++)
+ {
+ if ($user_list[$i]['selected'] != 'selected')
+ {
+ unset($user_list[$i]['selected']);
+ }
+ }
+
+//_debug_array($user_list);
+ return $user_list;
+ }
+
+
+
+ function get_type_list($selected='')
+ {
+ $types=$this->so->get_type_list();
+
+ while (is_array($types) && list(,$type) = each($types))
+ {
+ $sel_type = '';
+ if ($type['id']==$selected)
+ {
+ $sel_type = 'selected';
+ }
+
+ $type_list[] = array
+ (
+ 'id' => $type['id'],
+ 'num' => $type['num'],
+ 'selected' => $sel_type
+ );
+ }
+
+ for ($i=0;$i<count($type_list);$i++)
+ {
+ if ($type_list[$i]['selected'] != 'selected')
+ {
+ unset($type_list[$i]['selected']);
+ }
+ }
+
+ return $type_list;
+ }
+
+ //----------
+ function select_dimb_list($selected='')
+ {
+ $dimbs=$this->so->select_dimb_list();
+
+ while (is_array($dimbs) && list(,$dimb) = each($dimbs))
+ {
+ $sel_dimb = '';
+ if ($dimb['id']==$selected)
+ {
+ $sel_dimb = 'selected';
+ }
+
+ $dimb_list[] = array
+ (
+ 'id' => $dimb['id'],
+ 'num' => $dimb['num'],
+ 'selected' => $sel_dimb
+ );
+ }
+
+ for ($i=0;$i<count($dimb_list);$i++)
+ {
+ if ($dimb_list[$i]['selected'] != 'selected')
+ {
+ unset($dimb_list[$i]['selected']);
+ }
+ }
+
+ return $dimb_list;
+ }
+
+ //-------------------
+ function select_dimd_list($selected='')
+ {
+ $dimds=$this->so->select_dimd_list();
+
+ while (is_array($dimds) && list(,$dimd) = each($dimds))
+ {
+ $sel_dimd = '';
+ if ($dimd['id']==$selected)
+ {
+ $sel_dimd = 'selected';
+ }
+
+ $dimd_list[] = array
+ (
+ 'id' => $dimd['id'],
+ 'num' => $dimd['num'],
+ 'selected' => $sel_dimd
+ );
+ }
+
+ for ($i=0;$i<count($dimd_list);$i++)
+ {
+ if ($dimd_list[$i]['selected'] != 'selected')
+ {
+ unset($dimd_list[$i]['selected']);
+ }
+ }
+
+ return $dimd_list;
+ }
+
+ function select_tax_code_list($selected='')
+ {
+ $tax_codes=$this->so->select_tax_code_list();
+
+ while (is_array($tax_codes) && list(,$tax_code) =
each($tax_codes))
+ {
+ $sel_tax_code = '';
+ if ($tax_code['id']==$selected)
+ {
+ $sel_tax_code = 'selected';
+ }
+
+ $tax_code_list[] = array
+ (
+ 'id' => $tax_code['id'],
+ 'num' => $tax_code['num'],
+ 'selected' => $sel_tax_code
+ );
+ }
+
+ for ($i=0;$i<count($tax_code_list);$i++)
+ {
+ if ($tax_code_list[$i]['selected'] !=
'selected')
+ {
+ unset($tax_code_list[$i]['selected']);
+ }
+ }
+ return $tax_code_list;
+ }
+
+ function delete($params)
+ {
+ if (is_array($params))
+ {
+ $this->so->delete($params[0]);
+ }
+ else
+ {
+ $this->so->delete($params);
+ }
+ }
+
+ function add($values,$debug='')
+ {
+ $this->soXport =
CreateObject($this->currentapp.'.soXport');
+ if($values['loc1']=$values['location']['loc1'])
+ {
+ $values['dima']=implode('',$values['location']);
+ }
+
+ $values['spbudact_code']=$values['b_account_id'];
+ $values['fakturanr']=$values['invoice_num'];
+ $values['spvend_code']=$values['vendor_id'];
+
+ $values['belop'] =
str_replace('kr','',$values['amount']);
+ $values['belop'] = str_replace(' ','',$values['belop']);
+ $values['belop'] =
str_replace(',','.',$values['belop']);
+ $values['godkjentbelop']=$values['belop'];
+
+ $values['fakturadato'] =
date($this->bocommon->dateformat,mktime(2,0,0,$values['smonth'],$values['sday'],$values['syear']));
+
+ if($values['num_days'])
+ {
+ $values['forfallsdato'] =
date($this->bocommon->dateformat,mktime(2,0,0,$values['smonth'],$values['sday'],$values['syear'])+(86400*$values['num_days']));
+ }
+ else
+ {
+ $values['forfallsdato'] =
date($this->bocommon->dateformat,mktime(2,0,0,$values['emonth'],$values['eday'],$values['eyear']));
+ }
+
+ $values['artid'] =
$values['art'];
+ $values['periode'] =
$values['smonth'];
+ $values['dimb'] =
$values['dim_b'];
+ $values['oppsynsmannid'] = $values['janitor'];
+ $values['saksbehandlerid'] = $values['supervisor'];
+ $values['budsjettansvarligid'] =
$values['budget_responsible'];
+ $values['kildeid'] = 1;
+ $values['kidnr'] =
$values['kid_nr'];
+ $values['typeid'] =
$values['type'];
+ if($order_type =
$this->soXport->check_order(intval($values['order'])))
+ {
+ if($order_type=='workorder')
+ {
+ $soworkorder =
CreateObject($this->currentapp.'.soworkorder');
+ $soproject =
CreateObject($this->currentapp.'.soproject');
+ $workorder =
$soworkorder->read_single($values['order']);
+ $project =
$soproject->read_single($workorder['project_id']);
+
+ $values['spvend_code'] =
$workorder['vendor_id'];
+ $values['spbudact_code'] =
$workorder['b_account_id'];
+ $values['location_code']
=$project['location_code'];
+ $values['dima']
=str_replace('-','',$project['location_code']);
+ $values['vendor_name'] =
$this->get_vendor_name($workorder['vendor_id']);
+ $values['pmwrkord_code'] =
$values['order'];
+ $values['project_id']
= $workorder['project_id'];
+
+ $values =
$this->set_responsible($values,$workorder['user_id'],$workorder['b_account_id']);
+
+ if($values['auto_tax'])
+ {
+ $values['mvakode'] =
$this->soXport->auto_tax($values['dima']);
+ $values['mvakode'] =
$this->soXport->tax_b_account_override($values['mvakode'],$values['spbudact_code']);
+ $values['mvakode'] =
$this->soXport->tax_vendor_override($values['mvakode'],$values['spvend_code']);
+ $values['kostra_id'] =
$this->soXport->get_kostra_id($values['dima']);
+ }
+
+ $buffer[0]=$values;
+ }
+
+ if($order_type=='s_agreement')
+ {
+ $sos_agreement =
CreateObject($this->currentapp.'.sos_agreement');
+ $s_agreement =
$sos_agreement->read_single(array('s_agreement_id'=>$values['order']));
+
+ $values['spvend_code'] =
$s_agreement['vendor_id'];
+ $values['spbudact_code'] =
$s_agreement['b_account_id'];
+ $values['vendor_name'] =
$this->get_vendor_name($s_agreement['vendor_id']);
+ $values['pmwrkord_code'] =
intval($values['order']);
+ $values =
$this->set_responsible($values,$s_agreement['user_id'],$s_agreement['b_account_id']);
+
+
+ $s_agreement_detail =
$sos_agreement->read(array('allrows'=>True,'s_agreement_id'=>$values['order'],'detail'=>True));
+
+ $sum_agreement=0;
+ for
($i=0;$i<count($s_agreement_detail);$i++)
+ {
+ $sum_agreement = $sum_agreement
+ $s_agreement_detail[$i]['cost'];
+ }
+
+
+ for
($i=0;$i<count($s_agreement_detail);$i++)
+ {
+ $buffer[$i]=$values;
+
+ $buffer[$i]['location_code']
=$s_agreement_detail[$i]['location_code'];
+ $buffer[$i]['dima']
=str_replace('-','',$s_agreement_detail[$i]['location_code']);
+
+
+ $buffer[$i]['belop'] =
round($values['belop'] / $sum_agreement * $s_agreement_detail[$i]['cost'],2);
+ $buffer[$i]['godkjentbelop']
=$buffer[$i]['belop'];
+
+ if($values['auto_tax'])
+ {
+ $buffer[$i]['mvakode']
= $this->soXport->auto_tax($buffer[$i]['dima']);
+ $buffer[$i]['mvakode']
=
$this->soXport->tax_b_account_override($buffer[$i]['mvakode'],$buffer[$i]['spbudact_code']);
+ $buffer[$i]['mvakode']
=
$this->soXport->tax_vendor_override($buffer[$i]['mvakode'],$buffer[$i]['spvend_code']);
+
$buffer[$i]['kostra_id'] = $this->soXport->get_kostra_id($buffer[$i]['dima']);
+ }
+ }
+ }
+ }
+ else
+ {
+ if($values['auto_tax'])
+ {
+ $values['mvakode'] =
$this->soXport->auto_tax($values['loc1']);
+ $values['mvakode'] =
$this->soXport->tax_b_account_override($values['mvakode'],$values['spbudact_code']);
+ $values['mvakode'] =
$this->soXport->tax_vendor_override($values['mvakode'],$values['spvend_code']);
+ $values['kostra_id'] =
$this->soXport->get_kostra_id($values['loc1']);
+ }
+
+ $buffer[0]=$values;
+ }
+
+ if($debug)
+ {
+ return $buffer;
+ }
+
+ if($this->soXport->add($buffer)>0)
+ {
+ $receipt['message'][] =
array('msg'=>lang('Invoice %1 is added',$values['bilagsnr']));
+ }
+ else
+ {
+ $receipt['error'][] =
array('msg'=>lang('Invoice is NOT added!'));
+ }
+ return $receipt;
+ }
+
+ function get_vendor_name($vendor_id='')
+ {
+ $contacts =
CreateObject($this->currentapp.'.soactor');
+ $contacts->role='vendor';
+
+ $vendor_data =
$contacts->read_single(array('actor_id'=>$vendor_id));
+ if(is_array($vendor_data))
+ {
+ foreach($vendor_data['attributes'] as
$attribute)
+ {
+ if($attribute['name']=='org_name')
+ {
+ return $attribute['value'];
+ }
+ }
+ }
+ }
+
+ function set_responsible($values,$user_id='',$b_account_id='')
+ {
+ if (!$values['budget_responsible'])
+ {
+ $values['budget_responsible'] =
$this->soXport->get_responsible($b_account_id);
+ $values['budsjettansvarligid'] =
$values['budget_responsible'];
+ }
+
+ $acl2 =
CreateObject($this->currentapp.'.acl2',$user_id);
+ if($acl2->check('.invoice',32) &&
!$acl2->check('.invoice',64)):
+ {
+ $values['janitor'] =
$GLOBALS['phpgw']->accounts->id2name($user_id);
+ $values['oppsynsmannid'] =
$values['janitor'];
+ }
+ // elseif((!$acl2->check('.invoice',32) &&
$acl2->check('.invoice',64)) || ($acl2->check('.invoice',32) &&
$acl2->check('.invoice',64))):
+ elseif($acl2->check('.invoice',64)):
+ {
+ $values['supervisor'] =
$GLOBALS['phpgw']->accounts->id2name($user_id);
+ $values['saksbehandlerid'] =
$values['supervisor'];
+ }
+ endif;
+
+ return $values;
+ }
+ }
+?>
Index: property/inc/class.bolocation.inc.php
diff -u property/inc/class.bolocation.inc.php:1.8
property/inc/class.bolocation.inc.php:1.9
--- property/inc/class.bolocation.inc.php:1.8 Thu Nov 3 14:53:43 2005
+++ property/inc/class.bolocation.inc.php Fri Jan 27 14:05:43 2006
@@ -1,820 +1,820 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage location
- * @version $Id: class.bolocation.inc.php,v 1.8 2005/11/03 14:53:43
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class bolocation
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- var $soap_functions = array(
- 'list' => array(
- 'in' =>
array('int','int','struct','string','int'),
- 'out' => array('array')
- ),
- 'read' => array(
- 'in' => array('int','struct'),
- 'out' => array('array')
- ),
- 'save' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- ),
- 'delete' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- )
- );
-
- function bolocation($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.solocation');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $lookup_tenant =
get_var('lookup_tenant',array('POST','GET'));
- $district_id =
get_var('district_id',array('POST','GET'));
- $part_of_town_id =
get_var('part_of_town_id',array('POST','GET'));
- $status = get_var('status',array('POST','GET'));
- $type_id =
get_var('type_id',array('POST','GET'));
- $allrows =
get_var('allrows',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(isset($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- if(isset($part_of_town_id))
- {
- $this->part_of_town_id = $part_of_town_id;
- }
- if(isset($district_id))
- {
- $this->district_id = $district_id;
- }
- if(isset($status))
- {
- $this->status = $status;
- }
- if(isset($type_id))
- {
- $this->type_id = $type_id;
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
-
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','location');
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->part_of_town_id = $data['part_of_town_id'];
- $this->district_id = $data['district_id'];
- $this->status = $data['status'];
- $this->type_id = $data['type_id'];
- $this->allrows = $data['allrows'];
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','location',$data);
- }
- }
-
-
- function select_status_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('status_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('status_filter'));
- break;
- }
-
- $list= $this->so->select_status_list($this->type_id);
- return $this->bocommon->select_list($selected,$list);
- }
-
- function read_entity_to_link()
- {
- return $this->so->read_entity_to_link();
- }
-
- function get_owner_list($format='',$selected='')
- {
-
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_filter'));
- break;
- }
-
- $owners = $this->so->get_owner_list();
-
- while (is_array($owners) && list(,$owner) =
each($owners))
- {
- $sel_owner = '';
- if ($owner['id']==$selected)
- {
- $sel_owner = 'selected';
- }
-
- $owner_list[] = array
- (
- 'id' => $owner['id'],
- 'name' => $owner['name'],
- 'selected' => $sel_owner
- );
- }
-
- $owner_count=count($owner_list);
- for ($i=0;$i<$owner_count;$i++)
- {
- if ($owner_list[$i]['selected'] != 'selected')
- {
- unset($owner_list[$i]['selected']);
- }
- }
-
- return $owner_list;
- }
-
- function get_owner_type_list($format='',$selected='')
- {
-
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('owner_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('owner_filter'));
- break;
- }
-
- $owners = $this->so->get_owner_type_list();
-
- while (is_array($owners) && list(,$owner) =
each($owners))
- {
- $sel_owner = '';
- if ($owner['id']==$selected)
- {
- $sel_owner = 'selected';
- }
-
- $owner_list[] = array
- (
- 'id' => $owner['id'],
- 'name' => $owner['name'],
- 'selected' => $sel_owner
- );
- }
-
- $owner_count=count($owner_list);
-
- for ($i=0;$i<$owner_count;$i++)
- {
- if ($owner_list[$i]['selected'] != 'selected')
- {
- unset($owner_list[$i]['selected']);
- }
- }
-
- return $owner_list;
- }
-
-
- function initiate_ui_location($data)
- {
-
- switch($data['lookup_type'])
- {
- case 'form':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('location_form'));
- break;
- case 'view':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('location_view'));
- break;
- }
-
- $location_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.index&lookup=1');
-
- $config = $this->soadmin_location->read_config('');
-
- $this->config = $config;
-//_debug_array($config);
- $location_types =
$this->soadmin_location->select_location_type();
- $this->location_types = $location_types;
-
- if($data['type_id']<0)
- {
- $data['type_id'] = count($location_types);
- }
-//_debug_array($data);
-//_debug_array($location_types);
- $fm_location_cols =
$this->soadmin_location->read_attrib(array('type_id'=>$data['type_id'],'lookup_type'=>$data['type_id']));
-//_debug_array($fm_location_cols);
-
- for ($i=0;$i<$data['type_id'];$i++)
- {
- $location['location'][$i]['input_type']
= 'text';
- $location['location'][$i]['input_name']
= 'loc' . ($i+1);
- $input_name[]
=
$location['location'][$i]['input_name'];
- $insert_record['location'][]
= $location['location'][$i]['input_name'];
- $location['location'][$i]['size']
= 5;
- $location['location'][$i]['name']
= $location_types[($i)]['name'];
- $location['location'][$i]['value']
= $data['values']['loc' . ($i+1)];
- $location['location'][$i]['statustext']
= lang('Klick this link to select') . ' ' .
$location_types[($i)]['name'];
-
- if($i==0)
- {
-
$location['location'][$i]['extra'][0]['input_name'] = 'loc' .
($i+1).'_name';
- $input_name[]
=
$location['location'][$i]['extra'][0]['input_name'];
-
$location['location'][$i]['extra'][0]['input_type']
= 'text';
-
$location['location'][$i]['extra'][0]['size'] = 30;
-
$location['location'][$i]['extra'][0]['lookup_function_call'] = 'lookup_loc'
. ($i+1) . '()';
-
$location['location'][$i]['extra'][0]['value'] =
$data['values']['loc' . ($i+1).'_name'];
- }
- else
- {
-
$location['location'][$i]['extra'][0]['input_name'] = 'loc' .
($i+1).'_name';
- $input_name[]
=
$location['location'][$i]['extra'][0]['input_name'];
-
$location['location'][$i]['extra'][0]['input_type']
= 'text';
-
$location['location'][$i]['extra'][0]['size'] = 30;
-
$location['location'][$i]['extra'][0]['lookup_function_call'] = 'lookup_loc'
. ($i+1) . '()';
-
$location['location'][$i]['extra'][0]['value'] =
$data['values']['loc' . ($i+1).'_name'];
- }
-
-
$location['location'][$i]['lookup_function_call'] = 'lookup_loc' . ($i+1)
. '()';
- $location['location'][$i]['lookup_link']
= True;
- $location['location'][$i]['readonly']
= True;
- $lookup_functions[$i]['name']
= 'lookup_loc' . ($i+1) . '()';
- $lookup_functions[$i]['action']
= 'Window1=window.open('."'" . $location_link
.'&type_id=' . ($i+1) . '&lookup_name=' . $i . "'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
-
- if($data['no_link']>=($i+3))
- {
-
$location['location'][$i]['lookup_link'] = False;
- $lookup_functions[$i]['action']
= 'Window1=window.open('."'" . $location_link
.'&type_id=' . ($data['no_link']-1) . '&lookup_name=' . ($data[no_link]-2) .
"'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
- $location['location'][$i]['statustext']
= lang('Klick this link to select') . ' ' .
$location_types[($data[no_link]-2)]['name'];
- }
-
-
- if($data['query_link'] && $i <
($data['type_id']-1))
- {
- for ($j=1;$j<$i+2;$j++)
- {
- $temp_location[]=
$data['values']['loc' . ($j)];
- }
-
-
- $data['link_data']['query_location']
= implode('-',$temp_location);
- $location['location'][$i]['query_link']
= $GLOBALS['phpgw']->link('/index.php',$data['link_data']);
- unset($temp_location);
- }
-
-
- $m=$i;
- }
-
-//_debug_array($fm_location_cols);
-//_debug_array($data);
-
- $location_cols_count =count($fm_location_cols);
- for ($j=0;$j<$location_cols_count;$j++)
- {
- if(($fm_location_cols[$j]['location_type'] <=
$data['type_id']) && $fm_location_cols[$j]['lookup_form'])
- {
- $location['location'][$i]['input_type']
= 'text';
- $location['location'][$i]['input_name']
= $fm_location_cols[$j]['column_name'];
- $input_name[]
=
$location['location'][$i]['input_name'];
- $location['location'][$i]['size']
= 5;
-
$location['location'][$i]['lookup_function_call'] = 'lookup_loc' .
$fm_location_cols[$j]['location_type'] . '()';
-
$location['location'][$i]['lookup_link'] = True;
- $location['location'][$i]['readonly']
= True;
- $location['location'][$i]['name']
= $fm_location_cols[$j]['input_text'];
- $location['location'][$i]['value']
=
$data['values'][$fm_location_cols[$j]['column_name']];
- $location['location'][$i]['statustext']
= lang('Klick this link to select') . ' ' .
$location_types[($fm_location_cols[$j]['location_type']-1)]['name'];
- $i++;
-
- }
- }
-
-
- $config_count =count($config);
- for ($j=0;$j<$config_count;$j++)
- {
- if($config[$j]['location_type'] <=
$data['type_id'] && $config[$j]['lookup_form'] )
- {
-
if($config[$j]['column_name']=='street_id'):
- {
-
$location['location'][$i]['input_name'] =
$config[$j]['column_name'];
- $input_name[]
= 'street_id';
-
$location['location'][$i]['lookup_link'] = True;
-
$location['location'][$i]['lookup_function_call'] = 'lookup_loc' .
$config[$j]['location_type'] . '()';
-
$location['location'][$i]['name'] =
lang('address');
-
$location['location'][$i]['input_type'] = 'hidden';
-
$location['location'][$i]['value'] =
$data['values'][$config[$j]['column_name']];
-
-
$location['location'][$i]['extra'][0]['input_type']
= 'text';
-
$location['location'][$i]['extra'][0]['input_name']
= 'street_name';
-
$location['location'][$i]['extra'][0]['readonly']
= True;
- $input_name[]
= $location['location'][$i]['extra'][0]['input_name'];
-
$location['location'][$i]['extra'][0]['size']
= 30;
-
$location['location'][$i]['extra'][0]['lookup_function_call'] = 'lookup_loc'
. $config[$j]['location_type'] . '()';
-
$location['location'][$i]['extra'][0]['value']
= $data['values']['street_name'];
-
-
$location['location'][$i]['extra'][1]['input_type']
= 'text';
-
$location['location'][$i]['extra'][1]['input_name']
= 'street_number';
-
$location['location'][$i]['extra'][1]['readonly']
= True;
- $input_name[]
= $location['location'][$i]['extra'][1]['input_name'];
-
$location['location'][$i]['extra'][1]['size']
= 6;
-
$location['location'][$i]['extra'][1]['lookup_function_call'] = 'lookup_loc'
. $config[$j]['location_type'] . '()';
-
$location['location'][$i]['extra'][1]['value']
= $data['values']['street_number'];
- }
-
elseif($config[$j]['column_name']=='tenant_id' && $data['tenant']):
- {
- $m++;
- $lookup_functions[$m]['name'] =
'lookup_loc' . ($m+1) . '()';
- $lookup_functions[$m]['action']
= 'Window1=window.open('."'" . $location_link .'&lookup_tenant=1&type_id=' .
$config[$j]['location_type'] . '&lookup_name=' . $i ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
-
-
$location['location'][$i]['lookup_link']
= True;
-
$location['location'][$i]['name']
= lang('Tenant');
-
$location['location'][$i]['input_type']
= 'hidden';
-
$location['location'][$i]['input_name']
= 'tenant_id';
- $input_name[]
= $location['location'][$i]['input_name'];
-
$location['location'][$i]['value']
= $data['values'][$config[$j]['column_name']];
-
$location['location'][$i]['lookup_function_call']
= $lookup_functions[$m]['name'];
-
$location['location'][$i]['statustext']
= lang('tenant');
-
$insert_record['extra']['tenant_id']
= 'tenant_id';
-
-
$location['location'][$i]['extra'][0]['input_type']
= 'text';
-
$location['location'][$i]['extra'][0]['input_name']
= 'last_name';
-
$location['location'][$i]['extra'][0]['readonly']
= True;
- $input_name[]
= $location['location'][$i]['extra'][0]['input_name'];
-
$location['location'][$i]['extra'][0]['size']
= 15;
-
$location['location'][$i]['extra'][0]['lookup_function_call'] =
$lookup_functions[$m]['name'];
-
$location['location'][$i]['extra'][0]['value']
= $data['values']['last_name'];
-
$location['location'][$i]['extra'][0]['statustext']
= lang('last name');
-
-
$location['location'][$i]['extra'][1]['input_type']
= 'text';
-
$location['location'][$i]['extra'][1]['input_name']
= 'first_name';
-
$location['location'][$i]['extra'][1]['readonly']
= True;
- $input_name[]
= $location['location'][$i]['extra'][1]['input_name'];
-
$location['location'][$i]['extra'][1]['size']
= 15;
-
$location['location'][$i]['extra'][1]['lookup_function_call'] =
$lookup_functions[$m]['name'];
-
$location['location'][$i]['extra'][1]['value']
= $data['values']['first_name'];
-
$location['location'][$i]['extra'][1]['statustext']
= lang('first name');
- $i++;
-
$location['location'][$i]['input_type'] = 'text';
-
$location['location'][$i]['name'] =
lang('Contact phone');
-
$location['location'][$i]['input_name'] =
'contact_phone';
- $input_name[]
=
$location['location'][$i]['input_name'];
-
$location['location'][$i]['size'] = 12;
-
$location['location'][$i]['lookup_function_call'] =
'';//$lookup_functions[$m]['name'];
-
$insert_record['extra']['contact_phone'] =
'contact_phone';
-
$location['location'][$i]['value'] =
$data['values']['contact_phone'];
-
$location['location'][$i]['statustext'] = lang('contact
phone');
- }
-
elseif($config[$j]['column_name']!='tenant_id' &&
$config[$j]['column_name']!='street_id'):
- {
-
$location['location'][$i]['input_name'] =
$config[$j]['column_name'];
- $input_name[]
=
$location['location'][$i]['input_name'];
-// $insert_record[]
=
$location['location'][$i]['input_name'];
-
$location['location'][$i]['size'] = 5;
-
$location['location'][$i]['value'] =
$data['location']['value'][$config[$j]['column_name']];
-
$location['location'][$i]['lookup_function_call'] = 'lookup_loc' .
$fm_location_cols[$j]['location_type'] . '()';
-
$location['location'][$i]['lookup_link'] = True;
-
$location['location'][$i]['name'] =
$config[$j]['descr'];
-
$location['location'][$i]['value'] =
$data['values'][$config[$j]['column_name']];
-
$location['location'][$i]['statustext'] = lang('Klick
this link to select') . ' '
.$location_types[($fm_location_cols[$j]['location_type']-1)]['name'];
-
$location['location'][$i]['input_type'] = 'text';
- }
- endif;
- $i++;
- }
- }
-
- if (isset($data['lookup_entity']) &&
is_array($data['lookup_entity']))
- {
- foreach($data['lookup_entity'] as $entity)
- {
- $m++;
- $entity_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.entity&location_type='
. $data['type_id'] . '&entity_id=' .$entity['id']);
-
- $lookup_functions[$m]['name'] =
'lookup_entity_' . $entity['id'] .'()';
- $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $entity_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
-
- $location['location'][$i]['input_type']
= 'text';
- $location['location'][$i]['input_name']
= 'entity_num_' . $entity['id'];
- $input_name[]
=
'entity_num_' . $entity['id'];
- $insert_record['extra']['entity_num_' .
$entity['id']] = 'p_num';
-
- $location['location'][$i]['size']
= 8;
-
$location['location'][$i]['lookup_function_call']
= 'lookup_entity_' . $entity['id'] .'()';
-
$location['location'][$i]['lookup_link']
= True;
- $location['location'][$i]['name']
= $entity['name'];
- $location['location'][$i]['value']
=
$data['entity_data'][$entity['id']]['p_num'];
- $location['location'][$i]['statustext']
= lang('Klick this link to
select') .' ' . $entity['name'];
-
-
$location['location'][$i]['extra'][0]['input_name']
= 'entity_cat_name_' . $entity['id'];
- $input_name[]
=
$location['location'][$i]['extra'][0]['input_name'];
-
$location['location'][$i]['extra'][0]['input_type']
= 'text';
-
$location['location'][$i]['extra'][0]['size']
= 30;
-
$location['location'][$i]['extra'][0]['lookup_function_call'] =
'lookup_entity_' . $entity['id'] .'()';
-
$location['location'][$i]['extra'][0]['value']
= $data['entity_data'][$entity['id']]['p_cat_name'];
-
-
$location['location'][$i]['extra'][1]['input_type']
= 'hidden';
-
$location['location'][$i]['extra'][1]['input_name']
= 'entity_id_' . $entity['id'];
- $input_name[]
=
'entity_id_' . $entity['id'];
- $insert_record['extra']['entity_id_' .
$entity['id']] = 'p_entity_id';
-
$location['location'][$i]['extra'][1]['value']
= $data['entity_data'][$entity['id']]['p_entity_id'];
-
-
$location['location'][$i]['extra'][2]['input_type']
= 'hidden';
-
$location['location'][$i]['extra'][2]['input_name']
= 'cat_id_' . $entity['id'];
- $input_name[]
=
'cat_id_' . $entity['id'];
- $insert_record['extra']['cat_id_' .
$entity['id']] = 'p_cat_id';
-
$location['location'][$i]['extra'][2]['value']
= $data['entity_data'][$entity['id']]['p_cat_id'];
-
- $i++;
- }
- }
-
-//_debug_array($location['location']);
-
-
$GLOBALS['phpgw']->session->appsession('lookup_fields',$this->currentapp,$input_name);
-
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp,$insert_record);
-//
$GLOBALS['phpgw']->session->appsession('input_name',$this->currentapp,$input_name);
-
- for ($i=0;$i<count($location['location']);$i++)
- {
- $lookup_name[] =
$location['location'][$i]['name'];
-
- }
-
-
$GLOBALS['phpgw']->session->appsession('lookup_name',$this->currentapp,$lookup_name);
-
- for ($j=0;$j<count($lookup_functions);$j++)
- {
- $location['lookup_functions'] .= 'function ' .
$lookup_functions[$j]['name'] ."\r\n";
- $location['lookup_functions'] .= '{'."\r\n";
- $location['lookup_functions'] .=
$lookup_functions[$j]['action'] ."\r\n";
- $location['lookup_functions'] .= '}'."\r\n";
- }
-
-
-//_debug_array($location);
-
- return $location;
-
- }
-
- function
select_category_list($format='',$selected='',$type_id='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
- $categories= $this->so->select_category_list($type_id);
-
- while (is_array($categories) && list(,$category) =
each($categories))
- {
- $sel_category = '';
- if ($category['id']==$selected)
- {
- $sel_category = 'selected';
- }
-
- $category_list[] = array
- (
- 'cat_id' => $category['id'],
- 'name' => $category['name'],
- 'selected' => $sel_category
- );
- }
-
- $category_count=count($category_list);
- for ($i=0;$i<$category_count;$i++)
- {
- if ($category_list[$i]['selected'] !=
'selected')
- {
- unset($category_list[$i]['selected']);
- }
- }
-
- return $category_list;
- }
-
-
- function read($data='')
- {
- $location = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' => $this->cat_id,'type_id' =>
$data['type_id'],
-
'lookup_tenant'=>$data['lookup_tenant'],'lookup'=>$data['lookup'],
-
'district_id'=>$this->district_id,'allrows'=>$data['allrows'],
-
'status'=>$this->status,'part_of_town_id'=>$this->part_of_town_id));
- $this->total_records = $this->so->total_records;
- $this->uicols = $this->so->uicols;
-
- return $location;
- }
-
- function read_single($location_code='',$extra='')
- {
- $location_data = $this->so->read_single($location_code);
-
- if(!$extra['tenant_id']=='lookup')
- {
- if($extra['tenant_id']>0)
- {
-
$tenant_data=$this->bocommon->read_single_tenant($extra['tenant_id']);
- $location_data['tenant_id'] =
$extra['tenant_id'];
- $location_data['contact_phone']=
$extra['contact_phone'];
- $location_data['last_name'] =
$tenant_data['last_name'];
- $location_data['first_name'] =
$tenant_data['first_name'];
- }
- else
- {
- unset($location_data['tenant_id']);
- unset($location_data['contact_phone']);
- unset($location_data['last_name']);
- unset($location_data['first_name']);
- }
- }
-
- if(is_array($extra))
- {
- $location_data = $location_data + $extra;
- }
- return $location_data;
- }
-
- function check_location($location_code='',$type_id='')
- {
- return
$this->so->check_location($location_code,$type_id);
- }
-
-
- function
save($location,$values_attribute,$action='',$type_id='',$location_code_parent='')
- {
-
-
-//_debug_array($values_attribute);
-/* $location_datatype =
$GLOBALS['phpgw']->session->appsession('location_datatype',$this->currentapp);
-// _debug_array($location_datatype);
-
- if(is_array($location_datatype))
- {
- for ($i=0;$i<count($location_datatype);$i++)
- {
-
if($location_datatype[$i]['datatype']=='decimal' &&
$location[$location_datatype[$i]['input_name']])
- {
-
$location[$location_datatype[$i]['input_name']] =
str_replace(",",".",$location[$location_datatype[$i]['input_name']]);
- }
-
-
if($location_datatype[$i]['datatype']=='date' &&
$location[$location_datatype[$i]['input_name']])
- {
- $dateformat=
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $dateformat =
str_replace(".","",$dateformat);
- $dateformat =
str_replace("-","",$dateformat);
- $dateformat =
str_replace("/","",$dateformat);
- $y=strpos($dateformat,'Y');
- $d=strpos($dateformat,'d');
- $m=strpos($dateformat,'m');
-
- $dateparts = explode('/',
$location[$location_datatype[$i]['input_name']]);
- $day =
$dateparts[$d];
- $month =
$dateparts[$m];
- $year =
$dateparts[$y];
-
-//
$location[$location_datatype[$i]['input_name']] =
date($this->bocommon->dateformat,mktime(2,0,0,$month,$day,$year));
-
$location[$location_datatype[$i]['input_name']] =
mktime(0,0,0,$month,$day,$year);
-
- }
- }
- }
-
-*/
-
- $m=count($values_attribute);
- for ($i=0;$i<$m;$i++)
- {
- if($values_attribute[$i]['datatype']=='AB' ||
$values_attribute[$i]['datatype']=='VENDOR')
- {
- $values_attribute[$i]['value'] =
$_POST[$values_attribute[$i]['name']];
- }
- if($values_attribute[$i]['datatype']=='CH' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
serialize($values_attribute[$i]['value']);
- }
- if($values_attribute[$i]['datatype']=='R' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
$values_attribute[$i]['value'][0];
- }
-
- if($values_attribute[$i]['datatype']=='N' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
str_replace(",",".",$values_attribute[$i]['value']);
- }
-
- if($values_attribute[$i]['datatype']=='D' &&
$values_attribute[$i]['value'])
- {
-
- $values_attribute[$i]['value'] =
date($this->bocommon->dateformat,$this->bocommon->date_to_timestamp($values_attribute[$i]['value']));
- }
- }
-
-
-//_debug_array($values_attribute);
-
-
-
-// _debug_array($location);
-
- if ($action=='edit')
- {
- if
($this->so->check_location($location['location_code'],$type_id))
- {
- $receipt =
$this->so->edit($location,$values_attribute,$type_id);
- }
- else
- {
-
$receipt['error'][]=array('msg'=>lang('This location ID does not exist!'));
- }
- }
- else
- {
-
-/* if($type_id>1)
- {
-
if(!$this->so->check_location($location_code_parent,($type_id-1)))
- {
-
$receipt['error'][]=array('msg'=>lang('This location parent ID does not
exist!'));
- }
- }
-
-*/
- if(!$receipt['error'])
- {
- $receipt =
$this->so->add($location,$values_attribute,$type_id);
- }
- }
- return $receipt;
- }
-
- function delete($location_code)
- {
- $this->so->delete($location_code);
- }
-
- function update_cat()
- {
- return $this->so->update_cat();
- }
- function read_summary()
- {
-
- $summary = $this->so->read_summary(array('filter' =>
$this->filter,'type_id' => $data['type_id'],
-
'district_id'=>$this->district_id,'part_of_town_id'=>$this->part_of_town_id));
- $this->uicols = $this->so->uicols;
- return $summary;
-
- }
-
- function select_change_type($selected='')
- {
- $nullable[0]['id']= 1;
- $nullable[0]['name']= lang('Correct error');
- $nullable[1]['id']= 2;
- $nullable[1]['name']= lang('New values');
-
- while (is_array($nullable) && list(,$type) =
each($nullable))
- {
- $sel_type = '';
- if ($type['id']==$selected)
- {
- $sel_type = 'selected';
- }
-
- $change_type_list[] = array
- (
- 'id' => $type['id'],
- 'name' => $type['name'],
- 'selected' => $sel_type
- );
- }
-
- for ($i=0;$i<count($change_type_list);$i++)
- {
- if ($change_type_list[$i]['selected'] !=
'selected')
- {
-
unset($change_type_list[$i]['selected']);
- }
- }
- return $change_type_list;
- }
-
- function check_history($location_code)
- {
- return $this->so->check_history($location_code);
- }
-
- function get_history($location_code)
- {
- $history = $this->so->get_history($location_code);
- $this->total_records = $this->so->total_records;
- $this->uicols = $this->so->uicols;
-
- return $history;
-
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage location
+ * @version $Id: class.bolocation.inc.php,v 1.9 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class bolocation
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ var $soap_functions = array(
+ 'list' => array(
+ 'in' =>
array('int','int','struct','string','int'),
+ 'out' => array('array')
+ ),
+ 'read' => array(
+ 'in' => array('int','struct'),
+ 'out' => array('array')
+ ),
+ 'save' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ ),
+ 'delete' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ )
+ );
+
+ function bolocation($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.solocation');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $lookup_tenant =
get_var('lookup_tenant',array('POST','GET'));
+ $district_id =
get_var('district_id',array('POST','GET'));
+ $part_of_town_id =
get_var('part_of_town_id',array('POST','GET'));
+ $status = get_var('status',array('POST','GET'));
+ $type_id =
get_var('type_id',array('POST','GET'));
+ $allrows =
get_var('allrows',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(isset($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ if(isset($part_of_town_id))
+ {
+ $this->part_of_town_id = $part_of_town_id;
+ }
+ if(isset($district_id))
+ {
+ $this->district_id = $district_id;
+ }
+ if(isset($status))
+ {
+ $this->status = $status;
+ }
+ if(isset($type_id))
+ {
+ $this->type_id = $type_id;
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','location');
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->part_of_town_id = $data['part_of_town_id'];
+ $this->district_id = $data['district_id'];
+ $this->status = $data['status'];
+ $this->type_id = $data['type_id'];
+ $this->allrows = $data['allrows'];
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','location',$data);
+ }
+ }
+
+
+ function select_status_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('status_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('status_filter'));
+ break;
+ }
+
+ $list= $this->so->select_status_list($this->type_id);
+ return $this->bocommon->select_list($selected,$list);
+ }
+
+ function read_entity_to_link()
+ {
+ return $this->so->read_entity_to_link();
+ }
+
+ function get_owner_list($format='',$selected='')
+ {
+
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_filter'));
+ break;
+ }
+
+ $owners = $this->so->get_owner_list();
+
+ while (is_array($owners) && list(,$owner) =
each($owners))
+ {
+ $sel_owner = '';
+ if ($owner['id']==$selected)
+ {
+ $sel_owner = 'selected';
+ }
+
+ $owner_list[] = array
+ (
+ 'id' => $owner['id'],
+ 'name' => $owner['name'],
+ 'selected' => $sel_owner
+ );
+ }
+
+ $owner_count=count($owner_list);
+ for ($i=0;$i<$owner_count;$i++)
+ {
+ if ($owner_list[$i]['selected'] != 'selected')
+ {
+ unset($owner_list[$i]['selected']);
+ }
+ }
+
+ return $owner_list;
+ }
+
+ function get_owner_type_list($format='',$selected='')
+ {
+
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('owner_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('owner_filter'));
+ break;
+ }
+
+ $owners = $this->so->get_owner_type_list();
+
+ while (is_array($owners) && list(,$owner) =
each($owners))
+ {
+ $sel_owner = '';
+ if ($owner['id']==$selected)
+ {
+ $sel_owner = 'selected';
+ }
+
+ $owner_list[] = array
+ (
+ 'id' => $owner['id'],
+ 'name' => $owner['name'],
+ 'selected' => $sel_owner
+ );
+ }
+
+ $owner_count=count($owner_list);
+
+ for ($i=0;$i<$owner_count;$i++)
+ {
+ if ($owner_list[$i]['selected'] != 'selected')
+ {
+ unset($owner_list[$i]['selected']);
+ }
+ }
+
+ return $owner_list;
+ }
+
+
+ function initiate_ui_location($data)
+ {
+
+ switch($data['lookup_type'])
+ {
+ case 'form':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('location_form'));
+ break;
+ case 'view':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('location_view'));
+ break;
+ }
+
+ $location_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.index&lookup=1');
+
+ $config = $this->soadmin_location->read_config('');
+
+ $this->config = $config;
+//_debug_array($config);
+ $location_types =
$this->soadmin_location->select_location_type();
+ $this->location_types = $location_types;
+
+ if($data['type_id']<0)
+ {
+ $data['type_id'] = count($location_types);
+ }
+//_debug_array($data);
+//_debug_array($location_types);
+ $fm_location_cols =
$this->soadmin_location->read_attrib(array('type_id'=>$data['type_id'],'lookup_type'=>$data['type_id']));
+//_debug_array($fm_location_cols);
+
+ for ($i=0;$i<$data['type_id'];$i++)
+ {
+ $location['location'][$i]['input_type']
= 'text';
+ $location['location'][$i]['input_name']
= 'loc' . ($i+1);
+ $input_name[]
=
$location['location'][$i]['input_name'];
+ $insert_record['location'][]
= $location['location'][$i]['input_name'];
+ $location['location'][$i]['size']
= 5;
+ $location['location'][$i]['name']
= $location_types[($i)]['name'];
+ $location['location'][$i]['value']
= $data['values']['loc' . ($i+1)];
+ $location['location'][$i]['statustext']
= lang('Klick this link to select') . ' ' .
$location_types[($i)]['name'];
+
+ if($i==0)
+ {
+
$location['location'][$i]['extra'][0]['input_name'] = 'loc' .
($i+1).'_name';
+ $input_name[]
=
$location['location'][$i]['extra'][0]['input_name'];
+
$location['location'][$i]['extra'][0]['input_type']
= 'text';
+
$location['location'][$i]['extra'][0]['size'] = 30;
+
$location['location'][$i]['extra'][0]['lookup_function_call'] = 'lookup_loc'
. ($i+1) . '()';
+
$location['location'][$i]['extra'][0]['value'] =
$data['values']['loc' . ($i+1).'_name'];
+ }
+ else
+ {
+
$location['location'][$i]['extra'][0]['input_name'] = 'loc' .
($i+1).'_name';
+ $input_name[]
=
$location['location'][$i]['extra'][0]['input_name'];
+
$location['location'][$i]['extra'][0]['input_type']
= 'text';
+
$location['location'][$i]['extra'][0]['size'] = 30;
+
$location['location'][$i]['extra'][0]['lookup_function_call'] = 'lookup_loc'
. ($i+1) . '()';
+
$location['location'][$i]['extra'][0]['value'] =
$data['values']['loc' . ($i+1).'_name'];
+ }
+
+
$location['location'][$i]['lookup_function_call'] = 'lookup_loc' . ($i+1)
. '()';
+ $location['location'][$i]['lookup_link']
= True;
+ $location['location'][$i]['readonly']
= True;
+ $lookup_functions[$i]['name']
= 'lookup_loc' . ($i+1) . '()';
+ $lookup_functions[$i]['action']
= 'Window1=window.open('."'" . $location_link
.'&type_id=' . ($i+1) . '&lookup_name=' . $i . "'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+
+ if($data['no_link']>=($i+3))
+ {
+
$location['location'][$i]['lookup_link'] = False;
+ $lookup_functions[$i]['action']
= 'Window1=window.open('."'" . $location_link
.'&type_id=' . ($data['no_link']-1) . '&lookup_name=' . ($data[no_link]-2) .
"'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+ $location['location'][$i]['statustext']
= lang('Klick this link to select') . ' ' .
$location_types[($data[no_link]-2)]['name'];
+ }
+
+
+ if($data['query_link'] && $i <
($data['type_id']-1))
+ {
+ for ($j=1;$j<$i+2;$j++)
+ {
+ $temp_location[]=
$data['values']['loc' . ($j)];
+ }
+
+
+ $data['link_data']['query_location']
= implode('-',$temp_location);
+ $location['location'][$i]['query_link']
= $GLOBALS['phpgw']->link('/index.php',$data['link_data']);
+ unset($temp_location);
+ }
+
+
+ $m=$i;
+ }
+
+//_debug_array($fm_location_cols);
+//_debug_array($data);
+
+ $location_cols_count =count($fm_location_cols);
+ for ($j=0;$j<$location_cols_count;$j++)
+ {
+ if(($fm_location_cols[$j]['location_type'] <=
$data['type_id']) && $fm_location_cols[$j]['lookup_form'])
+ {
+ $location['location'][$i]['input_type']
= 'text';
+ $location['location'][$i]['input_name']
= $fm_location_cols[$j]['column_name'];
+ $input_name[]
=
$location['location'][$i]['input_name'];
+ $location['location'][$i]['size']
= 5;
+
$location['location'][$i]['lookup_function_call'] = 'lookup_loc' .
$fm_location_cols[$j]['location_type'] . '()';
+
$location['location'][$i]['lookup_link'] = True;
+ $location['location'][$i]['readonly']
= True;
+ $location['location'][$i]['name']
= $fm_location_cols[$j]['input_text'];
+ $location['location'][$i]['value']
=
$data['values'][$fm_location_cols[$j]['column_name']];
+ $location['location'][$i]['statustext']
= lang('Klick this link to select') . ' ' .
$location_types[($fm_location_cols[$j]['location_type']-1)]['name'];
+ $i++;
+
+ }
+ }
+
+
+ $config_count =count($config);
+ for ($j=0;$j<$config_count;$j++)
+ {
+ if($config[$j]['location_type'] <=
$data['type_id'] && $config[$j]['lookup_form'] )
+ {
+
if($config[$j]['column_name']=='street_id'):
+ {
+
$location['location'][$i]['input_name'] =
$config[$j]['column_name'];
+ $input_name[]
= 'street_id';
+
$location['location'][$i]['lookup_link'] = True;
+
$location['location'][$i]['lookup_function_call'] = 'lookup_loc' .
$config[$j]['location_type'] . '()';
+
$location['location'][$i]['name'] =
lang('address');
+
$location['location'][$i]['input_type'] = 'hidden';
+
$location['location'][$i]['value'] =
$data['values'][$config[$j]['column_name']];
+
+
$location['location'][$i]['extra'][0]['input_type']
= 'text';
+
$location['location'][$i]['extra'][0]['input_name']
= 'street_name';
+
$location['location'][$i]['extra'][0]['readonly']
= True;
+ $input_name[]
= $location['location'][$i]['extra'][0]['input_name'];
+
$location['location'][$i]['extra'][0]['size']
= 30;
+
$location['location'][$i]['extra'][0]['lookup_function_call'] = 'lookup_loc'
. $config[$j]['location_type'] . '()';
+
$location['location'][$i]['extra'][0]['value']
= $data['values']['street_name'];
+
+
$location['location'][$i]['extra'][1]['input_type']
= 'text';
+
$location['location'][$i]['extra'][1]['input_name']
= 'street_number';
+
$location['location'][$i]['extra'][1]['readonly']
= True;
+ $input_name[]
= $location['location'][$i]['extra'][1]['input_name'];
+
$location['location'][$i]['extra'][1]['size']
= 6;
+
$location['location'][$i]['extra'][1]['lookup_function_call'] = 'lookup_loc'
. $config[$j]['location_type'] . '()';
+
$location['location'][$i]['extra'][1]['value']
= $data['values']['street_number'];
+ }
+
elseif($config[$j]['column_name']=='tenant_id' && $data['tenant']):
+ {
+ $m++;
+ $lookup_functions[$m]['name'] =
'lookup_loc' . ($m+1) . '()';
+ $lookup_functions[$m]['action']
= 'Window1=window.open('."'" . $location_link .'&lookup_tenant=1&type_id=' .
$config[$j]['location_type'] . '&lookup_name=' . $i ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+
+
$location['location'][$i]['lookup_link']
= True;
+
$location['location'][$i]['name']
= lang('Tenant');
+
$location['location'][$i]['input_type']
= 'hidden';
+
$location['location'][$i]['input_name']
= 'tenant_id';
+ $input_name[]
= $location['location'][$i]['input_name'];
+
$location['location'][$i]['value']
= $data['values'][$config[$j]['column_name']];
+
$location['location'][$i]['lookup_function_call']
= $lookup_functions[$m]['name'];
+
$location['location'][$i]['statustext']
= lang('tenant');
+
$insert_record['extra']['tenant_id']
= 'tenant_id';
+
+
$location['location'][$i]['extra'][0]['input_type']
= 'text';
+
$location['location'][$i]['extra'][0]['input_name']
= 'last_name';
+
$location['location'][$i]['extra'][0]['readonly']
= True;
+ $input_name[]
= $location['location'][$i]['extra'][0]['input_name'];
+
$location['location'][$i]['extra'][0]['size']
= 15;
+
$location['location'][$i]['extra'][0]['lookup_function_call'] =
$lookup_functions[$m]['name'];
+
$location['location'][$i]['extra'][0]['value']
= $data['values']['last_name'];
+
$location['location'][$i]['extra'][0]['statustext']
= lang('last name');
+
+
$location['location'][$i]['extra'][1]['input_type']
= 'text';
+
$location['location'][$i]['extra'][1]['input_name']
= 'first_name';
+
$location['location'][$i]['extra'][1]['readonly']
= True;
+ $input_name[]
= $location['location'][$i]['extra'][1]['input_name'];
+
$location['location'][$i]['extra'][1]['size']
= 15;
+
$location['location'][$i]['extra'][1]['lookup_function_call'] =
$lookup_functions[$m]['name'];
+
$location['location'][$i]['extra'][1]['value']
= $data['values']['first_name'];
+
$location['location'][$i]['extra'][1]['statustext']
= lang('first name');
+ $i++;
+
$location['location'][$i]['input_type'] = 'text';
+
$location['location'][$i]['name'] =
lang('Contact phone');
+
$location['location'][$i]['input_name'] =
'contact_phone';
+ $input_name[]
=
$location['location'][$i]['input_name'];
+
$location['location'][$i]['size'] = 12;
+
$location['location'][$i]['lookup_function_call'] =
'';//$lookup_functions[$m]['name'];
+
$insert_record['extra']['contact_phone'] =
'contact_phone';
+
$location['location'][$i]['value'] =
$data['values']['contact_phone'];
+
$location['location'][$i]['statustext'] = lang('contact
phone');
+ }
+
elseif($config[$j]['column_name']!='tenant_id' &&
$config[$j]['column_name']!='street_id'):
+ {
+
$location['location'][$i]['input_name'] =
$config[$j]['column_name'];
+ $input_name[]
=
$location['location'][$i]['input_name'];
+// $insert_record[]
=
$location['location'][$i]['input_name'];
+
$location['location'][$i]['size'] = 5;
+
$location['location'][$i]['value'] =
$data['location']['value'][$config[$j]['column_name']];
+
$location['location'][$i]['lookup_function_call'] = 'lookup_loc' .
$fm_location_cols[$j]['location_type'] . '()';
+
$location['location'][$i]['lookup_link'] = True;
+
$location['location'][$i]['name'] =
$config[$j]['descr'];
+
$location['location'][$i]['value'] =
$data['values'][$config[$j]['column_name']];
+
$location['location'][$i]['statustext'] = lang('Klick
this link to select') . ' '
.$location_types[($fm_location_cols[$j]['location_type']-1)]['name'];
+
$location['location'][$i]['input_type'] = 'text';
+ }
+ endif;
+ $i++;
+ }
+ }
+
+ if (isset($data['lookup_entity']) &&
is_array($data['lookup_entity']))
+ {
+ foreach($data['lookup_entity'] as $entity)
+ {
+ $m++;
+ $entity_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.entity&location_type='
. $data['type_id'] . '&entity_id=' .$entity['id']);
+
+ $lookup_functions[$m]['name'] =
'lookup_entity_' . $entity['id'] .'()';
+ $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $entity_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+
+ $location['location'][$i]['input_type']
= 'text';
+ $location['location'][$i]['input_name']
= 'entity_num_' . $entity['id'];
+ $input_name[]
=
'entity_num_' . $entity['id'];
+ $insert_record['extra']['entity_num_' .
$entity['id']] = 'p_num';
+
+ $location['location'][$i]['size']
= 8;
+
$location['location'][$i]['lookup_function_call']
= 'lookup_entity_' . $entity['id'] .'()';
+
$location['location'][$i]['lookup_link']
= True;
+ $location['location'][$i]['name']
= $entity['name'];
+ $location['location'][$i]['value']
=
$data['entity_data'][$entity['id']]['p_num'];
+ $location['location'][$i]['statustext']
= lang('Klick this link to
select') .' ' . $entity['name'];
+
+
$location['location'][$i]['extra'][0]['input_name']
= 'entity_cat_name_' . $entity['id'];
+ $input_name[]
=
$location['location'][$i]['extra'][0]['input_name'];
+
$location['location'][$i]['extra'][0]['input_type']
= 'text';
+
$location['location'][$i]['extra'][0]['size']
= 30;
+
$location['location'][$i]['extra'][0]['lookup_function_call'] =
'lookup_entity_' . $entity['id'] .'()';
+
$location['location'][$i]['extra'][0]['value']
= $data['entity_data'][$entity['id']]['p_cat_name'];
+
+
$location['location'][$i]['extra'][1]['input_type']
= 'hidden';
+
$location['location'][$i]['extra'][1]['input_name']
= 'entity_id_' . $entity['id'];
+ $input_name[]
=
'entity_id_' . $entity['id'];
+ $insert_record['extra']['entity_id_' .
$entity['id']] = 'p_entity_id';
+
$location['location'][$i]['extra'][1]['value']
= $data['entity_data'][$entity['id']]['p_entity_id'];
+
+
$location['location'][$i]['extra'][2]['input_type']
= 'hidden';
+
$location['location'][$i]['extra'][2]['input_name']
= 'cat_id_' . $entity['id'];
+ $input_name[]
=
'cat_id_' . $entity['id'];
+ $insert_record['extra']['cat_id_' .
$entity['id']] = 'p_cat_id';
+
$location['location'][$i]['extra'][2]['value']
= $data['entity_data'][$entity['id']]['p_cat_id'];
+
+ $i++;
+ }
+ }
+
+//_debug_array($location['location']);
+
+
$GLOBALS['phpgw']->session->appsession('lookup_fields',$this->currentapp,$input_name);
+
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp,$insert_record);
+//
$GLOBALS['phpgw']->session->appsession('input_name',$this->currentapp,$input_name);
+
+ for ($i=0;$i<count($location['location']);$i++)
+ {
+ $lookup_name[] =
$location['location'][$i]['name'];
+
+ }
+
+
$GLOBALS['phpgw']->session->appsession('lookup_name',$this->currentapp,$lookup_name);
+
+ for ($j=0;$j<count($lookup_functions);$j++)
+ {
+ $location['lookup_functions'] .= 'function ' .
$lookup_functions[$j]['name'] ."\r\n";
+ $location['lookup_functions'] .= '{'."\r\n";
+ $location['lookup_functions'] .=
$lookup_functions[$j]['action'] ."\r\n";
+ $location['lookup_functions'] .= '}'."\r\n";
+ }
+
+
+//_debug_array($location);
+
+ return $location;
+
+ }
+
+ function
select_category_list($format='',$selected='',$type_id='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ break;
+ }
+
+ $categories= $this->so->select_category_list($type_id);
+
+ while (is_array($categories) && list(,$category) =
each($categories))
+ {
+ $sel_category = '';
+ if ($category['id']==$selected)
+ {
+ $sel_category = 'selected';
+ }
+
+ $category_list[] = array
+ (
+ 'cat_id' => $category['id'],
+ 'name' => $category['name'],
+ 'selected' => $sel_category
+ );
+ }
+
+ $category_count=count($category_list);
+ for ($i=0;$i<$category_count;$i++)
+ {
+ if ($category_list[$i]['selected'] !=
'selected')
+ {
+ unset($category_list[$i]['selected']);
+ }
+ }
+
+ return $category_list;
+ }
+
+
+ function read($data='')
+ {
+ $location = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' => $this->cat_id,'type_id' =>
$data['type_id'],
+
'lookup_tenant'=>$data['lookup_tenant'],'lookup'=>$data['lookup'],
+
'district_id'=>$this->district_id,'allrows'=>$data['allrows'],
+
'status'=>$this->status,'part_of_town_id'=>$this->part_of_town_id));
+ $this->total_records = $this->so->total_records;
+ $this->uicols = $this->so->uicols;
+
+ return $location;
+ }
+
+ function read_single($location_code='',$extra='')
+ {
+ $location_data = $this->so->read_single($location_code);
+
+ if(!$extra['tenant_id']=='lookup')
+ {
+ if($extra['tenant_id']>0)
+ {
+
$tenant_data=$this->bocommon->read_single_tenant($extra['tenant_id']);
+ $location_data['tenant_id'] =
$extra['tenant_id'];
+ $location_data['contact_phone']=
$extra['contact_phone'];
+ $location_data['last_name'] =
$tenant_data['last_name'];
+ $location_data['first_name'] =
$tenant_data['first_name'];
+ }
+ else
+ {
+ unset($location_data['tenant_id']);
+ unset($location_data['contact_phone']);
+ unset($location_data['last_name']);
+ unset($location_data['first_name']);
+ }
+ }
+
+ if(is_array($extra))
+ {
+ $location_data = $location_data + $extra;
+ }
+ return $location_data;
+ }
+
+ function check_location($location_code='',$type_id='')
+ {
+ return
$this->so->check_location($location_code,$type_id);
+ }
+
+
+ function
save($location,$values_attribute,$action='',$type_id='',$location_code_parent='')
+ {
+
+
+//_debug_array($values_attribute);
+/* $location_datatype =
$GLOBALS['phpgw']->session->appsession('location_datatype',$this->currentapp);
+// _debug_array($location_datatype);
+
+ if(is_array($location_datatype))
+ {
+ for ($i=0;$i<count($location_datatype);$i++)
+ {
+
if($location_datatype[$i]['datatype']=='decimal' &&
$location[$location_datatype[$i]['input_name']])
+ {
+
$location[$location_datatype[$i]['input_name']] =
str_replace(",",".",$location[$location_datatype[$i]['input_name']]);
+ }
+
+
if($location_datatype[$i]['datatype']=='date' &&
$location[$location_datatype[$i]['input_name']])
+ {
+ $dateformat=
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $dateformat =
str_replace(".","",$dateformat);
+ $dateformat =
str_replace("-","",$dateformat);
+ $dateformat =
str_replace("/","",$dateformat);
+ $y=strpos($dateformat,'Y');
+ $d=strpos($dateformat,'d');
+ $m=strpos($dateformat,'m');
+
+ $dateparts = explode('/',
$location[$location_datatype[$i]['input_name']]);
+ $day =
$dateparts[$d];
+ $month =
$dateparts[$m];
+ $year =
$dateparts[$y];
+
+//
$location[$location_datatype[$i]['input_name']] =
date($this->bocommon->dateformat,mktime(2,0,0,$month,$day,$year));
+
$location[$location_datatype[$i]['input_name']] =
mktime(0,0,0,$month,$day,$year);
+
+ }
+ }
+ }
+
+*/
+
+ $m=count($values_attribute);
+ for ($i=0;$i<$m;$i++)
+ {
+ if($values_attribute[$i]['datatype']=='AB' ||
$values_attribute[$i]['datatype']=='VENDOR')
+ {
+ $values_attribute[$i]['value'] =
$_POST[$values_attribute[$i]['name']];
+ }
+ if($values_attribute[$i]['datatype']=='CH' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
serialize($values_attribute[$i]['value']);
+ }
+ if($values_attribute[$i]['datatype']=='R' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
$values_attribute[$i]['value'][0];
+ }
+
+ if($values_attribute[$i]['datatype']=='N' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
str_replace(",",".",$values_attribute[$i]['value']);
+ }
+
+ if($values_attribute[$i]['datatype']=='D' &&
$values_attribute[$i]['value'])
+ {
+
+ $values_attribute[$i]['value'] =
date($this->bocommon->dateformat,$this->bocommon->date_to_timestamp($values_attribute[$i]['value']));
+ }
+ }
+
+
+//_debug_array($values_attribute);
+
+
+
+// _debug_array($location);
+
+ if ($action=='edit')
+ {
+ if
($this->so->check_location($location['location_code'],$type_id))
+ {
+ $receipt =
$this->so->edit($location,$values_attribute,$type_id);
+ }
+ else
+ {
+
$receipt['error'][]=array('msg'=>lang('This location ID does not exist!'));
+ }
+ }
+ else
+ {
+
+/* if($type_id>1)
+ {
+
if(!$this->so->check_location($location_code_parent,($type_id-1)))
+ {
+
$receipt['error'][]=array('msg'=>lang('This location parent ID does not
exist!'));
+ }
+ }
+
+*/
+ if(!$receipt['error'])
+ {
+ $receipt =
$this->so->add($location,$values_attribute,$type_id);
+ }
+ }
+ return $receipt;
+ }
+
+ function delete($location_code)
+ {
+ $this->so->delete($location_code);
+ }
+
+ function update_cat()
+ {
+ return $this->so->update_cat();
+ }
+ function read_summary()
+ {
+
+ $summary = $this->so->read_summary(array('filter' =>
$this->filter,'type_id' => $data['type_id'],
+
'district_id'=>$this->district_id,'part_of_town_id'=>$this->part_of_town_id));
+ $this->uicols = $this->so->uicols;
+ return $summary;
+
+ }
+
+ function select_change_type($selected='')
+ {
+ $nullable[0]['id']= 1;
+ $nullable[0]['name']= lang('Correct error');
+ $nullable[1]['id']= 2;
+ $nullable[1]['name']= lang('New values');
+
+ while (is_array($nullable) && list(,$type) =
each($nullable))
+ {
+ $sel_type = '';
+ if ($type['id']==$selected)
+ {
+ $sel_type = 'selected';
+ }
+
+ $change_type_list[] = array
+ (
+ 'id' => $type['id'],
+ 'name' => $type['name'],
+ 'selected' => $sel_type
+ );
+ }
+
+ for ($i=0;$i<count($change_type_list);$i++)
+ {
+ if ($change_type_list[$i]['selected'] !=
'selected')
+ {
+
unset($change_type_list[$i]['selected']);
+ }
+ }
+ return $change_type_list;
+ }
+
+ function check_history($location_code)
+ {
+ return $this->so->check_history($location_code);
+ }
+
+ function get_history($location_code)
+ {
+ $history = $this->so->get_history($location_code);
+ $this->total_records = $this->so->total_records;
+ $this->uicols = $this->so->uicols;
+
+ return $history;
+
+ }
+
+ }
+?>
Index: property/inc/class.bolookup.inc.php
diff -u property/inc/class.bolookup.inc.php:1.6
property/inc/class.bolookup.inc.php:1.7
--- property/inc/class.bolookup.inc.php:1.6 Thu May 12 21:26:28 2005
+++ property/inc/class.bolookup.inc.php Fri Jan 27 14:05:43 2006
@@ -1,254 +1,254 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage core
- * @version $Id: class.bolookup.inc.php,v 1.6 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class bolookup
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- var $soap_functions = array(
- 'list' => array(
- 'in' =>
array('int','int','struct','string','int'),
- 'out' => array('array')
- ),
- 'read' => array(
- 'in' => array('int','struct'),
- 'out' => array('array')
- ),
- 'save' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- ),
- 'delete' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- )
- );
-
- function bolookup($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.solookup');
- $this->solocation =
CreateObject($this->currentapp.'.solocation');
-
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start =
get_var('start',array('POST','GET'));
- $query =
get_var('query',array('POST','GET'));
- $sort =
get_var('sort',array('POST','GET'));
- $order =
get_var('order',array('POST','GET'));
- $filter =
get_var('filter',array('POST','GET'));
- $cat_id =
get_var('cat_id',array('POST','GET'));
- $district_id =
get_var('district_id',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- if(isset($district_id))
- {
- $this->district_id = $district_id;
- }
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','lookup',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','lookup');
-
- //_debug_array($data);
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->district_id = $data['district_id'];
- }
-
-
- function read_addressbook()
- {
-// $contact = $this->so->read_addressbook(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-//
'filter' => $this->filter,'cat_id' => $this->cat_id));
-// $this->total_records = $this->so->total_records;
-
-
-
if($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] &&
-
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] > 0)
- {
- $this->limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $this->limit = 15;
- }
-
- $fields[0] = 'per_first_name';
- $fields[1] = 'per_last_name';
- $fields[2] = 'per_department';
- $fields[3] = 'per_title';
- $fields[4] = 'addr_add1';
- $fields[5] = 'addr_city';
- $fields['owner'] = 'owner';
- $fields['contact_id'] = 'contact_id';
-
-
- $addressbook =
CreateObject('addressbook.boaddressbook');
-
- $criteria = $addressbook->criteria_contacts(1, -3,
'person', $this->query, $fields_search);
-
-//_debug_array($criteria);
- $entries = $addressbook->get_persons($fields,
$this->limit, $this->start, $this->order, $this->sort, '', $criteria);
-
-//_debug_array($entries);
- return $entries;
- }
-
-
- /**
- * Get the the person data what you want
- *
- * @param array $fields The fields that you can see from person
- * @param integer $limit Limit of records that you want
- * @param integer $ofset Ofset of record that you want start
- * @param string $orderby The field which you want order
- * @param string $sort ASC | DESC depending what you want
- * @param mixed $criteria All criterias what you want
- * @param mixed $criteria_token same like $criteria but
builded<br>with sql_criteria class, more powerfull
- * @return array with records
- */
- function get_persons($fields, $start='', $limit='',
$orderby='', $sort='', $criteria='', $token_criteria='')
- {
- $entries = $this->so->get_persons($fields, $start,
$limit, $orderby, $sort, $criteria, $token_criteria);
- if(is_array($entries))
- {
- foreach($entries as $data)
- {
- $persons[$data['contact_id']] = $data;
- }
- }
- else
- {
- $persons = array();
- }
- $this->total = $this->so->contacts->total_records;
- return $persons;
- }
-
-
-
-
-
- function read_vendor()
- {
- $vendor = $this->so->read_vendor(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' => $this->cat_id));
- $this->total_records = $this->so->total_records;
-
- return $vendor;
- }
-
- function read_b_account()
- {
- $b_account = $this->so->read_b_account(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' => $this->cat_id));
- $this->total_records = $this->so->total_records;
-
- return $b_account;
- }
-
- function read_street()
- {
- $street = $this->so->read_street(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' => $this->cat_id));
- $this->total_records = $this->so->total_records;
-
- return $street;
- }
-
- function read_tenant()
- {
- $tenant = $this->so->read_tenant(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' => $this->cat_id));
- $this->total_records = $this->so->total_records;
-
- return $tenant;
- }
-
- function read_ns3420()
- {
- $ns3420 = $this->so->read_ns3420(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' => $this->cat_id));
- $this->total_records = $this->so->total_records;
-
- return $ns3420;
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage core
+ * @version $Id: class.bolookup.inc.php,v 1.7 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class bolookup
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ var $soap_functions = array(
+ 'list' => array(
+ 'in' =>
array('int','int','struct','string','int'),
+ 'out' => array('array')
+ ),
+ 'read' => array(
+ 'in' => array('int','struct'),
+ 'out' => array('array')
+ ),
+ 'save' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ ),
+ 'delete' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ )
+ );
+
+ function bolookup($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.solookup');
+ $this->solocation =
CreateObject($this->currentapp.'.solocation');
+
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start =
get_var('start',array('POST','GET'));
+ $query =
get_var('query',array('POST','GET'));
+ $sort =
get_var('sort',array('POST','GET'));
+ $order =
get_var('order',array('POST','GET'));
+ $filter =
get_var('filter',array('POST','GET'));
+ $cat_id =
get_var('cat_id',array('POST','GET'));
+ $district_id =
get_var('district_id',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ if(isset($district_id))
+ {
+ $this->district_id = $district_id;
+ }
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','lookup',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','lookup');
+
+ //_debug_array($data);
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->district_id = $data['district_id'];
+ }
+
+
+ function read_addressbook()
+ {
+// $contact = $this->so->read_addressbook(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+//
'filter' => $this->filter,'cat_id' => $this->cat_id));
+// $this->total_records = $this->so->total_records;
+
+
+
if($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] &&
+
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] > 0)
+ {
+ $this->limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $this->limit = 15;
+ }
+
+ $fields[0] = 'per_first_name';
+ $fields[1] = 'per_last_name';
+ $fields[2] = 'per_department';
+ $fields[3] = 'per_title';
+ $fields[4] = 'addr_add1';
+ $fields[5] = 'addr_city';
+ $fields['owner'] = 'owner';
+ $fields['contact_id'] = 'contact_id';
+
+
+ $addressbook =
CreateObject('addressbook.boaddressbook');
+
+ $criteria = $addressbook->criteria_contacts(1, -3,
'person', $this->query, $fields_search);
+
+//_debug_array($criteria);
+ $entries = $addressbook->get_persons($fields,
$this->limit, $this->start, $this->order, $this->sort, '', $criteria);
+
+//_debug_array($entries);
+ return $entries;
+ }
+
+
+ /**
+ * Get the the person data what you want
+ *
+ * @param array $fields The fields that you can see from person
+ * @param integer $limit Limit of records that you want
+ * @param integer $ofset Ofset of record that you want start
+ * @param string $orderby The field which you want order
+ * @param string $sort ASC | DESC depending what you want
+ * @param mixed $criteria All criterias what you want
+ * @param mixed $criteria_token same like $criteria but
builded<br>with sql_criteria class, more powerfull
+ * @return array with records
+ */
+ function get_persons($fields, $start='', $limit='',
$orderby='', $sort='', $criteria='', $token_criteria='')
+ {
+ $entries = $this->so->get_persons($fields, $start,
$limit, $orderby, $sort, $criteria, $token_criteria);
+ if(is_array($entries))
+ {
+ foreach($entries as $data)
+ {
+ $persons[$data['contact_id']] = $data;
+ }
+ }
+ else
+ {
+ $persons = array();
+ }
+ $this->total = $this->so->contacts->total_records;
+ return $persons;
+ }
+
+
+
+
+
+ function read_vendor()
+ {
+ $vendor = $this->so->read_vendor(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' => $this->cat_id));
+ $this->total_records = $this->so->total_records;
+
+ return $vendor;
+ }
+
+ function read_b_account()
+ {
+ $b_account = $this->so->read_b_account(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' => $this->cat_id));
+ $this->total_records = $this->so->total_records;
+
+ return $b_account;
+ }
+
+ function read_street()
+ {
+ $street = $this->so->read_street(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' => $this->cat_id));
+ $this->total_records = $this->so->total_records;
+
+ return $street;
+ }
+
+ function read_tenant()
+ {
+ $tenant = $this->so->read_tenant(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' => $this->cat_id));
+ $this->total_records = $this->so->total_records;
+
+ return $tenant;
+ }
+
+ function read_ns3420()
+ {
+ $ns3420 = $this->so->read_ns3420(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' => $this->cat_id));
+ $this->total_records = $this->so->total_records;
+
+ return $ns3420;
+ }
+ }
+?>
Index: property/inc/class.bometer.inc.php
diff -u property/inc/class.bometer.inc.php:1.5
property/inc/class.bometer.inc.php:1.6
--- property/inc/class.bometer.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/class.bometer.inc.php Fri Jan 27 14:05:43 2006
@@ -1,260 +1,260 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage entity
- * @version $Id: class.bometer.inc.php,v 1.5 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class bometer
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- var $soap_functions = array(
- 'list' => array(
- 'in' =>
array('int','int','struct','string','int'),
- 'out' => array('array')
- ),
- 'read' => array(
- 'in' => array('int','struct'),
- 'out' => array('array')
- ),
- 'save' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- ),
- 'delete' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- )
- );
-
- function bometer($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.someter');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','meter',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','meter');
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- }
-
- function get_category_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
- $categories= $this->so->get_category_list();
-
- while (is_array($categories) && list(,$category) =
each($categories))
- {
- $sel_category = '';
- if ($category['id']==$selected)
- {
- $sel_category = 'selected';
- }
-
- $category_list[] = array
- (
- 'cat_id' => $category['id'],
- 'name' => $category['name'],
- 'selected' => $sel_category
- );
- }
-
- for ($i=0;$i<count($category_list);$i++)
- {
- if ($category_list[$i]['selected'] !=
'selected')
- {
- unset($category_list[$i]['selected']);
- }
- }
-
- return $category_list;
- }
-
- function read()
- {
- $meter = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' => $this->cat_id));
- $this->total_records = $this->so->total_records;
-
- $this->uicols = $this->so->uicols;
-/* $cols_extra = $this->so->cols_extra;
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $solocation =
CreateObject($this->currentapp.'.solocation');
-
- for ($i=0; $i<count($meter); $i++)
- {
- $meter[$i]['user'] =
$GLOBALS['phpgw']->accounts->id2name($meter[$i]['user_id']);
- $meter[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($meter[$i]['entry_date'],$dateformat);
-
$location_data=$solocation->read_single($meter[$i]['location_code']);
-
- for ($j=0;$j<count($cols_extra);$j++)
- {
- $meter[$i][$cols_extra[$j]] =
$location_data[$cols_extra[$j]];
- }
-
- }
-*/
- return $meter;
- }
-
- function read_single($meter_id)
- {
- $meter= $this->so->read_single($meter_id);
-
- if($meter['location_code'])
- {
- $solocation =
CreateObject($this->currentapp.'.solocation');
-
- $meter['location_data']
=$solocation->read_single($meter['location_code']);
- }
-
- if($meter['p_num'])
- {
- $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
- $category =
$soadmin_entity->read_single_category($meter['p_entity_id'],$meter['p_cat_id']);
-
-
$meter['p'][$meter['p_entity_id']]['p_num']=$meter['p_num'];
-
$meter['p'][$meter['p_entity_id']]['p_entity_id']=$meter['p_entity_id'];
-
$meter['p'][$meter['p_entity_id']]['p_cat_id']=$meter['p_cat_id'];
-
$meter['p'][$meter['p_entity_id']]['p_cat_name'] = $category['name'];
- }
-
- return $meter;
- }
-
- function check_meter_num($num)
- {
- return $this->so->check_meter_num($num);
- }
-
- function save($values,$action='')
- {
- while (is_array($values['location']) && list(,$value) =
each($values['location']))
- {
- if($value)
- {
- $location[] = $value;
- }
- }
-
- $values['location_code']=implode("-", $location);
-
- if ($action=='edit')
- {
- $receipt = $this->so->edit($values);
- }
- else
- {
- $receipt = $this->so->add($values);
- }
- return $receipt;
- }
-
- function delete($params)
- {
- if (is_array($params))
- {
- $this->so->delete($params[0]);
- }
- else
- {
- $this->so->delete($params);
- }
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage entity
+ * @version $Id: class.bometer.inc.php,v 1.6 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class bometer
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ var $soap_functions = array(
+ 'list' => array(
+ 'in' =>
array('int','int','struct','string','int'),
+ 'out' => array('array')
+ ),
+ 'read' => array(
+ 'in' => array('int','struct'),
+ 'out' => array('array')
+ ),
+ 'save' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ ),
+ 'delete' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ )
+ );
+
+ function bometer($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.someter');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','meter',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','meter');
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ }
+
+ function get_category_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ break;
+ }
+
+ $categories= $this->so->get_category_list();
+
+ while (is_array($categories) && list(,$category) =
each($categories))
+ {
+ $sel_category = '';
+ if ($category['id']==$selected)
+ {
+ $sel_category = 'selected';
+ }
+
+ $category_list[] = array
+ (
+ 'cat_id' => $category['id'],
+ 'name' => $category['name'],
+ 'selected' => $sel_category
+ );
+ }
+
+ for ($i=0;$i<count($category_list);$i++)
+ {
+ if ($category_list[$i]['selected'] !=
'selected')
+ {
+ unset($category_list[$i]['selected']);
+ }
+ }
+
+ return $category_list;
+ }
+
+ function read()
+ {
+ $meter = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' => $this->cat_id));
+ $this->total_records = $this->so->total_records;
+
+ $this->uicols = $this->so->uicols;
+/* $cols_extra = $this->so->cols_extra;
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $solocation =
CreateObject($this->currentapp.'.solocation');
+
+ for ($i=0; $i<count($meter); $i++)
+ {
+ $meter[$i]['user'] =
$GLOBALS['phpgw']->accounts->id2name($meter[$i]['user_id']);
+ $meter[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($meter[$i]['entry_date'],$dateformat);
+
$location_data=$solocation->read_single($meter[$i]['location_code']);
+
+ for ($j=0;$j<count($cols_extra);$j++)
+ {
+ $meter[$i][$cols_extra[$j]] =
$location_data[$cols_extra[$j]];
+ }
+
+ }
+*/
+ return $meter;
+ }
+
+ function read_single($meter_id)
+ {
+ $meter= $this->so->read_single($meter_id);
+
+ if($meter['location_code'])
+ {
+ $solocation =
CreateObject($this->currentapp.'.solocation');
+
+ $meter['location_data']
=$solocation->read_single($meter['location_code']);
+ }
+
+ if($meter['p_num'])
+ {
+ $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
+ $category =
$soadmin_entity->read_single_category($meter['p_entity_id'],$meter['p_cat_id']);
+
+
$meter['p'][$meter['p_entity_id']]['p_num']=$meter['p_num'];
+
$meter['p'][$meter['p_entity_id']]['p_entity_id']=$meter['p_entity_id'];
+
$meter['p'][$meter['p_entity_id']]['p_cat_id']=$meter['p_cat_id'];
+
$meter['p'][$meter['p_entity_id']]['p_cat_name'] = $category['name'];
+ }
+
+ return $meter;
+ }
+
+ function check_meter_num($num)
+ {
+ return $this->so->check_meter_num($num);
+ }
+
+ function save($values,$action='')
+ {
+ while (is_array($values['location']) && list(,$value) =
each($values['location']))
+ {
+ if($value)
+ {
+ $location[] = $value;
+ }
+ }
+
+ $values['location_code']=implode("-", $location);
+
+ if ($action=='edit')
+ {
+ $receipt = $this->so->edit($values);
+ }
+ else
+ {
+ $receipt = $this->so->add($values);
+ }
+ return $receipt;
+ }
+
+ function delete($params)
+ {
+ if (is_array($params))
+ {
+ $this->so->delete($params[0]);
+ }
+ else
+ {
+ $this->so->delete($params);
+ }
+ }
+
+ }
+?>
Index: property/inc/class.bop_of_town.inc.php
diff -u property/inc/class.bop_of_town.inc.php:1.5
property/inc/class.bop_of_town.inc.php:1.6
--- property/inc/class.bop_of_town.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/class.bop_of_town.inc.php Fri Jan 27 14:05:43 2006
@@ -1,242 +1,242 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.bop_of_town.inc.php,v 1.5 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class bop_of_town
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $district_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- var $soap_functions = array(
- 'list' => array(
- 'in' =>
array('int','int','struct','string','int'),
- 'out' => array('array')
- ),
- 'read' => array(
- 'in' => array('int','struct'),
- 'out' => array('array')
- ),
- 'save' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- ),
- 'delete' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- )
- );
-
- function bop_of_town($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.sop_of_town');
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $district_id =
get_var('district_id',array('POST','GET'));
- $allrows =
get_var('allrows',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($district_id) && !empty($district_id))
- {
- $this->district_id = $district_id;
- }
- else
- {
- unset($this->district_id);
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
- }
-
- function list_methods($_type='xmlrpc')
- {
- /*
- This handles introspection or discovery by the logged
in client,
- in which case the input might be an array. The
server always calls
- this function to fill the server dispatch map using a
string.
- */
- if (is_array($_type))
- {
- $_type = $_type['type'] ? $_type['type'] :
$_type[0];
- }
- switch($_type)
- {
- case 'xmlrpc':
- $xml_functions = array(
- 'read' => array(
- 'function' => 'read',
- 'signature' =>
array(array(xmlrpcInt,xmlrpcStruct)),
- 'docstring' =>
lang('Read a single entry by passing the id and fieldlist.')
- ),
- 'save' => array(
- 'function' => 'save',
- 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
- 'docstring' =>
lang('Update a single entry by passing the fields.')
- ),
- 'delete' => array(
- 'function' => 'delete',
- 'signature' =>
array(array(xmlrpcBoolean,xmlrpcInt)),
- 'docstring' =>
lang('Delete a single entry by passing the id.')
- ),
- 'list' => array(
- 'function' => '_list',
- 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
- 'docstring' =>
lang('Read a list of entries.')
- ),
- 'list_methods' => array(
- 'function' =>
'list_methods',
- 'signature' =>
array(array(xmlrpcStruct,xmlrpcString)),
- 'docstring' =>
lang('Read this list of methods.')
- )
- );
- return $xml_functions;
- break;
- case 'soap':
- return $this->soap_functions;
- break;
- default:
- return array();
- break;
- }
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','p_of_town',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','p_of_town');
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->district_id = $data['district_id'];
- }
-
- function check_perms($has, $needed)
- {
- return (!!($has & $needed) == True);
- }
-
-
- function read_district_name($district_id='')
- {
- return $this->so->read_district_name($district_id);
- }
-
-
- function read()
- {
- $p_of_town = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'district_id' =>
$this->district_id,'allrows'=>$this->allrows));
- $this->total_records = $this->so->total_records;
-
- return $p_of_town;
- }
-
- function read_single($part_of_town_id)
- {
- return $this->so->read_single($part_of_town_id);
- }
-
- function save($p_of_town)
- {
-
- if ($p_of_town['part_of_town_id'])
- {
- if ($p_of_town['part_of_town_id'] != 0)
- {
- $part_of_town_id =
$p_of_town['part_of_town_id'];
- $receipt=$this->so->edit($p_of_town);
- }
- }
- else
- {
- $receipt = $this->so->add($p_of_town);
- }
- return $receipt;
- }
-
- function delete($params)
- {
- if (is_array($params))
- {
- $this->so->delete($params[0]);
- }
- else
- {
- $this->so->delete($params);
- }
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.bop_of_town.inc.php,v 1.6 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class bop_of_town
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $district_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ var $soap_functions = array(
+ 'list' => array(
+ 'in' =>
array('int','int','struct','string','int'),
+ 'out' => array('array')
+ ),
+ 'read' => array(
+ 'in' => array('int','struct'),
+ 'out' => array('array')
+ ),
+ 'save' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ ),
+ 'delete' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ )
+ );
+
+ function bop_of_town($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.sop_of_town');
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $district_id =
get_var('district_id',array('POST','GET'));
+ $allrows =
get_var('allrows',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($district_id) && !empty($district_id))
+ {
+ $this->district_id = $district_id;
+ }
+ else
+ {
+ unset($this->district_id);
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+ }
+
+ function list_methods($_type='xmlrpc')
+ {
+ /*
+ This handles introspection or discovery by the logged
in client,
+ in which case the input might be an array. The
server always calls
+ this function to fill the server dispatch map using a
string.
+ */
+ if (is_array($_type))
+ {
+ $_type = $_type['type'] ? $_type['type'] :
$_type[0];
+ }
+ switch($_type)
+ {
+ case 'xmlrpc':
+ $xml_functions = array(
+ 'read' => array(
+ 'function' => 'read',
+ 'signature' =>
array(array(xmlrpcInt,xmlrpcStruct)),
+ 'docstring' =>
lang('Read a single entry by passing the id and fieldlist.')
+ ),
+ 'save' => array(
+ 'function' => 'save',
+ 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
+ 'docstring' =>
lang('Update a single entry by passing the fields.')
+ ),
+ 'delete' => array(
+ 'function' => 'delete',
+ 'signature' =>
array(array(xmlrpcBoolean,xmlrpcInt)),
+ 'docstring' =>
lang('Delete a single entry by passing the id.')
+ ),
+ 'list' => array(
+ 'function' => '_list',
+ 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
+ 'docstring' =>
lang('Read a list of entries.')
+ ),
+ 'list_methods' => array(
+ 'function' =>
'list_methods',
+ 'signature' =>
array(array(xmlrpcStruct,xmlrpcString)),
+ 'docstring' =>
lang('Read this list of methods.')
+ )
+ );
+ return $xml_functions;
+ break;
+ case 'soap':
+ return $this->soap_functions;
+ break;
+ default:
+ return array();
+ break;
+ }
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','p_of_town',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','p_of_town');
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->district_id = $data['district_id'];
+ }
+
+ function check_perms($has, $needed)
+ {
+ return (!!($has & $needed) == True);
+ }
+
+
+ function read_district_name($district_id='')
+ {
+ return $this->so->read_district_name($district_id);
+ }
+
+
+ function read()
+ {
+ $p_of_town = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'district_id' =>
$this->district_id,'allrows'=>$this->allrows));
+ $this->total_records = $this->so->total_records;
+
+ return $p_of_town;
+ }
+
+ function read_single($part_of_town_id)
+ {
+ return $this->so->read_single($part_of_town_id);
+ }
+
+ function save($p_of_town)
+ {
+
+ if ($p_of_town['part_of_town_id'])
+ {
+ if ($p_of_town['part_of_town_id'] != 0)
+ {
+ $part_of_town_id =
$p_of_town['part_of_town_id'];
+ $receipt=$this->so->edit($p_of_town);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add($p_of_town);
+ }
+ return $receipt;
+ }
+
+ function delete($params)
+ {
+ if (is_array($params))
+ {
+ $this->so->delete($params[0]);
+ }
+ else
+ {
+ $this->so->delete($params);
+ }
+ }
+ }
+?>
Index: property/inc/class.bopricebook.inc.php
diff -u property/inc/class.bopricebook.inc.php:1.6
property/inc/class.bopricebook.inc.php:1.7
--- property/inc/class.bopricebook.inc.php:1.6 Thu May 12 21:26:28 2005
+++ property/inc/class.bopricebook.inc.php Fri Jan 27 14:05:43 2006
@@ -1,565 +1,565 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage agreement
- * @version $Id: class.bopricebook.inc.php,v 1.6 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class bopricebook
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- var $soap_functions = array(
- 'list' => array(
- 'in' =>
array('int','int','struct','string','int'),
- 'out' => array('array')
- ),
- 'read' => array(
- 'in' => array('int','struct'),
- 'out' => array('array')
- ),
- 'save' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- ),
- 'delete' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- )
- );
-
- function bopricebook($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.sopricebook');
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $allrows =
get_var('allrows',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','pricebook',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','pricebook');
-
- //_debug_array($data);
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- }
-
-
- function select_status_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('status_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('status_filter'));
- break;
- }
-
- $status_entries= $this->so->select_status_list();
-
- while (is_array($status_entries) && list(,$status) =
each($status_entries))
- {
- $sel_status = '';
- if ($status['id']==$selected)
- {
- $sel_status = 'selected';
- }
-
- $status_list[] = array
- (
- 'id' => $status['id'],
- 'name' => $status['name'],
- 'selected' => $sel_status
- );
- }
-
- for ($i=0;$i<count($status_list);$i++)
- {
- if ($status_list[$i]['selected'] != 'selected')
- {
- unset($status_list[$i]['selected']);
- }
- }
-
- return $status_list;
- }
-
- function read()
- {
- $pricebook = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows));
- $this->total_records = $this->so->total_records;
- return $pricebook;
- }
-
- function read_agreement_group()
- {
- $agreement_group =
$this->so->read_agreement_group(array('start' => $this->start,'query' =>
$this->query,'sort' => $this->sort,'order' => $this->order,
-
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows));
- $this->total_records = $this->so->total_records;
- return $agreement_group;
- }
-
- function read_activity_prize($activity_id,$vendor_id)
- {
- $pricebook =
$this->so->read_activity_prize(array('start' => $this->start,'query' =>
$this->query,'sort' => $this->sort,'order' => $this->order,
-
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows,'activity_id'=>$activity_id,'vendor_id'=>$vendor_id));
- $this->total_records = $this->so->total_records;
- return $pricebook;
- }
-
-
- function read_activities_pr_agreement_group()
- {
- $pricebook =
$this->so->read_activities_pr_agreement_group(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows));
- $this->total_records = $this->so->total_records;
- return $pricebook;
- }
-
- function read_vendor_pr_activity($activity_id)
- {
- $pricebook =
$this->so->read_vendor_pr_activity(array('start' => $this->start,'query' =>
$this->query,'sort' => $this->sort,'order' => $this->order,
-
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows,'activity_id'=>$activity_id));
- $this->total_records = $this->so->total_records;
- return $pricebook;
- }
-
- function add_activity_vendor($values)
- {
- return $this->so->add_activity_vendor($values);
- }
-
- function read_single_activity($id='')
- {
- return $this->so->read_single_activity($id);
- }
-
- function read_single_agreement_group($id='')
- {
- return $this->so->read_single_agreement_group($id);
- }
-
-
- function read_category_name($cat_id)
- {
- return $this->so->read_category_name($cat_id);
- }
-
- function update_pricebook($values)
- {
-
-//_debug_array($values);
-
$date_array=$this->bocommon->date_array($values['date']);
-
- $date = mktime
(2,0,0,$date_array['month'],$date_array['day'],$date_array['year']);
-// $date= date($this->bocommon->dateformat,$date);
-
- $new_index=str_replace(",",".",$values['new_index']);
-
- while(address@hidden($values['update']))
- {
- $n=$entry[0];
-
- if(!$values['old_total_cost'][$n])
- {
-
$new_total_cost=($values['old_m_cost'][$n]+$values['old_w_cost'][$n])*$new_index;
- }
- else
- {
-
$new_total_cost=$values['old_total_cost'][$n]*$new_index;
- }
-
- if(!$values['old_m_cost'][$n])
- {
- $new_m_cost=0;
- }
- else
- {
-
$new_m_cost=$values['old_m_cost'][$n]*$new_index;
- }
-
- if(!$values['old_w_cost'][$n])
- {
- $new_w_cost=0;
- }
- else
- {
-
$new_w_cost=$values['old_w_cost'][$n]*$new_index;
- }
-
- $update[]=array(
- 'new_m_cost' => $new_m_cost,
- 'new_w_cost' => $new_w_cost,
- 'new_total_cost' =>
$new_total_cost,
- 'activity_id' =>
$values['activity_id'][$n],
- 'vendor_id' =>
$values['vendor_id'][$n],
- 'new_index' =>
$new_index,
- 'new_date' =>
$date,
- );
-
- }
-//_debug_array($update);
-
- if($update)
- {
- $receipt =
$this->so->update_pricebook($update);
- }
- else
- {
- $receipt['message'][] =
array('msg'=>lang('Nothing to do!'));
- }
-
- return $receipt;
-
- }
-
- function add_activity_first_prize($values)
- {
-
-
$date_array=$this->bocommon->date_array($values['date']);
-
- $date = mktime
(2,0,0,$date_array['month'],$date_array['day'],$date_array['year']);
-// $date= date($this->bocommon->dateformat,$date);
-
- $m_cost =
str_replace(",",".",$values['m_cost']);
- $w_cost =
str_replace(",",".",$values['w_cost']);
- $total_cost = $m_cost + $w_cost;
- $activity_id = $values['activity_id'][0];
- $vendor_id = $values['vendor_id'][0];
-
- $receipt =
$this->so->add_activity_first_prize($m_cost,$w_cost,$total_cost,$activity_id,$vendor_id,$date);
-
- return $receipt;
- }
-
- function get_vendor_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
- $vendors= $this->so->get_vendor_list();
-
- while (is_array($vendors) && list(,$vendor_entry) =
each($vendors))
- {
- $sel_vendor_entry = '';
- if ($vendor_entry['id']==$selected)
- {
- $sel_vendor_entry = 'selected';
- }
-
- $vendor_list[] = array
- (
- 'cat_id' => $vendor_entry['id'],
- 'name' =>
$vendor_entry['name'],
- 'selected' => $sel_vendor_entry
- );
- }
-
- for ($i=0;$i<count($vendor_list);$i++)
- {
- if ($vendor_list[$i]['selected'] != 'selected')
- {
- unset($vendor_list[$i]['selected']);
- }
- }
-
- return $vendor_list;
- }
-
- function get_dim_d_list($selected='')
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('dim_d_select'));
-
- $dim_ds= $this->so->get_dim_d_list();
-
- while (is_array($dim_ds) && list(,$dim_d_entry) =
each($dim_ds))
- {
- $sel_dim_d_entry = '';
- if ($dim_d_entry['id']==$selected)
- {
- $sel_dim_d_entry = 'selected';
- }
-
- $dim_d_list[] = array
- (
- 'id' => $dim_d_entry['id'],
- 'name' => $dim_d_entry['name'],
- 'selected' => $sel_dim_d_entry
- );
- }
-
- for ($i=0;$i<count($dim_d_list);$i++)
- {
- if ($dim_d_list[$i]['selected'] != 'selected')
- {
- unset($dim_d_list[$i]['selected']);
- }
- }
-
- return $dim_d_list;
- }
-
- function get_unit_list($selected='')
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('unit_select'));
-
- $units= $this->so->get_unit_list();
-
- while (is_array($units) && list(,$unit_entry) =
each($units))
- {
- $sel_unit_entry = '';
- if ($unit_entry['id']==$selected)
- {
- $sel_unit_entry = 'selected';
- }
-
- $unit_list[] = array
- (
- 'id' => $unit_entry['id'],
- 'name' => $unit_entry['name'],
- 'selected' => $sel_unit_entry
- );
- }
-
- for ($i=0;$i<count($unit_list);$i++)
- {
- if ($unit_list[$i]['selected'] != 'selected')
- {
- unset($unit_list[$i]['selected']);
- }
- }
-
- return $unit_list;
- }
-
- function get_branch_list($selected='')
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('branch_select'));
-
- $branches= $this->so->get_branch_list();
-
- while (is_array($branches) && list(,$branch_entry) =
each($branches))
- {
- $sel_branch_entry = '';
- if ($branch_entry['id']==$selected)
- {
- $sel_branch_entry = 'selected';
- }
-
- $branch_list[] = array
- (
- 'id' => $branch_entry['id'],
- 'name' =>
$branch_entry['name'],
- 'selected' => $sel_branch_entry
- );
- }
-
- for ($i=0;$i<count($branch_list);$i++)
- {
- if ($branch_list[$i]['selected'] != 'selected')
- {
- unset($branch_list[$i]['selected']);
- }
- }
-
- return $branch_list;
- }
-
- function get_agreement_group_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
- $agreement_groups=
$this->so->get_agreement_group_list();
-
- while (is_array($agreement_groups) &&
list(,$agreement_group_entry) = each($agreement_groups))
- {
- $sel_agreement_group_entry = '';
- if ($agreement_group_entry['id']==$selected)
- {
- $sel_agreement_group_entry = 'selected';
- }
-
- $agreement_group_list[] = array
- (
- 'cat_id' =>
$agreement_group_entry['id'],
- 'name' =>
$agreement_group_entry['name'],
- 'selected' =>
$sel_agreement_group_entry
- );
- }
-
- for ($i=0;$i<count($agreement_group_list);$i++)
- {
- if ($agreement_group_list[$i]['selected'] !=
'selected')
- {
-
unset($agreement_group_list[$i]['selected']);
- }
- }
-
- return $agreement_group_list;
- }
-
-
- function check_activity_num($num='',$agreement_group_id='')
- {
- return
$this->so->check_activity_num($num,$agreement_group_id);
- }
-
- function save_activity($values,$action='')
- {
- if ($action=='edit')
- {
- $receipt = $this->so->edit_activity($values);
- }
- else
- {
-
$values['activity_id']=$this->socommon->next_id('fm_activities');
- $receipt = $this->so->add_activity($values);
- }
- return $receipt;
- }
-
- function check_agreement_group_num($num='')
- {
- return $this->so->check_agreement_group_num($num);
- }
-
- function save_agreement_group($values,$action='')
- {
- if ($action=='edit')
- {
- $receipt =
$this->so->edit_agreement_group($values);
- }
- else
- {
-
$values['agreement_group_id']=$this->socommon->next_id('fm_agreement_group');
- $receipt =
$this->so->add_agreement_group($values);
- }
- return $receipt;
- }
-
- function delete_activity_vendor($activity_id,$vendor_id)
- {
-
$this->so->delete_activity_vendor($activity_id,$vendor_id);
- }
-
- function delete_activity($activity_id)
- {
- $this->so->delete_activity($activity_id);
- }
-
- function
delete_prize_index($activity_id,$vendor_id,$index_count)
- {
-
$this->so->delete_prize_index($activity_id,$vendor_id,$index_count);
- }
-
- function delete_agreement_group($agreement_group_id)
- {
- $this->so->delete_agreement_group($agreement_group_id);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage agreement
+ * @version $Id: class.bopricebook.inc.php,v 1.7 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class bopricebook
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ var $soap_functions = array(
+ 'list' => array(
+ 'in' =>
array('int','int','struct','string','int'),
+ 'out' => array('array')
+ ),
+ 'read' => array(
+ 'in' => array('int','struct'),
+ 'out' => array('array')
+ ),
+ 'save' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ ),
+ 'delete' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ )
+ );
+
+ function bopricebook($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.sopricebook');
+ $this->socommon =
CreateObject($this->currentapp.'.socommon');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $allrows =
get_var('allrows',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','pricebook',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','pricebook');
+
+ //_debug_array($data);
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ }
+
+
+ function select_status_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('status_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('status_filter'));
+ break;
+ }
+
+ $status_entries= $this->so->select_status_list();
+
+ while (is_array($status_entries) && list(,$status) =
each($status_entries))
+ {
+ $sel_status = '';
+ if ($status['id']==$selected)
+ {
+ $sel_status = 'selected';
+ }
+
+ $status_list[] = array
+ (
+ 'id' => $status['id'],
+ 'name' => $status['name'],
+ 'selected' => $sel_status
+ );
+ }
+
+ for ($i=0;$i<count($status_list);$i++)
+ {
+ if ($status_list[$i]['selected'] != 'selected')
+ {
+ unset($status_list[$i]['selected']);
+ }
+ }
+
+ return $status_list;
+ }
+
+ function read()
+ {
+ $pricebook = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows));
+ $this->total_records = $this->so->total_records;
+ return $pricebook;
+ }
+
+ function read_agreement_group()
+ {
+ $agreement_group =
$this->so->read_agreement_group(array('start' => $this->start,'query' =>
$this->query,'sort' => $this->sort,'order' => $this->order,
+
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows));
+ $this->total_records = $this->so->total_records;
+ return $agreement_group;
+ }
+
+ function read_activity_prize($activity_id,$vendor_id)
+ {
+ $pricebook =
$this->so->read_activity_prize(array('start' => $this->start,'query' =>
$this->query,'sort' => $this->sort,'order' => $this->order,
+
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows,'activity_id'=>$activity_id,'vendor_id'=>$vendor_id));
+ $this->total_records = $this->so->total_records;
+ return $pricebook;
+ }
+
+
+ function read_activities_pr_agreement_group()
+ {
+ $pricebook =
$this->so->read_activities_pr_agreement_group(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows));
+ $this->total_records = $this->so->total_records;
+ return $pricebook;
+ }
+
+ function read_vendor_pr_activity($activity_id)
+ {
+ $pricebook =
$this->so->read_vendor_pr_activity(array('start' => $this->start,'query' =>
$this->query,'sort' => $this->sort,'order' => $this->order,
+
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows,'activity_id'=>$activity_id));
+ $this->total_records = $this->so->total_records;
+ return $pricebook;
+ }
+
+ function add_activity_vendor($values)
+ {
+ return $this->so->add_activity_vendor($values);
+ }
+
+ function read_single_activity($id='')
+ {
+ return $this->so->read_single_activity($id);
+ }
+
+ function read_single_agreement_group($id='')
+ {
+ return $this->so->read_single_agreement_group($id);
+ }
+
+
+ function read_category_name($cat_id)
+ {
+ return $this->so->read_category_name($cat_id);
+ }
+
+ function update_pricebook($values)
+ {
+
+//_debug_array($values);
+
$date_array=$this->bocommon->date_array($values['date']);
+
+ $date = mktime
(2,0,0,$date_array['month'],$date_array['day'],$date_array['year']);
+// $date= date($this->bocommon->dateformat,$date);
+
+ $new_index=str_replace(",",".",$values['new_index']);
+
+ while(address@hidden($values['update']))
+ {
+ $n=$entry[0];
+
+ if(!$values['old_total_cost'][$n])
+ {
+
$new_total_cost=($values['old_m_cost'][$n]+$values['old_w_cost'][$n])*$new_index;
+ }
+ else
+ {
+
$new_total_cost=$values['old_total_cost'][$n]*$new_index;
+ }
+
+ if(!$values['old_m_cost'][$n])
+ {
+ $new_m_cost=0;
+ }
+ else
+ {
+
$new_m_cost=$values['old_m_cost'][$n]*$new_index;
+ }
+
+ if(!$values['old_w_cost'][$n])
+ {
+ $new_w_cost=0;
+ }
+ else
+ {
+
$new_w_cost=$values['old_w_cost'][$n]*$new_index;
+ }
+
+ $update[]=array(
+ 'new_m_cost' => $new_m_cost,
+ 'new_w_cost' => $new_w_cost,
+ 'new_total_cost' =>
$new_total_cost,
+ 'activity_id' =>
$values['activity_id'][$n],
+ 'vendor_id' =>
$values['vendor_id'][$n],
+ 'new_index' =>
$new_index,
+ 'new_date' =>
$date,
+ );
+
+ }
+//_debug_array($update);
+
+ if($update)
+ {
+ $receipt =
$this->so->update_pricebook($update);
+ }
+ else
+ {
+ $receipt['message'][] =
array('msg'=>lang('Nothing to do!'));
+ }
+
+ return $receipt;
+
+ }
+
+ function add_activity_first_prize($values)
+ {
+
+
$date_array=$this->bocommon->date_array($values['date']);
+
+ $date = mktime
(2,0,0,$date_array['month'],$date_array['day'],$date_array['year']);
+// $date= date($this->bocommon->dateformat,$date);
+
+ $m_cost =
str_replace(",",".",$values['m_cost']);
+ $w_cost =
str_replace(",",".",$values['w_cost']);
+ $total_cost = $m_cost + $w_cost;
+ $activity_id = $values['activity_id'][0];
+ $vendor_id = $values['vendor_id'][0];
+
+ $receipt =
$this->so->add_activity_first_prize($m_cost,$w_cost,$total_cost,$activity_id,$vendor_id,$date);
+
+ return $receipt;
+ }
+
+ function get_vendor_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ break;
+ }
+
+ $vendors= $this->so->get_vendor_list();
+
+ while (is_array($vendors) && list(,$vendor_entry) =
each($vendors))
+ {
+ $sel_vendor_entry = '';
+ if ($vendor_entry['id']==$selected)
+ {
+ $sel_vendor_entry = 'selected';
+ }
+
+ $vendor_list[] = array
+ (
+ 'cat_id' => $vendor_entry['id'],
+ 'name' =>
$vendor_entry['name'],
+ 'selected' => $sel_vendor_entry
+ );
+ }
+
+ for ($i=0;$i<count($vendor_list);$i++)
+ {
+ if ($vendor_list[$i]['selected'] != 'selected')
+ {
+ unset($vendor_list[$i]['selected']);
+ }
+ }
+
+ return $vendor_list;
+ }
+
+ function get_dim_d_list($selected='')
+ {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('dim_d_select'));
+
+ $dim_ds= $this->so->get_dim_d_list();
+
+ while (is_array($dim_ds) && list(,$dim_d_entry) =
each($dim_ds))
+ {
+ $sel_dim_d_entry = '';
+ if ($dim_d_entry['id']==$selected)
+ {
+ $sel_dim_d_entry = 'selected';
+ }
+
+ $dim_d_list[] = array
+ (
+ 'id' => $dim_d_entry['id'],
+ 'name' => $dim_d_entry['name'],
+ 'selected' => $sel_dim_d_entry
+ );
+ }
+
+ for ($i=0;$i<count($dim_d_list);$i++)
+ {
+ if ($dim_d_list[$i]['selected'] != 'selected')
+ {
+ unset($dim_d_list[$i]['selected']);
+ }
+ }
+
+ return $dim_d_list;
+ }
+
+ function get_unit_list($selected='')
+ {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('unit_select'));
+
+ $units= $this->so->get_unit_list();
+
+ while (is_array($units) && list(,$unit_entry) =
each($units))
+ {
+ $sel_unit_entry = '';
+ if ($unit_entry['id']==$selected)
+ {
+ $sel_unit_entry = 'selected';
+ }
+
+ $unit_list[] = array
+ (
+ 'id' => $unit_entry['id'],
+ 'name' => $unit_entry['name'],
+ 'selected' => $sel_unit_entry
+ );
+ }
+
+ for ($i=0;$i<count($unit_list);$i++)
+ {
+ if ($unit_list[$i]['selected'] != 'selected')
+ {
+ unset($unit_list[$i]['selected']);
+ }
+ }
+
+ return $unit_list;
+ }
+
+ function get_branch_list($selected='')
+ {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('branch_select'));
+
+ $branches= $this->so->get_branch_list();
+
+ while (is_array($branches) && list(,$branch_entry) =
each($branches))
+ {
+ $sel_branch_entry = '';
+ if ($branch_entry['id']==$selected)
+ {
+ $sel_branch_entry = 'selected';
+ }
+
+ $branch_list[] = array
+ (
+ 'id' => $branch_entry['id'],
+ 'name' =>
$branch_entry['name'],
+ 'selected' => $sel_branch_entry
+ );
+ }
+
+ for ($i=0;$i<count($branch_list);$i++)
+ {
+ if ($branch_list[$i]['selected'] != 'selected')
+ {
+ unset($branch_list[$i]['selected']);
+ }
+ }
+
+ return $branch_list;
+ }
+
+ function get_agreement_group_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ break;
+ }
+
+ $agreement_groups=
$this->so->get_agreement_group_list();
+
+ while (is_array($agreement_groups) &&
list(,$agreement_group_entry) = each($agreement_groups))
+ {
+ $sel_agreement_group_entry = '';
+ if ($agreement_group_entry['id']==$selected)
+ {
+ $sel_agreement_group_entry = 'selected';
+ }
+
+ $agreement_group_list[] = array
+ (
+ 'cat_id' =>
$agreement_group_entry['id'],
+ 'name' =>
$agreement_group_entry['name'],
+ 'selected' =>
$sel_agreement_group_entry
+ );
+ }
+
+ for ($i=0;$i<count($agreement_group_list);$i++)
+ {
+ if ($agreement_group_list[$i]['selected'] !=
'selected')
+ {
+
unset($agreement_group_list[$i]['selected']);
+ }
+ }
+
+ return $agreement_group_list;
+ }
+
+
+ function check_activity_num($num='',$agreement_group_id='')
+ {
+ return
$this->so->check_activity_num($num,$agreement_group_id);
+ }
+
+ function save_activity($values,$action='')
+ {
+ if ($action=='edit')
+ {
+ $receipt = $this->so->edit_activity($values);
+ }
+ else
+ {
+
$values['activity_id']=$this->socommon->next_id('fm_activities');
+ $receipt = $this->so->add_activity($values);
+ }
+ return $receipt;
+ }
+
+ function check_agreement_group_num($num='')
+ {
+ return $this->so->check_agreement_group_num($num);
+ }
+
+ function save_agreement_group($values,$action='')
+ {
+ if ($action=='edit')
+ {
+ $receipt =
$this->so->edit_agreement_group($values);
+ }
+ else
+ {
+
$values['agreement_group_id']=$this->socommon->next_id('fm_agreement_group');
+ $receipt =
$this->so->add_agreement_group($values);
+ }
+ return $receipt;
+ }
+
+ function delete_activity_vendor($activity_id,$vendor_id)
+ {
+
$this->so->delete_activity_vendor($activity_id,$vendor_id);
+ }
+
+ function delete_activity($activity_id)
+ {
+ $this->so->delete_activity($activity_id);
+ }
+
+ function
delete_prize_index($activity_id,$vendor_id,$index_count)
+ {
+
$this->so->delete_prize_index($activity_id,$vendor_id,$index_count);
+ }
+
+ function delete_agreement_group($agreement_group_id)
+ {
+ $this->so->delete_agreement_group($agreement_group_id);
+ }
+ }
+?>
Index: property/inc/class.boproject.inc.php
diff -u property/inc/class.boproject.inc.php:1.12
property/inc/class.boproject.inc.php:1.13
--- property/inc/class.boproject.inc.php:1.12 Mon Sep 12 08:19:02 2005
+++ property/inc/class.boproject.inc.php Fri Jan 27 14:05:43 2006
@@ -1,575 +1,575 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage project
- * @version $Id: class.boproject.inc.php,v 1.12 2005/09/12 08:19:02
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class boproject
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- function boproject($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.soproject');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->solocation =
CreateObject($this->currentapp.'.solocation');
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $status_id =
get_var('status_id',array('POST','GET'));
- $wo_hour_cat_id =
get_var('wo_hour_cat_id',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(isset($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- if(isset($status_id))
- {
- $this->status_id = $status_id;
- }
- if(isset($wo_hour_cat_id))
- {
- $this->wo_hour_cat_id = $wo_hour_cat_id;
- }
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','project',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','project');
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->status_id = $data['status_id'];
- $this->wo_hour_cat_id = $data['wo_hour_cat_id'];
- }
-
- function select_status_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('status_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('status_filter'));
- break;
- }
-
- $status_entries= $this->so->select_status_list();
-
- while (is_array($status_entries) && list(,$status) =
each($status_entries))
- {
- $sel_status = '';
- if ($status['id']==$selected)
- {
- $sel_status = 'selected';
- }
-
- $status_list[] = array
- (
- 'id' => $status['id'],
- 'name' => $status['name'],
- 'selected' => $sel_status
- );
- }
-
- for ($i=0;$i<count($status_list);$i++)
- {
- if ($status_list[$i]['selected'] != 'selected')
- {
- unset($status_list[$i]['selected']);
- }
- }
-
- return $status_list;
- }
-
- function select_branch_list($selected='')
- {
-
- $branch_entries= $this->so->select_branch_list();
-
- while (is_array($branch_entries) && list(,$branch) =
each($branch_entries))
- {
- $sel_branch = '';
- if ($branch['id']==$selected)
- {
- $sel_branch = 'selected';
- }
-
- $branch_list[] = array
- (
- 'id' => $branch['id'],
- 'name' => $branch['name'],
- 'selected' => $sel_branch
- );
- }
-
- for ($i=0;$i<count($branch_list);$i++)
- {
- if ($branch_list[$i]['selected'] != 'selected')
- {
- unset($branch_list[$i]['selected']);
- }
- }
-
- return $branch_list;
- }
-
- function select_branch_p_list($project_id='')
- {
-
- $selected =
$this->so->branch_p_list($project_id);
- $branch_entries = $this->so->select_branch_list();
-
- $j=0;
- while (is_array($branch_entries) && list(,$branch) =
each($branch_entries))
- {
- $branch_list[$j]['id'] = $branch['id'];
- $branch_list[$j]['name'] = $branch['name'];
-
- for ($i=0;$i<count($selected);$i++)
- {
- if($selected[$i]['branch_id'] ==
$branch['id'])
- {
- $branch_list[$j]['selected'] =
'selected';
- }
- }
- $j++;
- }
-
- for ($i=0;$i<count($branch_list);$i++)
- {
- if ($branch_list[$i]['selected'] != 'selected')
- {
- unset($branch_list[$i]['selected']);
- }
- }
-
- return $branch_list;
- }
-
-
- function select_key_location_list($selected='')
- {
-
- $key_location_entries=
$this->so->select_key_location_list();
-
- while (is_array($key_location_entries) &&
list(,$key_location) = each($key_location_entries))
- {
- $sel_key_location = '';
- if ($key_location['id']==$selected)
- {
- $sel_key_location = 'selected';
- }
-
- $key_location_list[] = array
- (
- 'id' => $key_location['id'],
- 'name' =>
$key_location['name'],
- 'selected' => $sel_key_location
- );
- }
-
- for ($i=0;$i<count($key_location_list);$i++)
- {
- if ($key_location_list[$i]['selected'] !=
'selected')
- {
-
unset($key_location_list[$i]['selected']);
- }
- }
-
- return $key_location_list;
- }
-
- function select_category_project_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
- $categories=
$this->so->select_category_workorder_list();
-
- while (is_array($categories) && list(,$category) =
each($categories))
- {
- $sel_category = '';
- if ($category['id']==$selected)
- {
- $sel_category = 'selected';
- }
-
- $category_list[] = array
- (
- 'cat_id' => $category['id'],
- 'name' => $category['name'],
- 'selected' => $sel_category
- );
- }
-
- for ($i=0;$i<count($category_list);$i++)
- {
- if ($category_list[$i]['selected'] !=
'selected')
- {
- unset($category_list[$i]['selected']);
- }
- }
-
- return $category_list;
- }
-
-
- function read($start_date='',$end_date='',$allrows='')
- {
- $start_date =
$this->bocommon->date_to_timestamp($start_date);
- $end_date =
$this->bocommon->date_to_timestamp($end_date);
-
- $project = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' => $this->cat_id,'status_id' =>
$this->status_id,'wo_hour_cat_id' => $this->wo_hour_cat_id,
-
'start_date'=>$start_date,'end_date'=>$end_date,'allrows'=>$allrows));
- $this->total_records = $this->so->total_records;
-
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-
- $this->uicols = $this->so->uicols;
- $this->uicols['input_type'][] = 'link';
- $this->uicols['name'][] = 'ticket_id';
- $this->uicols['descr'][] =
lang('ticket');
- $this->uicols['statustext'][] = false;
-
-// $cols_extra = $this->so->cols_extra;
-
- for ($i=0; $i<count($project); $i++)
- {
- $project[$i]['start_date'] =
$GLOBALS['phpgw']->common->show_date($project[$i]['start_date'],$dateformat);
- $project[$i]['ticket_id'] =
$this->so->get_ticket($project[$i]['project_id']);
-
-/*
$location_data=$this->solocation->read_single($project[$i]['location_code']);
-
- for ($j=0;$j<count($cols_extra);$j++)
- {
- $project[$i][$cols_extra[$j]] =
$location_data[$cols_extra[$j]];
- }
-*/
- }
-
-//_debug_array($project);
-
- return $project;
- }
-
- function read_single($project_id)
- {
- $contacts =
CreateObject($this->currentapp.'.soactor');
- $contacts->role='vendor';
-
- $config =
CreateObject('phpgwapi.config');
- $config->read_repository();
- $tax = 1+($config->config_data['fm_tax'])/100;
-
- $project
= $this->so->read_single($project_id);
- $dateformat
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $project['start_date'] =
$GLOBALS['phpgw']->common->show_date($project['start_date'],$dateformat);
- $project['end_date'] =
$GLOBALS['phpgw']->common->show_date($project['end_date'],$dateformat);
- $workorder_data =
$this->so->project_workorder_data($project_id);
-
- for ($i=0;$i<count($workorder_data);$i++)
- {
- $sum_workorder_budget=
$sum_workorder_budget+$workorder_data[$i]['budget'];
- $sum_deviation=
$sum_deviation+$workorder_data[$i]['deviation'];
- $sum_workorder_calculation=
$sum_workorder_calculation+$workorder_data[$i]['calculation'];
- $sum_workorder_actual_cost=
$sum_workorder_actual_cost+$workorder_data[$i]['act_mtrl_cost']+$workorder_data[$i]['act_vendor_cost'];
-
-
$project['workorder_budget'][$i]['workorder_id']=$workorder_data[$i]['workorder_id'];
-
$project['workorder_budget'][$i]['budget']=number_format($workorder_data[$i]['budget'],
2, ',', '');
-
$project['workorder_budget'][$i]['calculation']=number_format($workorder_data[$i]['calculation']*$tax,
2, ',', '');
-
$project['workorder_budget'][$i]['charge_tenant'] =
$workorder_data[$i]['charge_tenant'];
- $vendor =
$contacts->read_single(array('actor_id'=>(int)$workorder_data[$i]['vendor_id']));
- if(is_array($vendor))
- {
- foreach($vendor['attributes'] as
$attribute)
- {
-
if($attribute['name']=='org_name')
- {
-
$project['workorder_budget'][$i]['vendor_name']=$attribute['value'];
- break;
- }
- }
- }
- }
- if($workorder_data)
- {
- $project['sum_workorder_budget']=
number_format($sum_workorder_budget, 2, ',', '');
- $project['deviation']= $sum_deviation;
- $project['sum_workorder_calculation']=
number_format($sum_workorder_calculation*$tax, 2, ',', '');
- $project['sum_workorder_actual_cost']=
number_format($sum_workorder_actual_cost, 2, ',', '');
- }
-
- if($project['location_code'])
- {
- $project['location_data']
=$this->solocation->read_single($project['location_code']);
- }
-
- if($project['tenant_id']>0)
- {
-
$tenant_data=$this->bocommon->read_single_tenant($project['tenant_id']);
- $project['location_data']['tenant_id']=
$project['tenant_id'];
- $project['location_data']['contact_phone']=
$tenant_data['contact_phone'];
- $project['location_data']['last_name'] =
$tenant_data['last_name'];
- $project['location_data']['first_name'] =
$tenant_data['first_name'];
- }
- else
- {
- unset($project['location_data']['tenant_id']);
-
unset($project['location_data']['contact_phone']);
- unset($project['location_data']['last_name']);
- unset($project['location_data']['first_name']);
- }
-
- if($project['p_num'])
- {
- $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
- $category =
$soadmin_entity->read_single_category($project['p_entity_id'],$project['p_cat_id']);
-
-
$project['p'][$project['p_entity_id']]['p_num']=$project['p_num'];
-
$project['p'][$project['p_entity_id']]['p_entity_id']=$project['p_entity_id'];
-
$project['p'][$project['p_entity_id']]['p_cat_id']=$project['p_cat_id'];
-
$project['p'][$project['p_entity_id']]['p_cat_name'] = $category['name'];
- }
-
-
-//_debug_array($project);
- return $project;
- }
-
- function read_single_mini($project_id)
- {
- $project
= $this->so->read_single($project_id);
- $dateformat
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $project['start_date'] =
$GLOBALS['phpgw']->common->show_date($project['start_date'],$dateformat);
- $project['end_date'] =
$GLOBALS['phpgw']->common->show_date($project['end_date'],$dateformat);
-
- if($project['location_code'])
- {
- $project['location_data']
=$this->solocation->read_single($project['location_code']);
- }
-
- if($project['tenant_id']>0)
- {
-
$tenant_data=$this->bocommon->read_single_tenant($project['tenant_id']);
- $project['location_data']['tenant_id']=
$project['tenant_id'];
- $project['location_data']['contact_phone']=
$tenant_data['contact_phone'];
- $project['location_data']['last_name'] =
$tenant_data['last_name'];
- $project['location_data']['first_name'] =
$tenant_data['first_name'];
- }
- else
- {
- unset($project['location_data']['tenant_id']);
-
unset($project['location_data']['contact_phone']);
- unset($project['location_data']['last_name']);
- unset($project['location_data']['first_name']);
- }
-
-//_debug_array($project);
- return $project;
- }
-
-
- function read_record_history($id)
- {
- $historylog =
CreateObject($this->currentapp.'.historylog','project');
- $history_array =
$historylog->return_array(array('O'),array(),'','',$id);
- $i=0;
- while (is_array($history_array) && list(,$value) =
each($history_array))
- {
-
- $record_history[$i]['value_date'] =
$GLOBALS['phpgw']->common->show_date($value['datetime']);
- $record_history[$i]['value_user'] =
$value['owner'];
-
- switch ($value['status'])
- {
- case 'R': $type = lang('Re-opened');
break;
- case 'X': $type = lang('Closed');
break;
- case 'O': $type = lang('Opened');
break;
- case 'A': $type = lang('Re-assigned');
break;
- case 'P': $type = lang('Priority
changed'); break;
- case 'CO': $type = lang('Initial
Coordinator'); break;
- case 'C': $type = lang('Coordinator
changed'); break;
- case 'TO': $type = lang('Initial
Category'); break;
- case 'T': $type = lang('Category
changed'); break;
- case 'SO': $type = lang('Initial
Status'); break;
- case 'S': $type = lang('Status
changed'); break;
- default: break;
- }
-
-
if($value['new_value']=='O'){$value['new_value']=lang('Opened');}
-
if($value['new_value']=='X'){$value['new_value']=lang('Closed');}
-
-
- $record_history[$i]['value_action'] =
$type?$type:'';
- unset($type);
-
- if ($value['status'] == 'A')
- {
- if (! $value['new_value'])
- {
-
$record_history[$i]['value_new_value'] = lang('None');
- }
- else
- {
-
$record_history[$i]['value_new_value'] =
$GLOBALS['phpgw']->accounts->id2name($value['new_value']);
- }
- }
- else if ($value['status'] == 'C' ||
$value['status'] == 'CO')
- {
- $record_history[$i]['value_new_value']
= $GLOBALS['phpgw']->accounts->id2name($value['new_value']);
- }
- else if ($value['status'] == 'T' ||
$value['status'] == 'TO')
- {
- $record_history[$i]['value_new_value']
= $this->so->read_single_project_category($value['new_value']);
- }
- else if ($value['status'] != 'O' &&
$value['new_value'])
- {
- $record_history[$i]['value_new_value']
= $value['new_value'];
- }
- else
- {
- $record_history[$i]['value_new_value']
= '';
- }
-
- $i++;
- }
-
- return $record_history;
- }
-
-
- function next_project_id()
- {
- return $this->so->next_project_id();
- }
-
- function save($project,$action='')
- {
-
-//_debug_array($project);
- while (is_array($project['location']) && list(,$value)
= each($project['location']))
- {
- if($value)
- {
- $location[] = $value;
- }
- }
-
- $project['location_code']=implode("-", $location);
-
- $start_date =
$this->bocommon->date_array($project['start_date']);
- $end_date =
$this->bocommon->date_array($project['end_date']);
-
- $project['start_date'] = mktime
(2,0,0,$start_date['month'],$start_date['day'],$start_date['year']);
- $project['end_date'] = mktime
(2,0,0,$end_date['month'],$end_date['day'],$end_date['year']);
-
-
- if ($action=='edit')
- {
- $receipt = $this->so->edit($project);
- }
- else
- {
- $receipt = $this->so->add($project);
- }
- return $receipt;
- }
-
- function add_request($add_request,$id)
- {
-
- return $this->so->add_request($add_request,$id);
- }
-
- function delete($project_id)
- {
- $this->so->delete($project_id);
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage project
+ * @version $Id: class.boproject.inc.php,v 1.13 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class boproject
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ function boproject($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.soproject');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->solocation =
CreateObject($this->currentapp.'.solocation');
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $status_id =
get_var('status_id',array('POST','GET'));
+ $wo_hour_cat_id =
get_var('wo_hour_cat_id',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(isset($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ if(isset($status_id))
+ {
+ $this->status_id = $status_id;
+ }
+ if(isset($wo_hour_cat_id))
+ {
+ $this->wo_hour_cat_id = $wo_hour_cat_id;
+ }
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','project',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','project');
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->status_id = $data['status_id'];
+ $this->wo_hour_cat_id = $data['wo_hour_cat_id'];
+ }
+
+ function select_status_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('status_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('status_filter'));
+ break;
+ }
+
+ $status_entries= $this->so->select_status_list();
+
+ while (is_array($status_entries) && list(,$status) =
each($status_entries))
+ {
+ $sel_status = '';
+ if ($status['id']==$selected)
+ {
+ $sel_status = 'selected';
+ }
+
+ $status_list[] = array
+ (
+ 'id' => $status['id'],
+ 'name' => $status['name'],
+ 'selected' => $sel_status
+ );
+ }
+
+ for ($i=0;$i<count($status_list);$i++)
+ {
+ if ($status_list[$i]['selected'] != 'selected')
+ {
+ unset($status_list[$i]['selected']);
+ }
+ }
+
+ return $status_list;
+ }
+
+ function select_branch_list($selected='')
+ {
+
+ $branch_entries= $this->so->select_branch_list();
+
+ while (is_array($branch_entries) && list(,$branch) =
each($branch_entries))
+ {
+ $sel_branch = '';
+ if ($branch['id']==$selected)
+ {
+ $sel_branch = 'selected';
+ }
+
+ $branch_list[] = array
+ (
+ 'id' => $branch['id'],
+ 'name' => $branch['name'],
+ 'selected' => $sel_branch
+ );
+ }
+
+ for ($i=0;$i<count($branch_list);$i++)
+ {
+ if ($branch_list[$i]['selected'] != 'selected')
+ {
+ unset($branch_list[$i]['selected']);
+ }
+ }
+
+ return $branch_list;
+ }
+
+ function select_branch_p_list($project_id='')
+ {
+
+ $selected =
$this->so->branch_p_list($project_id);
+ $branch_entries = $this->so->select_branch_list();
+
+ $j=0;
+ while (is_array($branch_entries) && list(,$branch) =
each($branch_entries))
+ {
+ $branch_list[$j]['id'] = $branch['id'];
+ $branch_list[$j]['name'] = $branch['name'];
+
+ for ($i=0;$i<count($selected);$i++)
+ {
+ if($selected[$i]['branch_id'] ==
$branch['id'])
+ {
+ $branch_list[$j]['selected'] =
'selected';
+ }
+ }
+ $j++;
+ }
+
+ for ($i=0;$i<count($branch_list);$i++)
+ {
+ if ($branch_list[$i]['selected'] != 'selected')
+ {
+ unset($branch_list[$i]['selected']);
+ }
+ }
+
+ return $branch_list;
+ }
+
+
+ function select_key_location_list($selected='')
+ {
+
+ $key_location_entries=
$this->so->select_key_location_list();
+
+ while (is_array($key_location_entries) &&
list(,$key_location) = each($key_location_entries))
+ {
+ $sel_key_location = '';
+ if ($key_location['id']==$selected)
+ {
+ $sel_key_location = 'selected';
+ }
+
+ $key_location_list[] = array
+ (
+ 'id' => $key_location['id'],
+ 'name' =>
$key_location['name'],
+ 'selected' => $sel_key_location
+ );
+ }
+
+ for ($i=0;$i<count($key_location_list);$i++)
+ {
+ if ($key_location_list[$i]['selected'] !=
'selected')
+ {
+
unset($key_location_list[$i]['selected']);
+ }
+ }
+
+ return $key_location_list;
+ }
+
+ function select_category_project_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ break;
+ }
+
+ $categories=
$this->so->select_category_workorder_list();
+
+ while (is_array($categories) && list(,$category) =
each($categories))
+ {
+ $sel_category = '';
+ if ($category['id']==$selected)
+ {
+ $sel_category = 'selected';
+ }
+
+ $category_list[] = array
+ (
+ 'cat_id' => $category['id'],
+ 'name' => $category['name'],
+ 'selected' => $sel_category
+ );
+ }
+
+ for ($i=0;$i<count($category_list);$i++)
+ {
+ if ($category_list[$i]['selected'] !=
'selected')
+ {
+ unset($category_list[$i]['selected']);
+ }
+ }
+
+ return $category_list;
+ }
+
+
+ function read($start_date='',$end_date='',$allrows='')
+ {
+ $start_date =
$this->bocommon->date_to_timestamp($start_date);
+ $end_date =
$this->bocommon->date_to_timestamp($end_date);
+
+ $project = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' => $this->cat_id,'status_id' =>
$this->status_id,'wo_hour_cat_id' => $this->wo_hour_cat_id,
+
'start_date'=>$start_date,'end_date'=>$end_date,'allrows'=>$allrows));
+ $this->total_records = $this->so->total_records;
+
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ $this->uicols = $this->so->uicols;
+ $this->uicols['input_type'][] = 'link';
+ $this->uicols['name'][] = 'ticket_id';
+ $this->uicols['descr'][] =
lang('ticket');
+ $this->uicols['statustext'][] = false;
+
+// $cols_extra = $this->so->cols_extra;
+
+ for ($i=0; $i<count($project); $i++)
+ {
+ $project[$i]['start_date'] =
$GLOBALS['phpgw']->common->show_date($project[$i]['start_date'],$dateformat);
+ $project[$i]['ticket_id'] =
$this->so->get_ticket($project[$i]['project_id']);
+
+/*
$location_data=$this->solocation->read_single($project[$i]['location_code']);
+
+ for ($j=0;$j<count($cols_extra);$j++)
+ {
+ $project[$i][$cols_extra[$j]] =
$location_data[$cols_extra[$j]];
+ }
+*/
+ }
+
+//_debug_array($project);
+
+ return $project;
+ }
+
+ function read_single($project_id)
+ {
+ $contacts =
CreateObject($this->currentapp.'.soactor');
+ $contacts->role='vendor';
+
+ $config =
CreateObject('phpgwapi.config');
+ $config->read_repository();
+ $tax = 1+($config->config_data['fm_tax'])/100;
+
+ $project
= $this->so->read_single($project_id);
+ $dateformat
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $project['start_date'] =
$GLOBALS['phpgw']->common->show_date($project['start_date'],$dateformat);
+ $project['end_date'] =
$GLOBALS['phpgw']->common->show_date($project['end_date'],$dateformat);
+ $workorder_data =
$this->so->project_workorder_data($project_id);
+
+ for ($i=0;$i<count($workorder_data);$i++)
+ {
+ $sum_workorder_budget=
$sum_workorder_budget+$workorder_data[$i]['budget'];
+ $sum_deviation=
$sum_deviation+$workorder_data[$i]['deviation'];
+ $sum_workorder_calculation=
$sum_workorder_calculation+$workorder_data[$i]['calculation'];
+ $sum_workorder_actual_cost=
$sum_workorder_actual_cost+$workorder_data[$i]['act_mtrl_cost']+$workorder_data[$i]['act_vendor_cost'];
+
+
$project['workorder_budget'][$i]['workorder_id']=$workorder_data[$i]['workorder_id'];
+
$project['workorder_budget'][$i]['budget']=number_format($workorder_data[$i]['budget'],
2, ',', '');
+
$project['workorder_budget'][$i]['calculation']=number_format($workorder_data[$i]['calculation']*$tax,
2, ',', '');
+
$project['workorder_budget'][$i]['charge_tenant'] =
$workorder_data[$i]['charge_tenant'];
+ $vendor =
$contacts->read_single(array('actor_id'=>(int)$workorder_data[$i]['vendor_id']));
+ if(is_array($vendor))
+ {
+ foreach($vendor['attributes'] as
$attribute)
+ {
+
if($attribute['name']=='org_name')
+ {
+
$project['workorder_budget'][$i]['vendor_name']=$attribute['value'];
+ break;
+ }
+ }
+ }
+ }
+ if($workorder_data)
+ {
+ $project['sum_workorder_budget']=
number_format($sum_workorder_budget, 2, ',', '');
+ $project['deviation']= $sum_deviation;
+ $project['sum_workorder_calculation']=
number_format($sum_workorder_calculation*$tax, 2, ',', '');
+ $project['sum_workorder_actual_cost']=
number_format($sum_workorder_actual_cost, 2, ',', '');
+ }
+
+ if($project['location_code'])
+ {
+ $project['location_data']
=$this->solocation->read_single($project['location_code']);
+ }
+
+ if($project['tenant_id']>0)
+ {
+
$tenant_data=$this->bocommon->read_single_tenant($project['tenant_id']);
+ $project['location_data']['tenant_id']=
$project['tenant_id'];
+ $project['location_data']['contact_phone']=
$tenant_data['contact_phone'];
+ $project['location_data']['last_name'] =
$tenant_data['last_name'];
+ $project['location_data']['first_name'] =
$tenant_data['first_name'];
+ }
+ else
+ {
+ unset($project['location_data']['tenant_id']);
+
unset($project['location_data']['contact_phone']);
+ unset($project['location_data']['last_name']);
+ unset($project['location_data']['first_name']);
+ }
+
+ if($project['p_num'])
+ {
+ $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
+ $category =
$soadmin_entity->read_single_category($project['p_entity_id'],$project['p_cat_id']);
+
+
$project['p'][$project['p_entity_id']]['p_num']=$project['p_num'];
+
$project['p'][$project['p_entity_id']]['p_entity_id']=$project['p_entity_id'];
+
$project['p'][$project['p_entity_id']]['p_cat_id']=$project['p_cat_id'];
+
$project['p'][$project['p_entity_id']]['p_cat_name'] = $category['name'];
+ }
+
+
+//_debug_array($project);
+ return $project;
+ }
+
+ function read_single_mini($project_id)
+ {
+ $project
= $this->so->read_single($project_id);
+ $dateformat
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $project['start_date'] =
$GLOBALS['phpgw']->common->show_date($project['start_date'],$dateformat);
+ $project['end_date'] =
$GLOBALS['phpgw']->common->show_date($project['end_date'],$dateformat);
+
+ if($project['location_code'])
+ {
+ $project['location_data']
=$this->solocation->read_single($project['location_code']);
+ }
+
+ if($project['tenant_id']>0)
+ {
+
$tenant_data=$this->bocommon->read_single_tenant($project['tenant_id']);
+ $project['location_data']['tenant_id']=
$project['tenant_id'];
+ $project['location_data']['contact_phone']=
$tenant_data['contact_phone'];
+ $project['location_data']['last_name'] =
$tenant_data['last_name'];
+ $project['location_data']['first_name'] =
$tenant_data['first_name'];
+ }
+ else
+ {
+ unset($project['location_data']['tenant_id']);
+
unset($project['location_data']['contact_phone']);
+ unset($project['location_data']['last_name']);
+ unset($project['location_data']['first_name']);
+ }
+
+//_debug_array($project);
+ return $project;
+ }
+
+
+ function read_record_history($id)
+ {
+ $historylog =
CreateObject($this->currentapp.'.historylog','project');
+ $history_array =
$historylog->return_array(array('O'),array(),'','',$id);
+ $i=0;
+ while (is_array($history_array) && list(,$value) =
each($history_array))
+ {
+
+ $record_history[$i]['value_date'] =
$GLOBALS['phpgw']->common->show_date($value['datetime']);
+ $record_history[$i]['value_user'] =
$value['owner'];
+
+ switch ($value['status'])
+ {
+ case 'R': $type = lang('Re-opened');
break;
+ case 'X': $type = lang('Closed');
break;
+ case 'O': $type = lang('Opened');
break;
+ case 'A': $type = lang('Re-assigned');
break;
+ case 'P': $type = lang('Priority
changed'); break;
+ case 'CO': $type = lang('Initial
Coordinator'); break;
+ case 'C': $type = lang('Coordinator
changed'); break;
+ case 'TO': $type = lang('Initial
Category'); break;
+ case 'T': $type = lang('Category
changed'); break;
+ case 'SO': $type = lang('Initial
Status'); break;
+ case 'S': $type = lang('Status
changed'); break;
+ default: break;
+ }
+
+
if($value['new_value']=='O'){$value['new_value']=lang('Opened');}
+
if($value['new_value']=='X'){$value['new_value']=lang('Closed');}
+
+
+ $record_history[$i]['value_action'] =
$type?$type:'';
+ unset($type);
+
+ if ($value['status'] == 'A')
+ {
+ if (! $value['new_value'])
+ {
+
$record_history[$i]['value_new_value'] = lang('None');
+ }
+ else
+ {
+
$record_history[$i]['value_new_value'] =
$GLOBALS['phpgw']->accounts->id2name($value['new_value']);
+ }
+ }
+ else if ($value['status'] == 'C' ||
$value['status'] == 'CO')
+ {
+ $record_history[$i]['value_new_value']
= $GLOBALS['phpgw']->accounts->id2name($value['new_value']);
+ }
+ else if ($value['status'] == 'T' ||
$value['status'] == 'TO')
+ {
+ $record_history[$i]['value_new_value']
= $this->so->read_single_project_category($value['new_value']);
+ }
+ else if ($value['status'] != 'O' &&
$value['new_value'])
+ {
+ $record_history[$i]['value_new_value']
= $value['new_value'];
+ }
+ else
+ {
+ $record_history[$i]['value_new_value']
= '';
+ }
+
+ $i++;
+ }
+
+ return $record_history;
+ }
+
+
+ function next_project_id()
+ {
+ return $this->so->next_project_id();
+ }
+
+ function save($project,$action='')
+ {
+
+//_debug_array($project);
+ while (is_array($project['location']) && list(,$value)
= each($project['location']))
+ {
+ if($value)
+ {
+ $location[] = $value;
+ }
+ }
+
+ $project['location_code']=implode("-", $location);
+
+ $start_date =
$this->bocommon->date_array($project['start_date']);
+ $end_date =
$this->bocommon->date_array($project['end_date']);
+
+ $project['start_date'] = mktime
(2,0,0,$start_date['month'],$start_date['day'],$start_date['year']);
+ $project['end_date'] = mktime
(2,0,0,$end_date['month'],$end_date['day'],$end_date['year']);
+
+
+ if ($action=='edit')
+ {
+ $receipt = $this->so->edit($project);
+ }
+ else
+ {
+ $receipt = $this->so->add($project);
+ }
+ return $receipt;
+ }
+
+ function add_request($add_request,$id)
+ {
+
+ return $this->so->add_request($add_request,$id);
+ }
+
+ function delete($project_id)
+ {
+ $this->so->delete($project_id);
+ }
+
+ }
+?>
Index: property/inc/class.borequest.inc.php
diff -u property/inc/class.borequest.inc.php:1.8
property/inc/class.borequest.inc.php:1.9
--- property/inc/class.borequest.inc.php:1.8 Wed Sep 21 14:18:17 2005
+++ property/inc/class.borequest.inc.php Fri Jan 27 14:05:43 2006
@@ -1,610 +1,610 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage project
- * @version $Id: class.borequest.inc.php,v 1.8 2005/09/21 14:18:17
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class borequest
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- function borequest($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.sorequest');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->solocation =
CreateObject($this->currentapp.'.solocation');
- $this->historylog =
CreateObject($this->currentapp.'.historylog','request');
- $this->vfs =
CreateObject('phpgwapi.vfs');
- $this->rootdir = $this->vfs->basedir;
- $this->fakebase = $this->vfs->fakebase;
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $status_id =
get_var('status_id',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(isset($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- if(isset($status_id))
- {
- $this->status_id = $status_id;
- }
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','request',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','request');
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->status_id = $data['status_id'];
- }
-
-
- function create_home_dir($receipt='')
- {
- if(!$this->vfs->file_exists(array(
- 'string' => $this->fakebase. SEP .
'request',
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
- $this->vfs->override_acl = 1;
-
- if(!$this->vfs->mkdir (array(
- 'string' => $this->fakebase. SEP .
'request',
- 'relatives' => array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'request');
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'request');
- }
- $this->vfs->override_acl = 0;
- }
-
- return $receipt;
- }
-
- function create_document_dir($location_code='',$id='')
- {
- if(!$this->vfs->file_exists(array(
- 'string' => $this->fakebase. SEP .
'request' . SEP . $location_code,
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
- $this->vfs->override_acl = 1;
- if(!$this->vfs->mkdir (array(
- 'string' => $this->fakebase. SEP .
'request' . SEP . $location_code,
- 'relatives' => array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'request' . SEP . $location_code);
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'request' . SEP . $location_code);
- }
- $this->vfs->override_acl = 0;
- }
-
-
- if(!$this->vfs->file_exists(array(
- 'string' => $this->fakebase. SEP .
'request' . SEP . $location_code . SEP . $id,
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
- $this->vfs->override_acl = 1;
- if(!$this->vfs->mkdir (array(
- 'string' => $this->fakebase. SEP .
'request' . SEP . $location_code . SEP . $id,
- 'relatives' => array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'request' . SEP . $location_code . SEP . $id);
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'request' . SEP . $location_code . SEP . $id);
- }
- $this->vfs->override_acl = 0;
- }
-
-//_debug_array($receipt);
- return $receipt;
- }
-
-
- function
select_degree_list($degree_value='',$degreedefault_type='')
- {
- if ($degree_value)
- {
- $selected=$degree_value;
- }
- else
- {
-
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp][$degreedefault_type];
- }
-
- $degree_comment[0]=' - '.lang('None');
- $degree_comment[1]=' - '.lang('Minor');
- $degree_comment[2]=' - '.lang('Medium');
- $degree_comment[3]=' - '.lang('Serious');
- for ($i=0; $i<=3; $i++)
- {
- $degree_list[$i][id] = $i;
- $degree_list[$i]['name'] = $i .
$degree_comment[$i];
- if ($i==$selected)
- {
- $degree_list[$i]['selected']=
'selected';
- }
- }
-
- return $degree_list;
- }
-
- function select_probability_list($probability_value='')
- {
- $selected=$probability_value;
-
- $probability_comment[1]=' - '.lang('Small');
- $probability_comment[2]=' - '.lang('Medium');
- $probability_comment[3]=' - '.lang('Large');
- for ($i=1; $i<=3; $i++)
- {
- $probability_list[$i][id] = $i;
- $probability_list[$i]['name'] = $i .
$probability_comment[$i];
- if ($i==$selected)
- {
- $probability_list[$i]['selected']=
'selected';
- }
- }
-
- return $probability_list;
- }
-
- function select_conditions($request_id='')
- {
- $condition_type_list =
$this->so->select_condition_type_list();
-
- if($request_id)
- {
- $conditions =
$this->so->select_conditions($request_id,$condition_type_list);
- }
-
- for ($i=0;$i<count($condition_type_list);$i++)
- {
- $conditions[$i]['degree'] =
$this->select_degree_list($conditions[$i]['degree']);
- $conditions[$i]['probability'] =
$this->select_probability_list($conditions[$i]['probability']);
- $conditions[$i]['consequence'] =
$this->select_consequence_list($conditions[$i]['consequence']);
- $conditions[$i]['condition_type'] =
$condition_type_list[$i]['id'];
- $conditions[$i]['condition_type_name'] =
$condition_type_list[$i]['name'];
- }
-
- return $conditions;
- }
-
- function
select_consequence_list($consequence_value='',$consequencedefault_type='')
- {
- if ($consequence_value)
- {
- $selected=$consequence_value;
- }
- else
- {
-
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp][$consequencedefault_type];
- }
-
- $consequence_comment[0]=' - '.lang('None Consequences');
- $consequence_comment[1]=' - '.lang('Minor
Consequences');
- $consequence_comment[2]=' - '.lang('Medium
Consequences');
- $consequence_comment[3]=' - '.lang('Serious
Consequences');
- for ($i=0; $i<=3; $i++)
- {
- $consequence_list[$i][id] = $i;
- $consequence_list[$i]['name'] = $i .
$consequence_comment[$i];
- if ($i==$selected)
- {
- $consequence_list[$i]['selected']=
'selected';
- }
- }
-
- return $consequence_list;
- }
-
-
- function select_status_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('status_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('status_filter'));
- break;
- }
-
- $status_entries= $this->so->select_status_list();
-
- while (is_array($status_entries) && list(,$status) =
each($status_entries))
- {
- $sel_status = '';
- if ($status['id']==$selected)
- {
- $sel_status = 'selected';
- }
-
- $status_list[] = array
- (
- 'id' => $status['id'],
- 'name' => $status['name'],
- 'selected' => $sel_status
- );
- }
-
- for ($i=0;$i<count($status_list);$i++)
- {
- if ($status_list[$i]['selected'] != 'selected')
- {
- unset($status_list[$i]['selected']);
- }
- }
-
- return $status_list;
- }
-
-
- function select_category_request_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
- $categories=
$this->so->select_category_workorder_list();
-
- while (is_array($categories) && list(,$category) =
each($categories))
- {
- $sel_category = '';
- if ($category['id']==$selected)
- {
- $sel_category = 'selected';
- }
-
- $category_list[] = array
- (
- 'cat_id' => $category['id'],
- 'name' => $category['name'],
- 'selected' => $sel_category
- );
- }
-
- for ($i=0;$i<count($category_list);$i++)
- {
- if ($category_list[$i]['selected'] !=
'selected')
- {
- unset($category_list[$i]['selected']);
- }
- }
-
- return $category_list;
- }
-
- function read_priority_key()
- {
- return $this->so->read_priority_key();
- }
-
- function update_priority_key($values)
- {
- return $this->so->update_priority_key($values);
- }
-
- function read($project_id)
- {
- $request = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' => $this->cat_id,'status_id' =>
$this->status_id,'project_id' => $project_id));
- $this->total_records = $this->so->total_records;
-
- $this->uicols = $this->so->uicols;
- $cols_extra = $this->so->cols_extra;
-
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-
- for ($i=0; $i<count($request); $i++)
- {
- $request[$i]['coordinator'] =
$GLOBALS['phpgw']->accounts->id2name($request[$i]['coordinator']);
- $request[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($request[$i]['entry_date'],$dateformat);
-
$location_data=$this->solocation->read_single($request[$i]['location_code']);
-
- for ($j=0;$j<count($cols_extra);$j++)
- {
- $request[$i][$cols_extra[$j]] =
$location_data[$cols_extra[$j]];
- }
- }
-
- return $request;
- }
-
- function read_single($request_id)
- {
- $request
= $this->so->read_single($request_id);
- $dateformat
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $request['start_date'] =
$GLOBALS['phpgw']->common->show_date($request['start_date'],$dateformat);
- $request['end_date'] =
$GLOBALS['phpgw']->common->show_date($request['end_date'],$dateformat);
-
- if($request['location_code'])
- {
- $request['location_data']
=$this->solocation->read_single($request['location_code']);
- }
-
- if($request['tenant_id']>0)
- {
-
$tenant_data=$this->bocommon->read_single_tenant($request['tenant_id']);
- $request['location_data']['tenant_id']=
$request['tenant_id'];
- $request['location_data']['contact_phone']=
$tenant_data['contact_phone'];
- $request['location_data']['last_name'] =
$tenant_data['last_name'];
- $request['location_data']['first_name'] =
$tenant_data['first_name'];
- }
- else
- {
- unset($request['location_data']['tenant_id']);
-
unset($request['location_data']['contact_phone']);
- unset($request['location_data']['last_name']);
- unset($request['location_data']['first_name']);
- }
-
- if($request['p_num'])
- {
- $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
- $category =
$soadmin_entity->read_single_category($request['p_entity_id'],$request['p_cat_id']);
-
-
$request['p'][$request['p_entity_id']]['p_num']=$request['p_num'];
-
$request['p'][$request['p_entity_id']]['p_entity_id']=$request['p_entity_id'];
-
$request['p'][$request['p_entity_id']]['p_cat_id']=$request['p_cat_id'];
-
$request['p'][$request['p_entity_id']]['p_cat_name'] = $category['name'];
- }
-
- $this->vfs->override_acl = 1;
-
- $request['files'] = $this->vfs->ls (array(
- 'string' => $this->fakebase. '/' . 'request' . '/'
. $request['location_code'] . '/' . $request_id,
- 'relatives' => array(RELATIVE_NONE)));
-
- $this->vfs->override_acl = 0;
-
- if(!$request['files'][0]['file_id'])
- {
- unset($request['files']);
- }
-
- return $request;
- }
-
-
- function read_record_history($id)
- {
- $history_array =
$this->historylog->return_array(array('O'),array(),'','',$id);
- $i=0;
- while (is_array($history_array) && list(,$value) =
each($history_array))
- {
-
- $record_history[$i]['value_date'] =
$GLOBALS['phpgw']->common->show_date($value['datetime']);
- $record_history[$i]['value_user'] =
$value['owner'];
-
- switch ($value['status'])
- {
- case 'R': $type = lang('Re-opened');
break;
- case 'X': $type = lang('Closed');
break;
- case 'O': $type = lang('Opened');
break;
- case 'A': $type = lang('Re-assigned');
break;
- case 'P': $type = lang('Priority
changed'); break;
- case 'CO': $type = lang('Initial
Coordinator'); break;
- case 'C': $type = lang('Coordinator
changed'); break;
- case 'TO': $type = lang('Initial
Category'); break;
- case 'T': $type = lang('Category
changed'); break;
- case 'SO': $type = lang('Initial
Status'); break;
- case 'S': $type = lang('Status
changed'); break;
- default: break;
- }
-
-
if($value['new_value']=='O'){$value['new_value']=lang('Opened');}
-
if($value['new_value']=='X'){$value['new_value']=lang('Closed');}
-
-
- $record_history[$i]['value_action'] =
$type?$type:'';
- unset($type);
-
- if ($value['status'] == 'A')
- {
- if (! $value['new_value'])
- {
-
$record_history[$i]['value_new_value'] = lang('None');
- }
- else
- {
-
$record_history[$i]['value_new_value'] =
$GLOBALS['phpgw']->accounts->id2name($value['new_value']);
- }
- }
- else if ($value['status'] == 'C' ||
$value['status'] == 'CO')
- {
- $record_history[$i]['value_new_value']
= $GLOBALS['phpgw']->accounts->id2name($value['new_value']);
- }
- else if ($value['status'] == 'T' ||
$value['status'] == 'TO')
- {
- $record_history[$i]['value_new_value']
= $this->so->read_single_request_category($value['new_value']);
- }
- else if ($value['status'] != 'O' &&
$value['new_value'])
- {
- $record_history[$i]['value_new_value']
= $value['new_value'];
- }
- else
- {
- $record_history[$i]['value_new_value']
= '';
- }
-
- $i++;
- }
-
- return $record_history;
- }
-
-
- function next_id()
- {
- return $this->so->next_id();
- }
-
- function save($request,$action='')
- {
- while (is_array($request['location']) && list(,$value)
= each($request['location']))
- {
- if($value)
- {
- $location[] = $value;
- }
- }
-
- $request['location_code']=implode("-", $location);
- $start_date =
$this->bocommon->date_array($request['start_date']);
- $end_date =
$this->bocommon->date_array($request['end_date']);
-
- $request['start_date'] = mktime
(2,0,0,$start_date['month'],$start_date['day'],$start_date['year']);
- $request['end_date'] = mktime
(2,0,0,$end_date['month'],$end_date['day'],$end_date['year']);
-
- if ($action=='edit')
- {
- $receipt = $this->so->edit($request);
-
- if($request['delete_file'])
- {
- for
($i=0;$i<count($request['delete_file']);$i++)
- {
- $file = $this->fakebase. SEP .
'request' . SEP . $request['location_code'] . SEP . $request['request_id'] .
SEP . $request['delete_file'][$i];
-
-
if($this->vfs->file_exists(array(
- 'string' =>
$file,
- 'relatives' =>
Array(RELATIVE_NONE)
- )))
- {
-
$this->vfs->override_acl = 1;
-
- if(!$this->vfs->rm
(array(
- 'string' =>
$file,
- 'relatives' =>
array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to delete file') . ' :'.
$this->fakebase. SEP . 'request' . SEP . $request['location_code']. SEP .
$request['request_id'] . SEP .$request['delete_file'][$i]);
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('file deleted') . ' :'.
$this->fakebase. SEP . 'request' . SEP . $request['location_code']. SEP .
$request['request_id'] . SEP . $request['delete_file'][$i]);
- }
-
$this->vfs->override_acl = 0;
- }
- }
- }
-
- }
- else
- {
- $receipt = $this->so->add($request);
- }
- return $receipt;
- }
-
- function delete($request_id)
- {
- $this->so->delete($request_id);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage project
+ * @version $Id: class.borequest.inc.php,v 1.9 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class borequest
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ function borequest($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.sorequest');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->solocation =
CreateObject($this->currentapp.'.solocation');
+ $this->historylog =
CreateObject($this->currentapp.'.historylog','request');
+ $this->vfs =
CreateObject('phpgwapi.vfs');
+ $this->rootdir = $this->vfs->basedir;
+ $this->fakebase = $this->vfs->fakebase;
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $status_id =
get_var('status_id',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(isset($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ if(isset($status_id))
+ {
+ $this->status_id = $status_id;
+ }
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','request',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','request');
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->status_id = $data['status_id'];
+ }
+
+
+ function create_home_dir($receipt='')
+ {
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase. SEP .
'request',
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $this->vfs->override_acl = 1;
+
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase. SEP .
'request',
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'request');
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'request');
+ }
+ $this->vfs->override_acl = 0;
+ }
+
+ return $receipt;
+ }
+
+ function create_document_dir($location_code='',$id='')
+ {
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase. SEP .
'request' . SEP . $location_code,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $this->vfs->override_acl = 1;
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase. SEP .
'request' . SEP . $location_code,
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'request' . SEP . $location_code);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'request' . SEP . $location_code);
+ }
+ $this->vfs->override_acl = 0;
+ }
+
+
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase. SEP .
'request' . SEP . $location_code . SEP . $id,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $this->vfs->override_acl = 1;
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase. SEP .
'request' . SEP . $location_code . SEP . $id,
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'request' . SEP . $location_code . SEP . $id);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'request' . SEP . $location_code . SEP . $id);
+ }
+ $this->vfs->override_acl = 0;
+ }
+
+//_debug_array($receipt);
+ return $receipt;
+ }
+
+
+ function
select_degree_list($degree_value='',$degreedefault_type='')
+ {
+ if ($degree_value)
+ {
+ $selected=$degree_value;
+ }
+ else
+ {
+
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp][$degreedefault_type];
+ }
+
+ $degree_comment[0]=' - '.lang('None');
+ $degree_comment[1]=' - '.lang('Minor');
+ $degree_comment[2]=' - '.lang('Medium');
+ $degree_comment[3]=' - '.lang('Serious');
+ for ($i=0; $i<=3; $i++)
+ {
+ $degree_list[$i][id] = $i;
+ $degree_list[$i]['name'] = $i .
$degree_comment[$i];
+ if ($i==$selected)
+ {
+ $degree_list[$i]['selected']=
'selected';
+ }
+ }
+
+ return $degree_list;
+ }
+
+ function select_probability_list($probability_value='')
+ {
+ $selected=$probability_value;
+
+ $probability_comment[1]=' - '.lang('Small');
+ $probability_comment[2]=' - '.lang('Medium');
+ $probability_comment[3]=' - '.lang('Large');
+ for ($i=1; $i<=3; $i++)
+ {
+ $probability_list[$i][id] = $i;
+ $probability_list[$i]['name'] = $i .
$probability_comment[$i];
+ if ($i==$selected)
+ {
+ $probability_list[$i]['selected']=
'selected';
+ }
+ }
+
+ return $probability_list;
+ }
+
+ function select_conditions($request_id='')
+ {
+ $condition_type_list =
$this->so->select_condition_type_list();
+
+ if($request_id)
+ {
+ $conditions =
$this->so->select_conditions($request_id,$condition_type_list);
+ }
+
+ for ($i=0;$i<count($condition_type_list);$i++)
+ {
+ $conditions[$i]['degree'] =
$this->select_degree_list($conditions[$i]['degree']);
+ $conditions[$i]['probability'] =
$this->select_probability_list($conditions[$i]['probability']);
+ $conditions[$i]['consequence'] =
$this->select_consequence_list($conditions[$i]['consequence']);
+ $conditions[$i]['condition_type'] =
$condition_type_list[$i]['id'];
+ $conditions[$i]['condition_type_name'] =
$condition_type_list[$i]['name'];
+ }
+
+ return $conditions;
+ }
+
+ function
select_consequence_list($consequence_value='',$consequencedefault_type='')
+ {
+ if ($consequence_value)
+ {
+ $selected=$consequence_value;
+ }
+ else
+ {
+
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp][$consequencedefault_type];
+ }
+
+ $consequence_comment[0]=' - '.lang('None Consequences');
+ $consequence_comment[1]=' - '.lang('Minor
Consequences');
+ $consequence_comment[2]=' - '.lang('Medium
Consequences');
+ $consequence_comment[3]=' - '.lang('Serious
Consequences');
+ for ($i=0; $i<=3; $i++)
+ {
+ $consequence_list[$i][id] = $i;
+ $consequence_list[$i]['name'] = $i .
$consequence_comment[$i];
+ if ($i==$selected)
+ {
+ $consequence_list[$i]['selected']=
'selected';
+ }
+ }
+
+ return $consequence_list;
+ }
+
+
+ function select_status_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('status_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('status_filter'));
+ break;
+ }
+
+ $status_entries= $this->so->select_status_list();
+
+ while (is_array($status_entries) && list(,$status) =
each($status_entries))
+ {
+ $sel_status = '';
+ if ($status['id']==$selected)
+ {
+ $sel_status = 'selected';
+ }
+
+ $status_list[] = array
+ (
+ 'id' => $status['id'],
+ 'name' => $status['name'],
+ 'selected' => $sel_status
+ );
+ }
+
+ for ($i=0;$i<count($status_list);$i++)
+ {
+ if ($status_list[$i]['selected'] != 'selected')
+ {
+ unset($status_list[$i]['selected']);
+ }
+ }
+
+ return $status_list;
+ }
+
+
+ function select_category_request_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ break;
+ }
+
+ $categories=
$this->so->select_category_workorder_list();
+
+ while (is_array($categories) && list(,$category) =
each($categories))
+ {
+ $sel_category = '';
+ if ($category['id']==$selected)
+ {
+ $sel_category = 'selected';
+ }
+
+ $category_list[] = array
+ (
+ 'cat_id' => $category['id'],
+ 'name' => $category['name'],
+ 'selected' => $sel_category
+ );
+ }
+
+ for ($i=0;$i<count($category_list);$i++)
+ {
+ if ($category_list[$i]['selected'] !=
'selected')
+ {
+ unset($category_list[$i]['selected']);
+ }
+ }
+
+ return $category_list;
+ }
+
+ function read_priority_key()
+ {
+ return $this->so->read_priority_key();
+ }
+
+ function update_priority_key($values)
+ {
+ return $this->so->update_priority_key($values);
+ }
+
+ function read($project_id)
+ {
+ $request = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' => $this->cat_id,'status_id' =>
$this->status_id,'project_id' => $project_id));
+ $this->total_records = $this->so->total_records;
+
+ $this->uicols = $this->so->uicols;
+ $cols_extra = $this->so->cols_extra;
+
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ for ($i=0; $i<count($request); $i++)
+ {
+ $request[$i]['coordinator'] =
$GLOBALS['phpgw']->accounts->id2name($request[$i]['coordinator']);
+ $request[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($request[$i]['entry_date'],$dateformat);
+
$location_data=$this->solocation->read_single($request[$i]['location_code']);
+
+ for ($j=0;$j<count($cols_extra);$j++)
+ {
+ $request[$i][$cols_extra[$j]] =
$location_data[$cols_extra[$j]];
+ }
+ }
+
+ return $request;
+ }
+
+ function read_single($request_id)
+ {
+ $request
= $this->so->read_single($request_id);
+ $dateformat
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $request['start_date'] =
$GLOBALS['phpgw']->common->show_date($request['start_date'],$dateformat);
+ $request['end_date'] =
$GLOBALS['phpgw']->common->show_date($request['end_date'],$dateformat);
+
+ if($request['location_code'])
+ {
+ $request['location_data']
=$this->solocation->read_single($request['location_code']);
+ }
+
+ if($request['tenant_id']>0)
+ {
+
$tenant_data=$this->bocommon->read_single_tenant($request['tenant_id']);
+ $request['location_data']['tenant_id']=
$request['tenant_id'];
+ $request['location_data']['contact_phone']=
$tenant_data['contact_phone'];
+ $request['location_data']['last_name'] =
$tenant_data['last_name'];
+ $request['location_data']['first_name'] =
$tenant_data['first_name'];
+ }
+ else
+ {
+ unset($request['location_data']['tenant_id']);
+
unset($request['location_data']['contact_phone']);
+ unset($request['location_data']['last_name']);
+ unset($request['location_data']['first_name']);
+ }
+
+ if($request['p_num'])
+ {
+ $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
+ $category =
$soadmin_entity->read_single_category($request['p_entity_id'],$request['p_cat_id']);
+
+
$request['p'][$request['p_entity_id']]['p_num']=$request['p_num'];
+
$request['p'][$request['p_entity_id']]['p_entity_id']=$request['p_entity_id'];
+
$request['p'][$request['p_entity_id']]['p_cat_id']=$request['p_cat_id'];
+
$request['p'][$request['p_entity_id']]['p_cat_name'] = $category['name'];
+ }
+
+ $this->vfs->override_acl = 1;
+
+ $request['files'] = $this->vfs->ls (array(
+ 'string' => $this->fakebase. '/' . 'request' . '/'
. $request['location_code'] . '/' . $request_id,
+ 'relatives' => array(RELATIVE_NONE)));
+
+ $this->vfs->override_acl = 0;
+
+ if(!$request['files'][0]['file_id'])
+ {
+ unset($request['files']);
+ }
+
+ return $request;
+ }
+
+
+ function read_record_history($id)
+ {
+ $history_array =
$this->historylog->return_array(array('O'),array(),'','',$id);
+ $i=0;
+ while (is_array($history_array) && list(,$value) =
each($history_array))
+ {
+
+ $record_history[$i]['value_date'] =
$GLOBALS['phpgw']->common->show_date($value['datetime']);
+ $record_history[$i]['value_user'] =
$value['owner'];
+
+ switch ($value['status'])
+ {
+ case 'R': $type = lang('Re-opened');
break;
+ case 'X': $type = lang('Closed');
break;
+ case 'O': $type = lang('Opened');
break;
+ case 'A': $type = lang('Re-assigned');
break;
+ case 'P': $type = lang('Priority
changed'); break;
+ case 'CO': $type = lang('Initial
Coordinator'); break;
+ case 'C': $type = lang('Coordinator
changed'); break;
+ case 'TO': $type = lang('Initial
Category'); break;
+ case 'T': $type = lang('Category
changed'); break;
+ case 'SO': $type = lang('Initial
Status'); break;
+ case 'S': $type = lang('Status
changed'); break;
+ default: break;
+ }
+
+
if($value['new_value']=='O'){$value['new_value']=lang('Opened');}
+
if($value['new_value']=='X'){$value['new_value']=lang('Closed');}
+
+
+ $record_history[$i]['value_action'] =
$type?$type:'';
+ unset($type);
+
+ if ($value['status'] == 'A')
+ {
+ if (! $value['new_value'])
+ {
+
$record_history[$i]['value_new_value'] = lang('None');
+ }
+ else
+ {
+
$record_history[$i]['value_new_value'] =
$GLOBALS['phpgw']->accounts->id2name($value['new_value']);
+ }
+ }
+ else if ($value['status'] == 'C' ||
$value['status'] == 'CO')
+ {
+ $record_history[$i]['value_new_value']
= $GLOBALS['phpgw']->accounts->id2name($value['new_value']);
+ }
+ else if ($value['status'] == 'T' ||
$value['status'] == 'TO')
+ {
+ $record_history[$i]['value_new_value']
= $this->so->read_single_request_category($value['new_value']);
+ }
+ else if ($value['status'] != 'O' &&
$value['new_value'])
+ {
+ $record_history[$i]['value_new_value']
= $value['new_value'];
+ }
+ else
+ {
+ $record_history[$i]['value_new_value']
= '';
+ }
+
+ $i++;
+ }
+
+ return $record_history;
+ }
+
+
+ function next_id()
+ {
+ return $this->so->next_id();
+ }
+
+ function save($request,$action='')
+ {
+ while (is_array($request['location']) && list(,$value)
= each($request['location']))
+ {
+ if($value)
+ {
+ $location[] = $value;
+ }
+ }
+
+ $request['location_code']=implode("-", $location);
+ $start_date =
$this->bocommon->date_array($request['start_date']);
+ $end_date =
$this->bocommon->date_array($request['end_date']);
+
+ $request['start_date'] = mktime
(2,0,0,$start_date['month'],$start_date['day'],$start_date['year']);
+ $request['end_date'] = mktime
(2,0,0,$end_date['month'],$end_date['day'],$end_date['year']);
+
+ if ($action=='edit')
+ {
+ $receipt = $this->so->edit($request);
+
+ if($request['delete_file'])
+ {
+ for
($i=0;$i<count($request['delete_file']);$i++)
+ {
+ $file = $this->fakebase. SEP .
'request' . SEP . $request['location_code'] . SEP . $request['request_id'] .
SEP . $request['delete_file'][$i];
+
+
if($this->vfs->file_exists(array(
+ 'string' =>
$file,
+ 'relatives' =>
Array(RELATIVE_NONE)
+ )))
+ {
+
$this->vfs->override_acl = 1;
+
+ if(!$this->vfs->rm
(array(
+ 'string' =>
$file,
+ 'relatives' =>
array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to delete file') . ' :'.
$this->fakebase. SEP . 'request' . SEP . $request['location_code']. SEP .
$request['request_id'] . SEP .$request['delete_file'][$i]);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('file deleted') . ' :'.
$this->fakebase. SEP . 'request' . SEP . $request['location_code']. SEP .
$request['request_id'] . SEP . $request['delete_file'][$i]);
+ }
+
$this->vfs->override_acl = 0;
+ }
+ }
+ }
+
+ }
+ else
+ {
+ $receipt = $this->so->add($request);
+ }
+ return $receipt;
+ }
+
+ function delete($request_id)
+ {
+ $this->so->delete($request_id);
+ }
+ }
+?>
Index: property/inc/class.bos_agreement.inc.php
diff -u property/inc/class.bos_agreement.inc.php:1.10
property/inc/class.bos_agreement.inc.php:1.11
--- property/inc/class.bos_agreement.inc.php:1.10 Thu May 12 21:26:28 2005
+++ property/inc/class.bos_agreement.inc.php Fri Jan 27 14:05:43 2006
@@ -1,707 +1,707 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage agreement
- * @version $Id: class.bos_agreement.inc.php,v 1.10 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class bos_agreement
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
- var $role;
- var $member_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- function bos_agreement($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.sos_agreement');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->vfs =
CreateObject('phpgwapi.vfs');
- $this->rootdir = $this->vfs->basedir;
- $this->fakebase = $this->vfs->fakebase;
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $vendor_id =
get_var('vendor_id',array('POST','GET'));
- $allrows =
get_var('allrows',array('POST','GET'));
- $role = get_var('role',array('POST','GET'));
- $member_id =
get_var('member_id',array('POST','GET'));
-
-
- $this->role = $role;
- $this->so->role = $role;
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id) && !empty($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- else
- {
- unset($this->cat_id);
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
- if(isset($member_id))
- {
- $this->member_id = $member_id;
- }
- if(isset($vendor_id))
- {
- $this->vendor_id = $vendor_id;
- }
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','s_agreement',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','s_agreement');
-
- //_debug_array($data);
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->vendor_id= $data['vendor_id'];
- $this->member_id= $data['member_id'];
- $this->allrows = $data['allrows'];
- }
-
- function check_perms($has, $needed)
- {
- return (!!($has & $needed) == True);
- }
-
-
- function select_category_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
- $categories= $this->so->select_category_list();
-
- while (is_array($categories) && list(,$category) =
each($categories))
- {
- $sel_category = '';
- if ($category['id']==$selected)
- {
- $sel_category = 'selected';
- }
-
- $category_list[] = array
- (
- 'cat_id' => $category['id'],
- 'name' => $category['name'],
- 'selected' => $sel_category
- );
- }
-
- for ($i=0;$i<count($category_list);$i++)
- {
- if ($category_list[$i]['selected'] !=
'selected')
- {
- unset($category_list[$i]['selected']);
- }
- }
-
- return $category_list;
- }
-
- function select_vendor_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('select_vendor'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_vendor'));
- break;
- }
-
- $input_list= $this->so->select_vendor_list();
- $vendor_list=
$this->bocommon->select_list($selected,$input_list);
-
- return $vendor_list;
- }
-
- function read()
- {
- $s_agreement = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows,'member_id'=>$this->member_id,
-
'vendor_id'=>$this->vendor_id));
- $this->total_records = $this->so->total_records;
-
- $this->uicols = $this->so->uicols;
-
- for ($i=0; $i<count($s_agreement); $i++)
- {
- if($s_agreement[$i]['start_date'])
- {
- $s_agreement[$i]['start_date'] =
$GLOBALS['phpgw']->common->show_date($s_agreement[$i]['start_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- }
- if($s_agreement[$i]['end_date'])
- {
- $s_agreement[$i]['end_date'] =
$GLOBALS['phpgw']->common->show_date($s_agreement[$i]['end_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- }
- }
- return $s_agreement;
- }
-
- function read_details($id)
- {
- $list = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows,'member_id'=>$this->member_id,
-
's_agreement_id'=>$id,'detail'=>True));
- $this->total_records = $this->so->total_records;
-
- $this->uicols = $this->so->uicols;
-
- for ($i=0; $i<count($list); $i++)
- {
- $list[$i]['index_date'] =
$GLOBALS['phpgw']->common->show_date($list[$i]['index_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- }
-
- return $list;
- }
-
- function read_prizing($data)
- {
- $list = $this->so->read_prizing($data);
- $this->total_records = $this->so->total_records;
-
- $this->uicols = $this->so->uicols;
-
- for ($i=0; $i<count($list); $i++)
- {
- $list[$i]['index_date'] =
$GLOBALS['phpgw']->common->show_date($list[$i]['index_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- }
-
- return $list;
- }
-
- function read_event($data)
- {
- $boalarm =
CreateObject($this->currentapp.'.boalarm');
- $event = $this->so->read_single($data);
- $event['alarm_date']=$event['termination_date'];
- $event['alarm'] =
$boalarm->read_alarms($type='s_agreement',$data['s_agreement_id']);
- return $event;
- }
-
- function read_single($data)
- {
- $s_agreement = $this->so->read_single($data);
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $s_agreement['start_date'] =
$GLOBALS['phpgw']->common->show_date($s_agreement['start_date'],$dateformat);
- $s_agreement['end_date'] =
$GLOBALS['phpgw']->common->show_date($s_agreement['end_date'],$dateformat);
- if($s_agreement['termination_date'])
- {
- $s_agreement['termination_date']=
$GLOBALS['phpgw']->common->show_date($s_agreement['termination_date'],$dateformat);
- }
-
- $s_agreement = $this->convert_attribute($s_agreement);
-
- $this->vfs->override_acl = 1;
-
- $s_agreement['files'] = $this->vfs->ls (array(
- 'string' => $this->fakebase. '/' .
'service_agreement' . '/' . $data['s_agreement_id'],
- 'relatives' => array(RELATIVE_NONE)));
-
- $this->vfs->override_acl = 0;
-
- if(!$s_agreement['files'][0]['file_id'])
- {
- unset($s_agreement['files']);
- }
-
- return $s_agreement;
-
- }
-
- function read_single_item($data)
- {
- $item = $this->so->read_single_item($data);
-//_debug_array($item);
- $item = $this->convert_attribute($item,True);
-
- if($item['location_code'])
- {
- $solocation =
CreateObject($this->currentapp.'.solocation');
- $item['location_data']
=$solocation->read_single($item['location_code']);
- }
-
- if($item['p_num'])
- {
- $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
- $category =
$soadmin_entity->read_single_category($item['p_entity_id'],$item['p_cat_id']);
-
-
$item['p'][$item['p_entity_id']]['p_num']=$item['p_num'];
-
$item['p'][$item['p_entity_id']]['p_entity_id']=$item['p_entity_id'];
-
$item['p'][$item['p_entity_id']]['p_cat_id']=$item['p_cat_id'];
- $item['p'][$item['p_entity_id']]['p_cat_name']
= $category['name'];
- }
-
- return $item;
- }
-
- function convert_attribute($list,$detail='')
- {
- if($detail)
- {
- $this->so->role = 'detail';
- }
- $contacts =
CreateObject('phpgwapi.contacts');
-
- $vendor = CreateObject($this->currentapp.'.soactor');
- $vendor->role = 'vendor';
-
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-
- $input_type_array = array(
- 'R' => 'radio',
- 'CH' => 'checkbox',
- 'LB' => 'listbox'
- );
-
- $sep = '/';
- $dlarr[strpos($dateformat,'Y')] = 'Y';
- $dlarr[strpos($dateformat,'m')] = 'm';
- $dlarr[strpos($dateformat,'d')] = 'd';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
-//html_print_r($list);
- $m=0;
- for ($i=0;$i<count($list['attributes']);$i++)
- {
- if($list['attributes'][$i]['datatype']=='D' &&
$list['attributes'][$i]['value'])
- {
- $timestamp_date=
mktime(0,0,0,date(m,strtotime($list['attributes'][$i]['value'])),date(d,strtotime($list['attributes'][$i]['value'])),date(y,strtotime($list['attributes'][$i]['value'])));
- $list['attributes'][$i]['value']
= $GLOBALS['phpgw']->common->show_date($timestamp_date,$dateformat);
- }
- if($list['attributes'][$i]['datatype']=='AB')
- {
- if($list['attributes'][$i]['value'])
- {
- $contact_data =
$contacts->read_single_entry($list['attributes'][$i]['value'],array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
-
$list['attributes'][$i]['contact_name'] = $contact_data[0]['n_family'] . ', ' .
$contact_data[0]['n_given'];
- }
-
- $insert_record_list[] =
$list['attributes'][$i]['name'];
- $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.addressbook&column='
. $list['attributes'][$i]['name']);
-
- $lookup_functions[$m]['name'] =
'lookup_'. $list['attributes'][$i]['name'] .'()';
- $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
- $m++;
- }
-
if($list['attributes'][$i]['datatype']=='VENDOR')
- {
- if($list['attributes'][$i]['value'])
- {
- $vendor_data =
$vendor->read_single(array('actor_id'=>$list['attributes'][$i]['value']));
-
- for
($n=0;$n<count($vendor_data['attributes']);$n++)
- {
-
if($vendor_data['attributes'][$n]['name'] == 'org_name')
- {
-
$list['attributes'][$i]['vendor_name']= $vendor_data['attributes'][$n]['value'];
- $n
=count($vendor_data['attributes']);
- }
- }
- }
-
- $insert_record_list[] =
$list['attributes'][$i]['name'];
- $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor&column='
. $list['attributes'][$i]['name']);
-
- $lookup_functions[$m]['name'] =
'lookup_'. $list['attributes'][$i]['name'] .'()';
- $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
- $m++;
- }
- if($list['attributes'][$i]['datatype']=='R' ||
$list['attributes'][$i]['datatype']=='CH' ||
$list['attributes'][$i]['datatype']=='LB')
- {
- $list['attributes'][$i]['choice']
= $this->so->read_attrib_choice($list['attributes'][$i]['attrib_id']);
-
$input_type=$input_type_array[$list['attributes'][$i]['datatype']];
-
-
if($list['attributes'][$i]['datatype']=='CH')
- {
-
$list['attributes'][$i]['value']=unserialize($list['attributes'][$i]['value']);
-
$list['attributes'][$i]['choice'] =
$this->bocommon->select_multi_list_2($list['attributes'][$i]['value'],$list['attributes'][$i]['choice'],$input_type);
-
- }
- else
- {
- for
($j=0;$j<count($list['attributes'][$i]['choice']);$j++)
- {
-
$list['attributes'][$i]['choice'][$j]['input_type']=$input_type;
-
if($list['attributes'][$i]['choice'][$j]['id']==$list['attributes'][$i]['value'])
- {
-
$list['attributes'][$i]['choice'][$j]['checked']='checked';
- }
- }
- }
- }
-
- $list['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($list['attributes'][$i]['datatype']);
- $list['attributes'][$i]['counter'] = $i;
- $list['attributes'][$i]['type_id'] =
$data['type_id'];
- }
-
- for ($j=0;$j<count($lookup_functions);$j++)
- {
- $list['lookup_functions'] .= 'function ' .
$lookup_functions[$j]['name'] ."\r\n";
- $list['lookup_functions'] .= '{'."\r\n";
- $list['lookup_functions'] .=
$lookup_functions[$j]['action'] ."\r\n";
- $list['lookup_functions'] .= '}'."\r\n";
- }
-
-
$GLOBALS['phpgw']->session->appsession('insert_record_s_agreement' .
!!$detail,$this->currentapp,$insert_record_list);
-
-//html_print_r($list);
- return $list;
-
- }
-
- function convert_attribute_save($values_attribute='')
- {
-
- for ($i=0;$i<count($values_attribute);$i++)
- {
- if($values_attribute[$i]['datatype']=='CH' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
serialize($values_attribute[$i]['value']);
- }
- if($values_attribute[$i]['datatype']=='R' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
$values_attribute[$i]['value'][0];
- }
-
- if($values_attribute[$i]['datatype']=='N' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
str_replace(",",".",$values_attribute[$i]['value']);
- }
-
- if($values_attribute[$i]['datatype']=='D' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
date($this->bocommon->dateformat,$this->bocommon->date_to_timestamp($values_attribute[$i]['value']));
- }
- }
-
- return $values_attribute;
- }
-
- function save($values,$values_attribute='',$action='')
- {
-
- $values['start_date'] =
$this->bocommon->date_to_timestamp($values['start_date']);
- $values['end_date'] =
$this->bocommon->date_to_timestamp($values['end_date']);
- $values['termination_date'] =
$this->bocommon->date_to_timestamp($values['termination_date']);
-
- $values_attribute =
$this->convert_attribute_save($values_attribute);
-
- if ($action=='edit')
-// if ($values['s_agreement_id'])
- {
- if ($values['s_agreement_id'] != 0)
- {
-
$receipt=$this->so->edit($values,$values_attribute);
-
- if($values['delete_file'])
- {
- for
($i=0;$i<count($values['delete_file']);$i++)
- {
- $file =
$this->fakebase. SEP . 'service_agreement' . SEP . $values['s_agreement_id'] .
SEP . $values['delete_file'][$i];
-
-
if($this->vfs->file_exists(array(
-
'string' => $file,
-
'relatives' => Array(RELATIVE_NONE)
- )))
- {
-
$this->vfs->override_acl = 1;
-
-
if(!$this->vfs->rm (array(
-
'string' => $file,
-
'relatives' => array(
-
RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to delete file') . ' :'.
$this->fakebase. SEP . 'service_agreement'. SEP . $values['s_agreement_id'] .
SEP .$values['delete_file'][$i]);
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('file deleted') . ' :'.
$this->fakebase. SEP . 'service_agreement'. SEP . $values['id'] . SEP .
$values['delete_file'][$i]);
- }
-
$this->vfs->override_acl = 0;
- }
- }
- }
- }
- }
- else
- {
- $receipt =
$this->so->add($values,$values_attribute);
- }
- return $receipt;
- }
-
- function save_item($values,$values_attribute='')
- {
-
- while (is_array($values['location']) && list(,$value) =
each($values['location']))
- {
- if($value)
- {
- $location[] = $value;
- }
- }
-
- $values['location_code'address@hidden("-", $location);
-
- $values_attribute =
$this->convert_attribute_save($values_attribute);
-
- if ($values['id'])
- {
- if ($values['id'] != 0)
- {
-
$receipt=$this->so->edit_item($values,$values_attribute);
- }
- }
- else
- {
- $receipt =
$this->so->add_item($values,$values_attribute);
- }
- return $receipt;
- }
-
-
- function update($values)
- {
- $values['date'] =
$this->bocommon->date_to_timestamp($values['date']);
-
- return $this->so->update($values);
- }
-
- function delete_last_index($s_agreement_id,$id)
- {
- $this->so->delete_last_index($s_agreement_id,$id);
- }
-
-
- function delete_item($s_agreement_id,$item_id)
- {
- $this->so->delete_item($s_agreement_id,$item_id);
- }
-
- function delete($s_agreement_id='',$id='',$attrib='')
- {
- if ($attrib)
- {
- $this->so->delete_attrib($id);
- }
- else
- {
- $this->so->delete($s_agreement_id);
- }
- }
-
- function read_attrib($type_id='')
- {
- $attrib = $this->so->read_attrib(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'allrows'=>$this->allrows));
-
- for ($i=0; $i<count($attrib); $i++)
- {
- $attrib[$i]['datatype'] =
$this->bocommon->translate_datatype($attrib[$i]['datatype']);
- }
-
- $this->total_records = $this->so->total_records;
-
- return $attrib;
- }
-
- function read_single_attrib($id)
- {
- return $this->so->read_single_attrib($id);
- }
-
- function resort_attrib($data)
- {
- $this->so->resort_attrib($data);
- }
-
- function save_attrib($attrib,$action='')
- {
- if ($action=='edit')
- {
- if ($attrib['id'] != '')
- {
-
- $receipt =
$this->so->edit_attrib($attrib);
- }
- }
- else
- {
- $receipt = $this->so->add_attrib($attrib);
- }
- return $receipt;
- }
-
- function column_list($selected='',$allrows='')
- {
- if(!$selected)
- {
-
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]["s_agreement_columns"];
- }
-
- $columns =
$this->so->read_attrib(array('allrows'=>$allrows,'column_list'=>True));
-
-
$column_list=$this->bocommon->select_multi_list($selected,$columns);
-
- return $column_list;
- }
-
- function request_next_id()
- {
- return $this->so->request_next_id();
- }
-
- function create_home_dir($receipt='')
- {
- if(!$this->vfs->file_exists(array(
- 'string' => $this->fakebase. SEP .
'service_agreement',
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
- $this->vfs->override_acl = 1;
-
- if(!$this->vfs->mkdir (array(
- 'string' => $this->fakebase. SEP .
'service_agreement',
- 'relatives' => array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'service_agreement');
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'service_agreement');
- }
- $this->vfs->override_acl = 0;
- }
-
- return $receipt;
- }
-
- function create_document_dir($id='')
- {
-
- if(!$this->vfs->file_exists(array(
- 'string' => $this->fakebase. SEP .
'service_agreement' . SEP . $id,
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
- $this->vfs->override_acl = 1;
- if(!$this->vfs->mkdir (array(
- 'string' => $this->fakebase. SEP .
'service_agreement' . SEP . $id,
- 'relatives' => array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'service_agreement' . SEP . $id);
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'service_agreement' . SEP . $id);
- }
- $this->vfs->override_acl = 0;
- }
-
-//_debug_array($receipt);
- return $receipt;
- }
-
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage agreement
+ * @version $Id: class.bos_agreement.inc.php,v 1.11 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class bos_agreement
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+ var $role;
+ var $member_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ function bos_agreement($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.sos_agreement');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->vfs =
CreateObject('phpgwapi.vfs');
+ $this->rootdir = $this->vfs->basedir;
+ $this->fakebase = $this->vfs->fakebase;
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $vendor_id =
get_var('vendor_id',array('POST','GET'));
+ $allrows =
get_var('allrows',array('POST','GET'));
+ $role = get_var('role',array('POST','GET'));
+ $member_id =
get_var('member_id',array('POST','GET'));
+
+
+ $this->role = $role;
+ $this->so->role = $role;
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id) && !empty($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ else
+ {
+ unset($this->cat_id);
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+ if(isset($member_id))
+ {
+ $this->member_id = $member_id;
+ }
+ if(isset($vendor_id))
+ {
+ $this->vendor_id = $vendor_id;
+ }
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','s_agreement',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','s_agreement');
+
+ //_debug_array($data);
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->vendor_id= $data['vendor_id'];
+ $this->member_id= $data['member_id'];
+ $this->allrows = $data['allrows'];
+ }
+
+ function check_perms($has, $needed)
+ {
+ return (!!($has & $needed) == True);
+ }
+
+
+ function select_category_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ break;
+ }
+
+ $categories= $this->so->select_category_list();
+
+ while (is_array($categories) && list(,$category) =
each($categories))
+ {
+ $sel_category = '';
+ if ($category['id']==$selected)
+ {
+ $sel_category = 'selected';
+ }
+
+ $category_list[] = array
+ (
+ 'cat_id' => $category['id'],
+ 'name' => $category['name'],
+ 'selected' => $sel_category
+ );
+ }
+
+ for ($i=0;$i<count($category_list);$i++)
+ {
+ if ($category_list[$i]['selected'] !=
'selected')
+ {
+ unset($category_list[$i]['selected']);
+ }
+ }
+
+ return $category_list;
+ }
+
+ function select_vendor_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('select_vendor'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_vendor'));
+ break;
+ }
+
+ $input_list= $this->so->select_vendor_list();
+ $vendor_list=
$this->bocommon->select_list($selected,$input_list);
+
+ return $vendor_list;
+ }
+
+ function read()
+ {
+ $s_agreement = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows,'member_id'=>$this->member_id,
+
'vendor_id'=>$this->vendor_id));
+ $this->total_records = $this->so->total_records;
+
+ $this->uicols = $this->so->uicols;
+
+ for ($i=0; $i<count($s_agreement); $i++)
+ {
+ if($s_agreement[$i]['start_date'])
+ {
+ $s_agreement[$i]['start_date'] =
$GLOBALS['phpgw']->common->show_date($s_agreement[$i]['start_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ }
+ if($s_agreement[$i]['end_date'])
+ {
+ $s_agreement[$i]['end_date'] =
$GLOBALS['phpgw']->common->show_date($s_agreement[$i]['end_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ }
+ }
+ return $s_agreement;
+ }
+
+ function read_details($id)
+ {
+ $list = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows,'member_id'=>$this->member_id,
+
's_agreement_id'=>$id,'detail'=>True));
+ $this->total_records = $this->so->total_records;
+
+ $this->uicols = $this->so->uicols;
+
+ for ($i=0; $i<count($list); $i++)
+ {
+ $list[$i]['index_date'] =
$GLOBALS['phpgw']->common->show_date($list[$i]['index_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ }
+
+ return $list;
+ }
+
+ function read_prizing($data)
+ {
+ $list = $this->so->read_prizing($data);
+ $this->total_records = $this->so->total_records;
+
+ $this->uicols = $this->so->uicols;
+
+ for ($i=0; $i<count($list); $i++)
+ {
+ $list[$i]['index_date'] =
$GLOBALS['phpgw']->common->show_date($list[$i]['index_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ }
+
+ return $list;
+ }
+
+ function read_event($data)
+ {
+ $boalarm =
CreateObject($this->currentapp.'.boalarm');
+ $event = $this->so->read_single($data);
+ $event['alarm_date']=$event['termination_date'];
+ $event['alarm'] =
$boalarm->read_alarms($type='s_agreement',$data['s_agreement_id']);
+ return $event;
+ }
+
+ function read_single($data)
+ {
+ $s_agreement = $this->so->read_single($data);
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $s_agreement['start_date'] =
$GLOBALS['phpgw']->common->show_date($s_agreement['start_date'],$dateformat);
+ $s_agreement['end_date'] =
$GLOBALS['phpgw']->common->show_date($s_agreement['end_date'],$dateformat);
+ if($s_agreement['termination_date'])
+ {
+ $s_agreement['termination_date']=
$GLOBALS['phpgw']->common->show_date($s_agreement['termination_date'],$dateformat);
+ }
+
+ $s_agreement = $this->convert_attribute($s_agreement);
+
+ $this->vfs->override_acl = 1;
+
+ $s_agreement['files'] = $this->vfs->ls (array(
+ 'string' => $this->fakebase. '/' .
'service_agreement' . '/' . $data['s_agreement_id'],
+ 'relatives' => array(RELATIVE_NONE)));
+
+ $this->vfs->override_acl = 0;
+
+ if(!$s_agreement['files'][0]['file_id'])
+ {
+ unset($s_agreement['files']);
+ }
+
+ return $s_agreement;
+
+ }
+
+ function read_single_item($data)
+ {
+ $item = $this->so->read_single_item($data);
+//_debug_array($item);
+ $item = $this->convert_attribute($item,True);
+
+ if($item['location_code'])
+ {
+ $solocation =
CreateObject($this->currentapp.'.solocation');
+ $item['location_data']
=$solocation->read_single($item['location_code']);
+ }
+
+ if($item['p_num'])
+ {
+ $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
+ $category =
$soadmin_entity->read_single_category($item['p_entity_id'],$item['p_cat_id']);
+
+
$item['p'][$item['p_entity_id']]['p_num']=$item['p_num'];
+
$item['p'][$item['p_entity_id']]['p_entity_id']=$item['p_entity_id'];
+
$item['p'][$item['p_entity_id']]['p_cat_id']=$item['p_cat_id'];
+ $item['p'][$item['p_entity_id']]['p_cat_name']
= $category['name'];
+ }
+
+ return $item;
+ }
+
+ function convert_attribute($list,$detail='')
+ {
+ if($detail)
+ {
+ $this->so->role = 'detail';
+ }
+ $contacts =
CreateObject('phpgwapi.contacts');
+
+ $vendor = CreateObject($this->currentapp.'.soactor');
+ $vendor->role = 'vendor';
+
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ $input_type_array = array(
+ 'R' => 'radio',
+ 'CH' => 'checkbox',
+ 'LB' => 'listbox'
+ );
+
+ $sep = '/';
+ $dlarr[strpos($dateformat,'Y')] = 'Y';
+ $dlarr[strpos($dateformat,'m')] = 'm';
+ $dlarr[strpos($dateformat,'d')] = 'd';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+//html_print_r($list);
+ $m=0;
+ for ($i=0;$i<count($list['attributes']);$i++)
+ {
+ if($list['attributes'][$i]['datatype']=='D' &&
$list['attributes'][$i]['value'])
+ {
+ $timestamp_date=
mktime(0,0,0,date(m,strtotime($list['attributes'][$i]['value'])),date(d,strtotime($list['attributes'][$i]['value'])),date(y,strtotime($list['attributes'][$i]['value'])));
+ $list['attributes'][$i]['value']
= $GLOBALS['phpgw']->common->show_date($timestamp_date,$dateformat);
+ }
+ if($list['attributes'][$i]['datatype']=='AB')
+ {
+ if($list['attributes'][$i]['value'])
+ {
+ $contact_data =
$contacts->read_single_entry($list['attributes'][$i]['value'],array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
+
$list['attributes'][$i]['contact_name'] = $contact_data[0]['n_family'] . ', ' .
$contact_data[0]['n_given'];
+ }
+
+ $insert_record_list[] =
$list['attributes'][$i]['name'];
+ $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.addressbook&column='
. $list['attributes'][$i]['name']);
+
+ $lookup_functions[$m]['name'] =
'lookup_'. $list['attributes'][$i]['name'] .'()';
+ $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+ $m++;
+ }
+
if($list['attributes'][$i]['datatype']=='VENDOR')
+ {
+ if($list['attributes'][$i]['value'])
+ {
+ $vendor_data =
$vendor->read_single(array('actor_id'=>$list['attributes'][$i]['value']));
+
+ for
($n=0;$n<count($vendor_data['attributes']);$n++)
+ {
+
if($vendor_data['attributes'][$n]['name'] == 'org_name')
+ {
+
$list['attributes'][$i]['vendor_name']= $vendor_data['attributes'][$n]['value'];
+ $n
=count($vendor_data['attributes']);
+ }
+ }
+ }
+
+ $insert_record_list[] =
$list['attributes'][$i]['name'];
+ $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor&column='
. $list['attributes'][$i]['name']);
+
+ $lookup_functions[$m]['name'] =
'lookup_'. $list['attributes'][$i]['name'] .'()';
+ $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+ $m++;
+ }
+ if($list['attributes'][$i]['datatype']=='R' ||
$list['attributes'][$i]['datatype']=='CH' ||
$list['attributes'][$i]['datatype']=='LB')
+ {
+ $list['attributes'][$i]['choice']
= $this->so->read_attrib_choice($list['attributes'][$i]['attrib_id']);
+
$input_type=$input_type_array[$list['attributes'][$i]['datatype']];
+
+
if($list['attributes'][$i]['datatype']=='CH')
+ {
+
$list['attributes'][$i]['value']=unserialize($list['attributes'][$i]['value']);
+
$list['attributes'][$i]['choice'] =
$this->bocommon->select_multi_list_2($list['attributes'][$i]['value'],$list['attributes'][$i]['choice'],$input_type);
+
+ }
+ else
+ {
+ for
($j=0;$j<count($list['attributes'][$i]['choice']);$j++)
+ {
+
$list['attributes'][$i]['choice'][$j]['input_type']=$input_type;
+
if($list['attributes'][$i]['choice'][$j]['id']==$list['attributes'][$i]['value'])
+ {
+
$list['attributes'][$i]['choice'][$j]['checked']='checked';
+ }
+ }
+ }
+ }
+
+ $list['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($list['attributes'][$i]['datatype']);
+ $list['attributes'][$i]['counter'] = $i;
+ $list['attributes'][$i]['type_id'] =
$data['type_id'];
+ }
+
+ for ($j=0;$j<count($lookup_functions);$j++)
+ {
+ $list['lookup_functions'] .= 'function ' .
$lookup_functions[$j]['name'] ."\r\n";
+ $list['lookup_functions'] .= '{'."\r\n";
+ $list['lookup_functions'] .=
$lookup_functions[$j]['action'] ."\r\n";
+ $list['lookup_functions'] .= '}'."\r\n";
+ }
+
+
$GLOBALS['phpgw']->session->appsession('insert_record_s_agreement' .
!!$detail,$this->currentapp,$insert_record_list);
+
+//html_print_r($list);
+ return $list;
+
+ }
+
+ function convert_attribute_save($values_attribute='')
+ {
+
+ for ($i=0;$i<count($values_attribute);$i++)
+ {
+ if($values_attribute[$i]['datatype']=='CH' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
serialize($values_attribute[$i]['value']);
+ }
+ if($values_attribute[$i]['datatype']=='R' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
$values_attribute[$i]['value'][0];
+ }
+
+ if($values_attribute[$i]['datatype']=='N' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
str_replace(",",".",$values_attribute[$i]['value']);
+ }
+
+ if($values_attribute[$i]['datatype']=='D' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
date($this->bocommon->dateformat,$this->bocommon->date_to_timestamp($values_attribute[$i]['value']));
+ }
+ }
+
+ return $values_attribute;
+ }
+
+ function save($values,$values_attribute='',$action='')
+ {
+
+ $values['start_date'] =
$this->bocommon->date_to_timestamp($values['start_date']);
+ $values['end_date'] =
$this->bocommon->date_to_timestamp($values['end_date']);
+ $values['termination_date'] =
$this->bocommon->date_to_timestamp($values['termination_date']);
+
+ $values_attribute =
$this->convert_attribute_save($values_attribute);
+
+ if ($action=='edit')
+// if ($values['s_agreement_id'])
+ {
+ if ($values['s_agreement_id'] != 0)
+ {
+
$receipt=$this->so->edit($values,$values_attribute);
+
+ if($values['delete_file'])
+ {
+ for
($i=0;$i<count($values['delete_file']);$i++)
+ {
+ $file =
$this->fakebase. SEP . 'service_agreement' . SEP . $values['s_agreement_id'] .
SEP . $values['delete_file'][$i];
+
+
if($this->vfs->file_exists(array(
+
'string' => $file,
+
'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+
$this->vfs->override_acl = 1;
+
+
if(!$this->vfs->rm (array(
+
'string' => $file,
+
'relatives' => array(
+
RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to delete file') . ' :'.
$this->fakebase. SEP . 'service_agreement'. SEP . $values['s_agreement_id'] .
SEP .$values['delete_file'][$i]);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('file deleted') . ' :'.
$this->fakebase. SEP . 'service_agreement'. SEP . $values['id'] . SEP .
$values['delete_file'][$i]);
+ }
+
$this->vfs->override_acl = 0;
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ $receipt =
$this->so->add($values,$values_attribute);
+ }
+ return $receipt;
+ }
+
+ function save_item($values,$values_attribute='')
+ {
+
+ while (is_array($values['location']) && list(,$value) =
each($values['location']))
+ {
+ if($value)
+ {
+ $location[] = $value;
+ }
+ }
+
+ $values['location_code'address@hidden("-", $location);
+
+ $values_attribute =
$this->convert_attribute_save($values_attribute);
+
+ if ($values['id'])
+ {
+ if ($values['id'] != 0)
+ {
+
$receipt=$this->so->edit_item($values,$values_attribute);
+ }
+ }
+ else
+ {
+ $receipt =
$this->so->add_item($values,$values_attribute);
+ }
+ return $receipt;
+ }
+
+
+ function update($values)
+ {
+ $values['date'] =
$this->bocommon->date_to_timestamp($values['date']);
+
+ return $this->so->update($values);
+ }
+
+ function delete_last_index($s_agreement_id,$id)
+ {
+ $this->so->delete_last_index($s_agreement_id,$id);
+ }
+
+
+ function delete_item($s_agreement_id,$item_id)
+ {
+ $this->so->delete_item($s_agreement_id,$item_id);
+ }
+
+ function delete($s_agreement_id='',$id='',$attrib='')
+ {
+ if ($attrib)
+ {
+ $this->so->delete_attrib($id);
+ }
+ else
+ {
+ $this->so->delete($s_agreement_id);
+ }
+ }
+
+ function read_attrib($type_id='')
+ {
+ $attrib = $this->so->read_attrib(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'allrows'=>$this->allrows));
+
+ for ($i=0; $i<count($attrib); $i++)
+ {
+ $attrib[$i]['datatype'] =
$this->bocommon->translate_datatype($attrib[$i]['datatype']);
+ }
+
+ $this->total_records = $this->so->total_records;
+
+ return $attrib;
+ }
+
+ function read_single_attrib($id)
+ {
+ return $this->so->read_single_attrib($id);
+ }
+
+ function resort_attrib($data)
+ {
+ $this->so->resort_attrib($data);
+ }
+
+ function save_attrib($attrib,$action='')
+ {
+ if ($action=='edit')
+ {
+ if ($attrib['id'] != '')
+ {
+
+ $receipt =
$this->so->edit_attrib($attrib);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add_attrib($attrib);
+ }
+ return $receipt;
+ }
+
+ function column_list($selected='',$allrows='')
+ {
+ if(!$selected)
+ {
+
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]["s_agreement_columns"];
+ }
+
+ $columns =
$this->so->read_attrib(array('allrows'=>$allrows,'column_list'=>True));
+
+
$column_list=$this->bocommon->select_multi_list($selected,$columns);
+
+ return $column_list;
+ }
+
+ function request_next_id()
+ {
+ return $this->so->request_next_id();
+ }
+
+ function create_home_dir($receipt='')
+ {
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase. SEP .
'service_agreement',
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $this->vfs->override_acl = 1;
+
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase. SEP .
'service_agreement',
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'service_agreement');
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'service_agreement');
+ }
+ $this->vfs->override_acl = 0;
+ }
+
+ return $receipt;
+ }
+
+ function create_document_dir($id='')
+ {
+
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase. SEP .
'service_agreement' . SEP . $id,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $this->vfs->override_acl = 1;
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase. SEP .
'service_agreement' . SEP . $id,
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'service_agreement' . SEP . $id);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'service_agreement' . SEP . $id);
+ }
+ $this->vfs->override_acl = 0;
+ }
+
+//_debug_array($receipt);
+ return $receipt;
+ }
+
+
+ }
+?>
Index: property/inc/class.bostandard_2.inc.php
diff -u property/inc/class.bostandard_2.inc.php:1.5
property/inc/class.bostandard_2.inc.php:1.6
--- property/inc/class.bostandard_2.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/class.bostandard_2.inc.php Fri Jan 27 14:05:43 2006
@@ -1,175 +1,175 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.bostandard_2.inc.php,v 1.5 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class bostandard_2
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- var $soap_functions = array(
- 'list' => array(
- 'in' =>
array('int','int','struct','string','int'),
- 'out' => array('array')
- ),
- 'read' => array(
- 'in' => array('int','struct'),
- 'out' => array('array')
- ),
- 'save' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- ),
- 'delete' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- )
- );
-
- function bostandard_2($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.sostandard_2');
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $allrows= get_var('allrows',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','standard_2',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','standard_2');
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->allrows = $data['allrows'];
- }
-
- function read($type='')
- {
- $standard = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'type' => $type,'allrows'=>$this->allrows));
-
- $this->total_records = $this->so->total_records;
-
- return $standard;
- }
-
- function read_single($id,$type)
- {
- return $this->so->read_single($id,$type);
- }
-
- function select_part_of_town($part_of_town_id)
- {
- return
$this->socommon->select_part_of_town($part_of_town_id);
- }
-
- function save($standard,$action='',$type ='')
- {
- if ($action=='edit')
- {
- if ($standard['id'] != '')
- {
-
- $receipt =
$this->so->edit($standard,$type);
- }
- }
- else
- {
- $receipt = $this->so->add($standard,$type);
- }
- return $receipt;
-
- }
-
- function delete($id,$type)
- {
- $this->so->delete($id,$type);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.bostandard_2.inc.php,v 1.6 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class bostandard_2
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ var $soap_functions = array(
+ 'list' => array(
+ 'in' =>
array('int','int','struct','string','int'),
+ 'out' => array('array')
+ ),
+ 'read' => array(
+ 'in' => array('int','struct'),
+ 'out' => array('array')
+ ),
+ 'save' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ ),
+ 'delete' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ )
+ );
+
+ function bostandard_2($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.sostandard_2');
+ $this->socommon =
CreateObject($this->currentapp.'.socommon');
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $allrows= get_var('allrows',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','standard_2',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','standard_2');
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->allrows = $data['allrows'];
+ }
+
+ function read($type='')
+ {
+ $standard = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'type' => $type,'allrows'=>$this->allrows));
+
+ $this->total_records = $this->so->total_records;
+
+ return $standard;
+ }
+
+ function read_single($id,$type)
+ {
+ return $this->so->read_single($id,$type);
+ }
+
+ function select_part_of_town($part_of_town_id)
+ {
+ return
$this->socommon->select_part_of_town($part_of_town_id);
+ }
+
+ function save($standard,$action='',$type ='')
+ {
+ if ($action=='edit')
+ {
+ if ($standard['id'] != '')
+ {
+
+ $receipt =
$this->so->edit($standard,$type);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add($standard,$type);
+ }
+ return $receipt;
+
+ }
+
+ function delete($id,$type)
+ {
+ $this->so->delete($id,$type);
+ }
+ }
+?>
Index: property/inc/class.bostandard_3.inc.php
diff -u property/inc/class.bostandard_3.inc.php:1.5
property/inc/class.bostandard_3.inc.php:1.6
--- property/inc/class.bostandard_3.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/class.bostandard_3.inc.php Fri Jan 27 14:05:43 2006
@@ -1,165 +1,165 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.bostandard_3.inc.php,v 1.5 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class bostandard_3
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- var $soap_functions = array(
- 'list' => array(
- 'in' =>
array('int','int','struct','string','int'),
- 'out' => array('array')
- ),
- 'read' => array(
- 'in' => array('int','struct'),
- 'out' => array('array')
- ),
- 'save' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- ),
- 'delete' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- )
- );
-
- function bostandard_3($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.sostandard_3');
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','standard_3',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','standard_3');
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- }
-
-
- function read($type='')
- {
- $standard = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'type' => $type));
-
- $this->total_records = $this->so->total_records;
-
- return $standard;
- }
-
- function read_single($id,$type)
- {
- return $this->so->read_single($id,$type);
- }
-
- function save($standard,$action='',$type ='')
- {
- if ($action=='edit')
- {
- if ($standard['id'] != '')
- {
-
- $receipt =
$this->so->edit($standard,$type);
- }
- }
- else
- {
- $receipt = $this->so->add($standard,$type);
- }
- return $receipt;
-
- }
-
- function delete($id,$type)
- {
- $this->so->delete($id,$type);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.bostandard_3.inc.php,v 1.6 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class bostandard_3
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ var $soap_functions = array(
+ 'list' => array(
+ 'in' =>
array('int','int','struct','string','int'),
+ 'out' => array('array')
+ ),
+ 'read' => array(
+ 'in' => array('int','struct'),
+ 'out' => array('array')
+ ),
+ 'save' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ ),
+ 'delete' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ )
+ );
+
+ function bostandard_3($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.sostandard_3');
+ $this->socommon =
CreateObject($this->currentapp.'.socommon');
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','standard_3',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','standard_3');
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ }
+
+
+ function read($type='')
+ {
+ $standard = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'type' => $type));
+
+ $this->total_records = $this->so->total_records;
+
+ return $standard;
+ }
+
+ function read_single($id,$type)
+ {
+ return $this->so->read_single($id,$type);
+ }
+
+ function save($standard,$action='',$type ='')
+ {
+ if ($action=='edit')
+ {
+ if ($standard['id'] != '')
+ {
+
+ $receipt =
$this->so->edit($standard,$type);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add($standard,$type);
+ }
+ return $receipt;
+
+ }
+
+ function delete($id,$type)
+ {
+ $this->so->delete($id,$type);
+ }
+ }
+?>
Index: property/inc/class.bostandard_entity.inc.php
diff -u property/inc/class.bostandard_entity.inc.php:1.5
property/inc/class.bostandard_entity.inc.php:1.6
--- property/inc/class.bostandard_entity.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/class.bostandard_entity.inc.php Fri Jan 27 14:05:43 2006
@@ -1,284 +1,284 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.bostandard_entity.inc.php,v 1.5 2005/05/12
21:26:28 sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class bostandard_entity
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- var $soap_functions = array(
- 'list' => array(
- 'in' =>
array('int','int','struct','string','int'),
- 'out' => array('array')
- ),
- 'read' => array(
- 'in' => array('int','struct'),
- 'out' => array('array')
- ),
- 'save' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- ),
- 'delete' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- )
- );
-
- function bostandard_entity($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.sostandard_entity');
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- }
-
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','standard_e',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','standard_e');
-
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- }
-
-
- function read($type='')
- {
- $standard = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'type' => $type));
-
- $this->total_records = $this->so->total_records;
-
-
- return $standard;
- }
-
- function read_single($id,$type)
- {
- return $this->so->read_single($id,$type);
- }
-
- function save($standard,$action='',$type ='')
- {
- if ($action=='edit')
- {
- if ($standard['id'] != '')
- {
-
- $receipt =
$this->so->edit($standard,$type);
- }
- }
- else
- {
- $receipt = $this->so->add($standard,$type);
- }
- return $receipt;
-
- }
-
- function delete($id,$type,$attrib)
- {
- $this->so->delete($id,$type,$attrib);
- }
-
- function read_attrib($type='',$type_id='',$allrows='')
- {
- $attrib = $this->so->read_attrib(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'type' => $type,'type_id' => $type_id,'allrows' => $allrows));
-
- $this->total_records = $this->so->total_records;
-
- for ($i=0; $i<count($attrib); $i++)
- {
- $attrib[$i]['datatype'] =
$this->bocommon->translate_datatype($attrib[$i]['datatype']);
- }
-
- return $attrib;
- }
-
- function read_single_attrib($id,$type)
- {
- return $this->so->read_single_attrib($id,$type);
- }
-
- function save_attrib($attrib,$action='',$type ='')
- {
- if ($action=='edit')
- {
- if ($attrib['id'] != '')
- {
-
- $receipt =
$this->so->edit_attrib($attrib,$type);
- }
- }
- else
- {
- $receipt = $this->so->add_attrib($attrib,$type);
- }
- return $receipt;
- }
-
-
- function select_entity_type($type='',$selected='')
- {
- $entity_types= $this->so->select_entity_type($type);
-
- while (is_array($entity_types) && list(,$type) =
each($entity_types))
- {
- $sel_type = '';
- if ($type['id']==$selected)
- {
- $sel_type = 'selected';
- }
-
- $entity_type_list[] = array
- (
- 'id' => $type['id'],
- 'name' => $type['name'],
- 'selected' => $sel_type
- );
- }
-
- for ($i=0;$i<count($entity_type_list);$i++)
- {
- if ($entity_type_list[$i]['selected'] !=
'selected')
- {
-
unset($entity_type_list[$i]['selected']);
- }
- }
-
- return $entity_type_list;
- }
-
- function select_datatype($selected='')
- {
- $datatypes[0]['id']= 'C';
- $datatypes[0]['name']= lang('Character');
- $datatypes[1]['id']= 'I';
- $datatypes[1]['name']= lang('Integer');
- $datatypes[2]['id']= 'N';
- $datatypes[2]['name']= lang('Decimal');
- $datatypes[3]['id']= 'D';
- $datatypes[3]['name']= lang('Date');
- $datatypes[4]['id']= 'T';
- $datatypes[4]['name']= lang('Memo');
- $datatypes[5]['id']= 'R';
- $datatypes[5]['name']= lang('Multiple radio');
- $datatypes[6]['id']= 'CH';
- $datatypes[6]['name']= lang('Multiple Checkbox');
-
- while (is_array($datatypes) && list(,$type) =
each($datatypes))
- {
- $sel_type = '';
- if ($type['id']==$selected)
- {
- $sel_type = 'selected';
- }
-
- $datatype_list[] = array
- (
- 'id' => $type['id'],
- 'name' => $type['name'],
- 'selected' => $sel_type
- );
- }
-
- for ($i=0;$i<count($datatype_list);$i++)
- {
- if ($datatype_list[$i]['selected'] !=
'selected')
- {
- unset($datatype_list[$i]['selected']);
- }
- }
-
- return $datatype_list;
- }
-
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.bostandard_entity.inc.php,v 1.6 2006/01/27
14:05:43 sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class bostandard_entity
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ var $soap_functions = array(
+ 'list' => array(
+ 'in' =>
array('int','int','struct','string','int'),
+ 'out' => array('array')
+ ),
+ 'read' => array(
+ 'in' => array('int','struct'),
+ 'out' => array('array')
+ ),
+ 'save' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ ),
+ 'delete' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ )
+ );
+
+ function bostandard_entity($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.sostandard_entity');
+ $this->socommon =
CreateObject($this->currentapp.'.socommon');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ }
+
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','standard_e',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','standard_e');
+
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ }
+
+
+ function read($type='')
+ {
+ $standard = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'type' => $type));
+
+ $this->total_records = $this->so->total_records;
+
+
+ return $standard;
+ }
+
+ function read_single($id,$type)
+ {
+ return $this->so->read_single($id,$type);
+ }
+
+ function save($standard,$action='',$type ='')
+ {
+ if ($action=='edit')
+ {
+ if ($standard['id'] != '')
+ {
+
+ $receipt =
$this->so->edit($standard,$type);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add($standard,$type);
+ }
+ return $receipt;
+
+ }
+
+ function delete($id,$type,$attrib)
+ {
+ $this->so->delete($id,$type,$attrib);
+ }
+
+ function read_attrib($type='',$type_id='',$allrows='')
+ {
+ $attrib = $this->so->read_attrib(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'type' => $type,'type_id' => $type_id,'allrows' => $allrows));
+
+ $this->total_records = $this->so->total_records;
+
+ for ($i=0; $i<count($attrib); $i++)
+ {
+ $attrib[$i]['datatype'] =
$this->bocommon->translate_datatype($attrib[$i]['datatype']);
+ }
+
+ return $attrib;
+ }
+
+ function read_single_attrib($id,$type)
+ {
+ return $this->so->read_single_attrib($id,$type);
+ }
+
+ function save_attrib($attrib,$action='',$type ='')
+ {
+ if ($action=='edit')
+ {
+ if ($attrib['id'] != '')
+ {
+
+ $receipt =
$this->so->edit_attrib($attrib,$type);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add_attrib($attrib,$type);
+ }
+ return $receipt;
+ }
+
+
+ function select_entity_type($type='',$selected='')
+ {
+ $entity_types= $this->so->select_entity_type($type);
+
+ while (is_array($entity_types) && list(,$type) =
each($entity_types))
+ {
+ $sel_type = '';
+ if ($type['id']==$selected)
+ {
+ $sel_type = 'selected';
+ }
+
+ $entity_type_list[] = array
+ (
+ 'id' => $type['id'],
+ 'name' => $type['name'],
+ 'selected' => $sel_type
+ );
+ }
+
+ for ($i=0;$i<count($entity_type_list);$i++)
+ {
+ if ($entity_type_list[$i]['selected'] !=
'selected')
+ {
+
unset($entity_type_list[$i]['selected']);
+ }
+ }
+
+ return $entity_type_list;
+ }
+
+ function select_datatype($selected='')
+ {
+ $datatypes[0]['id']= 'C';
+ $datatypes[0]['name']= lang('Character');
+ $datatypes[1]['id']= 'I';
+ $datatypes[1]['name']= lang('Integer');
+ $datatypes[2]['id']= 'N';
+ $datatypes[2]['name']= lang('Decimal');
+ $datatypes[3]['id']= 'D';
+ $datatypes[3]['name']= lang('Date');
+ $datatypes[4]['id']= 'T';
+ $datatypes[4]['name']= lang('Memo');
+ $datatypes[5]['id']= 'R';
+ $datatypes[5]['name']= lang('Multiple radio');
+ $datatypes[6]['id']= 'CH';
+ $datatypes[6]['name']= lang('Multiple Checkbox');
+
+ while (is_array($datatypes) && list(,$type) =
each($datatypes))
+ {
+ $sel_type = '';
+ if ($type['id']==$selected)
+ {
+ $sel_type = 'selected';
+ }
+
+ $datatype_list[] = array
+ (
+ 'id' => $type['id'],
+ 'name' => $type['name'],
+ 'selected' => $sel_type
+ );
+ }
+
+ for ($i=0;$i<count($datatype_list);$i++)
+ {
+ if ($datatype_list[$i]['selected'] !=
'selected')
+ {
+ unset($datatype_list[$i]['selected']);
+ }
+ }
+
+ return $datatype_list;
+ }
+
+
+ }
+?>
Index: property/inc/class.botemplate.inc.php
diff -u property/inc/class.botemplate.inc.php:1.5
property/inc/class.botemplate.inc.php:1.6
--- property/inc/class.botemplate.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/class.botemplate.inc.php Fri Jan 27 14:05:43 2006
@@ -1,251 +1,251 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage project
- * @version $Id: class.botemplate.inc.php,v 1.5 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class botemplate
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- function botemplate($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.sotemplate');
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $allrows =
get_var('allrows',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(isset($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
- }
-
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','template',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','template');
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->allrows = $data['allrows'];
- }
-
-
- function read()
- {
- $template = $this->so->read(array('filter' =>
$this->filter,'start' => $this->start,'query' => $this->query,'sort' =>
$this->sort,'order' => $this->order,
-
'chapter_id' => $this->chapter_id,'allrows'=>$this->allrows,
'template_id'=>$template_id));
- $this->total_records = $this->so->total_records;
-
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-
- for ($i=0; $i<count($template); $i++)
- {
- $template[$i]['owner'] =
$GLOBALS['phpgw']->accounts->id2name($template[$i]['owner']);
- $template[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($template[$i]['entry_date'],$dateformat);
- }
-
- return $template;
- }
-
- function read_template_hour($template_id)
- {
- $template = $this->so->read_template_hour(array('start'
=> $this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'chapter_id' => $this->chapter_id,'allrows'=>$this->allrows,
'template_id'=>$template_id));
- $this->total_records = $this->so->total_records;
-
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-
- for ($i=0; $i<count($template); $i++)
- {
- $template[$i]['owner'] =
$GLOBALS['phpgw']->accounts->id2name($template[$i]['owner']);
- $template[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($template[$i]['entry_date'],$dateformat);
- }
-
- return $template;
- }
-
-
- function read_single_template($template_id)
- {
- return $this->so->read_single_template($template_id);
- }
-
- function read_single_hour($hour_id)
- {
- return $this->so->read_single_hour($hour_id);
- }
-
- function get_grouping_list($selected='',$template_id)
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('grouping_select'));
-
- $groupings= $this->so->get_grouping_list($template_id);
-
- while (is_array($groupings) && list(,$grouping_entry) =
each($groupings))
- {
- $sel_grouping_entry = '';
- if ($grouping_entry['id']==$selected)
- {
- $sel_grouping_entry = 'selected';
- }
-
- $grouping_list[] = array
- (
- 'id' =>
$grouping_entry['id'],
- 'name' =>
$grouping_entry['name'],
- 'selected' => $sel_grouping_entry
- );
- }
-
- for ($i=0;$i<count($grouping_list);$i++)
- {
- if ($grouping_list[$i]['selected'] !=
'selected')
- {
- unset($grouping_list[$i]['selected']);
- }
- }
-
- return $grouping_list;
- }
-
- function save_template($values)
- {
- if ($values['template_id'])
- {
- if ($values['template_id'] != 0)
- {
- $receipt =
$this->so->edit_template($values);
-
$receipt['template_id']=$values['template_id'];
- }
- }
- else
- {
- $receipt = $this->so->add_template($values);
- }
- return $receipt;
- }
-
- function save_hour($values,$template_id)
- {
- $values['billperae'] =
str_replace(",",".",$values['billperae']);
- $values['quantity'] =
str_replace(",",".",$values['quantity']);
- $values['cost'] =
$values['billperae']*$values['quantity'];
- if($values['ns3420_descr'])
- {
- $values['descr']=$values['ns3420_descr'];
- }
-
- if ($values['hour_id'])
- {
- if ($values['hour_id'] != 0)
- {
- $receipt =
$this->so->edit_hour($values,$template_id);
- }
- }
- else
- {
- $receipt =
$this->so->add_custom_hour($values,$template_id);
- }
- return $receipt;
- }
-
- function delete($params)
- {
- if (is_array($params))
- {
- $this->so->delete($params[0]);
- }
- else
- {
- $this->so->delete($params);
- }
- }
-
- function delete_hour($hour_id,$template_id)
- {
- return $this->so->delete_hour($hour_id,$template_id);
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage project
+ * @version $Id: class.botemplate.inc.php,v 1.6 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class botemplate
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ function botemplate($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.sotemplate');
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $allrows =
get_var('allrows',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(isset($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+ }
+
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','template',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','template');
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->allrows = $data['allrows'];
+ }
+
+
+ function read()
+ {
+ $template = $this->so->read(array('filter' =>
$this->filter,'start' => $this->start,'query' => $this->query,'sort' =>
$this->sort,'order' => $this->order,
+
'chapter_id' => $this->chapter_id,'allrows'=>$this->allrows,
'template_id'=>$template_id));
+ $this->total_records = $this->so->total_records;
+
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ for ($i=0; $i<count($template); $i++)
+ {
+ $template[$i]['owner'] =
$GLOBALS['phpgw']->accounts->id2name($template[$i]['owner']);
+ $template[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($template[$i]['entry_date'],$dateformat);
+ }
+
+ return $template;
+ }
+
+ function read_template_hour($template_id)
+ {
+ $template = $this->so->read_template_hour(array('start'
=> $this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'chapter_id' => $this->chapter_id,'allrows'=>$this->allrows,
'template_id'=>$template_id));
+ $this->total_records = $this->so->total_records;
+
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ for ($i=0; $i<count($template); $i++)
+ {
+ $template[$i]['owner'] =
$GLOBALS['phpgw']->accounts->id2name($template[$i]['owner']);
+ $template[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($template[$i]['entry_date'],$dateformat);
+ }
+
+ return $template;
+ }
+
+
+ function read_single_template($template_id)
+ {
+ return $this->so->read_single_template($template_id);
+ }
+
+ function read_single_hour($hour_id)
+ {
+ return $this->so->read_single_hour($hour_id);
+ }
+
+ function get_grouping_list($selected='',$template_id)
+ {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('grouping_select'));
+
+ $groupings= $this->so->get_grouping_list($template_id);
+
+ while (is_array($groupings) && list(,$grouping_entry) =
each($groupings))
+ {
+ $sel_grouping_entry = '';
+ if ($grouping_entry['id']==$selected)
+ {
+ $sel_grouping_entry = 'selected';
+ }
+
+ $grouping_list[] = array
+ (
+ 'id' =>
$grouping_entry['id'],
+ 'name' =>
$grouping_entry['name'],
+ 'selected' => $sel_grouping_entry
+ );
+ }
+
+ for ($i=0;$i<count($grouping_list);$i++)
+ {
+ if ($grouping_list[$i]['selected'] !=
'selected')
+ {
+ unset($grouping_list[$i]['selected']);
+ }
+ }
+
+ return $grouping_list;
+ }
+
+ function save_template($values)
+ {
+ if ($values['template_id'])
+ {
+ if ($values['template_id'] != 0)
+ {
+ $receipt =
$this->so->edit_template($values);
+
$receipt['template_id']=$values['template_id'];
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add_template($values);
+ }
+ return $receipt;
+ }
+
+ function save_hour($values,$template_id)
+ {
+ $values['billperae'] =
str_replace(",",".",$values['billperae']);
+ $values['quantity'] =
str_replace(",",".",$values['quantity']);
+ $values['cost'] =
$values['billperae']*$values['quantity'];
+ if($values['ns3420_descr'])
+ {
+ $values['descr']=$values['ns3420_descr'];
+ }
+
+ if ($values['hour_id'])
+ {
+ if ($values['hour_id'] != 0)
+ {
+ $receipt =
$this->so->edit_hour($values,$template_id);
+ }
+ }
+ else
+ {
+ $receipt =
$this->so->add_custom_hour($values,$template_id);
+ }
+ return $receipt;
+ }
+
+ function delete($params)
+ {
+ if (is_array($params))
+ {
+ $this->so->delete($params[0]);
+ }
+ else
+ {
+ $this->so->delete($params);
+ }
+ }
+
+ function delete_hour($hour_id,$template_id)
+ {
+ return $this->so->delete_hour($hour_id,$template_id);
+ }
+
+ }
+?>
Index: property/inc/class.botenant_claim.inc.php
diff -u property/inc/class.botenant_claim.inc.php:1.5
property/inc/class.botenant_claim.inc.php:1.6
--- property/inc/class.botenant_claim.inc.php:1.5 Thu Sep 22 13:47:43 2005
+++ property/inc/class.botenant_claim.inc.php Fri Jan 27 14:05:43 2006
@@ -1,311 +1,311 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage project
- * @version $Id: class.botenant_claim.inc.php,v 1.5 2005/09/22 13:47:43
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
-
-
- class botenant_claim
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- function botenant_claim($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->so =
CreateObject($this->currentapp.'.sotenant_claim');
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $status = get_var('status',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $allrows= get_var('allrows',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($filter))
- {
- $this->filter = $filter;
- }
- if(isset($status))
- {
- $this->status = $status;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id) && !empty($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- else
- {
- unset($this->cat_id);
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','tenant_claim',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','tenant_claim');
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->status = $data['status'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- }
-
- function check_perms($has, $needed)
- {
- return (!!($has & $needed) == True);
- }
-
- function get_status_list($data=0)
- {
- if(is_array($data))
- {
- $format =
(isset($data['format'])?$data['format']:'');
- $selected =
(isset($data['selected'])?$data['selected']:$data['default']);
- }
- else
- {
- return;
- }
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('status_' .
$format));
-
- $status[0][id]='closed';
- $status[0][name]=lang('Closed');
- if($format == "filter")
- {
- $status[1][id]='all';
- $status[1][name]=lang('All');
- }
- else
- {
- $status[1][id]='open';
- $status[1][name]=lang('Open');
- }
-
- while (is_array($status) && list(,$entry) =
each($status))
- {
- $sel_status = '';
- if ($entry['id']==$selected)
- {
- $sel_status = 'selected';
- }
-
- $status_list[] = array
- (
- 'id' => $entry['id'],
- 'name' => $entry['name'],
- 'selected' => $sel_status
- );
- }
-
- for ($i=0;$i<count($status_list);$i++)
- {
- if ($status_list[$i]['selected'] != 'selected')
- {
- unset($status_list[$i]['selected']);
- }
- }
-
- return $status_list;
- }
-
- function read_category_name($cat_id='')
- {
- return $this->so->read_category_name($cat_id);
- }
-
- function select_category_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
- $categories= $this->so->select_category_list();
-
- while (is_array($categories) && list(,$category) =
each($categories))
- {
- $sel_category = '';
- if ($category['id']==$selected)
- {
- $sel_category = 'selected';
- }
-
- $category_list[] = array
- (
- 'cat_id' => $category['id'],
- 'name' => $category['name'],
- 'selected' => $sel_category
- );
- }
-
- for ($i=0;$i<count($category_list);$i++)
- {
- if ($category_list[$i]['selected'] !=
'selected')
- {
- unset($category_list[$i]['selected']);
- }
- }
-
- return $category_list;
- }
-
- function read($data=0)
- {
- $claim = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'status' => $this->status,'cat_id' =>
$this->cat_id,
-
'allrows'=>$this->allrows,'project_id' => $data['project_id']));
- $this->total_records = $this->so->total_records;
-
- for ($i=0; $i<count($claim); $i++)
- {
- $claim[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($claim[$i]['entry_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- }
- return $claim;
- }
-
- function check_claim_project($project_id)
- {
- $claim = $this->so->check_claim_project($project_id);
- $this->total_records = $this->so->total_records;
- return $claim;
- }
-
- function check_claim_workorder($workorder_id)
- {
- $claim =
$this->so->check_claim_workorder($workorder_id);
- $this->total_records = $this->so->total_records;
- return $claim;
- }
-
- function read_single($claim_id)
- {
- return $this->so->read_single($claim_id);
- }
-
- function save($claim)
- {
-
- if ($claim['claim_id'])
- {
- if ($claim['claim_id'] != 0)
- {
- $claim_id = $claim['claim_id'];
- $receipt=$this->so->edit($claim);
- $action = lang('altered');
- }
- }
- else
- {
- $receipt = $this->so->add($claim);
- $action = lang('added');
- }
-
-
- $this->config =
CreateObject('phpgwapi.config',$this->currentapp);
- $this->config->read_repository();
- $claim_notify_mails =
$this->config->config_data['tenant_claim_notify_mails'];
- if ($claim_notify_mails)
- {
- // notify via email
-
$current_user_id=$GLOBALS['phpgw_info']['user']['account_id'];
- $current_prefs_user =
$this->bocommon->create_preferences($this->currentapp,$current_user_id);
- $from=$current_prefs_user['email'];
- $subject = lang("Tenant claim
%1",$receipt['claim_id']) .' ' . $action;
- $body = lang('Reminder');
-
- if(!is_object($GLOBALS['phpgw']->send))
- {
- $GLOBALS['phpgw']->send =
CreateObject('phpgwapi.send');
- }
- $subject =
$GLOBALS['phpgw']->send->encode_subject($subject);
- $notify_mails =
explode(',',$claim_notify_mails);
- foreach($notify_mails as $to)
- {
-
$GLOBALS['phpgw']->send->msg('email',$to,$subject,$body,'','','',$from,$from);
- }
- }
-
- return $receipt;
- }
-
- function delete($params)
- {
- if (is_array($params))
- {
- $this->so->delete($params[0]);
- }
- else
- {
- $this->so->delete($params);
- }
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage project
+ * @version $Id: class.botenant_claim.inc.php,v 1.6 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+
+
+ class botenant_claim
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ function botenant_claim($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->so =
CreateObject($this->currentapp.'.sotenant_claim');
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $status = get_var('status',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $allrows= get_var('allrows',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($status))
+ {
+ $this->status = $status;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id) && !empty($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ else
+ {
+ unset($this->cat_id);
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','tenant_claim',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','tenant_claim');
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->status = $data['status'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ }
+
+ function check_perms($has, $needed)
+ {
+ return (!!($has & $needed) == True);
+ }
+
+ function get_status_list($data=0)
+ {
+ if(is_array($data))
+ {
+ $format =
(isset($data['format'])?$data['format']:'');
+ $selected =
(isset($data['selected'])?$data['selected']:$data['default']);
+ }
+ else
+ {
+ return;
+ }
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('status_' .
$format));
+
+ $status[0][id]='closed';
+ $status[0][name]=lang('Closed');
+ if($format == "filter")
+ {
+ $status[1][id]='all';
+ $status[1][name]=lang('All');
+ }
+ else
+ {
+ $status[1][id]='open';
+ $status[1][name]=lang('Open');
+ }
+
+ while (is_array($status) && list(,$entry) =
each($status))
+ {
+ $sel_status = '';
+ if ($entry['id']==$selected)
+ {
+ $sel_status = 'selected';
+ }
+
+ $status_list[] = array
+ (
+ 'id' => $entry['id'],
+ 'name' => $entry['name'],
+ 'selected' => $sel_status
+ );
+ }
+
+ for ($i=0;$i<count($status_list);$i++)
+ {
+ if ($status_list[$i]['selected'] != 'selected')
+ {
+ unset($status_list[$i]['selected']);
+ }
+ }
+
+ return $status_list;
+ }
+
+ function read_category_name($cat_id='')
+ {
+ return $this->so->read_category_name($cat_id);
+ }
+
+ function select_category_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ break;
+ }
+
+ $categories= $this->so->select_category_list();
+
+ while (is_array($categories) && list(,$category) =
each($categories))
+ {
+ $sel_category = '';
+ if ($category['id']==$selected)
+ {
+ $sel_category = 'selected';
+ }
+
+ $category_list[] = array
+ (
+ 'cat_id' => $category['id'],
+ 'name' => $category['name'],
+ 'selected' => $sel_category
+ );
+ }
+
+ for ($i=0;$i<count($category_list);$i++)
+ {
+ if ($category_list[$i]['selected'] !=
'selected')
+ {
+ unset($category_list[$i]['selected']);
+ }
+ }
+
+ return $category_list;
+ }
+
+ function read($data=0)
+ {
+ $claim = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'status' => $this->status,'cat_id' =>
$this->cat_id,
+
'allrows'=>$this->allrows,'project_id' => $data['project_id']));
+ $this->total_records = $this->so->total_records;
+
+ for ($i=0; $i<count($claim); $i++)
+ {
+ $claim[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($claim[$i]['entry_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ }
+ return $claim;
+ }
+
+ function check_claim_project($project_id)
+ {
+ $claim = $this->so->check_claim_project($project_id);
+ $this->total_records = $this->so->total_records;
+ return $claim;
+ }
+
+ function check_claim_workorder($workorder_id)
+ {
+ $claim =
$this->so->check_claim_workorder($workorder_id);
+ $this->total_records = $this->so->total_records;
+ return $claim;
+ }
+
+ function read_single($claim_id)
+ {
+ return $this->so->read_single($claim_id);
+ }
+
+ function save($claim)
+ {
+
+ if ($claim['claim_id'])
+ {
+ if ($claim['claim_id'] != 0)
+ {
+ $claim_id = $claim['claim_id'];
+ $receipt=$this->so->edit($claim);
+ $action = lang('altered');
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add($claim);
+ $action = lang('added');
+ }
+
+
+ $this->config =
CreateObject('phpgwapi.config',$this->currentapp);
+ $this->config->read_repository();
+ $claim_notify_mails =
$this->config->config_data['tenant_claim_notify_mails'];
+ if ($claim_notify_mails)
+ {
+ // notify via email
+
$current_user_id=$GLOBALS['phpgw_info']['user']['account_id'];
+ $current_prefs_user =
$this->bocommon->create_preferences($this->currentapp,$current_user_id);
+ $from=$current_prefs_user['email'];
+ $subject = lang("Tenant claim
%1",$receipt['claim_id']) .' ' . $action;
+ $body = lang('Reminder');
+
+ if(!is_object($GLOBALS['phpgw']->send))
+ {
+ $GLOBALS['phpgw']->send =
CreateObject('phpgwapi.send');
+ }
+ $subject =
$GLOBALS['phpgw']->send->encode_subject($subject);
+ $notify_mails =
explode(',',$claim_notify_mails);
+ foreach($notify_mails as $to)
+ {
+
$GLOBALS['phpgw']->send->msg('email',$to,$subject,$body,'','','',$from,$from);
+ }
+ }
+
+ return $receipt;
+ }
+
+ function delete($params)
+ {
+ if (is_array($params))
+ {
+ $this->so->delete($params[0]);
+ }
+ else
+ {
+ $this->so->delete($params);
+ }
+ }
+ }
+?>
Index: property/inc/class.botts.inc.php
diff -u property/inc/class.botts.inc.php:1.14
property/inc/class.botts.inc.php:1.15
--- property/inc/class.botts.inc.php:1.14 Thu Nov 10 14:18:36 2005
+++ property/inc/class.botts.inc.php Fri Jan 27 14:05:43 2006
@@ -1,850 +1,850 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage helpdesk
- * @version $Id: class.botts.inc.php,v 1.14 2005/11/10 14:18:36 sigurdne
Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class botts
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- var $soap_functions = array(
- 'list' => array(
- 'in' =>
array('int','int','struct','string','int'),
- 'out' => array('array')
- ),
- 'read' => array(
- 'in' => array('int','struct'),
- 'out' => array('array')
- ),
- 'save' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- ),
- 'delete' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- )
- );
-
- function botts($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.sotts');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->historylog =
CreateObject($this->currentapp.'.historylog','tts');
- $this->config =
CreateObject('phpgwapi.config');
- $this->config->read_repository();
- $this->dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $user_filter =
get_var('user_filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $district_id =
get_var('district_id',array('POST','GET'));
- $allrows =
get_var('allrows',array('POST','GET'));
- $start_date =
get_var('start_date',array('POST','GET'));
- $end_date =
get_var('end_date',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(array_key_exists('query',$_POST))
- {
- $this->query = $query;
- }
- if(array_key_exists('filter',$_POST))
- {
- $this->filter = $filter;
- }
- if(array_key_exists('user_filter',$_POST))
- {
- $this->user_filter = $user_filter;
- }
- if(array_key_exists('sort',$_POST))
- {
- $this->sort = $sort;
- }
- if(array_key_exists('order',$_POST))
- {
- $this->order = $order;
- }
- if(array_key_exists('cat_id',$_POST))
- {
- $this->cat_id = $cat_id;
- }
- if(array_key_exists('district_id',$_POST))
- {
- $this->district_id = $district_id;
- }
- if(array_key_exists('allrows',$_POST) ||
array_key_exists('allrows',$_GET))
- {
- $this->allrows = $allrows;
- }
- if(array_key_exists('start_date',$_POST))
- {
- $this->start_date = $start_date;
- }
- if(array_key_exists('end_date',$_POST))
- {
- $this->end_date = $end_date;
- }
- }
-
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','fm_tts',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','fm_tts');
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->user_filter = $data['user_filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->district_id = $data['district_id'];
- $this->allrows = $data['allrows'];
- $this->start_date = $data['start_date'];
- $this->end_date = $data['end_date'];
- }
-
- function filter($data=0)
- {
- if(is_array($data))
- {
- $format =
(isset($data['format'])?$data['format']:'');
- $selected =
(isset($data['filter'])?$data['filter']:$data['default']);
- }
-
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_filter'));
- break;
- }
-
- $filters[0][id]='closed';
- $filters[0][name]=lang('Closed');
- $filters[1][id]='all';
- $filters[1][name]=lang('All');
-
- while (is_array($filters) && list(,$filter) =
each($filters))
- {
- $sel_filter = '';
- if ($filter['id']==$selected)
- {
- $sel_filter = 'selected';
- }
-
- $filter_list[] = array
- (
- 'id' => $filter['id'],
- 'name' => $filter['name'],
- 'selected' => $sel_filter
- );
- }
-
- for ($i=0;$i<count($filter_list);$i++)
- {
- if ($filter_list[$i]['selected'] != 'selected')
- {
- unset($filter_list[$i]['selected']);
- }
- }
-
- return $filter_list;
- }
-
- function get_status_list($selected)
- {
-
- $filters[0][id]='X';
- $filters[0][name]=lang('Closed');
- $filters[1][id]='O';
- $filters[1][name]=lang('Open');
-
- while (is_array($filters) && list(,$filter) =
each($filters))
- {
- $sel_filter = '';
- if ($filter['id']==$selected)
- {
- $sel_filter = 'selected';
- }
-
- $filter_list[] = array
- (
- 'id' => $filter['id'],
- 'name' => $filter['name'],
- 'selected' => $sel_filter
- );
- }
-
- for ($i=0;$i<count($filter_list);$i++)
- {
- if ($filter_list[$i]['selected'] != 'selected')
- {
- unset($filter_list[$i]['selected']);
- }
- }
-
- return $filter_list;
- }
-
-
- function get_priority_list($selected='')
- {
-
- if(!$selected)
- {
- $selected =
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['prioritydefault'];
- }
-
- $priority_comment[1]=' - '.lang('Lowest');
- $priority_comment[5]=' - '.lang('Medium');
- $priority_comment[10]=' - '.lang('Highest');
-
- for ($i=1; $i<=10; $i++)
- {
- $priorities[$i]['id'] =$i;
- $priorities[$i]['name'] =$i .
$priority_comment[$i];
- }
-
- while (is_array($priorities) && list(,$priority) =
each($priorities))
- {
- $sel_priority = '';
- if ($priority['id']==$selected)
- {
- $sel_priority = 'selected';
- }
-
- $priority_list[] = array
- (
- 'id' => $priority['id'],
- 'name' => $priority['name'],
- 'selected' => $sel_priority
- );
- }
-
- for ($i=0;$i<count($priority_list);$i++)
- {
- if ($priority_list[$i]['selected'] !=
'selected')
- {
- unset($priority_list[$i]['selected']);
- }
- }
-
-//_debug_array($priority_list);
- return $priority_list;
- }
-
- function get_category_name($cat_id)
- {
- return $this->so->get_category_name($cat_id);
- }
-
- function select_category_list($format='',$selected='')
- {
-
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
- $categories= $this->so->select_category_list();
-
- while (is_array($categories) && list(,$category) =
each($categories))
- {
- $sel_category = '';
- if ($category['id']==$selected)
- {
- $sel_category = 'selected';
- }
-
- $category_list[] = array
- (
- 'cat_id' => $category['id'],
- 'name' => $category['name'],
- 'selected' => $sel_category
- );
- }
-
- for ($i=0;$i<count($category_list);$i++)
- {
- if ($category_list[$i]['selected'] !=
'selected')
- {
- unset($category_list[$i]['selected']);
- }
- }
-
- return $category_list;
- }
-
- function read($start_date='',$end_date='')
- {
- $start_date =
$this->bocommon->date_to_timestamp($start_date);
- $end_date =
$this->bocommon->date_to_timestamp($end_date);
-
- $tickets = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' => $this->cat_id,'district_id' =>
$this->district_id,
-
'start_date'=>$start_date,'end_date'=>$end_date,
-
'allrows'=>$this->allrows,'user_filter' => $this->user_filter));
- $this->total_records = $this->so->total_records;
- $entity = $this->so->get_origin_entity_type();
-
- $this->uicols=$this->so->uicols;
- for ($i=0; $i<count($tickets); $i++)
- {
- if($tickets[$i]['assignedto'])
- {
- $tickets[$i]['assignedto'] =
$GLOBALS['phpgw']->accounts->id2name($tickets[$i]['assignedto']);
- }
- else
- {
- $tickets[$i]['assignedto'] =
$GLOBALS['phpgw']->accounts->id2name($tickets[$i]['group_id']);
- }
-
- $tickets[$i]['timestampopened'] =
$GLOBALS['phpgw']->common->show_date($tickets[$i]['entry_date'],$this->dateformat);
-
- if($tickets[$i]['finnish_date2'])
- {
-
$tickets[$i]['delay']=($tickets[$i]['finnish_date2']-$tickets[$i]['finnish_date'])/(24*3600);
-
$tickets[$i]['finnish_date']=$tickets[$i]['finnish_date2'];
- }
- $tickets[$i]['finnish_date'] =
(isset($tickets[$i]['finnish_date'])?$GLOBALS['phpgw']->common->show_date($tickets[$i]['finnish_date'],$this->dateformat):'');
-
- if ($tickets[$i]['status'] == 'X')
- {
- $history_values =
$this->historylog->return_array(array(),array('X'),'history_timestamp','DESC',$tickets[$i]['id']);
- $tickets[$i]['timestampclosed'] =
$GLOBALS['phpgw']->common->show_date($history_values[0]['datetime'],$this->dateformat);
- }
- if ($tickets[$i]['new_ticket'])
- {
- $tickets[$i]['new_ticket'] =
lang('New');
- }
-
- for ($j=0;$j<count($entity);$j++)
- {
- $tickets[$i]['child_date'][$j] =
$this->so->get_child_date($tickets[$i]['id'],$entity[$j]['type'],$entity[$j]['entity_id'],$entity[$j]['cat_id']);
- }
- }
-
-//_debug_array($tickets);
- return $tickets;
- }
-
- function read_single($id)
- {
-
- $this->so->update_view($id);
-
- $ticket = $this->so->read_single($id);
-
- $ticket['user_lid'] =
$GLOBALS['phpgw']->accounts->id2name($ticket['user_id']);
- $ticket['group_lid'] =
$GLOBALS['phpgw']->accounts->id2name($ticket['group_id']);
-
-
- if($ticket['finnish_date2'])
- {
-
$ticket['finnish_date']=$ticket['finnish_date2'];
- }
-
- if($ticket['finnish_date'])
- {
- $ticket['finnish_date'] =
$GLOBALS['phpgw']->common->show_date($ticket['finnish_date'],$this->dateformat);
- }
-
- if($ticket['location_code'])
- {
- $solocation =
CreateObject($this->currentapp.'.solocation');
- $ticket['location_data'] =
$solocation->read_single($ticket['location_code']);
- }
-//_debug_array($ticket['location_data']);
- if($ticket['p_num'])
- {
- $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
- $category =
$soadmin_entity->read_single_category($ticket['p_entity_id'],$ticket['p_cat_id']);
-
-
$ticket['p'][$ticket['p_entity_id']]['p_num']=$ticket['p_num'];
-
$ticket['p'][$ticket['p_entity_id']]['p_entity_id']=$ticket['p_entity_id'];
-
$ticket['p'][$ticket['p_entity_id']]['p_cat_id']=$ticket['p_cat_id'];
-
$ticket['p'][$ticket['p_entity_id']]['p_cat_name'] = $category['name'];
- }
-
-
- if($ticket['tenant_id']>0)
- {
-
$tenant_data=$this->bocommon->read_single_tenant($ticket['tenant_id']);
- $ticket['location_data']['tenant_id']=
$ticket['tenant_id'];
- $ticket['location_data']['contact_phone']=
$tenant_data['contact_phone'];
- $ticket['location_data']['last_name'] =
$tenant_data['last_name'];
- $ticket['location_data']['first_name'] =
$tenant_data['first_name'];
- }
- else
- {
- unset($ticket['location_data']['tenant_id']);
-
unset($ticket['location_data']['contact_phone']);
- unset($ticket['location_data']['last_name']);
- unset($ticket['location_data']['first_name']);
- }
-
-
- $history_values =
$this->historylog->return_array(array(),array('O'),'history_timestamp','DESC',$id);
- $ticket['timestampopened'] =
$GLOBALS['phpgw']->common->show_date($history_values[0]['datetime'],$this->dateformat);
- // Figure out when it was opened and last closed
-
- $history_values =
$this->historylog->return_array(array(),array('O'),'history_timestamp','ASC',$id);
- $ticket['last_opened'] =
$GLOBALS['phpgw']->common->show_date($history_values[0]['datetime']);
-
- if($ticket['status']=='X')
- {
-
- $history_values =
$this->historylog->return_array(array(),array('X'),'history_timestamp','DESC',$id);
- $ticket['timestampclosed']=
$GLOBALS['phpgw']->common->show_date($history_values[0]['datetime'],$this->dateformat);
- }
-
-
-
- $status_text = array(
- 'R' => 'Re-opened',
- 'X' => 'Closed',
- 'O' => 'Opened',
- 'A' => 'Re-assigned',
- 'G' => 'Re-assigned group',
- 'P' => 'Priority changed',
- 'T' => 'Category changed',
- 'S' => 'Subject changed',
- 'B' => 'Billing rate',
- 'H' => 'Billing hours',
- 'F' => 'finnish date'
- );
-
- $ticket['status_name'] =
lang($status_text[$ticket['status']]);
-
$ticket['assignedto_name']=$GLOBALS['phpgw']->accounts->id2name($ticket['assignedto']);
-
$ticket['user_lid']=$GLOBALS['phpgw']->accounts->id2name($ticket['user_id']);
-
$ticket['category_name']=ucfirst($this->get_category_name($ticket['cat_id']));
-
- return $ticket;
- }
-
- function read_additional_notes($id)
- {
- $history_array =
$this->historylog->return_array(array(),array('C'),'','',$id);
- $i=1;
- while (is_array($history_array) && list(,$value) =
each($history_array))
- {
- $additional_notes[] = array
- (
- 'value_count' => $i,
- 'value_date' =>
$GLOBALS['phpgw']->common->show_date($value['datetime']),
- 'value_user' => $value['owner'],
- 'value_note' =>
stripslashes(stripslashes($value['new_value'])),
- );
- $i++;
- }
-
- return $additional_notes;
- }
-
-
- function read_record_history($id)
- {
- $history_array =
$this->historylog->return_array(array('C','O'),array(),'','',$id);
- $i=0;
- while (is_array($history_array) && list(,$value) =
each($history_array))
- {
-
- $record_history[$i]['value_date'] =
$GLOBALS['phpgw']->common->show_date($value['datetime']);
- $record_history[$i]['value_user'] =
$value['owner'];
-
- switch ($value['status'])
- {
- case 'R': $type = lang('Re-opened');
break;
- case 'X': $type = lang('Closed');
break;
- case 'O': $type = lang('Opened');
break;
- case 'A': $type = lang('Re-assigned');
break;
- case 'G': $type = lang('Re-assigned
group'); break;
- case 'P': $type = lang('Priority
changed'); break;
- case 'T': $type = lang('Category
changed'); break;
- case 'S': $type = lang('Subject
changed'); break;
- case 'H': $type = lang('Billable hours
changed'); break;
- case 'B': $type = lang('Billable rate
changed'); break;
- case 'F': $type = lang('finnish date
changed'); break;
- case 'IF': $type = lang('Initial
finnish date'); break;
- default: break;
- }
-
-
if($value['new_value']=='O'){$value['new_value']=lang('Opened');}
-
if($value['new_value']=='X'){$value['new_value']=lang('Closed');}
-
-
- $record_history[$i]['value_action'] =
$type?$type:'';
- unset($type);
- if ($value['status'] == 'A' || $value['status']
== 'G')
- {
- if ((int)$value['new_value']>0)
- {
-
$record_history[$i]['value_new_value'] =
$GLOBALS['phpgw']->accounts->id2name($value['new_value']);
- }
- else
- {
-
$record_history[$i]['value_new_value'] = lang('None');
-
- }
- }
- else if ($value['status'] == 'T')
- {
- $record_history[$i]['value_new_value']
= $this->get_category_name($value['new_value']);
- }
- else if (($value['status'] == 'F') ||
($value['status'] =='IF'))
- {
- $record_history[$i]['value_new_value']
= $GLOBALS['phpgw']->common->show_date($value['new_value'],$this->dateformat);
- }
- else if ($value['status'] != 'O' &&
$value['new_value'])
- {
- $record_history[$i]['value_new_value']
= $value['new_value'];
- }
- else
- {
- $record_history[$i]['value_new_value']
= '';
- }
-
- $i++;
- }
-
- return $record_history;
- }
-
- function add($ticket)
- {
- while (is_array($ticket['location']) && list(,$value) =
each($ticket['location']))
- {
- if($value)
- {
- $location[] = $value;
- }
- }
-
- $ticket['finnish_date'] =
$this->bocommon->date_to_timestamp($ticket['finnish_date']);
- $ticket['location_code']=implode("-", $location);
-
- $receipt = $this->so->add($ticket);
-
- $this->config->read_repository();
-
- if ($this->config->config_data['mailnotification'] &&
$ticket['send_mail'])
- {
- $receipt =
$this->mail_ticket($receipt['id'],$fields_updated,$receipt,$ticket['location_code']);
- }
-
- return $receipt;
- }
-
-
- function
mail_ticket($id,$fields_updated,$receipt=0,$location_code='')
- {
- $this->send =
CreateObject('phpgwapi.send');
-
- $members = array();
-
- $ticket = $this->so->read_single($id);
-
- if($ticket['location_code'])
- {
-
- $solocation =
CreateObject($this->currentapp.'.solocation');
- $soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
- $location_data =
$solocation->read_single($ticket['location_code']);
-
-
$type_id=count(explode('-',$ticket['location_code']));
- $fm_location_cols =
$soadmin_location->read_attrib(array('type_id'=>$type_id,'lookup_type'=>$type_id));
- $i=0;
- if (isset($fm_location_cols) AND
is_array($fm_location_cols))
- {
- foreach($fm_location_cols as
$location_entry)
- {
-
if($location_entry['lookup_form'])
- {
-
$address_element[$i]['text']=$location_entry['input_text'];
-
$address_element[$i]['value']=$location_data[$location_entry['column_name']];
- }
- $i++;
- }
- }
- }
-
- $history_values =
$this->historylog->return_array(array(),array('O'),'history_timestamp','DESC',$id);
- $timestampopened =
$GLOBALS['phpgw']->common->show_date($history_values[0]['datetime'],$this->dateformat);
-
- if($ticket['status']=='X')
- {
- $history_values =
$this->historylog->return_array(array(),array('X'),'history_timestamp','DESC',$id);
- $timestampclosed =
$GLOBALS['phpgw']->common->show_date($history_values[0]['datetime'],$this->dateformat);
- }
-
- $history_2 =
$this->historylog->return_array(array('C','O'),array(),'','',$id);
- $m=count($history_2)-1;
- $ticket['status']=$history_2[$m]['status'];
-
- $stat = $ticket['status'];
- $status = array(
- 'R' => 'Re-opened',
- 'X' => 'Closed',
- 'O' => 'Opened',
- 'A' => 'Re-assigned',
- 'G' => 'Re-assigned group',
- 'P' => 'Priority changed',
- 'T' => 'Category changed',
- 'S' => 'Subject changed',
- 'B' => 'Billing rate',
- 'H' => 'Billing hours',
- 'F' => 'finnish date changed'
- );
-
-
- $group_name=
$GLOBALS['phpgw']->accounts->id2name($ticket['group_id']);
-
- // build subject
- $subject = '['.lang('Ticket').' #'.$id.'] : ' .
$location_code .' ' .$this->get_category_name($ticket['cat_id']) . '; '
.$ticket['subject'];
-
-
- // $prefs_user =
$GLOBALS['phpgw']->preferences->create_email_preferences($ticket['user_id']);
- $prefs_user =
$this->bocommon->create_preferences($this->currentapp,$ticket['user_id']);
-
- $from_address=$prefs_user['email'];
-
- //-----------from--------
-
-
$current_user_id=$GLOBALS['phpgw_info']['user']['account_id'];
-
- $current_user_firstname =
$GLOBALS['phpgw_info']['user']['firstname'];
-
- $current_user_lastname
=$GLOBALS['phpgw_info']['user']['lastname'];
-
- $current_user_name= $user_firstname . " "
.$user_lastname ;
-
-// $current_prefs_user =
$GLOBALS['phpgw']->preferences->create_email_preferences($current_user_id);
- $current_prefs_user =
$this->bocommon->create_preferences($this->currentapp,$current_user_id);
- $current_user_address=$current_prefs_user['email'];
-
- $headers = "Return-Path: <". $current_user_address
.">\r\n";
- $headers .= "From: " . $current_user_name . "<" .
$current_user_address .">\r\n";
- $headers .= "Bcc: " . $current_user_name . "<" .
$current_user_address .">\r\n";
- $headers .= "Content-type: text/html;
charset=iso-8859-1\r\n";
- $headers .= "MIME-Version: 1.0\r\n";
-
- //-----------from--------
- // build body
- $body = '';
- $body .= lang('Ticket').' #'.$id."\n";
- $body .= lang('Date Opened').': '.$timestampopened."\n";
- $body .= lang('Category').': '.
$this->get_category_name($ticket['cat_id']) ."\n";
-// $body .= lang('Subject').': '. $ticket['subject'] ."\n";
- $body .= lang('Location').': '.
$ticket['location_code'] ."\n";
- $body .= lang('Address').': '. $ticket['address'] ."\n";
- if (isset($address_element) AND
is_array($address_element))
- {
- foreach($address_element as $address_entry)
- {
- $body .= $address_entry['text'].': '.
$address_entry['value'] ."\n";
- }
- }
-
- if($ticket['tenant_id'])
- {
-
$tenant_data=$this->bocommon->read_single_tenant($ticket['tenant_id']);
- $body .= lang('Tenant').': '.
$tenant_data['first_name'] . ' ' .$tenant_data['last_name'] ."\n";
-
- if($tenant_data['contact_phone'])
- {
- $body .= lang('Contact phone').': '.
$tenant_data['contact_phone'] ."\n";
-
- }
- }
- $body .= lang('Assigned To').':
'.$GLOBALS['phpgw']->accounts->id2name($ticket['assignedto'])."\n";
- $body .= lang('Priority').': '.$ticket['priority']."\n";
- if($group_name)
- {
- $body .= lang('Group').': '. $group_name ."\n";
- }
- $body .= lang('Opened By').': '. $ticket['user_name']
."\n\n";
- $body .= lang('First Note Added').":\n";
- $body .=
stripslashes(strip_tags($ticket['details']))."\n\n";
-
-
/**************************************************************\
- * Display additional notes
*
-
\**************************************************************/
- if($fields_updated)
- {
- $i=1;
-
- $history_array =
$this->historylog->return_array(array(),array('C'),'','',$id);
- while (is_array($history_array) &&
list(,$value) = each($history_array))
- {
- $body .= lang('Date') . ':
'.$GLOBALS['phpgw']->common->show_date($value['datetime'])."\n";
- $body .= lang('User') . ':
'.$value['owner']."\n";
- $body .=lang('Note').': '.
nl2br(stripslashes($value['new_value']))."\n\n";
- $i++;
- }
- $subject.= "-" .$i;
- }
-
-
/**************************************************************\
- * Display record history
*
-
\**************************************************************/
-
- if($timestampclosed)
- {
- $body .= lang('Date Closed').':
'.$timestampclosed."\n\n";
- }
-
- if ($this->config->config_data['groupnotification'])
- {
- // select group recipients
- $members =
$GLOBALS['phpgw']->accounts->member($ticket['group_id']);
- }
-
- if ($this->config->config_data['ownernotification'])
- {
- // add owner to recipients
- $members[] = array('account_id' =>
$ticket['user_id'], 'account_name' =>
$GLOBALS['phpgw']->accounts->id2name($ticket['user_id']));
- }
-
- if ($this->config->config_data['assignednotification'])
- {
- // add assigned to recipients
- $members[] = array('account_id' =>
$ticket['assignedto'], 'account_name' =>
$GLOBALS['phpgw']->accounts->id2name($ticket['assignedto']));
- }
-
- $error = Array();
- $toarray = Array();
- $i=0;
- for ($i=0;$i<count($members);$i++)
- {
- if ($members[$i]['account_id'])
- {
- // $prefs =
$GLOBALS['phpgw']->preferences->create_email_preferences($members[$i]['account_id']);
- $prefs =
$this->bocommon->create_preferences($this->currentapp,$members[$i]['account_id']);
- if (strlen($prefs['email'])>
(strlen($members[$i]['account_name'])+1))
- {
- $toarray[$prefs['email']] =
$prefs['email'];
- }
- else
- {
- $receipt['error'][] =
array('msg'=> lang('Your message could not be sent!'));
- $receipt['error'][] =
array('msg'=>lang('This user has not defined an email address !') . ' : ' .
$members[$i]['account_name']);
- }
- }
- }
-
- if(count($toarray) > 1)
- {
- $to = implode(',',$toarray);
- }
- else
- {
- $to = current($toarray);
- }
-
- $mail_method=
$this->config->config_data['fmwrkorder_mail'];
-// echo 'mail_method: '.$mail_method .'<BR>';
-
- if ($mail_method=='smtp'):
- {
- $rc = $this->send->msg('email', $to, $subject,
stripslashes($body), '', $cc,
$bcc,$current_user_address,$current_user_name,'txt');
- }
- elseif ($mail_method=='sendmail'):
- {
- $rc= @mail($to,$subject,stripslashes($body),
$headers);
- }
- else:
- {
- $receipt['error'][] = array('msg'=>
lang('Mailing method is not chosen! (admin section)'));
- }
- endif;
-
- // $rc=1;
- if (!$rc &&
($this->config->config_data['groupnotification'] ||
$this->config->config_data['ownernotification'] ||
$this->config->config_data['groupnotification']))
- {
- $receipt['error'][] = array('msg'=> lang('Your
message could not be sent by mail!'));
- $receipt['error'][] = array('msg'=> lang('The
mail server returned'));
- $receipt['error'][] = array('msg'=> 'From :' .
$current_user_name . '<' . $current_user_address .'>');
- $receipt['error'][] = array('msg'=> 'to: '.$to);
- $receipt['error'][] = array('msg'=> 'subject:
'.$subject);
- $receipt['error'][] = array('msg'=> $body );
- // $receipt['error'][] = array('msg'=> 'cc: ' .
$cc);
- // $receipt['error'][] = array('msg'=> 'bcc:
'.$bcc);
- $receipt['error'][] = array('msg'=> 'group:
'.$group_name);
- $receipt['error'][] = array('msg'=> 'err_code:
'.$this->send->err['code']);
- $receipt['error'][] = array('msg'=> 'err_msg:
'. htmlspecialchars($this->send->err['msg']));
- $receipt['error'][] = array('msg'=> 'err_desc:
'. $GLOBALS['phpgw']->err['desc']);
- }
-
-//_debug_array($receipt);
- return $receipt;
- }
-
-
- function delete($id)
- {
- $this->so->delete($id);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage helpdesk
+ * @version $Id: class.botts.inc.php,v 1.15 2006/01/27 14:05:43 sigurdne
Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class botts
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ var $soap_functions = array(
+ 'list' => array(
+ 'in' =>
array('int','int','struct','string','int'),
+ 'out' => array('array')
+ ),
+ 'read' => array(
+ 'in' => array('int','struct'),
+ 'out' => array('array')
+ ),
+ 'save' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ ),
+ 'delete' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ )
+ );
+
+ function botts($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.sotts');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->historylog =
CreateObject($this->currentapp.'.historylog','tts');
+ $this->config =
CreateObject('phpgwapi.config');
+ $this->config->read_repository();
+ $this->dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $user_filter =
get_var('user_filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $district_id =
get_var('district_id',array('POST','GET'));
+ $allrows =
get_var('allrows',array('POST','GET'));
+ $start_date =
get_var('start_date',array('POST','GET'));
+ $end_date =
get_var('end_date',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(array_key_exists('query',$_POST))
+ {
+ $this->query = $query;
+ }
+ if(array_key_exists('filter',$_POST))
+ {
+ $this->filter = $filter;
+ }
+ if(array_key_exists('user_filter',$_POST))
+ {
+ $this->user_filter = $user_filter;
+ }
+ if(array_key_exists('sort',$_POST))
+ {
+ $this->sort = $sort;
+ }
+ if(array_key_exists('order',$_POST))
+ {
+ $this->order = $order;
+ }
+ if(array_key_exists('cat_id',$_POST))
+ {
+ $this->cat_id = $cat_id;
+ }
+ if(array_key_exists('district_id',$_POST))
+ {
+ $this->district_id = $district_id;
+ }
+ if(array_key_exists('allrows',$_POST) ||
array_key_exists('allrows',$_GET))
+ {
+ $this->allrows = $allrows;
+ }
+ if(array_key_exists('start_date',$_POST))
+ {
+ $this->start_date = $start_date;
+ }
+ if(array_key_exists('end_date',$_POST))
+ {
+ $this->end_date = $end_date;
+ }
+ }
+
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','fm_tts',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','fm_tts');
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->user_filter = $data['user_filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->district_id = $data['district_id'];
+ $this->allrows = $data['allrows'];
+ $this->start_date = $data['start_date'];
+ $this->end_date = $data['end_date'];
+ }
+
+ function filter($data=0)
+ {
+ if(is_array($data))
+ {
+ $format =
(isset($data['format'])?$data['format']:'');
+ $selected =
(isset($data['filter'])?$data['filter']:$data['default']);
+ }
+
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_filter'));
+ break;
+ }
+
+ $filters[0][id]='closed';
+ $filters[0][name]=lang('Closed');
+ $filters[1][id]='all';
+ $filters[1][name]=lang('All');
+
+ while (is_array($filters) && list(,$filter) =
each($filters))
+ {
+ $sel_filter = '';
+ if ($filter['id']==$selected)
+ {
+ $sel_filter = 'selected';
+ }
+
+ $filter_list[] = array
+ (
+ 'id' => $filter['id'],
+ 'name' => $filter['name'],
+ 'selected' => $sel_filter
+ );
+ }
+
+ for ($i=0;$i<count($filter_list);$i++)
+ {
+ if ($filter_list[$i]['selected'] != 'selected')
+ {
+ unset($filter_list[$i]['selected']);
+ }
+ }
+
+ return $filter_list;
+ }
+
+ function get_status_list($selected)
+ {
+
+ $filters[0][id]='X';
+ $filters[0][name]=lang('Closed');
+ $filters[1][id]='O';
+ $filters[1][name]=lang('Open');
+
+ while (is_array($filters) && list(,$filter) =
each($filters))
+ {
+ $sel_filter = '';
+ if ($filter['id']==$selected)
+ {
+ $sel_filter = 'selected';
+ }
+
+ $filter_list[] = array
+ (
+ 'id' => $filter['id'],
+ 'name' => $filter['name'],
+ 'selected' => $sel_filter
+ );
+ }
+
+ for ($i=0;$i<count($filter_list);$i++)
+ {
+ if ($filter_list[$i]['selected'] != 'selected')
+ {
+ unset($filter_list[$i]['selected']);
+ }
+ }
+
+ return $filter_list;
+ }
+
+
+ function get_priority_list($selected='')
+ {
+
+ if(!$selected)
+ {
+ $selected =
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['prioritydefault'];
+ }
+
+ $priority_comment[1]=' - '.lang('Lowest');
+ $priority_comment[5]=' - '.lang('Medium');
+ $priority_comment[10]=' - '.lang('Highest');
+
+ for ($i=1; $i<=10; $i++)
+ {
+ $priorities[$i]['id'] =$i;
+ $priorities[$i]['name'] =$i .
$priority_comment[$i];
+ }
+
+ while (is_array($priorities) && list(,$priority) =
each($priorities))
+ {
+ $sel_priority = '';
+ if ($priority['id']==$selected)
+ {
+ $sel_priority = 'selected';
+ }
+
+ $priority_list[] = array
+ (
+ 'id' => $priority['id'],
+ 'name' => $priority['name'],
+ 'selected' => $sel_priority
+ );
+ }
+
+ for ($i=0;$i<count($priority_list);$i++)
+ {
+ if ($priority_list[$i]['selected'] !=
'selected')
+ {
+ unset($priority_list[$i]['selected']);
+ }
+ }
+
+//_debug_array($priority_list);
+ return $priority_list;
+ }
+
+ function get_category_name($cat_id)
+ {
+ return $this->so->get_category_name($cat_id);
+ }
+
+ function select_category_list($format='',$selected='')
+ {
+
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ break;
+ }
+
+ $categories= $this->so->select_category_list();
+
+ while (is_array($categories) && list(,$category) =
each($categories))
+ {
+ $sel_category = '';
+ if ($category['id']==$selected)
+ {
+ $sel_category = 'selected';
+ }
+
+ $category_list[] = array
+ (
+ 'cat_id' => $category['id'],
+ 'name' => $category['name'],
+ 'selected' => $sel_category
+ );
+ }
+
+ for ($i=0;$i<count($category_list);$i++)
+ {
+ if ($category_list[$i]['selected'] !=
'selected')
+ {
+ unset($category_list[$i]['selected']);
+ }
+ }
+
+ return $category_list;
+ }
+
+ function read($start_date='',$end_date='')
+ {
+ $start_date =
$this->bocommon->date_to_timestamp($start_date);
+ $end_date =
$this->bocommon->date_to_timestamp($end_date);
+
+ $tickets = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' => $this->cat_id,'district_id' =>
$this->district_id,
+
'start_date'=>$start_date,'end_date'=>$end_date,
+
'allrows'=>$this->allrows,'user_filter' => $this->user_filter));
+ $this->total_records = $this->so->total_records;
+ $entity = $this->so->get_origin_entity_type();
+
+ $this->uicols=$this->so->uicols;
+ for ($i=0; $i<count($tickets); $i++)
+ {
+ if($tickets[$i]['assignedto'])
+ {
+ $tickets[$i]['assignedto'] =
$GLOBALS['phpgw']->accounts->id2name($tickets[$i]['assignedto']);
+ }
+ else
+ {
+ $tickets[$i]['assignedto'] =
$GLOBALS['phpgw']->accounts->id2name($tickets[$i]['group_id']);
+ }
+
+ $tickets[$i]['timestampopened'] =
$GLOBALS['phpgw']->common->show_date($tickets[$i]['entry_date'],$this->dateformat);
+
+ if($tickets[$i]['finnish_date2'])
+ {
+
$tickets[$i]['delay']=($tickets[$i]['finnish_date2']-$tickets[$i]['finnish_date'])/(24*3600);
+
$tickets[$i]['finnish_date']=$tickets[$i]['finnish_date2'];
+ }
+ $tickets[$i]['finnish_date'] =
(isset($tickets[$i]['finnish_date'])?$GLOBALS['phpgw']->common->show_date($tickets[$i]['finnish_date'],$this->dateformat):'');
+
+ if ($tickets[$i]['status'] == 'X')
+ {
+ $history_values =
$this->historylog->return_array(array(),array('X'),'history_timestamp','DESC',$tickets[$i]['id']);
+ $tickets[$i]['timestampclosed'] =
$GLOBALS['phpgw']->common->show_date($history_values[0]['datetime'],$this->dateformat);
+ }
+ if ($tickets[$i]['new_ticket'])
+ {
+ $tickets[$i]['new_ticket'] =
lang('New');
+ }
+
+ for ($j=0;$j<count($entity);$j++)
+ {
+ $tickets[$i]['child_date'][$j] =
$this->so->get_child_date($tickets[$i]['id'],$entity[$j]['type'],$entity[$j]['entity_id'],$entity[$j]['cat_id']);
+ }
+ }
+
+//_debug_array($tickets);
+ return $tickets;
+ }
+
+ function read_single($id)
+ {
+
+ $this->so->update_view($id);
+
+ $ticket = $this->so->read_single($id);
+
+ $ticket['user_lid'] =
$GLOBALS['phpgw']->accounts->id2name($ticket['user_id']);
+ $ticket['group_lid'] =
$GLOBALS['phpgw']->accounts->id2name($ticket['group_id']);
+
+
+ if($ticket['finnish_date2'])
+ {
+
$ticket['finnish_date']=$ticket['finnish_date2'];
+ }
+
+ if($ticket['finnish_date'])
+ {
+ $ticket['finnish_date'] =
$GLOBALS['phpgw']->common->show_date($ticket['finnish_date'],$this->dateformat);
+ }
+
+ if($ticket['location_code'])
+ {
+ $solocation =
CreateObject($this->currentapp.'.solocation');
+ $ticket['location_data'] =
$solocation->read_single($ticket['location_code']);
+ }
+//_debug_array($ticket['location_data']);
+ if($ticket['p_num'])
+ {
+ $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
+ $category =
$soadmin_entity->read_single_category($ticket['p_entity_id'],$ticket['p_cat_id']);
+
+
$ticket['p'][$ticket['p_entity_id']]['p_num']=$ticket['p_num'];
+
$ticket['p'][$ticket['p_entity_id']]['p_entity_id']=$ticket['p_entity_id'];
+
$ticket['p'][$ticket['p_entity_id']]['p_cat_id']=$ticket['p_cat_id'];
+
$ticket['p'][$ticket['p_entity_id']]['p_cat_name'] = $category['name'];
+ }
+
+
+ if($ticket['tenant_id']>0)
+ {
+
$tenant_data=$this->bocommon->read_single_tenant($ticket['tenant_id']);
+ $ticket['location_data']['tenant_id']=
$ticket['tenant_id'];
+ $ticket['location_data']['contact_phone']=
$tenant_data['contact_phone'];
+ $ticket['location_data']['last_name'] =
$tenant_data['last_name'];
+ $ticket['location_data']['first_name'] =
$tenant_data['first_name'];
+ }
+ else
+ {
+ unset($ticket['location_data']['tenant_id']);
+
unset($ticket['location_data']['contact_phone']);
+ unset($ticket['location_data']['last_name']);
+ unset($ticket['location_data']['first_name']);
+ }
+
+
+ $history_values =
$this->historylog->return_array(array(),array('O'),'history_timestamp','DESC',$id);
+ $ticket['timestampopened'] =
$GLOBALS['phpgw']->common->show_date($history_values[0]['datetime'],$this->dateformat);
+ // Figure out when it was opened and last closed
+
+ $history_values =
$this->historylog->return_array(array(),array('O'),'history_timestamp','ASC',$id);
+ $ticket['last_opened'] =
$GLOBALS['phpgw']->common->show_date($history_values[0]['datetime']);
+
+ if($ticket['status']=='X')
+ {
+
+ $history_values =
$this->historylog->return_array(array(),array('X'),'history_timestamp','DESC',$id);
+ $ticket['timestampclosed']=
$GLOBALS['phpgw']->common->show_date($history_values[0]['datetime'],$this->dateformat);
+ }
+
+
+
+ $status_text = array(
+ 'R' => 'Re-opened',
+ 'X' => 'Closed',
+ 'O' => 'Opened',
+ 'A' => 'Re-assigned',
+ 'G' => 'Re-assigned group',
+ 'P' => 'Priority changed',
+ 'T' => 'Category changed',
+ 'S' => 'Subject changed',
+ 'B' => 'Billing rate',
+ 'H' => 'Billing hours',
+ 'F' => 'finnish date'
+ );
+
+ $ticket['status_name'] =
lang($status_text[$ticket['status']]);
+
$ticket['assignedto_name']=$GLOBALS['phpgw']->accounts->id2name($ticket['assignedto']);
+
$ticket['user_lid']=$GLOBALS['phpgw']->accounts->id2name($ticket['user_id']);
+
$ticket['category_name']=ucfirst($this->get_category_name($ticket['cat_id']));
+
+ return $ticket;
+ }
+
+ function read_additional_notes($id)
+ {
+ $history_array =
$this->historylog->return_array(array(),array('C'),'','',$id);
+ $i=1;
+ while (is_array($history_array) && list(,$value) =
each($history_array))
+ {
+ $additional_notes[] = array
+ (
+ 'value_count' => $i,
+ 'value_date' =>
$GLOBALS['phpgw']->common->show_date($value['datetime']),
+ 'value_user' => $value['owner'],
+ 'value_note' =>
stripslashes(stripslashes($value['new_value'])),
+ );
+ $i++;
+ }
+
+ return $additional_notes;
+ }
+
+
+ function read_record_history($id)
+ {
+ $history_array =
$this->historylog->return_array(array('C','O'),array(),'','',$id);
+ $i=0;
+ while (is_array($history_array) && list(,$value) =
each($history_array))
+ {
+
+ $record_history[$i]['value_date'] =
$GLOBALS['phpgw']->common->show_date($value['datetime']);
+ $record_history[$i]['value_user'] =
$value['owner'];
+
+ switch ($value['status'])
+ {
+ case 'R': $type = lang('Re-opened');
break;
+ case 'X': $type = lang('Closed');
break;
+ case 'O': $type = lang('Opened');
break;
+ case 'A': $type = lang('Re-assigned');
break;
+ case 'G': $type = lang('Re-assigned
group'); break;
+ case 'P': $type = lang('Priority
changed'); break;
+ case 'T': $type = lang('Category
changed'); break;
+ case 'S': $type = lang('Subject
changed'); break;
+ case 'H': $type = lang('Billable hours
changed'); break;
+ case 'B': $type = lang('Billable rate
changed'); break;
+ case 'F': $type = lang('finnish date
changed'); break;
+ case 'IF': $type = lang('Initial
finnish date'); break;
+ default: break;
+ }
+
+
if($value['new_value']=='O'){$value['new_value']=lang('Opened');}
+
if($value['new_value']=='X'){$value['new_value']=lang('Closed');}
+
+
+ $record_history[$i]['value_action'] =
$type?$type:'';
+ unset($type);
+ if ($value['status'] == 'A' || $value['status']
== 'G')
+ {
+ if ((int)$value['new_value']>0)
+ {
+
$record_history[$i]['value_new_value'] =
$GLOBALS['phpgw']->accounts->id2name($value['new_value']);
+ }
+ else
+ {
+
$record_history[$i]['value_new_value'] = lang('None');
+
+ }
+ }
+ else if ($value['status'] == 'T')
+ {
+ $record_history[$i]['value_new_value']
= $this->get_category_name($value['new_value']);
+ }
+ else if (($value['status'] == 'F') ||
($value['status'] =='IF'))
+ {
+ $record_history[$i]['value_new_value']
= $GLOBALS['phpgw']->common->show_date($value['new_value'],$this->dateformat);
+ }
+ else if ($value['status'] != 'O' &&
$value['new_value'])
+ {
+ $record_history[$i]['value_new_value']
= $value['new_value'];
+ }
+ else
+ {
+ $record_history[$i]['value_new_value']
= '';
+ }
+
+ $i++;
+ }
+
+ return $record_history;
+ }
+
+ function add($ticket)
+ {
+ while (is_array($ticket['location']) && list(,$value) =
each($ticket['location']))
+ {
+ if($value)
+ {
+ $location[] = $value;
+ }
+ }
+
+ $ticket['finnish_date'] =
$this->bocommon->date_to_timestamp($ticket['finnish_date']);
+ $ticket['location_code']=implode("-", $location);
+
+ $receipt = $this->so->add($ticket);
+
+ $this->config->read_repository();
+
+ if ($this->config->config_data['mailnotification'] &&
$ticket['send_mail'])
+ {
+ $receipt =
$this->mail_ticket($receipt['id'],$fields_updated,$receipt,$ticket['location_code']);
+ }
+
+ return $receipt;
+ }
+
+
+ function
mail_ticket($id,$fields_updated,$receipt=0,$location_code='')
+ {
+ $this->send =
CreateObject('phpgwapi.send');
+
+ $members = array();
+
+ $ticket = $this->so->read_single($id);
+
+ if($ticket['location_code'])
+ {
+
+ $solocation =
CreateObject($this->currentapp.'.solocation');
+ $soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
+ $location_data =
$solocation->read_single($ticket['location_code']);
+
+
$type_id=count(explode('-',$ticket['location_code']));
+ $fm_location_cols =
$soadmin_location->read_attrib(array('type_id'=>$type_id,'lookup_type'=>$type_id));
+ $i=0;
+ if (isset($fm_location_cols) AND
is_array($fm_location_cols))
+ {
+ foreach($fm_location_cols as
$location_entry)
+ {
+
if($location_entry['lookup_form'])
+ {
+
$address_element[$i]['text']=$location_entry['input_text'];
+
$address_element[$i]['value']=$location_data[$location_entry['column_name']];
+ }
+ $i++;
+ }
+ }
+ }
+
+ $history_values =
$this->historylog->return_array(array(),array('O'),'history_timestamp','DESC',$id);
+ $timestampopened =
$GLOBALS['phpgw']->common->show_date($history_values[0]['datetime'],$this->dateformat);
+
+ if($ticket['status']=='X')
+ {
+ $history_values =
$this->historylog->return_array(array(),array('X'),'history_timestamp','DESC',$id);
+ $timestampclosed =
$GLOBALS['phpgw']->common->show_date($history_values[0]['datetime'],$this->dateformat);
+ }
+
+ $history_2 =
$this->historylog->return_array(array('C','O'),array(),'','',$id);
+ $m=count($history_2)-1;
+ $ticket['status']=$history_2[$m]['status'];
+
+ $stat = $ticket['status'];
+ $status = array(
+ 'R' => 'Re-opened',
+ 'X' => 'Closed',
+ 'O' => 'Opened',
+ 'A' => 'Re-assigned',
+ 'G' => 'Re-assigned group',
+ 'P' => 'Priority changed',
+ 'T' => 'Category changed',
+ 'S' => 'Subject changed',
+ 'B' => 'Billing rate',
+ 'H' => 'Billing hours',
+ 'F' => 'finnish date changed'
+ );
+
+
+ $group_name=
$GLOBALS['phpgw']->accounts->id2name($ticket['group_id']);
+
+ // build subject
+ $subject = '['.lang('Ticket').' #'.$id.'] : ' .
$location_code .' ' .$this->get_category_name($ticket['cat_id']) . '; '
.$ticket['subject'];
+
+
+ // $prefs_user =
$GLOBALS['phpgw']->preferences->create_email_preferences($ticket['user_id']);
+ $prefs_user =
$this->bocommon->create_preferences($this->currentapp,$ticket['user_id']);
+
+ $from_address=$prefs_user['email'];
+
+ //-----------from--------
+
+
$current_user_id=$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $current_user_firstname =
$GLOBALS['phpgw_info']['user']['firstname'];
+
+ $current_user_lastname
=$GLOBALS['phpgw_info']['user']['lastname'];
+
+ $current_user_name= $user_firstname . " "
.$user_lastname ;
+
+// $current_prefs_user =
$GLOBALS['phpgw']->preferences->create_email_preferences($current_user_id);
+ $current_prefs_user =
$this->bocommon->create_preferences($this->currentapp,$current_user_id);
+ $current_user_address=$current_prefs_user['email'];
+
+ $headers = "Return-Path: <". $current_user_address
.">\r\n";
+ $headers .= "From: " . $current_user_name . "<" .
$current_user_address .">\r\n";
+ $headers .= "Bcc: " . $current_user_name . "<" .
$current_user_address .">\r\n";
+ $headers .= "Content-type: text/html;
charset=iso-8859-1\r\n";
+ $headers .= "MIME-Version: 1.0\r\n";
+
+ //-----------from--------
+ // build body
+ $body = '';
+ $body .= lang('Ticket').' #'.$id."\n";
+ $body .= lang('Date Opened').': '.$timestampopened."\n";
+ $body .= lang('Category').': '.
$this->get_category_name($ticket['cat_id']) ."\n";
+// $body .= lang('Subject').': '. $ticket['subject'] ."\n";
+ $body .= lang('Location').': '.
$ticket['location_code'] ."\n";
+ $body .= lang('Address').': '. $ticket['address'] ."\n";
+ if (isset($address_element) AND
is_array($address_element))
+ {
+ foreach($address_element as $address_entry)
+ {
+ $body .= $address_entry['text'].': '.
$address_entry['value'] ."\n";
+ }
+ }
+
+ if($ticket['tenant_id'])
+ {
+
$tenant_data=$this->bocommon->read_single_tenant($ticket['tenant_id']);
+ $body .= lang('Tenant').': '.
$tenant_data['first_name'] . ' ' .$tenant_data['last_name'] ."\n";
+
+ if($tenant_data['contact_phone'])
+ {
+ $body .= lang('Contact phone').': '.
$tenant_data['contact_phone'] ."\n";
+
+ }
+ }
+ $body .= lang('Assigned To').':
'.$GLOBALS['phpgw']->accounts->id2name($ticket['assignedto'])."\n";
+ $body .= lang('Priority').': '.$ticket['priority']."\n";
+ if($group_name)
+ {
+ $body .= lang('Group').': '. $group_name ."\n";
+ }
+ $body .= lang('Opened By').': '. $ticket['user_name']
."\n\n";
+ $body .= lang('First Note Added').":\n";
+ $body .=
stripslashes(strip_tags($ticket['details']))."\n\n";
+
+
/**************************************************************\
+ * Display additional notes
*
+
\**************************************************************/
+ if($fields_updated)
+ {
+ $i=1;
+
+ $history_array =
$this->historylog->return_array(array(),array('C'),'','',$id);
+ while (is_array($history_array) &&
list(,$value) = each($history_array))
+ {
+ $body .= lang('Date') . ':
'.$GLOBALS['phpgw']->common->show_date($value['datetime'])."\n";
+ $body .= lang('User') . ':
'.$value['owner']."\n";
+ $body .=lang('Note').': '.
nl2br(stripslashes($value['new_value']))."\n\n";
+ $i++;
+ }
+ $subject.= "-" .$i;
+ }
+
+
/**************************************************************\
+ * Display record history
*
+
\**************************************************************/
+
+ if($timestampclosed)
+ {
+ $body .= lang('Date Closed').':
'.$timestampclosed."\n\n";
+ }
+
+ if ($this->config->config_data['groupnotification'])
+ {
+ // select group recipients
+ $members =
$GLOBALS['phpgw']->accounts->member($ticket['group_id']);
+ }
+
+ if ($this->config->config_data['ownernotification'])
+ {
+ // add owner to recipients
+ $members[] = array('account_id' =>
$ticket['user_id'], 'account_name' =>
$GLOBALS['phpgw']->accounts->id2name($ticket['user_id']));
+ }
+
+ if ($this->config->config_data['assignednotification'])
+ {
+ // add assigned to recipients
+ $members[] = array('account_id' =>
$ticket['assignedto'], 'account_name' =>
$GLOBALS['phpgw']->accounts->id2name($ticket['assignedto']));
+ }
+
+ $error = Array();
+ $toarray = Array();
+ $i=0;
+ for ($i=0;$i<count($members);$i++)
+ {
+ if ($members[$i]['account_id'])
+ {
+ // $prefs =
$GLOBALS['phpgw']->preferences->create_email_preferences($members[$i]['account_id']);
+ $prefs =
$this->bocommon->create_preferences($this->currentapp,$members[$i]['account_id']);
+ if (strlen($prefs['email'])>
(strlen($members[$i]['account_name'])+1))
+ {
+ $toarray[$prefs['email']] =
$prefs['email'];
+ }
+ else
+ {
+ $receipt['error'][] =
array('msg'=> lang('Your message could not be sent!'));
+ $receipt['error'][] =
array('msg'=>lang('This user has not defined an email address !') . ' : ' .
$members[$i]['account_name']);
+ }
+ }
+ }
+
+ if(count($toarray) > 1)
+ {
+ $to = implode(',',$toarray);
+ }
+ else
+ {
+ $to = current($toarray);
+ }
+
+ $mail_method=
$this->config->config_data['fmwrkorder_mail'];
+// echo 'mail_method: '.$mail_method .'<BR>';
+
+ if ($mail_method=='smtp'):
+ {
+ $rc = $this->send->msg('email', $to, $subject,
stripslashes($body), '', $cc,
$bcc,$current_user_address,$current_user_name,'txt');
+ }
+ elseif ($mail_method=='sendmail'):
+ {
+ $rc= @mail($to,$subject,stripslashes($body),
$headers);
+ }
+ else:
+ {
+ $receipt['error'][] = array('msg'=>
lang('Mailing method is not chosen! (admin section)'));
+ }
+ endif;
+
+ // $rc=1;
+ if (!$rc &&
($this->config->config_data['groupnotification'] ||
$this->config->config_data['ownernotification'] ||
$this->config->config_data['groupnotification']))
+ {
+ $receipt['error'][] = array('msg'=> lang('Your
message could not be sent by mail!'));
+ $receipt['error'][] = array('msg'=> lang('The
mail server returned'));
+ $receipt['error'][] = array('msg'=> 'From :' .
$current_user_name . '<' . $current_user_address .'>');
+ $receipt['error'][] = array('msg'=> 'to: '.$to);
+ $receipt['error'][] = array('msg'=> 'subject:
'.$subject);
+ $receipt['error'][] = array('msg'=> $body );
+ // $receipt['error'][] = array('msg'=> 'cc: ' .
$cc);
+ // $receipt['error'][] = array('msg'=> 'bcc:
'.$bcc);
+ $receipt['error'][] = array('msg'=> 'group:
'.$group_name);
+ $receipt['error'][] = array('msg'=> 'err_code:
'.$this->send->err['code']);
+ $receipt['error'][] = array('msg'=> 'err_msg:
'. htmlspecialchars($this->send->err['msg']));
+ $receipt['error'][] = array('msg'=> 'err_desc:
'. $GLOBALS['phpgw']->err['desc']);
+ }
+
+//_debug_array($receipt);
+ return $receipt;
+ }
+
+
+ function delete($id)
+ {
+ $this->so->delete($id);
+ }
+ }
+?>
Index: property/inc/class.bowo_hour.inc.php
diff -u property/inc/class.bowo_hour.inc.php:1.7
property/inc/class.bowo_hour.inc.php:1.8
--- property/inc/class.bowo_hour.inc.php:1.7 Mon Sep 12 08:19:02 2005
+++ property/inc/class.bowo_hour.inc.php Fri Jan 27 14:05:43 2006
@@ -1,487 +1,487 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage project
- * @version $Id: class.bowo_hour.inc.php,v 1.7 2005/09/12 08:19:02
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class bowo_hour
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- function bowo_hour($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.sowo_hour');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $chapter_id =
get_var('chapter_id',array('POST','GET'));
- $allrows =
get_var('allrows',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(isset($filter))
- {
- $this->filter = $filter;
- }
- if(isset($sort))
- {
- $this->sort = $sort;
- }
- if(isset($order))
- {
- $this->order = $order;
- }
- if(isset($cat_id))
- {
- $this->cat_id = $cat_id;
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
- if(isset($chapter_id))
- {
- $this->chapter_id = $chapter_id;
- }
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','wo_hour',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','wo_hour');
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->allrows = $data['allrows'];
- $this->chapter_id = $data['chapter_id'];
- }
-
- function get_chapter_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('chapter_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('chapter_filter'));
- break;
- }
-
- $chapters= $this->so->get_chapter_list();
-
- while (is_array($chapters) && list(,$chapter_entry) =
each($chapters))
- {
- $sel_chapter_entry = '';
- if ($chapter_entry['id']==$selected)
- {
- $sel_chapter_entry = 'selected';
- }
-
- $chapter_list[] = array
- (
- 'id' => $chapter_entry['id'],
- 'name' =>
$chapter_entry['name'],
- 'selected' => $sel_chapter_entry
- );
- }
-
- for ($i=0;$i<count($chapter_list);$i++)
- {
- if ($chapter_list[$i]['selected'] != 'selected')
- {
- unset($chapter_list[$i]['selected']);
- }
- }
-
- return $chapter_list;
- }
-
- function get_tolerance_list($selected='')
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('tolerance_select'));
-
- $tolerances[0]['id']= 1;
- $tolerances[1]['id']= 2;
- $tolerances[2]['id']= 3;
-
- while (is_array($tolerances) && list(,$tolerance_entry)
= each($tolerances))
- {
- $sel_tolerance_entry = '';
- if ($tolerance_entry['id']==$selected)
- {
- $sel_tolerance_entry = 'selected';
- }
-
- $tolerance_list[] = array
- (
- 'id' =>
$tolerance_entry['id'],
- 'name' =>
$tolerance_entry['id'],
- 'selected' => $sel_tolerance_entry
- );
- }
-
- for ($i=0;$i<count($tolerance_list);$i++)
- {
- if ($tolerance_list[$i]['selected'] !=
'selected')
- {
- unset($tolerance_list[$i]['selected']);
- }
- }
-
- return $tolerance_list;
- }
-
- function get_grouping_list($selected='',$workorder_id)
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('grouping_select'));
-
- $groupings= $this->so->get_grouping_list($workorder_id);
-
- while (is_array($groupings) && list(,$grouping_entry) =
each($groupings))
- {
- $sel_grouping_entry = '';
- if ($grouping_entry['id']==$selected)
- {
- $sel_grouping_entry = 'selected';
- }
-
- $grouping_list[] = array
- (
- 'id' =>
$grouping_entry['id'],
- 'name' =>
$grouping_entry['name'],
- 'selected' => $sel_grouping_entry
- );
- }
-
- for ($i=0;$i<count($grouping_list);$i++)
- {
- if ($grouping_list[$i]['selected'] !=
'selected')
- {
- unset($grouping_list[$i]['selected']);
- }
- }
-
- return $grouping_list;
- }
-
- function get_building_part_list($selected='')
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('building_part_select'));
-
- $building_parts= $this->so->get_building_part_list();
-
- while (is_array($building_parts) &&
list(,$building_part_entry) = each($building_parts))
- {
- $sel_building_part_entry = '';
- if ($building_part_entry['id']==$selected)
- {
- $sel_building_part_entry = 'selected';
- }
-
- $building_part_list[] = array
- (
- 'id' =>
$building_part_entry['id'],
- 'name' => '[ ' .
$building_part_entry['id'] . ' ] ' . $building_part_entry['name'],
- 'selected' =>
$sel_building_part_entry
- );
- }
-
- for ($i=0;$i<count($building_part_list);$i++)
- {
- if ($building_part_list[$i]['selected'] !=
'selected')
- {
-
unset($building_part_list[$i]['selected']);
- }
- }
-
- return $building_part_list;
- }
-
- function read($workorder_id='')
- {
- $hour = $this->so->read(array('workorder_id' =>
$workorder_id));
- $this->total_records = $this->so->total_records;
- return $hour;
- }
-
- function read_deviation($data)
- {
- $deviation =
$this->so->read_deviation(array('workorder_id' =>
$data['workorder_id'],'hour_id' => $data['hour_id']));
- $this->total_records = $this->so->total_records;
- return $deviation;
- }
-
- function read_single_deviation($data)
- {
- return $this->so->read_single_deviation($data);
- }
-
- function update_deviation($data)
- {
- $this->so->update_deviation($data);
- }
-
- function update_calculation($data)
- {
- $this->so->update_calculation($data);
- }
-
- function save_deviation($values,$action='')
- {
- if ($action=='edit')
- {
- if ($values['id'] != '')
- {
- $receipt =
$this->so->edit_deviation($values);
- }
- }
- else
- {
- $receipt = $this->so->add_deviation($values);
- }
- return $receipt;
- }
-
- function add_template($values,$workorder_id)
- {
- return $this->so->add_template($values,$workorder_id);
- }
-
- function add_hour($values,$workorder_id)
- {
-
-//_debug_array($values);
-
- foreach($values['select'] as $n)
- {
-
- if(!$values['quantity'][$n])
- {
- $values['quantity'][$n]=1;
- }
-
- $values['quantity'][$n] =
str_replace(",",".",$values['quantity'][$n]);
-
-
$cost=($values['total_cost'][$n]*$values['quantity'][$n]);
-
- $hour[]=array(
- 'activity_id' =>
$values['activity_id'][$n],
- 'activity_num' =>
$values['activity_num'][$n],
- 'hours_descr' =>
$values['descr'][$n],
- 'unit' =>
$values['unit'][$n],
- 'cost' => $cost,
- 'quantity' =>
$values['quantity'][$n],
- 'billperae' =>
$values['total_cost'][$n],
- 'ns3420_id' =>
$values['ns3420_id'][$n],
- 'dim_d' =>
$values['dim_d'][$n],
- 'workorder_id' =>
$workorder_id,
- 'wo_hour_cat' =>
$values['wo_hour_cat'][$n]
- );
-
- }
-//_debug_array($hour);
-
- if($hour)
- {
- $receipt = $this->so->add_hour($hour);
- }
- else
- {
- $receipt['message'][] =
array('msg'=>lang('Nothing to do!'));
- }
-
- return $receipt;
-
- }
-
- function add_hour_from_template($values,$workorder_id)
- {
-
-//_debug_array($values);
-
- foreach($values['select'] as $n)
- {
- if(!$values['quantity'][$n])
- {
- $values['quantity'][$n]=1;
- }
-
- $values['quantity'][$n] =
str_replace(",",".",$values['quantity'][$n]);
-
$cost=($values['billperae'][$n]*$values['quantity'][$n]);
-
- $hour[]=array(
- 'chapter_id' =>
$values['chapter_id'][$n],
- 'activity_id' =>
$values['activity_id'][$n],
- 'activity_num' =>
$values['activity_num'][$n],
- 'hours_descr' =>
$values['hours_descr'][$n],
- 'remark' =>
$values['remark'][$n],
- 'unit' =>
$values['unit'][$n],
- 'cost' =>
$cost,
- 'quantity' =>
$values['quantity'][$n],
- 'new_grouping' =>
$values['grouping_descr'][$n],
- 'billperae' =>
$values['billperae'][$n],
- 'ns3420_id' =>
$values['ns3420_id'][$n],
- 'tolerance' =>
$values['tolerance'][$n],
- 'building_part' =>
$values['building_part'][$n],
- 'dim_d' =>
$values['dim_d'][$n],
- 'workorder_id' =>
$workorder_id,
- );
-
- }
-//_debug_array($hour);
-
- if($hour)
- {
- $receipt =
$this->so->add_hour_from_template($hour,$workorder_id);
- }
- else
- {
- $receipt['message'][] =
array('msg'=>lang('Nothing to do!'));
- }
-
- return $receipt;
-
- }
-
- function read_single_hour($hour_id)
- {
- $hour = $this->so->read_single_hour($hour_id);
- return $hour;
- }
-
- function save_hour($values,$workorder_id)
- {
- $values['billperae'] =
str_replace(",",".",$values['billperae']);
- $values['quantity'] =
str_replace(",",".",$values['quantity']);
- $values['cost'] =
$values['billperae']*$values['quantity'];
- if($values['ns3420_descr'])
- {
- $values['descr']=$values['ns3420_descr'];
- }
-
- if ($values['hour_id'])
- {
- if ($values['hour_id'] != 0)
- {
- $receipt =
$this->so->edit($values,$workorder_id);
- }
- }
- else
- {
-//_debug_array($values);
- $receipt =
$this->so->add_custom_hour($values,$workorder_id);
- }
- return $receipt;
- }
-
- function get_email($to_email,$vendor_id)
- {
- $selected = $to_email;
-
- $email_ist = $this->so->get_email($vendor_id);
-
- while (is_array($email_ist) && list(,$email_entry) =
each($email_ist))
- {
- $sel_email = '';
- if ($email_entry['email']==$selected)
- {
- $sel_email = 'selected';
- }
-
- $email_list[] = array
- (
- 'email' =>
$email_entry['email'],
- 'selected' => $sel_email
- );
- }
-
- for ($i=0;$i<count($email_list);$i++)
- {
- if ($email_list[$i]['selected'] != 'selected')
- {
- unset($email_list[$i]['selected']);
- }
- }
-
- return $email_list;
- }
-
-
- function update_email($to_email,$workorder_id)
- {
- $this->so->update_email($to_email,$workorder_id);
- }
-
-
- function delete($hour_id,$workorder_id)
- {
- return $this->so->delete($hour_id,$workorder_id);
- }
-
- function delete_deviation($workorder_id,$hour_id,$id)
- {
- return
$this->so->delete_deviation($workorder_id,$hour_id,$id);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage project
+ * @version $Id: class.bowo_hour.inc.php,v 1.8 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class bowo_hour
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ function bowo_hour($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.sowo_hour');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $chapter_id =
get_var('chapter_id',array('POST','GET'));
+ $allrows =
get_var('allrows',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(isset($filter))
+ {
+ $this->filter = $filter;
+ }
+ if(isset($sort))
+ {
+ $this->sort = $sort;
+ }
+ if(isset($order))
+ {
+ $this->order = $order;
+ }
+ if(isset($cat_id))
+ {
+ $this->cat_id = $cat_id;
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+ if(isset($chapter_id))
+ {
+ $this->chapter_id = $chapter_id;
+ }
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','wo_hour',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','wo_hour');
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->allrows = $data['allrows'];
+ $this->chapter_id = $data['chapter_id'];
+ }
+
+ function get_chapter_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('chapter_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('chapter_filter'));
+ break;
+ }
+
+ $chapters= $this->so->get_chapter_list();
+
+ while (is_array($chapters) && list(,$chapter_entry) =
each($chapters))
+ {
+ $sel_chapter_entry = '';
+ if ($chapter_entry['id']==$selected)
+ {
+ $sel_chapter_entry = 'selected';
+ }
+
+ $chapter_list[] = array
+ (
+ 'id' => $chapter_entry['id'],
+ 'name' =>
$chapter_entry['name'],
+ 'selected' => $sel_chapter_entry
+ );
+ }
+
+ for ($i=0;$i<count($chapter_list);$i++)
+ {
+ if ($chapter_list[$i]['selected'] != 'selected')
+ {
+ unset($chapter_list[$i]['selected']);
+ }
+ }
+
+ return $chapter_list;
+ }
+
+ function get_tolerance_list($selected='')
+ {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('tolerance_select'));
+
+ $tolerances[0]['id']= 1;
+ $tolerances[1]['id']= 2;
+ $tolerances[2]['id']= 3;
+
+ while (is_array($tolerances) && list(,$tolerance_entry)
= each($tolerances))
+ {
+ $sel_tolerance_entry = '';
+ if ($tolerance_entry['id']==$selected)
+ {
+ $sel_tolerance_entry = 'selected';
+ }
+
+ $tolerance_list[] = array
+ (
+ 'id' =>
$tolerance_entry['id'],
+ 'name' =>
$tolerance_entry['id'],
+ 'selected' => $sel_tolerance_entry
+ );
+ }
+
+ for ($i=0;$i<count($tolerance_list);$i++)
+ {
+ if ($tolerance_list[$i]['selected'] !=
'selected')
+ {
+ unset($tolerance_list[$i]['selected']);
+ }
+ }
+
+ return $tolerance_list;
+ }
+
+ function get_grouping_list($selected='',$workorder_id)
+ {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('grouping_select'));
+
+ $groupings= $this->so->get_grouping_list($workorder_id);
+
+ while (is_array($groupings) && list(,$grouping_entry) =
each($groupings))
+ {
+ $sel_grouping_entry = '';
+ if ($grouping_entry['id']==$selected)
+ {
+ $sel_grouping_entry = 'selected';
+ }
+
+ $grouping_list[] = array
+ (
+ 'id' =>
$grouping_entry['id'],
+ 'name' =>
$grouping_entry['name'],
+ 'selected' => $sel_grouping_entry
+ );
+ }
+
+ for ($i=0;$i<count($grouping_list);$i++)
+ {
+ if ($grouping_list[$i]['selected'] !=
'selected')
+ {
+ unset($grouping_list[$i]['selected']);
+ }
+ }
+
+ return $grouping_list;
+ }
+
+ function get_building_part_list($selected='')
+ {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('building_part_select'));
+
+ $building_parts= $this->so->get_building_part_list();
+
+ while (is_array($building_parts) &&
list(,$building_part_entry) = each($building_parts))
+ {
+ $sel_building_part_entry = '';
+ if ($building_part_entry['id']==$selected)
+ {
+ $sel_building_part_entry = 'selected';
+ }
+
+ $building_part_list[] = array
+ (
+ 'id' =>
$building_part_entry['id'],
+ 'name' => '[ ' .
$building_part_entry['id'] . ' ] ' . $building_part_entry['name'],
+ 'selected' =>
$sel_building_part_entry
+ );
+ }
+
+ for ($i=0;$i<count($building_part_list);$i++)
+ {
+ if ($building_part_list[$i]['selected'] !=
'selected')
+ {
+
unset($building_part_list[$i]['selected']);
+ }
+ }
+
+ return $building_part_list;
+ }
+
+ function read($workorder_id='')
+ {
+ $hour = $this->so->read(array('workorder_id' =>
$workorder_id));
+ $this->total_records = $this->so->total_records;
+ return $hour;
+ }
+
+ function read_deviation($data)
+ {
+ $deviation =
$this->so->read_deviation(array('workorder_id' =>
$data['workorder_id'],'hour_id' => $data['hour_id']));
+ $this->total_records = $this->so->total_records;
+ return $deviation;
+ }
+
+ function read_single_deviation($data)
+ {
+ return $this->so->read_single_deviation($data);
+ }
+
+ function update_deviation($data)
+ {
+ $this->so->update_deviation($data);
+ }
+
+ function update_calculation($data)
+ {
+ $this->so->update_calculation($data);
+ }
+
+ function save_deviation($values,$action='')
+ {
+ if ($action=='edit')
+ {
+ if ($values['id'] != '')
+ {
+ $receipt =
$this->so->edit_deviation($values);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add_deviation($values);
+ }
+ return $receipt;
+ }
+
+ function add_template($values,$workorder_id)
+ {
+ return $this->so->add_template($values,$workorder_id);
+ }
+
+ function add_hour($values,$workorder_id)
+ {
+
+//_debug_array($values);
+
+ foreach($values['select'] as $n)
+ {
+
+ if(!$values['quantity'][$n])
+ {
+ $values['quantity'][$n]=1;
+ }
+
+ $values['quantity'][$n] =
str_replace(",",".",$values['quantity'][$n]);
+
+
$cost=($values['total_cost'][$n]*$values['quantity'][$n]);
+
+ $hour[]=array(
+ 'activity_id' =>
$values['activity_id'][$n],
+ 'activity_num' =>
$values['activity_num'][$n],
+ 'hours_descr' =>
$values['descr'][$n],
+ 'unit' =>
$values['unit'][$n],
+ 'cost' => $cost,
+ 'quantity' =>
$values['quantity'][$n],
+ 'billperae' =>
$values['total_cost'][$n],
+ 'ns3420_id' =>
$values['ns3420_id'][$n],
+ 'dim_d' =>
$values['dim_d'][$n],
+ 'workorder_id' =>
$workorder_id,
+ 'wo_hour_cat' =>
$values['wo_hour_cat'][$n]
+ );
+
+ }
+//_debug_array($hour);
+
+ if($hour)
+ {
+ $receipt = $this->so->add_hour($hour);
+ }
+ else
+ {
+ $receipt['message'][] =
array('msg'=>lang('Nothing to do!'));
+ }
+
+ return $receipt;
+
+ }
+
+ function add_hour_from_template($values,$workorder_id)
+ {
+
+//_debug_array($values);
+
+ foreach($values['select'] as $n)
+ {
+ if(!$values['quantity'][$n])
+ {
+ $values['quantity'][$n]=1;
+ }
+
+ $values['quantity'][$n] =
str_replace(",",".",$values['quantity'][$n]);
+
$cost=($values['billperae'][$n]*$values['quantity'][$n]);
+
+ $hour[]=array(
+ 'chapter_id' =>
$values['chapter_id'][$n],
+ 'activity_id' =>
$values['activity_id'][$n],
+ 'activity_num' =>
$values['activity_num'][$n],
+ 'hours_descr' =>
$values['hours_descr'][$n],
+ 'remark' =>
$values['remark'][$n],
+ 'unit' =>
$values['unit'][$n],
+ 'cost' =>
$cost,
+ 'quantity' =>
$values['quantity'][$n],
+ 'new_grouping' =>
$values['grouping_descr'][$n],
+ 'billperae' =>
$values['billperae'][$n],
+ 'ns3420_id' =>
$values['ns3420_id'][$n],
+ 'tolerance' =>
$values['tolerance'][$n],
+ 'building_part' =>
$values['building_part'][$n],
+ 'dim_d' =>
$values['dim_d'][$n],
+ 'workorder_id' =>
$workorder_id,
+ );
+
+ }
+//_debug_array($hour);
+
+ if($hour)
+ {
+ $receipt =
$this->so->add_hour_from_template($hour,$workorder_id);
+ }
+ else
+ {
+ $receipt['message'][] =
array('msg'=>lang('Nothing to do!'));
+ }
+
+ return $receipt;
+
+ }
+
+ function read_single_hour($hour_id)
+ {
+ $hour = $this->so->read_single_hour($hour_id);
+ return $hour;
+ }
+
+ function save_hour($values,$workorder_id)
+ {
+ $values['billperae'] =
str_replace(",",".",$values['billperae']);
+ $values['quantity'] =
str_replace(",",".",$values['quantity']);
+ $values['cost'] =
$values['billperae']*$values['quantity'];
+ if($values['ns3420_descr'])
+ {
+ $values['descr']=$values['ns3420_descr'];
+ }
+
+ if ($values['hour_id'])
+ {
+ if ($values['hour_id'] != 0)
+ {
+ $receipt =
$this->so->edit($values,$workorder_id);
+ }
+ }
+ else
+ {
+//_debug_array($values);
+ $receipt =
$this->so->add_custom_hour($values,$workorder_id);
+ }
+ return $receipt;
+ }
+
+ function get_email($to_email,$vendor_id)
+ {
+ $selected = $to_email;
+
+ $email_ist = $this->so->get_email($vendor_id);
+
+ while (is_array($email_ist) && list(,$email_entry) =
each($email_ist))
+ {
+ $sel_email = '';
+ if ($email_entry['email']==$selected)
+ {
+ $sel_email = 'selected';
+ }
+
+ $email_list[] = array
+ (
+ 'email' =>
$email_entry['email'],
+ 'selected' => $sel_email
+ );
+ }
+
+ for ($i=0;$i<count($email_list);$i++)
+ {
+ if ($email_list[$i]['selected'] != 'selected')
+ {
+ unset($email_list[$i]['selected']);
+ }
+ }
+
+ return $email_list;
+ }
+
+
+ function update_email($to_email,$workorder_id)
+ {
+ $this->so->update_email($to_email,$workorder_id);
+ }
+
+
+ function delete($hour_id,$workorder_id)
+ {
+ return $this->so->delete($hour_id,$workorder_id);
+ }
+
+ function delete_deviation($workorder_id,$hour_id,$id)
+ {
+ return
$this->so->delete_deviation($workorder_id,$hour_id,$id);
+ }
+ }
+?>
Index: property/inc/class.boworkorder.inc.php
diff -u property/inc/class.boworkorder.inc.php:1.8
property/inc/class.boworkorder.inc.php:1.9
--- property/inc/class.boworkorder.inc.php:1.8 Wed Nov 9 13:09:23 2005
+++ property/inc/class.boworkorder.inc.php Fri Jan 27 14:05:43 2006
@@ -1,476 +1,476 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage project
- * @version $Id: class.boworkorder.inc.php,v 1.8 2005/11/09 13:09:23
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class boworkorder
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
-
- var $public_functions = array
- (
- 'read' => True,
- 'read_single' => True,
- 'save' => True,
- 'delete' => True,
- 'check_perms' => True
- );
-
- function boworkorder($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.soworkorder');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = True;
- }
-
- $start = get_var('start',array('POST','GET'));
- $query = get_var('query',array('POST','GET'));
- $sort = get_var('sort',array('POST','GET'));
- $order = get_var('order',array('POST','GET'));
- $filter = get_var('filter',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $status_id =
get_var('status_id',array('POST','GET'));
- $search_vendor =
get_var('search_vendor',array('POST','GET'));
- $wo_hour_cat_id =
get_var('wo_hour_cat_id',array('POST','GET'));
- $start_date =
get_var('start_date',array('POST','GET'));
- $end_date =
get_var('end_date',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(array_key_exists('query',$_POST) ||
array_key_exists('query',$_GET) )
- {
- $this->query = $query;
- }
- if(array_key_exists('filter',$_POST))
- {
- $this->filter = $filter;
- }
- if(array_key_exists('sort',$_POST))
- {
- $this->sort = $sort;
- }
- if(array_key_exists('order',$_POST))
- {
- $this->order = $order;
- }
- if(array_key_exists('cat_id',$_POST))
- {
- $this->cat_id = $cat_id;
- }
- if(array_key_exists('status_id',$_POST))
- {
- $this->status_id = $status_id;
- }
- if(array_key_exists('search_vendor',$_POST))
- {
- $this->search_vendor = $search_vendor;
- }
- if(array_key_exists('wo_hour_cat_id',$_POST))
- {
- $this->wo_hour_cat_id = $wo_hour_cat_id;
- }
- if(array_key_exists('start_date',$_POST))
- {
- $this->start_date = $start_date;
- }
- if(array_key_exists('end_date',$_POST))
- {
- $this->end_date = $end_date;
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','workorder');
-
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->filter = $data['filter'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->cat_id = $data['cat_id'];
- $this->search_vendor = $data['search_vendor'];
- $this->status_id = $data['status_id'];
- $this->wo_hour_cat_id = $data['wo_hour_cat_id'];
- $this->start_date = $data['start_date'];
- $this->end_date = $data['end_date'];
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','workorder',$data);
- }
- }
-
- function next_id()
- {
- return $this->so->next_id();
- }
-
- function select_status_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('status_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('status_filter'));
- break;
- }
-
- $status_entries= $this->so->select_status_list();
-
- while (is_array($status_entries) && list(,$status) =
each($status_entries))
- {
- $sel_status = '';
- if ($status['id']==$selected)
- {
- $sel_status = 'selected';
- }
-
- $status_list[] = array
- (
- 'id' => $status['id'],
- 'name' => $status['name'],
- 'selected' => $sel_status
- );
- }
-
- for ($i=0;$i<count($status_list);$i++)
- {
- if ($status_list[$i]['selected'] != 'selected')
- {
- unset($status_list[$i]['selected']);
- }
- }
-
- return $status_list;
- }
-
- function select_branch_list($selected='')
- {
-
- $branch_entries= $this->so->select_branch_list();
-
- while (is_array($branch_entries) && list(,$branch) =
each($branch_entries))
- {
- $sel_branch = '';
- if ($branch['id']==$selected)
- {
- $sel_branch = 'selected';
- }
-
- $branch_list[] = array
- (
- 'id' => $branch['id'],
- 'name' => $branch['name'],
- 'selected' => $sel_branch
- );
- }
-
- for ($i=0;$i<count($branch_list);$i++)
- {
- if ($branch_list[$i]['selected'] != 'selected')
- {
- unset($branch_list[$i]['selected']);
- }
- }
-
- return $branch_list;
- }
-
- function select_branch_p_list($project_id='')
- {
-
- $selected =
$this->so->branch_p_list($project_id);
- $branch_entries = $this->so->select_branch_list();
-
- $j=0;
- while (is_array($branch_entries) && list(,$branch) =
each($branch_entries))
- {
- $branch_list[$j]['id'] = $branch['id'];
- $branch_list[$j]['name'] = $branch['name'];
-
- for ($i=0;$i<count($selected);$i++)
- {
- if($selected[$i]['branch_id'] ==
$branch['id'])
- {
- $branch_list[$j]['selected'] =
'selected';
- }
- }
- $j++;
- }
-
- for ($i=0;$i<count($branch_list);$i++)
- {
- if ($branch_list[$i]['selected'] != 'selected')
- {
- unset($branch_list[$i]['selected']);
- }
- }
-
- return $branch_list;
- }
-
-
- function select_key_location_list($selected='')
- {
-
- $key_location_entries=
$this->so->select_key_location_list();
-
- while (is_array($key_location_entries) &&
list(,$key_location) = each($key_location_entries))
- {
- $sel_key_location = '';
- if ($key_location['id']==$selected)
- {
- $sel_key_location = 'selected';
- }
-
- $key_location_list[] = array
- (
- 'id' => $key_location['id'],
- 'name' =>
$key_location['name'],
- 'selected' => $sel_key_location
- );
- }
-
- for ($i=0;$i<count($key_location_list);$i++)
- {
- if ($key_location_list[$i]['selected'] !=
'selected')
- {
-
unset($key_location_list[$i]['selected']);
- }
- }
-
- return $key_location_list;
- }
-
- function select_category_workorder_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
- $categories=
$this->so->select_category_workorder_list();
-
- while (is_array($categories) && list(,$category) =
each($categories))
- {
- $sel_category = '';
- if ($category['id']==$selected)
- {
- $sel_category = 'selected';
- }
-
- $category_list[] = array
- (
- 'cat_id' => $category['id'],
- 'name' => $category['name'],
- 'selected' => $sel_category
- );
- }
-
- for ($i=0;$i<count($category_list);$i++)
- {
- if ($category_list[$i]['selected'] !=
'selected')
- {
- unset($category_list[$i]['selected']);
- }
- }
-
- return $category_list;
- }
-
-
- function read($start_date='',$end_date='',$allrows='')
- {
- $start_date =
$this->bocommon->date_to_timestamp($start_date);
- $end_date =
$this->bocommon->date_to_timestamp($end_date);
-
- $workorder = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' => $this->cat_id,'status_id' =>
$this->status_id,
-
'search_vendor' => $this->search_vendor,'wo_hour_cat_id' =>
$this->wo_hour_cat_id,
-
'start_date'=>$start_date,'end_date'=>$end_date,'allrows'=>$allrows));
- $this->total_records = $this->so->total_records;
-
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-
- $this->uicols = $this->so->uicols;
-
- for ($i=0; $i<count($workorder); $i++)
- {
- $workorder[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($workorder[$i]['entry_date'],$dateformat);
- }
-
- return $workorder;
- }
-
- function read_single($workorder_id)
- {
- $contacts =
CreateObject($this->currentapp.'.soactor');
- $contacts->role='vendor';
- $workorder
= $this->so->read_single($workorder_id);
- $dateformat
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $workorder['start_date'] =
$GLOBALS['phpgw']->common->show_date($workorder['start_date'],$dateformat);
- $workorder['end_date'] =
$GLOBALS['phpgw']->common->show_date($workorder['end_date'],$dateformat);
- $vendor
= $contacts->read_single(array('actor_id'=>(int)$workorder['vendor_id']));
- if(is_array($vendor))
- {
- foreach($vendor['attributes'] as $attribute)
- {
- if($attribute['name']=='org_name')
- {
-
$workorder['vendor_name']=$attribute['value'];
- }
- if($attribute['name']=='email')
- {
-
$workorder['vendor_email']=$attribute['value'];
- }
- }
- }
-
- $workorder['b_account_name'] =
$this->so->get_b_account_name($workorder['b_account_id']);
-
- $config =
CreateObject('phpgwapi.config');
- $config->read_repository();
- $tax = 1+($config->config_data['fm_tax'])/100;
- $workorder['calculation']
=number_format($workorder['calculation']*$tax, 2, ',', '');
- $workorder['actual_cost']
=number_format(($workorder['act_mtrl_cost']+$workorder['act_vendor_cost']), 2,
',', '');
-
- return $workorder;
- }
-
- function read_record_history($id)
- {
- $historylog =
CreateObject($this->currentapp.'.historylog','workorder');
- $history_array =
$historylog->return_array(array('O'),array(),'','',$id);
- $i=0;
- while (is_array($history_array) && list(,$value) =
each($history_array))
- {
-
- $record_history[$i]['value_date'] =
$GLOBALS['phpgw']->common->show_date($value['datetime']);
- $record_history[$i]['value_user'] =
$value['owner'];
-
- switch ($value['status'])
- {
- case 'R': $type = lang('Re-opened');
break;
- case 'X': $type = lang('Closed');
break;
- case 'O': $type = lang('Opened');
break;
- case 'A': $type = lang('Re-assigned');
break;
- case 'P': $type = lang('Priority
changed'); break;
- case 'M': $type = lang('Sendt by email
to'); break;
- case 'B': $type = lang('Budget
changed'); break;
- case 'CO': $type = lang('Initial
Coordinator'); break;
- case 'C': $type = lang('Coordinator
changed'); break;
- case 'TO': $type = lang('Initial
Category'); break;
- case 'T': $type = lang('Category
changed'); break;
- case 'SO': $type = lang('Initial
Status'); break;
- case 'S': $type = lang('Status
changed'); break;
- default: break;
- }
-
-
if($value['new_value']=='O'){$value['new_value']=lang('Opened');}
-
if($value['new_value']=='X'){$value['new_value']=lang('Closed');}
-
-
- $record_history[$i]['value_action'] =
$type?$type:'';
- unset($type);
-
- if ($value['status'] == 'A')
- {
- if (! $value['new_value'])
- {
-
$record_history[$i]['value_new_value'] = lang('None');
- }
- else
- {
-
$record_history[$i]['value_new_value'] =
$GLOBALS['phpgw']->accounts->id2name($value['new_value']);
- }
- }
- else if ($value['status'] == 'C' ||
$value['status'] == 'CO')
- {
- $record_history[$i]['value_new_value']
= $GLOBALS['phpgw']->accounts->id2name($value['new_value']);
- }
- else if ($value['status'] == 'T' ||
$value['status'] == 'TO')
- {
- $record_history[$i]['value_new_value']
= $this->so->read_single_project_category($value['new_value']);
- }
- else if ($value['status'] != 'O' &&
$value['new_value'])
- {
- $record_history[$i]['value_new_value']
= $value['new_value'];
- }
- else if ($value['status'] != 'B' &&
$value['new_value'])
- {
- $record_history[$i]['value_new_value']
= $value['new_value'];
- }
- else
- {
- $record_history[$i]['value_new_value']
= '';
- }
-
- $i++;
- }
-
- return $record_history;
- }
-
- function save($workorder,$action='')
- {
- $workorder['start_date'] =
$this->bocommon->date_to_timestamp($workorder['start_date']);
- $workorder['end_date'] =
$this->bocommon->date_to_timestamp($workorder['end_date']);
-
- if ($action=='edit')
- {
- $receipt = $this->so->edit($workorder);
- }
- else
- {
- $receipt = $this->so->add($workorder);
- }
- return $receipt;
- }
-
- function delete($workorder_id)
- {
- $this->so->delete($workorder_id);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage project
+ * @version $Id: class.boworkorder.inc.php,v 1.9 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class boworkorder
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+
+ var $public_functions = array
+ (
+ 'read' => True,
+ 'read_single' => True,
+ 'save' => True,
+ 'delete' => True,
+ 'check_perms' => True
+ );
+
+ function boworkorder($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.soworkorder');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+
+ if ($session)
+ {
+ $this->read_sessiondata();
+ $this->use_session = True;
+ }
+
+ $start = get_var('start',array('POST','GET'));
+ $query = get_var('query',array('POST','GET'));
+ $sort = get_var('sort',array('POST','GET'));
+ $order = get_var('order',array('POST','GET'));
+ $filter = get_var('filter',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $status_id =
get_var('status_id',array('POST','GET'));
+ $search_vendor =
get_var('search_vendor',array('POST','GET'));
+ $wo_hour_cat_id =
get_var('wo_hour_cat_id',array('POST','GET'));
+ $start_date =
get_var('start_date',array('POST','GET'));
+ $end_date =
get_var('end_date',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(array_key_exists('query',$_POST) ||
array_key_exists('query',$_GET) )
+ {
+ $this->query = $query;
+ }
+ if(array_key_exists('filter',$_POST))
+ {
+ $this->filter = $filter;
+ }
+ if(array_key_exists('sort',$_POST))
+ {
+ $this->sort = $sort;
+ }
+ if(array_key_exists('order',$_POST))
+ {
+ $this->order = $order;
+ }
+ if(array_key_exists('cat_id',$_POST))
+ {
+ $this->cat_id = $cat_id;
+ }
+ if(array_key_exists('status_id',$_POST))
+ {
+ $this->status_id = $status_id;
+ }
+ if(array_key_exists('search_vendor',$_POST))
+ {
+ $this->search_vendor = $search_vendor;
+ }
+ if(array_key_exists('wo_hour_cat_id',$_POST))
+ {
+ $this->wo_hour_cat_id = $wo_hour_cat_id;
+ }
+ if(array_key_exists('start_date',$_POST))
+ {
+ $this->start_date = $start_date;
+ }
+ if(array_key_exists('end_date',$_POST))
+ {
+ $this->end_date = $end_date;
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','workorder');
+
+ $this->start = $data['start'];
+ $this->query = $data['query'];
+ $this->filter = $data['filter'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->cat_id = $data['cat_id'];
+ $this->search_vendor = $data['search_vendor'];
+ $this->status_id = $data['status_id'];
+ $this->wo_hour_cat_id = $data['wo_hour_cat_id'];
+ $this->start_date = $data['start_date'];
+ $this->end_date = $data['end_date'];
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','workorder',$data);
+ }
+ }
+
+ function next_id()
+ {
+ return $this->so->next_id();
+ }
+
+ function select_status_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('status_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('status_filter'));
+ break;
+ }
+
+ $status_entries= $this->so->select_status_list();
+
+ while (is_array($status_entries) && list(,$status) =
each($status_entries))
+ {
+ $sel_status = '';
+ if ($status['id']==$selected)
+ {
+ $sel_status = 'selected';
+ }
+
+ $status_list[] = array
+ (
+ 'id' => $status['id'],
+ 'name' => $status['name'],
+ 'selected' => $sel_status
+ );
+ }
+
+ for ($i=0;$i<count($status_list);$i++)
+ {
+ if ($status_list[$i]['selected'] != 'selected')
+ {
+ unset($status_list[$i]['selected']);
+ }
+ }
+
+ return $status_list;
+ }
+
+ function select_branch_list($selected='')
+ {
+
+ $branch_entries= $this->so->select_branch_list();
+
+ while (is_array($branch_entries) && list(,$branch) =
each($branch_entries))
+ {
+ $sel_branch = '';
+ if ($branch['id']==$selected)
+ {
+ $sel_branch = 'selected';
+ }
+
+ $branch_list[] = array
+ (
+ 'id' => $branch['id'],
+ 'name' => $branch['name'],
+ 'selected' => $sel_branch
+ );
+ }
+
+ for ($i=0;$i<count($branch_list);$i++)
+ {
+ if ($branch_list[$i]['selected'] != 'selected')
+ {
+ unset($branch_list[$i]['selected']);
+ }
+ }
+
+ return $branch_list;
+ }
+
+ function select_branch_p_list($project_id='')
+ {
+
+ $selected =
$this->so->branch_p_list($project_id);
+ $branch_entries = $this->so->select_branch_list();
+
+ $j=0;
+ while (is_array($branch_entries) && list(,$branch) =
each($branch_entries))
+ {
+ $branch_list[$j]['id'] = $branch['id'];
+ $branch_list[$j]['name'] = $branch['name'];
+
+ for ($i=0;$i<count($selected);$i++)
+ {
+ if($selected[$i]['branch_id'] ==
$branch['id'])
+ {
+ $branch_list[$j]['selected'] =
'selected';
+ }
+ }
+ $j++;
+ }
+
+ for ($i=0;$i<count($branch_list);$i++)
+ {
+ if ($branch_list[$i]['selected'] != 'selected')
+ {
+ unset($branch_list[$i]['selected']);
+ }
+ }
+
+ return $branch_list;
+ }
+
+
+ function select_key_location_list($selected='')
+ {
+
+ $key_location_entries=
$this->so->select_key_location_list();
+
+ while (is_array($key_location_entries) &&
list(,$key_location) = each($key_location_entries))
+ {
+ $sel_key_location = '';
+ if ($key_location['id']==$selected)
+ {
+ $sel_key_location = 'selected';
+ }
+
+ $key_location_list[] = array
+ (
+ 'id' => $key_location['id'],
+ 'name' =>
$key_location['name'],
+ 'selected' => $sel_key_location
+ );
+ }
+
+ for ($i=0;$i<count($key_location_list);$i++)
+ {
+ if ($key_location_list[$i]['selected'] !=
'selected')
+ {
+
unset($key_location_list[$i]['selected']);
+ }
+ }
+
+ return $key_location_list;
+ }
+
+ function select_category_workorder_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ break;
+ }
+
+ $categories=
$this->so->select_category_workorder_list();
+
+ while (is_array($categories) && list(,$category) =
each($categories))
+ {
+ $sel_category = '';
+ if ($category['id']==$selected)
+ {
+ $sel_category = 'selected';
+ }
+
+ $category_list[] = array
+ (
+ 'cat_id' => $category['id'],
+ 'name' => $category['name'],
+ 'selected' => $sel_category
+ );
+ }
+
+ for ($i=0;$i<count($category_list);$i++)
+ {
+ if ($category_list[$i]['selected'] !=
'selected')
+ {
+ unset($category_list[$i]['selected']);
+ }
+ }
+
+ return $category_list;
+ }
+
+
+ function read($start_date='',$end_date='',$allrows='')
+ {
+ $start_date =
$this->bocommon->date_to_timestamp($start_date);
+ $end_date =
$this->bocommon->date_to_timestamp($end_date);
+
+ $workorder = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' => $this->cat_id,'status_id' =>
$this->status_id,
+
'search_vendor' => $this->search_vendor,'wo_hour_cat_id' =>
$this->wo_hour_cat_id,
+
'start_date'=>$start_date,'end_date'=>$end_date,'allrows'=>$allrows));
+ $this->total_records = $this->so->total_records;
+
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ $this->uicols = $this->so->uicols;
+
+ for ($i=0; $i<count($workorder); $i++)
+ {
+ $workorder[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($workorder[$i]['entry_date'],$dateformat);
+ }
+
+ return $workorder;
+ }
+
+ function read_single($workorder_id)
+ {
+ $contacts =
CreateObject($this->currentapp.'.soactor');
+ $contacts->role='vendor';
+ $workorder
= $this->so->read_single($workorder_id);
+ $dateformat
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $workorder['start_date'] =
$GLOBALS['phpgw']->common->show_date($workorder['start_date'],$dateformat);
+ $workorder['end_date'] =
$GLOBALS['phpgw']->common->show_date($workorder['end_date'],$dateformat);
+ $vendor
= $contacts->read_single(array('actor_id'=>(int)$workorder['vendor_id']));
+ if(is_array($vendor))
+ {
+ foreach($vendor['attributes'] as $attribute)
+ {
+ if($attribute['name']=='org_name')
+ {
+
$workorder['vendor_name']=$attribute['value'];
+ }
+ if($attribute['name']=='email')
+ {
+
$workorder['vendor_email']=$attribute['value'];
+ }
+ }
+ }
+
+ $workorder['b_account_name'] =
$this->so->get_b_account_name($workorder['b_account_id']);
+
+ $config =
CreateObject('phpgwapi.config');
+ $config->read_repository();
+ $tax = 1+($config->config_data['fm_tax'])/100;
+ $workorder['calculation']
=number_format($workorder['calculation']*$tax, 2, ',', '');
+ $workorder['actual_cost']
=number_format(($workorder['act_mtrl_cost']+$workorder['act_vendor_cost']), 2,
',', '');
+
+ return $workorder;
+ }
+
+ function read_record_history($id)
+ {
+ $historylog =
CreateObject($this->currentapp.'.historylog','workorder');
+ $history_array =
$historylog->return_array(array('O'),array(),'','',$id);
+ $i=0;
+ while (is_array($history_array) && list(,$value) =
each($history_array))
+ {
+
+ $record_history[$i]['value_date'] =
$GLOBALS['phpgw']->common->show_date($value['datetime']);
+ $record_history[$i]['value_user'] =
$value['owner'];
+
+ switch ($value['status'])
+ {
+ case 'R': $type = lang('Re-opened');
break;
+ case 'X': $type = lang('Closed');
break;
+ case 'O': $type = lang('Opened');
break;
+ case 'A': $type = lang('Re-assigned');
break;
+ case 'P': $type = lang('Priority
changed'); break;
+ case 'M': $type = lang('Sendt by email
to'); break;
+ case 'B': $type = lang('Budget
changed'); break;
+ case 'CO': $type = lang('Initial
Coordinator'); break;
+ case 'C': $type = lang('Coordinator
changed'); break;
+ case 'TO': $type = lang('Initial
Category'); break;
+ case 'T': $type = lang('Category
changed'); break;
+ case 'SO': $type = lang('Initial
Status'); break;
+ case 'S': $type = lang('Status
changed'); break;
+ default: break;
+ }
+
+
if($value['new_value']=='O'){$value['new_value']=lang('Opened');}
+
if($value['new_value']=='X'){$value['new_value']=lang('Closed');}
+
+
+ $record_history[$i]['value_action'] =
$type?$type:'';
+ unset($type);
+
+ if ($value['status'] == 'A')
+ {
+ if (! $value['new_value'])
+ {
+
$record_history[$i]['value_new_value'] = lang('None');
+ }
+ else
+ {
+
$record_history[$i]['value_new_value'] =
$GLOBALS['phpgw']->accounts->id2name($value['new_value']);
+ }
+ }
+ else if ($value['status'] == 'C' ||
$value['status'] == 'CO')
+ {
+ $record_history[$i]['value_new_value']
= $GLOBALS['phpgw']->accounts->id2name($value['new_value']);
+ }
+ else if ($value['status'] == 'T' ||
$value['status'] == 'TO')
+ {
+ $record_history[$i]['value_new_value']
= $this->so->read_single_project_category($value['new_value']);
+ }
+ else if ($value['status'] != 'O' &&
$value['new_value'])
+ {
+ $record_history[$i]['value_new_value']
= $value['new_value'];
+ }
+ else if ($value['status'] != 'B' &&
$value['new_value'])
+ {
+ $record_history[$i]['value_new_value']
= $value['new_value'];
+ }
+ else
+ {
+ $record_history[$i]['value_new_value']
= '';
+ }
+
+ $i++;
+ }
+
+ return $record_history;
+ }
+
+ function save($workorder,$action='')
+ {
+ $workorder['start_date'] =
$this->bocommon->date_to_timestamp($workorder['start_date']);
+ $workorder['end_date'] =
$this->bocommon->date_to_timestamp($workorder['end_date']);
+
+ if ($action=='edit')
+ {
+ $receipt = $this->so->edit($workorder);
+ }
+ else
+ {
+ $receipt = $this->so->add($workorder);
+ }
+ return $receipt;
+ }
+
+ function delete($workorder_id)
+ {
+ $this->so->delete($workorder_id);
+ }
+ }
+?>
Index: property/inc/class.custom_functions.inc.php
diff -u property/inc/class.custom_functions.inc.php:1.4
property/inc/class.custom_functions.inc.php:1.5
--- property/inc/class.custom_functions.inc.php:1.4 Thu May 12 21:26:28 2005
+++ property/inc/class.custom_functions.inc.php Fri Jan 27 14:05:43 2006
@@ -1,64 +1,64 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage core
- * @version $Id: class.custom_functions.inc.php,v 1.4 2005/05/12
21:26:28 sigurdne Exp $
- */
-
- /**
- * This is a class used to gain access to custom classes stored in
/inc/custom to be run as cron jobs
- * or from the admin interface.
- * @package property
- */
-
- class custom_functions
- {
-
- var $public_functions = array(
- 'index' => True
- );
-
- function custom_functions ()
- {
- $GLOBALS['phpgw_info']['flags']['noheader'] = True;
- $GLOBALS['phpgw_info']['flags']['nonavbar'] = True;
-
-
- $GLOBALS['phpgw_info']['flags']['currentapp'] =
'property';
-
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->config =
CreateObject('phpgwapi.config',$this->currentapp);
-
- }
-
- /**
- * @param mixed $data
- * If $data is an array - then the process is run as cron - and
will look for $data['function'] to
- * determine which custom class to load
- */
-
- function index($data='')
- {
- if(is_array($data))
- {
- $function = $data['function'];
- }
- else
- {
- $function =
get_var('function',array('POST','GET'));
- }
-
-
include_once(PHPGW_SERVER_ROOT.'/'.'property'.'/inc/custom/' . $function .
'.php');
- $custom = new $function;
- $custom->pre_run($data);
- }
-
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage core
+ * @version $Id: class.custom_functions.inc.php,v 1.5 2006/01/27
14:05:43 sigurdne Exp $
+ */
+
+ /**
+ * This is a class used to gain access to custom classes stored in
/inc/custom to be run as cron jobs
+ * or from the admin interface.
+ * @package property
+ */
+
+ class custom_functions
+ {
+
+ var $public_functions = array(
+ 'index' => True
+ );
+
+ function custom_functions ()
+ {
+ $GLOBALS['phpgw_info']['flags']['noheader'] = True;
+ $GLOBALS['phpgw_info']['flags']['nonavbar'] = True;
+
+
+ $GLOBALS['phpgw_info']['flags']['currentapp'] =
'property';
+
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->config =
CreateObject('phpgwapi.config',$this->currentapp);
+
+ }
+
+ /**
+ * @param mixed $data
+ * If $data is an array - then the process is run as cron - and
will look for $data['function'] to
+ * determine which custom class to load
+ */
+
+ function index($data='')
+ {
+ if(is_array($data))
+ {
+ $function = $data['function'];
+ }
+ else
+ {
+ $function =
get_var('function',array('POST','GET'));
+ }
+
+
include_once(PHPGW_SERVER_ROOT.'/'.'property'.'/inc/custom/' . $function .
'.php');
+ $custom = new $function;
+ $custom->pre_run($data);
+ }
+
+
+ }
+?>
Index: property/inc/class.excel.inc.php
diff -u property/inc/class.excel.inc.php:1.5
property/inc/class.excel.inc.php:1.6
--- property/inc/class.excel.inc.php:1.5 Wed Nov 9 22:49:12 2005
+++ property/inc/class.excel.inc.php Fri Jan 27 14:05:43 2006
@@ -1,15 +1,15 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package Excel
- * @version $Id: class.excel.inc.php,v 1.5 2005/11/09 22:49:12 sigurdne
Exp $
- */
-
- require_once(PHPGW_APP_INC . '/excel/Worksheet.php');
- require_once(PHPGW_APP_INC . '/excel/Workbook.php');
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package Excel
+ * @version $Id: class.excel.inc.php,v 1.6 2006/01/27 14:05:43 sigurdne
Exp $
+ */
+
+ require_once(PHPGW_APP_INC . '/excel/Worksheet.php');
+ require_once(PHPGW_APP_INC . '/excel/Workbook.php');
+?>
Index: property/inc/class.historylog.inc.php
diff -u property/inc/class.historylog.inc.php:1.6
property/inc/class.historylog.inc.php:1.7
--- property/inc/class.historylog.inc.php:1.6 Fri May 13 12:17:25 2005
+++ property/inc/class.historylog.inc.php Fri Jan 27 14:05:43 2006
@@ -1,128 +1,128 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage core
- * @version $Id: class.historylog.inc.php,v 1.6 2005/05/13 12:17:25
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class historylog
- {
- var $db;
- var $appname;
- var $table;
- var $types = array(
- 'C' => 'Created',
- 'D' => 'Deleted',
- 'E' => 'Edited'
- );
- var $alternate_handlers = array();
-
- function historylog($appname)
- {
- if (! $appname)
- {
- $appname =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- }
-
- switch($appname)
- {
- case 'request':
- $this->table='fm_request_history';
- break;
- case 'workorder':
- $this->table='fm_workorder_history';
- break;
- case 'project':
- $this->table='fm_project_history';
- break;
- case 'tts':
- $this->table='fm_tts_history';
- break;
- case 'document':
- $this->table='fm_document_history';
- break;
- }
-
-
- $this->appname = $appname;
- $this->db = $GLOBALS['phpgw']->db;
- }
-
- function delete($record_id)
- {
- $this->db->query("delete from $this->table where
history_record_id='$record_id' and "
- . "history_appname='" . $this->appname .
"'",__LINE__,__FILE__);
- }
-
- function add($status,$record_id,$new_value)
- {
- $this->db->query("insert into $this->table
(history_record_id,"
- .
"history_appname,history_owner,history_status,history_new_value,history_timestamp)
"
- . "values ('$record_id','" . $this->appname .
"','"
- . $GLOBALS['phpgw_info']['user']['account_id']
. "','$status','"
- . $this->db->db_addslashes($new_value) . "','"
. $this->db->to_timestamp(time())
- . "')",__LINE__,__FILE__);
- }
-
- // array $filter_out
- function return_array($filter_out,$only_show,$_orderby =
'',$sort = '', $record_id)
- {
-
- if (! $sort || ! $_orderby)
- {
- $orderby = 'order by
history_timestamp,history_id';
- }
- else
- {
- $orderby = "order by $_orderby $sort";
- }
-
- while (is_array($filter_out) && list(,$_filter) =
each($filter_out))
- {
- $filtered[] = "history_status != '$_filter'";
- }
-
- if (is_array($filtered))
- {
- $filter = ' and ' . implode(' and ',$filtered);
- }
-
- while (is_array($only_show) && list(,$_filter) =
each($only_show))
- {
- $_only_show[] = "history_status='$_filter'";
- }
-
- if (is_array($_only_show))
- {
- $only_show_filter = ' and (' . implode(' or
',$_only_show) . ')';
- }
-
- $this->db->query("select * from $this->table where
history_appname='"
- . $this->appname . "' and
history_record_id='$record_id' $filter $only_show_filter "
- . "$orderby",__LINE__,__FILE__);
- while ($this->db->next_record())
- {
- $return_values[] = array(
- 'id' =>
$this->db->f('history_id'),
- 'record_id' =>
$this->db->f('history_record_id'),
- 'owner' =>
$GLOBALS['phpgw']->accounts->id2name($this->db->f('history_owner')),
-// 'status' =>
lang($this->types[$this->db->f('history_status')]),
- 'status' => ereg_replace('
','',$this->db->f('history_status')),
- 'new_value' =>
$this->db->f('history_new_value'),
- 'datetime' =>
$this->db->from_timestamp($this->db->f('history_timestamp'))
- );
- }
- return $return_values;
- }
- }
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage core
+ * @version $Id: class.historylog.inc.php,v 1.7 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class historylog
+ {
+ var $db;
+ var $appname;
+ var $table;
+ var $types = array(
+ 'C' => 'Created',
+ 'D' => 'Deleted',
+ 'E' => 'Edited'
+ );
+ var $alternate_handlers = array();
+
+ function historylog($appname)
+ {
+ if (! $appname)
+ {
+ $appname =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ }
+
+ switch($appname)
+ {
+ case 'request':
+ $this->table='fm_request_history';
+ break;
+ case 'workorder':
+ $this->table='fm_workorder_history';
+ break;
+ case 'project':
+ $this->table='fm_project_history';
+ break;
+ case 'tts':
+ $this->table='fm_tts_history';
+ break;
+ case 'document':
+ $this->table='fm_document_history';
+ break;
+ }
+
+
+ $this->appname = $appname;
+ $this->db = $GLOBALS['phpgw']->db;
+ }
+
+ function delete($record_id)
+ {
+ $this->db->query("delete from $this->table where
history_record_id='$record_id' and "
+ . "history_appname='" . $this->appname .
"'",__LINE__,__FILE__);
+ }
+
+ function add($status,$record_id,$new_value)
+ {
+ $this->db->query("insert into $this->table
(history_record_id,"
+ .
"history_appname,history_owner,history_status,history_new_value,history_timestamp)
"
+ . "values ('$record_id','" . $this->appname .
"','"
+ . $GLOBALS['phpgw_info']['user']['account_id']
. "','$status','"
+ . $this->db->db_addslashes($new_value) . "','"
. $this->db->to_timestamp(time())
+ . "')",__LINE__,__FILE__);
+ }
+
+ // array $filter_out
+ function return_array($filter_out,$only_show,$_orderby =
'',$sort = '', $record_id)
+ {
+
+ if (! $sort || ! $_orderby)
+ {
+ $orderby = 'order by
history_timestamp,history_id';
+ }
+ else
+ {
+ $orderby = "order by $_orderby $sort";
+ }
+
+ while (is_array($filter_out) && list(,$_filter) =
each($filter_out))
+ {
+ $filtered[] = "history_status != '$_filter'";
+ }
+
+ if (is_array($filtered))
+ {
+ $filter = ' and ' . implode(' and ',$filtered);
+ }
+
+ while (is_array($only_show) && list(,$_filter) =
each($only_show))
+ {
+ $_only_show[] = "history_status='$_filter'";
+ }
+
+ if (is_array($_only_show))
+ {
+ $only_show_filter = ' and (' . implode(' or
',$_only_show) . ')';
+ }
+
+ $this->db->query("select * from $this->table where
history_appname='"
+ . $this->appname . "' and
history_record_id='$record_id' $filter $only_show_filter "
+ . "$orderby",__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+ $return_values[] = array(
+ 'id' =>
$this->db->f('history_id'),
+ 'record_id' =>
$this->db->f('history_record_id'),
+ 'owner' =>
$GLOBALS['phpgw']->accounts->id2name($this->db->f('history_owner')),
+// 'status' =>
lang($this->types[$this->db->f('history_status')]),
+ 'status' => ereg_replace('
','',$this->db->f('history_status')),
+ 'new_value' =>
$this->db->f('history_new_value'),
+ 'datetime' =>
$this->db->from_timestamp($this->db->f('history_timestamp'))
+ );
+ }
+ return $return_values;
+ }
+ }
Index: property/inc/class.menu.inc.php
diff -u property/inc/class.menu.inc.php:1.14
property/inc/class.menu.inc.php:1.15
--- property/inc/class.menu.inc.php:1.14 Fri May 13 12:17:25 2005
+++ property/inc/class.menu.inc.php Fri Jan 27 14:05:43 2006
@@ -1,466 +1,466 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage core
- * @version $Id: class.menu.inc.php,v 1.14 2005/05/13 12:17:25 sigurdne
Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class menu
- {
- var $sub;
-
- var $public_functions = array
- (
- 'links' => True,
- );
-
- function menu($sub='')
- {
- $this->sub = $sub;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- }
-
- function links($page='',$page_2='')
- {
- $currentapp=$this->currentapp;
- $sub = $this->sub;
-// $menu =
$GLOBALS['phpgw']->session->appsession('menu',$currentapp.$sub);
-//_debug_array($page);
- if(!$menu)
- {
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
-
- $i=0;
- if($sub=='location')
- {
- $menu['module'][$i]['this']=True;
- }
- $menu['module'][$i]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uilocation.index&type_id=1');
- $menu['module'][$i]['name'] =
lang('Property');
- $menu['module'][$i]['statustext'] =
lang('Property');
- $i++;
-
- if($sub=='ticket')
- {
- $menu['module'][$i]['this']=True;
- }
- $menu['module'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uitts.index');
- $menu['module'][$i]['name']
= lang('Helpdesk');
- $menu['module'][$i]['statustext'] =
lang('Helpdesk');
- $i++;
- if($sub=='project')
- {
- $menu['module'][$i]['this']=True;
- }
- $menu['module'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiproject.index');
- $menu['module'][$i]['name']
= lang('Project');
- $menu['module'][$i]['statustext'] =
lang('Project');
- $i++;
- if($sub=='invoice')
- {
- $menu['module'][$i]['this']=True;
- }
- $menu['module'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiinvoice.index');
- $menu['module'][$i]['name']
= lang('Invoice');
- $menu['module'][$i]['statustext'] =
lang('Invoice');
-
-/* $i++;
- if($sub=='pricebook')
- {
- $menu['module'][$i]['this']=True;
- }
- $menu['module'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiagreement.index');
- $menu['module'][$i]['name']
= lang('Pricebook');
- $menu['module'][$i]['statustext'] =
lang('Pricebook');
-*/
-//--------------------
- $i++;
- if($sub=='agreement')
- {
- $menu['module'][$i]['this']=True;
- }
- $menu['module'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiagreement.index');
- $menu['module'][$i]['name']
= lang('Agreement');
- $menu['module'][$i]['statustext'] =
lang('Agreement');
-//----------------------
- $i++;
- if($sub=='document')
- {
- $menu['module'][$i]['this']=True;
- }
- $menu['module'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uidocument.index');
- $menu['module'][$i]['name']
= lang('Documentation');
- $menu['module'][$i]['statustext'] =
lang('Documentation');
- $i++;
- if($sub=='custom')
- {
- $menu['module'][$i]['this']=True;
- }
- $menu['module'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uicustom.index');
- $menu['module'][$i]['name']
= lang('Custom');
- $menu['module'][$i]['statustext'] =
lang('Custom queries');
-
- $entity =
CreateObject($this->currentapp.'.soadmin_entity');
- $entity_list =
$entity->read(array('allrows'=>True));
-
- if (isset($entity_list) AND
is_array($entity_list))
- {
- foreach($entity_list as $entry)
- {
- $i++;
- if($sub=='entity_' .
$entry['id'])
- {
-
$menu['module'][$i]['this']=True;
- }
- $menu['module'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uientity.index&entity_id='
.$entry['id']);
- $menu['module'][$i]['name']
= $entry['name'];
-
$menu['module'][$i]['statustext'] = $entry['descr'];
- }
- }
-
- unset($entity);
-
- if ($sub == 'location')
- {
- $soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
- $location =
$soadmin_location->select_location_type();
- $location_count=count($location);
- for ($j=0; $j<$location_count; $j++)
- {
- $i++;
-
if($page=='location'.$location[$j]['id'].'_')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uilocation.index&type_id='
.$location[$j]['id'] );
- $menu['sub_menu'][$i]['name'] =
$location[$j]['name'];
-
$menu['sub_menu'][$i]['statustext'] = $location[$j]['descr'];
- }
-
- $config_tenant =
$soadmin_location->read_config_single('tenant_id');
-
- $i++;
- if(substr($page,-2)=='_1')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uilocation.index&lookup_tenant=1&type_id='
. $config_tenant);
- $menu['sub_menu'][$i]['name']
= lang('Tenant');
- $menu['sub_menu'][$i]['statustext']
= lang('Tenant');
-
- $i++;
- if($page=='gab')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uigab.index');
- $menu['sub_menu'][$i]['name']
= lang('gabnr');
- $menu['sub_menu'][$i]['statustext']
= lang('gabnr');
- $i++;
- if($page=='summary')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uilocation.summary');
- $menu['sub_menu'][$i]['name']
= lang('Summary');
- $menu['sub_menu'][$i]['statustext']
= lang('Summary');
- }
-
- if ($sub == 'invoice')
- {
- $i++;
- if($page=='invoice_')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiinvoice.index');
- $menu['sub_menu'][$i]['name']
= lang('Invoice');
- $menu['sub_menu'][$i]['statustext']
= lang('Invoice');
- $i++;
- if($page=='invoice_1')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiinvoice.index&paid=true');
- $menu['sub_menu'][$i]['name']
= lang('Paid');
- $menu['sub_menu'][$i]['statustext']
= lang('Paid');
- $i++;
- if($page=='consume')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiinvoice.consume');
- $menu['sub_menu'][$i]['name']
= lang('consume');
- $menu['sub_menu'][$i]['statustext']
= lang('consume');
-
- $i++;
- if($page=='b_account')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uib_account.index');
- $menu['sub_menu'][$i]['name']
= lang('b_account');
- $menu['sub_menu'][$i]['statustext']
= lang('b_account');
-
- $i++;
- if($page=='vendor')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiactor.index&role=vendor');
- $menu['sub_menu'][$i]['name']
= lang('Vendor');
- $menu['sub_menu'][$i]['statustext']
= lang('Vendor');
-
- $i++;
- if($page=='tenant')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiactor.index&role=tenant');
- $menu['sub_menu'][$i]['name']
= lang('Tenant');
- $menu['sub_menu'][$i]['statustext']
= lang('Tenant');
-
- if ($this->acl2->check('.invoice',16))
- {
- $i++;
- if($page=='investment')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiinvestment.index');
- $menu['sub_menu'][$i]['name']
= lang('Investment value');
-
$menu['sub_menu'][$i]['statustext'] = lang('Investment
value');
- $i++;
- if($page=='import_inv')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiXport.import');
- $menu['sub_menu'][$i]['name']
= lang('Import invoice');
-
$menu['sub_menu'][$i]['statustext'] = lang('Import invoice');
- $i++;
- if($page=='export_inv')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiXport.export');
- $menu['sub_menu'][$i]['name']
= lang('Export invoice');
-
$menu['sub_menu'][$i]['statustext'] = lang('Export invoice');
- }
- if ($this->acl2->check('.invoice',2))
- {
- $i++;
- if($page=='add_inv')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiinvoice.add');
- $menu['sub_menu'][$i]['name']
= lang('Add');
-
$menu['sub_menu'][$i]['statustext'] = lang('Add invoice');
- }
- }
-
- if ($sub == 'pricebook' &&
$this->acl2->check('.pricebook',16))
- {
- $i++;
- if($page=='agreement_group')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uipricebook.agreement_group');
- $menu['sub_menu'][$i]['name']
= lang('Agreement group');
- $menu['sub_menu'][$i]['statustext']
= lang('Agreement group');
- $i++;
- if($page=='activity')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uipricebook.activity');
- $menu['sub_menu'][$i]['name']
= lang('Activities');
- $menu['sub_menu'][$i]['statustext']
= lang('Activities');
- $i++;
- if($page=='agreement')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiagreement.index');
- $menu['sub_menu'][$i]['name']
= lang('Agreement');
- $menu['sub_menu'][$i]['statustext']
= lang('Agreement');
- }
-//--------------
- if ($sub == 'agreement' &&
$this->acl2->check('.pricebook',16))
- {
- $i++;
- if($page=='agreement')
- {
-
$menu['sub_menu'][$i]['this']=True;
-
- $j=0;
- if($page_2=='agreement_group')
- {
-
$menu['sub_menu_2'][$j]['this']=True;
- }
- $menu['sub_menu_2'][$j]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uipricebook.agreement_group');
- $menu['sub_menu_2'][$j]['name']
= lang('Agreement group');
-
$menu['sub_menu_2'][$j]['statustext'] = lang('Agreement group');
- $j++;
- if($page_2=='activity')
- {
-
$menu['sub_menu_2'][$j]['this']=True;
- }
- $menu['sub_menu_2'][$j]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uipricebook.activity');
- $menu['sub_menu_2'][$j]['name']
= lang('Activities');
-
$menu['sub_menu_2'][$j]['statustext'] = lang('Activities');
- $j++;
- if($page_2=='agreement')
- {
-
$menu['sub_menu_2'][$j]['this']=True;
- }
- $menu['sub_menu_2'][$j]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiagreement.index');
- $menu['sub_menu_2'][$j]['name']
= lang('Agreement');
-
$menu['sub_menu_2'][$j]['statustext'] = lang('Agreement');
-
-
- }
-
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiagreement.index');
- $menu['sub_menu'][$i]['name']
= lang('Pricebook');
- $menu['sub_menu'][$i]['statustext']
= lang('Pricebook');
-
- $i++;
- if($page=='s_agreement')
- {
-
$menu['sub_menu'][$i]['this']=True;
-
- }
-
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uis_agreement.index');
- $menu['sub_menu'][$i]['name']
= lang('Service');
- $menu['sub_menu'][$i]['statustext']
= lang('service agreement');
- }
-
-//---------------
- if ($sub == 'project')
- {
- $i++;
- if($page=='project')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiproject.index');
- $menu['sub_menu'][$i]['name']
= lang('Project');
- $menu['sub_menu'][$i]['statustext']
= lang('Project');
- $i++;
- if($page=='workorder')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiworkorder.index');
- $menu['sub_menu'][$i]['name']
= lang('Workorder');
- $menu['sub_menu'][$i]['statustext']
= lang('Workorder');
-
-/* $i++;
- if($page=='s_agreement')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uis_agreement.index');
- $menu['sub_menu'][$i]['name']
= lang('Service');
- $menu['sub_menu'][$i]['statustext']
= lang('service agreement');
-*/ $i++;
-
- if($page=='request')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uirequest.index');
- $menu['sub_menu'][$i]['name']
= lang('Request');
- $menu['sub_menu'][$i]['statustext']
= lang('Request');
- $i++;
- if($page=='template')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uitemplate.index');
- $menu['sub_menu'][$i]['name']
= lang('template');
- $menu['sub_menu'][$i]['statustext']
= lang('Workorder template');
-
- $i++;
- if($page=='tenant_claim')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uitenant_claim.index');
- $menu['sub_menu'][$i]['name']
= lang('Tenant claim');
- $menu['sub_menu'][$i]['statustext']
= lang('Tenant claim');
- }
-
- if ($sub == adm_loc &&
$this->acl2->check('.location',16))
- {
- $i++;
- if($page=='loc_type')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiadmin_location.index');
- $menu['sub_menu'][$i]['name']
= lang('Location type');
- $menu['sub_menu'][$i]['statustext']
= lang('Location type');
- $i++;
- if($page=='loc_config')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiadmin_location.config');
- $menu['sub_menu'][$i]['name']
= lang('Config');
- $menu['sub_menu'][$i]['statustext']
= lang('Location Config');
- }
-
- if ($sub == 'document')
- {
- $i++;
- if($page=='document_')
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
- $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uidocument.index');
- $menu['sub_menu'][$i]['name']
= lang('location');
- $menu['sub_menu'][$i]['statustext']
= lang('Documentation for locations');
-
- if (isset($entity_list) AND
is_array($entity_list))
- {
- foreach($entity_list as $entry)
- {
-
if($entry['documentation'])
- {
- $i++;
-
if($page=='document_'.$entry['id'])
- {
-
$menu['sub_menu'][$i]['this']=True;
- }
-
$menu['sub_menu'][$i]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uidocument.index&entity_id='
.$entry['id']);
-
$menu['sub_menu'][$i]['name'] = $entry['name'];
-
$menu['sub_menu'][$i]['statustext'] = $entry['descr'];
- }
- }
- }
-
- }
-
- $menu =
$GLOBALS['phpgw']->session->appsession('menu',$currentapp.$sub,$menu);
- }
-
- return $menu;
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage core
+ * @version $Id: class.menu.inc.php,v 1.15 2006/01/27 14:05:43 sigurdne
Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class menu
+ {
+ var $sub;
+
+ var $public_functions = array
+ (
+ 'links' => True,
+ );
+
+ function menu($sub='')
+ {
+ $this->sub = $sub;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ }
+
+ function links($page='',$page_2='')
+ {
+ $currentapp=$this->currentapp;
+ $sub = $this->sub;
+// $menu =
$GLOBALS['phpgw']->session->appsession('menu',$currentapp.$sub);
+//_debug_array($page);
+ if(!$menu)
+ {
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+
+ $i=0;
+ if($sub=='location')
+ {
+ $menu['module'][$i]['this']=True;
+ }
+ $menu['module'][$i]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uilocation.index&type_id=1');
+ $menu['module'][$i]['name'] =
lang('Property');
+ $menu['module'][$i]['statustext'] =
lang('Property');
+ $i++;
+
+ if($sub=='ticket')
+ {
+ $menu['module'][$i]['this']=True;
+ }
+ $menu['module'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uitts.index');
+ $menu['module'][$i]['name']
= lang('Helpdesk');
+ $menu['module'][$i]['statustext'] =
lang('Helpdesk');
+ $i++;
+ if($sub=='project')
+ {
+ $menu['module'][$i]['this']=True;
+ }
+ $menu['module'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiproject.index');
+ $menu['module'][$i]['name']
= lang('Project');
+ $menu['module'][$i]['statustext'] =
lang('Project');
+ $i++;
+ if($sub=='invoice')
+ {
+ $menu['module'][$i]['this']=True;
+ }
+ $menu['module'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiinvoice.index');
+ $menu['module'][$i]['name']
= lang('Invoice');
+ $menu['module'][$i]['statustext'] =
lang('Invoice');
+
+/* $i++;
+ if($sub=='pricebook')
+ {
+ $menu['module'][$i]['this']=True;
+ }
+ $menu['module'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiagreement.index');
+ $menu['module'][$i]['name']
= lang('Pricebook');
+ $menu['module'][$i]['statustext'] =
lang('Pricebook');
+*/
+//--------------------
+ $i++;
+ if($sub=='agreement')
+ {
+ $menu['module'][$i]['this']=True;
+ }
+ $menu['module'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiagreement.index');
+ $menu['module'][$i]['name']
= lang('Agreement');
+ $menu['module'][$i]['statustext'] =
lang('Agreement');
+//----------------------
+ $i++;
+ if($sub=='document')
+ {
+ $menu['module'][$i]['this']=True;
+ }
+ $menu['module'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uidocument.index');
+ $menu['module'][$i]['name']
= lang('Documentation');
+ $menu['module'][$i]['statustext'] =
lang('Documentation');
+ $i++;
+ if($sub=='custom')
+ {
+ $menu['module'][$i]['this']=True;
+ }
+ $menu['module'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uicustom.index');
+ $menu['module'][$i]['name']
= lang('Custom');
+ $menu['module'][$i]['statustext'] =
lang('Custom queries');
+
+ $entity =
CreateObject($this->currentapp.'.soadmin_entity');
+ $entity_list =
$entity->read(array('allrows'=>True));
+
+ if (isset($entity_list) AND
is_array($entity_list))
+ {
+ foreach($entity_list as $entry)
+ {
+ $i++;
+ if($sub=='entity_' .
$entry['id'])
+ {
+
$menu['module'][$i]['this']=True;
+ }
+ $menu['module'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uientity.index&entity_id='
.$entry['id']);
+ $menu['module'][$i]['name']
= $entry['name'];
+
$menu['module'][$i]['statustext'] = $entry['descr'];
+ }
+ }
+
+ unset($entity);
+
+ if ($sub == 'location')
+ {
+ $soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
+ $location =
$soadmin_location->select_location_type();
+ $location_count=count($location);
+ for ($j=0; $j<$location_count; $j++)
+ {
+ $i++;
+
if($page=='location'.$location[$j]['id'].'_')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uilocation.index&type_id='
.$location[$j]['id'] );
+ $menu['sub_menu'][$i]['name'] =
$location[$j]['name'];
+
$menu['sub_menu'][$i]['statustext'] = $location[$j]['descr'];
+ }
+
+ $config_tenant =
$soadmin_location->read_config_single('tenant_id');
+
+ $i++;
+ if(substr($page,-2)=='_1')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uilocation.index&lookup_tenant=1&type_id='
. $config_tenant);
+ $menu['sub_menu'][$i]['name']
= lang('Tenant');
+ $menu['sub_menu'][$i]['statustext']
= lang('Tenant');
+
+ $i++;
+ if($page=='gab')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uigab.index');
+ $menu['sub_menu'][$i]['name']
= lang('gabnr');
+ $menu['sub_menu'][$i]['statustext']
= lang('gabnr');
+ $i++;
+ if($page=='summary')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uilocation.summary');
+ $menu['sub_menu'][$i]['name']
= lang('Summary');
+ $menu['sub_menu'][$i]['statustext']
= lang('Summary');
+ }
+
+ if ($sub == 'invoice')
+ {
+ $i++;
+ if($page=='invoice_')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiinvoice.index');
+ $menu['sub_menu'][$i]['name']
= lang('Invoice');
+ $menu['sub_menu'][$i]['statustext']
= lang('Invoice');
+ $i++;
+ if($page=='invoice_1')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiinvoice.index&paid=true');
+ $menu['sub_menu'][$i]['name']
= lang('Paid');
+ $menu['sub_menu'][$i]['statustext']
= lang('Paid');
+ $i++;
+ if($page=='consume')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiinvoice.consume');
+ $menu['sub_menu'][$i]['name']
= lang('consume');
+ $menu['sub_menu'][$i]['statustext']
= lang('consume');
+
+ $i++;
+ if($page=='b_account')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uib_account.index');
+ $menu['sub_menu'][$i]['name']
= lang('b_account');
+ $menu['sub_menu'][$i]['statustext']
= lang('b_account');
+
+ $i++;
+ if($page=='vendor')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiactor.index&role=vendor');
+ $menu['sub_menu'][$i]['name']
= lang('Vendor');
+ $menu['sub_menu'][$i]['statustext']
= lang('Vendor');
+
+ $i++;
+ if($page=='tenant')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiactor.index&role=tenant');
+ $menu['sub_menu'][$i]['name']
= lang('Tenant');
+ $menu['sub_menu'][$i]['statustext']
= lang('Tenant');
+
+ if ($this->acl2->check('.invoice',16))
+ {
+ $i++;
+ if($page=='investment')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiinvestment.index');
+ $menu['sub_menu'][$i]['name']
= lang('Investment value');
+
$menu['sub_menu'][$i]['statustext'] = lang('Investment
value');
+ $i++;
+ if($page=='import_inv')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiXport.import');
+ $menu['sub_menu'][$i]['name']
= lang('Import invoice');
+
$menu['sub_menu'][$i]['statustext'] = lang('Import invoice');
+ $i++;
+ if($page=='export_inv')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiXport.export');
+ $menu['sub_menu'][$i]['name']
= lang('Export invoice');
+
$menu['sub_menu'][$i]['statustext'] = lang('Export invoice');
+ }
+ if ($this->acl2->check('.invoice',2))
+ {
+ $i++;
+ if($page=='add_inv')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiinvoice.add');
+ $menu['sub_menu'][$i]['name']
= lang('Add');
+
$menu['sub_menu'][$i]['statustext'] = lang('Add invoice');
+ }
+ }
+
+ if ($sub == 'pricebook' &&
$this->acl2->check('.pricebook',16))
+ {
+ $i++;
+ if($page=='agreement_group')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uipricebook.agreement_group');
+ $menu['sub_menu'][$i]['name']
= lang('Agreement group');
+ $menu['sub_menu'][$i]['statustext']
= lang('Agreement group');
+ $i++;
+ if($page=='activity')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uipricebook.activity');
+ $menu['sub_menu'][$i]['name']
= lang('Activities');
+ $menu['sub_menu'][$i]['statustext']
= lang('Activities');
+ $i++;
+ if($page=='agreement')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiagreement.index');
+ $menu['sub_menu'][$i]['name']
= lang('Agreement');
+ $menu['sub_menu'][$i]['statustext']
= lang('Agreement');
+ }
+//--------------
+ if ($sub == 'agreement' &&
$this->acl2->check('.pricebook',16))
+ {
+ $i++;
+ if($page=='agreement')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+
+ $j=0;
+ if($page_2=='agreement_group')
+ {
+
$menu['sub_menu_2'][$j]['this']=True;
+ }
+ $menu['sub_menu_2'][$j]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uipricebook.agreement_group');
+ $menu['sub_menu_2'][$j]['name']
= lang('Agreement group');
+
$menu['sub_menu_2'][$j]['statustext'] = lang('Agreement group');
+ $j++;
+ if($page_2=='activity')
+ {
+
$menu['sub_menu_2'][$j]['this']=True;
+ }
+ $menu['sub_menu_2'][$j]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uipricebook.activity');
+ $menu['sub_menu_2'][$j]['name']
= lang('Activities');
+
$menu['sub_menu_2'][$j]['statustext'] = lang('Activities');
+ $j++;
+ if($page_2=='agreement')
+ {
+
$menu['sub_menu_2'][$j]['this']=True;
+ }
+ $menu['sub_menu_2'][$j]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiagreement.index');
+ $menu['sub_menu_2'][$j]['name']
= lang('Agreement');
+
$menu['sub_menu_2'][$j]['statustext'] = lang('Agreement');
+
+
+ }
+
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiagreement.index');
+ $menu['sub_menu'][$i]['name']
= lang('Pricebook');
+ $menu['sub_menu'][$i]['statustext']
= lang('Pricebook');
+
+ $i++;
+ if($page=='s_agreement')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+
+ }
+
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uis_agreement.index');
+ $menu['sub_menu'][$i]['name']
= lang('Service');
+ $menu['sub_menu'][$i]['statustext']
= lang('service agreement');
+ }
+
+//---------------
+ if ($sub == 'project')
+ {
+ $i++;
+ if($page=='project')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiproject.index');
+ $menu['sub_menu'][$i]['name']
= lang('Project');
+ $menu['sub_menu'][$i]['statustext']
= lang('Project');
+ $i++;
+ if($page=='workorder')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiworkorder.index');
+ $menu['sub_menu'][$i]['name']
= lang('Workorder');
+ $menu['sub_menu'][$i]['statustext']
= lang('Workorder');
+
+/* $i++;
+ if($page=='s_agreement')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uis_agreement.index');
+ $menu['sub_menu'][$i]['name']
= lang('Service');
+ $menu['sub_menu'][$i]['statustext']
= lang('service agreement');
+*/ $i++;
+
+ if($page=='request')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uirequest.index');
+ $menu['sub_menu'][$i]['name']
= lang('Request');
+ $menu['sub_menu'][$i]['statustext']
= lang('Request');
+ $i++;
+ if($page=='template')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uitemplate.index');
+ $menu['sub_menu'][$i]['name']
= lang('template');
+ $menu['sub_menu'][$i]['statustext']
= lang('Workorder template');
+
+ $i++;
+ if($page=='tenant_claim')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uitenant_claim.index');
+ $menu['sub_menu'][$i]['name']
= lang('Tenant claim');
+ $menu['sub_menu'][$i]['statustext']
= lang('Tenant claim');
+ }
+
+ if ($sub == adm_loc &&
$this->acl2->check('.location',16))
+ {
+ $i++;
+ if($page=='loc_type')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiadmin_location.index');
+ $menu['sub_menu'][$i]['name']
= lang('Location type');
+ $menu['sub_menu'][$i]['statustext']
= lang('Location type');
+ $i++;
+ if($page=='loc_config')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiadmin_location.config');
+ $menu['sub_menu'][$i]['name']
= lang('Config');
+ $menu['sub_menu'][$i]['statustext']
= lang('Location Config');
+ }
+
+ if ($sub == 'document')
+ {
+ $i++;
+ if($page=='document_')
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+ $menu['sub_menu'][$i]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uidocument.index');
+ $menu['sub_menu'][$i]['name']
= lang('location');
+ $menu['sub_menu'][$i]['statustext']
= lang('Documentation for locations');
+
+ if (isset($entity_list) AND
is_array($entity_list))
+ {
+ foreach($entity_list as $entry)
+ {
+
if($entry['documentation'])
+ {
+ $i++;
+
if($page=='document_'.$entry['id'])
+ {
+
$menu['sub_menu'][$i]['this']=True;
+ }
+
$menu['sub_menu'][$i]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uidocument.index&entity_id='
.$entry['id']);
+
$menu['sub_menu'][$i]['name'] = $entry['name'];
+
$menu['sub_menu'][$i]['statustext'] = $entry['descr'];
+ }
+ }
+ }
+
+ }
+
+ $menu =
$GLOBALS['phpgw']->session->appsession('menu',$currentapp.$sub,$menu);
+ }
+
+ return $menu;
+ }
+ }
+?>
Index: property/inc/class.pdf.inc.php
diff -u property/inc/class.pdf.inc.php:1.5 property/inc/class.pdf.inc.php:1.6
--- property/inc/class.pdf.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/class.pdf.inc.php Fri Jan 27 14:05:43 2006
@@ -1,15 +1,15 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package Cpdf
- * @version $Id: class.pdf.inc.php,v 1.5 2005/05/12 21:26:28 sigurdne
Exp $
- */
-
- include (PHPGW_APP_INC . '/pdf/class.pdf.php');
- include (PHPGW_APP_INC . '/pdf/class.ezpdf.php');
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package Cpdf
+ * @version $Id: class.pdf.inc.php,v 1.6 2006/01/27 14:05:43 sigurdne
Exp $
+ */
+
+ include (PHPGW_APP_INC . '/pdf/class.pdf.php');
+ include (PHPGW_APP_INC . '/pdf/class.ezpdf.php');
+?>
Index: property/inc/class.soXport.inc.php
diff -u property/inc/class.soXport.inc.php:1.19
property/inc/class.soXport.inc.php:1.20
--- property/inc/class.soXport.inc.php:1.19 Mon Oct 31 18:58:12 2005
+++ property/inc/class.soXport.inc.php Fri Jan 27 14:05:43 2006
@@ -1,549 +1,548 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.soXport.inc.php,v 1.19 2005/10/31 18:58:12
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class soXport
- {
- var $db = '';
- var $account_id = 0;
- var $total_records = 0;
-
- function soXport($useacl=True)
- {
-
- $GLOBALS['phpgw_info']['flags']['currentapp'] =
'property';
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db =
$GLOBALS['phpgw']->db;
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->join =
$this->bocommon->join;
- $this->left_join =
$this->bocommon->left_join;
- $this->datetimeformat =
$this->bocommon->datetimeformat;
- $this->like =
$this->bocommon->like;
- $this->account_id =
$GLOBALS['phpgw_info']['user']['account_id'];
- }
-
-
- function auto_tax($dima='')
- {
- if(!$dima)
- {
- return;
- }
- $sql = "select mva as tax_code from fm_location1 where
loc1=" . substr($dima,0,4);
- $this->db->query($sql);
- $this->db->next_record();
-
- return $this->db->f('tax_code');
- }
-
- function tax_b_account_override($mvakode='',$b_account_id='')
- {
- if(!$b_account_id)
- {
- return $mvakode;
- }
- $sql = "select mva as tax_code from fm_b_account where
id='$b_account_id'";
- $this->db->query($sql);
- $this->db->next_record();
-
- if($this->db->f('tax_code'))
- {
- return $this->db->f('tax_code');
- }
- else
- {
- return $mvakode;
- }
-
- }
-
- function tax_vendor_override($mvakode='',$vendor_id='')
- {
- if(!$vendor_id)
- {
- return $mvakode;
- }
- $sql = "select mva as tax_code from fm_vendor where
id='$vendor_id'";
- $this->db->query($sql);
- $this->db->next_record();
-
- if($this->db->f('tax_code'))
- {
- return $this->db->f('tax_code');
- }
- else
- {
- return $mvakode;
- }
-
- }
-
- function get_kostra_id($dima='')
- {
- if(!$dima)
- {
- return;
- }
- $sql = "select kostra_id from fm_location1 where loc1="
. substr($dima,0,4);
- $this->db->query($sql);
- $this->db->next_record();
-
- return $this->db->f('kostra_id');
- }
-
- function anleggsnr_to_objekt($anleggsnr,$meter_table)
- {
- $this->db->query("select
$meter_table.ext_meter_id,$meter_table.loc1,$meter_table.loc2,$meter_table.loc3,fm_part_of_town.district_id
"
- . " from $meter_table $this->join fm_location1 ON
$meter_table.loc1 = fm_location1.loc1 $this->join "
- . " fm_part_of_town ON fm_location1.part_of_town_id =
fm_part_of_town.part_of_town_id where $meter_table.ext_system_id='$anleggsnr'");
-
- $this->db->next_record();
-
-// $location = split("-",
$this->db->f('location_code'));
-
- $loc1 = $this->db->f('loc1');
- $loc2 = $this->db->f('loc2');
- $loc3 = $this->db->f('loc3');
- $dima=$loc1.$loc2.$loc3;
-
- $maalerinfo['loc1']=$loc1;
- $maalerinfo['dima']=$dima;
- $maalerinfo['maalernr']=$this->db->f('ext_meter_id');
- $maalerinfo['district']=$this->db->f('district_id');
- return $maalerinfo;
-
- }
-
- function gabnr_to_objekt($Gnr,$Bnr,$sekjonnr)
- {
- //Finn dima fra Boei
- $sql = "select fm_gab_location.loc1,
fm_gab_location.loc2, fm_gab_location.loc3 from fm_gab_location, fm_location1,
fm_owner "
- . "where substring(fm_gab_location.gab_id,5,5)='$Gnr'
and "
- . " substring(fm_gab_location.gab_id,10,4)='$Bnr'
and "
- . "
substring(fm_gab_location.gab_id,18,3)='$sekjonnr' and "
- . " fm_gab_location.loc1=fm_location1.loc1 and "
- . " fm_location1.owner_id=fm_owner.id ";
- // . " and (fm_owner.category=0 or
fm_owner.category=2)";
-
- $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
- $GLOBALS['phpgw']->db->next_record();
-
- $gabinfo['loc1']=$GLOBALS['phpgw']->db->f('loc1');
-
$gabinfo['dima']=$GLOBALS['phpgw']->db->f('loc1').$GLOBALS['phpgw']->db->f('loc2').$GLOBALS['phpgw']->db->f('loc3');
-
- return $gabinfo;
- }
-
-
- function dima_to_address($dima)
- {
- $loc1=substr($dima,0,4);
- $loc2=substr($dima,4,2);
- $loc3=substr($dima,6,2);
- $sql = "select loc3_name from fm_location3 where loc1 =
'$loc1' and loc2= '$loc2' and loc3 = '$loc3' ";
- $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
- $GLOBALS['phpgw']->db->next_record();
- $address=$GLOBALS['phpgw']->db->f('loc3_name');
- return $address;
-
- }
-
- function check_order($id)
- {
- $this->db->query("select id,type from fm_orders where
id='$id'");
- $this->db->next_record();
- return $this->db->f('type');
- }
-
- function get_project($id)
- {
- $this->db->query("select project_id from fm_workorder
where id='$id'");
- $this->db->next_record();
- return $this->db->f('project_id');
- }
-
- function check_spbudact_code($id)
- {
-
- $this->db->query("select count(*) from fm_b_account
where id='$id'");
- $this->db->next_record();
- return $this->db->f(0);
- }
-
- function add($buffer)
- {
- $this->db->transaction_begin();
-
- $num=0;
- foreach ($buffer as $fields)
- {
- if(abs($fields['belop'])>0)
- {
- $values= array(
- $fields['project_id'],
- $fields['kostra_id'],
- $fields['pmwrkord_code'],
- $fields['bilagsnr'],
- $fields['splitt'],
- $fields['kildeid'],
- $fields['kidnr'],
- $fields['typeid'],
- $fields['fakturadato'],
- $fields['forfallsdato'],
- $fields['regtid'],
- $fields['artid'],
- $fields['spvend_code'],
- $fields['dimb'],
- $fields['oppsynsmannid'],
- $fields['saksbehandlerid'],
- $fields['budsjettansvarligid'],
- $fields['fakturanr'],
- $fields['spbudact_code'],
- $fields['loc1'],
- $fields['dima'],
- $fields['dimd'],
- $fields['mvakode'],
- $fields['periode'],
-
$this->db->db_addslashes($fields['merknad']),
- False,
- False,
- False,
- False,
- $fields['item_type'],
- $fields['item_id']
- );
-
- $bilagsnr = $fields['bilagsnr'];
-
- $values =
$this->bocommon->validate_db_insert($values);
-
- $sql= "INSERT INTO fm_ecobilag
(project_id,kostra_id,pmwrkord_code,bilagsnr,splitt,kildeid,kidnr,typeid,fakturadato,"
- . "
forfallsdato,regtid,artid,spvend_code,dimb,oppsynsmannid,saksbehandlerid,budsjettansvarligid,"
- . "
fakturanr,spbudact_code,loc1,dima,dimd,mvakode,periode,merknad,oppsynsigndato,saksigndato,"
- . "
budsjettsigndato,utbetalingsigndato,item_type,item_id,belop,godkjentbelop)"
- . " VALUES ($values," .
$this->bocommon->moneyformat($fields['belop']) . "," .
$this->bocommon->moneyformat($fields['godkjentbelop']) . ")";
-
-
$this->db->query($sql,__LINE__,__FILE__);
-
- $num++;
- }
- }
-
- $this->db->query("UPDATE fm_idgenerator set value
=$bilagsnr WHERE name = 'Bilagsnummer'");
-
- $this->db->transaction_commit();
-
- return $num;
- }
-
- function add_OverfBilag ($data)
- {
- $values= array(
- $data['id'],
- $data['bilagsnr'],
- $data['kidnr'],
- $data['typeid'],
- $data['kildeid'],
- $data['project_id'],
- $data['kostra_id'],
- $data['pmwrkord_code'],
- $data['fakturadato'],
- $data['periode'],
- $data['forfallsdato'],
- $data['fakturanr'],
- $data['spbudact_code'],
- $data['regtid'],
- $data['artid'],
- $data['spvend_code'],
- $data['dima'],
- $data['loc1'],
- $data['dimb'],
- $data['mvakode'],
- $data['dimd'],
- $data['oppsynsmannid'],
- $data['saksbehandlerid'],
- $data['budsjettansvarligid'],
- $data['oppsynsigndato'],
- $data['saksigndato'],
- $data['budsjettsigndato'],
- $this->db->db_addslashes($data['merknad']),
- $data['splitt'],
- $data['utbetalingid'],
- $data['utbetalingsigndato'],
- $data['filnavn'],
- date("Y-m-d G:i:s"),
- $data['item_type'],
- $data['item_id'],
- );
-
- $values = $this->bocommon->validate_db_insert($values);
-
- $sql="INSERT INTO fm_ecobilagoverf
(id,bilagsnr,kidnr,typeid,kildeid,project_id,kostra_id,pmwrkord_code,fakturadato,"
- . "
periode,forfallsdato,fakturanr,spbudact_code,regtid,artid,spvend_code,dima,loc1,"
- . "
dimb,mvakode,dimd,oppsynsmannid,saksbehandlerid,budsjettansvarligid,oppsynsigndato,saksigndato,"
- . "
budsjettsigndato,merknad,splitt,utbetalingid,utbetalingsigndato,filnavn,overftid,item_type,item_id,"
- . " belop,godkjentbelop,ordrebelop)"
- . "values ($values, "
- . $this->bocommon->moneyformat($data['belop'])
. ","
- .
$this->bocommon->moneyformat($data['godkjentbelop']) . ","
- .
$this->bocommon->moneyformat($data['ordrebelop']) . ")";
-
- $this->db->query($sql,__LINE__,__FILE__);
-//echo 'sql ' . $sql.'<br>';
- }
-
- function delete_from_fm_ecobilag($id)
- {
- $sql="delete from fm_ecobilag where id=$id";
- $this->db->query($sql,__LINE__,__FILE__);
- }
-
- // Velg ut alle hoved bilag som skal overføres
- function hoved_bilag ($periode,$pre_transfer='')
- {
- if($pre_transfer)
- {
- $sql= "SELECT sum(belop) as belop, bilagsnr
from fm_ecobilag WHERE periode='$periode' AND utbetalingsigndato IS NULL GROUP
BY bilagsnr ";
- }
- else
- {
- $sql="select sum(belop) as belop, bilagsnr from
fm_ecobilag where periode='$periode' AND budsjettsigndato is not NULL AND (
saksigndato is not NULL OR oppsynsigndato is not NULL ) AND
utbetalingsigndato is not NULL group by bilagsnr";
- }
-
- $this->db->query($sql,__LINE__,__FILE__);
- $i = 0;
- while ($this->db->next_record())
- {
- $hoved_bilag_temp[$i]['belop'] =
$this->db->f('belop');
- $hoved_bilag_temp[$i]['bilagsnr'] =
$this->db->f('bilagsnr');
- $i++;
- }
-
-//_debug_array($hoved_bilag_temp);
-
- if ($hoved_bilag_temp)
- {
- $i = 0;
- while(each($hoved_bilag_temp))
- {
- $bilagsnr =
$hoved_bilag_temp[$i]['bilagsnr'];
-
- $sql= "select
fm_ecobilag.*,fm_ecouser.initials as saksbehandler from fm_ecobilag $this->join
fm_ecouser on fm_ecobilag.budsjettansvarligid=fm_ecouser.lid where
bilagsnr=$bilagsnr ";
-
$this->db->query($sql,__LINE__,__FILE__);
-
- $this->db->next_record();
-
- $hoved_bilag[$i]['id']
= $this->db->f('id');
- $hoved_bilag[$i]['bilagsnr']
= $bilagsnr;
- $hoved_bilag[$i]['kidnr']
= $this->db->f('kidnr');
- $hoved_bilag[$i]['typeid']
= $this->db->f('typeid');
- $hoved_bilag[$i]['kildeid']
= $this->db->f('kildeid');
- $hoved_bilag[$i]['pmwrkord_code']
= $this->db->f('pmwrkord_code');
- $hoved_bilag[$i]['belop']
= $hoved_bilag_temp[$i]['belop'];
- $hoved_bilag[$i]['fakturadato']
= $this->db->f('fakturadato');
- $hoved_bilag[$i]['periode']
= $this->db->f('periode');
- $hoved_bilag[$i]['forfallsdato']
= $this->db->f('forfallsdato');
- $hoved_bilag[$i]['fakturanr']
= $this->db->f('fakturanr');
- $hoved_bilag[$i]['spbudact_code']
= $this->db->f('spbudact_code');
- $hoved_bilag[$i]['regtid']
= $this->db->f('regtid');
- $hoved_bilag[$i]['artid']
= $this->db->f('artid');
- $hoved_bilag[$i]['godkjentbelop']
= $hoved_bilag_temp[$i]['belop'];
- $hoved_bilag[$i]['spvend_code']
= $this->db->f('spvend_code');
- $hoved_bilag[$i]['dima']
= $this->db->f('dima');
- $hoved_bilag[$i]['dimb']
= $this->db->f('dimb');
- $hoved_bilag[$i]['mvakode']
= $this->db->f('mvakode');
- $hoved_bilag[$i]['dimd']
= $this->db->f('dimd');
- if($this->db->f('oppsynsmannid'))
- {
-
$hoved_bilag[$i]['oppsynsmannid'] = $this->db->f('oppsynsmannid');
- }
- if($this->db->f('saksbehandlerid'))
- {
-
$hoved_bilag[$i]['saksbehandlerid'] = $this->db->f('saksbehandlerid');
- }
-
- $hoved_bilag[$i]['budsjettansvarligid']
= $this->db->f('budsjettansvarligid');
-
- if($this->db->f('oppsynsigndato'))
- {
-
$hoved_bilag[$i]['oppsynsigndato'] = $this->db->f('oppsynsigndato');
- }
- if($this->db->f('saksigndato'))
- {
- $hoved_bilag[$i]['saksigndato']
= $this->db->f('saksigndato');
- }
-
- $hoved_bilag[$i]['budsjettsigndato']
= $this->db->f('budsjettsigndato');
- $hoved_bilag[$i]['merknad']
= $this->db->f('merknad');
- $hoved_bilag[$i]['splitt']
= $this->db->f('splitt');
- $hoved_bilag[$i]['utbetalingid']
= $this->db->f('utbetalingid');
- $hoved_bilag[$i]['utbetalingsigndato']
= $this->db->f('utbetalingsigndato');
- $hoved_bilag[$i]['saksbehandler']
= $this->db->f('saksbehandler');
- $i++;
- }
- }
-//_debug_array($hoved_bilag);
-
- return $hoved_bilag;
- }
-
- //Velg ut alle underbilag
-
- function select_underbilag ($bilagsnr)
- {
- $sql= "SELECT fm_ecobilag.*
,fm_part_of_town.district_id FROM (fm_location1 $this->join fm_part_of_town ON
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id) $this->join
fm_ecobilag ON fm_location1.loc1 = fm_ecobilag.loc1 WHERE bilagsnr='$bilagsnr'";
-
- $this->db->query($sql,__LINE__,__FILE__);
- $i = 0;
- while ($this->db->next_record())
- {
- $underbilag[$i]['id'] = $this->db->f('id');
- $underbilag[$i]['bilagsnr'] =
$this->db->f('bilagsnr');
- $underbilag[$i]['kidnr'] =
$this->db->f('kidnr');
- $underbilag[$i]['typeid'] =
$this->db->f('typeid');
- $underbilag[$i]['kildeid'] =
$this->db->f('kildeid');
- $underbilag[$i]['pmwrkord_code'] =
$this->db->f('pmwrkord_code');
- $underbilag[$i]['belop'] =
$this->db->f('belop');
- $underbilag[$i]['fakturadato'] =
$this->db->f('fakturadato');
- $underbilag[$i]['periode'] =
$this->db->f('periode');
- $underbilag[$i]['forfallsdato'] =
$this->db->f('forfallsdato');
- $underbilag[$i]['fakturanr'] =
$this->db->f('fakturanr');
- $underbilag[$i]['spbudact_code'] =
$this->db->f('spbudact_code');
- $underbilag[$i]['regtid'] =
$this->db->f('regtid');
- $underbilag[$i]['artid'] =
$this->db->f('artid');
- $underbilag[$i]['godkjentbelop'] =
$this->db->f('godkjentbelop');
- $underbilag[$i]['spvend_code'] =
$this->db->f('spvend_code');
- $underbilag[$i]['dima'] = $this->db->f('dima');
- $underbilag[$i]['loc1'] = $this->db->f('loc1');
- $underbilag[$i]['dimb'] = $this->db->f('dimb');
- $underbilag[$i]['mvakode'] =
$this->db->f('mvakode');
- $underbilag[$i]['dimd'] = $this->db->f('dimd');
- $underbilag[$i]['project_id'] =
$this->db->f('project_id');
- $underbilag[$i]['kostra_id'] =
$this->db->f('kostra_id');
- if($this->db->f('oppsynsmannid'))
- {
- $underbilag[$i]['oppsynsmannid']
= $this->db->f('oppsynsmannid');
- }
- if($this->db->f('saksbehandlerid'))
- {
- $underbilag[$i]['saksbehandlerid']
= $this->db->f('saksbehandlerid');
- }
-
- $underbilag[$i]['budsjettansvarligid'] =
$this->db->f('budsjettansvarligid');
-
- if($this->db->f('oppsynsigndato'))
- {
- $underbilag[$i]['oppsynsigndato']
= $this->db->f('oppsynsigndato');
- }
- if($this->db->f('saksigndato'))
- {
- $underbilag[$i]['saksigndato'] =
$this->db->f('saksigndato');
- }
-
- $underbilag[$i]['budsjettsigndato'] =
$this->db->f('budsjettsigndato');
- $underbilag[$i]['merknad'] =
$this->db->f('merknad');
- $underbilag[$i]['splitt'] =
$this->db->f('splitt');
- $underbilag[$i]['utbetalingid'] =
$this->db->f('utbetalingid');
- $underbilag[$i]['utbetalingsigndato'] =
$this->db->f('utbetalingsigndato');
- $underbilag[$i]['district_id'] =
$this->db->f('district_id');
- $underbilag[$i]['item_type'] =
$this->db->f('item_type');
- $underbilag[$i]['item_id'] =
$this->db->f('item_id');
- $i++;
-
- }
-
- return $underbilag;
- }
-
-/* function update_avvik($avvik)
- {
- }
-
-*/
- function log_to_deviation_table($oRsBilag)
- {
- $bilagsnr=$oRsBilag['bilagsnr'];
- $fakturadato=$oRsBilag['fakturadato'];
- $forfallsdato=$oRsBilag['forfallsdato'];
- $oppsynsmannid=$oRsBilag['oppsynsmannid'];
- $oppsynsigndato=$oRsBilag['oppsynsigndato'];
- $saksbehandlerid=$oRsBilag['saksbehandlerid'];
- $saksigndato=$oRsBilag['saksigndato'];
- $budsjettansvarligid=$oRsBilag['budsjettansvarligid'];
- $budsjettsigndato=$oRsBilag['budsjettsigndato'];
- $artid=$oRsBilag['artid'];
- $spvend_code=$oRsBilag['spvend_code'];
- $belop=$oRsBilag['belop'];
- $godkjentbelop=$oRsBilag['godkjentbelop'];
-
- $sql="INSERT INTO fm_ecoavvik
(bilagsnr,fakturadato,forfallsdato,oppsynsmannid,oppsynsigndato,saksbehandlerid,saksigndato,budsjettansvarligid,budsjettsigndato,artid,spvend_code,belop,godkjentbelop)
values "
- .
"($bilagsnr','$fakturadato','$forfallsdato','$oppsynsmannid','$oppsynsigndato','$saksbehandlerid','$saksigndato','$budsjettansvarligid','$budsjettsigndato','$artid','$spvend_code','$belop','$godkjentbelop')";
- $this->db->query($sql,__LINE__,__FILE__);
- }
-
- function delete_avvik($bilagsnr)
- {
- $sql="delete from fm_ecoavvik where
bilagsnr='$bilagsnr'";
- $this->db->query($sql,__LINE__,__FILE__);
- }
-
- function delete_invoice($bilagsnr)
- {
- $sql="delete from fm_ecobilagoverf where
bilagsnr='$bilagsnr'";
- $this->db->query($sql,__LINE__,__FILE__);
- }
-
- //Logg transaksjon
- function log_transaction($batchid,$bilagid,$message='')
- {
- $tid=date($this->datetimeformat);
- $sql= "insert into fm_ecologg
(batchid,ecobilagid,melding,tid) values ('$batchid','$bilagid'
,'$message','$tid')";
- $this->db->query($sql,__LINE__,__FILE__);
- }
-
- function increment_batchid()
- {
- $this->db->query("update fm_idgenerator set value =
value + 1 where name = 'Ecobatchid'");
- $this->db->query("select value from fm_idgenerator
where name = 'Ecobatchid'");
- $this->db->next_record();
- $bilagsnr = $this->db->f('value');
- return $bilagsnr;
-
- }
-
- function next_batchid()
- {
-
- $this->db->query("select value from fm_idgenerator
where name = 'Ecobatchid'");
- $this->db->next_record();
- $batchid = $this->db->f('value')+1;
-
- return $batchid;
- }
-
- function get_responsible($b_abbount_id)
- {
- $this->db->query("select account_lid from fm_b_account
$this->join phpgw_accounts on fm_b_account.responsible =
phpgw_accounts.account_id where fm_b_account.id = '$b_abbount_id'");
- $this->db->next_record();
- $responsible = $this->db->f('account_lid');
- return $responsible;
- }
-
- }
-
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.soXport.inc.php,v 1.20 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class soXport
+ {
+ var $db = '';
+ var $account_id = 0;
+ var $total_records = 0;
+
+ function soXport($useacl=True)
+ {
+
+ $GLOBALS['phpgw_info']['flags']['currentapp'] =
'property';
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
$this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join =
$this->bocommon->join;
+ $this->left_join =
$this->bocommon->left_join;
+ $this->datetimeformat =
$this->bocommon->datetimeformat;
+ $this->like =
$this->bocommon->like;
+ $this->account_id =
$GLOBALS['phpgw_info']['user']['account_id'];
+ }
+
+
+ function auto_tax($dima='')
+ {
+ if(!$dima)
+ {
+ return;
+ }
+ $sql = "select mva as tax_code from fm_location1 where
loc1=" . substr($dima,0,4);
+ $this->db->query($sql);
+ $this->db->next_record();
+
+ return $this->db->f('tax_code');
+ }
+
+ function tax_b_account_override($mvakode='',$b_account_id='')
+ {
+ if(!$b_account_id)
+ {
+ return $mvakode;
+ }
+ $sql = "select mva as tax_code from fm_b_account where
id='$b_account_id'";
+ $this->db->query($sql);
+ $this->db->next_record();
+
+ if($this->db->f('tax_code'))
+ {
+ return $this->db->f('tax_code');
+ }
+ else
+ {
+ return $mvakode;
+ }
+
+ }
+
+ function tax_vendor_override($mvakode='',$vendor_id='')
+ {
+ if(!$vendor_id)
+ {
+ return $mvakode;
+ }
+ $sql = "select mva as tax_code from fm_vendor where
id='$vendor_id'";
+ $this->db->query($sql);
+ $this->db->next_record();
+
+ if($this->db->f('tax_code'))
+ {
+ return $this->db->f('tax_code');
+ }
+ else
+ {
+ return $mvakode;
+ }
+
+ }
+
+ function get_kostra_id($dima='')
+ {
+ if(!$dima)
+ {
+ return;
+ }
+ $sql = "select kostra_id from fm_location1 where loc1="
. substr($dima,0,4);
+ $this->db->query($sql);
+ $this->db->next_record();
+
+ return $this->db->f('kostra_id');
+ }
+
+ function anleggsnr_to_objekt($anleggsnr,$meter_table)
+ {
+ $this->db->query("select
$meter_table.ext_meter_id,$meter_table.loc1,$meter_table.loc2,$meter_table.loc3,fm_part_of_town.district_id
"
+ . " from $meter_table $this->join fm_location1 ON
$meter_table.loc1 = fm_location1.loc1 $this->join "
+ . " fm_part_of_town ON fm_location1.part_of_town_id =
fm_part_of_town.part_of_town_id where $meter_table.ext_system_id='$anleggsnr'");
+
+ $this->db->next_record();
+
+// $location = split("-",
$this->db->f('location_code'));
+
+ $loc1 = $this->db->f('loc1');
+ $loc2 = $this->db->f('loc2');
+ $loc3 = $this->db->f('loc3');
+ $dima=$loc1.$loc2.$loc3;
+
+ $maalerinfo['loc1']=$loc1;
+ $maalerinfo['dima']=$dima;
+ $maalerinfo['maalernr']=$this->db->f('ext_meter_id');
+ $maalerinfo['district']=$this->db->f('district_id');
+ return $maalerinfo;
+
+ }
+
+ function gabnr_to_objekt($Gnr,$Bnr,$sekjonnr)
+ {
+ //Finn dima fra Boei
+ $sql = "select fm_gab_location.loc1,
fm_gab_location.loc2, fm_gab_location.loc3 from fm_gab_location, fm_location1,
fm_owner "
+ . "where substring(fm_gab_location.gab_id,5,5)='$Gnr'
and "
+ . " substring(fm_gab_location.gab_id,10,4)='$Bnr'
and "
+ . "
substring(fm_gab_location.gab_id,18,3)='$sekjonnr' and "
+ . " fm_gab_location.loc1=fm_location1.loc1 and "
+ . " fm_location1.owner_id=fm_owner.id ";
+ // . " and (fm_owner.category=0 or
fm_owner.category=2)";
+
+ $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
+ $GLOBALS['phpgw']->db->next_record();
+
+ $gabinfo['loc1']=$GLOBALS['phpgw']->db->f('loc1');
+
$gabinfo['dima']=$GLOBALS['phpgw']->db->f('loc1').$GLOBALS['phpgw']->db->f('loc2').$GLOBALS['phpgw']->db->f('loc3');
+
+ return $gabinfo;
+ }
+
+
+ function dima_to_address($dima)
+ {
+ $loc1=substr($dima,0,4);
+ $loc2=substr($dima,4,2);
+ $loc3=substr($dima,6,2);
+ $sql = "select loc3_name from fm_location3 where loc1 =
'$loc1' and loc2= '$loc2' and loc3 = '$loc3' ";
+ $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
+ $GLOBALS['phpgw']->db->next_record();
+ $address=$GLOBALS['phpgw']->db->f('loc3_name');
+ return $address;
+
+ }
+
+ function check_order($id)
+ {
+ $this->db->query("select id,type from fm_orders where
id='$id'");
+ $this->db->next_record();
+ return $this->db->f('type');
+ }
+
+ function get_project($id)
+ {
+ $this->db->query("select project_id from fm_workorder
where id='$id'");
+ $this->db->next_record();
+ return $this->db->f('project_id');
+ }
+
+ function check_spbudact_code($id)
+ {
+
+ $this->db->query("select count(*) from fm_b_account
where id='$id'");
+ $this->db->next_record();
+ return $this->db->f(0);
+ }
+
+ function add($buffer)
+ {
+ $this->db->transaction_begin();
+
+ $num=0;
+ foreach ($buffer as $fields)
+ {
+ if(abs($fields['belop'])>0)
+ {
+ $values= array(
+ $fields['project_id'],
+ $fields['kostra_id'],
+ $fields['pmwrkord_code'],
+ $fields['bilagsnr'],
+ $fields['splitt'],
+ $fields['kildeid'],
+ $fields['kidnr'],
+ $fields['typeid'],
+ $fields['fakturadato'],
+ $fields['forfallsdato'],
+ $fields['regtid'],
+ $fields['artid'],
+ $fields['spvend_code'],
+ $fields['dimb'],
+ $fields['oppsynsmannid'],
+ $fields['saksbehandlerid'],
+ $fields['budsjettansvarligid'],
+ $fields['fakturanr'],
+ $fields['spbudact_code'],
+ $fields['loc1'],
+ $fields['dima'],
+ $fields['dimd'],
+ $fields['mvakode'],
+ $fields['periode'],
+
$this->db->db_addslashes($fields['merknad']),
+ False,
+ False,
+ False,
+ False,
+ $fields['item_type'],
+ $fields['item_id']
+ );
+
+ $bilagsnr = $fields['bilagsnr'];
+
+ $values =
$this->bocommon->validate_db_insert($values);
+
+ $sql= "INSERT INTO fm_ecobilag
(project_id,kostra_id,pmwrkord_code,bilagsnr,splitt,kildeid,kidnr,typeid,fakturadato,"
+ . "
forfallsdato,regtid,artid,spvend_code,dimb,oppsynsmannid,saksbehandlerid,budsjettansvarligid,"
+ . "
fakturanr,spbudact_code,loc1,dima,dimd,mvakode,periode,merknad,oppsynsigndato,saksigndato,"
+ . "
budsjettsigndato,utbetalingsigndato,item_type,item_id,belop,godkjentbelop)"
+ . " VALUES ($values," .
$this->bocommon->moneyformat($fields['belop']) . "," .
$this->bocommon->moneyformat($fields['godkjentbelop']) . ")";
+
+
$this->db->query($sql,__LINE__,__FILE__);
+
+ $num++;
+ }
+ }
+
+ $this->db->query("UPDATE fm_idgenerator set value
=$bilagsnr WHERE name = 'Bilagsnummer'");
+
+ $this->db->transaction_commit();
+
+ return $num;
+ }
+
+ function add_OverfBilag ($data)
+ {
+ $values= array(
+ $data['id'],
+ $data['bilagsnr'],
+ $data['kidnr'],
+ $data['typeid'],
+ $data['kildeid'],
+ $data['project_id'],
+ $data['kostra_id'],
+ $data['pmwrkord_code'],
+ $data['fakturadato'],
+ $data['periode'],
+ $data['forfallsdato'],
+ $data['fakturanr'],
+ $data['spbudact_code'],
+ $data['regtid'],
+ $data['artid'],
+ $data['spvend_code'],
+ $data['dima'],
+ $data['loc1'],
+ $data['dimb'],
+ $data['mvakode'],
+ $data['dimd'],
+ $data['oppsynsmannid'],
+ $data['saksbehandlerid'],
+ $data['budsjettansvarligid'],
+ $data['oppsynsigndato'],
+ $data['saksigndato'],
+ $data['budsjettsigndato'],
+ $this->db->db_addslashes($data['merknad']),
+ $data['splitt'],
+ $data['utbetalingid'],
+ $data['utbetalingsigndato'],
+ $data['filnavn'],
+ date("Y-m-d G:i:s"),
+ $data['item_type'],
+ $data['item_id'],
+ );
+
+ $values = $this->bocommon->validate_db_insert($values);
+
+ $sql="INSERT INTO fm_ecobilagoverf
(id,bilagsnr,kidnr,typeid,kildeid,project_id,kostra_id,pmwrkord_code,fakturadato,"
+ . "
periode,forfallsdato,fakturanr,spbudact_code,regtid,artid,spvend_code,dima,loc1,"
+ . "
dimb,mvakode,dimd,oppsynsmannid,saksbehandlerid,budsjettansvarligid,oppsynsigndato,saksigndato,"
+ . "
budsjettsigndato,merknad,splitt,utbetalingid,utbetalingsigndato,filnavn,overftid,item_type,item_id,"
+ . " belop,godkjentbelop,ordrebelop)"
+ . "values ($values, "
+ . $this->bocommon->moneyformat($data['belop'])
. ","
+ .
$this->bocommon->moneyformat($data['godkjentbelop']) . ","
+ .
$this->bocommon->moneyformat($data['ordrebelop']) . ")";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+//echo 'sql ' . $sql.'<br>';
+ }
+
+ function delete_from_fm_ecobilag($id)
+ {
+ $sql="delete from fm_ecobilag where id=$id";
+ $this->db->query($sql,__LINE__,__FILE__);
+ }
+
+ // Velg ut alle hoved bilag som skal overføres
+ function hoved_bilag ($periode,$pre_transfer='')
+ {
+ if($pre_transfer)
+ {
+ $sql= "SELECT sum(belop) as belop, bilagsnr
from fm_ecobilag WHERE periode='$periode' AND utbetalingsigndato IS NULL GROUP
BY bilagsnr ";
+ }
+ else
+ {
+ $sql="select sum(belop) as belop, bilagsnr from
fm_ecobilag where periode='$periode' AND budsjettsigndato is not NULL AND (
saksigndato is not NULL OR oppsynsigndato is not NULL ) AND
utbetalingsigndato is not NULL group by bilagsnr";
+ }
+
+ $this->db->query($sql,__LINE__,__FILE__);
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $hoved_bilag_temp[$i]['belop'] =
$this->db->f('belop');
+ $hoved_bilag_temp[$i]['bilagsnr'] =
$this->db->f('bilagsnr');
+ $i++;
+ }
+
+//_debug_array($hoved_bilag_temp);
+
+ if ($hoved_bilag_temp)
+ {
+ $i = 0;
+ while(each($hoved_bilag_temp))
+ {
+ $bilagsnr =
$hoved_bilag_temp[$i]['bilagsnr'];
+
+ $sql= "select
fm_ecobilag.*,fm_ecouser.initials as saksbehandler from fm_ecobilag $this->join
fm_ecouser on fm_ecobilag.budsjettansvarligid=fm_ecouser.lid where
bilagsnr=$bilagsnr ";
+
$this->db->query($sql,__LINE__,__FILE__);
+
+ $this->db->next_record();
+
+ $hoved_bilag[$i]['id']
= $this->db->f('id');
+ $hoved_bilag[$i]['bilagsnr']
= $bilagsnr;
+ $hoved_bilag[$i]['kidnr']
= $this->db->f('kidnr');
+ $hoved_bilag[$i]['typeid']
= $this->db->f('typeid');
+ $hoved_bilag[$i]['kildeid']
= $this->db->f('kildeid');
+ $hoved_bilag[$i]['pmwrkord_code']
= $this->db->f('pmwrkord_code');
+ $hoved_bilag[$i]['belop']
= $hoved_bilag_temp[$i]['belop'];
+ $hoved_bilag[$i]['fakturadato']
= $this->db->f('fakturadato');
+ $hoved_bilag[$i]['periode']
= $this->db->f('periode');
+ $hoved_bilag[$i]['forfallsdato']
= $this->db->f('forfallsdato');
+ $hoved_bilag[$i]['fakturanr']
= $this->db->f('fakturanr');
+ $hoved_bilag[$i]['spbudact_code']
= $this->db->f('spbudact_code');
+ $hoved_bilag[$i]['regtid']
= $this->db->f('regtid');
+ $hoved_bilag[$i]['artid']
= $this->db->f('artid');
+ $hoved_bilag[$i]['godkjentbelop']
= $hoved_bilag_temp[$i]['belop'];
+ $hoved_bilag[$i]['spvend_code']
= $this->db->f('spvend_code');
+ $hoved_bilag[$i]['dima']
= $this->db->f('dima');
+ $hoved_bilag[$i]['dimb']
= $this->db->f('dimb');
+ $hoved_bilag[$i]['mvakode']
= $this->db->f('mvakode');
+ $hoved_bilag[$i]['dimd']
= $this->db->f('dimd');
+ if($this->db->f('oppsynsmannid'))
+ {
+
$hoved_bilag[$i]['oppsynsmannid'] = $this->db->f('oppsynsmannid');
+ }
+ if($this->db->f('saksbehandlerid'))
+ {
+
$hoved_bilag[$i]['saksbehandlerid'] = $this->db->f('saksbehandlerid');
+ }
+
+ $hoved_bilag[$i]['budsjettansvarligid']
= $this->db->f('budsjettansvarligid');
+
+ if($this->db->f('oppsynsigndato'))
+ {
+
$hoved_bilag[$i]['oppsynsigndato'] = $this->db->f('oppsynsigndato');
+ }
+ if($this->db->f('saksigndato'))
+ {
+ $hoved_bilag[$i]['saksigndato']
= $this->db->f('saksigndato');
+ }
+
+ $hoved_bilag[$i]['budsjettsigndato']
= $this->db->f('budsjettsigndato');
+ $hoved_bilag[$i]['merknad']
= $this->db->f('merknad');
+ $hoved_bilag[$i]['splitt']
= $this->db->f('splitt');
+ $hoved_bilag[$i]['utbetalingid']
= $this->db->f('utbetalingid');
+ $hoved_bilag[$i]['utbetalingsigndato']
= $this->db->f('utbetalingsigndato');
+ $hoved_bilag[$i]['saksbehandler']
= $this->db->f('saksbehandler');
+ $i++;
+ }
+ }
+//_debug_array($hoved_bilag);
+
+ return $hoved_bilag;
+ }
+
+ //Velg ut alle underbilag
+
+ function select_underbilag ($bilagsnr)
+ {
+ $sql= "SELECT fm_ecobilag.*
,fm_part_of_town.district_id FROM (fm_location1 $this->join fm_part_of_town ON
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id) $this->join
fm_ecobilag ON fm_location1.loc1 = fm_ecobilag.loc1 WHERE bilagsnr='$bilagsnr'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $underbilag[$i]['id'] = $this->db->f('id');
+ $underbilag[$i]['bilagsnr'] =
$this->db->f('bilagsnr');
+ $underbilag[$i]['kidnr'] =
$this->db->f('kidnr');
+ $underbilag[$i]['typeid'] =
$this->db->f('typeid');
+ $underbilag[$i]['kildeid'] =
$this->db->f('kildeid');
+ $underbilag[$i]['pmwrkord_code'] =
$this->db->f('pmwrkord_code');
+ $underbilag[$i]['belop'] =
$this->db->f('belop');
+ $underbilag[$i]['fakturadato'] =
$this->db->f('fakturadato');
+ $underbilag[$i]['periode'] =
$this->db->f('periode');
+ $underbilag[$i]['forfallsdato'] =
$this->db->f('forfallsdato');
+ $underbilag[$i]['fakturanr'] =
$this->db->f('fakturanr');
+ $underbilag[$i]['spbudact_code'] =
$this->db->f('spbudact_code');
+ $underbilag[$i]['regtid'] =
$this->db->f('regtid');
+ $underbilag[$i]['artid'] =
$this->db->f('artid');
+ $underbilag[$i]['godkjentbelop'] =
$this->db->f('godkjentbelop');
+ $underbilag[$i]['spvend_code'] =
$this->db->f('spvend_code');
+ $underbilag[$i]['dima'] = $this->db->f('dima');
+ $underbilag[$i]['loc1'] = $this->db->f('loc1');
+ $underbilag[$i]['dimb'] = $this->db->f('dimb');
+ $underbilag[$i]['mvakode'] =
$this->db->f('mvakode');
+ $underbilag[$i]['dimd'] = $this->db->f('dimd');
+ $underbilag[$i]['project_id'] =
$this->db->f('project_id');
+ $underbilag[$i]['kostra_id'] =
$this->db->f('kostra_id');
+ if($this->db->f('oppsynsmannid'))
+ {
+ $underbilag[$i]['oppsynsmannid']
= $this->db->f('oppsynsmannid');
+ }
+ if($this->db->f('saksbehandlerid'))
+ {
+ $underbilag[$i]['saksbehandlerid']
= $this->db->f('saksbehandlerid');
+ }
+
+ $underbilag[$i]['budsjettansvarligid'] =
$this->db->f('budsjettansvarligid');
+
+ if($this->db->f('oppsynsigndato'))
+ {
+ $underbilag[$i]['oppsynsigndato']
= $this->db->f('oppsynsigndato');
+ }
+ if($this->db->f('saksigndato'))
+ {
+ $underbilag[$i]['saksigndato'] =
$this->db->f('saksigndato');
+ }
+
+ $underbilag[$i]['budsjettsigndato'] =
$this->db->f('budsjettsigndato');
+ $underbilag[$i]['merknad'] =
$this->db->f('merknad');
+ $underbilag[$i]['splitt'] =
$this->db->f('splitt');
+ $underbilag[$i]['utbetalingid'] =
$this->db->f('utbetalingid');
+ $underbilag[$i]['utbetalingsigndato'] =
$this->db->f('utbetalingsigndato');
+ $underbilag[$i]['district_id'] =
$this->db->f('district_id');
+ $underbilag[$i]['item_type'] =
$this->db->f('item_type');
+ $underbilag[$i]['item_id'] =
$this->db->f('item_id');
+ $i++;
+
+ }
+
+ return $underbilag;
+ }
+
+/* function update_avvik($avvik)
+ {
+ }
+
+*/
+ function log_to_deviation_table($oRsBilag)
+ {
+ $bilagsnr=$oRsBilag['bilagsnr'];
+ $fakturadato=$oRsBilag['fakturadato'];
+ $forfallsdato=$oRsBilag['forfallsdato'];
+ $oppsynsmannid=$oRsBilag['oppsynsmannid'];
+ $oppsynsigndato=$oRsBilag['oppsynsigndato'];
+ $saksbehandlerid=$oRsBilag['saksbehandlerid'];
+ $saksigndato=$oRsBilag['saksigndato'];
+ $budsjettansvarligid=$oRsBilag['budsjettansvarligid'];
+ $budsjettsigndato=$oRsBilag['budsjettsigndato'];
+ $artid=$oRsBilag['artid'];
+ $spvend_code=$oRsBilag['spvend_code'];
+ $belop=$oRsBilag['belop'];
+ $godkjentbelop=$oRsBilag['godkjentbelop'];
+
+ $sql="INSERT INTO fm_ecoavvik
(bilagsnr,fakturadato,forfallsdato,oppsynsmannid,oppsynsigndato,saksbehandlerid,saksigndato,budsjettansvarligid,budsjettsigndato,artid,spvend_code,belop,godkjentbelop)
values "
+ .
"($bilagsnr','$fakturadato','$forfallsdato','$oppsynsmannid','$oppsynsigndato','$saksbehandlerid','$saksigndato','$budsjettansvarligid','$budsjettsigndato','$artid','$spvend_code','$belop','$godkjentbelop')";
+ $this->db->query($sql,__LINE__,__FILE__);
+ }
+
+ function delete_avvik($bilagsnr)
+ {
+ $sql="delete from fm_ecoavvik where
bilagsnr='$bilagsnr'";
+ $this->db->query($sql,__LINE__,__FILE__);
+ }
+
+ function delete_invoice($bilagsnr)
+ {
+ $sql="delete from fm_ecobilagoverf where
bilagsnr='$bilagsnr'";
+ $this->db->query($sql,__LINE__,__FILE__);
+ }
+
+ //Logg transaksjon
+ function log_transaction($batchid,$bilagid,$message='')
+ {
+ $tid=date($this->datetimeformat);
+ $sql= "insert into fm_ecologg
(batchid,ecobilagid,melding,tid) values ('$batchid','$bilagid'
,'$message','$tid')";
+ $this->db->query($sql,__LINE__,__FILE__);
+ }
+
+ function increment_batchid()
+ {
+ $this->db->query("update fm_idgenerator set value =
value + 1 where name = 'Ecobatchid'");
+ $this->db->query("select value from fm_idgenerator
where name = 'Ecobatchid'");
+ $this->db->next_record();
+ $bilagsnr = $this->db->f('value');
+ return $bilagsnr;
+
+ }
+
+ function next_batchid()
+ {
+
+ $this->db->query("select value from fm_idgenerator
where name = 'Ecobatchid'");
+ $this->db->next_record();
+ $batchid = $this->db->f('value')+1;
+
+ return $batchid;
+ }
+
+ function get_responsible($b_abbount_id)
+ {
+ $this->db->query("select account_lid from fm_b_account
$this->join phpgw_accounts on fm_b_account.responsible =
phpgw_accounts.account_id where fm_b_account.id = '$b_abbount_id'");
+ $this->db->next_record();
+ $responsible = $this->db->f('account_lid');
+ return $responsible;
+ }
+
+ }
+
+?>
Index: property/inc/class.soactor.inc.php
diff -u property/inc/class.soactor.inc.php:1.9
property/inc/class.soactor.inc.php:1.10
--- property/inc/class.soactor.inc.php:1.9 Thu May 12 21:26:28 2005
+++ property/inc/class.soactor.inc.php Fri Jan 27 14:05:43 2006
@@ -1,913 +1,912 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.soactor.inc.php,v 1.9 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class soactor
- {
- var $role;
-
- function soactor()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->join = $this->bocommon->join;
- $this->left_join = $this->bocommon->left_join;
- $this->like = $this->bocommon->like;
- }
-
- function select_category_list()
- {
- $table = 'fm_' . $this->role . '_category';
- $this->db->query("SELECT id,descr FROM $table ORDER BY
descr ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $categories[$i]['id']
= $this->db->f('id');
- $categories[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $categories;
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- $start =
(isset($data['start'])?$data['start']:0);
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $member_id =
(isset($data['member_id'])?$data['member_id']:0);
- }
-
- $sql = $this->bocommon->fm_cache('sql_actor_' .
$this->role . $lookup);
-
- $entity_table = 'fm_' . $this->role;
- $category_table = 'fm_' . $this->role . '_category';
- $choice_table = 'fm_' . $this->role . '_choice';
- $attribute_table = 'fm_' . $this->role . '_attribute';
- if(!$sql)
- {
- $cols = $entity_table .
".*,$category_table.descr as category";
-
- $cols_return[] = 'id';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'id';
- $uicols['descr'][] =
lang('ID');
- $uicols['statustext'][] = lang('ID');
-
- $cols_return[] = 'id';
- $uicols['input_type'][] = 'hidden';
- $uicols['name'][] = 'id';
- $uicols['descr'][] = false;
- $uicols['statustext'][] = false;
-
- $cols_return[] =
'category';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'category';
- $uicols['descr'][] =
lang('category');
- $uicols['statustext'][] =
lang('category');
-
-
- $paranthesis .='(';
-
- $joinmethod .= " $this->join " . $entity_table
. "_category ON ( $entity_table" . ".category =" .$entity_table .
"_category.id))";
-
- $from .= " FROM $paranthesis $entity_table ";
-
- $sql = "SELECT $cols $from $joinmethod";
-
- $this->bocommon->fm_cache('sql_actor_' .
$this->role . $lookup,$sql);
- $this->bocommon->fm_cache('uicols_actor_' .
$this->role . $lookup,$uicols);
- $this->bocommon->fm_cache('cols_return_actor_'
. $this->role . $lookup,$cols_return);
-
- }
- else
- {
- $uicols
= $this->bocommon->fm_cache('uicols_actor_'. $this->role . $lookup);
- $cols_return
= $this->bocommon->fm_cache('cols_return_actor_' . $this->role . $lookup);
- if($lookup)
- {
- $admin_entity =
CreateObject($this->currentapp.'_soadmin_entity');
- $category =
$admin_entity->read_single_category($entity_id,$cat_id);
- }
- }
-
- $i = count($uicols['name']);
-
- $this->db->query("SELECT * FROM $attribute_table WHERE
list=1");
- while ($this->db->next_record())
- {
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
$this->db->f('column_name');
- $uicols['descr'][] =
$this->db->f('input_text');
- $uicols['statustext'][] =
$this->db->f('statustext');
- $uicols['datatype'][$i] =
$this->db->f('datatype');
- $cols_return_extra[]= array(
- 'name' => $this->db->f('column_name'),
- 'datatype' =>
$this->db->f('datatype'),
- 'attrib_id' => $this->db->f('id')
- );
-
- $i++;
- }
-
-
$user_columns=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['actor_columns_'
. $this->role];
-
-//_debug_array($user_columns);
-
- if (isset($user_columns) AND is_array($user_columns)
AND $user_columns[0])
- {
- foreach($user_columns as $column_id)
- {
- $this->db->query("SELECT * FROM
$attribute_table WHERE id= $column_id");
-
- $this->db->next_record();
- $uicols['input_type'][] =
'text';
- $uicols['name'][]
= $this->db->f('column_name');
- $uicols['descr'][]
= $this->db->f('input_text');
- $uicols['statustext'][] =
$this->db->f('statustext');
- $uicols['datatype'][$i] =
$this->db->f('datatype');
- $cols_return_extra[]= array(
- 'name' =>
$this->db->f('column_name'),
- 'datatype' =>
$this->db->f('datatype'),
- 'attrib_id' =>
$this->db->f('id')
- );
- $i++;
- }
- }
-
- $this->uicols = $uicols;
-
-//_debug_array($cols_return_extra);
- if ($order)
- {
- $ordermethod = " order by $entity_table.$order
$sort";
- }
- else
- {
- $ordermethod = " order by $entity_table.id
DESC";
- }
-
- $where= 'WHERE';
-
-/* if ($filter=='all')
- {
- if (is_array($grants))
- {
- while (list($user) = each($grants))
- {
- $public_user_list[] = $user;
- }
- reset($public_user_list);
- $filtermethod .= " $where (
$entity_table.user_id IN(" . implode(',',$public_user_list) . "))";
-
- $where= 'AND';
- }
-
- }
- else
- {
- $filtermethod = " $where
$entity_table.user_id=$filter ";
- $where= 'AND';
- }
-*/
-
- if ($cat_id)
- {
- $filtermethod .= " $where
$entity_table.category='$cat_id' ";
- $where= 'AND';
- }
-
- if ($member_id>0)
- {
- $filtermethod .= " $where
$entity_table.member_of $this->like '%,$member_id,%' ";
- $where= 'AND';
- }
-
- if ($status)
- {
- $filtermethod .= " $where
$entity_table.status='$status' ";
- $where= 'AND';
- }
-
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $filtermethod .= " $where $entity_table.id ='"
. (int)$query . "'";
- $where= 'OR';
-
- $this->db->query("SELECT * FROM
$attribute_table where search='1'");
-
- while ($this->db->next_record())
- {
- if($this->db->f('datatype')=='V' ||
$this->db->f('datatype')=='email' || $this->db->f('datatype')=='CH')
- {
- $querymethod[]=
"$entity_table." . $this->db->f('column_name') . " $this->like '%$query%'";
- }
- else
- {
- $querymethod[]=
"$entity_table." . $this->db->f('column_name') . " = '$query'";
- }
- }
-
- if (isset($querymethod) AND
is_array($querymethod))
- {
- $querymethod = " $where (" . implode ('
OR ',$querymethod) . ')';
- $where = 'AND';
- }
- }
-
- $sql .= " $filtermethod $querymethod";
-//echo $sql;
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- $j=0;
- $n=count($cols_return);
-//_debug_array($cols_return);
- $contacts =
CreateObject('phpgwapi.contacts');
-
- while ($this->db->next_record())
- {
- for ($i=0;$i<$n;$i++)
- {
- $actor_list[$j][$cols_return[$i]] =
$this->db->f($cols_return[$i]);
- $actor_list[$j]['grants'] =
(int)$grants[$this->db->f('user_id')];
- }
-
- for ($i=0;$i<count($cols_return_extra);$i++)
- {
- $value='';
-
$value=$this->db->f($cols_return_extra[$i]['name']);
-
-
if(($cols_return_extra[$i]['datatype']=='R' ||
$cols_return_extra[$i]['datatype']=='LB') && $value):
- {
- $sql="SELECT value FROM
$choice_table where attrib_id=" .$cols_return_extra[$i]['attrib_id']. " AND
id=" . $value;
- $this->db2->query($sql);
- $this->db2->next_record();
-
$actor_list[$j][$cols_return_extra[$i]['name']] = $this->db2->f('value');
- }
-
elseif($cols_return_extra[$i]['datatype']=='AB' && $value):
- {
- $contact_data =
$contacts->read_single_entry($value,array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
-
$actor_list[$j][$cols_return_extra[$i]['name']] = $contact_data[0]['n_family']
. ', ' . $contact_data[0]['n_given'];
-
-/* $sql="SELECT org_name FROM
phpgw_addressbook where id=$value";
- $this->db2->query($sql);
- $this->db2->next_record();
-
$actor_list[$j][$cols_return_extra[$i]['name']] = $this->db2->f('org_name');
-*/
- }
-
elseif($cols_return_extra[$i]['datatype']=='VENDOR' && $value):
- {
- $sql="SELECT org_name FROM
fm_vendor where id=$value";
- $this->db2->query($sql);
- $this->db2->next_record();
-
$actor_list[$j][$cols_return_extra[$i]['name']] = $this->db2->f('org_name');
- }
-
elseif($cols_return_extra[$i]['datatype']=='CH' && $value):
- {
- $ch= unserialize($value);
-
- if (isset($ch) AND
is_array($ch))
- {
- for
($k=0;$k<count($ch);$k++)
- {
- $sql="SELECT
value FROM $choice_table where attrib_id="
.$cols_return_extra[$i]['attrib_id']. " AND id=" . $ch[$k];
-
$this->db2->query($sql);
- while
($this->db2->next_record())
- {
-
$ch_value[]=$this->db2->f('value');
- }
- }
-
$actor_list[$j][$cols_return_extra[$i]['name']] = @implode(",", $ch_value);
- unset($ch_value);
- }
- }
-
elseif($cols_return_extra[$i]['datatype']=='D' && $value):
- {
-//html_print_r($value);
-
-
$actor_list[$j][$cols_return_extra[$i]['name']]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($value));
- }
- else:
- {
-
$actor_list[$j][$cols_return_extra[$i]['name']]=$value;
- }
- endif;
- }
-
- $j++;
- }
-//html_print_r($actor_list);
- return $actor_list;
- }
-
-
- function read_single($data)
- {
- $attribute_table = 'fm_' . $this->role . '_attribute';
- $table = 'fm_' . $this->role;
-
- $actor_id =$data['actor_id'];
-
- $this->db->query("SELECT * FROM $attribute_table ORDER
BY attrib_sort");
-
- while ($this->db->next_record())
- {
- $actor['attributes'][] = array
- (
- 'attrib_id' =>
$this->db->f('id'),
- 'name' =>
$this->db->f('column_name'),
- 'input_text' =>
stripslashes($this->db->f('input_text')),
- 'statustext' =>
stripslashes($this->db->f('statustext')),
- 'datatype' =>
$this->db->f('datatype')
- );
- }
-
- if($actor_id)
- {
- $this->db->query("SELECT * from $table where
id='$actor_id'");
-
- if($this->db->next_record())
- {
- $actor['id'] =
(int)$this->db->f('id');
- $actor['entry_date'] =
$this->db->f('entry_date');
- $actor['cat_id']
= $this->db->f('category');
- $actor['member_of']
= explode(',',$this->db->f('member_of'));
-
- for
($i=0;$i<count($actor['attributes']);$i++)
- {
-
$actor['attributes'][$i]['value'] =
$this->db->f($actor['attributes'][$i]['name']);
-
$actor['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($actor['attributes'][$i]['datatype']);
- }
-
- }
- }
- return $actor;
- }
-
- function add($actor,$values_attribute='')
- {
- $table = 'fm_' . $this->role;
-
- if($actor['member_of'])
- {
- $actor['member_of']=',' .
implode(',',$actor['member_of']) . ',';
- }
-
- while (is_array($actor['extra']) &&
list($input_name,$value) = each($actor['extra']))
- {
- if($value)
- {
- $cols[] = $input_name;
- $vals[] = $value;
- }
- }
-
- if (isset($values_attribute) AND
is_array($values_attribute))
- {
- foreach($values_attribute as $entry)
- {
- if($entry['value'])
- {
- $cols[] = $entry['name'];
- $vals[] = $entry['value'];
- }
- }
- }
-
- if($this->role == 'vendor')
- {
- $cols[] = 'member_of';
- $vals[] = $actor['member_of'];
- }
-
- if($cols)
- {
- $cols = "," . implode(",", $cols);
- $vals = "," .
$this->bocommon->validate_db_insert($vals);
- }
-
- $this->db->transaction_begin();
- if($actor['new_actor_id'])
- {
- $id = $actor['new_actor_id'];
- }
- else
- {
- $id = $this->bocommon->next_id($table);
- }
-
- $this->db->query("INSERT INTO $table
(id,entry_date,category $cols) "
- . "VALUES ($id,'" . time() . "','" .
$actor['cat_id'] . "' $vals)");
-
- $receipt['actor_id']=
$id;//$this->db->get_last_insert_id($table,'id');
-
- $receipt['message'][] = array('msg'=>lang('actor %1 has
been saved',$receipt['actor_id']));
-
- $this->db->transaction_commit();
- return $receipt;
- }
-
- function edit($actor,$values_attribute='')
- {
-//_debug_array($actor);
-//_debug_array($values_attribute);
- $table = 'fm_' . $this->role;
-
- if($actor['member_of'])
- {
- $actor['member_of']=',' .
implode(',',$actor['member_of']) . ',';
- }
-
- while (is_array($actor['extra']) &&
list($column,$value) = each($actor['extra']))
- {
- $value_set[$column] = $value;
- }
-
- if (isset($values_attribute) AND
is_array($values_attribute))
- {
- foreach($values_attribute as $entry)
- {
- if($entry['datatype']!='AB' &&
$entry['datatype']!='VENDOR')
- {
- $value_set[$entry['name']]
= $entry['value'];
- }
- }
- }
-
- $value_set['entry_date'] = time();
- $value_set['category'] = $actor['cat_id'];
-
- if($this->role == 'vendor')
- {
- $value_set['member_of'] = $actor['member_of'];
- }
-
- if($value_set)
- {
- $value_set =
$this->bocommon->validate_db_update($value_set);
- }
-
- $this->db->query("UPDATE $table set $value_set WHERE
id=" . intval($actor['actor_id']));
-
- $receipt['actor_id']= $actor['actor_id'];
- $receipt['message'][] = array('msg'=>lang('actor %1 has
been edited',$actor['actor_id']));
- return $receipt;
- }
-
- function delete($actor_id)
- {
- $table = 'fm_' . $this->role;
- $this->db->query('DELETE FROM $table WHERE id=' .
intval($actor_id));
- }
-
- function read_attrib($data)
- {
- $attribute_table = 'fm_' . $this->role . '_attribute';
-//html_print_r($data);
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $column_list =
(isset($data['column_list'])?$data['column_list']:'');
- }
-
- $where = 'WHERE';
- if ($column_list)
- {
- $filtermethod = " $where list !=1 or list is
null";
- $where = 'AND';
-
- }
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by attrib_sort asc';
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " $where
($attribute_table.input_text $this->like '%$query%' or
$attribute_table.column_name $this->like '%$query%')";
- }
-
- $sql = "SELECT * FROM $attribute_table $filtermethod
$querymethod";
-
-//echo $sql;
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $attrib[] = array
- (
- 'id' =>
$this->db->f('id'),
- 'attrib_sort' =>
$this->db->f('attrib_sort'),
- 'list' =>
$this->db->f('list'),
- 'lookup_form' =>
$this->db->f('lookup_form'),
- 'column_name' =>
$this->db->f('column_name'),
- 'name' =>
$this->db->f('input_text'),
- 'size' =>
$this->db->f('size'),
- 'statustext' =>
$this->db->f('statustext'),
- 'input_text' =>
$this->db->f('input_text'),
- 'type_name' =>
$this->db->f('type'),
- 'datatype' =>
$this->db->f('datatype'),
- 'search' =>
$this->db->f('search')
- );
- }
- return $attrib;
- }
-
- function read_single_attrib($id)
- {
- $attribute_table = 'fm_' . $this->role . '_attribute';
-
- $sql = "SELECT * FROM $attribute_table where id=$id";
-
- $this->db->query($sql);
-
- if($this->db->next_record())
- {
- $attrib['id']
= $this->db->f('id');
- $attrib['column_name']
= $this->db->f('column_name');
- $attrib['input_text']
= $this->db->f('input_text');
- $attrib['statustext']
= $this->db->f('statustext');
- $attrib['column_info']['precision'] =
$this->db->f('precision_');
- $attrib['column_info']['scale'] =
$this->db->f('scale');
- $attrib['column_info']['default'] =
$this->db->f('default_value');
- $attrib['column_info']['nullable'] =
$this->db->f('nullable');
- $attrib['column_info']['type'] =
$this->db->f('datatype');
- $attrib['type_name']
= $this->db->f('type_name');
- $attrib['lookup_form']
= $this->db->f('lookup_form');
- $attrib['list']
= $this->db->f('list');
- $attrib['search']
= $this->db->f('search');
- if($this->db->f('datatype')=='R' ||
$this->db->f('datatype')=='CH' || $this->db->f('datatype')=='LB')
- {
- $attrib['choice'] =
$this->read_attrib_choice($id);
- }
-
- return $attrib;
- }
- }
-
- function read_attrib_choice($attrib_id)
- {
- $choice_table = 'fm_' . $this->role . '_choice';
- $sql = "SELECT * FROM $choice_table WHERE
attrib_id=$attrib_id";
- $this->db->query($sql);
-
- while ($this->db->next_record())
- {
- $choice[] = array
- (
- 'id' => $this->db->f('id'),
- 'value' => $this->db->f('value')
- );
-
- }
- return $choice;
- }
-
- function add_attrib($attrib)
- {
- $table = 'fm_' . $this->role;
- $attribute_table = 'fm_' . $this->role . '_attribute';
- $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
- $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
- $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
- $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
- $attrib['id'] =
$this->bocommon->next_id($attribute_table);
-
- $sql = "SELECT max(attrib_sort) as max_sort FROM
$attribute_table";
- $this->db->query($sql);
- $this->db->next_record();
- $attrib_sort = $this->db->f('max_sort')+1;
-
- $values= array(
- $attrib['id'],
- $attrib['column_name'],
- $attrib['input_text'],
- $attrib['statustext'],
- $attrib['lookup_form'],
- $attrib['search'],
- $attrib['list'],
- $attrib_sort,
- $attrib['column_info']['type'],
- $attrib['column_info']['precision'],
- $attrib['column_info']['scale'],
- $attrib['column_info']['default'],
- $attrib['column_info']['nullable']
- );
-
- $values = $this->bocommon->validate_db_insert($values);
-
- $this->db->transaction_begin();
-
- $this->db->query("INSERT INTO $attribute_table
(id,column_name, input_text,
statustext,lookup_form,search,list,attrib_sort,datatype,precision_,scale,default_value,nullable)
"
- . "VALUES ($values)");
-
- $receipt['id']= $attrib['id'];
-
- if($attrib['column_info']['type']=='email' &&
!$attrib['column_info']['precision'])
- {
- $attrib['column_info']['precision']=64;
- }
-
- $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
-
- if($attrib['column_info']['type']=='int' &&
!$attrib['column_info']['precision'])
- {
- $attrib['column_info']['precision']=4;
- }
-
- if(!$attrib['column_info']['default'])
- {
- unset($attrib['column_info']['default']);
- }
-
- $this->init_process();
-
-
if($this->oProc->AddColumn($table,$attrib['column_name'],
$attrib['column_info']))
- {
- $receipt['message'][] = array('msg' =>
lang('Attribute has been saved') );
- $this->db->transaction_commit();
-
- }
- else
- {
- $receipt['error'][] = array('msg' =>
lang('column could not be added') );
- if($this->db->Transaction)
- {
- $GLOBALS['phpgw']->db->rollbacktrans();
- }
- else
- {
- $GLOBALS['phpgw']->db->Execute("DELETE
FROM $attribute_table WHERE id='" . $receipt['id'] . "'");
- unset($receipt['id']);
-
- }
- }
-
- return $receipt;
- }
-
- function init_process()
- {
- $this->oProc
=
CreateObject('phpgwapi.schema_proc',$GLOBALS['phpgw_info']['server']['db_type']);
- $this->oProc->m_odb
= $this->db;
- $this->oProc->m_odb->Halt_On_Error = 'report';
- }
-
- function edit_attrib($attrib)
- {
- $attribute_table = 'fm_' . $this->role . '_attribute';
- $table = 'fm_' . $this->role;
-
- $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
- $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
- $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
- $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
-
- $choice_table = 'fm_' . $this->role . '_choice';
-
- $this->db->query("SELECT column_name FROM
$attribute_table WHERE id='" . $attrib['id']. "'");
- $this->db->next_record();
- $OldColumnName = $this->db->f('column_name');
-
- $this->db->transaction_begin();
-
- $value_set=array(
- 'input_text' =>
$attrib['input_text'],
- 'statustext' =>
$attrib['statustext'],
- 'lookup_form' =>
$attrib['lookup_form'],
- 'search' =>
$attrib['search'],
- 'list' =>
$attrib['list'],
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE $attribute_table set
$value_set WHERE id=" . $attrib['id']);
-
- $attrib_type=$attrib['column_info']['type'];
- if(($OldColumnName !=$attrib['column_name']) ||
($attrib['column_info']['type'] != $this->db->f('datatype')))
- {
- $value_set=array(
- 'column_name' =>
$attrib['column_name'],
- 'datatype' =>
$attrib['column_info']['type'],
- 'precision_' =>
$attrib['column_info']['precision'],
- 'scale' =>
$attrib['column_info']['scale'],
- 'default_value' =>
$attrib['column_info']['default'],
- 'nullable' =>
$attrib['column_info']['nullable']
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE $attribute_table set
$value_set WHERE id=" . $attrib['id']);
-
- if($attrib['column_info']['type']=='email' &&
!$attrib['column_info']['precision'])
- {
- $attrib['column_info']['precision']=64;
- }
-
- $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
-
- if($attrib['column_info']['type']=='int' &&
!$attrib['column_info']['precision'])
- {
- $attrib['column_info']['precision']=4;
- }
-
- if(!$attrib['column_info']['default'])
- {
-
unset($attrib['column_info']['default']);
- }
-
- $this->init_process();
-
-
$this->oProc->AlterColumn($table,$OldColumnName,$attrib['column_name'],$attrib['column_info']);
-
- }
-
-
- if($attrib['new_choice'])
- {
- $choice_id =
$this->bocommon->next_id($choice_table ,array('attrib_id'=>$attrib['id']));
-
- $values= array(
- $attrib['id'],
- $choice_id,
- $attrib['new_choice']
- );
-
- $values =
$this->bocommon->validate_db_insert($values);
-
- $this->db->query("INSERT INTO $choice_table
(attrib_id,id,value) "
- . "VALUES ($values)");
- }
-
-
- if($attrib['delete_choice'])
- {
- for
($i=0;$i<count($attrib['delete_choice']);$i++)
- {
- $this->db->query("DELETE FROM
$choice_table WHERE attrib_id=" . $attrib['id'] ." AND id=" .
$attrib['delete_choice'][$i]);
- }
- }
-
-//html_print_r($attrib_type);
- if($attrib_type!='R' && $attrib_type!='CH' &&
$attrib_type!='LB')
- {
- $this->db->query("DELETE FROM $choice_table
WHERE attrib_id=" . $attrib['id']);
- }
-
-
- $this->db->transaction_commit();
-
- $receipt['message'][] = array('msg' =>
lang('Attribute has been edited'));
-
-
- return $receipt;
-
- }
- function resort_attrib($data)
- {
-//html_print_r($data);
- $attribute_table = 'fm_' . $this->role . '_attribute';
- if(is_array($data))
- {
- $resort =
(isset($data['resort'])?$data['resort']:'up');
- $id = (isset($data['id'])?$data['id']:'');
- }
-
- $sql = "SELECT attrib_sort FROM $attribute_table where
id=$id";
- $this->db->query($sql);
- $this->db->next_record();
- $attrib_sort = $this->db->f('attrib_sort');
- $sql = "SELECT max(attrib_sort) as max_sort FROM
$attribute_table";
- $this->db->query($sql);
- $this->db->next_record();
- $max_sort = $this->db->f('max_sort');
- switch($resort)
- {
- case 'up':
- if($attrib_sort>1)
- {
- $sql = "UPDATE $attribute_table
set attrib_sort=$attrib_sort WHERE attrib_sort =" . ($attrib_sort-1);
- $this->db->query($sql);
- $sql = "UPDATE $attribute_table
set attrib_sort=" . ($attrib_sort-1) ." WHERE id=$id";
- $this->db->query($sql);
- }
- break;
- case 'down':
- if($max_sort > $attrib_sort)
- {
- $sql = "UPDATE $attribute_table
set attrib_sort=$attrib_sort WHERE attrib_sort =" . ($attrib_sort+1);
- $this->db->query($sql);
- $sql = "UPDATE $attribute_table
set attrib_sort=" . ($attrib_sort+1) ." WHERE id=$id";
- $this->db->query($sql);
- }
- break;
- default:
- return;
- break;
- }
- }
- function delete_attrib($attrib_id)
- {
- $table = 'fm_' . $this->role;
- $attribute_table = 'fm_' . $this->role . '_attribute';
- $this->init_process();
-
- $sql = "SELECT * FROM $attribute_table WHERE
id=$attrib_id";
-
- $this->db->query($sql);
- $this->db->next_record();
- $ColumnName = $this->db->f('column_name');
-
- if($this->oProc->DropColumn($table,'', $ColumnName))
- {
- $sql = "SELECT attrib_sort FROM
$attribute_table where id=$attrib_id";
- $this->db->query($sql);
- $this->db->next_record();
- $attrib_sort = $this->db->f('attrib_sort');
- $sql2 = "SELECT max(attrib_sort) as max_sort
FROM $attribute_table";
- $this->db->query($sql2);
- $this->db->next_record();
- $max_sort = $this->db->f('max_sort');
- if($max_sort>$attrib_sort)
- {
- $sql = "UPDATE $attribute_table set
attrib_sort=attrib_sort-1 WHERE attrib_sort > $attrib_sort";
- $this->db->query($sql);
- }
-
- $this->db->query("DELETE FROM $attribute_table
WHERE id=$attrib_id");
- }
- else
- {
- $receipt['error'][] = array('msg' =>
lang('Attribute has NOT been deleted'));
- }
-
- return $receipt;
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.soactor.inc.php,v 1.10 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class soactor
+ {
+ var $role;
+
+ function soactor()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->left_join = $this->bocommon->left_join;
+ $this->like = $this->bocommon->like;
+ }
+
+ function select_category_list()
+ {
+ $table = 'fm_' . $this->role . '_category';
+ $this->db->query("SELECT id,descr FROM $table ORDER BY
descr ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $categories[$i]['id']
= $this->db->f('id');
+ $categories[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $categories;
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ $start =
(isset($data['start'])?$data['start']:0);
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $member_id =
(isset($data['member_id'])?$data['member_id']:0);
+ }
+
+ $sql = $this->bocommon->fm_cache('sql_actor_' .
$this->role . $lookup);
+
+ $entity_table = 'fm_' . $this->role;
+ $category_table = 'fm_' . $this->role . '_category';
+ $choice_table = 'fm_' . $this->role . '_choice';
+ $attribute_table = 'fm_' . $this->role . '_attribute';
+ if(!$sql)
+ {
+ $cols = $entity_table .
".*,$category_table.descr as category";
+
+ $cols_return[] = 'id';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'id';
+ $uicols['descr'][] =
lang('ID');
+ $uicols['statustext'][] = lang('ID');
+
+ $cols_return[] = 'id';
+ $uicols['input_type'][] = 'hidden';
+ $uicols['name'][] = 'id';
+ $uicols['descr'][] = false;
+ $uicols['statustext'][] = false;
+
+ $cols_return[] =
'category';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'category';
+ $uicols['descr'][] =
lang('category');
+ $uicols['statustext'][] =
lang('category');
+
+
+ $paranthesis .='(';
+
+ $joinmethod .= " $this->join " . $entity_table
. "_category ON ( $entity_table" . ".category =" .$entity_table .
"_category.id))";
+
+ $from .= " FROM $paranthesis $entity_table ";
+
+ $sql = "SELECT $cols $from $joinmethod";
+
+ $this->bocommon->fm_cache('sql_actor_' .
$this->role . $lookup,$sql);
+ $this->bocommon->fm_cache('uicols_actor_' .
$this->role . $lookup,$uicols);
+ $this->bocommon->fm_cache('cols_return_actor_'
. $this->role . $lookup,$cols_return);
+
+ }
+ else
+ {
+ $uicols
= $this->bocommon->fm_cache('uicols_actor_'. $this->role . $lookup);
+ $cols_return
= $this->bocommon->fm_cache('cols_return_actor_' . $this->role . $lookup);
+ if($lookup)
+ {
+ $admin_entity =
CreateObject($this->currentapp.'_soadmin_entity');
+ $category =
$admin_entity->read_single_category($entity_id,$cat_id);
+ }
+ }
+
+ $i = count($uicols['name']);
+
+ $this->db->query("SELECT * FROM $attribute_table WHERE
list=1");
+ while ($this->db->next_record())
+ {
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
$this->db->f('column_name');
+ $uicols['descr'][] =
$this->db->f('input_text');
+ $uicols['statustext'][] =
$this->db->f('statustext');
+ $uicols['datatype'][$i] =
$this->db->f('datatype');
+ $cols_return_extra[]= array(
+ 'name' => $this->db->f('column_name'),
+ 'datatype' =>
$this->db->f('datatype'),
+ 'attrib_id' => $this->db->f('id')
+ );
+
+ $i++;
+ }
+
+
$user_columns=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['actor_columns_'
. $this->role];
+
+//_debug_array($user_columns);
+
+ if (isset($user_columns) AND is_array($user_columns)
AND $user_columns[0])
+ {
+ foreach($user_columns as $column_id)
+ {
+ $this->db->query("SELECT * FROM
$attribute_table WHERE id= $column_id");
+
+ $this->db->next_record();
+ $uicols['input_type'][] =
'text';
+ $uicols['name'][]
= $this->db->f('column_name');
+ $uicols['descr'][]
= $this->db->f('input_text');
+ $uicols['statustext'][] =
$this->db->f('statustext');
+ $uicols['datatype'][$i] =
$this->db->f('datatype');
+ $cols_return_extra[]= array(
+ 'name' =>
$this->db->f('column_name'),
+ 'datatype' =>
$this->db->f('datatype'),
+ 'attrib_id' =>
$this->db->f('id')
+ );
+ $i++;
+ }
+ }
+
+ $this->uicols = $uicols;
+
+//_debug_array($cols_return_extra);
+ if ($order)
+ {
+ $ordermethod = " order by $entity_table.$order
$sort";
+ }
+ else
+ {
+ $ordermethod = " order by $entity_table.id
DESC";
+ }
+
+ $where= 'WHERE';
+
+/* if ($filter=='all')
+ {
+ if (is_array($grants))
+ {
+ while (list($user) = each($grants))
+ {
+ $public_user_list[] = $user;
+ }
+ reset($public_user_list);
+ $filtermethod .= " $where (
$entity_table.user_id IN(" . implode(',',$public_user_list) . "))";
+
+ $where= 'AND';
+ }
+
+ }
+ else
+ {
+ $filtermethod = " $where
$entity_table.user_id=$filter ";
+ $where= 'AND';
+ }
+*/
+
+ if ($cat_id)
+ {
+ $filtermethod .= " $where
$entity_table.category='$cat_id' ";
+ $where= 'AND';
+ }
+
+ if ($member_id>0)
+ {
+ $filtermethod .= " $where
$entity_table.member_of $this->like '%,$member_id,%' ";
+ $where= 'AND';
+ }
+
+ if ($status)
+ {
+ $filtermethod .= " $where
$entity_table.status='$status' ";
+ $where= 'AND';
+ }
+
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $filtermethod .= " $where $entity_table.id ='"
. (int)$query . "'";
+ $where= 'OR';
+
+ $this->db->query("SELECT * FROM
$attribute_table where search='1'");
+
+ while ($this->db->next_record())
+ {
+ if($this->db->f('datatype')=='V' ||
$this->db->f('datatype')=='email' || $this->db->f('datatype')=='CH')
+ {
+ $querymethod[]=
"$entity_table." . $this->db->f('column_name') . " $this->like '%$query%'";
+ }
+ else
+ {
+ $querymethod[]=
"$entity_table." . $this->db->f('column_name') . " = '$query'";
+ }
+ }
+
+ if (isset($querymethod) AND
is_array($querymethod))
+ {
+ $querymethod = " $where (" . implode ('
OR ',$querymethod) . ')';
+ $where = 'AND';
+ }
+ }
+
+ $sql .= " $filtermethod $querymethod";
+//echo $sql;
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ $j=0;
+ $n=count($cols_return);
+//_debug_array($cols_return);
+ $contacts =
CreateObject('phpgwapi.contacts');
+
+ while ($this->db->next_record())
+ {
+ for ($i=0;$i<$n;$i++)
+ {
+ $actor_list[$j][$cols_return[$i]] =
$this->db->f($cols_return[$i]);
+ $actor_list[$j]['grants'] =
(int)$grants[$this->db->f('user_id')];
+ }
+
+ for ($i=0;$i<count($cols_return_extra);$i++)
+ {
+ $value='';
+
$value=$this->db->f($cols_return_extra[$i]['name']);
+
+
if(($cols_return_extra[$i]['datatype']=='R' ||
$cols_return_extra[$i]['datatype']=='LB') && $value):
+ {
+ $sql="SELECT value FROM
$choice_table where attrib_id=" .$cols_return_extra[$i]['attrib_id']. " AND
id=" . $value;
+ $this->db2->query($sql);
+ $this->db2->next_record();
+
$actor_list[$j][$cols_return_extra[$i]['name']] = $this->db2->f('value');
+ }
+
elseif($cols_return_extra[$i]['datatype']=='AB' && $value):
+ {
+ $contact_data =
$contacts->read_single_entry($value,array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
+
$actor_list[$j][$cols_return_extra[$i]['name']] = $contact_data[0]['n_family']
. ', ' . $contact_data[0]['n_given'];
+
+/* $sql="SELECT org_name FROM
phpgw_addressbook where id=$value";
+ $this->db2->query($sql);
+ $this->db2->next_record();
+
$actor_list[$j][$cols_return_extra[$i]['name']] = $this->db2->f('org_name');
+*/
+ }
+
elseif($cols_return_extra[$i]['datatype']=='VENDOR' && $value):
+ {
+ $sql="SELECT org_name FROM
fm_vendor where id=$value";
+ $this->db2->query($sql);
+ $this->db2->next_record();
+
$actor_list[$j][$cols_return_extra[$i]['name']] = $this->db2->f('org_name');
+ }
+
elseif($cols_return_extra[$i]['datatype']=='CH' && $value):
+ {
+ $ch= unserialize($value);
+
+ if (isset($ch) AND
is_array($ch))
+ {
+ for
($k=0;$k<count($ch);$k++)
+ {
+ $sql="SELECT
value FROM $choice_table where attrib_id="
.$cols_return_extra[$i]['attrib_id']. " AND id=" . $ch[$k];
+
$this->db2->query($sql);
+ while
($this->db2->next_record())
+ {
+
$ch_value[]=$this->db2->f('value');
+ }
+ }
+
$actor_list[$j][$cols_return_extra[$i]['name']] = @implode(",", $ch_value);
+ unset($ch_value);
+ }
+ }
+
elseif($cols_return_extra[$i]['datatype']=='D' && $value):
+ {
+//html_print_r($value);
+
+
$actor_list[$j][$cols_return_extra[$i]['name']]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($value));
+ }
+ else:
+ {
+
$actor_list[$j][$cols_return_extra[$i]['name']]=$value;
+ }
+ endif;
+ }
+
+ $j++;
+ }
+//html_print_r($actor_list);
+ return $actor_list;
+ }
+
+
+ function read_single($data)
+ {
+ $attribute_table = 'fm_' . $this->role . '_attribute';
+ $table = 'fm_' . $this->role;
+
+ $actor_id =$data['actor_id'];
+
+ $this->db->query("SELECT * FROM $attribute_table ORDER
BY attrib_sort");
+
+ while ($this->db->next_record())
+ {
+ $actor['attributes'][] = array
+ (
+ 'attrib_id' =>
$this->db->f('id'),
+ 'name' =>
$this->db->f('column_name'),
+ 'input_text' =>
stripslashes($this->db->f('input_text')),
+ 'statustext' =>
stripslashes($this->db->f('statustext')),
+ 'datatype' =>
$this->db->f('datatype')
+ );
+ }
+
+ if($actor_id)
+ {
+ $this->db->query("SELECT * from $table where
id='$actor_id'");
+
+ if($this->db->next_record())
+ {
+ $actor['id'] =
(int)$this->db->f('id');
+ $actor['entry_date'] =
$this->db->f('entry_date');
+ $actor['cat_id']
= $this->db->f('category');
+ $actor['member_of']
= explode(',',$this->db->f('member_of'));
+
+ for
($i=0;$i<count($actor['attributes']);$i++)
+ {
+
$actor['attributes'][$i]['value'] =
$this->db->f($actor['attributes'][$i]['name']);
+
$actor['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($actor['attributes'][$i]['datatype']);
+ }
+
+ }
+ }
+ return $actor;
+ }
+
+ function add($actor,$values_attribute='')
+ {
+ $table = 'fm_' . $this->role;
+
+ if($actor['member_of'])
+ {
+ $actor['member_of']=',' .
implode(',',$actor['member_of']) . ',';
+ }
+
+ while (is_array($actor['extra']) &&
list($input_name,$value) = each($actor['extra']))
+ {
+ if($value)
+ {
+ $cols[] = $input_name;
+ $vals[] = $value;
+ }
+ }
+
+ if (isset($values_attribute) AND
is_array($values_attribute))
+ {
+ foreach($values_attribute as $entry)
+ {
+ if($entry['value'])
+ {
+ $cols[] = $entry['name'];
+ $vals[] = $entry['value'];
+ }
+ }
+ }
+
+ if($this->role == 'vendor')
+ {
+ $cols[] = 'member_of';
+ $vals[] = $actor['member_of'];
+ }
+
+ if($cols)
+ {
+ $cols = "," . implode(",", $cols);
+ $vals = "," .
$this->bocommon->validate_db_insert($vals);
+ }
+
+ $this->db->transaction_begin();
+ if($actor['new_actor_id'])
+ {
+ $id = $actor['new_actor_id'];
+ }
+ else
+ {
+ $id = $this->bocommon->next_id($table);
+ }
+
+ $this->db->query("INSERT INTO $table
(id,entry_date,category $cols) "
+ . "VALUES ($id,'" . time() . "','" .
$actor['cat_id'] . "' $vals)");
+
+ $receipt['actor_id']=
$id;//$this->db->get_last_insert_id($table,'id');
+
+ $receipt['message'][] = array('msg'=>lang('actor %1 has
been saved',$receipt['actor_id']));
+
+ $this->db->transaction_commit();
+ return $receipt;
+ }
+
+ function edit($actor,$values_attribute='')
+ {
+//_debug_array($actor);
+//_debug_array($values_attribute);
+ $table = 'fm_' . $this->role;
+
+ if($actor['member_of'])
+ {
+ $actor['member_of']=',' .
implode(',',$actor['member_of']) . ',';
+ }
+
+ while (is_array($actor['extra']) &&
list($column,$value) = each($actor['extra']))
+ {
+ $value_set[$column] = $value;
+ }
+
+ if (isset($values_attribute) AND
is_array($values_attribute))
+ {
+ foreach($values_attribute as $entry)
+ {
+ if($entry['datatype']!='AB' &&
$entry['datatype']!='VENDOR')
+ {
+ $value_set[$entry['name']]
= $entry['value'];
+ }
+ }
+ }
+
+ $value_set['entry_date'] = time();
+ $value_set['category'] = $actor['cat_id'];
+
+ if($this->role == 'vendor')
+ {
+ $value_set['member_of'] = $actor['member_of'];
+ }
+
+ if($value_set)
+ {
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+ }
+
+ $this->db->query("UPDATE $table set $value_set WHERE
id=" . intval($actor['actor_id']));
+
+ $receipt['actor_id']= $actor['actor_id'];
+ $receipt['message'][] = array('msg'=>lang('actor %1 has
been edited',$actor['actor_id']));
+ return $receipt;
+ }
+
+ function delete($actor_id)
+ {
+ $table = 'fm_' . $this->role;
+ $this->db->query('DELETE FROM $table WHERE id=' .
intval($actor_id));
+ }
+
+ function read_attrib($data)
+ {
+ $attribute_table = 'fm_' . $this->role . '_attribute';
+//html_print_r($data);
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $column_list =
(isset($data['column_list'])?$data['column_list']:'');
+ }
+
+ $where = 'WHERE';
+ if ($column_list)
+ {
+ $filtermethod = " $where list !=1 or list is
null";
+ $where = 'AND';
+
+ }
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by attrib_sort asc';
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " $where
($attribute_table.input_text $this->like '%$query%' or
$attribute_table.column_name $this->like '%$query%')";
+ }
+
+ $sql = "SELECT * FROM $attribute_table $filtermethod
$querymethod";
+
+//echo $sql;
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $attrib[] = array
+ (
+ 'id' =>
$this->db->f('id'),
+ 'attrib_sort' =>
$this->db->f('attrib_sort'),
+ 'list' =>
$this->db->f('list'),
+ 'lookup_form' =>
$this->db->f('lookup_form'),
+ 'column_name' =>
$this->db->f('column_name'),
+ 'name' =>
$this->db->f('input_text'),
+ 'size' =>
$this->db->f('size'),
+ 'statustext' =>
$this->db->f('statustext'),
+ 'input_text' =>
$this->db->f('input_text'),
+ 'type_name' =>
$this->db->f('type'),
+ 'datatype' =>
$this->db->f('datatype'),
+ 'search' =>
$this->db->f('search')
+ );
+ }
+ return $attrib;
+ }
+
+ function read_single_attrib($id)
+ {
+ $attribute_table = 'fm_' . $this->role . '_attribute';
+
+ $sql = "SELECT * FROM $attribute_table where id=$id";
+
+ $this->db->query($sql);
+
+ if($this->db->next_record())
+ {
+ $attrib['id']
= $this->db->f('id');
+ $attrib['column_name']
= $this->db->f('column_name');
+ $attrib['input_text']
= $this->db->f('input_text');
+ $attrib['statustext']
= $this->db->f('statustext');
+ $attrib['column_info']['precision'] =
$this->db->f('precision_');
+ $attrib['column_info']['scale'] =
$this->db->f('scale');
+ $attrib['column_info']['default'] =
$this->db->f('default_value');
+ $attrib['column_info']['nullable'] =
$this->db->f('nullable');
+ $attrib['column_info']['type'] =
$this->db->f('datatype');
+ $attrib['type_name']
= $this->db->f('type_name');
+ $attrib['lookup_form']
= $this->db->f('lookup_form');
+ $attrib['list']
= $this->db->f('list');
+ $attrib['search']
= $this->db->f('search');
+ if($this->db->f('datatype')=='R' ||
$this->db->f('datatype')=='CH' || $this->db->f('datatype')=='LB')
+ {
+ $attrib['choice'] =
$this->read_attrib_choice($id);
+ }
+
+ return $attrib;
+ }
+ }
+
+ function read_attrib_choice($attrib_id)
+ {
+ $choice_table = 'fm_' . $this->role . '_choice';
+ $sql = "SELECT * FROM $choice_table WHERE
attrib_id=$attrib_id";
+ $this->db->query($sql);
+
+ while ($this->db->next_record())
+ {
+ $choice[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'value' => $this->db->f('value')
+ );
+
+ }
+ return $choice;
+ }
+
+ function add_attrib($attrib)
+ {
+ $table = 'fm_' . $this->role;
+ $attribute_table = 'fm_' . $this->role . '_attribute';
+ $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
+ $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
+ $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
+ $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
+ $attrib['id'] =
$this->bocommon->next_id($attribute_table);
+
+ $sql = "SELECT max(attrib_sort) as max_sort FROM
$attribute_table";
+ $this->db->query($sql);
+ $this->db->next_record();
+ $attrib_sort = $this->db->f('max_sort')+1;
+
+ $values= array(
+ $attrib['id'],
+ $attrib['column_name'],
+ $attrib['input_text'],
+ $attrib['statustext'],
+ $attrib['lookup_form'],
+ $attrib['search'],
+ $attrib['list'],
+ $attrib_sort,
+ $attrib['column_info']['type'],
+ $attrib['column_info']['precision'],
+ $attrib['column_info']['scale'],
+ $attrib['column_info']['default'],
+ $attrib['column_info']['nullable']
+ );
+
+ $values = $this->bocommon->validate_db_insert($values);
+
+ $this->db->transaction_begin();
+
+ $this->db->query("INSERT INTO $attribute_table
(id,column_name, input_text,
statustext,lookup_form,search,list,attrib_sort,datatype,precision_,scale,default_value,nullable)
"
+ . "VALUES ($values)");
+
+ $receipt['id']= $attrib['id'];
+
+ if($attrib['column_info']['type']=='email' &&
!$attrib['column_info']['precision'])
+ {
+ $attrib['column_info']['precision']=64;
+ }
+
+ $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
+
+ if($attrib['column_info']['type']=='int' &&
!$attrib['column_info']['precision'])
+ {
+ $attrib['column_info']['precision']=4;
+ }
+
+ if(!$attrib['column_info']['default'])
+ {
+ unset($attrib['column_info']['default']);
+ }
+
+ $this->init_process();
+
+
if($this->oProc->AddColumn($table,$attrib['column_name'],
$attrib['column_info']))
+ {
+ $receipt['message'][] = array('msg' =>
lang('Attribute has been saved') );
+ $this->db->transaction_commit();
+
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('column could not be added') );
+ if($this->db->Transaction)
+ {
+ $GLOBALS['phpgw']->db->rollbacktrans();
+ }
+ else
+ {
+ $GLOBALS['phpgw']->db->Execute("DELETE
FROM $attribute_table WHERE id='" . $receipt['id'] . "'");
+ unset($receipt['id']);
+
+ }
+ }
+
+ return $receipt;
+ }
+
+ function init_process()
+ {
+ $this->oProc
=
CreateObject('phpgwapi.schema_proc',$GLOBALS['phpgw_info']['server']['db_type']);
+ $this->oProc->m_odb
= $this->db;
+ $this->oProc->m_odb->Halt_On_Error = 'report';
+ }
+
+ function edit_attrib($attrib)
+ {
+ $attribute_table = 'fm_' . $this->role . '_attribute';
+ $table = 'fm_' . $this->role;
+
+ $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
+ $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
+ $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
+ $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
+
+ $choice_table = 'fm_' . $this->role . '_choice';
+
+ $this->db->query("SELECT column_name FROM
$attribute_table WHERE id='" . $attrib['id']. "'");
+ $this->db->next_record();
+ $OldColumnName = $this->db->f('column_name');
+
+ $this->db->transaction_begin();
+
+ $value_set=array(
+ 'input_text' =>
$attrib['input_text'],
+ 'statustext' =>
$attrib['statustext'],
+ 'lookup_form' =>
$attrib['lookup_form'],
+ 'search' =>
$attrib['search'],
+ 'list' =>
$attrib['list'],
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE $attribute_table set
$value_set WHERE id=" . $attrib['id']);
+
+ $attrib_type=$attrib['column_info']['type'];
+ if(($OldColumnName !=$attrib['column_name']) ||
($attrib['column_info']['type'] != $this->db->f('datatype')))
+ {
+ $value_set=array(
+ 'column_name' =>
$attrib['column_name'],
+ 'datatype' =>
$attrib['column_info']['type'],
+ 'precision_' =>
$attrib['column_info']['precision'],
+ 'scale' =>
$attrib['column_info']['scale'],
+ 'default_value' =>
$attrib['column_info']['default'],
+ 'nullable' =>
$attrib['column_info']['nullable']
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE $attribute_table set
$value_set WHERE id=" . $attrib['id']);
+
+ if($attrib['column_info']['type']=='email' &&
!$attrib['column_info']['precision'])
+ {
+ $attrib['column_info']['precision']=64;
+ }
+
+ $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
+
+ if($attrib['column_info']['type']=='int' &&
!$attrib['column_info']['precision'])
+ {
+ $attrib['column_info']['precision']=4;
+ }
+
+ if(!$attrib['column_info']['default'])
+ {
+
unset($attrib['column_info']['default']);
+ }
+
+ $this->init_process();
+
+
$this->oProc->AlterColumn($table,$OldColumnName,$attrib['column_name'],$attrib['column_info']);
+
+ }
+
+
+ if($attrib['new_choice'])
+ {
+ $choice_id =
$this->bocommon->next_id($choice_table ,array('attrib_id'=>$attrib['id']));
+
+ $values= array(
+ $attrib['id'],
+ $choice_id,
+ $attrib['new_choice']
+ );
+
+ $values =
$this->bocommon->validate_db_insert($values);
+
+ $this->db->query("INSERT INTO $choice_table
(attrib_id,id,value) "
+ . "VALUES ($values)");
+ }
+
+
+ if($attrib['delete_choice'])
+ {
+ for
($i=0;$i<count($attrib['delete_choice']);$i++)
+ {
+ $this->db->query("DELETE FROM
$choice_table WHERE attrib_id=" . $attrib['id'] ." AND id=" .
$attrib['delete_choice'][$i]);
+ }
+ }
+
+//html_print_r($attrib_type);
+ if($attrib_type!='R' && $attrib_type!='CH' &&
$attrib_type!='LB')
+ {
+ $this->db->query("DELETE FROM $choice_table
WHERE attrib_id=" . $attrib['id']);
+ }
+
+
+ $this->db->transaction_commit();
+
+ $receipt['message'][] = array('msg' =>
lang('Attribute has been edited'));
+
+
+ return $receipt;
+
+ }
+ function resort_attrib($data)
+ {
+//html_print_r($data);
+ $attribute_table = 'fm_' . $this->role . '_attribute';
+ if(is_array($data))
+ {
+ $resort =
(isset($data['resort'])?$data['resort']:'up');
+ $id = (isset($data['id'])?$data['id']:'');
+ }
+
+ $sql = "SELECT attrib_sort FROM $attribute_table where
id=$id";
+ $this->db->query($sql);
+ $this->db->next_record();
+ $attrib_sort = $this->db->f('attrib_sort');
+ $sql = "SELECT max(attrib_sort) as max_sort FROM
$attribute_table";
+ $this->db->query($sql);
+ $this->db->next_record();
+ $max_sort = $this->db->f('max_sort');
+ switch($resort)
+ {
+ case 'up':
+ if($attrib_sort>1)
+ {
+ $sql = "UPDATE $attribute_table
set attrib_sort=$attrib_sort WHERE attrib_sort =" . ($attrib_sort-1);
+ $this->db->query($sql);
+ $sql = "UPDATE $attribute_table
set attrib_sort=" . ($attrib_sort-1) ." WHERE id=$id";
+ $this->db->query($sql);
+ }
+ break;
+ case 'down':
+ if($max_sort > $attrib_sort)
+ {
+ $sql = "UPDATE $attribute_table
set attrib_sort=$attrib_sort WHERE attrib_sort =" . ($attrib_sort+1);
+ $this->db->query($sql);
+ $sql = "UPDATE $attribute_table
set attrib_sort=" . ($attrib_sort+1) ." WHERE id=$id";
+ $this->db->query($sql);
+ }
+ break;
+ default:
+ return;
+ break;
+ }
+ }
+ function delete_attrib($attrib_id)
+ {
+ $table = 'fm_' . $this->role;
+ $attribute_table = 'fm_' . $this->role . '_attribute';
+ $this->init_process();
+
+ $sql = "SELECT * FROM $attribute_table WHERE
id=$attrib_id";
+
+ $this->db->query($sql);
+ $this->db->next_record();
+ $ColumnName = $this->db->f('column_name');
+
+ if($this->oProc->DropColumn($table,'', $ColumnName))
+ {
+ $sql = "SELECT attrib_sort FROM
$attribute_table where id=$attrib_id";
+ $this->db->query($sql);
+ $this->db->next_record();
+ $attrib_sort = $this->db->f('attrib_sort');
+ $sql2 = "SELECT max(attrib_sort) as max_sort
FROM $attribute_table";
+ $this->db->query($sql2);
+ $this->db->next_record();
+ $max_sort = $this->db->f('max_sort');
+ if($max_sort>$attrib_sort)
+ {
+ $sql = "UPDATE $attribute_table set
attrib_sort=attrib_sort-1 WHERE attrib_sort > $attrib_sort";
+ $this->db->query($sql);
+ }
+
+ $this->db->query("DELETE FROM $attribute_table
WHERE id=$attrib_id");
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('Attribute has NOT been deleted'));
+ }
+
+ return $receipt;
+ }
+ }
+?>
Index: property/inc/class.soadmin.inc.php
diff -u property/inc/class.soadmin.inc.php:1.5
property/inc/class.soadmin.inc.php:1.6
--- property/inc/class.soadmin.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/class.soadmin.inc.php Fri Jan 27 14:05:43 2006
@@ -1,115 +1,114 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.soadmin.inc.php,v 1.5 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class soadmin
- {
-
- function soadmin()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
-
- $this->join = $this->socommon->join;
- $this->like = $this->socommon->like;
- }
-
-
- function get_initials($id)
- {
- $this->db->query("SELECT initials FROM fm_ecouser WHERE
id=$id ");
- $this->db->next_record();
- return $this->db->f('initials');
- }
-
- function set_initials($initials)
- {
- while (is_array($initials) && list($account_id,$value)
= each($initials))
- {
- $this->db->query("UPDATE fm_ecouser set
initials= '$value' WHERE id=$account_id ",__LINE__,__FILE__);
- if($value)
- {
- if(!$this->get_initials($account_id))
- {
- $account_lid =
strtoupper($GLOBALS['phpgw']->accounts->id2name($account_id));
- $this->db->query("INSERT INTO
fm_ecouser (id,lid,initials) VALUES ($account_id,'$account_lid','$value'
)",__LINE__,__FILE__);
- }
- }
- }
- }
-
- function select_location($grant='')
- {
- if($grant)
- {
- $filter = ' WHERE allow_grant=1';
- }
- $this->db->query("SELECT * FROM fm_acl_location $filter
ORDER BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $location[$i]['id']
= $this->db->f('id');
- $location[$i]['descr']
= stripslashes($this->db->f('descr'));
- $i++;
- }
-
- return $location;
- }
-
-
- function read_fm_id()
- {
- $sql = "select * from fm_idgenerator ";
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $fm_ids[] = array(
- 'descr' =>
$this->db->f('name'),
- 'value' =>
$this->db->f('value'),
- 'remark' =>
$this->db->f('remark')
- );
-
- }
-
- return $fm_ids;
- }
-
- function edit_id($values='')
- {
- $field=$values['field'];
- $select=$values['select'];
-
- while($entry=each($select))
- {
- $n=$entry[0];
-
-
- $sql = "update fm_idgenerator set
value='$values[$n]' where name='$field[$n]'";
-
$this->db->query($sql,__LINE__,__FILE__);
-
- }
-
- $receipt['message'][] = array('msg' => lang('ID is
updated'));
- return $receipt;
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.soadmin.inc.php,v 1.6 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class soadmin
+ {
+
+ function soadmin()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->like = $this->bocommon->like;
+ }
+
+
+ function get_initials($id)
+ {
+ $this->db->query("SELECT initials FROM fm_ecouser WHERE
id=$id ");
+ $this->db->next_record();
+ return $this->db->f('initials');
+ }
+
+ function set_initials($initials)
+ {
+ while (is_array($initials) && list($account_id,$value)
= each($initials))
+ {
+ $this->db->query("UPDATE fm_ecouser set
initials= '$value' WHERE id=$account_id ",__LINE__,__FILE__);
+ if($value)
+ {
+ if(!$this->get_initials($account_id))
+ {
+ $account_lid =
strtoupper($GLOBALS['phpgw']->accounts->id2name($account_id));
+ $this->db->query("INSERT INTO
fm_ecouser (id,lid,initials) VALUES ($account_id,'$account_lid','$value'
)",__LINE__,__FILE__);
+ }
+ }
+ }
+ }
+
+ function select_location($grant='')
+ {
+ if($grant)
+ {
+ $filter = ' WHERE allow_grant=1';
+ }
+ $this->db->query("SELECT * FROM fm_acl_location $filter
ORDER BY id ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $location[$i]['id']
= $this->db->f('id');
+ $location[$i]['descr']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+
+ return $location;
+ }
+
+
+ function read_fm_id()
+ {
+ $sql = "select * from fm_idgenerator ";
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $fm_ids[] = array(
+ 'descr' =>
$this->db->f('name'),
+ 'value' =>
$this->db->f('value'),
+ 'remark' =>
$this->db->f('remark')
+ );
+
+ }
+
+ return $fm_ids;
+ }
+
+ function edit_id($values='')
+ {
+ $field=$values['field'];
+ $select=$values['select'];
+
+ while($entry=each($select))
+ {
+ $n=$entry[0];
+
+
+ $sql = "update fm_idgenerator set
value='$values[$n]' where name='$field[$n]'";
+
$this->db->query($sql,__LINE__,__FILE__);
+
+ }
+
+ $receipt['message'][] = array('msg' => lang('ID is
updated'));
+ return $receipt;
+ }
+ }
+?>
Index: property/inc/class.soadmin_entity.inc.php
diff -u property/inc/class.soadmin_entity.inc.php:1.10
property/inc/class.soadmin_entity.inc.php:1.11
--- property/inc/class.soadmin_entity.inc.php:1.10 Thu Nov 10 21:40:42 2005
+++ property/inc/class.soadmin_entity.inc.php Fri Jan 27 14:05:43 2006
@@ -1,1354 +1,1354 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.soadmin_entity.inc.php,v 1.10 2005/11/10 21:40:42
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class soadmin_entity
- {
- var $grants;
-
- function soadmin_entity($entity_id='',$cat_id='')
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->join = $this->bocommon->join;
- $this->like = $this->bocommon->like;
-
- if($entity_id && $cat_id)
- {
- $this->category_name =
$this->read_category_name($entity_id,$cat_id);
- }
- }
-
- function reset_fm_cache()
- {
- $this->db->query("DELETE FROM fm_cache
",__LINE__,__FILE__);
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by id asc';
- }
-
- $table = 'fm_entity';
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " where name $this->like
'%$query%' or descr $this->like '%$query%'";
- }
-
- $sql = "SELECT * FROM $table $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $entity[] = array
- (
- 'id' => $this->db->f('id'),
- 'name' => $this->db->f('name'),
- 'descr' => $this->db->f('descr'),
- 'documentation' =>
$this->db->f('documentation')
- );
- }
- return $entity;
- }
-
- function read_category($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $entity_id =
(isset($data['entity_id'])?$data['entity_id']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by id asc';
- }
-
- $table = 'fm_entity_category';
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " AND name $this->like
'%$query%' or descr $this->like '%$query%'";
- }
-
- $sql = "SELECT * FROM $table WHERE entity_id=$entity_id
$querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $standard[] = array
- (
- 'id' => $this->db->f('id'),
- 'name' => $this->db->f('name'),
- 'prefix'=> $this->db->f('prefix'),
- 'descr' => $this->db->f('descr')
- );
- }
- return $standard;
- }
-
- function read_status($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $entity_id =
(isset($data['entity_id'])?$data['entity_id']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by id asc';
- }
-
- $table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " AND name $this->like
'%$query%' or descr $this->like '%$query%'";
- }
-
- $sql = "SELECT * FROM $table $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $status[] = array
- (
- 'id' => $this->db->f('id'),
- 'descr' => $this->db->f('descr')
- );
- }
- return $status;
- }
-
-
- function read_single($id)
- {
-
- $sql = "SELECT * FROM fm_entity where id='$id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $entity['id'] =
$this->db->f('id');
- $entity['name'] =
$this->db->f('name');
- $entity['descr'] =
$this->db->f('descr');
- $entity['location_form'] =
$this->db->f('location_form');
- $entity['lookup_entity'] =
unserialize($this->db->f('lookup_entity'));
- $entity['documentation'] =
$this->db->f('documentation');
- }
-
- $sql = "SELECT location FROM fm_entity_lookup where
entity_id=$id AND type='lookup'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $entity['include_entity_for'][] =
$this->db->f('location');
- }
-
- $sql = "SELECT location FROM fm_entity_lookup where
entity_id=$id AND type='start'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $entity['start_entity_from'][] =
$this->db->f('location');
- }
-
- return $entity;
- }
-
- function read_single_category($entity_id,$cat_id)
- {
- $sql = "SELECT * FROM fm_entity_category where
entity_id=$entity_id AND id=$cat_id";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $category['id'] =
$this->db->f('id');
- $category['name'] =
$this->db->f('name');
- $category['descr'] =
$this->db->f('descr');
- $category['prefix'] =
$this->db->f('prefix');
- $category['lookup_tenant'] =
$this->db->f('lookup_tenant');
- $category['tracking'] =
$this->db->f('tracking');
- $category['location_level'] =
$this->db->f('location_level');
- $category['fileupload'] =
$this->db->f('fileupload');
- $category['loc_link'] =
$this->db->f('loc_link');
- $category['start_project'] =
$this->db->f('start_project');
- return $category;
- }
- }
-
- function read_category_name($entity_id,$cat_id)
- {
- $sql = "SELECT * FROM fm_entity_category where
entity_id=$entity_id AND id=$cat_id";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- return $this->db->f('name');
- }
-
- function read_single_status($entity_id,$cat_id,$id)
- {
-
- $table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
- $sql = "SELECT * FROM $table where id='$id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $status['id'] =
$this->db->f('id');
- $status['descr'] =
$this->db->f('descr');
-
- return $status;
- }
- }
-
- function add_entity($entity)
- {
- $entity['name'] =
$this->db->db_addslashes($entity['name']);
- $entity['descr'] =
$this->db->db_addslashes($entity['descr']);
-
- $entity['id'] = $this->bocommon->next_id('fm_entity');
-
- $values= array(
- $entity['id'],
- $entity['name'],
- $entity['descr'],
- $entity['location_form'],
- $entity['documentation']
- );
-
- $values = $this->bocommon->validate_db_insert($values);
-
- $this->db->query("INSERT INTO fm_entity (id,name,
descr,location_form,documentation) "
- . "VALUES ($values)",__LINE__,__FILE__);
-
-
- $values_acl_location= array(
- '.entity.' . $entity['id'],
- $entity['name'],
- 1
- );
-
- $values_acl_location =
$this->bocommon->validate_db_insert($values_acl_location);
-
- $this->db->query("INSERT INTO fm_acl_location
(id,descr,allow_grant) "
- . "VALUES
($values_acl_location)",__LINE__,__FILE__);
-
- $receipt['id']= $entity['id'];
-
- $receipt['message'][] = array('msg'=> lang('entity has
been added'));
- return $receipt;
- }
-
-
- function add_status($values,$entity_id,$cat_id)
- {
- $values['id'] = $this->db->db_addslashes($values['id']);
- $values['descr'] =
$this->db->db_addslashes($values['descr']);
-
- $values_insert= array(
- $values['id'],
- $values['descr'],
- );
-
- $values_insert =
$this->bocommon->validate_db_insert($values_insert);
-
- $table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
-
- $this->db->query("INSERT INTO $table (id,descr) VALUES
($values_insert)",__LINE__,__FILE__);
-
- $receipt['id']= $values['id'];
-
- $receipt['message'][] = array('msg'=> lang('status has
been added'));
- return $receipt;
- }
-
-
- function add_category($values)
- {
- $values['name'] =
$this->db->db_addslashes($values['name']);
- $values['descr'] =
$this->db->db_addslashes($values['descr']);
-
- $values['id'] =
$this->bocommon->next_id('fm_entity_category',array('entity_id'=>$values['entity_id']));
-
- $location_type =
$this->bocommon->next_id('fm_location_type');
-
- $values_insert= array(
- $values['entity_id'],
- $values['id'],
- $values['name'],
- $values['descr'],
- $values['prefix'],
- $values['lookup_tenant'],
- $values['tracking'],
- $values['location_level'],
- $values['fileupload'],
- $values['loc_link'],
- $values['start_project']
- );
-
- $values_insert =
$this->bocommon->validate_db_insert($values_insert);
-
-
- $this->db->transaction_begin();
-
- $this->db->query("INSERT INTO fm_entity_category
(entity_id,id,name,
descr,prefix,lookup_tenant,tracking,location_level,fileupload,loc_link,start_project)
"
- . "VALUES ($values_insert)",__LINE__,__FILE__);
-
- $values_acl_location= array(
- '.entity.' . $values['entity_id'] . '.' .
$values['id'],
- $values['name'],
- 1
- );
-
- $values_acl_location =
$this->bocommon->validate_db_insert($values_acl_location);
-
- $this->db->query("INSERT INTO fm_acl_location
(id,descr,allow_grant) "
- . "VALUES
($values_acl_location)",__LINE__,__FILE__);
-
- $receipt['id']= $values['id'];
-
- $this->init_process();
-
- $fd=array();
- $fd['id'] = array('type' => 'int', 'precision' => 4,
'nullable' => False);
- $fd['num'] = array('type' => 'varchar', 'precision' =>
16, 'nullable' => False);
- $fd['p_num'] = array('type' => 'varchar', 'precision'
=> 16, 'nullable' => True);
- $fd['p_entity_id'] = array('type' => 'int', 'precision'
=> 4, 'nullable' => True);
- $fd['p_cat_id'] = array('type' => 'int', 'precision' =>
4, 'nullable' => True);
- $fd['location_code'] = array('type' => 'varchar',
'precision' => 25, 'nullable' => True);
-
- for ($i=1; $i<$location_type; $i++)
- {
- $fd['loc' . $i] = array('type' => 'varchar',
'precision' => 4, 'nullable' => True);
- }
-
- $fd['address'] = array('type' => 'varchar', 'precision'
=> 150, 'nullable' => True);
- $fd['tenant_id'] = array('type' => 'int', 'precision'
=> 4, 'nullable' => True);
- $fd['contact_phone'] = array('type' => 'varchar',
'precision' => 30, 'nullable' => True);
- $fd['status'] = array('type' => 'int', 'precision' =>
4, 'nullable' => True);
- $fd['entry_date'] = array('type' => 'int', 'precision'
=> 4, 'nullable' => True);
- $fd['user_id'] = array('type' => 'int', 'precision' =>
4, 'nullable' => True);
-
- $pk[]= 'id';
- $table = 'fm_entity_'.
$values['entity_id'] .'_'.$values['id'];
-/*
- $fd_status['id'] = array('type' => 'varchar',
'precision' => 20, 'nullable' => False);
- $fd_status['descr'] = array('type' => 'varchar',
'precision' => 255, 'nullable' => False);
- $pk_status[]= 'id';
-
- $statustable = $table . '_' .'status';
-*/
- if(($this->oProc->CreateTable($table,array('fd' =>
$fd,'pk' => $pk,'fk' => $fk,'ix' => array('location_code'),'uc' => array()))))
-// &&
($this->oProc->CreateTable($statustable,array('fd' => $fd_status,'pk' =>
$pk_status,'fk' => $fk_status,'ix' => False,'uc' => array()))))
- {
-
- $values_insert= array(
- $values['entity_id'],
- $values['id'],
- 1,
- 'status',
- 'Status',
- 'Status',
- 'LB',
- 1,
- 'True'
- );
-
- $values_insert =
$this->bocommon->validate_db_insert($values_insert);
-
- $this->db->query("INSERT INTO
fm_entity_attribute
(entity_id,cat_id,id,column_name,input_text,statustext,datatype,attrib_sort,nullable)
"
- . "VALUES
($values_insert)",__LINE__,__FILE__);
-
- $receipt['message'][] = array('msg' =>
lang('table %1 has been saved',$table));
- $this->db->transaction_commit();
- }
- else
- {
- $receipt['error'][] = array('msg' =>
lang('table could not be added') );
- if($this->db->Transaction)
- {
- $this->db->transaction_abort();
- }
- else
- {
- $this->db->query("DELETE FROM
fm_entity_category WHERE id=" . $values['id'] . " AND entity_id=" .
$values['entity_id'],__LINE__,__FILE__);
- unset($receipt['id']);
-
- }
- }
-
- return $receipt;
- }
-
- function edit_status($values,$entity_id,$cat_id)
- {
- $table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
-
- $values['descr'] =
$this->db->db_addslashes($values['descr']);
-
- $value_set=array(
- 'descr' => $values['descr'],
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE $table set $value_set WHERE
id='" . $values['id'] . "'",__LINE__,__FILE__);
-
- $receipt['message'][] = array('msg'=> lang('Status has
been edited'));
-
- return $receipt;
- }
-
- function edit_entity($entity)
- {
- if (!$entity['name'])
- {
- $receipt['error'][] = array('msg'=>lang('Name
not entered!'));
- }
-
- if (!$receipt['error'])
- {
- $table = 'fm_entity';
-
- $entity['name'] =
$this->db->db_addslashes($entity['name']);
- $entity['descr'] =
$this->db->db_addslashes($entity['descr']);
-
- if(!$entity['location_form'])
- {
- unset($entity['lookup_entity']);
- }
-
- $value_set=array(
- 'descr' => $entity['descr'],
- 'name' => $entity['name'],
- 'location_form' => $entity['location_form'],
- 'lookup_entity' =>
serialize($entity['lookup_entity']),
- 'documentation' => $entity['documentation']
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->transaction_begin();
-
- $this->db->query("UPDATE $table set $value_set
WHERE id=" . $entity['id'],__LINE__,__FILE__);
-
- $value_set_acl=array(
- 'descr' =>
$entity['name']
- );
-
- $value_set_acl =
$this->bocommon->validate_db_update($value_set_acl);
-
- $this->db->query("UPDATE fm_acl_location set
$value_set_acl WHERE id='.entity." . $entity['id']. "'",__LINE__,__FILE__);
-
- $this->db->query("DELETE FROM fm_entity_lookup
WHERE type='lookup' AND entity_id=" . $entity['id'],__LINE__,__FILE__);
- if (isset($entity['include_entity_for']) AND
is_array($entity['include_entity_for']))
- {
- foreach($entity['include_entity_for']
as $location)
- {
- $this->db->query("INSERT INTO
fm_entity_lookup (entity_id,location,type)"
- . "VALUES (" .$entity['id'] .
",'$location','lookup' )",__LINE__,__FILE__);
- }
- }
-
- $this->db->query("DELETE FROM fm_entity_lookup
WHERE type='start' AND entity_id=" . $entity['id'],__LINE__,__FILE__);
-
- if (isset($entity['start_entity_from']) AND
is_array($entity['start_entity_from']))
- {
- foreach($entity['start_entity_from'] as
$location)
- {
- $this->db->query("INSERT INTO
fm_entity_lookup (entity_id,location,type)"
- . "VALUES (" .$entity['id'] .
",'$location','start' )",__LINE__,__FILE__);
- }
- }
-
- $this->db->transaction_commit();
-
- $receipt['message'][] = array('msg'=>
lang('entity has been edited'));
- }
- else
- {
- $receipt['error'][] = array('msg' =>
lang('entity has NOT been edited'));
- }
-
- return $receipt;
- }
-
- function edit_category($entity)
- {
-
- if (!$entity['name'])
- {
- $receipt['error'][] = array('msg'=>lang('Name
not entered!'));
- }
-
- if (!$receipt['error'])
- {
- $table = 'fm_entity_category';
-
- $entity['name'] =
$this->db->db_addslashes($entity['name']);
- $entity['descr'] =
$this->db->db_addslashes($entity['descr']);
-
- $value_set=array(
- 'descr' =>
$entity['descr'],
- 'name' =>
$entity['name'],
- 'prefix' =>
$entity['prefix'],
- 'lookup_tenant' =>
$entity['lookup_tenant'],
- 'tracking' =>
$entity['tracking'],
- 'location_level'=>
$entity['location_level'],
- 'fileupload' =>
$entity['fileupload'],
- 'loc_link' =>
$entity['loc_link'],
- 'start_project' =>
$entity['start_project']
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE $table set $value_set
WHERE entity_id=" . $entity['entity_id']. " AND id=" .
$entity['id'],__LINE__,__FILE__);
-
- $value_set_acl=array(
- 'descr' =>
$entity['name']
- );
-
- $value_set_acl =
$this->bocommon->validate_db_update($value_set_acl);
-
- $this->db->query("UPDATE fm_acl_location set
$value_set_acl WHERE id='.entity." . $entity['entity_id']. "." . $entity['id'].
"'",__LINE__,__FILE__);
-
-
- $receipt['message'][] = array('msg'=>
lang('entity has been edited'));
- }
- else
- {
- $receipt['error'][] = array('msg' =>
lang('entity has NOT been edited'));
- }
-
- return $receipt;
- }
-
- function delete_entity($id)
- {
-
$category_list=$this->read_category(array('entity_id'=>$id));
- $this->db->query("DELETE FROM fm_entity WHERE
id=$id",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_entity_category WHERE
entity_id=$id",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_entity_attribute WHERE
entity_id=$id",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_acl_location WHERE id
$this->like '.entity." . $id ."%'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_acl2 WHERE
acl_location $this->like '.entity." . $id ."%'",__LINE__,__FILE__);
- if (isset($category_list) AND is_array($category_list))
- {
- $this->init_process();
-
- foreach($category_list as $entry)
- {
- $this->oProc->DropTable('fm_entity_' .
$id . '_' . $entry['id']);
- }
- }
-
- }
-
- function delete_category($id,$entity_id)
- {
- $this->init_process();
- $this->oProc->DropTable('fm_entity_' . $entity_id . '_'
. $id);
-// $this->oProc->DropTable('fm_entity_' . $entity_id . '_'
. $id . '_' . 'status');
- $this->db->query("DELETE FROM fm_entity_category WHERE
entity_id= $entity_id AND id= $id",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_entity_attribute WHERE
entity_id= $entity_id AND cat_id= $id",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_acl_location WHERE
id='.entity." . $entity_id . "." . $id ."'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_acl2 WHERE
acl_location='.entity." . $entity_id . "." . $id ."'",__LINE__,__FILE__);
- }
-
- function delete_attrib($cat_id,$entity_id,$attrib_id)
- {
- $this->init_process();
-
- $sql = "SELECT * FROM fm_entity_attribute WHERE
entity_id=$entity_id AND cat_id=$cat_id AND id=$attrib_id";
-
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $ColumnName = $this->db->f('column_name');
-
- $this->oProc->DropColumn('fm_entity_' .$entity_id.'_'.
$cat_id,'', $ColumnName);
-
- $sql = "SELECT attrib_sort FROM fm_entity_attribute
where entity_id=$entity_id AND cat_id=$cat_id AND id=$attrib_id";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $attrib_sort = $this->db->f('attrib_sort');
- $sql2 = "SELECT max(attrib_sort) as max_sort FROM
fm_entity_attribute where entity_id=$entity_id AND cat_id=$cat_id";
- $this->db->query($sql2,__LINE__,__FILE__);
- $this->db->next_record();
- $max_sort = $this->db->f('max_sort');
- if($max_sort>$attrib_sort)
- {
- $sql = "UPDATE fm_entity_attribute set
attrib_sort=attrib_sort-1 WHERE entity_id=$entity_id AND cat_id=$cat_id AND
attrib_sort > $attrib_sort";
- $this->db->query($sql,__LINE__,__FILE__);
- }
-
- $this->db->query("DELETE FROM fm_entity_attribute WHERE
entity_id=$entity_id AND cat_id=$cat_id AND id=$attrib_id",__LINE__,__FILE__);
- }
-
- function delete_status($cat_id,$entity_id,$status_id)
- {
- $table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
-
- $this->db->query("DELETE FROM $table WHERE
id='$status_id'",__LINE__,__FILE__);
- }
-
- function read_attrib($data)
- {
-
-//_debug_array($data);
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $entity_id =
(isset($data['entity_id'])?$data['entity_id']:0);
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by attrib_sort asc';
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " AND (fm_entity_attribute.name
$this->like '%$query%' or fm_entity_attribute.descr $this->like '%$query%')";
- }
-
- $sql = "SELECT * FROM fm_entity_attribute WHERE
entity_id=$entity_id AND cat_id = $cat_id $filtermethod $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
-
- while ($this->db->next_record())
- {
- $attrib[] = array
- (
- 'id' =>
$this->db->f('id'),
- 'entity_type' =>
$this->db->f('type_id'),
- 'attrib_sort' =>
$this->db->f('attrib_sort'),
- 'list' =>
$this->db->f('list'),
- 'lookup_form' =>
$this->db->f('lookup_form'),
- 'entity_form' =>
$this->db->f('entity_form'),
- 'column_name' =>
$this->db->f('column_name'),
- 'name' =>
$this->db->f('input_text'),
- 'size' =>
$this->db->f('size'),
- 'statustext' =>
$this->db->f('statustext'),
- 'input_text' =>
$this->db->f('input_text'),
- 'type_name' =>
$this->db->f('type'),
- 'datatype' =>
$this->db->f('datatype'),
- 'search' =>
$this->db->f('search')
- );
- }
- return $attrib;
- }
-
- function read_single_attrib($entity_id,$cat_id,$id)
- {
-
- $sql = "SELECT * FROM fm_entity_attribute where
entity_id=$entity_id AND cat_id=$cat_id AND id=$id";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $attrib['id']
= $this->db->f('id');
- $attrib['column_name']
= $this->db->f('column_name');
- $attrib['input_text']
= $this->db->f('input_text');
- $attrib['statustext']
= $this->db->f('statustext');
- $attrib['column_info']['precision'] =
$this->db->f('precision_');
- $attrib['column_info']['scale'] =
$this->db->f('scale');
- $attrib['column_info']['default'] =
$this->db->f('default_value');
- $attrib['column_info']['nullable'] =
$this->db->f('nullable');
- $attrib['column_info']['type'] =
$this->db->f('datatype');
- $attrib['type_id']
= $this->db->f('type_id');
- $attrib['type_name']
= $this->db->f('type_name');
- $attrib['lookup_form']
= $this->db->f('lookup_form');
- $attrib['list']
= $this->db->f('list');
- $attrib['search']
= $this->db->f('search');
- if($this->db->f('datatype')=='R' ||
$this->db->f('datatype')=='CH' || $this->db->f('datatype')=='LB')
- {
- $attrib['choice'] =
$this->read_attrib_choice($entity_id,$cat_id,$id);
- }
-
- return $attrib;
- }
- }
-
- function read_attrib_choice($entity_id,$cat_id,$attrib_id)
- {
- $choice_table = 'fm_entity_choice';
- $sql = "SELECT * FROM $choice_table WHERE
entity_id=$entity_id AND cat_id=$cat_id AND attrib_id=$attrib_id";
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $choice[] = array
- (
- 'id' => $this->db->f('id'),
- 'value' => $this->db->f('value')
- );
- }
- return $choice;
- }
-
- function add_attrib($attrib)
- {
-
- $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
- $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
- $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
- $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
- $attrib['id'] =
$this->bocommon->next_id('fm_entity_attribute',array('entity_id'=>$attrib['entity_id'],'cat_id'=>$attrib['cat_id']));
-
- $sql = "SELECT max(attrib_sort) as max_sort FROM
fm_entity_attribute where entity_id=" . $attrib['entity_id'] . " AND cat_id=" .
$attrib['cat_id'];
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $attrib_sort = $this->db->f('max_sort')+1;
-
- $values= array(
- $attrib['entity_id'],
- $attrib['cat_id'],
- $attrib['id'],
- $attrib['column_name'],
- $attrib['input_text'],
- $attrib['statustext'],
- $attrib['search'],
- $attrib['list'],
- $attrib_sort,
- $attrib['column_info']['type'],
- $attrib['column_info']['precision'],
- $attrib['column_info']['scale'],
- $attrib['column_info']['default'],
- $attrib['column_info']['nullable']
- );
-
- $values = $this->bocommon->validate_db_insert($values);
-
- $this->db->transaction_begin();
-
- $this->db->query("INSERT INTO fm_entity_attribute
(entity_id,cat_id,id,column_name, input_text,
statustext,search,list,attrib_sort,
datatype,precision_,scale,default_value,nullable) "
- . "VALUES ($values)",__LINE__,__FILE__);
-
- $receipt['id']= $attrib['id'];
-
- if($attrib['column_info']['type']=='email' &&
!$attrib['column_info']['precision'])
- {
- $attrib['column_info']['precision']=64;
- }
-
- $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
-
- if($attrib['column_info']['type']=='int' &&
!$attrib['column_info']['precision'])
- {
- $attrib['column_info']['precision']=4;
- }
-
- if(!$attrib['column_info']['default'])
- {
- unset($attrib['column_info']['default']);
- }
-
- $this->init_process();
-
-
if($this->oProc->AddColumn('fm_entity_'.$attrib['entity_id'] . '_' .
$attrib['cat_id'],$attrib['column_name'], $attrib['column_info']))
- {
- $receipt['message'][] = array('msg' =>
lang('Attribute has been saved') );
- $this->db->transaction_commit();
-
- }
- else
- {
- $receipt['error'][] = array('msg' =>
lang('column could not be added') );
- if($this->db->Transaction)
- {
- $this->db->transaction_abort();
- }
- else
- {
- $this->db->query("DELETE FROM
fm_entity_attribute WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['id']. " AND id='" . $receipt['id'] . "'",__LINE__,__FILE__);
- unset($receipt['id']);
-
- }
- }
-
- return $receipt;
- }
-
- function init_process()
- {
- $this->oProc
=
CreateObject('phpgwapi.schema_proc',$GLOBALS['phpgw_info']['server']['db_type']);
- $this->oProc->m_odb
= $this->db;
- $this->oProc->m_odb->Halt_On_Error = 'report';
- }
-
- function edit_attrib($attrib)
- {
-
- $choice_table = 'fm_entity_choice';
-
- $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
- $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
- $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
- $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
-
- $this->db->query("SELECT column_name FROM
fm_entity_attribute WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['cat_id']. " AND id='" . $attrib['id']. "'",__LINE__,__FILE__);
- $this->db->next_record();
- $OldColumnName = $this->db->f('column_name');
-
- $this->db->transaction_begin();
-
- $value_set=array(
- 'input_text' =>
$attrib['input_text'],
- 'statustext' =>
$attrib['statustext'],
- 'search' =>
$attrib['search'],
- 'list' =>
$attrib['list'],
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE fm_entity_attribute
set $value_set WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['cat_id']. " AND id=" . $attrib['id'],__LINE__,__FILE__);
-
- if($OldColumnName !=$attrib['column_name'])
- {
-
- if($attrib['column_info']['type']!='R' &&
$attrib['column_info']['type']!='CH' && $attrib['column_info']['type']!='LB')
- {
- $this->db->query("DELETE FROM
$choice_table WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['cat_id']. " AND attrib_id=" . $attrib['id'],__LINE__,__FILE__);
- }
-
- if($attrib['column_info']['type']=='email' &&
!$attrib['column_info']['precision'])
- {
- $attrib['column_info']['precision']=64;
- }
-
- if($precision =
$this->bocommon->translate_datatype_precision($attrib['column_info']['type']))
- {
-
$attrib['column_info']['precision']=$precision;
- }
-
- if(!$attrib['column_info']['default'])
- {
-
unset($attrib['column_info']['default']);
- }
-
- $value_set=array(
- 'column_name' =>
$attrib['column_name'],
- 'datatype' =>
$attrib['column_info']['type'],
- 'precision_' =>
$attrib['column_info']['precision'],
- 'scale' =>
$attrib['column_info']['scale'],
- 'default_value' =>
$attrib['column_info']['default'],
- 'nullable' =>
$attrib['column_info']['nullable']
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE fm_entity_attribute
set $value_set WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['cat_id']. " AND id=" . $attrib['id'],__LINE__,__FILE__);
-
- $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
-
- $this->init_process();
-
- $mini_table_def = array(
- 'fm_entity_'.$attrib['entity_id'] . '_'
. $attrib['cat_id'] => array(
- 'fd' => array(
- $OldColumnName
=>$attrib['column_info']),
- 'pk' => array(),
- 'fk' => array(),
- 'ix' => array(),
- 'uc' => array()
- )
- );
-
- $this->oProc->GenerateScripts($mini_table_def);
-
$this->oProc->RenameColumn('fm_entity_'.$attrib['entity_id'] . '_' .
$attrib['cat_id'], $OldColumnName, $attrib['column_name']);
-
$this->oProc->AlterColumn('fm_entity_'.$attrib['entity_id'] . '_' .
$attrib['cat_id'],$attrib['column_name'],$attrib['column_info']);
- }
-
- $choice_table ='fm_entity_choice';
-
- if($attrib['new_choice'])
- {
- $choice_id =
$this->bocommon->next_id($choice_table
,array('entity_id'=>$attrib['entity_id'],'cat_id'=>$attrib['cat_id'],'attrib_id'=>$attrib['id']));
-
- $values= array(
- $attrib['entity_id'],
- $attrib['cat_id'],
- $attrib['id'],
- $choice_id,
- $attrib['new_choice']
- );
-
- $values =
$this->bocommon->validate_db_insert($values);
-
- $this->db->query("INSERT INTO $choice_table
(entity_id,cat_id,attrib_id,id,value) "
- . "VALUES ($values)",__LINE__,__FILE__);
- }
-
- if($attrib['delete_choice'])
- {
- for
($i=0;$i<count($attrib['delete_choice']);$i++)
- {
- $this->db->query("DELETE FROM
$choice_table WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['cat_id']. " AND attrib_id=" . $attrib['id'] ." AND id=" .
$attrib['delete_choice'][$i],__LINE__,__FILE__);
- }
- }
-
- $this->db->transaction_commit();
-
- $receipt['message'][] = array('msg' =>
lang('Attribute has been edited'));
-
- return $receipt;
- }
-
- function resort_attrib($data)
- {
- if(is_array($data))
- {
- $resort =
(isset($data['resort'])?$data['resort']:'up');
- $entity_id =
(isset($data['entity_id'])?$data['entity_id']:0);
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $id = (isset($data['id'])?$data['id']:'');
- }
-
- $sql = "SELECT attrib_sort FROM fm_entity_attribute
where entity_id=$entity_id AND cat_id=$cat_id AND id=$id";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $attrib_sort = $this->db->f('attrib_sort');
- $sql2 = "SELECT max(attrib_sort) as max_sort FROM
fm_entity_attribute where entity_id=$entity_id AND cat_id=$cat_id";
- $this->db->query($sql2,__LINE__,__FILE__);
- $this->db->next_record();
- $max_sort = $this->db->f('max_sort');
-
- switch($resort)
- {
- case 'up':
- if($attrib_sort>1)
- {
- $sql = "UPDATE
fm_entity_attribute set attrib_sort=$attrib_sort WHERE entity_id=$entity_id AND
cat_id=$cat_id AND attrib_sort =" . ($attrib_sort-1);
-
$this->db->query($sql,__LINE__,__FILE__);
- $sql = "UPDATE
fm_entity_attribute set attrib_sort=" . ($attrib_sort-1) ." WHERE
entity_id=$entity_id AND cat_id=$cat_id AND id=$id";
-
$this->db->query($sql,__LINE__,__FILE__);
- }
- break;
- case 'down':
- if($max_sort > $attrib_sort)
- {
- $sql = "UPDATE
fm_entity_attribute set attrib_sort=$attrib_sort WHERE entity_id=$entity_id AND
cat_id=$cat_id AND attrib_sort =" . ($attrib_sort+1);
-
$this->db->query($sql,__LINE__,__FILE__);
- $sql = "UPDATE
fm_entity_attribute set attrib_sort=" . ($attrib_sort+1) ." WHERE
entity_id=$entity_id AND cat_id=$cat_id AND id=$id";
-
$this->db->query($sql,__LINE__,__FILE__);
- }
- break;
- default:
- return;
- break;
- }
- }
-
- function read_custom_function($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $acl_location =
(isset($data['acl_location'])?$data['acl_location']:'');
- }
-
- if(!$acl_location)
- {
- return;
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by custom_sort asc';
- }
-
- $table = 'fm_custom_function';
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " AND name $this->like
'%$query%' or descr $this->like '%$query%'";
- }
-
- $sql = "SELECT * FROM $table WHERE
acl_location='$acl_location' $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $custom_function[] = array
- (
- 'id' => $this->db->f('id'),
- 'file_name' =>
$this->db->f('file_name'),
- 'sorting' =>
$this->db->f('custom_sort'),
- 'descr' =>
$this->db->f('descr'),
- 'active' =>
$this->db->f('active')
- );
- }
- return $custom_function;
- }
-
-
- function read_single_custom_function($acl_location,$id)
- {
-
- $sql = "SELECT * FROM fm_custom_function where
acl_location='$acl_location' AND id=$id";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $custom_function['id'] =
$this->db->f('id');
- $custom_function['descr'] =
$this->db->f('descr');
- $custom_function['custom_function_file']=
$this->db->f('file_name');
- $custom_function['active'] =
$this->db->f('active');
-
- return $custom_function;
- }
-
- }
-
- function add_custom_function($custom_function)
- {
- if(!$custom_function['acl_location'] &&
$custom_function['entity_id'] && $custom_function['cat_id'])
- {
- $acl_location = '.entity.' .
$custom_function['entity_id'] . '.' . $custom_function['cat_id'];
- }
- else
- {
- $acl_location =
$custom_function['acl_location'];
- }
-
- if(!$acl_location)
- {
- return $receipt['error'][] = array('msg' =>
lang('acl_locastion is missing'));
- }
-
- $custom_function['descr'] =
$this->db->db_addslashes($custom_function['descr']);
-
-
- $this->db->query("SELECT max(id) as maximum FROM
fm_custom_function WHERE acl_location='$acl_location'",__LINE__,__FILE__);
- $this->db->next_record();
- $custom_function['id'] = $this->db->f('maximum')+1;
-
- $sql = "SELECT max(custom_sort) as max_sort FROM
fm_custom_function where acl_location='$acl_location'";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $custom_sort = $this->db->f('max_sort')+1;
-
- $values= array(
- $acl_location,
- $custom_function['id'],
- $custom_function['custom_function_file'],
- $custom_function['descr'],
- $custom_function['active'],
- $custom_sort
- );
-
- $values = $this->bocommon->validate_db_insert($values);
-
-//_debug_array($custom_function);
- $this->db->transaction_begin();
-
- $this->db->query("INSERT INTO fm_custom_function
(acl_location, id, file_name, descr, active, custom_sort) "
- . "VALUES ($values)",__LINE__,__FILE__);
-
- $receipt['id']= $custom_function['id'];
-
- $this->db->transaction_commit();
-
- return $receipt;
- }
-
- function edit_custom_function($custom_function)
- {
- if(!$custom_function['acl_location'] &&
$custom_function['entity_id'] && $custom_function['cat_id'])
- {
- $acl_location = '.entity.' .
$custom_function['entity_id'] . '.' . $custom_function['cat_id'];
- }
- else
- {
- $acl_location =
$custom_function['acl_location'];
- }
-
- if(!$acl_location)
- {
- return $receipt['error'][] = array('msg' =>
lang('acl_locastion is missing'));
- }
-
- $custom_function['descr'] =
$this->db->db_addslashes($custom_function['descr']);
-
- $this->db->transaction_begin();
-
- $value_set=array(
- 'descr' =>
$custom_function['descr'],
- 'file_name' =>
$custom_function['custom_function_file'],
- 'active' =>
$custom_function['active']
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE fm_custom_function set
$value_set WHERE acl_location='" . $acl_location . "' AND id=" .
$custom_function['id'],__LINE__,__FILE__);
-
- $this->db->transaction_commit();
-
- $receipt['message'][] = array('msg' => lang('Custom
function has been edited'));
-
- return $receipt;
- }
-
- function resort_custom_function($data)
- {
- if(is_array($data))
- {
- $resort =
(isset($data['resort'])?$data['resort']:'up');
- $entity_id =
(isset($data['entity_id'])?$data['entity_id']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
- $acl_location =
(isset($data['acl_location'])?$data['acl_location']:'');
- $id = (isset($data['id'])?$data['id']:'');
- }
-
- if(!$acl_location && $entity_id && $cat_id)
- {
- $acl_location = '.entity.' . $entity_id . '.' .
$cat_id;
- }
- else
- {
- $acl_location = $acl_location;
- }
-
- if(!$acl_location)
- {
- return $receipt['error'][] = array('msg' =>
lang('acl_locastion is missing'));
- }
-
- $sql = "SELECT custom_sort FROM fm_custom_function
where acl_location='$acl_location' AND id=$id";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $custom_sort = $this->db->f('custom_sort');
- $sql2 = "SELECT max(custom_sort) as max_sort FROM
fm_custom_function where acl_location='$acl_location'";
- $this->db->query($sql2,__LINE__,__FILE__);
- $this->db->next_record();
- $max_sort = $this->db->f('max_sort');
-
- switch($resort)
- {
- case 'up':
- if($custom_sort>1)
- {
- $sql = "UPDATE
fm_custom_function set custom_sort=$custom_sort WHERE
acl_location='$acl_location' AND custom_sort =" . ($custom_sort-1);
-
$this->db->query($sql,__LINE__,__FILE__);
- $sql = "UPDATE
fm_custom_function set custom_sort=" . ($custom_sort-1) ." WHERE
acl_location='$acl_location' AND id=$id";
-
$this->db->query($sql,__LINE__,__FILE__);
- }
- break;
- case 'down':
- if($max_sort > $custom_sort)
- {
- $sql = "UPDATE
fm_custom_function set custom_sort=$custom_sort WHERE
acl_location='$acl_location' AND custom_sort =" . ($custom_sort+1);
-
$this->db->query($sql,__LINE__,__FILE__);
- $sql = "UPDATE
fm_custom_function set custom_sort=" . ($custom_sort+1) ." WHERE
acl_location='$acl_location' AND id=$id";
-
$this->db->query($sql,__LINE__,__FILE__);
- }
- break;
- default:
- return;
- break;
- }
- }
-
- function
delete_custom_function($acl_location,$custom_function_id)
- {
- $sql = "SELECT custom_sort FROM fm_custom_function
where acl_location='$acl_location' AND id=$custom_function_id";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $custom_sort = $this->db->f('custom_sort');
- $sql2 = "SELECT max(custom_sort) as max_sort FROM
fm_custom_function where acl_location='$acl_location'";
- $this->db->query($sql2,__LINE__,__FILE__);
- $this->db->next_record();
- $max_sort = $this->db->f('max_sort');
- if($max_sort>$custom_sort)
- {
- $sql = "UPDATE fm_custom_function set
custom_sort=custom_sort-1 WHERE acl_location='$acl_location' AND custom_sort >
$custom_sort";
- $this->db->query($sql,__LINE__,__FILE__);
- }
- $this->db->query("DELETE FROM fm_custom_function WHERE
acl_location='$acl_location' AND id=$custom_function_id",__LINE__,__FILE__);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.soadmin_entity.inc.php,v 1.11 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class soadmin_entity
+ {
+ var $grants;
+
+ function soadmin_entity($entity_id='',$cat_id='')
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+
+ $this->join = $this->bocommon->join;
+ $this->like = $this->bocommon->like;
+
+ if($entity_id && $cat_id)
+ {
+ $this->category_name =
$this->read_category_name($entity_id,$cat_id);
+ }
+ }
+
+ function reset_fm_cache()
+ {
+ $this->db->query("DELETE FROM fm_cache
",__LINE__,__FILE__);
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by id asc';
+ }
+
+ $table = 'fm_entity';
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " where name $this->like
'%$query%' or descr $this->like '%$query%'";
+ }
+
+ $sql = "SELECT * FROM $table $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $entity[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'name' => $this->db->f('name'),
+ 'descr' => $this->db->f('descr'),
+ 'documentation' =>
$this->db->f('documentation')
+ );
+ }
+ return $entity;
+ }
+
+ function read_category($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $entity_id =
(isset($data['entity_id'])?$data['entity_id']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by id asc';
+ }
+
+ $table = 'fm_entity_category';
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " AND name $this->like
'%$query%' or descr $this->like '%$query%'";
+ }
+
+ $sql = "SELECT * FROM $table WHERE entity_id=$entity_id
$querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $standard[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'name' => $this->db->f('name'),
+ 'prefix'=> $this->db->f('prefix'),
+ 'descr' => $this->db->f('descr')
+ );
+ }
+ return $standard;
+ }
+
+ function read_status($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $entity_id =
(isset($data['entity_id'])?$data['entity_id']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by id asc';
+ }
+
+ $table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " AND name $this->like
'%$query%' or descr $this->like '%$query%'";
+ }
+
+ $sql = "SELECT * FROM $table $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $status[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'descr' => $this->db->f('descr')
+ );
+ }
+ return $status;
+ }
+
+
+ function read_single($id)
+ {
+
+ $sql = "SELECT * FROM fm_entity where id='$id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $entity['id'] =
$this->db->f('id');
+ $entity['name'] =
$this->db->f('name');
+ $entity['descr'] =
$this->db->f('descr');
+ $entity['location_form'] =
$this->db->f('location_form');
+ $entity['lookup_entity'] =
unserialize($this->db->f('lookup_entity'));
+ $entity['documentation'] =
$this->db->f('documentation');
+ }
+
+ $sql = "SELECT location FROM fm_entity_lookup where
entity_id=$id AND type='lookup'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $entity['include_entity_for'][] =
$this->db->f('location');
+ }
+
+ $sql = "SELECT location FROM fm_entity_lookup where
entity_id=$id AND type='start'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $entity['start_entity_from'][] =
$this->db->f('location');
+ }
+
+ return $entity;
+ }
+
+ function read_single_category($entity_id,$cat_id)
+ {
+ $sql = "SELECT * FROM fm_entity_category where
entity_id=$entity_id AND id=$cat_id";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $category['id'] =
$this->db->f('id');
+ $category['name'] =
$this->db->f('name');
+ $category['descr'] =
$this->db->f('descr');
+ $category['prefix'] =
$this->db->f('prefix');
+ $category['lookup_tenant'] =
$this->db->f('lookup_tenant');
+ $category['tracking'] =
$this->db->f('tracking');
+ $category['location_level'] =
$this->db->f('location_level');
+ $category['fileupload'] =
$this->db->f('fileupload');
+ $category['loc_link'] =
$this->db->f('loc_link');
+ $category['start_project'] =
$this->db->f('start_project');
+ return $category;
+ }
+ }
+
+ function read_category_name($entity_id,$cat_id)
+ {
+ $sql = "SELECT * FROM fm_entity_category where
entity_id=$entity_id AND id=$cat_id";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ return $this->db->f('name');
+ }
+
+ function read_single_status($entity_id,$cat_id,$id)
+ {
+
+ $table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
+ $sql = "SELECT * FROM $table where id='$id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $status['id'] =
$this->db->f('id');
+ $status['descr'] =
$this->db->f('descr');
+
+ return $status;
+ }
+ }
+
+ function add_entity($entity)
+ {
+ $entity['name'] =
$this->db->db_addslashes($entity['name']);
+ $entity['descr'] =
$this->db->db_addslashes($entity['descr']);
+
+ $entity['id'] = $this->bocommon->next_id('fm_entity');
+
+ $values= array(
+ $entity['id'],
+ $entity['name'],
+ $entity['descr'],
+ $entity['location_form'],
+ $entity['documentation']
+ );
+
+ $values = $this->bocommon->validate_db_insert($values);
+
+ $this->db->query("INSERT INTO fm_entity (id,name,
descr,location_form,documentation) "
+ . "VALUES ($values)",__LINE__,__FILE__);
+
+
+ $values_acl_location= array(
+ '.entity.' . $entity['id'],
+ $entity['name'],
+ 1
+ );
+
+ $values_acl_location =
$this->bocommon->validate_db_insert($values_acl_location);
+
+ $this->db->query("INSERT INTO fm_acl_location
(id,descr,allow_grant) "
+ . "VALUES
($values_acl_location)",__LINE__,__FILE__);
+
+ $receipt['id']= $entity['id'];
+
+ $receipt['message'][] = array('msg'=> lang('entity has
been added'));
+ return $receipt;
+ }
+
+
+ function add_status($values,$entity_id,$cat_id)
+ {
+ $values['id'] = $this->db->db_addslashes($values['id']);
+ $values['descr'] =
$this->db->db_addslashes($values['descr']);
+
+ $values_insert= array(
+ $values['id'],
+ $values['descr'],
+ );
+
+ $values_insert =
$this->bocommon->validate_db_insert($values_insert);
+
+ $table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
+
+ $this->db->query("INSERT INTO $table (id,descr) VALUES
($values_insert)",__LINE__,__FILE__);
+
+ $receipt['id']= $values['id'];
+
+ $receipt['message'][] = array('msg'=> lang('status has
been added'));
+ return $receipt;
+ }
+
+
+ function add_category($values)
+ {
+ $values['name'] =
$this->db->db_addslashes($values['name']);
+ $values['descr'] =
$this->db->db_addslashes($values['descr']);
+
+ $values['id'] =
$this->bocommon->next_id('fm_entity_category',array('entity_id'=>$values['entity_id']));
+
+ $location_type =
$this->bocommon->next_id('fm_location_type');
+
+ $values_insert= array(
+ $values['entity_id'],
+ $values['id'],
+ $values['name'],
+ $values['descr'],
+ $values['prefix'],
+ $values['lookup_tenant'],
+ $values['tracking'],
+ $values['location_level'],
+ $values['fileupload'],
+ $values['loc_link'],
+ $values['start_project']
+ );
+
+ $values_insert =
$this->bocommon->validate_db_insert($values_insert);
+
+
+ $this->db->transaction_begin();
+
+ $this->db->query("INSERT INTO fm_entity_category
(entity_id,id,name,
descr,prefix,lookup_tenant,tracking,location_level,fileupload,loc_link,start_project)
"
+ . "VALUES ($values_insert)",__LINE__,__FILE__);
+
+ $values_acl_location= array(
+ '.entity.' . $values['entity_id'] . '.' .
$values['id'],
+ $values['name'],
+ 1
+ );
+
+ $values_acl_location =
$this->bocommon->validate_db_insert($values_acl_location);
+
+ $this->db->query("INSERT INTO fm_acl_location
(id,descr,allow_grant) "
+ . "VALUES
($values_acl_location)",__LINE__,__FILE__);
+
+ $receipt['id']= $values['id'];
+
+ $this->init_process();
+
+ $fd=array();
+ $fd['id'] = array('type' => 'int', 'precision' => 4,
'nullable' => False);
+ $fd['num'] = array('type' => 'varchar', 'precision' =>
16, 'nullable' => False);
+ $fd['p_num'] = array('type' => 'varchar', 'precision'
=> 16, 'nullable' => True);
+ $fd['p_entity_id'] = array('type' => 'int', 'precision'
=> 4, 'nullable' => True);
+ $fd['p_cat_id'] = array('type' => 'int', 'precision' =>
4, 'nullable' => True);
+ $fd['location_code'] = array('type' => 'varchar',
'precision' => 25, 'nullable' => True);
+
+ for ($i=1; $i<$location_type; $i++)
+ {
+ $fd['loc' . $i] = array('type' => 'varchar',
'precision' => 4, 'nullable' => True);
+ }
+
+ $fd['address'] = array('type' => 'varchar', 'precision'
=> 150, 'nullable' => True);
+ $fd['tenant_id'] = array('type' => 'int', 'precision'
=> 4, 'nullable' => True);
+ $fd['contact_phone'] = array('type' => 'varchar',
'precision' => 30, 'nullable' => True);
+ $fd['status'] = array('type' => 'int', 'precision' =>
4, 'nullable' => True);
+ $fd['entry_date'] = array('type' => 'int', 'precision'
=> 4, 'nullable' => True);
+ $fd['user_id'] = array('type' => 'int', 'precision' =>
4, 'nullable' => True);
+
+ $pk[]= 'id';
+ $table = 'fm_entity_'.
$values['entity_id'] .'_'.$values['id'];
+/*
+ $fd_status['id'] = array('type' => 'varchar',
'precision' => 20, 'nullable' => False);
+ $fd_status['descr'] = array('type' => 'varchar',
'precision' => 255, 'nullable' => False);
+ $pk_status[]= 'id';
+
+ $statustable = $table . '_' .'status';
+*/
+ if(($this->oProc->CreateTable($table,array('fd' =>
$fd,'pk' => $pk,'fk' => $fk,'ix' => array('location_code'),'uc' => array()))))
+// &&
($this->oProc->CreateTable($statustable,array('fd' => $fd_status,'pk' =>
$pk_status,'fk' => $fk_status,'ix' => False,'uc' => array()))))
+ {
+
+ $values_insert= array(
+ $values['entity_id'],
+ $values['id'],
+ 1,
+ 'status',
+ 'Status',
+ 'Status',
+ 'LB',
+ 1,
+ 'True'
+ );
+
+ $values_insert =
$this->bocommon->validate_db_insert($values_insert);
+
+ $this->db->query("INSERT INTO
fm_entity_attribute
(entity_id,cat_id,id,column_name,input_text,statustext,datatype,attrib_sort,nullable)
"
+ . "VALUES
($values_insert)",__LINE__,__FILE__);
+
+ $receipt['message'][] = array('msg' =>
lang('table %1 has been saved',$table));
+ $this->db->transaction_commit();
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('table could not be added') );
+ if($this->db->Transaction)
+ {
+ $this->db->transaction_abort();
+ }
+ else
+ {
+ $this->db->query("DELETE FROM
fm_entity_category WHERE id=" . $values['id'] . " AND entity_id=" .
$values['entity_id'],__LINE__,__FILE__);
+ unset($receipt['id']);
+
+ }
+ }
+
+ return $receipt;
+ }
+
+ function edit_status($values,$entity_id,$cat_id)
+ {
+ $table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
+
+ $values['descr'] =
$this->db->db_addslashes($values['descr']);
+
+ $value_set=array(
+ 'descr' => $values['descr'],
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE $table set $value_set WHERE
id='" . $values['id'] . "'",__LINE__,__FILE__);
+
+ $receipt['message'][] = array('msg'=> lang('Status has
been edited'));
+
+ return $receipt;
+ }
+
+ function edit_entity($entity)
+ {
+ if (!$entity['name'])
+ {
+ $receipt['error'][] = array('msg'=>lang('Name
not entered!'));
+ }
+
+ if (!$receipt['error'])
+ {
+ $table = 'fm_entity';
+
+ $entity['name'] =
$this->db->db_addslashes($entity['name']);
+ $entity['descr'] =
$this->db->db_addslashes($entity['descr']);
+
+ if(!$entity['location_form'])
+ {
+ unset($entity['lookup_entity']);
+ }
+
+ $value_set=array(
+ 'descr' => $entity['descr'],
+ 'name' => $entity['name'],
+ 'location_form' => $entity['location_form'],
+ 'lookup_entity' =>
serialize($entity['lookup_entity']),
+ 'documentation' => $entity['documentation']
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->transaction_begin();
+
+ $this->db->query("UPDATE $table set $value_set
WHERE id=" . $entity['id'],__LINE__,__FILE__);
+
+ $value_set_acl=array(
+ 'descr' =>
$entity['name']
+ );
+
+ $value_set_acl =
$this->bocommon->validate_db_update($value_set_acl);
+
+ $this->db->query("UPDATE fm_acl_location set
$value_set_acl WHERE id='.entity." . $entity['id']. "'",__LINE__,__FILE__);
+
+ $this->db->query("DELETE FROM fm_entity_lookup
WHERE type='lookup' AND entity_id=" . $entity['id'],__LINE__,__FILE__);
+ if (isset($entity['include_entity_for']) AND
is_array($entity['include_entity_for']))
+ {
+ foreach($entity['include_entity_for']
as $location)
+ {
+ $this->db->query("INSERT INTO
fm_entity_lookup (entity_id,location,type)"
+ . "VALUES (" .$entity['id'] .
",'$location','lookup' )",__LINE__,__FILE__);
+ }
+ }
+
+ $this->db->query("DELETE FROM fm_entity_lookup
WHERE type='start' AND entity_id=" . $entity['id'],__LINE__,__FILE__);
+
+ if (isset($entity['start_entity_from']) AND
is_array($entity['start_entity_from']))
+ {
+ foreach($entity['start_entity_from'] as
$location)
+ {
+ $this->db->query("INSERT INTO
fm_entity_lookup (entity_id,location,type)"
+ . "VALUES (" .$entity['id'] .
",'$location','start' )",__LINE__,__FILE__);
+ }
+ }
+
+ $this->db->transaction_commit();
+
+ $receipt['message'][] = array('msg'=>
lang('entity has been edited'));
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('entity has NOT been edited'));
+ }
+
+ return $receipt;
+ }
+
+ function edit_category($entity)
+ {
+
+ if (!$entity['name'])
+ {
+ $receipt['error'][] = array('msg'=>lang('Name
not entered!'));
+ }
+
+ if (!$receipt['error'])
+ {
+ $table = 'fm_entity_category';
+
+ $entity['name'] =
$this->db->db_addslashes($entity['name']);
+ $entity['descr'] =
$this->db->db_addslashes($entity['descr']);
+
+ $value_set=array(
+ 'descr' =>
$entity['descr'],
+ 'name' =>
$entity['name'],
+ 'prefix' =>
$entity['prefix'],
+ 'lookup_tenant' =>
$entity['lookup_tenant'],
+ 'tracking' =>
$entity['tracking'],
+ 'location_level'=>
$entity['location_level'],
+ 'fileupload' =>
$entity['fileupload'],
+ 'loc_link' =>
$entity['loc_link'],
+ 'start_project' =>
$entity['start_project']
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE $table set $value_set
WHERE entity_id=" . $entity['entity_id']. " AND id=" .
$entity['id'],__LINE__,__FILE__);
+
+ $value_set_acl=array(
+ 'descr' =>
$entity['name']
+ );
+
+ $value_set_acl =
$this->bocommon->validate_db_update($value_set_acl);
+
+ $this->db->query("UPDATE fm_acl_location set
$value_set_acl WHERE id='.entity." . $entity['entity_id']. "." . $entity['id'].
"'",__LINE__,__FILE__);
+
+
+ $receipt['message'][] = array('msg'=>
lang('entity has been edited'));
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('entity has NOT been edited'));
+ }
+
+ return $receipt;
+ }
+
+ function delete_entity($id)
+ {
+
$category_list=$this->read_category(array('entity_id'=>$id));
+ $this->db->query("DELETE FROM fm_entity WHERE
id=$id",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_entity_category WHERE
entity_id=$id",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_entity_attribute WHERE
entity_id=$id",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_acl_location WHERE id
$this->like '.entity." . $id ."%'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_acl2 WHERE
acl_location $this->like '.entity." . $id ."%'",__LINE__,__FILE__);
+ if (isset($category_list) AND is_array($category_list))
+ {
+ $this->init_process();
+
+ foreach($category_list as $entry)
+ {
+ $this->oProc->DropTable('fm_entity_' .
$id . '_' . $entry['id']);
+ }
+ }
+
+ }
+
+ function delete_category($id,$entity_id)
+ {
+ $this->init_process();
+ $this->oProc->DropTable('fm_entity_' . $entity_id . '_'
. $id);
+// $this->oProc->DropTable('fm_entity_' . $entity_id . '_'
. $id . '_' . 'status');
+ $this->db->query("DELETE FROM fm_entity_category WHERE
entity_id= $entity_id AND id= $id",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_entity_attribute WHERE
entity_id= $entity_id AND cat_id= $id",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_acl_location WHERE
id='.entity." . $entity_id . "." . $id ."'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_acl2 WHERE
acl_location='.entity." . $entity_id . "." . $id ."'",__LINE__,__FILE__);
+ }
+
+ function delete_attrib($cat_id,$entity_id,$attrib_id)
+ {
+ $this->init_process();
+
+ $sql = "SELECT * FROM fm_entity_attribute WHERE
entity_id=$entity_id AND cat_id=$cat_id AND id=$attrib_id";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $ColumnName = $this->db->f('column_name');
+
+ $this->oProc->DropColumn('fm_entity_' .$entity_id.'_'.
$cat_id,'', $ColumnName);
+
+ $sql = "SELECT attrib_sort FROM fm_entity_attribute
where entity_id=$entity_id AND cat_id=$cat_id AND id=$attrib_id";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $attrib_sort = $this->db->f('attrib_sort');
+ $sql2 = "SELECT max(attrib_sort) as max_sort FROM
fm_entity_attribute where entity_id=$entity_id AND cat_id=$cat_id";
+ $this->db->query($sql2,__LINE__,__FILE__);
+ $this->db->next_record();
+ $max_sort = $this->db->f('max_sort');
+ if($max_sort>$attrib_sort)
+ {
+ $sql = "UPDATE fm_entity_attribute set
attrib_sort=attrib_sort-1 WHERE entity_id=$entity_id AND cat_id=$cat_id AND
attrib_sort > $attrib_sort";
+ $this->db->query($sql,__LINE__,__FILE__);
+ }
+
+ $this->db->query("DELETE FROM fm_entity_attribute WHERE
entity_id=$entity_id AND cat_id=$cat_id AND id=$attrib_id",__LINE__,__FILE__);
+ }
+
+ function delete_status($cat_id,$entity_id,$status_id)
+ {
+ $table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
+
+ $this->db->query("DELETE FROM $table WHERE
id='$status_id'",__LINE__,__FILE__);
+ }
+
+ function read_attrib($data)
+ {
+
+//_debug_array($data);
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $entity_id =
(isset($data['entity_id'])?$data['entity_id']:0);
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by attrib_sort asc';
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " AND (fm_entity_attribute.name
$this->like '%$query%' or fm_entity_attribute.descr $this->like '%$query%')";
+ }
+
+ $sql = "SELECT * FROM fm_entity_attribute WHERE
entity_id=$entity_id AND cat_id = $cat_id $filtermethod $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+
+ while ($this->db->next_record())
+ {
+ $attrib[] = array
+ (
+ 'id' =>
$this->db->f('id'),
+ 'entity_type' =>
$this->db->f('type_id'),
+ 'attrib_sort' =>
$this->db->f('attrib_sort'),
+ 'list' =>
$this->db->f('list'),
+ 'lookup_form' =>
$this->db->f('lookup_form'),
+ 'entity_form' =>
$this->db->f('entity_form'),
+ 'column_name' =>
$this->db->f('column_name'),
+ 'name' =>
$this->db->f('input_text'),
+ 'size' =>
$this->db->f('size'),
+ 'statustext' =>
$this->db->f('statustext'),
+ 'input_text' =>
$this->db->f('input_text'),
+ 'type_name' =>
$this->db->f('type'),
+ 'datatype' =>
$this->db->f('datatype'),
+ 'search' =>
$this->db->f('search')
+ );
+ }
+ return $attrib;
+ }
+
+ function read_single_attrib($entity_id,$cat_id,$id)
+ {
+
+ $sql = "SELECT * FROM fm_entity_attribute where
entity_id=$entity_id AND cat_id=$cat_id AND id=$id";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $attrib['id']
= $this->db->f('id');
+ $attrib['column_name']
= $this->db->f('column_name');
+ $attrib['input_text']
= $this->db->f('input_text');
+ $attrib['statustext']
= $this->db->f('statustext');
+ $attrib['column_info']['precision'] =
$this->db->f('precision_');
+ $attrib['column_info']['scale'] =
$this->db->f('scale');
+ $attrib['column_info']['default'] =
$this->db->f('default_value');
+ $attrib['column_info']['nullable'] =
$this->db->f('nullable');
+ $attrib['column_info']['type'] =
$this->db->f('datatype');
+ $attrib['type_id']
= $this->db->f('type_id');
+ $attrib['type_name']
= $this->db->f('type_name');
+ $attrib['lookup_form']
= $this->db->f('lookup_form');
+ $attrib['list']
= $this->db->f('list');
+ $attrib['search']
= $this->db->f('search');
+ if($this->db->f('datatype')=='R' ||
$this->db->f('datatype')=='CH' || $this->db->f('datatype')=='LB')
+ {
+ $attrib['choice'] =
$this->read_attrib_choice($entity_id,$cat_id,$id);
+ }
+
+ return $attrib;
+ }
+ }
+
+ function read_attrib_choice($entity_id,$cat_id,$attrib_id)
+ {
+ $choice_table = 'fm_entity_choice';
+ $sql = "SELECT * FROM $choice_table WHERE
entity_id=$entity_id AND cat_id=$cat_id AND attrib_id=$attrib_id";
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $choice[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'value' => $this->db->f('value')
+ );
+ }
+ return $choice;
+ }
+
+ function add_attrib($attrib)
+ {
+
+ $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
+ $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
+ $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
+ $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
+ $attrib['id'] =
$this->bocommon->next_id('fm_entity_attribute',array('entity_id'=>$attrib['entity_id'],'cat_id'=>$attrib['cat_id']));
+
+ $sql = "SELECT max(attrib_sort) as max_sort FROM
fm_entity_attribute where entity_id=" . $attrib['entity_id'] . " AND cat_id=" .
$attrib['cat_id'];
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $attrib_sort = $this->db->f('max_sort')+1;
+
+ $values= array(
+ $attrib['entity_id'],
+ $attrib['cat_id'],
+ $attrib['id'],
+ $attrib['column_name'],
+ $attrib['input_text'],
+ $attrib['statustext'],
+ $attrib['search'],
+ $attrib['list'],
+ $attrib_sort,
+ $attrib['column_info']['type'],
+ $attrib['column_info']['precision'],
+ $attrib['column_info']['scale'],
+ $attrib['column_info']['default'],
+ $attrib['column_info']['nullable']
+ );
+
+ $values = $this->bocommon->validate_db_insert($values);
+
+ $this->db->transaction_begin();
+
+ $this->db->query("INSERT INTO fm_entity_attribute
(entity_id,cat_id,id,column_name, input_text,
statustext,search,list,attrib_sort,
datatype,precision_,scale,default_value,nullable) "
+ . "VALUES ($values)",__LINE__,__FILE__);
+
+ $receipt['id']= $attrib['id'];
+
+ if($attrib['column_info']['type']=='email' &&
!$attrib['column_info']['precision'])
+ {
+ $attrib['column_info']['precision']=64;
+ }
+
+ $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
+
+ if($attrib['column_info']['type']=='int' &&
!$attrib['column_info']['precision'])
+ {
+ $attrib['column_info']['precision']=4;
+ }
+
+ if(!$attrib['column_info']['default'])
+ {
+ unset($attrib['column_info']['default']);
+ }
+
+ $this->init_process();
+
+
if($this->oProc->AddColumn('fm_entity_'.$attrib['entity_id'] . '_' .
$attrib['cat_id'],$attrib['column_name'], $attrib['column_info']))
+ {
+ $receipt['message'][] = array('msg' =>
lang('Attribute has been saved') );
+ $this->db->transaction_commit();
+
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('column could not be added') );
+ if($this->db->Transaction)
+ {
+ $this->db->transaction_abort();
+ }
+ else
+ {
+ $this->db->query("DELETE FROM
fm_entity_attribute WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['id']. " AND id='" . $receipt['id'] . "'",__LINE__,__FILE__);
+ unset($receipt['id']);
+
+ }
+ }
+
+ return $receipt;
+ }
+
+ function init_process()
+ {
+ $this->oProc
=
CreateObject('phpgwapi.schema_proc',$GLOBALS['phpgw_info']['server']['db_type']);
+ $this->oProc->m_odb
= $this->db;
+ $this->oProc->m_odb->Halt_On_Error = 'report';
+ }
+
+ function edit_attrib($attrib)
+ {
+
+ $choice_table = 'fm_entity_choice';
+
+ $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
+ $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
+ $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
+ $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
+
+ $this->db->query("SELECT column_name FROM
fm_entity_attribute WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['cat_id']. " AND id='" . $attrib['id']. "'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $OldColumnName = $this->db->f('column_name');
+
+ $this->db->transaction_begin();
+
+ $value_set=array(
+ 'input_text' =>
$attrib['input_text'],
+ 'statustext' =>
$attrib['statustext'],
+ 'search' =>
$attrib['search'],
+ 'list' =>
$attrib['list'],
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE fm_entity_attribute
set $value_set WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['cat_id']. " AND id=" . $attrib['id'],__LINE__,__FILE__);
+
+ if($OldColumnName !=$attrib['column_name'])
+ {
+
+ if($attrib['column_info']['type']!='R' &&
$attrib['column_info']['type']!='CH' && $attrib['column_info']['type']!='LB')
+ {
+ $this->db->query("DELETE FROM
$choice_table WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['cat_id']. " AND attrib_id=" . $attrib['id'],__LINE__,__FILE__);
+ }
+
+ if($attrib['column_info']['type']=='email' &&
!$attrib['column_info']['precision'])
+ {
+ $attrib['column_info']['precision']=64;
+ }
+
+ if($precision =
$this->bocommon->translate_datatype_precision($attrib['column_info']['type']))
+ {
+
$attrib['column_info']['precision']=$precision;
+ }
+
+ if(!$attrib['column_info']['default'])
+ {
+
unset($attrib['column_info']['default']);
+ }
+
+ $value_set=array(
+ 'column_name' =>
$attrib['column_name'],
+ 'datatype' =>
$attrib['column_info']['type'],
+ 'precision_' =>
$attrib['column_info']['precision'],
+ 'scale' =>
$attrib['column_info']['scale'],
+ 'default_value' =>
$attrib['column_info']['default'],
+ 'nullable' =>
$attrib['column_info']['nullable']
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE fm_entity_attribute
set $value_set WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['cat_id']. " AND id=" . $attrib['id'],__LINE__,__FILE__);
+
+ $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
+
+ $this->init_process();
+
+ $mini_table_def = array(
+ 'fm_entity_'.$attrib['entity_id'] . '_'
. $attrib['cat_id'] => array(
+ 'fd' => array(
+ $OldColumnName
=>$attrib['column_info']),
+ 'pk' => array(),
+ 'fk' => array(),
+ 'ix' => array(),
+ 'uc' => array()
+ )
+ );
+
+ $this->oProc->GenerateScripts($mini_table_def);
+
$this->oProc->RenameColumn('fm_entity_'.$attrib['entity_id'] . '_' .
$attrib['cat_id'], $OldColumnName, $attrib['column_name']);
+
$this->oProc->AlterColumn('fm_entity_'.$attrib['entity_id'] . '_' .
$attrib['cat_id'],$attrib['column_name'],$attrib['column_info']);
+ }
+
+ $choice_table ='fm_entity_choice';
+
+ if($attrib['new_choice'])
+ {
+ $choice_id =
$this->bocommon->next_id($choice_table
,array('entity_id'=>$attrib['entity_id'],'cat_id'=>$attrib['cat_id'],'attrib_id'=>$attrib['id']));
+
+ $values= array(
+ $attrib['entity_id'],
+ $attrib['cat_id'],
+ $attrib['id'],
+ $choice_id,
+ $attrib['new_choice']
+ );
+
+ $values =
$this->bocommon->validate_db_insert($values);
+
+ $this->db->query("INSERT INTO $choice_table
(entity_id,cat_id,attrib_id,id,value) "
+ . "VALUES ($values)",__LINE__,__FILE__);
+ }
+
+ if($attrib['delete_choice'])
+ {
+ for
($i=0;$i<count($attrib['delete_choice']);$i++)
+ {
+ $this->db->query("DELETE FROM
$choice_table WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['cat_id']. " AND attrib_id=" . $attrib['id'] ." AND id=" .
$attrib['delete_choice'][$i],__LINE__,__FILE__);
+ }
+ }
+
+ $this->db->transaction_commit();
+
+ $receipt['message'][] = array('msg' =>
lang('Attribute has been edited'));
+
+ return $receipt;
+ }
+
+ function resort_attrib($data)
+ {
+ if(is_array($data))
+ {
+ $resort =
(isset($data['resort'])?$data['resort']:'up');
+ $entity_id =
(isset($data['entity_id'])?$data['entity_id']:0);
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $id = (isset($data['id'])?$data['id']:'');
+ }
+
+ $sql = "SELECT attrib_sort FROM fm_entity_attribute
where entity_id=$entity_id AND cat_id=$cat_id AND id=$id";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $attrib_sort = $this->db->f('attrib_sort');
+ $sql2 = "SELECT max(attrib_sort) as max_sort FROM
fm_entity_attribute where entity_id=$entity_id AND cat_id=$cat_id";
+ $this->db->query($sql2,__LINE__,__FILE__);
+ $this->db->next_record();
+ $max_sort = $this->db->f('max_sort');
+
+ switch($resort)
+ {
+ case 'up':
+ if($attrib_sort>1)
+ {
+ $sql = "UPDATE
fm_entity_attribute set attrib_sort=$attrib_sort WHERE entity_id=$entity_id AND
cat_id=$cat_id AND attrib_sort =" . ($attrib_sort-1);
+
$this->db->query($sql,__LINE__,__FILE__);
+ $sql = "UPDATE
fm_entity_attribute set attrib_sort=" . ($attrib_sort-1) ." WHERE
entity_id=$entity_id AND cat_id=$cat_id AND id=$id";
+
$this->db->query($sql,__LINE__,__FILE__);
+ }
+ break;
+ case 'down':
+ if($max_sort > $attrib_sort)
+ {
+ $sql = "UPDATE
fm_entity_attribute set attrib_sort=$attrib_sort WHERE entity_id=$entity_id AND
cat_id=$cat_id AND attrib_sort =" . ($attrib_sort+1);
+
$this->db->query($sql,__LINE__,__FILE__);
+ $sql = "UPDATE
fm_entity_attribute set attrib_sort=" . ($attrib_sort+1) ." WHERE
entity_id=$entity_id AND cat_id=$cat_id AND id=$id";
+
$this->db->query($sql,__LINE__,__FILE__);
+ }
+ break;
+ default:
+ return;
+ break;
+ }
+ }
+
+ function read_custom_function($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $acl_location =
(isset($data['acl_location'])?$data['acl_location']:'');
+ }
+
+ if(!$acl_location)
+ {
+ return;
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by custom_sort asc';
+ }
+
+ $table = 'fm_custom_function';
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " AND name $this->like
'%$query%' or descr $this->like '%$query%'";
+ }
+
+ $sql = "SELECT * FROM $table WHERE
acl_location='$acl_location' $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $custom_function[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'file_name' =>
$this->db->f('file_name'),
+ 'sorting' =>
$this->db->f('custom_sort'),
+ 'descr' =>
$this->db->f('descr'),
+ 'active' =>
$this->db->f('active')
+ );
+ }
+ return $custom_function;
+ }
+
+
+ function read_single_custom_function($acl_location,$id)
+ {
+
+ $sql = "SELECT * FROM fm_custom_function where
acl_location='$acl_location' AND id=$id";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $custom_function['id'] =
$this->db->f('id');
+ $custom_function['descr'] =
$this->db->f('descr');
+ $custom_function['custom_function_file']=
$this->db->f('file_name');
+ $custom_function['active'] =
$this->db->f('active');
+
+ return $custom_function;
+ }
+
+ }
+
+ function add_custom_function($custom_function)
+ {
+ if(!$custom_function['acl_location'] &&
$custom_function['entity_id'] && $custom_function['cat_id'])
+ {
+ $acl_location = '.entity.' .
$custom_function['entity_id'] . '.' . $custom_function['cat_id'];
+ }
+ else
+ {
+ $acl_location =
$custom_function['acl_location'];
+ }
+
+ if(!$acl_location)
+ {
+ return $receipt['error'][] = array('msg' =>
lang('acl_locastion is missing'));
+ }
+
+ $custom_function['descr'] =
$this->db->db_addslashes($custom_function['descr']);
+
+
+ $this->db->query("SELECT max(id) as maximum FROM
fm_custom_function WHERE acl_location='$acl_location'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $custom_function['id'] = $this->db->f('maximum')+1;
+
+ $sql = "SELECT max(custom_sort) as max_sort FROM
fm_custom_function where acl_location='$acl_location'";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $custom_sort = $this->db->f('max_sort')+1;
+
+ $values= array(
+ $acl_location,
+ $custom_function['id'],
+ $custom_function['custom_function_file'],
+ $custom_function['descr'],
+ $custom_function['active'],
+ $custom_sort
+ );
+
+ $values = $this->bocommon->validate_db_insert($values);
+
+//_debug_array($custom_function);
+ $this->db->transaction_begin();
+
+ $this->db->query("INSERT INTO fm_custom_function
(acl_location, id, file_name, descr, active, custom_sort) "
+ . "VALUES ($values)",__LINE__,__FILE__);
+
+ $receipt['id']= $custom_function['id'];
+
+ $this->db->transaction_commit();
+
+ return $receipt;
+ }
+
+ function edit_custom_function($custom_function)
+ {
+ if(!$custom_function['acl_location'] &&
$custom_function['entity_id'] && $custom_function['cat_id'])
+ {
+ $acl_location = '.entity.' .
$custom_function['entity_id'] . '.' . $custom_function['cat_id'];
+ }
+ else
+ {
+ $acl_location =
$custom_function['acl_location'];
+ }
+
+ if(!$acl_location)
+ {
+ return $receipt['error'][] = array('msg' =>
lang('acl_locastion is missing'));
+ }
+
+ $custom_function['descr'] =
$this->db->db_addslashes($custom_function['descr']);
+
+ $this->db->transaction_begin();
+
+ $value_set=array(
+ 'descr' =>
$custom_function['descr'],
+ 'file_name' =>
$custom_function['custom_function_file'],
+ 'active' =>
$custom_function['active']
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE fm_custom_function set
$value_set WHERE acl_location='" . $acl_location . "' AND id=" .
$custom_function['id'],__LINE__,__FILE__);
+
+ $this->db->transaction_commit();
+
+ $receipt['message'][] = array('msg' => lang('Custom
function has been edited'));
+
+ return $receipt;
+ }
+
+ function resort_custom_function($data)
+ {
+ if(is_array($data))
+ {
+ $resort =
(isset($data['resort'])?$data['resort']:'up');
+ $entity_id =
(isset($data['entity_id'])?$data['entity_id']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
+ $acl_location =
(isset($data['acl_location'])?$data['acl_location']:'');
+ $id = (isset($data['id'])?$data['id']:'');
+ }
+
+ if(!$acl_location && $entity_id && $cat_id)
+ {
+ $acl_location = '.entity.' . $entity_id . '.' .
$cat_id;
+ }
+ else
+ {
+ $acl_location = $acl_location;
+ }
+
+ if(!$acl_location)
+ {
+ return $receipt['error'][] = array('msg' =>
lang('acl_locastion is missing'));
+ }
+
+ $sql = "SELECT custom_sort FROM fm_custom_function
where acl_location='$acl_location' AND id=$id";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $custom_sort = $this->db->f('custom_sort');
+ $sql2 = "SELECT max(custom_sort) as max_sort FROM
fm_custom_function where acl_location='$acl_location'";
+ $this->db->query($sql2,__LINE__,__FILE__);
+ $this->db->next_record();
+ $max_sort = $this->db->f('max_sort');
+
+ switch($resort)
+ {
+ case 'up':
+ if($custom_sort>1)
+ {
+ $sql = "UPDATE
fm_custom_function set custom_sort=$custom_sort WHERE
acl_location='$acl_location' AND custom_sort =" . ($custom_sort-1);
+
$this->db->query($sql,__LINE__,__FILE__);
+ $sql = "UPDATE
fm_custom_function set custom_sort=" . ($custom_sort-1) ." WHERE
acl_location='$acl_location' AND id=$id";
+
$this->db->query($sql,__LINE__,__FILE__);
+ }
+ break;
+ case 'down':
+ if($max_sort > $custom_sort)
+ {
+ $sql = "UPDATE
fm_custom_function set custom_sort=$custom_sort WHERE
acl_location='$acl_location' AND custom_sort =" . ($custom_sort+1);
+
$this->db->query($sql,__LINE__,__FILE__);
+ $sql = "UPDATE
fm_custom_function set custom_sort=" . ($custom_sort+1) ." WHERE
acl_location='$acl_location' AND id=$id";
+
$this->db->query($sql,__LINE__,__FILE__);
+ }
+ break;
+ default:
+ return;
+ break;
+ }
+ }
+
+ function
delete_custom_function($acl_location,$custom_function_id)
+ {
+ $sql = "SELECT custom_sort FROM fm_custom_function
where acl_location='$acl_location' AND id=$custom_function_id";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $custom_sort = $this->db->f('custom_sort');
+ $sql2 = "SELECT max(custom_sort) as max_sort FROM
fm_custom_function where acl_location='$acl_location'";
+ $this->db->query($sql2,__LINE__,__FILE__);
+ $this->db->next_record();
+ $max_sort = $this->db->f('max_sort');
+ if($max_sort>$custom_sort)
+ {
+ $sql = "UPDATE fm_custom_function set
custom_sort=custom_sort-1 WHERE acl_location='$acl_location' AND custom_sort >
$custom_sort";
+ $this->db->query($sql,__LINE__,__FILE__);
+ }
+ $this->db->query("DELETE FROM fm_custom_function WHERE
acl_location='$acl_location' AND id=$custom_function_id",__LINE__,__FILE__);
+ }
+ }
+?>
Index: property/inc/class.soadmin_location.inc.php
diff -u property/inc/class.soadmin_location.inc.php:1.13
property/inc/class.soadmin_location.inc.php:1.14
--- property/inc/class.soadmin_location.inc.php:1.13 Wed May 18 16:05:55 2005
+++ property/inc/class.soadmin_location.inc.php Fri Jan 27 14:05:43 2006
@@ -1,1003 +1,1002 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.soadmin_location.inc.php,v 1.13 2005/05/18
16:05:55 sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class soadmin_location
- {
- var $grants;
-
- function soadmin_location()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->join = $this->bocommon->join;
- $this->like = $this->bocommon->like;
- }
-
-
- function reset_fm_cache()
- {
- $this->db->query("DELETE FROM fm_cache
",__LINE__,__FILE__);
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by id asc';
- }
-
- $table = 'fm_location_type';
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " where name $this->like
'%$query%' or descr $this->like '%$query%'";
- }
-
- $sql = "SELECT * FROM $table $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $standard[] = array
- (
- 'id' => $this->db->f('id'),
- 'name' => $this->db->f('name'),
- 'prefix'=> $this->db->f('prefix'),
- 'descr' => $this->db->f('descr')
- );
- }
- return $standard;
- }
-
- function read_config($data=0)
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
-
- if(is_array($data))
- {
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by column_name asc';
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " where name $this->like
'%$query%' or column_name $this->like '%$query%'";
- }
-
- $sql = "SELECT fm_location_config.*
,fm_location_type.name as name FROM fm_location_config $this->join
fm_location_type on fm_location_config.location_type=fm_location_type.id
$querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $config[] = array
- (
- 'column_name' =>
$this->db->f('column_name'),
- 'input_text' =>
$this->db->f('input_text'),
- 'f_key' =>
$this->db->f('f_key'),
- 'lookup_form' =>
$this->db->f('lookup_form'),
- 'ref_to_category' =>
$this->db->f('ref_to_category'),
- 'query_value' =>
$this->db->f('query_value'),
- 'reference_table' =>
$this->db->f('reference_table'),
- 'reference_id' =>
$this->db->f('reference_id'),
- 'location_name' =>
$this->db->f('name'),
- 'location_type' =>
$this->db->f('location_type')
- );
- }
- return $config;
- }
-
- function read_config_single($column_name='')
- {
- $this->db->query("SELECT location_type FROM
fm_location_config where column_name='$column_name'",__LINE__,__FILE__);
- $this->db->next_record();
- return $this->db->f('location_type');
- }
-
-
- function read_single($id)
- {
-
- $table = 'fm_location_type';
-
- $sql = "SELECT * FROM $table where id='$id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $standard['id'] =
$this->db->f('id');
- $standard['name'] =
$this->db->f('name');
- $standard['descr'] =
$this->db->f('descr');
- $standard['prefix'] =
$this->db->f('prefix');
-
- return $standard;
- }
- }
-
- function add($standard)
- {
-
- $standard['name'] =
$this->db->db_addslashes($standard['name']);
- $standard['descr'] =
$this->db->db_addslashes($standard['descr']);
-
- $standard['id'] =
$this->bocommon->next_id('fm_location_type');
-
- $this->db->transaction_begin();
-
-
- $receipt['id']= $standard['id'];
-
- $this->init_process();
-
- $default_attrib['id'][]= 1;
- $default_attrib['column_name'][]= 'location_code';
- $default_attrib['type'][]='V';
- $default_attrib['precision'][] =4*$standard['id'];
- $default_attrib['nullable'][] ='False';
- $default_attrib['input_text'][] ='dummy';
- $default_attrib['statustext'][] ='dummy';
- $default_attrib['attrib_sort'][] ='NULL';
- $default_attrib['custom'][] ='NULL';
-
- $default_attrib['id'][]= 2;
- $default_attrib['column_name'][]= 'loc' .
$standard['id'] . '_name';
- $default_attrib['type'][]='V';
- $default_attrib['precision'][] =50;
- $default_attrib['nullable'][] ='True';
- $default_attrib['input_text'][] ='dummy';
- $default_attrib['statustext'][] ='dummy';
- $default_attrib['attrib_sort'][] ='NULL';
- $default_attrib['custom'][] ='NULL';
-
- $default_attrib['id'][]= 3;
- $default_attrib['column_name'][]= 'entry_date';
- $default_attrib['type'][]='I';
- $default_attrib['precision'][] =4;
- $default_attrib['nullable'][] ='True';
- $default_attrib['input_text'][] ='dummy';
- $default_attrib['statustext'][] ='dummy';
- $default_attrib['attrib_sort'][] ='NULL';
- $default_attrib['custom'][] ='NULL';
-
- $default_attrib['id'][]= 4;
- $default_attrib['column_name'][]= 'category';
- $default_attrib['type'][]='I';
- $default_attrib['precision'][] =4;
- $default_attrib['nullable'][] ='False';
- $default_attrib['input_text'][] ='dummy';
- $default_attrib['statustext'][] ='dummy';
- $default_attrib['attrib_sort'][] ='NULL';
- $default_attrib['custom'][] ='NULL';
-
- $default_attrib['id'][]= 5;
- $default_attrib['column_name'][]= 'user_id';
- $default_attrib['type'][]='I';
- $default_attrib['precision'][] =4;
- $default_attrib['nullable'][] ='False';
- $default_attrib['input_text'][] ='dummy';
- $default_attrib['statustext'][] ='dummy';
- $default_attrib['attrib_sort'][] ='NULL';
- $default_attrib['custom'][] ='NULL';
-
- $default_attrib['id'][]= 6;
- $default_attrib['column_name'][]= 'status';
- $default_attrib['type'][]='LB';
- $default_attrib['precision'][] = False;
- $default_attrib['nullable'][] ='True';
- $default_attrib['input_text'][] ='Status';
- $default_attrib['statustext'][] ='Status';
- $default_attrib['attrib_sort'][] =1;
- $default_attrib['custom'][] =1;
-
- $default_attrib['id'][]= 7;
- $default_attrib['column_name'][]= 'remark';
- $default_attrib['type'][]='T';
- $default_attrib['precision'][] = False;
- $default_attrib['nullable'][] ='False';
- $default_attrib['input_text'][] ='Remark';
- $default_attrib['statustext'][] ='Remark';
- $default_attrib['attrib_sort'][] =2;
- $default_attrib['custom'][] =1;
-
- $fd=array();
- $fd['location_code'] = array('type' => 'varchar',
'precision' => 25, 'nullable' => False);
-
- for ($i=1; $i<$standard['id']+1; $i++)
- {
- $fd['loc' . $i] = array('type' => 'varchar',
'precision' => 4, 'nullable' => False);
- $pk[$i-1]= 'loc' . $i;
-
- $default_attrib['id'][]= $i+7;
- $default_attrib['column_name'][]= 'loc' . $i;
- $default_attrib['type'][]='V';
- $default_attrib['precision'][] =4;
- $default_attrib['nullable'][] ='False';
- $default_attrib['input_text'][] ='dummy';
- $default_attrib['statustext'][] ='dummy';
- $default_attrib['attrib_sort'][] ='NULL';
- $default_attrib['custom'][] ='NULL';
- }
-
- $fk_table='fm_location'. ($standard['id']-1);
-
- for ($i=1; $i<$standard['id']; $i++)
- {
- $fk['loc' . $i] = $fk_table . '.loc' . $i;
- }
-
- if($standard['id']==1)
- {
- $fd['part_of_town_id'] = array('type' => 'int',
'precision' => 2, 'nullable' => True);
- }
-
- $fd['loc' .$standard['id'] . '_name'] = array('type' =>
'varchar', 'precision' => 25, 'nullable' => True);
- $fd['entry_date'] = array('type' => 'int', 'precision'
=> 4, 'nullable' => True);
- $fd['category'] = array('type' => 'int', 'precision' =>
4, 'nullable' => True);
- $fd['user_id'] = array('type' => 'int', 'precision' =>
4, 'nullable' => True);
- $fd['remark'] = array('type' => 'text', 'nullable' =>
True);
- $fd['status'] = array('type' => 'int', 'precision' =>
4, 'nullable' => True);
-
- $ix = array('location_code');
- $uc = array();
-
- $fd_history = $fd;
- $fd_history['exp_date'] = array('type' =>
'timestamp','nullable' => True,'default' => 'current_timestamp');
-// $fd_history['change_type'] = array('type' =>
'int','precision' => '4','nullable' => True);
-
-
$add_columns_in_tables=array('fm_project','fm_tts_tickets','fm_request','fm_document','fm_investment');
-
- if($this->oProc->CreateTable('fm_location'.
$standard['id'],array('fd' => $fd,'pk' => $pk,'fk' => $fk,'ix' => $ix,'uc' =>
$uc))
- && $this->oProc->CreateTable('fm_location'.
$standard['id'] . '_history',array('fd' => $fd_history)))
- {
-
- $this->oProc->CreateTable('fm_location'.
$standard['id'] . '_category', array(
- 'fd' => array(
- 'id' => array('type' =>
'int','precision' => '4','nullable' => False),
- 'descr' => array('type' =>
'varchar','precision' => '50','nullable' => True)
- ),
- 'pk' => array('id'),
- 'fk' => array(),
- 'ix' => array(),
- 'uc' => array()));
-
- for ($i=0;$i<count($add_columns_in_tables);$i++)
- {
-
$this->oProc->AddColumn($add_columns_in_tables[$i],'loc'. $standard['id'],
array('type' => 'varchar', 'precision' => 4, 'nullable' => True));
- }
-
- $values_insert= array(
- $standard['id'],
- $standard['name'],
- $standard['descr'],
- $this->db->db_addslashes(implode(',',$pk)),
- $this->db->db_addslashes(implode(',',$ix)),
- $this->db->db_addslashes(implode(',',$uc)),
- );
-
- $values_insert =
$this->bocommon->validate_db_insert($values_insert);
-
- $this->db->query("INSERT INTO fm_location_type
(id,name, descr,pk,ix,uc) "
- . "VALUES
($values_insert)",__LINE__,__FILE__);
-
- for ($i=0;$i<count($default_attrib['id']);$i++)
- {
- $values_insert= array(
- $standard['id'],
- $default_attrib['id'][$i],
-
$default_attrib['column_name'][$i],
- $default_attrib['type'][$i],
-
$default_attrib['precision'][$i],
-
$default_attrib['input_text'][$i],
-
$default_attrib['statustext'][$i],
-
$default_attrib['attrib_sort'][$i],
- $default_attrib['custom'][$i],
- $default_attrib['nullable'][$i]
- );
-
-
- $values_insert =
$this->bocommon->validate_db_insert($values_insert);
-
- $this->db->query("INSERT INTO
fm_location_attrib
(type_id,id,column_name,datatype,precision_,input_text,statustext,attrib_sort,custom,nullable)
"
- . "VALUES
($values_insert)",__LINE__,__FILE__);
- }
-
- $type_id=$standard['id'];
-
- $this->db->query("INSERT INTO
fm_location_choice (type_id,attrib_id,id,value) "
- . "VALUES
($type_id,1,1,'ok')",__LINE__,__FILE__);
- $this->db->query("INSERT INTO
fm_location_choice (type_id,attrib_id,id,value) "
- . "VALUES ($type_id,1,2,'Not
Active')",__LINE__,__FILE__);
-
-
- $receipt['message'][] = array('msg' =>
lang('table %1 has been saved','fm_location'. $receipt['id']) );
- $this->db->transaction_commit();
- }
- else
- {
- $receipt['error'][] = array('msg' =>
lang('table could not be added') );
- if($this->db->Transaction)
- {
- $this->db->transaction_abort();
- }
- else
- {
- $this->db->query("DELETE FROM
fm_location_type WHERE id='" . $standard['id'] . "'",__LINE__,__FILE__);
- unset($receipt['id']);
-
- }
- }
-
- return $receipt;
- }
-
- function edit($standard)
- {
-
- if (!$standard['name'])
- {
- $receipt['error'][] = array('msg'=>lang('Name
not entered!'));
- }
-
- if (!$receipt['error'])
- {
- $table = 'fm_location_type';
-
- $standard['name'] =
$this->db->db_addslashes($standard['name']);
- $standard['descr'] =
$this->db->db_addslashes($standard['descr']);
-
- $this->db->query("UPDATE $table set descr='" .
$standard['descr'] . "', name='". $standard['name']
- . "' WHERE id='" . $standard['id'].
"'",__LINE__,__FILE__);
-
-
- $receipt['message'][] = array('msg'=>
lang('Standard has been edited'));
- }
- else
- {
- $receipt['error'][] = array('msg' =>
lang('Standard has NOT been edited'));
- }
-
- return $receipt;
- }
-
- function delete($type_id,$id,$attrib)
- {
- $this->init_process();
-
- if($attrib)
- {
- $table = 'fm_location_attrib';
-
- $this->db->query("SELECT column_name,type_id
FROM fm_location_attrib WHERE id='" . $id . "'",__LINE__,__FILE__);
- $this->db->next_record();
- $ColumnName =
$this->db->f('column_name');
-
- $this->oProc->DropColumn('fm_location'
.$type_id ,'', $ColumnName);
- $this->oProc->DropColumn('fm_location'
.$type_id . '_history','', $ColumnName);
- }
- else
- {
- $this->oProc->DropTable('fm_location' . $id);
- $this->oProc->DropTable('fm_location' . $id .
'_category');
- $this->oProc->DropTable('fm_location' . $id .
'_history');
-
- $table = 'fm_location_type';
- $attrib_table = 'fm_location_attrib';
- $this->db->query("DELETE FROM $attrib_table
WHERE type_id='" . $id . "'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM
fm_location_choice WHERE type_id='" . $id . "'",__LINE__,__FILE__);
- }
- $this->db->query("DELETE FROM $table WHERE id='" . $id
. "'",__LINE__,__FILE__);
- }
-
- function read_attrib($data)
- {
-
-//_debug_array($data);
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $type_id =
(isset($data['type_id'])?$data['type_id']:0);
- $lookup_type =
(isset($data['lookup_type'])?$data['lookup_type']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by
fm_location_attrib.attrib_sort asc';
- }
-
- $table = 'fm_location_attrib';
- $type_table = 'fm_location_type';
-
- if ($lookup_type)
- {
- $filtermethod = " OR (type_id < $lookup_type
AND lookup_form=1) ";
-
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " and ($table.name $this->like
'%$query%' or $table.descr $this->like '%$query%')";
- }
-
- $sql = "SELECT
$table.id,$table.type_id,$table.list,$table.attrib_sort,$table.location_form,lookup_form,$table.column_name,$table.size
,statustext,$table.input_text,"
- . " $table.datatype ,$type_table.name as type
FROM $type_table $this->join $table on $table.type_id = $type_table.id "
- . " WHERE $table.type_id= '$type_id' AND custom
= 1 $filtermethod $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $attrib[] = array
- (
- 'id' =>
$this->db->f('id'),
- 'location_type' =>
$this->db->f('type_id'),
- 'attrib_sort' =>
$this->db->f('attrib_sort'),
- 'list' =>
$this->db->f('list'),
- 'lookup_form' =>
$this->db->f('lookup_form'),
- 'location_form' =>
$this->db->f('location_form'),
- 'column_name' =>
$this->db->f('column_name'),
- 'size' =>
$this->db->f('size'),
- 'statustext' =>
$this->db->f('statustext'),
- 'input_text' =>
$this->db->f('input_text'),
- 'type_name' =>
$this->db->f('type'),
- 'datatype' =>
$this->db->f('datatype')
- );
- }
- return $attrib;
- }
-
- function read_single_attrib($type_id,$id)
- {
-
- $table = 'fm_location_attrib';
- $type_table = 'fm_location_type';
-
- $sql = "SELECT $table.* ,$type_table.name as type_name
FROM $type_table $this->join $table on $table.type_id = $type_id where
$table.id= '$id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $attrib['id']
= $this->db->f('id');
- $attrib['column_name']
= $this->db->f('column_name');
- $attrib['input_text']
= $this->db->f('input_text');
- $attrib['statustext']
= $this->db->f('statustext');
- $attrib['column_info']['precision'] =
$this->db->f('precision_');
- $attrib['column_info']['scale'] =
$this->db->f('scale');
- $attrib['column_info']['default'] =
$this->db->f('default_value');
- $attrib['column_info']['nullable'] =
$this->db->f('nullable');
- $attrib['column_info']['type'] =
$this->db->f('datatype');
- $attrib['type_id']
= $type_id;
- $attrib['type_name']
= $this->db->f('type_name');
- $attrib['lookup_form']
= $this->db->f('lookup_form');
- $attrib['list']
= $this->db->f('list');
- if($this->db->f('datatype')=='R' ||
$this->db->f('datatype')=='CH' || $this->db->f('datatype')=='LB')
- {
- $attrib['choice'] =
$this->read_attrib_choice($type_id,$id);
- }
-
- return $attrib;
- }
- }
-
- function read_attrib_choice($type_id,$attrib_id)
- {
- $choice_table = 'fm_location_choice';
- $sql = "SELECT * FROM $choice_table WHERE
type_id=$type_id AND attrib_id=$attrib_id";
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $choice[] = array
- (
- 'id' => $this->db->f('id'),
- 'value' => $this->db->f('value')
- );
- }
- return $choice;
- }
-
- function add_attrib($attrib)
- {
- $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
- $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
- $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
- $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
- $attrib['id'] =
$this->bocommon->next_id('fm_location_attrib',array('type_id'=>$attrib['type_id']));
-
- $sql = "SELECT max(attrib_sort) as max_sort FROM
fm_location_attrib where type_id=" . $attrib['type_id'];
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $attrib_sort = $this->db->f('max_sort')+1;
-
- if($precision =
$this->bocommon->translate_datatype_precision($attrib['column_info']['type']))
- {
- $attrib['column_info']['precision']=$precision;
- }
-
- $values= array(
- $attrib['id'],
- $attrib['column_name'],
- $attrib['input_text'],
- $attrib['statustext'],
- $attrib['type_id'],
- $attrib['lookup_form'],
- $attrib['list'],
- $attrib_sort,
- $attrib['column_info']['type'],
- $attrib['column_info']['precision'],
- $attrib['column_info']['scale'],
- $attrib['column_info']['default'],
- $attrib['column_info']['nullable'],
- 1
- );
-
- $values = $this->bocommon->validate_db_insert($values);
-
- $this->db->transaction_begin();
-
- $this->db->query("INSERT INTO fm_location_attrib
(id,column_name, input_text, statustext,
type_id,lookup_form,list,attrib_sort,datatype,precision_,scale,default_value,nullable,custom)
"
- . "VALUES ($values)",__LINE__,__FILE__);
-
- $receipt['id']= $attrib['id'];
-
- $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
-
- if(!$attrib['column_info']['default'])
- {
- unset($attrib['column_info']['default']);
- }
-
- $this->init_process();
-
-
if($this->oProc->AddColumn('fm_location'.$attrib['type_id'],$attrib['column_name'],
$attrib['column_info'])
- &&
$this->oProc->AddColumn('fm_location'.$attrib['type_id']
.'_history',$attrib['column_name'], $attrib['column_info']))
- {
- $receipt['message'][] = array('msg' =>
lang('Attribute has been saved') );
- $this->db->transaction_commit();
-
- }
- else
- {
- $receipt['error'][] = array('msg' =>
lang('column could not be added') );
- if($this->db->Transaction)
- {
- $this->db->transaction_abort();
- }
- else
- {
- $this->db->query("DELETE FROM
fm_location_attrib WHERE id=" . $receipt['id'] . " AND type_id=" .
$attrib['type_id'],__LINE__,__FILE__);
- unset($receipt['id']);
-
- }
- }
-
- return $receipt;
- }
-
- function init_process()
- {
- $this->oProc
=
CreateObject('phpgwapi.schema_proc',$GLOBALS['phpgw_info']['server']['db_type']);
- $this->oProc->m_odb
= $this->db;
- $this->oProc->m_odb->Halt_On_Error = 'report';
- }
-
-
- function save_config($values='',$column_name='')
- {
-
- $this->db->query("SELECT * FROM fm_location_config
WHERE column_name='$column_name' ",__LINE__,__FILE__);
- $this->db->next_record();
-
- $column_info['type'] =
$this->db->f('datatype');
- $column_info['precision'] =
$this->db->f('precision_');
- $column_info['scale'] = $this->db->f('scale');
- $column_info['default'] =
$this->db->f('default_value');
- $column_info['nullable'] =
$this->db->f('nullable');
- $location_type =
$this->db->f('location_type');
-
- if(!($location_type==$values[$column_name]))
- {
- $this->init_process();
-
-
if($this->oProc->AddColumn('fm_location'.$values[$column_name],$column_name,
$column_info))
- {
- if($column_name=='street_id')
- {
-
$this->oProc->AddColumn('fm_location'.$values[$column_name],'street_number',
array('type'=>'varchar','precision'=>10));
-
$this->oProc->DropColumn('fm_location' .$location_type ,'','street_number');
- }
-
- $this->oProc->DropColumn('fm_location'
.$location_type ,'', $column_name);
- $this->oProc->DropColumn('fm_location'
.$location_type . ' _history','', $column_name);
-
-
- $this->db->query("UPDATE
fm_location_config set
- location_type = '".
$values[$column_name] . "' WHERE column_name='" . $column_name .
"'",__LINE__,__FILE__);
-
- $receipt['message'][] = array('msg'
=> lang('column %1 has been moved',$column_name));
- }
- else
- {
- $receipt['message'][] = array('msg'
=> lang('column %1 could not be moved',$column_name));
-
- }
- }
-
- return $receipt;
- }
-
-
- function edit_attrib($attrib)
- {
- $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
- $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
- $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
- $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
-
- $this->db->query("SELECT * FROM fm_location_attrib
WHERE type_id = " . $attrib['type_id'] ." AND id=" .
$attrib['id'],__LINE__,__FILE__);
- $this->db->next_record();
- $OldColumnName = $this->db->f('column_name');
- $OldColumnType = $this->db->f('datatype');
- $OldColumnPrecision = $this->db->f('precision_');
-
- $table_def = $this->get_table_def($attrib['type_id']);
- $history_table_def['fm_location'.$attrib['type_id'] .
'_history'] = $table_def['fm_location'.$attrib['type_id']];
-
$history_table_def['fm_location'.$attrib['type_id']]['fd']['exp_date']=array('type'
=> 'timestamp','nullable' => False,'default' => 'current_timestamp');
-//
$history_table_def['fm_location'.$attrib['type_id']]['fd']['change_type'] =
array('type' => 'int','precision' => '4','nullable' => True);
-
-
unset($history_table_def['fm_location'.$attrib['type_id']]['pk']);
-
unset($history_table_def['fm_location'.$attrib['type_id']]['fk']);
-
unset($history_table_def['fm_location'.$attrib['type_id']]['ix']);
-
unset($history_table_def['fm_location'.$attrib['type_id']]['uc']);
-
- if($this->receipt['error'])
- {
- return $this->receipt;
- }
-
- $this->db->transaction_begin();
-
- $value_set=array(
- 'input_text' => $attrib['input_text'],
- 'statustext' => $attrib['statustext'],
- 'list' => $attrib['list'],
- 'lookup_form' => $attrib['lookup_form'],
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE fm_location_attrib set
$value_set WHERE type_id = " . $attrib['type_id'] ." AND id=" .
$attrib['id'],__LINE__,__FILE__);
-
- $this->init_process();
-
- if($OldColumnName !=$attrib['column_name'])
- {
- $value_set=array(
- 'column_name' =>
$attrib['column_name']
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE fm_location_attrib set
$value_set WHERE type_id = " . $attrib['type_id'] ." AND id=" .
$attrib['id'],__LINE__,__FILE__);
-
- $this->oProc->m_aTables = $table_def;
-
$this->oProc->RenameColumn('fm_location'.$attrib['type_id'], $OldColumnName,
$attrib['column_name']);
- $this->oProc->m_aTables = $history_table_def;
-
$this->oProc->RenameColumn('fm_location'.$attrib['type_id'] . '_history',
$OldColumnName, $attrib['column_name']);
- }
-
- if($OldColumnType !=$attrib['column_info']['type'])
- {
- if($precision =
$this->bocommon->translate_datatype_precision($attrib['column_info']['type']))
- {
-
$attrib['column_info']['precision']=$precision;
- }
-
- if(!$attrib['column_info']['default'])
- {
-
unset($attrib['column_info']['default']);
- }
-
-
- $value_set=array(
- 'type_id' =>
$attrib['type_id'],
- 'datatype' =>
$attrib['column_info']['type'],
- 'precision_' =>
$attrib['column_info']['precision'],
- 'scale' =>
$attrib['column_info']['scale'],
- 'default_value' =>
$attrib['column_info']['default'],
- 'nullable' =>
$attrib['column_info']['nullable']
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE fm_location_attrib set
$value_set WHERE type_id = " . $attrib['type_id'] ." AND id=" .
$attrib['id'],__LINE__,__FILE__);
-
- $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
-
- $this->oProc->m_aTables = $table_def;
-
$this->oProc->AlterColumn('fm_location'.$attrib['type_id'],$attrib['column_name'],$attrib['column_info']);
- $this->oProc->m_aTables = $history_table_def;
-
$this->oProc->AlterColumn('fm_location'.$attrib['type_id'] .
'_history',$attrib['column_name'],$attrib['column_info']);
- }
-
- $choice_table ='fm_location_choice';
-
- if($attrib['new_choice'])
- {
- $choice_id =
$this->bocommon->next_id($choice_table
,array('type_id'=>$attrib['type_id'],'attrib_id'=>$attrib['id']));
-
- $values= array(
- $attrib['type_id'],
- $attrib['id'],
- $choice_id,
- $attrib['new_choice']
- );
-
- $values =
$this->bocommon->validate_db_insert($values);
-
- $this->db->query("INSERT INTO $choice_table
(type_id,attrib_id,id,value) "
- . "VALUES ($values)",__LINE__,__FILE__);
- }
-
- if($attrib['delete_choice'])
- {
- for
($i=0;$i<count($attrib['delete_choice']);$i++)
- {
- $this->db->query("DELETE FROM
$choice_table WHERE type_id=" . $attrib['type_id']. " AND attrib_id=" .
$attrib['id'] ." AND id=" . $attrib['delete_choice'][$i],__LINE__,__FILE__);
- }
- }
-
- if($attrib['column_info']['type']!='R' &&
$attrib['column_info']['type']!='CH' && $attrib['column_info']['type']!='LB')
- {
- $this->db->query("DELETE FROM $choice_table
WHERE type_id=" . $attrib['type_id']. " AND attrib_id=" .
$attrib['id'],__LINE__,__FILE__);
- }
-
- $this->db->transaction_commit();
-
- $receipt['message'][] = array('msg' =>
lang('Attribute has been edited'));
-
- return $receipt;
-
- }
-
- function get_table_def($id='')
- {
-
- $metadata = $this->db->metadata('fm_location'.$id);
-// _debug_array($metadata);
-
- for ($i=0; $i<count($metadata); $i++)
- {
- $sql = "SELECT * FROM fm_location_attrib WHERE
type_id=$id AND column_name = '" . $metadata[$i]['name'] . "'";
-// _debug_array($sql);
-
- $this->db->query($sql,__LINE__,__FILE__);
- if($this->db->next_record())
- {
-
- if(!$precision =
$this->db->f('precision_'))
- {
- $precision =
$this->bocommon->translate_datatype_precision($this->db->f('datatype'));
- }
-
- $fd[$metadata[$i]['name']] = array(
- 'type' =>
$this->bocommon->translate_datatype_insert(stripslashes($this->db->f('datatype'))),
- 'precision' =>
$precision,
- 'nullable' =>
stripslashes($this->db->f('nullable')),
- 'default' =>
stripslashes($this->db->f('default_value')),
- 'scale' =>
$this->db->f('scale')
- );
- unset($precision);
- }
- else
- {
- $this->receipt['error'][] = array('msg'
=> lang('Column %1 is missing from metadata',$metadata[$i]['name']));
- }
- }
-
- $this->db->query("SELECT * FROM fm_location_type WHERE
id=$id");
- $this->db->next_record();
-
-
- if($id>1)
- {
- $fk_table='fm_location'. ($id-1);
- for ($i=1; $i<$id; $i++)
- {
- $fk['loc' . $i] = $fk_table . '.loc' .
$i;
- }
- }
-
- $table_def = array(
- 'fm_location'.$id => array(
- 'fd' => $fd
- )
- );
-
- if($this->db->f('pk'))
- {
- $table_def['fm_location'.$id]['pk'] =
explode(',',$this->db->f('pk'));
- }
- if($fk)
- {
- $table_def['fm_location'.$id]['fk'] = $fk;
- }
- if($this->db->f('ix'))
- {
- $table_def['fm_location'.$id]['ix'] =
explode(',',$this->db->f('ix'));
- }
- if($this->db->f('uc'))
- {
- $table_def['fm_location'.$id]['uc'] =
explode(',',$this->db->f('uc'));
- }
-
-
-
- return $table_def;
- }
-
-
- function select_location_type()
- {
- $this->db->query("SELECT * FROM fm_location_type ORDER
BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $location_type[$i]['id'] =
$this->db->f('id');
- $location_type[$i]['name'] =
stripslashes($this->db->f('name'));
- $location_type[$i]['descr'] =
stripslashes($this->db->f('descr'));
- $i++;
- }
-//_debug_array($location_type);
-
- return $location_type;
- }
-
- function resort_attrib($data)
- {
- if(is_array($data))
- {
- $resort =
(isset($data['resort'])?$data['resort']:'up');
- $type_id =
(isset($data['type_id'])?$data['type_id']:'');
- $id = (isset($data['id'])?$data['id']:'');
- }
-
- if(!$type_id)
- {
- return;
- }
-
- $sql = "SELECT attrib_sort FROM fm_location_attrib
where type_id=$type_id AND id=$id";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $attrib_sort = $this->db->f('attrib_sort');
- $sql2 = "SELECT max(attrib_sort) as max_sort FROM
fm_location_attrib where type_id=$type_id";
- $this->db->query($sql2,__LINE__,__FILE__);
- $this->db->next_record();
- $max_sort = $this->db->f('max_sort');
-
- switch($resort)
- {
- case 'up':
- if($attrib_sort>1)
- {
- $sql = "UPDATE
fm_location_attrib set attrib_sort=$attrib_sort WHERE type_id=$type_id AND
attrib_sort =" . ($attrib_sort-1);
-
$this->db->query($sql,__LINE__,__FILE__);
- $sql = "UPDATE
fm_location_attrib set attrib_sort=" . ($attrib_sort-1) ." WHERE
type_id=$type_id AND id=$id";
-
$this->db->query($sql,__LINE__,__FILE__);
- }
- break;
- case 'down':
- if($max_sort > $attrib_sort)
- {
- $sql = "UPDATE
fm_location_attrib set attrib_sort=$attrib_sort WHERE type_id=$type_id AND
attrib_sort =" . ($attrib_sort+1);
-
$this->db->query($sql,__LINE__,__FILE__);
- $sql = "UPDATE
fm_location_attrib set attrib_sort=" . ($attrib_sort+1) ." WHERE
type_id=$type_id AND id=$id";
-
$this->db->query($sql,__LINE__,__FILE__);
- }
- break;
- default:
- return;
- break;
- }
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.soadmin_location.inc.php,v 1.14 2006/01/27
14:05:43 sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class soadmin_location
+ {
+ var $grants;
+
+ function soadmin_location()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->like = $this->bocommon->like;
+ }
+
+
+ function reset_fm_cache()
+ {
+ $this->db->query("DELETE FROM fm_cache
",__LINE__,__FILE__);
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by id asc';
+ }
+
+ $table = 'fm_location_type';
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " where name $this->like
'%$query%' or descr $this->like '%$query%'";
+ }
+
+ $sql = "SELECT * FROM $table $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $standard[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'name' => $this->db->f('name'),
+ 'prefix'=> $this->db->f('prefix'),
+ 'descr' => $this->db->f('descr')
+ );
+ }
+ return $standard;
+ }
+
+ function read_config($data=0)
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+
+ if(is_array($data))
+ {
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by column_name asc';
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " where name $this->like
'%$query%' or column_name $this->like '%$query%'";
+ }
+
+ $sql = "SELECT fm_location_config.*
,fm_location_type.name as name FROM fm_location_config $this->join
fm_location_type on fm_location_config.location_type=fm_location_type.id
$querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $config[] = array
+ (
+ 'column_name' =>
$this->db->f('column_name'),
+ 'input_text' =>
$this->db->f('input_text'),
+ 'f_key' =>
$this->db->f('f_key'),
+ 'lookup_form' =>
$this->db->f('lookup_form'),
+ 'ref_to_category' =>
$this->db->f('ref_to_category'),
+ 'query_value' =>
$this->db->f('query_value'),
+ 'reference_table' =>
$this->db->f('reference_table'),
+ 'reference_id' =>
$this->db->f('reference_id'),
+ 'location_name' =>
$this->db->f('name'),
+ 'location_type' =>
$this->db->f('location_type')
+ );
+ }
+ return $config;
+ }
+
+ function read_config_single($column_name='')
+ {
+ $this->db->query("SELECT location_type FROM
fm_location_config where column_name='$column_name'",__LINE__,__FILE__);
+ $this->db->next_record();
+ return $this->db->f('location_type');
+ }
+
+
+ function read_single($id)
+ {
+
+ $table = 'fm_location_type';
+
+ $sql = "SELECT * FROM $table where id='$id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $standard['id'] =
$this->db->f('id');
+ $standard['name'] =
$this->db->f('name');
+ $standard['descr'] =
$this->db->f('descr');
+ $standard['prefix'] =
$this->db->f('prefix');
+
+ return $standard;
+ }
+ }
+
+ function add($standard)
+ {
+
+ $standard['name'] =
$this->db->db_addslashes($standard['name']);
+ $standard['descr'] =
$this->db->db_addslashes($standard['descr']);
+
+ $standard['id'] =
$this->bocommon->next_id('fm_location_type');
+
+ $this->db->transaction_begin();
+
+
+ $receipt['id']= $standard['id'];
+
+ $this->init_process();
+
+ $default_attrib['id'][]= 1;
+ $default_attrib['column_name'][]= 'location_code';
+ $default_attrib['type'][]='V';
+ $default_attrib['precision'][] =4*$standard['id'];
+ $default_attrib['nullable'][] ='False';
+ $default_attrib['input_text'][] ='dummy';
+ $default_attrib['statustext'][] ='dummy';
+ $default_attrib['attrib_sort'][] ='NULL';
+ $default_attrib['custom'][] ='NULL';
+
+ $default_attrib['id'][]= 2;
+ $default_attrib['column_name'][]= 'loc' .
$standard['id'] . '_name';
+ $default_attrib['type'][]='V';
+ $default_attrib['precision'][] =50;
+ $default_attrib['nullable'][] ='True';
+ $default_attrib['input_text'][] ='dummy';
+ $default_attrib['statustext'][] ='dummy';
+ $default_attrib['attrib_sort'][] ='NULL';
+ $default_attrib['custom'][] ='NULL';
+
+ $default_attrib['id'][]= 3;
+ $default_attrib['column_name'][]= 'entry_date';
+ $default_attrib['type'][]='I';
+ $default_attrib['precision'][] =4;
+ $default_attrib['nullable'][] ='True';
+ $default_attrib['input_text'][] ='dummy';
+ $default_attrib['statustext'][] ='dummy';
+ $default_attrib['attrib_sort'][] ='NULL';
+ $default_attrib['custom'][] ='NULL';
+
+ $default_attrib['id'][]= 4;
+ $default_attrib['column_name'][]= 'category';
+ $default_attrib['type'][]='I';
+ $default_attrib['precision'][] =4;
+ $default_attrib['nullable'][] ='False';
+ $default_attrib['input_text'][] ='dummy';
+ $default_attrib['statustext'][] ='dummy';
+ $default_attrib['attrib_sort'][] ='NULL';
+ $default_attrib['custom'][] ='NULL';
+
+ $default_attrib['id'][]= 5;
+ $default_attrib['column_name'][]= 'user_id';
+ $default_attrib['type'][]='I';
+ $default_attrib['precision'][] =4;
+ $default_attrib['nullable'][] ='False';
+ $default_attrib['input_text'][] ='dummy';
+ $default_attrib['statustext'][] ='dummy';
+ $default_attrib['attrib_sort'][] ='NULL';
+ $default_attrib['custom'][] ='NULL';
+
+ $default_attrib['id'][]= 6;
+ $default_attrib['column_name'][]= 'status';
+ $default_attrib['type'][]='LB';
+ $default_attrib['precision'][] = False;
+ $default_attrib['nullable'][] ='True';
+ $default_attrib['input_text'][] ='Status';
+ $default_attrib['statustext'][] ='Status';
+ $default_attrib['attrib_sort'][] =1;
+ $default_attrib['custom'][] =1;
+
+ $default_attrib['id'][]= 7;
+ $default_attrib['column_name'][]= 'remark';
+ $default_attrib['type'][]='T';
+ $default_attrib['precision'][] = False;
+ $default_attrib['nullable'][] ='False';
+ $default_attrib['input_text'][] ='Remark';
+ $default_attrib['statustext'][] ='Remark';
+ $default_attrib['attrib_sort'][] =2;
+ $default_attrib['custom'][] =1;
+
+ $fd=array();
+ $fd['location_code'] = array('type' => 'varchar',
'precision' => 25, 'nullable' => False);
+
+ for ($i=1; $i<$standard['id']+1; $i++)
+ {
+ $fd['loc' . $i] = array('type' => 'varchar',
'precision' => 4, 'nullable' => False);
+ $pk[$i-1]= 'loc' . $i;
+
+ $default_attrib['id'][]= $i+7;
+ $default_attrib['column_name'][]= 'loc' . $i;
+ $default_attrib['type'][]='V';
+ $default_attrib['precision'][] =4;
+ $default_attrib['nullable'][] ='False';
+ $default_attrib['input_text'][] ='dummy';
+ $default_attrib['statustext'][] ='dummy';
+ $default_attrib['attrib_sort'][] ='NULL';
+ $default_attrib['custom'][] ='NULL';
+ }
+
+ $fk_table='fm_location'. ($standard['id']-1);
+
+ for ($i=1; $i<$standard['id']; $i++)
+ {
+ $fk['loc' . $i] = $fk_table . '.loc' . $i;
+ }
+
+ if($standard['id']==1)
+ {
+ $fd['part_of_town_id'] = array('type' => 'int',
'precision' => 2, 'nullable' => True);
+ }
+
+ $fd['loc' .$standard['id'] . '_name'] = array('type' =>
'varchar', 'precision' => 25, 'nullable' => True);
+ $fd['entry_date'] = array('type' => 'int', 'precision'
=> 4, 'nullable' => True);
+ $fd['category'] = array('type' => 'int', 'precision' =>
4, 'nullable' => True);
+ $fd['user_id'] = array('type' => 'int', 'precision' =>
4, 'nullable' => True);
+ $fd['remark'] = array('type' => 'text', 'nullable' =>
True);
+ $fd['status'] = array('type' => 'int', 'precision' =>
4, 'nullable' => True);
+
+ $ix = array('location_code');
+ $uc = array();
+
+ $fd_history = $fd;
+ $fd_history['exp_date'] = array('type' =>
'timestamp','nullable' => True,'default' => 'current_timestamp');
+// $fd_history['change_type'] = array('type' =>
'int','precision' => '4','nullable' => True);
+
+
$add_columns_in_tables=array('fm_project','fm_tts_tickets','fm_request','fm_document','fm_investment');
+
+ if($this->oProc->CreateTable('fm_location'.
$standard['id'],array('fd' => $fd,'pk' => $pk,'fk' => $fk,'ix' => $ix,'uc' =>
$uc))
+ && $this->oProc->CreateTable('fm_location'.
$standard['id'] . '_history',array('fd' => $fd_history)))
+ {
+
+ $this->oProc->CreateTable('fm_location'.
$standard['id'] . '_category', array(
+ 'fd' => array(
+ 'id' => array('type' =>
'int','precision' => '4','nullable' => False),
+ 'descr' => array('type' =>
'varchar','precision' => '50','nullable' => True)
+ ),
+ 'pk' => array('id'),
+ 'fk' => array(),
+ 'ix' => array(),
+ 'uc' => array()));
+
+ for ($i=0;$i<count($add_columns_in_tables);$i++)
+ {
+
$this->oProc->AddColumn($add_columns_in_tables[$i],'loc'. $standard['id'],
array('type' => 'varchar', 'precision' => 4, 'nullable' => True));
+ }
+
+ $values_insert= array(
+ $standard['id'],
+ $standard['name'],
+ $standard['descr'],
+ $this->db->db_addslashes(implode(',',$pk)),
+ $this->db->db_addslashes(implode(',',$ix)),
+ $this->db->db_addslashes(implode(',',$uc)),
+ );
+
+ $values_insert =
$this->bocommon->validate_db_insert($values_insert);
+
+ $this->db->query("INSERT INTO fm_location_type
(id,name, descr,pk,ix,uc) "
+ . "VALUES
($values_insert)",__LINE__,__FILE__);
+
+ for ($i=0;$i<count($default_attrib['id']);$i++)
+ {
+ $values_insert= array(
+ $standard['id'],
+ $default_attrib['id'][$i],
+
$default_attrib['column_name'][$i],
+ $default_attrib['type'][$i],
+
$default_attrib['precision'][$i],
+
$default_attrib['input_text'][$i],
+
$default_attrib['statustext'][$i],
+
$default_attrib['attrib_sort'][$i],
+ $default_attrib['custom'][$i],
+ $default_attrib['nullable'][$i]
+ );
+
+
+ $values_insert =
$this->bocommon->validate_db_insert($values_insert);
+
+ $this->db->query("INSERT INTO
fm_location_attrib
(type_id,id,column_name,datatype,precision_,input_text,statustext,attrib_sort,custom,nullable)
"
+ . "VALUES
($values_insert)",__LINE__,__FILE__);
+ }
+
+ $type_id=$standard['id'];
+
+ $this->db->query("INSERT INTO
fm_location_choice (type_id,attrib_id,id,value) "
+ . "VALUES
($type_id,1,1,'ok')",__LINE__,__FILE__);
+ $this->db->query("INSERT INTO
fm_location_choice (type_id,attrib_id,id,value) "
+ . "VALUES ($type_id,1,2,'Not
Active')",__LINE__,__FILE__);
+
+
+ $receipt['message'][] = array('msg' =>
lang('table %1 has been saved','fm_location'. $receipt['id']) );
+ $this->db->transaction_commit();
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('table could not be added') );
+ if($this->db->Transaction)
+ {
+ $this->db->transaction_abort();
+ }
+ else
+ {
+ $this->db->query("DELETE FROM
fm_location_type WHERE id='" . $standard['id'] . "'",__LINE__,__FILE__);
+ unset($receipt['id']);
+
+ }
+ }
+
+ return $receipt;
+ }
+
+ function edit($standard)
+ {
+
+ if (!$standard['name'])
+ {
+ $receipt['error'][] = array('msg'=>lang('Name
not entered!'));
+ }
+
+ if (!$receipt['error'])
+ {
+ $table = 'fm_location_type';
+
+ $standard['name'] =
$this->db->db_addslashes($standard['name']);
+ $standard['descr'] =
$this->db->db_addslashes($standard['descr']);
+
+ $this->db->query("UPDATE $table set descr='" .
$standard['descr'] . "', name='". $standard['name']
+ . "' WHERE id='" . $standard['id'].
"'",__LINE__,__FILE__);
+
+
+ $receipt['message'][] = array('msg'=>
lang('Standard has been edited'));
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('Standard has NOT been edited'));
+ }
+
+ return $receipt;
+ }
+
+ function delete($type_id,$id,$attrib)
+ {
+ $this->init_process();
+
+ if($attrib)
+ {
+ $table = 'fm_location_attrib';
+
+ $this->db->query("SELECT column_name,type_id
FROM fm_location_attrib WHERE id='" . $id . "'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $ColumnName =
$this->db->f('column_name');
+
+ $this->oProc->DropColumn('fm_location'
.$type_id ,'', $ColumnName);
+ $this->oProc->DropColumn('fm_location'
.$type_id . '_history','', $ColumnName);
+ }
+ else
+ {
+ $this->oProc->DropTable('fm_location' . $id);
+ $this->oProc->DropTable('fm_location' . $id .
'_category');
+ $this->oProc->DropTable('fm_location' . $id .
'_history');
+
+ $table = 'fm_location_type';
+ $attrib_table = 'fm_location_attrib';
+ $this->db->query("DELETE FROM $attrib_table
WHERE type_id='" . $id . "'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM
fm_location_choice WHERE type_id='" . $id . "'",__LINE__,__FILE__);
+ }
+ $this->db->query("DELETE FROM $table WHERE id='" . $id
. "'",__LINE__,__FILE__);
+ }
+
+ function read_attrib($data)
+ {
+
+//_debug_array($data);
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $type_id =
(isset($data['type_id'])?$data['type_id']:0);
+ $lookup_type =
(isset($data['lookup_type'])?$data['lookup_type']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by
fm_location_attrib.attrib_sort asc';
+ }
+
+ $table = 'fm_location_attrib';
+ $type_table = 'fm_location_type';
+
+ if ($lookup_type)
+ {
+ $filtermethod = " OR (type_id < $lookup_type
AND lookup_form=1) ";
+
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " and ($table.name $this->like
'%$query%' or $table.descr $this->like '%$query%')";
+ }
+
+ $sql = "SELECT
$table.id,$table.type_id,$table.list,$table.attrib_sort,$table.location_form,lookup_form,$table.column_name,$table.size
,statustext,$table.input_text,"
+ . " $table.datatype ,$type_table.name as type
FROM $type_table $this->join $table on $table.type_id = $type_table.id "
+ . " WHERE $table.type_id= '$type_id' AND custom
= 1 $filtermethod $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $attrib[] = array
+ (
+ 'id' =>
$this->db->f('id'),
+ 'location_type' =>
$this->db->f('type_id'),
+ 'attrib_sort' =>
$this->db->f('attrib_sort'),
+ 'list' =>
$this->db->f('list'),
+ 'lookup_form' =>
$this->db->f('lookup_form'),
+ 'location_form' =>
$this->db->f('location_form'),
+ 'column_name' =>
$this->db->f('column_name'),
+ 'size' =>
$this->db->f('size'),
+ 'statustext' =>
$this->db->f('statustext'),
+ 'input_text' =>
$this->db->f('input_text'),
+ 'type_name' =>
$this->db->f('type'),
+ 'datatype' =>
$this->db->f('datatype')
+ );
+ }
+ return $attrib;
+ }
+
+ function read_single_attrib($type_id,$id)
+ {
+
+ $table = 'fm_location_attrib';
+ $type_table = 'fm_location_type';
+
+ $sql = "SELECT $table.* ,$type_table.name as type_name
FROM $type_table $this->join $table on $table.type_id = $type_id where
$table.id= '$id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $attrib['id']
= $this->db->f('id');
+ $attrib['column_name']
= $this->db->f('column_name');
+ $attrib['input_text']
= $this->db->f('input_text');
+ $attrib['statustext']
= $this->db->f('statustext');
+ $attrib['column_info']['precision'] =
$this->db->f('precision_');
+ $attrib['column_info']['scale'] =
$this->db->f('scale');
+ $attrib['column_info']['default'] =
$this->db->f('default_value');
+ $attrib['column_info']['nullable'] =
$this->db->f('nullable');
+ $attrib['column_info']['type'] =
$this->db->f('datatype');
+ $attrib['type_id']
= $type_id;
+ $attrib['type_name']
= $this->db->f('type_name');
+ $attrib['lookup_form']
= $this->db->f('lookup_form');
+ $attrib['list']
= $this->db->f('list');
+ if($this->db->f('datatype')=='R' ||
$this->db->f('datatype')=='CH' || $this->db->f('datatype')=='LB')
+ {
+ $attrib['choice'] =
$this->read_attrib_choice($type_id,$id);
+ }
+
+ return $attrib;
+ }
+ }
+
+ function read_attrib_choice($type_id,$attrib_id)
+ {
+ $choice_table = 'fm_location_choice';
+ $sql = "SELECT * FROM $choice_table WHERE
type_id=$type_id AND attrib_id=$attrib_id";
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $choice[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'value' => $this->db->f('value')
+ );
+ }
+ return $choice;
+ }
+
+ function add_attrib($attrib)
+ {
+ $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
+ $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
+ $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
+ $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
+ $attrib['id'] =
$this->bocommon->next_id('fm_location_attrib',array('type_id'=>$attrib['type_id']));
+
+ $sql = "SELECT max(attrib_sort) as max_sort FROM
fm_location_attrib where type_id=" . $attrib['type_id'];
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $attrib_sort = $this->db->f('max_sort')+1;
+
+ if($precision =
$this->bocommon->translate_datatype_precision($attrib['column_info']['type']))
+ {
+ $attrib['column_info']['precision']=$precision;
+ }
+
+ $values= array(
+ $attrib['id'],
+ $attrib['column_name'],
+ $attrib['input_text'],
+ $attrib['statustext'],
+ $attrib['type_id'],
+ $attrib['lookup_form'],
+ $attrib['list'],
+ $attrib_sort,
+ $attrib['column_info']['type'],
+ $attrib['column_info']['precision'],
+ $attrib['column_info']['scale'],
+ $attrib['column_info']['default'],
+ $attrib['column_info']['nullable'],
+ 1
+ );
+
+ $values = $this->bocommon->validate_db_insert($values);
+
+ $this->db->transaction_begin();
+
+ $this->db->query("INSERT INTO fm_location_attrib
(id,column_name, input_text, statustext,
type_id,lookup_form,list,attrib_sort,datatype,precision_,scale,default_value,nullable,custom)
"
+ . "VALUES ($values)",__LINE__,__FILE__);
+
+ $receipt['id']= $attrib['id'];
+
+ $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
+
+ if(!$attrib['column_info']['default'])
+ {
+ unset($attrib['column_info']['default']);
+ }
+
+ $this->init_process();
+
+
if($this->oProc->AddColumn('fm_location'.$attrib['type_id'],$attrib['column_name'],
$attrib['column_info'])
+ &&
$this->oProc->AddColumn('fm_location'.$attrib['type_id']
.'_history',$attrib['column_name'], $attrib['column_info']))
+ {
+ $receipt['message'][] = array('msg' =>
lang('Attribute has been saved') );
+ $this->db->transaction_commit();
+
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('column could not be added') );
+ if($this->db->Transaction)
+ {
+ $this->db->transaction_abort();
+ }
+ else
+ {
+ $this->db->query("DELETE FROM
fm_location_attrib WHERE id=" . $receipt['id'] . " AND type_id=" .
$attrib['type_id'],__LINE__,__FILE__);
+ unset($receipt['id']);
+
+ }
+ }
+
+ return $receipt;
+ }
+
+ function init_process()
+ {
+ $this->oProc
=
CreateObject('phpgwapi.schema_proc',$GLOBALS['phpgw_info']['server']['db_type']);
+ $this->oProc->m_odb
= $this->db;
+ $this->oProc->m_odb->Halt_On_Error = 'report';
+ }
+
+
+ function save_config($values='',$column_name='')
+ {
+
+ $this->db->query("SELECT * FROM fm_location_config
WHERE column_name='$column_name' ",__LINE__,__FILE__);
+ $this->db->next_record();
+
+ $column_info['type'] =
$this->db->f('datatype');
+ $column_info['precision'] =
$this->db->f('precision_');
+ $column_info['scale'] = $this->db->f('scale');
+ $column_info['default'] =
$this->db->f('default_value');
+ $column_info['nullable'] =
$this->db->f('nullable');
+ $location_type =
$this->db->f('location_type');
+
+ if(!($location_type==$values[$column_name]))
+ {
+ $this->init_process();
+
+
if($this->oProc->AddColumn('fm_location'.$values[$column_name],$column_name,
$column_info))
+ {
+ if($column_name=='street_id')
+ {
+
$this->oProc->AddColumn('fm_location'.$values[$column_name],'street_number',
array('type'=>'varchar','precision'=>10));
+
$this->oProc->DropColumn('fm_location' .$location_type ,'','street_number');
+ }
+
+ $this->oProc->DropColumn('fm_location'
.$location_type ,'', $column_name);
+ $this->oProc->DropColumn('fm_location'
.$location_type . ' _history','', $column_name);
+
+
+ $this->db->query("UPDATE
fm_location_config set
+ location_type = '".
$values[$column_name] . "' WHERE column_name='" . $column_name .
"'",__LINE__,__FILE__);
+
+ $receipt['message'][] = array('msg'
=> lang('column %1 has been moved',$column_name));
+ }
+ else
+ {
+ $receipt['message'][] = array('msg'
=> lang('column %1 could not be moved',$column_name));
+
+ }
+ }
+
+ return $receipt;
+ }
+
+
+ function edit_attrib($attrib)
+ {
+ $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
+ $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
+ $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
+ $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
+
+ $this->db->query("SELECT * FROM fm_location_attrib
WHERE type_id = " . $attrib['type_id'] ." AND id=" .
$attrib['id'],__LINE__,__FILE__);
+ $this->db->next_record();
+ $OldColumnName = $this->db->f('column_name');
+ $OldColumnType = $this->db->f('datatype');
+ $OldColumnPrecision = $this->db->f('precision_');
+
+ $table_def = $this->get_table_def($attrib['type_id']);
+ $history_table_def['fm_location'.$attrib['type_id'] .
'_history'] = $table_def['fm_location'.$attrib['type_id']];
+
$history_table_def['fm_location'.$attrib['type_id']]['fd']['exp_date']=array('type'
=> 'timestamp','nullable' => False,'default' => 'current_timestamp');
+//
$history_table_def['fm_location'.$attrib['type_id']]['fd']['change_type'] =
array('type' => 'int','precision' => '4','nullable' => True);
+
+
unset($history_table_def['fm_location'.$attrib['type_id']]['pk']);
+
unset($history_table_def['fm_location'.$attrib['type_id']]['fk']);
+
unset($history_table_def['fm_location'.$attrib['type_id']]['ix']);
+
unset($history_table_def['fm_location'.$attrib['type_id']]['uc']);
+
+ if($this->receipt['error'])
+ {
+ return $this->receipt;
+ }
+
+ $this->db->transaction_begin();
+
+ $value_set=array(
+ 'input_text' => $attrib['input_text'],
+ 'statustext' => $attrib['statustext'],
+ 'list' => $attrib['list'],
+ 'lookup_form' => $attrib['lookup_form'],
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE fm_location_attrib set
$value_set WHERE type_id = " . $attrib['type_id'] ." AND id=" .
$attrib['id'],__LINE__,__FILE__);
+
+ $this->init_process();
+
+ if($OldColumnName !=$attrib['column_name'])
+ {
+ $value_set=array(
+ 'column_name' =>
$attrib['column_name']
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE fm_location_attrib set
$value_set WHERE type_id = " . $attrib['type_id'] ." AND id=" .
$attrib['id'],__LINE__,__FILE__);
+
+ $this->oProc->m_aTables = $table_def;
+
$this->oProc->RenameColumn('fm_location'.$attrib['type_id'], $OldColumnName,
$attrib['column_name']);
+ $this->oProc->m_aTables = $history_table_def;
+
$this->oProc->RenameColumn('fm_location'.$attrib['type_id'] . '_history',
$OldColumnName, $attrib['column_name']);
+ }
+
+ if($OldColumnType !=$attrib['column_info']['type'])
+ {
+ if($precision =
$this->bocommon->translate_datatype_precision($attrib['column_info']['type']))
+ {
+
$attrib['column_info']['precision']=$precision;
+ }
+
+ if(!$attrib['column_info']['default'])
+ {
+
unset($attrib['column_info']['default']);
+ }
+
+
+ $value_set=array(
+ 'type_id' =>
$attrib['type_id'],
+ 'datatype' =>
$attrib['column_info']['type'],
+ 'precision_' =>
$attrib['column_info']['precision'],
+ 'scale' =>
$attrib['column_info']['scale'],
+ 'default_value' =>
$attrib['column_info']['default'],
+ 'nullable' =>
$attrib['column_info']['nullable']
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE fm_location_attrib set
$value_set WHERE type_id = " . $attrib['type_id'] ." AND id=" .
$attrib['id'],__LINE__,__FILE__);
+
+ $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
+
+ $this->oProc->m_aTables = $table_def;
+
$this->oProc->AlterColumn('fm_location'.$attrib['type_id'],$attrib['column_name'],$attrib['column_info']);
+ $this->oProc->m_aTables = $history_table_def;
+
$this->oProc->AlterColumn('fm_location'.$attrib['type_id'] .
'_history',$attrib['column_name'],$attrib['column_info']);
+ }
+
+ $choice_table ='fm_location_choice';
+
+ if($attrib['new_choice'])
+ {
+ $choice_id =
$this->bocommon->next_id($choice_table
,array('type_id'=>$attrib['type_id'],'attrib_id'=>$attrib['id']));
+
+ $values= array(
+ $attrib['type_id'],
+ $attrib['id'],
+ $choice_id,
+ $attrib['new_choice']
+ );
+
+ $values =
$this->bocommon->validate_db_insert($values);
+
+ $this->db->query("INSERT INTO $choice_table
(type_id,attrib_id,id,value) "
+ . "VALUES ($values)",__LINE__,__FILE__);
+ }
+
+ if($attrib['delete_choice'])
+ {
+ for
($i=0;$i<count($attrib['delete_choice']);$i++)
+ {
+ $this->db->query("DELETE FROM
$choice_table WHERE type_id=" . $attrib['type_id']. " AND attrib_id=" .
$attrib['id'] ." AND id=" . $attrib['delete_choice'][$i],__LINE__,__FILE__);
+ }
+ }
+
+ if($attrib['column_info']['type']!='R' &&
$attrib['column_info']['type']!='CH' && $attrib['column_info']['type']!='LB')
+ {
+ $this->db->query("DELETE FROM $choice_table
WHERE type_id=" . $attrib['type_id']. " AND attrib_id=" .
$attrib['id'],__LINE__,__FILE__);
+ }
+
+ $this->db->transaction_commit();
+
+ $receipt['message'][] = array('msg' =>
lang('Attribute has been edited'));
+
+ return $receipt;
+
+ }
+
+ function get_table_def($id='')
+ {
+
+ $metadata = $this->db->metadata('fm_location'.$id);
+// _debug_array($metadata);
+
+ for ($i=0; $i<count($metadata); $i++)
+ {
+ $sql = "SELECT * FROM fm_location_attrib WHERE
type_id=$id AND column_name = '" . $metadata[$i]['name'] . "'";
+// _debug_array($sql);
+
+ $this->db->query($sql,__LINE__,__FILE__);
+ if($this->db->next_record())
+ {
+
+ if(!$precision =
$this->db->f('precision_'))
+ {
+ $precision =
$this->bocommon->translate_datatype_precision($this->db->f('datatype'));
+ }
+
+ $fd[$metadata[$i]['name']] = array(
+ 'type' =>
$this->bocommon->translate_datatype_insert(stripslashes($this->db->f('datatype'))),
+ 'precision' =>
$precision,
+ 'nullable' =>
stripslashes($this->db->f('nullable')),
+ 'default' =>
stripslashes($this->db->f('default_value')),
+ 'scale' =>
$this->db->f('scale')
+ );
+ unset($precision);
+ }
+ else
+ {
+ $this->receipt['error'][] = array('msg'
=> lang('Column %1 is missing from metadata',$metadata[$i]['name']));
+ }
+ }
+
+ $this->db->query("SELECT * FROM fm_location_type WHERE
id=$id");
+ $this->db->next_record();
+
+
+ if($id>1)
+ {
+ $fk_table='fm_location'. ($id-1);
+ for ($i=1; $i<$id; $i++)
+ {
+ $fk['loc' . $i] = $fk_table . '.loc' .
$i;
+ }
+ }
+
+ $table_def = array(
+ 'fm_location'.$id => array(
+ 'fd' => $fd
+ )
+ );
+
+ if($this->db->f('pk'))
+ {
+ $table_def['fm_location'.$id]['pk'] =
explode(',',$this->db->f('pk'));
+ }
+ if($fk)
+ {
+ $table_def['fm_location'.$id]['fk'] = $fk;
+ }
+ if($this->db->f('ix'))
+ {
+ $table_def['fm_location'.$id]['ix'] =
explode(',',$this->db->f('ix'));
+ }
+ if($this->db->f('uc'))
+ {
+ $table_def['fm_location'.$id]['uc'] =
explode(',',$this->db->f('uc'));
+ }
+
+
+
+ return $table_def;
+ }
+
+
+ function select_location_type()
+ {
+ $this->db->query("SELECT * FROM fm_location_type ORDER
BY id ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $location_type[$i]['id'] =
$this->db->f('id');
+ $location_type[$i]['name'] =
stripslashes($this->db->f('name'));
+ $location_type[$i]['descr'] =
stripslashes($this->db->f('descr'));
+ $i++;
+ }
+//_debug_array($location_type);
+
+ return $location_type;
+ }
+
+ function resort_attrib($data)
+ {
+ if(is_array($data))
+ {
+ $resort =
(isset($data['resort'])?$data['resort']:'up');
+ $type_id =
(isset($data['type_id'])?$data['type_id']:'');
+ $id = (isset($data['id'])?$data['id']:'');
+ }
+
+ if(!$type_id)
+ {
+ return;
+ }
+
+ $sql = "SELECT attrib_sort FROM fm_location_attrib
where type_id=$type_id AND id=$id";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $attrib_sort = $this->db->f('attrib_sort');
+ $sql2 = "SELECT max(attrib_sort) as max_sort FROM
fm_location_attrib where type_id=$type_id";
+ $this->db->query($sql2,__LINE__,__FILE__);
+ $this->db->next_record();
+ $max_sort = $this->db->f('max_sort');
+
+ switch($resort)
+ {
+ case 'up':
+ if($attrib_sort>1)
+ {
+ $sql = "UPDATE
fm_location_attrib set attrib_sort=$attrib_sort WHERE type_id=$type_id AND
attrib_sort =" . ($attrib_sort-1);
+
$this->db->query($sql,__LINE__,__FILE__);
+ $sql = "UPDATE
fm_location_attrib set attrib_sort=" . ($attrib_sort-1) ." WHERE
type_id=$type_id AND id=$id";
+
$this->db->query($sql,__LINE__,__FILE__);
+ }
+ break;
+ case 'down':
+ if($max_sort > $attrib_sort)
+ {
+ $sql = "UPDATE
fm_location_attrib set attrib_sort=$attrib_sort WHERE type_id=$type_id AND
attrib_sort =" . ($attrib_sort+1);
+
$this->db->query($sql,__LINE__,__FILE__);
+ $sql = "UPDATE
fm_location_attrib set attrib_sort=" . ($attrib_sort+1) ." WHERE
type_id=$type_id AND id=$id";
+
$this->db->query($sql,__LINE__,__FILE__);
+ }
+ break;
+ default:
+ return;
+ break;
+ }
+ }
+ }
+?>
Index: property/inc/class.soagreement.inc.php
diff -u property/inc/class.soagreement.inc.php:1.8
property/inc/class.soagreement.inc.php:1.9
--- property/inc/class.soagreement.inc.php:1.8 Tue Jun 28 13:23:07 2005
+++ property/inc/class.soagreement.inc.php Fri Jan 27 14:05:43 2006
@@ -1,1570 +1,1569 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage agreement
- * @version $Id: class.soagreement.inc.php,v 1.8 2005/06/28 13:23:07
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class soagreement
- {
- var $role;
-
- function soagreement()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->join = $this->bocommon->join;
- $this->left_join = $this->bocommon->left_join;
- $this->like = $this->bocommon->like;
-// $this->role = 'agreement';
- }
-
- function select_category_list()
- {
- $table = 'fm_branch';
- $this->db->query("SELECT id,descr FROM $table ORDER BY
descr ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $categories[$i]['id']
= $this->db->f('id');
- $categories[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $categories;
- }
-
- function select_vendor_list()
- {
- $table = 'fm_agreement';
- $this->db->query("SELECT vendor_id,org_name FROM $table
$this->join fm_vendor on fm_agreement.vendor_id=fm_vendor.id GROUP BY
org_name,vendor_id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $vendor[$i]['id']
= $this->db->f('vendor_id');
- $vendor[$i]['name']
= stripslashes($this->db->f('org_name'));
- $i++;
- }
- return $vendor;
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- $start =
(isset($data['start'])?$data['start']:0);
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
- $vendor_id =
(isset($data['vendor_id'])?$data['vendor_id']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $member_id =
(isset($data['member_id'])?$data['member_id']:0);
- $agreement_id =
(isset($data['agreement_id'])?$data['agreement_id']:'');
- }
-
- $choice_table = 'fm_agreement_choice';
- $attribute_table = 'fm_agreement_attribute';
-
- $entity_table = 'fm_agreement';
- $category_table = 'fm_branch';
- $attribute_filter = " AND attrib_detail = 1";
- $paranthesis .='(';
- $joinmethod .= " $this->join $category_table ON (
$entity_table.category =$category_table.id)";
- $joinmethod .= " $this->join fm_vendor ON (
$entity_table.vendor_id =fm_vendor.id ))";
-
- $cols = $entity_table . ".*,$category_table.descr as
category, org_name";
-
- $cols_return[] = 'id';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'id';
- $uicols['descr'][] = lang('ID');
- $uicols['statustext'][] = lang('ID');
-
-
- $cols_return[] = 'name';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'name';
- $uicols['descr'][] = lang('name');
- $uicols['statustext'][] = lang('name');
-
- $cols_return[] = 'org_name';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'org_name';
- $uicols['descr'][] =
lang('Vendor');
- $uicols['statustext'][] = lang('Vendor');
-
- $cols_return[] = 'category';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'category';
- $uicols['descr'][] =
lang('category');
- $uicols['statustext'][] = lang('category');
-
- $cols_return[] = 'start_date';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'start_date';
- $uicols['descr'][] = lang('start');
- $uicols['statustext'][] = lang('start date');
-
- $cols_return[] = 'end_date';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'end_date';
- $uicols['descr'][] = lang('end');
- $uicols['statustext'][] = lang('end date');
-
- $cols_return[] = 'status';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'status';
- $uicols['descr'][] =
lang('status');
- $uicols['statustext'][] = lang('status');
-
- if ($order)
- {
- if ($order=='id')
- {
- $ordermethod = " order by
$entity_table.$order $sort";
- }
- else
- {
- $ordermethod = " order by $order $sort";
- }
- }
- else
- {
- $ordermethod = " order by $entity_table.id
DESC";
- }
-
-
- $from .= " FROM $paranthesis $entity_table ";
-
- $sql = "SELECT $cols $from $joinmethod";
-
- $i = count($uicols['name']);
-
- $this->db->query("SELECT * FROM $attribute_table WHERE
list=1 $attribute_filter ");
- while ($this->db->next_record())
- {
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
$this->db->f('column_name');
- $uicols['descr'][] =
$this->db->f('input_text');
- $uicols['statustext'][] =
$this->db->f('statustext');
- $uicols['datatype'][$i] =
$this->db->f('datatype');
- $cols_return_extra[]= array(
- 'name' => $this->db->f('column_name'),
- 'datatype' =>
$this->db->f('datatype'),
- 'attrib_id' => $this->db->f('id')
- );
-
- $i++;
- }
-
-
$user_columns=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['agreement_columns'
. !!$agreement_id];
-
-//_debug_array($user_columns);
-
- if (isset($user_columns) AND is_array($user_columns)
AND $user_columns[0])
- {
- foreach($user_columns as $column_id)
- {
- $this->db->query("SELECT * FROM
$attribute_table WHERE id= $column_id");
-
- $this->db->next_record();
- $uicols['input_type'][] =
'text';
- $uicols['name'][]
= $this->db->f('column_name');
- $uicols['descr'][]
= $this->db->f('input_text');
- $uicols['statustext'][] =
$this->db->f('statustext');
- $uicols['datatype'][$i] =
$this->db->f('datatype');
- $cols_return_extra[]= array(
- 'name' =>
$this->db->f('column_name'),
- 'datatype' =>
$this->db->f('datatype'),
- 'attrib_id' =>
$this->db->f('id')
- );
- $i++;
- }
- }
-
- $this->uicols = $uicols;
-
-//_debug_array($cols_return_extra);
-
- $where= 'WHERE';
-
-/* if ($filter=='all')
- {
- if (is_array($grants))
- {
- while (list($user) = each($grants))
- {
- $public_user_list[] = $user;
- }
- reset($public_user_list);
- $filtermethod .= " $where (
$entity_table.user_id IN(" . implode(',',$public_user_list) . "))";
-
- $where= 'AND';
- }
-
- }
- else
- {
- $filtermethod = " $where
$entity_table.user_id=$filter ";
- $where= 'AND';
- }
-*/
-
- if ($agreement_id)
- {
- $filtermethod .= " $where
$entity_table.agreement_id=$agreement_id";
- $filtermethod .= " AND current_index = 1";
- $where= 'AND';
- }
-
- if ($cat_id)
- {
- $filtermethod .= " $where
$entity_table.category='$cat_id' ";
- $where= 'AND';
- }
-
- if ($vendor_id)
- {
- $filtermethod .= " $where
$entity_table.vendor_id='$vendor_id' ";
- $where= 'AND';
- }
-
- if ($member_id>0)
- {
- $filtermethod .= " $where fm_vendor.member_of
$this->like '%,$member_id,%' ";
- $where= 'AND';
- }
-
- if ($status)
- {
- $filtermethod .= " $where
$entity_table.status='$status' ";
- $where= 'AND';
- }
-
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $this->db->query("SELECT * FROM
$attribute_table where search='1'");
-
- while ($this->db->next_record())
- {
- if($this->db->f('datatype')=='V' ||
$this->db->f('datatype')=='email' || $this->db->f('datatype')=='CH')
- {
- $querymethod[]=
"$entity_table." . $this->db->f('column_name') . " $this->like '%$query%'";
- }
- else
- {
- $querymethod[]=
"$entity_table." . $this->db->f('column_name') . " = '$query'";
- }
- }
-
- if (isset($querymethod) AND
is_array($querymethod))
- {
- $querymethod = " $where (" . implode ('
OR ',$querymethod) . ')';
- $where = 'AND';
- }
- }
-
- $sql .= " $filtermethod $querymethod";
-//echo $sql;
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- $j=0;
- $n=count($cols_return);
-//_debug_array($cols_return);
-
- $contacts =
CreateObject('phpgwapi.contacts');
-
- while ($this->db->next_record())
- {
- for ($i=0;$i<$n;$i++)
- {
- $agreement_list[$j][$cols_return[$i]] =
$this->db->f($cols_return[$i]);
- $agreement_list[$j]['grants'] =
(int)$grants[$this->db->f('user_id')];
- }
-
- for ($i=0;$i<count($cols_return_extra);$i++)
- {
- $value='';
-
$value=$this->db->f($cols_return_extra[$i]['name']);
-
-
if(($cols_return_extra[$i]['datatype']=='R' ||
$cols_return_extra[$i]['datatype']=='LB') && $value):
- {
- $sql="SELECT value FROM
$choice_table where attrib_id=" .$cols_return_extra[$i]['attrib_id']. " AND
id=" . $value . $attribute_filter;
- $this->db2->query($sql);
- $this->db2->next_record();
-
$agreement_list[$j][$cols_return_extra[$i]['name']] = $this->db2->f('value');
- }
-
elseif($cols_return_extra[$i]['datatype']=='AB' && $value):
- {
- $contact_data =
$contacts->read_single_entry($value,array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
-
$agreement_list[$j][$cols_return_extra[$i]['name']] =
$contact_data[0]['n_family'] . ', ' . $contact_data[0]['n_given'];
- }
-
elseif($cols_return_extra[$i]['datatype']=='VENDOR' && $value):
- {
- $sql="SELECT org_name FROM
fm_vendor where id=$value";
- $this->db2->query($sql);
- $this->db2->next_record();
-
$agreement_list[$j][$cols_return_extra[$i]['name']] = $this->db2->f('org_name');
-
- }
-
elseif($cols_return_extra[$i]['datatype']=='CH' && $value):
- {
- $ch= unserialize($value);
-
- if (isset($ch) AND
is_array($ch))
- {
- for
($k=0;$k<count($ch);$k++)
- {
- $sql="SELECT
value FROM $choice_table where attrib_id="
.$cols_return_extra[$i]['attrib_id']. " AND id=" . $ch[$k] . $attribute_filter;
-
$this->db2->query($sql);
- while
($this->db2->next_record())
- {
-
$ch_value[]=$this->db2->f('value');
- }
- }
-
$agreement_list[$j][$cols_return_extra[$i]['name']] = @implode(",", $ch_value);
- unset($ch_value);
- }
- }
-
elseif($cols_return_extra[$i]['datatype']=='D' && $value):
- {
-//_debug_array($value);
-
-
$agreement_list[$j][$cols_return_extra[$i]['name']]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($value));
- }
- else:
- {
-
$agreement_list[$j][$cols_return_extra[$i]['name']]=$value;
- }
- endif;
- }
-
-
- $j++;
- }
-//_debug_array($agreement_list);
- return $agreement_list;
- }
-
- function read_details($data)
- {
- if(is_array($data))
- {
- $start =
(isset($data['start'])?$data['start']:0);
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $agreement_id =
(isset($data['agreement_id'])?$data['agreement_id']:'');
- }
-
- $entity_table = 'fm_activity_price_index';
-
- $paranthesis .='(';
- $joinmethod .= " $this->join fm_activities ON (
fm_activities.id = $entity_table.activity_id))";
-
- $cols = "fm_activities.*,
$entity_table.m_cost,$entity_table.w_cost,"
- . "
$entity_table.total_cost,$entity_table.index_count,"
- . "
$entity_table.index_date,$entity_table.activity_id,"
- . "
$entity_table.this_index,$entity_table.agreement_id";
-
-
- $uicols['name'][] = 'activity_id';
- $uicols['descr'][] = lang('ID');
-
- $uicols['name'][] = 'num';
- $uicols['descr'][] = lang('Code');
-
- $uicols['name'][] = 'descr';
- $uicols['descr'][] = lang('descr');
-
- $uicols['name'][] = 'unit';
- $uicols['descr'][] = lang('unit');
-
- $uicols['name'][] = 'm_cost';
- $uicols['descr'][] =
lang('Material cost');
-
- $uicols['name'][] = 'w_cost';
- $uicols['descr'][] = lang('Labour
cost');
-
- $uicols['name'][] = 'total_cost';
- $uicols['descr'][] = lang('Total
cost');
-
- $uicols['name'][] = 'this_index';
- $uicols['descr'][] = lang('index');
-
- $uicols['name'][] = 'index_count';
- $uicols['descr'][] =
lang('index_count');
-
- $uicols['name'][] = 'index_date';
- $uicols['descr'][] = lang('Date');
-
- if ($order)
- {
- $ordermethod = " order by $entity_table.$order
$sort";
- }
- else
- {
- $ordermethod = " order by
$entity_table.activity_id DESC";
- }
-
-
- $from .= " FROM $paranthesis $entity_table ";
-
- $sql = "SELECT $cols $from $joinmethod";
-
- $this->uicols = $uicols;
-
- $where= 'WHERE';
-
- if ($agreement_id)
- {
- $filtermethod .= " $where
$entity_table.agreement_id=$agreement_id";
- $filtermethod .= " AND current_index = 1";
- $where= 'AND';
- }
-
- if ($cat_id)
- {
- $filtermethod .= " $where
$entity_table.category='$cat_id' ";
- $where= 'AND';
- }
-
- if ($vendor_id)
- {
- $filtermethod .= " $where
$entity_table.vendor_id='$vendor_id' ";
- $where= 'AND';
- }
-
- if ($member_id>0)
- {
- $filtermethod .= " $where fm_vendor.member_of
$this->like '%,$member_id,%' ";
- $where= 'AND';
- }
-
- if ($status)
- {
- $filtermethod .= " $where
$entity_table.status='$status' ";
- $where= 'AND';
- }
-
-
- $sql .= " $filtermethod";
-//echo $sql;
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-
- while ($this->db->next_record())
- {
- $details[] = array
- (
- 'agreement_id' =>
$this->db->f('agreement_id'),
- 'activity_id' =>
$this->db->f('activity_id'),
- 'id' =>
$this->db->f('id'),
- 'num' =>
$this->db->f('num'),
- 'descr' =>
$this->db->f('descr'),
- 'unit' =>
$this->db->f('unit'),
- 'm_cost' =>
$this->db->f('m_cost'),
- 'w_cost' =>
$this->db->f('w_cost'),
- 'total_cost' =>
$this->db->f('total_cost'),
- 'this_index' =>
$this->db->f('this_index'),
- 'index_count' =>
$this->db->f('index_count'),
- 'index_date' =>
$GLOBALS['phpgw']->common->show_date($this->db->f('index_date'),$dateformat)
- );
- }
-//html_print_r($details);
- return $details;
- }
-
- function read_prizing($data)
- {
- if(is_array($data))
- {
- $agreement_id =
(isset($data['agreement_id'])?$data['agreement_id']:0);
- $activity_id =
(isset($data['activity_id'])?$data['activity_id']:0);
- }
-
- $entity_table = 'fm_activity_price_index';
-
- $cols =
"fm_activity_price_index.m_cost,fm_activity_price_index.w_cost,fm_activity_price_index.total_cost,"
- . "
fm_activity_price_index.index_count,fm_activity_price_index.index_date,fm_activity_price_index.activity_id,fm_activity_price_index.this_index";
-
- $cols_return[] = 'activity_id';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'activity_id';
- $uicols['descr'][] =
lang('activity ID');
- $uicols['statustext'][] = lang('activity ID');
-
- $cols_return[] = 'id';
- $uicols['input_type'][] = 'hidden';
- $uicols['name'][] = 'id';
- $uicols['descr'][] = False;
- $uicols['statustext'][] = False;
-
- $cols_return[] = 'm_cost';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'm_cost';
- $uicols['descr'][] =
lang('m_cost');
- $uicols['statustext'][] = lang('m_cost');
- $cols_return[] = 'w_cost';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'w_cost';
- $uicols['descr'][] =
lang('w_cost');
- $uicols['statustext'][] = lang('w_cost');
- $cols_return[] = 'total_cost';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'total_cost';
- $uicols['descr'][] =
lang('total_cost');
- $uicols['statustext'][] = lang('total_cost');
-
- $cols_return[] = 'this_index';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'this_index';
- $uicols['descr'][] = lang('index');
- $uicols['statustext'][] = lang('index');
-
- $cols_return[] = 'index_count';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'index_count';
- $uicols['descr'][] =
lang('index_count');
- $uicols['statustext'][] = lang('index_count');
-
- $cols_return[] = 'index_date';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'index_date';
- $uicols['descr'][] = lang('date');
- $uicols['statustext'][] = lang('date');
-
- $from .= " FROM $entity_table ";
-
- $sql = "SELECT $cols $from $joinmethod";
-
-
- $this->uicols = $uicols;
-
- $ordermethod = " order by $entity_table.index_count
ASC";
-
- $where= 'WHERE';
-
-
- if ($agreement_id)
- {
- $filtermethod .= " $where
$entity_table.agreement_id=$agreement_id AND activity_id=$activity_id";
- $where= 'AND';
- }
-
-
- $sql .= " $filtermethod";
-//echo $sql;
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- $j=0;
- $n=count($cols_return);
-//_debug_array($cols_return);
- while ($this->db->next_record())
- {
- for ($i=0;$i<$n;$i++)
- {
- $agreement_list[$j][$cols_return[$i]] =
$this->db->f($cols_return[$i]);
- $agreement_list[$j]['agreement_id'] =
$agreement_id;
- }
- $j++;
- }
-//_debug_array($agreement_list);
- return $agreement_list;
- }
-
-
- function read_single($data)
- {
- $attribute_table = 'fm_agreement_attribute';
- $table = 'fm_agreement';
-
- $agreement_id =$data['agreement_id'];
-
- $this->db->query("SELECT * FROM $attribute_table WHERE
attrib_detail = 1 ORDER BY attrib_sort");
-
- while ($this->db->next_record())
- {
- $agreement['attributes'][] = array
- (
- 'attrib_id' =>
$this->db->f('id'),
- 'name' =>
$this->db->f('column_name'),
- 'input_text' =>
stripslashes($this->db->f('input_text')),
- 'statustext' =>
stripslashes($this->db->f('statustext')),
- 'datatype' =>
$this->db->f('datatype')
- );
- }
-
- if($agreement_id)
- {
- $this->db->query("SELECT
$table.*,fm_vendor.member_of FROM $table $this->join fm_vendor ON
$table.vendor_id = fm_vendor.id where $table.id='$agreement_id'");
-
- if($this->db->next_record())
- {
- $agreement['id']
= (int)$this->db->f('id');
- $agreement['entry_date'] =
$this->db->f('entry_date');
- $agreement['cat_id'] =
$this->db->f('category');
- $agreement['start_date'] =
$this->db->f('start_date');
- $agreement['end_date'] =
$this->db->f('end_date');
- $agreement['termination_date']=
$this->db->f('termination_date');
- $agreement['vendor_id'] =
$this->db->f('vendor_id');
- $agreement['b_account_id'] =
$this->db->f('account_id');
- $agreement['name']
= stripslashes($this->db->f('name'));
- $agreement['descr']
= stripslashes($this->db->f('descr'));
- $agreement['user_id'] =
$this->db->f('user_id');
- $agreement['group_id'] =
$this->db->f('group_id');
- $agreement['status'] =
$this->db->f('status');
- $agreement['member_of'] =
explode(',',$this->db->f('member_of'));
-
- for
($i=0;$i<count($agreement['attributes']);$i++)
- {
-
$agreement['attributes'][$i]['value'] =
$this->db->f($agreement['attributes'][$i]['name']);
-
$agreement['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($agreement['attributes'][$i]['datatype']);
- }
-
- }
- }
-//_debug_array($agreement);
- return $agreement;
- }
-
- function read_single_item($data)
- {
- $attribute_table = 'fm_agreement_attribute';
- $table = 'fm_activities';
-
- $agreement_id =$data['agreement_id'];
- $id =$data['id'];
-
- $this->db->query("SELECT * FROM $attribute_table WHERE
attrib_detail = 2 ORDER BY attrib_sort");
-
- while ($this->db->next_record())
- {
- $item['attributes'][] = array
- (
- 'attrib_id' =>
$this->db->f('id'),
- 'name' =>
$this->db->f('column_name'),
- 'input_text' =>
stripslashes($this->db->f('input_text')),
- 'statustext' =>
stripslashes($this->db->f('statustext')),
- 'datatype' =>
$this->db->f('datatype')
- );
- }
-
- if($id && $agreement_id)
- {
- $this->db->query("SELECT * from $table
$this->join fm_activity_price_index on $table.id =
fm_activity_price_index.activity_id where $table.id=$id AND
agreement_id=$agreement_id and index_count = 1");
-
- if($this->db->next_record())
- {
- $item['agreement_id'] =
(int)$this->db->f('agreement_id');
- $item['id']
= (int)$this->db->f('id');
- $item['num'] =
$this->db->f('num');
- $item['entry_date'] =
$this->db->f('entry_date');
- $item['m_cost'] =
$this->db->f('m_cost');
- $item['w_cost'] =
$this->db->f('w_cost');
- $item['total_cost'] =
$this->db->f('total_cost');
-
- for
($i=0;$i<count($item['attributes']);$i++)
- {
-
$item['attributes'][$i]['value'] =
$this->db->f($item['attributes'][$i]['name']);
-
$item['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($item['attributes'][$i]['datatype']);
- }
-
- }
- }
- return $item;
- }
-
- function add($agreement,$values_attribute='')
- {
-//_debug_array($agreement);
- $table = 'fm_agreement';
- $agreement['name'] =
$this->db->db_addslashes($agreement['name']);
- $agreement['descr'] =
$this->db->db_addslashes($agreement['descr']);
-
- if($agreement['member_of'])
- {
- $agreement['member_of']=',' .
implode(',',$agreement['member_of']) . ',';
- }
-
- $this->db->transaction_begin();
- $id = $this->bocommon->next_id($table);
- $vals[] = $id;
- $vals[] = $agreement['name'];
- $vals[] = $agreement['descr'];
- $vals[] = time();
- $vals[] = $agreement['cat_id'];
- $vals[] = $agreement['start_date'];
- $vals[] = $agreement['end_date'];
- $vals[] = $agreement['termination_date'];
- $vals[] = $agreement['vendor_id'];
- $vals[] = $this->account;
-
-
- while (is_array($agreement['extra']) &&
list($input_name,$value) = each($agreement['extra']))
- {
- if($value)
- {
- $cols[] = $input_name;
- $vals[] = $value;
- }
- }
-
- if (isset($values_attribute) AND
is_array($values_attribute))
- {
- foreach($values_attribute as $entry)
- {
- if($entry['value'])
- {
- $cols[] = $entry['name'];
- $vals[] = $entry['value'];
- }
- }
- }
-
- $cols[] = 'group_id';
- $vals[] = $agreement['group_id'];
- $cols[] = 'status';
- $vals[] = $agreement['status'];
-
- if($cols)
- {
- $cols = "," . implode(",", $cols);
- $vals =
$this->bocommon->validate_db_insert($vals);
- }
-
- $this->db->query("INSERT INTO $table
(id,name,descr,entry_date,category,start_date,end_date,termination_date,vendor_id,user_id
$cols) "
- . "VALUES ($vals)",__LINE__,__FILE__);
-
- $receipt['agreement_id']=
$id;//$this->db->get_last_insert_id($table,'id');
-
- $receipt['message'][] = array('msg'=>lang('agreement %1
has been saved',$receipt['agreement_id']));
-
- $this->db->transaction_commit();
- return $receipt;
- }
-
- function add_item($values,$values_attribute='')
- {
-//_debug_array($values);
-
- $this->db->transaction_begin();
-
- $this->db->query("SELECT start_date FROM fm_agreement
WHERE id=" . $values['agreement_id']);
- $this->db->next_record();
- $start_date = $this->db->f('start_date');
-
- $agreement_id = $values['agreement_id'];
- $activity_id = $values['id'];
- $m_cost = $this->floatval($values['m_cost']);
- $w_cost = $this->floatval($values['w_cost']);
- $total_cost = $this->floatval($values['total_cost']);
- $entry_date = time();
-
-
- $sql = "UPDATE fm_activity_price_index SET "
- . " index_count = 1,current_index =
1,this_index = 1,"
- . " m_cost = $m_cost,w_cost = $w_cost
,total_cost = $total_cost ,index_date = $start_date,"
- . " entry_date = $entry_date ,user_id =" .
$this->account . " WHERE agreement_id = $agreement_id AND activity_id =
$activity_id AND index_count = -1";
-
- $this->db->query($sql);
-
- $receipt['agreement_id']= $values['agreement_id'];
- $receipt['id']= $values['id'];
-
- $receipt['message'][] = array('msg'=>lang('activity %1
has been saved',$receipt['id']));
-
- $this->db->transaction_commit();
- return $receipt;
- }
-
- function edit($values,$values_attribute='')
- {
-//_debug_array($values);
-//_debug_array($values_attribute);
- $table = 'fm_agreement';
-
- $values['name'] =
$this->db->db_addslashes($values['name']);
-
- if($values['member_of'])
- {
- $values['member_of']=',' .
implode(',',$values['member_of']) . ',';
- }
-
- while (is_array($values['extra']) &&
list($column,$value) = each($values['extra']))
- {
- $value_set[$column] = $value;
- }
-
- if (isset($values_attribute) AND
is_array($values_attribute))
- {
- foreach($values_attribute as $entry)
- {
- if($entry['datatype']!='AB' &&
$entry['datatype']!='VENDOR')
- {
- $value_set[$entry['name']]
= $entry['value'];
- }
- }
- }
-
- $value_set['name'] = $values['name'];
- $value_set['descr'] = $values['descr'];
- $value_set['group_id'] = $values['group_id'];
- $value_set['status'] = $values['status'];
- if($value_set)
- {
- $value_set = ',' .
$this->bocommon->validate_db_update($value_set);
- }
-
- $this->db->query("UPDATE $table set entry_date='" .
time() . "', category='"
- . $values['cat_id'] .
"', start_date=" . intval($values['start_date']) . ", end_date=" .
intval($values['end_date']) . ", termination_date=" .
intval($values['termination_date']) . "$value_set WHERE id=" .
intval($values['agreement_id']));
-
- $this->db->query("UPDATE fm_activity_price_index set
index_date=" . intval($values['start_date']) . " WHERE index_count=1 AND
agreement_id= " . intval($values['agreement_id']));
-
- $receipt['agreement_id']= $values['agreement_id'];
- $receipt['message'][] = array('msg'=>lang('agreement %1
has been edited',$values['agreement_id']));
- return $receipt;
- }
-
- function edit_item($values)
- {
-//_debug_array($values);
-
- $value_set['m_cost'] = $values['m_cost'];
- $value_set['w_cost'] = $values['w_cost'];
- $value_set['total_cost'] = $values['total_cost'];
-
- if($value_set)
- {
- $value_set = ',' .
$this->bocommon->validate_db_update($value_set);
- }
-
- $this->db->query("UPDATE fm_activity_price_index set
entry_date=" . time() . "$value_set WHERE agreement_id=" .
intval($values['agreement_id']) . ' AND activity_id=' . intval($values['id']));
-
- $this->db->query("UPDATE fm_activity_price_index set
m_cost = this_index *" . $this->floatval($values['m_cost']) . ",w_cost =
this_index *" . $this->floatval($values['w_cost']) . ",total_cost = this_index
*" . $this->floatval($values['total_cost']) . " WHERE agreement_id=" .
intval($values['agreement_id']) . ' AND activity_id=' . intval($values['id']));
-
- $receipt['agreement_id']= $values['agreement_id'];
- $receipt['id']= $values['id'];
- $receipt['message'][] = array('msg'=>lang('Activity %1
has been edited',$values['id']));
- return $receipt;
- }
-
- function update($values)
- {
-//_debug_array($values);
-
$values['new_index']=$this->floatval($values['new_index']);
- $this->db->transaction_begin();
-
- while (is_array($values['select']) &&
list(,$activity_id) = each($values['select']))
- {
-
- if($values['id'][$activity_id]>0)
- {
- $this->db->query("UPDATE
fm_activity_price_index set current_index = NULL WHERE agreement_id=" .
intval($values['agreement_id']) . ' AND activity_id=' . intval($activity_id));
-
- $this->db->query("INSERT INTO
fm_activity_price_index
(agreement_id,activity_id,index_count,current_index,this_index,m_cost,w_cost,total_cost,index_date,entry_date,user_id)"
- . "VALUES (" .
$values['agreement_id'] . "," . $activity_id ."," .
($values['id'][$activity_id]+1) .",1,'" . $values['new_index'] . "','" .
($values['m_cost'][$activity_id] * $values['new_index']) . "','" .
($values['w_cost'][$activity_id] * $values['new_index']) . "','" .
($values['total_cost'][$activity_id] * $values['new_index']) . "'," .
(int)$values['date'] . "," . time()
- . "," . $this->account . ")");
-
- $receipt['message'][] =
array('msg'=>lang('Activity %1 has been updated for index',$activity_id));
- }
-
- }
-
- $this->db->transaction_commit();
-
- return $receipt;
- }
-
- function floatval($strValue)
- {
- $floatValue =
ereg_replace("(^[0-9]*)(\\.|,)([0-9]*)(.*)", "\\1.\\3", $strValue);
- if(!is_numeric($floatValue))
- {
- $floatValue = ereg_replace("(^[0-9]*)(.*)",
"\\1", $strValue);
- }
- if(!is_numeric($floatValue))
- {
- $floatValue = 0;
- }
- return $floatValue;
- }
-
-
- function delete_last_index($agreement_id,$activity_id)
- {
- $this->db->transaction_begin();
- $this->db->query("SELECT max(index_count) as
index_count FROM fm_activity_price_index WHERE agreement_id=$agreement_id AND
activity_id=$activity_id");
- $this->db->next_record();
- $index_count = $this->db->f('index_count');
- if($index_count>1)
- {
- $this->db->query("DELETE FROM
fm_activity_price_index WHERE agreement_id=$agreement_id AND
activity_id=$activity_id AND index_count=$index_count");
- $this->db->query("UPDATE
fm_activity_price_index set current_index = 1 WHERE agreement_id=$agreement_id
AND activity_id=$activity_id AND index_count =" . ($index_count-1));
- }
- else
- {
- $sql = "UPDATE fm_activity_price_index SET "
- . " index_count = -1,current_index =
1,this_index = 1,"
- . " m_cost = NULL,w_cost = NULL
,total_cost = NULL ,index_date = NULL,"
- . " entry_date = NULL ,user_id =" .
$this->account . " WHERE agreement_id = $agreement_id AND activity_id =
$activity_id";
-
- $this->db->query($sql);
-
- }
- $this->db->transaction_commit();
- }
-
- function delete_item($agreement_id,$activity_id)
- {
- $this->db->transaction_begin();
- $this->db->query("DELETE FROM fm_activity_price_index
WHERE agreement_id=$agreement_id AND activity_id=$activity_id");
- $this->db->transaction_commit();
- }
-
- function delete($agreement_id)
- {
- $this->db->transaction_begin();
- $this->db->query("DELETE FROM fm_agreement WHERE id=" .
intval($agreement_id));
- $this->db->query("DELETE FROM fm_activity_price_index
WHERE agreement_id=" . intval($agreement_id));
- $this->db->transaction_commit();
- }
-
- function read_attrib($data)
- {
- $attribute_table = 'fm_agreement_attribute';
-//html_print_r($data);
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $column_list =
(isset($data['column_list'])?$data['column_list']:'');
- }
-
- $where = 'WHERE';
- if ($column_list)
- {
- $filtermethod = " $where list !=1 or list is
null";
- $where = 'AND';
- }
- if ($this->role=='detail')
- {
- $filtermethod .= " $where attrib_detail=2 ";
- }
- else
- {
- $filtermethod .= " $where attrib_detail=1 ";
- }
-
- $where = 'AND';
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by attrib_sort asc';
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " $where
($attribute_table.input_text $this->like '%$query%' or
$attribute_table.column_name $this->like '%$query%')";
- }
-
- $sql = "SELECT * FROM $attribute_table $filtermethod
$querymethod";
-
-//echo $sql;
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $attrib[] = array
- (
- 'id' =>
$this->db->f('id'),
- 'attrib_sort' =>
$this->db->f('attrib_sort'),
- 'list' =>
$this->db->f('list'),
- 'lookup_form' =>
$this->db->f('lookup_form'),
- 'column_name' =>
$this->db->f('column_name'),
- 'name' =>
$this->db->f('input_text'),
- 'size' =>
$this->db->f('size'),
- 'statustext' =>
$this->db->f('statustext'),
- 'input_text' =>
$this->db->f('input_text'),
- 'type_name' =>
$this->db->f('type'),
- 'datatype' =>
$this->db->f('datatype'),
- 'search' =>
$this->db->f('search')
- );
- }
- return $attrib;
- }
-
- function read_single_attrib($id)
- {
- $attribute_table = 'fm_agreement_attribute';
-
- if ($this->role=='detail')
- {
- $filtermethod = " AND attrib_detail=2 ";
- }
- else
- {
- $filtermethod = " AND attrib_detail=1 ";
- }
-
- $sql = "SELECT * FROM $attribute_table where id=$id
$filtermethod";
-
- $this->db->query($sql);
-
- if($this->db->next_record())
- {
- $attrib['id']
= $this->db->f('id');
- $attrib['column_name']
= $this->db->f('column_name');
- $attrib['input_text']
= $this->db->f('input_text');
- $attrib['statustext']
= $this->db->f('statustext');
- $attrib['column_info']['precision'] =
$this->db->f('precision_');
- $attrib['column_info']['scale'] =
$this->db->f('scale');
- $attrib['column_info']['default'] =
$this->db->f('default_value');
- $attrib['column_info']['nullable'] =
$this->db->f('nullable');
- $attrib['column_info']['type'] =
$this->db->f('datatype');
- $attrib['type_name']
= $this->db->f('type_name');
- $attrib['lookup_form']
= $this->db->f('lookup_form');
- $attrib['list']
= $this->db->f('list');
- $attrib['search']
= $this->db->f('search');
- if($this->db->f('datatype')=='R' ||
$this->db->f('datatype')=='CH' || $this->db->f('datatype')=='LB')
- {
- $attrib['choice'] =
$this->read_attrib_choice($id);
- }
-
- return $attrib;
- }
- }
-
- function read_attrib_choice($attrib_id)
- {
- $choice_table = 'fm_agreement_choice';
-
- if ($this->role=='detail')
- {
- $filtermethod = " AND attrib_detail=2 ";
- }
- else
- {
- $filtermethod = " AND attrib_detail=1 ";
- }
-
- $sql = "SELECT * FROM $choice_table WHERE
attrib_id=$attrib_id $filtermethod";
- $this->db->query($sql);
-
- while ($this->db->next_record())
- {
- $choice[] = array
- (
- 'id' => $this->db->f('id'),
- 'value' => $this->db->f('value')
- );
-
- }
- return $choice;
- }
-
- function add_attrib($attrib)
- {
- $attribute_table = 'fm_agreement_attribute';
- $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
- $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
- $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
- $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
- $attrib['id'] =
$this->bocommon->next_id($attribute_table, array('attrib_detail'=>!!$this->role
+1));
-
- if($this->role=='detail')
- {
- $filtermethod= 'WHERE attrib_detail=2';
- $table = 'fm_agreement_detail';
- }
- else
- {
- $filtermethod= 'WHERE attrib_detail=1';
- $table = 'fm_agreement';
- }
- $sql = "SELECT max(attrib_sort) as max_sort FROM
$attribute_table $filtermethod";
- $this->db->query($sql);
- $this->db->next_record();
- $attrib_sort = $this->db->f('max_sort')+1;
-
- $values= array(
- !!$this->role +1,
- $attrib['id'],
- $attrib['column_name'],
- $attrib['input_text'],
- $attrib['statustext'],
- $attrib['lookup_form'],
- $attrib['search'],
- $attrib['list'],
- $attrib_sort,
- $attrib['column_info']['type'],
- $attrib['column_info']['precision'],
- $attrib['column_info']['scale'],
- $attrib['column_info']['default'],
- $attrib['column_info']['nullable']
- );
-
- $values = $this->bocommon->validate_db_insert($values);
-
- $this->db->transaction_begin();
-
- $this->db->query("INSERT INTO $attribute_table
(attrib_detail,id,column_name, input_text,
statustext,lookup_form,search,list,attrib_sort,datatype,precision_,scale,default_value,nullable)
"
- . "VALUES ($values)");
-
- $receipt['id']= $attrib['id'];
-
- if($attrib['column_info']['type']=='email' &&
!$attrib['column_info']['precision'])
- {
- $attrib['column_info']['precision']=64;
- }
-
- $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
-
- if($attrib['column_info']['type']=='int' &&
!$attrib['column_info']['precision'])
- {
- $attrib['column_info']['precision']=4;
- }
-
- if(!$attrib['column_info']['default'])
- {
- unset($attrib['column_info']['default']);
- }
-
- $this->init_process();
-
-
if($this->oProc->AddColumn($table,$attrib['column_name'],
$attrib['column_info']))
- {
- $receipt['message'][] = array('msg' =>
lang('Attribute has been saved') );
- $this->db->transaction_commit();
-
- }
- else
- {
- $receipt['error'][] = array('msg' =>
lang('column could not be added') );
- if($this->db->Transaction)
- {
- $GLOBALS['phpgw']->db->rollbacktrans();
- }
- else
- {
- $GLOBALS['phpgw']->db->Execute("DELETE
FROM $attribute_table WHERE id='" . $receipt['id'] . "'");
- unset($receipt['id']);
-
- }
- }
-
- return $receipt;
- }
-
- function init_process()
- {
- $this->oProc
=
CreateObject('phpgwapi.schema_proc',$GLOBALS['phpgw_info']['server']['db_type']);
- $this->oProc->m_odb
= $this->db;
- $this->oProc->m_odb->Halt_On_Error = 'report';
- }
-
- function edit_attrib($attrib)
- {
- $attribute_table = 'fm_agreement_attribute';
- $table = 'fm_agreement';
-
- $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
- $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
- $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
- $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
-
- $choice_table = 'fm_agreement_choice';
-
- if($this->role=='detail')
- {
- $filtermethod= ' AND attrib_detail=2';
- $table = 'fm_agreement_detail';
- }
- else
- {
- $filtermethod= ' AND attrib_detail=1';
- $table = 'fm_agreement';
- }
-
- $this->db->query("SELECT column_name FROM
$attribute_table WHERE id='" . $attrib['id']. "' $filtermethod");
- $this->db->next_record();
- $OldColumnName = $this->db->f('column_name');
-
- $this->db->transaction_begin();
-
- $attrib_type=$attrib['column_info']['type'];
- if(($OldColumnName !=$attrib['column_name']) ||
($attrib['column_info']['type'] != $this->db->f('datatype')))
- {
- $value_set=array(
- 'column_name' =>
$attrib['column_name'],
- 'input_text' =>
$attrib['input_text'],
- 'statustext' =>
$attrib['statustext'],
- 'lookup_form' =>
$attrib['lookup_form'],
- 'search' =>
$attrib['search'],
- 'list' =>
$attrib['list'],
- 'datatype' =>
$attrib['column_info']['type'],
- 'precision_' =>
$attrib['column_info']['precision'],
- 'scale' =>
$attrib['column_info']['scale'],
- 'default_value' =>
$attrib['column_info']['default'],
- 'nullable' =>
$attrib['column_info']['nullable']
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE $attribute_table set
$value_set WHERE id=" . $attrib['id'] . $filtermethod);
-
- if($attrib['column_info']['type']=='email' &&
!$attrib['column_info']['precision'])
- {
- $attrib['column_info']['precision']=64;
- }
-
- $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
-
- if($attrib['column_info']['type']=='int' &&
!$attrib['column_info']['precision'])
- {
- $attrib['column_info']['precision']=4;
- }
-
- if(!$attrib['column_info']['default'])
- {
-
unset($attrib['column_info']['default']);
- }
-
- $this->init_process();
-
-
$this->oProc->AlterColumn($table,$OldColumnName,$attrib['column_name'],$attrib['column_info']);
-
- }
-
-
- if($attrib['new_choice'])
- {
- $this->db->query("SELECT max(id) as id FROM
$choice_table WHERE attrib_id='" . $attrib['id']. "' $filtermethod");
- $this->db->next_record();
- $choice_id = $this->db->f('id')+1;
-
- // $choice_id =
$this->bocommon->next_id($choice_table
,array('attrib_detail'=>2,'attrib_id'=>$attrib['id']));
-
- $values= array(
- $attrib['id'],
- $choice_id,
- !!$this->role +1,
- $attrib['new_choice']
- );
-
- $values =
$this->bocommon->validate_db_insert($values);
-
- $this->db->query("INSERT INTO $choice_table
(attrib_id,id,attrib_detail,value) "
- . "VALUES ($values)");
- }
-
-
- if($attrib['delete_choice'])
- {
- for
($i=0;$i<count($attrib['delete_choice']);$i++)
- {
- $this->db->query("DELETE FROM
$choice_table WHERE attrib_id=" . $attrib['id'] ." AND id=" .
$attrib['delete_choice'][$i] . $filtermethod);
- }
- }
-
-//html_print_r($attrib_type);
- if($attrib_type!='R' && $attrib_type!='CH' &&
$attrib_type!='LB')
- {
- $this->db->query("DELETE FROM $choice_table
WHERE attrib_id=" . $attrib['id'] . $filtermethod);
- }
-
-
- $this->db->transaction_commit();
-
- $receipt['message'][] = array('msg' =>
lang('Attribute has been edited'));
-
-
- return $receipt;
-
- }
- function resort_attrib($data)
- {
-//html_print_r($data);
- $attribute_table = 'fm_agreement_attribute';
- if(is_array($data))
- {
- $resort =
(isset($data['resort'])?$data['resort']:'up');
- $id = (isset($data['id'])?$data['id']:'');
- }
-
- $sql = "SELECT attrib_sort FROM $attribute_table where
id=$id";
- $this->db->query($sql);
- $this->db->next_record();
- $attrib_sort = $this->db->f('attrib_sort');
- $sql = "SELECT max(attrib_sort) as max_sort FROM
$attribute_table";
- $this->db->query($sql);
- $this->db->next_record();
- $max_sort = $this->db->f('max_sort');
- switch($resort)
- {
- case 'up':
- if($attrib_sort>1)
- {
- $sql = "UPDATE $attribute_table
set attrib_sort=$attrib_sort WHERE attrib_sort =" . ($attrib_sort-1);
- $this->db->query($sql);
- $sql = "UPDATE $attribute_table
set attrib_sort=" . ($attrib_sort-1) ." WHERE id=$id";
- $this->db->query($sql);
- }
- break;
- case 'down':
- if($max_sort > $attrib_sort)
- {
- $sql = "UPDATE $attribute_table
set attrib_sort=$attrib_sort WHERE attrib_sort =" . ($attrib_sort+1);
- $this->db->query($sql);
- $sql = "UPDATE $attribute_table
set attrib_sort=" . ($attrib_sort+1) ." WHERE id=$id";
- $this->db->query($sql);
- }
- break;
- default:
- return;
- break;
- }
- }
- function delete_attrib($attrib_id)
- {
- $table = 'fm_agreement';
- $attribute_table = 'fm_agreement_attribute';
- $this->init_process();
-
- $sql = "SELECT * FROM $attribute_table WHERE
id=$attrib_id";
-
- $this->db->query($sql);
- $this->db->next_record();
- $ColumnName = $this->db->f('column_name');
-
- if($this->oProc->DropColumn($table,'', $ColumnName))
- {
- $sql = "SELECT attrib_sort FROM
$attribute_table where id=$attrib_id";
- $this->db->query($sql);
- $this->db->next_record();
- $attrib_sort = $this->db->f('attrib_sort');
- $sql2 = "SELECT max(attrib_sort) as max_sort
FROM $attribute_table";
- $this->db->query($sql2);
- $this->db->next_record();
- $max_sort = $this->db->f('max_sort');
- if($max_sort>$attrib_sort)
- {
- $sql = "UPDATE $attribute_table set
attrib_sort=attrib_sort-1 WHERE attrib_sort > $attrib_sort";
- $this->db->query($sql);
- }
-
- $this->db->query("DELETE FROM $attribute_table
WHERE id=$attrib_id");
- }
- else
- {
- $receipt['error'][] = array('msg' =>
lang('Attribute has NOT been deleted'));
- }
-
- return $receipt;
- }
-
- function request_next_id()
- {
- $this->db->query("SELECT max(id) as id FROM
fm_agreement");
- $this->db->next_record();
- $next_id= $this->db->f('id')+1;
- return $next_id;
- }
-
- function get_agreement_group_list()
- {
- $this->db->query("SELECT * FROM fm_agreement_group
ORDER BY descr asc");
- while ($this->db->next_record())
- {
- $agreement_group_list[]=array
- (
- 'id' => $this->db->f('id'),
- 'name' =>
$GLOBALS['phpgw']->strip_html($this->db->f('descr')).' [ '.
$GLOBALS['phpgw']->strip_html($this->db->f('status')).' ] '
- );
- }
- return $agreement_group_list;
- }
-
- function read_group_activity($group_id='',$agreement_id='')
- {
- $uicols['name'][] = 'id';
- $uicols['descr'][] = lang('ID');
- $uicols['name'][] = 'num';
- $uicols['descr'][] = lang('Num');
- $uicols['name'][] = 'base_descr';
- $uicols['descr'][] = lang('Base');
- $uicols['name'][] = 'descr';
- $uicols['descr'][] = lang('Descr');
- $uicols['name'][] = 'unit';
- $uicols['descr'][] = lang('Unit');
- $uicols['name'][] = 'ns3420';
- $uicols['descr'][] =
lang('ns3420');
-
- $this->uicols = $uicols;
-
- $sql="SELECT fm_activities.* FROM fm_activities WHERE
agreement_group_id = $group_id";
- $this->db->query($sql);
-
- while ($this->db->next_record())
- {
- $activity_list[$this->db->f('id')]=array
- (
- 'id' => $this->db->f('id'),
- 'num' => $this->db->f('num'),
- 'base_descr' =>
$this->db->f('base_descr'),
- 'descr' =>
$this->db->f('descr'),
- 'unit' => $this->db->f('unit'),
- 'ns3420' =>
$this->db->f('ns3420'),
- );
- }
-
- $sql="SELECT activity_id FROM fm_activity_price_index
WHERE agreement_id = $agreement_id";
-
- $this->db->query($sql);
-
- while ($this->db->next_record())
- {
-
unset($activity_list[$this->db->f('activity_id')]);
- }
-
- foreach($activity_list as $entry)
- {
- $activity_list_result[] = $entry;
- }
-
- return $activity_list_result;
- }
-
- function add_activity($values='',$agreement_id='')
- {
- if (isset($values['select']) AND
is_array($values['select']))
- {
- $this->db->transaction_begin();
-
- $this->db->query("SELECT start_date FROM
fm_agreement WHERE id=" . $values['agreement_id']);
- $this->db->next_record();
- $date = $this->db->f('start_date');
-
- foreach($values['select'] as $activity_id)
- {
- $this->db->query("INSERT INTO
fm_activity_price_index ( agreement_id,
activity_id,index_count,current_index,index_date,entry_date,user_id) "
- . "VALUES
($agreement_id,$activity_id,-1,1,$date," . time() . "," . $this->account . ")");
- }
-
- $this->db->transaction_commit();
- }
-
-
- $receipt['agreement_id']=
$id;//$this->db->get_last_insert_id($table,'id');
-
- $receipt['message'][] = array('msg'=>lang('agreement %1
has been saved',$receipt['agreement_id']));
-
- return $receipt;
- }
-
- function select_status_list()
- {
- $this->db->query("SELECT id, descr FROM
fm_agreement_status ORDER BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $status_entries[$i]['id']
= $this->db->f('id');
- $status_entries[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $status_entries;
- }
-
- function get_activity_descr($id)
- {
- $this->db->query("SELECT descr FROM fm_activities WHERE
id = $id",__LINE__,__FILE__);
- $this->db->next_record();
- return stripslashes($this->db->f('descr'));
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage agreement
+ * @version $Id: class.soagreement.inc.php,v 1.9 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class soagreement
+ {
+ var $role;
+
+ function soagreement()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->left_join = $this->bocommon->left_join;
+ $this->like = $this->bocommon->like;
+// $this->role = 'agreement';
+ }
+
+ function select_category_list()
+ {
+ $table = 'fm_branch';
+ $this->db->query("SELECT id,descr FROM $table ORDER BY
descr ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $categories[$i]['id']
= $this->db->f('id');
+ $categories[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $categories;
+ }
+
+ function select_vendor_list()
+ {
+ $table = 'fm_agreement';
+ $this->db->query("SELECT vendor_id,org_name FROM $table
$this->join fm_vendor on fm_agreement.vendor_id=fm_vendor.id GROUP BY
org_name,vendor_id ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $vendor[$i]['id']
= $this->db->f('vendor_id');
+ $vendor[$i]['name']
= stripslashes($this->db->f('org_name'));
+ $i++;
+ }
+ return $vendor;
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ $start =
(isset($data['start'])?$data['start']:0);
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
+ $vendor_id =
(isset($data['vendor_id'])?$data['vendor_id']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $member_id =
(isset($data['member_id'])?$data['member_id']:0);
+ $agreement_id =
(isset($data['agreement_id'])?$data['agreement_id']:'');
+ }
+
+ $choice_table = 'fm_agreement_choice';
+ $attribute_table = 'fm_agreement_attribute';
+
+ $entity_table = 'fm_agreement';
+ $category_table = 'fm_branch';
+ $attribute_filter = " AND attrib_detail = 1";
+ $paranthesis .='(';
+ $joinmethod .= " $this->join $category_table ON (
$entity_table.category =$category_table.id)";
+ $joinmethod .= " $this->join fm_vendor ON (
$entity_table.vendor_id =fm_vendor.id ))";
+
+ $cols = $entity_table . ".*,$category_table.descr as
category, org_name";
+
+ $cols_return[] = 'id';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'id';
+ $uicols['descr'][] = lang('ID');
+ $uicols['statustext'][] = lang('ID');
+
+
+ $cols_return[] = 'name';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'name';
+ $uicols['descr'][] = lang('name');
+ $uicols['statustext'][] = lang('name');
+
+ $cols_return[] = 'org_name';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'org_name';
+ $uicols['descr'][] =
lang('Vendor');
+ $uicols['statustext'][] = lang('Vendor');
+
+ $cols_return[] = 'category';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'category';
+ $uicols['descr'][] =
lang('category');
+ $uicols['statustext'][] = lang('category');
+
+ $cols_return[] = 'start_date';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'start_date';
+ $uicols['descr'][] = lang('start');
+ $uicols['statustext'][] = lang('start date');
+
+ $cols_return[] = 'end_date';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'end_date';
+ $uicols['descr'][] = lang('end');
+ $uicols['statustext'][] = lang('end date');
+
+ $cols_return[] = 'status';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'status';
+ $uicols['descr'][] =
lang('status');
+ $uicols['statustext'][] = lang('status');
+
+ if ($order)
+ {
+ if ($order=='id')
+ {
+ $ordermethod = " order by
$entity_table.$order $sort";
+ }
+ else
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ }
+ else
+ {
+ $ordermethod = " order by $entity_table.id
DESC";
+ }
+
+
+ $from .= " FROM $paranthesis $entity_table ";
+
+ $sql = "SELECT $cols $from $joinmethod";
+
+ $i = count($uicols['name']);
+
+ $this->db->query("SELECT * FROM $attribute_table WHERE
list=1 $attribute_filter ");
+ while ($this->db->next_record())
+ {
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
$this->db->f('column_name');
+ $uicols['descr'][] =
$this->db->f('input_text');
+ $uicols['statustext'][] =
$this->db->f('statustext');
+ $uicols['datatype'][$i] =
$this->db->f('datatype');
+ $cols_return_extra[]= array(
+ 'name' => $this->db->f('column_name'),
+ 'datatype' =>
$this->db->f('datatype'),
+ 'attrib_id' => $this->db->f('id')
+ );
+
+ $i++;
+ }
+
+
$user_columns=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['agreement_columns'
. !!$agreement_id];
+
+//_debug_array($user_columns);
+
+ if (isset($user_columns) AND is_array($user_columns)
AND $user_columns[0])
+ {
+ foreach($user_columns as $column_id)
+ {
+ $this->db->query("SELECT * FROM
$attribute_table WHERE id= $column_id");
+
+ $this->db->next_record();
+ $uicols['input_type'][] =
'text';
+ $uicols['name'][]
= $this->db->f('column_name');
+ $uicols['descr'][]
= $this->db->f('input_text');
+ $uicols['statustext'][] =
$this->db->f('statustext');
+ $uicols['datatype'][$i] =
$this->db->f('datatype');
+ $cols_return_extra[]= array(
+ 'name' =>
$this->db->f('column_name'),
+ 'datatype' =>
$this->db->f('datatype'),
+ 'attrib_id' =>
$this->db->f('id')
+ );
+ $i++;
+ }
+ }
+
+ $this->uicols = $uicols;
+
+//_debug_array($cols_return_extra);
+
+ $where= 'WHERE';
+
+/* if ($filter=='all')
+ {
+ if (is_array($grants))
+ {
+ while (list($user) = each($grants))
+ {
+ $public_user_list[] = $user;
+ }
+ reset($public_user_list);
+ $filtermethod .= " $where (
$entity_table.user_id IN(" . implode(',',$public_user_list) . "))";
+
+ $where= 'AND';
+ }
+
+ }
+ else
+ {
+ $filtermethod = " $where
$entity_table.user_id=$filter ";
+ $where= 'AND';
+ }
+*/
+
+ if ($agreement_id)
+ {
+ $filtermethod .= " $where
$entity_table.agreement_id=$agreement_id";
+ $filtermethod .= " AND current_index = 1";
+ $where= 'AND';
+ }
+
+ if ($cat_id)
+ {
+ $filtermethod .= " $where
$entity_table.category='$cat_id' ";
+ $where= 'AND';
+ }
+
+ if ($vendor_id)
+ {
+ $filtermethod .= " $where
$entity_table.vendor_id='$vendor_id' ";
+ $where= 'AND';
+ }
+
+ if ($member_id>0)
+ {
+ $filtermethod .= " $where fm_vendor.member_of
$this->like '%,$member_id,%' ";
+ $where= 'AND';
+ }
+
+ if ($status)
+ {
+ $filtermethod .= " $where
$entity_table.status='$status' ";
+ $where= 'AND';
+ }
+
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $this->db->query("SELECT * FROM
$attribute_table where search='1'");
+
+ while ($this->db->next_record())
+ {
+ if($this->db->f('datatype')=='V' ||
$this->db->f('datatype')=='email' || $this->db->f('datatype')=='CH')
+ {
+ $querymethod[]=
"$entity_table." . $this->db->f('column_name') . " $this->like '%$query%'";
+ }
+ else
+ {
+ $querymethod[]=
"$entity_table." . $this->db->f('column_name') . " = '$query'";
+ }
+ }
+
+ if (isset($querymethod) AND
is_array($querymethod))
+ {
+ $querymethod = " $where (" . implode ('
OR ',$querymethod) . ')';
+ $where = 'AND';
+ }
+ }
+
+ $sql .= " $filtermethod $querymethod";
+//echo $sql;
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ $j=0;
+ $n=count($cols_return);
+//_debug_array($cols_return);
+
+ $contacts =
CreateObject('phpgwapi.contacts');
+
+ while ($this->db->next_record())
+ {
+ for ($i=0;$i<$n;$i++)
+ {
+ $agreement_list[$j][$cols_return[$i]] =
$this->db->f($cols_return[$i]);
+ $agreement_list[$j]['grants'] =
(int)$grants[$this->db->f('user_id')];
+ }
+
+ for ($i=0;$i<count($cols_return_extra);$i++)
+ {
+ $value='';
+
$value=$this->db->f($cols_return_extra[$i]['name']);
+
+
if(($cols_return_extra[$i]['datatype']=='R' ||
$cols_return_extra[$i]['datatype']=='LB') && $value):
+ {
+ $sql="SELECT value FROM
$choice_table where attrib_id=" .$cols_return_extra[$i]['attrib_id']. " AND
id=" . $value . $attribute_filter;
+ $this->db2->query($sql);
+ $this->db2->next_record();
+
$agreement_list[$j][$cols_return_extra[$i]['name']] = $this->db2->f('value');
+ }
+
elseif($cols_return_extra[$i]['datatype']=='AB' && $value):
+ {
+ $contact_data =
$contacts->read_single_entry($value,array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
+
$agreement_list[$j][$cols_return_extra[$i]['name']] =
$contact_data[0]['n_family'] . ', ' . $contact_data[0]['n_given'];
+ }
+
elseif($cols_return_extra[$i]['datatype']=='VENDOR' && $value):
+ {
+ $sql="SELECT org_name FROM
fm_vendor where id=$value";
+ $this->db2->query($sql);
+ $this->db2->next_record();
+
$agreement_list[$j][$cols_return_extra[$i]['name']] = $this->db2->f('org_name');
+
+ }
+
elseif($cols_return_extra[$i]['datatype']=='CH' && $value):
+ {
+ $ch= unserialize($value);
+
+ if (isset($ch) AND
is_array($ch))
+ {
+ for
($k=0;$k<count($ch);$k++)
+ {
+ $sql="SELECT
value FROM $choice_table where attrib_id="
.$cols_return_extra[$i]['attrib_id']. " AND id=" . $ch[$k] . $attribute_filter;
+
$this->db2->query($sql);
+ while
($this->db2->next_record())
+ {
+
$ch_value[]=$this->db2->f('value');
+ }
+ }
+
$agreement_list[$j][$cols_return_extra[$i]['name']] = @implode(",", $ch_value);
+ unset($ch_value);
+ }
+ }
+
elseif($cols_return_extra[$i]['datatype']=='D' && $value):
+ {
+//_debug_array($value);
+
+
$agreement_list[$j][$cols_return_extra[$i]['name']]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($value));
+ }
+ else:
+ {
+
$agreement_list[$j][$cols_return_extra[$i]['name']]=$value;
+ }
+ endif;
+ }
+
+
+ $j++;
+ }
+//_debug_array($agreement_list);
+ return $agreement_list;
+ }
+
+ function read_details($data)
+ {
+ if(is_array($data))
+ {
+ $start =
(isset($data['start'])?$data['start']:0);
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $agreement_id =
(isset($data['agreement_id'])?$data['agreement_id']:'');
+ }
+
+ $entity_table = 'fm_activity_price_index';
+
+ $paranthesis .='(';
+ $joinmethod .= " $this->join fm_activities ON (
fm_activities.id = $entity_table.activity_id))";
+
+ $cols = "fm_activities.*,
$entity_table.m_cost,$entity_table.w_cost,"
+ . "
$entity_table.total_cost,$entity_table.index_count,"
+ . "
$entity_table.index_date,$entity_table.activity_id,"
+ . "
$entity_table.this_index,$entity_table.agreement_id";
+
+
+ $uicols['name'][] = 'activity_id';
+ $uicols['descr'][] = lang('ID');
+
+ $uicols['name'][] = 'num';
+ $uicols['descr'][] = lang('Code');
+
+ $uicols['name'][] = 'descr';
+ $uicols['descr'][] = lang('descr');
+
+ $uicols['name'][] = 'unit';
+ $uicols['descr'][] = lang('unit');
+
+ $uicols['name'][] = 'm_cost';
+ $uicols['descr'][] =
lang('Material cost');
+
+ $uicols['name'][] = 'w_cost';
+ $uicols['descr'][] = lang('Labour
cost');
+
+ $uicols['name'][] = 'total_cost';
+ $uicols['descr'][] = lang('Total
cost');
+
+ $uicols['name'][] = 'this_index';
+ $uicols['descr'][] = lang('index');
+
+ $uicols['name'][] = 'index_count';
+ $uicols['descr'][] =
lang('index_count');
+
+ $uicols['name'][] = 'index_date';
+ $uicols['descr'][] = lang('Date');
+
+ if ($order)
+ {
+ $ordermethod = " order by $entity_table.$order
$sort";
+ }
+ else
+ {
+ $ordermethod = " order by
$entity_table.activity_id DESC";
+ }
+
+
+ $from .= " FROM $paranthesis $entity_table ";
+
+ $sql = "SELECT $cols $from $joinmethod";
+
+ $this->uicols = $uicols;
+
+ $where= 'WHERE';
+
+ if ($agreement_id)
+ {
+ $filtermethod .= " $where
$entity_table.agreement_id=$agreement_id";
+ $filtermethod .= " AND current_index = 1";
+ $where= 'AND';
+ }
+
+ if ($cat_id)
+ {
+ $filtermethod .= " $where
$entity_table.category='$cat_id' ";
+ $where= 'AND';
+ }
+
+ if ($vendor_id)
+ {
+ $filtermethod .= " $where
$entity_table.vendor_id='$vendor_id' ";
+ $where= 'AND';
+ }
+
+ if ($member_id>0)
+ {
+ $filtermethod .= " $where fm_vendor.member_of
$this->like '%,$member_id,%' ";
+ $where= 'AND';
+ }
+
+ if ($status)
+ {
+ $filtermethod .= " $where
$entity_table.status='$status' ";
+ $where= 'AND';
+ }
+
+
+ $sql .= " $filtermethod";
+//echo $sql;
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ while ($this->db->next_record())
+ {
+ $details[] = array
+ (
+ 'agreement_id' =>
$this->db->f('agreement_id'),
+ 'activity_id' =>
$this->db->f('activity_id'),
+ 'id' =>
$this->db->f('id'),
+ 'num' =>
$this->db->f('num'),
+ 'descr' =>
$this->db->f('descr'),
+ 'unit' =>
$this->db->f('unit'),
+ 'm_cost' =>
$this->db->f('m_cost'),
+ 'w_cost' =>
$this->db->f('w_cost'),
+ 'total_cost' =>
$this->db->f('total_cost'),
+ 'this_index' =>
$this->db->f('this_index'),
+ 'index_count' =>
$this->db->f('index_count'),
+ 'index_date' =>
$GLOBALS['phpgw']->common->show_date($this->db->f('index_date'),$dateformat)
+ );
+ }
+//html_print_r($details);
+ return $details;
+ }
+
+ function read_prizing($data)
+ {
+ if(is_array($data))
+ {
+ $agreement_id =
(isset($data['agreement_id'])?$data['agreement_id']:0);
+ $activity_id =
(isset($data['activity_id'])?$data['activity_id']:0);
+ }
+
+ $entity_table = 'fm_activity_price_index';
+
+ $cols =
"fm_activity_price_index.m_cost,fm_activity_price_index.w_cost,fm_activity_price_index.total_cost,"
+ . "
fm_activity_price_index.index_count,fm_activity_price_index.index_date,fm_activity_price_index.activity_id,fm_activity_price_index.this_index";
+
+ $cols_return[] = 'activity_id';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'activity_id';
+ $uicols['descr'][] =
lang('activity ID');
+ $uicols['statustext'][] = lang('activity ID');
+
+ $cols_return[] = 'id';
+ $uicols['input_type'][] = 'hidden';
+ $uicols['name'][] = 'id';
+ $uicols['descr'][] = False;
+ $uicols['statustext'][] = False;
+
+ $cols_return[] = 'm_cost';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'm_cost';
+ $uicols['descr'][] =
lang('m_cost');
+ $uicols['statustext'][] = lang('m_cost');
+ $cols_return[] = 'w_cost';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'w_cost';
+ $uicols['descr'][] =
lang('w_cost');
+ $uicols['statustext'][] = lang('w_cost');
+ $cols_return[] = 'total_cost';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'total_cost';
+ $uicols['descr'][] =
lang('total_cost');
+ $uicols['statustext'][] = lang('total_cost');
+
+ $cols_return[] = 'this_index';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'this_index';
+ $uicols['descr'][] = lang('index');
+ $uicols['statustext'][] = lang('index');
+
+ $cols_return[] = 'index_count';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'index_count';
+ $uicols['descr'][] =
lang('index_count');
+ $uicols['statustext'][] = lang('index_count');
+
+ $cols_return[] = 'index_date';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'index_date';
+ $uicols['descr'][] = lang('date');
+ $uicols['statustext'][] = lang('date');
+
+ $from .= " FROM $entity_table ";
+
+ $sql = "SELECT $cols $from $joinmethod";
+
+
+ $this->uicols = $uicols;
+
+ $ordermethod = " order by $entity_table.index_count
ASC";
+
+ $where= 'WHERE';
+
+
+ if ($agreement_id)
+ {
+ $filtermethod .= " $where
$entity_table.agreement_id=$agreement_id AND activity_id=$activity_id";
+ $where= 'AND';
+ }
+
+
+ $sql .= " $filtermethod";
+//echo $sql;
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ $j=0;
+ $n=count($cols_return);
+//_debug_array($cols_return);
+ while ($this->db->next_record())
+ {
+ for ($i=0;$i<$n;$i++)
+ {
+ $agreement_list[$j][$cols_return[$i]] =
$this->db->f($cols_return[$i]);
+ $agreement_list[$j]['agreement_id'] =
$agreement_id;
+ }
+ $j++;
+ }
+//_debug_array($agreement_list);
+ return $agreement_list;
+ }
+
+
+ function read_single($data)
+ {
+ $attribute_table = 'fm_agreement_attribute';
+ $table = 'fm_agreement';
+
+ $agreement_id =$data['agreement_id'];
+
+ $this->db->query("SELECT * FROM $attribute_table WHERE
attrib_detail = 1 ORDER BY attrib_sort");
+
+ while ($this->db->next_record())
+ {
+ $agreement['attributes'][] = array
+ (
+ 'attrib_id' =>
$this->db->f('id'),
+ 'name' =>
$this->db->f('column_name'),
+ 'input_text' =>
stripslashes($this->db->f('input_text')),
+ 'statustext' =>
stripslashes($this->db->f('statustext')),
+ 'datatype' =>
$this->db->f('datatype')
+ );
+ }
+
+ if($agreement_id)
+ {
+ $this->db->query("SELECT
$table.*,fm_vendor.member_of FROM $table $this->join fm_vendor ON
$table.vendor_id = fm_vendor.id where $table.id='$agreement_id'");
+
+ if($this->db->next_record())
+ {
+ $agreement['id']
= (int)$this->db->f('id');
+ $agreement['entry_date'] =
$this->db->f('entry_date');
+ $agreement['cat_id'] =
$this->db->f('category');
+ $agreement['start_date'] =
$this->db->f('start_date');
+ $agreement['end_date'] =
$this->db->f('end_date');
+ $agreement['termination_date']=
$this->db->f('termination_date');
+ $agreement['vendor_id'] =
$this->db->f('vendor_id');
+ $agreement['b_account_id'] =
$this->db->f('account_id');
+ $agreement['name']
= stripslashes($this->db->f('name'));
+ $agreement['descr']
= stripslashes($this->db->f('descr'));
+ $agreement['user_id'] =
$this->db->f('user_id');
+ $agreement['group_id'] =
$this->db->f('group_id');
+ $agreement['status'] =
$this->db->f('status');
+ $agreement['member_of'] =
explode(',',$this->db->f('member_of'));
+
+ for
($i=0;$i<count($agreement['attributes']);$i++)
+ {
+
$agreement['attributes'][$i]['value'] =
$this->db->f($agreement['attributes'][$i]['name']);
+
$agreement['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($agreement['attributes'][$i]['datatype']);
+ }
+
+ }
+ }
+//_debug_array($agreement);
+ return $agreement;
+ }
+
+ function read_single_item($data)
+ {
+ $attribute_table = 'fm_agreement_attribute';
+ $table = 'fm_activities';
+
+ $agreement_id =$data['agreement_id'];
+ $id =$data['id'];
+
+ $this->db->query("SELECT * FROM $attribute_table WHERE
attrib_detail = 2 ORDER BY attrib_sort");
+
+ while ($this->db->next_record())
+ {
+ $item['attributes'][] = array
+ (
+ 'attrib_id' =>
$this->db->f('id'),
+ 'name' =>
$this->db->f('column_name'),
+ 'input_text' =>
stripslashes($this->db->f('input_text')),
+ 'statustext' =>
stripslashes($this->db->f('statustext')),
+ 'datatype' =>
$this->db->f('datatype')
+ );
+ }
+
+ if($id && $agreement_id)
+ {
+ $this->db->query("SELECT * from $table
$this->join fm_activity_price_index on $table.id =
fm_activity_price_index.activity_id where $table.id=$id AND
agreement_id=$agreement_id and index_count = 1");
+
+ if($this->db->next_record())
+ {
+ $item['agreement_id'] =
(int)$this->db->f('agreement_id');
+ $item['id']
= (int)$this->db->f('id');
+ $item['num'] =
$this->db->f('num');
+ $item['entry_date'] =
$this->db->f('entry_date');
+ $item['m_cost'] =
$this->db->f('m_cost');
+ $item['w_cost'] =
$this->db->f('w_cost');
+ $item['total_cost'] =
$this->db->f('total_cost');
+
+ for
($i=0;$i<count($item['attributes']);$i++)
+ {
+
$item['attributes'][$i]['value'] =
$this->db->f($item['attributes'][$i]['name']);
+
$item['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($item['attributes'][$i]['datatype']);
+ }
+
+ }
+ }
+ return $item;
+ }
+
+ function add($agreement,$values_attribute='')
+ {
+//_debug_array($agreement);
+ $table = 'fm_agreement';
+ $agreement['name'] =
$this->db->db_addslashes($agreement['name']);
+ $agreement['descr'] =
$this->db->db_addslashes($agreement['descr']);
+
+ if($agreement['member_of'])
+ {
+ $agreement['member_of']=',' .
implode(',',$agreement['member_of']) . ',';
+ }
+
+ $this->db->transaction_begin();
+ $id = $this->bocommon->next_id($table);
+ $vals[] = $id;
+ $vals[] = $agreement['name'];
+ $vals[] = $agreement['descr'];
+ $vals[] = time();
+ $vals[] = $agreement['cat_id'];
+ $vals[] = $agreement['start_date'];
+ $vals[] = $agreement['end_date'];
+ $vals[] = $agreement['termination_date'];
+ $vals[] = $agreement['vendor_id'];
+ $vals[] = $this->account;
+
+
+ while (is_array($agreement['extra']) &&
list($input_name,$value) = each($agreement['extra']))
+ {
+ if($value)
+ {
+ $cols[] = $input_name;
+ $vals[] = $value;
+ }
+ }
+
+ if (isset($values_attribute) AND
is_array($values_attribute))
+ {
+ foreach($values_attribute as $entry)
+ {
+ if($entry['value'])
+ {
+ $cols[] = $entry['name'];
+ $vals[] = $entry['value'];
+ }
+ }
+ }
+
+ $cols[] = 'group_id';
+ $vals[] = $agreement['group_id'];
+ $cols[] = 'status';
+ $vals[] = $agreement['status'];
+
+ if($cols)
+ {
+ $cols = "," . implode(",", $cols);
+ $vals =
$this->bocommon->validate_db_insert($vals);
+ }
+
+ $this->db->query("INSERT INTO $table
(id,name,descr,entry_date,category,start_date,end_date,termination_date,vendor_id,user_id
$cols) "
+ . "VALUES ($vals)",__LINE__,__FILE__);
+
+ $receipt['agreement_id']=
$id;//$this->db->get_last_insert_id($table,'id');
+
+ $receipt['message'][] = array('msg'=>lang('agreement %1
has been saved',$receipt['agreement_id']));
+
+ $this->db->transaction_commit();
+ return $receipt;
+ }
+
+ function add_item($values,$values_attribute='')
+ {
+//_debug_array($values);
+
+ $this->db->transaction_begin();
+
+ $this->db->query("SELECT start_date FROM fm_agreement
WHERE id=" . $values['agreement_id']);
+ $this->db->next_record();
+ $start_date = $this->db->f('start_date');
+
+ $agreement_id = $values['agreement_id'];
+ $activity_id = $values['id'];
+ $m_cost = $this->floatval($values['m_cost']);
+ $w_cost = $this->floatval($values['w_cost']);
+ $total_cost = $this->floatval($values['total_cost']);
+ $entry_date = time();
+
+
+ $sql = "UPDATE fm_activity_price_index SET "
+ . " index_count = 1,current_index =
1,this_index = 1,"
+ . " m_cost = $m_cost,w_cost = $w_cost
,total_cost = $total_cost ,index_date = $start_date,"
+ . " entry_date = $entry_date ,user_id =" .
$this->account . " WHERE agreement_id = $agreement_id AND activity_id =
$activity_id AND index_count = -1";
+
+ $this->db->query($sql);
+
+ $receipt['agreement_id']= $values['agreement_id'];
+ $receipt['id']= $values['id'];
+
+ $receipt['message'][] = array('msg'=>lang('activity %1
has been saved',$receipt['id']));
+
+ $this->db->transaction_commit();
+ return $receipt;
+ }
+
+ function edit($values,$values_attribute='')
+ {
+//_debug_array($values);
+//_debug_array($values_attribute);
+ $table = 'fm_agreement';
+
+ $values['name'] =
$this->db->db_addslashes($values['name']);
+
+ if($values['member_of'])
+ {
+ $values['member_of']=',' .
implode(',',$values['member_of']) . ',';
+ }
+
+ while (is_array($values['extra']) &&
list($column,$value) = each($values['extra']))
+ {
+ $value_set[$column] = $value;
+ }
+
+ if (isset($values_attribute) AND
is_array($values_attribute))
+ {
+ foreach($values_attribute as $entry)
+ {
+ if($entry['datatype']!='AB' &&
$entry['datatype']!='VENDOR')
+ {
+ $value_set[$entry['name']]
= $entry['value'];
+ }
+ }
+ }
+
+ $value_set['name'] = $values['name'];
+ $value_set['descr'] = $values['descr'];
+ $value_set['group_id'] = $values['group_id'];
+ $value_set['status'] = $values['status'];
+ if($value_set)
+ {
+ $value_set = ',' .
$this->bocommon->validate_db_update($value_set);
+ }
+
+ $this->db->query("UPDATE $table set entry_date='" .
time() . "', category='"
+ . $values['cat_id'] .
"', start_date=" . intval($values['start_date']) . ", end_date=" .
intval($values['end_date']) . ", termination_date=" .
intval($values['termination_date']) . "$value_set WHERE id=" .
intval($values['agreement_id']));
+
+ $this->db->query("UPDATE fm_activity_price_index set
index_date=" . intval($values['start_date']) . " WHERE index_count=1 AND
agreement_id= " . intval($values['agreement_id']));
+
+ $receipt['agreement_id']= $values['agreement_id'];
+ $receipt['message'][] = array('msg'=>lang('agreement %1
has been edited',$values['agreement_id']));
+ return $receipt;
+ }
+
+ function edit_item($values)
+ {
+//_debug_array($values);
+
+ $value_set['m_cost'] = $values['m_cost'];
+ $value_set['w_cost'] = $values['w_cost'];
+ $value_set['total_cost'] = $values['total_cost'];
+
+ if($value_set)
+ {
+ $value_set = ',' .
$this->bocommon->validate_db_update($value_set);
+ }
+
+ $this->db->query("UPDATE fm_activity_price_index set
entry_date=" . time() . "$value_set WHERE agreement_id=" .
intval($values['agreement_id']) . ' AND activity_id=' . intval($values['id']));
+
+ $this->db->query("UPDATE fm_activity_price_index set
m_cost = this_index *" . $this->floatval($values['m_cost']) . ",w_cost =
this_index *" . $this->floatval($values['w_cost']) . ",total_cost = this_index
*" . $this->floatval($values['total_cost']) . " WHERE agreement_id=" .
intval($values['agreement_id']) . ' AND activity_id=' . intval($values['id']));
+
+ $receipt['agreement_id']= $values['agreement_id'];
+ $receipt['id']= $values['id'];
+ $receipt['message'][] = array('msg'=>lang('Activity %1
has been edited',$values['id']));
+ return $receipt;
+ }
+
+ function update($values)
+ {
+//_debug_array($values);
+
$values['new_index']=$this->floatval($values['new_index']);
+ $this->db->transaction_begin();
+
+ while (is_array($values['select']) &&
list(,$activity_id) = each($values['select']))
+ {
+
+ if($values['id'][$activity_id]>0)
+ {
+ $this->db->query("UPDATE
fm_activity_price_index set current_index = NULL WHERE agreement_id=" .
intval($values['agreement_id']) . ' AND activity_id=' . intval($activity_id));
+
+ $this->db->query("INSERT INTO
fm_activity_price_index
(agreement_id,activity_id,index_count,current_index,this_index,m_cost,w_cost,total_cost,index_date,entry_date,user_id)"
+ . "VALUES (" .
$values['agreement_id'] . "," . $activity_id ."," .
($values['id'][$activity_id]+1) .",1,'" . $values['new_index'] . "','" .
($values['m_cost'][$activity_id] * $values['new_index']) . "','" .
($values['w_cost'][$activity_id] * $values['new_index']) . "','" .
($values['total_cost'][$activity_id] * $values['new_index']) . "'," .
(int)$values['date'] . "," . time()
+ . "," . $this->account . ")");
+
+ $receipt['message'][] =
array('msg'=>lang('Activity %1 has been updated for index',$activity_id));
+ }
+
+ }
+
+ $this->db->transaction_commit();
+
+ return $receipt;
+ }
+
+ function floatval($strValue)
+ {
+ $floatValue =
ereg_replace("(^[0-9]*)(\\.|,)([0-9]*)(.*)", "\\1.\\3", $strValue);
+ if(!is_numeric($floatValue))
+ {
+ $floatValue = ereg_replace("(^[0-9]*)(.*)",
"\\1", $strValue);
+ }
+ if(!is_numeric($floatValue))
+ {
+ $floatValue = 0;
+ }
+ return $floatValue;
+ }
+
+
+ function delete_last_index($agreement_id,$activity_id)
+ {
+ $this->db->transaction_begin();
+ $this->db->query("SELECT max(index_count) as
index_count FROM fm_activity_price_index WHERE agreement_id=$agreement_id AND
activity_id=$activity_id");
+ $this->db->next_record();
+ $index_count = $this->db->f('index_count');
+ if($index_count>1)
+ {
+ $this->db->query("DELETE FROM
fm_activity_price_index WHERE agreement_id=$agreement_id AND
activity_id=$activity_id AND index_count=$index_count");
+ $this->db->query("UPDATE
fm_activity_price_index set current_index = 1 WHERE agreement_id=$agreement_id
AND activity_id=$activity_id AND index_count =" . ($index_count-1));
+ }
+ else
+ {
+ $sql = "UPDATE fm_activity_price_index SET "
+ . " index_count = -1,current_index =
1,this_index = 1,"
+ . " m_cost = NULL,w_cost = NULL
,total_cost = NULL ,index_date = NULL,"
+ . " entry_date = NULL ,user_id =" .
$this->account . " WHERE agreement_id = $agreement_id AND activity_id =
$activity_id";
+
+ $this->db->query($sql);
+
+ }
+ $this->db->transaction_commit();
+ }
+
+ function delete_item($agreement_id,$activity_id)
+ {
+ $this->db->transaction_begin();
+ $this->db->query("DELETE FROM fm_activity_price_index
WHERE agreement_id=$agreement_id AND activity_id=$activity_id");
+ $this->db->transaction_commit();
+ }
+
+ function delete($agreement_id)
+ {
+ $this->db->transaction_begin();
+ $this->db->query("DELETE FROM fm_agreement WHERE id=" .
intval($agreement_id));
+ $this->db->query("DELETE FROM fm_activity_price_index
WHERE agreement_id=" . intval($agreement_id));
+ $this->db->transaction_commit();
+ }
+
+ function read_attrib($data)
+ {
+ $attribute_table = 'fm_agreement_attribute';
+//html_print_r($data);
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $column_list =
(isset($data['column_list'])?$data['column_list']:'');
+ }
+
+ $where = 'WHERE';
+ if ($column_list)
+ {
+ $filtermethod = " $where list !=1 or list is
null";
+ $where = 'AND';
+ }
+ if ($this->role=='detail')
+ {
+ $filtermethod .= " $where attrib_detail=2 ";
+ }
+ else
+ {
+ $filtermethod .= " $where attrib_detail=1 ";
+ }
+
+ $where = 'AND';
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by attrib_sort asc';
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " $where
($attribute_table.input_text $this->like '%$query%' or
$attribute_table.column_name $this->like '%$query%')";
+ }
+
+ $sql = "SELECT * FROM $attribute_table $filtermethod
$querymethod";
+
+//echo $sql;
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $attrib[] = array
+ (
+ 'id' =>
$this->db->f('id'),
+ 'attrib_sort' =>
$this->db->f('attrib_sort'),
+ 'list' =>
$this->db->f('list'),
+ 'lookup_form' =>
$this->db->f('lookup_form'),
+ 'column_name' =>
$this->db->f('column_name'),
+ 'name' =>
$this->db->f('input_text'),
+ 'size' =>
$this->db->f('size'),
+ 'statustext' =>
$this->db->f('statustext'),
+ 'input_text' =>
$this->db->f('input_text'),
+ 'type_name' =>
$this->db->f('type'),
+ 'datatype' =>
$this->db->f('datatype'),
+ 'search' =>
$this->db->f('search')
+ );
+ }
+ return $attrib;
+ }
+
+ function read_single_attrib($id)
+ {
+ $attribute_table = 'fm_agreement_attribute';
+
+ if ($this->role=='detail')
+ {
+ $filtermethod = " AND attrib_detail=2 ";
+ }
+ else
+ {
+ $filtermethod = " AND attrib_detail=1 ";
+ }
+
+ $sql = "SELECT * FROM $attribute_table where id=$id
$filtermethod";
+
+ $this->db->query($sql);
+
+ if($this->db->next_record())
+ {
+ $attrib['id']
= $this->db->f('id');
+ $attrib['column_name']
= $this->db->f('column_name');
+ $attrib['input_text']
= $this->db->f('input_text');
+ $attrib['statustext']
= $this->db->f('statustext');
+ $attrib['column_info']['precision'] =
$this->db->f('precision_');
+ $attrib['column_info']['scale'] =
$this->db->f('scale');
+ $attrib['column_info']['default'] =
$this->db->f('default_value');
+ $attrib['column_info']['nullable'] =
$this->db->f('nullable');
+ $attrib['column_info']['type'] =
$this->db->f('datatype');
+ $attrib['type_name']
= $this->db->f('type_name');
+ $attrib['lookup_form']
= $this->db->f('lookup_form');
+ $attrib['list']
= $this->db->f('list');
+ $attrib['search']
= $this->db->f('search');
+ if($this->db->f('datatype')=='R' ||
$this->db->f('datatype')=='CH' || $this->db->f('datatype')=='LB')
+ {
+ $attrib['choice'] =
$this->read_attrib_choice($id);
+ }
+
+ return $attrib;
+ }
+ }
+
+ function read_attrib_choice($attrib_id)
+ {
+ $choice_table = 'fm_agreement_choice';
+
+ if ($this->role=='detail')
+ {
+ $filtermethod = " AND attrib_detail=2 ";
+ }
+ else
+ {
+ $filtermethod = " AND attrib_detail=1 ";
+ }
+
+ $sql = "SELECT * FROM $choice_table WHERE
attrib_id=$attrib_id $filtermethod";
+ $this->db->query($sql);
+
+ while ($this->db->next_record())
+ {
+ $choice[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'value' => $this->db->f('value')
+ );
+
+ }
+ return $choice;
+ }
+
+ function add_attrib($attrib)
+ {
+ $attribute_table = 'fm_agreement_attribute';
+ $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
+ $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
+ $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
+ $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
+ $attrib['id'] =
$this->bocommon->next_id($attribute_table, array('attrib_detail'=>!!$this->role
+1));
+
+ if($this->role=='detail')
+ {
+ $filtermethod= 'WHERE attrib_detail=2';
+ $table = 'fm_agreement_detail';
+ }
+ else
+ {
+ $filtermethod= 'WHERE attrib_detail=1';
+ $table = 'fm_agreement';
+ }
+ $sql = "SELECT max(attrib_sort) as max_sort FROM
$attribute_table $filtermethod";
+ $this->db->query($sql);
+ $this->db->next_record();
+ $attrib_sort = $this->db->f('max_sort')+1;
+
+ $values= array(
+ !!$this->role +1,
+ $attrib['id'],
+ $attrib['column_name'],
+ $attrib['input_text'],
+ $attrib['statustext'],
+ $attrib['lookup_form'],
+ $attrib['search'],
+ $attrib['list'],
+ $attrib_sort,
+ $attrib['column_info']['type'],
+ $attrib['column_info']['precision'],
+ $attrib['column_info']['scale'],
+ $attrib['column_info']['default'],
+ $attrib['column_info']['nullable']
+ );
+
+ $values = $this->bocommon->validate_db_insert($values);
+
+ $this->db->transaction_begin();
+
+ $this->db->query("INSERT INTO $attribute_table
(attrib_detail,id,column_name, input_text,
statustext,lookup_form,search,list,attrib_sort,datatype,precision_,scale,default_value,nullable)
"
+ . "VALUES ($values)");
+
+ $receipt['id']= $attrib['id'];
+
+ if($attrib['column_info']['type']=='email' &&
!$attrib['column_info']['precision'])
+ {
+ $attrib['column_info']['precision']=64;
+ }
+
+ $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
+
+ if($attrib['column_info']['type']=='int' &&
!$attrib['column_info']['precision'])
+ {
+ $attrib['column_info']['precision']=4;
+ }
+
+ if(!$attrib['column_info']['default'])
+ {
+ unset($attrib['column_info']['default']);
+ }
+
+ $this->init_process();
+
+
if($this->oProc->AddColumn($table,$attrib['column_name'],
$attrib['column_info']))
+ {
+ $receipt['message'][] = array('msg' =>
lang('Attribute has been saved') );
+ $this->db->transaction_commit();
+
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('column could not be added') );
+ if($this->db->Transaction)
+ {
+ $GLOBALS['phpgw']->db->rollbacktrans();
+ }
+ else
+ {
+ $GLOBALS['phpgw']->db->Execute("DELETE
FROM $attribute_table WHERE id='" . $receipt['id'] . "'");
+ unset($receipt['id']);
+
+ }
+ }
+
+ return $receipt;
+ }
+
+ function init_process()
+ {
+ $this->oProc
=
CreateObject('phpgwapi.schema_proc',$GLOBALS['phpgw_info']['server']['db_type']);
+ $this->oProc->m_odb
= $this->db;
+ $this->oProc->m_odb->Halt_On_Error = 'report';
+ }
+
+ function edit_attrib($attrib)
+ {
+ $attribute_table = 'fm_agreement_attribute';
+ $table = 'fm_agreement';
+
+ $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
+ $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
+ $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
+ $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
+
+ $choice_table = 'fm_agreement_choice';
+
+ if($this->role=='detail')
+ {
+ $filtermethod= ' AND attrib_detail=2';
+ $table = 'fm_agreement_detail';
+ }
+ else
+ {
+ $filtermethod= ' AND attrib_detail=1';
+ $table = 'fm_agreement';
+ }
+
+ $this->db->query("SELECT column_name FROM
$attribute_table WHERE id='" . $attrib['id']. "' $filtermethod");
+ $this->db->next_record();
+ $OldColumnName = $this->db->f('column_name');
+
+ $this->db->transaction_begin();
+
+ $attrib_type=$attrib['column_info']['type'];
+ if(($OldColumnName !=$attrib['column_name']) ||
($attrib['column_info']['type'] != $this->db->f('datatype')))
+ {
+ $value_set=array(
+ 'column_name' =>
$attrib['column_name'],
+ 'input_text' =>
$attrib['input_text'],
+ 'statustext' =>
$attrib['statustext'],
+ 'lookup_form' =>
$attrib['lookup_form'],
+ 'search' =>
$attrib['search'],
+ 'list' =>
$attrib['list'],
+ 'datatype' =>
$attrib['column_info']['type'],
+ 'precision_' =>
$attrib['column_info']['precision'],
+ 'scale' =>
$attrib['column_info']['scale'],
+ 'default_value' =>
$attrib['column_info']['default'],
+ 'nullable' =>
$attrib['column_info']['nullable']
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE $attribute_table set
$value_set WHERE id=" . $attrib['id'] . $filtermethod);
+
+ if($attrib['column_info']['type']=='email' &&
!$attrib['column_info']['precision'])
+ {
+ $attrib['column_info']['precision']=64;
+ }
+
+ $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
+
+ if($attrib['column_info']['type']=='int' &&
!$attrib['column_info']['precision'])
+ {
+ $attrib['column_info']['precision']=4;
+ }
+
+ if(!$attrib['column_info']['default'])
+ {
+
unset($attrib['column_info']['default']);
+ }
+
+ $this->init_process();
+
+
$this->oProc->AlterColumn($table,$OldColumnName,$attrib['column_name'],$attrib['column_info']);
+
+ }
+
+
+ if($attrib['new_choice'])
+ {
+ $this->db->query("SELECT max(id) as id FROM
$choice_table WHERE attrib_id='" . $attrib['id']. "' $filtermethod");
+ $this->db->next_record();
+ $choice_id = $this->db->f('id')+1;
+
+ // $choice_id =
$this->bocommon->next_id($choice_table
,array('attrib_detail'=>2,'attrib_id'=>$attrib['id']));
+
+ $values= array(
+ $attrib['id'],
+ $choice_id,
+ !!$this->role +1,
+ $attrib['new_choice']
+ );
+
+ $values =
$this->bocommon->validate_db_insert($values);
+
+ $this->db->query("INSERT INTO $choice_table
(attrib_id,id,attrib_detail,value) "
+ . "VALUES ($values)");
+ }
+
+
+ if($attrib['delete_choice'])
+ {
+ for
($i=0;$i<count($attrib['delete_choice']);$i++)
+ {
+ $this->db->query("DELETE FROM
$choice_table WHERE attrib_id=" . $attrib['id'] ." AND id=" .
$attrib['delete_choice'][$i] . $filtermethod);
+ }
+ }
+
+//html_print_r($attrib_type);
+ if($attrib_type!='R' && $attrib_type!='CH' &&
$attrib_type!='LB')
+ {
+ $this->db->query("DELETE FROM $choice_table
WHERE attrib_id=" . $attrib['id'] . $filtermethod);
+ }
+
+
+ $this->db->transaction_commit();
+
+ $receipt['message'][] = array('msg' =>
lang('Attribute has been edited'));
+
+
+ return $receipt;
+
+ }
+ function resort_attrib($data)
+ {
+//html_print_r($data);
+ $attribute_table = 'fm_agreement_attribute';
+ if(is_array($data))
+ {
+ $resort =
(isset($data['resort'])?$data['resort']:'up');
+ $id = (isset($data['id'])?$data['id']:'');
+ }
+
+ $sql = "SELECT attrib_sort FROM $attribute_table where
id=$id";
+ $this->db->query($sql);
+ $this->db->next_record();
+ $attrib_sort = $this->db->f('attrib_sort');
+ $sql = "SELECT max(attrib_sort) as max_sort FROM
$attribute_table";
+ $this->db->query($sql);
+ $this->db->next_record();
+ $max_sort = $this->db->f('max_sort');
+ switch($resort)
+ {
+ case 'up':
+ if($attrib_sort>1)
+ {
+ $sql = "UPDATE $attribute_table
set attrib_sort=$attrib_sort WHERE attrib_sort =" . ($attrib_sort-1);
+ $this->db->query($sql);
+ $sql = "UPDATE $attribute_table
set attrib_sort=" . ($attrib_sort-1) ." WHERE id=$id";
+ $this->db->query($sql);
+ }
+ break;
+ case 'down':
+ if($max_sort > $attrib_sort)
+ {
+ $sql = "UPDATE $attribute_table
set attrib_sort=$attrib_sort WHERE attrib_sort =" . ($attrib_sort+1);
+ $this->db->query($sql);
+ $sql = "UPDATE $attribute_table
set attrib_sort=" . ($attrib_sort+1) ." WHERE id=$id";
+ $this->db->query($sql);
+ }
+ break;
+ default:
+ return;
+ break;
+ }
+ }
+ function delete_attrib($attrib_id)
+ {
+ $table = 'fm_agreement';
+ $attribute_table = 'fm_agreement_attribute';
+ $this->init_process();
+
+ $sql = "SELECT * FROM $attribute_table WHERE
id=$attrib_id";
+
+ $this->db->query($sql);
+ $this->db->next_record();
+ $ColumnName = $this->db->f('column_name');
+
+ if($this->oProc->DropColumn($table,'', $ColumnName))
+ {
+ $sql = "SELECT attrib_sort FROM
$attribute_table where id=$attrib_id";
+ $this->db->query($sql);
+ $this->db->next_record();
+ $attrib_sort = $this->db->f('attrib_sort');
+ $sql2 = "SELECT max(attrib_sort) as max_sort
FROM $attribute_table";
+ $this->db->query($sql2);
+ $this->db->next_record();
+ $max_sort = $this->db->f('max_sort');
+ if($max_sort>$attrib_sort)
+ {
+ $sql = "UPDATE $attribute_table set
attrib_sort=attrib_sort-1 WHERE attrib_sort > $attrib_sort";
+ $this->db->query($sql);
+ }
+
+ $this->db->query("DELETE FROM $attribute_table
WHERE id=$attrib_id");
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('Attribute has NOT been deleted'));
+ }
+
+ return $receipt;
+ }
+
+ function request_next_id()
+ {
+ $this->db->query("SELECT max(id) as id FROM
fm_agreement");
+ $this->db->next_record();
+ $next_id= $this->db->f('id')+1;
+ return $next_id;
+ }
+
+ function get_agreement_group_list()
+ {
+ $this->db->query("SELECT * FROM fm_agreement_group
ORDER BY descr asc");
+ while ($this->db->next_record())
+ {
+ $agreement_group_list[]=array
+ (
+ 'id' => $this->db->f('id'),
+ 'name' =>
$GLOBALS['phpgw']->strip_html($this->db->f('descr')).' [ '.
$GLOBALS['phpgw']->strip_html($this->db->f('status')).' ] '
+ );
+ }
+ return $agreement_group_list;
+ }
+
+ function read_group_activity($group_id='',$agreement_id='')
+ {
+ $uicols['name'][] = 'id';
+ $uicols['descr'][] = lang('ID');
+ $uicols['name'][] = 'num';
+ $uicols['descr'][] = lang('Num');
+ $uicols['name'][] = 'base_descr';
+ $uicols['descr'][] = lang('Base');
+ $uicols['name'][] = 'descr';
+ $uicols['descr'][] = lang('Descr');
+ $uicols['name'][] = 'unit';
+ $uicols['descr'][] = lang('Unit');
+ $uicols['name'][] = 'ns3420';
+ $uicols['descr'][] =
lang('ns3420');
+
+ $this->uicols = $uicols;
+
+ $sql="SELECT fm_activities.* FROM fm_activities WHERE
agreement_group_id = $group_id";
+ $this->db->query($sql);
+
+ while ($this->db->next_record())
+ {
+ $activity_list[$this->db->f('id')]=array
+ (
+ 'id' => $this->db->f('id'),
+ 'num' => $this->db->f('num'),
+ 'base_descr' =>
$this->db->f('base_descr'),
+ 'descr' =>
$this->db->f('descr'),
+ 'unit' => $this->db->f('unit'),
+ 'ns3420' =>
$this->db->f('ns3420'),
+ );
+ }
+
+ $sql="SELECT activity_id FROM fm_activity_price_index
WHERE agreement_id = $agreement_id";
+
+ $this->db->query($sql);
+
+ while ($this->db->next_record())
+ {
+
unset($activity_list[$this->db->f('activity_id')]);
+ }
+
+ foreach($activity_list as $entry)
+ {
+ $activity_list_result[] = $entry;
+ }
+
+ return $activity_list_result;
+ }
+
+ function add_activity($values='',$agreement_id='')
+ {
+ if (isset($values['select']) AND
is_array($values['select']))
+ {
+ $this->db->transaction_begin();
+
+ $this->db->query("SELECT start_date FROM
fm_agreement WHERE id=" . $values['agreement_id']);
+ $this->db->next_record();
+ $date = $this->db->f('start_date');
+
+ foreach($values['select'] as $activity_id)
+ {
+ $this->db->query("INSERT INTO
fm_activity_price_index ( agreement_id,
activity_id,index_count,current_index,index_date,entry_date,user_id) "
+ . "VALUES
($agreement_id,$activity_id,-1,1,$date," . time() . "," . $this->account . ")");
+ }
+
+ $this->db->transaction_commit();
+ }
+
+
+ $receipt['agreement_id']=
$id;//$this->db->get_last_insert_id($table,'id');
+
+ $receipt['message'][] = array('msg'=>lang('agreement %1
has been saved',$receipt['agreement_id']));
+
+ return $receipt;
+ }
+
+ function select_status_list()
+ {
+ $this->db->query("SELECT id, descr FROM
fm_agreement_status ORDER BY id ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $status_entries[$i]['id']
= $this->db->f('id');
+ $status_entries[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $status_entries;
+ }
+
+ function get_activity_descr($id)
+ {
+ $this->db->query("SELECT descr FROM fm_activities WHERE
id = $id",__LINE__,__FILE__);
+ $this->db->next_record();
+ return stripslashes($this->db->f('descr'));
+ }
+
+ }
+?>
Index: property/inc/class.soalarm.inc.php
diff -u property/inc/class.soalarm.inc.php:1.5
property/inc/class.soalarm.inc.php:1.6
--- property/inc/class.soalarm.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/class.soalarm.inc.php Fri Jan 27 14:05:43 2006
@@ -1,243 +1,242 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.soalarm.inc.php,v 1.5 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class soalarm
- {
-
- function soalarm()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
-
- $this->join = $this->socommon->join;
- $this->like = $this->socommon->like;
- }
-
- function select_method_list()
- {
- $this->db->query("SELECT id,name,data FROM
fm_async_method ORDER BY name ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- if($this->db->f('data'))
- {
- $method_data=array();
- $data_set =
unserialize($this->db->f('data'));
- while (is_array($data_set) &&
list($key,$value) = each($data_set))
- {
- $method_data[] = $key . '=' .
$value;
- }
-
- $method_data= @implode
(',',$method_data);
- }
-
- $categories[$i]['id']
= $this->db->f('id');
- $categories[$i]['name']
= stripslashes($this->db->f('name')) . '(' . $method_data . ')';
- $i++;
- }
- return $categories;
- }
-
- function read_single_method($id)
- {
- $this->db->query("SELECT name FROM fm_async_method
where id='$id'");
- $this->db->next_record();
- return $this->db->f('name');
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- $id = (isset($data['id'])?$data['id']:0);
- $start =
(isset($data['start'])?$data['start']:0);
- $filter =
(isset($data['filter'])?$data['filter']:'');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by id DESC';
- }
-
- $where = 'WHERE';
- if ($filter > 0)
- {
- $filtermethod .= " $where owner='$filter' ";
- $where = 'AND';
-
- }
-
- $id = $this->db->db_addslashes($id);
- if (strpos($id,'%') !== False || strpos($id,'_') !==
False)
- {
- $filtermethod = "$where id $this->like '%$id%'
AND id!='##last-check-run##'";
- }
- elseif (!$id)
- {
- $filtermethod = $where . ' next<='.time()." AND
id!='##last-check-run##'";
- }
- else
- {
- $filtermethod = "$where id='$id'";
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " AND (account_lid $this->like
'%$query%' OR method $this->like '%$query%' OR id $this->like '%$query%')";
- }
-
- $sql = "SELECT
phpgw_async.id,phpgw_async.next,phpgw_async.times,phpgw_async.method,phpgw_async.data,account_lid
FROM phpgw_async $this->join phpgw_accounts on
phpgw_async.account_id=phpgw_accounts.account_id $filtermethod $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- $jobs = array();
- while ($this->db->next_record())
- {
- $id = $this->db->f('id');
- $data = unserialize($this->db->f('data'));
-
- $jobs[$id] = array(
- 'id' => $id,
- 'next' => $this->db->f('next'),
- 'times' =>
unserialize($this->db->f('times')),
- 'method' => $this->db->f('method'),
- 'data' => $data,
- 'enabled' => (int)$data['enabled'],
- 'user' => $this->db->f('account_lid')
- );
- }
- if (!count($jobs))
- {
- return False;
- }
- return $jobs;
- }
-
- function read_org($id=0)
- {
- $id = $this->db->db_addslashes($id);
- if (strpos($id,'%') !== False || strpos($id,'_') !==
False)
- {
- $where = "id $this->like '%$id%' AND
id!='##last-check-run##'";
- }
- elseif (!$id)
- {
- $where = 'next<='.time()." AND
id!='##last-check-run##'";
- }
- else
- {
- $where = "id='$id'";
- }
- $this->db->query($sql="SELECT * FROM $this->db_table
WHERE $where",__LINE__,__FILE__);
-
- $jobs = array();
- while ($this->db->next_record())
- {
- $id = $this->db->f('id');
-
- $jobs[$id] = array(
- 'id' => $id,
- 'next' => $this->db->f('next'),
- 'times' =>
unserialize($this->db->f('times')),
- 'method' => $this->db->f('method'),
- 'data' =>
unserialize($this->db->f('data')),
- 'account_id' =>
$this->db->f('account_id')
- );
- //echo "job id='$id'<pre>";
print_r($jobs[$id]); echo "</pre>\n";
- }
- if (!count($jobs))
- {
- return False;
- }
- return $jobs;
- }
-
-
- function read_single($owner_id)
- {
- $this->db->query("select * from fm_owner where
owner_id='$owner_id'",__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $owner['id'] =
(int)$this->db->f('owner_id');
- $owner['abid'] =
$this->db->f('abid');
- $owner['contact_name'] =
stripslashes($this->db->f('contact_name'));
- $owner['remark'] =
stripslashes($this->db->f('remark'));
- $owner['entry_date'] =
$this->db->f('entry_date');
- $owner['cat_id'] =
(int)$this->db->f('category');
-
- return $owner;
- }
- }
-
- function add($owner)
- {
- $owner['name'] =
$this->db->db_addslashes($owner['name']);
-
- $this->db->query("INSERT INTO fm_owner
(entry_date,remark,abid,contact_name,category) "
- . "VALUES ('" . time() . "','" .
$owner['remark'] . "','" . $owner['abid'] . "','" . $owner['contact_name']
- . "','" . $owner['cat_id'] .
"')",__LINE__,__FILE__);
-
- $receipt['owner_id']=
$this->db->get_last_insert_id('fm_owner','owner_id');
- $receipt['message'][] = array('msg'=>lang('owner %1 has
been saved',$receipt['owner_id']));
- return $receipt;
- }
-
- function edit($owner)
- {
- $owner['name'] =
$this->db->db_addslashes($owner['name']);
-
- $this->db->query("UPDATE fm_owner set remark='" .
$owner['remark'] . "', entry_date='" . time() . "', abid='" . $owner['abid'] .
"', contact_name='" . $owner['contact_name'] . "', category='"
- . $owner['cat_id'] . "'
WHERE owner_id=" . intval($owner['owner_id']),__LINE__,__FILE__);
-
- $receipt['owner_id']= $owner['owner_id'];
- $receipt['message'][] = array('msg'=>lang('owner %1 has
been edited',$owner['owner_id']));
- return $receipt;
- }
-
- function delete($owner_id)
- {
- $this->db->query('DELETE FROM fm_owner WHERE owner_id='
. intval($owner_id),__LINE__,__FILE__);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.soalarm.inc.php,v 1.6 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class soalarm
+ {
+
+ function soalarm()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->like = $this->bocommon->like;
+ }
+
+ function select_method_list()
+ {
+ $this->db->query("SELECT id,name,data FROM
fm_async_method ORDER BY name ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ if($this->db->f('data'))
+ {
+ $method_data=array();
+ $data_set =
unserialize($this->db->f('data'));
+ while (is_array($data_set) &&
list($key,$value) = each($data_set))
+ {
+ $method_data[] = $key . '=' .
$value;
+ }
+
+ $method_data= @implode
(',',$method_data);
+ }
+
+ $categories[$i]['id']
= $this->db->f('id');
+ $categories[$i]['name']
= stripslashes($this->db->f('name')) . '(' . $method_data . ')';
+ $i++;
+ }
+ return $categories;
+ }
+
+ function read_single_method($id)
+ {
+ $this->db->query("SELECT name FROM fm_async_method
where id='$id'");
+ $this->db->next_record();
+ return $this->db->f('name');
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ $id = (isset($data['id'])?$data['id']:0);
+ $start =
(isset($data['start'])?$data['start']:0);
+ $filter =
(isset($data['filter'])?$data['filter']:'');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by id DESC';
+ }
+
+ $where = 'WHERE';
+ if ($filter > 0)
+ {
+ $filtermethod .= " $where owner='$filter' ";
+ $where = 'AND';
+
+ }
+
+ $id = $this->db->db_addslashes($id);
+ if (strpos($id,'%') !== False || strpos($id,'_') !==
False)
+ {
+ $filtermethod = "$where id $this->like '%$id%'
AND id!='##last-check-run##'";
+ }
+ elseif (!$id)
+ {
+ $filtermethod = $where . ' next<='.time()." AND
id!='##last-check-run##'";
+ }
+ else
+ {
+ $filtermethod = "$where id='$id'";
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " AND (account_lid $this->like
'%$query%' OR method $this->like '%$query%' OR id $this->like '%$query%')";
+ }
+
+ $sql = "SELECT
phpgw_async.id,phpgw_async.next,phpgw_async.times,phpgw_async.method,phpgw_async.data,account_lid
FROM phpgw_async $this->join phpgw_accounts on
phpgw_async.account_id=phpgw_accounts.account_id $filtermethod $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ $jobs = array();
+ while ($this->db->next_record())
+ {
+ $id = $this->db->f('id');
+ $data = unserialize($this->db->f('data'));
+
+ $jobs[$id] = array(
+ 'id' => $id,
+ 'next' => $this->db->f('next'),
+ 'times' =>
unserialize($this->db->f('times')),
+ 'method' => $this->db->f('method'),
+ 'data' => $data,
+ 'enabled' => (int)$data['enabled'],
+ 'user' => $this->db->f('account_lid')
+ );
+ }
+ if (!count($jobs))
+ {
+ return False;
+ }
+ return $jobs;
+ }
+
+ function read_org($id=0)
+ {
+ $id = $this->db->db_addslashes($id);
+ if (strpos($id,'%') !== False || strpos($id,'_') !==
False)
+ {
+ $where = "id $this->like '%$id%' AND
id!='##last-check-run##'";
+ }
+ elseif (!$id)
+ {
+ $where = 'next<='.time()." AND
id!='##last-check-run##'";
+ }
+ else
+ {
+ $where = "id='$id'";
+ }
+ $this->db->query($sql="SELECT * FROM $this->db_table
WHERE $where",__LINE__,__FILE__);
+
+ $jobs = array();
+ while ($this->db->next_record())
+ {
+ $id = $this->db->f('id');
+
+ $jobs[$id] = array(
+ 'id' => $id,
+ 'next' => $this->db->f('next'),
+ 'times' =>
unserialize($this->db->f('times')),
+ 'method' => $this->db->f('method'),
+ 'data' =>
unserialize($this->db->f('data')),
+ 'account_id' =>
$this->db->f('account_id')
+ );
+ //echo "job id='$id'<pre>";
print_r($jobs[$id]); echo "</pre>\n";
+ }
+ if (!count($jobs))
+ {
+ return False;
+ }
+ return $jobs;
+ }
+
+
+ function read_single($owner_id)
+ {
+ $this->db->query("select * from fm_owner where
owner_id='$owner_id'",__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $owner['id'] =
(int)$this->db->f('owner_id');
+ $owner['abid'] =
$this->db->f('abid');
+ $owner['contact_name'] =
stripslashes($this->db->f('contact_name'));
+ $owner['remark'] =
stripslashes($this->db->f('remark'));
+ $owner['entry_date'] =
$this->db->f('entry_date');
+ $owner['cat_id'] =
(int)$this->db->f('category');
+
+ return $owner;
+ }
+ }
+
+ function add($owner)
+ {
+ $owner['name'] =
$this->db->db_addslashes($owner['name']);
+
+ $this->db->query("INSERT INTO fm_owner
(entry_date,remark,abid,contact_name,category) "
+ . "VALUES ('" . time() . "','" .
$owner['remark'] . "','" . $owner['abid'] . "','" . $owner['contact_name']
+ . "','" . $owner['cat_id'] .
"')",__LINE__,__FILE__);
+
+ $receipt['owner_id']=
$this->db->get_last_insert_id('fm_owner','owner_id');
+ $receipt['message'][] = array('msg'=>lang('owner %1 has
been saved',$receipt['owner_id']));
+ return $receipt;
+ }
+
+ function edit($owner)
+ {
+ $owner['name'] =
$this->db->db_addslashes($owner['name']);
+
+ $this->db->query("UPDATE fm_owner set remark='" .
$owner['remark'] . "', entry_date='" . time() . "', abid='" . $owner['abid'] .
"', contact_name='" . $owner['contact_name'] . "', category='"
+ . $owner['cat_id'] . "'
WHERE owner_id=" . intval($owner['owner_id']),__LINE__,__FILE__);
+
+ $receipt['owner_id']= $owner['owner_id'];
+ $receipt['message'][] = array('msg'=>lang('owner %1 has
been edited',$owner['owner_id']));
+ return $receipt;
+ }
+
+ function delete($owner_id)
+ {
+ $this->db->query('DELETE FROM fm_owner WHERE owner_id='
. intval($owner_id),__LINE__,__FILE__);
+ }
+ }
+?>
Index: property/inc/class.soasync.inc.php
diff -u property/inc/class.soasync.inc.php:1.4
property/inc/class.soasync.inc.php:1.5
--- property/inc/class.soasync.inc.php:1.4 Thu May 12 21:26:28 2005
+++ property/inc/class.soasync.inc.php Fri Jan 27 14:05:43 2006
@@ -1,151 +1,149 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.soasync.inc.php,v 1.4 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class soasync
- {
-
- function soasync()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
-
- $this->join = $this->socommon->join;
- $this->like = $this->socommon->like;
-
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by id asc';
- }
-
- $table='fm_async_method';
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " where id $this->like
'%$query%' or descr $this->like '%$query%'";
- }
-
- $sql = "SELECT * FROM $table $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $method[] = array
- (
- 'id' => $this->db->f('id'),
- 'name' => $this->db->f('name'),
- 'data' => $this->db->f('data'),
- 'descr' => $this->db->f('descr')
- );
- }
- return $method;
- }
-
-
- function read_single($id)
- {
- $table='fm_async_method';
-
- $sql = "SELECT * FROM $table where id='$id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $method['id'] = $this->db->f('id');
- $method['name'] = $this->db->f('name');
- $method['data'] = $this->db->f('data');
- $method['descr'] = $this->db->f('descr');
-
- return $method;
- }
- }
-
- function add($method)
- {
- $table='fm_async_method';
-
- $method['id'] = $this->socommon->next_id($table);
- $method['name'] =
$this->db->db_addslashes($method['name']);
- $method['descr'] =
$this->db->db_addslashes($method['descr']);
-
- $this->db->query("INSERT INTO $table (id, name,data,
descr) "
- . "VALUES ('" . $method['id'] . "','" .
$method['name'] . "','" . $method['data'] . "','" . $method['descr'].
"')",__LINE__,__FILE__);
-
- $receipt['id'] = $method['id'];
- $receipt['message'][] = array('msg' => lang('async
method has been saved'));
-
- return $receipt;
- }
-
- function edit($method)
- {
-
- $table='fm_async_method';
-
- $method['name'] =
$this->db->db_addslashes($method['name']);
- $method['descr'] =
$this->db->db_addslashes($method['descr']);
-
- $this->db->query("UPDATE $table set descr='" .
$method['descr'] . "', name='". $method['name'] . "', data='". $method['data']
- . "' WHERE id='" .
$method['id']. "'",__LINE__,__FILE__);
-
- $receipt['id'] = $method['id'];
- $receipt['message'][] = array('msg' =>lang('method has
been edited'));
- return $receipt;
- }
-
- function delete($id)
- {
- $table='fm_async_method';
-
- $this->db->query("DELETE FROM $table WHERE id='" . $id
. "'",__LINE__,__FILE__);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.soasync.inc.php,v 1.5 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class soasync
+ {
+
+ function soasync()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->like = $this->bocommon->like;
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by id asc';
+ }
+
+ $table='fm_async_method';
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " where id $this->like
'%$query%' or descr $this->like '%$query%'";
+ }
+
+ $sql = "SELECT * FROM $table $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $method[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'name' => $this->db->f('name'),
+ 'data' => $this->db->f('data'),
+ 'descr' => $this->db->f('descr')
+ );
+ }
+ return $method;
+ }
+
+
+ function read_single($id)
+ {
+ $table='fm_async_method';
+
+ $sql = "SELECT * FROM $table where id='$id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $method['id'] = $this->db->f('id');
+ $method['name'] = $this->db->f('name');
+ $method['data'] = $this->db->f('data');
+ $method['descr'] = $this->db->f('descr');
+
+ return $method;
+ }
+ }
+
+ function add($method)
+ {
+ $table='fm_async_method';
+
+ $method['id'] = $this->socommon->next_id($table);
+ $method['name'] =
$this->db->db_addslashes($method['name']);
+ $method['descr'] =
$this->db->db_addslashes($method['descr']);
+
+ $this->db->query("INSERT INTO $table (id, name,data,
descr) "
+ . "VALUES ('" . $method['id'] . "','" .
$method['name'] . "','" . $method['data'] . "','" . $method['descr'].
"')",__LINE__,__FILE__);
+
+ $receipt['id'] = $method['id'];
+ $receipt['message'][] = array('msg' => lang('async
method has been saved'));
+
+ return $receipt;
+ }
+
+ function edit($method)
+ {
+
+ $table='fm_async_method';
+
+ $method['name'] =
$this->db->db_addslashes($method['name']);
+ $method['descr'] =
$this->db->db_addslashes($method['descr']);
+
+ $this->db->query("UPDATE $table set descr='" .
$method['descr'] . "', name='". $method['name'] . "', data='". $method['data']
+ . "' WHERE id='" .
$method['id']. "'",__LINE__,__FILE__);
+
+ $receipt['id'] = $method['id'];
+ $receipt['message'][] = array('msg' =>lang('method has
been edited'));
+ return $receipt;
+ }
+
+ function delete($id)
+ {
+ $table='fm_async_method';
+
+ $this->db->query("DELETE FROM $table WHERE id='" . $id
. "'",__LINE__,__FILE__);
+ }
+ }
+?>
Index: property/inc/class.sob_account.inc.php
diff -u property/inc/class.sob_account.inc.php:1.6
property/inc/class.sob_account.inc.php:1.7
--- property/inc/class.sob_account.inc.php:1.6 Thu May 12 21:26:28 2005
+++ property/inc/class.sob_account.inc.php Fri Jan 27 14:05:43 2006
@@ -1,150 +1,150 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.sob_account.inc.php,v 1.6 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class sob_account
- {
-
- function sob_account()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
- $this->like = $this->socommon->like;
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by id asc';
- }
-
- $table = 'fm_b_account';
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " where id $this->like
'%$query%' or descr $this->like '%$query%'";
- }
-
- $sql = "SELECT * FROM $table $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $b_account[] = array
- (
- 'id' => $this->db->f('id'),
- 'descr' =>
$this->db->f('descr')
- );
- }
- return $b_account;
- }
-
- function read_single($id)
- {
-
- $table = 'fm_b_account';
-
- $sql = "SELECT * FROM $table where id='$id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $b_account['id'] =
$this->db->f('id');
- $b_account['descr'] =
$this->db->f('descr');
- $b_account['group'] =
$this->db->f('grouping');
- $b_account['responsible'] =
$this->db->f('responsible');
-
- return $b_account;
- }
- }
-
- function add($b_account)
- {
- $table = 'fm_b_account';
-
- $b_account['descr'] =
$this->db->db_addslashes($b_account['descr']);
-
- $this->db->query("INSERT INTO $table (id,
descr,grouping,responsible) "
- . "VALUES ('" . $b_account['id'] . "','" .
$b_account['descr']. "','" . substr($b_account['id'],0,2) . "','" .
$b_account['responsible'] . "')",__LINE__,__FILE__);
-
- $receipt['message'][]=array('msg'=>lang('budget account
%1 has been saved',$b_account['id']));
- return $receipt;
- }
-
- function edit($b_account)
- {
-
- $table = 'fm_b_account';
-
- $b_account['descr'] =
$this->db->db_addslashes($b_account['descr']);
-
- $this->db->query("UPDATE $table set descr='" .
$b_account['descr'] . "',responsible='" . $b_account['responsible']
- . "' WHERE id='" .
$b_account['id']. "'",__LINE__,__FILE__);
-
-
- $receipt['message'][]=array('msg'=>lang('budget account
%1 has been edited',$b_account['id']));
- return $receipt;
- }
-
- function delete($id)
- {
- $table = 'fm_b_account';
-
- $this->db->query("DELETE FROM $table WHERE id='" . $id
. "'",__LINE__,__FILE__);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.sob_account.inc.php,v 1.7 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class sob_account
+ {
+
+ function sob_account()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->like = $this->bocommon->like;
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by id asc';
+ }
+
+ $table = 'fm_b_account';
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " where id $this->like
'%$query%' or descr $this->like '%$query%'";
+ }
+
+ $sql = "SELECT * FROM $table $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $b_account[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'descr' =>
$this->db->f('descr')
+ );
+ }
+ return $b_account;
+ }
+
+ function read_single($id)
+ {
+
+ $table = 'fm_b_account';
+
+ $sql = "SELECT * FROM $table where id='$id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $b_account['id'] =
$this->db->f('id');
+ $b_account['descr'] =
$this->db->f('descr');
+ $b_account['group'] =
$this->db->f('grouping');
+ $b_account['responsible'] =
$this->db->f('responsible');
+
+ return $b_account;
+ }
+ }
+
+ function add($b_account)
+ {
+ $table = 'fm_b_account';
+
+ $b_account['descr'] =
$this->db->db_addslashes($b_account['descr']);
+
+ $this->db->query("INSERT INTO $table (id,
descr,grouping,responsible) "
+ . "VALUES ('" . $b_account['id'] . "','" .
$b_account['descr']. "','" . substr($b_account['id'],0,2) . "','" .
$b_account['responsible'] . "')",__LINE__,__FILE__);
+
+ $receipt['message'][]=array('msg'=>lang('budget account
%1 has been saved',$b_account['id']));
+ return $receipt;
+ }
+
+ function edit($b_account)
+ {
+
+ $table = 'fm_b_account';
+
+ $b_account['descr'] =
$this->db->db_addslashes($b_account['descr']);
+
+ $this->db->query("UPDATE $table set descr='" .
$b_account['descr'] . "',responsible='" . $b_account['responsible']
+ . "' WHERE id='" .
$b_account['id']. "'",__LINE__,__FILE__);
+
+
+ $receipt['message'][]=array('msg'=>lang('budget account
%1 has been edited',$b_account['id']));
+ return $receipt;
+ }
+
+ function delete($id)
+ {
+ $table = 'fm_b_account';
+
+ $this->db->query("DELETE FROM $table WHERE id='" . $id
. "'",__LINE__,__FILE__);
+ }
+ }
+?>
Index: property/inc/class.socategory.inc.php
diff -u property/inc/class.socategory.inc.php:1.11
property/inc/class.socategory.inc.php:1.12
--- property/inc/class.socategory.inc.php:1.11 Wed Sep 21 14:18:20 2005
+++ property/inc/class.socategory.inc.php Fri Jan 27 14:05:43 2006
@@ -1,220 +1,219 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.socategory.inc.php,v 1.11 2005/09/21 14:18:20
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class socategory
- {
-
- function socategory()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
-
- $this->join = $this->socommon->join;
- $this->like = $this->socommon->like;
-
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $type =
(isset($data['type'])?$data['type']:'');
- $type_id =
(isset($data['type_id'])?$data['type_id']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- }
-
- if(!$type)
- {
- return;
- }
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by id asc';
- }
-
- $table = $this->select_table($type,$type_id);
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " where id $this->like
'%$query%' or descr $this->like '%$query%'";
- }
-
- $sql = "SELECT * FROM $table $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $category[] = array
- (
- 'id' => $this->db->f('id'),
- 'descr' =>
stripslashes($this->db->f('descr'))
- );
- }
- return $category;
- }
-
-
- function select_table($type,$type_id)
- {
-
- switch($type)
- {
- case 'dim_d':
- $table='fm_dim_d';
- break;
- case 'tender_chapter':
- $table='fm_chapter';
- break;
- case 'ticket':
- $table='fm_tts_category';
- break;
- case 'request':
- $table='fm_request_category';
- break;
- case 'wo':
- $table='fm_workorder_category';
- break;
- case 'location':
- $table='fm_location' . $type_id .
'_category';
- break;
- case 'meter':
- $table='fm_meter_category';
- break;
- case 'document':
- $table='fm_document_category';
- break;
- case 'owner':
- $table='fm_owner_category';
- break;
- case 'tenant':
- $table='fm_tenant_category';
- break;
- case 'vendor':
- $table='fm_vendor_category';
- break;
- case 'district':
- $table='fm_district';
- break;
- case 'street':
- $table='fm_streetaddress';
- break;
- case 's_agreement':
- $table='fm_s_agreement_category';
- break;
- case 'tenant_claim':
- $table='fm_tenant_claim_category';
- break;
- case 'wo_hours':
- $table='fm_wo_hours_category';
- break;
- case 'r_condition_type':
- $table='fm_request_condition_type';
- break;
- }
-
- return $table;
- }
-
-
- function read_single($id,$type,$type_id)
- {
-
- $table = $this->select_table($type,$type_id);
-
- $sql = "SELECT * FROM $table where id='$id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $category['id'] = $this->db->f('id');
- $category['descr'] =
stripslashes($this->db->f('descr'));
-
- return $category;
- }
- }
-
- function add($category,$type,$type_id)
- {
- $table = $this->select_table($type,$type_id);
-
- $category['descr'] =
$this->db->db_addslashes($category['descr']);
-
- $this->db->query("INSERT INTO $table (id, descr) "
- . "VALUES ('" . $category['id'] . "','" .
$category['descr']. "')",__LINE__,__FILE__);
-
- $receipt['message'][]=array('msg'=>lang('category has
been saved'));
- return $receipt;
- }
-
- function edit($category,$type,$type_id)
- {
-
- $table = $this->select_table($type,$type_id);
-
- $category['descr'] =
$this->db->db_addslashes($category['descr']);
-
- $this->db->query("UPDATE $table set descr='" .
$category['descr']
- . "' WHERE id='" .
$category['id']. "'",__LINE__,__FILE__);
-
-
- $receipt['message'][]=array('msg'=>lang('category has
been edited'));
- return $receipt;
- }
-
- function delete($id,$type,$type_id)
- {
- $table = $this->select_table($type,$type_id);
-
- $this->db->query("DELETE FROM $table WHERE id='" . $id
. "'",__LINE__,__FILE__);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.socategory.inc.php,v 1.12 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class socategory
+ {
+
+ function socategory()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->like = $this->bocommon->like;
+
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $type =
(isset($data['type'])?$data['type']:'');
+ $type_id =
(isset($data['type_id'])?$data['type_id']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ }
+
+ if(!$type)
+ {
+ return;
+ }
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by id asc';
+ }
+
+ $table = $this->select_table($type,$type_id);
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " where id $this->like
'%$query%' or descr $this->like '%$query%'";
+ }
+
+ $sql = "SELECT * FROM $table $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $category[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'descr' =>
stripslashes($this->db->f('descr'))
+ );
+ }
+ return $category;
+ }
+
+
+ function select_table($type,$type_id)
+ {
+
+ switch($type)
+ {
+ case 'dim_d':
+ $table='fm_dim_d';
+ break;
+ case 'tender_chapter':
+ $table='fm_chapter';
+ break;
+ case 'ticket':
+ $table='fm_tts_category';
+ break;
+ case 'request':
+ $table='fm_request_category';
+ break;
+ case 'wo':
+ $table='fm_workorder_category';
+ break;
+ case 'location':
+ $table='fm_location' . $type_id .
'_category';
+ break;
+ case 'meter':
+ $table='fm_meter_category';
+ break;
+ case 'document':
+ $table='fm_document_category';
+ break;
+ case 'owner':
+ $table='fm_owner_category';
+ break;
+ case 'tenant':
+ $table='fm_tenant_category';
+ break;
+ case 'vendor':
+ $table='fm_vendor_category';
+ break;
+ case 'district':
+ $table='fm_district';
+ break;
+ case 'street':
+ $table='fm_streetaddress';
+ break;
+ case 's_agreement':
+ $table='fm_s_agreement_category';
+ break;
+ case 'tenant_claim':
+ $table='fm_tenant_claim_category';
+ break;
+ case 'wo_hours':
+ $table='fm_wo_hours_category';
+ break;
+ case 'r_condition_type':
+ $table='fm_request_condition_type';
+ break;
+ }
+
+ return $table;
+ }
+
+
+ function read_single($id,$type,$type_id)
+ {
+
+ $table = $this->select_table($type,$type_id);
+
+ $sql = "SELECT * FROM $table where id='$id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $category['id'] = $this->db->f('id');
+ $category['descr'] =
stripslashes($this->db->f('descr'));
+
+ return $category;
+ }
+ }
+
+ function add($category,$type,$type_id)
+ {
+ $table = $this->select_table($type,$type_id);
+
+ $category['descr'] =
$this->db->db_addslashes($category['descr']);
+
+ $this->db->query("INSERT INTO $table (id, descr) "
+ . "VALUES ('" . $category['id'] . "','" .
$category['descr']. "')",__LINE__,__FILE__);
+
+ $receipt['message'][]=array('msg'=>lang('category has
been saved'));
+ return $receipt;
+ }
+
+ function edit($category,$type,$type_id)
+ {
+
+ $table = $this->select_table($type,$type_id);
+
+ $category['descr'] =
$this->db->db_addslashes($category['descr']);
+
+ $this->db->query("UPDATE $table set descr='" .
$category['descr']
+ . "' WHERE id='" .
$category['id']. "'",__LINE__,__FILE__);
+
+
+ $receipt['message'][]=array('msg'=>lang('category has
been edited'));
+ return $receipt;
+ }
+
+ function delete($id,$type,$type_id)
+ {
+ $table = $this->select_table($type,$type_id);
+
+ $this->db->query("DELETE FROM $table WHERE id='" . $id
. "'",__LINE__,__FILE__);
+ }
+ }
+?>
Index: property/inc/class.socommon.inc.php
diff -u property/inc/class.socommon.inc.php:1.13
property/inc/class.socommon.inc.php:1.14
--- property/inc/class.socommon.inc.php:1.13 Thu Nov 10 21:08:23 2005
+++ property/inc/class.socommon.inc.php Fri Jan 27 14:05:43 2006
@@ -1,305 +1,332 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage core
- * @version $Id: class.socommon.inc.php,v 1.13 2005/11/10 21:08:23
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class socommon
- {
-
- function socommon()
- {
- $GLOBALS['phpgw_info']['flags']['currentapp'] =
'property';
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- if
($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
- {
- $this->join = " JOIN ";
- $this->like = "ILIKE";
- }
- else
- {
- $this->join = " INNER JOIN ";
- $this->like = "LIKE";
- }
-
- $this->left_join = " LEFT JOIN ";
-
-
- }
-
- function fm_cache($name='',$value='')
- {
- if($value)
- {
- $value = serialize($value);
- $this->db->query("INSERT INTO fm_cache
(name,value)VALUES ('$name','$value')",__LINE__,__FILE__);
- }
- else
- {
- $this->db->query("SELECT value FROM fm_cache
where name='$name'");
- $this->db->next_record();
- $value= unserialize($this->db->f('value'));
- return $value;
-
- }
- }
-
- function create_preferences($app='',$user_id='')
- {
- $this->db->query("SELECT preference_value FROM
phpgw_preferences where preference_app = '$app' AND
preference_owner=".(int)$user_id );
- $this->db->next_record();
- $value=
unserialize($this->db->f('preference_value'));
- return $value;
- }
-
-
- function get_user_list_right($right='',$acl_location='')
- {
- $acl2 =
CreateObject($this->currentapp.'.acl2','##DEFAULT##','##DEFAULT##');
- $myaccounts = CreateObject('phpgwapi.accounts');
-
- while($my_memberships && list($key,$group) =
each($my_memberships))
- {
- $security .= "," . $group['account_id'];
- }
-
- $sql = "SELECT * FROM phpgw_accounts $this->join
fm_acl2 on phpgw_accounts.account_id=fm_acl2.acl_account WHERE account_status =
'A' AND acl_location $this->like '%$acl_location%' order by account_lastname
ASC";
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
- {
-
if($acl2->check($acl_location,$right,$this->db->f('acl_account')))
- {
- if($this->db->f('account_type')=='g')
- {
- $members =
$myaccounts->member($this->db->f('account_id'));
- if (isset($members) AND
is_array($members))
- {
- foreach($members as
$user)
- {
-
$accounts[$user['account_id']] = array($user['account_id']);
- }
- unset($members);
- }
- }
- else
- {
-
$accounts[$this->db->f('acl_account')] = array($this->db->f('acl_account'));
- }
- }
- }
-
- unset($myaccounts);
-
- $sql = "SELECT account_id FROM phpgw_accounts WHERE
account_status = 'I'";
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
- {
- unset($accounts[$this->db->f('account_id')]);
- }
-
- if (isset($accounts) AND is_array($accounts))
- {
- foreach($accounts as $account_id)
- {
- $i=0;
-
if(!$acl2->check($acl_location,$right,$account_id[0]))
- {
-
unset($accounts[$account_id[0]]);
- }
- $i++;
- }
- }
- address@hidden($accounts);
- $k=count($accounts);
- for ($i=0;$i<$k;$i++)
- {
- $in_list[] = $accounts[$i];
- }
-
- if($in_list)
- {
- $sql = 'SELECT * FROM phpgw_accounts where
account_id in ('. implode(',',$in_list) . ') order by account_lastname';
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
- {
- $employees[] = Array(
- 'account_id' =>
$this->db->f('account_id'),
- 'account_lid' =>
$this->db->f('account_lid'),
- 'account_type' =>
$this->db->f('account_type'),
- 'account_firstname' =>
$this->db->f('account_firstname'),
- 'account_lastname' =>
$this->db->f('account_lastname'),
- 'account_status' =>
$this->db->f('account_status'),
- 'account_expires' =>
$this->db->f('account_expires')
- );
-
- }
- }
-/* for ($i=0;$i<$k;$i++)
- {
- $sql = 'SELECT * FROM phpgw_accounts where
account_id=' . (int)$accounts[$i];
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $employees[] = Array(
- 'account_id' =>
$this->db->f('account_id'),
- 'account_lid' =>
$this->db->f('account_lid'),
- 'account_type' =>
$this->db->f('account_type'),
- 'account_firstname' =>
$this->db->f('account_firstname'),
- 'account_lastname' =>
$this->db->f('account_lastname'),
- 'account_status' =>
$this->db->f('account_status'),
- 'account_expires' =>
$this->db->f('account_expires')
- );
- }
-*/
- return $employees;
- }
-
- function read_single_tenant($id)
- {
-
- $this->db->query("SELECT * FROM fm_tenant WHERE id
=$id",__LINE__,__FILE__);
-
- $this->db->next_record();
- $tenant_data = array
- (
- 'first_name' =>
$this->db->f('first_name'),
- 'last_name' =>
$this->db->f('last_name'),
- 'contact_phone' =>
$this->db->f('contact_phone')
- );
-
-//_debug_array($tenant_data);
- return $tenant_data;
- }
-
- function check_location($location_code='',$type_id='')
- {
- $this->db->query("SELECT count(*) FROM
fm_location$type_id where location_code='$location_code'");
-
- $this->db->next_record();
-
- if ( $this->db->f(0))
- {
- return True;
- }
- }
-
- function select_part_of_town()
- {
-
- $this->db->query("SELECT name, part_of_town_id FROM
fm_part_of_town ORDER BY name ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $part_of_town[$i]['id'] =
$this->db->f('part_of_town_id');
- $part_of_town[$i]['name'] =
stripslashes($this->db->f('name'));
- $i++;
- }
-
- return $part_of_town;
- }
-
- function select_district_list()
- {
-
- $this->db->query("SELECT id, descr FROM fm_district
where id >'0' ORDER BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $district[$i]['id']
= $this->db->f('id');
- $district[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $district;
- }
-
- function next_id($table='',$key='')
- {
- if(is_array($key))
- {
- while (is_array($key) && list($column,$value) =
each($key))
- {
- if($value)
- {
- $condition[] = $column . '=' .
$value;
- }
- }
-
- $where=' WHERE ' . implode(" AND ", $condition);
- }
-
- $this->db->query("SELECT max(id) as maximum FROM $table
$where",__LINE__,__FILE__);
- $this->db->next_record();
- $next_id = $this->db->f('maximum')+1;
- return "$next_id";
- }
-
- function get_lookup_entity($location)
- {
- $this->db->query("SELECT entity_id,name FROM
fm_entity_lookup $this->join fm_entity on
fm_entity_lookup.entity_id=fm_entity.id WHERE type='lookup' AND
location='$location' ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $entity[$i]['id']
= $this->db->f('entity_id');
- $entity[$i]['name']
= $this->db->f('name');
- $i++;
- }
- return $entity;
- }
-
- function get_start_entity($location)
- {
- $this->db->query("SELECT entity_id,name FROM
fm_entity_lookup $this->join fm_entity on
fm_entity_lookup.entity_id=fm_entity.id WHERE type='start' AND
location='$location' ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $entity[$i]['id']
= $this->db->f('entity_id');
- $entity[$i]['name']
= $this->db->f('name');
- $i++;
- }
- return $entity;
- }
-
- function increment_id($name)
- {
- $this->db->query("SELECT value FROM fm_idgenerator
WHERE name='$name'");
- $this->db->next_record();
- $next_id=$this->db->f('value') +1;
-
- $this->db->query("update fm_idgenerator set value =
$next_id WHERE name = 'workorder'");
- return $next_id;
- }
-
- function select_wo_hours_category_list()
- {
- $this->db->query("SELECT id, descr FROM
fm_wo_hours_category ORDER BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $category_list[$i]['id'] = $this->db->f('id');
- $category_list[$i]['name'] =
stripslashes($this->db->f('descr'));
- $i++;
- }
- return $category_list;
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage core
+ * @version $Id: class.socommon.inc.php,v 1.14 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class socommon
+ {
+
+ function socommon()
+ {
+ $GLOBALS['phpgw_info']['flags']['currentapp'] =
'property';
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+// $this->db = $GLOBALS['phpgw']->db;
+ $this->db = CreateObject('phpgwapi.db');
+ $this->db->Host =
$GLOBALS['phpgw_info']['server']['db_host'];
+ $this->db->Type =
$GLOBALS['phpgw_info']['server']['db_type'];
+ $this->db->Database =
$GLOBALS['phpgw_info']['server']['db_name'];
+ $this->db->User =
$GLOBALS['phpgw_info']['server']['db_user'];
+ $this->db->Password =
$GLOBALS['phpgw_info']['server']['db_pass'];
+
+// $this->db2 = $this->db;
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ if
($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
+ {
+ $this->join = " JOIN ";
+ $this->like = "ILIKE";
+ }
+ else
+ {
+ $this->join = " INNER JOIN ";
+ $this->like = "LIKE";
+ }
+
+ $this->left_join = " LEFT JOIN ";
+
+
+ }
+
+ function fm_cache($name='',$value='')
+ {
+ if($value)
+ {
+ $value = serialize($value);
+ $this->db->query("INSERT INTO fm_cache
(name,value)VALUES ('$name','$value')",__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query("SELECT value FROM fm_cache
where name='$name'");
+ $this->db->next_record();
+ $value= unserialize($this->db->f('value'));
+ return $value;
+
+ }
+ }
+
+ function create_preferences($app='',$user_id='')
+ {
+ $this->db->query("SELECT preference_value FROM
phpgw_preferences where preference_app = '$app' AND
preference_owner=".(int)$user_id );
+ $this->db->next_record();
+ $value=
unserialize($this->db->f('preference_value'));
+ return $value;
+ }
+
+
+ function get_user_list_right($right='',$acl_location='')
+ {
+ $acl2 =
CreateObject($this->currentapp.'.acl2','##DEFAULT##','##DEFAULT##');
+ $myaccounts = CreateObject('phpgwapi.accounts');
+
+ while($my_memberships && list($key,$group) =
each($my_memberships))
+ {
+ $security .= "," . $group['account_id'];
+ }
+
+ $sql = "SELECT * FROM phpgw_accounts $this->join
fm_acl2 on phpgw_accounts.account_id=fm_acl2.acl_account WHERE account_status =
'A' AND acl_location $this->like '%$acl_location%' order by account_lastname
ASC";
+ $this->db->query($sql,__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+ $active_accounts[] = array(
+ 'acl_account' =>
$this->db->f('acl_account'),
+ 'account_id' =>
$this->db->f('account_id'),
+ 'account_type' =>
$this->db->f('account_type'),
+ );
+ }
+
+ foreach ($active_accounts as $entry)
+ {
+
if($acl2->check($acl_location,$right,$entry['acl_account']))
+ {
+ if($entry['account_type']=='g')
+ {
+ $members =
$myaccounts->member($entry['account_id']);
+ if (isset($members) AND
is_array($members))
+ {
+ foreach($members as
$user)
+ {
+
$accounts[$user['account_id']] = array($user['account_id']);
+ }
+ unset($members);
+ }
+ }
+ else
+ {
+
$accounts[$entry['acl_account']] = array($entry['acl_account']);
+ }
+ }
+ }
+
+ unset($active_accounts);
+ unset($myaccounts);
+
+ $sql = "SELECT account_id FROM phpgw_accounts WHERE
account_status = 'I'";
+ $this->db->query($sql,__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+ unset($accounts[$this->db->f('account_id')]);
+ }
+
+ if (isset($accounts) AND is_array($accounts))
+ {
+ foreach($accounts as $account_id)
+ {
+ $i=0;
+
if(!$acl2->check($acl_location,$right,$account_id[0]))
+ {
+
unset($accounts[$account_id[0]]);
+ }
+ $i++;
+ }
+ }
+ address@hidden($accounts);
+ $k=count($accounts);
+ for ($i=0;$i<$k;$i++)
+ {
+ $in_list[] = $accounts[$i];
+ }
+
+ if($in_list)
+ {
+ $sql = 'SELECT * FROM phpgw_accounts where
account_id in ('. implode(',',$in_list) . ') order by account_lastname';
+ $this->db->query($sql,__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+ $employees[] = Array(
+ 'account_id' =>
$this->db->f('account_id'),
+ 'account_lid' =>
$this->db->f('account_lid'),
+ 'account_type' =>
$this->db->f('account_type'),
+ 'account_firstname' =>
$this->db->f('account_firstname'),
+ 'account_lastname' =>
$this->db->f('account_lastname'),
+ 'account_status' =>
$this->db->f('account_status'),
+ 'account_expires' =>
$this->db->f('account_expires')
+ );
+
+ }
+ }
+/* for ($i=0;$i<$k;$i++)
+ {
+ $sql = 'SELECT * FROM phpgw_accounts where
account_id=' . (int)$accounts[$i];
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $employees[] = Array(
+ 'account_id' =>
$this->db->f('account_id'),
+ 'account_lid' =>
$this->db->f('account_lid'),
+ 'account_type' =>
$this->db->f('account_type'),
+ 'account_firstname' =>
$this->db->f('account_firstname'),
+ 'account_lastname' =>
$this->db->f('account_lastname'),
+ 'account_status' =>
$this->db->f('account_status'),
+ 'account_expires' =>
$this->db->f('account_expires')
+ );
+ }
+*/
+ return $employees;
+ }
+
+ function read_single_tenant($id)
+ {
+
+ $this->db->query("SELECT * FROM fm_tenant WHERE id
=$id",__LINE__,__FILE__);
+
+ $this->db->next_record();
+ $tenant_data = array
+ (
+ 'first_name' =>
$this->db->f('first_name'),
+ 'last_name' =>
$this->db->f('last_name'),
+ 'contact_phone' =>
$this->db->f('contact_phone')
+ );
+
+//_debug_array($tenant_data);
+ return $tenant_data;
+ }
+
+ function check_location($location_code='',$type_id='')
+ {
+ $this->db->query("SELECT count(*) FROM
fm_location$type_id where location_code='$location_code'");
+
+ $this->db->next_record();
+
+ if ( $this->db->f(0))
+ {
+ return True;
+ }
+ }
+
+ function select_part_of_town()
+ {
+
+ $this->db->query("SELECT name, part_of_town_id FROM
fm_part_of_town ORDER BY name ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $part_of_town[$i]['id'] =
$this->db->f('part_of_town_id');
+ $part_of_town[$i]['name'] =
stripslashes($this->db->f('name'));
+ $i++;
+ }
+
+ return $part_of_town;
+ }
+
+ function select_district_list()
+ {
+
+ $this->db->query("SELECT id, descr FROM fm_district
where id >'0' ORDER BY id ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $district[$i]['id']
= $this->db->f('id');
+ $district[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $district;
+ }
+
+ function next_id($table='',$key='')
+ {
+ if(is_array($key))
+ {
+ while (is_array($key) && list($column,$value) =
each($key))
+ {
+ if($value)
+ {
+ $condition[] = $column . '=' .
$value;
+ }
+ }
+
+ $where=' WHERE ' . implode(" AND ", $condition);
+ }
+
+ $this->db->query("SELECT max(id) as maximum FROM $table
$where",__LINE__,__FILE__);
+ $this->db->next_record();
+ $next_id = $this->db->f('maximum')+1;
+ return "$next_id";
+ }
+
+ function get_lookup_entity($location)
+ {
+ $this->db->query("SELECT entity_id,name FROM
fm_entity_lookup $this->join fm_entity on
fm_entity_lookup.entity_id=fm_entity.id WHERE type='lookup' AND
location='$location' ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $entity[$i]['id']
= $this->db->f('entity_id');
+ $entity[$i]['name']
= $this->db->f('name');
+ $i++;
+ }
+ return $entity;
+ }
+
+ function get_start_entity($location)
+ {
+ $this->db->query("SELECT entity_id,name FROM
fm_entity_lookup $this->join fm_entity on
fm_entity_lookup.entity_id=fm_entity.id WHERE type='start' AND
location='$location' ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $entity[$i]['id']
= $this->db->f('entity_id');
+ $entity[$i]['name']
= $this->db->f('name');
+ $i++;
+ }
+ return $entity;
+ }
+
+ function increment_id($name)
+ {
+ $this->db->query("SELECT value FROM fm_idgenerator
WHERE name='$name'");
+ $this->db->next_record();
+ $next_id=$this->db->f('value') +1;
+
+ $this->db->query("update fm_idgenerator set value =
$next_id WHERE name = 'workorder'");
+ return $next_id;
+ }
+
+ function select_wo_hours_category_list()
+ {
+ $this->db->query("SELECT id, descr FROM
fm_wo_hours_category ORDER BY id ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $category_list[$i]['id'] = $this->db->f('id');
+ $category_list[$i]['name'] =
stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $category_list;
+ }
+
+ function new_db()
+ {
$db = CreateObject('phpgwapi.db');
+ $db->Host = $GLOBALS['phpgw_info']['server']['db_host'];
+ $db->Type = $GLOBALS['phpgw_info']['server']['db_type'];
+ $db->Database =
$GLOBALS['phpgw_info']['server']['db_name'];
+ $db->User = $GLOBALS['phpgw_info']['server']['db_user'];
+ $db->Password =
$GLOBALS['phpgw_info']['server']['db_pass'];
+ return $db;
+ }
+ }
+?>
Index: property/inc/class.socustom.inc.php
diff -u property/inc/class.socustom.inc.php:1.6
property/inc/class.socustom.inc.php:1.7
--- property/inc/class.socustom.inc.php:1.6 Thu Jan 19 14:31:08 2006
+++ property/inc/class.socustom.inc.php Fri Jan 27 14:05:43 2006
@@ -1,333 +1,333 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage custom
- * @version $Id: class.socustom.inc.php,v 1.6 2006/01/19 14:31:08
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class socustom
- {
-
- function socustom()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->join = $this->bocommon->join;
- $this->like = $this->bocommon->like;
- }
-
-
- function read($data)
- {
- if(is_array($data))
- {
- $start =
(isset($data['start'])?$data['start']:0);
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by id DESC';
- }
-
-
- $where = 'WHERE';
- if ($cat_id > 0)
- {
- $filtermethod .= " $where category='$cat_id' ";
- $where = 'AND';
-
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " $where ( abid = '$query' or
org_name $this->like '%$query%')";
- }
-
- $sql = "SELECT * FROM fm_custom $filtermethod
$querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $customs[] = array
- (
- 'custom_id' =>
$this->db->f('id'),
- 'name' =>
stripslashes($this->db->f('name')),
- 'entry_date' =>
$this->db->f('entry_date'),
- 'user' =>
$GLOBALS['phpgw']->accounts->id2name($this->db->f('user_id'))
- );
- }
- return $customs;
- }
-
- function read_single($custom_id)
- {
- $this->db->query("select * from fm_custom where
id='$custom_id'",__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $custom['id'] =
(int)$this->db->f('id');
- $custom['name'] =
stripslashes($this->db->f('name'));
- $custom['sql_text'] =
stripslashes($this->db->f('sql_text'));
- $custom['entry_date'] =
$this->db->f('entry_date');
- $custom['cols'] =
$this->read_cols($custom_id);
- }
-
- return $custom;
- }
-
- function read_cols($custom_id)
- {
- $sql = "SELECT * FROM fm_custom_cols WHERE
custom_id=$custom_id ORDER by sorting";
- $this->db->query($sql);
-
- while ($this->db->next_record())
- {
- $choice[] = array
- (
- 'id' => $this->db->f('id'),
- 'name' => $this->db->f('name'),
- 'descr' => $this->db->f('descr'),
- 'sorting'=> $this->db->f('sorting')
- );
-
- }
- return $choice;
- }
-
- function read_custom_name($custom_id)
- {
- $this->db->query("select name from fm_custom where
id='$custom_id'",__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $name =
stripslashes($this->db->f('name'));
- }
-
- return $name;
- }
-
- function add($custom)
- {
- $custom['name'] =
$this->db->db_addslashes($custom['name']);
- $custom['sql_text'] =
$this->db->db_addslashes($custom['sql_text']);
-
- $this->db->transaction_begin();
-
- $id = $this->bocommon->next_id('fm_custom');
-
- $this->db->query("INSERT INTO fm_custom
(id,entry_date,sql_text,name,user_id) "
- . "VALUES ($id,'" . time() . "','" .
$custom['sql_text'] . "','" . $custom['name'] . "'," . $this->account .
")",__LINE__,__FILE__);
-
- $receipt['custom_id']= $id;
-
-
- $this->db->transaction_commit();
-
- $receipt['message'][] = array('msg'=>lang('custom %1
has been saved',$receipt['custom_id']));
- return $receipt;
- }
-
- function edit($custom)
- {
- $custom['name'] =
$this->db->db_addslashes($custom['name']);
- $custom['sql_text'] =
$this->db->db_addslashes($custom['sql_text']);
-
- $this->db->query("UPDATE fm_custom set sql_text='" .
$custom['sql_text'] . "', entry_date='" . time() . "', name='" .
$custom['name'] . "' WHERE id=" .
intval($custom['custom_id']),__LINE__,__FILE__);
-
- if($custom['new_name'])
- {
- $column_id =
$this->bocommon->next_id('fm_custom_cols'
,array('custom_id'=>$custom['custom_id']));
-
- $sql = "SELECT max(sorting) as max_sort FROM
fm_custom_cols WHERE custom_id=" . $custom['custom_id'];
- $this->db->query($sql);
- $this->db->next_record();
- $sorting = $this->db->f('max_sort')+1;
-
-
- $values= array(
- $custom['custom_id'],
- $column_id,
- $custom['new_name'],
-
$this->db->db_addslashes($custom['new_descr']),
- $sorting
- );
-
- $values =
$this->bocommon->validate_db_insert($values);
-
- $this->db->query("INSERT INTO fm_custom_cols
(custom_id,id,name,descr,sorting) "
- . "VALUES ($values)");
- }
-
-
- if($custom['delete_cols'])
- {
- for ($i=0;$i<count($custom['delete_cols']);$i++)
- {
-
- $sql = "SELECT sorting FROM
fm_custom_cols where custom_id=" . $custom['custom_id'] . " AND id=" .
$custom['delete_cols'][$i];
- $this->db->query($sql);
- $this->db->next_record();
- $sorting =
$this->db->f('sorting');
- $sql2 = "SELECT max(sorting) as
max_sort FROM fm_custom_cols";
- $this->db->query($sql2);
- $this->db->next_record();
- $max_sort =
$this->db->f('max_sort');
-
- if($max_sort>$sorting)
- {
- $sql = "UPDATE fm_custom_cols
set sorting=sorting-1 WHERE sorting > $sorting AND custom_id=" .
$custom['custom_id'];
- $this->db->query($sql);
- }
-
-
- $this->db->query("DELETE FROM
fm_custom_cols WHERE custom_id=" . $custom['custom_id'] ." AND id=" .
$custom['delete_cols'][$i]);
- }
- }
-
- $receipt['custom_id']= $custom['custom_id'];
- $receipt['message'][] = array('msg'=>lang('custom %1
has been edited',$custom['custom_id']));
- return $receipt;
- }
-
- function resort($data)
- {
-//html_print_r($data);
- if(is_array($data))
- {
- $resort =
(isset($data['resort'])?$data['resort']:'up');
- $custom_id =
(isset($data['id'])?$data['custom_id']:'');
- $id = (isset($data['id'])?$data['id']:'');
- }
-
- $sql = "SELECT sorting FROM fm_custom_cols WHERE
custom_id = $custom_id AND id=$id";
- $this->db->query($sql);
- $this->db->next_record();
- $sorting = $this->db->f('sorting');
- $sql = "SELECT max(sorting) as max_sort FROM
fm_custom_cols WHERE custom_id = $custom_id";
- $this->db->query($sql);
- $this->db->next_record();
- $max_sort = $this->db->f('max_sort');
- switch($resort)
- {
- case 'up':
- if($sorting>1)
- {
- $sql = "UPDATE fm_custom_cols
set sorting=$sorting WHERE custom_id = $custom_id AND sorting =" . ($sorting-1);
- $this->db->query($sql);
- $sql = "UPDATE fm_custom_cols
set sorting=" . ($sorting-1) ." WHERE custom_id = $custom_id AND id=$id";
- $this->db->query($sql);
- }
- break;
- case 'down':
- if($max_sort > $sorting)
- {
- $sql = "UPDATE fm_custom_cols
set sorting=$sorting WHERE custom_id = $custom_id AND sorting =" . ($sorting+1);
- $this->db->query($sql);
- $sql = "UPDATE fm_custom_cols
set sorting=" . ($sorting+1) ." WHERE custom_id = $custom_id AND id=$id";
- $this->db->query($sql);
- }
- break;
- default:
- return;
- break;
- }
- }
-
- function read_custom($data)
- {
- if(is_array($data))
- {
- $start =
(isset($data['start'])?$data['start']:0);
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $custom_id =
(isset($data['custom_id'])?$data['custom_id']:'');
- }
-
-
- $this->db->query("select sql_text from fm_custom where
id='$custom_id'",__LINE__,__FILE__);
- $this->db->next_record();
- $sql = stripslashes($this->db->f('sql_text'));
-
- $uicols = $this->read_cols($custom_id);
- $this->uicols = $uicols;
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- $n=count($uicols);
- $j=0;
- while ($this->db->next_record())
- {
- for ($i=0;$i<$n;$i++)
- {
- $custom[$j][$uicols[$i]['name']] =
$this->db->f($uicols[$i]['name']);
- $custom[$j]['grants'] =
(int)$grants[$this->db->f('user_id')];
- }
- $j++;
- }
-
-//_debug_array($custom);
- return $custom;
- }
-
- function delete($custom_id)
- {
- $this->db->query('DELETE FROM fm_custom WHERE id=' .
intval($custom_id),__LINE__,__FILE__);
- $this->db->query('DELETE FROM fm_custom_cols WHERE
custom_id=' . intval($custom_id),__LINE__,__FILE__);
- }
-
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage custom
+ * @version $Id: class.socustom.inc.php,v 1.7 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class socustom
+ {
+
+ function socustom()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->join = $this->bocommon->join;
+ $this->like = $this->bocommon->like;
+ }
+
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ $start =
(isset($data['start'])?$data['start']:0);
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by id DESC';
+ }
+
+
+ $where = 'WHERE';
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " $where category='$cat_id' ";
+ $where = 'AND';
+
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " $where ( abid = '$query' or
org_name $this->like '%$query%')";
+ }
+
+ $sql = "SELECT * FROM fm_custom $filtermethod
$querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $customs[] = array
+ (
+ 'custom_id' =>
$this->db->f('id'),
+ 'name' =>
stripslashes($this->db->f('name')),
+ 'entry_date' =>
$this->db->f('entry_date'),
+ 'user' =>
$GLOBALS['phpgw']->accounts->id2name($this->db->f('user_id'))
+ );
+ }
+ return $customs;
+ }
+
+ function read_single($custom_id)
+ {
+ $this->db->query("select * from fm_custom where
id='$custom_id'",__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $custom['id'] =
(int)$this->db->f('id');
+ $custom['name'] =
stripslashes($this->db->f('name'));
+ $custom['sql_text'] =
stripslashes($this->db->f('sql_text'));
+ $custom['entry_date'] =
$this->db->f('entry_date');
+ $custom['cols'] =
$this->read_cols($custom_id);
+ }
+
+ return $custom;
+ }
+
+ function read_cols($custom_id)
+ {
+ $sql = "SELECT * FROM fm_custom_cols WHERE
custom_id=$custom_id ORDER by sorting";
+ $this->db->query($sql);
+
+ while ($this->db->next_record())
+ {
+ $choice[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'name' => $this->db->f('name'),
+ 'descr' => $this->db->f('descr'),
+ 'sorting'=> $this->db->f('sorting')
+ );
+
+ }
+ return $choice;
+ }
+
+ function read_custom_name($custom_id)
+ {
+ $this->db->query("select name from fm_custom where
id='$custom_id'",__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $name =
stripslashes($this->db->f('name'));
+ }
+
+ return $name;
+ }
+
+ function add($custom)
+ {
+ $custom['name'] =
$this->db->db_addslashes($custom['name']);
+ $custom['sql_text'] =
$this->db->db_addslashes($custom['sql_text']);
+
+ $this->db->transaction_begin();
+
+ $id = $this->bocommon->next_id('fm_custom');
+
+ $this->db->query("INSERT INTO fm_custom
(id,entry_date,sql_text,name,user_id) "
+ . "VALUES ($id,'" . time() . "','" .
$custom['sql_text'] . "','" . $custom['name'] . "'," . $this->account .
")",__LINE__,__FILE__);
+
+ $receipt['custom_id']= $id;
+
+
+ $this->db->transaction_commit();
+
+ $receipt['message'][] = array('msg'=>lang('custom %1
has been saved',$receipt['custom_id']));
+ return $receipt;
+ }
+
+ function edit($custom)
+ {
+ $custom['name'] =
$this->db->db_addslashes($custom['name']);
+ $custom['sql_text'] =
$this->db->db_addslashes($custom['sql_text']);
+
+ $this->db->query("UPDATE fm_custom set sql_text='" .
$custom['sql_text'] . "', entry_date='" . time() . "', name='" .
$custom['name'] . "' WHERE id=" .
intval($custom['custom_id']),__LINE__,__FILE__);
+
+ if($custom['new_name'])
+ {
+ $column_id =
$this->bocommon->next_id('fm_custom_cols'
,array('custom_id'=>$custom['custom_id']));
+
+ $sql = "SELECT max(sorting) as max_sort FROM
fm_custom_cols WHERE custom_id=" . $custom['custom_id'];
+ $this->db->query($sql);
+ $this->db->next_record();
+ $sorting = $this->db->f('max_sort')+1;
+
+
+ $values= array(
+ $custom['custom_id'],
+ $column_id,
+ $custom['new_name'],
+
$this->db->db_addslashes($custom['new_descr']),
+ $sorting
+ );
+
+ $values =
$this->bocommon->validate_db_insert($values);
+
+ $this->db->query("INSERT INTO fm_custom_cols
(custom_id,id,name,descr,sorting) "
+ . "VALUES ($values)");
+ }
+
+
+ if($custom['delete_cols'])
+ {
+ for ($i=0;$i<count($custom['delete_cols']);$i++)
+ {
+
+ $sql = "SELECT sorting FROM
fm_custom_cols where custom_id=" . $custom['custom_id'] . " AND id=" .
$custom['delete_cols'][$i];
+ $this->db->query($sql);
+ $this->db->next_record();
+ $sorting =
$this->db->f('sorting');
+ $sql2 = "SELECT max(sorting) as
max_sort FROM fm_custom_cols";
+ $this->db->query($sql2);
+ $this->db->next_record();
+ $max_sort =
$this->db->f('max_sort');
+
+ if($max_sort>$sorting)
+ {
+ $sql = "UPDATE fm_custom_cols
set sorting=sorting-1 WHERE sorting > $sorting AND custom_id=" .
$custom['custom_id'];
+ $this->db->query($sql);
+ }
+
+
+ $this->db->query("DELETE FROM
fm_custom_cols WHERE custom_id=" . $custom['custom_id'] ." AND id=" .
$custom['delete_cols'][$i]);
+ }
+ }
+
+ $receipt['custom_id']= $custom['custom_id'];
+ $receipt['message'][] = array('msg'=>lang('custom %1
has been edited',$custom['custom_id']));
+ return $receipt;
+ }
+
+ function resort($data)
+ {
+//html_print_r($data);
+ if(is_array($data))
+ {
+ $resort =
(isset($data['resort'])?$data['resort']:'up');
+ $custom_id =
(isset($data['id'])?$data['custom_id']:'');
+ $id = (isset($data['id'])?$data['id']:'');
+ }
+
+ $sql = "SELECT sorting FROM fm_custom_cols WHERE
custom_id = $custom_id AND id=$id";
+ $this->db->query($sql);
+ $this->db->next_record();
+ $sorting = $this->db->f('sorting');
+ $sql = "SELECT max(sorting) as max_sort FROM
fm_custom_cols WHERE custom_id = $custom_id";
+ $this->db->query($sql);
+ $this->db->next_record();
+ $max_sort = $this->db->f('max_sort');
+ switch($resort)
+ {
+ case 'up':
+ if($sorting>1)
+ {
+ $sql = "UPDATE fm_custom_cols
set sorting=$sorting WHERE custom_id = $custom_id AND sorting =" . ($sorting-1);
+ $this->db->query($sql);
+ $sql = "UPDATE fm_custom_cols
set sorting=" . ($sorting-1) ." WHERE custom_id = $custom_id AND id=$id";
+ $this->db->query($sql);
+ }
+ break;
+ case 'down':
+ if($max_sort > $sorting)
+ {
+ $sql = "UPDATE fm_custom_cols
set sorting=$sorting WHERE custom_id = $custom_id AND sorting =" . ($sorting+1);
+ $this->db->query($sql);
+ $sql = "UPDATE fm_custom_cols
set sorting=" . ($sorting+1) ." WHERE custom_id = $custom_id AND id=$id";
+ $this->db->query($sql);
+ }
+ break;
+ default:
+ return;
+ break;
+ }
+ }
+
+ function read_custom($data)
+ {
+ if(is_array($data))
+ {
+ $start =
(isset($data['start'])?$data['start']:0);
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $custom_id =
(isset($data['custom_id'])?$data['custom_id']:'');
+ }
+
+
+ $this->db->query("select sql_text from fm_custom where
id='$custom_id'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $sql = stripslashes($this->db->f('sql_text'));
+
+ $uicols = $this->read_cols($custom_id);
+ $this->uicols = $uicols;
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ $n=count($uicols);
+ $j=0;
+ while ($this->db->next_record())
+ {
+ for ($i=0;$i<$n;$i++)
+ {
+ $custom[$j][$uicols[$i]['name']] =
$this->db->f($uicols[$i]['name']);
+ $custom[$j]['grants'] =
(int)$grants[$this->db->f('user_id')];
+ }
+ $j++;
+ }
+
+//_debug_array($custom);
+ return $custom;
+ }
+
+ function delete($custom_id)
+ {
+ $this->db->query('DELETE FROM fm_custom WHERE id=' .
intval($custom_id),__LINE__,__FILE__);
+ $this->db->query('DELETE FROM fm_custom_cols WHERE
custom_id=' . intval($custom_id),__LINE__,__FILE__);
+ }
+
+
+ }
+?>
Index: property/inc/class.sodocument.inc.php
diff -u property/inc/class.sodocument.inc.php:1.7
property/inc/class.sodocument.inc.php:1.8
--- property/inc/class.sodocument.inc.php:1.7 Fri Aug 19 11:56:50 2005
+++ property/inc/class.sodocument.inc.php Fri Jan 27 14:05:43 2006
@@ -1,643 +1,643 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage document
- * @version $Id: class.sodocument.inc.php,v 1.7 2005/08/19 11:56:50
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class sodocument
- {
-
- function sodocument()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon',True);
- $this->historylog =
CreateObject($this->currentapp.'.historylog','document');
- $this->vfs =
CreateObject('phpgwapi.vfs');
- $this->rootdir = $this->vfs->basedir;
- $this->fakebase = $this->vfs->fakebase;
-
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
-
- $this->join = $this->socommon->join;
- $this->like = $this->socommon->like;
- }
-
- function select_doc_type_list()
- {
- $this->db->query("SELECT id, descr FROM
fm_document_category ORDER BY descr ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $categories[$i]['id']
= $this->db->f('id');
- $categories[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $categories;
- }
-
- function read_single_category($id='')
- {
- $this->db->query("SELECT descr FROM
fm_document_category where id='$id' ");
- $this->db->next_record();
- return $this->db->f('descr');
- }
-
- function select_status_list()
- {
- $this->db->query("SELECT id, descr FROM
fm_document_status ORDER BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $status_entries[$i]['id']
= $this->db->f('id');
- $status_entries[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $status_entries;
- }
-
- function select_branch_list()
- {
- $this->db->query("SELECT id, descr FROM fm_branch ORDER
BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $branch_entries[$i]['id']
= $this->db->f('id');
- $branch_entries[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $branch_entries;
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $entity_id =
(isset($data['entity_id'])?$data['entity_id']:'');
- $doc_type =
(isset($data['doc_type'])?$data['doc_type']:0);
- }
-
- $sql = $this->bocommon->fm_cache('sql_document_' .
$entity_id);
-
- if(!$sql)
- {
-
- $document_table = 'fm_document';
-
- $cols .= $document_table . '.location_code';
- $cols_return[] = 'location_code';
-
-// $cols .= ",$document_table.id as document_id";
-// $cols_return[] =
'document_id';
-
- if ($entity_id)
- {
- $cols .= ",$document_table.p_num as
p_num";
- $cols_return[]
= 'p_num';
- $uicols['input_type'][] =
'text';
- $uicols['name'][]
= 'p_num';
- $uicols['descr'][]
= lang('ID');
- $uicols['statustext'][] =
lang('ID');
-
- $cols .= ',fm_entity_category.name as
category';
- $cols_return[]
= 'category';
- $uicols['input_type'][] =
'text';
- $uicols['name'][]
= 'category';
- $uicols['descr'][]
= lang('Type');
- $uicols['statustext'][] =
lang('Type');
-
- $cols .= ",$document_table.p_entity_id";
- $cols_return[]
= 'p_entity_id';
- $cols .= ",$document_table.p_cat_id";
- $cols_return[]
= 'p_cat_id';
-
- $joinmethod .= " $this->join
fm_entity_category ON (fm_entity_category.entity_id
=$document_table.p_entity_id AND fm_entity_category.id =
$document_table.p_cat_id))";
- $paranthesis .='(';
-
- }
-
-
- $sql =
$this->bocommon->generate_sql(array('entity_table'=>$document_table,'cols'=>$cols,'cols_return'=>$cols_return,
-
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query));
-
- $this->bocommon->fm_cache('sql_document_' .
$entity_id,$sql);
-
- $this->uicols =
$this->bocommon->uicols;
- $cols_return =
$this->bocommon->cols_return;
- $type_id =
$this->bocommon->type_id;
- $this->cols_extra =
$this->bocommon->cols_extra;
-
- $this->bocommon->fm_cache('uicols_document_' .
$entity_id,$this->uicols);
-
$this->bocommon->fm_cache('cols_return_document_' . $entity_id,$cols_return);
- $this->bocommon->fm_cache('type_id_document_' .
$entity_id,$type_id);
-
$this->bocommon->fm_cache('cols_extra_document_' .
$entity_id,$this->cols_extra);
-
- }
- else
- {
- $this->uicols =
$this->bocommon->fm_cache('uicols_document_' . $entity_id);
- $cols_return =
$this->bocommon->fm_cache('cols_return_document_' . $entity_id);
- $type_id =
$this->bocommon->fm_cache('type_id_document_' . $entity_id);
- $this->cols_extra =
$this->bocommon->fm_cache('cols_extra_document_' . $entity_id);
- }
-
- $groupmethod= " GROUP BY
fm_document.location_code,fm_document.address ";
-
- if ($entity_id)
- {
-
- $groupmethod.= "
,fm_document.p_entity_id,fm_entity_category.name,fm_document.p_num,fm_document.p_cat_id";
- }
-
- if ($order)
- {
- $ordermethod = " order by fm_document.$order
$sort";
- }
- else
- {
- $ordermethod = ' order by
fm_document.location_code ASC';
- }
-
- $where= 'WHERE';
-
- if(!$entity_id)
- {
- $filtermethod .= " $where ( fm_document.p_num
is NULL OR fm_document.p_num='') ";
- $where= 'AND';
- }
-
- if ($cat_id)
- {
- $filtermethod .= " $where
fm_document.p_cat_id=$cat_id ";
- $where= 'AND';
- }
-
- if ($doc_type > 0)
- {
- $filtermethod .= " $where
fm_document.category='$doc_type' ";
- $where= 'AND';
- }
-
- if ($filter!='all' && $filter)
- {
- $filtermethod .= " $where
fm_document.user_id='$filter' ";
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " $where (fm_document.address
$this->like '%$query%' or fm_document.location_code $this->like '%$query%')";
- }
-
-
- $sql .= " $filtermethod $querymethod $groupmethod";
-
-//echo $sql;
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
-
- $j=0;
- while ($this->db->next_record())
- {
- for ($i=0;$i<count($cols_return);$i++)
- {
- $document_list[$j][$cols_return[$i]] =
stripslashes($this->db->f($cols_return[$i]));
- }
-
- $location_code= $this->db->f('location_code');
- $location = split('-',$location_code);
- for ($m=0;$m<count($location);$m++)
- {
- $document_list[$j]['loc' . ($m+1)] =
$location[$m];
-
$document_list[$j]['query_location']['loc' . ($m+1)]=implode("-",
array_slice($location, 0, ($m+1)));
- }
-
- $j++;
- }
-
-
-//_debug_array($document_list);
- return $document_list;
- }
-
- function read_at_location($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $entity_id =
(isset($data['entity_id'])?$data['entity_id']:0);
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $doc_type =
(isset($data['doc_type'])?$data['doc_type']:0);
- $location_code =
(isset($data['location_code'])?$data['location_code']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by location_code ASC';
- }
-
- $filtermethod = " fm_document.location_code $this->like
'%$location_code%'";
-
- if ($doc_type > 0)
- {
- $filtermethod .= " AND
fm_document.category='$doc_type' ";
- }
- if ($cat_id > 0)
- {
- $filtermethod .= " AND
fm_document.p_cat_id=$cat_id AND fm_document.p_entity_id=$entity_id ";
- }
-
-
- if ($filter)
- {
- $filtermethod .= " AND
fm_document.user_id='$filter' ";
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " AND fm_document.title
$this->like '%$query%' or fm_document.document_name $this->like '%$query%'";
- }
-
- $sql = "SELECT fm_document.*,
fm_document_category.descr as category FROM fm_document $this->join
fm_document_category on fm_document.category = fm_document_category.id WHERE
$filtermethod $querymethod ";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $document_list[] = array
- (
- 'document_id' =>
$this->db->f('id'),
- 'document_name' =>
$this->db->f('document_name'),
- 'link' =>
$this->db->f('link'),
- 'title' =>
$this->db->f('title'),
- 'doc_type' =>
$this->db->f('category'),
- 'user_id' =>
$this->db->f('user_id')
- );
- }
-//_debug_array($document_list);
- return $document_list;
- }
-
- function read_single($document_id)
- {
- $sql = "SELECT * from fm_document where
id='$document_id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $document['document_id'] =
$this->db->f('id');
- $document['title']
= $this->db->f('title');
- $document['document_name'] =
$this->db->f('document_name');
- $document['link']
= $this->db->f('link');
- $document['location_code'] =
$this->db->f('location_code');
- $document['branch_id'] =
$this->db->f('branch_id');
- $document['version'] =
$this->db->f('version');
- $document['vendor_id'] =
$this->db->f('vendor_id');
- $document['floor_id'] =
$this->db->f('floor_id');
- $document['descr']
= $this->db->f('descr');
- $document['status']
= $this->db->f('status');
- $document['user_id'] =
$this->db->f('user_id');
- $document['coordinator'] =
$this->db->f('coordinator');
- $document['access']
= $this->db->f('access');
- $document['document_date'] =
$this->db->f('document_date');
- $document['doc_type'] =
$this->db->f('category');
- $document['p_num']
= $this->db->f('p_num');
- $document['p_entity_id'] =
$this->db->f('p_entity_id');
- $document['p_cat_id'] =
$this->db->f('p_cat_id');
- }
-
-//_debug_array($document);
- return $document;
- }
-
- function add($document)
- {
- while (is_array($document['location']) &&
list($input_name,$value) = each($document['location']))
- {
- if($value)
- {
- $cols[] = $input_name;
- $vals[] = $value;
- }
- }
-
- while (is_array($document['extra']) &&
list($input_name,$value) = each($document['extra']))
- {
- if($value)
- {
- $cols[] = $input_name;
- $vals[] = $value;
- }
- }
-
- if($cols)
- {
- $cols = "," . implode(",", $cols);
- $vals = ",'" . implode("','", $vals) . "'";
- }
-
- if($document['street_name'])
- {
- $address[]= $document['street_name'];
- $address[]= $document['street_number'];
- $address =
$this->db->db_addslashes(implode(" ", $address));
- }
-
- if(!$address)
- {
- $address =
$this->db->db_addslashes($document['location_name']);
- }
-
- $document['descr'] =
$this->db->db_addslashes($document['descr']);
- $document['name'] =
$this->db->db_addslashes($document['name']);
- $document['title'] =
$this->db->db_addslashes($document['title']);
-//_debug_array($document);
-
- $values= array(
- $document['document_name'],
- $document['link'],
- $document['title'],
- 'public',
- $document['doc_type'],
- time(),
- $document['document_date'],
- $document['version'],
- $document['coordinator'],
- $document['status'],
- $document['descr'],
- $document['location_code'],
- $address,
- $document['branch_id'],
- $document['vendor_id'],
- $this->account);
-
- $values = $this->bocommon->validate_db_insert($values);
-
- $this->db->query("INSERT INTO fm_document
(document_name,link,title,access,category,entry_date,document_date,version,coordinator,status,"
- .
"descr,location_code,address,branch_id,vendor_id,user_id $cols) "
- . "VALUES ($values $vals )",__LINE__,__FILE__);
-
- $receipt['document_id'] =
$this->db->get_last_insert_id('fm_document','id');
-
-
$this->historylog->add('SO',$receipt['document_id'],$document['status']);
-
$this->historylog->add('TO',$receipt['document_id'],$document['doc_type']);
- if($document['coordinator'])
- {
-
$this->historylog->add('CO',$receipt['document_id'],$document['coordinator']);
- }
- if($document['document_name'])
- {
-
$this->historylog->add('FO',$receipt['document_id'],$document['coodocument_name']);
- }
- if($document['link'])
- {
-
$this->historylog->add('LO',$receipt['document_id'],$document['link']);
- }
-
- $receipt['message'][] = array('msg'=>lang('document %1
has been saved',"'".$document['document_name']."'"));
- return $receipt;
- }
-
- function edit($document)
- {
- while (is_array($document['location']) &&
list($input_name,$value) = each($document['location']))
- {
- $vals[] = "$input_name = '$value'";
- }
-
- while (is_array($document['extra']) &&
list($input_name,$value) = each($document['extra']))
- {
- $vals[] = "$input_name = '$value'";
- }
-
- if($vals)
- {
- $vals = "," . implode(",",$vals);
- }
-
- if($document['street_name'])
- {
- $address[]= $document['street_name'];
- $address[]= $document['street_number'];
- $address =
$this->db->db_addslashes(implode(" ", $address));
- }
-
- if(!$address)
- {
- $address =
$this->db->db_addslashes($document['location_name']);
- }
-
- $this->db->query("SELECT
status,category,coordinator,document_name,loc1,link,p_num FROM fm_document
where id='" .$document['document_id']."'",__LINE__,__FILE__);
- $this->db->next_record();
-
- $old_status = $this->db->f('status');
- $old_doc_type = $this->db->f('category');
- $old_coordinator = $this->db->f('coordinator');
- $old_document_name = $this->db->f('document_name');
- $old_loc1 = $this->db->f('loc1');
- $old_link = $this->db->f('link');
- $old_p_num = $this->db->f('p_num');
-
- if ($old_status != $document['status'])
- {
-
$this->historylog->add('S',$document['document_id'],$document['status']);
- }
- if ($old_doc_type != $document['doc_type'])
- {
-
$this->historylog->add('T',$document['document_id'],$document['doc_type']);
- }
- if ((int)$old_coordinator !=
(int)$document['coordinator'])
- {
-
$this->historylog->add('C',$document['document_id'],$document['coordinator']);
- }
-
- if($document['document_name_orig'] &&
!$document['document_name'] )
- {
- $document['document_name'] =
$document['document_name_orig'];
- }
-
- if($old_link !=$document['link'] )
- {
-
$this->historylog->add('L',$document['document_id'],$document['link']);
- $alter_link=True;
- }
-
-//_debug_array($document);
- if ($old_document_name && ($old_document_name !=
$document['document_name']))
- {
- if($document['link'] && !$alter_link)
- {
-
$this->historylog->add('L',$document['document_id'],$document['link']);
- }
- else
- {
-
$this->historylog->add('F',$document['document_id'],$document['document_name']);
- }
-
- if($old_p_num)
- {
- $file = $this->fakebase. SEP .
'document' . SEP . $old_loc1 . SEP . $document['entity_name'] . SEP .
$document['category_name'] . SEP . $p_num . SEP . $old_document_name;
- }
- else
- {
- $file = $this->fakebase. SEP .
'document' . SEP . $old_loc1 . SEP . $old_document_name;
- }
-
- $receipt= $this->delete_file($file);
- }
-
- if($document['link'])
- {
- unset($document['document_name']);
- }
-
- $document['descr'] =
$this->db->db_addslashes($document['descr']);
- $document['name'] =
$this->db->db_addslashes($document['name']);
- $document['title'] =
$this->db->db_addslashes($document['title']);
-
- $value_set=array(
- 'document_name' =>$document['document_name'],
- 'link' =>$document['link'],
- 'title' =>$document['title'],
- 'branch_id'
=>$document['branch_id'],
- 'status' =>$document['status'],
- 'category' =>$document['doc_type'],
- 'document_date' =>$document['document_date'],
- 'coordinator' =>$document['coordinator'],
- 'descr' =>$document['descr'],
- 'version' =>$document['version'],
- 'location_code' =>$document['location_code'],
- 'vendor_id'
=>$document['vendor_id'],
- 'address' =>$address
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE fm_document set $value_set
$vals WHERE id= '" . $document['document_id'] ."'",__LINE__,__FILE__);
-
- $receipt['document_id'] = $document['document_id'];
- $receipt['message'][] = array('msg'=>lang('document %1
has been edited',"'".$document['title']."'"));
- return $receipt;
-
- }
-
- function delete_file($file)
- {
- if($this->vfs->file_exists(array(
- 'string' => $file,
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
- $this->vfs->override_acl = 1;
-
- if(!$this->vfs->rm (array(
- 'string' => $file,
- 'relatives' => array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to delete file') . ' :'.
$this->fakebase. SEP . 'document'. SEP . $document_name);
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('file deleted') . ' :'.
$this->fakebase. SEP . 'document'. SEP . $document_name);
- }
- $this->vfs->override_acl = 0;
- }
-
- }
-
- function delete($document_id )
- {
- $this->db->query("SELECT
document_name,location_code,p_num,p_entity_id,p_cat_id FROM fm_document where
id='$document_id'",__LINE__,__FILE__);
- $this->db->next_record();
- $document_name = $this->db->f('document_name');
- $location_code = $this->db->f('location_code');
- $p_num = $this->db->f('p_num');
- $p_entity_id = $this->db->f('p_entity_id');
- $p_cat_id = $this->db->f('p_cat_id');
-
- $location = split("-", $location_code);
- $loc1 = $location[0];
- if($p_cat_id)
- {
- $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
- $entity =
$boadmin_entity->read_single($p_entity_id,false);
- $category =
$boadmin_entity->read_single_category($p_entity_id,$p_cat_id);
- }
-
- if($document_name)
- {
- if($p_num)
- {
- $file = $this->fakebase. SEP .
'document' . SEP . $loc1 . SEP . $entity['name'] . SEP . $category['name'] .
SEP . $p_num . SEP . $document_name;
- }
- else
- {
- $file = $this->fakebase. SEP .
'document' . SEP . $loc1 . SEP . $document_name;
- }
-
- $receipt= $this->delete_file($file);
- }
-
- $this->db->query("DELETE FROM fm_document WHERE
id='$document_id'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_document_history
WHERE history_record_id='$document_id'",__LINE__,__FILE__);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage document
+ * @version $Id: class.sodocument.inc.php,v 1.8 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class sodocument
+ {
+
+ function sodocument()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon',True);
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->historylog =
CreateObject($this->currentapp.'.historylog','document');
+ $this->vfs =
CreateObject('phpgwapi.vfs');
+ $this->rootdir = $this->vfs->basedir;
+ $this->fakebase = $this->vfs->fakebase;
+
+ $this->socommon =
CreateObject($this->currentapp.'.socommon');
+
+ $this->join = $this->socommon->join;
+ $this->like = $this->socommon->like;
+ }
+
+ function select_doc_type_list()
+ {
+ $this->db->query("SELECT id, descr FROM
fm_document_category ORDER BY descr ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $categories[$i]['id']
= $this->db->f('id');
+ $categories[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $categories;
+ }
+
+ function read_single_category($id='')
+ {
+ $this->db->query("SELECT descr FROM
fm_document_category where id='$id' ");
+ $this->db->next_record();
+ return $this->db->f('descr');
+ }
+
+ function select_status_list()
+ {
+ $this->db->query("SELECT id, descr FROM
fm_document_status ORDER BY id ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $status_entries[$i]['id']
= $this->db->f('id');
+ $status_entries[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $status_entries;
+ }
+
+ function select_branch_list()
+ {
+ $this->db->query("SELECT id, descr FROM fm_branch ORDER
BY id ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $branch_entries[$i]['id']
= $this->db->f('id');
+ $branch_entries[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $branch_entries;
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $entity_id =
(isset($data['entity_id'])?$data['entity_id']:'');
+ $doc_type =
(isset($data['doc_type'])?$data['doc_type']:0);
+ }
+
+ $sql = $this->bocommon->fm_cache('sql_document_' .
$entity_id);
+
+ if(!$sql)
+ {
+
+ $document_table = 'fm_document';
+
+ $cols .= $document_table . '.location_code';
+ $cols_return[] = 'location_code';
+
+// $cols .= ",$document_table.id as document_id";
+// $cols_return[] =
'document_id';
+
+ if ($entity_id)
+ {
+ $cols .= ",$document_table.p_num as
p_num";
+ $cols_return[]
= 'p_num';
+ $uicols['input_type'][] =
'text';
+ $uicols['name'][]
= 'p_num';
+ $uicols['descr'][]
= lang('ID');
+ $uicols['statustext'][] =
lang('ID');
+
+ $cols .= ',fm_entity_category.name as
category';
+ $cols_return[]
= 'category';
+ $uicols['input_type'][] =
'text';
+ $uicols['name'][]
= 'category';
+ $uicols['descr'][]
= lang('Type');
+ $uicols['statustext'][] =
lang('Type');
+
+ $cols .= ",$document_table.p_entity_id";
+ $cols_return[]
= 'p_entity_id';
+ $cols .= ",$document_table.p_cat_id";
+ $cols_return[]
= 'p_cat_id';
+
+ $joinmethod .= " $this->join
fm_entity_category ON (fm_entity_category.entity_id
=$document_table.p_entity_id AND fm_entity_category.id =
$document_table.p_cat_id))";
+ $paranthesis .='(';
+
+ }
+
+
+ $sql =
$this->bocommon->generate_sql(array('entity_table'=>$document_table,'cols'=>$cols,'cols_return'=>$cols_return,
+
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query));
+
+ $this->bocommon->fm_cache('sql_document_' .
$entity_id,$sql);
+
+ $this->uicols =
$this->bocommon->uicols;
+ $cols_return =
$this->bocommon->cols_return;
+ $type_id =
$this->bocommon->type_id;
+ $this->cols_extra =
$this->bocommon->cols_extra;
+
+ $this->bocommon->fm_cache('uicols_document_' .
$entity_id,$this->uicols);
+
$this->bocommon->fm_cache('cols_return_document_' . $entity_id,$cols_return);
+ $this->bocommon->fm_cache('type_id_document_' .
$entity_id,$type_id);
+
$this->bocommon->fm_cache('cols_extra_document_' .
$entity_id,$this->cols_extra);
+
+ }
+ else
+ {
+ $this->uicols =
$this->bocommon->fm_cache('uicols_document_' . $entity_id);
+ $cols_return =
$this->bocommon->fm_cache('cols_return_document_' . $entity_id);
+ $type_id =
$this->bocommon->fm_cache('type_id_document_' . $entity_id);
+ $this->cols_extra =
$this->bocommon->fm_cache('cols_extra_document_' . $entity_id);
+ }
+
+ $groupmethod= " GROUP BY
fm_document.location_code,fm_document.address ";
+
+ if ($entity_id)
+ {
+
+ $groupmethod.= "
,fm_document.p_entity_id,fm_entity_category.name,fm_document.p_num,fm_document.p_cat_id";
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by fm_document.$order
$sort";
+ }
+ else
+ {
+ $ordermethod = ' order by
fm_document.location_code ASC';
+ }
+
+ $where= 'WHERE';
+
+ if(!$entity_id)
+ {
+ $filtermethod .= " $where ( fm_document.p_num
is NULL OR fm_document.p_num='') ";
+ $where= 'AND';
+ }
+
+ if ($cat_id)
+ {
+ $filtermethod .= " $where
fm_document.p_cat_id=$cat_id ";
+ $where= 'AND';
+ }
+
+ if ($doc_type > 0)
+ {
+ $filtermethod .= " $where
fm_document.category='$doc_type' ";
+ $where= 'AND';
+ }
+
+ if ($filter!='all' && $filter)
+ {
+ $filtermethod .= " $where
fm_document.user_id='$filter' ";
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " $where (fm_document.address
$this->like '%$query%' or fm_document.location_code $this->like '%$query%')";
+ }
+
+
+ $sql .= " $filtermethod $querymethod $groupmethod";
+
+//echo $sql;
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+
+ $j=0;
+ while ($this->db->next_record())
+ {
+ for ($i=0;$i<count($cols_return);$i++)
+ {
+ $document_list[$j][$cols_return[$i]] =
stripslashes($this->db->f($cols_return[$i]));
+ }
+
+ $location_code= $this->db->f('location_code');
+ $location = split('-',$location_code);
+ for ($m=0;$m<count($location);$m++)
+ {
+ $document_list[$j]['loc' . ($m+1)] =
$location[$m];
+
$document_list[$j]['query_location']['loc' . ($m+1)]=implode("-",
array_slice($location, 0, ($m+1)));
+ }
+
+ $j++;
+ }
+
+
+//_debug_array($document_list);
+ return $document_list;
+ }
+
+ function read_at_location($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $entity_id =
(isset($data['entity_id'])?$data['entity_id']:0);
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $doc_type =
(isset($data['doc_type'])?$data['doc_type']:0);
+ $location_code =
(isset($data['location_code'])?$data['location_code']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by location_code ASC';
+ }
+
+ $filtermethod = " fm_document.location_code $this->like
'%$location_code%'";
+
+ if ($doc_type > 0)
+ {
+ $filtermethod .= " AND
fm_document.category='$doc_type' ";
+ }
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " AND
fm_document.p_cat_id=$cat_id AND fm_document.p_entity_id=$entity_id ";
+ }
+
+
+ if ($filter)
+ {
+ $filtermethod .= " AND
fm_document.user_id='$filter' ";
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " AND fm_document.title
$this->like '%$query%' or fm_document.document_name $this->like '%$query%'";
+ }
+
+ $sql = "SELECT fm_document.*,
fm_document_category.descr as category FROM fm_document $this->join
fm_document_category on fm_document.category = fm_document_category.id WHERE
$filtermethod $querymethod ";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $document_list[] = array
+ (
+ 'document_id' =>
$this->db->f('id'),
+ 'document_name' =>
$this->db->f('document_name'),
+ 'link' =>
$this->db->f('link'),
+ 'title' =>
$this->db->f('title'),
+ 'doc_type' =>
$this->db->f('category'),
+ 'user_id' =>
$this->db->f('user_id')
+ );
+ }
+//_debug_array($document_list);
+ return $document_list;
+ }
+
+ function read_single($document_id)
+ {
+ $sql = "SELECT * from fm_document where
id='$document_id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $document['document_id'] =
$this->db->f('id');
+ $document['title']
= $this->db->f('title');
+ $document['document_name'] =
$this->db->f('document_name');
+ $document['link']
= $this->db->f('link');
+ $document['location_code'] =
$this->db->f('location_code');
+ $document['branch_id'] =
$this->db->f('branch_id');
+ $document['version'] =
$this->db->f('version');
+ $document['vendor_id'] =
$this->db->f('vendor_id');
+ $document['floor_id'] =
$this->db->f('floor_id');
+ $document['descr']
= $this->db->f('descr');
+ $document['status']
= $this->db->f('status');
+ $document['user_id'] =
$this->db->f('user_id');
+ $document['coordinator'] =
$this->db->f('coordinator');
+ $document['access']
= $this->db->f('access');
+ $document['document_date'] =
$this->db->f('document_date');
+ $document['doc_type'] =
$this->db->f('category');
+ $document['p_num']
= $this->db->f('p_num');
+ $document['p_entity_id'] =
$this->db->f('p_entity_id');
+ $document['p_cat_id'] =
$this->db->f('p_cat_id');
+ }
+
+//_debug_array($document);
+ return $document;
+ }
+
+ function add($document)
+ {
+ while (is_array($document['location']) &&
list($input_name,$value) = each($document['location']))
+ {
+ if($value)
+ {
+ $cols[] = $input_name;
+ $vals[] = $value;
+ }
+ }
+
+ while (is_array($document['extra']) &&
list($input_name,$value) = each($document['extra']))
+ {
+ if($value)
+ {
+ $cols[] = $input_name;
+ $vals[] = $value;
+ }
+ }
+
+ if($cols)
+ {
+ $cols = "," . implode(",", $cols);
+ $vals = ",'" . implode("','", $vals) . "'";
+ }
+
+ if($document['street_name'])
+ {
+ $address[]= $document['street_name'];
+ $address[]= $document['street_number'];
+ $address =
$this->db->db_addslashes(implode(" ", $address));
+ }
+
+ if(!$address)
+ {
+ $address =
$this->db->db_addslashes($document['location_name']);
+ }
+
+ $document['descr'] =
$this->db->db_addslashes($document['descr']);
+ $document['name'] =
$this->db->db_addslashes($document['name']);
+ $document['title'] =
$this->db->db_addslashes($document['title']);
+//_debug_array($document);
+
+ $values= array(
+ $document['document_name'],
+ $document['link'],
+ $document['title'],
+ 'public',
+ $document['doc_type'],
+ time(),
+ $document['document_date'],
+ $document['version'],
+ $document['coordinator'],
+ $document['status'],
+ $document['descr'],
+ $document['location_code'],
+ $address,
+ $document['branch_id'],
+ $document['vendor_id'],
+ $this->account);
+
+ $values = $this->bocommon->validate_db_insert($values);
+
+ $this->db->query("INSERT INTO fm_document
(document_name,link,title,access,category,entry_date,document_date,version,coordinator,status,"
+ .
"descr,location_code,address,branch_id,vendor_id,user_id $cols) "
+ . "VALUES ($values $vals )",__LINE__,__FILE__);
+
+ $receipt['document_id'] =
$this->db->get_last_insert_id('fm_document','id');
+
+
$this->historylog->add('SO',$receipt['document_id'],$document['status']);
+
$this->historylog->add('TO',$receipt['document_id'],$document['doc_type']);
+ if($document['coordinator'])
+ {
+
$this->historylog->add('CO',$receipt['document_id'],$document['coordinator']);
+ }
+ if($document['document_name'])
+ {
+
$this->historylog->add('FO',$receipt['document_id'],$document['coodocument_name']);
+ }
+ if($document['link'])
+ {
+
$this->historylog->add('LO',$receipt['document_id'],$document['link']);
+ }
+
+ $receipt['message'][] = array('msg'=>lang('document %1
has been saved',"'".$document['document_name']."'"));
+ return $receipt;
+ }
+
+ function edit($document)
+ {
+ while (is_array($document['location']) &&
list($input_name,$value) = each($document['location']))
+ {
+ $vals[] = "$input_name = '$value'";
+ }
+
+ while (is_array($document['extra']) &&
list($input_name,$value) = each($document['extra']))
+ {
+ $vals[] = "$input_name = '$value'";
+ }
+
+ if($vals)
+ {
+ $vals = "," . implode(",",$vals);
+ }
+
+ if($document['street_name'])
+ {
+ $address[]= $document['street_name'];
+ $address[]= $document['street_number'];
+ $address =
$this->db->db_addslashes(implode(" ", $address));
+ }
+
+ if(!$address)
+ {
+ $address =
$this->db->db_addslashes($document['location_name']);
+ }
+
+ $this->db->query("SELECT
status,category,coordinator,document_name,loc1,link,p_num FROM fm_document
where id='" .$document['document_id']."'",__LINE__,__FILE__);
+ $this->db->next_record();
+
+ $old_status = $this->db->f('status');
+ $old_doc_type = $this->db->f('category');
+ $old_coordinator = $this->db->f('coordinator');
+ $old_document_name = $this->db->f('document_name');
+ $old_loc1 = $this->db->f('loc1');
+ $old_link = $this->db->f('link');
+ $old_p_num = $this->db->f('p_num');
+
+ if ($old_status != $document['status'])
+ {
+
$this->historylog->add('S',$document['document_id'],$document['status']);
+ }
+ if ($old_doc_type != $document['doc_type'])
+ {
+
$this->historylog->add('T',$document['document_id'],$document['doc_type']);
+ }
+ if ((int)$old_coordinator !=
(int)$document['coordinator'])
+ {
+
$this->historylog->add('C',$document['document_id'],$document['coordinator']);
+ }
+
+ if($document['document_name_orig'] &&
!$document['document_name'] )
+ {
+ $document['document_name'] =
$document['document_name_orig'];
+ }
+
+ if($old_link !=$document['link'] )
+ {
+
$this->historylog->add('L',$document['document_id'],$document['link']);
+ $alter_link=True;
+ }
+
+//_debug_array($document);
+ if ($old_document_name && ($old_document_name !=
$document['document_name']))
+ {
+ if($document['link'] && !$alter_link)
+ {
+
$this->historylog->add('L',$document['document_id'],$document['link']);
+ }
+ else
+ {
+
$this->historylog->add('F',$document['document_id'],$document['document_name']);
+ }
+
+ if($old_p_num)
+ {
+ $file = $this->fakebase. SEP .
'document' . SEP . $old_loc1 . SEP . $document['entity_name'] . SEP .
$document['category_name'] . SEP . $p_num . SEP . $old_document_name;
+ }
+ else
+ {
+ $file = $this->fakebase. SEP .
'document' . SEP . $old_loc1 . SEP . $old_document_name;
+ }
+
+ $receipt= $this->delete_file($file);
+ }
+
+ if($document['link'])
+ {
+ unset($document['document_name']);
+ }
+
+ $document['descr'] =
$this->db->db_addslashes($document['descr']);
+ $document['name'] =
$this->db->db_addslashes($document['name']);
+ $document['title'] =
$this->db->db_addslashes($document['title']);
+
+ $value_set=array(
+ 'document_name' =>$document['document_name'],
+ 'link' =>$document['link'],
+ 'title' =>$document['title'],
+ 'branch_id'
=>$document['branch_id'],
+ 'status' =>$document['status'],
+ 'category' =>$document['doc_type'],
+ 'document_date' =>$document['document_date'],
+ 'coordinator' =>$document['coordinator'],
+ 'descr' =>$document['descr'],
+ 'version' =>$document['version'],
+ 'location_code' =>$document['location_code'],
+ 'vendor_id'
=>$document['vendor_id'],
+ 'address' =>$address
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE fm_document set $value_set
$vals WHERE id= '" . $document['document_id'] ."'",__LINE__,__FILE__);
+
+ $receipt['document_id'] = $document['document_id'];
+ $receipt['message'][] = array('msg'=>lang('document %1
has been edited',"'".$document['title']."'"));
+ return $receipt;
+
+ }
+
+ function delete_file($file)
+ {
+ if($this->vfs->file_exists(array(
+ 'string' => $file,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $this->vfs->override_acl = 1;
+
+ if(!$this->vfs->rm (array(
+ 'string' => $file,
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to delete file') . ' :'.
$this->fakebase. SEP . 'document'. SEP . $document_name);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('file deleted') . ' :'.
$this->fakebase. SEP . 'document'. SEP . $document_name);
+ }
+ $this->vfs->override_acl = 0;
+ }
+
+ }
+
+ function delete($document_id )
+ {
+ $this->db->query("SELECT
document_name,location_code,p_num,p_entity_id,p_cat_id FROM fm_document where
id='$document_id'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $document_name = $this->db->f('document_name');
+ $location_code = $this->db->f('location_code');
+ $p_num = $this->db->f('p_num');
+ $p_entity_id = $this->db->f('p_entity_id');
+ $p_cat_id = $this->db->f('p_cat_id');
+
+ $location = split("-", $location_code);
+ $loc1 = $location[0];
+ if($p_cat_id)
+ {
+ $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
+ $entity =
$boadmin_entity->read_single($p_entity_id,false);
+ $category =
$boadmin_entity->read_single_category($p_entity_id,$p_cat_id);
+ }
+
+ if($document_name)
+ {
+ if($p_num)
+ {
+ $file = $this->fakebase. SEP .
'document' . SEP . $loc1 . SEP . $entity['name'] . SEP . $category['name'] .
SEP . $p_num . SEP . $document_name;
+ }
+ else
+ {
+ $file = $this->fakebase. SEP .
'document' . SEP . $loc1 . SEP . $document_name;
+ }
+
+ $receipt= $this->delete_file($file);
+ }
+
+ $this->db->query("DELETE FROM fm_document WHERE
id='$document_id'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_document_history
WHERE history_record_id='$document_id'",__LINE__,__FILE__);
+ }
+ }
+?>
Index: property/inc/class.soentity.inc.php
diff -u property/inc/class.soentity.inc.php:1.10
property/inc/class.soentity.inc.php:1.11
--- property/inc/class.soentity.inc.php:1.10 Mon Sep 19 08:35:00 2005
+++ property/inc/class.soentity.inc.php Fri Jan 27 14:05:43 2006
@@ -1,648 +1,647 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage entity
- * @version $Id: class.soentity.inc.php,v 1.10 2005/09/19 08:35:00
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class soentity
- {
- function soentity()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->join = $this->bocommon->join;
- $this->left_join = $this->bocommon->left_join;
- $this->like = $this->bocommon->like;
- }
-
- function select_status_list($entity_id,$cat_id)
- {
- if(!$entity_id || !$cat_id)
- {
- return;
- }
-
- $sql= "SELECT fm_entity_choice.id,
fm_entity_choice.value FROM fm_entity_attribute $this->join fm_entity_choice ON
"
- . " fm_entity_attribute.entity_id=
fm_entity_choice.entity_id AND "
- . " fm_entity_attribute.cat_id= fm_entity_choice.cat_id
AND "
- . " fm_entity_attribute.id= fm_entity_choice.attrib_id "
- . " WHERE fm_entity_attribute.column_name='status' "
- . " AND fm_entity_choice.entity_id=$entity_id "
- . " AND fm_entity_choice.cat_id=$cat_id ORDER BY
fm_entity_choice.id";
-
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- $i = 0;
- while ($this->db->next_record())
- {
- $status[$i]['id']
= $this->db->f('id');
- $status[$i]['name']
= stripslashes($this->db->f('value'));
- $i++;
- }
- return $status;
- }
-
-
- function read($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter = $data['filter']?$data['filter']:'all';
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $district_id =
(isset($data['district_id'])?$data['district_id']:0);
- $lookup =
(isset($data['lookup'])?$data['lookup']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $entity_id =
(isset($data['entity_id'])?$data['entity_id']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
- $status =
(isset($data['status'])?$data['status']:'');
- $start_date =
(isset($data['start_date'])?$data['start_date']:'');
- $end_date =
(isset($data['end_date'])?$data['end_date']:'');
- }
-
- if(!$entity_id || !$cat_id)
- {
- return;
- }
-
- $grants =
$GLOBALS['phpgw']->session->appsession('grants_entity_'.$entity_id.'_'.$cat_id,$this->currentapp);
-
- if(!$grants)
- {
- $this->acl2 =
CreateObject($this->currentapp.'.acl2','##DEFAULT##','##DEFAULT##');
- $grants =
$this->acl2->get_grants($this->currentapp,'.entity.' . $entity_id . '.' .
$cat_id);
-
$GLOBALS['phpgw']->session->appsession('grants_entity_'.$entity_id.'_'.$cat_id,$this->currentapp,$grants);
- }
-
-
- $sql = $this->bocommon->fm_cache('sql_entity_' .
$entity_id . '_' . $cat_id . '_' . $lookup);
-
- $entity_table = 'fm_entity_' . $entity_id . '_' .
$cat_id;
- if(!$sql)
- {
- $cols = $entity_table . '.*';
- $cols_return[] = 'location_code';
-
- $cols_return[] = 'num';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'num';
- $uicols['descr'][] =
lang('ID');
- $uicols['statustext'][] = lang('ID');
-
- $cols_return[] = 'id';
- $uicols['input_type'][] = 'hidden';
- $uicols['name'][] = 'id';
- $uicols['descr'][] = false;
- $uicols['statustext'][] = false;
- if($lookup)
- {
- $cols .= ',num as entity_num_' .
$entity_id;
- $cols_return[] = 'entity_num_' .
$entity_id;
- }
-
-
- $admin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
- $category =
$admin_entity->read_single_category($entity_id,$cat_id);
-
- $sql =
$this->bocommon->generate_sql(array('entity_table'=>$entity_table,'cols_return'=>$cols_return,'cols'=>$cols,
-
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query,'lookup'=>$lookup,'location_level'=>$category['location_level']));
-
- $this->bocommon->fm_cache('sql_entity_' .
$entity_id . '_' . $cat_id . '_' . $lookup,$sql);
- $this->bocommon->fm_cache('uicols_entityt_' .
$entity_id . '_' . $cat_id . '_' . $lookup,$this->bocommon->uicols);
-
$this->bocommon->fm_cache('cols_return_entityt_' . $entity_id . '_' . $cat_id .
'_' . $lookup,$this->bocommon->cols_return);
-
$this->bocommon->fm_cache('cols_return_lookup_entityt_' . $entity_id . '_' .
$cat_id . '_' . $lookup,$this->bocommon->cols_return_lookup);
- $this->bocommon->fm_cache('cols_extra_entityt_'
. $entity_id . '_' . $cat_id . '_' . $lookup,$this->bocommon->cols_extra);
-
- $uicols
= $this->bocommon->uicols;
- $cols_return =
$this->bocommon->cols_return;
- $this->cols_return_lookup =
$this->bocommon->cols_return_lookup;
- $this->cols_extra =
$this->bocommon->cols_extra;
- }
- else
- {
- $uicols
= $this->bocommon->fm_cache('uicols_entityt_' . $entity_id . '_' .
$cat_id . '_' . $lookup);
- $cols_return
= $this->bocommon->fm_cache('cols_return_entityt_' . $entity_id . '_' . $cat_id
. '_' . $lookup);
- $this->cols_return_lookup =
$this->bocommon->fm_cache('cols_return_lookup_entityt_' . $entity_id . '_' .
$cat_id . '_' . $lookup);
- $this->cols_extra
= $this->bocommon->fm_cache('cols_extra_entityt_' . $entity_id . '_' . $cat_id
. '_' . $lookup);
- if($lookup)
- {
- $admin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
- $category =
$admin_entity->read_single_category($entity_id,$cat_id);
- }
-
- }
-
- if ($cat_id > 0)
- {
-
$user_columns=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['entity_columns_'.$entity_id.'_'.$cat_id];
-//_debug_array($user_columns);
-
- if (isset($user_columns) AND
is_array($user_columns) AND $user_columns[0])
- {
- $i = count($uicols['name']);
- foreach($user_columns as $column_id)
- {
- $this->db->query("SELECT * FROM
fm_entity_attribute WHERE entity_id= $entity_id AND cat_id= $cat_id AND id=
$column_id");
-
- $this->db->next_record();
- $uicols['input_type'][]
= 'text';
- $uicols['name'][]
= $this->db->f('column_name');
- $uicols['descr'][]
= $this->db->f('input_text');
- $uicols['statustext'][]
= $this->db->f('statustext');
- $uicols['datatype'][$i]
= $this->db->f('datatype');
- $cols_return_extra[]= array(
- 'name' =>
$this->db->f('column_name'),
- 'datatype' =>
$this->db->f('datatype'),
- 'attrib_id' =>
$this->db->f('id')
- );
- $i++;
- }
- }
- }
- else
- {
- return;
- }
-
- $this->uicols = $uicols;
-
-//_debug_array($cols_return_extra);
- if ($order)
- {
- $ordermethod = " order by $entity_table.$order
$sort";
- }
- else
- {
- $ordermethod = " order by $entity_table.id
DESC";
- }
-
- $where= 'WHERE';
-
- if ($filter=='all')
- {
- if (is_array($grants))
- {
- while (list($user) = each($grants))
- {
- $public_user_list[] = $user;
- }
- reset($public_user_list);
- $filtermethod .= " $where (
$entity_table.user_id IN(" . implode(',',$public_user_list) . "))";
-
- $where= 'AND';
- }
-
- }
- else
- {
- $filtermethod = " $where
$entity_table.user_id=$filter ";
- $where= 'AND';
- }
-
-
- if ($status)
- {
- $filtermethod .= " $where
$entity_table.status='$status' ";
- $where= 'AND';
- }
-
- if ($district_id > 0)
- {
- $filtermethod .= " $where
district_id='$district_id' ";
- $where = 'AND';
- }
-
- if ($start_date)
- {
- $filtermethod .= " $where
$entity_table.entry_date >= $start_date AND $entity_table.entry_date <=
$end_date ";
- $where= 'AND';
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $filtermethod .= " $where (
$entity_table.location_code $this->like '%$query%' OR $entity_table.num
$this->like '%$query%' OR loc1_name $this->like '%$query%' OR address
$this->like '%$query%')";
- $where= 'OR';
-
- $this->db->query("SELECT * FROM
fm_entity_attribute where search='1' AND entity_id= $entity_id AND cat_id =
$cat_id");
-
- while ($this->db->next_record())
- {
- if($this->db->f('datatype')=='V' ||
$this->db->f('datatype')=='email' || $this->db->f('datatype')=='CH')
- {
- $querymethod[]=
"$entity_table." . $this->db->f('column_name') . " $this->like '%$query%'";
- }
- else
- {
- $querymethod[]=
"$entity_table." . $this->db->f('column_name') . " = '$query'";
- }
- }
-
- if (isset($querymethod) AND
is_array($querymethod))
- {
- $querymethod = " $where (" . implode ('
OR ',$querymethod) . ')';
- $where = 'AND';
- }
-
- }
-
- $sql .= " $filtermethod $querymethod";
-
-//echo $sql;
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- $j=0;
- $n=count($cols_return);
-//_debug_array($cols_return);
- $contacts =
CreateObject('phpgwapi.contacts');
-
- while ($this->db->next_record())
- {
- for ($i=0;$i<$n;$i++)
- {
- $entity_list[$j][$cols_return[$i]] =
$this->db->f($cols_return[$i]);
- $entity_list[$j]['grants'] =
(int)$grants[$this->db->f('user_id')];
- if($lookup)
- {
-
$entity_list[$j]['entity_cat_name_' . $entity_id] = $category['name'];
- $entity_list[$j]['entity_id_' .
$entity_id] = $entity_id;
- $entity_list[$j]['cat_id_' .
$entity_id] = $cat_id;
- }
- }
-
- for ($i=0;$i<count($cols_return_extra);$i++)
- {
- $value='';
-
$value=$this->db->f($cols_return_extra[$i]['name']);
-
-
if(($cols_return_extra[$i]['datatype']=='R' ||
$cols_return_extra[$i]['datatype']=='LB') && $value):
- {
- $sql="SELECT value FROM
fm_entity_choice where entity_id=$entity_id AND cat_id=$cat_id AND attrib_id="
.$cols_return_extra[$i]['attrib_id']. " AND id=" . $value;
- $this->db2->query($sql);
- $this->db2->next_record();
-
$entity_list[$j][$cols_return_extra[$i]['name']] = $this->db2->f('value');
- }
-
elseif($cols_return_extra[$i]['datatype']=='AB' && $value):
- {
- $contact_data =
$contacts->read_single_entry($value,array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
-
$entity_list[$j][$cols_return_extra[$i]['name']] =
$contact_data[0]['n_family'] . ', ' . $contact_data[0]['n_given'];
- }
-
elseif($cols_return_extra[$i]['datatype']=='VENDOR' && $value):
- {
- $sql="SELECT org_name FROM
fm_vendor where id=$value";
- $this->db2->query($sql);
- $this->db2->next_record();
-
$entity_list[$j][$cols_return_extra[$i]['name']] = $this->db2->f('org_name');
- }
-
elseif($cols_return_extra[$i]['datatype']=='CH' && $value):
- {
- $ch= unserialize($value);
-
- if (isset($ch) AND
is_array($ch))
- {
- for
($k=0;$k<count($ch);$k++)
- {
- $sql="SELECT
value FROM fm_entity_choice where entity_id=$entity_id AND cat_id=$cat_id AND
attrib_id=" .$cols_return_extra[$i]['attrib_id']. " AND id=" . $ch[$k];
-
$this->db2->query($sql);
- while
($this->db2->next_record())
- {
-
$ch_value[]=$this->db2->f('value');
- }
- }
-
$entity_list[$j][$cols_return_extra[$i]['name']] = @implode(",", $ch_value);
- unset($ch_value);
- }
- }
-
elseif($cols_return_extra[$i]['datatype']=='D' && $value):
- {
-//_debug_array($value);
-
-
$entity_list[$j][$cols_return_extra[$i]['name']]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($value));
- }
- else:
- {
-
$entity_list[$j][$cols_return_extra[$i]['name']]=$value;
- }
- endif;
- }
-
- $location_code= $this->db->f('location_code');
- $location = split('-',$location_code);
- for ($m=0;$m<count($location);$m++)
- {
- $entity_list[$j]['loc' . ($m+1)] =
$location[$m];
-
$entity_list[$j]['query_location']['loc' . ($m+1)]=implode("-",
array_slice($location, 0, ($m+1)));
- }
-
- $j++;
- }
-//_debug_array($entity_list);
- return $entity_list;
- }
-
- function read_single($data)
- {
- $entity_id =$data['entity_id'];
- $cat_id =$data['cat_id'];
- $id =$data['id'];
-
- $this->db->query("SELECT * FROM fm_entity_attribute
WHERE entity_id =$entity_id AND cat_id =$cat_id ORDER BY attrib_sort");
-
- while ($this->db->next_record())
- {
- $entity['attributes'][] = array
- (
- 'attrib_id' =>
$this->db->f('id'),
- 'name' =>
$this->db->f('column_name'),
- 'input_text' =>
stripslashes($this->db->f('input_text')),
- 'statustext' =>
stripslashes($this->db->f('statustext')),
-// 'statustext' => str_replace("\n","
",stripslashes($this->db->f('statustext'))),
- 'datatype' =>
$this->db->f('datatype')
- );
- }
-//_debug_array($entity);
-
- if($id)
- {
- $table='fm_entity_' . $entity_id .'_' . $cat_id;
-
- $this->db->query("SELECT * FROM $table WHERE id
=$id");
-
- if($this->db->next_record())
- {
- $entity['id']
= $id;
- $entity['num']
= $this->db->f('num');
- $entity['p_num']
= $this->db->f('p_num');
- $entity['p_entity_id'] =
$this->db->f('p_entity_id');
- $entity['p_cat_id']
= $this->db->f('p_cat_id');
- $entity['location_code'] =
$this->db->f('location_code');
- $entity['tenant_id'] =
$this->db->f('tenant_id');
- $entity['contact_phone'] =
$this->db->f('contact_phone');
- $entity['status']
= $this->db->f('status');
-
- for
($i=0;$i<count($entity['attributes']);$i++)
- {
-
$entity['attributes'][$i]['value'] =
$this->db->f($entity['attributes'][$i]['name']);
-
$entity['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($entity['attributes'][$i]['datatype']);
- }
- }
-
- $sql = "SELECT * FROM fm_origin WHERE
destination ='entity_" . $entity_id . '_' . $cat_id . "' AND destination_id =
$id";
- $this->db->query($sql,__LINE__,__FILE__);
-
- $i=-1;
- while ($this->db->next_record())
- {
- if($last_type != $this->db->f('origin'))
- {
- $i++;
- }
- $entity['origin'][$i]['type'] =
$this->db->f('origin');
- $entity['origin'][$i]['link'] =
$this->bocommon->get_origin_link($this->db->f('origin'));
- $entity['origin'][$i]['data'][]= array(
- 'id'=>
$this->db->f('origin_id'),
- 'type'=> $this->db->f('origin')
- );
-
- $last_type=$this->db->f('origin');
- }
- }
-
- return $entity;
- }
-
-
- function check_entity($entity_id,$cat_id,$num)
- {
- $table='fm_entity_' . $entity_id .'_' . $cat_id;
- $this->db->query("SELECT count(*) FROM $table where
num='$num'");
-
- $this->db->next_record();
-
- if ( $this->db->f(0))
- {
- return True;
- }
- }
-
- function generate_id($data)
- {
- $table='fm_entity_' . $data['entity_id'] .'_' .
$data['cat_id'];
- $this->db->query("select max(id) as id from $table");
- $this->db->next_record();
- $id = $this->db->f('id')+1;
-
- return $id;
- }
-
- function generate_num($entity_id,$cat_id,$id)
- {
- $this->db->query("select prefix from fm_entity_category
WHERE entity_id=$entity_id AND id=$cat_id ");
- $this->db->next_record();
- $prefix = $this->db->f('prefix');
-
- if (strlen($id) == 4)
- $return = $id;
- if (strlen($id) == 3)
- $return = "0$id";
- if (strlen($id) == 2)
- $return = "00$id";
- if (strlen($id) == 1)
- $return = "000$id";
- if (strlen($id) == 0)
- $return = "0001";
-
- return $prefix . strtoupper($return);
- }
-
-
- function add($values,$values_attribute,$entity_id,$cat_id)
- {
- if($values['street_name'])
- {
- $address[]= $values['street_name'];
- $address[]= $values['street_number'];
- $address = $this->db->db_addslashes(implode("
", $address));
- }
-
- if(!$address)
- {
- $address =
$this->db->db_addslashes($values['location_name']);
- }
-
- $values['descr'] =
$this->db->db_addslashes($values['descr']);
-
- while (is_array($values['location']) &&
list($input_name,$value) = each($values['location']))
- {
- if($value)
- {
- $cols[] = $input_name;
- $vals[] = $value;
- }
- }
-//_debug_array($values);
- while (is_array($values['extra']) &&
list($input_name,$value) = each($values['extra']))
- {
- if($value)
- {
- $cols[] = $input_name;
- $vals[] = $value;
- }
- }
-
- if (isset($values_attribute) AND
is_array($values_attribute))
- {
- foreach($values_attribute as $entry)
- {
- if($entry['value'])
- {
- $cols[] = $entry['name'];
- $vals[] = $entry['value'];
- }
- }
- }
-
- if($cols)
- {
- $cols = "," . implode(",", $cols);
- $vals = "," .
$this->bocommon->validate_db_insert($vals);
- }
-
- $table='fm_entity_' . $entity_id .'_' . $cat_id;
-
$num=$this->generate_num($entity_id,$cat_id,$values['id']);
- $this->db->transaction_begin();
-
- $this->db->query("INSERT INTO $table
(id,num,address,location_code,entry_date,user_id $cols) "
- . "VALUES ("
- . $values['id']. ",'"
- . $num . "','"
- . $address. "','"
- . $values['location_code']. "',"
- . time() . ","
- . $this->account. " $vals)",__LINE__,__FILE__);
-
- if($values['origin'][0]['data'][0]['id'])
- {
- $this->db->query("INSERT INTO fm_origin
(origin,origin_id,destination,destination_id,user_id,entry_date) "
- . "VALUES ('"
- . $values['origin'][0]['type']. "',"
- .
$values['origin'][0]['data'][0]['id']. ","
- . "'entity_" . $entity_id .'_' .
$cat_id . "',"
- . $values['id']. ","
- . $this->account. ","
- . time() . ")",__LINE__,__FILE__);
- }
-
- $this->db->transaction_commit();
-
- $receipt['message'][] = array('msg'=>lang('Entity %1
has been saved',$values['id']));
- return $receipt;
- }
-
- function edit($values,$values_attribute,$entity_id,$cat_id)
- {
-
- if($values['street_name'])
- {
- $address[]= $values['street_name'];
- $address[]= $values['street_number'];
- $address = implode(" ", $address);
- }
-
- if(!$address)
- {
- $address = $values['location_name'];
- }
-
- $values['descr'] =
$this->db->db_addslashes($values['descr']);
-
- $value_set=array(
- 'location_code' => $values['location_code'],
- 'address' =>
$this->db->db_addslashes($address)
- );
-
- while (is_array($values['location']) &&
list($column,$value) = each($values['location']))
- {
- $value_set[$column] = $value;
- }
-
- while (is_array($values['extra']) &&
list($column,$value) = each($values['extra']))
- {
- $value_set[$column] = $value;
- }
-
- if (isset($values_attribute) AND
is_array($values_attribute))
- {
- foreach($values_attribute as $entry)
- {
- if($entry['datatype']!='AB' &&
$entry['datatype']!='VENDOR')
- {
- $value_set[$entry['name']]
= $entry['value'];
- }
- }
- }
-
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $table='fm_entity_' . $entity_id .'_' . $cat_id;
-
- $this->db->transaction_begin();
-
- $this->db->query("UPDATE $table set $value_set WHERE
id=" . $values['id'],__LINE__,__FILE__);
-
- $this->db->transaction_commit();
-
- $receipt['message'][] = array('msg'=>lang('entity %1
has been edited',$values['num']));
- return $receipt;
- }
-
- function delete($entity_id,$cat_id,$id )
- {
- $table='fm_entity_' . $entity_id .'_' . $cat_id;
- $this->db->transaction_begin();
- $this->db->query("DELETE FROM $table WHERE
id=$id",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_origin WHERE
destination ='entity_" . $entity_id . '_' . $cat_id . "' AND
destination_id=$id",__LINE__,__FILE__);
- $this->db->transaction_commit();
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage entity
+ * @version $Id: class.soentity.inc.php,v 1.11 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class soentity
+ {
+ function soentity()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->left_join = $this->bocommon->left_join;
+ $this->like = $this->bocommon->like;
+ }
+
+ function select_status_list($entity_id,$cat_id)
+ {
+ if(!$entity_id || !$cat_id)
+ {
+ return;
+ }
+
+ $sql= "SELECT fm_entity_choice.id,
fm_entity_choice.value FROM fm_entity_attribute $this->join fm_entity_choice ON
"
+ . " fm_entity_attribute.entity_id=
fm_entity_choice.entity_id AND "
+ . " fm_entity_attribute.cat_id= fm_entity_choice.cat_id
AND "
+ . " fm_entity_attribute.id= fm_entity_choice.attrib_id "
+ . " WHERE fm_entity_attribute.column_name='status' "
+ . " AND fm_entity_choice.entity_id=$entity_id "
+ . " AND fm_entity_choice.cat_id=$cat_id ORDER BY
fm_entity_choice.id";
+
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $status[$i]['id']
= $this->db->f('id');
+ $status[$i]['name']
= stripslashes($this->db->f('value'));
+ $i++;
+ }
+ return $status;
+ }
+
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter = $data['filter']?$data['filter']:'all';
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $district_id =
(isset($data['district_id'])?$data['district_id']:0);
+ $lookup =
(isset($data['lookup'])?$data['lookup']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $entity_id =
(isset($data['entity_id'])?$data['entity_id']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
+ $status =
(isset($data['status'])?$data['status']:'');
+ $start_date =
(isset($data['start_date'])?$data['start_date']:'');
+ $end_date =
(isset($data['end_date'])?$data['end_date']:'');
+ }
+
+ if(!$entity_id || !$cat_id)
+ {
+ return;
+ }
+
+ $grants =
$GLOBALS['phpgw']->session->appsession('grants_entity_'.$entity_id.'_'.$cat_id,$this->currentapp);
+
+ if(!$grants)
+ {
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2','##DEFAULT##','##DEFAULT##');
+ $grants =
$this->acl2->get_grants($this->currentapp,'.entity.' . $entity_id . '.' .
$cat_id);
+
$GLOBALS['phpgw']->session->appsession('grants_entity_'.$entity_id.'_'.$cat_id,$this->currentapp,$grants);
+ }
+
+
+ $sql = $this->bocommon->fm_cache('sql_entity_' .
$entity_id . '_' . $cat_id . '_' . $lookup);
+
+ $entity_table = 'fm_entity_' . $entity_id . '_' .
$cat_id;
+ if(!$sql)
+ {
+ $cols = $entity_table . '.*';
+ $cols_return[] = 'location_code';
+
+ $cols_return[] = 'num';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'num';
+ $uicols['descr'][] =
lang('ID');
+ $uicols['statustext'][] = lang('ID');
+
+ $cols_return[] = 'id';
+ $uicols['input_type'][] = 'hidden';
+ $uicols['name'][] = 'id';
+ $uicols['descr'][] = false;
+ $uicols['statustext'][] = false;
+ if($lookup)
+ {
+ $cols .= ',num as entity_num_' .
$entity_id;
+ $cols_return[] = 'entity_num_' .
$entity_id;
+ }
+
+
+ $admin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
+ $category =
$admin_entity->read_single_category($entity_id,$cat_id);
+
+ $sql =
$this->bocommon->generate_sql(array('entity_table'=>$entity_table,'cols_return'=>$cols_return,'cols'=>$cols,
+
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query,'lookup'=>$lookup,'location_level'=>$category['location_level']));
+
+ $this->bocommon->fm_cache('sql_entity_' .
$entity_id . '_' . $cat_id . '_' . $lookup,$sql);
+ $this->bocommon->fm_cache('uicols_entityt_' .
$entity_id . '_' . $cat_id . '_' . $lookup,$this->bocommon->uicols);
+
$this->bocommon->fm_cache('cols_return_entityt_' . $entity_id . '_' . $cat_id .
'_' . $lookup,$this->bocommon->cols_return);
+
$this->bocommon->fm_cache('cols_return_lookup_entityt_' . $entity_id . '_' .
$cat_id . '_' . $lookup,$this->bocommon->cols_return_lookup);
+ $this->bocommon->fm_cache('cols_extra_entityt_'
. $entity_id . '_' . $cat_id . '_' . $lookup,$this->bocommon->cols_extra);
+
+ $uicols
= $this->bocommon->uicols;
+ $cols_return =
$this->bocommon->cols_return;
+ $this->cols_return_lookup =
$this->bocommon->cols_return_lookup;
+ $this->cols_extra =
$this->bocommon->cols_extra;
+ }
+ else
+ {
+ $uicols
= $this->bocommon->fm_cache('uicols_entityt_' . $entity_id . '_' .
$cat_id . '_' . $lookup);
+ $cols_return
= $this->bocommon->fm_cache('cols_return_entityt_' . $entity_id . '_' . $cat_id
. '_' . $lookup);
+ $this->cols_return_lookup =
$this->bocommon->fm_cache('cols_return_lookup_entityt_' . $entity_id . '_' .
$cat_id . '_' . $lookup);
+ $this->cols_extra
= $this->bocommon->fm_cache('cols_extra_entityt_' . $entity_id . '_' . $cat_id
. '_' . $lookup);
+ if($lookup)
+ {
+ $admin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
+ $category =
$admin_entity->read_single_category($entity_id,$cat_id);
+ }
+
+ }
+
+ if ($cat_id > 0)
+ {
+
$user_columns=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['entity_columns_'.$entity_id.'_'.$cat_id];
+//_debug_array($user_columns);
+
+ if (isset($user_columns) AND
is_array($user_columns) AND $user_columns[0])
+ {
+ $i = count($uicols['name']);
+ foreach($user_columns as $column_id)
+ {
+ $this->db->query("SELECT * FROM
fm_entity_attribute WHERE entity_id= $entity_id AND cat_id= $cat_id AND id=
$column_id");
+
+ $this->db->next_record();
+ $uicols['input_type'][]
= 'text';
+ $uicols['name'][]
= $this->db->f('column_name');
+ $uicols['descr'][]
= $this->db->f('input_text');
+ $uicols['statustext'][]
= $this->db->f('statustext');
+ $uicols['datatype'][$i]
= $this->db->f('datatype');
+ $cols_return_extra[]= array(
+ 'name' =>
$this->db->f('column_name'),
+ 'datatype' =>
$this->db->f('datatype'),
+ 'attrib_id' =>
$this->db->f('id')
+ );
+ $i++;
+ }
+ }
+ }
+ else
+ {
+ return;
+ }
+
+ $this->uicols = $uicols;
+
+//_debug_array($cols_return_extra);
+ if ($order)
+ {
+ $ordermethod = " order by $entity_table.$order
$sort";
+ }
+ else
+ {
+ $ordermethod = " order by $entity_table.id
DESC";
+ }
+
+ $where= 'WHERE';
+
+ if ($filter=='all')
+ {
+ if (is_array($grants))
+ {
+ while (list($user) = each($grants))
+ {
+ $public_user_list[] = $user;
+ }
+ reset($public_user_list);
+ $filtermethod .= " $where (
$entity_table.user_id IN(" . implode(',',$public_user_list) . "))";
+
+ $where= 'AND';
+ }
+
+ }
+ else
+ {
+ $filtermethod = " $where
$entity_table.user_id=$filter ";
+ $where= 'AND';
+ }
+
+
+ if ($status)
+ {
+ $filtermethod .= " $where
$entity_table.status='$status' ";
+ $where= 'AND';
+ }
+
+ if ($district_id > 0)
+ {
+ $filtermethod .= " $where
district_id='$district_id' ";
+ $where = 'AND';
+ }
+
+ if ($start_date)
+ {
+ $filtermethod .= " $where
$entity_table.entry_date >= $start_date AND $entity_table.entry_date <=
$end_date ";
+ $where= 'AND';
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $filtermethod .= " $where (
$entity_table.location_code $this->like '%$query%' OR $entity_table.num
$this->like '%$query%' OR loc1_name $this->like '%$query%' OR address
$this->like '%$query%')";
+ $where= 'OR';
+
+ $this->db->query("SELECT * FROM
fm_entity_attribute where search='1' AND entity_id= $entity_id AND cat_id =
$cat_id");
+
+ while ($this->db->next_record())
+ {
+ if($this->db->f('datatype')=='V' ||
$this->db->f('datatype')=='email' || $this->db->f('datatype')=='CH')
+ {
+ $querymethod[]=
"$entity_table." . $this->db->f('column_name') . " $this->like '%$query%'";
+ }
+ else
+ {
+ $querymethod[]=
"$entity_table." . $this->db->f('column_name') . " = '$query'";
+ }
+ }
+
+ if (isset($querymethod) AND
is_array($querymethod))
+ {
+ $querymethod = " $where (" . implode ('
OR ',$querymethod) . ')';
+ $where = 'AND';
+ }
+
+ }
+
+ $sql .= " $filtermethod $querymethod";
+
+//echo $sql;
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ $j=0;
+ $n=count($cols_return);
+//_debug_array($cols_return);
+ $contacts =
CreateObject('phpgwapi.contacts');
+
+ while ($this->db->next_record())
+ {
+ for ($i=0;$i<$n;$i++)
+ {
+ $entity_list[$j][$cols_return[$i]] =
$this->db->f($cols_return[$i]);
+ $entity_list[$j]['grants'] =
(int)$grants[$this->db->f('user_id')];
+ if($lookup)
+ {
+
$entity_list[$j]['entity_cat_name_' . $entity_id] = $category['name'];
+ $entity_list[$j]['entity_id_' .
$entity_id] = $entity_id;
+ $entity_list[$j]['cat_id_' .
$entity_id] = $cat_id;
+ }
+ }
+
+ for ($i=0;$i<count($cols_return_extra);$i++)
+ {
+ $value='';
+
$value=$this->db->f($cols_return_extra[$i]['name']);
+
+
if(($cols_return_extra[$i]['datatype']=='R' ||
$cols_return_extra[$i]['datatype']=='LB') && $value):
+ {
+ $sql="SELECT value FROM
fm_entity_choice where entity_id=$entity_id AND cat_id=$cat_id AND attrib_id="
.$cols_return_extra[$i]['attrib_id']. " AND id=" . $value;
+ $this->db2->query($sql);
+ $this->db2->next_record();
+
$entity_list[$j][$cols_return_extra[$i]['name']] = $this->db2->f('value');
+ }
+
elseif($cols_return_extra[$i]['datatype']=='AB' && $value):
+ {
+ $contact_data =
$contacts->read_single_entry($value,array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
+
$entity_list[$j][$cols_return_extra[$i]['name']] =
$contact_data[0]['n_family'] . ', ' . $contact_data[0]['n_given'];
+ }
+
elseif($cols_return_extra[$i]['datatype']=='VENDOR' && $value):
+ {
+ $sql="SELECT org_name FROM
fm_vendor where id=$value";
+ $this->db2->query($sql);
+ $this->db2->next_record();
+
$entity_list[$j][$cols_return_extra[$i]['name']] = $this->db2->f('org_name');
+ }
+
elseif($cols_return_extra[$i]['datatype']=='CH' && $value):
+ {
+ $ch= unserialize($value);
+
+ if (isset($ch) AND
is_array($ch))
+ {
+ for
($k=0;$k<count($ch);$k++)
+ {
+ $sql="SELECT
value FROM fm_entity_choice where entity_id=$entity_id AND cat_id=$cat_id AND
attrib_id=" .$cols_return_extra[$i]['attrib_id']. " AND id=" . $ch[$k];
+
$this->db2->query($sql);
+ while
($this->db2->next_record())
+ {
+
$ch_value[]=$this->db2->f('value');
+ }
+ }
+
$entity_list[$j][$cols_return_extra[$i]['name']] = @implode(",", $ch_value);
+ unset($ch_value);
+ }
+ }
+
elseif($cols_return_extra[$i]['datatype']=='D' && $value):
+ {
+//_debug_array($value);
+
+
$entity_list[$j][$cols_return_extra[$i]['name']]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($value));
+ }
+ else:
+ {
+
$entity_list[$j][$cols_return_extra[$i]['name']]=$value;
+ }
+ endif;
+ }
+
+ $location_code= $this->db->f('location_code');
+ $location = split('-',$location_code);
+ for ($m=0;$m<count($location);$m++)
+ {
+ $entity_list[$j]['loc' . ($m+1)] =
$location[$m];
+
$entity_list[$j]['query_location']['loc' . ($m+1)]=implode("-",
array_slice($location, 0, ($m+1)));
+ }
+
+ $j++;
+ }
+//_debug_array($entity_list);
+ return $entity_list;
+ }
+
+ function read_single($data)
+ {
+ $entity_id =$data['entity_id'];
+ $cat_id =$data['cat_id'];
+ $id =$data['id'];
+
+ $this->db->query("SELECT * FROM fm_entity_attribute
WHERE entity_id =$entity_id AND cat_id =$cat_id ORDER BY attrib_sort");
+
+ while ($this->db->next_record())
+ {
+ $entity['attributes'][] = array
+ (
+ 'attrib_id' =>
$this->db->f('id'),
+ 'name' =>
$this->db->f('column_name'),
+ 'input_text' =>
stripslashes($this->db->f('input_text')),
+ 'statustext' =>
stripslashes($this->db->f('statustext')),
+// 'statustext' => str_replace("\n","
",stripslashes($this->db->f('statustext'))),
+ 'datatype' =>
$this->db->f('datatype')
+ );
+ }
+//_debug_array($entity);
+
+ if($id)
+ {
+ $table='fm_entity_' . $entity_id .'_' . $cat_id;
+
+ $this->db->query("SELECT * FROM $table WHERE id
=$id");
+
+ if($this->db->next_record())
+ {
+ $entity['id']
= $id;
+ $entity['num']
= $this->db->f('num');
+ $entity['p_num']
= $this->db->f('p_num');
+ $entity['p_entity_id'] =
$this->db->f('p_entity_id');
+ $entity['p_cat_id']
= $this->db->f('p_cat_id');
+ $entity['location_code'] =
$this->db->f('location_code');
+ $entity['tenant_id'] =
$this->db->f('tenant_id');
+ $entity['contact_phone'] =
$this->db->f('contact_phone');
+ $entity['status']
= $this->db->f('status');
+
+ for
($i=0;$i<count($entity['attributes']);$i++)
+ {
+
$entity['attributes'][$i]['value'] =
$this->db->f($entity['attributes'][$i]['name']);
+
$entity['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($entity['attributes'][$i]['datatype']);
+ }
+ }
+
+ $sql = "SELECT * FROM fm_origin WHERE
destination ='entity_" . $entity_id . '_' . $cat_id . "' AND destination_id =
$id";
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ $i=-1;
+ while ($this->db->next_record())
+ {
+ if($last_type != $this->db->f('origin'))
+ {
+ $i++;
+ }
+ $entity['origin'][$i]['type'] =
$this->db->f('origin');
+ $entity['origin'][$i]['link'] =
$this->bocommon->get_origin_link($this->db->f('origin'));
+ $entity['origin'][$i]['data'][]= array(
+ 'id'=>
$this->db->f('origin_id'),
+ 'type'=> $this->db->f('origin')
+ );
+
+ $last_type=$this->db->f('origin');
+ }
+ }
+
+ return $entity;
+ }
+
+
+ function check_entity($entity_id,$cat_id,$num)
+ {
+ $table='fm_entity_' . $entity_id .'_' . $cat_id;
+ $this->db->query("SELECT count(*) FROM $table where
num='$num'");
+
+ $this->db->next_record();
+
+ if ( $this->db->f(0))
+ {
+ return True;
+ }
+ }
+
+ function generate_id($data)
+ {
+ $table='fm_entity_' . $data['entity_id'] .'_' .
$data['cat_id'];
+ $this->db->query("select max(id) as id from $table");
+ $this->db->next_record();
+ $id = $this->db->f('id')+1;
+
+ return $id;
+ }
+
+ function generate_num($entity_id,$cat_id,$id)
+ {
+ $this->db->query("select prefix from fm_entity_category
WHERE entity_id=$entity_id AND id=$cat_id ");
+ $this->db->next_record();
+ $prefix = $this->db->f('prefix');
+
+ if (strlen($id) == 4)
+ $return = $id;
+ if (strlen($id) == 3)
+ $return = "0$id";
+ if (strlen($id) == 2)
+ $return = "00$id";
+ if (strlen($id) == 1)
+ $return = "000$id";
+ if (strlen($id) == 0)
+ $return = "0001";
+
+ return $prefix . strtoupper($return);
+ }
+
+
+ function add($values,$values_attribute,$entity_id,$cat_id)
+ {
+ if($values['street_name'])
+ {
+ $address[]= $values['street_name'];
+ $address[]= $values['street_number'];
+ $address = $this->db->db_addslashes(implode("
", $address));
+ }
+
+ if(!$address)
+ {
+ $address =
$this->db->db_addslashes($values['location_name']);
+ }
+
+ $values['descr'] =
$this->db->db_addslashes($values['descr']);
+
+ while (is_array($values['location']) &&
list($input_name,$value) = each($values['location']))
+ {
+ if($value)
+ {
+ $cols[] = $input_name;
+ $vals[] = $value;
+ }
+ }
+//_debug_array($values);
+ while (is_array($values['extra']) &&
list($input_name,$value) = each($values['extra']))
+ {
+ if($value)
+ {
+ $cols[] = $input_name;
+ $vals[] = $value;
+ }
+ }
+
+ if (isset($values_attribute) AND
is_array($values_attribute))
+ {
+ foreach($values_attribute as $entry)
+ {
+ if($entry['value'])
+ {
+ $cols[] = $entry['name'];
+ $vals[] = $entry['value'];
+ }
+ }
+ }
+
+ if($cols)
+ {
+ $cols = "," . implode(",", $cols);
+ $vals = "," .
$this->bocommon->validate_db_insert($vals);
+ }
+
+ $table='fm_entity_' . $entity_id .'_' . $cat_id;
+
$num=$this->generate_num($entity_id,$cat_id,$values['id']);
+ $this->db->transaction_begin();
+
+ $this->db->query("INSERT INTO $table
(id,num,address,location_code,entry_date,user_id $cols) "
+ . "VALUES ("
+ . $values['id']. ",'"
+ . $num . "','"
+ . $address. "','"
+ . $values['location_code']. "',"
+ . time() . ","
+ . $this->account. " $vals)",__LINE__,__FILE__);
+
+ if($values['origin'][0]['data'][0]['id'])
+ {
+ $this->db->query("INSERT INTO fm_origin
(origin,origin_id,destination,destination_id,user_id,entry_date) "
+ . "VALUES ('"
+ . $values['origin'][0]['type']. "',"
+ .
$values['origin'][0]['data'][0]['id']. ","
+ . "'entity_" . $entity_id .'_' .
$cat_id . "',"
+ . $values['id']. ","
+ . $this->account. ","
+ . time() . ")",__LINE__,__FILE__);
+ }
+
+ $this->db->transaction_commit();
+
+ $receipt['message'][] = array('msg'=>lang('Entity %1
has been saved',$values['id']));
+ return $receipt;
+ }
+
+ function edit($values,$values_attribute,$entity_id,$cat_id)
+ {
+
+ if($values['street_name'])
+ {
+ $address[]= $values['street_name'];
+ $address[]= $values['street_number'];
+ $address = implode(" ", $address);
+ }
+
+ if(!$address)
+ {
+ $address = $values['location_name'];
+ }
+
+ $values['descr'] =
$this->db->db_addslashes($values['descr']);
+
+ $value_set=array(
+ 'location_code' => $values['location_code'],
+ 'address' =>
$this->db->db_addslashes($address)
+ );
+
+ while (is_array($values['location']) &&
list($column,$value) = each($values['location']))
+ {
+ $value_set[$column] = $value;
+ }
+
+ while (is_array($values['extra']) &&
list($column,$value) = each($values['extra']))
+ {
+ $value_set[$column] = $value;
+ }
+
+ if (isset($values_attribute) AND
is_array($values_attribute))
+ {
+ foreach($values_attribute as $entry)
+ {
+ if($entry['datatype']!='AB' &&
$entry['datatype']!='VENDOR')
+ {
+ $value_set[$entry['name']]
= $entry['value'];
+ }
+ }
+ }
+
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $table='fm_entity_' . $entity_id .'_' . $cat_id;
+
+ $this->db->transaction_begin();
+
+ $this->db->query("UPDATE $table set $value_set WHERE
id=" . $values['id'],__LINE__,__FILE__);
+
+ $this->db->transaction_commit();
+
+ $receipt['message'][] = array('msg'=>lang('entity %1
has been edited',$values['num']));
+ return $receipt;
+ }
+
+ function delete($entity_id,$cat_id,$id )
+ {
+ $table='fm_entity_' . $entity_id .'_' . $cat_id;
+ $this->db->transaction_begin();
+ $this->db->query("DELETE FROM $table WHERE
id=$id",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_origin WHERE
destination ='entity_" . $entity_id . '_' . $cat_id . "' AND
destination_id=$id",__LINE__,__FILE__);
+ $this->db->transaction_commit();
+ }
+ }
+?>
Index: property/inc/class.sogab.inc.php
diff -u property/inc/class.sogab.inc.php:1.12
property/inc/class.sogab.inc.php:1.13
--- property/inc/class.sogab.inc.php:1.12 Fri Aug 19 11:56:50 2005
+++ property/inc/class.sogab.inc.php Fri Jan 27 14:05:43 2006
@@ -1,484 +1,482 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage location
- * @version $Id: class.sogab.inc.php,v 1.12 2005/08/19 11:56:50 sigurdne
Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class sogab
- {
- var $gab_insert_level;
-
- function sogab($gab_insert_level)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
-
- $this->join = $this->socommon->join;
- $this->like = $this->socommon->like;
-
- $this->gab_insert_level = $gab_insert_level;
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $loc1 = (isset($data['loc1'])?$data['loc1']:'');
- $gaards_nr =
(isset($data['gaards_nr'])?$data['gaards_nr']:'');
- $bruksnr =
(isset($data['bruksnr'])?$data['bruksnr']:'');
- $feste_nr =
(isset($data['feste_nr'])?$data['feste_nr']:'');
- $seksjons_nr =
(isset($data['seksjons_nr'])?$data['seksjons_nr']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $address =
(isset($data['address'])?$data['address']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by
fm_gab_location.$order $sort";
- }
- else
- {
- $ordermethod = ' order by gab_id ASC';
- }
-
- $where = 'WHERE';
-
- if ($cat_id > 0)
- {
- $filtermethod .= " $where
fm_gab_location.category='$cat_id' ";
- $where = 'AND';
- }
-
- if ($status_id)
- {
- $filtermethod .= " $where
fm_gab_location.status='$status_id' ";
- $where = 'AND';
- }
-
- if ($address)
- {
- $filtermethod .= " $where
fm_gab_location.address $this->like '%$address%' ";
- $where = 'AND';
- }
- if ($loc1)
- {
- $filtermethod .= " $where
fm_gab_location.loc1='$loc1' ";
- $where = 'AND';
- }
-
- if ($gaards_nr)
- {
- $filtermethod .= " $where SUBSTRING(gab_id,5,5)
$this->like '%$gaards_nr%' ";
- $where = 'AND';
- }
- if ($bruksnr)
- {
- $filtermethod .= " $where
SUBSTRING(gab_id,10,4) $this->like '%$bruksnr%' ";
- $where = 'AND';
- }
- if ($feste_nr)
- {
- $filtermethod .= " $where
SUBSTRING(gab_id,14,4) $this->like '%$feste_nr%' ";
- $where = 'AND';
- }
- if ($seksjons_nr)
- {
- $filtermethod .= " $where
SUBSTRING(gab_id,18,3) $this->like '%$seksjons_nr%' ";
- $where = 'AND';
- }
-
-
- $j = $this->gab_insert_level;
- $joinmethod .= " $this->join fm_location". ($j);
- $on = 'ON';
- for ($i=($j); $i>0; $i--)
- {
- $joinmethod .= " $on (fm_gab_location.loc" .
($i). " = fm_location" . ($j) . ".loc" . ($i) . ")";
- $on = 'AND';
- }
-
- $sql = "SELECT gab_id,count(gab_id) as hits, loc" . $j
. "_name as address ,fm_gab_location.location_code, fm_gab_location.owner as
owner FROM fm_gab_location $joinmethod $filtermethod GROUP BY
gab_id,fm_gab_location.location_code,loc" . $j . "_name,owner ";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $gab_list[] = array
- (
- 'gab_id' =>
$this->db->f('gab_id'),
- 'location_code' =>
$this->db->f('location_code'),
- 'address' =>
stripslashes($this->db->f('address')),
- 'hits' =>
$this->db->f('hits'),
- 'owner' =>
$this->db->f('owner')
- );
- }
- return $gab_list;
- }
-
- function read_detail($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $gab_id =
(isset($data['gab_id'])?$data['gab_id']:'0');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- }
-
-
- $entity_table = 'fm_gab_location';
-
- $cols .= $entity_table . '.location_code,';
- $cols .= $entity_table . '.owner';
-
- $cols_return[] = 'location_code';
- $cols .= ',gab_id';
- $cols_return[] = 'gab_id';
- $cols_return[] = 'owner';
-
-
- $sql =
$this->bocommon->generate_sql(array('entity_table'=>$entity_table,'cols'=>$cols,'cols_return'=>$cols_return,
-
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query));
-
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by
fm_gab_location.location_code ASC';
- }
-
- $filtermethod = " WHERE
fm_gab_location.gab_id='$gab_id'";
-
- if ($cat_id > 0)
- {
- $filtermethod .= " AND
fm_gab_location.category='$cat_id' ";
- }
-
- if ($status_id)
- {
- $filtermethod .= " AND
fm_gab_location.status='$status_id' ";
- }
-
- $sql .= " $filtermethod ";
-//echo $sql;
- $this->uicols = $this->bocommon->uicols;
- $cols_return = $this->bocommon->cols_return;
- $type_id =
$this->bocommon->type_id;
- $this->cols_extra = $this->bocommon->cols_extra;
-
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- $j=0;
- while ($this->db->next_record())
- {
- for ($i=0;$i<count($cols_return);$i++)
- {
- $gab_list[$j][$cols_return[$i]] =
$this->db->f($cols_return[$i]);
- }
-
- $location_code= $this->db->f('location_code');
- $location = split('-',$location_code);
- for ($m=0;$m<count($location);$m++)
- {
- $gab_list[$j]['loc' . ($m+1)] =
$location[$m];
- $gab_list[$j]['query_location']['loc' .
($m+1)]=implode("-", array_slice($location, 0, ($m+1)));
- }
-
- $j++;
- }
- return $gab_list;
- }
-
- function read_single($gab_id='',$location_code='')
- {
- $sql = "SELECT * from fm_gab_location where
gab_id='$gab_id' and location_code='$location_code' ";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $gab['location_code'] =
$location_code;
- $gab['remark'] =
$this->db->f('remark');
- $gab['owner'] =
$this->db->f('owner');
- }
-
-//_debug_array($gab);
- return $gab;
- }
-
- function exist_gab_location($gab_id='',$location_code='')
- {
- $this->db2->query("SELECT count(*) FROM fm_gab_location
where gab_id='$gab_id' and location_code='$location_code'");
-
- $this->db2->next_record();
-
- if ( $this->db2->f(0))
- {
- return True;
- }
- }
-
-
- function add($gab)
- {
- $location = explode('-', $gab['location_code']);
- $next_type = count($location)+1;
-
-//_debug_array($gab);
-
- $where= 'WHERE';
- for ($i=0;$i<count($location);$i++)
- {
- $where_condition .= " $where loc" . ($i+1) .
"='" . $location[$i] . "'";
- $where= 'AND';
- }
-
- $gab['remark'] =
$this->db->db_addslashes($gab['remark']);
-
- if(!$gab['owner'])
- {
- $gab['owner']='no';
- }
-
-
- $gab_id= $gab['kommune_nr'] .
sprintf("%05s",$gab['gaards_nr']) . sprintf("%04s",$gab['bruks_nr']) .
sprintf("%04s",$gab['feste_nr']) . sprintf("%03s",$gab['seksjons_nr']);
-
- if($gab['propagate'] && ($next_type <
($this->gab_insert_level+1)))
- {
-
- $sql = 'SELECT location_code,loc' .
$this->gab_insert_level . '_name as location_name FROM fm_location' .
$this->gab_insert_level . " $where_condition ";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
-
if(!$this->exist_gab_location($gab_id,$this->db->f('location_code')))
- {
- $gab_insert[] =
array('location_code' => $this->db->f('location_code'),
-
'gab_id' => $gab_id,
-
'location_name' => $this->db->f('location_name'),
-
'remark' => $gab['remark'],
-
'owner' => $gab['owner']);
- }
- else
- {
- $gab_update[] =
array('location_code' => $this->db->f('location_code'),
-
'gab_id' => $gab_id,
-
'location_name' => $this->db->f('location_name'),
-
'remark' => $gab['remark'],
-
'owner' => $gab['owner']);
- }
- }
- }
- else
- {
- if(count($location)==$this->gab_insert_level)
- {
- $gab_insert[] = array('location_code'=>
$gab['location_code'],
-
'gab_id' => $gab_id,
-
'street_name' => $gab['street_name'],
-
'street_number' => $gab['street_number'],
-
'location_name' => $gab['location_name'],
-
'remark' => $gab['remark'],
-
'owner' => $gab['owner']);
- }
- }
-
- if($gab_insert)
- {
- $receipt = $this->insert($gab_insert);
- }
- else
- {
- $receipt['error'][] = array('msg'=>lang('Could
not find any location to save to!'));
- }
-
- if($gab_update)
- {
- $receipt = $this->update($gab_update,$receipt);
- }
-
- $receipt['gab_id'] = $gab_id;
-
- return $receipt;
- }
-
-
- function insert($gab_insert)
- {
- $receipt['message'][] = array('msg'=>lang('gab %1 has
been added',$gab_insert[0]['gab_id']));
-
- for ($i=0;$i<count($gab_insert);$i++)
- {
- $location = explode('-',
$gab_insert[$i]['location_code']);
-
- while (is_array($location) &&
list($input_name,$value) = each($location))
- {
- if($value)
- {
- $col[] = 'loc' .
($input_name+1);
- $val[] = $value;
- }
- }
-
- if($col)
- {
- $cols = "," . implode(",", $col);
- $vals = ",'" . implode("','", $val) .
"'";
- }
-
- if($gab_insert[$i]['street_name'])
- {
- $address[]=
$gab_insert[$i]['street_name'];
- $address[]=
$gab_insert[$i]['street_number'];
- $address =
$this->db->db_addslashes(implode(" ", $address));
- }
-
- if(!$address)
- {
- $address =
$this->db->db_addslashes($gab_insert[$i]['location_name']);
- }
-
- $this->db->query("INSERT INTO fm_gab_location
(location_code,gab_id,remark,owner,entry_date,user_id,address $cols) "
- . "VALUES ('"
- . $gab_insert[$i]['location_code'].
"','"
- . $gab_insert[$i]['gab_id']. "','"
- . $gab_insert[$i]['remark']. "','"
- . $gab_insert[$i]['owner']. "','"
- . time() . "','"
- . $this->account. "','"
- . $address . "' $vals
)",__LINE__,__FILE__);
-
- $receipt['message'][] =
array('msg'=>lang('at location %1',$gab_insert[$i]['location_code']));
-
- unset($location);
- unset($col);
- unset($val);
- unset($cols);
- unset($vals);
- unset($address);
-
- }
-
-
- return $receipt;
- }
-
- function update($gab_update,$receipt)
- {
- $receipt['message'][] = array('msg'=>lang('gab %1 has
been updated',$gab_update[0]['gab_id']));
-
- for ($i=0;$i<count($gab_update);$i++)
- {
- $this->db->query("UPDATE fm_gab_location set
- remark ='" .
$gab_update[$i]['remark'] . "',
- owner ='" .
$gab_update[$i]['owner'] . "',
- entry_date ='" .
time() . "',
- user_id ='" .
$this->account
- . "' WHERE location_code = '" .
$gab_update[$i]['location_code'] ."' AND gab_id= '" . $gab_update[$i]['gab_id']
. "'",__LINE__,__FILE__);
-
- $receipt['message'][] =
array('msg'=>lang('at location %1',$gab_update[$i]['location_code']));
- }
-
- return $receipt;
- }
-
- function edit($gab)
- {
- $location = explode('-', $gab['location_code']);
-
-//_debug_array($gab);
-
- if(!$gab['owner'])
- {
- $gab['owner']='no';
- }
-
- if(count($location)==$this->gab_insert_level)
- {
-
- $this->db->query("UPDATE fm_gab_location set
- remark ='" .
$gab['remark'] . "',
- owner ='" .
$gab['owner'] . "',
- entry_date ='" .
time() . "',
- user_id ='" .
$this->account
- . "' WHERE location_code= '" .
$gab['location_code'] ."' and gab_id= '" . $gab['gab_id']
."'",__LINE__,__FILE__);
-
- $receipt['message'][] = array('msg'=>lang('gab
%1 has been edited',"'".$gab['gab_id']."'"));
- $receipt['message'][] = array('msg'=>lang('at
location %1',$gab['location_code']));
- }
- else
- {
- $receipt['error'][] =
array('msg'=>lang('Nothing to do !'));
- }
- $receipt['gab_id'] = $gab['gab_id'];
- return $receipt;
-
- }
-
- function delete($gab_id='',$location_code='')
- {
- $this->db->query("DELETE FROM fm_gab_location WHERE
gab_id='$gab_id' and location_code='$location_code'",__LINE__,__FILE__);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage location
+ * @version $Id: class.sogab.inc.php,v 1.13 2006/01/27 14:05:43 sigurdne
Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class sogab
+ {
+ var $gab_insert_level;
+
+ function sogab($gab_insert_level)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->like = $this->bocommon->like;
+
+ $this->gab_insert_level = $gab_insert_level;
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $loc1 = (isset($data['loc1'])?$data['loc1']:'');
+ $gaards_nr =
(isset($data['gaards_nr'])?$data['gaards_nr']:'');
+ $bruksnr =
(isset($data['bruksnr'])?$data['bruksnr']:'');
+ $feste_nr =
(isset($data['feste_nr'])?$data['feste_nr']:'');
+ $seksjons_nr =
(isset($data['seksjons_nr'])?$data['seksjons_nr']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $address =
(isset($data['address'])?$data['address']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by
fm_gab_location.$order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by gab_id ASC';
+ }
+
+ $where = 'WHERE';
+
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " $where
fm_gab_location.category='$cat_id' ";
+ $where = 'AND';
+ }
+
+ if ($status_id)
+ {
+ $filtermethod .= " $where
fm_gab_location.status='$status_id' ";
+ $where = 'AND';
+ }
+
+ if ($address)
+ {
+ $filtermethod .= " $where
fm_gab_location.address $this->like '%$address%' ";
+ $where = 'AND';
+ }
+ if ($loc1)
+ {
+ $filtermethod .= " $where
fm_gab_location.loc1='$loc1' ";
+ $where = 'AND';
+ }
+
+ if ($gaards_nr)
+ {
+ $filtermethod .= " $where SUBSTRING(gab_id,5,5)
$this->like '%$gaards_nr%' ";
+ $where = 'AND';
+ }
+ if ($bruksnr)
+ {
+ $filtermethod .= " $where
SUBSTRING(gab_id,10,4) $this->like '%$bruksnr%' ";
+ $where = 'AND';
+ }
+ if ($feste_nr)
+ {
+ $filtermethod .= " $where
SUBSTRING(gab_id,14,4) $this->like '%$feste_nr%' ";
+ $where = 'AND';
+ }
+ if ($seksjons_nr)
+ {
+ $filtermethod .= " $where
SUBSTRING(gab_id,18,3) $this->like '%$seksjons_nr%' ";
+ $where = 'AND';
+ }
+
+
+ $j = $this->gab_insert_level;
+ $joinmethod .= " $this->join fm_location". ($j);
+ $on = 'ON';
+ for ($i=($j); $i>0; $i--)
+ {
+ $joinmethod .= " $on (fm_gab_location.loc" .
($i). " = fm_location" . ($j) . ".loc" . ($i) . ")";
+ $on = 'AND';
+ }
+
+ $sql = "SELECT gab_id,count(gab_id) as hits, loc" . $j
. "_name as address ,fm_gab_location.location_code, fm_gab_location.owner as
owner FROM fm_gab_location $joinmethod $filtermethod GROUP BY
gab_id,fm_gab_location.location_code,loc" . $j . "_name,owner ";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $gab_list[] = array
+ (
+ 'gab_id' =>
$this->db->f('gab_id'),
+ 'location_code' =>
$this->db->f('location_code'),
+ 'address' =>
stripslashes($this->db->f('address')),
+ 'hits' =>
$this->db->f('hits'),
+ 'owner' =>
$this->db->f('owner')
+ );
+ }
+ return $gab_list;
+ }
+
+ function read_detail($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $gab_id =
(isset($data['gab_id'])?$data['gab_id']:'0');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ }
+
+
+ $entity_table = 'fm_gab_location';
+
+ $cols .= $entity_table . '.location_code,';
+ $cols .= $entity_table . '.owner';
+
+ $cols_return[] = 'location_code';
+ $cols .= ',gab_id';
+ $cols_return[] = 'gab_id';
+ $cols_return[] = 'owner';
+
+
+ $sql =
$this->bocommon->generate_sql(array('entity_table'=>$entity_table,'cols'=>$cols,'cols_return'=>$cols_return,
+
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query));
+
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by
fm_gab_location.location_code ASC';
+ }
+
+ $filtermethod = " WHERE
fm_gab_location.gab_id='$gab_id'";
+
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " AND
fm_gab_location.category='$cat_id' ";
+ }
+
+ if ($status_id)
+ {
+ $filtermethod .= " AND
fm_gab_location.status='$status_id' ";
+ }
+
+ $sql .= " $filtermethod ";
+//echo $sql;
+ $this->uicols = $this->bocommon->uicols;
+ $cols_return = $this->bocommon->cols_return;
+ $type_id =
$this->bocommon->type_id;
+ $this->cols_extra = $this->bocommon->cols_extra;
+
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ $j=0;
+ while ($this->db->next_record())
+ {
+ for ($i=0;$i<count($cols_return);$i++)
+ {
+ $gab_list[$j][$cols_return[$i]] =
$this->db->f($cols_return[$i]);
+ }
+
+ $location_code= $this->db->f('location_code');
+ $location = split('-',$location_code);
+ for ($m=0;$m<count($location);$m++)
+ {
+ $gab_list[$j]['loc' . ($m+1)] =
$location[$m];
+ $gab_list[$j]['query_location']['loc' .
($m+1)]=implode("-", array_slice($location, 0, ($m+1)));
+ }
+
+ $j++;
+ }
+ return $gab_list;
+ }
+
+ function read_single($gab_id='',$location_code='')
+ {
+ $sql = "SELECT * from fm_gab_location where
gab_id='$gab_id' and location_code='$location_code' ";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $gab['location_code'] =
$location_code;
+ $gab['remark'] =
$this->db->f('remark');
+ $gab['owner'] =
$this->db->f('owner');
+ }
+
+//_debug_array($gab);
+ return $gab;
+ }
+
+ function exist_gab_location($gab_id='',$location_code='')
+ {
+ $this->db2->query("SELECT count(*) FROM fm_gab_location
where gab_id='$gab_id' and location_code='$location_code'");
+
+ $this->db2->next_record();
+
+ if ( $this->db2->f(0))
+ {
+ return True;
+ }
+ }
+
+
+ function add($gab)
+ {
+ $location = explode('-', $gab['location_code']);
+ $next_type = count($location)+1;
+
+//_debug_array($gab);
+
+ $where= 'WHERE';
+ for ($i=0;$i<count($location);$i++)
+ {
+ $where_condition .= " $where loc" . ($i+1) .
"='" . $location[$i] . "'";
+ $where= 'AND';
+ }
+
+ $gab['remark'] =
$this->db->db_addslashes($gab['remark']);
+
+ if(!$gab['owner'])
+ {
+ $gab['owner']='no';
+ }
+
+
+ $gab_id= $gab['kommune_nr'] .
sprintf("%05s",$gab['gaards_nr']) . sprintf("%04s",$gab['bruks_nr']) .
sprintf("%04s",$gab['feste_nr']) . sprintf("%03s",$gab['seksjons_nr']);
+
+ if($gab['propagate'] && ($next_type <
($this->gab_insert_level+1)))
+ {
+
+ $sql = 'SELECT location_code,loc' .
$this->gab_insert_level . '_name as location_name FROM fm_location' .
$this->gab_insert_level . " $where_condition ";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+
if(!$this->exist_gab_location($gab_id,$this->db->f('location_code')))
+ {
+ $gab_insert[] =
array('location_code' => $this->db->f('location_code'),
+
'gab_id' => $gab_id,
+
'location_name' => $this->db->f('location_name'),
+
'remark' => $gab['remark'],
+
'owner' => $gab['owner']);
+ }
+ else
+ {
+ $gab_update[] =
array('location_code' => $this->db->f('location_code'),
+
'gab_id' => $gab_id,
+
'location_name' => $this->db->f('location_name'),
+
'remark' => $gab['remark'],
+
'owner' => $gab['owner']);
+ }
+ }
+ }
+ else
+ {
+ if(count($location)==$this->gab_insert_level)
+ {
+ $gab_insert[] = array('location_code'=>
$gab['location_code'],
+
'gab_id' => $gab_id,
+
'street_name' => $gab['street_name'],
+
'street_number' => $gab['street_number'],
+
'location_name' => $gab['location_name'],
+
'remark' => $gab['remark'],
+
'owner' => $gab['owner']);
+ }
+ }
+
+ if($gab_insert)
+ {
+ $receipt = $this->insert($gab_insert);
+ }
+ else
+ {
+ $receipt['error'][] = array('msg'=>lang('Could
not find any location to save to!'));
+ }
+
+ if($gab_update)
+ {
+ $receipt = $this->update($gab_update,$receipt);
+ }
+
+ $receipt['gab_id'] = $gab_id;
+
+ return $receipt;
+ }
+
+
+ function insert($gab_insert)
+ {
+ $receipt['message'][] = array('msg'=>lang('gab %1 has
been added',$gab_insert[0]['gab_id']));
+
+ for ($i=0;$i<count($gab_insert);$i++)
+ {
+ $location = explode('-',
$gab_insert[$i]['location_code']);
+
+ while (is_array($location) &&
list($input_name,$value) = each($location))
+ {
+ if($value)
+ {
+ $col[] = 'loc' .
($input_name+1);
+ $val[] = $value;
+ }
+ }
+
+ if($col)
+ {
+ $cols = "," . implode(",", $col);
+ $vals = ",'" . implode("','", $val) .
"'";
+ }
+
+ if($gab_insert[$i]['street_name'])
+ {
+ $address[]=
$gab_insert[$i]['street_name'];
+ $address[]=
$gab_insert[$i]['street_number'];
+ $address =
$this->db->db_addslashes(implode(" ", $address));
+ }
+
+ if(!$address)
+ {
+ $address =
$this->db->db_addslashes($gab_insert[$i]['location_name']);
+ }
+
+ $this->db->query("INSERT INTO fm_gab_location
(location_code,gab_id,remark,owner,entry_date,user_id,address $cols) "
+ . "VALUES ('"
+ . $gab_insert[$i]['location_code'].
"','"
+ . $gab_insert[$i]['gab_id']. "','"
+ . $gab_insert[$i]['remark']. "','"
+ . $gab_insert[$i]['owner']. "','"
+ . time() . "','"
+ . $this->account. "','"
+ . $address . "' $vals
)",__LINE__,__FILE__);
+
+ $receipt['message'][] =
array('msg'=>lang('at location %1',$gab_insert[$i]['location_code']));
+
+ unset($location);
+ unset($col);
+ unset($val);
+ unset($cols);
+ unset($vals);
+ unset($address);
+
+ }
+
+
+ return $receipt;
+ }
+
+ function update($gab_update,$receipt)
+ {
+ $receipt['message'][] = array('msg'=>lang('gab %1 has
been updated',$gab_update[0]['gab_id']));
+
+ for ($i=0;$i<count($gab_update);$i++)
+ {
+ $this->db->query("UPDATE fm_gab_location set
+ remark ='" .
$gab_update[$i]['remark'] . "',
+ owner ='" .
$gab_update[$i]['owner'] . "',
+ entry_date ='" .
time() . "',
+ user_id ='" .
$this->account
+ . "' WHERE location_code = '" .
$gab_update[$i]['location_code'] ."' AND gab_id= '" . $gab_update[$i]['gab_id']
. "'",__LINE__,__FILE__);
+
+ $receipt['message'][] =
array('msg'=>lang('at location %1',$gab_update[$i]['location_code']));
+ }
+
+ return $receipt;
+ }
+
+ function edit($gab)
+ {
+ $location = explode('-', $gab['location_code']);
+
+//_debug_array($gab);
+
+ if(!$gab['owner'])
+ {
+ $gab['owner']='no';
+ }
+
+ if(count($location)==$this->gab_insert_level)
+ {
+
+ $this->db->query("UPDATE fm_gab_location set
+ remark ='" .
$gab['remark'] . "',
+ owner ='" .
$gab['owner'] . "',
+ entry_date ='" .
time() . "',
+ user_id ='" .
$this->account
+ . "' WHERE location_code= '" .
$gab['location_code'] ."' and gab_id= '" . $gab['gab_id']
."'",__LINE__,__FILE__);
+
+ $receipt['message'][] = array('msg'=>lang('gab
%1 has been edited',"'".$gab['gab_id']."'"));
+ $receipt['message'][] = array('msg'=>lang('at
location %1',$gab['location_code']));
+ }
+ else
+ {
+ $receipt['error'][] =
array('msg'=>lang('Nothing to do !'));
+ }
+ $receipt['gab_id'] = $gab['gab_id'];
+ return $receipt;
+
+ }
+
+ function delete($gab_id='',$location_code='')
+ {
+ $this->db->query("DELETE FROM fm_gab_location WHERE
gab_id='$gab_id' and location_code='$location_code'",__LINE__,__FILE__);
+ }
+ }
+?>
Index: property/inc/class.soinvestment.inc.php
diff -u property/inc/class.soinvestment.inc.php:1.6
property/inc/class.soinvestment.inc.php:1.7
--- property/inc/class.soinvestment.inc.php:1.6 Fri Aug 19 11:56:50 2005
+++ property/inc/class.soinvestment.inc.php Fri Jan 27 14:05:43 2006
@@ -1,361 +1,360 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage eco
- * @version $Id: class.soinvestment.inc.php,v 1.6 2005/08/19 11:56:50
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class soinvestment
- {
-
- function soinvestment()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->join = $this->bocommon->join;
- $this->like = $this->bocommon->like;
- }
-
- function get_type_list()
- {
- $this->db->query("SELECT entity_type FROM fm_investment
GROUP BY entity_type ");
- while ($this->db->next_record())
- {
- $type_list[] = Array(
- 'id' =>
$this->db->f('entity_type'),
- 'num' =>
lang($this->db->f('entity_type'))
- );
- }
- return $type_list;
- }
-
-
- function read($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
- $part_of_town_id =
(isset($data['part_of_town_id'])?$data['part_of_town_id']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
-
- }
- if (!$cat_id)
- {
- return;
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- if ($cat_id=='property')
- {
- $ordermethod = ' order by
fm_part_of_town.name ,fm_location1.loc1 DESC';
- }
- else
- {
- $ordermethod = ' order by
fm_investment.entity_id DESC';
- }
- }
-
- if ($part_of_town_id)
- {
- $filtermethod = "and
fm_part_of_town.part_of_town_id ='$part_of_town_id'";
- }
-
- if ($filter=='investment')
- {
- $filtermethod .= "and initial_value > 0";
- }
- if ($filter=='funding')
- {
- $filtermethod .= "and initial_value < 0";
- }
-
- if ($cat_id=='property')
- {
- $sql = "SELECT fm_investment.entity_id as
entity_id, fm_investment.descr as descr,
fm_investment_value.invest_id,initial_value, fm_location1.loc1_name as name,
fm_part_of_town.district_id, fm_part_of_town.name as part_of_town,"
- . " fm_investment_value.value,
fm_investment_value.index_date, fm_investment_value.this_index, "
- . " fm_investment_value.index_count"
- . " FROM (((fm_investment $this->join
fm_investment_value ON ( fm_investment.entity_id =
fm_investment_value.entity_id) AND "
- . " (fm_investment.invest_id =
fm_investment_value.invest_id )) "
- . " $this->join fm_location1 ON
(fm_investment.loc1 = fm_location1.loc1)) "
- . " $this->join fm_part_of_town ON
(fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id)) "
- . " WHERE ( current_index = '1' or (this_index
= NULL and index_count= '1')) AND entity_type ='$cat_id' $filtermethod ";
-
- }
- else
- {
- $sql = "SELECT
fm_investment.location_code,fm_investment.entity_id, fm_investment.descr as
descr, fm_investment_value.invest_id,initial_value,
fm_part_of_town.district_id, fm_part_of_town.name as part_of_town,"
- . " fm_investment_value.value,
fm_investment_value.index_date,
fm_investment_value.this_index,fm_entity_category.name as entity_name, "
- . " fm_investment_value.index_count "
- . " FROM ((((fm_investment $this->join "
- . " fm_entity_category ON
(fm_investment.p_entity_id = fm_entity_category.entity_id AND
fm_investment.p_cat_id = fm_entity_category.id)) $this->join "
- . " fm_investment_value ON
(fm_investment_value.entity_id = fm_investment.entity_id) AND "
- . " (fm_investment_value.invest_id =
fm_investment.invest_id)) "
- . " $this->join fm_location1 ON
(fm_investment.loc1 = fm_location1.loc1)) "
- . " $this->join fm_part_of_town ON
(fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id)) "
- . " WHERE ( current_index = '1' or (this_index
= NULL and index_count= '1')) AND entity_type ='$cat_id' $filtermethod ";
- }
- if($sql)
- {
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
- }
-
-
- $i=0;
- while ($this->db->next_record())
- {
- $investment[$i]['counter']
= $i;
- $investment[$i]['location_code'] =
$this->db->f('location_code');
- $investment[$i]['entity_id'] =
$this->db->f('entity_id');
- $investment[$i]['investment_id'] =
$this->db->f('invest_id');
- $investment[$i]['district_id'] =
$this->db->f('district_id');
- $investment[$i]['part_of_town'] =
$this->db->f('part_of_town');
- $investment[$i]['descr']
= $this->db->f('descr');
- $investment[$i]['initial_value'] =
$this->db->f('initial_value');
- $investment[$i]['value']
= $this->db->f('value');
- $investment[$i]['this_index'] =
$this->db->f('this_index');
- $investment[$i]['index_count'] =
$this->db->f('index_count');
- $investment[$i]['date']
= $this->db->f('index_date');
- if ($cat_id=='property')
- {
- $investment[$i]['entity_name'] =
$this->db->f('name');
- }
- else
- {
- $investment[$i]['entity_name'] =
$this->db->f('entity_name');
- }
-
- $investment[$i]['this_write_off'] =
round(($this->db->f('this_index') * $this->db->f('initial_value')),2);
- $i++;
- }
-
-//_debug_array($investment);
- return $investment;
- }
-
- function save_investment($values)
- {
-//_debug_array($values);
-
- while (is_array($values['location']) &&
list($input_name,$value) = each($values['location']))
- {
- if($value)
- {
- $cols[] = $input_name;
- $vals[] = $value;
- }
- }
-
- while (is_array($values['extra']) &&
list($input_name,$value) = each($values['extra']))
- {
- if($value)
- {
- $cols[] = $input_name;
- $vals[] = $value;
- }
- }
-
- if($cols)
- {
- $cols = "," . implode(",", $cols);
- $vals = ",'" . implode("','", $vals) . "'";
- }
-
- if($values['street_name'])
- {
- $address[]= $values['street_name'];
- $address[]= $values['street_number'];
- $address =
$this->db->db_addslashes(implode(" ", $address));
- }
-
- if(!$address)
- {
- $address =
$this->db->db_addslashes($values['location_name']);
- }
-
-
- $period = $values['period'];
- $type = $values['funding'];
- $initial_value = $values['initial_value'];
- $descr =
$this->db->db_addslashes($values['descr']);
- $date = $values['date'];
- $location_code = $values['location_code'];
- $entity_id = $values['entity_id'];
- $entity_type = $values['entity_type'];
-
-
- $this->db->query("select max(invest_id) as
max_invest_id from fm_investment Where entity_id= '$entity_id'");
- $this->db->next_record();
- $next_invest_id = $this->db->f('max_invest_id')+1;
-
- $this->db->transaction_begin();
-
- $this->db->query("insert into fm_investment (entity_id,
invest_id,entity_type,location_code,writeoff_year, descr $cols) "
- . " values ('$entity_id',
'$next_invest_id','$entity_type','$location_code','$period','$descr' $vals )");
-
- $this->db->query("insert into fm_investment_value
(entity_id, invest_id, index_count, this_index, current_index,
value,initial_value, index_date) "
- . " values ('$entity_id', '$next_invest_id','1', '0',
'1','$initial_value','$initial_value','$date')");
-
-
- if($this->db->transaction_commit())
- {
- $receipt['message'][]=array('msg' =>
lang('Investment added !'));
- $receipt['message'][]=array('msg' =>
lang('Entity ID'). ' ' . $entity_id);
- $receipt['message'][]=array('msg' =>
lang('Investment ID:'). ' ' . $next_invest_id);
- }
- return $receipt;
- }
-
- function update_investment($values)
- {
- if (isSet($values) AND is_array($values))
- {
- $this->db->transaction_begin();
- foreach($values as $entry)
- {
- $this->db->query("select
max(index_count) as max_index_count from fm_investment_value Where entity_id='"
.$entry['entity_id'] . "' and invest_id=" .$entry['invest_id']);
- $this->db->next_record();
- $next_index_count =
$this->db->f('max_index_count')+1;
-
- $this->db->query("update
fm_investment_value set current_index = Null"
- . " WHERE entity_id='" .
$entry['entity_id'] . "' and invest_id=" . $entry['invest_id']);
-
- $insert= array(
- $entry['entity_id'],
- $entry['invest_id'],
- $next_index_count,
- $entry['new_index'],
- $entry['new_value'],
- $entry['initial_value'],
- $entry['date'],
- 1
- );
-
- $insert =
$this->bocommon->validate_db_insert($insert);
-
-
- $this->db->query("insert into
fm_investment_value (entity_id, invest_id, index_count, this_index,
value,initial_value, index_date,current_index) "
- . " values ($insert)");
- }
- $this->db->transaction_commit();
- }
- }
-
- function read_single($entity_id,$investment_id,$start,$allrows)
- {
- if (!$start)
- {
- $start=0;
- }
-
-
- $sql = "SELECT index_count,
this_index,current_index,value, initial_value, index_date "
- . " FROM fm_investment_value Where entity_id=
'$entity_id' and invest_id= '$investment_id' order by index_count";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
-
$this->db->limit_query($sql,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql,__LINE__,__FILE__);
- }
-
- $i=0;
- while ($this->db->next_record())
- {
- $investment[$i]['descr']
= $this->db->f('descr');
- $investment[$i]['initial_value'] =
$this->db->f('initial_value');
- $investment[$i]['value']
= $this->db->f('value');
- $investment[$i]['this_index'] =
$this->db->f('this_index');
- $investment[$i]['current_index'] =
$this->db->f('current_index');
- $investment[$i]['index_count'] =
$this->db->f('index_count');
- $investment[$i]['date']
= $this->db->f('index_date');
- $investment[$i]['this_write_off'] =
round(($this->db->f('this_index') * $this->db->f('initial_value')),2);
- $i++;
- }
-
- return $investment;
- }
-
-
- function write_off_period_list()
- {
- $this->db->query("SELECT writeoff_year FROM
fm_investment GROUP BY writeoff_year ",__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $period_list[] = Array(
- 'period' =>
$this->db->f('writeoff_year')
- );
- }
-
- return $period_list;
-
- }
-
- function delete($entity_id,$invest_id,$index_count)
- {
- $this->db->transaction_begin();
- if ($index_count==1)
- {
- $this->db->query("update fm_investment_value
set current_index = '0', this_index=Null,
value=Null,initial_value=Null,index_date=Null where entity_id='$entity_id' and
invest_id= '$invest_id' and index_count= '1'");
- }
- else
- {
- $this->db->query("delete from
fm_investment_value where entity_id='$entity_id' and invest_id= '$invest_id'
and index_count= '$index_count'");
-
- $new_current= $index_count -1;
-
- $this->db->query("update fm_investment_value
set current_index = '1' where entity_id='$entity_id' and invest_id=
'$invest_id' and index_count= '$new_current'");
- }
-
- // $this->db->query("DELETE FROM fm_investment_value WHERE
entity_id= '$entity_id' and invest_id='$invest_id' and
index_count='$index_count'",__LINE__,__FILE__);
- $this->db->transaction_commit();
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage eco
+ * @version $Id: class.soinvestment.inc.php,v 1.7 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class soinvestment
+ {
+
+ function soinvestment()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->like = $this->bocommon->like;
+ }
+
+ function get_type_list()
+ {
+ $this->db->query("SELECT entity_type FROM fm_investment
GROUP BY entity_type ");
+ while ($this->db->next_record())
+ {
+ $type_list[] = Array(
+ 'id' =>
$this->db->f('entity_type'),
+ 'num' =>
lang($this->db->f('entity_type'))
+ );
+ }
+ return $type_list;
+ }
+
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
+ $part_of_town_id =
(isset($data['part_of_town_id'])?$data['part_of_town_id']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+
+ }
+ if (!$cat_id)
+ {
+ return;
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ if ($cat_id=='property')
+ {
+ $ordermethod = ' order by
fm_part_of_town.name ,fm_location1.loc1 DESC';
+ }
+ else
+ {
+ $ordermethod = ' order by
fm_investment.entity_id DESC';
+ }
+ }
+
+ if ($part_of_town_id)
+ {
+ $filtermethod = "and
fm_part_of_town.part_of_town_id ='$part_of_town_id'";
+ }
+
+ if ($filter=='investment')
+ {
+ $filtermethod .= "and initial_value > 0";
+ }
+ if ($filter=='funding')
+ {
+ $filtermethod .= "and initial_value < 0";
+ }
+
+ if ($cat_id=='property')
+ {
+ $sql = "SELECT fm_investment.entity_id as
entity_id, fm_investment.descr as descr,
fm_investment_value.invest_id,initial_value, fm_location1.loc1_name as name,
fm_part_of_town.district_id, fm_part_of_town.name as part_of_town,"
+ . " fm_investment_value.value,
fm_investment_value.index_date, fm_investment_value.this_index, "
+ . " fm_investment_value.index_count"
+ . " FROM (((fm_investment $this->join
fm_investment_value ON ( fm_investment.entity_id =
fm_investment_value.entity_id) AND "
+ . " (fm_investment.invest_id =
fm_investment_value.invest_id )) "
+ . " $this->join fm_location1 ON
(fm_investment.loc1 = fm_location1.loc1)) "
+ . " $this->join fm_part_of_town ON
(fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id)) "
+ . " WHERE ( current_index = '1' or (this_index
= NULL and index_count= '1')) AND entity_type ='$cat_id' $filtermethod ";
+
+ }
+ else
+ {
+ $sql = "SELECT
fm_investment.location_code,fm_investment.entity_id, fm_investment.descr as
descr, fm_investment_value.invest_id,initial_value,
fm_part_of_town.district_id, fm_part_of_town.name as part_of_town,"
+ . " fm_investment_value.value,
fm_investment_value.index_date,
fm_investment_value.this_index,fm_entity_category.name as entity_name, "
+ . " fm_investment_value.index_count "
+ . " FROM ((((fm_investment $this->join "
+ . " fm_entity_category ON
(fm_investment.p_entity_id = fm_entity_category.entity_id AND
fm_investment.p_cat_id = fm_entity_category.id)) $this->join "
+ . " fm_investment_value ON
(fm_investment_value.entity_id = fm_investment.entity_id) AND "
+ . " (fm_investment_value.invest_id =
fm_investment.invest_id)) "
+ . " $this->join fm_location1 ON
(fm_investment.loc1 = fm_location1.loc1)) "
+ . " $this->join fm_part_of_town ON
(fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id)) "
+ . " WHERE ( current_index = '1' or (this_index
= NULL and index_count= '1')) AND entity_type ='$cat_id' $filtermethod ";
+ }
+ if($sql)
+ {
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+ }
+
+
+ $i=0;
+ while ($this->db->next_record())
+ {
+ $investment[$i]['counter']
= $i;
+ $investment[$i]['location_code'] =
$this->db->f('location_code');
+ $investment[$i]['entity_id'] =
$this->db->f('entity_id');
+ $investment[$i]['investment_id'] =
$this->db->f('invest_id');
+ $investment[$i]['district_id'] =
$this->db->f('district_id');
+ $investment[$i]['part_of_town'] =
$this->db->f('part_of_town');
+ $investment[$i]['descr']
= $this->db->f('descr');
+ $investment[$i]['initial_value'] =
$this->db->f('initial_value');
+ $investment[$i]['value']
= $this->db->f('value');
+ $investment[$i]['this_index'] =
$this->db->f('this_index');
+ $investment[$i]['index_count'] =
$this->db->f('index_count');
+ $investment[$i]['date']
= $this->db->f('index_date');
+ if ($cat_id=='property')
+ {
+ $investment[$i]['entity_name'] =
$this->db->f('name');
+ }
+ else
+ {
+ $investment[$i]['entity_name'] =
$this->db->f('entity_name');
+ }
+
+ $investment[$i]['this_write_off'] =
round(($this->db->f('this_index') * $this->db->f('initial_value')),2);
+ $i++;
+ }
+
+//_debug_array($investment);
+ return $investment;
+ }
+
+ function save_investment($values)
+ {
+//_debug_array($values);
+
+ while (is_array($values['location']) &&
list($input_name,$value) = each($values['location']))
+ {
+ if($value)
+ {
+ $cols[] = $input_name;
+ $vals[] = $value;
+ }
+ }
+
+ while (is_array($values['extra']) &&
list($input_name,$value) = each($values['extra']))
+ {
+ if($value)
+ {
+ $cols[] = $input_name;
+ $vals[] = $value;
+ }
+ }
+
+ if($cols)
+ {
+ $cols = "," . implode(",", $cols);
+ $vals = ",'" . implode("','", $vals) . "'";
+ }
+
+ if($values['street_name'])
+ {
+ $address[]= $values['street_name'];
+ $address[]= $values['street_number'];
+ $address =
$this->db->db_addslashes(implode(" ", $address));
+ }
+
+ if(!$address)
+ {
+ $address =
$this->db->db_addslashes($values['location_name']);
+ }
+
+
+ $period = $values['period'];
+ $type = $values['funding'];
+ $initial_value = $values['initial_value'];
+ $descr =
$this->db->db_addslashes($values['descr']);
+ $date = $values['date'];
+ $location_code = $values['location_code'];
+ $entity_id = $values['entity_id'];
+ $entity_type = $values['entity_type'];
+
+
+ $this->db->query("select max(invest_id) as
max_invest_id from fm_investment Where entity_id= '$entity_id'");
+ $this->db->next_record();
+ $next_invest_id = $this->db->f('max_invest_id')+1;
+
+ $this->db->transaction_begin();
+
+ $this->db->query("insert into fm_investment (entity_id,
invest_id,entity_type,location_code,writeoff_year, descr $cols) "
+ . " values ('$entity_id',
'$next_invest_id','$entity_type','$location_code','$period','$descr' $vals )");
+
+ $this->db->query("insert into fm_investment_value
(entity_id, invest_id, index_count, this_index, current_index,
value,initial_value, index_date) "
+ . " values ('$entity_id', '$next_invest_id','1', '0',
'1','$initial_value','$initial_value','$date')");
+
+
+ if($this->db->transaction_commit())
+ {
+ $receipt['message'][]=array('msg' =>
lang('Investment added !'));
+ $receipt['message'][]=array('msg' =>
lang('Entity ID'). ' ' . $entity_id);
+ $receipt['message'][]=array('msg' =>
lang('Investment ID:'). ' ' . $next_invest_id);
+ }
+ return $receipt;
+ }
+
+ function update_investment($values)
+ {
+ if (isSet($values) AND is_array($values))
+ {
+ $this->db->transaction_begin();
+ foreach($values as $entry)
+ {
+ $this->db->query("select
max(index_count) as max_index_count from fm_investment_value Where entity_id='"
.$entry['entity_id'] . "' and invest_id=" .$entry['invest_id']);
+ $this->db->next_record();
+ $next_index_count =
$this->db->f('max_index_count')+1;
+
+ $this->db->query("update
fm_investment_value set current_index = Null"
+ . " WHERE entity_id='" .
$entry['entity_id'] . "' and invest_id=" . $entry['invest_id']);
+
+ $insert= array(
+ $entry['entity_id'],
+ $entry['invest_id'],
+ $next_index_count,
+ $entry['new_index'],
+ $entry['new_value'],
+ $entry['initial_value'],
+ $entry['date'],
+ 1
+ );
+
+ $insert =
$this->bocommon->validate_db_insert($insert);
+
+
+ $this->db->query("insert into
fm_investment_value (entity_id, invest_id, index_count, this_index,
value,initial_value, index_date,current_index) "
+ . " values ($insert)");
+ }
+ $this->db->transaction_commit();
+ }
+ }
+
+ function read_single($entity_id,$investment_id,$start,$allrows)
+ {
+ if (!$start)
+ {
+ $start=0;
+ }
+
+
+ $sql = "SELECT index_count,
this_index,current_index,value, initial_value, index_date "
+ . " FROM fm_investment_value Where entity_id=
'$entity_id' and invest_id= '$investment_id' order by index_count";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+
$this->db->limit_query($sql,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql,__LINE__,__FILE__);
+ }
+
+ $i=0;
+ while ($this->db->next_record())
+ {
+ $investment[$i]['descr']
= $this->db->f('descr');
+ $investment[$i]['initial_value'] =
$this->db->f('initial_value');
+ $investment[$i]['value']
= $this->db->f('value');
+ $investment[$i]['this_index'] =
$this->db->f('this_index');
+ $investment[$i]['current_index'] =
$this->db->f('current_index');
+ $investment[$i]['index_count'] =
$this->db->f('index_count');
+ $investment[$i]['date']
= $this->db->f('index_date');
+ $investment[$i]['this_write_off'] =
round(($this->db->f('this_index') * $this->db->f('initial_value')),2);
+ $i++;
+ }
+
+ return $investment;
+ }
+
+
+ function write_off_period_list()
+ {
+ $this->db->query("SELECT writeoff_year FROM
fm_investment GROUP BY writeoff_year ",__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $period_list[] = Array(
+ 'period' =>
$this->db->f('writeoff_year')
+ );
+ }
+
+ return $period_list;
+
+ }
+
+ function delete($entity_id,$invest_id,$index_count)
+ {
+ $this->db->transaction_begin();
+ if ($index_count==1)
+ {
+ $this->db->query("update fm_investment_value
set current_index = '0', this_index=Null,
value=Null,initial_value=Null,index_date=Null where entity_id='$entity_id' and
invest_id= '$invest_id' and index_count= '1'");
+ }
+ else
+ {
+ $this->db->query("delete from
fm_investment_value where entity_id='$entity_id' and invest_id= '$invest_id'
and index_count= '$index_count'");
+
+ $new_current= $index_count -1;
+
+ $this->db->query("update fm_investment_value
set current_index = '1' where entity_id='$entity_id' and invest_id=
'$invest_id' and index_count= '$new_current'");
+ }
+
+ // $this->db->query("DELETE FROM fm_investment_value WHERE
entity_id= '$entity_id' and invest_id='$invest_id' and
index_count='$index_count'",__LINE__,__FILE__);
+ $this->db->transaction_commit();
+ }
+ }
+?>
Index: property/inc/class.soinvoice.inc.php
diff -u property/inc/class.soinvoice.inc.php:1.17
property/inc/class.soinvoice.inc.php:1.18
--- property/inc/class.soinvoice.inc.php:1.17 Wed Nov 2 11:55:03 2005
+++ property/inc/class.soinvoice.inc.php Fri Jan 27 14:05:43 2006
@@ -1,1147 +1,1146 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage eco
- * @version $Id: class.soinvoice.inc.php,v 1.17 2005/11/02 11:55:03
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class soinvoice
- {
-
- function soinvoice()
- {
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
-
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->account_id =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->acl2 =
CreateObject($this->currentapp.'.acl2','##DEFAULT##','##DEFAULT##');
-
- $this->join = $this->bocommon->join;
- $this->left_join = $this->bocommon->left_join;
- $this->like = $this->bocommon->like;
- }
-
-
- function read_invoice($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $user_lid =
(isset($data['user_lid'])?$data['user_lid']:'none');
- $paid =
(isset($data['paid'])?$data['paid']:'');
- $start_date =
(isset($data['start_date'])?$data['start_date']:'');
- $end_date =
(isset($data['end_date'])?$data['end_date']:'');
- $vendor_id =
(isset($data['vendor_id'])?$data['vendor_id']:'');
- $loc1 =
(isset($data['loc1'])?$data['loc1']:'');
- $workorder_id =
(isset($data['workorder_id'])?$data['workorder_id']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $voucher_id =
(isset($data['voucher_id'])?$data['voucher_id']:'');
- }
-
-//_debug_array($data);
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by bilagsnr DESC';
- }
-
- $where= 'WHERE';
-
- if ($user_lid=='none' || !$user_lid):
- {
- return;
- }
- elseif ($user_lid!='all'):
- {
- $filtermethod = " WHERE ( oppsynsmannid=
'$user_lid' or saksbehandlerid= '$user_lid' or budsjettansvarligid=
'$user_lid')";
- $where= 'AND';
- }
- endif;
-
- if ($cat_id > 0)
- {
- $filtermethod .= " $where typeid='$cat_id' ";
- $where= 'AND';
- }
-
- if ($district_id > 0)
- {
- $filtermethod .= " $where
district_id='$district_id' ";
- $where= 'AND';
- }
-
- if ($vendor_id)
- {
- $filtermethod .= " $where spvend_code
='$vendor_id' ";
- $where= 'AND';
- }
- if ($loc1)
- {
- $filtermethod .= " $where dima $this->like
'%$loc1%' ";
- $where= 'AND';
- }
- if ($workorder_id)
- {
- $filtermethod .= " $where pmwrkord_code
='$workorder_id' ";
- $where= 'AND';
- }
- if ($voucher_id)
- {
- $filtermethod .= " $where bilagsnr $this->like
'%$voucher_id%' ";
- $where= 'AND';
- }
-
-
- if ($paid)
- {
- $table = 'fm_ecobilagoverf';
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $dateformat = str_replace(".","",$dateformat);
- $dateformat = str_replace("-","",$dateformat);
- $dateformat = str_replace("/","",$dateformat);
- $y=strpos($dateformat,'y');
- $d=strpos($dateformat,'d');
- $m=strpos($dateformat,'m');
-
- $dateparts = explode('/', $start_date);
- $sday = $dateparts[$d];
- $smonth = $dateparts[$m];
- $syear = $dateparts[$y];
-
- $dateparts = explode('/', $end_date);
- $eday = $dateparts[$d];
- $emonth = $dateparts[$m];
- $eyear = $dateparts[$y];
-
- $start_date =
date($this->bocommon->dateformat,mktime(2,0,0,$smonth,$sday,$syear));
- $end_date =
date($this->bocommon->dateformat,mktime(2,0,0,$emonth,$eday,$eyear));
-
- if (!$workorder_id && !$voucher_id)
- {
- $filtermethod .= " $where overftid
>'$start_date' and overftid < '$end_date'";
- }
- }
- else
- {
- $table ='fm_ecobilag';
- }
-
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " $where ( spvend_code
$this->like '%$query%' OR bilagsnr $this->like '%$query%' )";
- }
-
-
- $sql = "SELECT DISTINCT bilagsnr, count(bilagsnr) as
invoice_count, sum(belop) as belop,spvend_code,fakturadato FROM $table
$filtermethod $querymethod group by bilagsnr,spvend_code,fakturadato ";
- $sql2 = "SELECT DISTINCT bilagsnr FROM $table
$filtermethod $querymethod";
-
-//echo $sql;
- $this->db2->query($sql2,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $temp[] = array
- (
- 'voucher_id' =>
$this->db->f('bilagsnr'),
- 'invoice_count' =>
$this->db->f('invoice_count'),
- 'amount' =>
$this->db->f('belop')
- );
- }
-
- if ($temp)
- {
- $role= $this->check_role();
- $i = 0;
- foreach($temp as $invoice_temp)
- {
- $voucher_id=$invoice_temp['voucher_id'];
-
- $sql = "SELECT
spvend_code,oppsynsmannid,saksbehandlerid,budsjettansvarligid,"
- . "
utbetalingid,oppsynsigndato,saksigndato,budsjettsigndato,utbetalingsigndato,fakturadato,org_name,"
- . "
forfallsdato,periode,artid,kidnr,kreditnota "
- . " from $table $this->join fm_vendor
ON fm_vendor.id = $table.spvend_code WHERE bilagsnr = $voucher_id "
- . " group by
bilagsnr,spvend_code,oppsynsmannid,saksbehandlerid,budsjettansvarligid,"
- . "
utbetalingid,oppsynsigndato,saksigndato,budsjettsigndato,utbetalingsigndato,fakturadato,org_name,"
- . "
forfallsdato,periode,artid,kidnr,kreditnota ";
-
-
$this->db->query($sql,__LINE__,__FILE__);
-
- $this->db->next_record();
-
- $timestamp_voucher_date=
mktime(0,0,0,date(m,strtotime($this->db->f('fakturadato'))),date(d,strtotime($this->db->f('fakturadato'))),date(y,strtotime($this->db->f('fakturadato'))));
- $timestamp_payment_date=
mktime(0,0,0,date(m,strtotime($this->db->f('forfallsdato'))),date(d,strtotime($this->db->f('forfallsdato'))),date(y,strtotime($this->db->f('forfallsdato'))));
-
- if($this->db->f('oppsynsmannid') &&
$this->db->f('oppsynsigndato'))
- {
-// $timestamp_jan_date
=
mktime(0,0,0,date(m,strtotime($this->db->f('oppsynsigndato'))),date(d,strtotime($this->db->f('oppsynsigndato'))),date(y,strtotime($this->db->f('oppsynsigndato'))));
-// $invoice[$i]['jan_date']
=
$GLOBALS['phpgw']->common->show_date($timestamp_jan_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-
$invoice[$i]['jan_date']=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($this->db->f('oppsynsigndato')));
- }
- else
- {
- $invoice[$i]['jan_date']
='';
- }
- if($this->db->f('saksbehandlerid') &&
$this->db->f('saksigndato'))
- {
-// $timestamp_super_date
=
mktime(0,0,0,date(m,strtotime($this->db->f('saksigndato'))),date(d,strtotime($this->db->f('saksigndato'))),date(y,strtotime($this->db->f('saksigndato'))));
-// $invoice[$i]['super_date']
=
$GLOBALS['phpgw']->common->show_date($timestamp_super_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-
$invoice[$i]['super_date']=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($this->db->f('saksigndato')));
- }
- else
- {
- $invoice[$i]['super_date']
='';
- }
-
- if($this->db->f('budsjettansvarligid')
&& $this->db->f('budsjettsigndato'))
- {
-// $timestamp_budget_date
=
mktime(0,0,0,date(m,strtotime($this->db->f('budsjettsigndato'))),date(d,strtotime($this->db->f('budsjettsigndato'))),date(y,strtotime($this->db->f('budsjettsigndato'))));
-//
$invoice[$i]['budget_date'] =
$GLOBALS['phpgw']->common->show_date($timestamp_budget_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-
$invoice[$i]['budget_date']=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($this->db->f('budsjettsigndato')));
- }
- else
- {
- $invoice[$i]['budget_date']
='';
- }
-
- if($this->db->f('utbetalingid') &&
$this->db->f('utbetalingsigndato'))
- {
-// $timestamp_transfer_date=
mktime(0,0,0,date(m,strtotime($this->db->f('utbetalingsigndato'))),date(d,strtotime($this->db->f('utbetalingsigndato'))),date(y,strtotime($this->db->f('utbetalingsigndato'))));
-// $invoice[$i]['transfer_date']
=
$GLOBALS['phpgw']->common->show_date($timestamp_transfer_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-
$invoice[$i]['transfer_date']=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($this->db->f('utbetalingsigndato')));
- }
- else
- {
- $invoice[$i]['transfer_date']
='';
- }
-
- $invoice[$i]['counter']
= $i;
- $invoice[$i]['current_user']
= $GLOBALS['phpgw_info']['user']['account_lid'];
- $invoice[$i]['voucher_id']
= $voucher_id;
- $invoice[$i]['invoice_count']
= $invoice_temp['invoice_count'];
- $invoice[$i]['vendor_id']
= $this->db->f('spvend_code');
- $invoice[$i]['vendor']
= $this->db->f('org_name');
- $invoice[$i]['is_janitor']
= $role['is_janitor'];
- $invoice[$i]['is_supervisor']
= $role['is_supervisor'];
- $invoice[$i]['is_budget_responsible']
= $role['is_budget_responsible'];
- $invoice[$i]['is_janitor']
= $role['is_janitor'];
- $invoice[$i]['is_transfer']
= $role['is_transfer'];
- $invoice[$i]['janitor']
= $this->db->f('oppsynsmannid');
- $invoice[$i]['supervisor']
= $this->db->f('saksbehandlerid');
- $invoice[$i]['budget_responsible']
= $this->db->f('budsjettansvarligid');
- $invoice[$i]['transfer_id']
= $this->db->f('utbetalingid');
- $invoice[$i]['voucher_date']
=
$GLOBALS['phpgw']->common->show_date($timestamp_voucher_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $invoice[$i]['payment_date']
=
$GLOBALS['phpgw']->common->show_date($timestamp_payment_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $invoice[$i]['period']
= $this->db->f('periode');
- $invoice[$i]['type']
= $this->db->f('artid');
- $invoice[$i]['kidnr']
= $this->db->f('kidnr');
- $invoice[$i]['kreditnota']
= $this->db->f('kreditnota');
- $invoice[$i]['amount']
= $invoice_temp['amount'];
- $invoice[$i]['num_days']
=
intval(($timestamp_payment_date-$timestamp_voucher_date)/(24*3600));
- $invoice[$i]['timestamp_voucher_date']
= $timestamp_voucher_date;
-
-
if($invoice[$i]['current_user']==$invoice[$i]['janitor'] &&
$invoice[$i]['jan_date']):
- {
-
$invoice[$i]['sign_orig']='sign_janitor';
- }
-
elseif($invoice[$i]['current_user']==$invoice[$i]['supervisor'] &&
$invoice[$i]['super_date']):
- {
-
$invoice[$i]['sign_orig']='sign_supervisor';
- }
-
elseif($invoice[$i]['current_user']==$invoice[$i]['budget_responsible'] &&
$invoice[$i]['budget_date']):
- {
-
$invoice[$i]['sign_orig']='sign_budget_responsible';
- }
- endif;
-
- $i++;
-
- }
- }
-// $end_time = explode(' ',microtime());
-// $this->end_time = $end_time;
-
-//_debug_array($invoice);
-//_debug_array($invoice_temp);
-
- return $invoice;
-
- }
-
-
- function read_invoice_sub($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $voucher_id =
(isset($data['voucher_id'])?$data['voucher_id']:0);
- $paid = (isset($data['paid'])?$data['paid']:'');
- }
-
- if ($paid)
- {
- $table = 'fm_ecobilagoverf';
- }
- else
- {
- $table ='fm_ecobilag';
- }
-
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by bilagsnr DESC';
- }
-
- if ($voucher_id)
- {
- $filtermethod = " WHERE ( bilagsnr=
'$voucher_id')";
- }
-
- $sql = "SELECT
$table.*,fm_workorder.status,fm_workorder.charge_tenant,org_name,fm_workorder.claim_issued
FROM $table "
- . " $this->left_join fm_workorder on fm_workorder.id =
$table.pmwrkord_code "
- . " $this->join fm_vendor on $table.spvend_code =
fm_vendor.id $filtermethod ";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- $this->db->query($sql .
$ordermethod,$start,__LINE__,__FILE__);
-
- $i = 0;
-
- while ($this->db->next_record())
- {
- $invoice[$i]['counter']
= $i;
- $invoice[$i]['claim_issued']
= $this->db->f('claim_issued');
- $invoice[$i]['project_id']
= $this->db->f('project_id');
- $invoice[$i]['workorder_id']
= $this->db->f('pmwrkord_code');
- $invoice[$i]['status']
= $this->db->f('status');
- if ($this->db->f('status')=='closed')
- {
- $invoice[$i]['closed']
= True;
- }
- $invoice[$i]['voucher_id']
= $voucher_id;
- $invoice[$i]['id']
= $this->db->f('id');
- $invoice[$i]['invoice_id']
= $this->db->f('fakturanr');
- $invoice[$i]['budget_account']
= $this->db->f('spbudact_code');
- $invoice[$i]['dima']
= $this->db->f('dima');
- $invoice[$i]['dimb']
= $this->db->f('dimb');
- $invoice[$i]['dimd']
= $this->db->f('dimd');
- if ($this->db->f('merknad'))
- {
- $invoice[$i]['remark']
= True;
- }
- $invoice[$i]['tax_code']
= $this->db->f('mvakode');
- $invoice[$i]['amount']
= $this->db->f('belop');
- $invoice[$i]['charge_tenant']
= $this->db->f('charge_tenant');
- $invoice[$i]['vendor']
= $this->db->f('org_name');
- $i++;
-
- }
-
- return $invoice;
-
- }
-
-
- function read_consume($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $start_date =
(isset($data['start_date'])?$data['start_date']:'');
- $end_date =
(isset($data['end_date'])?$data['end_date']:'');
- $vendor_id =
(isset($data['vendor_id'])?$data['vendor_id']:'');
- $loc1 =
(isset($data['loc1'])?$data['loc1']:'');
- $district_id =
(isset($data['district_id'])?$data['district_id']:'');
- $workorder_id =
(isset($data['workorder_id'])?$data['workorder_id']:0);
- $b_account_class =
(isset($data['b_account_class'])?$data['b_account_class']:'');
- }
-//_debug_array($data);
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $dateformat = str_replace(".","",$dateformat);
- $dateformat = str_replace("-","",$dateformat);
- $dateformat = str_replace("/","",$dateformat);
- $y=strpos($dateformat,'y');
- $d=strpos($dateformat,'d');
- $m=strpos($dateformat,'m');
- $dateparts = explode('/', $start_date);
- $sday = $dateparts[$d];
- $smonth = $dateparts[$m];
- $syear = $dateparts[$y];
-
- $dateparts = explode('/', $end_date);
- $eday = $dateparts[$d];
- $emonth = $dateparts[$m];
- $eyear = $dateparts[$y];
-
- $start_date =
date($this->bocommon->dateformat,mktime(2,0,0,$smonth,$sday,$syear));
- $end_date =
date($this->bocommon->dateformat,mktime(2,0,0,$emonth,$eday,$eyear));
-
-
- $where = 'WHERE';
-
- if($b_account_class)
- {
- $filtermethod= " $where
fm_b_account.grouping='$b_account_class'";
- $where= 'AND';
- }
- else
- {
- $select_account_class=',fm_b_account.grouping
as b_account_class';
- $group_account_class=',
spbudact_code,fm_b_account.grouping';
- }
-
- if ($vendor_id)
- {
- $filtermethod .= " $where (spvend_code =
$vendor_id)";
- $where= 'AND';
- }
-
- if($loc1)
- {
- $filtermethod .=" $where (dima $this->like
'%$loc1%')";
- $where= 'AND';
- }
-
-
- if ($district_id)
- {
- $filtermethod.= " $where district_id=
$district_id ";
- $where= 'AND';
- }
-
- if ($workorder_id)
- {
- $filtermethod.= " $where pmwrkord_code =
$workorder_id";
- $where= 'AND';
- }
-
-
- if ($cat_id>0)
- {
- $filtermethod .= " $where typeid = $cat_id";
- $where= 'AND';
- }
-
- $filtermethod .= " $where (fakturadato >'$start_date')
AND (fakturadato < '$end_date')";
-
- $sql = "SELECT district_id,periode,sum(godkjentbelop)
as consume $select_account_class "
- . " FROM fm_ecobilagoverf $this->join
fm_location1 ON (fm_ecobilagoverf.loc1 = fm_location1.loc1) "
- . " $this->join fm_part_of_town ON
(fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id) "
- . " $this->join fm_b_account ON
(fm_ecobilagoverf.spbudact_code = fm_b_account.id) "
- . " $filtermethod group by district_id,periode
$group_account_class";
-//echo $sql;
-
- $this->db->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db->num_rows();
- $this->db->query($sql .
$ordermethod,$start,__LINE__,__FILE__);
-
- $i = 0;
-
- while ($this->db->next_record())
- {
- $consume[$i]['consume']
= $this->db->f('consume');
- $consume[$i]['period']
= $this->db->f('periode');
- $consume[$i]['district_id']
= $this->db->f('district_id');
- if(!$b_account_class)
- {
- $consume[$i]['account_class']
= $this->db->f('b_account_class');
- }
- else
- {
- $consume[$i]['account_class']
= $b_account_class;
- }
-
- $i++;
- }
-//_debug_array($consume);
- return $consume;
- }
-
- function check_for_updates($values)
- {
- $update=False;
-
- if($values['sign_orig']!=$values['sign'])
- {
- $update=True;
- return $update;
- }
-
- $sql = "SELECT * FROM fm_ecobilag WHERE bilagsnr=" .
$values['voucher_id'];
- $this->db->limit_query($sql,0,__LINE__,__FILE__,1);
-
- $this->db->next_record();
-
- if( ($this->db->f('utbetalingsigndato') &&
!$values['transfer']) || (!$this->db->f('utbetalingsigndato') &&
$values['transfer']))
- {
- $update=True;
- return $update;
- }
-
- if( ($this->db->f('kreditnota') &&
!$values['kreditnota']) || (!$this->db->f('kreditnota') &&
$values['kreditnota']) )
- {
- $update=True;
- return $update;
- }
-
- $timestamp_voucher_date=
mktime(0,0,0,date(m,strtotime($this->db->f('fakturadato'))),date(d,strtotime($this->db->f('fakturadato'))),date(y,strtotime($this->db->f('fakturadato'))));
- $timestamp_payment_date=
mktime(0,0,0,date(m,strtotime($this->db->f('forfallsdato'))),date(d,strtotime($this->db->f('forfallsdato'))),date(y,strtotime($this->db->f('forfallsdato'))));
-
- if(
((intval(($timestamp_payment_date-$timestamp_voucher_date)/(24*3600)))!=$values['num_days'])
)
- {
- $update=True;
- return $update;
- }
- }
-
- function update_invoice_sub($values)
- {
-
- $GLOBALS['phpgw']->db->transaction_begin();
-
- while($entry=each($values['counter']))
- {
- $local_error='';
-
- $n=$entry[0];
-
-
-//_debug_array($entry);
-
-
- if ($values['budget_account'][$n])
- {
-
$budget_account=$values['budget_account'][$n];
-
- $GLOBALS['phpgw']->db->query("select
count(*) from fm_b_account where id =$budget_account");
- $GLOBALS['phpgw']->db->next_record();
- if ($GLOBALS['phpgw']->db->f(0) == 0)
- {
- $receipt['error'][] =
array('msg'=> lang('This account is not valid:'). " ".$budget_account);
- $local_error= true;
- }
- }
- else
- {
- $receipt['error'][] =
array('msg'=>lang('Budget account is missing:'));
- $local_error= true;
- }
-
- if(!$values['dimd'][$n])
- {
- $dimd_field="dimd=NULL";
- }
- else
- {
- $dimd=$values['dimd'][$n];
- $GLOBALS['phpgw']->db->query("select
count(*) from fm_dim_d where id =$dimd");
- $GLOBALS['phpgw']->db->next_record();
- if ($GLOBALS['phpgw']->db->f(0) == 0)
- {
- $receipt['error'][] =
array('msg'=>lang('This Dim D is not valid:'). " ".$dimd);
- $local_error= true;
- }
-
- $dimd_field="dimd="."'" . $dimd . "'";
- }
-
- if (!$values['dima'][$n])
- {
- $dima_field="dima=NULL";
- $receipt['error'][] =
array('msg'=>lang('Dim A is missing'));
- $local_error= true;
- }
- else
- {
-
$dima_check=substr($values['dima'][$n],0,4);
- $GLOBALS['phpgw']->db->query("select
loc1, kostra_id from fm_location1 where loc1 = '$dima_check' ");
- $GLOBALS['phpgw']->db->next_record();
- if (!$GLOBALS['phpgw']->db->f('loc1'))
- {
- $receipt['error'][] =
array('msg'=>lang('This Dim A is not valid:'). " ".$values['dima'][$n]);
- $local_error= true;
- }
-
- if
(!$GLOBALS['phpgw']->db->f('kostra_id') ||
$GLOBALS['phpgw']->db->f('kostra_id') == 0)
- {
- $receipt['error'][] =
array('msg'=>'objektet mangler tjeneste - utgått? '. " ".$values['dima'][$n]);
- $local_error= true;
- }
-
- // $dima_field="dima="."'" .
$values['dima'][$n] . "'";
- $dima_field="dima="."'" .
$values['dima'][$n] . "',loc1=" . "'" . substr($values['dima'][$n],0,4) . "'";
-
- $kostra_field="kostra_id="."'" .
$GLOBALS['phpgw']->db->f('kostra_id') . "'";
-
- }
-
- if (! $local_error)
- {
- $id =
$values['id'][$n];
- $tax_code =
$values['tax_code'][$n];
-
$workorder_id=$values['workorder_id'][$n];
- if($values['close_order'][$n] &&
!$values['close_order_orig'][$n])
- {
-
$update_status[$workorder_id]='X';
- }
-
- if(!$values['close_order'][$n] &&
$values['close_order_orig'][$n])
- {
-
$update_status[$workorder_id]='R';
- }
-
- $GLOBALS['phpgw']->db->query("UPDATE
fm_ecobilag set $dima_field ,$kostra_field,$dimd_field, mvakode =
'$tax_code',spbudact_code = '$budget_account' where id='$id'");
-
- $receipt['message'][] =
array('msg'=>lang('Voucher is updated '));
- }
-
- }
-
- if (isset($update_status) AND is_array($update_status))
- {
-
$status_code=array('X'=>'closed','R'=>'re_opened');
-
- $historylog_workorder =
CreateObject($this->currentapp.'.historylog','workorder');
-
- while (list($id,$entry) = each($update_status))
- {
-
$historylog_workorder->add($entry,$id,$status_code[$entry]);
- $GLOBALS['phpgw']->db->query("UPDATE
fm_workorder set status=" . "'$status_code[$entry]'" . "where id=$id");
- $receipt['message'][] =
array('msg'=>lang('Workorder %1 is %2',$id, $status_code[$entry]));
- }
- }
-
- $GLOBALS['phpgw']->db->transaction_commit();
-
- return $receipt;
- }
-
- function read_remark($id='',$paid='')
- {
- if ($paid)
- {
- $table = 'fm_ecobilagoverf';
- }
- else
- {
- $table ='fm_ecobilag';
- }
-
- $this->db->query(" SELECT merknad from $table where
id= '$id'");
- $this->db->next_record();
-
- return $this->db->f('merknad');
- }
-
- function check_role()
- {
- if(!$this->role)
- {
- $this->role=array(
- 'is_janitor'
=> $this->acl2->check('.invoice',32),
- 'is_supervisor'
=> $this->acl2->check('.invoice',64),
- 'is_budget_responsible' =>
$this->acl2->check('.invoice',128),
- 'is_transfer'
=> $this->acl2->check('.invoice',16)
- );
- }
- return $this->role;
- }
-
- function check_count($voucher_id)
- {
-
- $this->db->query("select count(dima) as dima_count ,
count(spbudact_code) as spbudact_code_count from fm_ecobilag where bilagsnr
='$voucher_id'");
- $this->db->next_record();
-
- $check_count=array(
- 'dima_count' =>
$this->db->f('dima_count'),
- 'spbudact_code_count' =>
$this->db->f('spbudact_code_count')
- );
-
- $this->db->query("select count(kostra_id) as
kostra_count from fm_ecobilag where bilagsnr ='$voucher_id' and kostra_id >
0");
- $this->db->next_record();
- $check_count['kostra_count'] =
$this->db->f('kostra_count');
-
- return $check_count;
- }
-
-
- function update_period($voucher_id='',$period='')
- {
- $this->db->transaction_begin();
-
- $this->db->query("UPDATE fm_ecobilag set
periode='$period' where bilagsnr='$voucher_id'");
-
- $this->db->transaction_commit();
-
- $receipt['message'][] = array('msg'=>lang('voucher
period is updated'));
- return $receipt;
- }
-
-
- function increment_bilagsnr()
- {
-
- $this->db->query("UPDATE fm_idgenerator set value =
value + 1 where name = 'Bilagsnummer'");
- $this->db->query("select value from fm_idgenerator
where name = 'Bilagsnummer'");
- $this->db->next_record();
- $bilagsnr = $this->db->f('value');
- return $bilagsnr;
-
- }
-
- function next_bilagsnr()
- {
-
- $this->db->query("select value from fm_idgenerator
where name = 'Bilagsnummer'");
- $this->db->next_record();
- $bilagsnr = $this->db->f('value')+1;
-
- return $bilagsnr;
- }
-
- function check_vendor($vendor_id)
- {
-
- $this->db->query("select count(*) from fm_vendor where
id='$vendor_id'");
- $this->db->next_record();
- return $this->db->f(0);
- }
-
-
- function tax_code_list($selected='')
- {
- $this->db->query("SELECT * FROM fm_ecomva order by id
asc ");
- while ($this->db->next_record())
- {
- $tax_code_list[] = Array(
- 'id' => $this->db->f('id'),
- );
- }
-
- return $tax_code_list;
- }
-
-
- function get_lisfm_ecoart()
- {
- $this->db->query("SELECT * FROM fm_ecoart order by id
asc ");
- while ($this->db->next_record())
- {
- $art_list[] = Array(
- 'id' => $this->db->f('id'),
- 'num' => $this->db->f('name')
- );
- }
-
- return $art_list;
- }
-
- //----------
-
- function get_type_list()
- {
- $this->db->query("SELECT * FROM fm_ecobilagtype order
by id asc ");
- while ($this->db->next_record())
- {
- $art_list[] = Array(
- 'id' => $this->db->f('id'),
- 'num' => $this->db->f('name')
- );
- }
- return $art_list;
- }
-
- //----------
- function select_dimb_list()
- {
- $this->db->query("SELECT * FROM fm_ecodimb order by id
asc ");
- while ($this->db->next_record())
- {
- $dimb_list[] = Array(
- 'id' => $this->db->f('id'),
- 'num' => $this->db->f('name')
- );
- }
- return $dimb_list;
- }
-
- //-------------------
- function select_dimd_list()
- {
- $this->db->query("SELECT * FROM fm_ecodimd order by id
asc ");
- while ($this->db->next_record())
- {
- $dimd_list[] = Array(
- 'id' => $this->db->f('id'),
- 'num' => $this->db->f('name')
- );
- }
- return $dimd_list;
- }
- //---------------------
-
- function select_tax_code_list()
- {
- $this->db->query("SELECT * FROM fm_ecomva order by id
asc ");
- while ($this->db->next_record())
- {
- $tax_code_list[] = Array(
- 'id' => $this->db->f('id'),
- 'num' => $this->db->f('name')
- );
- }
- return $tax_code_list;
- }
-
- function get_invoice_user_list()
- {
-
- $sql = "SELECT * FROM fm_acl2 $this->join
phpgw_accounts on phpgw_accounts.account_id=fm_acl2.acl_account where
acl_location ='.invoice' and account_type='u' order by account_lastname";
- $this->db->query($sql,__LINE__,__FILE__);
-
- $employees[] = Array(
- 'account_lid' => 'all',
- 'account_lastname' => lang('All')
- );
-
- while ($this->db->next_record())
- {
- $employees[] = Array(
- 'account_id' =>
$this->db->f('account_id'),
- 'account_lid' =>
$this->db->f('account_lid'),
- 'account_type' =>
$this->db->f('account_type'),
- 'account_firstname' =>
$this->db->f('account_firstname'),
- 'account_lastname' =>
$this->db->f('account_lastname'),
- 'account_status' =>
$this->db->f('account_status'),
- 'account_expires' =>
$this->db->f('account_expires')
- );
- }
-//_debug_array($employees);
- return $employees;
- }
-
- function select_account_class()
- {
- $sql = "SELECT DISTINCT grouping as id from
fm_b_account ";
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $class[] = Array(
- 'id' => $this->db->f('id')
- );
- }
- return $class;
- }
- function delete($bilagsnr)
- {
- $this->db->query("DELETE FROM fm_ecobilag WHERE
bilagsnr ='" . $bilagsnr ."'",__LINE__,__FILE__);
- }
-
-
- function update_invoice($values)
- {
-
-//_debug_array($values);
- foreach($values['counter'] as $n)
- {
- $local_error='';
-
- if($values['voucher_id'][$n])
- {
- $voucher_id=$values['voucher_id'][$n];
-
-
$check_value=array('voucher_id'=>$voucher_id,
- 'sign_orig'
=> $values['sign_orig'][$n],
- 'sign'
=> $values['sign'][$n],
- 'transfer'
=> $values['transfer'][$n],
- 'kreditnota' =>
$values['kreditnota'][$n],
- 'num_days'
=> $values['num_days'][$n]);
-
-
if($this->check_for_updates($check_value))
- {
-
- $check_count =
$this->check_count($voucher_id);
-
- if
(!($check_count['dima_count'] == $values['invoice_count'][$n]))
- {
- $receipt['error'][] =
array('msg'=>lang('Dima is missing from sub invoice in:'). "
".$values['voucher_id'][$n]);
- $local_error= true;
- }
-
- if
(!($check_count['spbudact_code_count'] == $values['invoice_count'][$n]))
- {
- $receipt['error'][] =
array('msg'=>lang('Budget code is missing from sub invoice in :'). "
".$values['voucher_id'][$n]);
- $local_error= true;
- }
-
- if
(!($check_count['kostra_count'] == $values['invoice_count'][$n]))
- {
- $receipt['error'][] =
array('msg'=>'Tjenestekode mangler for undebilag: ' . "
".$values['voucher_id'][$n]);
- $local_error= true;
- }
-
- if
($this->check_claim($voucher_id))
- {
- $receipt['error'][] =
array('msg'=>lang('Tenant claim is not issued for project in voucher
%1',$voucher_id));
- $local_error= true;
- }
-
- $blank_date = '';
- $sign_field='';
- $sign_id='';
- $sign_date_field='';
- $sign_date='';
- $kommma='';
- $wait_for_kreditnota='';
- $user_lid
=$GLOBALS['phpgw_info']['user']['account_lid'];
-
- if
(($values['sign'][$n]=='sign_none') &&
($values['sign_orig'][$n]=='sign_janitor')):
- $blank_date =
'oppsynsigndato= NULL';
- $sign_field='';
- $sign_id='';
- $sign_date_field='';
- $sign_date='';
- $kommma='';
- elseif
(($values['sign'][$n]=='sign_none') &&
($values['sign_orig'][$n]=='sign_supervisor')):
- $blank_date =
'saksigndato= NULL';
- $sign_field='';
- $sign_id='';
- $sign_date_field='';
- $sign_date='';
- $kommma='';
- elseif
(($values['sign'][$n]=='sign_none') &&
($values['sign_orig'][$n]=='sign_budget_responsible')):
- $blank_date =
'budsjettsigndato= NULL';
- $sign_field='';
- $sign_id='';
- $sign_date_field='';
- $sign_date='';
- $kommma='';
- elseif
($values['sign'][$n]=='sign_janitor' && !$values['sign_orig'][$n]):
- $blank_date = '';
- $sign_field =
'oppsynsmannid=';
- $sign_id =
"'$user_lid'";
- $sign_date_field =
'oppsynsigndato=';
- $sign_date="'" .
date($this->bocommon->datetimeformat) . "'";
- $kommma=",";
- elseif
($values['sign'][$n]=='sign_janitor' &&
$values['sign_orig'][$n]=='sign_supervisor'):
- $blank_date =
'saksigndato= NULL';
- $sign_field =
'oppsynsmannid=';
- $sign_id =
"'$user_lid'";
- $sign_date_field =
'oppsynsigndato=';
- $sign_date="'" .
date($this->bocommon->datetimeformat) . "'";
- $kommma=",";
- elseif
($values['sign'][$n]=='sign_janitor' &&
$values['sign_orig'][$n]=='sign_budget_responsible'):
- $blank_date =
'budsjettsigndato= NULL';
- $sign_field =
'oppsynsmannid=';
- $sign_id =
"'$user_lid'";
- $sign_date_field =
'oppsynsigndato=';
- $sign_date="'" .
date($this->bocommon->datetimeformat) . "'";
- $kommma=",";
- elseif
($values['sign'][$n]=='sign_supervisor' && !$values['sign_orig'][$n]):
- $blank_date = '';
- $sign_field =
'saksbehandlerid=';
- $sign_id =
"'$user_lid'";
- $sign_date_field =
'saksigndato=';
- $sign_date="'" .
date($this->bocommon->datetimeformat) . "'";
- $kommma=",";
- elseif
($values['sign'][$n]=='sign_supervisor' &&
$values['sign_orig'][$n]=='sign_janitor'):
- $blank_date =
'oppsynsigndato= NULL';
- $sign_field =
'saksbehandlerid=';
- $sign_id =
"'$user_lid'";
- $sign_date_field =
'saksigndato=';
- $sign_date="'" .
date($this->bocommon->datetimeformat) . "'";
- $kommma=",";
- elseif
($values['sign'][$n]=='sign_supervisor' &&
$values['sign_orig'][$n]=='sign_budget_responsible'):
- $blank_date =
'budsjettsigndato= NULL';
- $sign_field =
'saksbehandlerid=';
- $sign_id =
"'$user_lid'";
- $sign_date_field =
'saksigndato=';
- $sign_date="'" .
date($this->bocommon->datetimeformat) . "'";
- $kommma=",";
- elseif
($values['sign'][$n]=='sign_budget_responsible' &&
$values['sign_orig'][$n]=='sign_janitor'):
- $blank_date =
'oppsynsigndato= NULL';
- $sign_field =
'budsjettansvarligid=';
- $sign_id =
"'$user_lid'";
- $sign_date_field =
'budsjettsigndato=';
- $sign_date="'" .
date($this->bocommon->datetimeformat) . "'";
- $kommma=",";
- elseif
($values['sign'][$n]=='sign_budget_responsible' &&
$values['sign_orig'][$n]=='sign_supervisor'):
- $blank_date =
'saksigndato= NULL';
- $sign_field =
'budsjettansvarligid=';
- $sign_id =
"'$user_lid'";
- $sign_date_field =
'budsjettsigndato=';
- $sign_date="'" .
date($this->bocommon->datetimeformat) . "'";
- $kommma=",";
- elseif
($values['sign'][$n]=='sign_budget_responsible' && !$values['sign_orig'][$n]):
- $blank_date = '';
- $sign_field =
'budsjettansvarligid=';
- $sign_id =
"'$user_lid'";
- $sign_date_field =
'budsjettsigndato=';
- $sign_date="'" .
date($this->bocommon->datetimeformat) . "'";
- $kommma=",";
- endif;
-
-
- if($blank_date )
- {
- $kommma_blank=",";
- }
- else
- {
- $kommma_blank='';
- }
-
-
$transfer_sign_field='utbetalingid=';
-
$transfer_date_field='utbetalingsigndato=';
-
- if
(!($values['num_days_orig'][$n]==$values['num_days'][$n]))
- {
- $payment_date =
date($this->bocommon->dateformat,$values['timestamp_voucher_date'][$n]+(24*3600*$values['num_days'][$n]));
-
$GLOBALS['phpgw']->db->query("UPDATE fm_ecobilag set forfallsdato=
'$payment_date' where bilagsnr='$voucher_id'");
- }
-
- $transfer_id="Null".",";
- $transfer_date="Null";
-
- if ($values['transfer'][$n])
- {
- if
($this->check_for_transfer($voucher_id))
- {
-
$transfer_id="'$user_lid',";
-
$transfer_date="'" . date($this->bocommon->datetimeformat) . "'";
- }
- else
- {
-
$receipt['error'][] = array('msg'=>'Dette bilaget er ikkje godkjent: ' . "
".$voucher_id);
- $local_error=
true;
- }
-
- }
-
- if ($values['kreditnota'][$n])
- {
- $wait_for_kreditnota=1;
- $transfer_date="Null";
- }
- else
- {
-
$wait_for_kreditnota='NULL';
- }
-
- if (! $local_error)
- {
- $sql= "UPDATE
fm_ecobilag set $blank_date $kommma_blank $sign_field $sign_id $kommma
$sign_date_field $sign_date $kommma $transfer_sign_field $transfer_id
$transfer_date_field $transfer_date ,kreditnota=$wait_for_kreditnota where
bilagsnr='$voucher_id'";
-
$GLOBALS['phpgw']->db->transaction_begin();
-
$GLOBALS['phpgw']->db->query($sql);
-
$GLOBALS['phpgw']->db->transaction_commit();
-
- $receipt['message'][] =
array('msg'=> lang('voucher is updated: ') . $voucher_id);
- }
- }
- }
- }
-
- $GLOBALS['phpgw']->db->query("UPDATE fm_ecobilag set
utbetalingid = NULL, utbetalingsigndato = NULL WHERE budsjettsigndato IS NULL");
- $GLOBALS['phpgw']->db->query("UPDATE fm_ecobilag set
utbetalingid = NULL, utbetalingsigndato = NULL WHERE oppsynsigndato IS NULL AND
saksigndato IS NULL");
-
- return $receipt;
- }
-
- function check_for_transfer($voucher_id='')
- {
- $allow_transfer=False;
-
- $sql = "SELECT * FROM fm_ecobilag WHERE
bilagsnr='$voucher_id'";
- $this->db->limit_query($sql,0,__LINE__,__FILE__,1);
-
- $this->db->next_record();
-
- if ($this->db->f('budsjettsigndato') &&
($this->db->f('oppsynsigndato') || $this->db->f('saksigndato')))
- {
- $allow_transfer=True;
- }
-
- return $allow_transfer;
- }
-
- function check_claim($voucher_id='')
- {
- $sql = "SELECT count(*) FROM fm_ecobilag
$this->left_join fm_workorder on fm_ecobilag.pmwrkord_code = fm_workorder.id "
- . " WHERE bilagsnr='$voucher_id' AND
fm_workorder.charge_tenant=1 AND fm_workorder.claim_issued IS NULL";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- return $this->db->f(0);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage eco
+ * @version $Id: class.soinvoice.inc.php,v 1.18 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class soinvoice
+ {
+
+ function soinvoice()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->account_id =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2','##DEFAULT##','##DEFAULT##');
+
+ $this->join = $this->bocommon->join;
+ $this->left_join = $this->bocommon->left_join;
+ $this->like = $this->bocommon->like;
+ }
+
+
+ function read_invoice($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $user_lid =
(isset($data['user_lid'])?$data['user_lid']:'none');
+ $paid =
(isset($data['paid'])?$data['paid']:'');
+ $start_date =
(isset($data['start_date'])?$data['start_date']:'');
+ $end_date =
(isset($data['end_date'])?$data['end_date']:'');
+ $vendor_id =
(isset($data['vendor_id'])?$data['vendor_id']:'');
+ $loc1 =
(isset($data['loc1'])?$data['loc1']:'');
+ $workorder_id =
(isset($data['workorder_id'])?$data['workorder_id']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $voucher_id =
(isset($data['voucher_id'])?$data['voucher_id']:'');
+ }
+
+//_debug_array($data);
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by bilagsnr DESC';
+ }
+
+ $where= 'WHERE';
+
+ if ($user_lid=='none' || !$user_lid):
+ {
+ return;
+ }
+ elseif ($user_lid!='all'):
+ {
+ $filtermethod = " WHERE ( oppsynsmannid=
'$user_lid' or saksbehandlerid= '$user_lid' or budsjettansvarligid=
'$user_lid')";
+ $where= 'AND';
+ }
+ endif;
+
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " $where typeid='$cat_id' ";
+ $where= 'AND';
+ }
+
+ if ($district_id > 0)
+ {
+ $filtermethod .= " $where
district_id='$district_id' ";
+ $where= 'AND';
+ }
+
+ if ($vendor_id)
+ {
+ $filtermethod .= " $where spvend_code
='$vendor_id' ";
+ $where= 'AND';
+ }
+ if ($loc1)
+ {
+ $filtermethod .= " $where dima $this->like
'%$loc1%' ";
+ $where= 'AND';
+ }
+ if ($workorder_id)
+ {
+ $filtermethod .= " $where pmwrkord_code
='$workorder_id' ";
+ $where= 'AND';
+ }
+ if ($voucher_id)
+ {
+ $filtermethod .= " $where bilagsnr $this->like
'%$voucher_id%' ";
+ $where= 'AND';
+ }
+
+
+ if ($paid)
+ {
+ $table = 'fm_ecobilagoverf';
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $dateformat = str_replace(".","",$dateformat);
+ $dateformat = str_replace("-","",$dateformat);
+ $dateformat = str_replace("/","",$dateformat);
+ $y=strpos($dateformat,'y');
+ $d=strpos($dateformat,'d');
+ $m=strpos($dateformat,'m');
+
+ $dateparts = explode('/', $start_date);
+ $sday = $dateparts[$d];
+ $smonth = $dateparts[$m];
+ $syear = $dateparts[$y];
+
+ $dateparts = explode('/', $end_date);
+ $eday = $dateparts[$d];
+ $emonth = $dateparts[$m];
+ $eyear = $dateparts[$y];
+
+ $start_date =
date($this->bocommon->dateformat,mktime(2,0,0,$smonth,$sday,$syear));
+ $end_date =
date($this->bocommon->dateformat,mktime(2,0,0,$emonth,$eday,$eyear));
+
+ if (!$workorder_id && !$voucher_id)
+ {
+ $filtermethod .= " $where overftid
>'$start_date' and overftid < '$end_date'";
+ }
+ }
+ else
+ {
+ $table ='fm_ecobilag';
+ }
+
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " $where ( spvend_code
$this->like '%$query%' OR bilagsnr $this->like '%$query%' )";
+ }
+
+
+ $sql = "SELECT DISTINCT bilagsnr, count(bilagsnr) as
invoice_count, sum(belop) as belop,spvend_code,fakturadato FROM $table
$filtermethod $querymethod group by bilagsnr,spvend_code,fakturadato ";
+ $sql2 = "SELECT DISTINCT bilagsnr FROM $table
$filtermethod $querymethod";
+
+//echo $sql;
+ $this->db2->query($sql2,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $temp[] = array
+ (
+ 'voucher_id' =>
$this->db->f('bilagsnr'),
+ 'invoice_count' =>
$this->db->f('invoice_count'),
+ 'amount' =>
$this->db->f('belop')
+ );
+ }
+
+ if ($temp)
+ {
+ $role= $this->check_role();
+ $i = 0;
+ foreach($temp as $invoice_temp)
+ {
+ $voucher_id=$invoice_temp['voucher_id'];
+
+ $sql = "SELECT
spvend_code,oppsynsmannid,saksbehandlerid,budsjettansvarligid,"
+ . "
utbetalingid,oppsynsigndato,saksigndato,budsjettsigndato,utbetalingsigndato,fakturadato,org_name,"
+ . "
forfallsdato,periode,artid,kidnr,kreditnota "
+ . " from $table $this->join fm_vendor
ON fm_vendor.id = $table.spvend_code WHERE bilagsnr = $voucher_id "
+ . " group by
bilagsnr,spvend_code,oppsynsmannid,saksbehandlerid,budsjettansvarligid,"
+ . "
utbetalingid,oppsynsigndato,saksigndato,budsjettsigndato,utbetalingsigndato,fakturadato,org_name,"
+ . "
forfallsdato,periode,artid,kidnr,kreditnota ";
+
+
$this->db->query($sql,__LINE__,__FILE__);
+
+ $this->db->next_record();
+
+ $timestamp_voucher_date=
mktime(0,0,0,date(m,strtotime($this->db->f('fakturadato'))),date(d,strtotime($this->db->f('fakturadato'))),date(y,strtotime($this->db->f('fakturadato'))));
+ $timestamp_payment_date=
mktime(0,0,0,date(m,strtotime($this->db->f('forfallsdato'))),date(d,strtotime($this->db->f('forfallsdato'))),date(y,strtotime($this->db->f('forfallsdato'))));
+
+ if($this->db->f('oppsynsmannid') &&
$this->db->f('oppsynsigndato'))
+ {
+// $timestamp_jan_date
=
mktime(0,0,0,date(m,strtotime($this->db->f('oppsynsigndato'))),date(d,strtotime($this->db->f('oppsynsigndato'))),date(y,strtotime($this->db->f('oppsynsigndato'))));
+// $invoice[$i]['jan_date']
=
$GLOBALS['phpgw']->common->show_date($timestamp_jan_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+
$invoice[$i]['jan_date']=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($this->db->f('oppsynsigndato')));
+ }
+ else
+ {
+ $invoice[$i]['jan_date']
='';
+ }
+ if($this->db->f('saksbehandlerid') &&
$this->db->f('saksigndato'))
+ {
+// $timestamp_super_date
=
mktime(0,0,0,date(m,strtotime($this->db->f('saksigndato'))),date(d,strtotime($this->db->f('saksigndato'))),date(y,strtotime($this->db->f('saksigndato'))));
+// $invoice[$i]['super_date']
=
$GLOBALS['phpgw']->common->show_date($timestamp_super_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+
$invoice[$i]['super_date']=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($this->db->f('saksigndato')));
+ }
+ else
+ {
+ $invoice[$i]['super_date']
='';
+ }
+
+ if($this->db->f('budsjettansvarligid')
&& $this->db->f('budsjettsigndato'))
+ {
+// $timestamp_budget_date
=
mktime(0,0,0,date(m,strtotime($this->db->f('budsjettsigndato'))),date(d,strtotime($this->db->f('budsjettsigndato'))),date(y,strtotime($this->db->f('budsjettsigndato'))));
+//
$invoice[$i]['budget_date'] =
$GLOBALS['phpgw']->common->show_date($timestamp_budget_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+
$invoice[$i]['budget_date']=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($this->db->f('budsjettsigndato')));
+ }
+ else
+ {
+ $invoice[$i]['budget_date']
='';
+ }
+
+ if($this->db->f('utbetalingid') &&
$this->db->f('utbetalingsigndato'))
+ {
+// $timestamp_transfer_date=
mktime(0,0,0,date(m,strtotime($this->db->f('utbetalingsigndato'))),date(d,strtotime($this->db->f('utbetalingsigndato'))),date(y,strtotime($this->db->f('utbetalingsigndato'))));
+// $invoice[$i]['transfer_date']
=
$GLOBALS['phpgw']->common->show_date($timestamp_transfer_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+
$invoice[$i]['transfer_date']=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($this->db->f('utbetalingsigndato')));
+ }
+ else
+ {
+ $invoice[$i]['transfer_date']
='';
+ }
+
+ $invoice[$i]['counter']
= $i;
+ $invoice[$i]['current_user']
= $GLOBALS['phpgw_info']['user']['account_lid'];
+ $invoice[$i]['voucher_id']
= $voucher_id;
+ $invoice[$i]['invoice_count']
= $invoice_temp['invoice_count'];
+ $invoice[$i]['vendor_id']
= $this->db->f('spvend_code');
+ $invoice[$i]['vendor']
= $this->db->f('org_name');
+ $invoice[$i]['is_janitor']
= $role['is_janitor'];
+ $invoice[$i]['is_supervisor']
= $role['is_supervisor'];
+ $invoice[$i]['is_budget_responsible']
= $role['is_budget_responsible'];
+ $invoice[$i]['is_janitor']
= $role['is_janitor'];
+ $invoice[$i]['is_transfer']
= $role['is_transfer'];
+ $invoice[$i]['janitor']
= $this->db->f('oppsynsmannid');
+ $invoice[$i]['supervisor']
= $this->db->f('saksbehandlerid');
+ $invoice[$i]['budget_responsible']
= $this->db->f('budsjettansvarligid');
+ $invoice[$i]['transfer_id']
= $this->db->f('utbetalingid');
+ $invoice[$i]['voucher_date']
=
$GLOBALS['phpgw']->common->show_date($timestamp_voucher_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $invoice[$i]['payment_date']
=
$GLOBALS['phpgw']->common->show_date($timestamp_payment_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $invoice[$i]['period']
= $this->db->f('periode');
+ $invoice[$i]['type']
= $this->db->f('artid');
+ $invoice[$i]['kidnr']
= $this->db->f('kidnr');
+ $invoice[$i]['kreditnota']
= $this->db->f('kreditnota');
+ $invoice[$i]['amount']
= $invoice_temp['amount'];
+ $invoice[$i]['num_days']
=
intval(($timestamp_payment_date-$timestamp_voucher_date)/(24*3600));
+ $invoice[$i]['timestamp_voucher_date']
= $timestamp_voucher_date;
+
+
if($invoice[$i]['current_user']==$invoice[$i]['janitor'] &&
$invoice[$i]['jan_date']):
+ {
+
$invoice[$i]['sign_orig']='sign_janitor';
+ }
+
elseif($invoice[$i]['current_user']==$invoice[$i]['supervisor'] &&
$invoice[$i]['super_date']):
+ {
+
$invoice[$i]['sign_orig']='sign_supervisor';
+ }
+
elseif($invoice[$i]['current_user']==$invoice[$i]['budget_responsible'] &&
$invoice[$i]['budget_date']):
+ {
+
$invoice[$i]['sign_orig']='sign_budget_responsible';
+ }
+ endif;
+
+ $i++;
+
+ }
+ }
+// $end_time = explode(' ',microtime());
+// $this->end_time = $end_time;
+
+//_debug_array($invoice);
+//_debug_array($invoice_temp);
+
+ return $invoice;
+
+ }
+
+
+ function read_invoice_sub($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $voucher_id =
(isset($data['voucher_id'])?$data['voucher_id']:0);
+ $paid = (isset($data['paid'])?$data['paid']:'');
+ }
+
+ if ($paid)
+ {
+ $table = 'fm_ecobilagoverf';
+ }
+ else
+ {
+ $table ='fm_ecobilag';
+ }
+
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by bilagsnr DESC';
+ }
+
+ if ($voucher_id)
+ {
+ $filtermethod = " WHERE ( bilagsnr=
'$voucher_id')";
+ }
+
+ $sql = "SELECT
$table.*,fm_workorder.status,fm_workorder.charge_tenant,org_name,fm_workorder.claim_issued
FROM $table "
+ . " $this->left_join fm_workorder on fm_workorder.id =
$table.pmwrkord_code "
+ . " $this->join fm_vendor on $table.spvend_code =
fm_vendor.id $filtermethod ";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ $this->db->query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+
+ $i = 0;
+
+ while ($this->db->next_record())
+ {
+ $invoice[$i]['counter']
= $i;
+ $invoice[$i]['claim_issued']
= $this->db->f('claim_issued');
+ $invoice[$i]['project_id']
= $this->db->f('project_id');
+ $invoice[$i]['workorder_id']
= $this->db->f('pmwrkord_code');
+ $invoice[$i]['status']
= $this->db->f('status');
+ if ($this->db->f('status')=='closed')
+ {
+ $invoice[$i]['closed']
= True;
+ }
+ $invoice[$i]['voucher_id']
= $voucher_id;
+ $invoice[$i]['id']
= $this->db->f('id');
+ $invoice[$i]['invoice_id']
= $this->db->f('fakturanr');
+ $invoice[$i]['budget_account']
= $this->db->f('spbudact_code');
+ $invoice[$i]['dima']
= $this->db->f('dima');
+ $invoice[$i]['dimb']
= $this->db->f('dimb');
+ $invoice[$i]['dimd']
= $this->db->f('dimd');
+ if ($this->db->f('merknad'))
+ {
+ $invoice[$i]['remark']
= True;
+ }
+ $invoice[$i]['tax_code']
= $this->db->f('mvakode');
+ $invoice[$i]['amount']
= $this->db->f('belop');
+ $invoice[$i]['charge_tenant']
= $this->db->f('charge_tenant');
+ $invoice[$i]['vendor']
= $this->db->f('org_name');
+ $i++;
+
+ }
+
+ return $invoice;
+
+ }
+
+
+ function read_consume($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $start_date =
(isset($data['start_date'])?$data['start_date']:'');
+ $end_date =
(isset($data['end_date'])?$data['end_date']:'');
+ $vendor_id =
(isset($data['vendor_id'])?$data['vendor_id']:'');
+ $loc1 =
(isset($data['loc1'])?$data['loc1']:'');
+ $district_id =
(isset($data['district_id'])?$data['district_id']:'');
+ $workorder_id =
(isset($data['workorder_id'])?$data['workorder_id']:0);
+ $b_account_class =
(isset($data['b_account_class'])?$data['b_account_class']:'');
+ }
+//_debug_array($data);
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $dateformat = str_replace(".","",$dateformat);
+ $dateformat = str_replace("-","",$dateformat);
+ $dateformat = str_replace("/","",$dateformat);
+ $y=strpos($dateformat,'y');
+ $d=strpos($dateformat,'d');
+ $m=strpos($dateformat,'m');
+ $dateparts = explode('/', $start_date);
+ $sday = $dateparts[$d];
+ $smonth = $dateparts[$m];
+ $syear = $dateparts[$y];
+
+ $dateparts = explode('/', $end_date);
+ $eday = $dateparts[$d];
+ $emonth = $dateparts[$m];
+ $eyear = $dateparts[$y];
+
+ $start_date =
date($this->bocommon->dateformat,mktime(2,0,0,$smonth,$sday,$syear));
+ $end_date =
date($this->bocommon->dateformat,mktime(2,0,0,$emonth,$eday,$eyear));
+
+
+ $where = 'WHERE';
+
+ if($b_account_class)
+ {
+ $filtermethod= " $where
fm_b_account.grouping='$b_account_class'";
+ $where= 'AND';
+ }
+ else
+ {
+ $select_account_class=',fm_b_account.grouping
as b_account_class';
+ $group_account_class=',
spbudact_code,fm_b_account.grouping';
+ }
+
+ if ($vendor_id)
+ {
+ $filtermethod .= " $where (spvend_code =
$vendor_id)";
+ $where= 'AND';
+ }
+
+ if($loc1)
+ {
+ $filtermethod .=" $where (dima $this->like
'%$loc1%')";
+ $where= 'AND';
+ }
+
+
+ if ($district_id)
+ {
+ $filtermethod.= " $where district_id=
$district_id ";
+ $where= 'AND';
+ }
+
+ if ($workorder_id)
+ {
+ $filtermethod.= " $where pmwrkord_code =
$workorder_id";
+ $where= 'AND';
+ }
+
+
+ if ($cat_id>0)
+ {
+ $filtermethod .= " $where typeid = $cat_id";
+ $where= 'AND';
+ }
+
+ $filtermethod .= " $where (fakturadato >'$start_date')
AND (fakturadato < '$end_date')";
+
+ $sql = "SELECT district_id,periode,sum(godkjentbelop)
as consume $select_account_class "
+ . " FROM fm_ecobilagoverf $this->join
fm_location1 ON (fm_ecobilagoverf.loc1 = fm_location1.loc1) "
+ . " $this->join fm_part_of_town ON
(fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id) "
+ . " $this->join fm_b_account ON
(fm_ecobilagoverf.spbudact_code = fm_b_account.id) "
+ . " $filtermethod group by district_id,periode
$group_account_class";
+//echo $sql;
+
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db->num_rows();
+ $this->db->query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+
+ $i = 0;
+
+ while ($this->db->next_record())
+ {
+ $consume[$i]['consume']
= $this->db->f('consume');
+ $consume[$i]['period']
= $this->db->f('periode');
+ $consume[$i]['district_id']
= $this->db->f('district_id');
+ if(!$b_account_class)
+ {
+ $consume[$i]['account_class']
= $this->db->f('b_account_class');
+ }
+ else
+ {
+ $consume[$i]['account_class']
= $b_account_class;
+ }
+
+ $i++;
+ }
+//_debug_array($consume);
+ return $consume;
+ }
+
+ function check_for_updates($values)
+ {
+ $update=False;
+
+ if($values['sign_orig']!=$values['sign'])
+ {
+ $update=True;
+ return $update;
+ }
+
+ $sql = "SELECT * FROM fm_ecobilag WHERE bilagsnr=" .
$values['voucher_id'];
+ $this->db->limit_query($sql,0,__LINE__,__FILE__,1);
+
+ $this->db->next_record();
+
+ if( ($this->db->f('utbetalingsigndato') &&
!$values['transfer']) || (!$this->db->f('utbetalingsigndato') &&
$values['transfer']))
+ {
+ $update=True;
+ return $update;
+ }
+
+ if( ($this->db->f('kreditnota') &&
!$values['kreditnota']) || (!$this->db->f('kreditnota') &&
$values['kreditnota']) )
+ {
+ $update=True;
+ return $update;
+ }
+
+ $timestamp_voucher_date=
mktime(0,0,0,date(m,strtotime($this->db->f('fakturadato'))),date(d,strtotime($this->db->f('fakturadato'))),date(y,strtotime($this->db->f('fakturadato'))));
+ $timestamp_payment_date=
mktime(0,0,0,date(m,strtotime($this->db->f('forfallsdato'))),date(d,strtotime($this->db->f('forfallsdato'))),date(y,strtotime($this->db->f('forfallsdato'))));
+
+ if(
((intval(($timestamp_payment_date-$timestamp_voucher_date)/(24*3600)))!=$values['num_days'])
)
+ {
+ $update=True;
+ return $update;
+ }
+ }
+
+ function update_invoice_sub($values)
+ {
+
+ $GLOBALS['phpgw']->db->transaction_begin();
+
+ while($entry=each($values['counter']))
+ {
+ $local_error='';
+
+ $n=$entry[0];
+
+
+//_debug_array($entry);
+
+
+ if ($values['budget_account'][$n])
+ {
+
$budget_account=$values['budget_account'][$n];
+
+ $GLOBALS['phpgw']->db->query("select
count(*) from fm_b_account where id =$budget_account");
+ $GLOBALS['phpgw']->db->next_record();
+ if ($GLOBALS['phpgw']->db->f(0) == 0)
+ {
+ $receipt['error'][] =
array('msg'=> lang('This account is not valid:'). " ".$budget_account);
+ $local_error= true;
+ }
+ }
+ else
+ {
+ $receipt['error'][] =
array('msg'=>lang('Budget account is missing:'));
+ $local_error= true;
+ }
+
+ if(!$values['dimd'][$n])
+ {
+ $dimd_field="dimd=NULL";
+ }
+ else
+ {
+ $dimd=$values['dimd'][$n];
+ $GLOBALS['phpgw']->db->query("select
count(*) from fm_dim_d where id =$dimd");
+ $GLOBALS['phpgw']->db->next_record();
+ if ($GLOBALS['phpgw']->db->f(0) == 0)
+ {
+ $receipt['error'][] =
array('msg'=>lang('This Dim D is not valid:'). " ".$dimd);
+ $local_error= true;
+ }
+
+ $dimd_field="dimd="."'" . $dimd . "'";
+ }
+
+ if (!$values['dima'][$n])
+ {
+ $dima_field="dima=NULL";
+ $receipt['error'][] =
array('msg'=>lang('Dim A is missing'));
+ $local_error= true;
+ }
+ else
+ {
+
$dima_check=substr($values['dima'][$n],0,4);
+ $GLOBALS['phpgw']->db->query("select
loc1, kostra_id from fm_location1 where loc1 = '$dima_check' ");
+ $GLOBALS['phpgw']->db->next_record();
+ if (!$GLOBALS['phpgw']->db->f('loc1'))
+ {
+ $receipt['error'][] =
array('msg'=>lang('This Dim A is not valid:'). " ".$values['dima'][$n]);
+ $local_error= true;
+ }
+
+ if
(!$GLOBALS['phpgw']->db->f('kostra_id') ||
$GLOBALS['phpgw']->db->f('kostra_id') == 0)
+ {
+ $receipt['error'][] =
array('msg'=>'objektet mangler tjeneste - utgått? '. " ".$values['dima'][$n]);
+ $local_error= true;
+ }
+
+ // $dima_field="dima="."'" .
$values['dima'][$n] . "'";
+ $dima_field="dima="."'" .
$values['dima'][$n] . "',loc1=" . "'" . substr($values['dima'][$n],0,4) . "'";
+
+ $kostra_field="kostra_id="."'" .
$GLOBALS['phpgw']->db->f('kostra_id') . "'";
+
+ }
+
+ if (! $local_error)
+ {
+ $id =
$values['id'][$n];
+ $tax_code =
$values['tax_code'][$n];
+
$workorder_id=$values['workorder_id'][$n];
+ if($values['close_order'][$n] &&
!$values['close_order_orig'][$n])
+ {
+
$update_status[$workorder_id]='X';
+ }
+
+ if(!$values['close_order'][$n] &&
$values['close_order_orig'][$n])
+ {
+
$update_status[$workorder_id]='R';
+ }
+
+ $GLOBALS['phpgw']->db->query("UPDATE
fm_ecobilag set $dima_field ,$kostra_field,$dimd_field, mvakode =
'$tax_code',spbudact_code = '$budget_account' where id='$id'");
+
+ $receipt['message'][] =
array('msg'=>lang('Voucher is updated '));
+ }
+
+ }
+
+ if (isset($update_status) AND is_array($update_status))
+ {
+
$status_code=array('X'=>'closed','R'=>'re_opened');
+
+ $historylog_workorder =
CreateObject($this->currentapp.'.historylog','workorder');
+
+ while (list($id,$entry) = each($update_status))
+ {
+
$historylog_workorder->add($entry,$id,$status_code[$entry]);
+ $GLOBALS['phpgw']->db->query("UPDATE
fm_workorder set status=" . "'$status_code[$entry]'" . "where id=$id");
+ $receipt['message'][] =
array('msg'=>lang('Workorder %1 is %2',$id, $status_code[$entry]));
+ }
+ }
+
+ $GLOBALS['phpgw']->db->transaction_commit();
+
+ return $receipt;
+ }
+
+ function read_remark($id='',$paid='')
+ {
+ if ($paid)
+ {
+ $table = 'fm_ecobilagoverf';
+ }
+ else
+ {
+ $table ='fm_ecobilag';
+ }
+
+ $this->db->query(" SELECT merknad from $table where
id= '$id'");
+ $this->db->next_record();
+
+ return $this->db->f('merknad');
+ }
+
+ function check_role()
+ {
+ if(!$this->role)
+ {
+ $this->role=array(
+ 'is_janitor'
=> $this->acl2->check('.invoice',32),
+ 'is_supervisor'
=> $this->acl2->check('.invoice',64),
+ 'is_budget_responsible' =>
$this->acl2->check('.invoice',128),
+ 'is_transfer'
=> $this->acl2->check('.invoice',16)
+ );
+ }
+ return $this->role;
+ }
+
+ function check_count($voucher_id)
+ {
+
+ $this->db->query("select count(dima) as dima_count ,
count(spbudact_code) as spbudact_code_count from fm_ecobilag where bilagsnr
='$voucher_id'");
+ $this->db->next_record();
+
+ $check_count=array(
+ 'dima_count' =>
$this->db->f('dima_count'),
+ 'spbudact_code_count' =>
$this->db->f('spbudact_code_count')
+ );
+
+ $this->db->query("select count(kostra_id) as
kostra_count from fm_ecobilag where bilagsnr ='$voucher_id' and kostra_id >
0");
+ $this->db->next_record();
+ $check_count['kostra_count'] =
$this->db->f('kostra_count');
+
+ return $check_count;
+ }
+
+
+ function update_period($voucher_id='',$period='')
+ {
+ $this->db->transaction_begin();
+
+ $this->db->query("UPDATE fm_ecobilag set
periode='$period' where bilagsnr='$voucher_id'");
+
+ $this->db->transaction_commit();
+
+ $receipt['message'][] = array('msg'=>lang('voucher
period is updated'));
+ return $receipt;
+ }
+
+
+ function increment_bilagsnr()
+ {
+
+ $this->db->query("UPDATE fm_idgenerator set value =
value + 1 where name = 'Bilagsnummer'");
+ $this->db->query("select value from fm_idgenerator
where name = 'Bilagsnummer'");
+ $this->db->next_record();
+ $bilagsnr = $this->db->f('value');
+ return $bilagsnr;
+
+ }
+
+ function next_bilagsnr()
+ {
+
+ $this->db->query("select value from fm_idgenerator
where name = 'Bilagsnummer'");
+ $this->db->next_record();
+ $bilagsnr = $this->db->f('value')+1;
+
+ return $bilagsnr;
+ }
+
+ function check_vendor($vendor_id)
+ {
+
+ $this->db->query("select count(*) from fm_vendor where
id='$vendor_id'");
+ $this->db->next_record();
+ return $this->db->f(0);
+ }
+
+
+ function tax_code_list($selected='')
+ {
+ $this->db->query("SELECT * FROM fm_ecomva order by id
asc ");
+ while ($this->db->next_record())
+ {
+ $tax_code_list[] = Array(
+ 'id' => $this->db->f('id'),
+ );
+ }
+
+ return $tax_code_list;
+ }
+
+
+ function get_lisfm_ecoart()
+ {
+ $this->db->query("SELECT * FROM fm_ecoart order by id
asc ");
+ while ($this->db->next_record())
+ {
+ $art_list[] = Array(
+ 'id' => $this->db->f('id'),
+ 'num' => $this->db->f('name')
+ );
+ }
+
+ return $art_list;
+ }
+
+ //----------
+
+ function get_type_list()
+ {
+ $this->db->query("SELECT * FROM fm_ecobilagtype order
by id asc ");
+ while ($this->db->next_record())
+ {
+ $art_list[] = Array(
+ 'id' => $this->db->f('id'),
+ 'num' => $this->db->f('name')
+ );
+ }
+ return $art_list;
+ }
+
+ //----------
+ function select_dimb_list()
+ {
+ $this->db->query("SELECT * FROM fm_ecodimb order by id
asc ");
+ while ($this->db->next_record())
+ {
+ $dimb_list[] = Array(
+ 'id' => $this->db->f('id'),
+ 'num' => $this->db->f('name')
+ );
+ }
+ return $dimb_list;
+ }
+
+ //-------------------
+ function select_dimd_list()
+ {
+ $this->db->query("SELECT * FROM fm_ecodimd order by id
asc ");
+ while ($this->db->next_record())
+ {
+ $dimd_list[] = Array(
+ 'id' => $this->db->f('id'),
+ 'num' => $this->db->f('name')
+ );
+ }
+ return $dimd_list;
+ }
+ //---------------------
+
+ function select_tax_code_list()
+ {
+ $this->db->query("SELECT * FROM fm_ecomva order by id
asc ");
+ while ($this->db->next_record())
+ {
+ $tax_code_list[] = Array(
+ 'id' => $this->db->f('id'),
+ 'num' => $this->db->f('name')
+ );
+ }
+ return $tax_code_list;
+ }
+
+ function get_invoice_user_list()
+ {
+
+ $sql = "SELECT * FROM fm_acl2 $this->join
phpgw_accounts on phpgw_accounts.account_id=fm_acl2.acl_account where
acl_location ='.invoice' and account_type='u' order by account_lastname";
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ $employees[] = Array(
+ 'account_lid' => 'all',
+ 'account_lastname' => lang('All')
+ );
+
+ while ($this->db->next_record())
+ {
+ $employees[] = Array(
+ 'account_id' =>
$this->db->f('account_id'),
+ 'account_lid' =>
$this->db->f('account_lid'),
+ 'account_type' =>
$this->db->f('account_type'),
+ 'account_firstname' =>
$this->db->f('account_firstname'),
+ 'account_lastname' =>
$this->db->f('account_lastname'),
+ 'account_status' =>
$this->db->f('account_status'),
+ 'account_expires' =>
$this->db->f('account_expires')
+ );
+ }
+//_debug_array($employees);
+ return $employees;
+ }
+
+ function select_account_class()
+ {
+ $sql = "SELECT DISTINCT grouping as id from
fm_b_account ";
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $class[] = Array(
+ 'id' => $this->db->f('id')
+ );
+ }
+ return $class;
+ }
+ function delete($bilagsnr)
+ {
+ $this->db->query("DELETE FROM fm_ecobilag WHERE
bilagsnr ='" . $bilagsnr ."'",__LINE__,__FILE__);
+ }
+
+
+ function update_invoice($values)
+ {
+
+//_debug_array($values);
+ foreach($values['counter'] as $n)
+ {
+ $local_error='';
+
+ if($values['voucher_id'][$n])
+ {
+ $voucher_id=$values['voucher_id'][$n];
+
+
$check_value=array('voucher_id'=>$voucher_id,
+ 'sign_orig'
=> $values['sign_orig'][$n],
+ 'sign'
=> $values['sign'][$n],
+ 'transfer'
=> $values['transfer'][$n],
+ 'kreditnota' =>
$values['kreditnota'][$n],
+ 'num_days'
=> $values['num_days'][$n]);
+
+
if($this->check_for_updates($check_value))
+ {
+
+ $check_count =
$this->check_count($voucher_id);
+
+ if
(!($check_count['dima_count'] == $values['invoice_count'][$n]))
+ {
+ $receipt['error'][] =
array('msg'=>lang('Dima is missing from sub invoice in:'). "
".$values['voucher_id'][$n]);
+ $local_error= true;
+ }
+
+ if
(!($check_count['spbudact_code_count'] == $values['invoice_count'][$n]))
+ {
+ $receipt['error'][] =
array('msg'=>lang('Budget code is missing from sub invoice in :'). "
".$values['voucher_id'][$n]);
+ $local_error= true;
+ }
+
+ if
(!($check_count['kostra_count'] == $values['invoice_count'][$n]))
+ {
+ $receipt['error'][] =
array('msg'=>'Tjenestekode mangler for undebilag: ' . "
".$values['voucher_id'][$n]);
+ $local_error= true;
+ }
+
+ if
($this->check_claim($voucher_id))
+ {
+ $receipt['error'][] =
array('msg'=>lang('Tenant claim is not issued for project in voucher
%1',$voucher_id));
+ $local_error= true;
+ }
+
+ $blank_date = '';
+ $sign_field='';
+ $sign_id='';
+ $sign_date_field='';
+ $sign_date='';
+ $kommma='';
+ $wait_for_kreditnota='';
+ $user_lid
=$GLOBALS['phpgw_info']['user']['account_lid'];
+
+ if
(($values['sign'][$n]=='sign_none') &&
($values['sign_orig'][$n]=='sign_janitor')):
+ $blank_date =
'oppsynsigndato= NULL';
+ $sign_field='';
+ $sign_id='';
+ $sign_date_field='';
+ $sign_date='';
+ $kommma='';
+ elseif
(($values['sign'][$n]=='sign_none') &&
($values['sign_orig'][$n]=='sign_supervisor')):
+ $blank_date =
'saksigndato= NULL';
+ $sign_field='';
+ $sign_id='';
+ $sign_date_field='';
+ $sign_date='';
+ $kommma='';
+ elseif
(($values['sign'][$n]=='sign_none') &&
($values['sign_orig'][$n]=='sign_budget_responsible')):
+ $blank_date =
'budsjettsigndato= NULL';
+ $sign_field='';
+ $sign_id='';
+ $sign_date_field='';
+ $sign_date='';
+ $kommma='';
+ elseif
($values['sign'][$n]=='sign_janitor' && !$values['sign_orig'][$n]):
+ $blank_date = '';
+ $sign_field =
'oppsynsmannid=';
+ $sign_id =
"'$user_lid'";
+ $sign_date_field =
'oppsynsigndato=';
+ $sign_date="'" .
date($this->bocommon->datetimeformat) . "'";
+ $kommma=",";
+ elseif
($values['sign'][$n]=='sign_janitor' &&
$values['sign_orig'][$n]=='sign_supervisor'):
+ $blank_date =
'saksigndato= NULL';
+ $sign_field =
'oppsynsmannid=';
+ $sign_id =
"'$user_lid'";
+ $sign_date_field =
'oppsynsigndato=';
+ $sign_date="'" .
date($this->bocommon->datetimeformat) . "'";
+ $kommma=",";
+ elseif
($values['sign'][$n]=='sign_janitor' &&
$values['sign_orig'][$n]=='sign_budget_responsible'):
+ $blank_date =
'budsjettsigndato= NULL';
+ $sign_field =
'oppsynsmannid=';
+ $sign_id =
"'$user_lid'";
+ $sign_date_field =
'oppsynsigndato=';
+ $sign_date="'" .
date($this->bocommon->datetimeformat) . "'";
+ $kommma=",";
+ elseif
($values['sign'][$n]=='sign_supervisor' && !$values['sign_orig'][$n]):
+ $blank_date = '';
+ $sign_field =
'saksbehandlerid=';
+ $sign_id =
"'$user_lid'";
+ $sign_date_field =
'saksigndato=';
+ $sign_date="'" .
date($this->bocommon->datetimeformat) . "'";
+ $kommma=",";
+ elseif
($values['sign'][$n]=='sign_supervisor' &&
$values['sign_orig'][$n]=='sign_janitor'):
+ $blank_date =
'oppsynsigndato= NULL';
+ $sign_field =
'saksbehandlerid=';
+ $sign_id =
"'$user_lid'";
+ $sign_date_field =
'saksigndato=';
+ $sign_date="'" .
date($this->bocommon->datetimeformat) . "'";
+ $kommma=",";
+ elseif
($values['sign'][$n]=='sign_supervisor' &&
$values['sign_orig'][$n]=='sign_budget_responsible'):
+ $blank_date =
'budsjettsigndato= NULL';
+ $sign_field =
'saksbehandlerid=';
+ $sign_id =
"'$user_lid'";
+ $sign_date_field =
'saksigndato=';
+ $sign_date="'" .
date($this->bocommon->datetimeformat) . "'";
+ $kommma=",";
+ elseif
($values['sign'][$n]=='sign_budget_responsible' &&
$values['sign_orig'][$n]=='sign_janitor'):
+ $blank_date =
'oppsynsigndato= NULL';
+ $sign_field =
'budsjettansvarligid=';
+ $sign_id =
"'$user_lid'";
+ $sign_date_field =
'budsjettsigndato=';
+ $sign_date="'" .
date($this->bocommon->datetimeformat) . "'";
+ $kommma=",";
+ elseif
($values['sign'][$n]=='sign_budget_responsible' &&
$values['sign_orig'][$n]=='sign_supervisor'):
+ $blank_date =
'saksigndato= NULL';
+ $sign_field =
'budsjettansvarligid=';
+ $sign_id =
"'$user_lid'";
+ $sign_date_field =
'budsjettsigndato=';
+ $sign_date="'" .
date($this->bocommon->datetimeformat) . "'";
+ $kommma=",";
+ elseif
($values['sign'][$n]=='sign_budget_responsible' && !$values['sign_orig'][$n]):
+ $blank_date = '';
+ $sign_field =
'budsjettansvarligid=';
+ $sign_id =
"'$user_lid'";
+ $sign_date_field =
'budsjettsigndato=';
+ $sign_date="'" .
date($this->bocommon->datetimeformat) . "'";
+ $kommma=",";
+ endif;
+
+
+ if($blank_date )
+ {
+ $kommma_blank=",";
+ }
+ else
+ {
+ $kommma_blank='';
+ }
+
+
$transfer_sign_field='utbetalingid=';
+
$transfer_date_field='utbetalingsigndato=';
+
+ if
(!($values['num_days_orig'][$n]==$values['num_days'][$n]))
+ {
+ $payment_date =
date($this->bocommon->dateformat,$values['timestamp_voucher_date'][$n]+(24*3600*$values['num_days'][$n]));
+
$GLOBALS['phpgw']->db->query("UPDATE fm_ecobilag set forfallsdato=
'$payment_date' where bilagsnr='$voucher_id'");
+ }
+
+ $transfer_id="Null".",";
+ $transfer_date="Null";
+
+ if ($values['transfer'][$n])
+ {
+ if
($this->check_for_transfer($voucher_id))
+ {
+
$transfer_id="'$user_lid',";
+
$transfer_date="'" . date($this->bocommon->datetimeformat) . "'";
+ }
+ else
+ {
+
$receipt['error'][] = array('msg'=>'Dette bilaget er ikkje godkjent: ' . "
".$voucher_id);
+ $local_error=
true;
+ }
+
+ }
+
+ if ($values['kreditnota'][$n])
+ {
+ $wait_for_kreditnota=1;
+ $transfer_date="Null";
+ }
+ else
+ {
+
$wait_for_kreditnota='NULL';
+ }
+
+ if (! $local_error)
+ {
+ $sql= "UPDATE
fm_ecobilag set $blank_date $kommma_blank $sign_field $sign_id $kommma
$sign_date_field $sign_date $kommma $transfer_sign_field $transfer_id
$transfer_date_field $transfer_date ,kreditnota=$wait_for_kreditnota where
bilagsnr='$voucher_id'";
+
$GLOBALS['phpgw']->db->transaction_begin();
+
$GLOBALS['phpgw']->db->query($sql);
+
$GLOBALS['phpgw']->db->transaction_commit();
+
+ $receipt['message'][] =
array('msg'=> lang('voucher is updated: ') . $voucher_id);
+ }
+ }
+ }
+ }
+
+ $GLOBALS['phpgw']->db->query("UPDATE fm_ecobilag set
utbetalingid = NULL, utbetalingsigndato = NULL WHERE budsjettsigndato IS NULL");
+ $GLOBALS['phpgw']->db->query("UPDATE fm_ecobilag set
utbetalingid = NULL, utbetalingsigndato = NULL WHERE oppsynsigndato IS NULL AND
saksigndato IS NULL");
+
+ return $receipt;
+ }
+
+ function check_for_transfer($voucher_id='')
+ {
+ $allow_transfer=False;
+
+ $sql = "SELECT * FROM fm_ecobilag WHERE
bilagsnr='$voucher_id'";
+ $this->db->limit_query($sql,0,__LINE__,__FILE__,1);
+
+ $this->db->next_record();
+
+ if ($this->db->f('budsjettsigndato') &&
($this->db->f('oppsynsigndato') || $this->db->f('saksigndato')))
+ {
+ $allow_transfer=True;
+ }
+
+ return $allow_transfer;
+ }
+
+ function check_claim($voucher_id='')
+ {
+ $sql = "SELECT count(*) FROM fm_ecobilag
$this->left_join fm_workorder on fm_ecobilag.pmwrkord_code = fm_workorder.id "
+ . " WHERE bilagsnr='$voucher_id' AND
fm_workorder.charge_tenant=1 AND fm_workorder.claim_issued IS NULL";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ return $this->db->f(0);
+ }
+ }
+?>
Index: property/inc/class.solocation.inc.php
diff -u property/inc/class.solocation.inc.php:1.19
property/inc/class.solocation.inc.php:1.20
--- property/inc/class.solocation.inc.php:1.19 Thu Nov 3 14:53:43 2005
+++ property/inc/class.solocation.inc.php Fri Jan 27 14:05:43 2006
@@ -1,1255 +1,1255 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage location
- * @version $Id: class.solocation.inc.php,v 1.19 2005/11/03 14:53:43
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class solocation
- {
-
- function solocation()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
-
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
-
- $this->join = $this->socommon->join;
- $this->left_join = $this->socommon->left_join;
- $this->like = $this->socommon->like;
- }
-
- function read_entity_to_link()
- {
- $sql = "SELECT * FROM fm_entity_category where
loc_link=1";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $entity[] = array
- (
- 'entity_id' =>
$this->db->f('entity_id'),
- 'cat_id' => $this->db->f('id'),
- 'name' => $this->db->f('name'),
- 'descr' => $this->db->f('descr')
- );
- }
-
- return $entity;
- }
-
- function select_status_list($type_id)
- {
- if(!$type_id)
- {
- return;
- }
-
- $sql= "SELECT fm_location_choice.id,
fm_location_choice.value FROM fm_location_attrib $this->join fm_location_choice
ON "
- . " fm_location_attrib.type_id=
fm_location_choice.type_id AND "
- . " fm_location_attrib.id= fm_location_choice.attrib_id
"
- . " WHERE fm_location_attrib.column_name='status' "
- . " AND fm_location_choice.type_id=$type_id ORDER BY
fm_location_choice.id";
-
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- $i = 0;
- while ($this->db->next_record())
- {
- $status[$i]['id']
= $this->db->f('id');
- $status[$i]['name']
= stripslashes($this->db->f('value'));
- $i++;
- }
- return $status;
- }
-
-
- function get_owner_type_list()
- {
- $this->db->query("SELECT id,descr FROM
fm_owner_category ORDER BY descr ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $owner_type[$i]['id'] =
$this->db->f('id');
- $owner_type[$i]['name'] =
stripslashes($this->db->f('descr'));
- $i++;
- }
- return $owner_type;
- }
-
- function get_owner_list()
- {
- $this->db->query("SELECT fm_owner.*
,fm_owner_category.descr as category FROM fm_owner $this->join
fm_owner_category on fm_owner.category=fm_owner_category.id ORDER BY descr ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $owners[$i]['id'] =
$this->db->f('id');
- $owners[$i]['name'] =
stripslashes($this->db->f('org_name')) . ' ['. $this->db->f('category') . ']';
- $i++;
- }
- return $owners;
- }
-
- function check_location($location_code='',$type_id='')
- {
- $this->db->query("SELECT count(*) FROM
fm_location$type_id where location_code='$location_code'");
-
- $this->db->next_record();
-
- if ( $this->db->f(0))
- {
- return True;
- }
- }
-
-
- function select_category_list($type_id='')
- {
- if (!$type_id)
- {
- return;
- }
-
- $table= 'fm_location'. $type_id . '_category';
- $this->db->query("SELECT id, descr FROM $table where id
>'0' ORDER BY id asc ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $categories[$i]['id']
= $this->db->f('id');
- $categories[$i]['name']
= stripslashes($this->db->f('descr')) . ' [' . $this->db->f('id') . ']';
- $i++;
- }
- return $categories;
- }
-
-
- function read($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:0);
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $type_id =
(isset($data['type_id'])?$data['type_id']:'');
- $lookup_tenant =
(isset($data['lookup_tenant'])?$data['lookup_tenant']:'');
- $district_id =
(isset($data['district_id'])?$data['district_id']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $lookup =
(isset($data['lookup'])?$data['lookup']:'');
- $status =
(isset($data['status'])?$data['status']:'');
- $part_of_town_id =
(isset($data['part_of_town_id'])?$data['part_of_town_id']:'');
- }
-
- if (!$type_id)
- {
- return;
- }
-
- $sql = $this->socommon->fm_cache('sql_'. $type_id . '_'
. $lookup_tenant . '_' . $lookup);
-
- if(!$sql)
- {
- $location_types =
$this->soadmin_location->select_location_type();
-
- $cols = "fm_location" . ($type_id)
.".location_code";
- $cols_return[] = 'location_code';
- $uicols['input_type'][] = 'hidden';
- $uicols['name'][] =
'location_code';
- $uicols['descr'][] = 'dummy';
- $uicols['statustext'][] = 'dummy';
- $uicols['exchange'][] = false;
-
- for ($i=0; $i<($type_id); $i++)
- {
- $uicols['input_type'][] =
'text';
- $uicols['name'][] = 'loc'
. $location_types[$i]['id'];
- $uicols['descr'][] =
$location_types[$i]['name'];
- $uicols['statustext'][] =
$location_types[$i]['descr'];
- $uicols['exchange'][] = True;
- $cols .= ",fm_location" . ($type_id)
.".loc" . $location_types[$i]['id'];
- $cols_return[] = 'loc' .
$location_types[$i]['id'];
- }
-
-
- $street_level =
$this->soadmin_location->read_config_single('street_id');
- if ($street_level > $type_id)
- {
- $cols.= ',fm_location1.loc1_name as
loc1_name';
- $cols_return[]
= 'loc1_name';
- $uicols['input_type'][] =
'text';
- $uicols['name'][]
= 'loc1_name';
- $uicols['descr'][]
= lang('Property Name');
- $uicols['statustext'][] =
lang('Property Name');
- $uicols['exchange'][] = True;
-
- if($type_id>1)
- {
- $cols.= ',fm_location' .
$type_id . '.loc' . $type_id . '_name';
- $cols_return[]
= 'loc' . $type_id . '_name';
- $uicols['input_type'][]
= 'text';
- $uicols['name'][]
= 'loc' . $type_id . '_name';
- $uicols['descr'][]
= lang('Name');
- $uicols['statustext'][]
= lang('Name');
- $uicols['exchange'][]
= True;
- }
- }
-
-/* for ($i=2;$i<($type_id+1);$i++)
- {
- $cols.= ',fm_location' . $i . '.loc' .
$i . '_name';
- $cols_return[]
= 'loc' . $i . '_name';
- $uicols['input_type'][] =
'text';
- $uicols['name'][]
= 'loc' . $i . '_name';
- $uicols['descr'][]
= '';
- $uicols['statustext'][] = '';
- }
-
-*/
-
- for ($j=($type_id-1); $j>0; $j--)
- {
- $joinmethod .= " $this->join
fm_location". ($j);
-
- $paranthesis .='(';
-
- $on = 'ON';
- for ($i=($j); $i>0; $i--)
- {
- $joinmethod .= " $on
(fm_location" . ($j+1) .".loc" . ($i). " = fm_location" . ($j) . ".loc" . ($i)
. ")";
- $on = 'AND';
- if($i==1)
- {
- $joinmethod .= ")";
- }
- }
- }
-
- $config =
$this->soadmin_location->read_config('');
-
-//_debug_array($config);
-
- if($lookup_tenant)
- {
- $cols.= ',fm_tenant.id as tenant_id';
- $cols_return[]
= 'tenant_id';
- $uicols['input_type'][] =
'hidden';
- $uicols['name'][]
= 'tenant_id';
- $uicols['descr'][]
= 'dummy';
- $uicols['statustext'][] =
'dummy';
- $uicols['exchange'][] = True;
-
- $cols.= ',fm_tenant.last_name';
- $cols_return[]
= 'last_name';
- $uicols['input_type'][] =
'text';
- $uicols['name'][]
= 'last_name';
- $uicols['descr'][]
= lang('last name');
- $uicols['statustext'][] =
lang('last name');
- $uicols['exchange'][] = True;
-
- $cols.= ',fm_tenant.first_name';
- $cols_return[]
= 'first_name';
- $uicols['input_type'][] =
'text';
- $uicols['name'][]
= 'first_name';
- $uicols['descr'][]
= lang('first name');
- $uicols['statustext'][] =
lang('first name');
- $uicols['exchange'][] = True;
-
- $cols.= ',fm_tenant.contact_phone';
- $cols_return[]
= 'contact_phone';
- $uicols['input_type'][] =
'text';
- $uicols['name'][]
= 'contact_phone';
- $uicols['descr'][]
= lang('contact phone');
- $uicols['statustext'][] =
lang('contact phone');
- $uicols['exchange'][] = True;
-
- $sub_query_tenant=1;
-
$this->socommon->fm_cache('sub_query_tenant_'. $type_id . '_' . $lookup_tenant
. '_' . $lookup,$sub_query_tenant);
- }
-
- $config_count = count($config);
- for ($i=0;$i<$config_count;$i++)
- {
- if (($config[$i]['location_type'] <=
$type_id) && ($config[$i]['f_key'] ==1))
- {
- if(!$lookup_tenant &&
$config[$i]['column_name']=='tenant_id')
- {
- }
- else
- {
- $joinmethod .= "
$this->join " . $config[$i]['reference_table'] . " ON ( fm_location" .
$config[$i]['location_type'] . "." . $config[$i]['column_name'] . "=" .
$config[$i]['reference_table'] . ".".$config[$i]['reference_id']."))";
- $paranthesis .='(';
- }
- }
-
- if (($config[$i]['location_type'] <=
$type_id) && ($config[$i]['query_value'] ==1))
- {
-
-
if($config[$i]['column_name']=='street_id')
- {
-
- $sub_query_street=1;
-
$this->socommon->fm_cache('sub_query_street_'. $type_id . '_' . $lookup_tenant
. '_' . $lookup,$sub_query_street);
-
- $cols.=
',fm_streetaddress.descr as street_name';
- $cols_return[]
= 'street_name';
- $uicols['input_type'][]
= 'text';
- $uicols['name'][]
= 'street_name';
- $uicols['descr'][]
= lang('street name');
- $uicols['statustext'][]
= lang('street name');
- $uicols['exchange'][]
= True;
-
- $cols.=
',street_number';
- $cols_return[]
= 'street_number';
- $uicols['input_type'][]
= 'text';
- $uicols['name'][]
= 'street_number';
- $uicols['descr'][]
= lang('street number');
- $uicols['statustext'][]
= lang('street number');
- $uicols['exchange'][]
= True;
-
- $cols.= ',fm_location'
. $config[$i]['location_type'] . '.' . $config[$i]['column_name'];
- $cols_return[]
= $config[$i]['column_name'];
- $uicols['input_type'][]
= 'hidden';
- $uicols['name'][]
= $config[$i]['column_name'];
- $uicols['descr'][]
= lang($config[$i]['input_text']);
- $uicols['statustext'][]
= lang($config[$i]['input_text']);
- $uicols['exchange'][]
= True;
- }
- else
- {
- $cols.= ',fm_location'
. $config[$i]['location_type'] . '.' . $config[$i]['column_name'];
- $cols_return[]
= $config[$i]['column_name'];
- $uicols['input_type'][]
= 'hidden';
- $uicols['name'][]
= $config[$i]['column_name'];
- $uicols['descr'][]
= $config[$i]['input_text'];
- $uicols['statustext'][]
= $config[$i]['input_text'];
- $uicols['exchange'][]
= True;
- }
- }
- }
-
- $fm_location_cols =
$this->soadmin_location->read_attrib(array('type_id'=>$type_id,'lookup_type'=>$type_id));
-
-//_debug_array($fm_location_cols);
- $k = count($uicols['name']);
- $location_cols_count =
count($fm_location_cols);
-
- for ($i=0;$i<$location_cols_count;$i++)
- {
- if($fm_location_cols[$i]['list']==1)
- {
- $cols .= ",fm_location" .
$fm_location_cols[$i]['location_type']
.".".$fm_location_cols[$i]['column_name'];
- $cols_return[]
= $fm_location_cols[$i]['column_name'];
- $uicols['input_type'][]
= 'text';
- $uicols['name'][]
= $fm_location_cols[$i]['column_name'];
- $uicols['descr'][]
= $fm_location_cols[$i]['input_text'];
- $uicols['statustext'][]
= $fm_location_cols[$i]['statustext'];
-
-
$uicols['cols_return_extra'][$k]= array(
- 'id' => $k,
- 'name' =>
$fm_location_cols[$i]['column_name'],
- 'datatype' =>
$fm_location_cols[$i]['datatype'],
- 'attrib_id' =>
$fm_location_cols[$i]['id']
- );
- $k++;
-
-
if($fm_location_cols[$i]['lookup_form']==1)
- {
- $uicols['exchange'][]
= True;
- }
- else
- {
- $uicols['exchange'][]
= False;
- }
- }
- }
-
-
- $from .= " FROM $paranthesis
fm_location$type_id ";
-
- $sql = "SELECT $cols $from $joinmethod";
-
- $this->socommon->fm_cache('sql_'. $type_id .
'_' . $lookup_tenant . '_' . $lookup ,$sql);
- $this->socommon->fm_cache('uicols_'. $type_id
. '_' . $lookup_tenant . '_' . $lookup,$uicols);
- $this->socommon->fm_cache('cols_return_'.
$type_id . '_' . $lookup_tenant . '_' . $lookup,$cols_return);
-
- }
- else
- {
- $uicols = $this->socommon->fm_cache('uicols_'.
$type_id . '_' . $lookup_tenant . '_' . $lookup);
- $cols_return =
$this->socommon->fm_cache('cols_return_'. $type_id . '_' . $lookup_tenant .
'_' . $lookup);
-
- $sub_query_tenant =
$this->socommon->fm_cache('sub_query_tenant_'. $type_id . '_' . $lookup_tenant
. '_' . $lookup);
- $sub_query_street =
$this->socommon->fm_cache('sub_query_street_'. $type_id . '_' . $lookup_tenant
. '_' . $lookup);
- }
-
- $this->uicols = $uicols;
-
- $where= 'WHERE';
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by fm_location' .
($type_id) .'.location_code ASC';
- }
-
- if ($cat_id > 0)
- {
- $filtermethod .= " $where fm_location" .
($type_id). ".category=$cat_id ";
- $where= 'AND';
- }
- else
- {
- $filtermethod .= " $where (fm_location" .
($type_id). ".category !=99 OR fm_location" . ($type_id). ".category IS NULL)";
- $where= 'AND';
- }
-
- if ($filter > 0)
- {
- $filtermethod .= " $where
fm_owner.category='$filter' ";
- $where= 'AND';
- }
-
-
- if ($status > 0)
- {
- $filtermethod .= " $where fm_location" .
($type_id). ".status=$status ";
- $where= 'AND';
- }
- else
- {
-// $filtermethod .= " $where fm_location" .
($type_id). ".status IS NULL ";
-// $filtermethod .= " $where fm_location" .
($type_id). ".status !=2 ";
-// $where= 'AND';
- }
-
-
- if ($district_id > 0)
- {
- $filtermethod .= " $where
fm_part_of_town.district_id='$district_id' ";
- $where= 'AND';
- }
-
- if ($part_of_town_id > 0)
- {
- $filtermethod .= " $where
fm_part_of_town.part_of_town_id='$part_of_town_id' ";
- $where= 'AND';
- }
-
- if($query)
- {
- $query = str_replace(",",'.',$query);
- if(stristr($query, '.'))
- {
- $query=explode(".",$query);
- $querymethod = " $where (fm_location" .
($type_id).".loc1='" . $query[0] . "' AND fm_location" . $type_id .".loc" .
($type_id)."='" . $query[1] . "')";
- }
- else
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- if($sub_query_tenant)
- {
- $sub_query = "OR
fm_tenant.last_name $this->like '%$query%' OR fm_tenant.first_name $this->like
'%$query%' OR fm_tenant.contact_phone $this->like '%$query%'";
- }
-
- if($sub_query_street)
- {
- $sub_query .= "OR
fm_streetaddress.descr $this->like '%$query%'";
- }
-
- $querymethod = " $where (fm_location" .
($type_id).".loc1 $this->like '%$query%' $sub_query OR fm_location" .
($type_id).".location_code $this->like '%$query%' OR loc" . ($type_id)."_name
$this->like '%$query%')";
- }
- $where= 'AND';
- }
-
- $sql .= "$filtermethod $querymethod";
-
-//echo $sql;
- $this->db2->query($sql,__LINE__,__FILE__);
-
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- $j=0;
- $cols_return_count = count($cols_return);
- $location_count = $type_id-1;
-
- while ($this->db->next_record())
- {
- for ($i=0;$i<$cols_return_count;$i++)
- {
- $location_list[$j][$cols_return[$i]] =
stripslashes($this->db->f($cols_return[$i]));
-
- $value = $this->db->f($cols_return[$i]);
- if($uicols['cols_return_extra'][$i])
- {
-
if(($uicols['cols_return_extra'][$i]['datatype']=='R' ||
$uicols['cols_return_extra'][$i]['datatype']=='LB') && $value):
- {
- $sql="SELECT value FROM
fm_location_choice where type_id=$type_id AND attrib_id="
.$uicols['cols_return_extra'][$i]['attrib_id']. " AND id=" . $value;
- $this->db2->query($sql);
-
$this->db2->next_record();
-
$location_list[$j][$cols_return[$i]] = $this->db2->f('value');
- }
-
elseif($uicols['cols_return_extra'][$i]['datatype']=='AB' && $value):
- {
- $contact_data =
$contacts->read_single_entry($value,array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
-
$location_list[$j][$cols_return[$i]] = $contact_data[0]['n_family'] . ', ' .
$contact_data[0]['n_given'];
- }
-
elseif($uicols['cols_return_extra'][$i]['datatype']=='VENDOR' && $value):
- {
- $sql="SELECT org_name
FROM fm_vendor where id=$value";
- $this->db2->query($sql);
-
$this->db2->next_record();
-
$location_list[$j][$cols_return[$i]] = $this->db2->f('org_name');
- }
-
elseif($uicols['cols_return_extra'][$i]['datatype']=='CH' && $value):
- {
- $ch=
unserialize($value);
-
- if (isset($ch) AND
is_array($ch))
- {
- for
($k=0;$k<count($ch);$k++)
- {
-
$sql="SELECT value FROM fm_location_choice where type_id=$type_id AND
attrib_id=" .$uicols['cols_return_extra'][$i]['attrib_id']. " AND id=" .
$ch[$k];
-
$this->db2->query($sql);
- while
($this->db2->next_record())
- {
-
$ch_value[]=$this->db2->f('value');
- }
- }
-
$location_list[$j][$cols_return[$i]] = @implode(",", $ch_value);
-
unset($ch_value);
- }
- }
-
elseif($uicols['cols_return_extra'][$i]['datatype']=='D' && $value):
- {
-
$location_list[$j][$cols_return[$i]]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($value));
- }
- endif;
- }
- unset($value);
- }
-
- $location_code= $this->db->f('location_code');
- $location = split('-',$location_code);
- for ($m=0;$m<$location_count;$m++)
- {
- $location_list[$j]['loc' . ($m+1)] =
$location[$m];
-
$location_list[$j]['query_location']['loc' . ($m+1)]=implode("-",
array_slice($location, 0, ($m+1)));
- }
-
- $j++;
- }
-
- return $location_list;
- }
-
-
- function
generate_sql($type_id='',$cols='',$cols_return='',$uicols='',$read_single='')
- {
-
- $joinmethod .= " fm_location" . ($type_id);
-
- $location_types =
$this->soadmin_location->select_location_type();
-
- $cols .= "fm_location" . ($type_id) .".location_code";
- $cols_return[] = 'location_code';
- for ($i=0; $i<($type_id); $i++)
- {
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'loc'
. $location_types[$i]['id'];
- $uicols['descr'][] =
$location_types[$i]['name'];
- $uicols['statustext'][] =
$location_types[$i]['descr'];
- $cols .= ",fm_location" . ($type_id) .".loc" .
$location_types[$i]['id'];
- $cols_return[] = 'loc' .
$location_types[$i]['id'];
- }
-
-
- if($type!=1)
- {
-// $cols.= ',fm_location1.loc1_name as loc1_name';
-// $cols_return[] =
'loc1_name';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'loc1_name';
- $uicols['descr'][] =
lang('Property Name');
- $uicols['statustext'][] =
lang('Property Name');
- }
-
- for ($j=($type_id-1); $j>0; $j--)
- {
- $joinmethod .= " $this->join fm_location". ($j);
-
- $paranthesis .='(';
-
-
- $on = 'ON';
- for ($i=($j); $i>0; $i--)
- {
- $joinmethod .= " $on (fm_location" .
($j+1) .".loc" . ($i). " = fm_location" . ($j) . ".loc" . ($i) . ")";
- $on = 'AND';
- if($i==1)
- {
- $joinmethod .= ")";
- }
- }
- }
-
- $config = $this->soadmin_location->read_config('');
-
- $config_count = count($config);
- for ($i=0;$i<$config_count;$i++)
- {
- if (($config[$i]['location_type'] <= $type_id)
&& ($config[$i]['f_key'] ==1))
- {
-
-
if($config[$i]['column_name']=='tenant_id')
- {
- $join=$this->left_join;
- }
- else
- {
- $join =$this->join;
- }
-
- $joinmethod .= " $join " .
$config[$i]['reference_table'] . " ON ( fm_location" .
$config[$i]['location_type'] . "." . $config[$i]['column_name'] . "=" .
$config[$i]['reference_table'] . ".".$config[$i]['reference_id']."))";
-
- $paranthesis .='(';
- }
-
- if ($config[$i]['location_type'] <= $type_id)
- {
-
-
if($config[$i]['column_name']=='street_id'):
- {
- $cols.=
',fm_streetaddress.descr as street_name';
- $cols_return[]
= 'street_name';
- $uicols['input_type'][]
= 'text';
- $uicols['name'][]
= 'street_name';
- $uicols['descr'][]
= lang('street name');
- $uicols['statustext'][]
= lang('street name');
-
- $cols.= ',street_number';
- $cols_return[]
= 'street_number';
- $uicols['input_type'][]
= 'text';
- $uicols['name'][]
= 'street_number';
- $uicols['descr'][]
= lang('street number');
- $uicols['statustext'][]
= lang('street number');
-
- $cols.= ',fm_location' .
$config[$i]['location_type'] . '.' . $config[$i]['column_name'];
- $cols_return[]
= $config[$i]['column_name'];
- $uicols['input_type'][]
= 'hidden';
- $uicols['name'][]
= $config[$i]['column_name'];
- $uicols['descr'][]
= lang($config[$i]['input_text']);
- $uicols['statustext'][]
= lang($config[$i]['input_text']);
-
- }
-
elseif($config[$i]['column_name']=='tenant_id'):
- {
- $cols.= ',fm_tenant.id as
tenant_id';
- $cols_return[]
= 'tenant_id';
- $uicols['input_type'][]
= 'hidden';
- $uicols['name'][]
= 'tenant_id';
- $uicols['descr'][]
= 'dummy';
- $uicols['statustext'][]
= 'dummy';
-
- $cols.= ',fm_tenant.last_name
as last_name';
- $cols_return[]
= 'last_name';
- $uicols['input_type'][]
= 'text';
- $uicols['name'][]
= 'last_name';
- $uicols['descr'][]
= lang('last name');
- $uicols['statustext'][]
= lang('last name');
-
- $cols.= ',fm_tenant.first_name
as first_name';
- $cols_return[]
= 'first_name';
- $uicols['input_type'][]
= 'text';
- $uicols['name'][]
= 'first_name';
- $uicols['descr'][]
= lang('first name');
- $uicols['statustext'][]
= lang('first name');
-
- $cols.= ',contact_phone';
- $cols_return[]
= 'contact_phone';
- $uicols['input_type'][]
= 'text';
- $uicols['name'][]
= 'contact_phone';
- $uicols['descr'][]
= lang('contact phone');
- $uicols['statustext'][]
= lang('contact phone');
-
- }
- else:
- {
- $cols.= ',fm_location' .
$config[$i]['location_type'] . '.' . $config[$i]['column_name'];
- $cols_return[]
= $config[$i]['column_name'];
- $uicols['input_type'][]
= 'text';
- $uicols['name'][]
= $config[$i]['column_name'];
- $uicols['descr'][]
= $config[$i]['input_text'];
- $uicols['statustext'][]
= $config[$i]['input_text'];
- }
- endif;
- }
- }
-
- $fm_location_cols =
$this->soadmin_location->read_attrib(array('type_id'=>$type_id,'lookup_type'=>$type_id,'allrows'=>True));
-//_debug_array($fm_location_cols);
-
- $location_cols_count = count($fm_location_cols);
-
- for ($i=0;$i<$location_cols_count;$i++)
- {
-
- if($read_single)
- {
- $cols .= ",fm_location" .
$fm_location_cols[$i]['location_type']
.".".$fm_location_cols[$i]['column_name'];
- $cols_return[]
= $fm_location_cols[$i]['column_name'];
- $uicols['input_type'][] =
'text';
- $uicols['name'][]
= $fm_location_cols[$i]['column_name'];
- $uicols['descr'][]
= $fm_location_cols[$i]['input_text'];
- $uicols['statustext'][] =
$fm_location_cols[$i]['statustext'];
-
- }
- else
- {
- if($fm_location_cols[$i]['list']==1)
- {
- $cols .= ",fm_location" .
($type_id) .".".$fm_location_cols[$i]['column_name'];
- $cols_return[]
= $fm_location_cols[$i]['column_name'];
- $uicols['input_type'][]
= 'text';
- $uicols['name'][]
= $fm_location_cols[$i]['column_name'];
- $uicols['descr'][]
= $fm_location_cols[$i]['input_text'];
- $uicols['statustext'][]
= $fm_location_cols[$i]['statustext'];
- }
- }
- }
-
-
- $cols.= ',district_id';
- $cols_return[] = 'district_id';
-
- $this->uicols = $uicols;
- $this->cols_return = $cols_return;
-
- $from .= " FROM $paranthesis $entity_table ";
-
- $sql = "SELECT $cols $from $joinmethod";
-
- $this->socommon->fm_cache('sql_single_'. $type_id,$sql);
- $this->socommon->fm_cache('uicols_single_'.
$type_id,$uicols);
- $this->socommon->fm_cache('cols_return_single_'.
$type_id,$cols_return);
-
-
-// $GLOBALS['phpgw']->session->appsession('sql_single_'.
$type_id ,$this->currentapp,$sql);
-//
$GLOBALS['phpgw']->session->appsession('uicols_single_'. $type_id
,$this->currentapp,$uicols);
-//
$GLOBALS['phpgw']->session->appsession('cols_return_single_'. $type_id
,$this->currentapp,$cols_return);
-
- return $sql;
- }
-
- function read_single($location_code='')
- {
- $location_array = split('-',$location_code);
- $type_id= count($location_array);
-
- if (!$type_id)
- {
- return;
- }
-
- $cols.= 'fm_location' . $type_id .'.category as
cat_id,';
- $cols_return[] = 'cat_id';
-
- for ($i=1;$i<($type_id+1);$i++)
- {
- $cols.= 'fm_location' . $i .'.loc' . $i
.'_name,';
- $cols_return[] = 'loc'
. $i .'_name';
- }
-
-
- $cols.= 'fm_location' . $type_id . '.change_type,';
- $cols_return[] = 'change_type';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'loc' .
$type_id .'_name';
- $uicols['descr'][] = lang('name');
- $uicols['statustext'][] = lang('name');
-
- $cols.= 'fm_location' . $type_id .'.remark as remark,';
- $cols_return[] = 'remark';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'descr';
- $uicols['descr'][] =
lang('remark');
- $uicols['statustext'][] = lang('remark');
-
- $sql = $this->socommon->fm_cache('sql_single_'.
$type_id);
-
- if(!$sql)
- {
- $sql =
$this->generate_sql($type_id,$cols,$cols_return,$uicols,True);
- }
- else
- {
-
- $this->uicols =
$this->socommon->fm_cache('uicols_single_'. $type_id);
- $this->cols_return =
$this->socommon->fm_cache('cols_return_single_'. $type_id);
- }
-
- $sql .= " WHERE
fm_location$type_id.location_code='$location_code' ";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
-//echo $sql;
- $cols_return = $this->cols_return;
-
- $cols_return_count = count($cols_return);
-
- $this->db->next_record();
- for ($i=0;$i<$cols_return_count;$i++)
- {
- $location[$cols_return[$i]] =
stripslashes($this->db->f($cols_return[$i]));
- }
-
-//_debug_array($cols_return);
-//_debug_array($location);
- return $location;
- }
-
- function add($location='',$values_attribute='',$type_id='')
- {
- $location['remark'] =
$this->db->db_addslashes($location['remark']);
-
- while (is_array($location) && list($input_name,$value)
= each($location))
- {
- if($value)
- {
- if($input_name=='cat_id')
- {
- $input_name='category';
- }
- $cols[] = $input_name;
- $vals[] = $value;
- }
- }
-
- if (isset($values_attribute) AND
is_array($values_attribute))
- {
- foreach($values_attribute as $entry)
- {
- if($entry['value'])
- {
- $cols[] = $entry['name'];
- $vals[] = $entry['value'];
- }
- }
- }
-
- $cols =implode(",", $cols) . ",entry_date,user_id";
- $vals ="'" . implode("','", $vals) . "'," . "'" .
time() . "','" . $this->account . "'";
-
-
- $sql = "INSERT INTO fm_location$type_id ($cols)
VALUES ($vals)";
-
-//echo $sql;
- $this->db->query($sql,__LINE__,__FILE__);
-
- $receipt['message'][] = array('msg'=>lang('Location %1
has been saved',$location['location_code']));
- return $receipt;
- }
-
- function edit($location='',$values_attribute='',$type_id='')
- {
-//_debug_array($values_attribute);
- $location['remark'] =
$this->db->db_addslashes($location['remark']);
-
- while (is_array($location) && list($input_name,$value)
= each($location))
- {
- if($value)
- {
- if($input_name=='cat_id')
- {
- $input_name='category';
- }
- $value_set[$input_name] = $value;
- }
- }
-
- if (isset($values_attribute) AND
is_array($values_attribute))
- {
- foreach($values_attribute as $entry)
- {
- $value_set[$entry['name']] =
$entry['value'];
- }
- }
-
- $value_set['entry_date'] = time();
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $sql = "SELECT * from fm_location$type_id where
location_code ='" . $location['location_code'] . "'";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
-
- $metadata = $this->db->metadata('fm_location'.$type_id);
-
- for ($i=0; $i<count($metadata); $i++)
- {
- $cols[] = $metadata[$i]['name'];
- $vals[] = $this->db->f($metadata[$i]['name']);
- }
-
- $cols[] = 'exp_date';
- $vals[] = date($this->bocommon->datetimeformat,time());
-
- $cols =implode(",", $cols);
- $vals = $this->bocommon->validate_db_insert($vals);
-
- $sql = "INSERT INTO fm_location" . $type_id ."_history
($cols) VALUES ($vals)";
- $this->db->query($sql,__LINE__,__FILE__);
-
- $sql = "UPDATE fm_location$type_id SET $value_set WHERE
location_code='" . $location['location_code'] . "'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- $receipt['message'][] = array('msg'=>lang('Location %1
has been edited',$location['location_code']));
- return $receipt;
- }
-
- function delete($location_code )
- {
- $location_array = split('-',$location_code);
- $type_id= count($location_array);
-
- $this->db->query("DELETE FROM fm_location$type_id WHERE
location_code='" . $location_code ."'",__LINE__,__FILE__);
-// $this->db->query("DELETE FROM fm_location WHERE
location_code='" . $location_code ."'",__LINE__,__FILE__);
- }
-
- function update_cat()
- {
- $location_types =
$this->soadmin_location->select_location_type();
-
- $m= count($location_types);
-
- $this->db->transaction_begin();
-
- $this->db->query("UPDATE fm_location" . $m. " set
status= 2 WHERE category=99",__LINE__,__FILE__);
-
- for ($type_id=$m; $type_id>1; $type_id--)
- {
- $parent_table = 'fm_location' . ($type_id-1);
-
- $joinmethod .= " $this->join $parent_table";
-
- $paranthesis .='(';
-
- $on = 'ON';
- for ($i=($type_id-1); $i>0; $i--)
- {
- $joinmethod .= " $on (fm_location" .
($type_id) .".loc" . ($i). ' = '.$parent_table . ".loc" . ($i) . ")";
- $on = 'AND';
- if($i==1)
- {
- $joinmethod .= ")";
- }
- }
-
- $sql = "SELECT $parent_table.location_code
,count(*) as count_99 FROM $paranthesis fm_location$type_id $joinmethod where
fm_location$type_id.status=2 group by $parent_table.location_code ";
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
-
$outdated[$this->db->f('location_code')]['count_99']=$this->db->f('count_99');
- }
-
- $sql = "SELECT $parent_table.location_code
,count(*) as count_all FROM $paranthesis fm_location$type_id $joinmethod group
by $parent_table.location_code ";
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
- {
- if(
$outdated[$this->db->f('location_code')]['count_99']==$this->db->f('count_all'))
- {
- $update[]=array('location_code'
=> $this->db->f('location_code'));
- }
- }
-
- $j=0;
- for ($i=0; $i<count($update); $i++)
- {
-
- $sql = "SELECT status FROM
$parent_table WHERE location_code= '" . $update[$i]['location_code'] ."'";
-
-
$this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
-
- if($this->db->f('status')!=2)
- {
- $j++;
- $this->db->query("UPDATE
fm_location" . ($type_id-1). " set status= 2 WHERE location_code= '" .
$update[$i]['location_code'] ."'",__LINE__,__FILE__);
- }
- }
-
- $receipt['message'][]=array('msg'=>lang('%1
location %2 has been updated to not active of %3 already not
active',$j,$location_types[($type_id-2)]['descr'],count($update)));
-
- unset($outdated);
- unset($update);
- unset($joinmethod);
- unset($paranthesis);
- }
-
- $this->db->transaction_commit();
-
- return $receipt;
- }
-
- function read_summary($data='')
- {
- if(is_array($data))
- {
- $filter =
(isset($data['filter'])?$data['filter']:0);
- $type_id =
(isset($data['type_id'])?$data['type_id']:'');
- $district_id =
(isset($data['district_id'])?$data['district_id']:'');
- $part_of_town_id =
(isset($data['part_of_town_id'])?$data['part_of_town_id']:'');
- }
-
- if(!$type_id)
- {
- $type_id=4;
- }
-
- $entity_table = 'fm_location' . $type_id ;
-
- $cols= "count(*) as number, $entity_table.category,
$entity_table"."_category.descr as type";
-
- $groupmethod = " GROUP by $entity_table.category ,
$entity_table"."_category.descr";
-
- $uicols['name'][] = 'type';
- $uicols['descr'][] = lang('type');
-
-
- $where = 'WHERE';
- if($district_id>0)
- {
- $uicols['name'][] = 'district_id';
- $uicols['descr'][] = lang('district_id');
- $cols.=", fm_part_of_town.district_id as
district_id";
- $groupmethod .= " ,fm_part_of_town.district_id";
- $filtermethod = " $where
fm_part_of_town.district_id=$district_id";
- $where = 'AND';
- }
-
- if($part_of_town_id>0)
- {
- $uicols['name'][] = 'part_of_town';
- $uicols['descr'][] = lang('part of town');
- $groupmethod .= " ,fm_part_of_town.name";
- $cols.=", fm_part_of_town.name as part_of_town";
- $filtermethod .= " $where
fm_part_of_town.part_of_town_id=$part_of_town_id";
- $where = 'AND';
- }
-
- if($filter>0)
- {
- $filtermethod .= " $where fm_owner.id=$filter";
- $where = 'AND';
- }
-
-
- $uicols['name'][] = 'number';
- $uicols['descr'][] = lang('number');
-
- $joinmethod= "$this->join $entity_table"."_category on
$entity_table.category=$entity_table"."_category.id";
-
- $sql =
$this->bocommon->generate_sql(array('entity_table'=>$entity_table,'cols_return'=>$cols_return,'cols'=>$cols,
-
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query,'no_address'=>True,'location_level'=>$type_id));
-
- $this->db->query($sql . $filtermethod . $groupmethod .
" ORDER BY $entity_table.category",__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $summary[]=array(
- 'number' =>
$this->db->f('number'),
- 'type' => '[' .
$this->db->f('category') . '] ' .$this->db->f('type'),
- 'part_of_town' =>
$this->db->f('part_of_town'),
- 'district_id' =>
$this->db->f('district_id')
- );
- }
-
-
- $this->uicols = $uicols;
- return $summary;
- }
-
- function check_history($location_code='')
- {
- $location_array = split('-',$location_code);
- $type_id= count($location_array);
-
- if (!$type_id)
- {
- return false;
- }
-
- $table = 'fm_location' . $type_id . '_history';
-
- $sql = "SELECT count(*) FROM $table WHERE
location_code='$location_code'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- $this->db->next_record();
-
- if($this->db->f('0')>0)
- {
- return True;
- }
- else
- {
- return;
- }
- }
-
- function get_history($location_code='')
- {
- $this->uicols = array();
- $location_array = split('-',$location_code);
- $type_id= count($location_array);
-
- if (!$type_id)
- {
- return;
- }
-
- $table = 'fm_location' . $type_id . '_history';
-
- $table_category = 'fm_location' . $type_id .
'_category';
-
- $sql = "SELECT column_name,datatype,input_text,id as
attrib_id FROM fm_location_attrib WHERE type_id = $type_id";
-
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
- {
- $attrib[] = array(
- 'column_name' =>
$this->db->f('column_name'),
- 'input_text' =>
$this->db->f('input_text'),
- 'datatype' => $this->db->f('datatype'),
- 'attrib_id' => $this->db->f('attrib_id')
- );
-
- $this->uicols['input_type'][] = 'text';
- $this->uicols['name'][] =
$this->db->f('column_name');
- $this->uicols['descr'][] =
$this->db->f('input_text');
- }
-
- $this->uicols['input_type'][] = 'text';
- $this->uicols['name'][] = 'exp_date';
- $this->uicols['descr'][] = lang('exp date');
-
-
- $attrib[] = array(
- 'column_name' => 'exp_date',
- 'input_text' => 'exp date',
- 'datatype' => 'D'
- );
-
- $sql = "SELECT $table.*, $table_category.descr as
category FROM $table $this->left_join $table_category ON $table.category
=$table_category.id WHERE location_code='$location_code' ORDER BY exp_date
DESC";
- $this->db->query($sql,__LINE__,__FILE__);
-
- $j=0;
- while ($this->db->next_record())
- {
- for ($i=0; $i<count($attrib); $i++)
- {
-
$location[$j][$attrib[$i]['column_name']]=$this->db->f($attrib[$i]['column_name']);
-
- $value =
$this->db->f($attrib[$i]['column_name']);
- if(($attrib[$i]['datatype']=='R' ||
$attrib[$i]['datatype']=='LB') && $value):
- {
- $sql="SELECT value FROM
fm_location_choice where type_id=$type_id AND attrib_id="
.$attrib[$i]['attrib_id']. " AND id=" . $value;
- $this->db2->query($sql);
- $this->db2->next_record();
-
$location[$j][$attrib[$i]['column_name']] = $this->db2->f('value');
- }
- elseif($attrib[$i]['datatype']=='AB' &&
$value):
- {
- $contact_data =
$contacts->read_single_entry($value,array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
-
$location[$j][$attrib[$i]['column_name']] = $contact_data[0]['n_family']
. ', ' . $contact_data[0]['n_given'];
- }
-
elseif($attrib[$i]['datatype']=='VENDOR' && $value):
- {
- $sql="SELECT org_name FROM
fm_vendor where id=$value";
- $this->db2->query($sql);
- $this->db2->next_record();
-
$location[$j][$attrib[$i]['column_name']] = $this->db2->f('org_name');
- }
- elseif($attrib[$i]['datatype']=='CH' &&
$value):
- {
- $ch= unserialize($value);
- if (isset($ch) AND
is_array($ch))
- {
- for
($k=0;$k<count($ch);$k++)
- {
- $sql="SELECT
value FROM fm_location_choice where type_id=$type_id AND attrib_id="
.$attrib[$i]['attrib_id']. " AND id=" . $ch[$k];
-
$this->db2->query($sql);
- while
($this->db2->next_record())
- {
-
$ch_value[]=$this->db2->f('value');
- }
- }
-
$location[$j][$attrib[$i]['column_name']] = @implode(",", $ch_value);
- unset($ch_value);
- }
- }
- elseif($attrib[$i]['datatype']=='D' &&
$value):
- {
-
$location[$j][$attrib[$i]['column_name']]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($value));
- }
-
elseif($attrib[$i]['column_name']=='entry_date' && $value):
- {
-
$location[$j][$attrib[$i]['column_name']]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],$value);
- }
- endif;
-
- unset($value);
-
- }
- $j++;
- }
-
- return $location;
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage location
+ * @version $Id: class.solocation.inc.php,v 1.20 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class solocation
+ {
+
+ function solocation()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->socommon =
CreateObject($this->currentapp.'.socommon');
+
+ $this->join = $this->bocommon->join;
+ $this->left_join = $this->bocommon->left_join;
+ $this->like = $this->bocommon->like;
+ }
+
+ function read_entity_to_link()
+ {
+ $sql = "SELECT * FROM fm_entity_category where
loc_link=1";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $entity[] = array
+ (
+ 'entity_id' =>
$this->db->f('entity_id'),
+ 'cat_id' => $this->db->f('id'),
+ 'name' => $this->db->f('name'),
+ 'descr' => $this->db->f('descr')
+ );
+ }
+
+ return $entity;
+ }
+
+ function select_status_list($type_id)
+ {
+ if(!$type_id)
+ {
+ return;
+ }
+
+ $sql= "SELECT fm_location_choice.id,
fm_location_choice.value FROM fm_location_attrib $this->join fm_location_choice
ON "
+ . " fm_location_attrib.type_id=
fm_location_choice.type_id AND "
+ . " fm_location_attrib.id= fm_location_choice.attrib_id
"
+ . " WHERE fm_location_attrib.column_name='status' "
+ . " AND fm_location_choice.type_id=$type_id ORDER BY
fm_location_choice.id";
+
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $status[$i]['id']
= $this->db->f('id');
+ $status[$i]['name']
= stripslashes($this->db->f('value'));
+ $i++;
+ }
+ return $status;
+ }
+
+
+ function get_owner_type_list()
+ {
+ $this->db->query("SELECT id,descr FROM
fm_owner_category ORDER BY descr ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $owner_type[$i]['id'] =
$this->db->f('id');
+ $owner_type[$i]['name'] =
stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $owner_type;
+ }
+
+ function get_owner_list()
+ {
+ $this->db->query("SELECT fm_owner.*
,fm_owner_category.descr as category FROM fm_owner $this->join
fm_owner_category on fm_owner.category=fm_owner_category.id ORDER BY descr ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $owners[$i]['id'] =
$this->db->f('id');
+ $owners[$i]['name'] =
stripslashes($this->db->f('org_name')) . ' ['. $this->db->f('category') . ']';
+ $i++;
+ }
+ return $owners;
+ }
+
+ function check_location($location_code='',$type_id='')
+ {
+ $this->db->query("SELECT count(*) FROM
fm_location$type_id where location_code='$location_code'");
+
+ $this->db->next_record();
+
+ if ( $this->db->f(0))
+ {
+ return True;
+ }
+ }
+
+
+ function select_category_list($type_id='')
+ {
+ if (!$type_id)
+ {
+ return;
+ }
+
+ $table= 'fm_location'. $type_id . '_category';
+ $this->db->query("SELECT id, descr FROM $table where id
>'0' ORDER BY id asc ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $categories[$i]['id']
= $this->db->f('id');
+ $categories[$i]['name']
= stripslashes($this->db->f('descr')) . ' [' . $this->db->f('id') . ']';
+ $i++;
+ }
+ return $categories;
+ }
+
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:0);
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $type_id =
(isset($data['type_id'])?$data['type_id']:'');
+ $lookup_tenant =
(isset($data['lookup_tenant'])?$data['lookup_tenant']:'');
+ $district_id =
(isset($data['district_id'])?$data['district_id']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $lookup =
(isset($data['lookup'])?$data['lookup']:'');
+ $status =
(isset($data['status'])?$data['status']:'');
+ $part_of_town_id =
(isset($data['part_of_town_id'])?$data['part_of_town_id']:'');
+ }
+
+ if (!$type_id)
+ {
+ return;
+ }
+
+ $sql = $this->socommon->fm_cache('sql_'. $type_id . '_'
. $lookup_tenant . '_' . $lookup);
+
+ if(!$sql)
+ {
+ $location_types =
$this->soadmin_location->select_location_type();
+
+ $cols = "fm_location" . ($type_id)
.".location_code";
+ $cols_return[] = 'location_code';
+ $uicols['input_type'][] = 'hidden';
+ $uicols['name'][] =
'location_code';
+ $uicols['descr'][] = 'dummy';
+ $uicols['statustext'][] = 'dummy';
+ $uicols['exchange'][] = false;
+
+ for ($i=0; $i<($type_id); $i++)
+ {
+ $uicols['input_type'][] =
'text';
+ $uicols['name'][] = 'loc'
. $location_types[$i]['id'];
+ $uicols['descr'][] =
$location_types[$i]['name'];
+ $uicols['statustext'][] =
$location_types[$i]['descr'];
+ $uicols['exchange'][] = True;
+ $cols .= ",fm_location" . ($type_id)
.".loc" . $location_types[$i]['id'];
+ $cols_return[] = 'loc' .
$location_types[$i]['id'];
+ }
+
+
+ $street_level =
$this->soadmin_location->read_config_single('street_id');
+ if ($street_level > $type_id)
+ {
+ $cols.= ',fm_location1.loc1_name as
loc1_name';
+ $cols_return[]
= 'loc1_name';
+ $uicols['input_type'][] =
'text';
+ $uicols['name'][]
= 'loc1_name';
+ $uicols['descr'][]
= lang('Property Name');
+ $uicols['statustext'][] =
lang('Property Name');
+ $uicols['exchange'][] = True;
+
+ if($type_id>1)
+ {
+ $cols.= ',fm_location' .
$type_id . '.loc' . $type_id . '_name';
+ $cols_return[]
= 'loc' . $type_id . '_name';
+ $uicols['input_type'][]
= 'text';
+ $uicols['name'][]
= 'loc' . $type_id . '_name';
+ $uicols['descr'][]
= lang('Name');
+ $uicols['statustext'][]
= lang('Name');
+ $uicols['exchange'][]
= True;
+ }
+ }
+
+/* for ($i=2;$i<($type_id+1);$i++)
+ {
+ $cols.= ',fm_location' . $i . '.loc' .
$i . '_name';
+ $cols_return[]
= 'loc' . $i . '_name';
+ $uicols['input_type'][] =
'text';
+ $uicols['name'][]
= 'loc' . $i . '_name';
+ $uicols['descr'][]
= '';
+ $uicols['statustext'][] = '';
+ }
+
+*/
+
+ for ($j=($type_id-1); $j>0; $j--)
+ {
+ $joinmethod .= " $this->join
fm_location". ($j);
+
+ $paranthesis .='(';
+
+ $on = 'ON';
+ for ($i=($j); $i>0; $i--)
+ {
+ $joinmethod .= " $on
(fm_location" . ($j+1) .".loc" . ($i). " = fm_location" . ($j) . ".loc" . ($i)
. ")";
+ $on = 'AND';
+ if($i==1)
+ {
+ $joinmethod .= ")";
+ }
+ }
+ }
+
+ $config =
$this->soadmin_location->read_config('');
+
+//_debug_array($config);
+
+ if($lookup_tenant)
+ {
+ $cols.= ',fm_tenant.id as tenant_id';
+ $cols_return[]
= 'tenant_id';
+ $uicols['input_type'][] =
'hidden';
+ $uicols['name'][]
= 'tenant_id';
+ $uicols['descr'][]
= 'dummy';
+ $uicols['statustext'][] =
'dummy';
+ $uicols['exchange'][] = True;
+
+ $cols.= ',fm_tenant.last_name';
+ $cols_return[]
= 'last_name';
+ $uicols['input_type'][] =
'text';
+ $uicols['name'][]
= 'last_name';
+ $uicols['descr'][]
= lang('last name');
+ $uicols['statustext'][] =
lang('last name');
+ $uicols['exchange'][] = True;
+
+ $cols.= ',fm_tenant.first_name';
+ $cols_return[]
= 'first_name';
+ $uicols['input_type'][] =
'text';
+ $uicols['name'][]
= 'first_name';
+ $uicols['descr'][]
= lang('first name');
+ $uicols['statustext'][] =
lang('first name');
+ $uicols['exchange'][] = True;
+
+ $cols.= ',fm_tenant.contact_phone';
+ $cols_return[]
= 'contact_phone';
+ $uicols['input_type'][] =
'text';
+ $uicols['name'][]
= 'contact_phone';
+ $uicols['descr'][]
= lang('contact phone');
+ $uicols['statustext'][] =
lang('contact phone');
+ $uicols['exchange'][] = True;
+
+ $sub_query_tenant=1;
+
$this->socommon->fm_cache('sub_query_tenant_'. $type_id . '_' . $lookup_tenant
. '_' . $lookup,$sub_query_tenant);
+ }
+
+ $config_count = count($config);
+ for ($i=0;$i<$config_count;$i++)
+ {
+ if (($config[$i]['location_type'] <=
$type_id) && ($config[$i]['f_key'] ==1))
+ {
+ if(!$lookup_tenant &&
$config[$i]['column_name']=='tenant_id')
+ {
+ }
+ else
+ {
+ $joinmethod .= "
$this->join " . $config[$i]['reference_table'] . " ON ( fm_location" .
$config[$i]['location_type'] . "." . $config[$i]['column_name'] . "=" .
$config[$i]['reference_table'] . ".".$config[$i]['reference_id']."))";
+ $paranthesis .='(';
+ }
+ }
+
+ if (($config[$i]['location_type'] <=
$type_id) && ($config[$i]['query_value'] ==1))
+ {
+
+
if($config[$i]['column_name']=='street_id')
+ {
+
+ $sub_query_street=1;
+
$this->socommon->fm_cache('sub_query_street_'. $type_id . '_' . $lookup_tenant
. '_' . $lookup,$sub_query_street);
+
+ $cols.=
',fm_streetaddress.descr as street_name';
+ $cols_return[]
= 'street_name';
+ $uicols['input_type'][]
= 'text';
+ $uicols['name'][]
= 'street_name';
+ $uicols['descr'][]
= lang('street name');
+ $uicols['statustext'][]
= lang('street name');
+ $uicols['exchange'][]
= True;
+
+ $cols.=
',street_number';
+ $cols_return[]
= 'street_number';
+ $uicols['input_type'][]
= 'text';
+ $uicols['name'][]
= 'street_number';
+ $uicols['descr'][]
= lang('street number');
+ $uicols['statustext'][]
= lang('street number');
+ $uicols['exchange'][]
= True;
+
+ $cols.= ',fm_location'
. $config[$i]['location_type'] . '.' . $config[$i]['column_name'];
+ $cols_return[]
= $config[$i]['column_name'];
+ $uicols['input_type'][]
= 'hidden';
+ $uicols['name'][]
= $config[$i]['column_name'];
+ $uicols['descr'][]
= lang($config[$i]['input_text']);
+ $uicols['statustext'][]
= lang($config[$i]['input_text']);
+ $uicols['exchange'][]
= True;
+ }
+ else
+ {
+ $cols.= ',fm_location'
. $config[$i]['location_type'] . '.' . $config[$i]['column_name'];
+ $cols_return[]
= $config[$i]['column_name'];
+ $uicols['input_type'][]
= 'hidden';
+ $uicols['name'][]
= $config[$i]['column_name'];
+ $uicols['descr'][]
= $config[$i]['input_text'];
+ $uicols['statustext'][]
= $config[$i]['input_text'];
+ $uicols['exchange'][]
= True;
+ }
+ }
+ }
+
+ $fm_location_cols =
$this->soadmin_location->read_attrib(array('type_id'=>$type_id,'lookup_type'=>$type_id));
+
+//_debug_array($fm_location_cols);
+ $k = count($uicols['name']);
+ $location_cols_count =
count($fm_location_cols);
+
+ for ($i=0;$i<$location_cols_count;$i++)
+ {
+ if($fm_location_cols[$i]['list']==1)
+ {
+ $cols .= ",fm_location" .
$fm_location_cols[$i]['location_type']
.".".$fm_location_cols[$i]['column_name'];
+ $cols_return[]
= $fm_location_cols[$i]['column_name'];
+ $uicols['input_type'][]
= 'text';
+ $uicols['name'][]
= $fm_location_cols[$i]['column_name'];
+ $uicols['descr'][]
= $fm_location_cols[$i]['input_text'];
+ $uicols['statustext'][]
= $fm_location_cols[$i]['statustext'];
+
+
$uicols['cols_return_extra'][$k]= array(
+ 'id' => $k,
+ 'name' =>
$fm_location_cols[$i]['column_name'],
+ 'datatype' =>
$fm_location_cols[$i]['datatype'],
+ 'attrib_id' =>
$fm_location_cols[$i]['id']
+ );
+ $k++;
+
+
if($fm_location_cols[$i]['lookup_form']==1)
+ {
+ $uicols['exchange'][]
= True;
+ }
+ else
+ {
+ $uicols['exchange'][]
= False;
+ }
+ }
+ }
+
+
+ $from .= " FROM $paranthesis
fm_location$type_id ";
+
+ $sql = "SELECT $cols $from $joinmethod";
+
+ $this->socommon->fm_cache('sql_'. $type_id .
'_' . $lookup_tenant . '_' . $lookup ,$sql);
+ $this->socommon->fm_cache('uicols_'. $type_id
. '_' . $lookup_tenant . '_' . $lookup,$uicols);
+ $this->socommon->fm_cache('cols_return_'.
$type_id . '_' . $lookup_tenant . '_' . $lookup,$cols_return);
+
+ }
+ else
+ {
+ $uicols = $this->socommon->fm_cache('uicols_'.
$type_id . '_' . $lookup_tenant . '_' . $lookup);
+ $cols_return =
$this->socommon->fm_cache('cols_return_'. $type_id . '_' . $lookup_tenant .
'_' . $lookup);
+
+ $sub_query_tenant =
$this->socommon->fm_cache('sub_query_tenant_'. $type_id . '_' . $lookup_tenant
. '_' . $lookup);
+ $sub_query_street =
$this->socommon->fm_cache('sub_query_street_'. $type_id . '_' . $lookup_tenant
. '_' . $lookup);
+ }
+
+ $this->uicols = $uicols;
+
+ $where= 'WHERE';
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by fm_location' .
($type_id) .'.location_code ASC';
+ }
+
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " $where fm_location" .
($type_id). ".category=$cat_id ";
+ $where= 'AND';
+ }
+ else
+ {
+ $filtermethod .= " $where (fm_location" .
($type_id). ".category !=99 OR fm_location" . ($type_id). ".category IS NULL)";
+ $where= 'AND';
+ }
+
+ if ($filter > 0)
+ {
+ $filtermethod .= " $where
fm_owner.category='$filter' ";
+ $where= 'AND';
+ }
+
+
+ if ($status > 0)
+ {
+ $filtermethod .= " $where fm_location" .
($type_id). ".status=$status ";
+ $where= 'AND';
+ }
+ else
+ {
+// $filtermethod .= " $where fm_location" .
($type_id). ".status IS NULL ";
+// $filtermethod .= " $where fm_location" .
($type_id). ".status !=2 ";
+// $where= 'AND';
+ }
+
+
+ if ($district_id > 0)
+ {
+ $filtermethod .= " $where
fm_part_of_town.district_id='$district_id' ";
+ $where= 'AND';
+ }
+
+ if ($part_of_town_id > 0)
+ {
+ $filtermethod .= " $where
fm_part_of_town.part_of_town_id='$part_of_town_id' ";
+ $where= 'AND';
+ }
+
+ if($query)
+ {
+ $query = str_replace(",",'.',$query);
+ if(stristr($query, '.'))
+ {
+ $query=explode(".",$query);
+ $querymethod = " $where (fm_location" .
($type_id).".loc1='" . $query[0] . "' AND fm_location" . $type_id .".loc" .
($type_id)."='" . $query[1] . "')";
+ }
+ else
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ if($sub_query_tenant)
+ {
+ $sub_query = "OR
fm_tenant.last_name $this->like '%$query%' OR fm_tenant.first_name $this->like
'%$query%' OR fm_tenant.contact_phone $this->like '%$query%'";
+ }
+
+ if($sub_query_street)
+ {
+ $sub_query .= "OR
fm_streetaddress.descr $this->like '%$query%'";
+ }
+
+ $querymethod = " $where (fm_location" .
($type_id).".loc1 $this->like '%$query%' $sub_query OR fm_location" .
($type_id).".location_code $this->like '%$query%' OR loc" . ($type_id)."_name
$this->like '%$query%')";
+ }
+ $where= 'AND';
+ }
+
+ $sql .= "$filtermethod $querymethod";
+
+//echo $sql;
+ $this->db2->query($sql,__LINE__,__FILE__);
+
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ $j=0;
+ $cols_return_count = count($cols_return);
+ $location_count = $type_id-1;
+
+ while ($this->db->next_record())
+ {
+ for ($i=0;$i<$cols_return_count;$i++)
+ {
+ $location_list[$j][$cols_return[$i]] =
stripslashes($this->db->f($cols_return[$i]));
+
+ $value = $this->db->f($cols_return[$i]);
+ if($uicols['cols_return_extra'][$i])
+ {
+
if(($uicols['cols_return_extra'][$i]['datatype']=='R' ||
$uicols['cols_return_extra'][$i]['datatype']=='LB') && $value):
+ {
+ $sql="SELECT value FROM
fm_location_choice where type_id=$type_id AND attrib_id="
.$uicols['cols_return_extra'][$i]['attrib_id']. " AND id=" . $value;
+ $this->db2->query($sql);
+
$this->db2->next_record();
+
$location_list[$j][$cols_return[$i]] = $this->db2->f('value');
+ }
+
elseif($uicols['cols_return_extra'][$i]['datatype']=='AB' && $value):
+ {
+ $contact_data =
$contacts->read_single_entry($value,array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
+
$location_list[$j][$cols_return[$i]] = $contact_data[0]['n_family'] . ', ' .
$contact_data[0]['n_given'];
+ }
+
elseif($uicols['cols_return_extra'][$i]['datatype']=='VENDOR' && $value):
+ {
+ $sql="SELECT org_name
FROM fm_vendor where id=$value";
+ $this->db2->query($sql);
+
$this->db2->next_record();
+
$location_list[$j][$cols_return[$i]] = $this->db2->f('org_name');
+ }
+
elseif($uicols['cols_return_extra'][$i]['datatype']=='CH' && $value):
+ {
+ $ch=
unserialize($value);
+
+ if (isset($ch) AND
is_array($ch))
+ {
+ for
($k=0;$k<count($ch);$k++)
+ {
+
$sql="SELECT value FROM fm_location_choice where type_id=$type_id AND
attrib_id=" .$uicols['cols_return_extra'][$i]['attrib_id']. " AND id=" .
$ch[$k];
+
$this->db2->query($sql);
+ while
($this->db2->next_record())
+ {
+
$ch_value[]=$this->db2->f('value');
+ }
+ }
+
$location_list[$j][$cols_return[$i]] = @implode(",", $ch_value);
+
unset($ch_value);
+ }
+ }
+
elseif($uicols['cols_return_extra'][$i]['datatype']=='D' && $value):
+ {
+
$location_list[$j][$cols_return[$i]]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($value));
+ }
+ endif;
+ }
+ unset($value);
+ }
+
+ $location_code= $this->db->f('location_code');
+ $location = split('-',$location_code);
+ for ($m=0;$m<$location_count;$m++)
+ {
+ $location_list[$j]['loc' . ($m+1)] =
$location[$m];
+
$location_list[$j]['query_location']['loc' . ($m+1)]=implode("-",
array_slice($location, 0, ($m+1)));
+ }
+
+ $j++;
+ }
+
+ return $location_list;
+ }
+
+
+ function
generate_sql($type_id='',$cols='',$cols_return='',$uicols='',$read_single='')
+ {
+
+ $joinmethod .= " fm_location" . ($type_id);
+
+ $location_types =
$this->soadmin_location->select_location_type();
+
+ $cols .= "fm_location" . ($type_id) .".location_code";
+ $cols_return[] = 'location_code';
+ for ($i=0; $i<($type_id); $i++)
+ {
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'loc'
. $location_types[$i]['id'];
+ $uicols['descr'][] =
$location_types[$i]['name'];
+ $uicols['statustext'][] =
$location_types[$i]['descr'];
+ $cols .= ",fm_location" . ($type_id) .".loc" .
$location_types[$i]['id'];
+ $cols_return[] = 'loc' .
$location_types[$i]['id'];
+ }
+
+
+ if($type!=1)
+ {
+// $cols.= ',fm_location1.loc1_name as loc1_name';
+// $cols_return[] =
'loc1_name';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'loc1_name';
+ $uicols['descr'][] =
lang('Property Name');
+ $uicols['statustext'][] =
lang('Property Name');
+ }
+
+ for ($j=($type_id-1); $j>0; $j--)
+ {
+ $joinmethod .= " $this->join fm_location". ($j);
+
+ $paranthesis .='(';
+
+
+ $on = 'ON';
+ for ($i=($j); $i>0; $i--)
+ {
+ $joinmethod .= " $on (fm_location" .
($j+1) .".loc" . ($i). " = fm_location" . ($j) . ".loc" . ($i) . ")";
+ $on = 'AND';
+ if($i==1)
+ {
+ $joinmethod .= ")";
+ }
+ }
+ }
+
+ $config = $this->soadmin_location->read_config('');
+
+ $config_count = count($config);
+ for ($i=0;$i<$config_count;$i++)
+ {
+ if (($config[$i]['location_type'] <= $type_id)
&& ($config[$i]['f_key'] ==1))
+ {
+
+
if($config[$i]['column_name']=='tenant_id')
+ {
+ $join=$this->left_join;
+ }
+ else
+ {
+ $join =$this->join;
+ }
+
+ $joinmethod .= " $join " .
$config[$i]['reference_table'] . " ON ( fm_location" .
$config[$i]['location_type'] . "." . $config[$i]['column_name'] . "=" .
$config[$i]['reference_table'] . ".".$config[$i]['reference_id']."))";
+
+ $paranthesis .='(';
+ }
+
+ if ($config[$i]['location_type'] <= $type_id)
+ {
+
+
if($config[$i]['column_name']=='street_id'):
+ {
+ $cols.=
',fm_streetaddress.descr as street_name';
+ $cols_return[]
= 'street_name';
+ $uicols['input_type'][]
= 'text';
+ $uicols['name'][]
= 'street_name';
+ $uicols['descr'][]
= lang('street name');
+ $uicols['statustext'][]
= lang('street name');
+
+ $cols.= ',street_number';
+ $cols_return[]
= 'street_number';
+ $uicols['input_type'][]
= 'text';
+ $uicols['name'][]
= 'street_number';
+ $uicols['descr'][]
= lang('street number');
+ $uicols['statustext'][]
= lang('street number');
+
+ $cols.= ',fm_location' .
$config[$i]['location_type'] . '.' . $config[$i]['column_name'];
+ $cols_return[]
= $config[$i]['column_name'];
+ $uicols['input_type'][]
= 'hidden';
+ $uicols['name'][]
= $config[$i]['column_name'];
+ $uicols['descr'][]
= lang($config[$i]['input_text']);
+ $uicols['statustext'][]
= lang($config[$i]['input_text']);
+
+ }
+
elseif($config[$i]['column_name']=='tenant_id'):
+ {
+ $cols.= ',fm_tenant.id as
tenant_id';
+ $cols_return[]
= 'tenant_id';
+ $uicols['input_type'][]
= 'hidden';
+ $uicols['name'][]
= 'tenant_id';
+ $uicols['descr'][]
= 'dummy';
+ $uicols['statustext'][]
= 'dummy';
+
+ $cols.= ',fm_tenant.last_name
as last_name';
+ $cols_return[]
= 'last_name';
+ $uicols['input_type'][]
= 'text';
+ $uicols['name'][]
= 'last_name';
+ $uicols['descr'][]
= lang('last name');
+ $uicols['statustext'][]
= lang('last name');
+
+ $cols.= ',fm_tenant.first_name
as first_name';
+ $cols_return[]
= 'first_name';
+ $uicols['input_type'][]
= 'text';
+ $uicols['name'][]
= 'first_name';
+ $uicols['descr'][]
= lang('first name');
+ $uicols['statustext'][]
= lang('first name');
+
+ $cols.= ',contact_phone';
+ $cols_return[]
= 'contact_phone';
+ $uicols['input_type'][]
= 'text';
+ $uicols['name'][]
= 'contact_phone';
+ $uicols['descr'][]
= lang('contact phone');
+ $uicols['statustext'][]
= lang('contact phone');
+
+ }
+ else:
+ {
+ $cols.= ',fm_location' .
$config[$i]['location_type'] . '.' . $config[$i]['column_name'];
+ $cols_return[]
= $config[$i]['column_name'];
+ $uicols['input_type'][]
= 'text';
+ $uicols['name'][]
= $config[$i]['column_name'];
+ $uicols['descr'][]
= $config[$i]['input_text'];
+ $uicols['statustext'][]
= $config[$i]['input_text'];
+ }
+ endif;
+ }
+ }
+
+ $fm_location_cols =
$this->soadmin_location->read_attrib(array('type_id'=>$type_id,'lookup_type'=>$type_id,'allrows'=>True));
+//_debug_array($fm_location_cols);
+
+ $location_cols_count = count($fm_location_cols);
+
+ for ($i=0;$i<$location_cols_count;$i++)
+ {
+
+ if($read_single)
+ {
+ $cols .= ",fm_location" .
$fm_location_cols[$i]['location_type']
.".".$fm_location_cols[$i]['column_name'];
+ $cols_return[]
= $fm_location_cols[$i]['column_name'];
+ $uicols['input_type'][] =
'text';
+ $uicols['name'][]
= $fm_location_cols[$i]['column_name'];
+ $uicols['descr'][]
= $fm_location_cols[$i]['input_text'];
+ $uicols['statustext'][] =
$fm_location_cols[$i]['statustext'];
+
+ }
+ else
+ {
+ if($fm_location_cols[$i]['list']==1)
+ {
+ $cols .= ",fm_location" .
($type_id) .".".$fm_location_cols[$i]['column_name'];
+ $cols_return[]
= $fm_location_cols[$i]['column_name'];
+ $uicols['input_type'][]
= 'text';
+ $uicols['name'][]
= $fm_location_cols[$i]['column_name'];
+ $uicols['descr'][]
= $fm_location_cols[$i]['input_text'];
+ $uicols['statustext'][]
= $fm_location_cols[$i]['statustext'];
+ }
+ }
+ }
+
+
+ $cols.= ',district_id';
+ $cols_return[] = 'district_id';
+
+ $this->uicols = $uicols;
+ $this->cols_return = $cols_return;
+
+ $from .= " FROM $paranthesis $entity_table ";
+
+ $sql = "SELECT $cols $from $joinmethod";
+
+ $this->socommon->fm_cache('sql_single_'. $type_id,$sql);
+ $this->socommon->fm_cache('uicols_single_'.
$type_id,$uicols);
+ $this->socommon->fm_cache('cols_return_single_'.
$type_id,$cols_return);
+
+
+// $GLOBALS['phpgw']->session->appsession('sql_single_'.
$type_id ,$this->currentapp,$sql);
+//
$GLOBALS['phpgw']->session->appsession('uicols_single_'. $type_id
,$this->currentapp,$uicols);
+//
$GLOBALS['phpgw']->session->appsession('cols_return_single_'. $type_id
,$this->currentapp,$cols_return);
+
+ return $sql;
+ }
+
+ function read_single($location_code='')
+ {
+ $location_array = split('-',$location_code);
+ $type_id= count($location_array);
+
+ if (!$type_id)
+ {
+ return;
+ }
+
+ $cols.= 'fm_location' . $type_id .'.category as
cat_id,';
+ $cols_return[] = 'cat_id';
+
+ for ($i=1;$i<($type_id+1);$i++)
+ {
+ $cols.= 'fm_location' . $i .'.loc' . $i
.'_name,';
+ $cols_return[] = 'loc'
. $i .'_name';
+ }
+
+
+ $cols.= 'fm_location' . $type_id . '.change_type,';
+ $cols_return[] = 'change_type';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'loc' .
$type_id .'_name';
+ $uicols['descr'][] = lang('name');
+ $uicols['statustext'][] = lang('name');
+
+ $cols.= 'fm_location' . $type_id .'.remark as remark,';
+ $cols_return[] = 'remark';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'descr';
+ $uicols['descr'][] =
lang('remark');
+ $uicols['statustext'][] = lang('remark');
+
+ $sql = $this->socommon->fm_cache('sql_single_'.
$type_id);
+
+ if(!$sql)
+ {
+ $sql =
$this->generate_sql($type_id,$cols,$cols_return,$uicols,True);
+ }
+ else
+ {
+
+ $this->uicols =
$this->socommon->fm_cache('uicols_single_'. $type_id);
+ $this->cols_return =
$this->socommon->fm_cache('cols_return_single_'. $type_id);
+ }
+
+ $sql .= " WHERE
fm_location$type_id.location_code='$location_code' ";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+//echo $sql;
+ $cols_return = $this->cols_return;
+
+ $cols_return_count = count($cols_return);
+
+ $this->db->next_record();
+ for ($i=0;$i<$cols_return_count;$i++)
+ {
+ $location[$cols_return[$i]] =
stripslashes($this->db->f($cols_return[$i]));
+ }
+
+//_debug_array($cols_return);
+//_debug_array($location);
+ return $location;
+ }
+
+ function add($location='',$values_attribute='',$type_id='')
+ {
+ $location['remark'] =
$this->db->db_addslashes($location['remark']);
+
+ while (is_array($location) && list($input_name,$value)
= each($location))
+ {
+ if($value)
+ {
+ if($input_name=='cat_id')
+ {
+ $input_name='category';
+ }
+ $cols[] = $input_name;
+ $vals[] = $value;
+ }
+ }
+
+ if (isset($values_attribute) AND
is_array($values_attribute))
+ {
+ foreach($values_attribute as $entry)
+ {
+ if($entry['value'])
+ {
+ $cols[] = $entry['name'];
+ $vals[] = $entry['value'];
+ }
+ }
+ }
+
+ $cols =implode(",", $cols) . ",entry_date,user_id";
+ $vals ="'" . implode("','", $vals) . "'," . "'" .
time() . "','" . $this->account . "'";
+
+
+ $sql = "INSERT INTO fm_location$type_id ($cols)
VALUES ($vals)";
+
+//echo $sql;
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ $receipt['message'][] = array('msg'=>lang('Location %1
has been saved',$location['location_code']));
+ return $receipt;
+ }
+
+ function edit($location='',$values_attribute='',$type_id='')
+ {
+//_debug_array($values_attribute);
+ $location['remark'] =
$this->db->db_addslashes($location['remark']);
+
+ while (is_array($location) && list($input_name,$value)
= each($location))
+ {
+ if($value)
+ {
+ if($input_name=='cat_id')
+ {
+ $input_name='category';
+ }
+ $value_set[$input_name] = $value;
+ }
+ }
+
+ if (isset($values_attribute) AND
is_array($values_attribute))
+ {
+ foreach($values_attribute as $entry)
+ {
+ $value_set[$entry['name']] =
$entry['value'];
+ }
+ }
+
+ $value_set['entry_date'] = time();
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $sql = "SELECT * from fm_location$type_id where
location_code ='" . $location['location_code'] . "'";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+
+ $metadata = $this->db->metadata('fm_location'.$type_id);
+
+ for ($i=0; $i<count($metadata); $i++)
+ {
+ $cols[] = $metadata[$i]['name'];
+ $vals[] = $this->db->f($metadata[$i]['name']);
+ }
+
+ $cols[] = 'exp_date';
+ $vals[] = date($this->bocommon->datetimeformat,time());
+
+ $cols =implode(",", $cols);
+ $vals = $this->bocommon->validate_db_insert($vals);
+
+ $sql = "INSERT INTO fm_location" . $type_id ."_history
($cols) VALUES ($vals)";
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ $sql = "UPDATE fm_location$type_id SET $value_set WHERE
location_code='" . $location['location_code'] . "'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ $receipt['message'][] = array('msg'=>lang('Location %1
has been edited',$location['location_code']));
+ return $receipt;
+ }
+
+ function delete($location_code )
+ {
+ $location_array = split('-',$location_code);
+ $type_id= count($location_array);
+
+ $this->db->query("DELETE FROM fm_location$type_id WHERE
location_code='" . $location_code ."'",__LINE__,__FILE__);
+// $this->db->query("DELETE FROM fm_location WHERE
location_code='" . $location_code ."'",__LINE__,__FILE__);
+ }
+
+ function update_cat()
+ {
+ $location_types =
$this->soadmin_location->select_location_type();
+
+ $m= count($location_types);
+
+ $this->db->transaction_begin();
+
+ $this->db->query("UPDATE fm_location" . $m. " set
status= 2 WHERE category=99",__LINE__,__FILE__);
+
+ for ($type_id=$m; $type_id>1; $type_id--)
+ {
+ $parent_table = 'fm_location' . ($type_id-1);
+
+ $joinmethod .= " $this->join $parent_table";
+
+ $paranthesis .='(';
+
+ $on = 'ON';
+ for ($i=($type_id-1); $i>0; $i--)
+ {
+ $joinmethod .= " $on (fm_location" .
($type_id) .".loc" . ($i). ' = '.$parent_table . ".loc" . ($i) . ")";
+ $on = 'AND';
+ if($i==1)
+ {
+ $joinmethod .= ")";
+ }
+ }
+
+ $sql = "SELECT $parent_table.location_code
,count(*) as count_99 FROM $paranthesis fm_location$type_id $joinmethod where
fm_location$type_id.status=2 group by $parent_table.location_code ";
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+
$outdated[$this->db->f('location_code')]['count_99']=$this->db->f('count_99');
+ }
+
+ $sql = "SELECT $parent_table.location_code
,count(*) as count_all FROM $paranthesis fm_location$type_id $joinmethod group
by $parent_table.location_code ";
+ $this->db->query($sql,__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+ if(
$outdated[$this->db->f('location_code')]['count_99']==$this->db->f('count_all'))
+ {
+ $update[]=array('location_code'
=> $this->db->f('location_code'));
+ }
+ }
+
+ $j=0;
+ for ($i=0; $i<count($update); $i++)
+ {
+
+ $sql = "SELECT status FROM
$parent_table WHERE location_code= '" . $update[$i]['location_code'] ."'";
+
+
$this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+
+ if($this->db->f('status')!=2)
+ {
+ $j++;
+ $this->db->query("UPDATE
fm_location" . ($type_id-1). " set status= 2 WHERE location_code= '" .
$update[$i]['location_code'] ."'",__LINE__,__FILE__);
+ }
+ }
+
+ $receipt['message'][]=array('msg'=>lang('%1
location %2 has been updated to not active of %3 already not
active',$j,$location_types[($type_id-2)]['descr'],count($update)));
+
+ unset($outdated);
+ unset($update);
+ unset($joinmethod);
+ unset($paranthesis);
+ }
+
+ $this->db->transaction_commit();
+
+ return $receipt;
+ }
+
+ function read_summary($data='')
+ {
+ if(is_array($data))
+ {
+ $filter =
(isset($data['filter'])?$data['filter']:0);
+ $type_id =
(isset($data['type_id'])?$data['type_id']:'');
+ $district_id =
(isset($data['district_id'])?$data['district_id']:'');
+ $part_of_town_id =
(isset($data['part_of_town_id'])?$data['part_of_town_id']:'');
+ }
+
+ if(!$type_id)
+ {
+ $type_id=4;
+ }
+
+ $entity_table = 'fm_location' . $type_id ;
+
+ $cols= "count(*) as number, $entity_table.category,
$entity_table"."_category.descr as type";
+
+ $groupmethod = " GROUP by $entity_table.category ,
$entity_table"."_category.descr";
+
+ $uicols['name'][] = 'type';
+ $uicols['descr'][] = lang('type');
+
+
+ $where = 'WHERE';
+ if($district_id>0)
+ {
+ $uicols['name'][] = 'district_id';
+ $uicols['descr'][] = lang('district_id');
+ $cols.=", fm_part_of_town.district_id as
district_id";
+ $groupmethod .= " ,fm_part_of_town.district_id";
+ $filtermethod = " $where
fm_part_of_town.district_id=$district_id";
+ $where = 'AND';
+ }
+
+ if($part_of_town_id>0)
+ {
+ $uicols['name'][] = 'part_of_town';
+ $uicols['descr'][] = lang('part of town');
+ $groupmethod .= " ,fm_part_of_town.name";
+ $cols.=", fm_part_of_town.name as part_of_town";
+ $filtermethod .= " $where
fm_part_of_town.part_of_town_id=$part_of_town_id";
+ $where = 'AND';
+ }
+
+ if($filter>0)
+ {
+ $filtermethod .= " $where fm_owner.id=$filter";
+ $where = 'AND';
+ }
+
+
+ $uicols['name'][] = 'number';
+ $uicols['descr'][] = lang('number');
+
+ $joinmethod= "$this->join $entity_table"."_category on
$entity_table.category=$entity_table"."_category.id";
+
+ $sql =
$this->bocommon->generate_sql(array('entity_table'=>$entity_table,'cols_return'=>$cols_return,'cols'=>$cols,
+
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query,'no_address'=>True,'location_level'=>$type_id));
+
+ $this->db->query($sql . $filtermethod . $groupmethod .
" ORDER BY $entity_table.category",__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $summary[]=array(
+ 'number' =>
$this->db->f('number'),
+ 'type' => '[' .
$this->db->f('category') . '] ' .$this->db->f('type'),
+ 'part_of_town' =>
$this->db->f('part_of_town'),
+ 'district_id' =>
$this->db->f('district_id')
+ );
+ }
+
+
+ $this->uicols = $uicols;
+ return $summary;
+ }
+
+ function check_history($location_code='')
+ {
+ $location_array = split('-',$location_code);
+ $type_id= count($location_array);
+
+ if (!$type_id)
+ {
+ return false;
+ }
+
+ $table = 'fm_location' . $type_id . '_history';
+
+ $sql = "SELECT count(*) FROM $table WHERE
location_code='$location_code'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ $this->db->next_record();
+
+ if($this->db->f('0')>0)
+ {
+ return True;
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ function get_history($location_code='')
+ {
+ $this->uicols = array();
+ $location_array = split('-',$location_code);
+ $type_id= count($location_array);
+
+ if (!$type_id)
+ {
+ return;
+ }
+
+ $table = 'fm_location' . $type_id . '_history';
+
+ $table_category = 'fm_location' . $type_id .
'_category';
+
+ $sql = "SELECT column_name,datatype,input_text,id as
attrib_id FROM fm_location_attrib WHERE type_id = $type_id";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+ $attrib[] = array(
+ 'column_name' =>
$this->db->f('column_name'),
+ 'input_text' =>
$this->db->f('input_text'),
+ 'datatype' => $this->db->f('datatype'),
+ 'attrib_id' => $this->db->f('attrib_id')
+ );
+
+ $this->uicols['input_type'][] = 'text';
+ $this->uicols['name'][] =
$this->db->f('column_name');
+ $this->uicols['descr'][] =
$this->db->f('input_text');
+ }
+
+ $this->uicols['input_type'][] = 'text';
+ $this->uicols['name'][] = 'exp_date';
+ $this->uicols['descr'][] = lang('exp date');
+
+
+ $attrib[] = array(
+ 'column_name' => 'exp_date',
+ 'input_text' => 'exp date',
+ 'datatype' => 'D'
+ );
+
+ $sql = "SELECT $table.*, $table_category.descr as
category FROM $table $this->left_join $table_category ON $table.category
=$table_category.id WHERE location_code='$location_code' ORDER BY exp_date
DESC";
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ $j=0;
+ while ($this->db->next_record())
+ {
+ for ($i=0; $i<count($attrib); $i++)
+ {
+
$location[$j][$attrib[$i]['column_name']]=$this->db->f($attrib[$i]['column_name']);
+
+ $value =
$this->db->f($attrib[$i]['column_name']);
+ if(($attrib[$i]['datatype']=='R' ||
$attrib[$i]['datatype']=='LB') && $value):
+ {
+ $sql="SELECT value FROM
fm_location_choice where type_id=$type_id AND attrib_id="
.$attrib[$i]['attrib_id']. " AND id=" . $value;
+ $this->db2->query($sql);
+ $this->db2->next_record();
+
$location[$j][$attrib[$i]['column_name']] = $this->db2->f('value');
+ }
+ elseif($attrib[$i]['datatype']=='AB' &&
$value):
+ {
+ $contact_data =
$contacts->read_single_entry($value,array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
+
$location[$j][$attrib[$i]['column_name']] = $contact_data[0]['n_family']
. ', ' . $contact_data[0]['n_given'];
+ }
+
elseif($attrib[$i]['datatype']=='VENDOR' && $value):
+ {
+ $sql="SELECT org_name FROM
fm_vendor where id=$value";
+ $this->db2->query($sql);
+ $this->db2->next_record();
+
$location[$j][$attrib[$i]['column_name']] = $this->db2->f('org_name');
+ }
+ elseif($attrib[$i]['datatype']=='CH' &&
$value):
+ {
+ $ch= unserialize($value);
+ if (isset($ch) AND
is_array($ch))
+ {
+ for
($k=0;$k<count($ch);$k++)
+ {
+ $sql="SELECT
value FROM fm_location_choice where type_id=$type_id AND attrib_id="
.$attrib[$i]['attrib_id']. " AND id=" . $ch[$k];
+
$this->db2->query($sql);
+ while
($this->db2->next_record())
+ {
+
$ch_value[]=$this->db2->f('value');
+ }
+ }
+
$location[$j][$attrib[$i]['column_name']] = @implode(",", $ch_value);
+ unset($ch_value);
+ }
+ }
+ elseif($attrib[$i]['datatype']=='D' &&
$value):
+ {
+
$location[$j][$attrib[$i]['column_name']]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($value));
+ }
+
elseif($attrib[$i]['column_name']=='entry_date' && $value):
+ {
+
$location[$j][$attrib[$i]['column_name']]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],$value);
+ }
+ endif;
+
+ unset($value);
+
+ }
+ $j++;
+ }
+
+ return $location;
+ }
+ }
+?>
Index: property/inc/class.solookup.inc.php
diff -u property/inc/class.solookup.inc.php:1.7
property/inc/class.solookup.inc.php:1.8
--- property/inc/class.solookup.inc.php:1.7 Fri Aug 19 11:56:50 2005
+++ property/inc/class.solookup.inc.php Fri Jan 27 14:05:43 2006
@@ -1,385 +1,384 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage core
- * @version $Id: class.solookup.inc.php,v 1.7 2005/08/19 11:56:50
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class solookup
- {
- var $grants;
-
- function solookup()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
-
- $this->join = $this->socommon->join;
- $this->like = $this->socommon->like;
-
- }
-
- function read_addressbook($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- }
-
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by last_name DESC';
- }
-
-
- $where= 'WHERE';
-
- if ($cat_id > 0)
- {
- $filtermethod .= " $where cat_id $this->like
'%,$cat_id,%' ";
- $where= 'AND';
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " $where (id $this->like
'%$query%' or org_name $this->like '%$query%')";
- }
-
- $sql = "SELECT person_id,first_name,last_name FROM
phpgw_contact_person $filtermethod $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $contact[] = array
- (
- 'id' =>
$this->db->f('person_id'),
- 'contact_name' =>
$this->db->f('last_name') . ', ' . $this->db->f('first_name'),
- );
- }
-//_debug_array($vendor);
-
- return $contact;
- }
-
- function read_vendor($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- }
-
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by org_name DESC';
- }
-
-
- $where= 'WHERE';
-
- if ($cat_id > 0)
- {
- $filtermethod .= " $where member_of $this->like
'%,$cat_id,%' ";
- $where= 'AND';
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " $where (id $this->like
'%$query%' or org_name $this->like '%$query%')";
- }
-
- $sql = "SELECT id,org_name FROM fm_vendor $filtermethod
$querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $vendor[] = array
- (
- 'id' => $this->db->f('id'),
- 'org_name' =>
$this->db->f('org_name'),
- );
- }
-//_debug_array($vendor);
-
- return $vendor;
- }
-
-
- function read_b_account($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by id DESC';
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " where (id $this->like
'%$query%' or descr $this->like '%$query%')";
- }
-
- $sql = "SELECT * FROM fm_b_account $querymethod ";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $b_account[] = array
- (
- 'id' =>
$this->db->f('id'),
- 'descr' => $this->db->f('descr')
- );
- }
-
- return $b_account;
- }
-
-
- function read_street($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by
fm_streetaddress.descr DESC';
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " where ( descr $this->like
'%$query%')";
- }
-
- $sql = "SELECT * FROM fm_streetaddress $querymethod ";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $street[] = array
- (
- 'id' => $this->db->f('id'),
- 'street_name' =>
stripslashes($this->db->f('descr'))
- );
- }
-
- return $street;
- }
-
- function read_tenant($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by last_name DESC';
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " where ( last_name $this->like
'%$query%' or first_name $this->like '%$query%')";
- }
-
- $sql = "SELECT * FROM fm_tenant $querymethod ";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $tenant[] = array
- (
- 'id' =>
$this->db->f('id'),
- 'last_name' =>
$this->db->f('last_name'),
- 'first_name' =>
$this->db->f('first_name')
- );
- }
-
- return $tenant;
- }
-
- function read_ns3420($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by tekst1 DESC';
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " where ( tekst1 $this->like
'%$query%' or tekst2 $this->like '%$query%' or tekst3 $this->like '%$query%' or
tekst4 $this->like '%$query%' or tekst5 $this->like '%$query%' or tekst6
$this->like '%$query%')";
- }
-
- $sql = "SELECT * FROM fm_ns3420 $querymethod ";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $ns3420[] = array
- (
- 'id' =>
$this->db->f('id'),
- 'ns3420_descr' =>
$this->db->f('tekst1') . ' ' .$this->db->f('tekst2') . ' '
.$this->db->f('tekst3') . ' ' .$this->db->f('tekst4') . ' '
.$this->db->f('tekst5') . ' ' .$this->db->f('tekst6')
- );
- }
-
- return $ns3420;
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage core
+ * @version $Id: class.solookup.inc.php,v 1.8 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class solookup
+ {
+ var $grants;
+
+ function solookup()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->like = $this->bocommon->like;
+
+ }
+
+ function read_addressbook($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ }
+
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by last_name DESC';
+ }
+
+
+ $where= 'WHERE';
+
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " $where cat_id $this->like
'%,$cat_id,%' ";
+ $where= 'AND';
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " $where (id $this->like
'%$query%' or org_name $this->like '%$query%')";
+ }
+
+ $sql = "SELECT person_id,first_name,last_name FROM
phpgw_contact_person $filtermethod $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $contact[] = array
+ (
+ 'id' =>
$this->db->f('person_id'),
+ 'contact_name' =>
$this->db->f('last_name') . ', ' . $this->db->f('first_name'),
+ );
+ }
+//_debug_array($vendor);
+
+ return $contact;
+ }
+
+ function read_vendor($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ }
+
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by org_name DESC';
+ }
+
+
+ $where= 'WHERE';
+
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " $where member_of $this->like
'%,$cat_id,%' ";
+ $where= 'AND';
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " $where (id $this->like
'%$query%' or org_name $this->like '%$query%')";
+ }
+
+ $sql = "SELECT id,org_name FROM fm_vendor $filtermethod
$querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $vendor[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'org_name' =>
$this->db->f('org_name'),
+ );
+ }
+//_debug_array($vendor);
+
+ return $vendor;
+ }
+
+
+ function read_b_account($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by id DESC';
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " where (id $this->like
'%$query%' or descr $this->like '%$query%')";
+ }
+
+ $sql = "SELECT * FROM fm_b_account $querymethod ";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $b_account[] = array
+ (
+ 'id' =>
$this->db->f('id'),
+ 'descr' => $this->db->f('descr')
+ );
+ }
+
+ return $b_account;
+ }
+
+
+ function read_street($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by
fm_streetaddress.descr DESC';
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " where ( descr $this->like
'%$query%')";
+ }
+
+ $sql = "SELECT * FROM fm_streetaddress $querymethod ";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $street[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'street_name' =>
stripslashes($this->db->f('descr'))
+ );
+ }
+
+ return $street;
+ }
+
+ function read_tenant($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by last_name DESC';
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " where ( last_name $this->like
'%$query%' or first_name $this->like '%$query%')";
+ }
+
+ $sql = "SELECT * FROM fm_tenant $querymethod ";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $tenant[] = array
+ (
+ 'id' =>
$this->db->f('id'),
+ 'last_name' =>
$this->db->f('last_name'),
+ 'first_name' =>
$this->db->f('first_name')
+ );
+ }
+
+ return $tenant;
+ }
+
+ function read_ns3420($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by tekst1 DESC';
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " where ( tekst1 $this->like
'%$query%' or tekst2 $this->like '%$query%' or tekst3 $this->like '%$query%' or
tekst4 $this->like '%$query%' or tekst5 $this->like '%$query%' or tekst6
$this->like '%$query%')";
+ }
+
+ $sql = "SELECT * FROM fm_ns3420 $querymethod ";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $ns3420[] = array
+ (
+ 'id' =>
$this->db->f('id'),
+ 'ns3420_descr' =>
$this->db->f('tekst1') . ' ' .$this->db->f('tekst2') . ' '
.$this->db->f('tekst3') . ' ' .$this->db->f('tekst4') . ' '
.$this->db->f('tekst5') . ' ' .$this->db->f('tekst6')
+ );
+ }
+
+ return $ns3420;
+ }
+ }
+?>
Index: property/inc/class.someter.inc.php
diff -u property/inc/class.someter.inc.php:1.5
property/inc/class.someter.inc.php:1.6
--- property/inc/class.someter.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/class.someter.inc.php Fri Jan 27 14:05:43 2006
@@ -1,284 +1,284 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage entity
- * @version $Id: class.someter.inc.php,v 1.5 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class someter
- {
-
- function someter()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->join = $this->bocommon->join;
- $this->like = $this->bocommon->like;
- }
-
- function get_category_list()
- {
-
- $this->db->query("SELECT id, descr FROM
fm_meter_category ORDER BY descr ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $categories[$i]['id']
= $this->db->f('id');
- $categories[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $categories;
- }
-
- function check_meter_num($num='')
- {
- $this->db->query("SELECT count(*) FROM fm_meter where
num='$num'");
-
- $this->db->next_record();
-
- if ( $this->db->f(0))
- {
- return True;
- }
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- }
-
-
- $entity_table = 'fm_meter';
-
- $cols .= $entity_table . '.location_code';
- $cols_return[] = 'location_code';
-
- $cols .= ",$entity_table.id as meter_id";
- $cols_return[] = 'meter_id';
-
- $cols .= ",$entity_table.num as num";
- $cols_return[] = 'num';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'num';
- $uicols['descr'][] = lang('Meter
ID');
- $uicols['statustext'][] = lang('Meter ID');
-
- $cols .= ",$entity_table.name ";
- $cols_return[] = 'name';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'name';
- $uicols['descr'][] = lang('Name');
- $uicols['statustext'][] = lang('Name');
-
- $cols .= ",fm_meter_category.descr as meter_type";
- $cols_return[] = 'meter_type';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'meter_type';
- $uicols['descr'][] = lang('Meter
Type');
- $uicols['statustext'][] = lang('Meter Type');
-
-
- $joinmethod .= " $this->join fm_meter_category ON
($entity_table.category = fm_meter_category.id))";
- $paranthesis .='(';
-
-
- $sql =
$this->bocommon->generate_sql(array('entity_table'=>$entity_table,'cols'=>$cols,'cols_return'=>$cols_return,
-
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query));
-
-
- if ($order)
- {
- $ordermethod = " order by $entity_table.$order
$sort";
- }
- else
- {
- $ordermethod = " order by
$entity_table.location_code asc";
- }
-
-
- $where = 'WHERE';
- if ($cat_id)
- {
- $filtermethod .= " $where
fm_meter.category='$cat_id' ";
- $where = 'AND';
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " $where (fm_meter.name
$this->like '%$query%' OR fm_meter.num $this->like '%$query%' OR
fm_meter.location_code $this->like '%$query%' OR fm_meter.address $this->like
'%$query%')";
- }
-
- $sql .= " $filtermethod $querymethod";
-//echo $sql;
- $this->uicols = $this->bocommon->uicols;
- $cols_return = $this->bocommon->cols_return;
- $type_id =
$this->bocommon->type_id;
- $this->cols_extra = $this->bocommon->cols_extra;
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
-
-
- $j=0;
- while ($this->db->next_record())
- {
- for ($i=0;$i<count($cols_return);$i++)
- {
- $meter[$j][$cols_return[$i]] =
$this->db->f($cols_return[$i]);
- }
-
- $location_code= $this->db->f('location_code');
- $location = split('-',$location_code);
- for ($m=0;$m<count($location);$m++)
- {
- $meter[$j]['loc' . ($m+1)] =
$location[$m];
- $meter[$j]['query_location']['loc' .
($m+1)]=implode("-", array_slice($location, 0, ($m+1)));
- }
-
- $j++;
- }
-
- return $meter;
- }
-
- function read_single($meter_id)
- {
- $sql = "SELECT * FROM fm_meter where id='$meter_id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $meter['meter_id'] =
$this->db->f('id');
- $meter['num'] =
$this->db->f('num');
- $meter['name'] =
stripslashes($this->db->f('name'));
- $meter['remark'] =
stripslashes($this->db->f('remark'));
- $meter['cat_id'] =
$this->db->f('category');
- $meter['location_code'] =
$this->db->f('location_code');
- $meter['p_num'] =
$this->db->f('p_num');
- $meter['p_entity_id'] =
$this->db->f('p_entity_id');
- $meter['p_cat_id'] =
$this->db->f('p_cat_id');
- }
- return $meter;
- }
-
- function add($meter)
- {
-
- while (is_array($meter['location']) &&
list($input_name,$value) = each($meter['location']))
- {
- if($value)
- {
- $cols[] = $input_name;
- $vals[] = $value;
- }
- }
-
- if($cols)
- {
- $cols = "," . implode(",", $cols);
- $vals = ",'" . implode("','", $vals) . "'";
- }
-
- if($meter['street_name'])
- {
- $address[]= $meter['street_name'];
- $address[]= $meter['street_number'];
- $address = implode(" ", $address);
- }
-
- if(!$address)
- {
- $address = $meter['location_name'];
- }
-
- $meter['remark'] =
$this->db->db_addslashes($meter['remark']);
-
- $this->db->query("INSERT INTO fm_meter (location_code,
num,user_id,entry_date,name,address,category,remark $cols ) "
- . "VALUES ('" . $meter['location_code'] . "','"
. $meter['num'] . "','" . $this->account . "','" . time() . "','" .
$meter['name']
- . "','" . $address ."','" . $meter['cat_id']
."','" . $meter['remark']. "' $vals )",__LINE__,__FILE__);
-
-
- $meter_id =
$this->db->get_last_insert_id('fm_meter','id');
-
- $receipt['meter_id'] = $meter_id;
- $receipt['message'][]=array('msg'=>lang('Meter %1 has
been saved',$meter['num']));
- return $receipt;
- }
-
- function edit($meter)
- {
-
- while (is_array($meter['location']) &&
list($input_name,$value) = each($meter['location']))
- {
- $vals[] = "$input_name = '$value'";
- }
-
- if($vals)
- {
- $vals = "," . implode(",",$vals);
- }
-
- if($meter['street_name'])
- {
- $address[]= $meter['street_name'];
- $address[]= $meter['street_number'];
- $address = implode(" ", $address);
- }
-
- if(!$address)
- {
- $address = $meter['location_name'];
- }
-
- $meter['remark'] =
$this->db->db_addslashes($meter['remark']);
-
-
- $this->db->query("UPDATE fm_meter set name='" .
$meter['name'] . "', entry_date='" . time() . "', category='"
- . $meter['cat_id'] .
"', location_code='" . $meter['location_code'] . "', address='" . $address .
"', remark='" . $meter['remark']
- . "' $vals WHERE id='"
. $meter['meter_id'] . "'",__LINE__,__FILE__);
-
- $receipt['message'][]=array('msg'=>lang('Meter %1 has
been edited',$meter['num']));
- return $receipt;
- }
-
- function delete($meter_id)
- {
- $this->db->query("DELETE FROM fm_meter WHERE id='" .
$meter_id ."'",__LINE__,__FILE__);
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage entity
+ * @version $Id: class.someter.inc.php,v 1.6 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class someter
+ {
+
+ function someter()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->like = $this->bocommon->like;
+ }
+
+ function get_category_list()
+ {
+
+ $this->db->query("SELECT id, descr FROM
fm_meter_category ORDER BY descr ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $categories[$i]['id']
= $this->db->f('id');
+ $categories[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $categories;
+ }
+
+ function check_meter_num($num='')
+ {
+ $this->db->query("SELECT count(*) FROM fm_meter where
num='$num'");
+
+ $this->db->next_record();
+
+ if ( $this->db->f(0))
+ {
+ return True;
+ }
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ }
+
+
+ $entity_table = 'fm_meter';
+
+ $cols .= $entity_table . '.location_code';
+ $cols_return[] = 'location_code';
+
+ $cols .= ",$entity_table.id as meter_id";
+ $cols_return[] = 'meter_id';
+
+ $cols .= ",$entity_table.num as num";
+ $cols_return[] = 'num';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'num';
+ $uicols['descr'][] = lang('Meter
ID');
+ $uicols['statustext'][] = lang('Meter ID');
+
+ $cols .= ",$entity_table.name ";
+ $cols_return[] = 'name';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'name';
+ $uicols['descr'][] = lang('Name');
+ $uicols['statustext'][] = lang('Name');
+
+ $cols .= ",fm_meter_category.descr as meter_type";
+ $cols_return[] = 'meter_type';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'meter_type';
+ $uicols['descr'][] = lang('Meter
Type');
+ $uicols['statustext'][] = lang('Meter Type');
+
+
+ $joinmethod .= " $this->join fm_meter_category ON
($entity_table.category = fm_meter_category.id))";
+ $paranthesis .='(';
+
+
+ $sql =
$this->bocommon->generate_sql(array('entity_table'=>$entity_table,'cols'=>$cols,'cols_return'=>$cols_return,
+
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query));
+
+
+ if ($order)
+ {
+ $ordermethod = " order by $entity_table.$order
$sort";
+ }
+ else
+ {
+ $ordermethod = " order by
$entity_table.location_code asc";
+ }
+
+
+ $where = 'WHERE';
+ if ($cat_id)
+ {
+ $filtermethod .= " $where
fm_meter.category='$cat_id' ";
+ $where = 'AND';
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " $where (fm_meter.name
$this->like '%$query%' OR fm_meter.num $this->like '%$query%' OR
fm_meter.location_code $this->like '%$query%' OR fm_meter.address $this->like
'%$query%')";
+ }
+
+ $sql .= " $filtermethod $querymethod";
+//echo $sql;
+ $this->uicols = $this->bocommon->uicols;
+ $cols_return = $this->bocommon->cols_return;
+ $type_id =
$this->bocommon->type_id;
+ $this->cols_extra = $this->bocommon->cols_extra;
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+
+
+ $j=0;
+ while ($this->db->next_record())
+ {
+ for ($i=0;$i<count($cols_return);$i++)
+ {
+ $meter[$j][$cols_return[$i]] =
$this->db->f($cols_return[$i]);
+ }
+
+ $location_code= $this->db->f('location_code');
+ $location = split('-',$location_code);
+ for ($m=0;$m<count($location);$m++)
+ {
+ $meter[$j]['loc' . ($m+1)] =
$location[$m];
+ $meter[$j]['query_location']['loc' .
($m+1)]=implode("-", array_slice($location, 0, ($m+1)));
+ }
+
+ $j++;
+ }
+
+ return $meter;
+ }
+
+ function read_single($meter_id)
+ {
+ $sql = "SELECT * FROM fm_meter where id='$meter_id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $meter['meter_id'] =
$this->db->f('id');
+ $meter['num'] =
$this->db->f('num');
+ $meter['name'] =
stripslashes($this->db->f('name'));
+ $meter['remark'] =
stripslashes($this->db->f('remark'));
+ $meter['cat_id'] =
$this->db->f('category');
+ $meter['location_code'] =
$this->db->f('location_code');
+ $meter['p_num'] =
$this->db->f('p_num');
+ $meter['p_entity_id'] =
$this->db->f('p_entity_id');
+ $meter['p_cat_id'] =
$this->db->f('p_cat_id');
+ }
+ return $meter;
+ }
+
+ function add($meter)
+ {
+
+ while (is_array($meter['location']) &&
list($input_name,$value) = each($meter['location']))
+ {
+ if($value)
+ {
+ $cols[] = $input_name;
+ $vals[] = $value;
+ }
+ }
+
+ if($cols)
+ {
+ $cols = "," . implode(",", $cols);
+ $vals = ",'" . implode("','", $vals) . "'";
+ }
+
+ if($meter['street_name'])
+ {
+ $address[]= $meter['street_name'];
+ $address[]= $meter['street_number'];
+ $address = implode(" ", $address);
+ }
+
+ if(!$address)
+ {
+ $address = $meter['location_name'];
+ }
+
+ $meter['remark'] =
$this->db->db_addslashes($meter['remark']);
+
+ $this->db->query("INSERT INTO fm_meter (location_code,
num,user_id,entry_date,name,address,category,remark $cols ) "
+ . "VALUES ('" . $meter['location_code'] . "','"
. $meter['num'] . "','" . $this->account . "','" . time() . "','" .
$meter['name']
+ . "','" . $address ."','" . $meter['cat_id']
."','" . $meter['remark']. "' $vals )",__LINE__,__FILE__);
+
+
+ $meter_id =
$this->db->get_last_insert_id('fm_meter','id');
+
+ $receipt['meter_id'] = $meter_id;
+ $receipt['message'][]=array('msg'=>lang('Meter %1 has
been saved',$meter['num']));
+ return $receipt;
+ }
+
+ function edit($meter)
+ {
+
+ while (is_array($meter['location']) &&
list($input_name,$value) = each($meter['location']))
+ {
+ $vals[] = "$input_name = '$value'";
+ }
+
+ if($vals)
+ {
+ $vals = "," . implode(",",$vals);
+ }
+
+ if($meter['street_name'])
+ {
+ $address[]= $meter['street_name'];
+ $address[]= $meter['street_number'];
+ $address = implode(" ", $address);
+ }
+
+ if(!$address)
+ {
+ $address = $meter['location_name'];
+ }
+
+ $meter['remark'] =
$this->db->db_addslashes($meter['remark']);
+
+
+ $this->db->query("UPDATE fm_meter set name='" .
$meter['name'] . "', entry_date='" . time() . "', category='"
+ . $meter['cat_id'] .
"', location_code='" . $meter['location_code'] . "', address='" . $address .
"', remark='" . $meter['remark']
+ . "' $vals WHERE id='"
. $meter['meter_id'] . "'",__LINE__,__FILE__);
+
+ $receipt['message'][]=array('msg'=>lang('Meter %1 has
been edited',$meter['num']));
+ return $receipt;
+ }
+
+ function delete($meter_id)
+ {
+ $this->db->query("DELETE FROM fm_meter WHERE id='" .
$meter_id ."'",__LINE__,__FILE__);
+ }
+
+ }
+?>
Index: property/inc/class.sop_of_town.inc.php
diff -u property/inc/class.sop_of_town.inc.php:1.5
property/inc/class.sop_of_town.inc.php:1.6
--- property/inc/class.sop_of_town.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/class.sop_of_town.inc.php Fri Jan 27 14:05:43 2006
@@ -1,152 +1,151 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.sop_of_town.inc.php,v 1.5 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class sop_of_town
- {
-
- function sop_of_town()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
-
- $this->join = $this->socommon->join;
- $this->like = $this->socommon->like;
- }
-
-
- function read_district_name($id)
- {
- $this->db->query("SELECT descr FROM fm_district where
id='$id'");
- $this->db->next_record();
- return $this->db->f('descr');
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- $start =
(isset($data['start'])?$data['start']:0);
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $district_id =
(isset($data['district_id'])?$data['district_id']:0);
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by part_of_town_id ASC';
- }
-
-
- $where = 'WHERE';
- if ($district_id > 0)
- {
- $filtermethod .= " $where
district_id='$district_id' ";
- $where = 'AND';
-
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " $where ( name $this->like
'%$query%')";
- }
-
- $sql = "SELECT fm_part_of_town.*, descr as category
FROM fm_part_of_town $this->join fm_district on
fm_part_of_town.district_id=fm_district.id $filtermethod $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $p_of_towns[] = array
- (
- 'part_of_town_id' =>
$this->db->f('part_of_town_id'),
- 'name' =>
stripslashes($this->db->f('name')),
- 'category' =>
stripslashes($this->db->f('category')),
- 'district_id' =>
$this->db->f('district_id')
- );
- }
- return $p_of_towns;
- }
-
- function read_single($part_of_town_id)
- {
- $this->db->query("select * from fm_part_of_town where
part_of_town_id='$part_of_town_id'",__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $p_of_town['id'] =
(int)$this->db->f('part_of_town_id');
- $p_of_town['name'] =
stripslashes($this->db->f('name'));
- $p_of_town['district_id'] =
(int)$this->db->f('district_id');
-
- return $p_of_town;
- }
- }
-
- function add($p_of_town)
- {
- $p_of_town['name'] =
$this->db->db_addslashes($p_of_town['name']);
-
- $this->db->query("INSERT INTO fm_part_of_town
(name,district_id) "
- . "VALUES ('" . $p_of_town['name']
- . "','" . $p_of_town['district_id'] .
"')",__LINE__,__FILE__);
-
- $receipt['part_of_town_id']=
$this->db->get_last_insert_id('fm_part_of_town','part_of_town_id');
- $receipt['message'][] = array('msg'=>lang('Part of town
%1 has been saved',$receipt['part_of_town_id']));
- return $receipt;
- }
-
- function edit($p_of_town)
- {
- $p_of_town['name'] =
$this->db->db_addslashes($p_of_town['name']);
-
- $this->db->query("UPDATE fm_part_of_town set name='" .
$p_of_town['name'] . "', district_id='"
- .
$p_of_town['district_id'] . "' WHERE part_of_town_id=" .
intval($p_of_town['part_of_town_id']),__LINE__,__FILE__);
-
- $receipt['part_of_town_id']=
$p_of_town['part_of_town_id'];
- $receipt['message'][] = array('msg'=>lang('Part of town
%1 has been edited',$p_of_town['part_of_town_id']));
- return $receipt;
- }
-
- function delete($part_of_town_id)
- {
- $this->db->query('DELETE FROM fm_part_of_town WHERE
part_of_town_id=' . intval($part_of_town_id),__LINE__,__FILE__);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.sop_of_town.inc.php,v 1.6 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class sop_of_town
+ {
+
+ function sop_of_town()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->like = $this->bocommon->like;
+ }
+
+
+ function read_district_name($id)
+ {
+ $this->db->query("SELECT descr FROM fm_district where
id='$id'");
+ $this->db->next_record();
+ return $this->db->f('descr');
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ $start =
(isset($data['start'])?$data['start']:0);
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $district_id =
(isset($data['district_id'])?$data['district_id']:0);
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by part_of_town_id ASC';
+ }
+
+
+ $where = 'WHERE';
+ if ($district_id > 0)
+ {
+ $filtermethod .= " $where
district_id='$district_id' ";
+ $where = 'AND';
+
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " $where ( name $this->like
'%$query%')";
+ }
+
+ $sql = "SELECT fm_part_of_town.*, descr as category
FROM fm_part_of_town $this->join fm_district on
fm_part_of_town.district_id=fm_district.id $filtermethod $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $p_of_towns[] = array
+ (
+ 'part_of_town_id' =>
$this->db->f('part_of_town_id'),
+ 'name' =>
stripslashes($this->db->f('name')),
+ 'category' =>
stripslashes($this->db->f('category')),
+ 'district_id' =>
$this->db->f('district_id')
+ );
+ }
+ return $p_of_towns;
+ }
+
+ function read_single($part_of_town_id)
+ {
+ $this->db->query("select * from fm_part_of_town where
part_of_town_id='$part_of_town_id'",__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $p_of_town['id'] =
(int)$this->db->f('part_of_town_id');
+ $p_of_town['name'] =
stripslashes($this->db->f('name'));
+ $p_of_town['district_id'] =
(int)$this->db->f('district_id');
+
+ return $p_of_town;
+ }
+ }
+
+ function add($p_of_town)
+ {
+ $p_of_town['name'] =
$this->db->db_addslashes($p_of_town['name']);
+
+ $this->db->query("INSERT INTO fm_part_of_town
(name,district_id) "
+ . "VALUES ('" . $p_of_town['name']
+ . "','" . $p_of_town['district_id'] .
"')",__LINE__,__FILE__);
+
+ $receipt['part_of_town_id']=
$this->db->get_last_insert_id('fm_part_of_town','part_of_town_id');
+ $receipt['message'][] = array('msg'=>lang('Part of town
%1 has been saved',$receipt['part_of_town_id']));
+ return $receipt;
+ }
+
+ function edit($p_of_town)
+ {
+ $p_of_town['name'] =
$this->db->db_addslashes($p_of_town['name']);
+
+ $this->db->query("UPDATE fm_part_of_town set name='" .
$p_of_town['name'] . "', district_id='"
+ .
$p_of_town['district_id'] . "' WHERE part_of_town_id=" .
intval($p_of_town['part_of_town_id']),__LINE__,__FILE__);
+
+ $receipt['part_of_town_id']=
$p_of_town['part_of_town_id'];
+ $receipt['message'][] = array('msg'=>lang('Part of town
%1 has been edited',$p_of_town['part_of_town_id']));
+ return $receipt;
+ }
+
+ function delete($part_of_town_id)
+ {
+ $this->db->query('DELETE FROM fm_part_of_town WHERE
part_of_town_id=' . intval($part_of_town_id),__LINE__,__FILE__);
+ }
+ }
+?>
Index: property/inc/class.sopricebook.inc.php
diff -u property/inc/class.sopricebook.inc.php:1.12
property/inc/class.sopricebook.inc.php:1.13
--- property/inc/class.sopricebook.inc.php:1.12 Fri Sep 30 12:45:58 2005
+++ property/inc/class.sopricebook.inc.php Fri Jan 27 14:05:43 2006
@@ -1,795 +1,794 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage agreement
- * @version $Id: class.sopricebook.inc.php,v 1.12 2005/09/30 12:45:58
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class sopricebook
- {
-
- function sopricebook()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->join = $this->bocommon->join;
- $this->like = $this->bocommon->like;
- }
-
- function
add_activity_first_prize($m_cost,$w_cost,$total_cost,$activity_id,$vendor_id,$date)
- {
- $this->db->query("update fm_activity_price_index set
index_count='1',this_index='1',
m_cost='$m_cost',w_cost='$w_cost',total_cost='$total_cost',index_date='$date',current_index='1'
where activity_id='$activity_id' and vendor_id= '$vendor_id' and index_count=
'1'",__LINE__,__FILE__);
-
- $receipt['message'][] = array('msg'=>lang('First entry
is added!'));
-
- return $receipt;
- }
-
- function update_pricebook($update)
- {
- for ($i=0; $i<count($update); $i++)
- {
- $this->db->query("select max(index_count) as
max_index_count from fm_activity_price_index Where activity_id='".
$update[$i]['activity_id'] . "' and vendor_id='".$update[$i]['vendor_id'] .
"'",__LINE__,__FILE__);
- $this->db->next_record();
- $next_index_count =
$this->db->f('max_index_count')+1;
-
- $this->db->query("update
fm_activity_price_index set current_index = Null"
- . " WHERE activity_id='" .
$update[$i]['activity_id'] . "' and vendor_id='" . $update[$i]['vendor_id'] .
"'",__LINE__,__FILE__);
-
- $this->db->query("insert into
fm_activity_price_index (activity_id, vendor_id, index_count, this_index,
m_cost, w_cost, total_cost, index_date,current_index) "
- . " values ('" .
- $update[$i]['activity_id'] . "','" .
- $update[$i]['vendor_id'] . "','" .
- $next_index_count . "','" .
- $update[$i]['new_index'] . "','" .
- $update[$i]['new_m_cost'] . "','" .
- $update[$i]['new_w_cost'] . "','" .
- $update[$i]['new_total_cost'] . "','" .
- $update[$i]['new_date']. "',
'1')",__LINE__,__FILE__);
- }
-
- $receipt['message'][] = array('msg'=>lang('%1 entries
is updated!',$i));
-
- return $receipt;
-
- }
-
- function get_vendor_list()
- {
- $this->db->query("SELECT fm_vendor.org_name ,vendor_id "
- . " FROM fm_agreement $this->join fm_vendor ON
fm_agreement.vendor_id = fm_vendor.id "
- . " WHERE fm_agreement.status='active'"
- . " GROUP by fm_vendor.org_name ,vendor_id "
- . " ORDER BY fm_vendor.org_name
",__LINE__,__FILE__);
- while ($this->db->next_record())
- {
-//--------->fix this------->
- if($this->db->f('vendor_id'))
- {
- $vendor_list[]=array
- (
- 'id' =>
$this->db->f('vendor_id'),
- 'name' =>
$this->db->f('org_name')
- );
- }
- }
- return $vendor_list;
- }
-
- function get_agreement_group_list()
- {
- $this->db->query("SELECT * FROM fm_agreement_group
ORDER BY descr asc");
- while ($this->db->next_record())
- {
- $agreement_group_list[]=array
- (
- 'id' => $this->db->f('id'),
- 'name' =>
$GLOBALS['phpgw']->strip_html($this->db->f('descr')).' [ '.
$GLOBALS['phpgw']->strip_html($this->db->f('status')).' ] '
- );
- }
- return $agreement_group_list;
- }
-
- function get_dim_d_list()
- {
- $this->db->query("SELECT * FROM fm_dim_d ORDER BY descr
asc");
- while ($this->db->next_record())
- {
- $dim_d_list[]=array
- (
- 'id' => $this->db->f('id'),
- 'name' => $this->db->f('id')
- );
- }
- return $dim_d_list;
- }
-
- function get_unit_list()
- {
- $this->db->query("SELECT * FROM fm_standard_unit ORDER
BY descr asc");
- while ($this->db->next_record())
- {
- $unit_list[]=array
- (
- 'id' => $this->db->f('id'),
- 'name' =>
$GLOBALS['phpgw']->strip_html($this->db->f('descr'))
- );
- }
- return $unit_list;
- }
-
- function get_branch_list()
- {
- $this->db->query("SELECT * FROM fm_branch ORDER BY
descr asc");
- while ($this->db->next_record())
- {
- $branch_list[]=array
- (
- 'id' => $this->db->f('id'),
- 'name' =>
$GLOBALS['phpgw']->strip_html($this->db->f('descr'))
- );
- }
- return $branch_list;
- }
-
- function check_activity_num($num='',$agreement_group_id='')
- {
- $this->db->query("SELECT count(*) FROM fm_activities
where num='$num' and agreement_group_id ='$agreement_group_id'");
-
- $this->db->next_record();
-
- if ( $this->db->f(0))
- {
- return True;
- }
- }
-
- function check_agreement_group_num($num='')
- {
- $this->db->query("SELECT count(*) FROM
fm_agreement_group where num='$num'");
-
- $this->db->next_record();
-
- if ( $this->db->f(0))
- {
- return True;
- }
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- }
-
-//_debug_array($data);
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by activity_id';
- }
-
- if ($cat_id > 0)
- {
- $filtermethod .= " AND cat_id='$cat_id' ";
- $vendor_condition= "= $cat_id";
- }
- else
- {
- $vendor_condition= " IS NULL";
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " AND (fm_activities.descr
$this->like '%$query%' or fm_activities.num $this->like '%$query%')";
- }
-
-
- $sql = "SELECT fm_activities.num, fm_activities.unit,
fm_activities.dim_d, fm_activities.ns3420, fm_activities.descr AS descr,"
- . " fm_activities.base_descr,
fm_activity_price_index.activity_id, fm_branch.descr AS branch,"
- . " fm_agreement.vendor_id,
fm_activity_price_index.total_cost, fm_activity_price_index.m_cost,"
- . " fm_activity_price_index.w_cost,
fm_activity_price_index.index_count, fm_activity_price_index.this_index,
fm_agreement.id"
- . " FROM fm_activities "
- . " $this->join fm_activity_price_index ON
fm_activities.id = fm_activity_price_index.activity_id "
- . " $this->join fm_branch ON fm_activities.branch_id =
fm_branch.id "
- . " $this->join fm_agreement ON
fm_activity_price_index.agreement_id = fm_agreement.id "
- . " WHERE fm_agreement.status='active' AND
(fm_agreement.vendor_id $vendor_condition and current_index is not null "
- . " OR (fm_agreement.vendor_id $vendor_condition) AND
(fm_activity_price_index.this_index IS NULL)) $querymethod";
-
-
-//echo $sql;
-
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $pricebook[] = array
- (
- 'activity_id' =>
$this->db->f('activity_id'),
- 'num' =>
$this->db->f('num'),
- 'branch' =>
$this->db->f('branch'),
- 'vendor_id' =>
$this->db->f('vendor_id'),
- 'm_cost' =>
$this->db->f('m_cost'),
- 'w_cost' =>
$this->db->f('w_cost'),
- 'total_cost' =>
$this->db->f('total_cost'),
- 'this_index' =>
$this->db->f('this_index'),
- 'unit' =>
$this->db->f('unit'),
- 'dim_d' =>
$this->db->f('dim_d'),
- 'ns3420_id' =>
$this->db->f('ns3420'),
- 'descr' =>
stripslashes($this->db->f('descr')),
- 'base_descr' =>
stripslashes($this->db->f('base_descr')),
- 'index_count' =>
$this->db->f('index_count')
- );
- }
-// _debug_array($pricebook);
- return $pricebook;
- }
-
- function read_agreement_group($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by id asc';
- }
-
- $where = 'WHERE';
-
- if ($cat_id)
- {
- $filtermethod .= " $where status='$cat_id' ";
- $where = 'AND';
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " $where (descr $this->like
'%$query%' or num $this->like '%$query%')";
- }
-
- $sql = "SELECT * FROM fm_agreement_group $filtermethod
$querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $agreement_group[] = array
- (
- 'agreement_group_id' =>
$this->db->f('id'),
- 'num' =>
$this->db->f('num'),
- 'status' =>
$this->db->f('status'),
- 'descr' =>
stripslashes($this->db->f('descr'))
- );
- }
-// _debug_array($agreement_group);
- return $agreement_group;
- }
-
- function select_status_list()
- {
- $this->db->query("SELECT id, descr FROM
fm_agreement_status ORDER BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $status_entries[$i]['id']
= $this->db->f('id');
- $status_entries[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $status_entries;
- }
-
-
- function read_activity_prize($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $activity_id =
(isset($data['activity_id'])?$data['activity_id']:0);
- $vendor_id =
(isset($data['vendor_id'])?$data['vendor_id']:0);
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by index_count';
- }
-
- if ($cat_id > 0)
- {
- $filtermethod .= " AND cat_id='$cat_id' ";
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " AND (fm_activities.descr
$this->like '%$query%' or fm_activities.num $this->like '%$query%')";
- }
-
- $sql = "SELECT
index_count,this_index,current_index,m_cost,w_cost,total_cost,index_date"
- . " FROM fm_activity_price_index $this->join
fm_agreement on fm_activity_price_index.agreement_id = fm_agreement.id "
- . " Where activity_id= '$activity_id' and
vendor_id= '$vendor_id'";
-
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $pricebook[] = array
- (
- 'index_count' =>
$this->db->f('index_count'),
- 'this_index' =>
$this->db->f('this_index'),
- 'current_index' =>
$this->db->f('current_index'),
- 'm_cost' =>
$this->db->f('m_cost'),
- 'w_cost' =>
$this->db->f('w_cost'),
- 'total_cost' =>
$this->db->f('total_cost'),
- 'date' =>
$this->db->f('index_date')
- );
- }
-// _debug_array($pricebook);
- return $pricebook;
- }
-
- function read_activities_pr_agreement_group($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = " order by activity_id asc";
- }
-
- if ($cat_id > 0)
- {
- $filtermethod .= " Where
agreement_group_id='$cat_id' ";
- }
- else
- {
- $filtermethod = " Where agreement_group_id IS
NULL";
- }
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
-// $querymethod = " AND (fm_activities.descr
$this->like '%$query%' or fm_activities.num $this->like '%$query%')";
- $querymethod = " and (fm_activities.descr
$this->like '%$query%' or fm_activities.base_descr $this->like '%$query%' or
fm_activities.num $this->like '%$query%') ";
- }
-
- $sql = "SELECT fm_activities.id AS activity_id,
fm_activities.num, fm_activities.base_descr, fm_activities.unit,
fm_activities.dim_d, fm_branch.descr as branch, fm_activities.descr, ns3420 "
- . " FROM fm_activities $this->join fm_branch
on fm_activities.branch_id=fm_branch.id"
- . " $filtermethod $querymethod ";
-
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $pricebook[] = array
- (
- 'activity_id' =>
$this->db->f('activity_id'),
- 'num' =>
$this->db->f('num'),
- 'base_descr' =>
stripslashes($this->db->f('base_descr')),
- 'branch' =>
$this->db->f('branch'),
- 'dim_d' =>
$this->db->f('dim_d'),
- 'ns3420' =>
$this->db->f('ns3420'),
- 'unit' =>
$this->db->f('unit'),
- 'descr' =>
stripslashes($this->db->f('descr'))
- );
- }
-// _debug_array($pricebook);
- return $pricebook;
- }
-
- function read_vendor_pr_activity($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $activity_id =
(isset($data['activity_id'])?$data['activity_id']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = " order by fm_vendor.org_name
asc";
- }
-
- if ($cat_id > 0)
- {
- $filtermethod .= " Where
agreement_group_id='$cat_id' ";
- }
- else
- {
- $filtermethod = " Where agreement_group_id =
''";
- }
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " AND (fm_vendor.org_name
$this->like '%$query%' or vendor_id $this->like '%$query%')";
- }
-
- $sql = "SELECT fm_activities.id as
activity_id,fm_activities.num, fm_vendor.org_name,fm_branch.descr as branch
,fm_activity_price_index.vendor_id "
- . " FROM (fm_activities $this->join
fm_activity_price_index ON fm_activities.id =
fm_activity_price_index.activity_id) "
- . " $this->join fm_agreement ON
fm_activity_price_index.agreement_id = fm_agreement.id "
- . " $this->join fm_vendor ON
fm_agreement.vendor_id = fm_vendor.id "
- . " $this->join fm_branch on fm_branch.id =
fm_activities.branch_id "
- . " Where fm_activity_price_index.activity_id=
'$activity_id' $querymethod group by fm_activities.id,fm_activities.num,"
- . " fm_branch.descr,org_name
,fm_activity_price_index.vendor_id ";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $pricebook[] = array
- (
- 'activity_id' =>
$this->db->f('activity_id'),
- 'num' =>
$this->db->f('num'),
- 'branch' =>
$this->db->f('branch'),
- 'vendor_name' =>
$this->db->f('org_name'),
- 'vendor_id' =>
$this->db->f('vendor_id')
- );
- }
- return $pricebook;
- }
-
- function read_single_activity($id)
- {
- $sql = "SELECT * FROM fm_activities where id='$id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $activity['activity_id']= $id;
- $activity['num'] =
$this->db->f('num');
- $activity['unit'] =
$this->db->f('unit');
- $activity['cat_id'] =
$this->db->f('agreement_group_id');
- $activity['ns3420_id'] =
$this->db->f('ns3420');
- $activity['descr'] =
stripslashes($this->db->f('descr'));
- $activity['base_descr'] =
stripslashes($this->db->f('base_descr'));
- $activity['dim_d'] =
$this->db->f('dim_d');
- $activity['branch_id'] =
$this->db->f('branch_id');
-
- return $activity;
- }
- }
-
- function read_single_agreement_group($id)
- {
- $sql = "SELECT * FROM fm_agreement_group where
id='$id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $agreement_group['agreement_group_id'] = $id;
- $agreement_group['num'] =
$this->db->f('num');
- $agreement_group['status'] =
$this->db->f('status');
- $agreement_group['descr']
= stripslashes($this->db->f('descr'));
-
- return $agreement_group;
- }
- }
-
- function add_activity($values)
- {
- $values['descr'] =
$this->db->db_addslashes($values['descr']);
- $values['base_descr'] =
$this->db->db_addslashes($values['base_descr']);
-
- $vals= array(
- $values['activity_id'],
- $values['num'] ,
- $values['unit'] ,
- $values['cat_id'] , // agreement_group
- $values['ns3420_id'] ,
- $values['dim_d'],
- $values['branch_id'],
- $values['descr'],
- $values['base_descr']
- );
-
- $vals = $this->bocommon->validate_db_insert($vals);
-
- $this->db->transaction_begin();
- $this->db->query("INSERT INTO fm_activities (id,
num,unit,agreement_group_id,ns3420,dim_d,branch_id,descr,base_descr) "
- . "VALUES ($vals)",__LINE__,__FILE__);
- $this->db->transaction_commit();
-
- $receipt['message'][] = array('msg'=>lang('Activity has
been saved'));
- $receipt['activity_id']= $values['activity_id'];
- return $receipt;
- }
-
- function edit_activity($values)
- {
- $values['descr'] =
$this->db->db_addslashes($values['descr']);
- $values['base_descr'] =
$this->db->db_addslashes($values['base_descr']);
-
- $value_set=array(
- 'num' =>
$values['num'],
- 'unit' =>
$values['unit'],
- 'agreement_group_id' => $values['cat_id'],
- 'ns3420' =>
$values['ns3420_id'],
- 'dim_d' =>
$values['dim_d'],
- 'branch_id' =>
$values['branch_id'],
- 'descr' =>
$values['descr'],
- 'base_descr' =>
$values['base_descr']
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
- $this->db->transaction_begin();
- $this->db->query("UPDATE fm_activities set $value_set
WHERE id= '" . $values['activity_id'] . "'",__LINE__,__FILE__);
- $this->db->transaction_commit();
-
- $receipt['activity_id']= $values['activity_id'];
- $receipt['message'][] = array('msg'=>lang('Activity has
been edited'));
- return $receipt;
- }
-
- function add_agreement_group($values)
- {
- $values['descr'] =
$this->db->db_addslashes($values['descr']);
-
- $vals= array(
- $values['agreement_group_id'],
- $values['num'],
- $values['status'],
- $values['descr']
- );
-
- $vals = $this->bocommon->validate_db_insert($vals);
-
- $this->db->query("INSERT INTO fm_agreement_group
(id,num,status,descr) "
- . "VALUES ($vals)",__LINE__,__FILE__);
-
- $receipt['message'][] = array('msg'=>lang('Agreement
group has been saved'));
- $receipt['agreement_group_id'] =
$values['agreement_group_id'];
- return $receipt;
- }
-
- function edit_agreement_group($values)
- {
- $values['descr'] =
$this->db->db_addslashes($values['descr']);
-
- $value_set=array(
- 'num' => $values['num'],
- 'status'=> $values['status'],
- 'descr' => $values['descr']
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
- $this->db->transaction_begin();
-
- $this->db->query("UPDATE fm_agreement_group set
$value_set WHERE id= '" . $values['agreement_group_id'] .
"'",__LINE__,__FILE__);
-
- $this->db->transaction_commit();
-
- $receipt['message'][] =
array('msg'=>lang('Agreement_group has been edited'));
- return $receipt;
- }
-
- function delete_activity_vendor($activity_id,$vendor_id)
- {
- $this->db->query("DELETE FROM fm_activity_price_index
WHERE activity_id='$activity_id' and vendor_id='$vendor_id'",__LINE__,__FILE__);
- }
-
- function delete_activity($activity_id)
- {
- $this->db->query("DELETE FROM fm_activities WHERE
id='$activity_id'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_activity_price_index
WHERE activity_id='$activity_id'",__LINE__,__FILE__);
- }
-
- function
delete_prize_index($activity_id,$vendor_id,$index_count)
- {
- if ($index_count==1)
- {
- $this->db->query("update
fm_activity_price_index set index_count = '1', current_index = '0',
this_index=Null, m_cost=Null,w_cost=Null,total_cost=Null,index_date=Null where
activity_id='$activity_id' and vendor_id= '$vendor_id' and index_count=
'1'",__LINE__,__FILE__);
- }
- else
- {
- $this->db->query("delete from
fm_activity_price_index where activity_id='$activity_id' and vendor_id=
'$vendor_id' and index_count= '$index_count'",__LINE__,__FILE__);
-
- $new_index_count= $index_count -1;
-
- $this->db->query("update
fm_activity_price_index set current_index = '1' where
activity_id='$activity_id' and vendor_id= '$vendor_id' and index_count=
'$new_index_count'",__LINE__,__FILE__);
- }
-
- }
-
- function delete_agreement_group($agreement_group_id)
- {
- $this->db->query("DELETE FROM fm_agreement_group WHERE
id='$agreement_group_id'",__LINE__,__FILE__);
-//how to handle the activities and vendors ...?
- }
-
-
- function add_activity_vendor($values)
- {
- $this->db->query("SELECT count(*) FROM
fm_activity_price_index WHERE activity_id='" . $values['activity_id'] . "' and
vendor_id='" . $values['vendor_id'] . "'",__LINE__,__FILE__);
-
- $this->db->next_record();
-
- if ( $this->db->f(0))
- {
- $receipt['error'][] = array('msg'=>lang('This
Vendor is already registered for this activity'));
- }
- else
- {
- $this->db->query("insert into
fm_activity_price_index (activity_id, vendor_id,
index_count,current_index,m_cost,w_cost,total_cost) "
- . " values ('" .
- $values['activity_id']. "','" .
- $values['vendor_id'].
"','1','0',NULL,NULL,NULL)",__LINE__,__FILE__);
-
- $receipt['message'][] =
array('msg'=>lang('Vendor has been added'));
-
- }
- return $receipt;
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage agreement
+ * @version $Id: class.sopricebook.inc.php,v 1.13 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class sopricebook
+ {
+
+ function sopricebook()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->like = $this->bocommon->like;
+ }
+
+ function
add_activity_first_prize($m_cost,$w_cost,$total_cost,$activity_id,$vendor_id,$date)
+ {
+ $this->db->query("update fm_activity_price_index set
index_count='1',this_index='1',
m_cost='$m_cost',w_cost='$w_cost',total_cost='$total_cost',index_date='$date',current_index='1'
where activity_id='$activity_id' and vendor_id= '$vendor_id' and index_count=
'1'",__LINE__,__FILE__);
+
+ $receipt['message'][] = array('msg'=>lang('First entry
is added!'));
+
+ return $receipt;
+ }
+
+ function update_pricebook($update)
+ {
+ for ($i=0; $i<count($update); $i++)
+ {
+ $this->db->query("select max(index_count) as
max_index_count from fm_activity_price_index Where activity_id='".
$update[$i]['activity_id'] . "' and vendor_id='".$update[$i]['vendor_id'] .
"'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $next_index_count =
$this->db->f('max_index_count')+1;
+
+ $this->db->query("update
fm_activity_price_index set current_index = Null"
+ . " WHERE activity_id='" .
$update[$i]['activity_id'] . "' and vendor_id='" . $update[$i]['vendor_id'] .
"'",__LINE__,__FILE__);
+
+ $this->db->query("insert into
fm_activity_price_index (activity_id, vendor_id, index_count, this_index,
m_cost, w_cost, total_cost, index_date,current_index) "
+ . " values ('" .
+ $update[$i]['activity_id'] . "','" .
+ $update[$i]['vendor_id'] . "','" .
+ $next_index_count . "','" .
+ $update[$i]['new_index'] . "','" .
+ $update[$i]['new_m_cost'] . "','" .
+ $update[$i]['new_w_cost'] . "','" .
+ $update[$i]['new_total_cost'] . "','" .
+ $update[$i]['new_date']. "',
'1')",__LINE__,__FILE__);
+ }
+
+ $receipt['message'][] = array('msg'=>lang('%1 entries
is updated!',$i));
+
+ return $receipt;
+
+ }
+
+ function get_vendor_list()
+ {
+ $this->db->query("SELECT fm_vendor.org_name ,vendor_id "
+ . " FROM fm_agreement $this->join fm_vendor ON
fm_agreement.vendor_id = fm_vendor.id "
+ . " WHERE fm_agreement.status='active'"
+ . " GROUP by fm_vendor.org_name ,vendor_id "
+ . " ORDER BY fm_vendor.org_name
",__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+//--------->fix this------->
+ if($this->db->f('vendor_id'))
+ {
+ $vendor_list[]=array
+ (
+ 'id' =>
$this->db->f('vendor_id'),
+ 'name' =>
$this->db->f('org_name')
+ );
+ }
+ }
+ return $vendor_list;
+ }
+
+ function get_agreement_group_list()
+ {
+ $this->db->query("SELECT * FROM fm_agreement_group
ORDER BY descr asc");
+ while ($this->db->next_record())
+ {
+ $agreement_group_list[]=array
+ (
+ 'id' => $this->db->f('id'),
+ 'name' =>
$GLOBALS['phpgw']->strip_html($this->db->f('descr')).' [ '.
$GLOBALS['phpgw']->strip_html($this->db->f('status')).' ] '
+ );
+ }
+ return $agreement_group_list;
+ }
+
+ function get_dim_d_list()
+ {
+ $this->db->query("SELECT * FROM fm_dim_d ORDER BY descr
asc");
+ while ($this->db->next_record())
+ {
+ $dim_d_list[]=array
+ (
+ 'id' => $this->db->f('id'),
+ 'name' => $this->db->f('id')
+ );
+ }
+ return $dim_d_list;
+ }
+
+ function get_unit_list()
+ {
+ $this->db->query("SELECT * FROM fm_standard_unit ORDER
BY descr asc");
+ while ($this->db->next_record())
+ {
+ $unit_list[]=array
+ (
+ 'id' => $this->db->f('id'),
+ 'name' =>
$GLOBALS['phpgw']->strip_html($this->db->f('descr'))
+ );
+ }
+ return $unit_list;
+ }
+
+ function get_branch_list()
+ {
+ $this->db->query("SELECT * FROM fm_branch ORDER BY
descr asc");
+ while ($this->db->next_record())
+ {
+ $branch_list[]=array
+ (
+ 'id' => $this->db->f('id'),
+ 'name' =>
$GLOBALS['phpgw']->strip_html($this->db->f('descr'))
+ );
+ }
+ return $branch_list;
+ }
+
+ function check_activity_num($num='',$agreement_group_id='')
+ {
+ $this->db->query("SELECT count(*) FROM fm_activities
where num='$num' and agreement_group_id ='$agreement_group_id'");
+
+ $this->db->next_record();
+
+ if ( $this->db->f(0))
+ {
+ return True;
+ }
+ }
+
+ function check_agreement_group_num($num='')
+ {
+ $this->db->query("SELECT count(*) FROM
fm_agreement_group where num='$num'");
+
+ $this->db->next_record();
+
+ if ( $this->db->f(0))
+ {
+ return True;
+ }
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ }
+
+//_debug_array($data);
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by activity_id';
+ }
+
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " AND cat_id='$cat_id' ";
+ $vendor_condition= "= $cat_id";
+ }
+ else
+ {
+ $vendor_condition= " IS NULL";
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " AND (fm_activities.descr
$this->like '%$query%' or fm_activities.num $this->like '%$query%')";
+ }
+
+
+ $sql = "SELECT fm_activities.num, fm_activities.unit,
fm_activities.dim_d, fm_activities.ns3420, fm_activities.descr AS descr,"
+ . " fm_activities.base_descr,
fm_activity_price_index.activity_id, fm_branch.descr AS branch,"
+ . " fm_agreement.vendor_id,
fm_activity_price_index.total_cost, fm_activity_price_index.m_cost,"
+ . " fm_activity_price_index.w_cost,
fm_activity_price_index.index_count, fm_activity_price_index.this_index,
fm_agreement.id"
+ . " FROM fm_activities "
+ . " $this->join fm_activity_price_index ON
fm_activities.id = fm_activity_price_index.activity_id "
+ . " $this->join fm_branch ON fm_activities.branch_id =
fm_branch.id "
+ . " $this->join fm_agreement ON
fm_activity_price_index.agreement_id = fm_agreement.id "
+ . " WHERE fm_agreement.status='active' AND
(fm_agreement.vendor_id $vendor_condition and current_index is not null "
+ . " OR (fm_agreement.vendor_id $vendor_condition) AND
(fm_activity_price_index.this_index IS NULL)) $querymethod";
+
+
+//echo $sql;
+
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $pricebook[] = array
+ (
+ 'activity_id' =>
$this->db->f('activity_id'),
+ 'num' =>
$this->db->f('num'),
+ 'branch' =>
$this->db->f('branch'),
+ 'vendor_id' =>
$this->db->f('vendor_id'),
+ 'm_cost' =>
$this->db->f('m_cost'),
+ 'w_cost' =>
$this->db->f('w_cost'),
+ 'total_cost' =>
$this->db->f('total_cost'),
+ 'this_index' =>
$this->db->f('this_index'),
+ 'unit' =>
$this->db->f('unit'),
+ 'dim_d' =>
$this->db->f('dim_d'),
+ 'ns3420_id' =>
$this->db->f('ns3420'),
+ 'descr' =>
stripslashes($this->db->f('descr')),
+ 'base_descr' =>
stripslashes($this->db->f('base_descr')),
+ 'index_count' =>
$this->db->f('index_count')
+ );
+ }
+// _debug_array($pricebook);
+ return $pricebook;
+ }
+
+ function read_agreement_group($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by id asc';
+ }
+
+ $where = 'WHERE';
+
+ if ($cat_id)
+ {
+ $filtermethod .= " $where status='$cat_id' ";
+ $where = 'AND';
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " $where (descr $this->like
'%$query%' or num $this->like '%$query%')";
+ }
+
+ $sql = "SELECT * FROM fm_agreement_group $filtermethod
$querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $agreement_group[] = array
+ (
+ 'agreement_group_id' =>
$this->db->f('id'),
+ 'num' =>
$this->db->f('num'),
+ 'status' =>
$this->db->f('status'),
+ 'descr' =>
stripslashes($this->db->f('descr'))
+ );
+ }
+// _debug_array($agreement_group);
+ return $agreement_group;
+ }
+
+ function select_status_list()
+ {
+ $this->db->query("SELECT id, descr FROM
fm_agreement_status ORDER BY id ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $status_entries[$i]['id']
= $this->db->f('id');
+ $status_entries[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $status_entries;
+ }
+
+
+ function read_activity_prize($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $activity_id =
(isset($data['activity_id'])?$data['activity_id']:0);
+ $vendor_id =
(isset($data['vendor_id'])?$data['vendor_id']:0);
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by index_count';
+ }
+
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " AND cat_id='$cat_id' ";
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " AND (fm_activities.descr
$this->like '%$query%' or fm_activities.num $this->like '%$query%')";
+ }
+
+ $sql = "SELECT
index_count,this_index,current_index,m_cost,w_cost,total_cost,index_date"
+ . " FROM fm_activity_price_index $this->join
fm_agreement on fm_activity_price_index.agreement_id = fm_agreement.id "
+ . " Where activity_id= '$activity_id' and
vendor_id= '$vendor_id'";
+
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $pricebook[] = array
+ (
+ 'index_count' =>
$this->db->f('index_count'),
+ 'this_index' =>
$this->db->f('this_index'),
+ 'current_index' =>
$this->db->f('current_index'),
+ 'm_cost' =>
$this->db->f('m_cost'),
+ 'w_cost' =>
$this->db->f('w_cost'),
+ 'total_cost' =>
$this->db->f('total_cost'),
+ 'date' =>
$this->db->f('index_date')
+ );
+ }
+// _debug_array($pricebook);
+ return $pricebook;
+ }
+
+ function read_activities_pr_agreement_group($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = " order by activity_id asc";
+ }
+
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " Where
agreement_group_id='$cat_id' ";
+ }
+ else
+ {
+ $filtermethod = " Where agreement_group_id IS
NULL";
+ }
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+// $querymethod = " AND (fm_activities.descr
$this->like '%$query%' or fm_activities.num $this->like '%$query%')";
+ $querymethod = " and (fm_activities.descr
$this->like '%$query%' or fm_activities.base_descr $this->like '%$query%' or
fm_activities.num $this->like '%$query%') ";
+ }
+
+ $sql = "SELECT fm_activities.id AS activity_id,
fm_activities.num, fm_activities.base_descr, fm_activities.unit,
fm_activities.dim_d, fm_branch.descr as branch, fm_activities.descr, ns3420 "
+ . " FROM fm_activities $this->join fm_branch
on fm_activities.branch_id=fm_branch.id"
+ . " $filtermethod $querymethod ";
+
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $pricebook[] = array
+ (
+ 'activity_id' =>
$this->db->f('activity_id'),
+ 'num' =>
$this->db->f('num'),
+ 'base_descr' =>
stripslashes($this->db->f('base_descr')),
+ 'branch' =>
$this->db->f('branch'),
+ 'dim_d' =>
$this->db->f('dim_d'),
+ 'ns3420' =>
$this->db->f('ns3420'),
+ 'unit' =>
$this->db->f('unit'),
+ 'descr' =>
stripslashes($this->db->f('descr'))
+ );
+ }
+// _debug_array($pricebook);
+ return $pricebook;
+ }
+
+ function read_vendor_pr_activity($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $activity_id =
(isset($data['activity_id'])?$data['activity_id']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = " order by fm_vendor.org_name
asc";
+ }
+
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " Where
agreement_group_id='$cat_id' ";
+ }
+ else
+ {
+ $filtermethod = " Where agreement_group_id =
''";
+ }
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " AND (fm_vendor.org_name
$this->like '%$query%' or vendor_id $this->like '%$query%')";
+ }
+
+ $sql = "SELECT fm_activities.id as
activity_id,fm_activities.num, fm_vendor.org_name,fm_branch.descr as branch
,fm_activity_price_index.vendor_id "
+ . " FROM (fm_activities $this->join
fm_activity_price_index ON fm_activities.id =
fm_activity_price_index.activity_id) "
+ . " $this->join fm_agreement ON
fm_activity_price_index.agreement_id = fm_agreement.id "
+ . " $this->join fm_vendor ON
fm_agreement.vendor_id = fm_vendor.id "
+ . " $this->join fm_branch on fm_branch.id =
fm_activities.branch_id "
+ . " Where fm_activity_price_index.activity_id=
'$activity_id' $querymethod group by fm_activities.id,fm_activities.num,"
+ . " fm_branch.descr,org_name
,fm_activity_price_index.vendor_id ";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $pricebook[] = array
+ (
+ 'activity_id' =>
$this->db->f('activity_id'),
+ 'num' =>
$this->db->f('num'),
+ 'branch' =>
$this->db->f('branch'),
+ 'vendor_name' =>
$this->db->f('org_name'),
+ 'vendor_id' =>
$this->db->f('vendor_id')
+ );
+ }
+ return $pricebook;
+ }
+
+ function read_single_activity($id)
+ {
+ $sql = "SELECT * FROM fm_activities where id='$id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $activity['activity_id']= $id;
+ $activity['num'] =
$this->db->f('num');
+ $activity['unit'] =
$this->db->f('unit');
+ $activity['cat_id'] =
$this->db->f('agreement_group_id');
+ $activity['ns3420_id'] =
$this->db->f('ns3420');
+ $activity['descr'] =
stripslashes($this->db->f('descr'));
+ $activity['base_descr'] =
stripslashes($this->db->f('base_descr'));
+ $activity['dim_d'] =
$this->db->f('dim_d');
+ $activity['branch_id'] =
$this->db->f('branch_id');
+
+ return $activity;
+ }
+ }
+
+ function read_single_agreement_group($id)
+ {
+ $sql = "SELECT * FROM fm_agreement_group where
id='$id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $agreement_group['agreement_group_id'] = $id;
+ $agreement_group['num'] =
$this->db->f('num');
+ $agreement_group['status'] =
$this->db->f('status');
+ $agreement_group['descr']
= stripslashes($this->db->f('descr'));
+
+ return $agreement_group;
+ }
+ }
+
+ function add_activity($values)
+ {
+ $values['descr'] =
$this->db->db_addslashes($values['descr']);
+ $values['base_descr'] =
$this->db->db_addslashes($values['base_descr']);
+
+ $vals= array(
+ $values['activity_id'],
+ $values['num'] ,
+ $values['unit'] ,
+ $values['cat_id'] , // agreement_group
+ $values['ns3420_id'] ,
+ $values['dim_d'],
+ $values['branch_id'],
+ $values['descr'],
+ $values['base_descr']
+ );
+
+ $vals = $this->bocommon->validate_db_insert($vals);
+
+ $this->db->transaction_begin();
+ $this->db->query("INSERT INTO fm_activities (id,
num,unit,agreement_group_id,ns3420,dim_d,branch_id,descr,base_descr) "
+ . "VALUES ($vals)",__LINE__,__FILE__);
+ $this->db->transaction_commit();
+
+ $receipt['message'][] = array('msg'=>lang('Activity has
been saved'));
+ $receipt['activity_id']= $values['activity_id'];
+ return $receipt;
+ }
+
+ function edit_activity($values)
+ {
+ $values['descr'] =
$this->db->db_addslashes($values['descr']);
+ $values['base_descr'] =
$this->db->db_addslashes($values['base_descr']);
+
+ $value_set=array(
+ 'num' =>
$values['num'],
+ 'unit' =>
$values['unit'],
+ 'agreement_group_id' => $values['cat_id'],
+ 'ns3420' =>
$values['ns3420_id'],
+ 'dim_d' =>
$values['dim_d'],
+ 'branch_id' =>
$values['branch_id'],
+ 'descr' =>
$values['descr'],
+ 'base_descr' =>
$values['base_descr']
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+ $this->db->transaction_begin();
+ $this->db->query("UPDATE fm_activities set $value_set
WHERE id= '" . $values['activity_id'] . "'",__LINE__,__FILE__);
+ $this->db->transaction_commit();
+
+ $receipt['activity_id']= $values['activity_id'];
+ $receipt['message'][] = array('msg'=>lang('Activity has
been edited'));
+ return $receipt;
+ }
+
+ function add_agreement_group($values)
+ {
+ $values['descr'] =
$this->db->db_addslashes($values['descr']);
+
+ $vals= array(
+ $values['agreement_group_id'],
+ $values['num'],
+ $values['status'],
+ $values['descr']
+ );
+
+ $vals = $this->bocommon->validate_db_insert($vals);
+
+ $this->db->query("INSERT INTO fm_agreement_group
(id,num,status,descr) "
+ . "VALUES ($vals)",__LINE__,__FILE__);
+
+ $receipt['message'][] = array('msg'=>lang('Agreement
group has been saved'));
+ $receipt['agreement_group_id'] =
$values['agreement_group_id'];
+ return $receipt;
+ }
+
+ function edit_agreement_group($values)
+ {
+ $values['descr'] =
$this->db->db_addslashes($values['descr']);
+
+ $value_set=array(
+ 'num' => $values['num'],
+ 'status'=> $values['status'],
+ 'descr' => $values['descr']
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+ $this->db->transaction_begin();
+
+ $this->db->query("UPDATE fm_agreement_group set
$value_set WHERE id= '" . $values['agreement_group_id'] .
"'",__LINE__,__FILE__);
+
+ $this->db->transaction_commit();
+
+ $receipt['message'][] =
array('msg'=>lang('Agreement_group has been edited'));
+ return $receipt;
+ }
+
+ function delete_activity_vendor($activity_id,$vendor_id)
+ {
+ $this->db->query("DELETE FROM fm_activity_price_index
WHERE activity_id='$activity_id' and vendor_id='$vendor_id'",__LINE__,__FILE__);
+ }
+
+ function delete_activity($activity_id)
+ {
+ $this->db->query("DELETE FROM fm_activities WHERE
id='$activity_id'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_activity_price_index
WHERE activity_id='$activity_id'",__LINE__,__FILE__);
+ }
+
+ function
delete_prize_index($activity_id,$vendor_id,$index_count)
+ {
+ if ($index_count==1)
+ {
+ $this->db->query("update
fm_activity_price_index set index_count = '1', current_index = '0',
this_index=Null, m_cost=Null,w_cost=Null,total_cost=Null,index_date=Null where
activity_id='$activity_id' and vendor_id= '$vendor_id' and index_count=
'1'",__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query("delete from
fm_activity_price_index where activity_id='$activity_id' and vendor_id=
'$vendor_id' and index_count= '$index_count'",__LINE__,__FILE__);
+
+ $new_index_count= $index_count -1;
+
+ $this->db->query("update
fm_activity_price_index set current_index = '1' where
activity_id='$activity_id' and vendor_id= '$vendor_id' and index_count=
'$new_index_count'",__LINE__,__FILE__);
+ }
+
+ }
+
+ function delete_agreement_group($agreement_group_id)
+ {
+ $this->db->query("DELETE FROM fm_agreement_group WHERE
id='$agreement_group_id'",__LINE__,__FILE__);
+//how to handle the activities and vendors ...?
+ }
+
+
+ function add_activity_vendor($values)
+ {
+ $this->db->query("SELECT count(*) FROM
fm_activity_price_index WHERE activity_id='" . $values['activity_id'] . "' and
vendor_id='" . $values['vendor_id'] . "'",__LINE__,__FILE__);
+
+ $this->db->next_record();
+
+ if ( $this->db->f(0))
+ {
+ $receipt['error'][] = array('msg'=>lang('This
Vendor is already registered for this activity'));
+ }
+ else
+ {
+ $this->db->query("insert into
fm_activity_price_index (activity_id, vendor_id,
index_count,current_index,m_cost,w_cost,total_cost) "
+ . " values ('" .
+ $values['activity_id']. "','" .
+ $values['vendor_id'].
"','1','0',NULL,NULL,NULL)",__LINE__,__FILE__);
+
+ $receipt['message'][] =
array('msg'=>lang('Vendor has been added'));
+
+ }
+ return $receipt;
+ }
+ }
+?>
Index: property/inc/class.soproject.inc.php
diff -u property/inc/class.soproject.inc.php:1.24
property/inc/class.soproject.inc.php:1.25
--- property/inc/class.soproject.inc.php:1.24 Mon Sep 12 08:19:02 2005
+++ property/inc/class.soproject.inc.php Fri Jan 27 14:05:43 2006
@@ -1,931 +1,930 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage project
- * @version $Id: class.soproject.inc.php,v 1.24 2005/09/12 08:19:02
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class soproject
- {
-
- function soproject()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->join = $this->bocommon->join;
- $this->left_join = $this->bocommon->left_join;
- $this->like = $this->bocommon->like;
-
- $this->grants =
$GLOBALS['phpgw']->session->appsession('grants_project',$this->currentapp);
-
- if(!$this->grants)
- {
- $this->acl2 =
CreateObject($this->currentapp.'.acl2','##DEFAULT##','##DEFAULT##');
- $this->grants =
$this->acl2->get_grants($this->currentapp,'.project');
-
$GLOBALS['phpgw']->session->appsession('grants_project',$this->currentapp,$this->grants);
- }
- }
-
-
- function select_category_workorder_list()
- {
-
- $this->db->query("SELECT id, descr FROM
fm_workorder_category ORDER BY descr ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $categories[$i]['id']
= $this->db->f('id');
- $categories[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $categories;
- }
-
- function read_single_project_category($id='')
- {
- $this->db->query("SELECT descr FROM
fm_workorder_category where id='$id' ");
- $this->db->next_record();
- return $this->db->f('descr');
- }
-
- function select_status_list()
- {
- $this->db->query("SELECT id, descr FROM
fm_workorder_status ORDER BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $status_entries[$i]['id']
= $this->db->f('id');
- $status_entries[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $status_entries;
- }
-
- function select_branch_list()
- {
- $this->db->query("SELECT id, descr FROM fm_branch ORDER
BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $branch_entries[$i]['id']
= $this->db->f('id');
- $branch_entries[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $branch_entries;
- }
-
- function select_key_location_list()
- {
- $this->db->query("SELECT id, descr FROM fm_key_loc
ORDER BY descr ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $key_location_entries[$i]['id']
= $this->db->f('id');
- $key_location_entries[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $key_location_entries;
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
$data['filter']?$data['filter']:$this->account;
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $status_id =
(isset($data['status_id'])?$data['status_id']:'');
- $start_date =
(isset($data['start_date'])?$data['start_date']:'');
- $end_date =
(isset($data['end_date'])?$data['end_date']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $wo_hour_cat_id =
(isset($data['wo_hour_cat_id'])?$data['wo_hour_cat_id']:'');
- }
-
- $sql = $this->bocommon->fm_cache('sql_project_' .
!!$wo_hour_cat_id);
-
- if(!$sql)
- {
- $entity_table = 'fm_project';
-
- $cols .= $entity_table . '.location_code';
- $cols_return[] = 'location_code';
-
- $cols .= ",$entity_table.id as project_id";
- $cols_return[] =
'project_id';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'project_id';
- $uicols['descr'][] =
lang('Project');
- $uicols['statustext'][] = lang('Project
ID');
-
- $cols.= ",$entity_table.start_date";
- $cols_return[] =
'start_date';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'start_date';
- $uicols['descr'][] =
lang('start date');
- $uicols['statustext'][] = lang('Project
start date');
-
- $cols.= ",$entity_table.name as name";
- $cols_return[] =
'name';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'name';
- $uicols['descr'][] =
lang('name');
- $uicols['statustext'][] = lang('Project
name');
-
- $cols.= ",account_lid as coordinator";
- $cols_return[] =
'coordinator';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'coordinator';
- $uicols['descr'][] =
lang('Coordinator');
- $uicols['statustext'][] = lang('Project
coordinator');
-
- $cols.= ",$entity_table.user_id";
-
- $joinmethod .= " $this->join phpgw_accounts ON
($entity_table.coordinator = phpgw_accounts.account_id))";
- $paranthesis .='(';
-
- //----- wo_hour_status
-
- if($wo_hour_cat_id)
- {
- $joinmethod .= " $this->join
fm_workorder ON ($entity_table.id = fm_workorder.project_id))";
- $paranthesis .='(';
-
- $joinmethod .= " $this->join
fm_wo_hours ON (fm_workorder.id = fm_wo_hours.workorder_id))";
- $paranthesis .='(';
-
- $joinmethod .= " $this->join
fm_wo_hours_category ON (fm_wo_hours.category = fm_wo_hours_category.id))";
- $paranthesis .='(';
- }
-
- //----- wo_hour_status
-
- $sql =
$this->bocommon->generate_sql(array('entity_table'=>$entity_table,'cols'=>$cols,'cols_return'=>$cols_return,
-
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query));
-
- $this->bocommon->fm_cache('sql_project_' .
!!$wo_hour_cat_id,$sql);
-
- $this->uicols =
$this->bocommon->uicols;
- $cols_return =
$this->bocommon->cols_return;
- $type_id =
$this->bocommon->type_id;
- $this->cols_extra =
$this->bocommon->cols_extra;
-
- $this->bocommon->fm_cache('uicols_project_' .
!!$wo_hour_cat_id,$this->uicols);
-
$this->bocommon->fm_cache('cols_return_project_' .
!!$wo_hour_cat_id,$cols_return);
- $this->bocommon->fm_cache('type_id_project_' .
!!$wo_hour_cat_id,$type_id);
- $this->bocommon->fm_cache('cols_extra_project_'
. !!$wo_hour_cat_id,$this->cols_extra);
-
- }
- else
- {
- $this->uicols =
$this->bocommon->fm_cache('uicols_project_' . !!$wo_hour_cat_id);
- $cols_return =
$this->bocommon->fm_cache('cols_return_project_' . !!$wo_hour_cat_id);
- $type_id =
$this->bocommon->fm_cache('type_id_project_' . !!$wo_hour_cat_id);
- $this->cols_extra =
$this->bocommon->fm_cache('cols_extra_project_' . !!$wo_hour_cat_id);
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by fm_project.id DESC';
- }
-
- $where= 'WHERE';
-
- if ($cat_id > 0)
- {
- $filtermethod .= " $where
fm_project.category=$cat_id ";
- $where= 'AND';
- }
-
- if ($status_id)
- {
- $filtermethod .= " $where
fm_project.status='$status_id' ";
- $where= 'AND';
- }
-
- if($wo_hour_cat_id)
- {
- $filtermethod .= " $where
fm_wo_hours_category.id=$wo_hour_cat_id ";
- $where= 'AND';
- $group_method = " group by
fm_project.location_code,fm_project.id
,fm_project.start_date,fm_project.name,account_lid
,fm_project.user_id,fm_project.address";
- }
-
- if ($filter=='all')
- {
- if (is_array($this->grants))
- {
- $grants = $this->grants;
- while (list($user) = each($grants))
- {
- $public_user_list[] = $user;
- }
- reset($public_user_list);
- $filtermethod .= " $where
(fm_project.coordinator IN(" . implode(',',$public_user_list) . "))";
-
- $where= 'AND';
- }
- }
- else
- {
- $filtermethod .= " $where
fm_project.coordinator=$filter ";
- $where= 'AND';
- }
-
- if ($start_date)
- {
- $filtermethod .= " $where fm_project.start_date
>= $start_date AND fm_project.start_date <= $end_date ";
- $where= 'AND';
- }
-
-
- if($query)
- {
- $query = str_replace(",",'.',$query);
- if(stristr($query, '.'))
- {
- $query=explode(".",$query);
- $querymethod = " $where
(fm_project.loc1='" . $query[0] . "' AND fm_project.loc".$type_id."='" .
$query[1] . "')";
- }
- else
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
- $querymethod = " $where
(fm_project.name $this->like '%$query%' or fm_project.address $this->like
'%$query%' or fm_project.location_code $this->like '%$query%' or fm_project.id
$this->like '%$query%')";
- }
- }
-
- $sql .= " $filtermethod $querymethod $group_method";
-//echo $sql;
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- $j=0;
- $k=count($cols_return);
- while ($this->db->next_record())
- {
- for ($i=0;$i<$k;$i++)
- {
- $project_list[$j][$cols_return[$i]] =
stripslashes($this->db->f($cols_return[$i]));
- $project_list[$j]['grants'] =
(int)$this->grants[$this->db->f('user_id')];
- }
-
- $location_code= $this->db->f('location_code');
- $location = split('-',$location_code);
- $n=count($location);
- for ($m=0;$m<$n;$m++)
- {
- $project_list[$j]['loc' . ($m+1)] =
$location[$m];
-
$project_list[$j]['query_location']['loc' . ($m+1)]=implode("-",
array_slice($location, 0, ($m+1)));
- }
-
- $j++;
- }
-
-//_debug_array($project_list);
- return $project_list;
- }
-
- function read_single($project_id)
- {
- $config = CreateObject('phpgwapi.config','property');
- $config->read_repository();
- $meter_table = $config->config_data['meter_table'];
-
- $sql = "SELECT * from fm_project where
id='$project_id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $project['project_id'] =
$this->db->f('id');
- $project['title'] =
$this->db->f('title');
- $project['name'] =
$this->db->f('name');
- $project['location_code'] =
$this->db->f('location_code');
- $project['key_fetch'] =
$this->db->f('key_fetch');
- $project['key_deliver'] =
$this->db->f('key_deliver');
- $project['other_branch'] =
$this->db->f('other_branch');
- $project['key_responsible'] =
$this->db->f('key_responsible');
- $project['descr'] =
$this->db->f('descr');
- $project['status'] =
$this->db->f('status');
- $project['budget'] =
(int)$this->db->f('budget');
- $project['reserve'] =
(int)$this->db->f('reserve');
- $project['tenant_id'] =
$this->db->f('tenant_id');
- $project['user_id'] =
$this->db->f('user_id');
- $project['coordinator'] =
$this->db->f('coordinator');
- $project['access'] =
$this->db->f('access');
- $project['start_date'] =
$this->db->f('start_date');
- $project['end_date'] =
$this->db->f('end_date');
- $project['cat_id'] =
$this->db->f('category');
- $project['grants'] =
(int)$this->grants[$this->db->f('user_id')];
- $project['p_num'] =
$this->db->f('p_num');
- $project['p_entity_id'] =
$this->db->f('p_entity_id');
- $project['p_cat_id'] =
$this->db->f('p_cat_id');
- $project['contact_phone'] =
$this->db->f('contact_phone');
-
-
- if($meter_table)
- {
- $project['power_meter'] =
$this->get_power_meter($this->db->f('location_code'),$meter_table);
- }
- }
-
- $sql = "SELECT * FROM fm_origin WHERE destination =
'project' AND destination_id='$project_id' ORDER by origin DESC ";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- $i=-1;
- while ($this->db->next_record())
- {
- if($last_type != $this->db->f('origin'))
- {
- $i++;
- }
- $project['origin'][$i]['type'] =
$this->db->f('origin');
- $project['origin'][$i]['link'] =
$this->bocommon->get_origin_link($this->db->f('origin'));
- $project['origin'][$i]['data'][]= array(
- 'id'=> $this->db->f('origin_id'),
- 'type'=> $this->db->f('origin')
- );
-
- $last_type=$this->db->f('origin');
- }
-
-//_debug_array($project);
- return $project;
- }
-
- function get_ticket($project_id = '')
- {
- $sql = "SELECT * FROM fm_origin WHERE origin ='tts' AND
destination = 'project' AND destination_id='$project_id' ORDER by origin DESC
";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- return $this->db->f('origin_id');
- }
-
- function get_power_meter($location_code = '',$meter_table='')
- {
- if(!$meter_table)
- {
- $config =
CreateObject('phpgwapi.config','property');
- $config->read_repository();
- $meter_table =
$config->config_data['meter_table'];
- }
-
- $this->db2->query("SELECT ext_meter_id as power_meter
FROM $meter_table where location_code='$location_code' and
category='1'",__LINE__,__FILE__);
-
- $this->db2->next_record();
-
- return $this->db2->f('power_meter');
- }
-
- function project_workorder_data($project_id = '')
- {
- $this->db->query("SELECT act_mtrl_cost,
act_vendor_cost, budget, id as workorder_id, vendor_id,
calculation,rig_addition,addition,deviation,charge_tenant from fm_workorder
where project_id='$project_id'");
- while ($this->db->next_record())
- {
- $budget[] = array(
- 'workorder_id' =>
$this->db->f('workorder_id'),
- 'budget' =>
$this->db->f('budget'),
- 'deviation' =>
$this->db->f('deviation'),
- 'calculation' =>
($this->db->f('calculation')*(1+$this->db->f('addition')/100))+$this->db->f('rig_addition'),
- 'vendor_id' =>
$this->db->f('vendor_id'),
- 'act_mtrl_cost' =>
$this->db->f('act_mtrl_cost'),
- 'act_vendor_cost' =>
$this->db->f('act_vendor_cost'),
- 'charge_tenant' =>
$this->db->f('charge_tenant')
- );
- }
- return $budget;
- }
-
- function branch_p_list($project_id = '')
- {
-
- $this->db2->query("SELECT branch_id from
fm_projectbranch WHERE project_id=" . (int)$project_id ,__LINE__,__FILE__);
- while ($this->db2->next_record())
- {
- $selected[] = array('branch_id' =>
$this->db2->f('branch_id'));
- }
-
- return $selected;
- }
-
- function increment_project_id()
- {
- $this->db->query("update fm_idgenerator set value =
value + 1 where name = 'project'");
- }
-
- function next_project_id()
- {
- $this->db->query("select value from fm_idgenerator
where name = 'project'");
- $this->db->next_record();
- $project_id = $this->db->f('value')+1;
- return $project_id;
- }
-
- function add($project)
- {
- $historylog =
CreateObject($this->currentapp.'.historylog','project');
-
- while (is_array($project['location']) &&
list($input_name,$value) = each($project['location']))
- {
- if($value)
- {
- $cols[] = $input_name;
- $vals[] = $value;
- }
- }
-
- while (is_array($project['extra']) &&
list($input_name,$value) = each($project['extra']))
- {
- if($value)
- {
- $cols[] = $input_name;
- $vals[] = $value;
- }
- }
-
- if($cols)
- {
- $cols = "," . implode(",", $cols);
- $vals = ",'" . implode("','", $vals) . "'";
- }
-
- if($project['street_name'])
- {
- $address[]= $project['street_name'];
- $address[]= $project['street_number'];
- $address = $this->db->db_addslashes(implode("
", $address));
- }
-
- if(!$address)
- {
- $address =
$this->db->db_addslashes($project['location_name']);
- }
-
- $project['descr'] =
$this->db->db_addslashes($project['descr']);
- $project['name'] =
$this->db->db_addslashes($project['name']);
-
- $values= array(
- $project['project_id'],
- $project['name'],
- 'public',
- $project['cat_id'],
- time(),
- $project['start_date'],
- $project['end_date'],
- $project['coordinator'],
- $project['status'],
- $project['descr'],
- $project['budget'],
- $project['reserve'],
- $project['location_code'],
- $address,
- $project['key_deliver'],
- $project['key_fetch'],
- $project['other_branch'],
- $project['key_responsible'],
- $this->account);
-
- $values = $this->bocommon->validate_db_insert($values);
-
- $this->db->transaction_begin();
-
- $this->db->query("INSERT INTO fm_project
(id,name,access,category,entry_date,start_date,end_date,coordinator,status,"
- .
"descr,budget,reserve,location_code,address,key_deliver,key_fetch,other_branch,key_responsible,user_id
$cols) "
- . "VALUES ($values $vals )",__LINE__,__FILE__);
-
- if($project['extra']['contact_phone'] &&
$project['extra']['tenant_id'])
- {
- $this->db->query("update fm_tenant set
contact_phone='". $project['extra']['contact_phone']. "' where id='".
$project['extra']['tenant_id']. "'",__LINE__,__FILE__);
- }
-
- $config = CreateObject('phpgwapi.config','property');
- $config->read_repository();
- $meter_table = $config->config_data['meter_table'];
-
- if ($project['power_meter'] && $meter_table)
- {
-
$this->update_power_meter($project['power_meter'],$project['location_code'],$address,$meter_table);
- }
-
- if (count($project['branch']) != 0)
- {
- while($branch=each($project['branch']))
- {
- $this->db->query("insert into
fm_projectbranch (project_id,branch_id) values ('" . $project['project_id'].
"','$branch[1]')",__LINE__,__FILE__);
- }
- }
-
- if($project['origin'][0]['data'][0]['id'])
- {
- $this->db->query("INSERT INTO fm_origin
(origin,origin_id,destination,destination_id,user_id,entry_date) "
- . "VALUES ('"
- . $project['origin'][0]['type']. "','"
- .
$project['origin'][0]['data'][0]['id']. "',"
- . "'project',"
- . $project['project_id']. ","
- . $this->account . ","
- . time() . ")",__LINE__,__FILE__);
- }
-
-
- if($this->db->transaction_commit())
- {
- $this->increment_project_id();
-
$historylog->add('SO',$project['project_id'],$project['status']);
-
$historylog->add('TO',$project['project_id'],$project['cat_id']);
-
$historylog->add('CO',$project['project_id'],$project['coordinator']);
-
- $receipt['message'][] =
array('msg'=>lang('project %1 has been saved',$project['project_id']));
- }
- else
- {
- $receipt['error'][] = array('msg'=>lang('the
project has not been saved'));
- }
- return $receipt;
- }
-
- function
update_power_meter($power_meter,$location_code,$address,$meter_table)
- {
-
- $location=explode('-',$location_code);
-
- $i=1;
- if (isset($location) AND is_array($location))
- {
- foreach($location as $location_entry)
- {
-
- $cols[] = 'loc' . $i;
- $vals[] = $location_entry;
-
- $i++;
- }
-
- }
-
- if($cols)
- {
- $cols = "," . implode(",", $cols);
- $vals = ",'" . implode("','", $vals) . "'";
- }
-
-
- $this->db->query("SELECT count(*) FROM $meter_table
where location_code='$location_code' and category=1",__LINE__,__FILE__);
-
- $this->db->next_record();
-
- if ( $this->db->f(0))
- {
- $this->db->query("update $meter_table set
ext_meter_id='$power_meter',address='$address' where
location_code='$location_code' and category='1'",__LINE__,__FILE__);
- }
- else
- {
- $id = $this->bocommon->next_id($meter_table);
-
- $meter_id =
$this->generate_meter_id($meter_table);
- $this->db->query("insert into $meter_table
(id,num,ext_meter_id,category,location_code,entry_date,user_id,address $cols) "
- . "VALUES ('"
- . $id. "','"
- . $meter_id. "','"
- . $power_meter. "',"
- . "1,'"
- . $location_code. "',"
- . time() . ",$this->account, '$address'
$vals)",__LINE__,__FILE__);
- }
- }
-
- function generate_meter_id($meter_table)
- {
- $prefix = 'meter';
- $pos = strlen($prefix);
- $this->db->query("select max(num) from $meter_table
where num $this->like ('$prefix%')");
- $this->db->next_record();
-
- $max =
$this->bocommon->add_leading_zero(substr($this->db->f(0),$pos));
-
- $meter_id= $prefix . $max;
- return $meter_id;
- }
-
- function edit($project)
- {
- $historylog =
CreateObject($this->currentapp.'.historylog','project');
-
- while (is_array($project['location']) &&
list($input_name,$value) = each($project['location']))
- {
- $vals[] = "$input_name = '$value'";
- }
-
- while (is_array($project['extra']) &&
list($input_name,$value) = each($project['extra']))
- {
- $vals[] = "$input_name = '$value'";
- }
-
- if($vals)
- {
- $vals = "," . implode(",",$vals);
- }
-
- if($project['street_name'])
- {
- $address[]= $project['street_name'];
- $address[]= $project['street_number'];
- $address = $this->db->db_addslashes(implode("
", $address));
- }
-
- if(!$address)
- {
- $address =
$this->db->db_addslashes($project['location_name']);
- }
-
- $project['descr'] =
$this->db->db_addslashes($project['descr']);
- $project['name'] =
$this->db->db_addslashes($project['name']);
-
- $value_set=array(
- 'name' => $project['name'],
- 'status' => $project['status'],
- 'category' => $project['cat_id'],
- 'start_date' =>
$project['start_date'],
- 'end_date' => $project['end_date'],
- 'coordinator' =>
$project['coordinator'],
- 'descr' => $project['descr'],
- 'budget' =>
(int)$project['budget'],
- 'reserve' =>
(int)$project['reserve'],
- 'key_deliver' =>
$project['key_deliver'],
- 'key_fetch' =>
$project['key_fetch'],
- 'other_branch' =>
$project['other_branch'],
- 'key_responsible' =>
$project['key_responsible'],
- 'location_code' =>
$project['location_code'],
- 'address' => $address
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->transaction_begin();
-
- $this->db->query("SELECT status,category,coordinator
FROM fm_project where id='" .$project['project_id']."'",__LINE__,__FILE__);
- $this->db->next_record();
- $old_status = $this->db->f('status');
- $old_categroy = (int)$this->db->f('category');
- $old_coordinator = (int)$this->db->f('coordinator');
-
- $this->db->query("UPDATE fm_project set $value_set
$vals WHERE id= '" . $project['project_id'] ."'",__LINE__,__FILE__);
-
- if($project['extra']['contact_phone'] &&
$project['extra']['tenant_id'])
- {
- $this->db->query("update fm_tenant set
contact_phone='". $project['extra']['contact_phone']. "' where id='".
$project['extra']['tenant_id']. "'",__LINE__,__FILE__);
- }
-
- $config = CreateObject('phpgwapi.config','property');
- $config->read_repository();
- $meter_table = $config->config_data['meter_table'];
-
- if ($project['power_meter'] && $meter_table)
- {
-
$this->update_power_meter($project['power_meter'],$project['location_code'],$address,$meter_table);
- }
- // -----------------which branch is represented
- $this->db->query("delete from fm_projectbranch where
project_id='" . $project['project_id'] ."'",__LINE__,__FILE__);
-
- if (count($project['branch']) != 0)
- {
- while($branch=each($project['branch']))
- {
- $this->db->query("insert into
fm_projectbranch (project_id,branch_id) values ('" . $project['project_id'].
"','$branch[1]')",__LINE__,__FILE__);
- }
- }
-
- if($project['delete_request'])
- {
- $receipt =
$this->delete_request_from_project($project['delete_request'],$project['project_id']);
-
- }
-
-
$this->update_request_status($project['project_id'],$project['status'],$project['cat_id'],$project['coordinator']);
-
- if ($old_status != $project['status'])
- {
-
$historylog->add('S',$project['project_id'],$project['status']);
-
- $this->db->query("UPDATE fm_workorder set
status='". $project['status'] . "' WHERE project_id= '" .
$project['project_id'] ."'",__LINE__,__FILE__);
-
- $this->db2->query("SELECT id from fm_workorder
WHERE project_id=" . (int)$project['project_id'] ,__LINE__,__FILE__);
- while ($this->db2->next_record())
- {
- $workorder[] = $this->db2->f('id');
- }
-
- if (isset($workorder) AND is_array($workorder))
- {
- $historylog_workorder =
CreateObject($this->currentapp.'.historylog','workorder');
- foreach($workorder as $workorder_id)
- {
-
$historylog_workorder->add('S',$workorder_id,$project['status']);
- }
- }
-
- $receipt['notice_owner'][]=lang('Status
changed') . ': ' . $project['status'];
- }
- if ($old_categroy != $project['cat_id'])
- {
-
$historylog->add('T',$project['project_id'],$project['cat_id']);
- }
- if ($old_coordinator != $project['coordinator'])
- {
-
$historylog->add('C',$project['project_id'],$project['coordinator']);
- $receipt['notice_owner'][]=lang('Coordinator
changed') . ': ' .
$GLOBALS['phpgw']->accounts->id2name($project['coordinator']);
- }
-
- $receipt['message'][] = array('msg'=>lang('project %1
has been edited',$project['project_id']));
-
- $this->db->transaction_commit();
-
- return $receipt;
-
- }
-
-
- function delete_request_from_project($request_id,$project_id)
- {
- for ($i=0;$i<count($request_id);$i++)
- {
- $this->db2->query("update fm_request set
project_id = NULL where id='". $request_id[$i] . "'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_origin WHERE
destination ='project' AND origin_id='" . $request_id[$i] . "' AND
origin='request'",__LINE__,__FILE__);
- $receipt['message'][] =
array('msg'=>lang('Request %1 has been deleted from project
%2',$request_id[$i],$project_id));
- }
- return $receipt;
- }
-
-
- function
update_request_status($project_id='',$status='',$category=0,$coordinator=0)
- {
- $historylog_r =
CreateObject($this->currentapp.'.historylog','request');
-
- $sql = "SELECT origin_id FROM fm_origin WHERE
destination ='project' AND destination_id='$project_id' and origin ='request'";
-// $sql = "SELECT origin_id FROM fm_project_origin WHERE
project_id='$project_id' and origin ='request'";
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $request_id[] = $this->db->f('origin_id');
- }
-
- for ($i=0;$i<count($request_id);$i++)
- {
- $this->db->query("SELECT
status,category,coordinator FROM fm_request where id='" .$request_id[$i]
."'",__LINE__,__FILE__);
-
- $this->db->next_record();
-
- $old_status = $this->db->f('status');
- $old_category = (int)$this->db->f('category');
- $old_coordinator =
(int)$this->db->f('coordinator');
-
- if ($old_status != $status)
- {
-
$historylog_r->add('S',$request_id[$i],$status);
- }
-
- if ((int)$old_category != (int)$category)
- {
-
$historylog_r->add('T',$request_id[$i],$category);
- }
-
- if ((int)$old_coordinator != (int)$coordinator)
- {
-
$historylog_r->add('C',$request_id[$i],$coordinator);
- }
-
- $this->db2->query("update fm_request set
status='$status',coordinator='$coordinator' where id='". $request_id[$i] .
"'",__LINE__,__FILE__);
- }
- }
-
-
- function check_request($request_id)
- {
- $sql = "SELECT destination_id FROM fm_origin WHERE
destination ='project' AND origin_id='$request_id' and origin ='request'";
- $this->db->query($sql,__LINE__,__FILE__);
-
- $this->db->next_record();
-
- if ( $this->db->f(0))
- {
- return $this->db->f('destination_id');
- }
- }
-
- function add_request($add_request,$id)
- {
-
- for ($i=0;$i<count($add_request['request_id']);$i++)
- {
-
$project_id=$this->check_request($add_request['request_id'][$i]);
-
- if(!$project_id)
- {
- $this->db->query("INSERT INTO
fm_origin (origin,origin_id,destination,destination_id,user_id,entry_date) "
- . "VALUES ('request','"
- .
$add_request['request_id'][$i]. "','"
- . "project',"
- . $id . ","
- . $this->account . ","
- . time() .
")",__LINE__,__FILE__);
-
- $this->db2->query("update fm_request
set project_id='$id' where id='". $add_request['request_id'][$i] .
"'",__LINE__,__FILE__);
-
- $receipt['message'][] =
array('msg'=>lang('request %1 has been added',$add_request['request_id'][$i]));
- }
- else
- {
- $receipt['error'][] =
array('msg'=>lang('request %1 has already been added to project
%2',$add_request['request_id'][$i],$project_id));
- }
-
- }
-
- return $receipt;
- }
-
- function delete($project_id )
- {
- $sql = "SELECT origin_id FROM fm_origin WHERE
destination ='project' AND destination_id='$project_id' and origin ='request'";
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $request_id[] = $this->db->f('origin_id');
- }
-
-
- $sql = "SELECT id as workorder_id FROM fm_workorder
WHERE project_id='$project_id'";
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $workorder_id[] = $this->db->f('workorder_id');
- }
-
- $this->db->transaction_begin();
-
- for ($i=0;$i<count($request_id);$i++)
- {
-
- $this->db2->query("update fm_request set
project_id = NULL where id='". $request_id[$i] . "'",__LINE__,__FILE__);
- }
-
- $this->db->query("DELETE FROM fm_project WHERE id='" .
$project_id . "'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_project_history WHERE
history_record_id='" . $project_id . "'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_projectbranch WHERE
project_id='" . $project_id . "'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_origin WHERE
destination ='project' AND destination_id ='" . $project_id .
"'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_workorder WHERE
project_id='" . $project_id . "'",__LINE__,__FILE__);
-
- for ($i=0;$i<count($workorder_id);$i++)
- {
- $this->db->query("DELETE FROM fm_wo_hours WHERE
workorder_id='" . $workorder_id[$i] . "'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM
fm_workorder_history WHERE history_record_id='" . $workorder_id[$i] .
"'",__LINE__,__FILE__);
- }
-
- $this->db->transaction_commit();
-
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage project
+ * @version $Id: class.soproject.inc.php,v 1.25 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class soproject
+ {
+
+ function soproject()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->left_join = $this->bocommon->left_join;
+ $this->like = $this->bocommon->like;
+
+ $this->grants =
$GLOBALS['phpgw']->session->appsession('grants_project',$this->currentapp);
+
+ if(!$this->grants)
+ {
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2','##DEFAULT##','##DEFAULT##');
+ $this->grants =
$this->acl2->get_grants($this->currentapp,'.project');
+
$GLOBALS['phpgw']->session->appsession('grants_project',$this->currentapp,$this->grants);
+ }
+ }
+
+
+ function select_category_workorder_list()
+ {
+
+ $this->db->query("SELECT id, descr FROM
fm_workorder_category ORDER BY descr ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $categories[$i]['id']
= $this->db->f('id');
+ $categories[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $categories;
+ }
+
+ function read_single_project_category($id='')
+ {
+ $this->db->query("SELECT descr FROM
fm_workorder_category where id='$id' ");
+ $this->db->next_record();
+ return $this->db->f('descr');
+ }
+
+ function select_status_list()
+ {
+ $this->db->query("SELECT id, descr FROM
fm_workorder_status ORDER BY id ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $status_entries[$i]['id']
= $this->db->f('id');
+ $status_entries[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $status_entries;
+ }
+
+ function select_branch_list()
+ {
+ $this->db->query("SELECT id, descr FROM fm_branch ORDER
BY id ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $branch_entries[$i]['id']
= $this->db->f('id');
+ $branch_entries[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $branch_entries;
+ }
+
+ function select_key_location_list()
+ {
+ $this->db->query("SELECT id, descr FROM fm_key_loc
ORDER BY descr ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $key_location_entries[$i]['id']
= $this->db->f('id');
+ $key_location_entries[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $key_location_entries;
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
$data['filter']?$data['filter']:$this->account;
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $status_id =
(isset($data['status_id'])?$data['status_id']:'');
+ $start_date =
(isset($data['start_date'])?$data['start_date']:'');
+ $end_date =
(isset($data['end_date'])?$data['end_date']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $wo_hour_cat_id =
(isset($data['wo_hour_cat_id'])?$data['wo_hour_cat_id']:'');
+ }
+
+ $sql = $this->bocommon->fm_cache('sql_project_' .
!!$wo_hour_cat_id);
+
+ if(!$sql)
+ {
+ $entity_table = 'fm_project';
+
+ $cols .= $entity_table . '.location_code';
+ $cols_return[] = 'location_code';
+
+ $cols .= ",$entity_table.id as project_id";
+ $cols_return[] =
'project_id';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'project_id';
+ $uicols['descr'][] =
lang('Project');
+ $uicols['statustext'][] = lang('Project
ID');
+
+ $cols.= ",$entity_table.start_date";
+ $cols_return[] =
'start_date';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'start_date';
+ $uicols['descr'][] =
lang('start date');
+ $uicols['statustext'][] = lang('Project
start date');
+
+ $cols.= ",$entity_table.name as name";
+ $cols_return[] =
'name';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'name';
+ $uicols['descr'][] =
lang('name');
+ $uicols['statustext'][] = lang('Project
name');
+
+ $cols.= ",account_lid as coordinator";
+ $cols_return[] =
'coordinator';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'coordinator';
+ $uicols['descr'][] =
lang('Coordinator');
+ $uicols['statustext'][] = lang('Project
coordinator');
+
+ $cols.= ",$entity_table.user_id";
+
+ $joinmethod .= " $this->join phpgw_accounts ON
($entity_table.coordinator = phpgw_accounts.account_id))";
+ $paranthesis .='(';
+
+ //----- wo_hour_status
+
+ if($wo_hour_cat_id)
+ {
+ $joinmethod .= " $this->join
fm_workorder ON ($entity_table.id = fm_workorder.project_id))";
+ $paranthesis .='(';
+
+ $joinmethod .= " $this->join
fm_wo_hours ON (fm_workorder.id = fm_wo_hours.workorder_id))";
+ $paranthesis .='(';
+
+ $joinmethod .= " $this->join
fm_wo_hours_category ON (fm_wo_hours.category = fm_wo_hours_category.id))";
+ $paranthesis .='(';
+ }
+
+ //----- wo_hour_status
+
+ $sql =
$this->bocommon->generate_sql(array('entity_table'=>$entity_table,'cols'=>$cols,'cols_return'=>$cols_return,
+
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query));
+
+ $this->bocommon->fm_cache('sql_project_' .
!!$wo_hour_cat_id,$sql);
+
+ $this->uicols =
$this->bocommon->uicols;
+ $cols_return =
$this->bocommon->cols_return;
+ $type_id =
$this->bocommon->type_id;
+ $this->cols_extra =
$this->bocommon->cols_extra;
+
+ $this->bocommon->fm_cache('uicols_project_' .
!!$wo_hour_cat_id,$this->uicols);
+
$this->bocommon->fm_cache('cols_return_project_' .
!!$wo_hour_cat_id,$cols_return);
+ $this->bocommon->fm_cache('type_id_project_' .
!!$wo_hour_cat_id,$type_id);
+ $this->bocommon->fm_cache('cols_extra_project_'
. !!$wo_hour_cat_id,$this->cols_extra);
+
+ }
+ else
+ {
+ $this->uicols =
$this->bocommon->fm_cache('uicols_project_' . !!$wo_hour_cat_id);
+ $cols_return =
$this->bocommon->fm_cache('cols_return_project_' . !!$wo_hour_cat_id);
+ $type_id =
$this->bocommon->fm_cache('type_id_project_' . !!$wo_hour_cat_id);
+ $this->cols_extra =
$this->bocommon->fm_cache('cols_extra_project_' . !!$wo_hour_cat_id);
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by fm_project.id DESC';
+ }
+
+ $where= 'WHERE';
+
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " $where
fm_project.category=$cat_id ";
+ $where= 'AND';
+ }
+
+ if ($status_id)
+ {
+ $filtermethod .= " $where
fm_project.status='$status_id' ";
+ $where= 'AND';
+ }
+
+ if($wo_hour_cat_id)
+ {
+ $filtermethod .= " $where
fm_wo_hours_category.id=$wo_hour_cat_id ";
+ $where= 'AND';
+ $group_method = " group by
fm_project.location_code,fm_project.id
,fm_project.start_date,fm_project.name,account_lid
,fm_project.user_id,fm_project.address";
+ }
+
+ if ($filter=='all')
+ {
+ if (is_array($this->grants))
+ {
+ $grants = $this->grants;
+ while (list($user) = each($grants))
+ {
+ $public_user_list[] = $user;
+ }
+ reset($public_user_list);
+ $filtermethod .= " $where
(fm_project.coordinator IN(" . implode(',',$public_user_list) . "))";
+
+ $where= 'AND';
+ }
+ }
+ else
+ {
+ $filtermethod .= " $where
fm_project.coordinator=$filter ";
+ $where= 'AND';
+ }
+
+ if ($start_date)
+ {
+ $filtermethod .= " $where fm_project.start_date
>= $start_date AND fm_project.start_date <= $end_date ";
+ $where= 'AND';
+ }
+
+
+ if($query)
+ {
+ $query = str_replace(",",'.',$query);
+ if(stristr($query, '.'))
+ {
+ $query=explode(".",$query);
+ $querymethod = " $where
(fm_project.loc1='" . $query[0] . "' AND fm_project.loc".$type_id."='" .
$query[1] . "')";
+ }
+ else
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+ $querymethod = " $where
(fm_project.name $this->like '%$query%' or fm_project.address $this->like
'%$query%' or fm_project.location_code $this->like '%$query%' or fm_project.id
$this->like '%$query%')";
+ }
+ }
+
+ $sql .= " $filtermethod $querymethod $group_method";
+//echo $sql;
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ $j=0;
+ $k=count($cols_return);
+ while ($this->db->next_record())
+ {
+ for ($i=0;$i<$k;$i++)
+ {
+ $project_list[$j][$cols_return[$i]] =
stripslashes($this->db->f($cols_return[$i]));
+ $project_list[$j]['grants'] =
(int)$this->grants[$this->db->f('user_id')];
+ }
+
+ $location_code= $this->db->f('location_code');
+ $location = split('-',$location_code);
+ $n=count($location);
+ for ($m=0;$m<$n;$m++)
+ {
+ $project_list[$j]['loc' . ($m+1)] =
$location[$m];
+
$project_list[$j]['query_location']['loc' . ($m+1)]=implode("-",
array_slice($location, 0, ($m+1)));
+ }
+
+ $j++;
+ }
+
+//_debug_array($project_list);
+ return $project_list;
+ }
+
+ function read_single($project_id)
+ {
+ $config = CreateObject('phpgwapi.config','property');
+ $config->read_repository();
+ $meter_table = $config->config_data['meter_table'];
+
+ $sql = "SELECT * from fm_project where
id='$project_id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $project['project_id'] =
$this->db->f('id');
+ $project['title'] =
$this->db->f('title');
+ $project['name'] =
$this->db->f('name');
+ $project['location_code'] =
$this->db->f('location_code');
+ $project['key_fetch'] =
$this->db->f('key_fetch');
+ $project['key_deliver'] =
$this->db->f('key_deliver');
+ $project['other_branch'] =
$this->db->f('other_branch');
+ $project['key_responsible'] =
$this->db->f('key_responsible');
+ $project['descr'] =
$this->db->f('descr');
+ $project['status'] =
$this->db->f('status');
+ $project['budget'] =
(int)$this->db->f('budget');
+ $project['reserve'] =
(int)$this->db->f('reserve');
+ $project['tenant_id'] =
$this->db->f('tenant_id');
+ $project['user_id'] =
$this->db->f('user_id');
+ $project['coordinator'] =
$this->db->f('coordinator');
+ $project['access'] =
$this->db->f('access');
+ $project['start_date'] =
$this->db->f('start_date');
+ $project['end_date'] =
$this->db->f('end_date');
+ $project['cat_id'] =
$this->db->f('category');
+ $project['grants'] =
(int)$this->grants[$this->db->f('user_id')];
+ $project['p_num'] =
$this->db->f('p_num');
+ $project['p_entity_id'] =
$this->db->f('p_entity_id');
+ $project['p_cat_id'] =
$this->db->f('p_cat_id');
+ $project['contact_phone'] =
$this->db->f('contact_phone');
+
+
+ if($meter_table)
+ {
+ $project['power_meter'] =
$this->get_power_meter($this->db->f('location_code'),$meter_table);
+ }
+ }
+
+ $sql = "SELECT * FROM fm_origin WHERE destination =
'project' AND destination_id='$project_id' ORDER by origin DESC ";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ $i=-1;
+ while ($this->db->next_record())
+ {
+ if($last_type != $this->db->f('origin'))
+ {
+ $i++;
+ }
+ $project['origin'][$i]['type'] =
$this->db->f('origin');
+ $project['origin'][$i]['link'] =
$this->bocommon->get_origin_link($this->db->f('origin'));
+ $project['origin'][$i]['data'][]= array(
+ 'id'=> $this->db->f('origin_id'),
+ 'type'=> $this->db->f('origin')
+ );
+
+ $last_type=$this->db->f('origin');
+ }
+
+//_debug_array($project);
+ return $project;
+ }
+
+ function get_ticket($project_id = '')
+ {
+ $sql = "SELECT * FROM fm_origin WHERE origin ='tts' AND
destination = 'project' AND destination_id='$project_id' ORDER by origin DESC
";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ return $this->db->f('origin_id');
+ }
+
+ function get_power_meter($location_code = '',$meter_table='')
+ {
+ if(!$meter_table)
+ {
+ $config =
CreateObject('phpgwapi.config','property');
+ $config->read_repository();
+ $meter_table =
$config->config_data['meter_table'];
+ }
+
+ $this->db2->query("SELECT ext_meter_id as power_meter
FROM $meter_table where location_code='$location_code' and
category='1'",__LINE__,__FILE__);
+
+ $this->db2->next_record();
+
+ return $this->db2->f('power_meter');
+ }
+
+ function project_workorder_data($project_id = '')
+ {
+ $this->db->query("SELECT act_mtrl_cost,
act_vendor_cost, budget, id as workorder_id, vendor_id,
calculation,rig_addition,addition,deviation,charge_tenant from fm_workorder
where project_id='$project_id'");
+ while ($this->db->next_record())
+ {
+ $budget[] = array(
+ 'workorder_id' =>
$this->db->f('workorder_id'),
+ 'budget' =>
$this->db->f('budget'),
+ 'deviation' =>
$this->db->f('deviation'),
+ 'calculation' =>
($this->db->f('calculation')*(1+$this->db->f('addition')/100))+$this->db->f('rig_addition'),
+ 'vendor_id' =>
$this->db->f('vendor_id'),
+ 'act_mtrl_cost' =>
$this->db->f('act_mtrl_cost'),
+ 'act_vendor_cost' =>
$this->db->f('act_vendor_cost'),
+ 'charge_tenant' =>
$this->db->f('charge_tenant')
+ );
+ }
+ return $budget;
+ }
+
+ function branch_p_list($project_id = '')
+ {
+
+ $this->db2->query("SELECT branch_id from
fm_projectbranch WHERE project_id=" . (int)$project_id ,__LINE__,__FILE__);
+ while ($this->db2->next_record())
+ {
+ $selected[] = array('branch_id' =>
$this->db2->f('branch_id'));
+ }
+
+ return $selected;
+ }
+
+ function increment_project_id()
+ {
+ $this->db->query("update fm_idgenerator set value =
value + 1 where name = 'project'");
+ }
+
+ function next_project_id()
+ {
+ $this->db->query("select value from fm_idgenerator
where name = 'project'");
+ $this->db->next_record();
+ $project_id = $this->db->f('value')+1;
+ return $project_id;
+ }
+
+ function add($project)
+ {
+ $historylog =
CreateObject($this->currentapp.'.historylog','project');
+
+ while (is_array($project['location']) &&
list($input_name,$value) = each($project['location']))
+ {
+ if($value)
+ {
+ $cols[] = $input_name;
+ $vals[] = $value;
+ }
+ }
+
+ while (is_array($project['extra']) &&
list($input_name,$value) = each($project['extra']))
+ {
+ if($value)
+ {
+ $cols[] = $input_name;
+ $vals[] = $value;
+ }
+ }
+
+ if($cols)
+ {
+ $cols = "," . implode(",", $cols);
+ $vals = ",'" . implode("','", $vals) . "'";
+ }
+
+ if($project['street_name'])
+ {
+ $address[]= $project['street_name'];
+ $address[]= $project['street_number'];
+ $address = $this->db->db_addslashes(implode("
", $address));
+ }
+
+ if(!$address)
+ {
+ $address =
$this->db->db_addslashes($project['location_name']);
+ }
+
+ $project['descr'] =
$this->db->db_addslashes($project['descr']);
+ $project['name'] =
$this->db->db_addslashes($project['name']);
+
+ $values= array(
+ $project['project_id'],
+ $project['name'],
+ 'public',
+ $project['cat_id'],
+ time(),
+ $project['start_date'],
+ $project['end_date'],
+ $project['coordinator'],
+ $project['status'],
+ $project['descr'],
+ $project['budget'],
+ $project['reserve'],
+ $project['location_code'],
+ $address,
+ $project['key_deliver'],
+ $project['key_fetch'],
+ $project['other_branch'],
+ $project['key_responsible'],
+ $this->account);
+
+ $values = $this->bocommon->validate_db_insert($values);
+
+ $this->db->transaction_begin();
+
+ $this->db->query("INSERT INTO fm_project
(id,name,access,category,entry_date,start_date,end_date,coordinator,status,"
+ .
"descr,budget,reserve,location_code,address,key_deliver,key_fetch,other_branch,key_responsible,user_id
$cols) "
+ . "VALUES ($values $vals )",__LINE__,__FILE__);
+
+ if($project['extra']['contact_phone'] &&
$project['extra']['tenant_id'])
+ {
+ $this->db->query("update fm_tenant set
contact_phone='". $project['extra']['contact_phone']. "' where id='".
$project['extra']['tenant_id']. "'",__LINE__,__FILE__);
+ }
+
+ $config = CreateObject('phpgwapi.config','property');
+ $config->read_repository();
+ $meter_table = $config->config_data['meter_table'];
+
+ if ($project['power_meter'] && $meter_table)
+ {
+
$this->update_power_meter($project['power_meter'],$project['location_code'],$address,$meter_table);
+ }
+
+ if (count($project['branch']) != 0)
+ {
+ while($branch=each($project['branch']))
+ {
+ $this->db->query("insert into
fm_projectbranch (project_id,branch_id) values ('" . $project['project_id'].
"','$branch[1]')",__LINE__,__FILE__);
+ }
+ }
+
+ if($project['origin'][0]['data'][0]['id'])
+ {
+ $this->db->query("INSERT INTO fm_origin
(origin,origin_id,destination,destination_id,user_id,entry_date) "
+ . "VALUES ('"
+ . $project['origin'][0]['type']. "','"
+ .
$project['origin'][0]['data'][0]['id']. "',"
+ . "'project',"
+ . $project['project_id']. ","
+ . $this->account . ","
+ . time() . ")",__LINE__,__FILE__);
+ }
+
+
+ if($this->db->transaction_commit())
+ {
+ $this->increment_project_id();
+
$historylog->add('SO',$project['project_id'],$project['status']);
+
$historylog->add('TO',$project['project_id'],$project['cat_id']);
+
$historylog->add('CO',$project['project_id'],$project['coordinator']);
+
+ $receipt['message'][] =
array('msg'=>lang('project %1 has been saved',$project['project_id']));
+ }
+ else
+ {
+ $receipt['error'][] = array('msg'=>lang('the
project has not been saved'));
+ }
+ return $receipt;
+ }
+
+ function
update_power_meter($power_meter,$location_code,$address,$meter_table)
+ {
+
+ $location=explode('-',$location_code);
+
+ $i=1;
+ if (isset($location) AND is_array($location))
+ {
+ foreach($location as $location_entry)
+ {
+
+ $cols[] = 'loc' . $i;
+ $vals[] = $location_entry;
+
+ $i++;
+ }
+
+ }
+
+ if($cols)
+ {
+ $cols = "," . implode(",", $cols);
+ $vals = ",'" . implode("','", $vals) . "'";
+ }
+
+
+ $this->db->query("SELECT count(*) FROM $meter_table
where location_code='$location_code' and category=1",__LINE__,__FILE__);
+
+ $this->db->next_record();
+
+ if ( $this->db->f(0))
+ {
+ $this->db->query("update $meter_table set
ext_meter_id='$power_meter',address='$address' where
location_code='$location_code' and category='1'",__LINE__,__FILE__);
+ }
+ else
+ {
+ $id = $this->bocommon->next_id($meter_table);
+
+ $meter_id =
$this->generate_meter_id($meter_table);
+ $this->db->query("insert into $meter_table
(id,num,ext_meter_id,category,location_code,entry_date,user_id,address $cols) "
+ . "VALUES ('"
+ . $id. "','"
+ . $meter_id. "','"
+ . $power_meter. "',"
+ . "1,'"
+ . $location_code. "',"
+ . time() . ",$this->account, '$address'
$vals)",__LINE__,__FILE__);
+ }
+ }
+
+ function generate_meter_id($meter_table)
+ {
+ $prefix = 'meter';
+ $pos = strlen($prefix);
+ $this->db->query("select max(num) from $meter_table
where num $this->like ('$prefix%')");
+ $this->db->next_record();
+
+ $max =
$this->bocommon->add_leading_zero(substr($this->db->f(0),$pos));
+
+ $meter_id= $prefix . $max;
+ return $meter_id;
+ }
+
+ function edit($project)
+ {
+ $historylog =
CreateObject($this->currentapp.'.historylog','project');
+
+ while (is_array($project['location']) &&
list($input_name,$value) = each($project['location']))
+ {
+ $vals[] = "$input_name = '$value'";
+ }
+
+ while (is_array($project['extra']) &&
list($input_name,$value) = each($project['extra']))
+ {
+ $vals[] = "$input_name = '$value'";
+ }
+
+ if($vals)
+ {
+ $vals = "," . implode(",",$vals);
+ }
+
+ if($project['street_name'])
+ {
+ $address[]= $project['street_name'];
+ $address[]= $project['street_number'];
+ $address = $this->db->db_addslashes(implode("
", $address));
+ }
+
+ if(!$address)
+ {
+ $address =
$this->db->db_addslashes($project['location_name']);
+ }
+
+ $project['descr'] =
$this->db->db_addslashes($project['descr']);
+ $project['name'] =
$this->db->db_addslashes($project['name']);
+
+ $value_set=array(
+ 'name' => $project['name'],
+ 'status' => $project['status'],
+ 'category' => $project['cat_id'],
+ 'start_date' =>
$project['start_date'],
+ 'end_date' => $project['end_date'],
+ 'coordinator' =>
$project['coordinator'],
+ 'descr' => $project['descr'],
+ 'budget' =>
(int)$project['budget'],
+ 'reserve' =>
(int)$project['reserve'],
+ 'key_deliver' =>
$project['key_deliver'],
+ 'key_fetch' =>
$project['key_fetch'],
+ 'other_branch' =>
$project['other_branch'],
+ 'key_responsible' =>
$project['key_responsible'],
+ 'location_code' =>
$project['location_code'],
+ 'address' => $address
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->transaction_begin();
+
+ $this->db->query("SELECT status,category,coordinator
FROM fm_project where id='" .$project['project_id']."'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $old_status = $this->db->f('status');
+ $old_categroy = (int)$this->db->f('category');
+ $old_coordinator = (int)$this->db->f('coordinator');
+
+ $this->db->query("UPDATE fm_project set $value_set
$vals WHERE id= '" . $project['project_id'] ."'",__LINE__,__FILE__);
+
+ if($project['extra']['contact_phone'] &&
$project['extra']['tenant_id'])
+ {
+ $this->db->query("update fm_tenant set
contact_phone='". $project['extra']['contact_phone']. "' where id='".
$project['extra']['tenant_id']. "'",__LINE__,__FILE__);
+ }
+
+ $config = CreateObject('phpgwapi.config','property');
+ $config->read_repository();
+ $meter_table = $config->config_data['meter_table'];
+
+ if ($project['power_meter'] && $meter_table)
+ {
+
$this->update_power_meter($project['power_meter'],$project['location_code'],$address,$meter_table);
+ }
+ // -----------------which branch is represented
+ $this->db->query("delete from fm_projectbranch where
project_id='" . $project['project_id'] ."'",__LINE__,__FILE__);
+
+ if (count($project['branch']) != 0)
+ {
+ while($branch=each($project['branch']))
+ {
+ $this->db->query("insert into
fm_projectbranch (project_id,branch_id) values ('" . $project['project_id'].
"','$branch[1]')",__LINE__,__FILE__);
+ }
+ }
+
+ if($project['delete_request'])
+ {
+ $receipt =
$this->delete_request_from_project($project['delete_request'],$project['project_id']);
+
+ }
+
+
$this->update_request_status($project['project_id'],$project['status'],$project['cat_id'],$project['coordinator']);
+
+ if ($old_status != $project['status'])
+ {
+
$historylog->add('S',$project['project_id'],$project['status']);
+
+ $this->db->query("UPDATE fm_workorder set
status='". $project['status'] . "' WHERE project_id= '" .
$project['project_id'] ."'",__LINE__,__FILE__);
+
+ $this->db2->query("SELECT id from fm_workorder
WHERE project_id=" . (int)$project['project_id'] ,__LINE__,__FILE__);
+ while ($this->db2->next_record())
+ {
+ $workorder[] = $this->db2->f('id');
+ }
+
+ if (isset($workorder) AND is_array($workorder))
+ {
+ $historylog_workorder =
CreateObject($this->currentapp.'.historylog','workorder');
+ foreach($workorder as $workorder_id)
+ {
+
$historylog_workorder->add('S',$workorder_id,$project['status']);
+ }
+ }
+
+ $receipt['notice_owner'][]=lang('Status
changed') . ': ' . $project['status'];
+ }
+ if ($old_categroy != $project['cat_id'])
+ {
+
$historylog->add('T',$project['project_id'],$project['cat_id']);
+ }
+ if ($old_coordinator != $project['coordinator'])
+ {
+
$historylog->add('C',$project['project_id'],$project['coordinator']);
+ $receipt['notice_owner'][]=lang('Coordinator
changed') . ': ' .
$GLOBALS['phpgw']->accounts->id2name($project['coordinator']);
+ }
+
+ $receipt['message'][] = array('msg'=>lang('project %1
has been edited',$project['project_id']));
+
+ $this->db->transaction_commit();
+
+ return $receipt;
+
+ }
+
+
+ function delete_request_from_project($request_id,$project_id)
+ {
+ for ($i=0;$i<count($request_id);$i++)
+ {
+ $this->db2->query("update fm_request set
project_id = NULL where id='". $request_id[$i] . "'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_origin WHERE
destination ='project' AND origin_id='" . $request_id[$i] . "' AND
origin='request'",__LINE__,__FILE__);
+ $receipt['message'][] =
array('msg'=>lang('Request %1 has been deleted from project
%2',$request_id[$i],$project_id));
+ }
+ return $receipt;
+ }
+
+
+ function
update_request_status($project_id='',$status='',$category=0,$coordinator=0)
+ {
+ $historylog_r =
CreateObject($this->currentapp.'.historylog','request');
+
+ $sql = "SELECT origin_id FROM fm_origin WHERE
destination ='project' AND destination_id='$project_id' and origin ='request'";
+// $sql = "SELECT origin_id FROM fm_project_origin WHERE
project_id='$project_id' and origin ='request'";
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $request_id[] = $this->db->f('origin_id');
+ }
+
+ for ($i=0;$i<count($request_id);$i++)
+ {
+ $this->db->query("SELECT
status,category,coordinator FROM fm_request where id='" .$request_id[$i]
."'",__LINE__,__FILE__);
+
+ $this->db->next_record();
+
+ $old_status = $this->db->f('status');
+ $old_category = (int)$this->db->f('category');
+ $old_coordinator =
(int)$this->db->f('coordinator');
+
+ if ($old_status != $status)
+ {
+
$historylog_r->add('S',$request_id[$i],$status);
+ }
+
+ if ((int)$old_category != (int)$category)
+ {
+
$historylog_r->add('T',$request_id[$i],$category);
+ }
+
+ if ((int)$old_coordinator != (int)$coordinator)
+ {
+
$historylog_r->add('C',$request_id[$i],$coordinator);
+ }
+
+ $this->db2->query("update fm_request set
status='$status',coordinator='$coordinator' where id='". $request_id[$i] .
"'",__LINE__,__FILE__);
+ }
+ }
+
+
+ function check_request($request_id)
+ {
+ $sql = "SELECT destination_id FROM fm_origin WHERE
destination ='project' AND origin_id='$request_id' and origin ='request'";
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ $this->db->next_record();
+
+ if ( $this->db->f(0))
+ {
+ return $this->db->f('destination_id');
+ }
+ }
+
+ function add_request($add_request,$id)
+ {
+
+ for ($i=0;$i<count($add_request['request_id']);$i++)
+ {
+
$project_id=$this->check_request($add_request['request_id'][$i]);
+
+ if(!$project_id)
+ {
+ $this->db->query("INSERT INTO
fm_origin (origin,origin_id,destination,destination_id,user_id,entry_date) "
+ . "VALUES ('request','"
+ .
$add_request['request_id'][$i]. "','"
+ . "project',"
+ . $id . ","
+ . $this->account . ","
+ . time() .
")",__LINE__,__FILE__);
+
+ $this->db2->query("update fm_request
set project_id='$id' where id='". $add_request['request_id'][$i] .
"'",__LINE__,__FILE__);
+
+ $receipt['message'][] =
array('msg'=>lang('request %1 has been added',$add_request['request_id'][$i]));
+ }
+ else
+ {
+ $receipt['error'][] =
array('msg'=>lang('request %1 has already been added to project
%2',$add_request['request_id'][$i],$project_id));
+ }
+
+ }
+
+ return $receipt;
+ }
+
+ function delete($project_id )
+ {
+ $sql = "SELECT origin_id FROM fm_origin WHERE
destination ='project' AND destination_id='$project_id' and origin ='request'";
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $request_id[] = $this->db->f('origin_id');
+ }
+
+
+ $sql = "SELECT id as workorder_id FROM fm_workorder
WHERE project_id='$project_id'";
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $workorder_id[] = $this->db->f('workorder_id');
+ }
+
+ $this->db->transaction_begin();
+
+ for ($i=0;$i<count($request_id);$i++)
+ {
+
+ $this->db2->query("update fm_request set
project_id = NULL where id='". $request_id[$i] . "'",__LINE__,__FILE__);
+ }
+
+ $this->db->query("DELETE FROM fm_project WHERE id='" .
$project_id . "'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_project_history WHERE
history_record_id='" . $project_id . "'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_projectbranch WHERE
project_id='" . $project_id . "'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_origin WHERE
destination ='project' AND destination_id ='" . $project_id .
"'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_workorder WHERE
project_id='" . $project_id . "'",__LINE__,__FILE__);
+
+ for ($i=0;$i<count($workorder_id);$i++)
+ {
+ $this->db->query("DELETE FROM fm_wo_hours WHERE
workorder_id='" . $workorder_id[$i] . "'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM
fm_workorder_history WHERE history_record_id='" . $workorder_id[$i] .
"'",__LINE__,__FILE__);
+ }
+
+ $this->db->transaction_commit();
+
+ }
+ }
+?>
Index: property/inc/class.sorequest.inc.php
diff -u property/inc/class.sorequest.inc.php:1.11
property/inc/class.sorequest.inc.php:1.12
--- property/inc/class.sorequest.inc.php:1.11 Thu Sep 22 08:35:53 2005
+++ property/inc/class.sorequest.inc.php Fri Jan 27 14:05:43 2006
@@ -1,644 +1,642 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage project
- * @version $Id: class.sorequest.inc.php,v 1.11 2005/09/22 08:35:53
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class sorequest
- {
- function sorequest()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->soproject =
CreateObject($this->currentapp.'.soproject');
- $this->historylog =
CreateObject($this->currentapp.'.historylog','request');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
-
- $this->join = $this->socommon->join;
- $this->like = $this->socommon->like;
- }
-
- function select_category_workorder_list()
- {
-
- $this->db->query("SELECT id, descr FROM
fm_workorder_category ORDER BY descr ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $categories[$i]['id']
= $this->db->f('id');
- $categories[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $categories;
- }
-
- function read_priority_key()
- {
- $this->db->query("SELECT * FROM
fm_request_condition_type",__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $priority_key[] = array(
- 'id' => $this->db->f('id'),
- 'descr' =>
$this->db->f('descr'),
- 'priority_key' =>
$this->db->f('priority_key')
- );
- }
-
- return $priority_key;
- }
-
- function update_priority_key($values)
- {
-
- while (is_array($values['priority_key']) &&
list($id,$priority_key) = each($values['priority_key']))
- {
- $this->db->query("UPDATE
fm_request_condition_type SET priority_key = $priority_key WHERE id =
$id",__LINE__,__FILE__);
- }
-
- $this->update_score();
-
- $receipt['message'][] = array('msg'=> lang('priority
keys has been updated'));
- return $receipt;
-
- }
-
-
- function update_score($request_id='')
- {
- if($request_id)
- {
- $request[] = $request_id;
- }
- else
- {
- $this->db->query("SELECT id FROM
fm_request",__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $request[] = $this->db->f('id');
- }
- }
-
- while (is_array($request) && list(,$id) =
each($request))
- {
-
-
if($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
- {
- $sql = "UPDATE fm_request SET score =
(SELECT sum(priority_key * ( degree * probability * ( consequence +1 ))) FROM
fm_request_condition"
- . " $this->join
fm_request_condition_type ON (fm_request_condition.condition_type =
fm_request_condition_type.id) WHERE request_id = $id) WHERE fm_request.id =
$id";
-
-
$this->db->query($sql,__LINE__,__FILE__);
- }
- else
- {
- $sql = "SELECT sum(priority_key * (
degree * probability * ( consequence +1 ))) AS score FROM fm_request_condition"
- . " $this->join
fm_request_condition_type ON (fm_request_condition.condition_type =
fm_request_condition_type.id) WHERE request_id = $id";
-
-
$this->db->query($sql,__LINE__,__FILE__);
-
- $this->db->next_record();
- $score = $this->db->f('score');
- $this->db->query("UPDATE fm_request SET
score = $score WHERE id = $id",__LINE__,__FILE__);
- }
- }
- }
-
-
- function read_single_request_category($id='')
- {
- $this->db->query("SELECT descr FROM
fm_workorder_category where id='$id' ");
- $this->db->next_record();
- return $this->db->f('descr');
- }
-
- function select_status_list()
- {
- $this->db->query("SELECT id, descr FROM
fm_request_status ORDER BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $status_entries[$i]['id']
= $this->db->f('id');
- $status_entries[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $status_entries;
- }
-
- function select_condition_type_list()
- {
- $this->db->query("SELECT id, descr FROM
fm_request_condition_type ORDER BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $condition_type_list[$i]['id'] =
$this->db->f('id');
- $condition_type_list[$i]['name'] =
stripslashes($this->db->f('descr'));
- $i++;
- }
- return $condition_type_list;
- }
-
- function
select_conditions($request_id='',$condition_type_list='')
- {
- for ($i=0;$i<count($condition_type_list);$i++)
- {
- $this->db->query("SELECT
degree,probability,consequence FROM fm_request_condition WHERE
request_id=$request_id AND condition_type =" . $condition_type_list[$i]['id']);
- $this->db->next_record();
- $conditions[$i]['request_id'] =
$request_id;
- $conditions[$i]['degree'] =
$this->db->f('degree');
- $conditions[$i]['probability'] =
$this->db->f('probability');
- $conditions[$i]['consequence'] =
$this->db->f('consequence');
- }
-
- return $conditions;
- }
-
-
- function read($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $status_id =
(isset($data['status_id'])?$data['status_id']:0);
- $project_id =
(isset($data['project_id'])?$data['project_id']:'');
- }
-
- $entity_table = 'fm_request';
-
- $cols .= $entity_table . '.location_code';
- $cols_return[] = 'location_code';
-
- $cols .= ",$entity_table.id as request_id";
- $cols_return[] = 'request_id';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'request_id';
- $uicols['descr'][] =
lang('Request');
- $uicols['statustext'][] = lang('Request ID');
-
- $cols.= ",$entity_table.entry_date";
- $cols_return[] = 'entry_date';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'entry_date';
- $uicols['descr'][] = lang('entry
date');
- $uicols['statustext'][] = lang('Request entry
date');
-
- $cols.= ",$entity_table.title as title";
- $cols_return[] = 'title';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'title';
- $uicols['descr'][] = lang('title');
- $uicols['statustext'][] = lang('Request title');
-
- $cols.= ",$entity_table.coordinator";
- $cols_return[] = 'coordinator';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'coordinator';
- $uicols['descr'][] =
lang('Coordinator');
- $uicols['statustext'][] = lang('Project
coordinator');
-
- $cols.= ",$entity_table.score";
- $cols_return[] = 'score';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'score';
- $uicols['descr'][] = lang('score');
- $uicols['statustext'][] = lang('score');
-
- $sql =
$this->bocommon->generate_sql(array('entity_table'=>$entity_table,'cols'=>$cols,'cols_return'=>$cols_return,
-
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query));
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by fm_request.id ASC';
- }
-
- $where = 'WHERE';
- if ($cat_id > 0)
- {
- $filtermethod .= " $where
fm_request.category='$cat_id' ";
- $where = 'AND';
- }
-
- if ($status_id)
- {
- $filtermethod .= " $where
fm_request.status='$status_id' ";
- $where = 'AND';
- }
-
- if ($filter)
- {
- $filtermethod .= " $where
fm_request.coordinator='$filter' ";
- $where = 'AND';
- }
-
- if ($project_id)// lookup requests not already
allocated to projects
- {
- $filtermethod .= " $where project_id is NULL ";
- $where = 'AND';
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " $where (fm_request.title
$this->like '%$query%' or fm_request.address $this->like '%$query%' or
fm_request.location_code $this->like '%$query%')";
- }
-
- $sql .= " $filtermethod $querymethod";
-
- $this->uicols = $this->bocommon->uicols;
- $cols_return = $this->bocommon->cols_return;
- $type_id =
$this->bocommon->type_id;
- $this->cols_extra = $this->bocommon->cols_extra;
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
-
-
- $j=0;
- while ($this->db->next_record())
- {
- for ($i=0;$i<count($cols_return);$i++)
- {
- $request_list[$j][$cols_return[$i]] =
stripslashes($this->db->f($cols_return[$i]));
- }
-
- $location_code= $this->db->f('location_code');
- $location = split('-',$location_code);
- for ($m=0;$m<count($location);$m++)
- {
- $request_list[$j]['loc' . ($m+1)] =
$location[$m];
-
$request_list[$j]['query_location']['loc' . ($m+1)]=implode("-",
array_slice($location, 0, ($m+1)));
- }
-
- $j++;
- }
-//_debug_array($request_list);
- return $request_list;
- }
-
- function read_single($request_id)
- {
- $sql = "SELECT * from fm_request where
id='$request_id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $request['request_id']
= $this->db->f('id');
- $request['title']
= $this->db->f('title');
- $request['location_code']
= $this->db->f('location_code');
- $request['descr']
= $this->db->f('descr');
- $request['status']
= $this->db->f('status');
- $request['budget']
= (int)$this->db->f('budget');
- $request['tenant_id']
= $this->db->f('tenant_id');
- $request['owner']
= $this->db->f('owner');
- $request['coordinator']
= $this->db->f('coordinator');
- $request['access']
= $this->db->f('access');
- $request['start_date']
= $this->db->f('start_date');
- $request['end_date']
= $this->db->f('end_date');
- $request['cat_id']
= $this->db->f('category');
-
- $request['branch_id']
= $this->db->f('branch_id');
- $request['authorities_demands']
= $this->db->f('authorities_demands');
- $request['score']
= $this->db->f('score');
- $request['p_num']
= $this->db->f('p_num');
- $request['p_entity_id']
= $this->db->f('p_entity_id');
- $request['p_cat_id']
= $this->db->f('p_cat_id');
- $request['contact_phone']
= $this->db->f('contact_phone');
-
- $request['power_meter'] =
$this->soproject->get_power_meter($this->db->f('location_code'));
- }
-
- $sql = "SELECT * FROM fm_origin WHERE destination =
'request' AND destination_id='$request_id' ORDER by origin DESC ";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- $i=-1;
- while ($this->db->next_record())
- {
- if($last_type != $this->db->f('origin'))
- {
- $i++;
- }
- $request['origin'][$i]['type'] =
$this->db->f('origin');
- $request['origin'][$i]['link'] =
$this->bocommon->get_origin_link($this->db->f('origin'));
- $request['origin'][$i]['data'][]= array(
- 'id'=> $this->db->f('origin_id'),
- 'type'=> $this->db->f('origin')
- );
-
- $last_type=$this->db->f('origin');
- }
-
- $sql = "SELECT * FROM fm_origin WHERE origin =
'request' AND origin_id='$request_id' ORDER by destination DESC ";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- if($last_type != $this->db->f('destination'))
- {
- $i++;
- }
- $request['origin'][$i]['type'] =
$this->db->f('destination');
- $request['origin'][$i]['link'] =
$this->bocommon->get_origin_link($this->db->f('destination'));
- $request['origin'][$i]['data'][]= array(
- 'id'=> $this->db->f('destination_id'),
- 'type'=> $this->db->f('destination')
- );
-
- $last_type=$this->db->f('destination');
- }
-
- return $request;
- }
-
- function request_workorder_data($request_id = '')
- {
- $this->db->query("select budget, id as workorder_id,
vendor_id from fm_workorder where request_id='$request_id'");
- while ($this->db->next_record())
- {
- $budget[] = array(
- 'workorder_id' =>
$this->db->f('workorder_id'),
- 'budget' =>
sprintf("%01.2f",$this->db->f('budget')),
- 'vendor_id' =>
$this->db->f('vendor_id')
- );
- }
- return $budget;
- }
-
-
- function increment_request_id()
- {
- $this->db->query("update fm_idgenerator set value =
value + 1 where name = 'request'");
- }
-
- function next_id()
- {
- $this->db->query("select value from fm_idgenerator
where name = 'request'");
- $this->db->next_record();
- $id = $this->db->f('value')+1;
- return $id;
- }
-
- function add($request)
- {
-//_debug_array($request);
- while (is_array($request['location']) &&
list($input_name,$value) = each($request['location']))
- {
- if($value)
- {
- $cols[] = $input_name;
- $vals[] = $value;
- }
- }
-
- while (is_array($request['extra']) &&
list($input_name,$value) = each($request['extra']))
- {
- if($value)
- {
- $cols[] = $input_name;
- $vals[] = $value;
- }
- }
-
- if($cols)
- {
- $cols = "," . implode(",", $cols);
- $vals = ",'" . implode("','", $vals) . "'";
- }
-
- if($request['street_name'])
- {
- $address[]= $request['street_name'];
- $address[]= $request['street_number'];
- $address =
$this->db->db_addslashes(implode(" ", $address));
- }
-
- if(!$address)
- {
- $address =
$this->db->db_addslashes($request['location_name']);
- }
-
- $request['descr'] =
$this->db->db_addslashes($request['descr']);
- $request['name'] =
$this->db->db_addslashes($request['name']);
- $request['title'] =
$this->db->db_addslashes($request['title']);
-
- $values= array(
- $request['request_id'],
- $request['title'],
- $this->account,
- $request['cat_id'],
- $request['descr'],
- $request['location_code'],
- $address,
- time(),
- $request['budget'],
- $request['status'],
- $request['branch_id'],
- $request['coordinator'],
- $request['authorities_demands']);
-
- $values = $this->bocommon->validate_db_insert($values);
-
- $this->db->transaction_begin();
-
- $this->db->query("insert into fm_request
(id,title,owner,category,descr,location_code,"
- .
"address,entry_date,budget,status,branch_id,coordinator,"
- . "authorities_demands $cols) "
- . "VALUES ($values $vals )",__LINE__,__FILE__);
-
- while (is_array($request['condition']) &&
list($condition_type,$value_type) = each($request['condition']))
- {
- $this->db->query("INSERT INTO
fm_request_condition
(request_id,condition_type,degree,probability,consequence,user_id,entry_date) "
- . "VALUES ('"
- . $request['request_id']. "','"
- . $condition_type . "',"
- . $value_type['degree']. ","
- . $value_type['probability']. ","
- . $value_type['consequence']. ","
- . $this->account . ","
- . time() . ")",__LINE__,__FILE__);
- }
-
- $this->update_score($request['request_id']);
-
-
- if($request['extra']['contact_phone'] &&
$request['extra']['tenant_id'])
- {
- $this->db->query("update fm_tenant set
contact_phone='". $request['extra']['contact_phone']. "' where id='".
$request['extra']['tenant_id']. "'",__LINE__,__FILE__);
- }
-
- if ($request['power_meter'] )
- {
-
$this->soproject->update_power_meter($request['power_meter'],$request['location_code'],$address);
- }
-
- if($request['origin'][0]['data'][0]['id'])
- {
- $this->db->query("INSERT INTO fm_origin
(origin,origin_id,destination,destination_id,user_id,entry_date) "
- . "VALUES ('"
- . $request['origin'][0]['type']. "','"
- .
$request['origin'][0]['data'][0]['id']. "',"
- . "'request',"
- . $request['request_id']. ","
- . $this->account . ","
- . time() . ")",__LINE__,__FILE__);
- }
-
-
- if($this->db->transaction_commit())
- {
- $this->increment_request_id();
-
$this->historylog->add('SO',$request['request_id'],$request['status']);
-
$this->historylog->add('TO',$request['request_id'],$request['cat_id']);
-
$this->historylog->add('CO',$request['request_id'],$request['coordinator']);
- $receipt['message'][] =
array('msg'=>lang('request %1 has been saved',$request['request_id']));
- }
- else
- {
- $receipt['error'][] =
array('msg'=>lang('request %1 has not been saved',$request['request_id']));
- }
- return $receipt;
- }
-
- function edit($request)
- {
- while (is_array($request['location']) &&
list($input_name,$value) = each($request['location']))
- {
- $vals[] = "$input_name = '$value'";
- }
-
- while (is_array($request['extra']) &&
list($input_name,$value) = each($request['extra']))
- {
- $vals[] = "$input_name = '$value'";
- }
-
- if($vals)
- {
- $vals = "," . implode(",",$vals);
- }
-
- if($request['street_name'])
- {
- $address[]= $request['street_name'];
- $address[]= $request['street_number'];
- $address = $this->db->db_addslashes(implode("
", $address));
- }
-
- if(!$address)
- {
- $address =
$this->db->db_addslashes($request['location_name']);
- }
-
-
- $request['descr'] =
$this->db->db_addslashes($request['descr']);
- $request['name'] =
$this->db->db_addslashes($request['name']);
- $request['title'] =
$this->db->db_addslashes($request['title']);
-//_debug_array($request);
-
- $this->db->transaction_begin();
-
- $this->db->query("DELETE FROM fm_request_condition
WHERE request_id='" . $request['request_id'] . "'",__LINE__,__FILE__);
- while (is_array($request['condition']) &&
list($condition_type,$value_type) = each($request['condition']))
- {
- $this->db->query("INSERT INTO
fm_request_condition
(request_id,condition_type,degree,probability,consequence,user_id,entry_date) "
- . "VALUES ('"
- . $request['request_id']. "','"
- . $condition_type . "',"
- . $value_type['degree']. ","
- . $value_type['probability']. ","
- . $value_type['consequence']. ","
- . $this->account . ","
- . time() . ")",__LINE__,__FILE__);
- }
-
- $this->update_score($request['request_id']);
-
- if($request['extra']['contact_phone'] &&
$request['extra']['tenant_id'])
- {
- $this->db->query("update fm_tenant set
contact_phone='". $request['extra']['contact_phone']. "' where id='".
$request['extra']['tenant_id']. "'",__LINE__,__FILE__);
- }
-
- if ($request['power_meter'] )
- {
-
$this->soproject->update_power_meter($request['power_meter'],$request['location_code'],$address);
- }
-
- if($this->db->transaction_commit())
- {
- $this->db->query("SELECT
status,category,coordinator FROM fm_request where id='"
.$request['request_id']."'",__LINE__,__FILE__);
- $this->db->next_record();
-
- $old_status = $this->db->f('status');
- $old_categroy = $this->db->f('category');
- $old_coordinator = $this->db->f('coordinator');
- if ($old_status != $request['status'])
- {
-
$this->historylog->add('S',$request['request_id'],$request['status']);
- }
- if ($old_categroy != $request['cat_id'])
- {
-
$this->historylog->add('T',$request['request_id'],$request['cat_id']);
- }
- if ($old_coordinator != $request['coordinator'])
- {
-
$this->historylog->add('C',$request['request_id'],$request['coordinator']);
- }
-
- $receipt['message'][] =
array('msg'=>lang('request %1 has been edited',$request['request_id']));
- }
- else
- {
- $receipt['message'][] =
array('msg'=>lang('request %1 has not been edited',$request['request_id']));
- }
- return $receipt;
-
- }
-
- function delete($request_id )
- {
- $this->db->query("DELETE FROM fm_request WHERE id='" .
$request_id . "'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_request_condition
WHERE request_id='" . $request_id . "'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_request_history WHERE
history_record_id='" . $request_id . "'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_origin WHERE
destination = 'request' AND destination_id='" . $request_id .
"'",__LINE__,__FILE__);
-
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage project
+ * @version $Id: class.sorequest.inc.php,v 1.12 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class sorequest
+ {
+ function sorequest()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->soproject =
CreateObject($this->currentapp.'.soproject');
+ $this->historylog =
CreateObject($this->currentapp.'.historylog','request');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->like = $this->bocommon->like;
+ }
+
+ function select_category_workorder_list()
+ {
+
+ $this->db->query("SELECT id, descr FROM
fm_workorder_category ORDER BY descr ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $categories[$i]['id']
= $this->db->f('id');
+ $categories[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $categories;
+ }
+
+ function read_priority_key()
+ {
+ $this->db->query("SELECT * FROM
fm_request_condition_type",__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $priority_key[] = array(
+ 'id' => $this->db->f('id'),
+ 'descr' =>
$this->db->f('descr'),
+ 'priority_key' =>
$this->db->f('priority_key')
+ );
+ }
+
+ return $priority_key;
+ }
+
+ function update_priority_key($values)
+ {
+
+ while (is_array($values['priority_key']) &&
list($id,$priority_key) = each($values['priority_key']))
+ {
+ $this->db->query("UPDATE
fm_request_condition_type SET priority_key = $priority_key WHERE id =
$id",__LINE__,__FILE__);
+ }
+
+ $this->update_score();
+
+ $receipt['message'][] = array('msg'=> lang('priority
keys has been updated'));
+ return $receipt;
+
+ }
+
+
+ function update_score($request_id='')
+ {
+ if($request_id)
+ {
+ $request[] = $request_id;
+ }
+ else
+ {
+ $this->db->query("SELECT id FROM
fm_request",__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $request[] = $this->db->f('id');
+ }
+ }
+
+ while (is_array($request) && list(,$id) =
each($request))
+ {
+
+
if($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
+ {
+ $sql = "UPDATE fm_request SET score =
(SELECT sum(priority_key * ( degree * probability * ( consequence +1 ))) FROM
fm_request_condition"
+ . " $this->join
fm_request_condition_type ON (fm_request_condition.condition_type =
fm_request_condition_type.id) WHERE request_id = $id) WHERE fm_request.id =
$id";
+
+
$this->db->query($sql,__LINE__,__FILE__);
+ }
+ else
+ {
+ $sql = "SELECT sum(priority_key * (
degree * probability * ( consequence +1 ))) AS score FROM fm_request_condition"
+ . " $this->join
fm_request_condition_type ON (fm_request_condition.condition_type =
fm_request_condition_type.id) WHERE request_id = $id";
+
+
$this->db->query($sql,__LINE__,__FILE__);
+
+ $this->db->next_record();
+ $score = $this->db->f('score');
+ $this->db->query("UPDATE fm_request SET
score = $score WHERE id = $id",__LINE__,__FILE__);
+ }
+ }
+ }
+
+
+ function read_single_request_category($id='')
+ {
+ $this->db->query("SELECT descr FROM
fm_workorder_category where id='$id' ");
+ $this->db->next_record();
+ return $this->db->f('descr');
+ }
+
+ function select_status_list()
+ {
+ $this->db->query("SELECT id, descr FROM
fm_request_status ORDER BY id ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $status_entries[$i]['id']
= $this->db->f('id');
+ $status_entries[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $status_entries;
+ }
+
+ function select_condition_type_list()
+ {
+ $this->db->query("SELECT id, descr FROM
fm_request_condition_type ORDER BY id ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $condition_type_list[$i]['id'] =
$this->db->f('id');
+ $condition_type_list[$i]['name'] =
stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $condition_type_list;
+ }
+
+ function
select_conditions($request_id='',$condition_type_list='')
+ {
+ for ($i=0;$i<count($condition_type_list);$i++)
+ {
+ $this->db->query("SELECT
degree,probability,consequence FROM fm_request_condition WHERE
request_id=$request_id AND condition_type =" . $condition_type_list[$i]['id']);
+ $this->db->next_record();
+ $conditions[$i]['request_id'] =
$request_id;
+ $conditions[$i]['degree'] =
$this->db->f('degree');
+ $conditions[$i]['probability'] =
$this->db->f('probability');
+ $conditions[$i]['consequence'] =
$this->db->f('consequence');
+ }
+
+ return $conditions;
+ }
+
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $status_id =
(isset($data['status_id'])?$data['status_id']:0);
+ $project_id =
(isset($data['project_id'])?$data['project_id']:'');
+ }
+
+ $entity_table = 'fm_request';
+
+ $cols .= $entity_table . '.location_code';
+ $cols_return[] = 'location_code';
+
+ $cols .= ",$entity_table.id as request_id";
+ $cols_return[] = 'request_id';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'request_id';
+ $uicols['descr'][] =
lang('Request');
+ $uicols['statustext'][] = lang('Request ID');
+
+ $cols.= ",$entity_table.entry_date";
+ $cols_return[] = 'entry_date';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'entry_date';
+ $uicols['descr'][] = lang('entry
date');
+ $uicols['statustext'][] = lang('Request entry
date');
+
+ $cols.= ",$entity_table.title as title";
+ $cols_return[] = 'title';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'title';
+ $uicols['descr'][] = lang('title');
+ $uicols['statustext'][] = lang('Request title');
+
+ $cols.= ",$entity_table.coordinator";
+ $cols_return[] = 'coordinator';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'coordinator';
+ $uicols['descr'][] =
lang('Coordinator');
+ $uicols['statustext'][] = lang('Project
coordinator');
+
+ $cols.= ",$entity_table.score";
+ $cols_return[] = 'score';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'score';
+ $uicols['descr'][] = lang('score');
+ $uicols['statustext'][] = lang('score');
+
+ $sql =
$this->bocommon->generate_sql(array('entity_table'=>$entity_table,'cols'=>$cols,'cols_return'=>$cols_return,
+
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query));
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by fm_request.id ASC';
+ }
+
+ $where = 'WHERE';
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " $where
fm_request.category='$cat_id' ";
+ $where = 'AND';
+ }
+
+ if ($status_id)
+ {
+ $filtermethod .= " $where
fm_request.status='$status_id' ";
+ $where = 'AND';
+ }
+
+ if ($filter)
+ {
+ $filtermethod .= " $where
fm_request.coordinator='$filter' ";
+ $where = 'AND';
+ }
+
+ if ($project_id)// lookup requests not already
allocated to projects
+ {
+ $filtermethod .= " $where project_id is NULL ";
+ $where = 'AND';
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " $where (fm_request.title
$this->like '%$query%' or fm_request.address $this->like '%$query%' or
fm_request.location_code $this->like '%$query%')";
+ }
+
+ $sql .= " $filtermethod $querymethod";
+
+ $this->uicols = $this->bocommon->uicols;
+ $cols_return = $this->bocommon->cols_return;
+ $type_id =
$this->bocommon->type_id;
+ $this->cols_extra = $this->bocommon->cols_extra;
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+
+
+ $j=0;
+ while ($this->db->next_record())
+ {
+ for ($i=0;$i<count($cols_return);$i++)
+ {
+ $request_list[$j][$cols_return[$i]] =
stripslashes($this->db->f($cols_return[$i]));
+ }
+
+ $location_code= $this->db->f('location_code');
+ $location = split('-',$location_code);
+ for ($m=0;$m<count($location);$m++)
+ {
+ $request_list[$j]['loc' . ($m+1)] =
$location[$m];
+
$request_list[$j]['query_location']['loc' . ($m+1)]=implode("-",
array_slice($location, 0, ($m+1)));
+ }
+
+ $j++;
+ }
+//_debug_array($request_list);
+ return $request_list;
+ }
+
+ function read_single($request_id)
+ {
+ $sql = "SELECT * from fm_request where
id='$request_id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $request['request_id']
= $this->db->f('id');
+ $request['title']
= $this->db->f('title');
+ $request['location_code']
= $this->db->f('location_code');
+ $request['descr']
= $this->db->f('descr');
+ $request['status']
= $this->db->f('status');
+ $request['budget']
= (int)$this->db->f('budget');
+ $request['tenant_id']
= $this->db->f('tenant_id');
+ $request['owner']
= $this->db->f('owner');
+ $request['coordinator']
= $this->db->f('coordinator');
+ $request['access']
= $this->db->f('access');
+ $request['start_date']
= $this->db->f('start_date');
+ $request['end_date']
= $this->db->f('end_date');
+ $request['cat_id']
= $this->db->f('category');
+
+ $request['branch_id']
= $this->db->f('branch_id');
+ $request['authorities_demands']
= $this->db->f('authorities_demands');
+ $request['score']
= $this->db->f('score');
+ $request['p_num']
= $this->db->f('p_num');
+ $request['p_entity_id']
= $this->db->f('p_entity_id');
+ $request['p_cat_id']
= $this->db->f('p_cat_id');
+ $request['contact_phone']
= $this->db->f('contact_phone');
+
+ $request['power_meter'] =
$this->soproject->get_power_meter($this->db->f('location_code'));
+ }
+
+ $sql = "SELECT * FROM fm_origin WHERE destination =
'request' AND destination_id='$request_id' ORDER by origin DESC ";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ $i=-1;
+ while ($this->db->next_record())
+ {
+ if($last_type != $this->db->f('origin'))
+ {
+ $i++;
+ }
+ $request['origin'][$i]['type'] =
$this->db->f('origin');
+ $request['origin'][$i]['link'] =
$this->bocommon->get_origin_link($this->db->f('origin'));
+ $request['origin'][$i]['data'][]= array(
+ 'id'=> $this->db->f('origin_id'),
+ 'type'=> $this->db->f('origin')
+ );
+
+ $last_type=$this->db->f('origin');
+ }
+
+ $sql = "SELECT * FROM fm_origin WHERE origin =
'request' AND origin_id='$request_id' ORDER by destination DESC ";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ if($last_type != $this->db->f('destination'))
+ {
+ $i++;
+ }
+ $request['origin'][$i]['type'] =
$this->db->f('destination');
+ $request['origin'][$i]['link'] =
$this->bocommon->get_origin_link($this->db->f('destination'));
+ $request['origin'][$i]['data'][]= array(
+ 'id'=> $this->db->f('destination_id'),
+ 'type'=> $this->db->f('destination')
+ );
+
+ $last_type=$this->db->f('destination');
+ }
+
+ return $request;
+ }
+
+ function request_workorder_data($request_id = '')
+ {
+ $this->db->query("select budget, id as workorder_id,
vendor_id from fm_workorder where request_id='$request_id'");
+ while ($this->db->next_record())
+ {
+ $budget[] = array(
+ 'workorder_id' =>
$this->db->f('workorder_id'),
+ 'budget' =>
sprintf("%01.2f",$this->db->f('budget')),
+ 'vendor_id' =>
$this->db->f('vendor_id')
+ );
+ }
+ return $budget;
+ }
+
+
+ function increment_request_id()
+ {
+ $this->db->query("update fm_idgenerator set value =
value + 1 where name = 'request'");
+ }
+
+ function next_id()
+ {
+ $this->db->query("select value from fm_idgenerator
where name = 'request'");
+ $this->db->next_record();
+ $id = $this->db->f('value')+1;
+ return $id;
+ }
+
+ function add($request)
+ {
+//_debug_array($request);
+ while (is_array($request['location']) &&
list($input_name,$value) = each($request['location']))
+ {
+ if($value)
+ {
+ $cols[] = $input_name;
+ $vals[] = $value;
+ }
+ }
+
+ while (is_array($request['extra']) &&
list($input_name,$value) = each($request['extra']))
+ {
+ if($value)
+ {
+ $cols[] = $input_name;
+ $vals[] = $value;
+ }
+ }
+
+ if($cols)
+ {
+ $cols = "," . implode(",", $cols);
+ $vals = ",'" . implode("','", $vals) . "'";
+ }
+
+ if($request['street_name'])
+ {
+ $address[]= $request['street_name'];
+ $address[]= $request['street_number'];
+ $address =
$this->db->db_addslashes(implode(" ", $address));
+ }
+
+ if(!$address)
+ {
+ $address =
$this->db->db_addslashes($request['location_name']);
+ }
+
+ $request['descr'] =
$this->db->db_addslashes($request['descr']);
+ $request['name'] =
$this->db->db_addslashes($request['name']);
+ $request['title'] =
$this->db->db_addslashes($request['title']);
+
+ $values= array(
+ $request['request_id'],
+ $request['title'],
+ $this->account,
+ $request['cat_id'],
+ $request['descr'],
+ $request['location_code'],
+ $address,
+ time(),
+ $request['budget'],
+ $request['status'],
+ $request['branch_id'],
+ $request['coordinator'],
+ $request['authorities_demands']);
+
+ $values = $this->bocommon->validate_db_insert($values);
+
+ $this->db->transaction_begin();
+
+ $this->db->query("insert into fm_request
(id,title,owner,category,descr,location_code,"
+ .
"address,entry_date,budget,status,branch_id,coordinator,"
+ . "authorities_demands $cols) "
+ . "VALUES ($values $vals )",__LINE__,__FILE__);
+
+ while (is_array($request['condition']) &&
list($condition_type,$value_type) = each($request['condition']))
+ {
+ $this->db->query("INSERT INTO
fm_request_condition
(request_id,condition_type,degree,probability,consequence,user_id,entry_date) "
+ . "VALUES ('"
+ . $request['request_id']. "','"
+ . $condition_type . "',"
+ . $value_type['degree']. ","
+ . $value_type['probability']. ","
+ . $value_type['consequence']. ","
+ . $this->account . ","
+ . time() . ")",__LINE__,__FILE__);
+ }
+
+ $this->update_score($request['request_id']);
+
+
+ if($request['extra']['contact_phone'] &&
$request['extra']['tenant_id'])
+ {
+ $this->db->query("update fm_tenant set
contact_phone='". $request['extra']['contact_phone']. "' where id='".
$request['extra']['tenant_id']. "'",__LINE__,__FILE__);
+ }
+
+ if ($request['power_meter'] )
+ {
+
$this->soproject->update_power_meter($request['power_meter'],$request['location_code'],$address);
+ }
+
+ if($request['origin'][0]['data'][0]['id'])
+ {
+ $this->db->query("INSERT INTO fm_origin
(origin,origin_id,destination,destination_id,user_id,entry_date) "
+ . "VALUES ('"
+ . $request['origin'][0]['type']. "','"
+ .
$request['origin'][0]['data'][0]['id']. "',"
+ . "'request',"
+ . $request['request_id']. ","
+ . $this->account . ","
+ . time() . ")",__LINE__,__FILE__);
+ }
+
+
+ if($this->db->transaction_commit())
+ {
+ $this->increment_request_id();
+
$this->historylog->add('SO',$request['request_id'],$request['status']);
+
$this->historylog->add('TO',$request['request_id'],$request['cat_id']);
+
$this->historylog->add('CO',$request['request_id'],$request['coordinator']);
+ $receipt['message'][] =
array('msg'=>lang('request %1 has been saved',$request['request_id']));
+ }
+ else
+ {
+ $receipt['error'][] =
array('msg'=>lang('request %1 has not been saved',$request['request_id']));
+ }
+ return $receipt;
+ }
+
+ function edit($request)
+ {
+ while (is_array($request['location']) &&
list($input_name,$value) = each($request['location']))
+ {
+ $vals[] = "$input_name = '$value'";
+ }
+
+ while (is_array($request['extra']) &&
list($input_name,$value) = each($request['extra']))
+ {
+ $vals[] = "$input_name = '$value'";
+ }
+
+ if($vals)
+ {
+ $vals = "," . implode(",",$vals);
+ }
+
+ if($request['street_name'])
+ {
+ $address[]= $request['street_name'];
+ $address[]= $request['street_number'];
+ $address = $this->db->db_addslashes(implode("
", $address));
+ }
+
+ if(!$address)
+ {
+ $address =
$this->db->db_addslashes($request['location_name']);
+ }
+
+
+ $request['descr'] =
$this->db->db_addslashes($request['descr']);
+ $request['name'] =
$this->db->db_addslashes($request['name']);
+ $request['title'] =
$this->db->db_addslashes($request['title']);
+//_debug_array($request);
+
+ $this->db->transaction_begin();
+
+ $this->db->query("DELETE FROM fm_request_condition
WHERE request_id='" . $request['request_id'] . "'",__LINE__,__FILE__);
+ while (is_array($request['condition']) &&
list($condition_type,$value_type) = each($request['condition']))
+ {
+ $this->db->query("INSERT INTO
fm_request_condition
(request_id,condition_type,degree,probability,consequence,user_id,entry_date) "
+ . "VALUES ('"
+ . $request['request_id']. "','"
+ . $condition_type . "',"
+ . $value_type['degree']. ","
+ . $value_type['probability']. ","
+ . $value_type['consequence']. ","
+ . $this->account . ","
+ . time() . ")",__LINE__,__FILE__);
+ }
+
+ $this->update_score($request['request_id']);
+
+ if($request['extra']['contact_phone'] &&
$request['extra']['tenant_id'])
+ {
+ $this->db->query("update fm_tenant set
contact_phone='". $request['extra']['contact_phone']. "' where id='".
$request['extra']['tenant_id']. "'",__LINE__,__FILE__);
+ }
+
+ if ($request['power_meter'] )
+ {
+
$this->soproject->update_power_meter($request['power_meter'],$request['location_code'],$address);
+ }
+
+ if($this->db->transaction_commit())
+ {
+ $this->db->query("SELECT
status,category,coordinator FROM fm_request where id='"
.$request['request_id']."'",__LINE__,__FILE__);
+ $this->db->next_record();
+
+ $old_status = $this->db->f('status');
+ $old_categroy = $this->db->f('category');
+ $old_coordinator = $this->db->f('coordinator');
+ if ($old_status != $request['status'])
+ {
+
$this->historylog->add('S',$request['request_id'],$request['status']);
+ }
+ if ($old_categroy != $request['cat_id'])
+ {
+
$this->historylog->add('T',$request['request_id'],$request['cat_id']);
+ }
+ if ($old_coordinator != $request['coordinator'])
+ {
+
$this->historylog->add('C',$request['request_id'],$request['coordinator']);
+ }
+
+ $receipt['message'][] =
array('msg'=>lang('request %1 has been edited',$request['request_id']));
+ }
+ else
+ {
+ $receipt['message'][] =
array('msg'=>lang('request %1 has not been edited',$request['request_id']));
+ }
+ return $receipt;
+
+ }
+
+ function delete($request_id )
+ {
+ $this->db->query("DELETE FROM fm_request WHERE id='" .
$request_id . "'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_request_condition
WHERE request_id='" . $request_id . "'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_request_history WHERE
history_record_id='" . $request_id . "'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_origin WHERE
destination = 'request' AND destination_id='" . $request_id .
"'",__LINE__,__FILE__);
+
+ }
+ }
+?>
Index: property/inc/class.sos_agreement.inc.php
diff -u property/inc/class.sos_agreement.inc.php:1.14
property/inc/class.sos_agreement.inc.php:1.15
--- property/inc/class.sos_agreement.inc.php:1.14 Fri Aug 19 11:56:50 2005
+++ property/inc/class.sos_agreement.inc.php Fri Jan 27 14:05:43 2006
@@ -1,1444 +1,1443 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage agreement
- * @version $Id: class.sos_agreement.inc.php,v 1.14 2005/08/19 11:56:50
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class sos_agreement
- {
- var $role;
-
- function sos_agreement()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->join = $this->bocommon->join;
- $this->left_join = $this->bocommon->left_join;
- $this->like = $this->bocommon->like;
- }
-
- function select_category_list()
- {
- $table = 'fm_s_agreement' . '_category';
- $this->db->query("SELECT id,descr FROM $table ORDER BY
descr ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $categories[$i]['id']
= $this->db->f('id');
- $categories[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $categories;
- }
-
- function select_vendor_list()
- {
- $table = 'fm_s_agreement';
- $this->db->query("SELECT vendor_id,org_name FROM $table
$this->join fm_vendor on fm_s_agreement.vendor_id=fm_vendor.id GROUP BY
org_name,vendor_id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $vendor[$i]['id']
= $this->db->f('vendor_id');
- $vendor[$i]['name']
= stripslashes($this->db->f('org_name'));
- $i++;
- }
- return $vendor;
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- $start =
(isset($data['start'])?$data['start']:0);
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
- $vendor_id =
(isset($data['vendor_id'])?$data['vendor_id']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $member_id =
(isset($data['member_id'])?$data['member_id']:0);
- $s_agreement_id =
(isset($data['s_agreement_id'])?$data['s_agreement_id']:'');
- $detail =
(isset($data['detail'])?$data['detail']:'');
- }
-
- $choice_table = 'fm_s_agreement_choice';
- $attribute_table = 'fm_s_agreement_attribute';
-
- if(!$detail)
- {
- $entity_table = 'fm_s_agreement';
- $category_table = 'fm_s_agreement_category';
- $attribute_filter = " AND attrib_detail = 1";
-
- $paranthesis .='(';
- $joinmethod .= " $this->join $category_table ON
( $entity_table.category =$category_table.id))";
- $paranthesis .='(';
- $joinmethod .= " $this->join fm_vendor ON (
$entity_table.vendor_id =fm_vendor.id))";
-
- $cols = $entity_table .
".*,$category_table.descr as category, org_name";
-
- $cols_return[] = 'id';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'id';
- $uicols['descr'][] =
lang('ID');
- $uicols['statustext'][] = lang('ID');
-
- $cols_return[] =
'name';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'name';
- $uicols['descr'][] =
lang('name');
- $uicols['statustext'][] = lang('name');
-
- $cols_return[] =
'org_name';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'org_name';
- $uicols['descr'][] =
lang('vendor');
- $uicols['statustext'][] =
lang('vendor');
-
- $cols_return[] =
'category';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'category';
- $uicols['descr'][] =
lang('category');
- $uicols['statustext'][] =
lang('category');
-
- $cols_return[] =
'start_date';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'start_date';
- $uicols['descr'][] =
lang('start');
- $uicols['statustext'][] = lang('start
date');
-
- $cols_return[] =
'end_date';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'end_date';
- $uicols['descr'][] =
lang('end');
- $uicols['statustext'][] = lang('end
date');
-
- }
- else
- {
- $allrows=True;
- $entity_table = 'fm_s_agreement_detail';
- $attribute_filter = " AND attrib_detail = 2";
-
- $paranthesis .='(';
- $joinmethod .= " $this->join
fm_s_agreement_pricing ON ( $entity_table.agreement_id
=fm_s_agreement_pricing.agreement_id AND $entity_table.id
=fm_s_agreement_pricing.item_id))";
-
-
-
- $cols = "$entity_table.*,
fm_s_agreement_pricing.cost,fm_s_agreement_pricing.id as
index_count,fm_s_agreement_pricing.index_date,fm_s_agreement_pricing.item_id,fm_s_agreement_pricing.this_index";
-
- $cols_return[] =
'agreement_id';
- $uicols['input_type'][] = 'hidden';
- $uicols['name'][] =
'agreement_id';
- $uicols['descr'][] =
lang('agreement_id');
- $uicols['statustext'][] =
lang('agreement_id');
-
- $cols_return[] =
'item_id';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'item_id';
- $uicols['descr'][] =
lang('ID');
- $uicols['statustext'][] = lang('ID');
-
- $cols_return[] = 'id';
- $uicols['input_type'][] = 'hidden';
- $uicols['name'][] = 'id';
- $uicols['descr'][] = False;
- $uicols['statustext'][] = False;
-
- $cols_return[] =
'location_code';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'location_code';
- $uicols['descr'][] =
lang('location');
- $uicols['statustext'][] =
lang('location');
-
- $cols_return[] =
'address';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'address';
- $uicols['descr'][] =
lang('address');
- $uicols['statustext'][] =
lang('address');
-
- $cols_return[] =
'p_num';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'p_num';
- $uicols['descr'][] =
lang('entity num');
- $uicols['statustext'][] = lang('entity
num');
-
- $cols_return[] =
'cost';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'cost';
- $uicols['descr'][] =
lang('cost');
- $uicols['statustext'][] = lang('cost');
-
- $cols_return[] =
'this_index';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'this_index';
- $uicols['descr'][] =
lang('index');
- $uicols['statustext'][] = lang('index');
-
- $cols_return[] =
'index_count';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'index_count';
- $uicols['descr'][] =
lang('index_count');
- $uicols['statustext'][] =
lang('index_count');
-
- $cols_return[] =
'index_date';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'index_date';
- $uicols['descr'][] =
lang('date');
- $uicols['statustext'][] = lang('date');
- }
-
- $from .= " FROM $paranthesis $entity_table ";
-
- $sql = "SELECT $cols $from $joinmethod";
-
- $i = count($uicols['name']);
-
- $this->db->query("SELECT * FROM $attribute_table WHERE
list=1 $attribute_filter ");
- while ($this->db->next_record())
- {
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
$this->db->f('column_name');
- $uicols['descr'][] =
$this->db->f('input_text');
- $uicols['statustext'][] =
$this->db->f('statustext');
- $uicols['datatype'][$i] =
$this->db->f('datatype');
- $cols_return_extra[]= array(
- 'name' => $this->db->f('column_name'),
- 'datatype' =>
$this->db->f('datatype'),
- 'attrib_id' => $this->db->f('id')
- );
-
- $i++;
- }
-
-
$user_columns=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['s_agreement_columns'
. !!$s_agreement_id];
-
-//_debug_array($user_columns);
-
- if (isset($user_columns) AND is_array($user_columns)
AND $user_columns[0])
- {
- foreach($user_columns as $column_id)
- {
- $this->db->query("SELECT * FROM
$attribute_table WHERE id= $column_id");
-
- $this->db->next_record();
- $uicols['input_type'][] =
'text';
- $uicols['name'][]
= $this->db->f('column_name');
- $uicols['descr'][]
= $this->db->f('input_text');
- $uicols['statustext'][] =
$this->db->f('statustext');
- $uicols['datatype'][$i] =
$this->db->f('datatype');
- $cols_return_extra[]= array(
- 'name' =>
$this->db->f('column_name'),
- 'datatype' =>
$this->db->f('datatype'),
- 'attrib_id' =>
$this->db->f('id')
- );
- $i++;
- }
- }
-
- $this->uicols = $uicols;
-
-//_debug_array($cols_return_extra);
- if ($order)
- {
- if ($order=='id')
- {
- $ordermethod = " order by
$entity_table.$order $sort";
- }
- else
- {
- $ordermethod = " order by $order $sort";
- }
- }
- else
- {
- $ordermethod = " order by $entity_table.id
DESC";
- }
-
- $where= 'WHERE';
-
-/* if ($filter=='all')
- {
- if (is_array($grants))
- {
- while (list($user) = each($grants))
- {
- $public_user_list[] = $user;
- }
- reset($public_user_list);
- $filtermethod .= " $where (
$entity_table.user_id IN(" . implode(',',$public_user_list) . "))";
-
- $where= 'AND';
- }
-
- }
- else
- {
- $filtermethod = " $where
$entity_table.user_id=$filter ";
- $where= 'AND';
- }
-*/
-
- if ($s_agreement_id)
- {
- $filtermethod .= " $where
$entity_table.agreement_id=$s_agreement_id AND current_index = 1";
- $where= 'AND';
- }
-
- if ($cat_id)
- {
- $filtermethod .= " $where
$entity_table.category='$cat_id' ";
- $where= 'AND';
- }
-
- if ($vendor_id)
- {
- $filtermethod .= " $where
$entity_table.vendor_id='$vendor_id' ";
- $where= 'AND';
- }
-
- if ($member_id>0)
- {
- $filtermethod .= " $where
$entity_table.member_of $this->like '%,$member_id,%' ";
- $where= 'AND';
- }
-
- if ($status)
- {
- $filtermethod .= " $where
$entity_table.status='$status' ";
- $where= 'AND';
- }
-
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $this->db->query("SELECT * FROM
$attribute_table where search='1'");
-
- while ($this->db->next_record())
- {
- if($this->db->f('datatype')=='V' ||
$this->db->f('datatype')=='email' || $this->db->f('datatype')=='CH')
- {
- $querymethod[]=
"$entity_table." . $this->db->f('column_name') . " $this->like '%$query%'";
- }
- else
- {
- $querymethod[]=
"$entity_table." . $this->db->f('column_name') . " = '$query'";
- }
- }
-
- if (isset($querymethod) AND
is_array($querymethod))
- {
- $querymethod = " $where (" . implode ('
OR ',$querymethod) . ')';
- $where = 'AND';
- }
- }
-
- $sql .= " $filtermethod $querymethod";
-//echo $sql;
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- $j=0;
- $n=count($cols_return);
-//_debug_array($cols_return);
-
- $contacts =
CreateObject('phpgwapi.contacts');
-
- while ($this->db->next_record())
- {
- for ($i=0;$i<$n;$i++)
- {
- $s_agreement_list[$j][$cols_return[$i]]
= stripslashes($this->db->f($cols_return[$i]));
- $s_agreement_list[$j]['grants'] =
(int)$grants[$this->db->f('user_id')];
- }
-
- for ($i=0;$i<count($cols_return_extra);$i++)
- {
- $value='';
-
$value=$this->db->f($cols_return_extra[$i]['name']);
-
-
if(($cols_return_extra[$i]['datatype']=='R' ||
$cols_return_extra[$i]['datatype']=='LB') && $value):
- {
- $sql="SELECT value FROM
$choice_table where attrib_id=" .$cols_return_extra[$i]['attrib_id']. " AND
id=" . $value . $attribute_filter;
- $this->db2->query($sql);
- $this->db2->next_record();
-
$s_agreement_list[$j][$cols_return_extra[$i]['name']] = $this->db2->f('value');
- }
-
elseif($cols_return_extra[$i]['datatype']=='AB' && $value):
- {
- $contact_data =
$contacts->read_single_entry($value,array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
-
$s_agreement_list[$j][$cols_return_extra[$i]['name']] =
$contact_data[0]['n_family'] . ', ' . $contact_data[0]['n_given'];
-
- }
-
elseif($cols_return_extra[$i]['datatype']=='VENDOR' && $value):
- {
- $sql="SELECT org_name FROM
fm_vendor where id=$value";
- $this->db2->query($sql);
- $this->db2->next_record();
-
$s_agreement_list[$j][$cols_return_extra[$i]['name']] =
$this->db2->f('org_name');
- }
-
elseif($cols_return_extra[$i]['datatype']=='CH' && $value):
- {
- $ch= unserialize($value);
-
- if (isset($ch) AND
is_array($ch))
- {
- for
($k=0;$k<count($ch);$k++)
- {
- $sql="SELECT
value FROM $choice_table where attrib_id="
.$cols_return_extra[$i]['attrib_id']. " AND id=" . $ch[$k] . $attribute_filter;
-
$this->db2->query($sql);
- while
($this->db2->next_record())
- {
-
$ch_value[]=$this->db2->f('value');
- }
- }
-
$s_agreement_list[$j][$cols_return_extra[$i]['name']] = @implode(",",
$ch_value);
- unset($ch_value);
- }
- }
-
elseif($cols_return_extra[$i]['datatype']=='D' && $value):
- {
-//html_print_r($value);
-
-
$s_agreement_list[$j][$cols_return_extra[$i]['name']]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($value));
- }
- else:
- {
-
$s_agreement_list[$j][$cols_return_extra[$i]['name']]=$value;
- }
- endif;
- }
-
- $j++;
- }
-//html_print_r($s_agreement_list);
- return $s_agreement_list;
- }
-
- function read_prizing($data)
- {
- if(is_array($data))
- {
- $s_agreement_id =
(isset($data['s_agreement_id'])?$data['s_agreement_id']:0);
- $item_id =
(isset($data['item_id'])?$data['item_id']:0);
- }
-
- $entity_table = 'fm_s_agreement_pricing';
-
- $cols =
"fm_s_agreement_pricing.cost,fm_s_agreement_pricing.id as
index_count,fm_s_agreement_pricing.index_date,fm_s_agreement_pricing.item_id,fm_s_agreement_pricing.this_index";
-
- $cols_return[] = 'item_id';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'item_id';
- $uicols['descr'][] = lang('ID');
- $uicols['statustext'][] = lang('ID');
-
- $cols_return[] = 'id';
- $uicols['input_type'][] = 'hidden';
- $uicols['name'][] = 'id';
- $uicols['descr'][] = False;
- $uicols['statustext'][] = False;
-
- $cols_return[] = 'cost';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'cost';
- $uicols['descr'][] = lang('cost');
- $uicols['statustext'][] = lang('cost');
-
- $cols_return[] = 'this_index';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'this_index';
- $uicols['descr'][] = lang('index');
- $uicols['statustext'][] = lang('index');
-
- $cols_return[] = 'index_count';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'index_count';
- $uicols['descr'][] =
lang('index_count');
- $uicols['statustext'][] = lang('index_count');
-
- $cols_return[] = 'index_date';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'index_date';
- $uicols['descr'][] = lang('date');
- $uicols['statustext'][] = lang('date');
-
- $from .= " FROM $entity_table ";
-
- $sql = "SELECT $cols $from $joinmethod";
-
-
- $this->uicols = $uicols;
-
- $ordermethod = " order by $entity_table.id ASC";
-
- $where= 'WHERE';
-
-
- if ($s_agreement_id)
- {
- $filtermethod .= " $where
$entity_table.agreement_id=$s_agreement_id AND item_id=$item_id";
- $where= 'AND';
- }
-
-
- $sql .= " $filtermethod";
-//echo $sql;
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- $j=0;
- $n=count($cols_return);
-//_debug_array($cols_return);
- while ($this->db->next_record())
- {
- for ($i=0;$i<$n;$i++)
- {
- $s_agreement_list[$j][$cols_return[$i]]
= $this->db->f($cols_return[$i]);
- $s_agreement_list[$j]['agreement_id'] =
$s_agreement_id;
- }
- $j++;
- }
-//_debug_array($s_agreement_list);
- return $s_agreement_list;
- }
-
-
- function read_single($data)
- {
- $attribute_table = 'fm_s_agreement_attribute';
- $table = 'fm_s_agreement';
-
- $s_agreement_id =$data['s_agreement_id'];
-
- $this->db->query("SELECT * FROM $attribute_table WHERE
attrib_detail = 1 ORDER BY attrib_sort");
-
- while ($this->db->next_record())
- {
- $s_agreement['attributes'][] = array
- (
- 'attrib_id' =>
$this->db->f('id'),
- 'name' =>
$this->db->f('column_name'),
- 'input_text' =>
stripslashes($this->db->f('input_text')),
- 'statustext' =>
stripslashes($this->db->f('statustext')),
- 'datatype' =>
$this->db->f('datatype')
- );
- }
-
- if($s_agreement_id)
- {
- $this->db->query("SELECT * from $table where
id='$s_agreement_id'");
-
- if($this->db->next_record())
- {
- $s_agreement['id']
= (int)$this->db->f('id');
- $s_agreement['entry_date']
= $this->db->f('entry_date');
- $s_agreement['cat_id']
= $this->db->f('category');
- $s_agreement['member_of']
= explode(',',$this->db->f('member_of'));
- $s_agreement['cat_id']
= $this->db->f('category');
- $s_agreement['start_date']
= $this->db->f('start_date');
- $s_agreement['end_date']
= $this->db->f('end_date');
- $s_agreement['termination_date']=
$this->db->f('termination_date');
- $s_agreement['vendor_id']
= $this->db->f('vendor_id');
- $s_agreement['b_account_id'] =
$this->db->f('account_id');
- $s_agreement['name']
= stripslashes($this->db->f('name'));
- $s_agreement['descr']
= stripslashes($this->db->f('descr'));
- $s_agreement['user_id']
= $this->db->f('user_id');
-
- for
($i=0;$i<count($s_agreement['attributes']);$i++)
- {
-
$s_agreement['attributes'][$i]['value'] =
$this->db->f($s_agreement['attributes'][$i]['name']);
-
$s_agreement['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($s_agreement['attributes'][$i]['datatype']);
- }
-
- }
- }
- return $s_agreement;
- }
-
- function read_single_item($data)
- {
- $attribute_table = 'fm_s_agreement_attribute';
- $table = 'fm_s_agreement_detail';
-
- $s_agreement_id =$data['s_agreement_id'];
- $id =$data['id'];
-
- $this->db->query("SELECT * FROM $attribute_table WHERE
attrib_detail = 2 ORDER BY attrib_sort");
-
- while ($this->db->next_record())
- {
- $item['attributes'][] = array
- (
- 'attrib_id' =>
$this->db->f('id'),
- 'name' =>
$this->db->f('column_name'),
- 'input_text' =>
stripslashes($this->db->f('input_text')),
- 'statustext' =>
stripslashes($this->db->f('statustext')),
- 'datatype' =>
$this->db->f('datatype')
- );
- }
-
- if($id && $s_agreement_id)
- {
- $this->db->query("SELECT * from $table where
agreement_id=$s_agreement_id AND id=$id");
-
- if($this->db->next_record())
- {
- $item['agreement_id'] =
(int)$this->db->f('agreement_id');
- $item['id']
= (int)$this->db->f('id');
- $item['entry_date'] =
$this->db->f('entry_date');
- $item['location_code'] =
$this->db->f('location_code');
- $item['p_num'] =
$this->db->f('p_num');
- $item['p_entity_id'] =
$this->db->f('p_entity_id');
- $item['p_cat_id'] =
$this->db->f('p_cat_id');
- $item['cost'] =
$this->db->f('cost');
-
- for
($i=0;$i<count($item['attributes']);$i++)
- {
-
$item['attributes'][$i]['value'] =
$this->db->f($item['attributes'][$i]['name']);
-
$item['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($item['attributes'][$i]['datatype']);
- }
-
- }
- }
- return $item;
- }
-
- function add($s_agreement,$values_attribute='')
- {
-//_debug_array($s_agreement);
- $table = 'fm_s_agreement';
- $s_agreement['name'] =
$this->db->db_addslashes($s_agreement['name']);
- $s_agreement['descr'] =
$this->db->db_addslashes($s_agreement['descr']);
-
- if($s_agreement['member_of'])
- {
- $s_agreement['member_of']=',' .
implode(',',$s_agreement['member_of']) . ',';
- }
-
-
- $this->db->transaction_begin();
- $id = $this->bocommon->increment_id('workorder');
-
- $vals[] = $id;
- $vals[] = $s_agreement['name'];
- $vals[] = $s_agreement['descr'];
- $vals[] = time();
- $vals[] = $s_agreement['cat_id'];
- $vals[] = $s_agreement['member_of'];
- $vals[] = $s_agreement['start_date'];
- $vals[] = $s_agreement['end_date'];
- $vals[] = $s_agreement['termination_date'];
- $vals[] = $s_agreement['vendor_id'];
- $vals[] = $s_agreement['b_account_id'];
- $vals[] = $this->account;
-
- while (is_array($s_agreement['extra']) &&
list($input_name,$value) = each($s_agreement['extra']))
- {
- if($value)
- {
- $cols[] = $input_name;
- $vals[] = $value;
- }
- }
-
- if (isset($values_attribute) AND
is_array($values_attribute))
- {
- foreach($values_attribute as $entry)
- {
- if($entry['value'])
- {
- $cols[] = $entry['name'];
- $vals[] = $entry['value'];
- }
- }
- }
-
- if($cols)
- {
- $cols = "," . implode(",", $cols);
- $vals =
$this->bocommon->validate_db_insert($vals);
- }
-
- $this->db->query("INSERT INTO $table
(id,name,descr,entry_date,category,member_of,start_date,end_date,termination_date,vendor_id,account_id,user_id
$cols) "
- . "VALUES ($vals)",__LINE__,__FILE__);
-
- $this->db->query("INSERT INTO fm_orders (id,type)
VALUES ($id,'s_agreement')");
-
- $receipt['s_agreement_id']=
$id;//$this->db->get_last_insert_id($table,'id');
-
- $receipt['message'][] = array('msg'=>lang('s_agreement
%1 has been saved',$receipt['s_agreement_id']));
-
- $this->db->transaction_commit();
- return $receipt;
- }
-
- function add_item($values,$values_attribute='')
- {
-//_debug_array($values);
- $table = 'fm_s_agreement_detail';
-
- $cols[] = 'location_code';
- $vals[] = $values['location_code'];
-
-/* while (is_array($values['location']) &&
list($input_name,$value) = each($values['location']))
- {
- if($value)
- {
- $cols[] = $input_name;
- $vals[] = $value;
- }
- }
-*/
- while (is_array($values['extra']) &&
list($input_name,$value) = each($values['extra']))
- {
- if($value)
- {
- $cols[] = $input_name;
- $vals[] = $value;
- }
- }
-
- if (isset($values_attribute) AND
is_array($values_attribute))
- {
- foreach($values_attribute as $entry)
- {
- if($entry['value'])
- {
- $cols[] = $entry['name'];
- $vals[] = $entry['value'];
- }
- }
- }
-
- if($values['street_name'])
- {
- $address[]= $values['street_name'];
- $address[]= $values['street_number'];
- $address = $this->db->db_addslashes(implode("
", $address));
- }
-
- if(!$address)
- {
- $address =
$this->db->db_addslashes($values['location_name']);
- }
-
- $cols[] = 'address';
- $vals[] = $address;
- $cols[] = 'cost';
- $vals[] = $this->floatval($values['cost']);
-
- if($cols)
- {
- $cols = "," . implode(",", $cols);
- $vals = "," .
$this->bocommon->validate_db_insert($vals);
- }
-
- $this->db->transaction_begin();
- $id =
$this->bocommon->next_id($table,array('agreement_id'=>$values['s_agreement_id']));
-
- $this->db->query("INSERT INTO $table
(id,agreement_id,entry_date,user_id $cols) "
- . "VALUES ($id," . $values['s_agreement_id']
."," . time()
- . "," . $this->account . " $vals)");
-
-
- $this->db->query("SELECT start_date FROM fm_s_agreement
WHERE id=" . $values['s_agreement_id']);
- $this->db->next_record();
- $start_date = $this->db->f('start_date');
-
-
- $this->db->query("INSERT INTO fm_s_agreement_pricing
(agreement_id,item_id,id,current_index,this_index,cost,index_date,entry_date,user_id)
"
- . "VALUES (" . $values['s_agreement_id'] . ","
. $id .",1,1,1," . $this->floatval($values['cost']) . "," . (int)$start_date .
"," . time()
- . "," . $this->account . ")");
-
- $receipt['s_agreement_id']= $values['s_agreement_id'];
- $receipt['id']= $id;
-
- $receipt['message'][] = array('msg'=>lang('s_agreement
%1 has been saved',$receipt['s_agreement_id']));
-
- $this->db->transaction_commit();
- return $receipt;
- }
-
- function edit($values,$values_attribute='')
- {
-//_debug_array($values);
-//_debug_array($values_attribute);
- $table = 'fm_s_agreement';
-
- $values['name'] =
$this->db->db_addslashes($values['name']);
-
- if($values['member_of'])
- {
- $values['member_of']=',' .
implode(',',$values['member_of']) . ',';
- }
-
- while (is_array($values['extra']) &&
list($column,$value) = each($values['extra']))
- {
- $value_set[$column] = $value;
- }
-
- if (isset($values_attribute) AND
is_array($values_attribute))
- {
- foreach($values_attribute as $entry)
- {
- if($entry['datatype']!='AB' &&
$entry['datatype']!='VENDOR')
- {
- $value_set[$entry['name']]
= $entry['value'];
- }
- }
- }
-
- $value_set['name'] = $values['name'];
- $value_set['descr'] = $values['descr'];
- if($value_set)
- {
- $value_set = ',' .
$this->bocommon->validate_db_update($value_set);
- }
-
- $this->db->query("UPDATE $table set entry_date='" .
time() . "', category='"
- . $values['cat_id'] .
"', member_of='" . $values['member_of'] . "', start_date=" .
intval($values['start_date']) . ", end_date=" . intval($values['end_date']) .
", termination_date=" . intval($values['termination_date']) . ", account_id=" .
intval($values['b_account_id']) . "$value_set WHERE id=" .
intval($values['s_agreement_id']));
-
- $this->db->query("UPDATE fm_s_agreement_pricing set
index_date=" . intval($values['start_date']) . " WHERE id=1 AND agreement_id= "
. intval($values['s_agreement_id']));
-
- $receipt['s_agreement_id']= $values['s_agreement_id'];
- $receipt['message'][] = array('msg'=>lang('s_agreement
%1 has been edited',$values['s_agreement_id']));
- return $receipt;
- }
-
- function edit_item($values,$values_attribute='')
- {
-//_debug_array($values);
-//_debug_array($values_attribute);
- $table = 'fm_s_agreement_detail';
-
- while (is_array($values['extra']) &&
list($column,$value) = each($values['extra']))
- {
- $value_set[$column] = $value;
- }
-
- if (isset($values_attribute) AND
is_array($values_attribute))
- {
- foreach($values_attribute as $entry)
- {
- if($entry['datatype']!='AB' &&
$entry['datatype']!='VENDOR')
- {
- $value_set[$entry['name']]
= $entry['value'];
- }
- }
- }
-
- if($values['street_name'])
- {
- $address[]= $values['street_name'];
- $address[]= $values['street_number'];
- $address =
$this->db->db_addslashes(implode(" ", $address));
- }
-
- if(!$address)
- {
- $address =
$this->db->db_addslashes($values['location_name']);
- }
-
- $value_set['location_code'] =
$values['location_code'];
- $value_set['cost'] = $values['cost'];
- $value_set['address'] = $address;
-
- if($value_set)
- {
- $value_set = ',' .
$this->bocommon->validate_db_update($value_set);
- }
-
- $this->db->query("UPDATE $table set entry_date=" .
time() . "$value_set WHERE agreement_id=" . intval($values['s_agreement_id']) .
' AND id=' . intval($values['id']));
-
- $this->db->query("UPDATE fm_s_agreement_pricing set
cost = this_index *" . $this->floatval($values['cost']) . " WHERE
agreement_id=" . intval($values['s_agreement_id']) . ' AND item_id=' .
intval($values['id']));
-
- $receipt['s_agreement_id']= $values['s_agreement_id'];
- $receipt['id']= $values['id'];
- $receipt['message'][] = array('msg'=>lang('s_agreement
%1 has been edited',$values['s_agreement_id']));
- return $receipt;
- }
-
- function update($values)
- {
-//_debug_array($values);
-
$values['new_index']=$this->floatval($values['new_index']);
- $this->db->transaction_begin();
-
- while (is_array($values['select']) &&
list($item_id,$value) = each($values['select']))
- {
-
- $this->db->query("UPDATE fm_s_agreement_pricing
set current_index = NULL WHERE agreement_id=" . intval($values['agreement_id'])
. ' AND item_id=' . intval($item_id));
-
- $this->db->query("INSERT INTO
fm_s_agreement_pricing
(agreement_id,item_id,id,current_index,this_index,cost,index_date,entry_date,user_id)"
- . "VALUES (" . $values['agreement_id']
. "," . $item_id ."," . ($values['id'][$item_id]+1) .",1,'" .
$values['new_index'] . "','" . ($value * $values['new_index']) . "'," .
(int)$values['date'] . "," . time()
- . "," . $this->account . ")");
-
- }
-
- $this->db->transaction_commit();
- $receipt['message'][] = array('msg'=>lang('s_agreement
%1 has been updated for index',$values['agreement_id']));
-
- return $receipt;
- }
-
- function floatval($strValue)
- {
- $floatValue =
ereg_replace("(^[0-9]*)(\\.|,)([0-9]*)(.*)", "\\1.\\3", $strValue);
- if(!is_numeric($floatValue))
- {
- $floatValue = ereg_replace("(^[0-9]*)(.*)",
"\\1", $strValue);
- }
- if(!is_numeric($floatValue))
- {
- $floatValue = 0;
- }
- return $floatValue;
- }
-
-
- function delete_last_index($s_agreement_id,$item_id)
- {
- $this->db->transaction_begin();
- $this->db->query("SELECT max(id) as index_count FROM
fm_s_agreement_pricing WHERE agreement_id=$s_agreement_id AND
item_id=$item_id");
- $this->db->next_record();
- $index_count = $this->db->f('index_count');
- if($index_count>1)
- {
- $this->db->query("DELETE FROM
fm_s_agreement_pricing WHERE agreement_id=$s_agreement_id AND item_id=$item_id
AND id=$index_count");
- $this->db->query("UPDATE fm_s_agreement_pricing
set current_index = 1 WHERE agreement_id=$s_agreement_id AND item_id=$item_id
AND id =" . ($index_count-1));
- }
- $this->db->transaction_commit();
- }
-
- function delete_item($s_agreement_id,$item_id)
- {
- $this->db->transaction_begin();
- $this->db->query("DELETE FROM fm_s_agreement_detail
WHERE agreement_id=$s_agreement_id AND id=$item_id");
- $this->db->query("DELETE FROM fm_s_agreement_pricing
WHERE agreement_id=$s_agreement_id AND item_id=$item_id");
- $this->db->transaction_commit();
- }
-
-
- function delete($s_agreement_id)
- {
- $table = 'fm_s_agreement';
- $this->db->transaction_begin();
- $this->db->query("DELETE FROM $table WHERE id=" .
intval($s_agreement_id));
- $this->db->query("DELETE FROM fm_s_agreement_detail
WHERE agreement_id=" . intval($s_agreement_id));
- $this->db->query("DELETE FROM fm_s_agreement_pricing
WHERE agreement_id=" . intval($s_agreement_id));
- $this->db->query("DELETE FROM fm_orders WHERE id=" .
intval($s_agreement_id));
- $this->db->transaction_commit();
- }
-
- function read_attrib($data)
- {
- $attribute_table = 'fm_s_agreement_attribute';
-//html_print_r($data);
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $column_list =
(isset($data['column_list'])?$data['column_list']:'');
- }
-
- $where = 'WHERE';
- if ($column_list)
- {
- $filtermethod = " $where list !=1 or list is
null";
- $where = 'AND';
- }
- if ($this->role=='detail')
- {
- $filtermethod .= " $where attrib_detail=2 ";
- }
- else
- {
- $filtermethod .= " $where attrib_detail=1 ";
- }
-
- $where = 'AND';
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by attrib_sort asc';
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " $where
($attribute_table.input_text $this->like '%$query%' or
$attribute_table.column_name $this->like '%$query%')";
- }
-
- $sql = "SELECT * FROM $attribute_table $filtermethod
$querymethod";
-
-//echo $sql;
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $attrib[] = array
- (
- 'id' =>
$this->db->f('id'),
- 'attrib_sort' =>
$this->db->f('attrib_sort'),
- 'list' =>
$this->db->f('list'),
- 'lookup_form' =>
$this->db->f('lookup_form'),
- 'column_name' =>
$this->db->f('column_name'),
- 'name' =>
$this->db->f('input_text'),
- 'size' =>
$this->db->f('size'),
- 'statustext' =>
$this->db->f('statustext'),
- 'input_text' =>
$this->db->f('input_text'),
- 'type_name' =>
$this->db->f('type'),
- 'datatype' =>
$this->db->f('datatype'),
- 'search' =>
$this->db->f('search')
- );
- }
- return $attrib;
- }
-
- function read_single_attrib($id)
- {
- $attribute_table = 'fm_s_agreement_attribute';
-
- if ($this->role=='detail')
- {
- $filtermethod = " AND attrib_detail=2 ";
- }
- else
- {
- $filtermethod = " AND attrib_detail=1 ";
- }
-
- $sql = "SELECT * FROM $attribute_table where id=$id
$filtermethod";
-
- $this->db->query($sql);
-
- if($this->db->next_record())
- {
- $attrib['id']
= $this->db->f('id');
- $attrib['column_name']
= $this->db->f('column_name');
- $attrib['input_text']
= $this->db->f('input_text');
- $attrib['statustext']
= $this->db->f('statustext');
- $attrib['column_info']['precision'] =
$this->db->f('precision_');
- $attrib['column_info']['scale'] =
$this->db->f('scale');
- $attrib['column_info']['default'] =
$this->db->f('default_value');
- $attrib['column_info']['nullable'] =
$this->db->f('nullable');
- $attrib['column_info']['type'] =
$this->db->f('datatype');
- $attrib['type_name']
= $this->db->f('type_name');
- $attrib['lookup_form']
= $this->db->f('lookup_form');
- $attrib['list']
= $this->db->f('list');
- $attrib['search']
= $this->db->f('search');
- if($this->db->f('datatype')=='R' ||
$this->db->f('datatype')=='CH' || $this->db->f('datatype')=='LB')
- {
- $attrib['choice'] =
$this->read_attrib_choice($id);
- }
-
- return $attrib;
- }
- }
-
- function read_attrib_choice($attrib_id)
- {
- $choice_table = 'fm_s_agreement_choice';
-
- if ($this->role=='detail')
- {
- $filtermethod = " AND attrib_detail=2 ";
- }
- else
- {
- $filtermethod = " AND attrib_detail=1 ";
- }
-
- $sql = "SELECT * FROM $choice_table WHERE
attrib_id=$attrib_id $filtermethod";
- $this->db->query($sql);
-
- while ($this->db->next_record())
- {
- $choice[] = array
- (
- 'id' => $this->db->f('id'),
- 'value' => $this->db->f('value')
- );
-
- }
- return $choice;
- }
-
- function add_attrib($attrib)
- {
- $attribute_table = 'fm_s_agreement_attribute';
- $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
- $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
- $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
- $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
- $attrib['id'] =
$this->bocommon->next_id($attribute_table, array('attrib_detail'=>!!$this->role
+1));
-
- if($this->role=='detail')
- {
- $filtermethod= 'WHERE attrib_detail=2';
- $table = 'fm_s_agreement_detail';
- }
- else
- {
- $filtermethod= 'WHERE attrib_detail=1';
- $table = 'fm_s_agreement';
- }
- $sql = "SELECT max(attrib_sort) as max_sort FROM
$attribute_table $filtermethod";
- $this->db->query($sql);
- $this->db->next_record();
- $attrib_sort = $this->db->f('max_sort')+1;
-
- $values= array(
- !!$this->role +1,
- $attrib['id'],
- $attrib['column_name'],
- $attrib['input_text'],
- $attrib['statustext'],
- $attrib['lookup_form'],
- $attrib['search'],
- $attrib['list'],
- $attrib_sort,
- $attrib['column_info']['type'],
- $attrib['column_info']['precision'],
- $attrib['column_info']['scale'],
- $attrib['column_info']['default'],
- $attrib['column_info']['nullable']
- );
-
- $values = $this->bocommon->validate_db_insert($values);
-
- $this->db->transaction_begin();
-
- $this->db->query("INSERT INTO $attribute_table
(attrib_detail,id,column_name, input_text,
statustext,lookup_form,search,list,attrib_sort,datatype,precision_,scale,default_value,nullable)
"
- . "VALUES ($values)");
-
- $receipt['id']= $attrib['id'];
-
- if($attrib['column_info']['type']=='email' &&
!$attrib['column_info']['precision'])
- {
- $attrib['column_info']['precision']=64;
- }
-
- $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
-
- if($attrib['column_info']['type']=='int' &&
!$attrib['column_info']['precision'])
- {
- $attrib['column_info']['precision']=4;
- }
-
- if(!$attrib['column_info']['default'])
- {
- unset($attrib['column_info']['default']);
- }
-
- $this->init_process();
-
-
if($this->oProc->AddColumn($table,$attrib['column_name'],
$attrib['column_info']))
- {
- $receipt['message'][] = array('msg' =>
lang('Attribute has been saved') );
- $this->db->transaction_commit();
-
- }
- else
- {
- $receipt['error'][] = array('msg' =>
lang('column could not be added') );
- if($this->db->Transaction)
- {
- $GLOBALS['phpgw']->db->rollbacktrans();
- }
- else
- {
- $GLOBALS['phpgw']->db->Execute("DELETE
FROM $attribute_table WHERE id='" . $receipt['id'] . "'");
- unset($receipt['id']);
-
- }
- }
-
- return $receipt;
- }
-
- function init_process()
- {
- $this->oProc
=
CreateObject('phpgwapi.schema_proc',$GLOBALS['phpgw_info']['server']['db_type']);
- $this->oProc->m_odb
= $this->db;
- $this->oProc->m_odb->Halt_On_Error = 'report';
- }
-
- function edit_attrib($attrib)
- {
- $attribute_table = 'fm_s_agreement_attribute';
- $table = 'fm_s_agreement';
-
- $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
- $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
- $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
- $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
-
- $choice_table = 'fm_s_agreement_choice';
-
- if($this->role=='detail')
- {
- $filtermethod= ' AND attrib_detail=2';
- $table = 'fm_s_agreement_detail';
- }
- else
- {
- $filtermethod= ' AND attrib_detail=1';
- $table = 'fm_s_agreement';
- }
-
- $this->db->query("SELECT column_name FROM
$attribute_table WHERE id='" . $attrib['id']. "' $filtermethod");
- $this->db->next_record();
- $OldColumnName = $this->db->f('column_name');
-
- $this->db->transaction_begin();
-
- $attrib_type=$attrib['column_info']['type'];
- if(($OldColumnName !=$attrib['column_name']) ||
($attrib['column_info']['type'] != $this->db->f('datatype')))
- {
- $value_set=array(
- 'column_name' =>
$attrib['column_name'],
- 'input_text' =>
$attrib['input_text'],
- 'statustext' =>
$attrib['statustext'],
- 'lookup_form' =>
$attrib['lookup_form'],
- 'search' =>
$attrib['search'],
- 'list' =>
$attrib['list'],
- 'datatype' =>
$attrib['column_info']['type'],
- 'precision_' =>
$attrib['column_info']['precision'],
- 'scale' =>
$attrib['column_info']['scale'],
- 'default_value' =>
$attrib['column_info']['default'],
- 'nullable' =>
$attrib['column_info']['nullable']
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE $attribute_table set
$value_set WHERE id=" . $attrib['id'] . $filtermethod);
-
- if($attrib['column_info']['type']=='email' &&
!$attrib['column_info']['precision'])
- {
- $attrib['column_info']['precision']=64;
- }
-
- $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
-
- if($attrib['column_info']['type']=='int' &&
!$attrib['column_info']['precision'])
- {
- $attrib['column_info']['precision']=4;
- }
-
- if(!$attrib['column_info']['default'])
- {
-
unset($attrib['column_info']['default']);
- }
-
- $this->init_process();
-
-
$this->oProc->AlterColumn($table,$OldColumnName,$attrib['column_name'],$attrib['column_info']);
-
- }
-
-
- if($attrib['new_choice'])
- {
- $this->db->query("SELECT max(id) as id FROM
$choice_table WHERE attrib_id='" . $attrib['id']. "' $filtermethod");
- $this->db->next_record();
- $choice_id = $this->db->f('id')+1;
-
- // $choice_id =
$this->bocommon->next_id($choice_table
,array('attrib_detail'=>2,'attrib_id'=>$attrib['id']));
-
- $values= array(
- $attrib['id'],
- $choice_id,
- !!$this->role +1,
- $attrib['new_choice']
- );
-
- $values =
$this->bocommon->validate_db_insert($values);
-
- $this->db->query("INSERT INTO $choice_table
(attrib_id,id,attrib_detail,value) "
- . "VALUES ($values)");
- }
-
-
- if($attrib['delete_choice'])
- {
- for
($i=0;$i<count($attrib['delete_choice']);$i++)
- {
- $this->db->query("DELETE FROM
$choice_table WHERE attrib_id=" . $attrib['id'] ." AND id=" .
$attrib['delete_choice'][$i] . $filtermethod);
- }
- }
-
-//html_print_r($attrib_type);
- if($attrib_type!='R' && $attrib_type!='CH' &&
$attrib_type!='LB')
- {
- $this->db->query("DELETE FROM $choice_table
WHERE attrib_id=" . $attrib['id'] . $filtermethod);
- }
-
-
- $this->db->transaction_commit();
-
- $receipt['message'][] = array('msg' =>
lang('Attribute has been edited'));
-
-
- return $receipt;
-
- }
- function resort_attrib($data)
- {
-//html_print_r($data);
- $attribute_table = 'fm_s_agreement_attribute';
- if(is_array($data))
- {
- $resort =
(isset($data['resort'])?$data['resort']:'up');
- $id = (isset($data['id'])?$data['id']:'');
- }
-
- $sql = "SELECT attrib_sort FROM $attribute_table where
id=$id";
- $this->db->query($sql);
- $this->db->next_record();
- $attrib_sort = $this->db->f('attrib_sort');
- $sql = "SELECT max(attrib_sort) as max_sort FROM
$attribute_table";
- $this->db->query($sql);
- $this->db->next_record();
- $max_sort = $this->db->f('max_sort');
- switch($resort)
- {
- case 'up':
- if($attrib_sort>1)
- {
- $sql = "UPDATE $attribute_table
set attrib_sort=$attrib_sort WHERE attrib_sort =" . ($attrib_sort-1);
- $this->db->query($sql);
- $sql = "UPDATE $attribute_table
set attrib_sort=" . ($attrib_sort-1) ." WHERE id=$id";
- $this->db->query($sql);
- }
- break;
- case 'down':
- if($max_sort > $attrib_sort)
- {
- $sql = "UPDATE $attribute_table
set attrib_sort=$attrib_sort WHERE attrib_sort =" . ($attrib_sort+1);
- $this->db->query($sql);
- $sql = "UPDATE $attribute_table
set attrib_sort=" . ($attrib_sort+1) ." WHERE id=$id";
- $this->db->query($sql);
- }
- break;
- default:
- return;
- break;
- }
- }
- function delete_attrib($attrib_id)
- {
- $table = 'fm_s_agreement';
- $attribute_table = 'fm_s_agreement_attribute';
- $this->init_process();
-
- $sql = "SELECT * FROM $attribute_table WHERE
id=$attrib_id";
-
- $this->db->query($sql);
- $this->db->next_record();
- $ColumnName = $this->db->f('column_name');
-
- if($this->oProc->DropColumn($table,'', $ColumnName))
- {
- $sql = "SELECT attrib_sort FROM
$attribute_table where id=$attrib_id";
- $this->db->query($sql);
- $this->db->next_record();
- $attrib_sort = $this->db->f('attrib_sort');
- $sql2 = "SELECT max(attrib_sort) as max_sort
FROM $attribute_table";
- $this->db->query($sql2);
- $this->db->next_record();
- $max_sort = $this->db->f('max_sort');
- if($max_sort>$attrib_sort)
- {
- $sql = "UPDATE $attribute_table set
attrib_sort=attrib_sort-1 WHERE attrib_sort > $attrib_sort";
- $this->db->query($sql);
- }
-
- $this->db->query("DELETE FROM $attribute_table
WHERE id=$attrib_id");
- }
- else
- {
- $receipt['error'][] = array('msg' =>
lang('Attribute has NOT been deleted'));
- }
-
- return $receipt;
- }
-
- function request_next_id()
- {
- $this->db->query("SELECT max(id) as id FROM
fm_s_agreement");
- $this->db->next_record();
- $next_id= $this->db->f('id')+1;
- return $next_id;
- }
-
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage agreement
+ * @version $Id: class.sos_agreement.inc.php,v 1.15 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class sos_agreement
+ {
+ var $role;
+
+ function sos_agreement()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->left_join = $this->bocommon->left_join;
+ $this->like = $this->bocommon->like;
+ }
+
+ function select_category_list()
+ {
+ $table = 'fm_s_agreement' . '_category';
+ $this->db->query("SELECT id,descr FROM $table ORDER BY
descr ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $categories[$i]['id']
= $this->db->f('id');
+ $categories[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $categories;
+ }
+
+ function select_vendor_list()
+ {
+ $table = 'fm_s_agreement';
+ $this->db->query("SELECT vendor_id,org_name FROM $table
$this->join fm_vendor on fm_s_agreement.vendor_id=fm_vendor.id GROUP BY
org_name,vendor_id ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $vendor[$i]['id']
= $this->db->f('vendor_id');
+ $vendor[$i]['name']
= stripslashes($this->db->f('org_name'));
+ $i++;
+ }
+ return $vendor;
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ $start =
(isset($data['start'])?$data['start']:0);
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
+ $vendor_id =
(isset($data['vendor_id'])?$data['vendor_id']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $member_id =
(isset($data['member_id'])?$data['member_id']:0);
+ $s_agreement_id =
(isset($data['s_agreement_id'])?$data['s_agreement_id']:'');
+ $detail =
(isset($data['detail'])?$data['detail']:'');
+ }
+
+ $choice_table = 'fm_s_agreement_choice';
+ $attribute_table = 'fm_s_agreement_attribute';
+
+ if(!$detail)
+ {
+ $entity_table = 'fm_s_agreement';
+ $category_table = 'fm_s_agreement_category';
+ $attribute_filter = " AND attrib_detail = 1";
+
+ $paranthesis .='(';
+ $joinmethod .= " $this->join $category_table ON
( $entity_table.category =$category_table.id))";
+ $paranthesis .='(';
+ $joinmethod .= " $this->join fm_vendor ON (
$entity_table.vendor_id =fm_vendor.id))";
+
+ $cols = $entity_table .
".*,$category_table.descr as category, org_name";
+
+ $cols_return[] = 'id';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'id';
+ $uicols['descr'][] =
lang('ID');
+ $uicols['statustext'][] = lang('ID');
+
+ $cols_return[] =
'name';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'name';
+ $uicols['descr'][] =
lang('name');
+ $uicols['statustext'][] = lang('name');
+
+ $cols_return[] =
'org_name';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'org_name';
+ $uicols['descr'][] =
lang('vendor');
+ $uicols['statustext'][] =
lang('vendor');
+
+ $cols_return[] =
'category';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'category';
+ $uicols['descr'][] =
lang('category');
+ $uicols['statustext'][] =
lang('category');
+
+ $cols_return[] =
'start_date';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'start_date';
+ $uicols['descr'][] =
lang('start');
+ $uicols['statustext'][] = lang('start
date');
+
+ $cols_return[] =
'end_date';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'end_date';
+ $uicols['descr'][] =
lang('end');
+ $uicols['statustext'][] = lang('end
date');
+
+ }
+ else
+ {
+ $allrows=True;
+ $entity_table = 'fm_s_agreement_detail';
+ $attribute_filter = " AND attrib_detail = 2";
+
+ $paranthesis .='(';
+ $joinmethod .= " $this->join
fm_s_agreement_pricing ON ( $entity_table.agreement_id
=fm_s_agreement_pricing.agreement_id AND $entity_table.id
=fm_s_agreement_pricing.item_id))";
+
+
+
+ $cols = "$entity_table.*,
fm_s_agreement_pricing.cost,fm_s_agreement_pricing.id as
index_count,fm_s_agreement_pricing.index_date,fm_s_agreement_pricing.item_id,fm_s_agreement_pricing.this_index";
+
+ $cols_return[] =
'agreement_id';
+ $uicols['input_type'][] = 'hidden';
+ $uicols['name'][] =
'agreement_id';
+ $uicols['descr'][] =
lang('agreement_id');
+ $uicols['statustext'][] =
lang('agreement_id');
+
+ $cols_return[] =
'item_id';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'item_id';
+ $uicols['descr'][] =
lang('ID');
+ $uicols['statustext'][] = lang('ID');
+
+ $cols_return[] = 'id';
+ $uicols['input_type'][] = 'hidden';
+ $uicols['name'][] = 'id';
+ $uicols['descr'][] = False;
+ $uicols['statustext'][] = False;
+
+ $cols_return[] =
'location_code';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'location_code';
+ $uicols['descr'][] =
lang('location');
+ $uicols['statustext'][] =
lang('location');
+
+ $cols_return[] =
'address';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'address';
+ $uicols['descr'][] =
lang('address');
+ $uicols['statustext'][] =
lang('address');
+
+ $cols_return[] =
'p_num';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'p_num';
+ $uicols['descr'][] =
lang('entity num');
+ $uicols['statustext'][] = lang('entity
num');
+
+ $cols_return[] =
'cost';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'cost';
+ $uicols['descr'][] =
lang('cost');
+ $uicols['statustext'][] = lang('cost');
+
+ $cols_return[] =
'this_index';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'this_index';
+ $uicols['descr'][] =
lang('index');
+ $uicols['statustext'][] = lang('index');
+
+ $cols_return[] =
'index_count';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'index_count';
+ $uicols['descr'][] =
lang('index_count');
+ $uicols['statustext'][] =
lang('index_count');
+
+ $cols_return[] =
'index_date';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'index_date';
+ $uicols['descr'][] =
lang('date');
+ $uicols['statustext'][] = lang('date');
+ }
+
+ $from .= " FROM $paranthesis $entity_table ";
+
+ $sql = "SELECT $cols $from $joinmethod";
+
+ $i = count($uicols['name']);
+
+ $this->db->query("SELECT * FROM $attribute_table WHERE
list=1 $attribute_filter ");
+ while ($this->db->next_record())
+ {
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
$this->db->f('column_name');
+ $uicols['descr'][] =
$this->db->f('input_text');
+ $uicols['statustext'][] =
$this->db->f('statustext');
+ $uicols['datatype'][$i] =
$this->db->f('datatype');
+ $cols_return_extra[]= array(
+ 'name' => $this->db->f('column_name'),
+ 'datatype' =>
$this->db->f('datatype'),
+ 'attrib_id' => $this->db->f('id')
+ );
+
+ $i++;
+ }
+
+
$user_columns=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['s_agreement_columns'
. !!$s_agreement_id];
+
+//_debug_array($user_columns);
+
+ if (isset($user_columns) AND is_array($user_columns)
AND $user_columns[0])
+ {
+ foreach($user_columns as $column_id)
+ {
+ $this->db->query("SELECT * FROM
$attribute_table WHERE id= $column_id");
+
+ $this->db->next_record();
+ $uicols['input_type'][] =
'text';
+ $uicols['name'][]
= $this->db->f('column_name');
+ $uicols['descr'][]
= $this->db->f('input_text');
+ $uicols['statustext'][] =
$this->db->f('statustext');
+ $uicols['datatype'][$i] =
$this->db->f('datatype');
+ $cols_return_extra[]= array(
+ 'name' =>
$this->db->f('column_name'),
+ 'datatype' =>
$this->db->f('datatype'),
+ 'attrib_id' =>
$this->db->f('id')
+ );
+ $i++;
+ }
+ }
+
+ $this->uicols = $uicols;
+
+//_debug_array($cols_return_extra);
+ if ($order)
+ {
+ if ($order=='id')
+ {
+ $ordermethod = " order by
$entity_table.$order $sort";
+ }
+ else
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ }
+ else
+ {
+ $ordermethod = " order by $entity_table.id
DESC";
+ }
+
+ $where= 'WHERE';
+
+/* if ($filter=='all')
+ {
+ if (is_array($grants))
+ {
+ while (list($user) = each($grants))
+ {
+ $public_user_list[] = $user;
+ }
+ reset($public_user_list);
+ $filtermethod .= " $where (
$entity_table.user_id IN(" . implode(',',$public_user_list) . "))";
+
+ $where= 'AND';
+ }
+
+ }
+ else
+ {
+ $filtermethod = " $where
$entity_table.user_id=$filter ";
+ $where= 'AND';
+ }
+*/
+
+ if ($s_agreement_id)
+ {
+ $filtermethod .= " $where
$entity_table.agreement_id=$s_agreement_id AND current_index = 1";
+ $where= 'AND';
+ }
+
+ if ($cat_id)
+ {
+ $filtermethod .= " $where
$entity_table.category='$cat_id' ";
+ $where= 'AND';
+ }
+
+ if ($vendor_id)
+ {
+ $filtermethod .= " $where
$entity_table.vendor_id='$vendor_id' ";
+ $where= 'AND';
+ }
+
+ if ($member_id>0)
+ {
+ $filtermethod .= " $where
$entity_table.member_of $this->like '%,$member_id,%' ";
+ $where= 'AND';
+ }
+
+ if ($status)
+ {
+ $filtermethod .= " $where
$entity_table.status='$status' ";
+ $where= 'AND';
+ }
+
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $this->db->query("SELECT * FROM
$attribute_table where search='1'");
+
+ while ($this->db->next_record())
+ {
+ if($this->db->f('datatype')=='V' ||
$this->db->f('datatype')=='email' || $this->db->f('datatype')=='CH')
+ {
+ $querymethod[]=
"$entity_table." . $this->db->f('column_name') . " $this->like '%$query%'";
+ }
+ else
+ {
+ $querymethod[]=
"$entity_table." . $this->db->f('column_name') . " = '$query'";
+ }
+ }
+
+ if (isset($querymethod) AND
is_array($querymethod))
+ {
+ $querymethod = " $where (" . implode ('
OR ',$querymethod) . ')';
+ $where = 'AND';
+ }
+ }
+
+ $sql .= " $filtermethod $querymethod";
+//echo $sql;
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ $j=0;
+ $n=count($cols_return);
+//_debug_array($cols_return);
+
+ $contacts =
CreateObject('phpgwapi.contacts');
+
+ while ($this->db->next_record())
+ {
+ for ($i=0;$i<$n;$i++)
+ {
+ $s_agreement_list[$j][$cols_return[$i]]
= stripslashes($this->db->f($cols_return[$i]));
+ $s_agreement_list[$j]['grants'] =
(int)$grants[$this->db->f('user_id')];
+ }
+
+ for ($i=0;$i<count($cols_return_extra);$i++)
+ {
+ $value='';
+
$value=$this->db->f($cols_return_extra[$i]['name']);
+
+
if(($cols_return_extra[$i]['datatype']=='R' ||
$cols_return_extra[$i]['datatype']=='LB') && $value):
+ {
+ $sql="SELECT value FROM
$choice_table where attrib_id=" .$cols_return_extra[$i]['attrib_id']. " AND
id=" . $value . $attribute_filter;
+ $this->db2->query($sql);
+ $this->db2->next_record();
+
$s_agreement_list[$j][$cols_return_extra[$i]['name']] = $this->db2->f('value');
+ }
+
elseif($cols_return_extra[$i]['datatype']=='AB' && $value):
+ {
+ $contact_data =
$contacts->read_single_entry($value,array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
+
$s_agreement_list[$j][$cols_return_extra[$i]['name']] =
$contact_data[0]['n_family'] . ', ' . $contact_data[0]['n_given'];
+
+ }
+
elseif($cols_return_extra[$i]['datatype']=='VENDOR' && $value):
+ {
+ $sql="SELECT org_name FROM
fm_vendor where id=$value";
+ $this->db2->query($sql);
+ $this->db2->next_record();
+
$s_agreement_list[$j][$cols_return_extra[$i]['name']] =
$this->db2->f('org_name');
+ }
+
elseif($cols_return_extra[$i]['datatype']=='CH' && $value):
+ {
+ $ch= unserialize($value);
+
+ if (isset($ch) AND
is_array($ch))
+ {
+ for
($k=0;$k<count($ch);$k++)
+ {
+ $sql="SELECT
value FROM $choice_table where attrib_id="
.$cols_return_extra[$i]['attrib_id']. " AND id=" . $ch[$k] . $attribute_filter;
+
$this->db2->query($sql);
+ while
($this->db2->next_record())
+ {
+
$ch_value[]=$this->db2->f('value');
+ }
+ }
+
$s_agreement_list[$j][$cols_return_extra[$i]['name']] = @implode(",",
$ch_value);
+ unset($ch_value);
+ }
+ }
+
elseif($cols_return_extra[$i]['datatype']=='D' && $value):
+ {
+//html_print_r($value);
+
+
$s_agreement_list[$j][$cols_return_extra[$i]['name']]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($value));
+ }
+ else:
+ {
+
$s_agreement_list[$j][$cols_return_extra[$i]['name']]=$value;
+ }
+ endif;
+ }
+
+ $j++;
+ }
+//html_print_r($s_agreement_list);
+ return $s_agreement_list;
+ }
+
+ function read_prizing($data)
+ {
+ if(is_array($data))
+ {
+ $s_agreement_id =
(isset($data['s_agreement_id'])?$data['s_agreement_id']:0);
+ $item_id =
(isset($data['item_id'])?$data['item_id']:0);
+ }
+
+ $entity_table = 'fm_s_agreement_pricing';
+
+ $cols =
"fm_s_agreement_pricing.cost,fm_s_agreement_pricing.id as
index_count,fm_s_agreement_pricing.index_date,fm_s_agreement_pricing.item_id,fm_s_agreement_pricing.this_index";
+
+ $cols_return[] = 'item_id';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'item_id';
+ $uicols['descr'][] = lang('ID');
+ $uicols['statustext'][] = lang('ID');
+
+ $cols_return[] = 'id';
+ $uicols['input_type'][] = 'hidden';
+ $uicols['name'][] = 'id';
+ $uicols['descr'][] = False;
+ $uicols['statustext'][] = False;
+
+ $cols_return[] = 'cost';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'cost';
+ $uicols['descr'][] = lang('cost');
+ $uicols['statustext'][] = lang('cost');
+
+ $cols_return[] = 'this_index';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'this_index';
+ $uicols['descr'][] = lang('index');
+ $uicols['statustext'][] = lang('index');
+
+ $cols_return[] = 'index_count';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'index_count';
+ $uicols['descr'][] =
lang('index_count');
+ $uicols['statustext'][] = lang('index_count');
+
+ $cols_return[] = 'index_date';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'index_date';
+ $uicols['descr'][] = lang('date');
+ $uicols['statustext'][] = lang('date');
+
+ $from .= " FROM $entity_table ";
+
+ $sql = "SELECT $cols $from $joinmethod";
+
+
+ $this->uicols = $uicols;
+
+ $ordermethod = " order by $entity_table.id ASC";
+
+ $where= 'WHERE';
+
+
+ if ($s_agreement_id)
+ {
+ $filtermethod .= " $where
$entity_table.agreement_id=$s_agreement_id AND item_id=$item_id";
+ $where= 'AND';
+ }
+
+
+ $sql .= " $filtermethod";
+//echo $sql;
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ $j=0;
+ $n=count($cols_return);
+//_debug_array($cols_return);
+ while ($this->db->next_record())
+ {
+ for ($i=0;$i<$n;$i++)
+ {
+ $s_agreement_list[$j][$cols_return[$i]]
= $this->db->f($cols_return[$i]);
+ $s_agreement_list[$j]['agreement_id'] =
$s_agreement_id;
+ }
+ $j++;
+ }
+//_debug_array($s_agreement_list);
+ return $s_agreement_list;
+ }
+
+
+ function read_single($data)
+ {
+ $attribute_table = 'fm_s_agreement_attribute';
+ $table = 'fm_s_agreement';
+
+ $s_agreement_id =$data['s_agreement_id'];
+
+ $this->db->query("SELECT * FROM $attribute_table WHERE
attrib_detail = 1 ORDER BY attrib_sort");
+
+ while ($this->db->next_record())
+ {
+ $s_agreement['attributes'][] = array
+ (
+ 'attrib_id' =>
$this->db->f('id'),
+ 'name' =>
$this->db->f('column_name'),
+ 'input_text' =>
stripslashes($this->db->f('input_text')),
+ 'statustext' =>
stripslashes($this->db->f('statustext')),
+ 'datatype' =>
$this->db->f('datatype')
+ );
+ }
+
+ if($s_agreement_id)
+ {
+ $this->db->query("SELECT * from $table where
id='$s_agreement_id'");
+
+ if($this->db->next_record())
+ {
+ $s_agreement['id']
= (int)$this->db->f('id');
+ $s_agreement['entry_date']
= $this->db->f('entry_date');
+ $s_agreement['cat_id']
= $this->db->f('category');
+ $s_agreement['member_of']
= explode(',',$this->db->f('member_of'));
+ $s_agreement['cat_id']
= $this->db->f('category');
+ $s_agreement['start_date']
= $this->db->f('start_date');
+ $s_agreement['end_date']
= $this->db->f('end_date');
+ $s_agreement['termination_date']=
$this->db->f('termination_date');
+ $s_agreement['vendor_id']
= $this->db->f('vendor_id');
+ $s_agreement['b_account_id'] =
$this->db->f('account_id');
+ $s_agreement['name']
= stripslashes($this->db->f('name'));
+ $s_agreement['descr']
= stripslashes($this->db->f('descr'));
+ $s_agreement['user_id']
= $this->db->f('user_id');
+
+ for
($i=0;$i<count($s_agreement['attributes']);$i++)
+ {
+
$s_agreement['attributes'][$i]['value'] =
$this->db->f($s_agreement['attributes'][$i]['name']);
+
$s_agreement['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($s_agreement['attributes'][$i]['datatype']);
+ }
+
+ }
+ }
+ return $s_agreement;
+ }
+
+ function read_single_item($data)
+ {
+ $attribute_table = 'fm_s_agreement_attribute';
+ $table = 'fm_s_agreement_detail';
+
+ $s_agreement_id =$data['s_agreement_id'];
+ $id =$data['id'];
+
+ $this->db->query("SELECT * FROM $attribute_table WHERE
attrib_detail = 2 ORDER BY attrib_sort");
+
+ while ($this->db->next_record())
+ {
+ $item['attributes'][] = array
+ (
+ 'attrib_id' =>
$this->db->f('id'),
+ 'name' =>
$this->db->f('column_name'),
+ 'input_text' =>
stripslashes($this->db->f('input_text')),
+ 'statustext' =>
stripslashes($this->db->f('statustext')),
+ 'datatype' =>
$this->db->f('datatype')
+ );
+ }
+
+ if($id && $s_agreement_id)
+ {
+ $this->db->query("SELECT * from $table where
agreement_id=$s_agreement_id AND id=$id");
+
+ if($this->db->next_record())
+ {
+ $item['agreement_id'] =
(int)$this->db->f('agreement_id');
+ $item['id']
= (int)$this->db->f('id');
+ $item['entry_date'] =
$this->db->f('entry_date');
+ $item['location_code'] =
$this->db->f('location_code');
+ $item['p_num'] =
$this->db->f('p_num');
+ $item['p_entity_id'] =
$this->db->f('p_entity_id');
+ $item['p_cat_id'] =
$this->db->f('p_cat_id');
+ $item['cost'] =
$this->db->f('cost');
+
+ for
($i=0;$i<count($item['attributes']);$i++)
+ {
+
$item['attributes'][$i]['value'] =
$this->db->f($item['attributes'][$i]['name']);
+
$item['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($item['attributes'][$i]['datatype']);
+ }
+
+ }
+ }
+ return $item;
+ }
+
+ function add($s_agreement,$values_attribute='')
+ {
+//_debug_array($s_agreement);
+ $table = 'fm_s_agreement';
+ $s_agreement['name'] =
$this->db->db_addslashes($s_agreement['name']);
+ $s_agreement['descr'] =
$this->db->db_addslashes($s_agreement['descr']);
+
+ if($s_agreement['member_of'])
+ {
+ $s_agreement['member_of']=',' .
implode(',',$s_agreement['member_of']) . ',';
+ }
+
+
+ $this->db->transaction_begin();
+ $id = $this->bocommon->increment_id('workorder');
+
+ $vals[] = $id;
+ $vals[] = $s_agreement['name'];
+ $vals[] = $s_agreement['descr'];
+ $vals[] = time();
+ $vals[] = $s_agreement['cat_id'];
+ $vals[] = $s_agreement['member_of'];
+ $vals[] = $s_agreement['start_date'];
+ $vals[] = $s_agreement['end_date'];
+ $vals[] = $s_agreement['termination_date'];
+ $vals[] = $s_agreement['vendor_id'];
+ $vals[] = $s_agreement['b_account_id'];
+ $vals[] = $this->account;
+
+ while (is_array($s_agreement['extra']) &&
list($input_name,$value) = each($s_agreement['extra']))
+ {
+ if($value)
+ {
+ $cols[] = $input_name;
+ $vals[] = $value;
+ }
+ }
+
+ if (isset($values_attribute) AND
is_array($values_attribute))
+ {
+ foreach($values_attribute as $entry)
+ {
+ if($entry['value'])
+ {
+ $cols[] = $entry['name'];
+ $vals[] = $entry['value'];
+ }
+ }
+ }
+
+ if($cols)
+ {
+ $cols = "," . implode(",", $cols);
+ $vals =
$this->bocommon->validate_db_insert($vals);
+ }
+
+ $this->db->query("INSERT INTO $table
(id,name,descr,entry_date,category,member_of,start_date,end_date,termination_date,vendor_id,account_id,user_id
$cols) "
+ . "VALUES ($vals)",__LINE__,__FILE__);
+
+ $this->db->query("INSERT INTO fm_orders (id,type)
VALUES ($id,'s_agreement')");
+
+ $receipt['s_agreement_id']=
$id;//$this->db->get_last_insert_id($table,'id');
+
+ $receipt['message'][] = array('msg'=>lang('s_agreement
%1 has been saved',$receipt['s_agreement_id']));
+
+ $this->db->transaction_commit();
+ return $receipt;
+ }
+
+ function add_item($values,$values_attribute='')
+ {
+//_debug_array($values);
+ $table = 'fm_s_agreement_detail';
+
+ $cols[] = 'location_code';
+ $vals[] = $values['location_code'];
+
+/* while (is_array($values['location']) &&
list($input_name,$value) = each($values['location']))
+ {
+ if($value)
+ {
+ $cols[] = $input_name;
+ $vals[] = $value;
+ }
+ }
+*/
+ while (is_array($values['extra']) &&
list($input_name,$value) = each($values['extra']))
+ {
+ if($value)
+ {
+ $cols[] = $input_name;
+ $vals[] = $value;
+ }
+ }
+
+ if (isset($values_attribute) AND
is_array($values_attribute))
+ {
+ foreach($values_attribute as $entry)
+ {
+ if($entry['value'])
+ {
+ $cols[] = $entry['name'];
+ $vals[] = $entry['value'];
+ }
+ }
+ }
+
+ if($values['street_name'])
+ {
+ $address[]= $values['street_name'];
+ $address[]= $values['street_number'];
+ $address = $this->db->db_addslashes(implode("
", $address));
+ }
+
+ if(!$address)
+ {
+ $address =
$this->db->db_addslashes($values['location_name']);
+ }
+
+ $cols[] = 'address';
+ $vals[] = $address;
+ $cols[] = 'cost';
+ $vals[] = $this->floatval($values['cost']);
+
+ if($cols)
+ {
+ $cols = "," . implode(",", $cols);
+ $vals = "," .
$this->bocommon->validate_db_insert($vals);
+ }
+
+ $this->db->transaction_begin();
+ $id =
$this->bocommon->next_id($table,array('agreement_id'=>$values['s_agreement_id']));
+
+ $this->db->query("INSERT INTO $table
(id,agreement_id,entry_date,user_id $cols) "
+ . "VALUES ($id," . $values['s_agreement_id']
."," . time()
+ . "," . $this->account . " $vals)");
+
+
+ $this->db->query("SELECT start_date FROM fm_s_agreement
WHERE id=" . $values['s_agreement_id']);
+ $this->db->next_record();
+ $start_date = $this->db->f('start_date');
+
+
+ $this->db->query("INSERT INTO fm_s_agreement_pricing
(agreement_id,item_id,id,current_index,this_index,cost,index_date,entry_date,user_id)
"
+ . "VALUES (" . $values['s_agreement_id'] . ","
. $id .",1,1,1," . $this->floatval($values['cost']) . "," . (int)$start_date .
"," . time()
+ . "," . $this->account . ")");
+
+ $receipt['s_agreement_id']= $values['s_agreement_id'];
+ $receipt['id']= $id;
+
+ $receipt['message'][] = array('msg'=>lang('s_agreement
%1 has been saved',$receipt['s_agreement_id']));
+
+ $this->db->transaction_commit();
+ return $receipt;
+ }
+
+ function edit($values,$values_attribute='')
+ {
+//_debug_array($values);
+//_debug_array($values_attribute);
+ $table = 'fm_s_agreement';
+
+ $values['name'] =
$this->db->db_addslashes($values['name']);
+
+ if($values['member_of'])
+ {
+ $values['member_of']=',' .
implode(',',$values['member_of']) . ',';
+ }
+
+ while (is_array($values['extra']) &&
list($column,$value) = each($values['extra']))
+ {
+ $value_set[$column] = $value;
+ }
+
+ if (isset($values_attribute) AND
is_array($values_attribute))
+ {
+ foreach($values_attribute as $entry)
+ {
+ if($entry['datatype']!='AB' &&
$entry['datatype']!='VENDOR')
+ {
+ $value_set[$entry['name']]
= $entry['value'];
+ }
+ }
+ }
+
+ $value_set['name'] = $values['name'];
+ $value_set['descr'] = $values['descr'];
+ if($value_set)
+ {
+ $value_set = ',' .
$this->bocommon->validate_db_update($value_set);
+ }
+
+ $this->db->query("UPDATE $table set entry_date='" .
time() . "', category='"
+ . $values['cat_id'] .
"', member_of='" . $values['member_of'] . "', start_date=" .
intval($values['start_date']) . ", end_date=" . intval($values['end_date']) .
", termination_date=" . intval($values['termination_date']) . ", account_id=" .
intval($values['b_account_id']) . "$value_set WHERE id=" .
intval($values['s_agreement_id']));
+
+ $this->db->query("UPDATE fm_s_agreement_pricing set
index_date=" . intval($values['start_date']) . " WHERE id=1 AND agreement_id= "
. intval($values['s_agreement_id']));
+
+ $receipt['s_agreement_id']= $values['s_agreement_id'];
+ $receipt['message'][] = array('msg'=>lang('s_agreement
%1 has been edited',$values['s_agreement_id']));
+ return $receipt;
+ }
+
+ function edit_item($values,$values_attribute='')
+ {
+//_debug_array($values);
+//_debug_array($values_attribute);
+ $table = 'fm_s_agreement_detail';
+
+ while (is_array($values['extra']) &&
list($column,$value) = each($values['extra']))
+ {
+ $value_set[$column] = $value;
+ }
+
+ if (isset($values_attribute) AND
is_array($values_attribute))
+ {
+ foreach($values_attribute as $entry)
+ {
+ if($entry['datatype']!='AB' &&
$entry['datatype']!='VENDOR')
+ {
+ $value_set[$entry['name']]
= $entry['value'];
+ }
+ }
+ }
+
+ if($values['street_name'])
+ {
+ $address[]= $values['street_name'];
+ $address[]= $values['street_number'];
+ $address =
$this->db->db_addslashes(implode(" ", $address));
+ }
+
+ if(!$address)
+ {
+ $address =
$this->db->db_addslashes($values['location_name']);
+ }
+
+ $value_set['location_code'] =
$values['location_code'];
+ $value_set['cost'] = $values['cost'];
+ $value_set['address'] = $address;
+
+ if($value_set)
+ {
+ $value_set = ',' .
$this->bocommon->validate_db_update($value_set);
+ }
+
+ $this->db->query("UPDATE $table set entry_date=" .
time() . "$value_set WHERE agreement_id=" . intval($values['s_agreement_id']) .
' AND id=' . intval($values['id']));
+
+ $this->db->query("UPDATE fm_s_agreement_pricing set
cost = this_index *" . $this->floatval($values['cost']) . " WHERE
agreement_id=" . intval($values['s_agreement_id']) . ' AND item_id=' .
intval($values['id']));
+
+ $receipt['s_agreement_id']= $values['s_agreement_id'];
+ $receipt['id']= $values['id'];
+ $receipt['message'][] = array('msg'=>lang('s_agreement
%1 has been edited',$values['s_agreement_id']));
+ return $receipt;
+ }
+
+ function update($values)
+ {
+//_debug_array($values);
+
$values['new_index']=$this->floatval($values['new_index']);
+ $this->db->transaction_begin();
+
+ while (is_array($values['select']) &&
list($item_id,$value) = each($values['select']))
+ {
+
+ $this->db->query("UPDATE fm_s_agreement_pricing
set current_index = NULL WHERE agreement_id=" . intval($values['agreement_id'])
. ' AND item_id=' . intval($item_id));
+
+ $this->db->query("INSERT INTO
fm_s_agreement_pricing
(agreement_id,item_id,id,current_index,this_index,cost,index_date,entry_date,user_id)"
+ . "VALUES (" . $values['agreement_id']
. "," . $item_id ."," . ($values['id'][$item_id]+1) .",1,'" .
$values['new_index'] . "','" . ($value * $values['new_index']) . "'," .
(int)$values['date'] . "," . time()
+ . "," . $this->account . ")");
+
+ }
+
+ $this->db->transaction_commit();
+ $receipt['message'][] = array('msg'=>lang('s_agreement
%1 has been updated for index',$values['agreement_id']));
+
+ return $receipt;
+ }
+
+ function floatval($strValue)
+ {
+ $floatValue =
ereg_replace("(^[0-9]*)(\\.|,)([0-9]*)(.*)", "\\1.\\3", $strValue);
+ if(!is_numeric($floatValue))
+ {
+ $floatValue = ereg_replace("(^[0-9]*)(.*)",
"\\1", $strValue);
+ }
+ if(!is_numeric($floatValue))
+ {
+ $floatValue = 0;
+ }
+ return $floatValue;
+ }
+
+
+ function delete_last_index($s_agreement_id,$item_id)
+ {
+ $this->db->transaction_begin();
+ $this->db->query("SELECT max(id) as index_count FROM
fm_s_agreement_pricing WHERE agreement_id=$s_agreement_id AND
item_id=$item_id");
+ $this->db->next_record();
+ $index_count = $this->db->f('index_count');
+ if($index_count>1)
+ {
+ $this->db->query("DELETE FROM
fm_s_agreement_pricing WHERE agreement_id=$s_agreement_id AND item_id=$item_id
AND id=$index_count");
+ $this->db->query("UPDATE fm_s_agreement_pricing
set current_index = 1 WHERE agreement_id=$s_agreement_id AND item_id=$item_id
AND id =" . ($index_count-1));
+ }
+ $this->db->transaction_commit();
+ }
+
+ function delete_item($s_agreement_id,$item_id)
+ {
+ $this->db->transaction_begin();
+ $this->db->query("DELETE FROM fm_s_agreement_detail
WHERE agreement_id=$s_agreement_id AND id=$item_id");
+ $this->db->query("DELETE FROM fm_s_agreement_pricing
WHERE agreement_id=$s_agreement_id AND item_id=$item_id");
+ $this->db->transaction_commit();
+ }
+
+
+ function delete($s_agreement_id)
+ {
+ $table = 'fm_s_agreement';
+ $this->db->transaction_begin();
+ $this->db->query("DELETE FROM $table WHERE id=" .
intval($s_agreement_id));
+ $this->db->query("DELETE FROM fm_s_agreement_detail
WHERE agreement_id=" . intval($s_agreement_id));
+ $this->db->query("DELETE FROM fm_s_agreement_pricing
WHERE agreement_id=" . intval($s_agreement_id));
+ $this->db->query("DELETE FROM fm_orders WHERE id=" .
intval($s_agreement_id));
+ $this->db->transaction_commit();
+ }
+
+ function read_attrib($data)
+ {
+ $attribute_table = 'fm_s_agreement_attribute';
+//html_print_r($data);
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $column_list =
(isset($data['column_list'])?$data['column_list']:'');
+ }
+
+ $where = 'WHERE';
+ if ($column_list)
+ {
+ $filtermethod = " $where list !=1 or list is
null";
+ $where = 'AND';
+ }
+ if ($this->role=='detail')
+ {
+ $filtermethod .= " $where attrib_detail=2 ";
+ }
+ else
+ {
+ $filtermethod .= " $where attrib_detail=1 ";
+ }
+
+ $where = 'AND';
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by attrib_sort asc';
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " $where
($attribute_table.input_text $this->like '%$query%' or
$attribute_table.column_name $this->like '%$query%')";
+ }
+
+ $sql = "SELECT * FROM $attribute_table $filtermethod
$querymethod";
+
+//echo $sql;
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $attrib[] = array
+ (
+ 'id' =>
$this->db->f('id'),
+ 'attrib_sort' =>
$this->db->f('attrib_sort'),
+ 'list' =>
$this->db->f('list'),
+ 'lookup_form' =>
$this->db->f('lookup_form'),
+ 'column_name' =>
$this->db->f('column_name'),
+ 'name' =>
$this->db->f('input_text'),
+ 'size' =>
$this->db->f('size'),
+ 'statustext' =>
$this->db->f('statustext'),
+ 'input_text' =>
$this->db->f('input_text'),
+ 'type_name' =>
$this->db->f('type'),
+ 'datatype' =>
$this->db->f('datatype'),
+ 'search' =>
$this->db->f('search')
+ );
+ }
+ return $attrib;
+ }
+
+ function read_single_attrib($id)
+ {
+ $attribute_table = 'fm_s_agreement_attribute';
+
+ if ($this->role=='detail')
+ {
+ $filtermethod = " AND attrib_detail=2 ";
+ }
+ else
+ {
+ $filtermethod = " AND attrib_detail=1 ";
+ }
+
+ $sql = "SELECT * FROM $attribute_table where id=$id
$filtermethod";
+
+ $this->db->query($sql);
+
+ if($this->db->next_record())
+ {
+ $attrib['id']
= $this->db->f('id');
+ $attrib['column_name']
= $this->db->f('column_name');
+ $attrib['input_text']
= $this->db->f('input_text');
+ $attrib['statustext']
= $this->db->f('statustext');
+ $attrib['column_info']['precision'] =
$this->db->f('precision_');
+ $attrib['column_info']['scale'] =
$this->db->f('scale');
+ $attrib['column_info']['default'] =
$this->db->f('default_value');
+ $attrib['column_info']['nullable'] =
$this->db->f('nullable');
+ $attrib['column_info']['type'] =
$this->db->f('datatype');
+ $attrib['type_name']
= $this->db->f('type_name');
+ $attrib['lookup_form']
= $this->db->f('lookup_form');
+ $attrib['list']
= $this->db->f('list');
+ $attrib['search']
= $this->db->f('search');
+ if($this->db->f('datatype')=='R' ||
$this->db->f('datatype')=='CH' || $this->db->f('datatype')=='LB')
+ {
+ $attrib['choice'] =
$this->read_attrib_choice($id);
+ }
+
+ return $attrib;
+ }
+ }
+
+ function read_attrib_choice($attrib_id)
+ {
+ $choice_table = 'fm_s_agreement_choice';
+
+ if ($this->role=='detail')
+ {
+ $filtermethod = " AND attrib_detail=2 ";
+ }
+ else
+ {
+ $filtermethod = " AND attrib_detail=1 ";
+ }
+
+ $sql = "SELECT * FROM $choice_table WHERE
attrib_id=$attrib_id $filtermethod";
+ $this->db->query($sql);
+
+ while ($this->db->next_record())
+ {
+ $choice[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'value' => $this->db->f('value')
+ );
+
+ }
+ return $choice;
+ }
+
+ function add_attrib($attrib)
+ {
+ $attribute_table = 'fm_s_agreement_attribute';
+ $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
+ $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
+ $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
+ $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
+ $attrib['id'] =
$this->bocommon->next_id($attribute_table, array('attrib_detail'=>!!$this->role
+1));
+
+ if($this->role=='detail')
+ {
+ $filtermethod= 'WHERE attrib_detail=2';
+ $table = 'fm_s_agreement_detail';
+ }
+ else
+ {
+ $filtermethod= 'WHERE attrib_detail=1';
+ $table = 'fm_s_agreement';
+ }
+ $sql = "SELECT max(attrib_sort) as max_sort FROM
$attribute_table $filtermethod";
+ $this->db->query($sql);
+ $this->db->next_record();
+ $attrib_sort = $this->db->f('max_sort')+1;
+
+ $values= array(
+ !!$this->role +1,
+ $attrib['id'],
+ $attrib['column_name'],
+ $attrib['input_text'],
+ $attrib['statustext'],
+ $attrib['lookup_form'],
+ $attrib['search'],
+ $attrib['list'],
+ $attrib_sort,
+ $attrib['column_info']['type'],
+ $attrib['column_info']['precision'],
+ $attrib['column_info']['scale'],
+ $attrib['column_info']['default'],
+ $attrib['column_info']['nullable']
+ );
+
+ $values = $this->bocommon->validate_db_insert($values);
+
+ $this->db->transaction_begin();
+
+ $this->db->query("INSERT INTO $attribute_table
(attrib_detail,id,column_name, input_text,
statustext,lookup_form,search,list,attrib_sort,datatype,precision_,scale,default_value,nullable)
"
+ . "VALUES ($values)");
+
+ $receipt['id']= $attrib['id'];
+
+ if($attrib['column_info']['type']=='email' &&
!$attrib['column_info']['precision'])
+ {
+ $attrib['column_info']['precision']=64;
+ }
+
+ $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
+
+ if($attrib['column_info']['type']=='int' &&
!$attrib['column_info']['precision'])
+ {
+ $attrib['column_info']['precision']=4;
+ }
+
+ if(!$attrib['column_info']['default'])
+ {
+ unset($attrib['column_info']['default']);
+ }
+
+ $this->init_process();
+
+
if($this->oProc->AddColumn($table,$attrib['column_name'],
$attrib['column_info']))
+ {
+ $receipt['message'][] = array('msg' =>
lang('Attribute has been saved') );
+ $this->db->transaction_commit();
+
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('column could not be added') );
+ if($this->db->Transaction)
+ {
+ $GLOBALS['phpgw']->db->rollbacktrans();
+ }
+ else
+ {
+ $GLOBALS['phpgw']->db->Execute("DELETE
FROM $attribute_table WHERE id='" . $receipt['id'] . "'");
+ unset($receipt['id']);
+
+ }
+ }
+
+ return $receipt;
+ }
+
+ function init_process()
+ {
+ $this->oProc
=
CreateObject('phpgwapi.schema_proc',$GLOBALS['phpgw_info']['server']['db_type']);
+ $this->oProc->m_odb
= $this->db;
+ $this->oProc->m_odb->Halt_On_Error = 'report';
+ }
+
+ function edit_attrib($attrib)
+ {
+ $attribute_table = 'fm_s_agreement_attribute';
+ $table = 'fm_s_agreement';
+
+ $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
+ $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
+ $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
+ $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
+
+ $choice_table = 'fm_s_agreement_choice';
+
+ if($this->role=='detail')
+ {
+ $filtermethod= ' AND attrib_detail=2';
+ $table = 'fm_s_agreement_detail';
+ }
+ else
+ {
+ $filtermethod= ' AND attrib_detail=1';
+ $table = 'fm_s_agreement';
+ }
+
+ $this->db->query("SELECT column_name FROM
$attribute_table WHERE id='" . $attrib['id']. "' $filtermethod");
+ $this->db->next_record();
+ $OldColumnName = $this->db->f('column_name');
+
+ $this->db->transaction_begin();
+
+ $attrib_type=$attrib['column_info']['type'];
+ if(($OldColumnName !=$attrib['column_name']) ||
($attrib['column_info']['type'] != $this->db->f('datatype')))
+ {
+ $value_set=array(
+ 'column_name' =>
$attrib['column_name'],
+ 'input_text' =>
$attrib['input_text'],
+ 'statustext' =>
$attrib['statustext'],
+ 'lookup_form' =>
$attrib['lookup_form'],
+ 'search' =>
$attrib['search'],
+ 'list' =>
$attrib['list'],
+ 'datatype' =>
$attrib['column_info']['type'],
+ 'precision_' =>
$attrib['column_info']['precision'],
+ 'scale' =>
$attrib['column_info']['scale'],
+ 'default_value' =>
$attrib['column_info']['default'],
+ 'nullable' =>
$attrib['column_info']['nullable']
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE $attribute_table set
$value_set WHERE id=" . $attrib['id'] . $filtermethod);
+
+ if($attrib['column_info']['type']=='email' &&
!$attrib['column_info']['precision'])
+ {
+ $attrib['column_info']['precision']=64;
+ }
+
+ $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
+
+ if($attrib['column_info']['type']=='int' &&
!$attrib['column_info']['precision'])
+ {
+ $attrib['column_info']['precision']=4;
+ }
+
+ if(!$attrib['column_info']['default'])
+ {
+
unset($attrib['column_info']['default']);
+ }
+
+ $this->init_process();
+
+
$this->oProc->AlterColumn($table,$OldColumnName,$attrib['column_name'],$attrib['column_info']);
+
+ }
+
+
+ if($attrib['new_choice'])
+ {
+ $this->db->query("SELECT max(id) as id FROM
$choice_table WHERE attrib_id='" . $attrib['id']. "' $filtermethod");
+ $this->db->next_record();
+ $choice_id = $this->db->f('id')+1;
+
+ // $choice_id =
$this->bocommon->next_id($choice_table
,array('attrib_detail'=>2,'attrib_id'=>$attrib['id']));
+
+ $values= array(
+ $attrib['id'],
+ $choice_id,
+ !!$this->role +1,
+ $attrib['new_choice']
+ );
+
+ $values =
$this->bocommon->validate_db_insert($values);
+
+ $this->db->query("INSERT INTO $choice_table
(attrib_id,id,attrib_detail,value) "
+ . "VALUES ($values)");
+ }
+
+
+ if($attrib['delete_choice'])
+ {
+ for
($i=0;$i<count($attrib['delete_choice']);$i++)
+ {
+ $this->db->query("DELETE FROM
$choice_table WHERE attrib_id=" . $attrib['id'] ." AND id=" .
$attrib['delete_choice'][$i] . $filtermethod);
+ }
+ }
+
+//html_print_r($attrib_type);
+ if($attrib_type!='R' && $attrib_type!='CH' &&
$attrib_type!='LB')
+ {
+ $this->db->query("DELETE FROM $choice_table
WHERE attrib_id=" . $attrib['id'] . $filtermethod);
+ }
+
+
+ $this->db->transaction_commit();
+
+ $receipt['message'][] = array('msg' =>
lang('Attribute has been edited'));
+
+
+ return $receipt;
+
+ }
+ function resort_attrib($data)
+ {
+//html_print_r($data);
+ $attribute_table = 'fm_s_agreement_attribute';
+ if(is_array($data))
+ {
+ $resort =
(isset($data['resort'])?$data['resort']:'up');
+ $id = (isset($data['id'])?$data['id']:'');
+ }
+
+ $sql = "SELECT attrib_sort FROM $attribute_table where
id=$id";
+ $this->db->query($sql);
+ $this->db->next_record();
+ $attrib_sort = $this->db->f('attrib_sort');
+ $sql = "SELECT max(attrib_sort) as max_sort FROM
$attribute_table";
+ $this->db->query($sql);
+ $this->db->next_record();
+ $max_sort = $this->db->f('max_sort');
+ switch($resort)
+ {
+ case 'up':
+ if($attrib_sort>1)
+ {
+ $sql = "UPDATE $attribute_table
set attrib_sort=$attrib_sort WHERE attrib_sort =" . ($attrib_sort-1);
+ $this->db->query($sql);
+ $sql = "UPDATE $attribute_table
set attrib_sort=" . ($attrib_sort-1) ." WHERE id=$id";
+ $this->db->query($sql);
+ }
+ break;
+ case 'down':
+ if($max_sort > $attrib_sort)
+ {
+ $sql = "UPDATE $attribute_table
set attrib_sort=$attrib_sort WHERE attrib_sort =" . ($attrib_sort+1);
+ $this->db->query($sql);
+ $sql = "UPDATE $attribute_table
set attrib_sort=" . ($attrib_sort+1) ." WHERE id=$id";
+ $this->db->query($sql);
+ }
+ break;
+ default:
+ return;
+ break;
+ }
+ }
+ function delete_attrib($attrib_id)
+ {
+ $table = 'fm_s_agreement';
+ $attribute_table = 'fm_s_agreement_attribute';
+ $this->init_process();
+
+ $sql = "SELECT * FROM $attribute_table WHERE
id=$attrib_id";
+
+ $this->db->query($sql);
+ $this->db->next_record();
+ $ColumnName = $this->db->f('column_name');
+
+ if($this->oProc->DropColumn($table,'', $ColumnName))
+ {
+ $sql = "SELECT attrib_sort FROM
$attribute_table where id=$attrib_id";
+ $this->db->query($sql);
+ $this->db->next_record();
+ $attrib_sort = $this->db->f('attrib_sort');
+ $sql2 = "SELECT max(attrib_sort) as max_sort
FROM $attribute_table";
+ $this->db->query($sql2);
+ $this->db->next_record();
+ $max_sort = $this->db->f('max_sort');
+ if($max_sort>$attrib_sort)
+ {
+ $sql = "UPDATE $attribute_table set
attrib_sort=attrib_sort-1 WHERE attrib_sort > $attrib_sort";
+ $this->db->query($sql);
+ }
+
+ $this->db->query("DELETE FROM $attribute_table
WHERE id=$attrib_id");
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('Attribute has NOT been deleted'));
+ }
+
+ return $receipt;
+ }
+
+ function request_next_id()
+ {
+ $this->db->query("SELECT max(id) as id FROM
fm_s_agreement");
+ $this->db->next_record();
+ $next_id= $this->db->f('id')+1;
+ return $next_id;
+ }
+
+
+ }
+?>
Index: property/inc/class.sostandard_2.inc.php
diff -u property/inc/class.sostandard_2.inc.php:1.6
property/inc/class.sostandard_2.inc.php:1.7
--- property/inc/class.sostandard_2.inc.php:1.6 Fri May 13 12:17:25 2005
+++ property/inc/class.sostandard_2.inc.php Fri Jan 27 14:05:43 2006
@@ -1,180 +1,179 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.sostandard_2.inc.php,v 1.6 2005/05/13 12:17:25
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class sostandard_2
- {
-
- function sostandard_2()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
-
- $this->join = $this->socommon->join;
- $this->like = $this->socommon->like;
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $type =
(isset($data['type'])?$data['type']:0);
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by id asc';
- }
-
- $table = $this->select_table($type);
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " where id $this->like
'%$query%' or descr $this->like '%$query%'";
- }
-
- $sql = "SELECT * FROM $table $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $standard[] = array
- (
- 'id' => $this->db->f('id'),
- 'descr' => $this->db->f('descr')
- );
- }
- return $standard;
- }
-
-
- function select_table($type)
- {
-
- switch($type)
- {
- case 'workorder_status':
- $table='fm_workorder_status';
- break;
- case 'request_status':
- $table='fm_request_status';
- break;
- case 'agreement_status':
- $table='fm_agreement_status';
- break;
- case 'building_part':
- $table='fm_building_part';
- break;
- case 'document_status':
- $table='fm_document_status';
- break;
- case 'unit':
- $table='fm_standard_unit';
- break;
- }
-
- return $table;
- }
-
-
- function read_single($id,$type)
- {
-
- $table = $this->select_table($type);
-
- $sql = "SELECT * FROM $table where id='$id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $standard['id'] =
$this->db->f('id');
- $standard['descr']
= $this->db->f('descr');
-
- return $standard;
- }
- }
-
- function add($standard,$type)
- {
- $table = $this->select_table($type);
-
- $standard['descr'] =
$this->db->db_addslashes($standard['descr']);
-
- $this->db->query("INSERT INTO $table (id, descr) "
- . "VALUES ('" . $standard['id'] . "','" .
$standard['descr']. "')",__LINE__,__FILE__);
-
- $receipt['message'][] = array('msg' => lang('standard
has been saved'));
- return $receipt;
- }
-
- function edit($standard,$type)
- {
-
- $table = $this->select_table($type);
-
- $standard['descr'] =
$this->db->db_addslashes($standard['descr']);
-
- $this->db->query("UPDATE $table set descr='" .
$standard['descr']
- . "' WHERE id='" .
$standard['id']. "'",__LINE__,__FILE__);
-
- $receipt['message'][] = array('msg' => lang('standard
has been edited'));
- return $receipt;
- }
-
- function delete($id,$type)
- {
- $table = $this->select_table($type);
-
- $this->db->query("DELETE FROM $table WHERE id='" . $id
. "'",__LINE__,__FILE__);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.sostandard_2.inc.php,v 1.7 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class sostandard_2
+ {
+
+ function sostandard_2()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->like = $this->bocommon->like;
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $type =
(isset($data['type'])?$data['type']:0);
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by id asc';
+ }
+
+ $table = $this->select_table($type);
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " where id $this->like
'%$query%' or descr $this->like '%$query%'";
+ }
+
+ $sql = "SELECT * FROM $table $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $standard[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'descr' => $this->db->f('descr')
+ );
+ }
+ return $standard;
+ }
+
+
+ function select_table($type)
+ {
+
+ switch($type)
+ {
+ case 'workorder_status':
+ $table='fm_workorder_status';
+ break;
+ case 'request_status':
+ $table='fm_request_status';
+ break;
+ case 'agreement_status':
+ $table='fm_agreement_status';
+ break;
+ case 'building_part':
+ $table='fm_building_part';
+ break;
+ case 'document_status':
+ $table='fm_document_status';
+ break;
+ case 'unit':
+ $table='fm_standard_unit';
+ break;
+ }
+
+ return $table;
+ }
+
+
+ function read_single($id,$type)
+ {
+
+ $table = $this->select_table($type);
+
+ $sql = "SELECT * FROM $table where id='$id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $standard['id'] =
$this->db->f('id');
+ $standard['descr']
= $this->db->f('descr');
+
+ return $standard;
+ }
+ }
+
+ function add($standard,$type)
+ {
+ $table = $this->select_table($type);
+
+ $standard['descr'] =
$this->db->db_addslashes($standard['descr']);
+
+ $this->db->query("INSERT INTO $table (id, descr) "
+ . "VALUES ('" . $standard['id'] . "','" .
$standard['descr']. "')",__LINE__,__FILE__);
+
+ $receipt['message'][] = array('msg' => lang('standard
has been saved'));
+ return $receipt;
+ }
+
+ function edit($standard,$type)
+ {
+
+ $table = $this->select_table($type);
+
+ $standard['descr'] =
$this->db->db_addslashes($standard['descr']);
+
+ $this->db->query("UPDATE $table set descr='" .
$standard['descr']
+ . "' WHERE id='" .
$standard['id']. "'",__LINE__,__FILE__);
+
+ $receipt['message'][] = array('msg' => lang('standard
has been edited'));
+ return $receipt;
+ }
+
+ function delete($id,$type)
+ {
+ $table = $this->select_table($type);
+
+ $this->db->query("DELETE FROM $table WHERE id='" . $id
. "'",__LINE__,__FILE__);
+ }
+ }
+?>
Index: property/inc/class.sostandard_3.inc.php
diff -u property/inc/class.sostandard_3.inc.php:1.7
property/inc/class.sostandard_3.inc.php:1.8
--- property/inc/class.sostandard_3.inc.php:1.7 Thu May 12 21:26:28 2005
+++ property/inc/class.sostandard_3.inc.php Fri Jan 27 14:05:43 2006
@@ -1,169 +1,169 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.sostandard_3.inc.php,v 1.7 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class sostandard_3
- {
-
- function sostandard_3()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
-
- $this->join = $this->socommon->join;
- $this->like = $this->socommon->like;
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $type = (isset($data['type'])?$data['type']:0);
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by id asc';
- }
-
- $table = $this->select_table($type);
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " where id $this->like
'%$query%' or descr $this->like '%$query%'";
- }
-
- $sql = "SELECT * FROM $table $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $standard[] = array
- (
- 'id' => $this->db->f('id'),
- 'num' => $this->db->f('num'),
- 'descr' => $this->db->f('descr')
- );
- }
- return $standard;
- }
-
-
- function select_table($type)
- {
-
- switch($type)
- {
- case 'branch':
- $table='fm_branch';
- break;
- case 'key_location':
- $table='fm_key_loc';
- break;
- case 'async':
- $table='fm_async_method';
- break;
- }
-
-
- return $table;
- }
-
-
- function read_single($id,$type)
- {
-
- $table = $this->select_table($type);
-
- $sql = "SELECT * FROM $table where id='$id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $standard['id'] =
$this->db->f('id');
- $standard['num'] =
$this->db->f('num');
- $standard['descr'] =
$this->db->f('descr');
-
- return $standard;
- }
- }
-
- function add($standard,$type)
- {
- $table = $this->select_table($type);
-
- $standard['id'] = $this->socommon->next_id($table);
- $standard['num'] =
$this->db->db_addslashes($standard['descr']);
- $standard['descr'] =
$this->db->db_addslashes($standard['descr']);
-
- $this->db->query("INSERT INTO $table (id, num, descr) "
- . "VALUES ('" . $standard['id'] . "','" .
$standard['num'] . "','" . $standard['descr']. "')",__LINE__,__FILE__);
-
- $receipt['message'][] = array('msg' => lang('standard
has been saved'));
-
- return $receipt;
- }
-
- function edit($standard,$type)
- {
-
- $table = $this->select_table($type);
-
- $standard['num'] =
$this->db->db_addslashes($standard['num']);
- $standard['descr'] =
$this->db->db_addslashes($standard['descr']);
-
- $this->db->query("UPDATE $table set descr='" .
$standard['descr'] . "', num='". $standard['num']
- . "' WHERE id='" .
$standard['id']. "'",__LINE__,__FILE__);
-
- $receipt['message'][] = array('msg' =>lang('standard
has been edited'));
- return $receipt;
- }
-
- function delete($id,$type)
- {
- $table = $this->select_table($type);
-
- $this->db->query("DELETE FROM $table WHERE id='" . $id
. "'",__LINE__,__FILE__);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.sostandard_3.inc.php,v 1.8 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class sostandard_3
+ {
+
+ function sostandard_3()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->socommon =
CreateObject($this->currentapp.'.socommon');
+ $this->join = $this->bocommon->join;
+ $this->like = $this->bocommon->like;
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $type = (isset($data['type'])?$data['type']:0);
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by id asc';
+ }
+
+ $table = $this->select_table($type);
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " where id $this->like
'%$query%' or descr $this->like '%$query%'";
+ }
+
+ $sql = "SELECT * FROM $table $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $standard[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'num' => $this->db->f('num'),
+ 'descr' => $this->db->f('descr')
+ );
+ }
+ return $standard;
+ }
+
+
+ function select_table($type)
+ {
+
+ switch($type)
+ {
+ case 'branch':
+ $table='fm_branch';
+ break;
+ case 'key_location':
+ $table='fm_key_loc';
+ break;
+ case 'async':
+ $table='fm_async_method';
+ break;
+ }
+
+
+ return $table;
+ }
+
+
+ function read_single($id,$type)
+ {
+
+ $table = $this->select_table($type);
+
+ $sql = "SELECT * FROM $table where id='$id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $standard['id'] =
$this->db->f('id');
+ $standard['num'] =
$this->db->f('num');
+ $standard['descr'] =
$this->db->f('descr');
+
+ return $standard;
+ }
+ }
+
+ function add($standard,$type)
+ {
+ $table = $this->select_table($type);
+
+ $standard['id'] = $this->socommon->next_id($table);
+ $standard['num'] =
$this->db->db_addslashes($standard['descr']);
+ $standard['descr'] =
$this->db->db_addslashes($standard['descr']);
+
+ $this->db->query("INSERT INTO $table (id, num, descr) "
+ . "VALUES ('" . $standard['id'] . "','" .
$standard['num'] . "','" . $standard['descr']. "')",__LINE__,__FILE__);
+
+ $receipt['message'][] = array('msg' => lang('standard
has been saved'));
+
+ return $receipt;
+ }
+
+ function edit($standard,$type)
+ {
+
+ $table = $this->select_table($type);
+
+ $standard['num'] =
$this->db->db_addslashes($standard['num']);
+ $standard['descr'] =
$this->db->db_addslashes($standard['descr']);
+
+ $this->db->query("UPDATE $table set descr='" .
$standard['descr'] . "', num='". $standard['num']
+ . "' WHERE id='" .
$standard['id']. "'",__LINE__,__FILE__);
+
+ $receipt['message'][] = array('msg' =>lang('standard
has been edited'));
+ return $receipt;
+ }
+
+ function delete($id,$type)
+ {
+ $table = $this->select_table($type);
+
+ $this->db->query("DELETE FROM $table WHERE id='" . $id
. "'",__LINE__,__FILE__);
+ }
+ }
+?>
Index: property/inc/class.sostandard_entity.inc.php
diff -u property/inc/class.sostandard_entity.inc.php:1.5
property/inc/class.sostandard_entity.inc.php:1.6
--- property/inc/class.sostandard_entity.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/class.sostandard_entity.inc.php Fri Jan 27 14:05:43 2006
@@ -1,504 +1,503 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.sostandard_entity.inc.php,v 1.5 2005/05/12
21:26:28 sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class sostandard_entity
- {
-
- function sostandard_entity()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->join = $this->bocommon->join;
- $this->like = $this->bocommon->like;
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $type = (isset($data['type'])?$data['type']:0);
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by id asc';
- }
-
- $table = $this->select_table($type);
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " where name $this->like
'%$query%' or descr $this->like '%$query%'";
- }
-
- $sql = "SELECT * FROM $table $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $standard[] = array
- (
- 'id' => $this->db->f('id'),
- 'name' => $this->db->f('name'),
- 'prefix'=> $this->db->f('prefix'),
- 'descr' => $this->db->f('descr')
- );
- }
- return $standard;
- }
-
-
- function select_table($type)
- {
-
- switch($type)
- {
- case 'report':
- $table='fm_report_type';
- break;
- }
-
- return $table;
- }
-
- function select_table_attrib($type)
- {
-
- switch($type)
- {
- case 'report':
- $table='fm_report_type_attrib';
- break;
- }
-
- return $table;
- }
-
- function select_table_choice($type)
- {
-
- switch($type)
- {
- case 'report':
- $table='fm_report_type_choice';
- break;
- }
-
- return $table;
- }
-
-
- function read_single($id,$type)
- {
-
- $table = $this->select_table($type);
-
- $sql = "SELECT * FROM $table where id='$id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $standard['id'] =
$this->db->f('id');
- $standard['name'] =
$this->db->f('name');
- $standard['descr'] =
$this->db->f('descr');
- $standard['prefix'] =
$this->db->f('prefix');
-
- return $standard;
- }
- }
-
- function add($standard,$type)
- {
-
- if (!$standard['name'])
- {
- $receipt['error'][] = array('msg'=>lang('Name
not entered!'));
- }
-
- if (!$receipt['error'])
- {
- $table = $this->select_table($type);
-
- $standard['id'] =
$this->bocommon->next_id($table);
- $standard['name'] =
$this->db->db_addslashes($standard['name']);
- $standard['descr'] =
$this->db->db_addslashes($standard['descr']);
-
- $values= array(
- $standard['id'],
- $standard['name'],
- $standard['descr'],
- $standard['prefix']
- );
-
- $values = $this->bocommon->validate_db_insert($values);
-
-
- $this->db->query("INSERT INTO $table (id, name,
descr, prefix) VALUES ($values)",__LINE__,__FILE__);
-
- $receipt['id']=$standard['id'];
- $receipt['message'][] = array('msg' =>
lang('standard has been saved'));
- }
- else
- {
- $receipt['error'][] = array('msg'=>
lang('Attribute has NOT been saved'));
- }
-
-//_debug_array($receipt);
- return $receipt;
- }
-
- function edit($standard,$type)
- {
-
- if (!$standard['name'])
- {
- $receipt['error'][] = array('msg'=>lang('Name
not entered!'));
- }
-
- if (!$receipt['error'])
- {
- $table = $this->select_table($type);
-
- $standard['name'] =
$this->db->db_addslashes($standard['name']);
- $standard['descr'] =
$this->db->db_addslashes($standard['descr']);
-
- $value_set=array(
- 'descr' =>
$standard['descr'],
- 'name' => $standard['name'],
- 'prefix' => $standard['prefix']
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE $table set $value_set
WHERE id=" . $standard['id'],__LINE__,__FILE__);
-
- $receipt['message'][] = array('msg'=>
lang('Standard has been edited'));
- }
- else
- {
- $receipt['error'][] = array('msg' =>
lang('Standard has NOT been edited'));
- }
-
- return $receipt;
- }
-
- function delete($id,$type,$attrib)
- {
- if($attrib)
- {
- $table = $this->select_table_attrib($type);
- }
- else
- {
-
- $table =
$this->select_table($type);
- $attrib_table =
$this->select_table_attrib($type);
- $this->db->query("DELETE_ FROM $attrib_table
WHERE type_id='" . $id . "'",__LINE__,__FILE__);
- }
- $this->db->query("DELETE_ FROM $table WHERE id='" . $id
. "'",__LINE__,__FILE__);
- }
-
- function read_attrib($data)
- {
-
-//_debug_array($data);
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $type = (isset($data['type'])?$data['type']:0);
- $type_id =
(isset($data['type_id'])?$data['type_id']:0);
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- }
-
- $table = $this->select_table_attrib($type);
- $type_table = $this->select_table($type);
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = " order by $table.id asc";
- }
-
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " and ($table.name $this->like
'%$query%' or $table.descr $this->like '%$query%')";
- }
-
- $sql = "SELECT $table.id ,$table.name ,$table.descr,
$table.datatype ,$type_table.name as type FROM $type_table $this->join $table
on $table.type_id = $type_table.id where $table.type_id= '$type_id'
$querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
-
- while ($this->db->next_record())
- {
- $attrib[] = array
- (
- 'id' => $this->db->f('id'),
- 'name' => $this->db->f('name'),
- 'descr' => $this->db->f('descr'),
- 'type_name' => $this->db->f('type'),
- 'datatype' =>
$this->db->f('datatype')
- );
- }
- return $attrib;
- }
-
- function read_single_attrib($id,$type)
- {
-
- $table = $this->select_table_attrib($type);
- $type_table = $this->select_table($type);
-
- $sql = "SELECT $table.id ,$table.name ,$table.descr,
$table.datatype,$type_table.id as type_id ,$type_table.name as type_name FROM
$type_table $this->join $table on $table.type_id = $type_table.id where
$table.id= '$id' $querymethod";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $attrib['id'] = $this->db->f('id');
- $attrib['name'] = $this->db->f('name');
- $attrib['descr'] = $this->db->f('descr');
- $attrib['type_id'] =
$this->db->f('type_id');
- $attrib['type_name'] =
$this->db->f('type_name');
- $attrib['datatype'] =
$this->db->f('datatype');
-// $attrib['list'] = $this->db->f('list');
- if($this->db->f('datatype')=='R' ||
$this->db->f('datatype')=='CH')
- {
- $attrib['choice'] =
$this->read_attrib_choice($attrib['id'],$type);
- }
-
-//_debug_array($attrib);
- }
- return $attrib;
- }
-
- function read_attrib_choice($attrib_id='',$type='')
- {
- $choice_table = $this->select_table_choice($type);
- $sql = "SELECT * FROM $choice_table WHERE
attrib_id=$attrib_id";
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $choice[] = array
- (
- 'id' => $this->db->f('id'),
- 'value' => $this->db->f('value')
- );
- }
- return $choice;
- }
-
- function add_attrib($attrib,$type)
- {
-
- if (!$attrib['type_id'])
- {
- $receipt['error'][] = array('msg'=>lang('Entity
type not choosen!'));
- }
-
- if (!$attrib['datatype'])
- {
- $receipt['error'][] =
array('msg'=>lang('Datatype type not choosen!'));
- }
-
- if (!$attrib['name'])
- {
- $receipt['error'][] = array('msg'=>lang('Name
not entered!'));
- }
-
- if (!$receipt['error'])
- {
-
- $table = $this->select_table_attrib($type);
-
- $attrib['id'] =
$this->bocommon->next_id($table);
- $attrib['name'] =
$this->db->db_addslashes($attrib['name']);
- $attrib['descr'] =
$this->db->db_addslashes($attrib['descr']);
-
-
- $values= array(
- $attrib['id'],
- $attrib['type_id'],
- $attrib['name'],
- $attrib['descr'],
- $attrib['datatype']
-// $attrib['list']
- );
-
- $values = $this->bocommon->validate_db_insert($values);
-
- $this->db->query("INSERT INTO $table (id,
type_id, name, descr, datatype) "
- . "VALUES ($values)",__LINE__,__FILE__);
-
- $receipt['id']=$attrib['id'];
- $receipt['message'][] = array('msg' =>
lang('Attribute has been saved') );
-
- }
- else
- {
- $receipt['error'][] = array('msg' =>
lang('Attribute has NOT been saved'));
- }
- return $receipt;
- }
-
- function edit_attrib($attrib,$type)
- {
-
- if (!$attrib['type_id'])
- {
- $receipt['error'][] = array('msg'=>lang('Entity
type not choosen!'));
- }
-
- if (!$attrib['datatype'])
- {
- $receipt['error'][] =
array('msg'=>lang('Datatype type not choosen!'));
- }
-
- if (!$attrib['name'])
- {
- $receipt['error'][] = array('msg'=>lang('Name
not entered!'));
- }
-
- if (!$receipt['error'])
- {
- $table = $this->select_table_attrib($type);
- $choice_table =
$this->select_table_choice($type);
-
- $attrib['name'] =
$this->db->db_addslashes($attrib['name']);
- $attrib['descr'] =
$this->db->db_addslashes($attrib['descr']);
-
- $value_set=array(
- 'descr' => $attrib['descr'],
- 'name' => $attrib['name'],
- 'type_id' => $attrib['type_id'],
- 'datatype' => $attrib['datatype']
-// 'list' => $attrib['list']
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE $table set $value_set
WHERE id=" . $attrib['id'],__LINE__,__FILE__);
-
- if($attrib['new_choice'])
- {
- $this->db->query("INSERT INTO
$choice_table (attrib_id, value) "
- . "VALUES ('" . $attrib['id'] . "','" .
$attrib['new_choice']. "')",__LINE__,__FILE__);
-
- }
-
- if($attrib['delete_choice'])
- {
- for
($i=0;$i<count($attrib['delete_choice']);$i++)
- {
-
- $this->db->query("DELETE FROM
$choice_table WHERE id='" . $attrib['delete_choice'][$i] .
"'",__LINE__,__FILE__);
- }
- }
-
- if($attrib['datatype']!='R' &&
$attrib['datatype']!='CH')
- {
- $this->db->query("DELETE FROM
$choice_table WHERE attrib_id='" . $attrib['id'] . "'",__LINE__,__FILE__);
- }
-
- $receipt['message'][] = array('msg' =>
lang('Attribute has been edited'));
- }
- else
- {
- $receipt['error'][] = array('msg' =>
lang('Attribute has NOT been edited'));
- }
- return $receipt;
- }
-
-
- function select_entity_type($type='')
- {
- $table = $this->select_table($type);
-
- $this->db->query("SELECT * FROM $table ORDER BY name ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $entity_type[$i]['id'] =
$this->db->f('id');
- $entity_type[$i]['name'] =
stripslashes($this->db->f('name'));
- $entity_type[$i]['descr'] =
stripslashes($this->db->f('descr'));
- $i++;
- }
-//_debug_array($entity_type);
-
- return $entity_type;
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.sostandard_entity.inc.php,v 1.6 2006/01/27
14:05:43 sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class sostandard_entity
+ {
+
+ function sostandard_entity()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->like = $this->bocommon->like;
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $type = (isset($data['type'])?$data['type']:0);
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by id asc';
+ }
+
+ $table = $this->select_table($type);
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " where name $this->like
'%$query%' or descr $this->like '%$query%'";
+ }
+
+ $sql = "SELECT * FROM $table $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $standard[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'name' => $this->db->f('name'),
+ 'prefix'=> $this->db->f('prefix'),
+ 'descr' => $this->db->f('descr')
+ );
+ }
+ return $standard;
+ }
+
+
+ function select_table($type)
+ {
+
+ switch($type)
+ {
+ case 'report':
+ $table='fm_report_type';
+ break;
+ }
+
+ return $table;
+ }
+
+ function select_table_attrib($type)
+ {
+
+ switch($type)
+ {
+ case 'report':
+ $table='fm_report_type_attrib';
+ break;
+ }
+
+ return $table;
+ }
+
+ function select_table_choice($type)
+ {
+
+ switch($type)
+ {
+ case 'report':
+ $table='fm_report_type_choice';
+ break;
+ }
+
+ return $table;
+ }
+
+
+ function read_single($id,$type)
+ {
+
+ $table = $this->select_table($type);
+
+ $sql = "SELECT * FROM $table where id='$id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $standard['id'] =
$this->db->f('id');
+ $standard['name'] =
$this->db->f('name');
+ $standard['descr'] =
$this->db->f('descr');
+ $standard['prefix'] =
$this->db->f('prefix');
+
+ return $standard;
+ }
+ }
+
+ function add($standard,$type)
+ {
+
+ if (!$standard['name'])
+ {
+ $receipt['error'][] = array('msg'=>lang('Name
not entered!'));
+ }
+
+ if (!$receipt['error'])
+ {
+ $table = $this->select_table($type);
+
+ $standard['id'] =
$this->bocommon->next_id($table);
+ $standard['name'] =
$this->db->db_addslashes($standard['name']);
+ $standard['descr'] =
$this->db->db_addslashes($standard['descr']);
+
+ $values= array(
+ $standard['id'],
+ $standard['name'],
+ $standard['descr'],
+ $standard['prefix']
+ );
+
+ $values = $this->bocommon->validate_db_insert($values);
+
+
+ $this->db->query("INSERT INTO $table (id, name,
descr, prefix) VALUES ($values)",__LINE__,__FILE__);
+
+ $receipt['id']=$standard['id'];
+ $receipt['message'][] = array('msg' =>
lang('standard has been saved'));
+ }
+ else
+ {
+ $receipt['error'][] = array('msg'=>
lang('Attribute has NOT been saved'));
+ }
+
+//_debug_array($receipt);
+ return $receipt;
+ }
+
+ function edit($standard,$type)
+ {
+
+ if (!$standard['name'])
+ {
+ $receipt['error'][] = array('msg'=>lang('Name
not entered!'));
+ }
+
+ if (!$receipt['error'])
+ {
+ $table = $this->select_table($type);
+
+ $standard['name'] =
$this->db->db_addslashes($standard['name']);
+ $standard['descr'] =
$this->db->db_addslashes($standard['descr']);
+
+ $value_set=array(
+ 'descr' =>
$standard['descr'],
+ 'name' => $standard['name'],
+ 'prefix' => $standard['prefix']
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE $table set $value_set
WHERE id=" . $standard['id'],__LINE__,__FILE__);
+
+ $receipt['message'][] = array('msg'=>
lang('Standard has been edited'));
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('Standard has NOT been edited'));
+ }
+
+ return $receipt;
+ }
+
+ function delete($id,$type,$attrib)
+ {
+ if($attrib)
+ {
+ $table = $this->select_table_attrib($type);
+ }
+ else
+ {
+
+ $table =
$this->select_table($type);
+ $attrib_table =
$this->select_table_attrib($type);
+ $this->db->query("DELETE_ FROM $attrib_table
WHERE type_id='" . $id . "'",__LINE__,__FILE__);
+ }
+ $this->db->query("DELETE_ FROM $table WHERE id='" . $id
. "'",__LINE__,__FILE__);
+ }
+
+ function read_attrib($data)
+ {
+
+//_debug_array($data);
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $type = (isset($data['type'])?$data['type']:0);
+ $type_id =
(isset($data['type_id'])?$data['type_id']:0);
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ }
+
+ $table = $this->select_table_attrib($type);
+ $type_table = $this->select_table($type);
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = " order by $table.id asc";
+ }
+
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " and ($table.name $this->like
'%$query%' or $table.descr $this->like '%$query%')";
+ }
+
+ $sql = "SELECT $table.id ,$table.name ,$table.descr,
$table.datatype ,$type_table.name as type FROM $type_table $this->join $table
on $table.type_id = $type_table.id where $table.type_id= '$type_id'
$querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+
+ while ($this->db->next_record())
+ {
+ $attrib[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'name' => $this->db->f('name'),
+ 'descr' => $this->db->f('descr'),
+ 'type_name' => $this->db->f('type'),
+ 'datatype' =>
$this->db->f('datatype')
+ );
+ }
+ return $attrib;
+ }
+
+ function read_single_attrib($id,$type)
+ {
+
+ $table = $this->select_table_attrib($type);
+ $type_table = $this->select_table($type);
+
+ $sql = "SELECT $table.id ,$table.name ,$table.descr,
$table.datatype,$type_table.id as type_id ,$type_table.name as type_name FROM
$type_table $this->join $table on $table.type_id = $type_table.id where
$table.id= '$id' $querymethod";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $attrib['id'] = $this->db->f('id');
+ $attrib['name'] = $this->db->f('name');
+ $attrib['descr'] = $this->db->f('descr');
+ $attrib['type_id'] =
$this->db->f('type_id');
+ $attrib['type_name'] =
$this->db->f('type_name');
+ $attrib['datatype'] =
$this->db->f('datatype');
+// $attrib['list'] = $this->db->f('list');
+ if($this->db->f('datatype')=='R' ||
$this->db->f('datatype')=='CH')
+ {
+ $attrib['choice'] =
$this->read_attrib_choice($attrib['id'],$type);
+ }
+
+//_debug_array($attrib);
+ }
+ return $attrib;
+ }
+
+ function read_attrib_choice($attrib_id='',$type='')
+ {
+ $choice_table = $this->select_table_choice($type);
+ $sql = "SELECT * FROM $choice_table WHERE
attrib_id=$attrib_id";
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $choice[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'value' => $this->db->f('value')
+ );
+ }
+ return $choice;
+ }
+
+ function add_attrib($attrib,$type)
+ {
+
+ if (!$attrib['type_id'])
+ {
+ $receipt['error'][] = array('msg'=>lang('Entity
type not choosen!'));
+ }
+
+ if (!$attrib['datatype'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Datatype type not choosen!'));
+ }
+
+ if (!$attrib['name'])
+ {
+ $receipt['error'][] = array('msg'=>lang('Name
not entered!'));
+ }
+
+ if (!$receipt['error'])
+ {
+
+ $table = $this->select_table_attrib($type);
+
+ $attrib['id'] =
$this->bocommon->next_id($table);
+ $attrib['name'] =
$this->db->db_addslashes($attrib['name']);
+ $attrib['descr'] =
$this->db->db_addslashes($attrib['descr']);
+
+
+ $values= array(
+ $attrib['id'],
+ $attrib['type_id'],
+ $attrib['name'],
+ $attrib['descr'],
+ $attrib['datatype']
+// $attrib['list']
+ );
+
+ $values = $this->bocommon->validate_db_insert($values);
+
+ $this->db->query("INSERT INTO $table (id,
type_id, name, descr, datatype) "
+ . "VALUES ($values)",__LINE__,__FILE__);
+
+ $receipt['id']=$attrib['id'];
+ $receipt['message'][] = array('msg' =>
lang('Attribute has been saved') );
+
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('Attribute has NOT been saved'));
+ }
+ return $receipt;
+ }
+
+ function edit_attrib($attrib,$type)
+ {
+
+ if (!$attrib['type_id'])
+ {
+ $receipt['error'][] = array('msg'=>lang('Entity
type not choosen!'));
+ }
+
+ if (!$attrib['datatype'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Datatype type not choosen!'));
+ }
+
+ if (!$attrib['name'])
+ {
+ $receipt['error'][] = array('msg'=>lang('Name
not entered!'));
+ }
+
+ if (!$receipt['error'])
+ {
+ $table = $this->select_table_attrib($type);
+ $choice_table =
$this->select_table_choice($type);
+
+ $attrib['name'] =
$this->db->db_addslashes($attrib['name']);
+ $attrib['descr'] =
$this->db->db_addslashes($attrib['descr']);
+
+ $value_set=array(
+ 'descr' => $attrib['descr'],
+ 'name' => $attrib['name'],
+ 'type_id' => $attrib['type_id'],
+ 'datatype' => $attrib['datatype']
+// 'list' => $attrib['list']
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE $table set $value_set
WHERE id=" . $attrib['id'],__LINE__,__FILE__);
+
+ if($attrib['new_choice'])
+ {
+ $this->db->query("INSERT INTO
$choice_table (attrib_id, value) "
+ . "VALUES ('" . $attrib['id'] . "','" .
$attrib['new_choice']. "')",__LINE__,__FILE__);
+
+ }
+
+ if($attrib['delete_choice'])
+ {
+ for
($i=0;$i<count($attrib['delete_choice']);$i++)
+ {
+
+ $this->db->query("DELETE FROM
$choice_table WHERE id='" . $attrib['delete_choice'][$i] .
"'",__LINE__,__FILE__);
+ }
+ }
+
+ if($attrib['datatype']!='R' &&
$attrib['datatype']!='CH')
+ {
+ $this->db->query("DELETE FROM
$choice_table WHERE attrib_id='" . $attrib['id'] . "'",__LINE__,__FILE__);
+ }
+
+ $receipt['message'][] = array('msg' =>
lang('Attribute has been edited'));
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('Attribute has NOT been edited'));
+ }
+ return $receipt;
+ }
+
+
+ function select_entity_type($type='')
+ {
+ $table = $this->select_table($type);
+
+ $this->db->query("SELECT * FROM $table ORDER BY name ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $entity_type[$i]['id'] =
$this->db->f('id');
+ $entity_type[$i]['name'] =
stripslashes($this->db->f('name'));
+ $entity_type[$i]['descr'] =
stripslashes($this->db->f('descr'));
+ $i++;
+ }
+//_debug_array($entity_type);
+
+ return $entity_type;
+ }
+
+ }
+?>
Index: property/inc/class.sotemplate.inc.php
diff -u property/inc/class.sotemplate.inc.php:1.5
property/inc/class.sotemplate.inc.php:1.6
--- property/inc/class.sotemplate.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/class.sotemplate.inc.php Fri Jan 27 14:05:43 2006
@@ -1,474 +1,473 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage project
- * @version $Id: class.sotemplate.inc.php,v 1.5 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class sotemplate
- {
-
- function sotemplate()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->socommon =
CreateObject($this->currentapp.'.socommon');
-
- $this->join = $this->socommon->join;
- $this->left_join = $this->socommon->left_join;
- $this->like = $this->socommon->like;
- }
-
- function read($data)
- {
-
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
(isset($data['filter'])?$data['filter']:'');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $chapter_id =
(isset($data['chapter_id'])?$data['chapter_id']:0);
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $template_id =
(isset($data['template_id'])?$data['template_id']:0);
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by fm_template.id desc';
- }
-
- $where= 'WHERE';
-
- if ($chapter_id > 0)
- {
- $filtermethod .= " $where
chapter_id='$chapter_id' ";
- $where= 'AND';
- }
-
- if ($filter)
- {
- $filtermethod .= " $where
fm_template.owner='$filter' ";
- $where= 'AND';
- }
-
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " $where (fm_template.descr
$this->like '%$query%')";
- }
-
- $sql = "SELECT
fm_template.id,fm_template.descr,fm_template.name,fm_template.owner,fm_template.entry_date,"
- . " fm_chapter.descr as chapter FROM fm_template
$this->left_join fm_chapter on fm_template.chapter_id=fm_chapter.id"
- . " $filtermethod $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $template_list[] = array
- (
- 'template_id' =>
$this->db->f('id'),
- 'name' =>
stripslashes($this->db->f('name')),
- 'descr' =>
stripslashes($this->db->f('descr')),
- 'owner' =>
$this->db->f('owner'),
- 'entry_date' =>
$this->db->f('entry_date'),
- 'chapter' =>
$this->db->f('chapter')
- );
- }
- return $template_list;
- }
-
- function read_template_hour($data)
- {
-
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $chapter_id =
(isset($data['chapter_id'])?$data['chapter_id']:0);
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $template_id =
(isset($data['template_id'])?$data['template_id']:0);
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by record ';
- }
-
-
- $filtermethod .= " where template_id='$template_id' ";
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " AND (hours_descr $this->like
'%$query%' or fm_template_hours.remark $this->like '%$query%' or ns3420_id
$this->like '%$query%')";
- }
-
- $sql = "SELECT fm_template_hours.*, chapter_id from
fm_template_hours $this->join fm_template on
fm_template.id=fm_template_hours.template_id $filtermethod $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $hour_list[] = array
- (
- 'hour_id' =>
$this->db->f('id'),
- 'chapter_id' =>
$this->db->f('chapter_id'),
- 'activity_num' =>
$this->db->f('activity_num'),
- 'hours_descr' =>
stripslashes($this->db->f('hours_descr')),
- 'remark' =>
stripslashes($this->db->f('remark')),
- 'grouping_id' =>
$this->db->f('grouping_id'),
- 'grouping_descr' =>
$this->db->f('grouping_descr'),
- 'ns3420_id' =>
$this->db->f('ns3420_id'),
- 'tolerance' =>
$this->db->f('tolerance'),
- 'activity_id' =>
$this->db->f('activity_id'),
- 'unit' =>
$this->db->f('unit'),
- 'record' =>
$this->db->f('record'),
- 'cost' =>
$this->db->f('cost'),
- 'billperae' =>
$this->db->f('billperae'),
- 'building_part' =>
$this->db->f('building_part'),
- 'dim_d' =>
$this->db->f('dim_d')
- );
- }
- return $hour_list;
- }
-
- function read_single_template($template_id)
- {
- $sql = "SELECT * FROM fm_template where
id='$template_id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $template['template_id'] =
$this->db->f('id');
- $template['name']
= stripslashes($this->db->f('name'));
- $template['descr']
= stripslashes($this->db->f('descr'));
- $template['chapter_id'] =
(int)$this->db->f('chapter_id');
- }
- return $template;
- }
-
- function read_single_hour($hour_id)
- {
- $sql = "SELECT * from fm_template_hours where
id='$hour_id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $hour['hour_id']
= $this->db->f('id');
- $hour['record']
= $this->db->f('record');
- $hour['activity_id'] =
$this->db->f('activity_id');
- $hour['activity_num'] =
$this->db->f('activity_num');
- $hour['grouping_id'] =
$this->db->f('grouping_id');
- $hour['hours_descr'] =
$this->db->f('hours_descr');
- $hour['remark']
= $this->db->f('remark');
- $hour['billperae']
= $this->db->f('billperae');
- $hour['unit']
= $this->db->f('unit');
- $hour['ns3420_id']
= $this->db->f('ns3420_id');
- $hour['tolerance_id'] =
(int)$this->db->f('tolerance');
- $hour['building_part_id'] =
(int)$this->db->f('building_part');
- $hour['quantity']
= $this->db->f('quantity');
- $hour['cost']
= $this->db->f('cost');
- $hour['dim_d']
= $this->db->f('dim_d');
- }
-
- return $hour;
- }
-
- function next_record($template_id)
- {
-
- $this->db->query("SELECT max(record) as record FROM
fm_template_hours where template_id='$template_id'",__LINE__,__FILE__);
- $this->db->next_record();
- $record = $this->db->f('record')+1;
- return $record;
-
- }
-
- function add_custom_hour($hour,$template_id)
- {
-
- $hour['record'] = $this->next_record($template_id);
-
- $this->db->query("UPDATE fm_template set
- chapter_id ='" . $hour['chapter_id'] . "'
WHERE id= '$template_id'",__LINE__,__FILE__);
-
- if($hour['grouping_id'])
- {
- $this->db->query("SELECT grouping_descr ,
max(record) as record FROM fm_template_hours where grouping_id='"
.$hour['grouping_id'] . "' and template_id= '$template_id' GROUP by
grouping_descr",__LINE__,__FILE__);
- $this->db->next_record();
- $hour['grouping_descr'] =
$this->db->f('grouping_descr');
- }
-
- if($hour['new_grouping'])
- {
- $this->db->query("SELECT grouping_id FROM
fm_template_hours where grouping_descr ='" .$hour['new_grouping'] . "' and
template_id= '$template_id'",__LINE__,__FILE__);
- $this->db->next_record();
- if ( $this->db->f('grouping_id'))
- {
- $hour['grouping_id'] =
$this->db->f('grouping_id');
- }
- else
- {
- $this->db->query("SELECT
max(grouping_id) as grouping_id FROM fm_template_hours where template_id=
'$template_id'",__LINE__,__FILE__);
- $this->db->next_record();
- $hour['grouping_id'] =
$this->db->f('grouping_id')+1;
- }
-
- $hour['grouping_descr'] = $hour['new_grouping'];
- }
-
- $this->db->query("insert into fm_template_hours
(owner,hours_descr,unit,cost,quantity,billperae,ns3420_id,dim_d,"
- . "
grouping_id,grouping_descr,record,building_part,tolerance,remark,entry_date,template_id)
"
- . " values ('" .
- $this->account . "','" .
- $hour['descr'] . "','" .
- $hour['unit'] . "','" .
- $hour['cost'] . "','" .
- $hour['quantity'] . "','" .
- $hour['billperae'] . "','" .
- $hour['ns3420_id'] . "','" .
- $hour['dim_d'] . "','" .
- $hour['grouping_id'] . "','" .
- $hour['grouping_descr'] . "','" .
- $hour['record'] . "','" .
- $hour['building_part_id'] . "','" .
- $hour['tolerance_id'] . "','" .
- $hour['remark'] . "','" .
- time() . "','" .
- $template_id . "')",__LINE__,__FILE__);
-
- $receipt['hour_id'] =
$this->db->get_last_insert_id('fm_template_hours','id');
-
- $receipt['message'][] = array('msg'=>lang('hour %1 is
added!',$hour['record']));
-
- return $receipt;
- }
-
-
- function edit_hour($hour,$template_id)
- {
-
- $hour['descr'] =
$this->db->db_addslashes($hour['descr']);
- $hour['remark'] =
$this->db->db_addslashes($hour['remark']);
-
- $this->db->query("UPDATE fm_template set
- chapter_id ='" . $hour['chapter_id'] . "'
WHERE id= '$template_id'",__LINE__,__FILE__);
-
- if($hour['new_grouping'])
- {
- $this->db->query("SELECT grouping_id FROM
fm_template_hours where grouping_descr ='" .$hour['new_grouping'] . "' and
template_id= '$template_id'",__LINE__,__FILE__);
- $this->db->next_record();
- if ( $this->db->f('grouping_id'))
- {
- $hour['grouping_id'] =
$this->db->f('grouping_id');
- }
- else
- {
-
- $this->db->query("UPDATE
fm_template_hours set grouping_id = NULL WHERE id ='" .$hour['hour_id'] .
"'",__LINE__,__FILE__);
- $this->db->query("SELECT
count(grouping_id) as num_grouping FROM fm_template_hours where template_id=
'$template_id' and grouping_id >0 ",__LINE__,__FILE__);
- $this->db->next_record();
- if ($this->db->f('num_grouping')==1)
- {
- $hour['grouping_id']=1;
- }
- else
- {
- $this->db->query("SELECT
max(grouping_id) as grouping_id FROM fm_template_hours where template_id=
'$template_id'",__LINE__,__FILE__);
- $this->db->next_record();
- $hour['grouping_id'] =
$this->db->f('grouping_id')+1;
- }
- }
- $hour['grouping_descr'] = $hour['new_grouping'];
- }
- else
- {
- $this->db->query("SELECT
grouping_id,grouping_descr FROM fm_template_hours where id ='"
.$hour['hour_id'] . "'",__LINE__,__FILE__);
- $this->db->next_record();
- $old_grouping_id =
$this->db->f('grouping_id');
-
- if ( $old_grouping_id == $hour['grouping_id'])
- {
-
- $hour['grouping_descr'] =
$this->db->f('grouping_descr');
- }
- else
- {
- $this->db->query("SELECT grouping_descr
, max(record) as record FROM fm_template_hours where grouping_id='"
.$hour['grouping_id'] . "' and template_id= '$template_id' GROUP by
grouping_descr",__LINE__,__FILE__);
- $this->db->next_record();
- if($this->db->f('grouping_descr'))
- {
- $hour['grouping_descr'] =
$this->db->f('grouping_descr');
- }
- else
- {
- $hour['grouping_id']='';
- $hour['grouping_descr']='';
- }
-
- }
- }
-
- $this->db->query("SELECT record FROM fm_template_hours
where id ='" .$hour['hour_id'] . "'",__LINE__,__FILE__);
- $this->db->next_record();
- $hour['record'] = $this->db->f('record');
-
- $this->db->query("UPDATE fm_template_hours set
- hours_descr ='" .
$hour['descr'] . "',
- remark ='" .
$hour['remark'] . "',
- billperae ='" .
$hour['billperae'] . "',
- unit ='" .
$hour['unit'] . "',
- quantity ='" .
$hour['quantity'] . "',
- cost ='" .
$hour['cost'] . "',
- ns3420_id ='" .
$hour['ns3420_id'] . "',
- tolerance ='" .
$hour['tolerance_id'] . "',
- building_part ='" .
$hour['building_part_id'] . "',
- dim_d ='" .
$hour['dim_d'] . "',
- grouping_id ='" .
$hour['grouping_id'] . "',
- grouping_descr ='" .
$hour['grouping_descr']
- . "' WHERE id= '" . $hour['hour_id']
."'",__LINE__,__FILE__);
-
- $receipt['hour_id'] = $hour['hour_id'];
- $receipt['message'][] = array('msg'=>lang('hour %1 has
been edited',$hour['record']));
- return $receipt;
-
- }
-
- function get_grouping_list($template_id='')
- {
- $this->db->query("SELECT grouping_id, grouping_descr
FROM fm_template_hours where template_id='$template_id' and grouping_id >0
group by grouping_id, grouping_descr");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $grouping_entries[$i]['id']
= $this->db->f('grouping_id');
- $grouping_entries[$i]['name']
= stripslashes($this->db->f('grouping_descr'));
- $i++;
- }
- return $grouping_entries;
- }
-
- function add_template($values)
- {
-
- $values['name'] =
$this->db->db_addslashes($values['name']);
-
- $this->db->query("insert into fm_template
(owner,name,descr,chapter_id,entry_date) "
- . " values ('" .
- $this->account . "','" .
- $values['name'] . "','" .
- $values['descr'] . "','" .
- $values['chapter_id'] . "','" .
- time() . "')",__LINE__,__FILE__);
-
- $template_id =
$this->db->get_last_insert_id('fm_template','id');
-
- $receipt['template_id'] = $template_id;
- $receipt['message'][] = array('msg'=>lang('template %1
is added',$values['name']));
- return $receipt;
- }
-
- function edit_template($values)
- {
- $values['name'] =
$this->db->db_addslashes($values['name']);
- $values['descr'] =
$this->db->db_addslashes($values['descr']);
-
- $this->db->query("UPDATE fm_template set name='" .
$values['name'] . "', descr='" . $values['descr'] . "', chapter_id='"
- .
(int)$values['chapter_id']
- . "' WHERE id='" .
$values['template_id'] . "'",__LINE__,__FILE__);
-
- $receipt['message'][]=array('msg'=>lang('Property has
been edited'));
- return $receipt;
- }
-
- function delete($id)
- {
- $this->db->query("DELETE FROM fm_template WHERE
id='$id'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_template_hours WHERE
template_id='$id'",__LINE__,__FILE__);
- }
-
- function delete_hour($hour_id,$template_id )
- {
- $this->db->query("SELECT record FROM fm_template_hours
where id ='$hour_id'",__LINE__,__FILE__);
- $this->db->next_record();
- $old_record = $this->db->f('record');
-
- $this->db->query("DELETE FROM fm_template_hours WHERE
id='" . $hour_id . "'",__LINE__,__FILE__);
- if($old_record)
- {
- $this->db->query("UPDATE fm_template_hours set
record = record - 1 where template_id= '$template_id' and record >
$old_record ",__LINE__,__FILE__);
- }
-
- $receipt['message'][] = array('msg'=>lang('hour %1 has
been deleted',$hour_id));
- return $receipt;
-
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage project
+ * @version $Id: class.sotemplate.inc.php,v 1.6 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class sotemplate
+ {
+
+ function sotemplate()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->left_join = $this->bocommon->left_join;
+ $this->like = $this->bocommon->like;
+ }
+
+ function read($data)
+ {
+
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
(isset($data['filter'])?$data['filter']:'');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $chapter_id =
(isset($data['chapter_id'])?$data['chapter_id']:0);
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $template_id =
(isset($data['template_id'])?$data['template_id']:0);
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by fm_template.id desc';
+ }
+
+ $where= 'WHERE';
+
+ if ($chapter_id > 0)
+ {
+ $filtermethod .= " $where
chapter_id='$chapter_id' ";
+ $where= 'AND';
+ }
+
+ if ($filter)
+ {
+ $filtermethod .= " $where
fm_template.owner='$filter' ";
+ $where= 'AND';
+ }
+
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " $where (fm_template.descr
$this->like '%$query%')";
+ }
+
+ $sql = "SELECT
fm_template.id,fm_template.descr,fm_template.name,fm_template.owner,fm_template.entry_date,"
+ . " fm_chapter.descr as chapter FROM fm_template
$this->left_join fm_chapter on fm_template.chapter_id=fm_chapter.id"
+ . " $filtermethod $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $template_list[] = array
+ (
+ 'template_id' =>
$this->db->f('id'),
+ 'name' =>
stripslashes($this->db->f('name')),
+ 'descr' =>
stripslashes($this->db->f('descr')),
+ 'owner' =>
$this->db->f('owner'),
+ 'entry_date' =>
$this->db->f('entry_date'),
+ 'chapter' =>
$this->db->f('chapter')
+ );
+ }
+ return $template_list;
+ }
+
+ function read_template_hour($data)
+ {
+
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $chapter_id =
(isset($data['chapter_id'])?$data['chapter_id']:0);
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $template_id =
(isset($data['template_id'])?$data['template_id']:0);
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by record ';
+ }
+
+
+ $filtermethod .= " where template_id='$template_id' ";
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " AND (hours_descr $this->like
'%$query%' or fm_template_hours.remark $this->like '%$query%' or ns3420_id
$this->like '%$query%')";
+ }
+
+ $sql = "SELECT fm_template_hours.*, chapter_id from
fm_template_hours $this->join fm_template on
fm_template.id=fm_template_hours.template_id $filtermethod $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $hour_list[] = array
+ (
+ 'hour_id' =>
$this->db->f('id'),
+ 'chapter_id' =>
$this->db->f('chapter_id'),
+ 'activity_num' =>
$this->db->f('activity_num'),
+ 'hours_descr' =>
stripslashes($this->db->f('hours_descr')),
+ 'remark' =>
stripslashes($this->db->f('remark')),
+ 'grouping_id' =>
$this->db->f('grouping_id'),
+ 'grouping_descr' =>
$this->db->f('grouping_descr'),
+ 'ns3420_id' =>
$this->db->f('ns3420_id'),
+ 'tolerance' =>
$this->db->f('tolerance'),
+ 'activity_id' =>
$this->db->f('activity_id'),
+ 'unit' =>
$this->db->f('unit'),
+ 'record' =>
$this->db->f('record'),
+ 'cost' =>
$this->db->f('cost'),
+ 'billperae' =>
$this->db->f('billperae'),
+ 'building_part' =>
$this->db->f('building_part'),
+ 'dim_d' =>
$this->db->f('dim_d')
+ );
+ }
+ return $hour_list;
+ }
+
+ function read_single_template($template_id)
+ {
+ $sql = "SELECT * FROM fm_template where
id='$template_id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $template['template_id'] =
$this->db->f('id');
+ $template['name']
= stripslashes($this->db->f('name'));
+ $template['descr']
= stripslashes($this->db->f('descr'));
+ $template['chapter_id'] =
(int)$this->db->f('chapter_id');
+ }
+ return $template;
+ }
+
+ function read_single_hour($hour_id)
+ {
+ $sql = "SELECT * from fm_template_hours where
id='$hour_id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $hour['hour_id']
= $this->db->f('id');
+ $hour['record']
= $this->db->f('record');
+ $hour['activity_id'] =
$this->db->f('activity_id');
+ $hour['activity_num'] =
$this->db->f('activity_num');
+ $hour['grouping_id'] =
$this->db->f('grouping_id');
+ $hour['hours_descr'] =
$this->db->f('hours_descr');
+ $hour['remark']
= $this->db->f('remark');
+ $hour['billperae']
= $this->db->f('billperae');
+ $hour['unit']
= $this->db->f('unit');
+ $hour['ns3420_id']
= $this->db->f('ns3420_id');
+ $hour['tolerance_id'] =
(int)$this->db->f('tolerance');
+ $hour['building_part_id'] =
(int)$this->db->f('building_part');
+ $hour['quantity']
= $this->db->f('quantity');
+ $hour['cost']
= $this->db->f('cost');
+ $hour['dim_d']
= $this->db->f('dim_d');
+ }
+
+ return $hour;
+ }
+
+ function next_record($template_id)
+ {
+
+ $this->db->query("SELECT max(record) as record FROM
fm_template_hours where template_id='$template_id'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $record = $this->db->f('record')+1;
+ return $record;
+
+ }
+
+ function add_custom_hour($hour,$template_id)
+ {
+
+ $hour['record'] = $this->next_record($template_id);
+
+ $this->db->query("UPDATE fm_template set
+ chapter_id ='" . $hour['chapter_id'] . "'
WHERE id= '$template_id'",__LINE__,__FILE__);
+
+ if($hour['grouping_id'])
+ {
+ $this->db->query("SELECT grouping_descr ,
max(record) as record FROM fm_template_hours where grouping_id='"
.$hour['grouping_id'] . "' and template_id= '$template_id' GROUP by
grouping_descr",__LINE__,__FILE__);
+ $this->db->next_record();
+ $hour['grouping_descr'] =
$this->db->f('grouping_descr');
+ }
+
+ if($hour['new_grouping'])
+ {
+ $this->db->query("SELECT grouping_id FROM
fm_template_hours where grouping_descr ='" .$hour['new_grouping'] . "' and
template_id= '$template_id'",__LINE__,__FILE__);
+ $this->db->next_record();
+ if ( $this->db->f('grouping_id'))
+ {
+ $hour['grouping_id'] =
$this->db->f('grouping_id');
+ }
+ else
+ {
+ $this->db->query("SELECT
max(grouping_id) as grouping_id FROM fm_template_hours where template_id=
'$template_id'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $hour['grouping_id'] =
$this->db->f('grouping_id')+1;
+ }
+
+ $hour['grouping_descr'] = $hour['new_grouping'];
+ }
+
+ $this->db->query("insert into fm_template_hours
(owner,hours_descr,unit,cost,quantity,billperae,ns3420_id,dim_d,"
+ . "
grouping_id,grouping_descr,record,building_part,tolerance,remark,entry_date,template_id)
"
+ . " values ('" .
+ $this->account . "','" .
+ $hour['descr'] . "','" .
+ $hour['unit'] . "','" .
+ $hour['cost'] . "','" .
+ $hour['quantity'] . "','" .
+ $hour['billperae'] . "','" .
+ $hour['ns3420_id'] . "','" .
+ $hour['dim_d'] . "','" .
+ $hour['grouping_id'] . "','" .
+ $hour['grouping_descr'] . "','" .
+ $hour['record'] . "','" .
+ $hour['building_part_id'] . "','" .
+ $hour['tolerance_id'] . "','" .
+ $hour['remark'] . "','" .
+ time() . "','" .
+ $template_id . "')",__LINE__,__FILE__);
+
+ $receipt['hour_id'] =
$this->db->get_last_insert_id('fm_template_hours','id');
+
+ $receipt['message'][] = array('msg'=>lang('hour %1 is
added!',$hour['record']));
+
+ return $receipt;
+ }
+
+
+ function edit_hour($hour,$template_id)
+ {
+
+ $hour['descr'] =
$this->db->db_addslashes($hour['descr']);
+ $hour['remark'] =
$this->db->db_addslashes($hour['remark']);
+
+ $this->db->query("UPDATE fm_template set
+ chapter_id ='" . $hour['chapter_id'] . "'
WHERE id= '$template_id'",__LINE__,__FILE__);
+
+ if($hour['new_grouping'])
+ {
+ $this->db->query("SELECT grouping_id FROM
fm_template_hours where grouping_descr ='" .$hour['new_grouping'] . "' and
template_id= '$template_id'",__LINE__,__FILE__);
+ $this->db->next_record();
+ if ( $this->db->f('grouping_id'))
+ {
+ $hour['grouping_id'] =
$this->db->f('grouping_id');
+ }
+ else
+ {
+
+ $this->db->query("UPDATE
fm_template_hours set grouping_id = NULL WHERE id ='" .$hour['hour_id'] .
"'",__LINE__,__FILE__);
+ $this->db->query("SELECT
count(grouping_id) as num_grouping FROM fm_template_hours where template_id=
'$template_id' and grouping_id >0 ",__LINE__,__FILE__);
+ $this->db->next_record();
+ if ($this->db->f('num_grouping')==1)
+ {
+ $hour['grouping_id']=1;
+ }
+ else
+ {
+ $this->db->query("SELECT
max(grouping_id) as grouping_id FROM fm_template_hours where template_id=
'$template_id'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $hour['grouping_id'] =
$this->db->f('grouping_id')+1;
+ }
+ }
+ $hour['grouping_descr'] = $hour['new_grouping'];
+ }
+ else
+ {
+ $this->db->query("SELECT
grouping_id,grouping_descr FROM fm_template_hours where id ='"
.$hour['hour_id'] . "'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $old_grouping_id =
$this->db->f('grouping_id');
+
+ if ( $old_grouping_id == $hour['grouping_id'])
+ {
+
+ $hour['grouping_descr'] =
$this->db->f('grouping_descr');
+ }
+ else
+ {
+ $this->db->query("SELECT grouping_descr
, max(record) as record FROM fm_template_hours where grouping_id='"
.$hour['grouping_id'] . "' and template_id= '$template_id' GROUP by
grouping_descr",__LINE__,__FILE__);
+ $this->db->next_record();
+ if($this->db->f('grouping_descr'))
+ {
+ $hour['grouping_descr'] =
$this->db->f('grouping_descr');
+ }
+ else
+ {
+ $hour['grouping_id']='';
+ $hour['grouping_descr']='';
+ }
+
+ }
+ }
+
+ $this->db->query("SELECT record FROM fm_template_hours
where id ='" .$hour['hour_id'] . "'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $hour['record'] = $this->db->f('record');
+
+ $this->db->query("UPDATE fm_template_hours set
+ hours_descr ='" .
$hour['descr'] . "',
+ remark ='" .
$hour['remark'] . "',
+ billperae ='" .
$hour['billperae'] . "',
+ unit ='" .
$hour['unit'] . "',
+ quantity ='" .
$hour['quantity'] . "',
+ cost ='" .
$hour['cost'] . "',
+ ns3420_id ='" .
$hour['ns3420_id'] . "',
+ tolerance ='" .
$hour['tolerance_id'] . "',
+ building_part ='" .
$hour['building_part_id'] . "',
+ dim_d ='" .
$hour['dim_d'] . "',
+ grouping_id ='" .
$hour['grouping_id'] . "',
+ grouping_descr ='" .
$hour['grouping_descr']
+ . "' WHERE id= '" . $hour['hour_id']
."'",__LINE__,__FILE__);
+
+ $receipt['hour_id'] = $hour['hour_id'];
+ $receipt['message'][] = array('msg'=>lang('hour %1 has
been edited',$hour['record']));
+ return $receipt;
+
+ }
+
+ function get_grouping_list($template_id='')
+ {
+ $this->db->query("SELECT grouping_id, grouping_descr
FROM fm_template_hours where template_id='$template_id' and grouping_id >0
group by grouping_id, grouping_descr");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $grouping_entries[$i]['id']
= $this->db->f('grouping_id');
+ $grouping_entries[$i]['name']
= stripslashes($this->db->f('grouping_descr'));
+ $i++;
+ }
+ return $grouping_entries;
+ }
+
+ function add_template($values)
+ {
+
+ $values['name'] =
$this->db->db_addslashes($values['name']);
+
+ $this->db->query("insert into fm_template
(owner,name,descr,chapter_id,entry_date) "
+ . " values ('" .
+ $this->account . "','" .
+ $values['name'] . "','" .
+ $values['descr'] . "','" .
+ $values['chapter_id'] . "','" .
+ time() . "')",__LINE__,__FILE__);
+
+ $template_id =
$this->db->get_last_insert_id('fm_template','id');
+
+ $receipt['template_id'] = $template_id;
+ $receipt['message'][] = array('msg'=>lang('template %1
is added',$values['name']));
+ return $receipt;
+ }
+
+ function edit_template($values)
+ {
+ $values['name'] =
$this->db->db_addslashes($values['name']);
+ $values['descr'] =
$this->db->db_addslashes($values['descr']);
+
+ $this->db->query("UPDATE fm_template set name='" .
$values['name'] . "', descr='" . $values['descr'] . "', chapter_id='"
+ .
(int)$values['chapter_id']
+ . "' WHERE id='" .
$values['template_id'] . "'",__LINE__,__FILE__);
+
+ $receipt['message'][]=array('msg'=>lang('Property has
been edited'));
+ return $receipt;
+ }
+
+ function delete($id)
+ {
+ $this->db->query("DELETE FROM fm_template WHERE
id='$id'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_template_hours WHERE
template_id='$id'",__LINE__,__FILE__);
+ }
+
+ function delete_hour($hour_id,$template_id )
+ {
+ $this->db->query("SELECT record FROM fm_template_hours
where id ='$hour_id'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $old_record = $this->db->f('record');
+
+ $this->db->query("DELETE FROM fm_template_hours WHERE
id='" . $hour_id . "'",__LINE__,__FILE__);
+ if($old_record)
+ {
+ $this->db->query("UPDATE fm_template_hours set
record = record - 1 where template_id= '$template_id' and record >
$old_record ",__LINE__,__FILE__);
+ }
+
+ $receipt['message'][] = array('msg'=>lang('hour %1 has
been deleted',$hour_id));
+ return $receipt;
+
+ }
+ }
+?>
Index: property/inc/class.sotenant_claim.inc.php
diff -u property/inc/class.sotenant_claim.inc.php:1.7
property/inc/class.sotenant_claim.inc.php:1.8
--- property/inc/class.sotenant_claim.inc.php:1.7 Wed May 18 16:05:55 2005
+++ property/inc/class.sotenant_claim.inc.php Fri Jan 27 14:05:43 2006
@@ -1,307 +1,306 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage project
- * @version $Id: class.sotenant_claim.inc.php,v 1.7 2005/05/18 16:05:55
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
-
- class sotenant_claim
- {
-
- function sotenant_claim()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->join = $this->bocommon->join;
- }
-
- function select_category_list()
- {
- $this->db->query("SELECT id,descr FROM
fm_tenant_claim_category ORDER BY descr ",__LINE__,__FILE__);
-
- $i = 0;
- while ($this->db->next_record())
- {
- $categories[$i]['id'] =
$this->db->f('id');
- $categories[$i]['name'] =
stripslashes($this->db->f('descr'));
- $i++;
- }
- return $categories;
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- $start =
(isset($data['start'])?$data['start']:0);
- $filter =
(isset($data['filter'])?$data['filter']:'none');
- $status =
(isset($data['status'])?$data['status']:'open');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $project_id =
(isset($data['project_id'])?$data['project_id']:'');
-
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by id DESC';
- }
-
-
- $where = 'WHERE';
- if ($cat_id > 0)
- {
- $filtermethod .= " $where category='$cat_id' ";
- $where = 'AND';
- }
-
- if ($project_id > 0)
- {
- $filtermethod .= " $where
project_id='$project_id' ";
- $where = 'AND';
- }
-
- if ($status == 'closed'):
- {
- $filtermethod .= " $where
fm_tenant_claim.status='closed'";
- $where = 'AND';
- }
- elseif($status == ''):
- {
- $filtermethod .= " $where
fm_tenant_claim.status='open'";
- $where = 'AND';
- }
- endif;
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " $where ( abid = '$query' or
org_name LIKE '%$query%')";
- }
-
- $sql = "SELECT fm_tenant_claim.*, descr as category
FROM fm_tenant_claim $this->join fm_tenant_claim_category on
fm_tenant_claim.category=fm_tenant_claim_category.id $filtermethod
$querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $claims[] = array
- (
- 'claim_id' =>
$this->db->f('id'),
- 'project_id' =>
$this->db->f('project_id'),
- 'tenant_id' =>
$this->db->f('tenant_id'),
- 'remark' =>
stripslashes($this->db->f('remark')),
- 'entry_date' =>
$this->db->f('entry_date'),
- 'category' =>
$this->db->f('category'),
- 'status' =>
$this->db->f('status')
- );
- }
- return $claims;
- }
-
- function check_claim_project($project_id)
- {
- $sql = "SELECT fm_tenant_claim.*, descr as category
FROM fm_tenant_claim"
- . " $this->join fm_tenant_claim_category on
fm_tenant_claim.category=fm_tenant_claim_category.id"
- . " WHERE project_id = $project_id";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- $this->db->query($sql . $ordermethod,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $claims[] = array
- (
- 'claim_id' =>
$this->db->f('id'),
- 'project_id' =>
$this->db->f('project_id'),
- 'tenant_id' =>
$this->db->f('tenant_id'),
- 'entry_date' =>
$this->db->f('entry_date'),
- 'category' =>
$this->db->f('category')
- );
- }
- return $claims;
- }
-
- function check_claim_workorder($workorder_id)
- {
- $this->db->query("select * from fm_origin WHERE
destination ='tenant_claim' AND origin_id='$workorder_id'",__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $claim[] = $this->db->f('destination_id');
- }
-
- return @implode(",", $claim);
- }
-
- function read_single($id)
- {
- $this->db->query("select * from fm_tenant_claim where
id='$id'",__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $claim['id'] = $id;
- $claim['project_id'] =
$this->db->f('project_id');
- $claim['tenant_id'] =
$this->db->f('tenant_id');
- $claim['remark'] =
stripslashes($this->db->f('remark'));
- $claim['entry_date'] =
$this->db->f('entry_date');
- $claim['cat_id'] =
(int)$this->db->f('category');
- $claim['amount'] =
$this->db->f('amount');
- $claim['b_account_id'] =
$this->db->f('b_account_id');
- $claim['cat_id'] =
(int)$this->db->f('category');
- $claim['status'] =
$this->db->f('status');
-
- }
-
- $this->db->query("select * from fm_origin WHERE
destination ='tenant_claim' AND destination_id='$id'",__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $claim['workorder'][] =
$this->db->f('origin_id');
- }
-
- return $claim;
- }
-
- function add($claim)
- {
- $this->db->transaction_begin();
-
- $claim['name'] =
$this->db->db_addslashes($claim['name']);
- $claim['amount'] =
str_replace(",",".",$claim['amount']);
-
- $values_insert= array(
- $claim['project_id'],
- $claim['tenant_id'],
- $claim['amount'],
- $claim['b_account_id'],
- $claim['cat_id'],
- $claim['remark'],
- $this->account,
- time(),
- $claim['status']
- );
-
- $values_insert =
$this->bocommon->validate_db_insert($values_insert);
-
-
- $this->db->query("INSERT INTO fm_tenant_claim
(project_id,tenant_id,amount,b_account_id,category,remark,user_id,entry_date,status)
"
- . "VALUES ($values_insert)",__LINE__,__FILE__);
-
- $claim_id =
$this->db->get_last_insert_id('fm_tenant_claim','id');
- $receipt['claim_id'] = $claim_id;
-
- foreach ($claim['workorder'] as $workorder_id)
- {
- $this->db->query("INSERT INTO fm_origin
(origin,origin_id,destination,destination_id,entry_date,user_id) "
- . "VALUES ('workorder',"
- . $workorder_id .","
- . "'tenant_claim',"
- . $claim_id . ","
- . time().","
- . $this->account .")",__LINE__,__FILE__);
-
- $this->db->query("UPDATE fm_workorder set
claim_issued = 1 WHERE id=" . $workorder_id ,__LINE__,__FILE__);
- }
-
- $this->db->transaction_commit();
-
- $receipt['message'][] = array('msg'=>lang('claim %1 has
been saved',$claim_id));
- return $receipt;
- }
-
- function edit($claim)
- {
- $this->db->transaction_begin();
-
- $claim['name'] =
$this->db->db_addslashes($claim['name']);
- $claim['amount'] =
str_replace(",",".",$claim['amount']);
-
- $value_set=array(
- 'amount' =>
$claim['amount'],
- 'tenant_id' =>
$claim['tenant_id'],
- 'b_account_id' =>
$claim['b_account_id'],
- 'amount' =>
$claim['amount'],
- 'category' =>
$claim['cat_id'],
- 'status' =>
$claim['status'],
- 'user_id' =>
$this->account,
- 'remark' =>
$this->db->db_addslashes($claim['remark'])
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE fm_tenant_claim set $value_set
WHERE id=" . intval($claim['claim_id']),__LINE__,__FILE__);
-
- $claim_id = $claim['claim_id'];
-
- $this->db->query("DELETE FROM fm_origin WHERE
destination ='tenant_claim' AND destination_id=$claim_id",__LINE__,__FILE__);
-
- $this->db->query("UPDATE fm_workorder set claim_issued
= NULL WHERE id=" . $claim['project_id'] ,__LINE__,__FILE__);
-
- foreach ($claim['workorder'] as $workorder_id)
- {
- $this->db->query("INSERT INTO fm_origin
(origin,origin_id,destination,destination_id,entry_date,user_id) "
- . "VALUES ('workorder',"
- . $workorder_id .","
- . "'tenant_claim',"
- . $claim_id . ","
- . time().","
- . $this->account .")",__LINE__,__FILE__);
-
- $this->db->query("UPDATE fm_workorder set
claim_issued = 1 WHERE id=" . $workorder_id ,__LINE__,__FILE__);
- }
-
- $this->db->transaction_commit();
-
- $receipt['claim_id']= $claim['claim_id'];
- $receipt['message'][] = array('msg'=>lang('claim %1 has
been edited',$claim['claim_id']));
- return $receipt;
- }
-
- function delete($id)
- {
- $this->db->transaction_begin();
- $this->db->query('DELETE FROM fm_tenant_claim WHERE
id=' . intval($id),__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_origin WHERE
destination ='tenant_claim' AND destination_id=$id",__LINE__,__FILE__);
- $this->db->transaction_commit();
-
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage project
+ * @version $Id: class.sotenant_claim.inc.php,v 1.8 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+
+ class sotenant_claim
+ {
+
+ function sotenant_claim()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ }
+
+ function select_category_list()
+ {
+ $this->db->query("SELECT id,descr FROM
fm_tenant_claim_category ORDER BY descr ",__LINE__,__FILE__);
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $categories[$i]['id'] =
$this->db->f('id');
+ $categories[$i]['name'] =
stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $categories;
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ $start =
(isset($data['start'])?$data['start']:0);
+ $filter =
(isset($data['filter'])?$data['filter']:'none');
+ $status =
(isset($data['status'])?$data['status']:'open');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $project_id =
(isset($data['project_id'])?$data['project_id']:'');
+
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by id DESC';
+ }
+
+
+ $where = 'WHERE';
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " $where category='$cat_id' ";
+ $where = 'AND';
+ }
+
+ if ($project_id > 0)
+ {
+ $filtermethod .= " $where
project_id='$project_id' ";
+ $where = 'AND';
+ }
+
+ if ($status == 'closed'):
+ {
+ $filtermethod .= " $where
fm_tenant_claim.status='closed'";
+ $where = 'AND';
+ }
+ elseif($status == ''):
+ {
+ $filtermethod .= " $where
fm_tenant_claim.status='open'";
+ $where = 'AND';
+ }
+ endif;
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " $where ( abid = '$query' or
org_name LIKE '%$query%')";
+ }
+
+ $sql = "SELECT fm_tenant_claim.*, descr as category
FROM fm_tenant_claim $this->join fm_tenant_claim_category on
fm_tenant_claim.category=fm_tenant_claim_category.id $filtermethod
$querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $claims[] = array
+ (
+ 'claim_id' =>
$this->db->f('id'),
+ 'project_id' =>
$this->db->f('project_id'),
+ 'tenant_id' =>
$this->db->f('tenant_id'),
+ 'remark' =>
stripslashes($this->db->f('remark')),
+ 'entry_date' =>
$this->db->f('entry_date'),
+ 'category' =>
$this->db->f('category'),
+ 'status' =>
$this->db->f('status')
+ );
+ }
+ return $claims;
+ }
+
+ function check_claim_project($project_id)
+ {
+ $sql = "SELECT fm_tenant_claim.*, descr as category
FROM fm_tenant_claim"
+ . " $this->join fm_tenant_claim_category on
fm_tenant_claim.category=fm_tenant_claim_category.id"
+ . " WHERE project_id = $project_id";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ $this->db->query($sql . $ordermethod,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $claims[] = array
+ (
+ 'claim_id' =>
$this->db->f('id'),
+ 'project_id' =>
$this->db->f('project_id'),
+ 'tenant_id' =>
$this->db->f('tenant_id'),
+ 'entry_date' =>
$this->db->f('entry_date'),
+ 'category' =>
$this->db->f('category')
+ );
+ }
+ return $claims;
+ }
+
+ function check_claim_workorder($workorder_id)
+ {
+ $this->db->query("select * from fm_origin WHERE
destination ='tenant_claim' AND origin_id='$workorder_id'",__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $claim[] = $this->db->f('destination_id');
+ }
+
+ return @implode(",", $claim);
+ }
+
+ function read_single($id)
+ {
+ $this->db->query("select * from fm_tenant_claim where
id='$id'",__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $claim['id'] = $id;
+ $claim['project_id'] =
$this->db->f('project_id');
+ $claim['tenant_id'] =
$this->db->f('tenant_id');
+ $claim['remark'] =
stripslashes($this->db->f('remark'));
+ $claim['entry_date'] =
$this->db->f('entry_date');
+ $claim['cat_id'] =
(int)$this->db->f('category');
+ $claim['amount'] =
$this->db->f('amount');
+ $claim['b_account_id'] =
$this->db->f('b_account_id');
+ $claim['cat_id'] =
(int)$this->db->f('category');
+ $claim['status'] =
$this->db->f('status');
+
+ }
+
+ $this->db->query("select * from fm_origin WHERE
destination ='tenant_claim' AND destination_id='$id'",__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $claim['workorder'][] =
$this->db->f('origin_id');
+ }
+
+ return $claim;
+ }
+
+ function add($claim)
+ {
+ $this->db->transaction_begin();
+
+ $claim['name'] =
$this->db->db_addslashes($claim['name']);
+ $claim['amount'] =
str_replace(",",".",$claim['amount']);
+
+ $values_insert= array(
+ $claim['project_id'],
+ $claim['tenant_id'],
+ $claim['amount'],
+ $claim['b_account_id'],
+ $claim['cat_id'],
+ $claim['remark'],
+ $this->account,
+ time(),
+ $claim['status']
+ );
+
+ $values_insert =
$this->bocommon->validate_db_insert($values_insert);
+
+
+ $this->db->query("INSERT INTO fm_tenant_claim
(project_id,tenant_id,amount,b_account_id,category,remark,user_id,entry_date,status)
"
+ . "VALUES ($values_insert)",__LINE__,__FILE__);
+
+ $claim_id =
$this->db->get_last_insert_id('fm_tenant_claim','id');
+ $receipt['claim_id'] = $claim_id;
+
+ foreach ($claim['workorder'] as $workorder_id)
+ {
+ $this->db->query("INSERT INTO fm_origin
(origin,origin_id,destination,destination_id,entry_date,user_id) "
+ . "VALUES ('workorder',"
+ . $workorder_id .","
+ . "'tenant_claim',"
+ . $claim_id . ","
+ . time().","
+ . $this->account .")",__LINE__,__FILE__);
+
+ $this->db->query("UPDATE fm_workorder set
claim_issued = 1 WHERE id=" . $workorder_id ,__LINE__,__FILE__);
+ }
+
+ $this->db->transaction_commit();
+
+ $receipt['message'][] = array('msg'=>lang('claim %1 has
been saved',$claim_id));
+ return $receipt;
+ }
+
+ function edit($claim)
+ {
+ $this->db->transaction_begin();
+
+ $claim['name'] =
$this->db->db_addslashes($claim['name']);
+ $claim['amount'] =
str_replace(",",".",$claim['amount']);
+
+ $value_set=array(
+ 'amount' =>
$claim['amount'],
+ 'tenant_id' =>
$claim['tenant_id'],
+ 'b_account_id' =>
$claim['b_account_id'],
+ 'amount' =>
$claim['amount'],
+ 'category' =>
$claim['cat_id'],
+ 'status' =>
$claim['status'],
+ 'user_id' =>
$this->account,
+ 'remark' =>
$this->db->db_addslashes($claim['remark'])
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE fm_tenant_claim set $value_set
WHERE id=" . intval($claim['claim_id']),__LINE__,__FILE__);
+
+ $claim_id = $claim['claim_id'];
+
+ $this->db->query("DELETE FROM fm_origin WHERE
destination ='tenant_claim' AND destination_id=$claim_id",__LINE__,__FILE__);
+
+ $this->db->query("UPDATE fm_workorder set claim_issued
= NULL WHERE id=" . $claim['project_id'] ,__LINE__,__FILE__);
+
+ foreach ($claim['workorder'] as $workorder_id)
+ {
+ $this->db->query("INSERT INTO fm_origin
(origin,origin_id,destination,destination_id,entry_date,user_id) "
+ . "VALUES ('workorder',"
+ . $workorder_id .","
+ . "'tenant_claim',"
+ . $claim_id . ","
+ . time().","
+ . $this->account .")",__LINE__,__FILE__);
+
+ $this->db->query("UPDATE fm_workorder set
claim_issued = 1 WHERE id=" . $workorder_id ,__LINE__,__FILE__);
+ }
+
+ $this->db->transaction_commit();
+
+ $receipt['claim_id']= $claim['claim_id'];
+ $receipt['message'][] = array('msg'=>lang('claim %1 has
been edited',$claim['claim_id']));
+ return $receipt;
+ }
+
+ function delete($id)
+ {
+ $this->db->transaction_begin();
+ $this->db->query('DELETE FROM fm_tenant_claim WHERE
id=' . intval($id),__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_origin WHERE
destination ='tenant_claim' AND destination_id=$id",__LINE__,__FILE__);
+ $this->db->transaction_commit();
+
+ }
+ }
+?>
Index: property/inc/class.sotts.inc.php
diff -u property/inc/class.sotts.inc.php:1.11
property/inc/class.sotts.inc.php:1.12
--- property/inc/class.sotts.inc.php:1.11 Wed Nov 9 10:34:11 2005
+++ property/inc/class.sotts.inc.php Fri Jan 27 14:05:43 2006
@@ -1,454 +1,454 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage helpdesk
- * @version $Id: class.sotts.inc.php,v 1.11 2005/11/09 10:34:11 sigurdne
Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class sotts
- {
-
- function sotts()
- {
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage helpdesk
+ * @version $Id: class.sotts.inc.php,v 1.12 2006/01/27 14:05:43 sigurdne
Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class sotts
+ {
+
+ function sotts()
+ {
$this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->historylog =
CreateObject($this->currentapp.'.historylog','tts');
- $this->config =
CreateObject('phpgwapi.config');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->join = $this->bocommon->join;
- $this->like = $this->bocommon->like;
- $this->soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
- $this->dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-
- }
-
- function get_category_name($cat_id)
- {
- $this->db->query("SELECT descr FROM fm_tts_category
WHERE id='$cat_id' ");
-
- $this->db->next_record();
-
- return stripslashes($this->db->f('descr'));
- }
-
- function select_category_list()
- {
- $this->db->query("SELECT id, descr FROM fm_tts_category
ORDER BY descr ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $categories[$i]['id']
= $this->db->f('id');
- $categories[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $categories;
- }
-
-
- function read($data)
- {
-
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- if ($data['filter'])
- {
- $filter=$data['filter'];
- }
- else
- {
- $filter='open';
- }
- // $filter =
(isset($data['filter'])?$data['filter']:'open');
- $user_filter=
(isset($data['user_filter'])?$data['user_filter']:'');
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $district_id =
(isset($data['district_id'])?$data['district_id']:0);
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $start_date =
(isset($data['start_date'])?$data['start_date']:'');
- $end_date =
(isset($data['end_date'])?$data['end_date']:'');
- }
-
-
-/* $this->grants =
$GLOBALS['phpgw']->session->appsession('grants_ticket',$this->currentapp);
-
- if(!$this->grants)
- {
- $this->acl2 =
CreateObject($this->currentapp.'.acl2','##DEFAULT##','##DEFAULT##');
- $this->grants =
$this->acl2->get_grants($this->currentapp,'.ticket');
-
$GLOBALS['phpgw']->session->appsession('grants_ticket',$this->currentapp,$this->grants);
- }
-*/
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by fm_tts_tickets.id
DESC';
- }
-
- $where= 'WHERE';
-
-/* $filtermethod = $where . ' ( fm_tts_tickets.user_id=' .
$this->account;
- if (is_array($this->grants))
- {
- $grants = $this->grants;
- while (list($user) = each($grants))
- {
- $public_user_list[] = $user;
- }
- reset($public_user_list);
- $filtermethod = " $where (
fm_tts_tickets.user_id IN(" . implode(',',$public_user_list) . "))";
- }
-
- $where= 'AND';
-
-*/
- if ($filter == 'closed'):
- {
- $filtermethod .= " $where
fm_tts_tickets.status='X'";
- $where = 'AND';
- }
- elseif($filter == 'open'):
- {
- $filtermethod .= " $where
fm_tts_tickets.status='O'";
- $where = 'AND';
- }
- endif;
-
- if ($cat_id > 0)
- {
- $filtermethod .= " $where cat_id='$cat_id' ";
- $where = 'AND';
- }
-
- if ($user_filter > 0)
- {
- $filtermethod .= " $where
assignedto=$user_filter";
- $where = 'AND';
- }
-
- if ($district_id > 0)
- {
- $filtermethod .= " $where
district_id='$district_id' ";
- $where = 'AND';
- }
-
- if ($start_date)
- {
- $filtermethod .= " $where
fm_tts_tickets.entry_date >= $start_date AND fm_tts_tickets.entry_date <=
$end_date ";
- $where= 'AND';
- }
-
- if($query)
- {
- $query = str_replace(",",'.',$query);
- if(stristr($query, '.'))
- {
- $query=explode(".",$query);
- $querymethod = " $where
(fm_tts_tickets.loc1='" . $query[0] . "' AND fm_tts_tickets.loc4='" . $query[1]
. "')";
- }
- else
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
- $querymethod = " $where (subject
$this->like '%$query%' or address $this->like '%$query%' or
fm_tts_tickets.location_code $this->like '%$query%')";
- }
- }
-
- $sql = "SELECT fm_tts_tickets.*, fm_tts_category.descr
as category,phpgw_accounts.account_lid as user_lid FROM fm_tts_tickets
$this->join fm_tts_category on fm_tts_tickets.cat_id=fm_tts_category.id "
- . " $this->join phpgw_accounts on
fm_tts_tickets.user_id=phpgw_accounts.account_id "
- . " $this->join fm_location1 on
fm_tts_tickets.loc1=fm_location1.loc1 "
- . " $this->join fm_part_of_town on
fm_location1.part_of_town_id=fm_part_of_town.part_of_town_id $filtermethod
$querymethod";
-
-//echo $sql;
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- $i = 0;
-
- while ($this->db->next_record())
- {
-
- $tickets[$i]['id']
= $this->db->f('id');
- $tickets[$i]['subject'] =
$this->db->f('subject');
- $tickets[$i]['location_code'] =
$this->db->f('location_code');
- $tickets[$i]['user'] =
$this->db->f('user_lid');
- $tickets[$i]['address'] =
stripslashes($this->db->f('address'));
- $tickets[$i]['assignedto'] =
$this->db->f('assignedto');
- $tickets[$i]['status'] =
$this->db->f('status');
- $tickets[$i]['priority'] =
$this->db->f('priority');
- $tickets[$i]['category'] =
$this->db->f('category');
- $tickets[$i]['subject'] =
$this->db->f('subject');
- $tickets[$i]['group_id'] =
$this->db->f('group_id');
- $tickets[$i]['entry_date'] =
$this->db->f('entry_date');
- $tickets[$i]['finnish_date'] =
$this->db->f('finnish_date');
- $tickets[$i]['finnish_date2'] =
$this->db->f('finnish_date2');
-
- $this->db2->query("select count(*) from
fm_tts_views where id='" . $this->db->f('id')
- . "' and account_id='" .
$GLOBALS['phpgw_info']['user']['account_id'] . "'",__LINE__,__FILE__);
- $this->db2->next_record();
-
- if (!$this->db2->f(0))
- {
- $tickets[$i]['new_ticket'] = True;
- }
-
- $i++;
-
- }
- return $tickets;
- }
-
- function get_origin_entity_type()
- {
- $sql = "SELECT entity_id, id as cat_id,name"
- . " FROM fm_entity_category "
- . " WHERE tracking=1 ORDER by entity_id,cat_id";
-
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- $i=0;
- while ($this->db->next_record())
- {
-
$entity[$i]['entity_id']=$this->db->f('entity_id');
- $entity[$i]['cat_id']=$this->db->f('cat_id');
- $entity[$i]['type']='entity';
- $uicols[] = $this->db->f('name');
- $i++;
- }
-
- $entity[$i]['type']='project';
- $uicols[] = lang('project');
-
- $this->uicols = $uicols;
- return $entity;
- }
-
- function get_child_date($id,$type,$entity_id='',$cat_id='')
- {
- $table= 'fm_origin';
- if($cat_id)
- {
- $and = " AND destination = 'entity_" .
$entity_id . '_' . $cat_id . "'";
- }
- else
- {
- $and = " AND destination = '$type'";
- }
-
- $sql = "SELECT * FROM $table WHERE origin_id='$id' and
origin ='tts' $and";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- $i=0;
- while ($this->db->next_record())
- {
- $date_info['date_info'][$i]['entry_date']=
$GLOBALS['phpgw']->common->show_date($this->db->f('entry_date'),$this->dateformat);
- if($cat_id)
- {
-
$date_info['date_info'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.view&entity_id='.$entity_id.'&cat_id='
. $cat_id . '&id=' . $this->db->f('destination_id'));
-
$date_info['date_info'][$i]['descr']=$this->soadmin_entity->read_category_name($entity_id,$cat_id);
- }
- else
- {
-
$date_info['date_info'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.ui'
. $type . '.view&id=' . $this->db->f('destination_id'));
-
$date_info['date_info'][$i]['descr']=lang($type);
- }
-
- $i++;
- }
-//_debug_array($date_info);
- return $date_info;
- }
-
- function read_single($id)
- {
- $sql = "SELECT * FROM fm_tts_tickets WHERE id=$id";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $ticket['assignedto'] =
$this->db->f('assignedto');
- $ticket['user_id'] =
$this->db->f('user_id');
- $ticket['group_id'] =
$this->db->f('group_id');
- $ticket['status'] =
$this->db->f('status');
- $ticket['cat_id'] =
$this->db->f('cat_id');
- $ticket['subject'] =
stripslashes($this->db->f('subject'));
- $ticket['priority'] =
$this->db->f('priority');
- $ticket['details'] =
stripslashes($this->db->f('details'));
- $ticket['location_code'] =
$this->db->f('location_code');
- $ticket['contact_phone'] =
$this->db->f('contact_phone');
- $ticket['address'] =
stripslashes($this->db->f('address'));
- $ticket['tenant_id'] =
$this->db->f('tenant_id');
- $ticket['p_num'] =
$this->db->f('p_num');
- $ticket['p_entity_id'] =
$this->db->f('p_entity_id');
- $ticket['p_cat_id'] =
$this->db->f('p_cat_id');
- $ticket['finnish_date'] =
$this->db->f('finnish_date');
- $ticket['finnish_date2'] =
$this->db->f('finnish_date2');
-
- $user_id=(int)$this->db->f('user_id');
- $this->db->query("SELECT
account_firstname,account_lastname FROM phpgw_accounts WHERE
account_id='$user_id' ");
- $this->db->next_record();
-
- $ticket['user_name'] =
$this->db->f('account_firstname') . " " .$this->db->f('account_lastname') ;
-
- }
-
-
- $sql = "SELECT * FROM fm_origin WHERE origin = 'tts'
AND origin_id='$id' ORDER by destination DESC ";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- $i=-1;
- while ($this->db->next_record())
- {
- if($last_type != $this->db->f('destination'))
- {
- $i++;
- }
- $ticket['origin'][$i]['type'] =
$this->db->f('destination');
- $ticket['origin'][$i]['link'] =
$this->bocommon->get_origin_link($this->db->f('destination'));
- $ticket['origin'][$i]['data'][]= array(
- 'id'=> $this->db->f('destination_id'),
- 'type'=> $this->db->f('destination')
- );
-
- $last_type=$this->db->f('destination');
- }
-
- return $ticket;
- }
-
- function update_view($id='')
- {
- // Have they viewed this ticket before ?
- $this->db->query("select count(*) from fm_tts_views
where id='$id' "
- . "and account_id='" .
$GLOBALS['phpgw_info']['user']['account_id'] . "'",__LINE__,__FILE__);
- $this->db->next_record();
-
- if (! $this->db->f(0))
- {
- $this->db->query("insert into fm_tts_views
(id,account_id,time) values ('$id','"
- .
$GLOBALS['phpgw_info']['user']['account_id'] . "','" . time() .
"')",__LINE__,__FILE__);
- }
- }
-
- function add($ticket)
- {
- while (is_array($ticket['location']) &&
list($input_name,$value) = each($ticket['location']))
- {
- if($value)
- {
- $cols[] = $input_name;
- $vals[] = $value;
- }
- }
-
-
- while (is_array($ticket['extra']) &&
list($input_name,$value) = each($ticket['extra']))
- {
- if($value)
- {
- $cols[] = $input_name;
- $vals[] = $value;
- }
- }
-
- if($cols)
- {
- $cols = "," . implode(",", $cols);
- $vals = ",'" . implode("','", $vals) . "'";
- }
-
- if($ticket['street_name'])
- {
- $address[]= $ticket['street_name'];
- $address[]= $ticket['street_number'];
- $address =
$this->db->db_addslashes(implode(" ", $address));
- }
-
- if(!$address)
- {
- $address =
$this->db->db_addslashes($ticket['location_name']);
- }
-
- $values= array(
- $ticket['priority'],
- $GLOBALS['phpgw_info']['user']['account_id'],
- $ticket['assignedto'],
- $ticket['group_id'],
- $this->db->db_addslashes($ticket['subject']),
- $ticket['cat_id'],
- 'O',
- $this->db->db_addslashes($ticket['details']),
- $ticket['location_code'],
- $address,
- time(),
- $ticket['finnish_date']);
-
- $values = $this->bocommon->validate_db_insert($values);
- $this->db->transaction_begin();
-
- $this->db->query("insert into fm_tts_tickets
(priority,user_id,"
- .
"assignedto,group_id,subject,cat_id,status,details,location_code,"
- . "address,entry_date,finnish_date $cols)"
- . "VALUES ($values $vals )",__LINE__,__FILE__);
-
- $id =
$this->db->get_last_insert_id('fm_tts_tickets','id');
- if($ticket['extra']['contact_phone'] &&
$ticket['extra']['tenant_id'])
- {
- $this->db->query("update fm_tenant set
contact_phone='". $ticket['extra']['contact_phone']. "' where id='".
$ticket['extra']['tenant_id']. "'",__LINE__,__FILE__);
- }
-
- if($this->db->transaction_commit())
- {
- $this->historylog->add('O',$id,mktime(),'');
- if($ticket['finnish_date'])
- {
-
$this->historylog->add('IF',$id,$ticket['finnish_date'],'');
- }
- }
-
- $receipt['message'][0]=array('msg'=>lang('Ticket %1 has
been saved',$id));
- $receipt['id'] = $id;
- return $receipt;
- }
-
- }
-?>
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->historylog =
CreateObject($this->currentapp.'.historylog','tts');
+ $this->config =
CreateObject('phpgwapi.config');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->like = $this->bocommon->like;
+ $this->soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
+ $this->dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ }
+
+ function get_category_name($cat_id)
+ {
+ $this->db->query("SELECT descr FROM fm_tts_category
WHERE id='$cat_id' ");
+
+ $this->db->next_record();
+
+ return stripslashes($this->db->f('descr'));
+ }
+
+ function select_category_list()
+ {
+ $this->db->query("SELECT id, descr FROM fm_tts_category
ORDER BY descr ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $categories[$i]['id']
= $this->db->f('id');
+ $categories[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $categories;
+ }
+
+
+ function read($data)
+ {
+
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ if ($data['filter'])
+ {
+ $filter=$data['filter'];
+ }
+ else
+ {
+ $filter='open';
+ }
+ // $filter =
(isset($data['filter'])?$data['filter']:'open');
+ $user_filter=
(isset($data['user_filter'])?$data['user_filter']:'');
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $district_id =
(isset($data['district_id'])?$data['district_id']:0);
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $start_date =
(isset($data['start_date'])?$data['start_date']:'');
+ $end_date =
(isset($data['end_date'])?$data['end_date']:'');
+ }
+
+
+/* $this->grants =
$GLOBALS['phpgw']->session->appsession('grants_ticket',$this->currentapp);
+
+ if(!$this->grants)
+ {
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2','##DEFAULT##','##DEFAULT##');
+ $this->grants =
$this->acl2->get_grants($this->currentapp,'.ticket');
+
$GLOBALS['phpgw']->session->appsession('grants_ticket',$this->currentapp,$this->grants);
+ }
+*/
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by fm_tts_tickets.id
DESC';
+ }
+
+ $where= 'WHERE';
+
+/* $filtermethod = $where . ' ( fm_tts_tickets.user_id=' .
$this->account;
+ if (is_array($this->grants))
+ {
+ $grants = $this->grants;
+ while (list($user) = each($grants))
+ {
+ $public_user_list[] = $user;
+ }
+ reset($public_user_list);
+ $filtermethod = " $where (
fm_tts_tickets.user_id IN(" . implode(',',$public_user_list) . "))";
+ }
+
+ $where= 'AND';
+
+*/
+ if ($filter == 'closed'):
+ {
+ $filtermethod .= " $where
fm_tts_tickets.status='X'";
+ $where = 'AND';
+ }
+ elseif($filter == 'open'):
+ {
+ $filtermethod .= " $where
fm_tts_tickets.status='O'";
+ $where = 'AND';
+ }
+ endif;
+
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " $where cat_id='$cat_id' ";
+ $where = 'AND';
+ }
+
+ if ($user_filter > 0)
+ {
+ $filtermethod .= " $where
assignedto=$user_filter";
+ $where = 'AND';
+ }
+
+ if ($district_id > 0)
+ {
+ $filtermethod .= " $where
district_id='$district_id' ";
+ $where = 'AND';
+ }
+
+ if ($start_date)
+ {
+ $filtermethod .= " $where
fm_tts_tickets.entry_date >= $start_date AND fm_tts_tickets.entry_date <=
$end_date ";
+ $where= 'AND';
+ }
+
+ if($query)
+ {
+ $query = str_replace(",",'.',$query);
+ if(stristr($query, '.'))
+ {
+ $query=explode(".",$query);
+ $querymethod = " $where
(fm_tts_tickets.loc1='" . $query[0] . "' AND fm_tts_tickets.loc4='" . $query[1]
. "')";
+ }
+ else
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+ $querymethod = " $where (subject
$this->like '%$query%' or address $this->like '%$query%' or
fm_tts_tickets.location_code $this->like '%$query%')";
+ }
+ }
+
+ $sql = "SELECT fm_tts_tickets.*, fm_tts_category.descr
as category,phpgw_accounts.account_lid as user_lid FROM fm_tts_tickets
$this->join fm_tts_category on fm_tts_tickets.cat_id=fm_tts_category.id "
+ . " $this->join phpgw_accounts on
fm_tts_tickets.user_id=phpgw_accounts.account_id "
+ . " $this->join fm_location1 on
fm_tts_tickets.loc1=fm_location1.loc1 "
+ . " $this->join fm_part_of_town on
fm_location1.part_of_town_id=fm_part_of_town.part_of_town_id $filtermethod
$querymethod";
+
+//echo $sql;
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ $i = 0;
+
+ while ($this->db->next_record())
+ {
+
+ $tickets[$i]['id']
= $this->db->f('id');
+ $tickets[$i]['subject'] =
$this->db->f('subject');
+ $tickets[$i]['location_code'] =
$this->db->f('location_code');
+ $tickets[$i]['user'] =
$this->db->f('user_lid');
+ $tickets[$i]['address'] =
stripslashes($this->db->f('address'));
+ $tickets[$i]['assignedto'] =
$this->db->f('assignedto');
+ $tickets[$i]['status'] =
$this->db->f('status');
+ $tickets[$i]['priority'] =
$this->db->f('priority');
+ $tickets[$i]['category'] =
$this->db->f('category');
+ $tickets[$i]['subject'] =
$this->db->f('subject');
+ $tickets[$i]['group_id'] =
$this->db->f('group_id');
+ $tickets[$i]['entry_date'] =
$this->db->f('entry_date');
+ $tickets[$i]['finnish_date'] =
$this->db->f('finnish_date');
+ $tickets[$i]['finnish_date2'] =
$this->db->f('finnish_date2');
+
+ $this->db2->query("select count(*) from
fm_tts_views where id='" . $this->db->f('id')
+ . "' and account_id='" .
$GLOBALS['phpgw_info']['user']['account_id'] . "'",__LINE__,__FILE__);
+ $this->db2->next_record();
+
+ if (!$this->db2->f(0))
+ {
+ $tickets[$i]['new_ticket'] = True;
+ }
+
+ $i++;
+
+ }
+ return $tickets;
+ }
+
+ function get_origin_entity_type()
+ {
+ $sql = "SELECT entity_id, id as cat_id,name"
+ . " FROM fm_entity_category "
+ . " WHERE tracking=1 ORDER by entity_id,cat_id";
+
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ $i=0;
+ while ($this->db->next_record())
+ {
+
$entity[$i]['entity_id']=$this->db->f('entity_id');
+ $entity[$i]['cat_id']=$this->db->f('cat_id');
+ $entity[$i]['type']='entity';
+ $uicols[] = $this->db->f('name');
+ $i++;
+ }
+
+ $entity[$i]['type']='project';
+ $uicols[] = lang('project');
+
+ $this->uicols = $uicols;
+ return $entity;
+ }
+
+ function get_child_date($id,$type,$entity_id='',$cat_id='')
+ {
+ $table= 'fm_origin';
+ if($cat_id)
+ {
+ $and = " AND destination = 'entity_" .
$entity_id . '_' . $cat_id . "'";
+ }
+ else
+ {
+ $and = " AND destination = '$type'";
+ }
+
+ $sql = "SELECT * FROM $table WHERE origin_id='$id' and
origin ='tts' $and";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ $i=0;
+ while ($this->db->next_record())
+ {
+ $date_info['date_info'][$i]['entry_date']=
$GLOBALS['phpgw']->common->show_date($this->db->f('entry_date'),$this->dateformat);
+ if($cat_id)
+ {
+
$date_info['date_info'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.view&entity_id='.$entity_id.'&cat_id='
. $cat_id . '&id=' . $this->db->f('destination_id'));
+
$date_info['date_info'][$i]['descr']=$this->soadmin_entity->read_category_name($entity_id,$cat_id);
+ }
+ else
+ {
+
$date_info['date_info'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.ui'
. $type . '.view&id=' . $this->db->f('destination_id'));
+
$date_info['date_info'][$i]['descr']=lang($type);
+ }
+
+ $i++;
+ }
+//_debug_array($date_info);
+ return $date_info;
+ }
+
+ function read_single($id)
+ {
+ $sql = "SELECT * FROM fm_tts_tickets WHERE id=$id";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $ticket['assignedto'] =
$this->db->f('assignedto');
+ $ticket['user_id'] =
$this->db->f('user_id');
+ $ticket['group_id'] =
$this->db->f('group_id');
+ $ticket['status'] =
$this->db->f('status');
+ $ticket['cat_id'] =
$this->db->f('cat_id');
+ $ticket['subject'] =
stripslashes($this->db->f('subject'));
+ $ticket['priority'] =
$this->db->f('priority');
+ $ticket['details'] =
stripslashes($this->db->f('details'));
+ $ticket['location_code'] =
$this->db->f('location_code');
+ $ticket['contact_phone'] =
$this->db->f('contact_phone');
+ $ticket['address'] =
stripslashes($this->db->f('address'));
+ $ticket['tenant_id'] =
$this->db->f('tenant_id');
+ $ticket['p_num'] =
$this->db->f('p_num');
+ $ticket['p_entity_id'] =
$this->db->f('p_entity_id');
+ $ticket['p_cat_id'] =
$this->db->f('p_cat_id');
+ $ticket['finnish_date'] =
$this->db->f('finnish_date');
+ $ticket['finnish_date2'] =
$this->db->f('finnish_date2');
+
+ $user_id=(int)$this->db->f('user_id');
+ $this->db->query("SELECT
account_firstname,account_lastname FROM phpgw_accounts WHERE
account_id='$user_id' ");
+ $this->db->next_record();
+
+ $ticket['user_name'] =
$this->db->f('account_firstname') . " " .$this->db->f('account_lastname') ;
+
+ }
+
+
+ $sql = "SELECT * FROM fm_origin WHERE origin = 'tts'
AND origin_id='$id' ORDER by destination DESC ";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ $i=-1;
+ while ($this->db->next_record())
+ {
+ if($last_type != $this->db->f('destination'))
+ {
+ $i++;
+ }
+ $ticket['origin'][$i]['type'] =
$this->db->f('destination');
+ $ticket['origin'][$i]['link'] =
$this->bocommon->get_origin_link($this->db->f('destination'));
+ $ticket['origin'][$i]['data'][]= array(
+ 'id'=> $this->db->f('destination_id'),
+ 'type'=> $this->db->f('destination')
+ );
+
+ $last_type=$this->db->f('destination');
+ }
+
+ return $ticket;
+ }
+
+ function update_view($id='')
+ {
+ // Have they viewed this ticket before ?
+ $this->db->query("select count(*) from fm_tts_views
where id='$id' "
+ . "and account_id='" .
$GLOBALS['phpgw_info']['user']['account_id'] . "'",__LINE__,__FILE__);
+ $this->db->next_record();
+
+ if (! $this->db->f(0))
+ {
+ $this->db->query("insert into fm_tts_views
(id,account_id,time) values ('$id','"
+ .
$GLOBALS['phpgw_info']['user']['account_id'] . "','" . time() .
"')",__LINE__,__FILE__);
+ }
+ }
+
+ function add($ticket)
+ {
+ while (is_array($ticket['location']) &&
list($input_name,$value) = each($ticket['location']))
+ {
+ if($value)
+ {
+ $cols[] = $input_name;
+ $vals[] = $value;
+ }
+ }
+
+
+ while (is_array($ticket['extra']) &&
list($input_name,$value) = each($ticket['extra']))
+ {
+ if($value)
+ {
+ $cols[] = $input_name;
+ $vals[] = $value;
+ }
+ }
+
+ if($cols)
+ {
+ $cols = "," . implode(",", $cols);
+ $vals = ",'" . implode("','", $vals) . "'";
+ }
+
+ if($ticket['street_name'])
+ {
+ $address[]= $ticket['street_name'];
+ $address[]= $ticket['street_number'];
+ $address =
$this->db->db_addslashes(implode(" ", $address));
+ }
+
+ if(!$address)
+ {
+ $address =
$this->db->db_addslashes($ticket['location_name']);
+ }
+
+ $values= array(
+ $ticket['priority'],
+ $GLOBALS['phpgw_info']['user']['account_id'],
+ $ticket['assignedto'],
+ $ticket['group_id'],
+ $this->db->db_addslashes($ticket['subject']),
+ $ticket['cat_id'],
+ 'O',
+ $this->db->db_addslashes($ticket['details']),
+ $ticket['location_code'],
+ $address,
+ time(),
+ $ticket['finnish_date']);
+
+ $values = $this->bocommon->validate_db_insert($values);
+ $this->db->transaction_begin();
+
+ $this->db->query("insert into fm_tts_tickets
(priority,user_id,"
+ .
"assignedto,group_id,subject,cat_id,status,details,location_code,"
+ . "address,entry_date,finnish_date $cols)"
+ . "VALUES ($values $vals )",__LINE__,__FILE__);
+
+ $id =
$this->db->get_last_insert_id('fm_tts_tickets','id');
+ if($ticket['extra']['contact_phone'] &&
$ticket['extra']['tenant_id'])
+ {
+ $this->db->query("update fm_tenant set
contact_phone='". $ticket['extra']['contact_phone']. "' where id='".
$ticket['extra']['tenant_id']. "'",__LINE__,__FILE__);
+ }
+
+ if($this->db->transaction_commit())
+ {
+ $this->historylog->add('O',$id,mktime(),'');
+ if($ticket['finnish_date'])
+ {
+
$this->historylog->add('IF',$id,$ticket['finnish_date'],'');
+ }
+ }
+
+ $receipt['message'][0]=array('msg'=>lang('Ticket %1 has
been saved',$id));
+ $receipt['id'] = $id;
+ return $receipt;
+ }
+
+ }
+?>
Index: property/inc/class.sotts2.inc.php
diff -u property/inc/class.sotts2.inc.php:1.8
property/inc/class.sotts2.inc.php:1.9
--- property/inc/class.sotts2.inc.php:1.8 Thu May 12 21:26:28 2005
+++ property/inc/class.sotts2.inc.php Fri Jan 27 14:05:43 2006
@@ -1,280 +1,279 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage helpdesk
- * @version $Id: class.sotts2.inc.php,v 1.8 2005/05/12 21:26:28 sigurdne
Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class sotts2
- {
- function sotts2()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->bo =
CreateObject($this->currentapp.'.botts');
- $this->historylog =
CreateObject($this->currentapp.'.historylog','tts');
- $this->config =
CreateObject('phpgwapi.config');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->join = $this->bocommon->join;
- $this->like = $this->bocommon->like;
- }
-
- function update_status($ticket,$id='')
- {
- // DB Content is fresher than http posted value.
- $this->db->query("select * from fm_tts_tickets where
id='$id'",__LINE__,__FILE__);
- $this->db->next_record();
- $old_status = $this->db->f('status');
-
- $this->db->transaction_begin();
-
- /*
- ** phpgw_fm_tts_append.append_type - Defs
- ** R - Reopen ticket
- ** X - Ticket closed
- ** O - Ticket opened
- ** C - Comment appended
- ** A - Ticket assignment
- ** G - Ticket group assignment
- ** P - Priority change
- ** T - Category change
- ** S - Subject change
- ** B - Billing rate
- ** H - Billing hours
- ** F - finnish date
- */
-
- if ($old_status != $ticket['status'])
- {
- $fields_updated = True;
- if($old_status=='X')
- {
-
$this->historylog->add('R',$id,$ticket['status'],$old_status);
-
- $this->db->query("update fm_tts_tickets
set status='O' where id='$id'",__LINE__,__FILE__);
- }
- else
- {
-
$this->historylog->add($ticket['status'],$id,$ticket['status'],$old_status);
-
- $this->db->query("update fm_tts_tickets
set status='"
- . $ticket['status'] . "' where
id='$id'",__LINE__,__FILE__);
- }
- }
-
- $this->db->transaction_commit();
-
- if ($fields_updated)
- {
- $this->config->read_repository();
-
- if
($this->config->config_data['mailnotification'])
- {
-
$receipt=$this->bo->mail_ticket($id,$fields_updated,'',$location_code);
-
- }
-
- $receipt['message'][]= array('msg' =>
lang('Ticket %1 has been updated',$id));
- }
-
- return $receipt;
-
- }
-
- function update_ticket($ticket,$id='')
- {
- // DB Content is fresher than http posted value.
- $this->db->query("select * from fm_tts_tickets where
id='$id'",__LINE__,__FILE__);
- $this->db->next_record();
-
-
- $location_code = $this->db->f('location_code');
- $oldfinnish_date = $this->db->f('finnish_date');
- $oldfinnish_date2 = $this->db->f('finnish_date2');
- $oldassigned = $this->db->f('assignedto');
- $oldgroup_id = $this->db->f('group_id');
- $oldpriority = $this->db->f('priority');
- $oldcat_id =
$this->db->f('cat_id');
- $old_status = $this->db->f('status');
- $old_billable_hours =
$this->db->f('billable_hours');
- $old_billable_rate = $this->db->f('billable_rate');
- $old_subject = $this->db->f('subject');
- if($oldcat_id ==0){$oldcat_id ='';}
- if($oldassigned ==0){$oldassigned ='';}
- if($oldgroup_id ==0){$oldgroup_id ='';}
-
- // Figure out and last note
-
- $history_values =
$this->historylog->return_array(array(),array('C'),'history_timestamp','DESC',$id);
- $old_note = $history_values[0]['new_value'];
-
- if(!$old_note)
- {
- $old_note = $this->db->f('details');
- }
-
-
- $this->db->transaction_begin();
-
- /*
- ** phpgw_fm_tts_append.append_type - Defs
- ** R - Reopen ticket
- ** X - Ticket closed
- ** O - Ticket opened
- ** C - Comment appended
- ** A - Ticket assignment
- ** G - Ticket group assignment
- ** P - Priority change
- ** T - Category change
- ** S - Subject change
- ** B - Billing rate
- ** H - Billing hours
- ** F - finnish date
- */
-
- $finnish_date =
$this->bocommon->date_to_timestamp($ticket['finnish_date']);
-
- if ($oldfinnish_date && $ticket['finnish_date']):
- {
- $this->db->query("update fm_tts_tickets set
finnish_date2='" . $finnish_date
- . "' where id='$id'",__LINE__,__FILE__);
- }
- elseif(!$oldfinnish_date && $ticket['finnish_date'] ):
- {
- $this->db->query("update fm_tts_tickets set
finnish_date='" . $finnish_date
- . "' where id='$id'",__LINE__,__FILE__);
- }
- endif;
-
- if($oldfinnish_date2>0)
- {
- $oldfinnish_date = $oldfinnish_date2;
- }
- if($ticket['finnish_date'])
- {
- if ($oldfinnish_date != $finnish_date)
- {
- $fields_updated = True;
-
$this->historylog->add('F',$id,$finnish_date,$oldfinnish_date);
- }
- }
-
- if ($old_status != $ticket['status'])
- {
- $fields_updated = True;
- if($old_status=='X')
- {
-
$this->historylog->add('R',$id,$ticket['status'],$old_status);
-
- $this->db->query("update fm_tts_tickets
set status='O' where id='$id'",__LINE__,__FILE__);
- }
- else
- {
-
$this->historylog->add($ticket['status'],$id,$ticket['status'],$old_status);
-
- $this->db->query("update fm_tts_tickets
set status='"
- . $ticket['status'] . "' where
id='$id'",__LINE__,__FILE__);
- }
- }
-
- if ($oldassigned != $ticket['assignedto'])
- {
- $fields_updated = True;
-
- $value_set=array('assignedto' =>
$ticket['assignedto']);
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("update fm_tts_tickets set
$value_set where id='$id'",__LINE__,__FILE__);
-
$this->historylog->add('A',$id,$ticket['assignedto'],$oldassigned);
- }
-
- if ($oldgroup_id != $ticket['group_id'])
- {
- $fields_updated = True;
-
- $value_set=array('group_id' =>
$ticket['group_id']);
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("update fm_tts_tickets set
$value_set where id='$id'",__LINE__,__FILE__);
-
$this->historylog->add('G',$id,$ticket['group_id'],$oldgroup_id);
- }
-
- if ($oldpriority != $ticket['priority'])
- {
- $fields_updated = True;
- $this->db->query("update fm_tts_tickets set
priority='" . $ticket['priority']
- . "' where id='$id'",__LINE__,__FILE__);
-
$this->historylog->add('P',$id,$ticket['priority'],$oldpriority);
- }
-
- if ($oldcat_id != $ticket['cat_id'])
- {
- $fields_updated = True;
- $this->db->query("update fm_tts_tickets set
cat_id='" . $ticket['cat_id']
- . "' where id='$id'",__LINE__,__FILE__);
-
$this->historylog->add('T',$id,$ticket['cat_id'],$oldcat_id);
- }
-
- if ($old_billable_hours != $ticket['billable_hours'])
- {
- $fields_updated = True;
- $this->db->query("update fm_tts_tickets set
billable_hours='" . $ticket['billable_hours']
- . "' where id='$id'",__LINE__,__FILE__);
-
$this->historylog->add('H',$id,$ticket['billable_hours'],$old_billable_hours);
- }
-
- if ($old_billable_rate != $ticket['billable_rate'])
- {
- $fields_updated = True;
- $this->db->query("update fm_tts_tickets set
billable_rate='" . $ticket['billable_rate']
- . "' where id='$id'",__LINE__,__FILE__);
-
$this->historylog->add('B',$id,$ticket['billable_rate'],$old_billable_rate);
- }
-
- if ($old_subject != $ticket['subject'])
- {
- $this->db->query("update fm_tts_tickets set
subject='" . $ticket['subject']
- . "' where id='$id'",__LINE__,__FILE__);
-
$this->historylog->add('S',$id,$ticket['subject'],$old_subject);
- $receipt['message'][]= array('msg' =>
lang('Subject has been updated'));
- }
-
- if (($old_note != $ticket['note']) && $ticket['note'])
- {
- $fields_updated = True;
-
$this->historylog->add('C',$id,$this->db->db_addslashes($ticket['note']),$old_note);
- }
-
- $this->db->transaction_commit();
-
- if ($fields_updated)
- {
- $this->config->read_repository();
-
- if
($this->config->config_data['mailnotification'] && $ticket['send_mail'])
- {
-
$receipt=$this->bo->mail_ticket($id,$fields_updated,'',$location_code);
-
- }
-
- $receipt['message'][]= array('msg' =>
lang('Ticket has been updated'));
- }
-
- return $receipt;
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage helpdesk
+ * @version $Id: class.sotts2.inc.php,v 1.9 2006/01/27 14:05:43 sigurdne
Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class sotts2
+ {
+ function sotts2()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->bo =
CreateObject($this->currentapp.'.botts');
+ $this->historylog =
CreateObject($this->currentapp.'.historylog','tts');
+ $this->config =
CreateObject('phpgwapi.config');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->like = $this->bocommon->like;
+ }
+
+ function update_status($ticket,$id='')
+ {
+ // DB Content is fresher than http posted value.
+ $this->db->query("select * from fm_tts_tickets where
id='$id'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $old_status = $this->db->f('status');
+
+ $this->db->transaction_begin();
+
+ /*
+ ** phpgw_fm_tts_append.append_type - Defs
+ ** R - Reopen ticket
+ ** X - Ticket closed
+ ** O - Ticket opened
+ ** C - Comment appended
+ ** A - Ticket assignment
+ ** G - Ticket group assignment
+ ** P - Priority change
+ ** T - Category change
+ ** S - Subject change
+ ** B - Billing rate
+ ** H - Billing hours
+ ** F - finnish date
+ */
+
+ if ($old_status != $ticket['status'])
+ {
+ $fields_updated = True;
+ if($old_status=='X')
+ {
+
$this->historylog->add('R',$id,$ticket['status'],$old_status);
+
+ $this->db->query("update fm_tts_tickets
set status='O' where id='$id'",__LINE__,__FILE__);
+ }
+ else
+ {
+
$this->historylog->add($ticket['status'],$id,$ticket['status'],$old_status);
+
+ $this->db->query("update fm_tts_tickets
set status='"
+ . $ticket['status'] . "' where
id='$id'",__LINE__,__FILE__);
+ }
+ }
+
+ $this->db->transaction_commit();
+
+ if ($fields_updated)
+ {
+ $this->config->read_repository();
+
+ if
($this->config->config_data['mailnotification'])
+ {
+
$receipt=$this->bo->mail_ticket($id,$fields_updated,'',$location_code);
+
+ }
+
+ $receipt['message'][]= array('msg' =>
lang('Ticket %1 has been updated',$id));
+ }
+
+ return $receipt;
+
+ }
+
+ function update_ticket($ticket,$id='')
+ {
+ // DB Content is fresher than http posted value.
+ $this->db->query("select * from fm_tts_tickets where
id='$id'",__LINE__,__FILE__);
+ $this->db->next_record();
+
+
+ $location_code = $this->db->f('location_code');
+ $oldfinnish_date = $this->db->f('finnish_date');
+ $oldfinnish_date2 = $this->db->f('finnish_date2');
+ $oldassigned = $this->db->f('assignedto');
+ $oldgroup_id = $this->db->f('group_id');
+ $oldpriority = $this->db->f('priority');
+ $oldcat_id =
$this->db->f('cat_id');
+ $old_status = $this->db->f('status');
+ $old_billable_hours =
$this->db->f('billable_hours');
+ $old_billable_rate = $this->db->f('billable_rate');
+ $old_subject = $this->db->f('subject');
+ if($oldcat_id ==0){$oldcat_id ='';}
+ if($oldassigned ==0){$oldassigned ='';}
+ if($oldgroup_id ==0){$oldgroup_id ='';}
+
+ // Figure out and last note
+
+ $history_values =
$this->historylog->return_array(array(),array('C'),'history_timestamp','DESC',$id);
+ $old_note = $history_values[0]['new_value'];
+
+ if(!$old_note)
+ {
+ $old_note = $this->db->f('details');
+ }
+
+
+ $this->db->transaction_begin();
+
+ /*
+ ** phpgw_fm_tts_append.append_type - Defs
+ ** R - Reopen ticket
+ ** X - Ticket closed
+ ** O - Ticket opened
+ ** C - Comment appended
+ ** A - Ticket assignment
+ ** G - Ticket group assignment
+ ** P - Priority change
+ ** T - Category change
+ ** S - Subject change
+ ** B - Billing rate
+ ** H - Billing hours
+ ** F - finnish date
+ */
+
+ $finnish_date =
$this->bocommon->date_to_timestamp($ticket['finnish_date']);
+
+ if ($oldfinnish_date && $ticket['finnish_date']):
+ {
+ $this->db->query("update fm_tts_tickets set
finnish_date2='" . $finnish_date
+ . "' where id='$id'",__LINE__,__FILE__);
+ }
+ elseif(!$oldfinnish_date && $ticket['finnish_date'] ):
+ {
+ $this->db->query("update fm_tts_tickets set
finnish_date='" . $finnish_date
+ . "' where id='$id'",__LINE__,__FILE__);
+ }
+ endif;
+
+ if($oldfinnish_date2>0)
+ {
+ $oldfinnish_date = $oldfinnish_date2;
+ }
+ if($ticket['finnish_date'])
+ {
+ if ($oldfinnish_date != $finnish_date)
+ {
+ $fields_updated = True;
+
$this->historylog->add('F',$id,$finnish_date,$oldfinnish_date);
+ }
+ }
+
+ if ($old_status != $ticket['status'])
+ {
+ $fields_updated = True;
+ if($old_status=='X')
+ {
+
$this->historylog->add('R',$id,$ticket['status'],$old_status);
+
+ $this->db->query("update fm_tts_tickets
set status='O' where id='$id'",__LINE__,__FILE__);
+ }
+ else
+ {
+
$this->historylog->add($ticket['status'],$id,$ticket['status'],$old_status);
+
+ $this->db->query("update fm_tts_tickets
set status='"
+ . $ticket['status'] . "' where
id='$id'",__LINE__,__FILE__);
+ }
+ }
+
+ if ($oldassigned != $ticket['assignedto'])
+ {
+ $fields_updated = True;
+
+ $value_set=array('assignedto' =>
$ticket['assignedto']);
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("update fm_tts_tickets set
$value_set where id='$id'",__LINE__,__FILE__);
+
$this->historylog->add('A',$id,$ticket['assignedto'],$oldassigned);
+ }
+
+ if ($oldgroup_id != $ticket['group_id'])
+ {
+ $fields_updated = True;
+
+ $value_set=array('group_id' =>
$ticket['group_id']);
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("update fm_tts_tickets set
$value_set where id='$id'",__LINE__,__FILE__);
+
$this->historylog->add('G',$id,$ticket['group_id'],$oldgroup_id);
+ }
+
+ if ($oldpriority != $ticket['priority'])
+ {
+ $fields_updated = True;
+ $this->db->query("update fm_tts_tickets set
priority='" . $ticket['priority']
+ . "' where id='$id'",__LINE__,__FILE__);
+
$this->historylog->add('P',$id,$ticket['priority'],$oldpriority);
+ }
+
+ if ($oldcat_id != $ticket['cat_id'])
+ {
+ $fields_updated = True;
+ $this->db->query("update fm_tts_tickets set
cat_id='" . $ticket['cat_id']
+ . "' where id='$id'",__LINE__,__FILE__);
+
$this->historylog->add('T',$id,$ticket['cat_id'],$oldcat_id);
+ }
+
+ if ($old_billable_hours != $ticket['billable_hours'])
+ {
+ $fields_updated = True;
+ $this->db->query("update fm_tts_tickets set
billable_hours='" . $ticket['billable_hours']
+ . "' where id='$id'",__LINE__,__FILE__);
+
$this->historylog->add('H',$id,$ticket['billable_hours'],$old_billable_hours);
+ }
+
+ if ($old_billable_rate != $ticket['billable_rate'])
+ {
+ $fields_updated = True;
+ $this->db->query("update fm_tts_tickets set
billable_rate='" . $ticket['billable_rate']
+ . "' where id='$id'",__LINE__,__FILE__);
+
$this->historylog->add('B',$id,$ticket['billable_rate'],$old_billable_rate);
+ }
+
+ if ($old_subject != $ticket['subject'])
+ {
+ $this->db->query("update fm_tts_tickets set
subject='" . $ticket['subject']
+ . "' where id='$id'",__LINE__,__FILE__);
+
$this->historylog->add('S',$id,$ticket['subject'],$old_subject);
+ $receipt['message'][]= array('msg' =>
lang('Subject has been updated'));
+ }
+
+ if (($old_note != $ticket['note']) && $ticket['note'])
+ {
+ $fields_updated = True;
+
$this->historylog->add('C',$id,$this->db->db_addslashes($ticket['note']),$old_note);
+ }
+
+ $this->db->transaction_commit();
+
+ if ($fields_updated)
+ {
+ $this->config->read_repository();
+
+ if
($this->config->config_data['mailnotification'] && $ticket['send_mail'])
+ {
+
$receipt=$this->bo->mail_ticket($id,$fields_updated,'',$location_code);
+
+ }
+
+ $receipt['message'][]= array('msg' =>
lang('Ticket has been updated'));
+ }
+
+ return $receipt;
+ }
+
+ }
+?>
Index: property/inc/class.sowo_hour.inc.php
diff -u property/inc/class.sowo_hour.inc.php:1.9
property/inc/class.sowo_hour.inc.php:1.10
--- property/inc/class.sowo_hour.inc.php:1.9 Mon Sep 12 08:19:02 2005
+++ property/inc/class.sowo_hour.inc.php Fri Jan 27 14:05:43 2006
@@ -1,712 +1,711 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage project
- * @version $Id: class.sowo_hour.inc.php,v 1.9 2005/09/12 08:19:02
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class sowo_hour
- {
-
- function sowo_hour()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db =
$GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->join = $this->bocommon->join;
- $this->left_join =
$this->bocommon->left_join;
- $this->like = $this->bocommon->like;
- }
-
- function get_chapter_list()
- {
- $this->db->query("SELECT id, descr FROM fm_chapter
ORDER BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $chapter_entries[$i]['id']
= $this->db->f('id');
- $chapter_entries[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $chapter_entries;
- }
-
- function get_grouping_list($workorder_id='')
- {
- $this->db->query("SELECT grouping_id, grouping_descr
FROM fm_wo_hours where workorder_id='$workorder_id' and grouping_id >0 group by
grouping_id, grouping_descr");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $grouping_entries[$i]['id']
= $this->db->f('grouping_id');
- $grouping_entries[$i]['name']
= stripslashes($this->db->f('grouping_descr'));
- $i++;
- }
- return $grouping_entries;
- }
-
- function get_building_part_list()
- {
- $this->db->query("SELECT id, descr FROM
fm_building_part ORDER BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $building_part_entries[$i]['id']
= $this->db->f('id');
- $building_part_entries[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $building_part_entries;
- }
-
-
- function select_branch_list()
- {
- $this->db->query("SELECT id, descr FROM fm_branch ORDER
BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $branch_entries[$i]['id']
= $this->db->f('id');
- $branch_entries[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $branch_entries;
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- $workorder_id =
(isset($data['workorder_id'])?$data['workorder_id']:0);
- }
-
-
- $ordermethod = ' order by grouping_id, record , id asc
';
-
- $sql = "SELECT fm_wo_hours.*,
fm_wo_hours_category.descr as wo_hour_category"
- . " FROM fm_wo_hours $this->left_join
fm_wo_hours_category on fm_wo_hours.category = fm_wo_hours_category.id WHERE
workorder_id='$workorder_id' ";
-
- $this->db->query($sql . $ordermethod,__LINE__,__FILE__);
- $this->total_records = $this->db->num_rows();
-
- while ($this->db->next_record())
- {
- $hour_list[] = array
- (
- 'hour_id' =>
$this->db->f('id'),
- 'activity_num' =>
$this->db->f('activity_num'),
- 'hours_descr' =>
stripslashes($this->db->f('hours_descr')),
- 'owner' =>
$this->db->f('owner'),
- 'quantity' =>
$this->db->f('quantity'),
- 'grouping_id' =>
$this->db->f('grouping_id'),
- 'grouping_descr' =>
$this->db->f('grouping_descr'),
- 'ns3420_id' =>
$this->db->f('ns3420_id'),
- 'tolerance' =>
$this->db->f('tolerance'),
- 'activity_id' =>
$this->db->f('activity_id'),
- 'unit' =>
$this->db->f('unit'),
- 'record' =>
$this->db->f('record'),
- 'cost' =>
$this->db->f('cost'),
- 'billperae' =>
$this->db->f('billperae'),
- 'remark' =>
$this->db->f('remark'),
- 'building_part' =>
$this->db->f('building_part'),
- 'dim_d' =>
$this->db->f('dim_d'),
- 'wo_hour_category' =>
$this->db->f('wo_hour_category')
- );
- }
-
- for ($i=0; $i<count($hour_list); $i++)
- {
- $sql = "SELECT sum(amount) as deviation,
count(amount) as count_deviation FROM fm_wo_h_deviation WHERE
workorder_id=$workorder_id and hour_id=". $hour_list[$i]['hour_id'];
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
-
$hour_list[$i]['deviation']=$this->db->f('deviation');
-
$hour_list[$i]['count_deviation']=$this->db->f('count_deviation');
- }
-
- return $hour_list;
- }
-
-
- function read_deviation($data)
- {
- if(is_array($data))
- {
- $workorder_id =
(isset($data['workorder_id'])?$data['workorder_id']:0);
- $hour_id =
(isset($data['hour_id'])?$data['hour_id']:0);
- }
-
- $ordermethod = ' order by id asc';
-
- $sql = "SELECT * FROM fm_wo_h_deviation WHERE
workorder_id=$workorder_id AND hour_id=$hour_id ";
-
-
- $this->db->query($sql . $ordermethod,__LINE__,__FILE__);
- $this->total_records = $this->db->num_rows();
-
- while ($this->db->next_record())
- {
- $deviation[] = array
- (
- 'entry_date' =>
$this->db->f('entry_date'),
- 'workorder_id' =>
$workorder_id,
- 'hour_id' =>
$hour_id,
- 'id' =>
$this->db->f('id'),
- 'amount' =>
$this->db->f('amount'),
- 'descr' =>
stripslashes($this->db->f('descr'))
- );
- }
-//_debug_array($deviation);
- return $deviation;
- }
-
-
- function read_single_deviation($data)
- {
- if(is_array($data))
- {
- $workorder_id =
(isset($data['workorder_id'])?$data['workorder_id']:0);
- $hour_id =
(isset($data['hour_id'])?$data['hour_id']:0);
- $id = (isset($data['id'])?$data['id']:0);
- }
-
- $sql = "SELECT * FROM fm_wo_h_deviation WHERE
workorder_id=$workorder_id AND hour_id=$hour_id AND id = $id";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $deviation = array
- (
- 'entry_date' =>
$this->db->f('entry_date'),
- 'workorder_id' => $workorder_id,
- 'hour_id' => $hour_id,
- 'id' =>
$this->db->f('id'),
- 'amount' =>
$this->db->f('amount'),
- 'descr' =>
stripslashes($this->db->f('descr'))
- );
- return $deviation;
- }
-
- function add_deviation($values)
- {
- $sql = "SELECT max(id) as current_id FROM
fm_wo_h_deviation WHERE workorder_id=" . $values['workorder_id'] . " AND
hour_id=" . $values['hour_id'];
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $id=$this->db->f('current_id')+1;
-
- $values['descr'] =
$this->db->db_addslashes($values['descr']);
-
- $values_insert= array(
- $values['workorder_id'],
- $values['hour_id'],
- $id,
- $values['amount'],
- $values['descr'],
- time()
- );
-
- $values_insert =
$this->bocommon->validate_db_insert($values_insert);
-
- $this->db->query("INSERT INTO fm_wo_h_deviation
(workorder_id,hour_id,id,amount,descr,entry_date) VALUES
($values_insert)",__LINE__,__FILE__);
-
- $receipt['id']= $id;
-
- $receipt['message'][] = array('msg'=> lang('deviation
has been added'));
- return $receipt;
- }
-
- function edit_deviation($values)
- {
- $values['descr'] =
$this->db->db_addslashes($values['descr']);
-
- $value_set=array(
- 'amount' =>
$values['amount'],
- 'descr' =>
$this->db->db_addslashes($values['descr'])
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE fm_wo_h_deviation set
$value_set WHERE workorder_id=" . $values['workorder_id'] . " AND hour_id=" .
$values['hour_id'] . " AND id=" . $values['id'],__LINE__,__FILE__);
-
- $receipt['message'][] = array('msg'=> lang('deviation
has been edited'));
-
- return $receipt;
- }
-
- function update_deviation($data)
- {
- if(is_array($data))
- {
- $id =
(isset($data['workorder_id'])?$data['workorder_id']:0);
- $deviation =
(isset($data['sum_deviation'])?$data['sum_deviation']:0);
- }
- $this->db->query("UPDATE fm_workorder set deviation =
$deviation WHERE id=$id",__LINE__,__FILE__);
- return $receipt;
- }
-
-
- function next_record($workorder_id)
- {
- $this->db->query("SELECT max(record) as record FROM
fm_wo_hours where workorder_id='$workorder_id'",__LINE__,__FILE__);
- $this->db->next_record();
- $record = $this->db->f('record')+1;
- return $record;
- }
-
- function add_template($values,$workorder_id)
- {
-
- $values['name'] =
$this->db->db_addslashes($values['name']);
- $soworkorder =
CreateObject($this->currentapp.'.soworkorder');
- $workorder =
$soworkorder->read_single($workorder_id);
-
- $this->db->transaction_begin();
-
- $values_insert= array(
- $this->account,
- $values['name'],
- $values['descr'],
- $workorder['chapter_id'],
- time()
- );
-
- $values_insert =
$this->bocommon->validate_db_insert($values_insert);
-
- $this->db->query("insert into fm_template
(owner,name,descr,chapter_id,entry_date) "
- . " values ($values_insert)",__LINE__,__FILE__);
-
- unset ($values_insert);
-
- $template_id =
$this->db->get_last_insert_id('fm_template','id');
-
- $hour = $this->read(array('workorder_id' =>
$workorder_id));
-
- $record = $this->next_record($workorder_id);
-
- for ($i=0; $i<count($hour); $i++)
- {
- $values_insert= array(
- $hour[$i]['activity_id'],
- $hour[$i]['activity_num'],
- $this->account,
- $hour[$i]['hours_descr'],
- $hour[$i]['unit'],
- $hour[$i]['cost'],
- $hour[$i]['quantity'],
- $hour[$i]['billperae'],
- $hour[$i]['ns3420_id'],
- $hour[$i]['dim_d'],
- $hour[$i]['grouping_id'],
- $hour[$i]['grouping_descr'],
- $hour[$i]['remark'],
- $hour[$i]['tolerance'],
- $hour[$i]['building_part'],
- $record,
- $template_id );
-
- $values_insert =
$this->bocommon->validate_db_insert($values_insert);
-
- $this->db->query("insert into fm_template_hours
(activity_id,activity_num,owner,hours_descr,unit,"
- .
"cost,quantity,billperae,ns3420_id,dim_d,grouping_id,grouping_descr,remark,tolerance,building_part,record,template_id)
"
- . " values ($values_insert)",__LINE__,__FILE__);
-
- $record++;
- }
-
- $this->db->transaction_commit();
-
- $receipt['message'][] = array('msg'=>lang('template %1
is added',$values['name']));
- return $receipt;
- }
-
-
- function add_hour($hour)
- {
- $record = $this->next_record($hour[0]['workorder_id']);
-
- for ($i=0; $i<count($hour); $i++)
- {
- $values= array(
- $hour[$i]['activity_id'],
- $hour[$i]['activity_num'],
- $this->account,
- $hour[$i]['hours_descr'],
- $hour[$i]['unit'],
- $hour[$i]['cost'],
- $hour[$i]['quantity'],
- $hour[$i]['billperae'],
- $hour[$i]['ns3420_id'],
- $hour[$i]['dim_d'],
- $record,
- time(),
- $hour[$i]['workorder_id'],
- $hour[$i]['wo_hour_cat']);
-
- $values =
$this->bocommon->validate_db_insert($values);
-
- $this->db->query("insert into fm_wo_hours
(activity_id,activity_num,owner,hours_descr,unit,cost,quantity,billperae,ns3420_id,dim_d,record,entry_date,workorder_id,category)
"
- . " values ($values)",__LINE__,__FILE__);
-
- $record++;
- }
-
- $receipt['message'][] = array('msg'=>lang('%1 entries
is added!',count($hour)));
-
- $receipt['hour_id'] =
$this->db->get_last_insert_id('fm_wo_hours','id');
-
- return $receipt;
- }
-
- function add_hour_from_template($hour,$workorder_id)
- {
-
- $record = $this->next_record($workorder_id);
-
- if($hour[0]['chapter_id'])
- {
- $this->db->query("UPDATE fm_workorder set
- chapter_id ='" .
$hour[0]['chapter_id'] . "' WHERE id= '$workorder_id'",__LINE__,__FILE__);
- }
-
- for ($i=0; $i<count($hour); $i++)
- {
-
- if($hour[$i]['new_grouping'])
- {
- $this->db->query("SELECT grouping_id
FROM fm_wo_hours where grouping_descr ='" .$hour[$i]['new_grouping'] . "' and
workorder_id= '$workorder_id'",__LINE__,__FILE__);
- $this->db->next_record();
- if ( $this->db->f('grouping_id'))
- {
- $grouping_id =
$this->db->f('grouping_id');
- }
- else
- {
- $this->db->query("SELECT
max(grouping_id) as grouping_id FROM fm_wo_hours where workorder_id=
'$workorder_id'",__LINE__,__FILE__);
- $this->db->next_record();
- $grouping_id =
$this->db->f('grouping_id')+1;
- }
-
- $grouping_descr =
$hour[$i]['new_grouping'];
- }
-
- $values= array(
- $this->account,
- $hour[$i]['activity_id'],
- $hour[$i]['activity_num'],
- $hour[$i]['hours_descr'],
- $hour[$i]['unit'],
- $hour[$i]['cost'],
- $hour[$i]['quantity'],
- $hour[$i]['billperae'],
- $hour[$i]['ns3420_id'],
- $hour[$i]['dim_d'],
- $grouping_id,
- $grouping_descr,
- $record,
- $hour[$i]['building_part_id'],
- $hour[$i]['tolerance_id'],
- $hour[$i]['remark'],
- time(),
- $workorder_id );
-
- $values =
$this->bocommon->validate_db_insert($values);
-
- $this->db->query("insert into fm_wo_hours
(owner,activity_id,activity_num,hours_descr,unit,cost,quantity,billperae,ns3420_id,dim_d,"
- . "
grouping_id,grouping_descr,record,building_part,tolerance,remark,entry_date,workorder_id)
"
- . " values ($values )",__LINE__,__FILE__);
-
- $record++;
- }
-
- $receipt['message'][] = array('msg'=>lang('the number
of %1 hour is added!',$i));
-
- return $receipt;
- }
-
- function add_custom_hour($hour,$workorder_id)
- {
-
- $hour['record'] = $this->next_record($workorder_id);
-
- if($hour['chapter_id'])
- {
- $this->db->query("UPDATE fm_workorder set
- chapter_id ='" . $hour['chapter_id'] . "'
WHERE id= '$workorder_id'",__LINE__,__FILE__);
- }
-
- if($hour['grouping_id'])
- {
- $this->db->query("SELECT grouping_descr ,
max(record) as record FROM fm_wo_hours where grouping_id='"
.$hour['grouping_id'] . "' and workorder_id= '$workorder_id' GROUP by
grouping_descr",__LINE__,__FILE__);
- $this->db->next_record();
- $hour['grouping_descr'] =
$this->db->f('grouping_descr');
-// $hour['record'] = $this->db->f('record')+1;
- }
-
- if($hour['new_grouping'])
- {
- $this->db->query("SELECT grouping_id FROM
fm_wo_hours where grouping_descr ='" .$hour['new_grouping'] . "' and
workorder_id= '$workorder_id'",__LINE__,__FILE__);
- $this->db->next_record();
- if ( $this->db->f('grouping_id'))
- {
- $hour['grouping_id'] =
$this->db->f('grouping_id');
- }
- else
- {
- $this->db->query("SELECT
max(grouping_id) as grouping_id FROM fm_wo_hours where workorder_id=
'$workorder_id'",__LINE__,__FILE__);
- $this->db->next_record();
- $hour['grouping_id'] =
$this->db->f('grouping_id')+1;
-// $hour['record'] = 1;
- }
-
- $hour['grouping_descr'] = $hour['new_grouping'];
- }
-
- $values= array(
- $this->account,
- $hour['descr'],
- $hour['unit'],
- $hour['cost'],
- $hour['quantity'],
- $hour['billperae'],
- $hour['ns3420_id'],
- $hour['dim_d'],
- $hour['grouping_id'],
- $hour['grouping_descr'],
- $hour['record'],
- $hour['building_part_id'],
- $hour['tolerance_id'],
- $hour['remark'],
- time(),
- $workorder_id,
- $hour['wo_hour_cat']
- );
-
- $values = $this->bocommon->validate_db_insert($values);
-
- $this->db->query("insert into fm_wo_hours
(owner,hours_descr,unit,cost,quantity,billperae,ns3420_id,dim_d,"
- . "
grouping_id,grouping_descr,record,building_part,tolerance,remark,entry_date,workorder_id,category)
"
- . "VALUES ( $values )",__LINE__,__FILE__);
-
- $receipt['hour_id'] =
$this->db->get_last_insert_id('fm_wo_hours','id');
-
- $receipt['message'][] = array('msg'=>lang('hour %1 is
added!',$receipt['hour_id']));
-
- return $receipt;
-
- }
-
- function read_single_hour($hour_id)
- {
- $sql = "SELECT * from fm_wo_hours where id='$hour_id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $hour['hour_id']
= $this->db->f('id');
- $hour['record']
= $this->db->f('record');
- $hour['activity_id'] =
$this->db->f('activity_id');
- $hour['activity_num'] =
$this->db->f('activity_num');
- $hour['grouping_id'] =
$this->db->f('grouping_id');
- $hour['hours_descr'] =
$this->db->f('hours_descr');
- $hour['remark']
= $this->db->f('remark');
- $hour['billperae']
= $this->db->f('billperae');
- $hour['unit']
= $this->db->f('unit');
- $hour['ns3420_id']
= $this->db->f('ns3420_id');
- $hour['tolerance_id'] =
(int)$this->db->f('tolerance');
- $hour['building_part_id'] =
(int)$this->db->f('building_part');
- $hour['quantity']
= $this->db->f('quantity');
- $hour['cost']
= $this->db->f('cost');
- $hour['dim_d']
= $this->db->f('dim_d');
- $hour['wo_hour_cat']
= $this->db->f('category');
- }
-
- return $hour;
- }
-
- function edit($hour,$workorder_id)
- {
-
- $hour['descr'] =
$this->db->db_addslashes($hour['descr']);
- $hour['remark'] =
$this->db->db_addslashes($hour['remark']);
-//_debug_array($hour);
-
-
- if($hour['chapter_id'])
- {
- $this->db->query("UPDATE fm_workorder set
- chapter_id ='" . $hour['chapter_id'] . "'
WHERE id= '$workorder_id'",__LINE__,__FILE__);
- }
-
- if($hour['new_grouping'])
- {
- $this->db->query("SELECT grouping_id FROM
fm_wo_hours where grouping_descr ='" .$hour['new_grouping'] . "' and
workorder_id= '$workorder_id'",__LINE__,__FILE__);
- $this->db->next_record();
- if ( $this->db->f('grouping_id'))
- {
- $hour['grouping_id'] =
$this->db->f('grouping_id');
- }
- else
- {
-
- $this->db->query("UPDATE fm_wo_hours
set grouping_id = NULL WHERE id ='" .$hour['hour_id'] . "'",__LINE__,__FILE__);
- $this->db->query("SELECT
count(grouping_id) as num_grouping FROM fm_wo_hours where workorder_id=
'$workorder_id' and grouping_id >0 ",__LINE__,__FILE__);
- $this->db->next_record();
- if ($this->db->f('num_grouping')==1)
- {
- $hour['grouping_id']=1;
- }
- else
- {
- $this->db->query("SELECT
max(grouping_id) as grouping_id FROM fm_wo_hours where workorder_id=
'$workorder_id'",__LINE__,__FILE__);
- $this->db->next_record();
- $hour['grouping_id'] =
$this->db->f('grouping_id')+1;
- }
- }
- $hour['grouping_descr'] = $hour['new_grouping'];
- }
- else
- {
- $this->db->query("SELECT
grouping_id,grouping_descr FROM fm_wo_hours where id ='" .$hour['hour_id'] .
"'",__LINE__,__FILE__);
- $this->db->next_record();
- $old_grouping_id =
$this->db->f('grouping_id');
-
- if ( $old_grouping_id == $hour['grouping_id'])
- {
-
- $hour['grouping_descr'] =
$this->db->f('grouping_descr');
- }
- else
- {
- $this->db->query("SELECT grouping_descr
, max(record) as record FROM fm_wo_hours where grouping_id='"
.$hour['grouping_id'] . "' and workorder_id= '$workorder_id' GROUP by
grouping_descr",__LINE__,__FILE__);
- $this->db->next_record();
- if($this->db->f('grouping_descr'))
- {
- $hour['grouping_descr'] =
$this->db->f('grouping_descr');
- }
- else
- {
- $hour['grouping_id']='';
- $hour['grouping_descr']='';
- }
-
-/* if($old_record>1)
- {
- $this->db->query("UPDATE
fm_wo_hours set
- record = record - 1
where grouping_id='" .$hour['grouping_id'] . "' and workorder_id=
'$workorder_id' and record > $old_record ",__LINE__,__FILE__);
-
- }
-
-*/
- }
- }
-
- $value_set=array(
- 'hours_descr' => $hour['descr'],
- 'remark' =>
$hour['remark'],
- 'billperae' =>
$hour['billperae'],
- 'unit' =>
$hour['unit'],
- 'quantity' =>
$hour['quantity'],
- 'cost' =>
$hour['cost'],
- 'ns3420_id' =>
$hour['ns3420_id'],
- 'tolerance' =>
$hour['tolerance_id'],
- 'building_part' =>
$hour['building_part_id'],
- 'dim_d' =>
$hour['dim_d'],
- 'grouping_id' => $hour['grouping_id'],
- 'grouping_descr' =>
$hour['grouping_descr'],
- 'category' => $hour['wo_hour_cat']
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE fm_wo_hours set $value_set
WHERE id= '" . $hour['hour_id'] ."'",__LINE__,__FILE__);
-
- $receipt['hour_id'] = $hour['hour_id'];
- $receipt['message'][] = array('msg'=>lang('hour %1 has
been edited',$hour['hour_id']));
- return $receipt;
-
- }
-
- function update_email($to_email,$workorder_id)
- {
- $this->db->query("SELECT vendor_id FROM fm_workorder
where id ='$workorder_id'",__LINE__,__FILE__);
- $this->db->next_record();
- $vendor_id = $this->db->f('vendor_id');
-
- $this->db->query("UPDATE fm_vendor set email
='$to_email' where id= '$vendor_id'",__LINE__,__FILE__);
- }
-
- function get_email($vendor_id)
- {
- $vendor_id=(int)$vendor_id;
-
- $this->db->query("select column_name from
fm_vendor_attribute WHERE datatype='email'",__LINE__,__FILE__);
- while ($this->db->next_record())
- {
- $this->db2->query("select " .
$this->db->f('column_name') . " from fm_vendor where
id=$vendor_id",__LINE__,__FILE__);
- while ($this->db2->next_record())
- {
-
if($this->db2->f($this->db->f('column_name')))
- {
- $email_list[] = array('email'
=> $this->db2->f($this->db->f('column_name')));
- }
- }
- }
-
- return $email_list;
- }
-
- function delete($hour_id,$workorder_id )
- {
- $this->db->query("SELECT record FROM fm_wo_hours where
id ='$hour_id'",__LINE__,__FILE__);
- $this->db->next_record();
- $old_record = $this->db->f('record');
-
- $this->db->transaction_begin();
-
- $this->db->query("DELETE FROM fm_wo_hours WHERE id='" .
$hour_id . "'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_wo_h_deviation WHERE
workorder_id=$workorder_id AND hour_id=$hour_id",__LINE__,__FILE__);
- if($old_record)
- {
- $this->db->query("UPDATE fm_wo_hours set record
= record - 1 where workorder_id= '$workorder_id' and record > $old_record
",__LINE__,__FILE__);
- }
-
- $this->db->transaction_commit();
-
- $receipt['message'][] = array('msg'=>lang('hour %1 has
been deleted',$hour_id));
- return $receipt;
-
- }
-
- function delete_deviation($workorder_id,$hour_id,$id )
- {
- $this->db->query("DELETE FROM fm_wo_h_deviation WHERE
workorder_id=$workorder_id AND hour_id=$hour_id AND id=$id",__LINE__,__FILE__);
- $receipt['message'][] = array('msg'=>lang('deviation %1
has been deleted',$id));
- return $receipt;
- }
-
- function update_calculation($data)
- {
- if(is_array($data))
- {
- $id =
(isset($data['workorder_id'])?$data['workorder_id']:0);
- $calculation =
(isset($data['calculation'])?$data['calculation']:0);
- }
- $this->db->query("UPDATE fm_workorder set calculation =
$calculation WHERE id=$id",__LINE__,__FILE__);
- return $receipt;
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage project
+ * @version $Id: class.sowo_hour.inc.php,v 1.10 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class sowo_hour
+ {
+
+ function sowo_hour()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->left_join =
$this->bocommon->left_join;
+ $this->like = $this->bocommon->like;
+ }
+
+ function get_chapter_list()
+ {
+ $this->db->query("SELECT id, descr FROM fm_chapter
ORDER BY id ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $chapter_entries[$i]['id']
= $this->db->f('id');
+ $chapter_entries[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $chapter_entries;
+ }
+
+ function get_grouping_list($workorder_id='')
+ {
+ $this->db->query("SELECT grouping_id, grouping_descr
FROM fm_wo_hours where workorder_id='$workorder_id' and grouping_id >0 group by
grouping_id, grouping_descr");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $grouping_entries[$i]['id']
= $this->db->f('grouping_id');
+ $grouping_entries[$i]['name']
= stripslashes($this->db->f('grouping_descr'));
+ $i++;
+ }
+ return $grouping_entries;
+ }
+
+ function get_building_part_list()
+ {
+ $this->db->query("SELECT id, descr FROM
fm_building_part ORDER BY id ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $building_part_entries[$i]['id']
= $this->db->f('id');
+ $building_part_entries[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $building_part_entries;
+ }
+
+
+ function select_branch_list()
+ {
+ $this->db->query("SELECT id, descr FROM fm_branch ORDER
BY id ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $branch_entries[$i]['id']
= $this->db->f('id');
+ $branch_entries[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $branch_entries;
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ $workorder_id =
(isset($data['workorder_id'])?$data['workorder_id']:0);
+ }
+
+
+ $ordermethod = ' order by grouping_id, record , id asc
';
+
+ $sql = "SELECT fm_wo_hours.*,
fm_wo_hours_category.descr as wo_hour_category"
+ . " FROM fm_wo_hours $this->left_join
fm_wo_hours_category on fm_wo_hours.category = fm_wo_hours_category.id WHERE
workorder_id='$workorder_id' ";
+
+ $this->db->query($sql . $ordermethod,__LINE__,__FILE__);
+ $this->total_records = $this->db->num_rows();
+
+ while ($this->db->next_record())
+ {
+ $hour_list[] = array
+ (
+ 'hour_id' =>
$this->db->f('id'),
+ 'activity_num' =>
$this->db->f('activity_num'),
+ 'hours_descr' =>
stripslashes($this->db->f('hours_descr')),
+ 'owner' =>
$this->db->f('owner'),
+ 'quantity' =>
$this->db->f('quantity'),
+ 'grouping_id' =>
$this->db->f('grouping_id'),
+ 'grouping_descr' =>
$this->db->f('grouping_descr'),
+ 'ns3420_id' =>
$this->db->f('ns3420_id'),
+ 'tolerance' =>
$this->db->f('tolerance'),
+ 'activity_id' =>
$this->db->f('activity_id'),
+ 'unit' =>
$this->db->f('unit'),
+ 'record' =>
$this->db->f('record'),
+ 'cost' =>
$this->db->f('cost'),
+ 'billperae' =>
$this->db->f('billperae'),
+ 'remark' =>
$this->db->f('remark'),
+ 'building_part' =>
$this->db->f('building_part'),
+ 'dim_d' =>
$this->db->f('dim_d'),
+ 'wo_hour_category' =>
$this->db->f('wo_hour_category')
+ );
+ }
+
+ for ($i=0; $i<count($hour_list); $i++)
+ {
+ $sql = "SELECT sum(amount) as deviation,
count(amount) as count_deviation FROM fm_wo_h_deviation WHERE
workorder_id=$workorder_id and hour_id=". $hour_list[$i]['hour_id'];
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+
$hour_list[$i]['deviation']=$this->db->f('deviation');
+
$hour_list[$i]['count_deviation']=$this->db->f('count_deviation');
+ }
+
+ return $hour_list;
+ }
+
+
+ function read_deviation($data)
+ {
+ if(is_array($data))
+ {
+ $workorder_id =
(isset($data['workorder_id'])?$data['workorder_id']:0);
+ $hour_id =
(isset($data['hour_id'])?$data['hour_id']:0);
+ }
+
+ $ordermethod = ' order by id asc';
+
+ $sql = "SELECT * FROM fm_wo_h_deviation WHERE
workorder_id=$workorder_id AND hour_id=$hour_id ";
+
+
+ $this->db->query($sql . $ordermethod,__LINE__,__FILE__);
+ $this->total_records = $this->db->num_rows();
+
+ while ($this->db->next_record())
+ {
+ $deviation[] = array
+ (
+ 'entry_date' =>
$this->db->f('entry_date'),
+ 'workorder_id' =>
$workorder_id,
+ 'hour_id' =>
$hour_id,
+ 'id' =>
$this->db->f('id'),
+ 'amount' =>
$this->db->f('amount'),
+ 'descr' =>
stripslashes($this->db->f('descr'))
+ );
+ }
+//_debug_array($deviation);
+ return $deviation;
+ }
+
+
+ function read_single_deviation($data)
+ {
+ if(is_array($data))
+ {
+ $workorder_id =
(isset($data['workorder_id'])?$data['workorder_id']:0);
+ $hour_id =
(isset($data['hour_id'])?$data['hour_id']:0);
+ $id = (isset($data['id'])?$data['id']:0);
+ }
+
+ $sql = "SELECT * FROM fm_wo_h_deviation WHERE
workorder_id=$workorder_id AND hour_id=$hour_id AND id = $id";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $deviation = array
+ (
+ 'entry_date' =>
$this->db->f('entry_date'),
+ 'workorder_id' => $workorder_id,
+ 'hour_id' => $hour_id,
+ 'id' =>
$this->db->f('id'),
+ 'amount' =>
$this->db->f('amount'),
+ 'descr' =>
stripslashes($this->db->f('descr'))
+ );
+ return $deviation;
+ }
+
+ function add_deviation($values)
+ {
+ $sql = "SELECT max(id) as current_id FROM
fm_wo_h_deviation WHERE workorder_id=" . $values['workorder_id'] . " AND
hour_id=" . $values['hour_id'];
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $id=$this->db->f('current_id')+1;
+
+ $values['descr'] =
$this->db->db_addslashes($values['descr']);
+
+ $values_insert= array(
+ $values['workorder_id'],
+ $values['hour_id'],
+ $id,
+ $values['amount'],
+ $values['descr'],
+ time()
+ );
+
+ $values_insert =
$this->bocommon->validate_db_insert($values_insert);
+
+ $this->db->query("INSERT INTO fm_wo_h_deviation
(workorder_id,hour_id,id,amount,descr,entry_date) VALUES
($values_insert)",__LINE__,__FILE__);
+
+ $receipt['id']= $id;
+
+ $receipt['message'][] = array('msg'=> lang('deviation
has been added'));
+ return $receipt;
+ }
+
+ function edit_deviation($values)
+ {
+ $values['descr'] =
$this->db->db_addslashes($values['descr']);
+
+ $value_set=array(
+ 'amount' =>
$values['amount'],
+ 'descr' =>
$this->db->db_addslashes($values['descr'])
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE fm_wo_h_deviation set
$value_set WHERE workorder_id=" . $values['workorder_id'] . " AND hour_id=" .
$values['hour_id'] . " AND id=" . $values['id'],__LINE__,__FILE__);
+
+ $receipt['message'][] = array('msg'=> lang('deviation
has been edited'));
+
+ return $receipt;
+ }
+
+ function update_deviation($data)
+ {
+ if(is_array($data))
+ {
+ $id =
(isset($data['workorder_id'])?$data['workorder_id']:0);
+ $deviation =
(isset($data['sum_deviation'])?$data['sum_deviation']:0);
+ }
+ $this->db->query("UPDATE fm_workorder set deviation =
$deviation WHERE id=$id",__LINE__,__FILE__);
+ return $receipt;
+ }
+
+
+ function next_record($workorder_id)
+ {
+ $this->db->query("SELECT max(record) as record FROM
fm_wo_hours where workorder_id='$workorder_id'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $record = $this->db->f('record')+1;
+ return $record;
+ }
+
+ function add_template($values,$workorder_id)
+ {
+
+ $values['name'] =
$this->db->db_addslashes($values['name']);
+ $soworkorder =
CreateObject($this->currentapp.'.soworkorder');
+ $workorder =
$soworkorder->read_single($workorder_id);
+
+ $this->db->transaction_begin();
+
+ $values_insert= array(
+ $this->account,
+ $values['name'],
+ $values['descr'],
+ $workorder['chapter_id'],
+ time()
+ );
+
+ $values_insert =
$this->bocommon->validate_db_insert($values_insert);
+
+ $this->db->query("insert into fm_template
(owner,name,descr,chapter_id,entry_date) "
+ . " values ($values_insert)",__LINE__,__FILE__);
+
+ unset ($values_insert);
+
+ $template_id =
$this->db->get_last_insert_id('fm_template','id');
+
+ $hour = $this->read(array('workorder_id' =>
$workorder_id));
+
+ $record = $this->next_record($workorder_id);
+
+ for ($i=0; $i<count($hour); $i++)
+ {
+ $values_insert= array(
+ $hour[$i]['activity_id'],
+ $hour[$i]['activity_num'],
+ $this->account,
+ $hour[$i]['hours_descr'],
+ $hour[$i]['unit'],
+ $hour[$i]['cost'],
+ $hour[$i]['quantity'],
+ $hour[$i]['billperae'],
+ $hour[$i]['ns3420_id'],
+ $hour[$i]['dim_d'],
+ $hour[$i]['grouping_id'],
+ $hour[$i]['grouping_descr'],
+ $hour[$i]['remark'],
+ $hour[$i]['tolerance'],
+ $hour[$i]['building_part'],
+ $record,
+ $template_id );
+
+ $values_insert =
$this->bocommon->validate_db_insert($values_insert);
+
+ $this->db->query("insert into fm_template_hours
(activity_id,activity_num,owner,hours_descr,unit,"
+ .
"cost,quantity,billperae,ns3420_id,dim_d,grouping_id,grouping_descr,remark,tolerance,building_part,record,template_id)
"
+ . " values ($values_insert)",__LINE__,__FILE__);
+
+ $record++;
+ }
+
+ $this->db->transaction_commit();
+
+ $receipt['message'][] = array('msg'=>lang('template %1
is added',$values['name']));
+ return $receipt;
+ }
+
+
+ function add_hour($hour)
+ {
+ $record = $this->next_record($hour[0]['workorder_id']);
+
+ for ($i=0; $i<count($hour); $i++)
+ {
+ $values= array(
+ $hour[$i]['activity_id'],
+ $hour[$i]['activity_num'],
+ $this->account,
+ $hour[$i]['hours_descr'],
+ $hour[$i]['unit'],
+ $hour[$i]['cost'],
+ $hour[$i]['quantity'],
+ $hour[$i]['billperae'],
+ $hour[$i]['ns3420_id'],
+ $hour[$i]['dim_d'],
+ $record,
+ time(),
+ $hour[$i]['workorder_id'],
+ $hour[$i]['wo_hour_cat']);
+
+ $values =
$this->bocommon->validate_db_insert($values);
+
+ $this->db->query("insert into fm_wo_hours
(activity_id,activity_num,owner,hours_descr,unit,cost,quantity,billperae,ns3420_id,dim_d,record,entry_date,workorder_id,category)
"
+ . " values ($values)",__LINE__,__FILE__);
+
+ $record++;
+ }
+
+ $receipt['message'][] = array('msg'=>lang('%1 entries
is added!',count($hour)));
+
+ $receipt['hour_id'] =
$this->db->get_last_insert_id('fm_wo_hours','id');
+
+ return $receipt;
+ }
+
+ function add_hour_from_template($hour,$workorder_id)
+ {
+
+ $record = $this->next_record($workorder_id);
+
+ if($hour[0]['chapter_id'])
+ {
+ $this->db->query("UPDATE fm_workorder set
+ chapter_id ='" .
$hour[0]['chapter_id'] . "' WHERE id= '$workorder_id'",__LINE__,__FILE__);
+ }
+
+ for ($i=0; $i<count($hour); $i++)
+ {
+
+ if($hour[$i]['new_grouping'])
+ {
+ $this->db->query("SELECT grouping_id
FROM fm_wo_hours where grouping_descr ='" .$hour[$i]['new_grouping'] . "' and
workorder_id= '$workorder_id'",__LINE__,__FILE__);
+ $this->db->next_record();
+ if ( $this->db->f('grouping_id'))
+ {
+ $grouping_id =
$this->db->f('grouping_id');
+ }
+ else
+ {
+ $this->db->query("SELECT
max(grouping_id) as grouping_id FROM fm_wo_hours where workorder_id=
'$workorder_id'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $grouping_id =
$this->db->f('grouping_id')+1;
+ }
+
+ $grouping_descr =
$hour[$i]['new_grouping'];
+ }
+
+ $values= array(
+ $this->account,
+ $hour[$i]['activity_id'],
+ $hour[$i]['activity_num'],
+ $hour[$i]['hours_descr'],
+ $hour[$i]['unit'],
+ $hour[$i]['cost'],
+ $hour[$i]['quantity'],
+ $hour[$i]['billperae'],
+ $hour[$i]['ns3420_id'],
+ $hour[$i]['dim_d'],
+ $grouping_id,
+ $grouping_descr,
+ $record,
+ $hour[$i]['building_part_id'],
+ $hour[$i]['tolerance_id'],
+ $hour[$i]['remark'],
+ time(),
+ $workorder_id );
+
+ $values =
$this->bocommon->validate_db_insert($values);
+
+ $this->db->query("insert into fm_wo_hours
(owner,activity_id,activity_num,hours_descr,unit,cost,quantity,billperae,ns3420_id,dim_d,"
+ . "
grouping_id,grouping_descr,record,building_part,tolerance,remark,entry_date,workorder_id)
"
+ . " values ($values )",__LINE__,__FILE__);
+
+ $record++;
+ }
+
+ $receipt['message'][] = array('msg'=>lang('the number
of %1 hour is added!',$i));
+
+ return $receipt;
+ }
+
+ function add_custom_hour($hour,$workorder_id)
+ {
+
+ $hour['record'] = $this->next_record($workorder_id);
+
+ if($hour['chapter_id'])
+ {
+ $this->db->query("UPDATE fm_workorder set
+ chapter_id ='" . $hour['chapter_id'] . "'
WHERE id= '$workorder_id'",__LINE__,__FILE__);
+ }
+
+ if($hour['grouping_id'])
+ {
+ $this->db->query("SELECT grouping_descr ,
max(record) as record FROM fm_wo_hours where grouping_id='"
.$hour['grouping_id'] . "' and workorder_id= '$workorder_id' GROUP by
grouping_descr",__LINE__,__FILE__);
+ $this->db->next_record();
+ $hour['grouping_descr'] =
$this->db->f('grouping_descr');
+// $hour['record'] = $this->db->f('record')+1;
+ }
+
+ if($hour['new_grouping'])
+ {
+ $this->db->query("SELECT grouping_id FROM
fm_wo_hours where grouping_descr ='" .$hour['new_grouping'] . "' and
workorder_id= '$workorder_id'",__LINE__,__FILE__);
+ $this->db->next_record();
+ if ( $this->db->f('grouping_id'))
+ {
+ $hour['grouping_id'] =
$this->db->f('grouping_id');
+ }
+ else
+ {
+ $this->db->query("SELECT
max(grouping_id) as grouping_id FROM fm_wo_hours where workorder_id=
'$workorder_id'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $hour['grouping_id'] =
$this->db->f('grouping_id')+1;
+// $hour['record'] = 1;
+ }
+
+ $hour['grouping_descr'] = $hour['new_grouping'];
+ }
+
+ $values= array(
+ $this->account,
+ $hour['descr'],
+ $hour['unit'],
+ $hour['cost'],
+ $hour['quantity'],
+ $hour['billperae'],
+ $hour['ns3420_id'],
+ $hour['dim_d'],
+ $hour['grouping_id'],
+ $hour['grouping_descr'],
+ $hour['record'],
+ $hour['building_part_id'],
+ $hour['tolerance_id'],
+ $hour['remark'],
+ time(),
+ $workorder_id,
+ $hour['wo_hour_cat']
+ );
+
+ $values = $this->bocommon->validate_db_insert($values);
+
+ $this->db->query("insert into fm_wo_hours
(owner,hours_descr,unit,cost,quantity,billperae,ns3420_id,dim_d,"
+ . "
grouping_id,grouping_descr,record,building_part,tolerance,remark,entry_date,workorder_id,category)
"
+ . "VALUES ( $values )",__LINE__,__FILE__);
+
+ $receipt['hour_id'] =
$this->db->get_last_insert_id('fm_wo_hours','id');
+
+ $receipt['message'][] = array('msg'=>lang('hour %1 is
added!',$receipt['hour_id']));
+
+ return $receipt;
+
+ }
+
+ function read_single_hour($hour_id)
+ {
+ $sql = "SELECT * from fm_wo_hours where id='$hour_id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $hour['hour_id']
= $this->db->f('id');
+ $hour['record']
= $this->db->f('record');
+ $hour['activity_id'] =
$this->db->f('activity_id');
+ $hour['activity_num'] =
$this->db->f('activity_num');
+ $hour['grouping_id'] =
$this->db->f('grouping_id');
+ $hour['hours_descr'] =
$this->db->f('hours_descr');
+ $hour['remark']
= $this->db->f('remark');
+ $hour['billperae']
= $this->db->f('billperae');
+ $hour['unit']
= $this->db->f('unit');
+ $hour['ns3420_id']
= $this->db->f('ns3420_id');
+ $hour['tolerance_id'] =
(int)$this->db->f('tolerance');
+ $hour['building_part_id'] =
(int)$this->db->f('building_part');
+ $hour['quantity']
= $this->db->f('quantity');
+ $hour['cost']
= $this->db->f('cost');
+ $hour['dim_d']
= $this->db->f('dim_d');
+ $hour['wo_hour_cat']
= $this->db->f('category');
+ }
+
+ return $hour;
+ }
+
+ function edit($hour,$workorder_id)
+ {
+
+ $hour['descr'] =
$this->db->db_addslashes($hour['descr']);
+ $hour['remark'] =
$this->db->db_addslashes($hour['remark']);
+//_debug_array($hour);
+
+
+ if($hour['chapter_id'])
+ {
+ $this->db->query("UPDATE fm_workorder set
+ chapter_id ='" . $hour['chapter_id'] . "'
WHERE id= '$workorder_id'",__LINE__,__FILE__);
+ }
+
+ if($hour['new_grouping'])
+ {
+ $this->db->query("SELECT grouping_id FROM
fm_wo_hours where grouping_descr ='" .$hour['new_grouping'] . "' and
workorder_id= '$workorder_id'",__LINE__,__FILE__);
+ $this->db->next_record();
+ if ( $this->db->f('grouping_id'))
+ {
+ $hour['grouping_id'] =
$this->db->f('grouping_id');
+ }
+ else
+ {
+
+ $this->db->query("UPDATE fm_wo_hours
set grouping_id = NULL WHERE id ='" .$hour['hour_id'] . "'",__LINE__,__FILE__);
+ $this->db->query("SELECT
count(grouping_id) as num_grouping FROM fm_wo_hours where workorder_id=
'$workorder_id' and grouping_id >0 ",__LINE__,__FILE__);
+ $this->db->next_record();
+ if ($this->db->f('num_grouping')==1)
+ {
+ $hour['grouping_id']=1;
+ }
+ else
+ {
+ $this->db->query("SELECT
max(grouping_id) as grouping_id FROM fm_wo_hours where workorder_id=
'$workorder_id'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $hour['grouping_id'] =
$this->db->f('grouping_id')+1;
+ }
+ }
+ $hour['grouping_descr'] = $hour['new_grouping'];
+ }
+ else
+ {
+ $this->db->query("SELECT
grouping_id,grouping_descr FROM fm_wo_hours where id ='" .$hour['hour_id'] .
"'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $old_grouping_id =
$this->db->f('grouping_id');
+
+ if ( $old_grouping_id == $hour['grouping_id'])
+ {
+
+ $hour['grouping_descr'] =
$this->db->f('grouping_descr');
+ }
+ else
+ {
+ $this->db->query("SELECT grouping_descr
, max(record) as record FROM fm_wo_hours where grouping_id='"
.$hour['grouping_id'] . "' and workorder_id= '$workorder_id' GROUP by
grouping_descr",__LINE__,__FILE__);
+ $this->db->next_record();
+ if($this->db->f('grouping_descr'))
+ {
+ $hour['grouping_descr'] =
$this->db->f('grouping_descr');
+ }
+ else
+ {
+ $hour['grouping_id']='';
+ $hour['grouping_descr']='';
+ }
+
+/* if($old_record>1)
+ {
+ $this->db->query("UPDATE
fm_wo_hours set
+ record = record - 1
where grouping_id='" .$hour['grouping_id'] . "' and workorder_id=
'$workorder_id' and record > $old_record ",__LINE__,__FILE__);
+
+ }
+
+*/
+ }
+ }
+
+ $value_set=array(
+ 'hours_descr' => $hour['descr'],
+ 'remark' =>
$hour['remark'],
+ 'billperae' =>
$hour['billperae'],
+ 'unit' =>
$hour['unit'],
+ 'quantity' =>
$hour['quantity'],
+ 'cost' =>
$hour['cost'],
+ 'ns3420_id' =>
$hour['ns3420_id'],
+ 'tolerance' =>
$hour['tolerance_id'],
+ 'building_part' =>
$hour['building_part_id'],
+ 'dim_d' =>
$hour['dim_d'],
+ 'grouping_id' => $hour['grouping_id'],
+ 'grouping_descr' =>
$hour['grouping_descr'],
+ 'category' => $hour['wo_hour_cat']
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE fm_wo_hours set $value_set
WHERE id= '" . $hour['hour_id'] ."'",__LINE__,__FILE__);
+
+ $receipt['hour_id'] = $hour['hour_id'];
+ $receipt['message'][] = array('msg'=>lang('hour %1 has
been edited',$hour['hour_id']));
+ return $receipt;
+
+ }
+
+ function update_email($to_email,$workorder_id)
+ {
+ $this->db->query("SELECT vendor_id FROM fm_workorder
where id ='$workorder_id'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $vendor_id = $this->db->f('vendor_id');
+
+ $this->db->query("UPDATE fm_vendor set email
='$to_email' where id= '$vendor_id'",__LINE__,__FILE__);
+ }
+
+ function get_email($vendor_id)
+ {
+ $vendor_id=(int)$vendor_id;
+
+ $this->db->query("select column_name from
fm_vendor_attribute WHERE datatype='email'",__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+ $this->db2->query("select " .
$this->db->f('column_name') . " from fm_vendor where
id=$vendor_id",__LINE__,__FILE__);
+ while ($this->db2->next_record())
+ {
+
if($this->db2->f($this->db->f('column_name')))
+ {
+ $email_list[] = array('email'
=> $this->db2->f($this->db->f('column_name')));
+ }
+ }
+ }
+
+ return $email_list;
+ }
+
+ function delete($hour_id,$workorder_id )
+ {
+ $this->db->query("SELECT record FROM fm_wo_hours where
id ='$hour_id'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $old_record = $this->db->f('record');
+
+ $this->db->transaction_begin();
+
+ $this->db->query("DELETE FROM fm_wo_hours WHERE id='" .
$hour_id . "'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_wo_h_deviation WHERE
workorder_id=$workorder_id AND hour_id=$hour_id",__LINE__,__FILE__);
+ if($old_record)
+ {
+ $this->db->query("UPDATE fm_wo_hours set record
= record - 1 where workorder_id= '$workorder_id' and record > $old_record
",__LINE__,__FILE__);
+ }
+
+ $this->db->transaction_commit();
+
+ $receipt['message'][] = array('msg'=>lang('hour %1 has
been deleted',$hour_id));
+ return $receipt;
+
+ }
+
+ function delete_deviation($workorder_id,$hour_id,$id )
+ {
+ $this->db->query("DELETE FROM fm_wo_h_deviation WHERE
workorder_id=$workorder_id AND hour_id=$hour_id AND id=$id",__LINE__,__FILE__);
+ $receipt['message'][] = array('msg'=>lang('deviation %1
has been deleted',$id));
+ return $receipt;
+ }
+
+ function update_calculation($data)
+ {
+ if(is_array($data))
+ {
+ $id =
(isset($data['workorder_id'])?$data['workorder_id']:0);
+ $calculation =
(isset($data['calculation'])?$data['calculation']:0);
+ }
+ $this->db->query("UPDATE fm_workorder set calculation =
$calculation WHERE id=$id",__LINE__,__FILE__);
+ return $receipt;
+ }
+ }
+?>
Index: property/inc/class.soworkorder.inc.php
diff -u property/inc/class.soworkorder.inc.php:1.12
property/inc/class.soworkorder.inc.php:1.13
--- property/inc/class.soworkorder.inc.php:1.12 Wed Oct 12 08:36:17 2005
+++ property/inc/class.soworkorder.inc.php Fri Jan 27 14:05:43 2006
@@ -1,583 +1,582 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage project
- * @version $Id: class.soworkorder.inc.php,v 1.12 2005/10/12 08:36:17
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class soworkorder
- {
-
- function soworkorder()
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->join = $this->bocommon->join;
- $this->left_join = $this->bocommon->left_join;
- $this->like = $this->bocommon->like;
- $this->grants =
$GLOBALS['phpgw']->session->appsession('grants_project',$this->currentapp);
-
- if(!$this->grants)
- {
- $this->acl2 =
CreateObject($this->currentapp.'.acl2','##DEFAULT##','##DEFAULT##');
- $this->grants =
$this->acl2->get_grants($this->currentapp,'.project');
-
$GLOBALS['phpgw']->session->appsession('grants_project',$this->currentapp,$this->grants);
- }
- }
-
- function next_id()
- {
- $this->db->query("select value from fm_idgenerator
where name = 'workorder'");
- $this->db->next_record();
- $id = $this->db->f('value')+1;
- return $id;
- }
-
- function select_category_workorder_list()
- {
-
- $this->db->query("SELECT id, descr FROM
fm_workorder_category ORDER BY descr ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $categories[$i]['id']
= $this->db->f('id');
- $categories[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $categories;
- }
-
- function read_single_project_category($id='')
- {
- $this->db->query("SELECT descr FROM
fm_workorder_category where id='$id' ");
- $this->db->next_record();
- return $this->db->f('descr');
- }
-
- function get_b_account_name($id='')
- {
- $this->db->query("SELECT descr FROM fm_b_account where
id='$id' ");
- $this->db->next_record();
- return $this->db->f('descr');
- }
-
- function select_status_list()
- {
- $this->db->query("SELECT id, descr FROM
fm_workorder_status ORDER BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $status_entries[$i]['id']
= $this->db->f('id');
- $status_entries[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $status_entries;
- }
-
- function select_branch_list()
- {
- $this->db->query("SELECT id, descr FROM fm_branch ORDER
BY id ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $branch_entries[$i]['id']
= $this->db->f('id');
- $branch_entries[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $branch_entries;
- }
-
- function select_key_location_list()
- {
- $this->db->query("SELECT id, descr FROM fm_key_loc
ORDER BY descr ");
-
- $i = 0;
- while ($this->db->next_record())
- {
- $key_location_entries[$i]['id']
= $this->db->f('id');
- $key_location_entries[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
- }
- return $key_location_entries;
- }
-
- function read($data)
- {
-
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $filter =
$data['filter']?$data['filter']:$this->account;
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $status_id =
(isset($data['status_id'])?$data['status_id']:0);
- $search_vendor =
(isset($data['search_vendor'])?$data['search_vendor']:'');
- $start_date =
(isset($data['start_date'])?$data['start_date']:'');
- $end_date =
(isset($data['end_date'])?$data['end_date']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $wo_hour_cat_id =
(isset($data['wo_hour_cat_id'])?$data['wo_hour_cat_id']:'');
- }
-
-//_debug_array($data);
- $sql =
$this->bocommon->fm_cache('sql_workorder'.!!$search_vendor . '_' .
!!$wo_hour_cat_id);
-
- if(!$sql)
- {
- $entity_table = 'fm_project';
-
- $cols .= $entity_table . '.location_code';
- $cols_return[] = 'location_code';
-
- $cols .= ",$entity_table.id as project_id";
- $cols_return[] =
'project_id';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'project_id';
- $uicols['descr'][] =
lang('Project');
- $uicols['statustext'][] = lang('Project
ID');
-
- $cols .= ",fm_workorder.id as workorder_id";
- $cols_return[] =
'workorder_id';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'workorder_id';
- $uicols['descr'][] =
lang('Workorder');
- $uicols['statustext'][] =
lang('Workorder ID');
-
- $cols .= ",fm_workorder.title as title";
- $cols_return[] =
'title';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'title';
- $uicols['descr'][] =
lang('Title');
- $uicols['statustext'][] =
lang('Workorder title');
-
- $cols .= ",fm_workorder.status as status";
- $cols_return[] =
'status';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'status';
- $uicols['descr'][] =
lang('Status');
- $uicols['statustext'][] =
lang('Workorder status');
-
- $cols .= ",fm_workorder.entry_date as
entry_date";
- $cols_return[] =
'entry_date';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'entry_date';
- $uicols['descr'][] =
lang('Entry date');
- $uicols['statustext'][] =
lang('Workorder entry date');
-
- $cols .= ",phpgw_accounts.account_lid as
user_lid";
- $cols_return[] =
'user_lid';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'user_lid';
- $uicols['descr'][] =
lang('User');
- $uicols['statustext'][] =
lang('Workorder User');
-
- $cols .= ',fm_workorder.vendor_id';
- $cols_return[] = 'vendor_id';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'vendor_id';
- $uicols['descr'][] =
lang('Vendor ID');
-
- $cols .= ",fm_project.user_id as project_owner";
-
- $joinmethod .= " $this->join fm_workorder ON
($entity_table.id = fm_workorder.project_id) $this->join phpgw_accounts ON
(fm_workorder.user_id = phpgw_accounts.account_id))";
- $paranthesis .='(';
-
- $cols .= ',fm_vendor.org_name';
- $cols_return[] = 'org_name';
- $uicols['input_type'][] = 'hidden';
- $uicols['name'][] =
'org_name';
- $uicols['descr'][] =
lang('Vendor name');
-
- $joinmethod .= " $this->left_join fm_vendor ON
(fm_workorder.vendor_id = fm_vendor.id))";
- $paranthesis .='(';
-
- //----- wo_hour_status
-
- if($wo_hour_cat_id)
- {
- $joinmethod .= " $this->join
fm_wo_hours ON (fm_workorder.id = fm_wo_hours.workorder_id))";
- $paranthesis .='(';
-
- $joinmethod .= " $this->join
fm_wo_hours_category ON (fm_wo_hours.category = fm_wo_hours_category.id))";
- $paranthesis .='(';
- }
-
- //----- wo_hour_status
-
- $sql =
$this->bocommon->generate_sql(array('entity_table'=>$entity_table,'cols'=>$cols,'cols_return'=>$cols_return,
-
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query));
-
-
-
$this->bocommon->fm_cache('sql_workorder'.!!$search_vendor . '_' .
!!$wo_hour_cat_id,$sql);
-
- $this->uicols =
$this->bocommon->uicols;
- $cols_return =
$this->bocommon->cols_return;
- $type_id =
$this->bocommon->type_id;
-// $this->cols_extra =
$this->bocommon->cols_extra;
-
-
$this->bocommon->fm_cache('uicols_workorder'.!!$search_vendor . '_' .
!!$wo_hour_cat_id,$this->uicols);
-
$this->bocommon->fm_cache('cols_return_workorder'.!!$search_vendor . '_' .
!!$wo_hour_cat_id,$cols_return);
-
$this->bocommon->fm_cache('type_id_workorder'.!!$search_vendor . '_' .
!!$wo_hour_cat_id,$type_id);
-//
$this->bocommon->fm_cache('cols_extra_workorder'.!!$search_vendor . '_' .
!!$wo_hour_cat_id,$this->cols_extra);
-
- }
- else
- {
- $this->uicols =
$this->bocommon->fm_cache('uicols_workorder'.!!$search_vendor . '_' .
!!$wo_hour_cat_id);
- $cols_return =
$this->bocommon->fm_cache('cols_return_workorder'.!!$search_vendor . '_' .
!!$wo_hour_cat_id);
- $type_id =
$this->bocommon->fm_cache('type_id_workorder'.!!$search_vendor . '_' .
!!$wo_hour_cat_id);
-// $this->cols_extra =
$this->bocommon->fm_cache('cols_extra_workorder'.!!$search_vendor . '_' .
!!$wo_hour_cat_id);
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
- }
- else
- {
- $ordermethod = ' order by fm_workorder.id DESC';
- }
-
- $where= 'WHERE';
-
- if ($cat_id > 0)
- {
- $filtermethod .= " $where
fm_project.category=$cat_id ";
- $where= 'AND';
- }
-
- if ($status_id)
- {
- $filtermethod .= " $where
fm_workorder.status='$status_id' ";
- $where= 'AND';
- }
-
- if($wo_hour_cat_id)
- {
- $filtermethod .= " $where
fm_wo_hours_category.id=$wo_hour_cat_id ";
- $where= 'AND';
- $group_method = " group by
fm_project.id,fm_project.location_code,fm_workorder.id,workorder_id,title,fm_workorder.status,fm_workorder.entry_date,user_lid,fm_workorder.vendor_id,project_owner,fm_project.address,fm_vendor.org_name";
- }
-
- if ($filter=='all')
- {
- if (is_array($this->grants))
- {
- $grants = $this->grants;
- while (list($user) = each($grants))
- {
- $public_user_list[] = $user;
- }
- reset($public_user_list);
- $filtermethod .= " $where
(fm_project.access='public' AND fm_project.user_id IN(" .
implode(',',$public_user_list) . "))";
- $where= 'AND';
- }
- }
- else
- {
- $filtermethod .= " $where
fm_workorder.user_id=$filter ";
- $where= 'AND';
- }
-
- if ($start_date)
- {
- $filtermethod .= " $where
fm_workorder.start_date >= $start_date AND fm_workorder.start_date <= $end_date
";
- $where= 'AND';
- }
-
- if($query)
- {
- $query = str_replace(",",'.',$query);
- if(stristr($query, '.'))
- {
- $query=explode(".",$query);
- $querymethod = " $where
(fm_project.loc1='" . $query[0] . "' AND fm_project.loc".$type_id."='" .
$query[1] . "')";
- }
- else
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " $where
(fm_workorder.title $this->like '%$query%' or fm_workorder.descr $this->like
'%$query%' or fm_project.address $this->like '%$query%' or
fm_project.location_code $this->like '%$query%' or fm_workorder.id $this->like
'%$query%')";
- }
- $where= 'AND';
-
- }
-
- if($search_vendor)
- {
- if((int)$search_vendor>0)
- {
- $querymethod_vendor = " $where
fm_workorder.vendor_id=" .(int)$search_vendor ;
- }
- else
- {
- $querymethod_vendor = " $where
fm_vendor.org_name $this->like '%$search_vendor%'";
- }
- }
-
- $sql .= " $filtermethod $querymethod
$querymethod_vendor $group_method";
-//echo $sql;
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- $count_cols_return=count($cols_return);
- $j=0;
- while ($this->db->next_record())
- {
- for ($i=0;$i<$count_cols_return;$i++)
- {
- $workorder_list[$j][$cols_return[$i]] =
$this->db->f($cols_return[$i]);
- $workorder_list[$j]['grants'] =
(int)$this->grants[$this->db->f('project_owner')];
- }
-
- $location_code= $this->db->f('location_code');
- $location = split('-',$location_code);
- $count_location =count($location);
- for ($m=0;$m<$count_location;$m++)
- {
- $workorder_list[$j]['loc' . ($m+1)] =
$location[$m];
-
$workorder_list[$j]['query_location']['loc' . ($m+1)]=implode("-",
array_slice($location, 0, ($m+1)));
- }
-
- $j++;
- }
-
- return $workorder_list;
- }
-
- function read_single($workorder_id)
- {
- $sql = "SELECT fm_workorder.*, fm_chapter.descr as
chapter ,fm_project.user_id from fm_workorder $this->join fm_project on
fm_workorder.project_id=fm_project.id $this->left_join fm_chapter on "
- . " fm_workorder.chapter_id = fm_chapter.id
where fm_workorder.id=$workorder_id";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $workorder['workorder_id'] =
$this->db->f('id');
- $workorder['project_id'] =
$this->db->f('project_id');
- $workorder['title']
= $this->db->f('title');
- $workorder['name']
= $this->db->f('name');
- $workorder['key_fetch'] =
$this->db->f('key_fetch');
- $workorder['key_deliver'] =
$this->db->f('key_deliver');
- $workorder['key_responsible'] =
$this->db->f('key_responsible');
- $workorder['charge_tenant'] =
$this->db->f('charge_tenant');
- $workorder['descr']
= $this->db->f('descr');
- $workorder['status'] =
$this->db->f('status');
- $workorder['budget'] =
(int)$this->db->f('budget');
- $workorder['calculation']
=
($this->db->f('calculation')*(1+$this->db->f('addition')/100))+$this->db->f('rig_addition');
- $workorder['b_account_id']
= (int)$this->db->f('account_id');
- $workorder['addition_percentage'] =
(int)$this->db->f('addition');
- $workorder['addition_rs']
= (int)$this->db->f('rig_addition');
- $workorder['act_mtrl_cost']
= $this->db->f('act_mtrl_cost');
- $workorder['act_vendor_cost'] =
$this->db->f('act_vendor_cost');
- $workorder['user_id']
= $this->db->f('user_id');
- $workorder['vendor_id'] =
$this->db->f('vendor_id');
- $workorder['coordinator'] =
$this->db->f('coordinator');
- $workorder['access'] =
$this->db->f('access');
- $workorder['start_date'] =
$this->db->f('start_date');
- $workorder['end_date'] =
$this->db->f('end_date');
- $workorder['cat_id'] =
$this->db->f('category');
- $workorder['chapter_id'] =
$this->db->f('chapter_id');
- $workorder['chapter'] =
$this->db->f('chapter');
- $workorder['deviation'] =
$this->db->f('deviation');
- $workorder['grants']
= (int)$this->grants[$this->db->f('user_id')];
- }
-
-//_debug_array($workorder);
- return $workorder;
- }
-
-
- function project_budget_from_workorder($project_id = '')
- {
- $this->db->query("select budget, id as workorder_id
from fm_workorder where project_id='$project_id'");
- while ($this->db->next_record())
- {
- $budget[] = array(
- 'workorder_id' =>
$this->db->f('workorder_id'),
- 'budget' =>
sprintf("%01.2f",$this->db->f('budget'))
- );
- }
- return $budget;
- }
-
- function branch_p_list($project_id = '')
- {
-
- $this->db2->query("SELECT branch_id from
fm_projectbranch WHERE project_id='$project_id' ",__LINE__,__FILE__);
- while ($this->db2->next_record())
- {
- $selected[] = array('branch_id' =>
$this->db2->f('branch_id'));
- }
-
- return $selected;
- }
-
- function increment_workorder_id()
- {
- $this->db->query("update fm_idgenerator set value =
value + 1 where name = 'workorder'");
- }
-
- function add($workorder)
- {
- $historylog =
CreateObject($this->currentapp.'.historylog','workorder');
- $workorder['descr'] =
$this->db->db_addslashes($workorder['descr']);
- $workorder['title'] =
$this->db->db_addslashes($workorder['title']);
-
- $values= array(
- $workorder['workorder_id'],
- $workorder['project_id'],
- $workorder['title'],
- 'public',
- time(),
- $workorder['start_date'],
- $workorder['end_date'],
- $workorder['status'],
- $workorder['descr'],
- $workorder['budget'],
- $workorder['b_account_id'],
- $workorder['addition_rs'],
- $workorder['addition_percentage'],
- $workorder['key_deliver'],
- $workorder['key_fetch'],
- $workorder['vendor_id'],
- $workorder['charge_tenant'],
- $this->account);
-
- $values = $this->bocommon->validate_db_insert($values);
-
- $this->db->transaction_begin();
-
- $this->db->query("INSERT INTO fm_workorder
(id,project_id,title,access,entry_date,start_date,end_date,status,"
- .
"descr,budget,account_id,rig_addition,addition,key_deliver,key_fetch,vendor_id,charge_tenant,user_id)
"
- . "VALUES ( $values )",__LINE__,__FILE__);
-
- $this->db->query("INSERT INTO fm_orders (id,type)
VALUES (" . $workorder['workorder_id'] . ",'workorder')");
-
-/*
- if($workorder['charge_tenant'])
- {
- $this->db->query("UPDATE fm_project set
charge_tenant = 1 WHERE id =" . $workorder['project_id']);
- }
-*/
- if($this->db->transaction_commit())
- {
- $this->increment_workorder_id();
-
$historylog->add('SO',$workorder['workorder_id'],$workorder['status']);
- $receipt['message'][] =
array('msg'=>lang('workorder %1 has been saved',$workorder['workorder_id']));
- }
- else
- {
- $receipt['error'][] = array('msg'=>lang('the
workorder has not been saved'));
- }
- return $receipt;
- }
-
- function edit($workorder)
- {
- $historylog =
CreateObject($this->currentapp.'.historylog','workorder');
- $workorder['descr'] =
$this->db->db_addslashes($workorder['descr']);
- $workorder['title'] =
$this->db->db_addslashes($workorder['title']);
-
- $value_set=array(
- 'title' => $workorder['title'],
- 'status' => $workorder['status'],
- 'start_date' => $workorder['start_date'],
- 'end_date' =>
$workorder['end_date'],
- 'descr' => $workorder['descr'],
- 'budget' =>
(int)$workorder['budget'],
- 'key_deliver' => $workorder['key_deliver'],
- 'key_fetch' =>
$workorder['key_fetch'],
- 'account_id' => $workorder['b_account_id'],
- 'rig_addition' => $workorder['addition_rs'],
- 'addition' =>
$workorder['addition_percentage'],
- 'charge_tenant' => $workorder['charge_tenant'],
- 'vendor_id' =>
$workorder['vendor_id']
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("SELECT status,budget FROM
fm_workorder where id='" .$workorder['workorder_id']."'",__LINE__,__FILE__);
- $this->db->next_record();
-
- $old_status = $this->db->f('status');
- $old_budget = $this->db->f('budget');
-
- $this->db->transaction_begin();
-
- $this->db->query("UPDATE fm_workorder set $value_set
WHERE id=" . $workorder['workorder_id'] ,__LINE__,__FILE__);
-
-/* if($workorder['charge_tenant'])
- {
- $this->db->query("UPDATE fm_project set
charge_tenant = 1 WHERE id =" . $workorder['project_id']);
- }
-*/
- if($this->db->transaction_commit())
- {
- if ($old_status != $workorder['status'])
- {
-
$historylog->add('S',$workorder['workorder_id'],$workorder['status']);
- }
- if ($old_budget != $workorder['budget'])
- {
-
$historylog->add('B',$workorder['workorder_id'],$workorder['budget']);
- }
-
- $receipt['message'][] =
array('msg'=>lang('workorder %1 has been edited',$workorder['workorder_id']));
- }
- else
- {
- $receipt['error'][] =
array('msg'=>lang('workorder %1 has not been
edited',$workorder['workorder_id']));
- }
-
- return $receipt;
- }
-
- function delete($workorder_id )
- {
- $this->db->transaction_begin();
- $this->db->query("DELETE FROM fm_workorder WHERE id='"
. $workorder_id . "'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_workorder_history
WHERE history_record_id='" . $workorder_id . "'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_wo_hours WHERE
workorder_id='" . $workorder_id . "'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_orders WHERE id='" .
$workorder_id . "'",__LINE__,__FILE__);
- $this->db->transaction_commit();
-
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage project
+ * @version $Id: class.soworkorder.inc.php,v 1.13 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class soworkorder
+ {
+
+ function soworkorder()
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->db = $this->bocommon->new_db();
+ $this->db2 = $this->bocommon->new_db();
+ $this->join = $this->bocommon->join;
+ $this->left_join = $this->bocommon->left_join;
+ $this->like = $this->bocommon->like;
+ $this->grants =
$GLOBALS['phpgw']->session->appsession('grants_project',$this->currentapp);
+
+ if(!$this->grants)
+ {
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2','##DEFAULT##','##DEFAULT##');
+ $this->grants =
$this->acl2->get_grants($this->currentapp,'.project');
+
$GLOBALS['phpgw']->session->appsession('grants_project',$this->currentapp,$this->grants);
+ }
+ }
+
+ function next_id()
+ {
+ $this->db->query("select value from fm_idgenerator
where name = 'workorder'");
+ $this->db->next_record();
+ $id = $this->db->f('value')+1;
+ return $id;
+ }
+
+ function select_category_workorder_list()
+ {
+
+ $this->db->query("SELECT id, descr FROM
fm_workorder_category ORDER BY descr ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $categories[$i]['id']
= $this->db->f('id');
+ $categories[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $categories;
+ }
+
+ function read_single_project_category($id='')
+ {
+ $this->db->query("SELECT descr FROM
fm_workorder_category where id='$id' ");
+ $this->db->next_record();
+ return $this->db->f('descr');
+ }
+
+ function get_b_account_name($id='')
+ {
+ $this->db->query("SELECT descr FROM fm_b_account where
id='$id' ");
+ $this->db->next_record();
+ return $this->db->f('descr');
+ }
+
+ function select_status_list()
+ {
+ $this->db->query("SELECT id, descr FROM
fm_workorder_status ORDER BY id ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $status_entries[$i]['id']
= $this->db->f('id');
+ $status_entries[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $status_entries;
+ }
+
+ function select_branch_list()
+ {
+ $this->db->query("SELECT id, descr FROM fm_branch ORDER
BY id ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $branch_entries[$i]['id']
= $this->db->f('id');
+ $branch_entries[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $branch_entries;
+ }
+
+ function select_key_location_list()
+ {
+ $this->db->query("SELECT id, descr FROM fm_key_loc
ORDER BY descr ");
+
+ $i = 0;
+ while ($this->db->next_record())
+ {
+ $key_location_entries[$i]['id']
= $this->db->f('id');
+ $key_location_entries[$i]['name']
= stripslashes($this->db->f('descr'));
+ $i++;
+ }
+ return $key_location_entries;
+ }
+
+ function read($data)
+ {
+
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $filter =
$data['filter']?$data['filter']:$this->account;
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $status_id =
(isset($data['status_id'])?$data['status_id']:0);
+ $search_vendor =
(isset($data['search_vendor'])?$data['search_vendor']:'');
+ $start_date =
(isset($data['start_date'])?$data['start_date']:'');
+ $end_date =
(isset($data['end_date'])?$data['end_date']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $wo_hour_cat_id =
(isset($data['wo_hour_cat_id'])?$data['wo_hour_cat_id']:'');
+ }
+
+//_debug_array($data);
+ $sql =
$this->bocommon->fm_cache('sql_workorder'.!!$search_vendor . '_' .
!!$wo_hour_cat_id);
+
+ if(!$sql)
+ {
+ $entity_table = 'fm_project';
+
+ $cols .= $entity_table . '.location_code';
+ $cols_return[] = 'location_code';
+
+ $cols .= ",$entity_table.id as project_id";
+ $cols_return[] =
'project_id';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'project_id';
+ $uicols['descr'][] =
lang('Project');
+ $uicols['statustext'][] = lang('Project
ID');
+
+ $cols .= ",fm_workorder.id as workorder_id";
+ $cols_return[] =
'workorder_id';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'workorder_id';
+ $uicols['descr'][] =
lang('Workorder');
+ $uicols['statustext'][] =
lang('Workorder ID');
+
+ $cols .= ",fm_workorder.title as title";
+ $cols_return[] =
'title';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'title';
+ $uicols['descr'][] =
lang('Title');
+ $uicols['statustext'][] =
lang('Workorder title');
+
+ $cols .= ",fm_workorder.status as status";
+ $cols_return[] =
'status';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'status';
+ $uicols['descr'][] =
lang('Status');
+ $uicols['statustext'][] =
lang('Workorder status');
+
+ $cols .= ",fm_workorder.entry_date as
entry_date";
+ $cols_return[] =
'entry_date';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'entry_date';
+ $uicols['descr'][] =
lang('Entry date');
+ $uicols['statustext'][] =
lang('Workorder entry date');
+
+ $cols .= ",phpgw_accounts.account_lid as
user_lid";
+ $cols_return[] =
'user_lid';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'user_lid';
+ $uicols['descr'][] =
lang('User');
+ $uicols['statustext'][] =
lang('Workorder User');
+
+ $cols .= ',fm_workorder.vendor_id';
+ $cols_return[] = 'vendor_id';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'vendor_id';
+ $uicols['descr'][] =
lang('Vendor ID');
+
+ $cols .= ",fm_project.user_id as project_owner";
+
+ $joinmethod .= " $this->join fm_workorder ON
($entity_table.id = fm_workorder.project_id) $this->join phpgw_accounts ON
(fm_workorder.user_id = phpgw_accounts.account_id))";
+ $paranthesis .='(';
+
+ $cols .= ',fm_vendor.org_name';
+ $cols_return[] = 'org_name';
+ $uicols['input_type'][] = 'hidden';
+ $uicols['name'][] =
'org_name';
+ $uicols['descr'][] =
lang('Vendor name');
+
+ $joinmethod .= " $this->left_join fm_vendor ON
(fm_workorder.vendor_id = fm_vendor.id))";
+ $paranthesis .='(';
+
+ //----- wo_hour_status
+
+ if($wo_hour_cat_id)
+ {
+ $joinmethod .= " $this->join
fm_wo_hours ON (fm_workorder.id = fm_wo_hours.workorder_id))";
+ $paranthesis .='(';
+
+ $joinmethod .= " $this->join
fm_wo_hours_category ON (fm_wo_hours.category = fm_wo_hours_category.id))";
+ $paranthesis .='(';
+ }
+
+ //----- wo_hour_status
+
+ $sql =
$this->bocommon->generate_sql(array('entity_table'=>$entity_table,'cols'=>$cols,'cols_return'=>$cols_return,
+
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query));
+
+
+
$this->bocommon->fm_cache('sql_workorder'.!!$search_vendor . '_' .
!!$wo_hour_cat_id,$sql);
+
+ $this->uicols =
$this->bocommon->uicols;
+ $cols_return =
$this->bocommon->cols_return;
+ $type_id =
$this->bocommon->type_id;
+// $this->cols_extra =
$this->bocommon->cols_extra;
+
+
$this->bocommon->fm_cache('uicols_workorder'.!!$search_vendor . '_' .
!!$wo_hour_cat_id,$this->uicols);
+
$this->bocommon->fm_cache('cols_return_workorder'.!!$search_vendor . '_' .
!!$wo_hour_cat_id,$cols_return);
+
$this->bocommon->fm_cache('type_id_workorder'.!!$search_vendor . '_' .
!!$wo_hour_cat_id,$type_id);
+//
$this->bocommon->fm_cache('cols_extra_workorder'.!!$search_vendor . '_' .
!!$wo_hour_cat_id,$this->cols_extra);
+
+ }
+ else
+ {
+ $this->uicols =
$this->bocommon->fm_cache('uicols_workorder'.!!$search_vendor . '_' .
!!$wo_hour_cat_id);
+ $cols_return =
$this->bocommon->fm_cache('cols_return_workorder'.!!$search_vendor . '_' .
!!$wo_hour_cat_id);
+ $type_id =
$this->bocommon->fm_cache('type_id_workorder'.!!$search_vendor . '_' .
!!$wo_hour_cat_id);
+// $this->cols_extra =
$this->bocommon->fm_cache('cols_extra_workorder'.!!$search_vendor . '_' .
!!$wo_hour_cat_id);
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+ }
+ else
+ {
+ $ordermethod = ' order by fm_workorder.id DESC';
+ }
+
+ $where= 'WHERE';
+
+ if ($cat_id > 0)
+ {
+ $filtermethod .= " $where
fm_project.category=$cat_id ";
+ $where= 'AND';
+ }
+
+ if ($status_id)
+ {
+ $filtermethod .= " $where
fm_workorder.status='$status_id' ";
+ $where= 'AND';
+ }
+
+ if($wo_hour_cat_id)
+ {
+ $filtermethod .= " $where
fm_wo_hours_category.id=$wo_hour_cat_id ";
+ $where= 'AND';
+ $group_method = " group by
fm_project.id,fm_project.location_code,fm_workorder.id,workorder_id,title,fm_workorder.status,fm_workorder.entry_date,user_lid,fm_workorder.vendor_id,project_owner,fm_project.address,fm_vendor.org_name";
+ }
+
+ if ($filter=='all')
+ {
+ if (is_array($this->grants))
+ {
+ $grants = $this->grants;
+ while (list($user) = each($grants))
+ {
+ $public_user_list[] = $user;
+ }
+ reset($public_user_list);
+ $filtermethod .= " $where
(fm_project.access='public' AND fm_project.user_id IN(" .
implode(',',$public_user_list) . "))";
+ $where= 'AND';
+ }
+ }
+ else
+ {
+ $filtermethod .= " $where
fm_workorder.user_id=$filter ";
+ $where= 'AND';
+ }
+
+ if ($start_date)
+ {
+ $filtermethod .= " $where
fm_workorder.start_date >= $start_date AND fm_workorder.start_date <= $end_date
";
+ $where= 'AND';
+ }
+
+ if($query)
+ {
+ $query = str_replace(",",'.',$query);
+ if(stristr($query, '.'))
+ {
+ $query=explode(".",$query);
+ $querymethod = " $where
(fm_project.loc1='" . $query[0] . "' AND fm_project.loc".$type_id."='" .
$query[1] . "')";
+ }
+ else
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " $where
(fm_workorder.title $this->like '%$query%' or fm_workorder.descr $this->like
'%$query%' or fm_project.address $this->like '%$query%' or
fm_project.location_code $this->like '%$query%' or fm_workorder.id $this->like
'%$query%')";
+ }
+ $where= 'AND';
+
+ }
+
+ if($search_vendor)
+ {
+ if((int)$search_vendor>0)
+ {
+ $querymethod_vendor = " $where
fm_workorder.vendor_id=" .(int)$search_vendor ;
+ }
+ else
+ {
+ $querymethod_vendor = " $where
fm_vendor.org_name $this->like '%$search_vendor%'";
+ }
+ }
+
+ $sql .= " $filtermethod $querymethod
$querymethod_vendor $group_method";
+//echo $sql;
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ $count_cols_return=count($cols_return);
+ $j=0;
+ while ($this->db->next_record())
+ {
+ for ($i=0;$i<$count_cols_return;$i++)
+ {
+ $workorder_list[$j][$cols_return[$i]] =
$this->db->f($cols_return[$i]);
+ $workorder_list[$j]['grants'] =
(int)$this->grants[$this->db->f('project_owner')];
+ }
+
+ $location_code= $this->db->f('location_code');
+ $location = split('-',$location_code);
+ $count_location =count($location);
+ for ($m=0;$m<$count_location;$m++)
+ {
+ $workorder_list[$j]['loc' . ($m+1)] =
$location[$m];
+
$workorder_list[$j]['query_location']['loc' . ($m+1)]=implode("-",
array_slice($location, 0, ($m+1)));
+ }
+
+ $j++;
+ }
+
+ return $workorder_list;
+ }
+
+ function read_single($workorder_id)
+ {
+ $sql = "SELECT fm_workorder.*, fm_chapter.descr as
chapter ,fm_project.user_id from fm_workorder $this->join fm_project on
fm_workorder.project_id=fm_project.id $this->left_join fm_chapter on "
+ . " fm_workorder.chapter_id = fm_chapter.id
where fm_workorder.id=$workorder_id";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $workorder['workorder_id'] =
$this->db->f('id');
+ $workorder['project_id'] =
$this->db->f('project_id');
+ $workorder['title']
= $this->db->f('title');
+ $workorder['name']
= $this->db->f('name');
+ $workorder['key_fetch'] =
$this->db->f('key_fetch');
+ $workorder['key_deliver'] =
$this->db->f('key_deliver');
+ $workorder['key_responsible'] =
$this->db->f('key_responsible');
+ $workorder['charge_tenant'] =
$this->db->f('charge_tenant');
+ $workorder['descr']
= $this->db->f('descr');
+ $workorder['status'] =
$this->db->f('status');
+ $workorder['budget'] =
(int)$this->db->f('budget');
+ $workorder['calculation']
=
($this->db->f('calculation')*(1+$this->db->f('addition')/100))+$this->db->f('rig_addition');
+ $workorder['b_account_id']
= (int)$this->db->f('account_id');
+ $workorder['addition_percentage'] =
(int)$this->db->f('addition');
+ $workorder['addition_rs']
= (int)$this->db->f('rig_addition');
+ $workorder['act_mtrl_cost']
= $this->db->f('act_mtrl_cost');
+ $workorder['act_vendor_cost'] =
$this->db->f('act_vendor_cost');
+ $workorder['user_id']
= $this->db->f('user_id');
+ $workorder['vendor_id'] =
$this->db->f('vendor_id');
+ $workorder['coordinator'] =
$this->db->f('coordinator');
+ $workorder['access'] =
$this->db->f('access');
+ $workorder['start_date'] =
$this->db->f('start_date');
+ $workorder['end_date'] =
$this->db->f('end_date');
+ $workorder['cat_id'] =
$this->db->f('category');
+ $workorder['chapter_id'] =
$this->db->f('chapter_id');
+ $workorder['chapter'] =
$this->db->f('chapter');
+ $workorder['deviation'] =
$this->db->f('deviation');
+ $workorder['grants']
= (int)$this->grants[$this->db->f('user_id')];
+ }
+
+//_debug_array($workorder);
+ return $workorder;
+ }
+
+
+ function project_budget_from_workorder($project_id = '')
+ {
+ $this->db->query("select budget, id as workorder_id
from fm_workorder where project_id='$project_id'");
+ while ($this->db->next_record())
+ {
+ $budget[] = array(
+ 'workorder_id' =>
$this->db->f('workorder_id'),
+ 'budget' =>
sprintf("%01.2f",$this->db->f('budget'))
+ );
+ }
+ return $budget;
+ }
+
+ function branch_p_list($project_id = '')
+ {
+
+ $this->db2->query("SELECT branch_id from
fm_projectbranch WHERE project_id='$project_id' ",__LINE__,__FILE__);
+ while ($this->db2->next_record())
+ {
+ $selected[] = array('branch_id' =>
$this->db2->f('branch_id'));
+ }
+
+ return $selected;
+ }
+
+ function increment_workorder_id()
+ {
+ $this->db->query("update fm_idgenerator set value =
value + 1 where name = 'workorder'");
+ }
+
+ function add($workorder)
+ {
+ $historylog =
CreateObject($this->currentapp.'.historylog','workorder');
+ $workorder['descr'] =
$this->db->db_addslashes($workorder['descr']);
+ $workorder['title'] =
$this->db->db_addslashes($workorder['title']);
+
+ $values= array(
+ $workorder['workorder_id'],
+ $workorder['project_id'],
+ $workorder['title'],
+ 'public',
+ time(),
+ $workorder['start_date'],
+ $workorder['end_date'],
+ $workorder['status'],
+ $workorder['descr'],
+ $workorder['budget'],
+ $workorder['b_account_id'],
+ $workorder['addition_rs'],
+ $workorder['addition_percentage'],
+ $workorder['key_deliver'],
+ $workorder['key_fetch'],
+ $workorder['vendor_id'],
+ $workorder['charge_tenant'],
+ $this->account);
+
+ $values = $this->bocommon->validate_db_insert($values);
+
+ $this->db->transaction_begin();
+
+ $this->db->query("INSERT INTO fm_workorder
(id,project_id,title,access,entry_date,start_date,end_date,status,"
+ .
"descr,budget,account_id,rig_addition,addition,key_deliver,key_fetch,vendor_id,charge_tenant,user_id)
"
+ . "VALUES ( $values )",__LINE__,__FILE__);
+
+ $this->db->query("INSERT INTO fm_orders (id,type)
VALUES (" . $workorder['workorder_id'] . ",'workorder')");
+
+/*
+ if($workorder['charge_tenant'])
+ {
+ $this->db->query("UPDATE fm_project set
charge_tenant = 1 WHERE id =" . $workorder['project_id']);
+ }
+*/
+ if($this->db->transaction_commit())
+ {
+ $this->increment_workorder_id();
+
$historylog->add('SO',$workorder['workorder_id'],$workorder['status']);
+ $receipt['message'][] =
array('msg'=>lang('workorder %1 has been saved',$workorder['workorder_id']));
+ }
+ else
+ {
+ $receipt['error'][] = array('msg'=>lang('the
workorder has not been saved'));
+ }
+ return $receipt;
+ }
+
+ function edit($workorder)
+ {
+ $historylog =
CreateObject($this->currentapp.'.historylog','workorder');
+ $workorder['descr'] =
$this->db->db_addslashes($workorder['descr']);
+ $workorder['title'] =
$this->db->db_addslashes($workorder['title']);
+
+ $value_set=array(
+ 'title' => $workorder['title'],
+ 'status' => $workorder['status'],
+ 'start_date' => $workorder['start_date'],
+ 'end_date' =>
$workorder['end_date'],
+ 'descr' => $workorder['descr'],
+ 'budget' =>
(int)$workorder['budget'],
+ 'key_deliver' => $workorder['key_deliver'],
+ 'key_fetch' =>
$workorder['key_fetch'],
+ 'account_id' => $workorder['b_account_id'],
+ 'rig_addition' => $workorder['addition_rs'],
+ 'addition' =>
$workorder['addition_percentage'],
+ 'charge_tenant' => $workorder['charge_tenant'],
+ 'vendor_id' =>
$workorder['vendor_id']
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("SELECT status,budget FROM
fm_workorder where id='" .$workorder['workorder_id']."'",__LINE__,__FILE__);
+ $this->db->next_record();
+
+ $old_status = $this->db->f('status');
+ $old_budget = $this->db->f('budget');
+
+ $this->db->transaction_begin();
+
+ $this->db->query("UPDATE fm_workorder set $value_set
WHERE id=" . $workorder['workorder_id'] ,__LINE__,__FILE__);
+
+/* if($workorder['charge_tenant'])
+ {
+ $this->db->query("UPDATE fm_project set
charge_tenant = 1 WHERE id =" . $workorder['project_id']);
+ }
+*/
+ if($this->db->transaction_commit())
+ {
+ if ($old_status != $workorder['status'])
+ {
+
$historylog->add('S',$workorder['workorder_id'],$workorder['status']);
+ }
+ if ($old_budget != $workorder['budget'])
+ {
+
$historylog->add('B',$workorder['workorder_id'],$workorder['budget']);
+ }
+
+ $receipt['message'][] =
array('msg'=>lang('workorder %1 has been edited',$workorder['workorder_id']));
+ }
+ else
+ {
+ $receipt['error'][] =
array('msg'=>lang('workorder %1 has not been
edited',$workorder['workorder_id']));
+ }
+
+ return $receipt;
+ }
+
+ function delete($workorder_id )
+ {
+ $this->db->transaction_begin();
+ $this->db->query("DELETE FROM fm_workorder WHERE id='"
. $workorder_id . "'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_workorder_history
WHERE history_record_id='" . $workorder_id . "'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_wo_hours WHERE
workorder_id='" . $workorder_id . "'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_orders WHERE id='" .
$workorder_id . "'",__LINE__,__FILE__);
+ $this->db->transaction_commit();
+
+ }
+ }
+?>
Index: property/inc/class.uiXport.inc.php
diff -u property/inc/class.uiXport.inc.php:1.14
property/inc/class.uiXport.inc.php:1.15
--- property/inc/class.uiXport.inc.php:1.14 Wed Jan 25 18:19:12 2006
+++ property/inc/class.uiXport.inc.php Fri Jan 27 14:05:43 2006
@@ -1,697 +1,697 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.uiXport.inc.php,v 1.14 2006/01/25 18:19:12
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uiXport
- {
- var $public_functions = array(
- 'import' => True,
- 'export' => True,
- 'rollback' => True
- );
-
- var $start;
- var $limit;
- var $query;
- var $sort;
- var $order;
- var $filter;
- var $cat_id;
-
- function uiXport()
- {
-
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->bo =
CreateObject($this->currentapp.'.boXport',True);
- $this->invoice =
CreateObject($this->currentapp.'.boinvoice');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
- $this->contacts =
CreateObject($this->currentapp.'.soactor');
- $this->contacts->role = 'vendor';
-
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
- $this->acl2_location = '.invoice';
- $this->acl_read =
$this->acl2->check('.invoice',1);
- $this->acl_add =
$this->acl2->check('.invoice',2);
- $this->acl_edit =
$this->acl2->check('.invoice',4);
- $this->acl_delete =
$this->acl2->check('.invoice',8);
- $this->acl_manage =
$this->acl2->check('.invoice',16);
-
- $this->start = $this->bo->start;
- $this->limit = $this->bo->limit;
- $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->menu->sub ='invoice';
- }
-
- function import()
- {
- if(!$this->acl_add)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
- }
-
- $receipt =
$GLOBALS['phpgw']->session->appsession('session_data','import_receipt');
-
$GLOBALS['phpgw']->session->appsession('session_data','import_receipt','');
-
- $art =
get_var('art',array('POST','GET'));
- $type =
get_var('type',array('POST','GET'));
- $dim_b =
get_var('dim_b',array('POST','GET'));
- $invoice_num =
get_var('invoice_num',array('POST','GET'));
- $kid_nr =
get_var('kid_nr',array('POST','GET'));
- $vendor_id =
get_var('vendor_id',array('POST','GET'));
- $vendor_name =
get_var('vendor_name',array('POST','GET'));
- $janitor =
get_var('janitor',array('POST','GET'));
- $supervisor =
get_var('supervisor',array('POST','GET'));
- $budget_responsible =
get_var('budget_responsible',array('POST','GET'));
- $invoice_date =
urldecode(get_var('invoice_date',array('POST','GET')));
- $num_days =
get_var('num_days',array('POST','GET'));
- $payment_date =
urldecode(get_var('payment_date',array('POST','GET')));
- $cancel =
get_var('cancel',array('POST','GET'));
- $convert =
get_var('convert',array('POST','GET'));
- $conv_type =
get_var('conv_type',array('POST','GET'));
- $sday =
get_var('sday',array('POST','GET'));
- $smonth =
get_var('smonth',array('POST','GET'));
- $syear =
get_var('syear',array('POST','GET'));
- $eday =
get_var('eday',array('POST','GET'));
- $emonth =
get_var('emonth',array('POST','GET'));
- $eyear =
get_var('eyear',array('POST','GET'));
- $download =
get_var('download',array('POST','GET'));
- $auto_tax =
get_var('auto_tax',array('POST','GET'));
-
- $tsvfile = $_FILES['tsvfile']['tmp_name'];
-
- if(!$tsvfile)
- {
- $tsvfile =
get_var('tsvfile',array('POST','GET'));
- }
-
- $links = $this->menu->links('import_inv');
-
- if ($cancel && $tsvfile)
- {
- unlink ($tsvfile);
- }
-
- if ($convert)
- {
- unset($receipt);
-
- if ($conv_type=='')
- {
- $receipt['error'][] =
array('msg'=>lang('Please - select a import format !'));
- }
-
- if (!$tsvfile)
- {
- $receipt['error'][] =
array('msg'=>lang('Please - select a file to import from !'));
- }
-
- if (!$art)
- {
- $receipt['error'][] =
array('msg'=>lang('Please - select type invoice!'));
- }
- if (!$vendor_id)
- {
- $receipt['error'][] =
array('msg'=>lang('Please - select Vendor!'));
- }
-
- if (!$type)
- {
- $receipt['error'][] =
array('msg'=>lang('Please - select type order!'));
- }
-
- if (!$budget_responsible)
- {
- $receipt['error'][] =
array('msg'=>lang('Please - select budget responsible!'));
- }
-
- if (!$this->invoice->check_vendor($vendor_id))
- {
- $receipt['error'][] =
array('msg'=>lang('That Vendor ID is not valid !'). ' : ' . $vendor_id);
- }
-
- if (!$payment_date && !$num_days)
- {
- $receipt['error'][] =
array('msg'=>lang('Please - select either payment date or number of days from
invoice date !'));
- }
-
- if (!file_exists($tsvfile))
- {
- $receipt['error'][] =
array('msg'=>lang('The file is empty or removed!'));
- }
- if (!is_array($receipt['error']))
- {
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $dateformat =
str_replace(".","",$dateformat);
- $dateformat =
str_replace("-","",$dateformat);
- $dateformat =
str_replace("/","",$dateformat);
- $y=strpos($dateformat,'y');
- $d=strpos($dateformat,'d');
- $m=strpos($dateformat,'m');
-
- if($invoice_date)
- {
- $dateparts = explode('/',
$invoice_date);
- $sday = $dateparts[$d];
- $smonth = $dateparts[$m];
- $syear = $dateparts[$y];
-
- $dateparts = explode('/',
$payment_date);
- $eday = $dateparts[$d];
- $emonth = $dateparts[$m];
- $eyear = $dateparts[$y];
- }
-
- $old = $tsvfile;
- $tsvfile =
$GLOBALS['phpgw_info']['server']['temp_dir'].'/invoice_import_'.basename($tsvfile);
- rename($old,$tsvfile);
-
- $invoice_common=array(
- 'bilagsnr'
=> $this->invoice->next_bilagsnr(),
- 'art'
=> $art,
- 'type'
=> $type,
- 'dim_b'
=> $dim_b,
- 'invoice_num'
=> $invoice_num,
- 'kid_nr'
=> $kid_nr,
- 'vendor_id'
=> $vendor_id,
- 'vendor_name'
=> $vendor_name,
- 'janitor'
=> $janitor,
- 'supervisor'
=> $supervisor,
-
'budget_responsible' => $budget_responsible,
- 'num_days'
=> $num_days,
- 'sday'
=> $sday,
- 'smonth'
=> $smonth,
- 'syear'
=> $syear,
- 'eday'
=> $eday,
- 'emonth'
=> $emonth,
- 'eyear'
=> $eyear,
- 'tsvfile'
=> $tsvfile,
- 'conv_type'
=> $conv_type,
- 'invoice_date'
=> $invoice_date,
- 'payment_date'
=> $payment_date,
- 'auto_tax'
=> $auto_tax
- );
-
- $buffer =
$this->bo->import($invoice_common,$download);
-
- if(!$download)
- {
- $receipt = $buffer;
-
$GLOBALS['phpgw']->session->appsession('session_data','import_receipt',$receipt);
- unlink ($tsvfile);
- unset($invoice_common);
- unset($art);
- unset($type);
- unset($dim_b);
- unset($invoice_num);
- unset($kid_nr);
- unset($vendor_id);
- unset($vendor_name);
- unset($janitor);
- unset($supervisor);
- unset($budget_responsible);
- unset($invoice_date);
- unset($num_days);
- unset($payment_date);
- unset($conv_type);
- unset($auto_tax);
-//
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiXport.import');
- }
- else
- {
-
$this->debug_import($buffer,$invoice_common);
- return;
- }
- }
- }
-
-
- set_time_limit(0);
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiXport.import',
- 'sub' => $sub
- );
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'links'
=> $links,
-
- 'jsDateFormat'
=> $jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle'
=> lang('Select date'),
- 'calendar_setup_invoice'
=> "Calendar.setup({inputField : 'invoice_date',ifFormat : '" . $jsDateFormat
. "',button : 'invoice_date-trigger'});",
- 'calendar_setup_payment'
=> "Calendar.setup({inputField : 'payment_date',ifFormat : '" . $jsDateFormat
. "',button : 'payment_date-trigger'});",
-
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'cancel_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.index&sub='.$sub),
- 'lang_cancel'
=> lang('Cancel'),
- 'lang_cancel_statustext' =>
lang('cancel the import'),
- 'action_url'
=> $GLOBALS['phpgw']->link('/index.php','menuaction='. $this->currentapp
.'.uiXport.import'),
- 'tsvfilename'
=> '',
-
- 'lang_debug'
=> lang('Debug output in browser'),
- 'lang_debug_statustext' =>
lang('Check this to have the output to screen before import (recommended)'),
- 'value_debug'
=> $download,
-
- 'lang_import'
=> lang('Import'),
- 'lang_import_statustext' =>
lang('Klick this button to start the import'),
-
- 'lang_invoice_date'
=> lang('invoice date'),
- 'lang_payment_date'
=> lang('Payment date'),
- 'lang_no_of_days'
=> lang('Days'),
- 'lang_invoice_number' =>
lang('Invoice Number'),
- 'lang_invoice_num_statustext' => lang('Enter
Invoice Number'),
-
-
- 'lang_select'
=> lang('Select per button !'),
- 'lang_kidnr'
=> lang('KID nr'),
- 'lang_kid_nr_statustext' =>
lang('Enter Kid nr'),
-
-
- 'lang_vendor'
=> lang('Vendor'),
- 'addressbook_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor'),
-
- 'lang_invoice_date_statustext' => lang('Enter
the invoice date'),
- 'lang_num_days_statustext' =>
lang('Enter the payment date or the payment delay'),
- 'lang_payment_date_statustext' => lang('Enter
the payment date or the payment delay'),
- 'lang_file_statustext' =>
lang('Select the file to import from'),
- 'lang_vendor_statustext'
=> lang('Select the vendor by klicking the button'),
- 'lang_vendor_name_statustext' => lang('Select
the vendor by klicking the button'),
- 'lang_select_vendor_statustext' => lang('Select
the vendor by klicking this button'),
-
-
- 'value_invoice_date' =>
$invoice_date,
- 'value_payment_date' =>
$payment_date,
- 'value_belop'
=> $belop,
- 'value_vendor_id'
=> $vendor_id,
- 'value_vendor_name'
=> $vendor_name,
- 'value_kid_nr'
=> $kid_nr,
- 'value_dim_b'
=> $dim_b,
- 'value_invoice_num'
=> $invoice_num,
- 'value_merknad'
=> $merknad,
- 'value_num_days'
=> $num_days,
-// 'value_tsvfile'
=> $tsvfile,
-
- 'lang_file'
=> lang('File'),
- 'lang_conv'
=> lang('Conversion'),
- 'conv_list'
=> $this->bo->select_import_conv($conv_type),
- 'select_conv'
=> 'conv_type',
- 'lang_select_conversion' =>
lang('Select the type of conversion:'),
- 'lang_conv_statustext' =>
lang('You have to select the Conversion for this import'),
-
- 'lang_auto_tax'
=> lang('Auto TAX'),
- 'lang_auto_tax_statustext' =>
lang('Set tax during import'),
-
- 'lang_art'
=> lang('Art'),
- 'art_list'
=> $this->invoice->get_lisfm_ecoart($art),
- 'select_art'
=> 'art',
- 'lang_select_art'
=> lang('Select Invoice Type'),
- 'lang_art_statustext' =>
lang('You have to select type of invoice'),
-
- 'lang_type'
=> lang('Type invoice II'),
- 'type_list'
=> $this->invoice->get_type_list($type),
- 'select_type'
=> 'type',
- 'lang_no_type'
=> lang('No type'),
- 'lang_type_statustext' =>
lang('Select the type invoice. To do not use type - select NO TYPE'),
-
- 'lang_dimb'
=> lang('Dim B'),
- 'dimb_list'
=> $this->invoice->select_dimb_list($dim_b),
- 'select_dimb'
=> 'dim_b',
- 'lang_no_dimb'
=> lang('No Dim B'),
- 'lang_dimb_statustext' =>
lang('Select the Dim B for this invoice. To do not use Dim B - select NO DIM
B'),
-
- 'lang_janitor'
=> lang('Janitor'),
- 'janitor_list'
=> $this->bocommon->get_user_list_right(32,$janitor,'.invoice'),
- 'select_janitor'
=> 'janitor',
- 'lang_no_janitor'
=> lang('No janitor'),
- 'lang_janitor_statustext' =>
lang('Select the janitor responsible for this invoice. To do not use janitor -
select NO JANITOR'),
-
- 'lang_supervisor'
=> lang('Supervisor'),
- 'supervisor_list'
=> $this->bocommon->get_user_list_right(64,$supervisor,'.invoice'),
- 'select_supervisor'
=> 'supervisor',
- 'lang_no_supervisor' =>
lang('No supervisor'),
- 'lang_supervisor_statustext' =>
lang('Select the supervisor responsible for this invoice. To do not use
supervisor - select NO SUPERVISOR'),
-
- 'lang_budget_responsible' =>
lang('B - responsible'),
- 'budget_responsible_list' =>
$this->bocommon->get_user_list_right(128,$budget_responsible,'.invoice'),
- 'select_budget_responsible' =>
'budget_responsible',
- 'lang_select_budget_responsible'=> lang('Select
B-Responsible'),
- 'lang_budget_responsible_statustext'
=> lang('You have to select a budget responsible for this invoice in order to
make the import')
- );
-
-//_debug_array($data);
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('invoice','menu'));
-
- $appname
= lang('Invoice');
- $function_msg =
lang('Import from CSV');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('import' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function debug_import($buffer='',$invoice_common='')
- {
- $table = $buffer['table'];
- $header = $buffer['header'];
- $import = $buffer['import'];
-
- $sum=0;
-
- $import_count = count($import);
- $table_count = count($table)+1;
- for ($i=1; $i<$table_count; $i++)
- {
- for ($k=0; $k<$import_count; $k++)
- {
- $content[$i]['row'][$k]['value']
= $table[$i][$import[$header[$k]]];
- if ($import[$header[$k]]=='belop')
- {
-
$content[$i]['row'][$k]['align'] = 'right';
-
$sum=$sum+$table[$i][$import[$header[$k]]];
-
$content[$i]['row'][$k]['value'] =
number_format($table[$i][$import[$header[$k]]], 2, ',', '');
- }
- }
- }
-
- for ($k=0; $k<count($header); $k++)
- {
- $table_header[$k]['header'] = $header[$k];
- $table_header[$k]['width'] = '5%';
- $table_header[$k]['align'] =
'center';
- }
-
-
- $link_data_add = array
- (
- 'menuaction' =>
$this->currentapp.'.uiXport.import',
- 'convert' => 'true'
- );
-
- $link_data_cancel = array
- (
- 'menuaction' =>
$this->currentapp.'.uiXport.import',
- 'cancel' => True
-
- );
-
- $link_data_add = $link_data_add +
$invoice_common;
- $link_data_cancel = $link_data_cancel
+ $invoice_common;
-
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('Import'),
- 'lang_add_statustext' => lang('Import this
invoice'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data_add),
- 'lang_cancel' =>
lang('cancel'),
- 'lang_cancel_statustext'=> lang('Do not import
this invoice'),
- 'cancel_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data_cancel)
-
- );
-
- $vendor =
$this->contacts->read_single(array('actor_id'=>$table[1]['spvend_code']));
- if(is_array($vendor))
- {
- foreach($vendor['attributes'] as $attribute)
- {
- if($attribute['name']=='org_name')
- {
-
$vendor_name=$attribute['value'];
- break;
- }
- }
- }
-
- $data = array
- (
- 'artid'
=> $table[1]['artid'],
- 'lang_type'
=> lang('Type'),
- 'artid'
=> $table[1]['artid'],
- 'lang_bilagsnr'
=> lang('bilagsnr'),
- 'bilagsnr'
=> $table[1]['bilagsnr'],
- 'lang_vendor'
=> lang('Vendor'),
- 'vendor_name'
=> $vendor_name,
- 'spvend_code'
=> $table[1]['spvend_code'],
- 'lang_fakturadato'
=> lang('invoice date'),
- 'fakturadato'
=> $table[1]['fakturadato'],
- 'lang_forfallsdato'
=> lang('Payment date'),
- 'forfallsdato'
=> $table[1]['forfallsdato'],
- 'lang_janitor'
=> lang('Janitor'),
- 'oppsynsmannid'
=> $table[1]['oppsynsmannid'],
- 'lang_supervisor'
=> lang('Supervisor'),
- 'saksbehandlerid'
=> $table[1]['saksbehandlerid'],
- 'lang_budget_responsible' =>
lang('Budget Responsible'),
- 'budsjettansvarligid' =>
$table[1]['budsjettansvarligid'],
- 'lang_sum'
=> lang('Sum'),
- 'sum'
=> number_format($sum, 2, ',', ''),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
-
- unset($content);
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('invoice','table_header'));
- $appname
= lang('Invoice');
- $function_msg =
lang('Debug');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('debug' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function export()
- {
- if(!$this->acl_manage)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=16&acl_location='
. $this->acl2_location);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('invoice','menu',
-
'search_field'));
-
- $values = get_var('values',array('POST','GET'));
- $date = get_var('date',array('POST','GET'));
-
- $links = $this->menu->links('export_inv');
-
- if($values['submit'])
- {
- if (!$values['conv_type'] && !$values['file'] ):
- {
-
- $receipt['error'][] = array('msg'=>
lang('No conversion type could be located.') . ' - ' . lang('Please choose a
conversion type from the list'));
- }
- elseif($values['conv_type'] &&
!$values['file']):
- {
- $receipt =
$this->bo->export(array('conv_type'=>$values['conv_type'],'download'=>$values['download'],'force_period_year'=>$values['force_period_year']));
- if(!$values['download'])
- {
-
$GLOBALS['phpgw_info']['flags'][noheader] = True;
-
$GLOBALS['phpgw_info']['flags'][nofooter] = True;
-
$GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
-
$GLOBALS['phpgw_info']['flags']['noframework'] = True;
- echo '<pre>' .
$receipt['message'][0]['msg'] . '</pre>';
- echo ' <a
href="'.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiXport.export')
. '">' . lang('Back') . '</a>';
- }
- }
- endif;
- }
- else
- {
- $date =
$GLOBALS['phpgw']->common->show_date(mktime(0,0,0,date("m"),date("d"),date("Y")),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- }
-//_debug_array($receipt);
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiXport.export',
- 'invoice_id' => $invoice_id,
- 'sub' => $sub);
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $force_period_year= array(
- 'id' => date(Y) -1
- );
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'force_period_year'
=> $force_period_year,
- 'lang_force_period_year' =>
lang('Force year for period'),
- 'lang_force_period_year_statustext'
=> lang('Force year for period'),
- 'lang_select_year'
=> lang('select year'),
- 'links'
=> $links,
- 'lang_select_conv'
=> lang('Select conversion'),
- 'conv_list'
=> $this->bo->select_export_conv($values['conv_type']),
- 'select_conv'
=> 'values[conv_type]',
- 'lang_conv_statustext' =>
lang('Select conversion'),
-
- 'lang_rollback_file' =>
lang('Roll back'),
- 'link_rollback_file' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiXport.rollback'),
-
- 'lang_export_to_file' =>
lang('Export to file'),
- 'value_debug'
=> $values['debug'],
- 'lang_debug_statustext' =>
lang('Uncheck to debug the result'),
-
- 'lang_submit'
=> lang('Submit'),
- 'lang_cancel'
=> lang('Cancel'),
-
- 'message'
=> $message,
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_save'
=> lang('save')
- );
-
-//_debug_array($data);
- $appname
= lang('Invoice');
- $function_msg =
lang('Export invoice');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('export' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function rollback()
- {
- if(!$this->acl_manage)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=16&acl_location='
. $this->acl2_location);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('invoice','menu',
-
'search_field'));
-
- $values = get_var('values',array('POST','GET'));
- $date = get_var('date',array('POST','GET'));
-//_debug_array($values);
-
- $links = $this->menu->links('export_inv');
-
- if($values['submit'])
- {
- if (!$values['conv_type'])
- {
- $receipt['error'][] = array('msg'=>
lang('No conversion type could be located.') .' - ' . lang('Please choose a
conversion type from the list'));
- }
-
- if(!$values['file'])
- {
- $receipt['error'][] =
array('msg'=>lang('Please choose a file'));
- }
-
- if(!$receipt['error'])
- {
- $receipt =
$this->bo->rollback($values['conv_type'],$values['file'],$date);
- }
- }
- else
- {
- $date =
$GLOBALS['phpgw']->common->show_date(mktime(0,0,0,date("m"),date("d"),date("Y")),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- }
-
- $link_data = array('menuaction' =>
$this->currentapp.'.uiXport.rollback');
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
-//_debug_array($receipt);
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'links'
=> $links,
-
- 'jsDateFormat'
=> $jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle'
=> lang('Select date'),
- 'calendar_setup'
=> "Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat .
"',button : 'date-trigger'});",
-
- 'lang_select_conv'
=> lang('Select conversion'),
- 'conv_list'
=> $this->bo->select_export_conv($values['conv_type']),
- 'select_conv'
=> 'values[conv_type]',
- 'lang_conv_statustext' =>
lang('Select conversion'),
-
- 'lang_select_file'
=> lang('Select file to roll back'),
- 'lang_no_file'
=> lang('No file selected'),
- 'lang_file_statustext' =>
lang('Select file to roll back'),
- 'select_file'
=> 'values[file]',
-
- 'rollback_file_list' =>
$this->bo->select_rollback_file($values['file']),
- 'lang_export_to_file' =>
lang('Export to file'),
- 'value_debug'
=> $values['debug'],
-
- 'value_date'
=> $date,
- 'lang_date'
=> lang('Export date'),
- 'lang_date_statustext' =>
lang('Select date for the file to roll back'),
-
- 'lang_submit'
=> lang('Submit'),
- 'lang_cancel'
=> lang('Cancel'),
-
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_save'
=> lang('save')
- );
-
-//_debug_array($data);
-
- $appname
= lang('Invoice');
- $function_msg =
lang('Rollback invoice');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('rollback' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.uiXport.inc.php,v 1.15 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uiXport
+ {
+ var $public_functions = array(
+ 'import' => True,
+ 'export' => True,
+ 'rollback' => True
+ );
+
+ var $start;
+ var $limit;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+ var $cat_id;
+
+ function uiXport()
+ {
+
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->bo =
CreateObject($this->currentapp.'.boXport',True);
+ $this->invoice =
CreateObject($this->currentapp.'.boinvoice');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+ $this->contacts =
CreateObject($this->currentapp.'.soactor');
+ $this->contacts->role = 'vendor';
+
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+ $this->acl2_location = '.invoice';
+ $this->acl_read =
$this->acl2->check('.invoice',1);
+ $this->acl_add =
$this->acl2->check('.invoice',2);
+ $this->acl_edit =
$this->acl2->check('.invoice',4);
+ $this->acl_delete =
$this->acl2->check('.invoice',8);
+ $this->acl_manage =
$this->acl2->check('.invoice',16);
+
+ $this->start = $this->bo->start;
+ $this->limit = $this->bo->limit;
+ $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->menu->sub ='invoice';
+ }
+
+ function import()
+ {
+ if(!$this->acl_add)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
+ }
+
+ $receipt =
$GLOBALS['phpgw']->session->appsession('session_data','import_receipt');
+
$GLOBALS['phpgw']->session->appsession('session_data','import_receipt','');
+
+ $art =
get_var('art',array('POST','GET'));
+ $type =
get_var('type',array('POST','GET'));
+ $dim_b =
get_var('dim_b',array('POST','GET'));
+ $invoice_num =
get_var('invoice_num',array('POST','GET'));
+ $kid_nr =
get_var('kid_nr',array('POST','GET'));
+ $vendor_id =
get_var('vendor_id',array('POST','GET'));
+ $vendor_name =
get_var('vendor_name',array('POST','GET'));
+ $janitor =
get_var('janitor',array('POST','GET'));
+ $supervisor =
get_var('supervisor',array('POST','GET'));
+ $budget_responsible =
get_var('budget_responsible',array('POST','GET'));
+ $invoice_date =
urldecode(get_var('invoice_date',array('POST','GET')));
+ $num_days =
get_var('num_days',array('POST','GET'));
+ $payment_date =
urldecode(get_var('payment_date',array('POST','GET')));
+ $cancel =
get_var('cancel',array('POST','GET'));
+ $convert =
get_var('convert',array('POST','GET'));
+ $conv_type =
get_var('conv_type',array('POST','GET'));
+ $sday =
get_var('sday',array('POST','GET'));
+ $smonth =
get_var('smonth',array('POST','GET'));
+ $syear =
get_var('syear',array('POST','GET'));
+ $eday =
get_var('eday',array('POST','GET'));
+ $emonth =
get_var('emonth',array('POST','GET'));
+ $eyear =
get_var('eyear',array('POST','GET'));
+ $download =
get_var('download',array('POST','GET'));
+ $auto_tax =
get_var('auto_tax',array('POST','GET'));
+
+ $tsvfile = $_FILES['tsvfile']['tmp_name'];
+
+ if(!$tsvfile)
+ {
+ $tsvfile =
get_var('tsvfile',array('POST','GET'));
+ }
+
+ $links = $this->menu->links('import_inv');
+
+ if ($cancel && $tsvfile)
+ {
+ unlink ($tsvfile);
+ }
+
+ if ($convert)
+ {
+ unset($receipt);
+
+ if ($conv_type=='')
+ {
+ $receipt['error'][] =
array('msg'=>lang('Please - select a import format !'));
+ }
+
+ if (!$tsvfile)
+ {
+ $receipt['error'][] =
array('msg'=>lang('Please - select a file to import from !'));
+ }
+
+ if (!$art)
+ {
+ $receipt['error'][] =
array('msg'=>lang('Please - select type invoice!'));
+ }
+ if (!$vendor_id)
+ {
+ $receipt['error'][] =
array('msg'=>lang('Please - select Vendor!'));
+ }
+
+ if (!$type)
+ {
+ $receipt['error'][] =
array('msg'=>lang('Please - select type order!'));
+ }
+
+ if (!$budget_responsible)
+ {
+ $receipt['error'][] =
array('msg'=>lang('Please - select budget responsible!'));
+ }
+
+ if (!$this->invoice->check_vendor($vendor_id))
+ {
+ $receipt['error'][] =
array('msg'=>lang('That Vendor ID is not valid !'). ' : ' . $vendor_id);
+ }
+
+ if (!$payment_date && !$num_days)
+ {
+ $receipt['error'][] =
array('msg'=>lang('Please - select either payment date or number of days from
invoice date !'));
+ }
+
+ if (!file_exists($tsvfile))
+ {
+ $receipt['error'][] =
array('msg'=>lang('The file is empty or removed!'));
+ }
+ if (!is_array($receipt['error']))
+ {
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $dateformat =
str_replace(".","",$dateformat);
+ $dateformat =
str_replace("-","",$dateformat);
+ $dateformat =
str_replace("/","",$dateformat);
+ $y=strpos($dateformat,'y');
+ $d=strpos($dateformat,'d');
+ $m=strpos($dateformat,'m');
+
+ if($invoice_date)
+ {
+ $dateparts = explode('/',
$invoice_date);
+ $sday = $dateparts[$d];
+ $smonth = $dateparts[$m];
+ $syear = $dateparts[$y];
+
+ $dateparts = explode('/',
$payment_date);
+ $eday = $dateparts[$d];
+ $emonth = $dateparts[$m];
+ $eyear = $dateparts[$y];
+ }
+
+ $old = $tsvfile;
+ $tsvfile =
$GLOBALS['phpgw_info']['server']['temp_dir'].'/invoice_import_'.basename($tsvfile);
+ rename($old,$tsvfile);
+
+ $invoice_common=array(
+ 'bilagsnr'
=> $this->invoice->next_bilagsnr(),
+ 'art'
=> $art,
+ 'type'
=> $type,
+ 'dim_b'
=> $dim_b,
+ 'invoice_num'
=> $invoice_num,
+ 'kid_nr'
=> $kid_nr,
+ 'vendor_id'
=> $vendor_id,
+ 'vendor_name'
=> $vendor_name,
+ 'janitor'
=> $janitor,
+ 'supervisor'
=> $supervisor,
+
'budget_responsible' => $budget_responsible,
+ 'num_days'
=> $num_days,
+ 'sday'
=> $sday,
+ 'smonth'
=> $smonth,
+ 'syear'
=> $syear,
+ 'eday'
=> $eday,
+ 'emonth'
=> $emonth,
+ 'eyear'
=> $eyear,
+ 'tsvfile'
=> $tsvfile,
+ 'conv_type'
=> $conv_type,
+ 'invoice_date'
=> $invoice_date,
+ 'payment_date'
=> $payment_date,
+ 'auto_tax'
=> $auto_tax
+ );
+
+ $buffer =
$this->bo->import($invoice_common,$download);
+
+ if(!$download)
+ {
+ $receipt = $buffer;
+
$GLOBALS['phpgw']->session->appsession('session_data','import_receipt',$receipt);
+ unlink ($tsvfile);
+ unset($invoice_common);
+ unset($art);
+ unset($type);
+ unset($dim_b);
+ unset($invoice_num);
+ unset($kid_nr);
+ unset($vendor_id);
+ unset($vendor_name);
+ unset($janitor);
+ unset($supervisor);
+ unset($budget_responsible);
+ unset($invoice_date);
+ unset($num_days);
+ unset($payment_date);
+ unset($conv_type);
+ unset($auto_tax);
+//
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiXport.import');
+ }
+ else
+ {
+
$this->debug_import($buffer,$invoice_common);
+ return;
+ }
+ }
+ }
+
+
+ set_time_limit(0);
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiXport.import',
+ 'sub' => $sub
+ );
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'links'
=> $links,
+
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle'
=> lang('Select date'),
+ 'calendar_setup_invoice'
=> "Calendar.setup({inputField : 'invoice_date',ifFormat : '" . $jsDateFormat
. "',button : 'invoice_date-trigger'});",
+ 'calendar_setup_payment'
=> "Calendar.setup({inputField : 'payment_date',ifFormat : '" . $jsDateFormat
. "',button : 'payment_date-trigger'});",
+
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'cancel_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.index&sub='.$sub),
+ 'lang_cancel'
=> lang('Cancel'),
+ 'lang_cancel_statustext' =>
lang('cancel the import'),
+ 'action_url'
=> $GLOBALS['phpgw']->link('/index.php','menuaction='. $this->currentapp
.'.uiXport.import'),
+ 'tsvfilename'
=> '',
+
+ 'lang_debug'
=> lang('Debug output in browser'),
+ 'lang_debug_statustext' =>
lang('Check this to have the output to screen before import (recommended)'),
+ 'value_debug'
=> $download,
+
+ 'lang_import'
=> lang('Import'),
+ 'lang_import_statustext' =>
lang('Klick this button to start the import'),
+
+ 'lang_invoice_date'
=> lang('invoice date'),
+ 'lang_payment_date'
=> lang('Payment date'),
+ 'lang_no_of_days'
=> lang('Days'),
+ 'lang_invoice_number' =>
lang('Invoice Number'),
+ 'lang_invoice_num_statustext' => lang('Enter
Invoice Number'),
+
+
+ 'lang_select'
=> lang('Select per button !'),
+ 'lang_kidnr'
=> lang('KID nr'),
+ 'lang_kid_nr_statustext' =>
lang('Enter Kid nr'),
+
+
+ 'lang_vendor'
=> lang('Vendor'),
+ 'addressbook_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor'),
+
+ 'lang_invoice_date_statustext' => lang('Enter
the invoice date'),
+ 'lang_num_days_statustext' =>
lang('Enter the payment date or the payment delay'),
+ 'lang_payment_date_statustext' => lang('Enter
the payment date or the payment delay'),
+ 'lang_file_statustext' =>
lang('Select the file to import from'),
+ 'lang_vendor_statustext'
=> lang('Select the vendor by klicking the button'),
+ 'lang_vendor_name_statustext' => lang('Select
the vendor by klicking the button'),
+ 'lang_select_vendor_statustext' => lang('Select
the vendor by klicking this button'),
+
+
+ 'value_invoice_date' =>
$invoice_date,
+ 'value_payment_date' =>
$payment_date,
+ 'value_belop'
=> $belop,
+ 'value_vendor_id'
=> $vendor_id,
+ 'value_vendor_name'
=> $vendor_name,
+ 'value_kid_nr'
=> $kid_nr,
+ 'value_dim_b'
=> $dim_b,
+ 'value_invoice_num'
=> $invoice_num,
+ 'value_merknad'
=> $merknad,
+ 'value_num_days'
=> $num_days,
+// 'value_tsvfile'
=> $tsvfile,
+
+ 'lang_file'
=> lang('File'),
+ 'lang_conv'
=> lang('Conversion'),
+ 'conv_list'
=> $this->bo->select_import_conv($conv_type),
+ 'select_conv'
=> 'conv_type',
+ 'lang_select_conversion' =>
lang('Select the type of conversion:'),
+ 'lang_conv_statustext' =>
lang('You have to select the Conversion for this import'),
+
+ 'lang_auto_tax'
=> lang('Auto TAX'),
+ 'lang_auto_tax_statustext' =>
lang('Set tax during import'),
+
+ 'lang_art'
=> lang('Art'),
+ 'art_list'
=> $this->invoice->get_lisfm_ecoart($art),
+ 'select_art'
=> 'art',
+ 'lang_select_art'
=> lang('Select Invoice Type'),
+ 'lang_art_statustext' =>
lang('You have to select type of invoice'),
+
+ 'lang_type'
=> lang('Type invoice II'),
+ 'type_list'
=> $this->invoice->get_type_list($type),
+ 'select_type'
=> 'type',
+ 'lang_no_type'
=> lang('No type'),
+ 'lang_type_statustext' =>
lang('Select the type invoice. To do not use type - select NO TYPE'),
+
+ 'lang_dimb'
=> lang('Dim B'),
+ 'dimb_list'
=> $this->invoice->select_dimb_list($dim_b),
+ 'select_dimb'
=> 'dim_b',
+ 'lang_no_dimb'
=> lang('No Dim B'),
+ 'lang_dimb_statustext' =>
lang('Select the Dim B for this invoice. To do not use Dim B - select NO DIM
B'),
+
+ 'lang_janitor'
=> lang('Janitor'),
+ 'janitor_list'
=> $this->bocommon->get_user_list_right(32,$janitor,'.invoice'),
+ 'select_janitor'
=> 'janitor',
+ 'lang_no_janitor'
=> lang('No janitor'),
+ 'lang_janitor_statustext' =>
lang('Select the janitor responsible for this invoice. To do not use janitor -
select NO JANITOR'),
+
+ 'lang_supervisor'
=> lang('Supervisor'),
+ 'supervisor_list'
=> $this->bocommon->get_user_list_right(64,$supervisor,'.invoice'),
+ 'select_supervisor'
=> 'supervisor',
+ 'lang_no_supervisor' =>
lang('No supervisor'),
+ 'lang_supervisor_statustext' =>
lang('Select the supervisor responsible for this invoice. To do not use
supervisor - select NO SUPERVISOR'),
+
+ 'lang_budget_responsible' =>
lang('B - responsible'),
+ 'budget_responsible_list' =>
$this->bocommon->get_user_list_right(128,$budget_responsible,'.invoice'),
+ 'select_budget_responsible' =>
'budget_responsible',
+ 'lang_select_budget_responsible'=> lang('Select
B-Responsible'),
+ 'lang_budget_responsible_statustext'
=> lang('You have to select a budget responsible for this invoice in order to
make the import')
+ );
+
+//_debug_array($data);
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('invoice','menu'));
+
+ $appname
= lang('Invoice');
+ $function_msg =
lang('Import from CSV');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('import' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function debug_import($buffer='',$invoice_common='')
+ {
+ $table = $buffer['table'];
+ $header = $buffer['header'];
+ $import = $buffer['import'];
+
+ $sum=0;
+
+ $import_count = count($import);
+ $table_count = count($table)+1;
+ for ($i=1; $i<$table_count; $i++)
+ {
+ for ($k=0; $k<$import_count; $k++)
+ {
+ $content[$i]['row'][$k]['value']
= $table[$i][$import[$header[$k]]];
+ if ($import[$header[$k]]=='belop')
+ {
+
$content[$i]['row'][$k]['align'] = 'right';
+
$sum=$sum+$table[$i][$import[$header[$k]]];
+
$content[$i]['row'][$k]['value'] =
number_format($table[$i][$import[$header[$k]]], 2, ',', '');
+ }
+ }
+ }
+
+ for ($k=0; $k<count($header); $k++)
+ {
+ $table_header[$k]['header'] = $header[$k];
+ $table_header[$k]['width'] = '5%';
+ $table_header[$k]['align'] =
'center';
+ }
+
+
+ $link_data_add = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiXport.import',
+ 'convert' => 'true'
+ );
+
+ $link_data_cancel = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiXport.import',
+ 'cancel' => True
+
+ );
+
+ $link_data_add = $link_data_add +
$invoice_common;
+ $link_data_cancel = $link_data_cancel
+ $invoice_common;
+
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('Import'),
+ 'lang_add_statustext' => lang('Import this
invoice'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data_add),
+ 'lang_cancel' =>
lang('cancel'),
+ 'lang_cancel_statustext'=> lang('Do not import
this invoice'),
+ 'cancel_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data_cancel)
+
+ );
+
+ $vendor =
$this->contacts->read_single(array('actor_id'=>$table[1]['spvend_code']));
+ if(is_array($vendor))
+ {
+ foreach($vendor['attributes'] as $attribute)
+ {
+ if($attribute['name']=='org_name')
+ {
+
$vendor_name=$attribute['value'];
+ break;
+ }
+ }
+ }
+
+ $data = array
+ (
+ 'artid'
=> $table[1]['artid'],
+ 'lang_type'
=> lang('Type'),
+ 'artid'
=> $table[1]['artid'],
+ 'lang_bilagsnr'
=> lang('bilagsnr'),
+ 'bilagsnr'
=> $table[1]['bilagsnr'],
+ 'lang_vendor'
=> lang('Vendor'),
+ 'vendor_name'
=> $vendor_name,
+ 'spvend_code'
=> $table[1]['spvend_code'],
+ 'lang_fakturadato'
=> lang('invoice date'),
+ 'fakturadato'
=> $table[1]['fakturadato'],
+ 'lang_forfallsdato'
=> lang('Payment date'),
+ 'forfallsdato'
=> $table[1]['forfallsdato'],
+ 'lang_janitor'
=> lang('Janitor'),
+ 'oppsynsmannid'
=> $table[1]['oppsynsmannid'],
+ 'lang_supervisor'
=> lang('Supervisor'),
+ 'saksbehandlerid'
=> $table[1]['saksbehandlerid'],
+ 'lang_budget_responsible' =>
lang('Budget Responsible'),
+ 'budsjettansvarligid' =>
$table[1]['budsjettansvarligid'],
+ 'lang_sum'
=> lang('Sum'),
+ 'sum'
=> number_format($sum, 2, ',', ''),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ unset($content);
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('invoice','table_header'));
+ $appname
= lang('Invoice');
+ $function_msg =
lang('Debug');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('debug' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function export()
+ {
+ if(!$this->acl_manage)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=16&acl_location='
. $this->acl2_location);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('invoice','menu',
+
'search_field'));
+
+ $values = get_var('values',array('POST','GET'));
+ $date = get_var('date',array('POST','GET'));
+
+ $links = $this->menu->links('export_inv');
+
+ if($values['submit'])
+ {
+ if (!$values['conv_type'] && !$values['file'] ):
+ {
+
+ $receipt['error'][] = array('msg'=>
lang('No conversion type could be located.') . ' - ' . lang('Please choose a
conversion type from the list'));
+ }
+ elseif($values['conv_type'] &&
!$values['file']):
+ {
+ $receipt =
$this->bo->export(array('conv_type'=>$values['conv_type'],'download'=>$values['download'],'force_period_year'=>$values['force_period_year']));
+ if(!$values['download'])
+ {
+
$GLOBALS['phpgw_info']['flags'][noheader] = True;
+
$GLOBALS['phpgw_info']['flags'][nofooter] = True;
+
$GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
+
$GLOBALS['phpgw_info']['flags']['noframework'] = True;
+ echo '<pre>' .
$receipt['message'][0]['msg'] . '</pre>';
+ echo ' <a
href="'.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiXport.export')
. '">' . lang('Back') . '</a>';
+ }
+ }
+ endif;
+ }
+ else
+ {
+ $date =
$GLOBALS['phpgw']->common->show_date(mktime(0,0,0,date("m"),date("d"),date("Y")),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ }
+//_debug_array($receipt);
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiXport.export',
+ 'invoice_id' => $invoice_id,
+ 'sub' => $sub);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $force_period_year= array(
+ 'id' => date(Y) -1
+ );
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'force_period_year'
=> $force_period_year,
+ 'lang_force_period_year' =>
lang('Force year for period'),
+ 'lang_force_period_year_statustext'
=> lang('Force year for period'),
+ 'lang_select_year'
=> lang('select year'),
+ 'links'
=> $links,
+ 'lang_select_conv'
=> lang('Select conversion'),
+ 'conv_list'
=> $this->bo->select_export_conv($values['conv_type']),
+ 'select_conv'
=> 'values[conv_type]',
+ 'lang_conv_statustext' =>
lang('Select conversion'),
+
+ 'lang_rollback_file' =>
lang('Roll back'),
+ 'link_rollback_file' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiXport.rollback'),
+
+ 'lang_export_to_file' =>
lang('Export to file'),
+ 'value_debug'
=> $values['debug'],
+ 'lang_debug_statustext' =>
lang('Uncheck to debug the result'),
+
+ 'lang_submit'
=> lang('Submit'),
+ 'lang_cancel'
=> lang('Cancel'),
+
+ 'message'
=> $message,
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_save'
=> lang('save')
+ );
+
+//_debug_array($data);
+ $appname
= lang('Invoice');
+ $function_msg =
lang('Export invoice');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('export' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function rollback()
+ {
+ if(!$this->acl_manage)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=16&acl_location='
. $this->acl2_location);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('invoice','menu',
+
'search_field'));
+
+ $values = get_var('values',array('POST','GET'));
+ $date = get_var('date',array('POST','GET'));
+//_debug_array($values);
+
+ $links = $this->menu->links('export_inv');
+
+ if($values['submit'])
+ {
+ if (!$values['conv_type'])
+ {
+ $receipt['error'][] = array('msg'=>
lang('No conversion type could be located.') .' - ' . lang('Please choose a
conversion type from the list'));
+ }
+
+ if(!$values['file'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Please choose a file'));
+ }
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$this->bo->rollback($values['conv_type'],$values['file'],$date);
+ }
+ }
+ else
+ {
+ $date =
$GLOBALS['phpgw']->common->show_date(mktime(0,0,0,date("m"),date("d"),date("Y")),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ }
+
+ $link_data = array('menuaction' =>
$this->currentapp.'.uiXport.rollback');
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+//_debug_array($receipt);
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'links'
=> $links,
+
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle'
=> lang('Select date'),
+ 'calendar_setup'
=> "Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat .
"',button : 'date-trigger'});",
+
+ 'lang_select_conv'
=> lang('Select conversion'),
+ 'conv_list'
=> $this->bo->select_export_conv($values['conv_type']),
+ 'select_conv'
=> 'values[conv_type]',
+ 'lang_conv_statustext' =>
lang('Select conversion'),
+
+ 'lang_select_file'
=> lang('Select file to roll back'),
+ 'lang_no_file'
=> lang('No file selected'),
+ 'lang_file_statustext' =>
lang('Select file to roll back'),
+ 'select_file'
=> 'values[file]',
+
+ 'rollback_file_list' =>
$this->bo->select_rollback_file($values['file']),
+ 'lang_export_to_file' =>
lang('Export to file'),
+ 'value_debug'
=> $values['debug'],
+
+ 'value_date'
=> $date,
+ 'lang_date'
=> lang('Export date'),
+ 'lang_date_statustext' =>
lang('Select date for the file to roll back'),
+
+ 'lang_submit'
=> lang('Submit'),
+ 'lang_cancel'
=> lang('Cancel'),
+
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_save'
=> lang('save')
+ );
+
+//_debug_array($data);
+
+ $appname
= lang('Invoice');
+ $function_msg =
lang('Rollback invoice');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('rollback' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+ }
+?>
Index: property/inc/class.uiactor.inc.php
diff -u property/inc/class.uiactor.inc.php:1.11
property/inc/class.uiactor.inc.php:1.12
--- property/inc/class.uiactor.inc.php:1.11 Thu May 12 21:26:28 2005
+++ property/inc/class.uiactor.inc.php Fri Jan 27 14:05:43 2006
@@ -1,921 +1,921 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.uiactor.inc.php,v 1.11 2005/05/12 21:26:28
sigurdne Exp $
- */
-
-
- /**
- * uiactor class
- *
- * uiactor is the ui-class for three set of actors, separarated by
their roles:
- * - Tenant
- * - Vendor
- * - Owner
- * @package property
- */
-
- class uiactor
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
-
- var $public_functions = array
- (
- 'index' => True,
- 'view' => True,
- 'edit' => True,
- 'delete' => True,
- 'list_attribute'=> True,
- 'edit_attrib' => True,
- 'columns' => True
- );
-
- function uiactor()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- $this->bo =
CreateObject($this->currentapp.'.boactor',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
-
- $this->role = $this->bo->role;
-
- $this->cats =
CreateObject('phpgwapi.categories');
- $this->cats->app_name = 'fm_' . $this->role;
-
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
- $this->acl2_location= '.' . $this->role;
-
- $this->acl_read =
$this->acl2->check($this->acl2_location,1);
- $this->acl_add =
$this->acl2->check($this->acl2_location,2);
- $this->acl_edit =
$this->acl2->check($this->acl2_location,4);
- $this->acl_delete =
$this->acl2->check($this->acl2_location,8);
-
- $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->allrows = $this->bo->allrows;
- $this->member_id = $this->bo->member_id;
-
- $valid_role = array(
- 'tenant'=>True,
- 'owner' =>True,
- 'vendor'=>True
- );
- if(!$valid_role[$this->role])
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.index');
- }
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' => $this->filter,
- 'cat_id' => $this->cat_id,
- 'allrows' => $this->allrows,
- 'member_id' => $this->member_id
- );
- $this->bo->save_sessiondata($data);
- }
-
- function columns()
- {
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('columns'));
-
-
- $GLOBALS['phpgw_info']['flags']['noframework'] = True;
-
- $values =
get_var('values',array('POST','GET'));
-
- if ($values['save'])
- {
-
-
$GLOBALS['phpgw']->preferences->account_id=$this->account;
-
$GLOBALS['phpgw']->preferences->read_repository();
-
$GLOBALS['phpgw']->preferences->add($this->currentapp,'actor_columns_'
.$this->role,$values['columns'],'user');
-
$GLOBALS['phpgw']->preferences->save_repository();
-
- $receipt['message'][] = array('msg' =>
lang('columns is updated'));
- }
-
- $function_msg = lang('Select Column');
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiactor.columns',
- 'role' => $this->role
- );
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'column_list' =>
$this->bo->column_list($values['columns'],$allrows=True),
- 'function_msg' => $function_msg,
- 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_columns' => lang('columns'),
- 'lang_none' => lang('None'),
- 'lang_save' => lang('save'),
- 'select_name' => 'period'
- );
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
$function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('columns' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
-
- function index()
- {
- $menu_sub = array(
- 'tenant'=>'invoice',
- 'owner' =>'admin',
- 'vendor'=>'invoice'
- );
-
- $this->menu->sub = $menu_sub[$this->role];
-
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('actor',
-
'menu',
-
'receipt',
-
'search_field',
-
'nextmatchs',
-
'filter_member_of'));
-
- $links = $this->menu->links($this->role);
-
- $receipt =
$GLOBALS['phpgw']->session->appsession('session_data',$this->role . '_receipt');
-
$GLOBALS['phpgw']->session->appsession('session_data',$this->role .
'_receipt','');
-
- $list = $this->bo->read();
-
- $uicols = $this->bo->uicols;
-
- $j=0;
-
- if (isset($list) AND is_array($list))
- {
- foreach($list as $entry)
- {
- for
($i=0;$i<count($uicols['name']);$i++)
- {
-
if($uicols['input_type'][$i]!='hidden')
- {
-
$content[$j]['row'][$i]['value'] =
$entry[$uicols['name'][$i]];
-
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
- }
- }
-
- if($this->acl_read)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('view the
entity');
- $content[$j]['row'][$i]['text']
= lang('view');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.view&actor_id='
. $entry['id'] .'&role=' . $this->role);
- }
- if($this->acl_edit)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('edit the
actor');
- $content[$j]['row'][$i]['text']
= lang('edit');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.edit&actor_id='
. $entry['id'] .'&role=' . $this->role);
- }
- if($this->acl_delete)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('delete the
actor');
- $content[$j]['row'][$i]['text']
= lang('delete');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.delete&actor_id='
. $entry['id'] .'&role=' . $this->role);
- }
-
- $j++;
- }
- }
-
-//html_print_r($content);
- for ($i=0;$i<count($uicols['descr']);$i++)
- {
- if($uicols['input_type'][$i]!='hidden')
- {
- $table_header[$i]['header'] =
$uicols['descr'][$i];
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- if($uicols['datatype'][$i]!='T' &&
$uicols['datatype'][$i]!='CH')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
- (
- 'sort' =>
$this->sort,
- 'var' =>
$uicols['name'][$i],
- 'order' =>
$this->order,
- 'extra'
=> array('menuaction' => $this->currentapp.'.uiactor.index',
-
'query' =>$this->query,
-
'lookup' =>$lookup,
-
'district_id' => $this->district_id,
-
'start_date' => $start_date,
-
'role' => $this->role,
-
'member_id' => $this->member_id,
-
'end_date'=>$end_date)
- ));
- }
- }
- }
-
- if($this->acl_read)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('view');
- $i++;
- }
- if($this->acl_edit)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('edit');
- $i++;
- }
- if($this->acl_delete)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('delete');
- $i++;
- }
-
- if($this->acl_add)
- {
- $table_add = array
- (
- 'lang_add'
=> lang('add'),
- 'lang_add_statustext' => lang('add a
actor'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.edit&role='
. $this->role)
- );
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiactor.index',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query,
- 'role' =>
$this->role,
- 'member_id' =>
$this->member_id
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $link_columns = array
- (
- 'menuaction' =>
$this->currentapp.'.uiactor.columns',
- 'role' =>
$this->role
- );
-
- $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True, 'link_data' =>$link_data));
-
- $data = array
- (
- 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
- 'lang_columns'
=> lang('columns'),
- 'link_columns'
=> $GLOBALS['phpgw']->link('/index.php',$link_columns),
- 'lang_columns_help'
=> lang('Choose columns'),
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'links'
=> $links,
- 'allow_allrows'
=> false,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the actor belongs to. To do not use a category select
NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $this->bo->select_category_list('filter',$this->cat_id),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
-
- 'lang_no_member'
=> lang('no member'),
- 'member_of_name'
=> 'member_id',
- 'member_of_list'
=> $member_of_data['cat_list'],
-
- 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter)),
- 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
- $this->save_sessiondata();
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('actor') . ': ' . lang('list ' . $this->role);
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function edit()
- {
- $actor_id =
get_var('actor_id',array('POST','GET'));
- $values = get_var('values',array('POST'));
- $values_attribute =
get_var('values_attribute',array('POST'));
-
- $insert_record_actor =
$GLOBALS['phpgw']->session->appsession('insert_record_actor',$this->currentapp);
-
-//_debug_array($insert_record_actor);
- for ($j=0;$j<count($insert_record_actor);$j++)
- {
-
$insert_record['extra'][$insert_record_actor[$j]] =
$insert_record_actor[$j];
- }
-
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('actor','attributes_form'));
-
- if (is_array($values))
- {
- while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
- {
- if($_POST[$key])
- {
- $values['extra'][$column]
= $_POST[$key];
- }
- }
-
-//_debug_array($values);
-
- if ($values['save'] || $values['apply'])
- {
-
- if(!$values['cat_id'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
- }
-
- if(!$values['last_name'])
- {
-//
$receipt['error'][]=array('msg'=>lang('Please enter a name !'));
- }
-
- if(!$receipt['error'])
- {
- $values['actor_id'] =
$actor_id;
- $receipt =
$this->bo->save($values,$values_attribute);
- $actor_id =
$receipt['actor_id'];
- $this->cat_id =
($values['cat_id']?$values['cat_id']:$this->cat_id);
-
- if ($values['save'])
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','actor_receipt',$receipt);
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiactor.index&role='
. $this->role);
- }
- }
- }
- else
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiactor.index&role='
. $this->role);
- }
- }
-
-
- $actor =
$this->bo->read_single(array('actor_id'=>$actor_id));
-
- if ($actor_id)
- {
- $this->cat_id =
($actor['cat_id']?$actor['cat_id']:$this->cat_id);
- $this->member_id =
($actor['member_of']?$actor['member_of']:$this->member_id);
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiactor.edit',
- 'actor_id' => $actor_id,
- 'role' => $this->role
- );
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- switch(substr($dateformat,0,1))
- {
- case 'M':
- $dateformat_validate=
"javascript:vDateType='1'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
- $onBlur =
"DateFormat(this,this.value,event,true,'1')";
- break;
- case 'y':
-
$dateformat_validate="javascript:vDateType='2'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
- $onBlur =
"DateFormat(this,this.value,event,true,'2')";
- break;
- case 'D':
-
$dateformat_validate="javascript:vDateType='3'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
- $onBlur =
"DateFormat(this,this.value,event,true,'3')";
- break;
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True, 'link_data' =>array()));
-
-//_debug_array($member_of_data);
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_actor_id'
=> lang($this->role) . ' ID',
- 'value_actor_id'
=> $actor_id,
- 'lang_category'
=> lang('category'),
- 'lang_save'
=> lang('save'),
- 'lang_cancel'
=> lang('cancel'),
- 'lang_apply'
=> lang('apply'),
- 'value_cat'
=> $actor['cat'],
- 'lang_id_statustext' =>
lang('Choose an ID'),
- 'lang_apply_statustext' =>
lang('Apply the values'),
- 'lang_cancel_statustext' =>
lang('Leave the actor untouched and return back to the list'),
- 'lang_save_statustext' =>
lang('Save the actor and return back to the list'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the actor belongs to. To do not use a category select
NO CATEGORY'),
- 'select_name'
=> 'values[cat_id]',
- 'cat_list'
=> $this->bo->select_category_list('select',$this->cat_id),
-
- 'lang_member_of'
=> lang('member of'),
- 'member_of_name'
=> 'member_id',
- 'member_of_list'
=> $member_of_data['cat_list'],
-
- 'lang_dateformat'
=> lang(strtolower($dateformat)),
- 'dateformat_validate' =>
$dateformat_validate,
- 'onKeyUp'
=> $onKeyUp,
- 'onBlur'
=> $onBlur,
- 'dateformat_source'
=> './'.$this->currentapp.'/inc/dateformat.js',
- 'lang_attributes'
=> lang('Attributes'),
- 'attributes_header'
=> $attributes_header,
- 'attributes_values'
=> $actor['attributes'],
- 'lookup_functions'
=> $actor['lookup_functions'],
- 'dateformat'
=> $dateformat,
- );
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('actor') . ': ' . ($actor_id?lang('edit') . ' ' .
lang($this->role):lang('add') . ' ' . lang($this->role));
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- function delete()
- {
- $attrib = get_var('attrib',array('POST','GET'));
- $id = get_var('id',array('POST','GET'));
- $actor_id =
get_var('actor_id',array('POST','GET'));
- $delete = get_var('delete',array('POST'));
- $confirm = get_var('confirm',array('POST'));
-
-
- if($attrib)
- {
- $function='list_attribute';
- }
- else
- {
- $function='index';
- }
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiactor.'.$function,
- 'role' => $this->role
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($actor_id,$id,$attrib);
-// Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
-
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.delete&actor_id='
. $actor_id. '&id=' . $id . '&attrib=' . $attrib . '&role=' . $this->role),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('actor');
- $function_msg =
lang('delete') . ' ' . lang($this->role);
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
-
- function view()
- {
- $actor_id = get_var('actor_id',array('GET'));
- $action = get_var('action',array('GET'));
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('actor') . ': ' . lang('view') . ' ' . lang($this->role);
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('actor','attributes_view'));
-
- $actor =
$this->bo->read_single(array('actor_id'=>$actor_id));
-
- $attributes_values=$actor['attributes'];
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- $member_of_data =
$this->cats->formatted_xslt_list(array('selected' =>
$actor['member_of'],'globals' => True, 'link_data' =>array()));
-
- $data = array
- (
- 'lang_actor_id' =>
lang($this->role) . ' ID',
- 'value_actor_id' =>
$actor_id,
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.index&role='
. $this->role),
- 'lang_category' =>
lang('category'),
- 'lang_time_created' =>
lang('time created'),
- 'lang_done'
=> lang('done'),
- 'cat_list'
=> $this->bo->select_category_list('',$actor['cat_id']),
- 'lang_member_of' =>
lang('member of'),
- 'member_of_list' =>
$member_of_data['cat_list'],
-
- 'value_date' =>
$GLOBALS['phpgw']->common->show_date($actor['entry_date']),
- 'lang_dateformat' =>
lang(strtolower($dateformat)),
- 'lang_attributes' =>
lang('Attributes'),
- 'attributes_view' =>
$attributes_values,
- 'dateformat' =>
$dateformat
- );
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function list_attribute()
- {
- $id = get_var('id',array('POST','GET'));
- $resort = get_var('resort',array('POST','GET'));
-
- $GLOBALS['phpgw']->xslttpl->add_file(array(
- 'actor',
- 'nextmatchs',
-
'search_field'));
-
- if($resort)
- {
-
$this->bo->resort_attrib(array('resort'=>$resort,'id'=>$id));
- }
-
- $attrib_list = $this->bo->read_attrib();
-
- while (is_array($attrib_list) && list(,$attrib) =
each($attrib_list))
- {
- $content[] = array
- (
- 'name'
=> $attrib['name'],
- 'type_name'
=> $attrib['type_name'],
- 'datatype'
=> $attrib['datatype'],
- 'column_name'
=> $attrib['column_name'],
- 'input_text'
=> $attrib['input_text'],
- 'sorting'
=> $attrib['attrib_sort'],
- 'search'
=> $attrib['search'],
- 'link_up'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.list_attribute&resort=up&id='
. $attrib['id'] . '&allrows=' . $this->allrows . '&role=' . $this->role),
- 'link_down'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.list_attribute&resort=down&id='
. $attrib['id'] . '&allrows=' . $this->allrows . '&role=' . $this->role),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.edit_attrib&id='
. $attrib['id'] . '&role=' . $this->role),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.delete&id='
. $attrib['id'].'&attrib=true&role=' . $this->role),
- 'lang_view_attribtext' =>
lang('view the attrib'),
- 'lang_attribute_attribtext' =>
lang('attributes for the attrib'). ' ' . lang('location'),
- 'lang_edit_attribtext' =>
lang('edit the attrib'),
- 'lang_delete_attribtext' =>
lang('delete the attrib'),
- 'text_attribute'
=> lang('Attributes'),
- 'text_up'
=> lang('up'),
- 'text_down'
=> lang('down'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
-
- //html_print_r($content);
-
- $table_header[] = array
- (
- 'lang_descr' => lang('Descr'),
- 'lang_datatype' => lang('Datatype'),
- 'lang_sorting' => lang('sorting'),
- 'lang_search' => lang('search'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_sorting' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'attrib_sort',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiactor.list_attribute',
-
'allrows'=>$this->allrows,
-
'role' => $this->role)
-
)),
-
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'column_name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiactor.list_attribute',
-
'allrows'=>$this->allrows,
-
'role' => $this->role)
-
)),
- 'lang_name' => lang('Name'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_attribtext' => lang('add a attrib'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.edit_attrib&role='
. $this->role),
- 'lang_done' =>
lang('done'),
- 'lang_done_attribtext' => lang('back to
admin'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php'),
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiactor.list_attribute',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'query'
=>$this->query,
- 'role' =>
$this->role
-
- );
-
- $data = array
- (
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($attrib_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_attribtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_attribtext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_attrib' =>
$table_header,
- 'values_attrib'
=> $content,
- 'table_add2'
=> $table_add
- );
-
- $appname
= lang('actor');
- $function_msg =
lang('list attribute') . ': ' . lang($this->role);
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
- //$this->save_sessiondata();
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_attribute' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function edit_attrib()
- {
- $id =
get_var('id',array('POST','GET'));
- $values = get_var('values',array('POST'));
- // $GLOBALS['phpgw']->common->msgbox(lang('Altering
ColumnName OR Datatype - deletes your data in this Column'));
- //html_print_r($values);
-
$GLOBALS['phpgw']->xslttpl->add_file(array('actor','choice',));
-
- if ($values['save'])
- {
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
- $type_id =
$values['type_id'];
-
- if (!$values['column_name'])
- {
- $receipt['error'][] =
array('msg'=>lang('Column name not entered!'));
- }
-
- if (!$values['input_text'])
- {
- $receipt['error'][] =
array('msg'=>lang('Input text not entered!'));
- }
- if (!$values['statustext'])
- {
- $receipt['error'][] =
array('msg'=>lang('Statustext not entered!'));
- }
-
- if (!$values['column_info']['type'])
- {
- $receipt['error'][] =
array('msg'=>lang('Datatype type not choosen!'));
- }
-
-
if(!ctype_digit($values['column_info']['precision']))
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter precision as integer !'));
-
unset($values['column_info']['precision']);
- }
-
-
if(!ctype_digit($values['column_info']['scale']))
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter scale as integer !'));
- unset($values['column_info']['scale']);
- }
-
- if (!$values['column_info']['nullable'])
- {
- $receipt['error'][] =
array('msg'=>lang('Nullable not choosen!'));
- }
-
-
- if (!$receipt['error'])
- {
- $receipt =
$this->bo->save_attrib($values,$action);
-
- if(!$id)
- {
- $id=$receipt['id'];
- }
- }
- else
- {
- $receipt['error'][] = array('msg'
=> lang('Attribute has NOT been saved'));
- }
-
- }
-
- if ($id)
- {
- $values = $this->bo->read_single_attrib($id);
- $function_msg = lang('edit attribute') . ': ' .
lang($this->role);
- $action='edit';
- }
- else
- {
- $function_msg = lang('add attribute') . ': ' .
lang($this->role);
- $action='add';
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiactor.edit_attrib',
- 'id' => $id,
- 'role' => $this->role
-
- );
- //html_print_r($values);
-
- if($values['column_info']['type']=='R' ||
$values['column_info']['type']=='CH' || $values['column_info']['type']=='LB')
- {
- $multiple_choice= True;
- }
-
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'lang_choice' =>
lang('Choice'),
- 'lang_new_value' =>
lang('New value'),
- 'lang_new_value_statustext' => lang('New
value for mulitple choice'),
- 'multiple_choice' =>
$multiple_choice,
- 'value_choice' =>
$values['choice'],
- 'lang_delete_value' =>
lang('Delete value'),
- 'lang_value' =>
lang('value'),
- 'lang_delete_choice_statustext'=> lang('Delete
this value from the list of multiple choice'),
- //'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.list_attribute&type_id='.$type_id
. '&role=' . $this->role),
- 'lang_id'
=> lang('Attribute ID'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_id'
=> $id,
-
- 'lang_column_name'
=> lang('Column name'),
- 'value_column_name'
=> $values['column_name'],
- 'lang_column_name_statustext' => lang('enter
the name for the column'),
-
- 'lang_input_text'
=> lang('input text'),
- 'value_input_text'
=> $values['input_text'],
- 'lang_input_name_statustext' => lang('enter
the input text for records'),
-
- 'lang_id_attribtext' => lang('Enter
the attribute ID'),
- 'lang_entity_statustext' => lang('Select
a actor type'),
-
- 'lang_statustext' =>
lang('Statustext'),
- 'lang_statustext_attribtext'=> lang('Enter a
statustext for the inputfield in forms'),
- 'value_statustext' =>
$values['statustext'],
-
- 'lang_done_attribtext' => lang('Back
to the list'),
- 'lang_save_attribtext' => lang('Save
the attribute'),
-
- 'lang_datatype' =>
lang('Datatype'),
- 'lang_datatype_statustext' => lang('Select
a datatype'),
- 'lang_no_datatype' =>
lang('No datatype'),
- 'datatype_list' =>
$this->bocommon->select_datatype($values['column_info']['type']),
-
- 'lang_precision' =>
lang('Precision'),
- 'lang_precision_statustext' => lang('enter
the record length'),
- 'value_precision' =>
$values['column_info']['precision'],
-
- 'lang_scale' =>
lang('scale'),
- 'lang_scale_statustext' => lang('enter
the scale if type is decimal'),
- 'value_scale' =>
$values['column_info']['scale'],
-
- 'lang_default' =>
lang('default'),
- 'lang_default_statustext' => lang('enter
the default value'),
- 'value_default' =>
$values['column_info']['default'],
-
- 'lang_nullable' =>
lang('Nullable'),
- 'lang_nullable_statustext' => lang('Chose
if this column is nullable'),
- 'lang_select_nullable' => lang('Select
nullable'),
- 'nullable_list' =>
$this->bocommon->select_nullable($values['column_info']['nullable']),
-
- 'value_list' =>
$values['list'],
- 'lang_list'
=> lang('show in list'),
- 'lang_list_statustext' => lang('check
to show this attribute in location list'),
-
- 'value_search' =>
$values['search'],
- 'lang_include_search' =>
lang('Include in search'),
- 'lang_include_search_statustext'=> lang('check
to show this attribute in location list'),
-
-
- );
- //html_print_r($data);
-
- $appname
= lang('actor');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_attrib' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
- }
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.uiactor.inc.php,v 1.12 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+
+ /**
+ * uiactor class
+ *
+ * uiactor is the ui-class for three set of actors, separarated by
their roles:
+ * - Tenant
+ * - Vendor
+ * - Owner
+ * @package property
+ */
+
+ class uiactor
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'view' => True,
+ 'edit' => True,
+ 'delete' => True,
+ 'list_attribute'=> True,
+ 'edit_attrib' => True,
+ 'columns' => True
+ );
+
+ function uiactor()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $this->bo =
CreateObject($this->currentapp.'.boactor',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+
+ $this->role = $this->bo->role;
+
+ $this->cats =
CreateObject('phpgwapi.categories');
+ $this->cats->app_name = 'fm_' . $this->role;
+
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+ $this->acl2_location= '.' . $this->role;
+
+ $this->acl_read =
$this->acl2->check($this->acl2_location,1);
+ $this->acl_add =
$this->acl2->check($this->acl2_location,2);
+ $this->acl_edit =
$this->acl2->check($this->acl2_location,4);
+ $this->acl_delete =
$this->acl2->check($this->acl2_location,8);
+
+ $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->allrows = $this->bo->allrows;
+ $this->member_id = $this->bo->member_id;
+
+ $valid_role = array(
+ 'tenant'=>True,
+ 'owner' =>True,
+ 'vendor'=>True
+ );
+ if(!$valid_role[$this->role])
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.index');
+ }
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' => $this->filter,
+ 'cat_id' => $this->cat_id,
+ 'allrows' => $this->allrows,
+ 'member_id' => $this->member_id
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function columns()
+ {
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('columns'));
+
+
+ $GLOBALS['phpgw_info']['flags']['noframework'] = True;
+
+ $values =
get_var('values',array('POST','GET'));
+
+ if ($values['save'])
+ {
+
+
$GLOBALS['phpgw']->preferences->account_id=$this->account;
+
$GLOBALS['phpgw']->preferences->read_repository();
+
$GLOBALS['phpgw']->preferences->add($this->currentapp,'actor_columns_'
.$this->role,$values['columns'],'user');
+
$GLOBALS['phpgw']->preferences->save_repository();
+
+ $receipt['message'][] = array('msg' =>
lang('columns is updated'));
+ }
+
+ $function_msg = lang('Select Column');
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiactor.columns',
+ 'role' => $this->role
+ );
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'column_list' =>
$this->bo->column_list($values['columns'],$allrows=True),
+ 'function_msg' => $function_msg,
+ 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_columns' => lang('columns'),
+ 'lang_none' => lang('None'),
+ 'lang_save' => lang('save'),
+ 'select_name' => 'period'
+ );
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
$function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('columns' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+
+ function index()
+ {
+ $menu_sub = array(
+ 'tenant'=>'invoice',
+ 'owner' =>'admin',
+ 'vendor'=>'invoice'
+ );
+
+ $this->menu->sub = $menu_sub[$this->role];
+
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('actor',
+
'menu',
+
'receipt',
+
'search_field',
+
'nextmatchs',
+
'filter_member_of'));
+
+ $links = $this->menu->links($this->role);
+
+ $receipt =
$GLOBALS['phpgw']->session->appsession('session_data',$this->role . '_receipt');
+
$GLOBALS['phpgw']->session->appsession('session_data',$this->role .
'_receipt','');
+
+ $list = $this->bo->read();
+
+ $uicols = $this->bo->uicols;
+
+ $j=0;
+
+ if (isset($list) AND is_array($list))
+ {
+ foreach($list as $entry)
+ {
+ for
($i=0;$i<count($uicols['name']);$i++)
+ {
+
if($uicols['input_type'][$i]!='hidden')
+ {
+
$content[$j]['row'][$i]['value'] =
$entry[$uicols['name'][$i]];
+
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
+ }
+ }
+
+ if($this->acl_read)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('view the
entity');
+ $content[$j]['row'][$i]['text']
= lang('view');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.view&actor_id='
. $entry['id'] .'&role=' . $this->role);
+ }
+ if($this->acl_edit)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('edit the
actor');
+ $content[$j]['row'][$i]['text']
= lang('edit');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.edit&actor_id='
. $entry['id'] .'&role=' . $this->role);
+ }
+ if($this->acl_delete)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('delete the
actor');
+ $content[$j]['row'][$i]['text']
= lang('delete');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.delete&actor_id='
. $entry['id'] .'&role=' . $this->role);
+ }
+
+ $j++;
+ }
+ }
+
+//html_print_r($content);
+ for ($i=0;$i<count($uicols['descr']);$i++)
+ {
+ if($uicols['input_type'][$i]!='hidden')
+ {
+ $table_header[$i]['header'] =
$uicols['descr'][$i];
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ if($uicols['datatype'][$i]!='T' &&
$uicols['datatype'][$i]!='CH')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+ (
+ 'sort' =>
$this->sort,
+ 'var' =>
$uicols['name'][$i],
+ 'order' =>
$this->order,
+ 'extra'
=> array('menuaction' => $this->currentapp.'.uiactor.index',
+
'query' =>$this->query,
+
'lookup' =>$lookup,
+
'district_id' => $this->district_id,
+
'start_date' => $start_date,
+
'role' => $this->role,
+
'member_id' => $this->member_id,
+
'end_date'=>$end_date)
+ ));
+ }
+ }
+ }
+
+ if($this->acl_read)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('view');
+ $i++;
+ }
+ if($this->acl_edit)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('edit');
+ $i++;
+ }
+ if($this->acl_delete)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('delete');
+ $i++;
+ }
+
+ if($this->acl_add)
+ {
+ $table_add = array
+ (
+ 'lang_add'
=> lang('add'),
+ 'lang_add_statustext' => lang('add a
actor'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.edit&role='
. $this->role)
+ );
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiactor.index',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query,
+ 'role' =>
$this->role,
+ 'member_id' =>
$this->member_id
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $link_columns = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiactor.columns',
+ 'role' =>
$this->role
+ );
+
+ $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True, 'link_data' =>$link_data));
+
+ $data = array
+ (
+ 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
+ 'lang_columns'
=> lang('columns'),
+ 'link_columns'
=> $GLOBALS['phpgw']->link('/index.php',$link_columns),
+ 'lang_columns_help'
=> lang('Choose columns'),
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'links'
=> $links,
+ 'allow_allrows'
=> false,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the actor belongs to. To do not use a category select
NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $this->bo->select_category_list('filter',$this->cat_id),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+
+ 'lang_no_member'
=> lang('no member'),
+ 'member_of_name'
=> 'member_id',
+ 'member_of_list'
=> $member_of_data['cat_list'],
+
+ 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter)),
+ 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+ $this->save_sessiondata();
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('actor') . ': ' . lang('list ' . $this->role);
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function edit()
+ {
+ $actor_id =
get_var('actor_id',array('POST','GET'));
+ $values = get_var('values',array('POST'));
+ $values_attribute =
get_var('values_attribute',array('POST'));
+
+ $insert_record_actor =
$GLOBALS['phpgw']->session->appsession('insert_record_actor',$this->currentapp);
+
+//_debug_array($insert_record_actor);
+ for ($j=0;$j<count($insert_record_actor);$j++)
+ {
+
$insert_record['extra'][$insert_record_actor[$j]] =
$insert_record_actor[$j];
+ }
+
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('actor','attributes_form'));
+
+ if (is_array($values))
+ {
+ while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
+ {
+ if($_POST[$key])
+ {
+ $values['extra'][$column]
= $_POST[$key];
+ }
+ }
+
+//_debug_array($values);
+
+ if ($values['save'] || $values['apply'])
+ {
+
+ if(!$values['cat_id'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
+ }
+
+ if(!$values['last_name'])
+ {
+//
$receipt['error'][]=array('msg'=>lang('Please enter a name !'));
+ }
+
+ if(!$receipt['error'])
+ {
+ $values['actor_id'] =
$actor_id;
+ $receipt =
$this->bo->save($values,$values_attribute);
+ $actor_id =
$receipt['actor_id'];
+ $this->cat_id =
($values['cat_id']?$values['cat_id']:$this->cat_id);
+
+ if ($values['save'])
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','actor_receipt',$receipt);
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiactor.index&role='
. $this->role);
+ }
+ }
+ }
+ else
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiactor.index&role='
. $this->role);
+ }
+ }
+
+
+ $actor =
$this->bo->read_single(array('actor_id'=>$actor_id));
+
+ if ($actor_id)
+ {
+ $this->cat_id =
($actor['cat_id']?$actor['cat_id']:$this->cat_id);
+ $this->member_id =
($actor['member_of']?$actor['member_of']:$this->member_id);
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiactor.edit',
+ 'actor_id' => $actor_id,
+ 'role' => $this->role
+ );
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ switch(substr($dateformat,0,1))
+ {
+ case 'M':
+ $dateformat_validate=
"javascript:vDateType='1'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'1')";
+ break;
+ case 'y':
+
$dateformat_validate="javascript:vDateType='2'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'2')";
+ break;
+ case 'D':
+
$dateformat_validate="javascript:vDateType='3'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'3')";
+ break;
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True, 'link_data' =>array()));
+
+//_debug_array($member_of_data);
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_actor_id'
=> lang($this->role) . ' ID',
+ 'value_actor_id'
=> $actor_id,
+ 'lang_category'
=> lang('category'),
+ 'lang_save'
=> lang('save'),
+ 'lang_cancel'
=> lang('cancel'),
+ 'lang_apply'
=> lang('apply'),
+ 'value_cat'
=> $actor['cat'],
+ 'lang_id_statustext' =>
lang('Choose an ID'),
+ 'lang_apply_statustext' =>
lang('Apply the values'),
+ 'lang_cancel_statustext' =>
lang('Leave the actor untouched and return back to the list'),
+ 'lang_save_statustext' =>
lang('Save the actor and return back to the list'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the actor belongs to. To do not use a category select
NO CATEGORY'),
+ 'select_name'
=> 'values[cat_id]',
+ 'cat_list'
=> $this->bo->select_category_list('select',$this->cat_id),
+
+ 'lang_member_of'
=> lang('member of'),
+ 'member_of_name'
=> 'member_id',
+ 'member_of_list'
=> $member_of_data['cat_list'],
+
+ 'lang_dateformat'
=> lang(strtolower($dateformat)),
+ 'dateformat_validate' =>
$dateformat_validate,
+ 'onKeyUp'
=> $onKeyUp,
+ 'onBlur'
=> $onBlur,
+ 'dateformat_source'
=> './'.$this->currentapp.'/inc/dateformat.js',
+ 'lang_attributes'
=> lang('Attributes'),
+ 'attributes_header'
=> $attributes_header,
+ 'attributes_values'
=> $actor['attributes'],
+ 'lookup_functions'
=> $actor['lookup_functions'],
+ 'dateformat'
=> $dateformat,
+ );
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('actor') . ': ' . ($actor_id?lang('edit') . ' ' .
lang($this->role):lang('add') . ' ' . lang($this->role));
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ function delete()
+ {
+ $attrib = get_var('attrib',array('POST','GET'));
+ $id = get_var('id',array('POST','GET'));
+ $actor_id =
get_var('actor_id',array('POST','GET'));
+ $delete = get_var('delete',array('POST'));
+ $confirm = get_var('confirm',array('POST'));
+
+
+ if($attrib)
+ {
+ $function='list_attribute';
+ }
+ else
+ {
+ $function='index';
+ }
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiactor.'.$function,
+ 'role' => $this->role
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($actor_id,$id,$attrib);
+// Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.delete&actor_id='
. $actor_id. '&id=' . $id . '&attrib=' . $attrib . '&role=' . $this->role),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('actor');
+ $function_msg =
lang('delete') . ' ' . lang($this->role);
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+
+ function view()
+ {
+ $actor_id = get_var('actor_id',array('GET'));
+ $action = get_var('action',array('GET'));
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('actor') . ': ' . lang('view') . ' ' . lang($this->role);
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('actor','attributes_view'));
+
+ $actor =
$this->bo->read_single(array('actor_id'=>$actor_id));
+
+ $attributes_values=$actor['attributes'];
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ $member_of_data =
$this->cats->formatted_xslt_list(array('selected' =>
$actor['member_of'],'globals' => True, 'link_data' =>array()));
+
+ $data = array
+ (
+ 'lang_actor_id' =>
lang($this->role) . ' ID',
+ 'value_actor_id' =>
$actor_id,
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.index&role='
. $this->role),
+ 'lang_category' =>
lang('category'),
+ 'lang_time_created' =>
lang('time created'),
+ 'lang_done'
=> lang('done'),
+ 'cat_list'
=> $this->bo->select_category_list('',$actor['cat_id']),
+ 'lang_member_of' =>
lang('member of'),
+ 'member_of_list' =>
$member_of_data['cat_list'],
+
+ 'value_date' =>
$GLOBALS['phpgw']->common->show_date($actor['entry_date']),
+ 'lang_dateformat' =>
lang(strtolower($dateformat)),
+ 'lang_attributes' =>
lang('Attributes'),
+ 'attributes_view' =>
$attributes_values,
+ 'dateformat' =>
$dateformat
+ );
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function list_attribute()
+ {
+ $id = get_var('id',array('POST','GET'));
+ $resort = get_var('resort',array('POST','GET'));
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array(
+ 'actor',
+ 'nextmatchs',
+
'search_field'));
+
+ if($resort)
+ {
+
$this->bo->resort_attrib(array('resort'=>$resort,'id'=>$id));
+ }
+
+ $attrib_list = $this->bo->read_attrib();
+
+ while (is_array($attrib_list) && list(,$attrib) =
each($attrib_list))
+ {
+ $content[] = array
+ (
+ 'name'
=> $attrib['name'],
+ 'type_name'
=> $attrib['type_name'],
+ 'datatype'
=> $attrib['datatype'],
+ 'column_name'
=> $attrib['column_name'],
+ 'input_text'
=> $attrib['input_text'],
+ 'sorting'
=> $attrib['attrib_sort'],
+ 'search'
=> $attrib['search'],
+ 'link_up'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.list_attribute&resort=up&id='
. $attrib['id'] . '&allrows=' . $this->allrows . '&role=' . $this->role),
+ 'link_down'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.list_attribute&resort=down&id='
. $attrib['id'] . '&allrows=' . $this->allrows . '&role=' . $this->role),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.edit_attrib&id='
. $attrib['id'] . '&role=' . $this->role),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.delete&id='
. $attrib['id'].'&attrib=true&role=' . $this->role),
+ 'lang_view_attribtext' =>
lang('view the attrib'),
+ 'lang_attribute_attribtext' =>
lang('attributes for the attrib'). ' ' . lang('location'),
+ 'lang_edit_attribtext' =>
lang('edit the attrib'),
+ 'lang_delete_attribtext' =>
lang('delete the attrib'),
+ 'text_attribute'
=> lang('Attributes'),
+ 'text_up'
=> lang('up'),
+ 'text_down'
=> lang('down'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+
+ //html_print_r($content);
+
+ $table_header[] = array
+ (
+ 'lang_descr' => lang('Descr'),
+ 'lang_datatype' => lang('Datatype'),
+ 'lang_sorting' => lang('sorting'),
+ 'lang_search' => lang('search'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_sorting' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'attrib_sort',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiactor.list_attribute',
+
'allrows'=>$this->allrows,
+
'role' => $this->role)
+
)),
+
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'column_name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiactor.list_attribute',
+
'allrows'=>$this->allrows,
+
'role' => $this->role)
+
)),
+ 'lang_name' => lang('Name'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_attribtext' => lang('add a attrib'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.edit_attrib&role='
. $this->role),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_attribtext' => lang('back to
admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php'),
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiactor.list_attribute',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'query'
=>$this->query,
+ 'role' =>
$this->role
+
+ );
+
+ $data = array
+ (
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($attrib_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_attribtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_attribtext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_attrib' =>
$table_header,
+ 'values_attrib'
=> $content,
+ 'table_add2'
=> $table_add
+ );
+
+ $appname
= lang('actor');
+ $function_msg =
lang('list attribute') . ': ' . lang($this->role);
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+ //$this->save_sessiondata();
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_attribute' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function edit_attrib()
+ {
+ $id =
get_var('id',array('POST','GET'));
+ $values = get_var('values',array('POST'));
+ // $GLOBALS['phpgw']->common->msgbox(lang('Altering
ColumnName OR Datatype - deletes your data in this Column'));
+ //html_print_r($values);
+
$GLOBALS['phpgw']->xslttpl->add_file(array('actor','choice',));
+
+ if ($values['save'])
+ {
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+ $type_id =
$values['type_id'];
+
+ if (!$values['column_name'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Column name not entered!'));
+ }
+
+ if (!$values['input_text'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Input text not entered!'));
+ }
+ if (!$values['statustext'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Statustext not entered!'));
+ }
+
+ if (!$values['column_info']['type'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Datatype type not choosen!'));
+ }
+
+
if(!ctype_digit($values['column_info']['precision']))
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter precision as integer !'));
+
unset($values['column_info']['precision']);
+ }
+
+
if(!ctype_digit($values['column_info']['scale']))
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter scale as integer !'));
+ unset($values['column_info']['scale']);
+ }
+
+ if (!$values['column_info']['nullable'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Nullable not choosen!'));
+ }
+
+
+ if (!$receipt['error'])
+ {
+ $receipt =
$this->bo->save_attrib($values,$action);
+
+ if(!$id)
+ {
+ $id=$receipt['id'];
+ }
+ }
+ else
+ {
+ $receipt['error'][] = array('msg'
=> lang('Attribute has NOT been saved'));
+ }
+
+ }
+
+ if ($id)
+ {
+ $values = $this->bo->read_single_attrib($id);
+ $function_msg = lang('edit attribute') . ': ' .
lang($this->role);
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add attribute') . ': ' .
lang($this->role);
+ $action='add';
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiactor.edit_attrib',
+ 'id' => $id,
+ 'role' => $this->role
+
+ );
+ //html_print_r($values);
+
+ if($values['column_info']['type']=='R' ||
$values['column_info']['type']=='CH' || $values['column_info']['type']=='LB')
+ {
+ $multiple_choice= True;
+ }
+
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'lang_choice' =>
lang('Choice'),
+ 'lang_new_value' =>
lang('New value'),
+ 'lang_new_value_statustext' => lang('New
value for mulitple choice'),
+ 'multiple_choice' =>
$multiple_choice,
+ 'value_choice' =>
$values['choice'],
+ 'lang_delete_value' =>
lang('Delete value'),
+ 'lang_value' =>
lang('value'),
+ 'lang_delete_choice_statustext'=> lang('Delete
this value from the list of multiple choice'),
+ //'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiactor.list_attribute&type_id='.$type_id
. '&role=' . $this->role),
+ 'lang_id'
=> lang('Attribute ID'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id'
=> $id,
+
+ 'lang_column_name'
=> lang('Column name'),
+ 'value_column_name'
=> $values['column_name'],
+ 'lang_column_name_statustext' => lang('enter
the name for the column'),
+
+ 'lang_input_text'
=> lang('input text'),
+ 'value_input_text'
=> $values['input_text'],
+ 'lang_input_name_statustext' => lang('enter
the input text for records'),
+
+ 'lang_id_attribtext' => lang('Enter
the attribute ID'),
+ 'lang_entity_statustext' => lang('Select
a actor type'),
+
+ 'lang_statustext' =>
lang('Statustext'),
+ 'lang_statustext_attribtext'=> lang('Enter a
statustext for the inputfield in forms'),
+ 'value_statustext' =>
$values['statustext'],
+
+ 'lang_done_attribtext' => lang('Back
to the list'),
+ 'lang_save_attribtext' => lang('Save
the attribute'),
+
+ 'lang_datatype' =>
lang('Datatype'),
+ 'lang_datatype_statustext' => lang('Select
a datatype'),
+ 'lang_no_datatype' =>
lang('No datatype'),
+ 'datatype_list' =>
$this->bocommon->select_datatype($values['column_info']['type']),
+
+ 'lang_precision' =>
lang('Precision'),
+ 'lang_precision_statustext' => lang('enter
the record length'),
+ 'value_precision' =>
$values['column_info']['precision'],
+
+ 'lang_scale' =>
lang('scale'),
+ 'lang_scale_statustext' => lang('enter
the scale if type is decimal'),
+ 'value_scale' =>
$values['column_info']['scale'],
+
+ 'lang_default' =>
lang('default'),
+ 'lang_default_statustext' => lang('enter
the default value'),
+ 'value_default' =>
$values['column_info']['default'],
+
+ 'lang_nullable' =>
lang('Nullable'),
+ 'lang_nullable_statustext' => lang('Chose
if this column is nullable'),
+ 'lang_select_nullable' => lang('Select
nullable'),
+ 'nullable_list' =>
$this->bocommon->select_nullable($values['column_info']['nullable']),
+
+ 'value_list' =>
$values['list'],
+ 'lang_list'
=> lang('show in list'),
+ 'lang_list_statustext' => lang('check
to show this attribute in location list'),
+
+ 'value_search' =>
$values['search'],
+ 'lang_include_search' =>
lang('Include in search'),
+ 'lang_include_search_statustext'=> lang('check
to show this attribute in location list'),
+
+
+ );
+ //html_print_r($data);
+
+ $appname
= lang('actor');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_attrib' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+ }
?>
\ No newline at end of file
Index: property/inc/class.uiadmin.inc.php
diff -u property/inc/class.uiadmin.inc.php:1.9
property/inc/class.uiadmin.inc.php:1.10
--- property/inc/class.uiadmin.inc.php:1.9 Thu May 12 21:26:28 2005
+++ property/inc/class.uiadmin.inc.php Fri Jan 27 14:05:43 2006
@@ -1,690 +1,690 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.uiadmin.inc.php,v 1.9 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uiadmin
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
- var $submodule_id;
- var $permission;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'list_acl2' => True,
- 'aclprefs' => True,
- 'edit_id' => True,
- 'contact_info' => True
- );
-
- function uiadmin()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- $this->bo =
CreateObject($this->currentapp.'.boadmin',true);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $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->location =
$this->bo->location;
- $this->granting_group =
$this->bo->granting_group;
- $this->allrows =
$this->bo->allrows;
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' => $this->filter,
- 'cat_id' => $this->cat_id,
- 'location' => $this->location,
- 'granting_group' =>
$this->granting_group,
- 'allrows' => $this->allrows
- );
-
- $this->bo->save_sessiondata($data);
- }
-
- function aclprefs()
- {
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('admin','nextmatchs',
-
'search_field'));
-
- $values =
get_var('values',array('POST'));
- $r_processed = get_var('processed',array('POST'));
- $acl_app =
get_var('acl_app',array('GET'));
- $set_permission =
get_var('set_permission',array('POST'));
-
- $app_id =
$GLOBALS['phpgw']->applications->data[$acl_app]['id'];
-
- if($set_permission)
- {
- $receipt =
$this->bo->set_grant($values,$r_processed);
- }
-
- if ($this->location)
- {
- if(!$this->cat_id || $this->cat_id=='accounts')
- {
- $user_list =
$this->bo->get_user_list('accounts',$app_id);
- }
-
- while (is_array($user_list) && list(,$user) =
each($user_list))
- {
- $processed[] = $user['account_id'];
- $users[] = array
- (
- 'account_id'
=> $user['account_id'],
- 'lid'
=> $user['account_lid'],
- 'name'
=> $user['account_firstname'] . ' ' . $user['account_lastname'],
- 'read_right'
=> $user['right'][1],
- 'add_right'
=> $user['right'][2],
- 'edit_right'
=> $user['right'][4],
- 'delete_right'
=> $user['right'][8],
- 'read_mask'
=> $user['mask'][1],
- 'add_mask'
=> $user['mask'][2],
- 'edit_mask'
=> $user['mask'][4],
- 'delete_mask'
=> $user['mask'][8],
- 'read_result'
=> $user['result'][1],
- 'add_result'
=> $user['result'][2],
- 'edit_result'
=> $user['result'][4],
- 'delete_result'
=> $user['result'][8],
- 'lang_right'
=> lang('right'),
- 'lang_mask'
=> lang('mask'),
- 'lang_result'
=> lang('result'),
- 'lang_read'
=> lang('Read'), //1
- 'lang_add'
=> lang('Add'), //2
- 'lang_edit'
=> lang('Edit'), //4
- 'lang_delete'
=> lang('Delete'), //8
- 'type'
=> 'users'
- );
- }
-
- if(!$this->cat_id || $this->cat_id=='groups')
- {
- $group_list =
$this->bo->get_user_list('groups',$app_id);
- }
-
-
- while (is_array($group_list) && list(,$group) =
each($group_list))
- {
- $processed[] = $group['account_id'];
- $groups[] = array
- (
- 'account_id'
=> $group['account_id'],
- 'lid'
=> $group['account_lid'],
- 'name'
=> $group['account_firstname'],
- 'read_right'
=> $group['right'][1],
- 'add_right'
=> $group['right'][2],
- 'edit_right'
=> $group['right'][4],
- 'delete_right'
=> $group['right'][8],
- 'read_mask'
=> $group['mask'][1],
- 'add_mask'
=> $group['mask'][2],
- 'edit_mask'
=> $group['mask'][4],
- 'delete_mask'
=> $group['mask'][8],
- 'read_result'
=> $group['result'][1],
- 'add_result'
=> $group['result'][2],
- 'edit_result'
=> $group['result'][4],
- 'delete_result'
=> $group['result'][8],
- 'lang_right'
=> lang('right'),
- 'lang_mask'
=> lang('mask'),
- 'lang_result'
=> lang('result'),
- 'lang_read'
=> lang('Read'), //1
- 'lang_add'
=> lang('Add'), //2
- 'lang_edit'
=> lang('Edit'), //4
- 'lang_delete'
=> lang('Delete'), //8
- 'type'
=> 'groups'
- );
- }
-
- address@hidden("_", $processed);
- }
-
-
- $table_header[] = array
- (
- 'lang_read'
=> lang('Read'), //1
- 'lang_add'
=> lang('Add'), //2
- 'lang_edit'
=> lang('Edit'), //4
- 'lang_delete' =>
lang('Delete'), //8
- 'lang_manager' =>
lang('Manager') //16
- );
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin.aclprefs',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query,
- 'module'
=> $this->location,
- 'granting_group' =>
$this->granting_group
- );
-
- if(!$this->location)
- {
- $receipt['error'][] = array('msg' =>
lang('select a location!'));
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=> $GLOBALS['phpgw']->link('/preferences/index.php'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'processed'
=> $processed,
- 'location'
=> $this->location,
- 'links'
=> $links,
- 'allow_allrows'
=> false,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($user_list)+count($group_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin.aclprefs'),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
-
- 'lang_groups'
=> lang('groups'),
- 'lang_users'
=> lang('users'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the permissions belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $this->bo->select_category_list('filter',$this->cat_id),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'cat_id'
=> $this->cat_id,
- 'permission'
=> False,
- 'grant'
=> 1,
-
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_permission' =>
$table_header,
- 'values_groups'
=> $groups,
- 'values_users'
=> $users,
- 'lang_no_location'
=> lang('No location'),
- 'lang_location_statustext' =>
lang('Select submodule'),
- 'select_name_location' =>
'module',
- 'location_list'
=> $this->bo->select_location('filter',$this->location,True),
-
- 'is_admin'
=> $GLOBALS['phpgw_info']['user']['apps']['admin'],
- 'lang_group_statustext' =>
lang('Select the granting group. To do not use a granting group select NO
GRANTING GROUP'),
- 'select_group_name'
=> 'granting_group',
- 'lang_no_group'
=> lang('No granting group'),
- 'group_list'
=>
$this->bocommon->get_group_list('filter',$this->granting_group,$start=-1,$sort='ASC',$order='account_firstname',$query='',$offset=-1),
- );
-
- $appname
= lang('preferences');
- $function_msg =
lang('set grants');
- $owner_name =
$GLOBALS['phpgw']->accounts->id2name($GLOBALS['phpgw']->accounts->account_id);
// get owner name for title
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg . ': ' .
$owner_name;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_permission' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
-
- }
-
- function list_acl2()
- {
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('admin','nextmatchs',
-
'search_field'));
-
- $values =
get_var('values',array('POST'));
- $r_processed = get_var('processed',array('POST'));
- $initials =
get_var('initials',array('POST'));
-
- $set_permission =
get_var('set_permission',array('POST'));
-
- if($set_permission)
- {
- $receipt =
$this->bo->set_permission($values,$r_processed,$initials);
- }
-
- if ($this->location)
- {
- if($this->cat_id=='accounts')
- {
- $user_list =
$this->bo->get_user_list2('accounts',$app_id);
- }
-
- if (isSet($user_list) AND is_array($user_list))
- {
- foreach($user_list as $user)
- {
- $processed[] =
$user['account_id'];
- $users[] = array
- (
- 'account_id'
=> $user['account_id'],
- 'lid'
=> $user['account_lid'],
- 'name'
=> $user['account_firstname'] . ' ' .
$user['account_lastname'] . ' [' . $user['account_lid'] . ']',
- 'read_right'
=> $user['right'][1],
- 'add_right'
=> $user['right'][2],
- 'edit_right'
=> $user['right'][4],
- 'delete_right'
=> $user['right'][8],
- 'manage_right'
=> $user['right'][16],
- 'janitor_right'
=> $user['right'][32],
- 'supervisor_right'
=> $user['right'][64],
-
'budget_responsible_right' => $user['right'][128],
- 'read_mask'
=> $user['mask'][1],
- 'add_mask'
=> $user['mask'][2],
- 'edit_mask'
=> $user['mask'][4],
- 'delete_mask'
=> $user['mask'][8],
- 'manage_mask'
=> $user['mask'][16],
- 'janitor_mask'
=> $user['mask'][32],
- 'supervisor_mask'
=> $user['mask'][64],
-
'budget_responsible_mask' => $user['mask'][128],
- 'read_result'
=> $user['result'][1],
- 'add_result'
=> $user['result'][2],
- 'edit_result'
=> $user['result'][4],
- 'delete_result'
=> $user['result'][8],
- 'manage_result'
=> $user['result'][16],
- 'janitor_result'
=> $user['result'][32],
- 'supervisor_result'
=> $user['result'][64],
-
'budget_responsible_result' => $user['result'][128],
- 'initials'
=> $user['initials'],
- 'lang_right'
=> lang('right'),
- 'lang_mask'
=> lang('mask'),
- 'lang_result'
=> lang('result'),
- 'lang_read'
=> lang('Read'), //1
- 'lang_add'
=> lang('Add'), //2
- 'lang_edit'
=> lang('Edit'), //4
- 'lang_delete'
=> lang('Delete'), //8
- 'lang_manage'
=> lang('Manage'), //16
- 'lang_janitor'
=> lang('Janitor'), //32
- 'lang_supervisor'
=> lang('Supervisor'), //64
-
'lang_budget_responsible' => lang('Budget Responsible'), //128
- 'lang_initials'
=> lang('Initials'),
- 'type'
=> 'users'
- );
- }
- }
-
- if($this->cat_id=='groups')
- {
- $group_list =
$this->bo->get_user_list2('groups',$app_id);
- }
-
- if (isSet($group_list) AND
is_array($group_list))
- {
- foreach($group_list as $group)
- {
- $processed[] =
$group['account_id'];
- $groups[] = array
- (
- 'account_id'
=> $group['account_id'],
- 'lid'
=> $group['account_lid'],
- 'name'
=> $group['account_firstname'],
- 'read_right'
=> $group['right'][1],
- 'add_right'
=> $group['right'][2],
- 'edit_right'
=> $group['right'][4],
- 'delete_right'
=> $group['right'][8],
- 'manage_right'
=> $group['right'][16],
- 'read_mask'
=> $group['mask'][1],
- 'add_mask'
=> $group['mask'][2],
- 'edit_mask'
=> $group['mask'][4],
- 'delete_mask'
=> $group['mask'][8],
- 'manage_mask'
=> $group['mask'][16],
- 'read_result'
=> $group['result'][1],
- 'add_result'
=> $group['result'][2],
- 'edit_result'
=> $group['result'][4],
- 'delete_result'
=> $group['result'][8],
- 'manage_result'
=> $group['result'][16],
- 'initials'
=> $group['initials'],
- 'lang_right'
=> lang('right'),
- 'lang_mask'
=> lang('mask'),
- 'lang_result'
=> lang('result'),
- 'lang_read'
=> lang('Read'), //1
- 'lang_add'
=> lang('Add'), //2
- 'lang_edit'
=> lang('Edit'), //4
- 'lang_delete'
=> lang('Delete'), //8
- 'lang_manage'
=> lang('Manage'), //16
- 'lang_janitor'
=> lang('Janitor'), //32
- 'lang_supervisor'
=> lang('Supervisor'), //64
-
'lang_budget_responsible' => lang('Budget Responsible'), //128
- 'lang_initials'
=> lang('Initials'),
- 'type'
=> 'groups'
- );
- }
- }
-
-
- address@hidden("_", $processed);
- }
-
-
- $table_header[] = array
- (
- 'sort_lid' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'account_lid',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin.list_acl2',
-
'cat_id'
=>$this->cat_id,
-
'query'
=>$this->query,
-
'module'
=> $this->location,
-
'submodule_id'
=>$this->submodule_id)
-
)),
- 'sort_lastname' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'account_lastname',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin.list_acl2',
-
'cat_id'
=>$this->cat_id,
-
'query'
=>$this->query,
-
'module'
=> $this->location,
-
'submodule_id'
=>$this->submodule_id)
-
)),
- 'sort_firstname' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'account_firstname',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin.list_acl2',
-
'cat_id'
=>$this->cat_id,
-
'query'
=>$this->query,
-
'module'
=> $this->location,
-
'submodule_id'
=>$this->submodule_id)
-
)),
-
-
- 'lang_values' =>
lang('values'),
- 'lang_read'
=> lang('Read'), //1
- 'lang_add'
=> lang('Add'), //2
- 'lang_edit'
=> lang('Edit'), //4
- 'lang_delete' =>
lang('Delete'), //8
- 'lang_manager' =>
lang('Manager'), //16
- 'lang_janitor' =>
lang('Janitor'), //32
- 'lang_supervisor' =>
lang('Supervisor'), //64
- 'lang_budget_responsible' => lang('Budget
Responsible'), //128
- 'lang_initials' =>
lang('Initials')
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin.list_acl2',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query,
- 'module' =>
$this->location
-
- );
-
- if(!$this->location)
- {
- $receipt['error'][] = array('msg' =>
lang('select a location!'));
- }
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'allrows'
=> $this->allrows,
- 'allow_allrows'
=> true,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
-
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=> $GLOBALS['phpgw']->link('/admin/index.php'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'processed'
=> $processed,
- 'location'
=> $this->location,
- 'links'
=> $links,
-
- 'num_records'
=> count($user_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
-
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the permissions belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $this->bo->select_category_list('filter',$this->cat_id),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'cat_id'
=> $this->cat_id,
- 'permission'
=> 1,
-
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_permission' =>
$table_header,
- // 'table_header_acl2'
=> $table_header,
- // 'values_acl2'
=> $content,
- 'values_groups'
=> $groups,
- 'values_users'
=> $users,
- 'lang_groups'
=> lang('groups'),
- 'lang_users'
=> lang('users'),
-
- 'lang_no_location'
=> lang('No location'),
- 'lang_location_statustext' =>
lang('Select submodule'),
- 'select_name_location' =>
'module',
- 'location_list'
=> $this->bo->select_location('filter',$this->location,False)
- );
-
- $appname
= lang('permission');
- $function_msg =
lang('set permission');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_permission' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit_id()
- {
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('admin'));
-
- $values = get_var('values',array('POST'));
-
- if ($values['select'])
- {
- $receipt = $this->bo->edit_id($values);
- }
-
- $fm_ids = $this->bo->read_fm_id();
-
- for ($i=0;$i<count($fm_ids);$i++)
- {
-
- $content[] = array
- (
- 'descr' => $fm_ids[$i]['descr'],
- 'value' => $fm_ids[$i]['value'],
- 'remark' =>
$fm_ids[$i]['remark'],
- 'key_id' => $i
- );
- }
-
- $table_header[] = array
- (
- 'lang_select' => lang('Select'),
- 'lang_descr' => lang('Descr'),
- 'lang_value' => lang('Value'),
- 'lang_remark' => lang('Remark'),
- );
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin.edit_id'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php'),
- 'lang_submit' =>
lang('submit'),
- 'lang_save' =>
lang('Edit'),
- 'lang_add_statustext' => lang('Edit ID'),
- 'lang_done' =>
lang('done'),
- 'lang_done_statustext' => lang('Back to
Admin'),
- 'lang_select' =>
lang('Select'),
- 'lang_descr' =>
lang('Descr'),
- 'lang_value' =>
lang('Value'),
- 'lang_remark' =>
lang('Remark'),
- 'id_table_header' =>
$table_header,
- 'id_values' =>
$content,
- );
-
- $appname
= lang('ID');
- $function_msg =
lang('edit ID');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_id' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function contact_info()
- {
- $GLOBALS['phpgw']->xslttpl->add_file(array('admin'));
-
- $values = get_var('values',array('POST'));
-
- if ($values['save'])
- {
-
$GLOBALS['phpgw']->preferences->account_id=$this->filter;
-
$GLOBALS['phpgw']->preferences->read_repository();
-
- if ($values['old_email'] != $values['email'])
- {
-
$GLOBALS['phpgw']->preferences->add($this->currentapp,"email",$values['email'],'user');
- $receipt['message'][] = array('msg' =>
lang('Users email is updated'));
- }
- if ($values['old_phone'] != $values['phone'])
- {
-
$GLOBALS['phpgw']->preferences->add($this->currentapp,"cellphone",$values['phone'],'user');
- $receipt['message'][] = array('msg' =>
lang('Users phone is updated'));
- }
- if ($values['old_approval_from'] !=
$values['approval_from'])
- {
-
$GLOBALS['phpgw']->preferences->add($this->currentapp,"approval_from",$values['approval_from'],'user');
- $receipt['message'][] = array('msg' =>
lang('Approval from is updated'));
- }
- if ($values['old_default_vendor_category'] !=
$values['default_vendor_category'])
- {
-
$GLOBALS['phpgw']->preferences->add($this->currentapp,"default_vendor_category",$values['default_vendor_category'],'user');
- $receipt['message'][] = array('msg' =>
lang('default vendor category is updated'));
- }
-
$GLOBALS['phpgw']->preferences->save_repository();
- }
-
- if($this->filter)
- {
- $prefs =
$this->bocommon->create_preferences($this->currentapp,$this->filter);
- }
-
- $cats = CreateObject('phpgwapi.categories');
- $cats->app_name = 'fm_vendor';
-
- $cat_data =
$cats->formatted_xslt_list(array('selected' =>
$prefs['default_vendor_category'],'globals' => True, 'link_data' =>array()));
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin.contact_info'),
- 'done_action'
=> $GLOBALS['phpgw']->link('/admin/index.php'),
- 'lang_submit'
=> lang('submit'),
- 'lang_save'
=> lang('Edit'),
- 'lang_add_statustext' =>
lang('Edit ID'),
- 'lang_done'
=> lang('done'),
- 'lang_done_statustext' =>
lang('Back to Admin'),
-
- 'lang_email_statustext' =>
lang('Enter the email-address for this user'),
-
- 'lang_user'
=> lang('User'),
- 'lang_email'
=> lang('Email'),
- 'value_old_email'
=> $prefs['email'],
- 'value_email'
=> $prefs['email'],
-
- 'lang_phone'
=> lang('Phone'),
- 'value_old_phone'
=> $prefs['cellphone'],
- 'value_phone'
=> $prefs['cellphone'],
-
- 'lang_approval_from' =>
lang('Approval from'),
- 'value_old_approval_from' =>
$prefs['approval_from'],
- 'approval_from'
=>
$this->bocommon->get_user_list('select',$prefs['approval_from'],$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
-
- 'select_user_name'
=> 'approval_from',
- 'lang_approval_from_statustext' => lang('Select
the users supervisor'),
-
- 'lang_default_vendor_category' =>
lang('default vendor category'),
- 'value_old_default_vendor_category' =>
$prefs['default_vendor_category'],
- 'vendor_category'
=> $cat_data['cat_list'],
- 'select_user_name'
=> 'approval_from',
- 'lang_default_vendor_category_statustext'
=> lang('Select default vendor category'),
- 'lang_no_cat'
=> lang('No category'),
-
-
- 'lang_user_statustext' =>
lang('Select the user to edit email'),
- 'select_user_name'
=> 'filter',
- 'lang_no_user'
=> lang('No user'),
- 'value_user_id'
=> $this->filter,
- 'user_list'
=>
$this->bocommon->get_user_list('filter',$this->filter,$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
- );
-
- $appname
= lang('User contact info');
- $function_msg
= lang('edit info');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('contact_info' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.uiadmin.inc.php,v 1.10 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uiadmin
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+ var $submodule_id;
+ var $permission;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'list_acl2' => True,
+ 'aclprefs' => True,
+ 'edit_id' => True,
+ 'contact_info' => True
+ );
+
+ function uiadmin()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $this->bo =
CreateObject($this->currentapp.'.boadmin',true);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+
+ $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->location =
$this->bo->location;
+ $this->granting_group =
$this->bo->granting_group;
+ $this->allrows =
$this->bo->allrows;
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' => $this->filter,
+ 'cat_id' => $this->cat_id,
+ 'location' => $this->location,
+ 'granting_group' =>
$this->granting_group,
+ 'allrows' => $this->allrows
+ );
+
+ $this->bo->save_sessiondata($data);
+ }
+
+ function aclprefs()
+ {
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('admin','nextmatchs',
+
'search_field'));
+
+ $values =
get_var('values',array('POST'));
+ $r_processed = get_var('processed',array('POST'));
+ $acl_app =
get_var('acl_app',array('GET'));
+ $set_permission =
get_var('set_permission',array('POST'));
+
+ $app_id =
$GLOBALS['phpgw']->applications->data[$acl_app]['id'];
+
+ if($set_permission)
+ {
+ $receipt =
$this->bo->set_grant($values,$r_processed);
+ }
+
+ if ($this->location)
+ {
+ if(!$this->cat_id || $this->cat_id=='accounts')
+ {
+ $user_list =
$this->bo->get_user_list('accounts',$app_id);
+ }
+
+ while (is_array($user_list) && list(,$user) =
each($user_list))
+ {
+ $processed[] = $user['account_id'];
+ $users[] = array
+ (
+ 'account_id'
=> $user['account_id'],
+ 'lid'
=> $user['account_lid'],
+ 'name'
=> $user['account_firstname'] . ' ' . $user['account_lastname'],
+ 'read_right'
=> $user['right'][1],
+ 'add_right'
=> $user['right'][2],
+ 'edit_right'
=> $user['right'][4],
+ 'delete_right'
=> $user['right'][8],
+ 'read_mask'
=> $user['mask'][1],
+ 'add_mask'
=> $user['mask'][2],
+ 'edit_mask'
=> $user['mask'][4],
+ 'delete_mask'
=> $user['mask'][8],
+ 'read_result'
=> $user['result'][1],
+ 'add_result'
=> $user['result'][2],
+ 'edit_result'
=> $user['result'][4],
+ 'delete_result'
=> $user['result'][8],
+ 'lang_right'
=> lang('right'),
+ 'lang_mask'
=> lang('mask'),
+ 'lang_result'
=> lang('result'),
+ 'lang_read'
=> lang('Read'), //1
+ 'lang_add'
=> lang('Add'), //2
+ 'lang_edit'
=> lang('Edit'), //4
+ 'lang_delete'
=> lang('Delete'), //8
+ 'type'
=> 'users'
+ );
+ }
+
+ if(!$this->cat_id || $this->cat_id=='groups')
+ {
+ $group_list =
$this->bo->get_user_list('groups',$app_id);
+ }
+
+
+ while (is_array($group_list) && list(,$group) =
each($group_list))
+ {
+ $processed[] = $group['account_id'];
+ $groups[] = array
+ (
+ 'account_id'
=> $group['account_id'],
+ 'lid'
=> $group['account_lid'],
+ 'name'
=> $group['account_firstname'],
+ 'read_right'
=> $group['right'][1],
+ 'add_right'
=> $group['right'][2],
+ 'edit_right'
=> $group['right'][4],
+ 'delete_right'
=> $group['right'][8],
+ 'read_mask'
=> $group['mask'][1],
+ 'add_mask'
=> $group['mask'][2],
+ 'edit_mask'
=> $group['mask'][4],
+ 'delete_mask'
=> $group['mask'][8],
+ 'read_result'
=> $group['result'][1],
+ 'add_result'
=> $group['result'][2],
+ 'edit_result'
=> $group['result'][4],
+ 'delete_result'
=> $group['result'][8],
+ 'lang_right'
=> lang('right'),
+ 'lang_mask'
=> lang('mask'),
+ 'lang_result'
=> lang('result'),
+ 'lang_read'
=> lang('Read'), //1
+ 'lang_add'
=> lang('Add'), //2
+ 'lang_edit'
=> lang('Edit'), //4
+ 'lang_delete'
=> lang('Delete'), //8
+ 'type'
=> 'groups'
+ );
+ }
+
+ address@hidden("_", $processed);
+ }
+
+
+ $table_header[] = array
+ (
+ 'lang_read'
=> lang('Read'), //1
+ 'lang_add'
=> lang('Add'), //2
+ 'lang_edit'
=> lang('Edit'), //4
+ 'lang_delete' =>
lang('Delete'), //8
+ 'lang_manager' =>
lang('Manager') //16
+ );
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin.aclprefs',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query,
+ 'module'
=> $this->location,
+ 'granting_group' =>
$this->granting_group
+ );
+
+ if(!$this->location)
+ {
+ $receipt['error'][] = array('msg' =>
lang('select a location!'));
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=> $GLOBALS['phpgw']->link('/preferences/index.php'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'processed'
=> $processed,
+ 'location'
=> $this->location,
+ 'links'
=> $links,
+ 'allow_allrows'
=> false,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($user_list)+count($group_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin.aclprefs'),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+
+ 'lang_groups'
=> lang('groups'),
+ 'lang_users'
=> lang('users'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the permissions belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $this->bo->select_category_list('filter',$this->cat_id),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'cat_id'
=> $this->cat_id,
+ 'permission'
=> False,
+ 'grant'
=> 1,
+
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_permission' =>
$table_header,
+ 'values_groups'
=> $groups,
+ 'values_users'
=> $users,
+ 'lang_no_location'
=> lang('No location'),
+ 'lang_location_statustext' =>
lang('Select submodule'),
+ 'select_name_location' =>
'module',
+ 'location_list'
=> $this->bo->select_location('filter',$this->location,True),
+
+ 'is_admin'
=> $GLOBALS['phpgw_info']['user']['apps']['admin'],
+ 'lang_group_statustext' =>
lang('Select the granting group. To do not use a granting group select NO
GRANTING GROUP'),
+ 'select_group_name'
=> 'granting_group',
+ 'lang_no_group'
=> lang('No granting group'),
+ 'group_list'
=>
$this->bocommon->get_group_list('filter',$this->granting_group,$start=-1,$sort='ASC',$order='account_firstname',$query='',$offset=-1),
+ );
+
+ $appname
= lang('preferences');
+ $function_msg =
lang('set grants');
+ $owner_name =
$GLOBALS['phpgw']->accounts->id2name($GLOBALS['phpgw']->accounts->account_id);
// get owner name for title
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg . ': ' .
$owner_name;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_permission' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+
+ }
+
+ function list_acl2()
+ {
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('admin','nextmatchs',
+
'search_field'));
+
+ $values =
get_var('values',array('POST'));
+ $r_processed = get_var('processed',array('POST'));
+ $initials =
get_var('initials',array('POST'));
+
+ $set_permission =
get_var('set_permission',array('POST'));
+
+ if($set_permission)
+ {
+ $receipt =
$this->bo->set_permission($values,$r_processed,$initials);
+ }
+
+ if ($this->location)
+ {
+ if($this->cat_id=='accounts')
+ {
+ $user_list =
$this->bo->get_user_list2('accounts',$app_id);
+ }
+
+ if (isSet($user_list) AND is_array($user_list))
+ {
+ foreach($user_list as $user)
+ {
+ $processed[] =
$user['account_id'];
+ $users[] = array
+ (
+ 'account_id'
=> $user['account_id'],
+ 'lid'
=> $user['account_lid'],
+ 'name'
=> $user['account_firstname'] . ' ' .
$user['account_lastname'] . ' [' . $user['account_lid'] . ']',
+ 'read_right'
=> $user['right'][1],
+ 'add_right'
=> $user['right'][2],
+ 'edit_right'
=> $user['right'][4],
+ 'delete_right'
=> $user['right'][8],
+ 'manage_right'
=> $user['right'][16],
+ 'janitor_right'
=> $user['right'][32],
+ 'supervisor_right'
=> $user['right'][64],
+
'budget_responsible_right' => $user['right'][128],
+ 'read_mask'
=> $user['mask'][1],
+ 'add_mask'
=> $user['mask'][2],
+ 'edit_mask'
=> $user['mask'][4],
+ 'delete_mask'
=> $user['mask'][8],
+ 'manage_mask'
=> $user['mask'][16],
+ 'janitor_mask'
=> $user['mask'][32],
+ 'supervisor_mask'
=> $user['mask'][64],
+
'budget_responsible_mask' => $user['mask'][128],
+ 'read_result'
=> $user['result'][1],
+ 'add_result'
=> $user['result'][2],
+ 'edit_result'
=> $user['result'][4],
+ 'delete_result'
=> $user['result'][8],
+ 'manage_result'
=> $user['result'][16],
+ 'janitor_result'
=> $user['result'][32],
+ 'supervisor_result'
=> $user['result'][64],
+
'budget_responsible_result' => $user['result'][128],
+ 'initials'
=> $user['initials'],
+ 'lang_right'
=> lang('right'),
+ 'lang_mask'
=> lang('mask'),
+ 'lang_result'
=> lang('result'),
+ 'lang_read'
=> lang('Read'), //1
+ 'lang_add'
=> lang('Add'), //2
+ 'lang_edit'
=> lang('Edit'), //4
+ 'lang_delete'
=> lang('Delete'), //8
+ 'lang_manage'
=> lang('Manage'), //16
+ 'lang_janitor'
=> lang('Janitor'), //32
+ 'lang_supervisor'
=> lang('Supervisor'), //64
+
'lang_budget_responsible' => lang('Budget Responsible'), //128
+ 'lang_initials'
=> lang('Initials'),
+ 'type'
=> 'users'
+ );
+ }
+ }
+
+ if($this->cat_id=='groups')
+ {
+ $group_list =
$this->bo->get_user_list2('groups',$app_id);
+ }
+
+ if (isSet($group_list) AND
is_array($group_list))
+ {
+ foreach($group_list as $group)
+ {
+ $processed[] =
$group['account_id'];
+ $groups[] = array
+ (
+ 'account_id'
=> $group['account_id'],
+ 'lid'
=> $group['account_lid'],
+ 'name'
=> $group['account_firstname'],
+ 'read_right'
=> $group['right'][1],
+ 'add_right'
=> $group['right'][2],
+ 'edit_right'
=> $group['right'][4],
+ 'delete_right'
=> $group['right'][8],
+ 'manage_right'
=> $group['right'][16],
+ 'read_mask'
=> $group['mask'][1],
+ 'add_mask'
=> $group['mask'][2],
+ 'edit_mask'
=> $group['mask'][4],
+ 'delete_mask'
=> $group['mask'][8],
+ 'manage_mask'
=> $group['mask'][16],
+ 'read_result'
=> $group['result'][1],
+ 'add_result'
=> $group['result'][2],
+ 'edit_result'
=> $group['result'][4],
+ 'delete_result'
=> $group['result'][8],
+ 'manage_result'
=> $group['result'][16],
+ 'initials'
=> $group['initials'],
+ 'lang_right'
=> lang('right'),
+ 'lang_mask'
=> lang('mask'),
+ 'lang_result'
=> lang('result'),
+ 'lang_read'
=> lang('Read'), //1
+ 'lang_add'
=> lang('Add'), //2
+ 'lang_edit'
=> lang('Edit'), //4
+ 'lang_delete'
=> lang('Delete'), //8
+ 'lang_manage'
=> lang('Manage'), //16
+ 'lang_janitor'
=> lang('Janitor'), //32
+ 'lang_supervisor'
=> lang('Supervisor'), //64
+
'lang_budget_responsible' => lang('Budget Responsible'), //128
+ 'lang_initials'
=> lang('Initials'),
+ 'type'
=> 'groups'
+ );
+ }
+ }
+
+
+ address@hidden("_", $processed);
+ }
+
+
+ $table_header[] = array
+ (
+ 'sort_lid' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'account_lid',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin.list_acl2',
+
'cat_id'
=>$this->cat_id,
+
'query'
=>$this->query,
+
'module'
=> $this->location,
+
'submodule_id'
=>$this->submodule_id)
+
)),
+ 'sort_lastname' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'account_lastname',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin.list_acl2',
+
'cat_id'
=>$this->cat_id,
+
'query'
=>$this->query,
+
'module'
=> $this->location,
+
'submodule_id'
=>$this->submodule_id)
+
)),
+ 'sort_firstname' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'account_firstname',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin.list_acl2',
+
'cat_id'
=>$this->cat_id,
+
'query'
=>$this->query,
+
'module'
=> $this->location,
+
'submodule_id'
=>$this->submodule_id)
+
)),
+
+
+ 'lang_values' =>
lang('values'),
+ 'lang_read'
=> lang('Read'), //1
+ 'lang_add'
=> lang('Add'), //2
+ 'lang_edit'
=> lang('Edit'), //4
+ 'lang_delete' =>
lang('Delete'), //8
+ 'lang_manager' =>
lang('Manager'), //16
+ 'lang_janitor' =>
lang('Janitor'), //32
+ 'lang_supervisor' =>
lang('Supervisor'), //64
+ 'lang_budget_responsible' => lang('Budget
Responsible'), //128
+ 'lang_initials' =>
lang('Initials')
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin.list_acl2',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query,
+ 'module' =>
$this->location
+
+ );
+
+ if(!$this->location)
+ {
+ $receipt['error'][] = array('msg' =>
lang('select a location!'));
+ }
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'allrows'
=> $this->allrows,
+ 'allow_allrows'
=> true,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=> $GLOBALS['phpgw']->link('/admin/index.php'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'processed'
=> $processed,
+ 'location'
=> $this->location,
+ 'links'
=> $links,
+
+ 'num_records'
=> count($user_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the permissions belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $this->bo->select_category_list('filter',$this->cat_id),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'cat_id'
=> $this->cat_id,
+ 'permission'
=> 1,
+
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_permission' =>
$table_header,
+ // 'table_header_acl2'
=> $table_header,
+ // 'values_acl2'
=> $content,
+ 'values_groups'
=> $groups,
+ 'values_users'
=> $users,
+ 'lang_groups'
=> lang('groups'),
+ 'lang_users'
=> lang('users'),
+
+ 'lang_no_location'
=> lang('No location'),
+ 'lang_location_statustext' =>
lang('Select submodule'),
+ 'select_name_location' =>
'module',
+ 'location_list'
=> $this->bo->select_location('filter',$this->location,False)
+ );
+
+ $appname
= lang('permission');
+ $function_msg =
lang('set permission');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_permission' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit_id()
+ {
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('admin'));
+
+ $values = get_var('values',array('POST'));
+
+ if ($values['select'])
+ {
+ $receipt = $this->bo->edit_id($values);
+ }
+
+ $fm_ids = $this->bo->read_fm_id();
+
+ for ($i=0;$i<count($fm_ids);$i++)
+ {
+
+ $content[] = array
+ (
+ 'descr' => $fm_ids[$i]['descr'],
+ 'value' => $fm_ids[$i]['value'],
+ 'remark' =>
$fm_ids[$i]['remark'],
+ 'key_id' => $i
+ );
+ }
+
+ $table_header[] = array
+ (
+ 'lang_select' => lang('Select'),
+ 'lang_descr' => lang('Descr'),
+ 'lang_value' => lang('Value'),
+ 'lang_remark' => lang('Remark'),
+ );
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin.edit_id'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php'),
+ 'lang_submit' =>
lang('submit'),
+ 'lang_save' =>
lang('Edit'),
+ 'lang_add_statustext' => lang('Edit ID'),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_statustext' => lang('Back to
Admin'),
+ 'lang_select' =>
lang('Select'),
+ 'lang_descr' =>
lang('Descr'),
+ 'lang_value' =>
lang('Value'),
+ 'lang_remark' =>
lang('Remark'),
+ 'id_table_header' =>
$table_header,
+ 'id_values' =>
$content,
+ );
+
+ $appname
= lang('ID');
+ $function_msg =
lang('edit ID');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_id' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function contact_info()
+ {
+ $GLOBALS['phpgw']->xslttpl->add_file(array('admin'));
+
+ $values = get_var('values',array('POST'));
+
+ if ($values['save'])
+ {
+
$GLOBALS['phpgw']->preferences->account_id=$this->filter;
+
$GLOBALS['phpgw']->preferences->read_repository();
+
+ if ($values['old_email'] != $values['email'])
+ {
+
$GLOBALS['phpgw']->preferences->add($this->currentapp,"email",$values['email'],'user');
+ $receipt['message'][] = array('msg' =>
lang('Users email is updated'));
+ }
+ if ($values['old_phone'] != $values['phone'])
+ {
+
$GLOBALS['phpgw']->preferences->add($this->currentapp,"cellphone",$values['phone'],'user');
+ $receipt['message'][] = array('msg' =>
lang('Users phone is updated'));
+ }
+ if ($values['old_approval_from'] !=
$values['approval_from'])
+ {
+
$GLOBALS['phpgw']->preferences->add($this->currentapp,"approval_from",$values['approval_from'],'user');
+ $receipt['message'][] = array('msg' =>
lang('Approval from is updated'));
+ }
+ if ($values['old_default_vendor_category'] !=
$values['default_vendor_category'])
+ {
+
$GLOBALS['phpgw']->preferences->add($this->currentapp,"default_vendor_category",$values['default_vendor_category'],'user');
+ $receipt['message'][] = array('msg' =>
lang('default vendor category is updated'));
+ }
+
$GLOBALS['phpgw']->preferences->save_repository();
+ }
+
+ if($this->filter)
+ {
+ $prefs =
$this->bocommon->create_preferences($this->currentapp,$this->filter);
+ }
+
+ $cats = CreateObject('phpgwapi.categories');
+ $cats->app_name = 'fm_vendor';
+
+ $cat_data =
$cats->formatted_xslt_list(array('selected' =>
$prefs['default_vendor_category'],'globals' => True, 'link_data' =>array()));
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin.contact_info'),
+ 'done_action'
=> $GLOBALS['phpgw']->link('/admin/index.php'),
+ 'lang_submit'
=> lang('submit'),
+ 'lang_save'
=> lang('Edit'),
+ 'lang_add_statustext' =>
lang('Edit ID'),
+ 'lang_done'
=> lang('done'),
+ 'lang_done_statustext' =>
lang('Back to Admin'),
+
+ 'lang_email_statustext' =>
lang('Enter the email-address for this user'),
+
+ 'lang_user'
=> lang('User'),
+ 'lang_email'
=> lang('Email'),
+ 'value_old_email'
=> $prefs['email'],
+ 'value_email'
=> $prefs['email'],
+
+ 'lang_phone'
=> lang('Phone'),
+ 'value_old_phone'
=> $prefs['cellphone'],
+ 'value_phone'
=> $prefs['cellphone'],
+
+ 'lang_approval_from' =>
lang('Approval from'),
+ 'value_old_approval_from' =>
$prefs['approval_from'],
+ 'approval_from'
=>
$this->bocommon->get_user_list('select',$prefs['approval_from'],$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
+
+ 'select_user_name'
=> 'approval_from',
+ 'lang_approval_from_statustext' => lang('Select
the users supervisor'),
+
+ 'lang_default_vendor_category' =>
lang('default vendor category'),
+ 'value_old_default_vendor_category' =>
$prefs['default_vendor_category'],
+ 'vendor_category'
=> $cat_data['cat_list'],
+ 'select_user_name'
=> 'approval_from',
+ 'lang_default_vendor_category_statustext'
=> lang('Select default vendor category'),
+ 'lang_no_cat'
=> lang('No category'),
+
+
+ 'lang_user_statustext' =>
lang('Select the user to edit email'),
+ 'select_user_name'
=> 'filter',
+ 'lang_no_user'
=> lang('No user'),
+ 'value_user_id'
=> $this->filter,
+ 'user_list'
=>
$this->bocommon->get_user_list('filter',$this->filter,$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
+ );
+
+ $appname
= lang('User contact info');
+ $function_msg
= lang('edit info');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('contact_info' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ }
+?>
Index: property/inc/class.uiadmin_entity.inc.php
diff -u property/inc/class.uiadmin_entity.inc.php:1.11
property/inc/class.uiadmin_entity.inc.php:1.12
--- property/inc/class.uiadmin_entity.inc.php:1.11 Wed Jan 11 10:13:32 2006
+++ property/inc/class.uiadmin_entity.inc.php Fri Jan 27 14:05:43 2006
@@ -1,1495 +1,1495 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.uiadmin_entity.inc.php,v 1.11 2006/01/11 10:13:32
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uiadmin_entity
- {
- var $grants;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'index' => True,
- 'list_status' => True,
- 'category' => True,
- 'edit' => True,
- 'edit_status' => True,
- 'edit_category' => True,
- 'view' => True,
- 'delete' => True,
- 'list_attribute' => True,
- 'edit_attrib' => True,
- 'list_custom_function'=>True,
- 'edit_custom_function' => True
- );
-
- function uiadmin_entity()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bo =
CreateObject($this->currentapp.'.boadmin_entity',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
-
- $this->start =
$this->bo->start;
- $this->query =
$this->bo->query;
- $this->sort =
$this->bo->sort;
- $this->order =
$this->bo->order;
- $this->entity_id =
$this->bo->entity_id;
- $this->cat_id =
$this->bo->cat_id;
- $this->allrows =
$this->bo->allrows;
-
- $this->menu->sub ='admin_entity';
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'allrows' => $this->allrows,
- 'entity_id' => $this->entity_id,
- 'cat_id' => $this->cat_id
- );
- $this->bo->save_sessiondata($data);
- }
-
- function index()
- {
- $this->bo->reset_fm_cache();
- $GLOBALS['phpgw']->xslttpl->add_file(array(
-
'admin_entity',
-
'nextmatchs',
-
'menu',
-
'search_field'));
- $links = $this->menu->links();
-
- $entity_list = $this->bo->read();
-
- if (isSet($entity_list) AND is_array($entity_list))
- {
- foreach($entity_list as $entry)
- {
- $content[] = array
- (
- 'id'
=> $entry['id'],
- 'name'
=> $entry['name'],
- 'descr'
=> $entry['descr'],
- 'link_categories'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.category&entity_id='
. $entry['id']),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit&id='
. $entry['id']),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.delete&entity_id='
. $entry['id']),
- 'lang_view_standardtext'
=> lang('view the standard'),
- 'lang_category_text'
=> lang('categories for the entity type'),
- 'lang_edit_standardtext'
=> lang('edit the entity'),
- 'lang_delete_standardtext'
=> lang('delete the entity'),
- 'text_categories'
=> lang('Categories'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
- }
-
-//_debug_array($content);
-
- $table_header[] = array
- (
-
- 'lang_descr' => lang('Descr'),
- 'lang_categories' => lang('Categories'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.index',
-
'allrows'=>$this->allrows)
-
)),
- 'lang_id' => lang('entity id'),
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.index',
-
'allrows'=>$this->allrows)
-
)),
- 'lang_name' => lang('Name'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_standardtext' => lang('add a
standard'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit'),
- 'lang_done' =>
lang('done'),
- 'lang_done_standardtext' => lang('back
to admin'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php')
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.index',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'query'
=>$this->query
- );
-
- $data = array
- (
- 'links'
=> $links,
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($entity_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('entity');
- $function_msg =
lang('list entity type');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function list_status()
- {
- $this->bo->reset_fm_cache();
- $GLOBALS['phpgw']->xslttpl->add_file(array(
-
'admin_entity',
-
'nextmatchs',
-
'menu',
-
'search_field'));
- $links = $this->menu->links();
-
- $list = $this->bo->read_status();
-
- if (isSet($list) AND is_array($list))
- {
- foreach($list as $entry)
- {
- $content[] = array
- (
- 'id'
=> $entry['id'],
- 'descr'
=> $entry['descr'],
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_status&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id . '&id=' . $entry['id']),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.delete&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id . '&status_id=' .
$entry['id']),
- 'lang_edit_standardtext'
=> lang('edit the entity'),
- 'lang_delete_standardtext'
=> lang('delete the entity'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
- }
-
-//_debug_array($content);
-
- $table_header[] = array
- (
-
- 'lang_descr' => lang('Descr'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.list_status',
-
'entity_id' =>
$this->entity_id,
-
'cat_id' =>
$this->cat_id
-
)
-
)),
- 'lang_id' => lang('status'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_text' => lang('add a standard'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_status&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id),
- 'lang_done' =>
lang('done'),
- 'lang_done_text' => lang('back to
admin'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.category&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id),
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.list_status',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'query'
=>$this->query,
- 'entity_id'
=>$this->entity_id,
- 'cat_id'
=>$this->cat_id
- );
-
- $entity =
$this->bo->read_single($this->entity_id,false);
- $category =
$this->bo->read_single_category($this->entity_id,$this->cat_id);
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'lang_entity'
=> lang('entity'),
- 'entity_name'
=> $entity['name'],
- 'lang_category'
=> lang('category'),
- 'category_name'
=> $category['name'],
- 'links'
=> $links,
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($entity_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_status' =>
$table_header,
- 'values_status'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('entity');
- $function_msg =
lang('list status');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_status' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function category()
- {
-
- $entity_id =
get_var('entity_id',array('POST','GET'));
-
- $GLOBALS['phpgw']->xslttpl->add_file(array(
-
'admin_entity',
-
'nextmatchs',
-
'menu',
-
'search_field'));
- $links = $this->menu->links();
-
- $category_list = $this->bo->read_category($entity_id);
-
- if (isSet($category_list) AND is_array($category_list))
- {
- foreach($category_list as $entry)
- {
- $content[] = array
- (
- 'id'
=> $entry['id'],
- 'name'
=> $entry['name'],
- 'prefix'
=> $entry['prefix'],
- 'descr'
=> $entry['descr'],
-// 'link_status'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_status&cat_id='
. $entry['id'] . '&entity_id=' . $entity_id),
- 'link_custom_function'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_custom_function&cat_id='
. $entry['id'] . '&entity_id=' . $entity_id),
- 'link_attribute'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_attribute&cat_id='
. $entry['id'] . '&entity_id=' . $entity_id),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_category&id='
. $entry['id'] . '&entity_id=' . $entity_id),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.delete&cat_id='
. $entry['id'] . '&entity_id=' . $entity_id),
- 'lang_view_standardtext'
=> lang('view the category'),
- 'lang_status_standardtext'
=> lang('Status for the entity category'),
- 'lang_attribute_standardtext'
=> lang('attributes for the entity category'),
-
'lang_custom_function_standardtext' => lang('custom functions for the
entity category'),
- 'lang_edit_standardtext'
=> lang('edit the standard'),
- 'lang_delete_standardtext'
=> lang('delete the standard'),
- 'text_status'
=> lang('Status'),
- 'text_attribute'
=> lang('Attributes'),
- 'text_custom_function'
=> lang('Custom functions'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
- }
-
-//_debug_array($content);
-
- $table_header[] = array
- (
-
- 'lang_descr' => lang('Descr'),
- 'lang_prefix' => lang('prefix'),
-// 'lang_status' => lang('Status'),
- 'lang_attribute' => lang('Attributes'),
- 'lang_custom_function' => lang('custom
functions'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.category',
-
'entity_id' =>$entity_id,
-
'allrows'=>$this->allrows)
-
)),
- 'lang_id' => lang('category id'),
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.category',
-
'entity_id' =>$entity_id,
-
'allrows'=>$this->allrows)
-
)),
- 'lang_name' => lang('Name'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_standardtext' => lang('add a
category'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_category&entity_id='
. $entity_id),
- 'lang_done' =>
lang('done'),
- 'lang_done_standardtext' => lang('back
to entity'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.index')
- );
-
- $entity = $this->bo->read_single($entity_id,false);
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.category',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'query'
=>$this->query,
- 'entity_id'
=>$entity_id
- );
-
- $data = array
- (
- 'lang_entity'
=> lang('entity'),
- 'entity_name'
=> $entity['name'],
- 'links'
=> $links,
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($category_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_category' =>
$table_header,
- 'values_category'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('entity');
- $function_msg =
lang('list entity type');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_category' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit()
- {
- $id = get_var('id',array('POST','GET'));
- $values =
get_var('values',array('POST'));
- $config =
CreateObject('phpgwapi.config',$this->currentapp);
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_entity'));
-
- if ($values['save'])
- {
- if (!$values['name'])
- {
- $receipt['error'][] =
array('msg'=>lang('Name not entered!'));
- }
-
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
-
- if (!$receipt['error'])
- {
-
- $receipt =
$this->bo->save($values,$action);
- if(!$id)
- {
- $id=$receipt['id'];
- }
- $config->read_repository();
-
-
if(!is_array($config->config_data['location_form']))
- {
-
$config->config_data['location_form'] = array();
- }
-
- if($values['location_form'])
- {
-
-
$config->config_data['location_form']['entity_' . $id] = 'entity_' . $id;
-
- }
- else
- {
-
unset($config->config_data['location_form']['entity_' . $id]);
- }
-
- $config->save_repository();
- }
- else
- {
- $receipt['error'][] = array('msg'=>
lang('Entity has NOT been saved'));
- }
-
- }
-
-
- if ($id)
- {
- $values = $this->bo->read_single($id);
- $function_msg = lang('edit standard');
- $action='edit';
- }
- else
- {
- $function_msg = lang('add entity');
- $action='add';
- }
-
- $include_list =
$this->bo->get_entity_list($values['lookup_entity']);
- $include_list_2 =
$this->bo->get_entity_list_2($values['include_entity_for']);
- $include_list_3 =
$this->bo->get_entity_list_3($values['start_entity_from']);
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.edit',
- 'id' => $id
- );
-//_debug_array($include_list);
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'lang_name_standardtext' =>
lang('Enter a name of the standard'),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.index'),
- 'lang_id'
=> lang('standard ID'),
- 'lang_name'
=> lang('Name'),
- 'lang_descr'
=> lang('Descr'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_id'
=> $id,
- 'value_name'
=> $values['name'],
- 'lang_id_standardtext' =>
lang('Enter the standard ID'),
- 'lang_descr_standardtext' =>
lang('Enter a description of the standard'),
- 'lang_done_standardtext' =>
lang('Back to the list'),
- 'lang_save_standardtext' =>
lang('Save the standard'),
- 'type_id'
=> $values['type_id'],
- 'value_descr'
=> $values['descr'],
- 'lang_location_form' =>
lang('location form'),
- 'value_location_form' =>
$values['location_form'],
- 'lang_location_form_statustext' => lang('If
this entity type is to be linked to a location'),
- 'lang_include_in_location_form' =>
lang('include in location form'),
- 'include_list'
=> $include_list,
- 'lang_include_statustext' =>
lang('Which entity type is to show up in location forms'),
- 'lang_include_this_entity' =>
lang('include this entity'),
- 'include_list_2'
=> $include_list_2,
- 'lang_include_2_statustext' =>
lang('Let this entity show up in location form'),
- 'lang_start_this_entity' =>
lang('start this entity'),
- 'include_list_3'
=> $include_list_3,
- 'lang_include_3_statustext' =>
lang('Start this entity from'),
- 'lang_select'
=> lang('select'),
- 'lang_documentation' =>
lang('documentation'),
- 'value_documentation' =>
$values['documentation'],
- 'lang_documentation_statustext' => lang('If
this entity type is to be linked to documents'),
- );
-
- $appname
= lang('entity');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function edit_status()
- {
- $id = get_var('id',array('POST','GET'));
- $values =
get_var('values',array('POST'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_entity'));
-
- if ($values['save'])
- {
- if (!$values['id'])
- {
- $receipt['error'][] =
array('msg'=>lang('ID not entered!'));
- }
-
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
-
- if (!$receipt['error'])
- {
- $receipt =
$this->bo->save_status($values,$action);
- if(!$id)
- {
- $id=$receipt['id'];
- }
- }
- else
- {
- $receipt['error'][] = array('msg'=>
lang('Status has NOT been saved'));
- }
-
- }
-
- if ($id)
- {
- $values = $this->bo->read_single_status($id);
- $function_msg = lang('edit status');
- $action='edit';
- }
- else
- {
- $function_msg = lang('add status');
- $action='add';
- }
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.edit_status',
- 'entity_id' => $this->entity_id,
- 'cat_id' => $this->cat_id,
- 'id' => $id
- );
-//_debug_array($link_data);
-
- $entity =
$this->bo->read_single($this->entity_id,false);
- $category =
$this->bo->read_single_category($this->entity_id,$this->cat_id);
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'lang_entity'
=> lang('entity'),
- 'entity_name'
=> $entity['name'],
- 'lang_category'
=> lang('category'),
- 'category_name'
=> $category['name'],
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'lang_name_standardtext' =>
lang('Enter a name of the standard'),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_status&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id),
- 'lang_id'
=> lang('status ID'),
- 'lang_descr'
=> lang('Descr'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_id'
=> $id,
- 'lang_id_standardtext' =>
lang('Enter the status ID'),
- 'lang_descr_standardtext' =>
lang('Enter a description of the status'),
- 'lang_done_standardtext' =>
lang('Back to the list'),
- 'lang_save_standardtext' =>
lang('Save the status'),
- 'value_descr'
=> $values['descr']
- );
-
- $appname
= lang('entity');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_status' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function edit_category()
- {
- $entity_id =
get_var('entity_id',array('POST','GET'));
- $id = get_var('id',array('POST','GET'));
- $values =
get_var('values',array('POST'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_entity'));
-
- if ($values['save'])
- {
- $values['entity_id'] = $entity_id;
-
- if (!$values['name'])
- {
- $receipt['error'][] =
array('msg'=>lang('Name not entered!'));
- }
- if (!$values['entity_id'])
- {
- $receipt['error'][] =
array('msg'=>lang('Entity not choosen'));
- }
-
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
-
- if (!$receipt['error'])
- {
- $receipt =
$this->bo->save_category($values,$action);
- if(!$id)
- {
- $id=$receipt['id'];
- }
- }
- else
- {
- $receipt['error'][] = array('msg'=>
lang('Category has NOT been saved'));
- }
-
- }
-
- if ($id)
- {
- $values =
$this->bo->read_single_category($entity_id,$id);
- $function_msg = lang('edit category');
- $action='edit';
- }
- else
- {
- $function_msg = lang('add category');
- $action='add';
- }
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.edit_category',
- 'entity_id' =>$entity_id,
- 'id' => $id
- );
-//_debug_array($link_data);
-
- $entity = $this->bo->read_single($entity_id,false);
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'lang_entity'
=> lang('entity'),
- 'entity_name'
=> $entity['name'],
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'lang_prefix_standardtext' =>
lang('Enter a standard prefix for the id'),
- 'lang_name_standardtext' =>
lang('Enter a name of the standard'),
-
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.category&entity_id='
. $entity_id),
- 'lang_id'
=> lang('Category'),
- 'lang_name'
=> lang('Name'),
- 'lang_descr'
=> lang('Descr'),
- 'lang_prefix'
=> lang('Prefix'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_id'
=> $id,
- 'value_name'
=> $values['name'],
- 'value_prefix'
=> $values['prefix'],
- 'lang_id_standardtext' =>
lang('Enter the standard ID'),
- 'lang_descr_standardtext' =>
lang('Enter a description of the standard'),
- 'lang_done_standardtext' =>
lang('Back to the list'),
- 'lang_save_standardtext' =>
lang('Save the standard'),
- 'type_id'
=> $values['type_id'],
- 'value_descr'
=> $values['descr'],
- 'lang_lookup_tenant' =>
lang('lookup tenant'),
- 'value_lookup_tenant' =>
$values['lookup_tenant'],
- 'lang_lookup_tenant_statustext' => lang('If
this entity type is to look up tenants'),
- 'lang_location_level' =>
lang('location level'),
- 'location_level_list' =>
$this->bo->get_location_level_list($values['location_level']),
- 'lang_location_level_statustext' =>
lang('select location level'),
- 'lang_no_location_level' =>
lang('None'),
- 'lang_tracking'
=> lang('tracking'),
- 'value_tracking'
=> $values['tracking'],
- 'lang_tracking_statustext' =>
lang('If this entity type is to be tracket in ticket list'),
- 'lang_fileupload'
=> lang('Enable file upload'),
- 'value_fileupload'
=> $values['fileupload'],
- 'lang_fileupload_statustext' => lang('If
files can be uploaded for this category'),
- 'lang_loc_link'
=> lang('Link from location'),
- 'value_loc_link'
=> $values['loc_link'],
- 'lang_loc_link_statustext' =>
lang('Enable link from location detail'),
- 'lang_start_project' =>
lang('Start project'),
- 'value_start_project' =>
$values['start_project'],
- 'lang_start_project_statustext' => lang('Enable
start project from this category')
- );
-
- $appname
= lang('entity');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function delete()
- {
- $entity_id =
get_var('entity_id',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $attrib_id =
get_var('attrib_id',array('POST','GET'));
- $status_id =
get_var('status_id',array('POST','GET'));
- $acl_location =
get_var('acl_location',array('POST','GET'));
- $custom_function_id =
get_var('custom_function_id',array('POST','GET'));
- $confirm = get_var('confirm',array('POST'));
-
- if($attrib_id):
- {
- $function='list_attribute';
- }
- elseif($custom_function_id):
- {
- $function='list_custom_function';
- }
- endif;
-
- if (!$acl_location && $entity_id && $cat_id)
- {
- $acl_location = '.entity.' . $entity_id . '.' .
$cat_id;
- }
-
- if(!$function)
- {
- if($cat_id)
- {
- if($status_id)
- {
- $function='list_status';
- }
- else
- {
- $function='category';
- }
- }
- else
- {
- $function='index';
- }
- }
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.'.$function,
- 'cat_id' => $cat_id,
- 'entity_id' => $entity_id,
- 'attrib_id' => $attrib_id,
- 'status_id' => $status_id
- );
-
- $delete_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.delete',
- 'cat_id' => $cat_id,
- 'entity_id' => $entity_id,
- 'attrib_id' => $attrib_id,
- 'status_id' => $status_id,
- 'acl_location' => $acl_location,
- 'custom_function_id' => $custom_function_id
- );
-
- if (get_var('confirm',array('POST')))
- {
-
$this->bo->delete($cat_id,$entity_id,$attrib_id,$status_id,$acl_location,$custom_function_id);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php',$delete_data),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_standardtext' => lang('Delete the
entry'),
- 'lang_no_standardtext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('entity');
- $function_msg =
lang('delete entity type');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- function list_attribute()
- {
- $entity_id = $this->entity_id;
- $cat_id = $this->cat_id;
- $id = get_var('id',array('POST','GET'));
- $resort = get_var('resort',array('POST','GET'));
-
- $GLOBALS['phpgw']->xslttpl->add_file(array(
-
'admin_entity',
-
'nextmatchs',
-
'search_field'));
-
- if($resort)
- {
- $this->bo->resort_attrib($id,$resort);
- }
- $attrib_list =
$this->bo->read_attrib($entity_id,$cat_id);
-
- if (isset($attrib_list) AND is_array($attrib_list))
- {
- foreach($attrib_list as $entry)
- {
-
- $content[] = array
- (
- 'name'
=> $entry['name'],
- 'datatype'
=> $entry['datatype'],
- 'column_name'
=> $entry['column_name'],
- 'input_text'
=> $entry['input_text'],
- 'sorting'
=> $entry['attrib_sort'],
- 'search'
=> $entry['search'],
- 'link_up'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_attribute&resort=up&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id'] . '&allrows=' .
$this->allrows),
- 'link_down'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_attribute&resort=down&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id'] . '&allrows=' .
$this->allrows),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_attrib&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id']),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.delete&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&attrib_id=' . $entry['id']),
- 'lang_up_text'
=> lang('shift up'),
- 'lang_down_text'
=> lang('shift down'),
- 'lang_edit_text'
=> lang('edit the attrib'),
- 'lang_delete_text'
=> lang('delete the attrib'),
- 'text_attribute'
=> lang('Attributes'),
- 'text_up'
=> lang('up'),
- 'text_down'
=> lang('down'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
- }
-
-//_debug_array($content);
-
- $table_header[] = array
- (
- 'lang_descr' => lang('Descr'),
- 'lang_datatype' => lang('Datatype'),
- 'lang_sorting' => lang('sorting'),
- 'lang_search' => lang('search'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'column_name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.list_attribute',
-
'entity_id'
=>$entity_id,
-
'cat_id'
=>$cat_id,
-
'allrows'=>$this->allrows)
-
)),
- 'sort_sorting' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'attrib_sort',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.list_attribute',
-
'entity_id'
=>$entity_id,
-
'cat_id'
=>$cat_id,
-
'allrows'=>$this->allrows)
-
)),
- 'lang_name' => lang('Name'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_attribtext' => lang('add a attrib'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_attrib&entity_id='.$entity_id
. '&cat_id=' . $cat_id),
- 'lang_done' =>
lang('done'),
- 'lang_done_attribtext' => lang('back to
admin'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.category&entity_id='.$entity_id),
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.list_attribute',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'query'
=>$this->query,
- 'entity_id'
=>$entity_id,
- 'cat_id'
=>$cat_id
- );
-
- $entity = $this->bo->read_single($entity_id,false);
- $category =
$this->bo->read_single_category($entity_id,$cat_id);
-
- $data = array
- (
- 'lang_entity'
=> lang('entity'),
- 'entity_name'
=> $entity['name'],
- 'lang_category'
=> lang('category'),
- 'category_name'
=> $category['name'],
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'start_record'
=> $this->start,
- 'num_records'
=> count($attrib_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_attribtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_attribtext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_attrib' =>
$table_header,
- 'values_attrib'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('attribute');
- $function_msg =
lang('list entity attribute');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_attribute' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit_attrib()
- {
- $entity_id =
get_var('entity_id',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $id =
get_var('id',array('POST','GET'));
- $values = get_var('values',array('POST'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_entity'));
-
- if ($values['save'])
- {
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
-
- $values['entity_id']=$entity_id;
- $values['cat_id']=$cat_id;
-
- if (!$values['column_name'])
- {
- $receipt['error'][] =
array('msg'=>lang('Column name not entered!'));
- }
-
- if (!$values['input_text'])
- {
- $receipt['error'][] =
array('msg'=>lang('Input text not entered!'));
- }
- if (!$values['statustext'])
- {
- $receipt['error'][] =
array('msg'=>lang('Statustext not entered!'));
- }
-
- if (!$values['entity_id'])
- {
- $receipt['error'][] =
array('msg'=>lang('entity type not choosen!'));
- }
-
- if (!$values['column_info']['type'])
- {
- $receipt['error'][] =
array('msg'=>lang('Datatype type not choosen!'));
- }
-
-
if(!ctype_digit($values['column_info']['precision']))
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter precision as integer !'));
-
unset($values['column_info']['precision']);
- }
-
- if($values['column_info']['scale'] &&
!ctype_digit($values['column_info']['scale']))
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter scale as integer !'));
- unset($values['column_info']['scale']);
- }
-
- if (!$values['column_info']['nullable'])
- {
- $receipt['error'][] =
array('msg'=>lang('Nullable not choosen!'));
- }
-
-
- if (!$receipt['error'])
- {
-
- $receipt =
$this->bo->save_attrib($values,$action);
-
- if(!$id)
- {
- $id=$receipt['id'];
- }
- }
- else
- {
- $receipt['error'][] = array('msg'
=> lang('Attribute has NOT been saved'));
- }
-
- }
-
- if ($id)
- {
- $values =
$this->bo->read_single_attrib($entity_id,$cat_id,$id);
- $type_name=$values['type_name'];
- $function_msg = lang('edit attribute'). ' ' .
lang($type_name);
- $action='edit';
- }
- else
- {
- $function_msg = lang('add attribute');
- $action='add';
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.edit_attrib',
- 'entity_id' => $entity_id,
- 'cat_id' => $cat_id,
- 'id' => $id
- );
-
- if($values['column_info']['type']=='R' ||
$values['column_info']['type']=='CH' || $values['column_info']['type']=='LB')
- {
- $multiple_choice= True;
- }
-
-//_debug_array($values);
-
- $entity = $this->bo->read_single($entity_id,false);
- $category =
$this->bo->read_single_category($entity_id,$cat_id);
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'lang_entity'
=> lang('entity'),
- 'entity_name'
=> $entity['name'],
- 'lang_category'
=> lang('category'),
- 'category_name'
=> $category['name'],
-
- 'lang_choice' =>
lang('Choice'),
- 'lang_new_value' =>
lang('New value'),
- 'lang_new_value_statustext' => lang('New
value for mulitple choice'),
- 'multiple_choice' =>
$multiple_choice,
- 'value_choice' =>
$values['choice'],
- 'lang_delete_value' =>
lang('Delete value'),
- 'lang_value' =>
lang('value'),
- 'lang_delete_choice_statustext'=> lang('Delete
this value from the list of multiple choice'),
-
- 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_attribute&entity_id='.$entity_id
. '&cat_id='.$cat_id),
- 'lang_id'
=> lang('Attribute ID'),
- 'lang_entity_type' =>
lang('Entity type'),
- 'lang_no_entity_type' => lang('No
entity type'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_id'
=> $id,
-
- 'lang_column_name'
=> lang('Column name'),
- 'value_column_name'
=> $values['column_name'],
- 'lang_column_name_statustext' => lang('enter
the name for the column'),
-
- 'lang_input_text'
=> lang('input text'),
- 'value_input_text'
=> $values['input_text'],
- 'lang_input_name_statustext' => lang('enter
the input text for records'),
-
- 'lang_id_attribtext' => lang('Enter
the attribute ID'),
- 'lang_entity_statustext' => lang('Select
a entity type'),
-
- 'lang_statustext' =>
lang('Statustext'),
- 'lang_statustext_attribtext'=> lang('Enter a
statustext for the inputfield in forms'),
- 'value_statustext' =>
$values['statustext'],
-
- 'lang_done_attribtext' => lang('Back
to the list'),
- 'lang_save_attribtext' => lang('Save
the attribute'),
-
- 'lang_datatype' =>
lang('Datatype'),
- 'lang_datatype_statustext' => lang('Select
a datatype'),
- 'lang_no_datatype' =>
lang('No datatype'),
- 'datatype_list' =>
$this->bocommon->select_datatype($values['column_info']['type']),
-
- 'lang_precision' =>
lang('Precision'),
- 'lang_precision_statustext' => lang('enter
the record length'),
- 'value_precision' =>
$values['column_info']['precision'],
-
- 'lang_scale' =>
lang('scale'),
- 'lang_scale_statustext' => lang('enter
the scale if type is decimal'),
- 'value_scale' =>
$values['column_info']['scale'],
-
- 'lang_default' =>
lang('default'),
- 'lang_default_statustext' => lang('enter
the default value'),
- 'value_default' =>
$values['column_info']['default'],
-
- 'lang_nullable' =>
lang('Nullable'),
- 'lang_nullable_statustext' => lang('Chose
if this column is nullable'),
- 'lang_select_nullable' => lang('Select
nullable'),
- 'nullable_list' =>
$this->bocommon->select_nullable($values['column_info']['nullable']),
- 'value_lookup_form' =>
$values['lookup_form'],
- 'lang_lookup_form'
=> lang('show in lookup forms'),
- 'lang_lookup_form_statustext'
=> lang('check to show this attribue in lookup forms'),
- 'value_list' =>
$values['list'],
- 'lang_list' =>
lang('show in list'),
- 'lang_list_statustext' =>
lang('check to show this attribute in entity list'),
- 'value_search' =>
$values['search'],
- 'lang_include_search' =>
lang('Include in search'),
- 'lang_include_search_statustext'=> lang('check
to show this attribute in location list'),
-
- );
-//_debug_array($values);
-
- $appname
= lang('entity');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_attrib' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function list_custom_function()
- {
- $entity_id = $this->entity_id;
- $cat_id = $this->cat_id;
- $id = get_var('id',array('POST','GET'));
- $resort = get_var('resort',array('POST','GET'));
-
- $GLOBALS['phpgw']->xslttpl->add_file(array(
-
'admin_entity',
-
'nextmatchs',
-
'search_field'));
-
- if($resort)
- {
- $this->bo->resort_custom_function($id,$resort);
- }
- $custom_function_list =
$this->bo->read_custom_function($entity_id,$cat_id);
-
- if (isset($custom_function_list) AND
is_array($custom_function_list))
- {
- foreach($custom_function_list as $entry)
- {
-
- $content[] = array
- (
- 'file_name'
=> $entry['file_name'],
- 'descr'
=> $entry['descr'],
- 'sorting'
=> $entry['sorting'],
- 'active'
=> $entry['active']?'X':'',
- 'link_up'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_custom_function&resort=up&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id'] . '&allrows=' .
$this->allrows),
- 'link_down'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_custom_function&resort=down&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id'] . '&allrows=' .
$this->allrows),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_custom_function&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id']),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.delete&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&custom_function_id=' . $entry['id']),
- 'lang_up_text'
=> lang('shift up'),
- 'lang_down_text'
=> lang('shift down'),
- 'lang_edit_text'
=> lang('edit the custom_function'),
- 'lang_delete_text'
=> lang('delete the custom_function'),
- 'text_custom_function'
=> lang('custom_functions'),
- 'text_up'
=> lang('up'),
- 'text_down'
=> lang('down'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
- }
-
- $table_header[] = array
- (
- 'lang_descr' => lang('Descr'),
- 'lang_active' => lang('Active'),
- 'lang_sorting' => lang('sorting'),
- 'lang_search' => lang('search'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'column_name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.list_custom_function',
-
'entity_id'
=>$entity_id,
-
'cat_id'
=>$cat_id,
-
'allrows'=>$this->allrows)
-
)),
- 'sort_sorting' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'custom_function_sort',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.list_custom_function',
-
'entity_id'
=>$entity_id,
-
'cat_id'
=>$cat_id,
-
'allrows'=>$this->allrows)
-
)),
- 'lang_name' => lang('Name'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_custom_functiontext' => lang('add a
custom_function'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_custom_function&entity_id='.$entity_id
. '&cat_id=' . $cat_id),
- 'lang_done' =>
lang('done'),
- 'lang_done_custom_functiontext' => lang('back
to admin'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.category&entity_id='.$entity_id),
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.list_custom_function',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'query'
=>$this->query,
- 'entity_id'
=>$entity_id,
- 'cat_id'
=>$cat_id
- );
-
- $entity = $this->bo->read_single($entity_id,false);
- $category =
$this->bo->read_single_category($entity_id,$cat_id);
-
- $data = array
- (
- 'lang_entity'
=> lang('entity'),
- 'entity_name'
=> $entity['name'],
- 'lang_category'
=> lang('category'),
- 'category_name'
=> $category['name'],
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'start_record'
=> $this->start,
- 'num_records'
=> count($custom_function_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_custom_functiontext' =>
lang('Enter the search string. To show all entries, empty this field and press
the SUBMIT button again'),
- 'lang_searchbutton_custom_functiontext' =>
lang('Submit the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_custom_function'
=> $table_header,
- 'values_custom_function'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('custom function');
- $function_msg =
lang('list entity custom function');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_custom_function' =>
$data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit_custom_function()
- {
- $entity_id =
get_var('entity_id',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $id =
get_var('id',array('POST','GET'));
- $values = get_var('values',array('POST'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_entity'));
-
- if ($values['save'])
- {
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
-
- $values['entity_id']=$entity_id;
- $values['cat_id']=$cat_id;
-
-
- if (!$values['entity_id'])
- {
- $receipt['error'][] =
array('msg'=>lang('entity type not choosen!'));
- }
-
- if (!$values['custom_function_file'])
- {
- $receipt['error'][] =
array('msg'=>lang('custom function file not choosen!'));
- }
-
-
- if (!$receipt['error'])
- {
-
- $receipt =
$this->bo->save_custom_function($values,$action);
-
- if(!$id)
- {
- $id=$receipt['id'];
- }
- }
- else
- {
- $receipt['error'][] = array('msg'
=> lang('Custom function has NOT been saved'));
- }
-
- }
-
- if ($id)
- {
- $values =
$this->bo->read_single_custom_function($entity_id,$cat_id,$id);
- $type_name=$values['type_name'];
- $function_msg = lang('edit custom function'). '
' . lang($type_name);
- $action='edit';
- }
- else
- {
- $function_msg = lang('add custom function');
- $action='add';
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.edit_custom_function',
- 'entity_id' => $entity_id,
- 'cat_id' => $cat_id,
- 'id' => $id
- );
-
-
-//_debug_array($values);
-
- $entity = $this->bo->read_single($entity_id,false);
- $category =
$this->bo->read_single_category($entity_id,$cat_id);
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'lang_entity'
=> lang('entity'),
- 'entity_name'
=> $entity['name'],
- 'lang_category'
=> lang('category'),
- 'category_name'
=> $category['name'],
-
- 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_custom_function&entity_id='.$entity_id
. '&cat_id='.$cat_id),
- 'lang_id'
=> lang('Custom function ID'),
- 'lang_entity_type' =>
lang('Entity type'),
- 'lang_no_entity_type' => lang('No
entity type'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_id'
=> $id,
-
- 'lang_descr' =>
lang('descr'),
- 'lang_descr_custom_functiontext'=> lang('Enter
a descr for the custom function'),
- 'value_descr' =>
$values['descr'],
-
- 'lang_done_custom_functiontext' =>
lang('Back to the list'),
- 'lang_save_custom_functiontext' =>
lang('Save the custom function'),
-
- 'lang_custom_function'
=> lang('custom function'),
- 'lang_custom_function_statustext' =>
lang('Select a custom_function'),
- 'lang_no_custom_function'
=> lang('No custom function'),
- 'custom_function_list'
=> $this->bo->select_custom_function($values['custom_function_file']),
-
- 'value_active' =>
$values['active'],
- 'lang_active' =>
lang('Active'),
- 'lang_active_statustext' => lang('check
acivate custom function'),
- 'value_search' =>
$values['search'],
- 'lang_include_search' =>
lang('Include in search'),
- 'lang_include_search_statustext'=> lang('check
to show this custom function in location list')
- );
-
- $appname
= lang('entity');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_custom_function' =>
$data));
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.uiadmin_entity.inc.php,v 1.12 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uiadmin_entity
+ {
+ var $grants;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'list_status' => True,
+ 'category' => True,
+ 'edit' => True,
+ 'edit_status' => True,
+ 'edit_category' => True,
+ 'view' => True,
+ 'delete' => True,
+ 'list_attribute' => True,
+ 'edit_attrib' => True,
+ 'list_custom_function'=>True,
+ 'edit_custom_function' => True
+ );
+
+ function uiadmin_entity()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bo =
CreateObject($this->currentapp.'.boadmin_entity',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+
+ $this->start =
$this->bo->start;
+ $this->query =
$this->bo->query;
+ $this->sort =
$this->bo->sort;
+ $this->order =
$this->bo->order;
+ $this->entity_id =
$this->bo->entity_id;
+ $this->cat_id =
$this->bo->cat_id;
+ $this->allrows =
$this->bo->allrows;
+
+ $this->menu->sub ='admin_entity';
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'allrows' => $this->allrows,
+ 'entity_id' => $this->entity_id,
+ 'cat_id' => $this->cat_id
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function index()
+ {
+ $this->bo->reset_fm_cache();
+ $GLOBALS['phpgw']->xslttpl->add_file(array(
+
'admin_entity',
+
'nextmatchs',
+
'menu',
+
'search_field'));
+ $links = $this->menu->links();
+
+ $entity_list = $this->bo->read();
+
+ if (isSet($entity_list) AND is_array($entity_list))
+ {
+ foreach($entity_list as $entry)
+ {
+ $content[] = array
+ (
+ 'id'
=> $entry['id'],
+ 'name'
=> $entry['name'],
+ 'descr'
=> $entry['descr'],
+ 'link_categories'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.category&entity_id='
. $entry['id']),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit&id='
. $entry['id']),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.delete&entity_id='
. $entry['id']),
+ 'lang_view_standardtext'
=> lang('view the standard'),
+ 'lang_category_text'
=> lang('categories for the entity type'),
+ 'lang_edit_standardtext'
=> lang('edit the entity'),
+ 'lang_delete_standardtext'
=> lang('delete the entity'),
+ 'text_categories'
=> lang('Categories'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+ }
+
+//_debug_array($content);
+
+ $table_header[] = array
+ (
+
+ 'lang_descr' => lang('Descr'),
+ 'lang_categories' => lang('Categories'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.index',
+
'allrows'=>$this->allrows)
+
)),
+ 'lang_id' => lang('entity id'),
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.index',
+
'allrows'=>$this->allrows)
+
)),
+ 'lang_name' => lang('Name'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_standardtext' => lang('add a
standard'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit'),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_standardtext' => lang('back
to admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php')
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.index',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'query'
=>$this->query
+ );
+
+ $data = array
+ (
+ 'links'
=> $links,
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($entity_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('entity');
+ $function_msg =
lang('list entity type');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function list_status()
+ {
+ $this->bo->reset_fm_cache();
+ $GLOBALS['phpgw']->xslttpl->add_file(array(
+
'admin_entity',
+
'nextmatchs',
+
'menu',
+
'search_field'));
+ $links = $this->menu->links();
+
+ $list = $this->bo->read_status();
+
+ if (isSet($list) AND is_array($list))
+ {
+ foreach($list as $entry)
+ {
+ $content[] = array
+ (
+ 'id'
=> $entry['id'],
+ 'descr'
=> $entry['descr'],
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_status&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id . '&id=' . $entry['id']),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.delete&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id . '&status_id=' .
$entry['id']),
+ 'lang_edit_standardtext'
=> lang('edit the entity'),
+ 'lang_delete_standardtext'
=> lang('delete the entity'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+ }
+
+//_debug_array($content);
+
+ $table_header[] = array
+ (
+
+ 'lang_descr' => lang('Descr'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.list_status',
+
'entity_id' =>
$this->entity_id,
+
'cat_id' =>
$this->cat_id
+
)
+
)),
+ 'lang_id' => lang('status'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_text' => lang('add a standard'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_status&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_text' => lang('back to
admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.category&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id),
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.list_status',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'query'
=>$this->query,
+ 'entity_id'
=>$this->entity_id,
+ 'cat_id'
=>$this->cat_id
+ );
+
+ $entity =
$this->bo->read_single($this->entity_id,false);
+ $category =
$this->bo->read_single_category($this->entity_id,$this->cat_id);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'lang_entity'
=> lang('entity'),
+ 'entity_name'
=> $entity['name'],
+ 'lang_category'
=> lang('category'),
+ 'category_name'
=> $category['name'],
+ 'links'
=> $links,
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($entity_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_status' =>
$table_header,
+ 'values_status'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('entity');
+ $function_msg =
lang('list status');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_status' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function category()
+ {
+
+ $entity_id =
get_var('entity_id',array('POST','GET'));
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array(
+
'admin_entity',
+
'nextmatchs',
+
'menu',
+
'search_field'));
+ $links = $this->menu->links();
+
+ $category_list = $this->bo->read_category($entity_id);
+
+ if (isSet($category_list) AND is_array($category_list))
+ {
+ foreach($category_list as $entry)
+ {
+ $content[] = array
+ (
+ 'id'
=> $entry['id'],
+ 'name'
=> $entry['name'],
+ 'prefix'
=> $entry['prefix'],
+ 'descr'
=> $entry['descr'],
+// 'link_status'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_status&cat_id='
. $entry['id'] . '&entity_id=' . $entity_id),
+ 'link_custom_function'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_custom_function&cat_id='
. $entry['id'] . '&entity_id=' . $entity_id),
+ 'link_attribute'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_attribute&cat_id='
. $entry['id'] . '&entity_id=' . $entity_id),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_category&id='
. $entry['id'] . '&entity_id=' . $entity_id),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.delete&cat_id='
. $entry['id'] . '&entity_id=' . $entity_id),
+ 'lang_view_standardtext'
=> lang('view the category'),
+ 'lang_status_standardtext'
=> lang('Status for the entity category'),
+ 'lang_attribute_standardtext'
=> lang('attributes for the entity category'),
+
'lang_custom_function_standardtext' => lang('custom functions for the
entity category'),
+ 'lang_edit_standardtext'
=> lang('edit the standard'),
+ 'lang_delete_standardtext'
=> lang('delete the standard'),
+ 'text_status'
=> lang('Status'),
+ 'text_attribute'
=> lang('Attributes'),
+ 'text_custom_function'
=> lang('Custom functions'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+ }
+
+//_debug_array($content);
+
+ $table_header[] = array
+ (
+
+ 'lang_descr' => lang('Descr'),
+ 'lang_prefix' => lang('prefix'),
+// 'lang_status' => lang('Status'),
+ 'lang_attribute' => lang('Attributes'),
+ 'lang_custom_function' => lang('custom
functions'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.category',
+
'entity_id' =>$entity_id,
+
'allrows'=>$this->allrows)
+
)),
+ 'lang_id' => lang('category id'),
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.category',
+
'entity_id' =>$entity_id,
+
'allrows'=>$this->allrows)
+
)),
+ 'lang_name' => lang('Name'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_standardtext' => lang('add a
category'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_category&entity_id='
. $entity_id),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_standardtext' => lang('back
to entity'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.index')
+ );
+
+ $entity = $this->bo->read_single($entity_id,false);
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.category',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'query'
=>$this->query,
+ 'entity_id'
=>$entity_id
+ );
+
+ $data = array
+ (
+ 'lang_entity'
=> lang('entity'),
+ 'entity_name'
=> $entity['name'],
+ 'links'
=> $links,
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($category_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_category' =>
$table_header,
+ 'values_category'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('entity');
+ $function_msg =
lang('list entity type');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_category' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit()
+ {
+ $id = get_var('id',array('POST','GET'));
+ $values =
get_var('values',array('POST'));
+ $config =
CreateObject('phpgwapi.config',$this->currentapp);
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_entity'));
+
+ if ($values['save'])
+ {
+ if (!$values['name'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Name not entered!'));
+ }
+
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+
+ if (!$receipt['error'])
+ {
+
+ $receipt =
$this->bo->save($values,$action);
+ if(!$id)
+ {
+ $id=$receipt['id'];
+ }
+ $config->read_repository();
+
+
if(!is_array($config->config_data['location_form']))
+ {
+
$config->config_data['location_form'] = array();
+ }
+
+ if($values['location_form'])
+ {
+
+
$config->config_data['location_form']['entity_' . $id] = 'entity_' . $id;
+
+ }
+ else
+ {
+
unset($config->config_data['location_form']['entity_' . $id]);
+ }
+
+ $config->save_repository();
+ }
+ else
+ {
+ $receipt['error'][] = array('msg'=>
lang('Entity has NOT been saved'));
+ }
+
+ }
+
+
+ if ($id)
+ {
+ $values = $this->bo->read_single($id);
+ $function_msg = lang('edit standard');
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add entity');
+ $action='add';
+ }
+
+ $include_list =
$this->bo->get_entity_list($values['lookup_entity']);
+ $include_list_2 =
$this->bo->get_entity_list_2($values['include_entity_for']);
+ $include_list_3 =
$this->bo->get_entity_list_3($values['start_entity_from']);
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.edit',
+ 'id' => $id
+ );
+//_debug_array($include_list);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'lang_name_standardtext' =>
lang('Enter a name of the standard'),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.index'),
+ 'lang_id'
=> lang('standard ID'),
+ 'lang_name'
=> lang('Name'),
+ 'lang_descr'
=> lang('Descr'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id'
=> $id,
+ 'value_name'
=> $values['name'],
+ 'lang_id_standardtext' =>
lang('Enter the standard ID'),
+ 'lang_descr_standardtext' =>
lang('Enter a description of the standard'),
+ 'lang_done_standardtext' =>
lang('Back to the list'),
+ 'lang_save_standardtext' =>
lang('Save the standard'),
+ 'type_id'
=> $values['type_id'],
+ 'value_descr'
=> $values['descr'],
+ 'lang_location_form' =>
lang('location form'),
+ 'value_location_form' =>
$values['location_form'],
+ 'lang_location_form_statustext' => lang('If
this entity type is to be linked to a location'),
+ 'lang_include_in_location_form' =>
lang('include in location form'),
+ 'include_list'
=> $include_list,
+ 'lang_include_statustext' =>
lang('Which entity type is to show up in location forms'),
+ 'lang_include_this_entity' =>
lang('include this entity'),
+ 'include_list_2'
=> $include_list_2,
+ 'lang_include_2_statustext' =>
lang('Let this entity show up in location form'),
+ 'lang_start_this_entity' =>
lang('start this entity'),
+ 'include_list_3'
=> $include_list_3,
+ 'lang_include_3_statustext' =>
lang('Start this entity from'),
+ 'lang_select'
=> lang('select'),
+ 'lang_documentation' =>
lang('documentation'),
+ 'value_documentation' =>
$values['documentation'],
+ 'lang_documentation_statustext' => lang('If
this entity type is to be linked to documents'),
+ );
+
+ $appname
= lang('entity');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function edit_status()
+ {
+ $id = get_var('id',array('POST','GET'));
+ $values =
get_var('values',array('POST'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_entity'));
+
+ if ($values['save'])
+ {
+ if (!$values['id'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('ID not entered!'));
+ }
+
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+
+ if (!$receipt['error'])
+ {
+ $receipt =
$this->bo->save_status($values,$action);
+ if(!$id)
+ {
+ $id=$receipt['id'];
+ }
+ }
+ else
+ {
+ $receipt['error'][] = array('msg'=>
lang('Status has NOT been saved'));
+ }
+
+ }
+
+ if ($id)
+ {
+ $values = $this->bo->read_single_status($id);
+ $function_msg = lang('edit status');
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add status');
+ $action='add';
+ }
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.edit_status',
+ 'entity_id' => $this->entity_id,
+ 'cat_id' => $this->cat_id,
+ 'id' => $id
+ );
+//_debug_array($link_data);
+
+ $entity =
$this->bo->read_single($this->entity_id,false);
+ $category =
$this->bo->read_single_category($this->entity_id,$this->cat_id);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'lang_entity'
=> lang('entity'),
+ 'entity_name'
=> $entity['name'],
+ 'lang_category'
=> lang('category'),
+ 'category_name'
=> $category['name'],
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'lang_name_standardtext' =>
lang('Enter a name of the standard'),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_status&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id),
+ 'lang_id'
=> lang('status ID'),
+ 'lang_descr'
=> lang('Descr'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id'
=> $id,
+ 'lang_id_standardtext' =>
lang('Enter the status ID'),
+ 'lang_descr_standardtext' =>
lang('Enter a description of the status'),
+ 'lang_done_standardtext' =>
lang('Back to the list'),
+ 'lang_save_standardtext' =>
lang('Save the status'),
+ 'value_descr'
=> $values['descr']
+ );
+
+ $appname
= lang('entity');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_status' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function edit_category()
+ {
+ $entity_id =
get_var('entity_id',array('POST','GET'));
+ $id = get_var('id',array('POST','GET'));
+ $values =
get_var('values',array('POST'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_entity'));
+
+ if ($values['save'])
+ {
+ $values['entity_id'] = $entity_id;
+
+ if (!$values['name'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Name not entered!'));
+ }
+ if (!$values['entity_id'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Entity not choosen'));
+ }
+
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+
+ if (!$receipt['error'])
+ {
+ $receipt =
$this->bo->save_category($values,$action);
+ if(!$id)
+ {
+ $id=$receipt['id'];
+ }
+ }
+ else
+ {
+ $receipt['error'][] = array('msg'=>
lang('Category has NOT been saved'));
+ }
+
+ }
+
+ if ($id)
+ {
+ $values =
$this->bo->read_single_category($entity_id,$id);
+ $function_msg = lang('edit category');
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add category');
+ $action='add';
+ }
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.edit_category',
+ 'entity_id' =>$entity_id,
+ 'id' => $id
+ );
+//_debug_array($link_data);
+
+ $entity = $this->bo->read_single($entity_id,false);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'lang_entity'
=> lang('entity'),
+ 'entity_name'
=> $entity['name'],
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'lang_prefix_standardtext' =>
lang('Enter a standard prefix for the id'),
+ 'lang_name_standardtext' =>
lang('Enter a name of the standard'),
+
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.category&entity_id='
. $entity_id),
+ 'lang_id'
=> lang('Category'),
+ 'lang_name'
=> lang('Name'),
+ 'lang_descr'
=> lang('Descr'),
+ 'lang_prefix'
=> lang('Prefix'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id'
=> $id,
+ 'value_name'
=> $values['name'],
+ 'value_prefix'
=> $values['prefix'],
+ 'lang_id_standardtext' =>
lang('Enter the standard ID'),
+ 'lang_descr_standardtext' =>
lang('Enter a description of the standard'),
+ 'lang_done_standardtext' =>
lang('Back to the list'),
+ 'lang_save_standardtext' =>
lang('Save the standard'),
+ 'type_id'
=> $values['type_id'],
+ 'value_descr'
=> $values['descr'],
+ 'lang_lookup_tenant' =>
lang('lookup tenant'),
+ 'value_lookup_tenant' =>
$values['lookup_tenant'],
+ 'lang_lookup_tenant_statustext' => lang('If
this entity type is to look up tenants'),
+ 'lang_location_level' =>
lang('location level'),
+ 'location_level_list' =>
$this->bo->get_location_level_list($values['location_level']),
+ 'lang_location_level_statustext' =>
lang('select location level'),
+ 'lang_no_location_level' =>
lang('None'),
+ 'lang_tracking'
=> lang('tracking'),
+ 'value_tracking'
=> $values['tracking'],
+ 'lang_tracking_statustext' =>
lang('If this entity type is to be tracket in ticket list'),
+ 'lang_fileupload'
=> lang('Enable file upload'),
+ 'value_fileupload'
=> $values['fileupload'],
+ 'lang_fileupload_statustext' => lang('If
files can be uploaded for this category'),
+ 'lang_loc_link'
=> lang('Link from location'),
+ 'value_loc_link'
=> $values['loc_link'],
+ 'lang_loc_link_statustext' =>
lang('Enable link from location detail'),
+ 'lang_start_project' =>
lang('Start project'),
+ 'value_start_project' =>
$values['start_project'],
+ 'lang_start_project_statustext' => lang('Enable
start project from this category')
+ );
+
+ $appname
= lang('entity');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function delete()
+ {
+ $entity_id =
get_var('entity_id',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $attrib_id =
get_var('attrib_id',array('POST','GET'));
+ $status_id =
get_var('status_id',array('POST','GET'));
+ $acl_location =
get_var('acl_location',array('POST','GET'));
+ $custom_function_id =
get_var('custom_function_id',array('POST','GET'));
+ $confirm = get_var('confirm',array('POST'));
+
+ if($attrib_id):
+ {
+ $function='list_attribute';
+ }
+ elseif($custom_function_id):
+ {
+ $function='list_custom_function';
+ }
+ endif;
+
+ if (!$acl_location && $entity_id && $cat_id)
+ {
+ $acl_location = '.entity.' . $entity_id . '.' .
$cat_id;
+ }
+
+ if(!$function)
+ {
+ if($cat_id)
+ {
+ if($status_id)
+ {
+ $function='list_status';
+ }
+ else
+ {
+ $function='category';
+ }
+ }
+ else
+ {
+ $function='index';
+ }
+ }
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.'.$function,
+ 'cat_id' => $cat_id,
+ 'entity_id' => $entity_id,
+ 'attrib_id' => $attrib_id,
+ 'status_id' => $status_id
+ );
+
+ $delete_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.delete',
+ 'cat_id' => $cat_id,
+ 'entity_id' => $entity_id,
+ 'attrib_id' => $attrib_id,
+ 'status_id' => $status_id,
+ 'acl_location' => $acl_location,
+ 'custom_function_id' => $custom_function_id
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+
$this->bo->delete($cat_id,$entity_id,$attrib_id,$status_id,$acl_location,$custom_function_id);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php',$delete_data),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_standardtext' => lang('Delete the
entry'),
+ 'lang_no_standardtext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('entity');
+ $function_msg =
lang('delete entity type');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ function list_attribute()
+ {
+ $entity_id = $this->entity_id;
+ $cat_id = $this->cat_id;
+ $id = get_var('id',array('POST','GET'));
+ $resort = get_var('resort',array('POST','GET'));
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array(
+
'admin_entity',
+
'nextmatchs',
+
'search_field'));
+
+ if($resort)
+ {
+ $this->bo->resort_attrib($id,$resort);
+ }
+ $attrib_list =
$this->bo->read_attrib($entity_id,$cat_id);
+
+ if (isset($attrib_list) AND is_array($attrib_list))
+ {
+ foreach($attrib_list as $entry)
+ {
+
+ $content[] = array
+ (
+ 'name'
=> $entry['name'],
+ 'datatype'
=> $entry['datatype'],
+ 'column_name'
=> $entry['column_name'],
+ 'input_text'
=> $entry['input_text'],
+ 'sorting'
=> $entry['attrib_sort'],
+ 'search'
=> $entry['search'],
+ 'link_up'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_attribute&resort=up&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id'] . '&allrows=' .
$this->allrows),
+ 'link_down'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_attribute&resort=down&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id'] . '&allrows=' .
$this->allrows),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_attrib&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id']),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.delete&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&attrib_id=' . $entry['id']),
+ 'lang_up_text'
=> lang('shift up'),
+ 'lang_down_text'
=> lang('shift down'),
+ 'lang_edit_text'
=> lang('edit the attrib'),
+ 'lang_delete_text'
=> lang('delete the attrib'),
+ 'text_attribute'
=> lang('Attributes'),
+ 'text_up'
=> lang('up'),
+ 'text_down'
=> lang('down'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+ }
+
+//_debug_array($content);
+
+ $table_header[] = array
+ (
+ 'lang_descr' => lang('Descr'),
+ 'lang_datatype' => lang('Datatype'),
+ 'lang_sorting' => lang('sorting'),
+ 'lang_search' => lang('search'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'column_name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.list_attribute',
+
'entity_id'
=>$entity_id,
+
'cat_id'
=>$cat_id,
+
'allrows'=>$this->allrows)
+
)),
+ 'sort_sorting' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'attrib_sort',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.list_attribute',
+
'entity_id'
=>$entity_id,
+
'cat_id'
=>$cat_id,
+
'allrows'=>$this->allrows)
+
)),
+ 'lang_name' => lang('Name'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_attribtext' => lang('add a attrib'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_attrib&entity_id='.$entity_id
. '&cat_id=' . $cat_id),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_attribtext' => lang('back to
admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.category&entity_id='.$entity_id),
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.list_attribute',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'query'
=>$this->query,
+ 'entity_id'
=>$entity_id,
+ 'cat_id'
=>$cat_id
+ );
+
+ $entity = $this->bo->read_single($entity_id,false);
+ $category =
$this->bo->read_single_category($entity_id,$cat_id);
+
+ $data = array
+ (
+ 'lang_entity'
=> lang('entity'),
+ 'entity_name'
=> $entity['name'],
+ 'lang_category'
=> lang('category'),
+ 'category_name'
=> $category['name'],
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'start_record'
=> $this->start,
+ 'num_records'
=> count($attrib_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_attribtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_attribtext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_attrib' =>
$table_header,
+ 'values_attrib'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('attribute');
+ $function_msg =
lang('list entity attribute');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_attribute' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit_attrib()
+ {
+ $entity_id =
get_var('entity_id',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $id =
get_var('id',array('POST','GET'));
+ $values = get_var('values',array('POST'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_entity'));
+
+ if ($values['save'])
+ {
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+
+ $values['entity_id']=$entity_id;
+ $values['cat_id']=$cat_id;
+
+ if (!$values['column_name'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Column name not entered!'));
+ }
+
+ if (!$values['input_text'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Input text not entered!'));
+ }
+ if (!$values['statustext'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Statustext not entered!'));
+ }
+
+ if (!$values['entity_id'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('entity type not choosen!'));
+ }
+
+ if (!$values['column_info']['type'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Datatype type not choosen!'));
+ }
+
+
if(!ctype_digit($values['column_info']['precision']))
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter precision as integer !'));
+
unset($values['column_info']['precision']);
+ }
+
+ if($values['column_info']['scale'] &&
!ctype_digit($values['column_info']['scale']))
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter scale as integer !'));
+ unset($values['column_info']['scale']);
+ }
+
+ if (!$values['column_info']['nullable'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Nullable not choosen!'));
+ }
+
+
+ if (!$receipt['error'])
+ {
+
+ $receipt =
$this->bo->save_attrib($values,$action);
+
+ if(!$id)
+ {
+ $id=$receipt['id'];
+ }
+ }
+ else
+ {
+ $receipt['error'][] = array('msg'
=> lang('Attribute has NOT been saved'));
+ }
+
+ }
+
+ if ($id)
+ {
+ $values =
$this->bo->read_single_attrib($entity_id,$cat_id,$id);
+ $type_name=$values['type_name'];
+ $function_msg = lang('edit attribute'). ' ' .
lang($type_name);
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add attribute');
+ $action='add';
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.edit_attrib',
+ 'entity_id' => $entity_id,
+ 'cat_id' => $cat_id,
+ 'id' => $id
+ );
+
+ if($values['column_info']['type']=='R' ||
$values['column_info']['type']=='CH' || $values['column_info']['type']=='LB')
+ {
+ $multiple_choice= True;
+ }
+
+//_debug_array($values);
+
+ $entity = $this->bo->read_single($entity_id,false);
+ $category =
$this->bo->read_single_category($entity_id,$cat_id);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'lang_entity'
=> lang('entity'),
+ 'entity_name'
=> $entity['name'],
+ 'lang_category'
=> lang('category'),
+ 'category_name'
=> $category['name'],
+
+ 'lang_choice' =>
lang('Choice'),
+ 'lang_new_value' =>
lang('New value'),
+ 'lang_new_value_statustext' => lang('New
value for mulitple choice'),
+ 'multiple_choice' =>
$multiple_choice,
+ 'value_choice' =>
$values['choice'],
+ 'lang_delete_value' =>
lang('Delete value'),
+ 'lang_value' =>
lang('value'),
+ 'lang_delete_choice_statustext'=> lang('Delete
this value from the list of multiple choice'),
+
+ 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_attribute&entity_id='.$entity_id
. '&cat_id='.$cat_id),
+ 'lang_id'
=> lang('Attribute ID'),
+ 'lang_entity_type' =>
lang('Entity type'),
+ 'lang_no_entity_type' => lang('No
entity type'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id'
=> $id,
+
+ 'lang_column_name'
=> lang('Column name'),
+ 'value_column_name'
=> $values['column_name'],
+ 'lang_column_name_statustext' => lang('enter
the name for the column'),
+
+ 'lang_input_text'
=> lang('input text'),
+ 'value_input_text'
=> $values['input_text'],
+ 'lang_input_name_statustext' => lang('enter
the input text for records'),
+
+ 'lang_id_attribtext' => lang('Enter
the attribute ID'),
+ 'lang_entity_statustext' => lang('Select
a entity type'),
+
+ 'lang_statustext' =>
lang('Statustext'),
+ 'lang_statustext_attribtext'=> lang('Enter a
statustext for the inputfield in forms'),
+ 'value_statustext' =>
$values['statustext'],
+
+ 'lang_done_attribtext' => lang('Back
to the list'),
+ 'lang_save_attribtext' => lang('Save
the attribute'),
+
+ 'lang_datatype' =>
lang('Datatype'),
+ 'lang_datatype_statustext' => lang('Select
a datatype'),
+ 'lang_no_datatype' =>
lang('No datatype'),
+ 'datatype_list' =>
$this->bocommon->select_datatype($values['column_info']['type']),
+
+ 'lang_precision' =>
lang('Precision'),
+ 'lang_precision_statustext' => lang('enter
the record length'),
+ 'value_precision' =>
$values['column_info']['precision'],
+
+ 'lang_scale' =>
lang('scale'),
+ 'lang_scale_statustext' => lang('enter
the scale if type is decimal'),
+ 'value_scale' =>
$values['column_info']['scale'],
+
+ 'lang_default' =>
lang('default'),
+ 'lang_default_statustext' => lang('enter
the default value'),
+ 'value_default' =>
$values['column_info']['default'],
+
+ 'lang_nullable' =>
lang('Nullable'),
+ 'lang_nullable_statustext' => lang('Chose
if this column is nullable'),
+ 'lang_select_nullable' => lang('Select
nullable'),
+ 'nullable_list' =>
$this->bocommon->select_nullable($values['column_info']['nullable']),
+ 'value_lookup_form' =>
$values['lookup_form'],
+ 'lang_lookup_form'
=> lang('show in lookup forms'),
+ 'lang_lookup_form_statustext'
=> lang('check to show this attribue in lookup forms'),
+ 'value_list' =>
$values['list'],
+ 'lang_list' =>
lang('show in list'),
+ 'lang_list_statustext' =>
lang('check to show this attribute in entity list'),
+ 'value_search' =>
$values['search'],
+ 'lang_include_search' =>
lang('Include in search'),
+ 'lang_include_search_statustext'=> lang('check
to show this attribute in location list'),
+
+ );
+//_debug_array($values);
+
+ $appname
= lang('entity');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_attrib' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function list_custom_function()
+ {
+ $entity_id = $this->entity_id;
+ $cat_id = $this->cat_id;
+ $id = get_var('id',array('POST','GET'));
+ $resort = get_var('resort',array('POST','GET'));
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array(
+
'admin_entity',
+
'nextmatchs',
+
'search_field'));
+
+ if($resort)
+ {
+ $this->bo->resort_custom_function($id,$resort);
+ }
+ $custom_function_list =
$this->bo->read_custom_function($entity_id,$cat_id);
+
+ if (isset($custom_function_list) AND
is_array($custom_function_list))
+ {
+ foreach($custom_function_list as $entry)
+ {
+
+ $content[] = array
+ (
+ 'file_name'
=> $entry['file_name'],
+ 'descr'
=> $entry['descr'],
+ 'sorting'
=> $entry['sorting'],
+ 'active'
=> $entry['active']?'X':'',
+ 'link_up'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_custom_function&resort=up&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id'] . '&allrows=' .
$this->allrows),
+ 'link_down'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_custom_function&resort=down&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id'] . '&allrows=' .
$this->allrows),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_custom_function&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id']),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.delete&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&custom_function_id=' . $entry['id']),
+ 'lang_up_text'
=> lang('shift up'),
+ 'lang_down_text'
=> lang('shift down'),
+ 'lang_edit_text'
=> lang('edit the custom_function'),
+ 'lang_delete_text'
=> lang('delete the custom_function'),
+ 'text_custom_function'
=> lang('custom_functions'),
+ 'text_up'
=> lang('up'),
+ 'text_down'
=> lang('down'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+ }
+
+ $table_header[] = array
+ (
+ 'lang_descr' => lang('Descr'),
+ 'lang_active' => lang('Active'),
+ 'lang_sorting' => lang('sorting'),
+ 'lang_search' => lang('search'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'column_name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.list_custom_function',
+
'entity_id'
=>$entity_id,
+
'cat_id'
=>$cat_id,
+
'allrows'=>$this->allrows)
+
)),
+ 'sort_sorting' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'custom_function_sort',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.list_custom_function',
+
'entity_id'
=>$entity_id,
+
'cat_id'
=>$cat_id,
+
'allrows'=>$this->allrows)
+
)),
+ 'lang_name' => lang('Name'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_custom_functiontext' => lang('add a
custom_function'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_custom_function&entity_id='.$entity_id
. '&cat_id=' . $cat_id),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_custom_functiontext' => lang('back
to admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.category&entity_id='.$entity_id),
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.list_custom_function',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'query'
=>$this->query,
+ 'entity_id'
=>$entity_id,
+ 'cat_id'
=>$cat_id
+ );
+
+ $entity = $this->bo->read_single($entity_id,false);
+ $category =
$this->bo->read_single_category($entity_id,$cat_id);
+
+ $data = array
+ (
+ 'lang_entity'
=> lang('entity'),
+ 'entity_name'
=> $entity['name'],
+ 'lang_category'
=> lang('category'),
+ 'category_name'
=> $category['name'],
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'start_record'
=> $this->start,
+ 'num_records'
=> count($custom_function_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_custom_functiontext' =>
lang('Enter the search string. To show all entries, empty this field and press
the SUBMIT button again'),
+ 'lang_searchbutton_custom_functiontext' =>
lang('Submit the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_custom_function'
=> $table_header,
+ 'values_custom_function'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('custom function');
+ $function_msg =
lang('list entity custom function');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_custom_function' =>
$data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit_custom_function()
+ {
+ $entity_id =
get_var('entity_id',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $id =
get_var('id',array('POST','GET'));
+ $values = get_var('values',array('POST'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_entity'));
+
+ if ($values['save'])
+ {
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+
+ $values['entity_id']=$entity_id;
+ $values['cat_id']=$cat_id;
+
+
+ if (!$values['entity_id'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('entity type not choosen!'));
+ }
+
+ if (!$values['custom_function_file'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('custom function file not choosen!'));
+ }
+
+
+ if (!$receipt['error'])
+ {
+
+ $receipt =
$this->bo->save_custom_function($values,$action);
+
+ if(!$id)
+ {
+ $id=$receipt['id'];
+ }
+ }
+ else
+ {
+ $receipt['error'][] = array('msg'
=> lang('Custom function has NOT been saved'));
+ }
+
+ }
+
+ if ($id)
+ {
+ $values =
$this->bo->read_single_custom_function($entity_id,$cat_id,$id);
+ $type_name=$values['type_name'];
+ $function_msg = lang('edit custom function'). '
' . lang($type_name);
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add custom function');
+ $action='add';
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.edit_custom_function',
+ 'entity_id' => $entity_id,
+ 'cat_id' => $cat_id,
+ 'id' => $id
+ );
+
+
+//_debug_array($values);
+
+ $entity = $this->bo->read_single($entity_id,false);
+ $category =
$this->bo->read_single_category($entity_id,$cat_id);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'lang_entity'
=> lang('entity'),
+ 'entity_name'
=> $entity['name'],
+ 'lang_category'
=> lang('category'),
+ 'category_name'
=> $category['name'],
+
+ 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_custom_function&entity_id='.$entity_id
. '&cat_id='.$cat_id),
+ 'lang_id'
=> lang('Custom function ID'),
+ 'lang_entity_type' =>
lang('Entity type'),
+ 'lang_no_entity_type' => lang('No
entity type'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id'
=> $id,
+
+ 'lang_descr' =>
lang('descr'),
+ 'lang_descr_custom_functiontext'=> lang('Enter
a descr for the custom function'),
+ 'value_descr' =>
$values['descr'],
+
+ 'lang_done_custom_functiontext' =>
lang('Back to the list'),
+ 'lang_save_custom_functiontext' =>
lang('Save the custom function'),
+
+ 'lang_custom_function'
=> lang('custom function'),
+ 'lang_custom_function_statustext' =>
lang('Select a custom_function'),
+ 'lang_no_custom_function'
=> lang('No custom function'),
+ 'custom_function_list'
=> $this->bo->select_custom_function($values['custom_function_file']),
+
+ 'value_active' =>
$values['active'],
+ 'lang_active' =>
lang('Active'),
+ 'lang_active_statustext' => lang('check
acivate custom function'),
+ 'value_search' =>
$values['search'],
+ 'lang_include_search' =>
lang('Include in search'),
+ 'lang_include_search_statustext'=> lang('check
to show this custom function in location list')
+ );
+
+ $appname
= lang('entity');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_custom_function' =>
$data));
+ }
+
+ }
+?>
Index: property/inc/class.uiadmin_location.inc.php
diff -u property/inc/class.uiadmin_location.inc.php:1.9
property/inc/class.uiadmin_location.inc.php:1.10
--- property/inc/class.uiadmin_location.inc.php:1.9 Wed May 18 16:05:55 2005
+++ property/inc/class.uiadmin_location.inc.php Fri Jan 27 14:05:43 2006
@@ -1,787 +1,787 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.uiadmin_location.inc.php,v 1.9 2005/05/18
16:05:55 sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uiadmin_location
- {
- var $grants;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'index' => True,
- 'config' => True,
- 'edit_config' => True,
- 'view' => True,
- 'edit' => True,
- 'delete' => True,
- 'list_attribute' => True,
- 'edit_attrib' => True,
- );
-
- function uiadmin_location()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bo =
CreateObject($this->currentapp.'.boadmin_location',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
-
- $this->start =
$this->bo->start;
- $this->query =
$this->bo->query;
- $this->sort =
$this->bo->sort;
- $this->order =
$this->bo->order;
- $this->allrows =
$this->bo->allrows;
-
- $this->menu->sub ='adm_loc';
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- );
- $this->bo->save_sessiondata($data);
- }
-
- function index()
- {
-
- $this->bo->reset_fm_cache();
- $GLOBALS['phpgw']->xslttpl->add_file(array(
-
'admin_location',
-
'nextmatchs',
-
'menu',
-
'search_field'));
- $links = $this->menu->links('loc_type');
-
- $standard_list = $this->bo->read();
-
- while (is_array($standard_list) && list(,$standard) =
each($standard_list))
- {
- $words = split(' ',$standard['descr']);
- $first = "$words[0] $words[1] $words[2]
$words[3]";
-
- $content[] = array
- (
- 'id'
=> $standard['id'],
- 'name'
=> $standard['name'],
- 'prefix'
=> $standard['prefix'],
- 'first'
=> $first,
- 'link_categories'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicategory.index&type=location&type_id='
. $standard['id']),
- 'link_attribute'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.list_attribute&type_id='
. $standard['id']),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.edit&id='
. $standard['id']),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.delete&id='
. $standard['id']),
- 'lang_view_standardtext' =>
lang('view the standard'),
- 'lang_category_text' =>
lang('categories for the location type'),
- 'lang_attribute_standardtext' =>
lang('attributes for the location type'),
- 'lang_edit_standardtext' =>
lang('edit the standard'),
- 'lang_delete_standardtext' =>
lang('delete the standard'),
- 'text_categories'
=> lang('Categories'),
- 'text_attribute'
=> lang('Attributes'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
-
-//_debug_array($content);
-
- $table_header[] = array
- (
-
- 'lang_descr' => lang('Descr'),
- 'lang_prefix' => lang('prefix'),
- 'lang_categories' => lang('Categories'),
- 'lang_attribute' => lang('Attributes'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_location.index')
-
)),
- 'lang_id' => lang('standard id'),
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_location.index')
-
)),
- 'lang_name' => lang('Name'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_standardtext' => lang('add a
standard'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.edit'),
- 'lang_done' =>
lang('done'),
- 'lang_done_standardtext' => lang('back
to admin'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php')
- );
-
-
- $data = array
- (
- 'links'
=> $links,
- 'allow_allrows'
=> False,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($standard_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.index'),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('location');
- $function_msg =
lang('list location standard');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit()
- {
- $id = get_var('id',array('POST','GET'));
- $values =
get_var('values',array('POST'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_location'));
-
- if ($values['save'])
- {
- if (!$values['name'])
- {
- $receipt['error'][] =
array('msg'=>lang('Name not entered!'));
- }
-
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
-
- if (!$receipt['error'])
- {
-
- $receipt =
$this->bo->save($values,$action);
- if(!$id)
- {
- $id=$receipt['id'];
- }
- }
- else
- {
- $receipt['error'][] = array('msg'=>
lang('Table has NOT been saved'));
- }
-
- }
-
- if ($id)
- {
- $values = $this->bo->read_single($id);
- $function_msg = lang('edit standard');
- $action='edit';
- }
- else
- {
- $function_msg = lang('add standard');
- $action='add';
- }
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_location.edit',
- 'id' => $id
- );
-//_debug_array($link_data);
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'lang_prefix'
=> lang('Standard prefix'),
- 'lang_prefix_standardtext' =>
lang('Enter a standard prefix for the id'),
- 'lang_name_standardtext' =>
lang('Enter a name of the standard'),
-
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.index'),
- 'lang_id'
=> lang('standard ID'),
- 'lang_name'
=> lang('Name'),
- 'lang_descr'
=> lang('Descr'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_id'
=> $id,
- 'value_name'
=> $values['name'],
- 'value_prefix'
=> $values['prefix'],
- 'lang_id_standardtext' =>
lang('Enter the standard ID'),
- 'lang_descr_standardtext' =>
lang('Enter a description of the standard'),
- 'lang_done_standardtext' =>
lang('Back to the list'),
- 'lang_save_standardtext' =>
lang('Save the standard'),
- 'type_id'
=> $values['type_id'],
- 'value_descr'
=> $values['descr']
- );
-
- $appname
= lang('location');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function delete()
- {
- $attrib = get_var('attrib',array('POST','GET'));
- $type_id =
get_var('type_id',array('POST','GET'));
- $id =
get_var('id',array('POST','GET'));
- $confirm = get_var('confirm',array('POST'));
-
- if($attrib)
- {
- $function='list_attribute';
- }
- else
- {
- $function='index';
- }
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_location.'.$function,
- 'type_id' => $type_id
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($type_id,$id,$attrib);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.delete&id='
. $id.'&attrib='.$attrib.'&type_id='.$type_id),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_standardtext' => lang('Delete the
entry'),
- 'lang_no_standardtext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('location');
- $function_msg =
lang('delete location standard');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- function list_attribute()
- {
- $type_id =
get_var('type_id',array('POST','GET'));
- $id = get_var('id',array('POST','GET'));
- $resort = get_var('resort',array('POST','GET'));
-
- $GLOBALS['phpgw']->xslttpl->add_file(array(
-
'admin_location',
-
'nextmatchs',
-
'search_field'));
-
- if($resort)
- {
-
$this->bo->resort_attrib(array('resort'=>$resort,'type_id' =>
$type_id,'id'=>$id));
- }
-
- $attrib_list = $this->bo->read_attrib($type_id);
-
- while (is_array($attrib_list) && list(,$attrib) =
each($attrib_list))
- {
- $content[] = array
- (
- 'name'
=> $attrib['name'],
- 'type_name'
=> $attrib['type_name'],
- 'datatype'
=> $attrib['datatype'],
- 'column_name'
=> $attrib['column_name'],
- 'input_text'
=> $attrib['input_text'],
- 'sorting'
=> $attrib['attrib_sort'],
- 'link_up'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.list_attribute&resort=up&id='
. $attrib['id'].'&type_id='.$type_id . '&allrows=' . $this->allrows),
- 'link_down'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.list_attribute&resort=down&id='
. $attrib['id'].'&type_id='.$type_id . '&allrows=' . $this->allrows),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.edit_attrib&id='
. $attrib['id'].'&type_id='.$type_id),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.delete&id='
. $attrib['id'].'&type_id='.$type_id.'&attrib=true'),
- 'lang_view_attribtext' =>
lang('view the attrib'),
- 'lang_attribute_attribtext' =>
lang('attributes for the attrib'). ' ' . lang('location'),
- 'lang_edit_attribtext' =>
lang('edit the attrib'),
- 'lang_delete_attribtext' =>
lang('delete the attrib'),
- 'text_attribute'
=> lang('Attributes'),
- 'text_up'
=> lang('up'),
- 'text_down'
=> lang('down'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
-
-//_debug_array($content);
-
- $table_header[] = array
- (
- 'lang_type_name' => lang('Type'),
- 'lang_descr' => lang('Descr'),
- 'lang_datatype' => lang('Datatype'),
- 'lang_sorting' => lang('sorting'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_sorting' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'attrib_sort',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_location.list_attribute',
-
'type_id'
=>$type_id,
-
'allrows'=>$this->allrows)
-
)),
-
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'column_name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_location.list_attribute',
-
'type_id'
=>$type_id,
-
'allrows'=>$this->allrows)
-
)),
- 'lang_name' => lang('Name'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_attribtext' => lang('add a attrib'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.edit_attrib&type_id='.$type_id),
- 'lang_done' =>
lang('done'),
- 'lang_done_attribtext' => lang('back to
admin'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.index'),
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_location.list_attribute',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'query'
=>$this->query,
- 'type_id'
=>$type_id
- );
-
- $data = array
- (
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($attrib_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_attribtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_attribtext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_attrib' =>
$table_header,
- 'values_attrib'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('attribute');
- $function_msg =
lang('list location attribute');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_attribute' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit_attrib()
- {
- $type_id =
get_var('type_id',array('POST','GET'));
- $id =
get_var('id',array('POST','GET'));
- $values = get_var('values',array('POST'));
-
-//_debug_array($values);
-
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_location'));
-
- if ($values['save'])
- {
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
- $type_id =
$values['type_id'];
-
- if (!$values['column_name'])
- {
- $receipt['error'][] =
array('msg'=>lang('Column name not entered!'));
- }
-
- if (!$values['input_text'])
- {
- $receipt['error'][] =
array('msg'=>lang('Input text not entered!'));
- }
- if (!$values['statustext'])
- {
- $receipt['error'][] =
array('msg'=>lang('Statustext not entered!'));
- }
-
- if (!$values['type_id'])
- {
- $receipt['error'][] =
array('msg'=>lang('Location type not choosen!'));
- }
-
- if (!$values['column_info']['type'])
- {
- $receipt['error'][] =
array('msg'=>lang('Datatype type not choosen!'));
- }
-
-
if(!ctype_digit($values['column_info']['precision']))
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter precision as integer !'));
-
unset($values['column_info']['precision']);
- }
-
-
if(!ctype_digit($values['column_info']['scale']))
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter scale as integer !'));
- unset($values['column_info']['scale']);
- }
-
- if (!$values['column_info']['nullable'])
- {
- $receipt['error'][] =
array('msg'=>lang('Nullable not choosen!'));
- }
-
-
- if (!$receipt['error'])
- {
-
- $receipt =
$this->bo->save_attrib($values,$action);
-
- if(!$id)
- {
- $id=$receipt['id'];
- }
- }
- else
- {
- $receipt['error'][] = array('msg'
=> lang('Attribute has NOT been saved'));
- }
-
- }
-
- if ($id)
- {
- $values =
$this->bo->read_single_attrib($type_id,$id);
- $type_name=$attrib['type_name'];
- $function_msg = lang('edit attribute'). ' ' .
lang($type_name);
- $action='edit';
- }
- else
- {
- $function_msg = lang('add attribute');
- $action='add';
- }
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_location.edit_attrib',
- 'id' => $id
- );
-//_debug_array($values);
-
- if($values['column_info']['type']=='R' ||
$values['column_info']['type']=='CH' || $values['column_info']['type']=='LB')
- {
- $multiple_choice= True;
- }
-
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'lang_choice' =>
lang('Choice'),
- 'lang_new_value' =>
lang('New value'),
- 'lang_new_value_statustext' => lang('New
value for mulitple choice'),
- 'multiple_choice' =>
$multiple_choice,
- 'value_choice' =>
$values['choice'],
- 'lang_delete_value' =>
lang('Delete value'),
- 'lang_value' =>
lang('value'),
- 'lang_delete_choice_statustext'=> lang('Delete
this value from the list of multiple choice'),
-
- 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.list_attribute&type_id='.$type_id),
- 'lang_id'
=> lang('Attribute ID'),
- 'lang_location_type' =>
lang('Type'),
- 'lang_no_location_type' => lang('No
entity type'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_id'
=> $id,
-
- 'lang_column_name'
=> lang('Column name'),
- 'value_column_name'
=> $values['column_name'],
- 'lang_column_name_statustext' => lang('enter
the name for the column'),
-
- 'lang_input_text'
=> lang('input text'),
- 'value_input_text'
=> $values['input_text'],
- 'lang_input_name_statustext' => lang('enter
the input text for records'),
-
- 'lang_id_attribtext' => lang('Enter
the attribute ID'),
- 'lang_entity_statustext' => lang('Select
a entity type'),
-
- 'lang_statustext' =>
lang('Statustext'),
- 'lang_statustext_attribtext'=> lang('Enter a
statustext for the inputfield in forms'),
- 'value_statustext' =>
$values['statustext'],
-
- 'lang_done_attribtext' => lang('Back
to the list'),
- 'lang_save_attribtext' => lang('Save
the attribute'),
- 'type_id'
=> $values['type_id'],
- 'entity_list' =>
$this->bo->select_location_type($type_id),
- 'select_location_type' =>
'values[type_id]',
- 'lang_datatype' =>
lang('Datatype'),
- 'lang_datatype_statustext' => lang('Select
a datatype'),
- 'lang_no_datatype' =>
lang('No datatype'),
- 'datatype_list' =>
$this->bocommon->select_datatype($values['column_info']['type']),
-
- 'lang_precision' =>
lang('Precision'),
- 'lang_precision_statustext' => lang('enter
the record length'),
- 'value_precision' =>
$values['column_info']['precision'],
-
- 'lang_scale' =>
lang('scale'),
- 'lang_scale_statustext' => lang('enter
the scale if type is decimal'),
- 'value_scale' =>
$values['column_info']['scale'],
-
- 'lang_default' =>
lang('default'),
- 'lang_default_statustext' => lang('enter
the default value'),
- 'value_default' =>
$values['column_info']['default'],
-
- 'lang_nullable' =>
lang('Nullable'),
- 'lang_nullable_statustext' => lang('Chose
if this column is nullable'),
- 'lang_select_nullable' => lang('Select
nullable'),
- 'nullable_list' =>
$this->bocommon->select_nullable($values['column_info']['nullable']),
- 'value_lookup_form' =>
$values['lookup_form'],
- 'lang_lookup_form'
=> lang('show in lookup forms'),
- 'lang_lookup_form_statustext'
=> lang('check to show this attribue in lookup forms'),
- 'value_list' =>
$values['list'],
- 'lang_list' =>
lang('show in list'),
- 'lang_list_statustext' =>
lang('check to show this attribute in location list')
- );
-//_debug_array($data);
-
- $appname
= lang('location');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_attrib' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function config()
- {
-
- $GLOBALS['phpgw']->xslttpl->add_file(array(
-
'admin_location',
-
'nextmatchs',
-
'menu',
-
'search_field'));
- $links = $this->menu->links('loc_config');
-
- $standard_list = $this->bo->read_config();
-
- while (is_array($standard_list) && list(,$standard) =
each($standard_list))
- {
- $content[] = array
- (
- 'column_name'
=> $standard['column_name'],
- 'name'
=> $standard['location_name'],
- 'prefix'
=> $standard['prefix'],
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.edit_config&column_name='
. $standard['column_name']),
- 'lang_edit_standardtext' =>
lang('edit the column relation'),
- 'text_edit'
=> lang('edit')
- );
- }
-
-//_debug_array($content);
-
- $table_header[] = array
- (
-
- 'lang_attribute' => lang('Attributes'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_column_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'column_name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_location.config')
-
)),
- 'lang_column_name' => lang('column name'),
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_location.config')
-
)),
- 'lang_name' => lang('Table Name'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_standardtext' => lang('add a
standard'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.edit'),
- 'lang_done' =>
lang('done'),
- 'lang_done_standardtext' => lang('back
to admin'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php')
- );
-
-
- $data = array
- (
- 'links'
=> $links,
- 'allow_allrows'
=> False,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($standard_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.index'),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_list_config' =>
$table_header,
- 'values_list_config' =>
$content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('location');
- $function_msg =
lang('list config');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_config' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit_config()
- {
- $column_name =
get_var('column_name',array('POST','GET'));
- $values =
get_var('values',array('POST'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_location'));
-
- if ($values['save'])
- {
-
- if (!$receipt['error'])
- {
-
- $receipt =
$this->bo->save_config($values,$column_name);
- }
-
- }
-
- $type_id =
$this->bo->read_config_single($column_name);
-
- $function_msg = lang('edit location config for') . ' '
.$column_name;
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_location.edit_config',
- 'column_name' => $column_name
- );
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
-
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.config'),
-
- 'lang_column_name'
=> lang('Column name'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'column_name'
=> $column_name,
- 'value_name'
=> $values['name'],
-
- 'location_list'
=> $this->bo->select_location_type($type_id),
-
- 'lang_config_statustext' =>
lang('Select the level for this information'),
- 'lang_done_standardtext' =>
lang('Back to the list'),
- 'lang_save_standardtext' =>
lang('Save the standard'),
- 'type_id'
=> $values['type_id'],
- 'value_descr'
=> $values['descr']
- );
-
- $appname
= lang('location');
-
-//_debug_array($data);
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_config' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.uiadmin_location.inc.php,v 1.10 2006/01/27
14:05:43 sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uiadmin_location
+ {
+ var $grants;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'config' => True,
+ 'edit_config' => True,
+ 'view' => True,
+ 'edit' => True,
+ 'delete' => True,
+ 'list_attribute' => True,
+ 'edit_attrib' => True,
+ );
+
+ function uiadmin_location()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bo =
CreateObject($this->currentapp.'.boadmin_location',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+
+ $this->start =
$this->bo->start;
+ $this->query =
$this->bo->query;
+ $this->sort =
$this->bo->sort;
+ $this->order =
$this->bo->order;
+ $this->allrows =
$this->bo->allrows;
+
+ $this->menu->sub ='adm_loc';
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function index()
+ {
+
+ $this->bo->reset_fm_cache();
+ $GLOBALS['phpgw']->xslttpl->add_file(array(
+
'admin_location',
+
'nextmatchs',
+
'menu',
+
'search_field'));
+ $links = $this->menu->links('loc_type');
+
+ $standard_list = $this->bo->read();
+
+ while (is_array($standard_list) && list(,$standard) =
each($standard_list))
+ {
+ $words = split(' ',$standard['descr']);
+ $first = "$words[0] $words[1] $words[2]
$words[3]";
+
+ $content[] = array
+ (
+ 'id'
=> $standard['id'],
+ 'name'
=> $standard['name'],
+ 'prefix'
=> $standard['prefix'],
+ 'first'
=> $first,
+ 'link_categories'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicategory.index&type=location&type_id='
. $standard['id']),
+ 'link_attribute'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.list_attribute&type_id='
. $standard['id']),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.edit&id='
. $standard['id']),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.delete&id='
. $standard['id']),
+ 'lang_view_standardtext' =>
lang('view the standard'),
+ 'lang_category_text' =>
lang('categories for the location type'),
+ 'lang_attribute_standardtext' =>
lang('attributes for the location type'),
+ 'lang_edit_standardtext' =>
lang('edit the standard'),
+ 'lang_delete_standardtext' =>
lang('delete the standard'),
+ 'text_categories'
=> lang('Categories'),
+ 'text_attribute'
=> lang('Attributes'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+
+//_debug_array($content);
+
+ $table_header[] = array
+ (
+
+ 'lang_descr' => lang('Descr'),
+ 'lang_prefix' => lang('prefix'),
+ 'lang_categories' => lang('Categories'),
+ 'lang_attribute' => lang('Attributes'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_location.index')
+
)),
+ 'lang_id' => lang('standard id'),
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_location.index')
+
)),
+ 'lang_name' => lang('Name'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_standardtext' => lang('add a
standard'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.edit'),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_standardtext' => lang('back
to admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php')
+ );
+
+
+ $data = array
+ (
+ 'links'
=> $links,
+ 'allow_allrows'
=> False,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($standard_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.index'),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('location');
+ $function_msg =
lang('list location standard');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit()
+ {
+ $id = get_var('id',array('POST','GET'));
+ $values =
get_var('values',array('POST'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_location'));
+
+ if ($values['save'])
+ {
+ if (!$values['name'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Name not entered!'));
+ }
+
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+
+ if (!$receipt['error'])
+ {
+
+ $receipt =
$this->bo->save($values,$action);
+ if(!$id)
+ {
+ $id=$receipt['id'];
+ }
+ }
+ else
+ {
+ $receipt['error'][] = array('msg'=>
lang('Table has NOT been saved'));
+ }
+
+ }
+
+ if ($id)
+ {
+ $values = $this->bo->read_single($id);
+ $function_msg = lang('edit standard');
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add standard');
+ $action='add';
+ }
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_location.edit',
+ 'id' => $id
+ );
+//_debug_array($link_data);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'lang_prefix'
=> lang('Standard prefix'),
+ 'lang_prefix_standardtext' =>
lang('Enter a standard prefix for the id'),
+ 'lang_name_standardtext' =>
lang('Enter a name of the standard'),
+
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.index'),
+ 'lang_id'
=> lang('standard ID'),
+ 'lang_name'
=> lang('Name'),
+ 'lang_descr'
=> lang('Descr'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id'
=> $id,
+ 'value_name'
=> $values['name'],
+ 'value_prefix'
=> $values['prefix'],
+ 'lang_id_standardtext' =>
lang('Enter the standard ID'),
+ 'lang_descr_standardtext' =>
lang('Enter a description of the standard'),
+ 'lang_done_standardtext' =>
lang('Back to the list'),
+ 'lang_save_standardtext' =>
lang('Save the standard'),
+ 'type_id'
=> $values['type_id'],
+ 'value_descr'
=> $values['descr']
+ );
+
+ $appname
= lang('location');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function delete()
+ {
+ $attrib = get_var('attrib',array('POST','GET'));
+ $type_id =
get_var('type_id',array('POST','GET'));
+ $id =
get_var('id',array('POST','GET'));
+ $confirm = get_var('confirm',array('POST'));
+
+ if($attrib)
+ {
+ $function='list_attribute';
+ }
+ else
+ {
+ $function='index';
+ }
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_location.'.$function,
+ 'type_id' => $type_id
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($type_id,$id,$attrib);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.delete&id='
. $id.'&attrib='.$attrib.'&type_id='.$type_id),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_standardtext' => lang('Delete the
entry'),
+ 'lang_no_standardtext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('location');
+ $function_msg =
lang('delete location standard');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ function list_attribute()
+ {
+ $type_id =
get_var('type_id',array('POST','GET'));
+ $id = get_var('id',array('POST','GET'));
+ $resort = get_var('resort',array('POST','GET'));
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array(
+
'admin_location',
+
'nextmatchs',
+
'search_field'));
+
+ if($resort)
+ {
+
$this->bo->resort_attrib(array('resort'=>$resort,'type_id' =>
$type_id,'id'=>$id));
+ }
+
+ $attrib_list = $this->bo->read_attrib($type_id);
+
+ while (is_array($attrib_list) && list(,$attrib) =
each($attrib_list))
+ {
+ $content[] = array
+ (
+ 'name'
=> $attrib['name'],
+ 'type_name'
=> $attrib['type_name'],
+ 'datatype'
=> $attrib['datatype'],
+ 'column_name'
=> $attrib['column_name'],
+ 'input_text'
=> $attrib['input_text'],
+ 'sorting'
=> $attrib['attrib_sort'],
+ 'link_up'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.list_attribute&resort=up&id='
. $attrib['id'].'&type_id='.$type_id . '&allrows=' . $this->allrows),
+ 'link_down'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.list_attribute&resort=down&id='
. $attrib['id'].'&type_id='.$type_id . '&allrows=' . $this->allrows),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.edit_attrib&id='
. $attrib['id'].'&type_id='.$type_id),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.delete&id='
. $attrib['id'].'&type_id='.$type_id.'&attrib=true'),
+ 'lang_view_attribtext' =>
lang('view the attrib'),
+ 'lang_attribute_attribtext' =>
lang('attributes for the attrib'). ' ' . lang('location'),
+ 'lang_edit_attribtext' =>
lang('edit the attrib'),
+ 'lang_delete_attribtext' =>
lang('delete the attrib'),
+ 'text_attribute'
=> lang('Attributes'),
+ 'text_up'
=> lang('up'),
+ 'text_down'
=> lang('down'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+
+//_debug_array($content);
+
+ $table_header[] = array
+ (
+ 'lang_type_name' => lang('Type'),
+ 'lang_descr' => lang('Descr'),
+ 'lang_datatype' => lang('Datatype'),
+ 'lang_sorting' => lang('sorting'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_sorting' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'attrib_sort',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_location.list_attribute',
+
'type_id'
=>$type_id,
+
'allrows'=>$this->allrows)
+
)),
+
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'column_name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_location.list_attribute',
+
'type_id'
=>$type_id,
+
'allrows'=>$this->allrows)
+
)),
+ 'lang_name' => lang('Name'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_attribtext' => lang('add a attrib'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.edit_attrib&type_id='.$type_id),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_attribtext' => lang('back to
admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.index'),
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_location.list_attribute',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'query'
=>$this->query,
+ 'type_id'
=>$type_id
+ );
+
+ $data = array
+ (
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($attrib_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_attribtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_attribtext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_attrib' =>
$table_header,
+ 'values_attrib'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('attribute');
+ $function_msg =
lang('list location attribute');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_attribute' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit_attrib()
+ {
+ $type_id =
get_var('type_id',array('POST','GET'));
+ $id =
get_var('id',array('POST','GET'));
+ $values = get_var('values',array('POST'));
+
+//_debug_array($values);
+
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_location'));
+
+ if ($values['save'])
+ {
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+ $type_id =
$values['type_id'];
+
+ if (!$values['column_name'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Column name not entered!'));
+ }
+
+ if (!$values['input_text'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Input text not entered!'));
+ }
+ if (!$values['statustext'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Statustext not entered!'));
+ }
+
+ if (!$values['type_id'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Location type not choosen!'));
+ }
+
+ if (!$values['column_info']['type'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Datatype type not choosen!'));
+ }
+
+
if(!ctype_digit($values['column_info']['precision']))
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter precision as integer !'));
+
unset($values['column_info']['precision']);
+ }
+
+
if(!ctype_digit($values['column_info']['scale']))
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter scale as integer !'));
+ unset($values['column_info']['scale']);
+ }
+
+ if (!$values['column_info']['nullable'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Nullable not choosen!'));
+ }
+
+
+ if (!$receipt['error'])
+ {
+
+ $receipt =
$this->bo->save_attrib($values,$action);
+
+ if(!$id)
+ {
+ $id=$receipt['id'];
+ }
+ }
+ else
+ {
+ $receipt['error'][] = array('msg'
=> lang('Attribute has NOT been saved'));
+ }
+
+ }
+
+ if ($id)
+ {
+ $values =
$this->bo->read_single_attrib($type_id,$id);
+ $type_name=$attrib['type_name'];
+ $function_msg = lang('edit attribute'). ' ' .
lang($type_name);
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add attribute');
+ $action='add';
+ }
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_location.edit_attrib',
+ 'id' => $id
+ );
+//_debug_array($values);
+
+ if($values['column_info']['type']=='R' ||
$values['column_info']['type']=='CH' || $values['column_info']['type']=='LB')
+ {
+ $multiple_choice= True;
+ }
+
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'lang_choice' =>
lang('Choice'),
+ 'lang_new_value' =>
lang('New value'),
+ 'lang_new_value_statustext' => lang('New
value for mulitple choice'),
+ 'multiple_choice' =>
$multiple_choice,
+ 'value_choice' =>
$values['choice'],
+ 'lang_delete_value' =>
lang('Delete value'),
+ 'lang_value' =>
lang('value'),
+ 'lang_delete_choice_statustext'=> lang('Delete
this value from the list of multiple choice'),
+
+ 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.list_attribute&type_id='.$type_id),
+ 'lang_id'
=> lang('Attribute ID'),
+ 'lang_location_type' =>
lang('Type'),
+ 'lang_no_location_type' => lang('No
entity type'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id'
=> $id,
+
+ 'lang_column_name'
=> lang('Column name'),
+ 'value_column_name'
=> $values['column_name'],
+ 'lang_column_name_statustext' => lang('enter
the name for the column'),
+
+ 'lang_input_text'
=> lang('input text'),
+ 'value_input_text'
=> $values['input_text'],
+ 'lang_input_name_statustext' => lang('enter
the input text for records'),
+
+ 'lang_id_attribtext' => lang('Enter
the attribute ID'),
+ 'lang_entity_statustext' => lang('Select
a entity type'),
+
+ 'lang_statustext' =>
lang('Statustext'),
+ 'lang_statustext_attribtext'=> lang('Enter a
statustext for the inputfield in forms'),
+ 'value_statustext' =>
$values['statustext'],
+
+ 'lang_done_attribtext' => lang('Back
to the list'),
+ 'lang_save_attribtext' => lang('Save
the attribute'),
+ 'type_id'
=> $values['type_id'],
+ 'entity_list' =>
$this->bo->select_location_type($type_id),
+ 'select_location_type' =>
'values[type_id]',
+ 'lang_datatype' =>
lang('Datatype'),
+ 'lang_datatype_statustext' => lang('Select
a datatype'),
+ 'lang_no_datatype' =>
lang('No datatype'),
+ 'datatype_list' =>
$this->bocommon->select_datatype($values['column_info']['type']),
+
+ 'lang_precision' =>
lang('Precision'),
+ 'lang_precision_statustext' => lang('enter
the record length'),
+ 'value_precision' =>
$values['column_info']['precision'],
+
+ 'lang_scale' =>
lang('scale'),
+ 'lang_scale_statustext' => lang('enter
the scale if type is decimal'),
+ 'value_scale' =>
$values['column_info']['scale'],
+
+ 'lang_default' =>
lang('default'),
+ 'lang_default_statustext' => lang('enter
the default value'),
+ 'value_default' =>
$values['column_info']['default'],
+
+ 'lang_nullable' =>
lang('Nullable'),
+ 'lang_nullable_statustext' => lang('Chose
if this column is nullable'),
+ 'lang_select_nullable' => lang('Select
nullable'),
+ 'nullable_list' =>
$this->bocommon->select_nullable($values['column_info']['nullable']),
+ 'value_lookup_form' =>
$values['lookup_form'],
+ 'lang_lookup_form'
=> lang('show in lookup forms'),
+ 'lang_lookup_form_statustext'
=> lang('check to show this attribue in lookup forms'),
+ 'value_list' =>
$values['list'],
+ 'lang_list' =>
lang('show in list'),
+ 'lang_list_statustext' =>
lang('check to show this attribute in location list')
+ );
+//_debug_array($data);
+
+ $appname
= lang('location');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_attrib' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function config()
+ {
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array(
+
'admin_location',
+
'nextmatchs',
+
'menu',
+
'search_field'));
+ $links = $this->menu->links('loc_config');
+
+ $standard_list = $this->bo->read_config();
+
+ while (is_array($standard_list) && list(,$standard) =
each($standard_list))
+ {
+ $content[] = array
+ (
+ 'column_name'
=> $standard['column_name'],
+ 'name'
=> $standard['location_name'],
+ 'prefix'
=> $standard['prefix'],
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.edit_config&column_name='
. $standard['column_name']),
+ 'lang_edit_standardtext' =>
lang('edit the column relation'),
+ 'text_edit'
=> lang('edit')
+ );
+ }
+
+//_debug_array($content);
+
+ $table_header[] = array
+ (
+
+ 'lang_attribute' => lang('Attributes'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_column_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'column_name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_location.config')
+
)),
+ 'lang_column_name' => lang('column name'),
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_location.config')
+
)),
+ 'lang_name' => lang('Table Name'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_standardtext' => lang('add a
standard'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.edit'),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_standardtext' => lang('back
to admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php')
+ );
+
+
+ $data = array
+ (
+ 'links'
=> $links,
+ 'allow_allrows'
=> False,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($standard_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.index'),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_list_config' =>
$table_header,
+ 'values_list_config' =>
$content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('location');
+ $function_msg =
lang('list config');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_config' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit_config()
+ {
+ $column_name =
get_var('column_name',array('POST','GET'));
+ $values =
get_var('values',array('POST'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_location'));
+
+ if ($values['save'])
+ {
+
+ if (!$receipt['error'])
+ {
+
+ $receipt =
$this->bo->save_config($values,$column_name);
+ }
+
+ }
+
+ $type_id =
$this->bo->read_config_single($column_name);
+
+ $function_msg = lang('edit location config for') . ' '
.$column_name;
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_location.edit_config',
+ 'column_name' => $column_name
+ );
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_location.config'),
+
+ 'lang_column_name'
=> lang('Column name'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'column_name'
=> $column_name,
+ 'value_name'
=> $values['name'],
+
+ 'location_list'
=> $this->bo->select_location_type($type_id),
+
+ 'lang_config_statustext' =>
lang('Select the level for this information'),
+ 'lang_done_standardtext' =>
lang('Back to the list'),
+ 'lang_save_standardtext' =>
lang('Save the standard'),
+ 'type_id'
=> $values['type_id'],
+ 'value_descr'
=> $values['descr']
+ );
+
+ $appname
= lang('location');
+
+//_debug_array($data);
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_config' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ }
+?>
Index: property/inc/class.uiagreement.inc.php
diff -u property/inc/class.uiagreement.inc.php:1.16
property/inc/class.uiagreement.inc.php:1.17
--- property/inc/class.uiagreement.inc.php:1.16 Wed Nov 9 22:49:12 2005
+++ property/inc/class.uiagreement.inc.php Fri Jan 27 14:05:43 2006
@@ -1,1930 +1,1930 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage agreement
- * @version $Id: class.uiagreement.inc.php,v 1.16 2005/11/09 22:49:12
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uiagreement
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
-
- var $public_functions = array
- (
- 'index' => True,
- 'view' => True,
- 'edit' => True,
- 'delete' => True,
- 'list_attribute'=> True,
- 'edit_attrib' => True,
- 'columns' => True,
- 'edit_item' => True,
- 'view_item' => True,
- 'view_file' => True,
- 'excel' => True,
- 'add_activity' => True
- );
-
- function uiagreement()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- $this->bo =
CreateObject($this->currentapp.'.boagreement',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
-
- $this->role = $this->bo->role;
-
- $this->cats =
CreateObject('phpgwapi.categories');
- $this->cats->app_name = 'fm_vendor';
-
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
- $this->acl2_location= '.pricebook';
-
- $this->acl_read =
$this->acl2->check($this->acl2_location,1);
- $this->acl_add =
$this->acl2->check($this->acl2_location,2);
- $this->acl_edit =
$this->acl2->check($this->acl2_location,4);
- $this->acl_delete =
$this->acl2->check($this->acl2_location,8);
- $this->acl_manage =
$this->acl2->check($this->acl2_location,16);
-
- $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->vendor_id = $this->bo->vendor_id;
- $this->allrows = $this->bo->allrows;
- $this->member_id = $this->bo->member_id;
- $this->fakebase = $this->bo->fakebase;
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' => $this->filter,
- 'cat_id' => $this->cat_id,
- 'vendor_id' => $this->vendor_id,
- 'allrows' => $this->allrows,
- 'member_id' => $this->member_id
- );
- $this->bo->save_sessiondata($data);
- }
-
- function columns()
- {
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('columns'));
-
- $GLOBALS['phpgw_info']['flags']['noframework'] = True;
-
- $values =
get_var('values',array('POST','GET'));
-
- if ($values['save'])
- {
-
-
$GLOBALS['phpgw']->preferences->account_id=$this->account;
-
$GLOBALS['phpgw']->preferences->read_repository();
-
$GLOBALS['phpgw']->preferences->add($this->currentapp,'agreement_columns',$values['columns'],'user');
-
$GLOBALS['phpgw']->preferences->save_repository();
-
- $receipt['message'][] = array('msg' =>
lang('columns is updated'));
- }
-
- $function_msg = lang('Select Column');
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiagreement.columns',
- 'role' => $this->role
- );
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'column_list' =>
$this->bo->column_list($values['columns'],$allrows=True),
- 'function_msg' => $function_msg,
- 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_columns' => lang('columns'),
- 'lang_none' => lang('None'),
- 'lang_save' => lang('save'),
- 'select_name' => 'period'
- );
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
$function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('columns' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function view_file()
- {
- $GLOBALS['phpgw_info']['flags'][noheader] = True;
- $GLOBALS['phpgw_info']['flags'][nofooter] = True;
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
-
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $file_name =
urldecode(get_var('file_name',array('POST','GET')));
- $id = get_var('id',array('POST','GET'));
-
- $file = $this->fakebase. SEP . 'agreement' . SEP . $id
. SEP . $file_name;
-
- if($this->bo->vfs->file_exists(array(
- 'string' => $file,
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
-
- $size =
$this->bo->vfs->get_size(array(
- 'string' => $file,
- 'relatives' =>
Array(RELATIVE_NONE),
- 'checksubdirs' =>
True));
-
- $document= $this->bo->vfs->read(array(
- 'string' => $file,
- 'relatives' => Array(RELATIVE_NONE)));
-
- $filename =
basename($values['document_name']);
- $filetype = array_pop(explode('.',
basename($file)));
- $browser = CreateObject('phpgwapi.browser');
-
$browser->content_header($filename,$filetype,$size);
-
- echo $document;
-
- }
- }
-
- function index()
- {
- $this->menu->sub = 'agreement';
-
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('agreement',
-
'menu',
-
'receipt',
-
'search_field',
-
'nextmatchs',
-
'filter_member_of'));
-
- $links = $this->menu->links('agreement','agreement');
-
- $receipt =
$GLOBALS['phpgw']->session->appsession('session_data','agreement_receipt');
-
$GLOBALS['phpgw']->session->appsession('session_data','agreement_receipt','');
-
- $list = $this->bo->read();
-
- $uicols = $this->bo->uicols;
-
- $j=0;
-
- if (isset($list) AND is_array($list))
- {
- foreach($list as $entry)
- {
- for
($i=0;$i<count($uicols['name']);$i++)
- {
-
if($uicols['input_type'][$i]!='hidden')
- {
-
$content[$j]['row'][$i]['value'] =
$entry[$uicols['name'][$i]];
-
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
- }
- }
-
- if($this->acl_read)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('view the
entity');
- $content[$j]['row'][$i]['text']
= lang('view');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.view&id='
. $entry['id'] .'&role=' . $this->role);
- }
- if($this->acl_edit)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('edit the
agreement');
- $content[$j]['row'][$i]['text']
= lang('edit');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit&id='
. $entry['id'] .'&role=' . $this->role);
- }
- if($this->acl_delete)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('delete the
agreement');
- $content[$j]['row'][$i]['text']
= lang('delete');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.delete&agreement_id='
. $entry['id'] .'&role=' . $this->role);
- }
-
- $j++;
- }
- }
-
-//_debug_array($content);
- for ($i=0;$i<count($uicols['descr']);$i++)
- {
- if($uicols['input_type'][$i]!='hidden')
- {
- $table_header[$i]['header'] =
$uicols['descr'][$i];
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- if($uicols['datatype'][$i]!='T' &&
$uicols['datatype'][$i]!='CH')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
- (
- 'sort' =>
$this->sort,
- 'var' =>
$uicols['name'][$i],
- 'order' =>
$this->order,
- 'extra'
=> array('menuaction' => $this->currentapp.'.uiagreement.index',
-
'query' =>$this->query,
-
'lookup' =>$lookup,
-
'district_id' => $this->district_id,
-
'start_date' => $start_date,
-
'role' => $this->role,
-
'member_id' => $this->member_id,
-
'allrows' => $this->allrows,
-
'end_date' => $end_date
-
)
- ));
- }
- }
- }
-
- if($this->acl_read)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('view');
- $i++;
- }
- if($this->acl_edit)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('edit');
- $i++;
- }
- if($this->acl_delete)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('delete');
- $i++;
- }
-
-
- if($this->acl_add)
- {
- $table_add = array
- (
- 'lang_add'
=> lang('add'),
- 'lang_add_statustext' => lang('add a
agreement'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit&role='
. $this->role)
- );
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiagreement.index',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query,
- 'role' =>
$this->role,
- 'member_id' =>
$this->member_id
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $link_columns = array
- (
- 'menuaction' =>
$this->currentapp.'.uiagreement.columns',
- 'role' =>
$this->role
- );
-
- $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True,link_data =>$link_data));
-
- $data = array
- (
- 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
- 'lang_columns'
=> lang('columns'),
- 'link_columns'
=> $GLOBALS['phpgw']->link('/index.php',$link_columns),
- 'lang_columns_help'
=> lang('Choose columns'),
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'links'
=> $links,
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the agreement belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $this->bo->select_category_list('filter',$this->cat_id),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
-
- 'lang_no_vendor'
=> lang('no vendor'),
- 'lang_vendor_statustext' =>
lang('Select the vendor the agreement belongs to.'),
- 'vendor_list'
=> $this->bo->select_vendor_list('filter',$this->vendor_id),
-
- 'lang_no_member'
=> lang('no member'),
- 'member_of_name'
=> 'member_id',
- 'member_of_list'
=> $member_of_data['cat_list'],
-
- 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter)),
- 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
- $this->save_sessiondata();
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('agreement') . ': ' . lang('list ' . $this->role);
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function list_content($list,$uicols,$edit_item='',$view_only='')
- {
- $j=0;
-//_debug_array($list);
- if (isset($list) AND is_array($list))
- {
- foreach($list as $entry)
- {
- $content[$j]['id']
= $entry['id'];
- $content[$j]['activity_id'] =
$entry['activity_id'];
- $content[$j]['index_count']
= $entry['index_count'];
- $content[$j]['m_cost']
= $entry['m_cost'];
- $content[$j]['w_cost']
= $entry['w_cost'];
- $content[$j]['total_cost']
= $entry['total_cost'];
- $content[$j]['index_count'] =
$entry['index_count'];
- for
($i=0;$i<count($uicols['name']);$i++)
- {
-
if($uicols['input_type'][$i]!='hidden')
- {
-
$content[$j]['row'][$i]['value'] =
$entry[$uicols['name'][$i]];
-
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
- }
- }
-
- if($this->acl_read && !$edit_item &&
!$view_only)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('view the
entity');
- $content[$j]['row'][$i]['text']
= lang('view');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.view_item&agreement_id='
. $entry['agreement_id'] .'&id=' . $entry['id']);
- }
- if($this->acl_edit && !$edit_item &&
!$view_only)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('edit the
agreement');
- $content[$j]['row'][$i]['text']
= lang('edit');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit_item&agreement_id='
. $entry['agreement_id'] .'&id=' . $entry['id']);
- }
- if($this->acl_delete && !$edit_item &&
!$view_only)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('delete this
item');
- $content[$j]['row'][$i]['text']
= lang('delete');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit&delete_item=1&agreement_id='
. $entry['agreement_id'] .'&activity_id=' . $entry['id']);
- }
-
- $j++;
- }
- }
-
-//html_print_r($content);
- for ($i=0;$i<count($uicols['descr']);$i++)
- {
- if($uicols['input_type'][$i]!='hidden')
- {
- $table_header[$i]['header'] =
$uicols['descr'][$i];
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- }
- }
-
- if($this->acl_read && !$edit_item && !$view_only)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('view');
- $i++;
- }
- if($this->acl_edit && !$edit_item && !$view_only)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('edit');
- $i++;
- }
- if($this->acl_delete && !$edit_item && !$view_only)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('delete');
- $i++;
- }
- if($this->acl_manage && !$edit_item && !$view_only)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('Update');
- $i++;
- }
-
- return
array('content'=>$content,'table_header'=>$table_header);
- }
-
- function add_activity()
- {
- $agreement_id =
get_var('agreement_id',array('POST','GET'));
- $group_id =
get_var('group_id',array('POST','GET'));
- $values = get_var('values',array('POST','GET'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('agreement'));
-
- $agreement =
$this->bo->read_single(array('agreement_id'=>$agreement_id));
-
- if($this->acl_add && (is_array($values)))
- {
- if ($values['save'] || $values['apply'])
- {
- $receipt =
$this->bo->add_activity($values,$agreement_id);
-
- if ($values['save'])
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','agreement_receipt',$receipt);
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit&id='
. $agreement_id);
- }
- }
- else
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit&id='
. $agreement_id);
-
- }
- }
-
- $content =
$this->bo->read_group_activity($group_id,$agreement_id);
-
-//_debug_array($content);
- $uicols = $this->bo->uicols;
- $uicols['descr'][] =
lang('select');
-
- for ($i=0;$i<count($uicols['descr']);$i++)
- {
- if($uicols['input_type'][$i]!='hidden')
- {
- $table_header[$i]['header'] =
$uicols['descr'][$i];
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- }
- }
-
-
- $data = array
- (
- 'lang_id'
=> lang('ID'),
- 'value_agreement_id' =>
$agreement_id,
- 'lang_name'
=> lang('name'),
- 'value_name'
=> $agreement['name'],
- 'lang_descr'
=> lang('descr'),
- 'value_descr'
=> $agreement['descr'],
- 'lang_select_all'
=> lang('Select All'),
- 'img_check'
=>
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
- 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
- 'add_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.add_activity&group_id='
. $group_id . '&agreement_id=' . $agreement_id),
- 'agreement_id'
=> $agreement_id,
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'lang_save'
=> lang('save'),
- 'lang_cancel'
=> lang('cancel'),
- 'lang_apply'
=> lang('apply'),
- 'lang_apply_statustext' =>
lang('Apply the values'),
- 'lang_cancel_statustext' =>
lang('Leave the agreement untouched and return back to the list'),
- 'lang_save_statustext' =>
lang('Save the agreement and return back to the list'),
- );
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('agreement') . ': ' . lang('add activity');
-//_debug_array($data);
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('add_activity' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function edit()
- {
- $id = get_var('id',array('POST','GET'));
- $values = get_var('values',array('POST'));
- $delete_item = get_var('delete_item',array('GET'));
- $activity_id = get_var('activity_id',array('GET'));
-
- $config =
CreateObject('phpgwapi.config',$this->currentapp);
- $boalarm =
CreateObject($this->currentapp.'.boalarm');
-
- if($delete_item && $id && $activity_id)
- {
- $this->bo->delete_item($id,$activity_id);
- }
-
- $values_attribute =
get_var('values_attribute',array('POST'));
-
- $insert_record_agreement =
$GLOBALS['phpgw']->session->appsession('insert_record_agreement',$this->currentapp);
-
-//_debug_array($insert_record_agreement);
- for ($j=0;$j<count($insert_record_agreement);$j++)
- {
-
$insert_record['extra'][$insert_record_agreement[$j]] =
$insert_record_agreement[$j];
- }
-
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('agreement','nextmatchs','attributes_form'));
-
- if (is_array($values))
- {
- while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
- {
- if($_POST[$key])
- {
- $values['extra'][$column]
= $_POST[$key];
- }
- }
-
-//_debug_array($values);
-
- if ($values['save'] || $values['apply']):
- {
- $values['vendor_id'] =
get_var('vendor_id',array('POST'));
- $values['vendor_name'] =
get_var('vendor_name',array('POST'));
- $values['start_date'] =
get_var('start_date',array('POST'));
- $values['end_date']
= get_var('end_date',array('POST'));
- $values['termination_date'] =
get_var('termination_date',array('POST'));
-
- if(!$values['cat_id'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
- }
-
- if(!$values['last_name'])
- {
-//
$receipt['error'][]=array('msg'=>lang('Please enter a name !'));
- }
-
-
- if($id)
- {
- $values['agreement_id']=$id;
- $action='edit';
- }
- else
- {
-
$values['agreement_id']=$this->bo->request_next_id();
- }
-
-
$values['file_name']=$_FILES['file']['name'];
- $to_file = $this->fakebase. SEP .
'agreement' . SEP . $values['agreement_id'] . SEP . $values['file_name'];
-
- if(!$values['document_name_orig'] &&
$this->bo->vfs->file_exists(array(
- 'string' => $to_file,
- 'relatives' =>
Array(RELATIVE_NONE)
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('This file already exists !'));
- }
-
-
- if(!$receipt['error'])
- {
-// $values['agreement_id'] = $id;
- $receipt =
$this->bo->create_home_dir($receipt);
- $receipt =
$this->bo->save($values,$values_attribute,$action);
- $id = $receipt['agreement_id'];
- $this->cat_id =
($values['cat_id']?$values['cat_id']:$this->cat_id);
-
- if($values['file_name'])
- {
-
$this->bo->create_document_dir($id);
-
$this->bo->vfs->override_acl = 1;
-
- if(!$this->bo->vfs->cp
(array (
- 'from' =>
$_FILES['file']['tmp_name'],
- 'to' =>
$to_file,
- 'relatives'
=> array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
- {
-
$receipt['error'][]=array('msg'=>lang('Failed to upload file !'));
- }
-
$this->bo->vfs->override_acl = 0;
- }
-
-
- if ($values['save'])
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','agreement_receipt',$receipt);
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiagreement.index&role='
. $this->role);
- }
- }
- }
- elseif($values['update']):
- {
- $values['date'] =
get_var('date',array('POST'));
-
- if(!$values['date'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a date !'));
- }
- if(!$values['new_index'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter a index !'));
- }
-
- if(!$receipt['error'])
- {
- $receipt =
$this->bo->update($values);
- }
-
- }
- elseif($values['delete_alarm'] &&
count($values['alarm'])):
- {
-
- if(!$receipt['error'])
- {
- $receipt =
$boalarm->delete_alarm('agreement',$values['alarm']);
- }
-
- }
- elseif(($values['enable_alarm'] ||
$values['disable_alarm']) && count($values['alarm'])):
- {
-
- if(!$receipt['error'])
- {
- $receipt =
$boalarm->enable_alarm('agreement',$values['alarm'],$values['enable_alarm']);
- }
-
- }
- elseif($values['add_alarm']):
- {
- $time =
intval($values['time']['days'])*24*3600 +
-
intval($values['time']['hours'])*3600 +
-
intval($values['time']['mins'])*60;
-
- if ($time > 0)
- {
- $receipt =
$boalarm->add_alarm('agreement',$this->bo->read_event(array('agreement_id'=>$id)),$time,$values['user_id']);
- }
- }
- elseif (!$values['save'] && !$values['apply']
&& !$values['update']):
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiagreement.index&role='
. $this->role);
- }
- endif;
- }
-
-
- $agreement =
$this->bo->read_single(array('agreement_id'=>$id));
-
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
- if ($id)
- {
- $this->cat_id =
($agreement['cat_id']?$agreement['cat_id']:$this->cat_id);
- $this->member_id =
($agreement['member_of']?$agreement['member_of']:$this->member_id);
- $list = $this->bo->read_details($id);
-
- $content = $list;
- //_debug_array($list);
- if (isset($list) AND is_array($list))
- {
- $k=count($list);
- for ($j=0;$j<$k;$j++)
- {
- if($this->acl_read &&
!$edit_item && !$view_only)
- {
-
$content[$j]['lang_view_statustext'] = lang('view the entity');
-
$content[$j]['text_view'] = lang('view');
-
$content[$j]['link_view'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.view_item&agreement_id='
. $id .'&id=' . $content[$j]['activity_id']);
- }
- if($this->acl_edit &&
!$edit_item && !$view_only)
- {
-
$content[$j]['lang_edit_statustext'] = lang('edit the agreement');
-
$content[$j]['text_edit'] = lang('edit');
-
$content[$j]['link_edit'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit_item&agreement_id='
. $id .'&id=' . $content[$j]['activity_id']);
- }
- if($this->acl_delete &&
!$edit_item && !$view_only)
- {
-
$content[$j]['lang_delete_statustext'] = lang('delete this item');
-
$content[$j]['text_delete'] = lang('delete');
-
$content[$j]['link_delete'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit&delete_item=1&id='
. $id .'&activity_id=' . $content[$j]['activity_id']);
- }
-
- $content[$j]['acl_manage']
= $this->acl_manage;
- $content[$j]['acl_read']
= $this->acl_read;
- $content[$j]['acl_edit']
= $this->acl_edit;
- $content[$j]['acl_delete']
= $this->acl_delete;
- }
- }
-
-
- $uicols = $this->bo->uicols;
-
- for ($i=0;$i<count($uicols['descr']);$i++)
- {
- if($uicols['input_type'][$i]!='hidden')
- {
- $table_header[$i]['header']
= $uicols['descr'][$i];
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- }
- }
-
- if($this->acl_read && !$edit_item &&
!$view_only)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('view');
- $i++;
- $set_column[]=True;
- }
- if($this->acl_edit && !$edit_item &&
!$view_only)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('edit');
- $i++;
- $set_column[]=True;
- }
- if($this->acl_delete && !$edit_item &&
!$view_only)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('delete');
- $i++;
- $set_column[]=True;
- }
- if($this->acl_manage && !$edit_item &&
!$view_only)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('Update');
- $i++;
- $set_column[]=True;
- }
-
-// $table_header=$list['table_header'];
- for ($i=0; $i<9; $i++)
- {
- $set_column[]=True;
- }
-
- if ($content)
- {
- $table_update[] = array
- (
- 'jsDateFormat'
=> $jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle'
=> lang('Select date'),
- 'calendar_setup'
=> "Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat
. "',button : 'date-trigger'});",
-
- 'lang_new_index'
=> lang('New index'),
- 'lang_new_index_statustext'
=> lang('Enter a new index'),
- 'lang_date_statustext'
=> lang('Select the date for the update'),
- 'lang_update'
=> lang('Update'),
- 'lang_update_statustext'
=> lang('update selected investments')
- );
- }
-
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiagreement.edit',
- 'sort' =>$this->sort,
- 'order' =>$this->order,
- 'id' => $id,
- 'role' => $this->role
- );
-
-
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
- 'vendor_id' =>
$agreement['vendor_id'],
- 'vendor_name' =>
$agreement['vendor_name']));
-
- if($agreement['vendor_id'])
- {
- $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True, link_data => array()));
- }
-
- $alarm_data=$this->bocommon->initiate_ui_alarm(array(
-
'acl_location'=>$this->acl2_location,
- 'alarm_type'=> 'agreement',
- 'type' => 'form',
- 'text' => 'Email
notification',
- 'times' => $times,
- 'id' => $id,
- 'method' => $method,
- 'data' => $data,
- 'account_id'=> $account_id
- ));
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- switch(substr($dateformat,0,1))
- {
- case 'M':
- $dateformat_validate=
"javascript:vDateType='1'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
- $onBlur =
"DateFormat(this,this.value,event,true,'1')";
- break;
- case 'y':
-
$dateformat_validate="javascript:vDateType='2'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
- $onBlur =
"DateFormat(this,this.value,event,true,'2')";
- break;
- case 'D':
-
$dateformat_validate="javascript:vDateType='3'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
- $onBlur =
"DateFormat(this,this.value,event,true,'3')";
- break;
- }
-
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add detail'),
- 'lang_add_standardtext' => lang('add an item to
the details'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.add_activity&agreement_id='
. $id . '&group_id=' . $agreement['group_id'])
- );
-
-
- $link_file_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiagreement.view_file',
- 'id' =>$id
- );
-
- $config->read_repository();
- $link_to_files = $config->config_data['files_url'];
-
- $j = count($agreement['files']);
- for ($i=0;$i<$j;$i++)
- {
-
$agreement['files'][$i]['file_name']=urlencode($agreement['files'][$i]['name']);
- }
-
- $link_excel = array
- (
- 'menuaction' =>
$this->currentapp.'.uiagreement.excel',
- 'id'
=>$id,
- 'allrows'
=>$this->allrows
- );
-
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $data = array
- (
-
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
-
- 'alarm_data' =>
$alarm_data,
- 'lang_alarm' =>
lang('Alarm'),
- 'lang_excel' =>
'excel',
- 'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
- 'lang_excel_help' =>
lang('Download table to MS Excel'),
- 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
-
- 'fileupload'
=> True,
- 'link_view_file'
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
- 'link_to_files'
=> $link_to_files,
- 'files'
=> $agreement['files'],
- 'lang_files'
=> lang('files'),
- 'lang_filename'
=> lang('Filename'),
- 'lang_delete_file'
=> lang('Delete file'),
- 'lang_view_file_statustext' =>
lang('Klick to view file'),
- 'lang_delete_file_statustext' => lang('Check
to delete file'),
- 'lang_upload_file'
=> lang('Upload file'),
- 'lang_file_statustext' =>
lang('Select file to upload'),
-
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_id'
=> lang('ID'),
- 'value_agreement_id' => $id,
- 'lang_category'
=> lang('category'),
- 'lang_save'
=> lang('save'),
- 'lang_cancel'
=> lang('cancel'),
- 'lang_apply'
=> lang('apply'),
- 'value_cat'
=> $agreement['cat'],
- 'lang_apply_statustext' =>
lang('Apply the values'),
- 'lang_cancel_statustext' =>
lang('Leave the agreement untouched and return back to the list'),
- 'lang_save_statustext' =>
lang('Save the agreement and return back to the list'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the agreement belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'values[cat_id]',
- 'cat_list'
=> $this->bo->select_category_list('select',$this->cat_id),
-
- 'lang_member_of'
=> lang('member of'),
- 'member_of_name'
=> 'member_id',
- 'member_of_list'
=> $member_of_data['cat_list'],
-
- 'lang_dateformat'
=> lang(strtolower($dateformat)),
- 'dateformat_validate' =>
$dateformat_validate,
- 'onKeyUp'
=> $onKeyUp,
- 'onBlur'
=> $onBlur,
- 'dateformat_source'
=> './'.$this->currentapp.'/inc/dateformat.js',
- 'lang_attributes'
=> lang('Attributes'),
- 'attributes_header'
=> $attributes_header,
- 'attributes_values'
=> $agreement['attributes'],
- 'lookup_functions'
=> $agreement['lookup_functions'],
- 'dateformat'
=> $dateformat,
-
- 'jsDateFormat'
=> $jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle'
=> lang('Select date'),
- 'calendar_setup_start' =>
"Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});",
- 'calendar_setup_end' =>
"Calendar.setup({inputField : 'end_date',ifFormat : '" . $jsDateFormat .
"',button : 'end_date-trigger'});",
- 'calendar_setup_termination'
=> "Calendar.setup({inputField : 'termination_date',ifFormat : '" .
$jsDateFormat . "',button : 'termination_date-trigger'});",
-
- 'lang_start_date_statustext' => lang('Select
the estimated end date for the agreement'),
- 'lang_start_date'
=> lang('start date'),
- 'value_start_date'
=> $agreement['start_date'],
-
- 'lang_end_date_statustext' =>
lang('Select the estimated end date for the agreement'),
- 'lang_end_date'
=> lang('end date'),
- 'value_end_date'
=> $agreement['end_date'],
-
- 'lang_termination_date_statustext'
=> lang('Select the estimated termination date'),
- 'lang_termination_date'
=> lang('termination date'),
- 'value_termination_date'
=> $agreement['termination_date'],
-
- 'vendor_data'
=> $vendor_data,
- 'lang_name'
=> lang('name'),
- 'lang_name_statustext' =>
lang('name'),
- 'value_name'
=> $agreement['name'],
- 'lang_descr'
=> lang('descr'),
- 'lang_descr_statustext' =>
lang('descr'),
- 'value_descr'
=> $agreement['descr'],
- 'table_add'
=> $table_add,
- 'values'
=> $content,
- 'table_header'
=> $table_header,
- 'table_update'
=> $table_update,
- 'update_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit&id='
. $id),
- 'lang_select_all'
=> lang('Select All'),
- 'img_check'
=>
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
- 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
- 'check_all_script'
=> $check_all_script,
- 'set_column'
=> $set_column,
-
- 'lang_agreement_group' =>
lang('Agreement group'),
- 'lang_no_agreement_group' =>
lang('Select agreement group'),
- 'agreement_group_list' =>
$this->bo->get_agreement_group_list($agreement['group_id']),
-
- 'lang_status'
=> lang('Status'),
- 'status_list'
=> $this->bo->select_status_list('select',$agreement['status']),
- 'status_name'
=> 'values[status]',
- 'lang_no_status'
=> lang('Select status'),
-
- );
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('agreement') . ': ' . ($id?lang('edit') . ' ' .
lang($this->role):lang('add') . ' ' . lang($this->role));
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function excel()
- {
- $id = get_var('id',array('POST','GET'));
- $list = $this->bo->read_details($id);
- $uicols = $this->bo->uicols;
-
$this->bocommon->excel($list,$uicols['name'],$uicols['descr'],$uicols['input_type']);
- }
-
- function edit_item()
- {
- $agreement_id =
get_var('agreement_id',array('POST','GET'));
- $id = get_var('id',array('POST','GET'));
- $values = get_var('values',array('POST'));
- $delete_last = get_var('delete_last',array('GET'));
- if($delete_last)
- {
- $this->bo->delete_last_index($agreement_id,$id);
- }
-
- $values_attribute =
get_var('values_attribute',array('POST'));
-
-// $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
-// $insert_record_entity =
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp);
-
- $insert_record_agreement =
$GLOBALS['phpgw']->session->appsession('insert_record_agreement',$this->currentapp);
-
-//_debug_array($insert_record_agreement);
-
- for ($j=0;$j<count($insert_record_entity);$j++)
- {
-
$insert_record['extra'][$insert_record_entity[$j]] =
$insert_record_entity[$j];
- }
-
- for ($j=0;$j<count($insert_record_agreement1);$j++)
- {
-
$insert_record['extra'][$insert_record_agreement[$j]] =
$insert_record_agreement[$j];
- }
-
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('agreement','attributes_form'));
-
- if (is_array($values))
- {
-
-/* for ($i=0;
$i<count($insert_record['location']); $i++)
- {
-
if($_POST[$insert_record['location'][$i]])
- {
-
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
- }
- }
-
- while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
- {
- if($_POST[$key])
- {
- $values['extra'][$column]
= $_POST[$key];
- }
- }
-
- $values['street_name'] =
$_POST['street_name'];
- $values['street_number'] =
$_POST['street_number'];
- $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
-
-*/
-//_debug_array($values);
- if ($values['save'] || $values['apply']):
- {
-
- if(!$receipt['error'])
- {
- $values['agreement_id'] =
$agreement_id;
- $values['id'] = $id;
- $receipt =
$this->bo->save_item($values,$values_attribute);
- $agreement_id =
$receipt['agreement_id'];
- $id =
$receipt['id'];
- $this->cat_id =
($values['cat_id']?$values['cat_id']:$this->cat_id);
-
- if ($values['save'])
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','agreement_receipt',$receipt);
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit&id='
. $agreement_id);
- }
- }
- }
- elseif($values['update']):
- {
- $values['date'] =
get_var('date',array('POST'));
-
- if(!$values['date'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a date !'));
- }
- if(!$values['new_index'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter a index !'));
- }
-
- if(!$receipt['error'])
- {
- $receipt =
$this->bo->update($values);
- }
-
- }
- elseif (!$values['save'] && !$values['apply']
&& !$values['update']):
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit&id='
. $agreement_id);
- }
- endif;
- }
-
- $agreement =
$this->bo->read_single(array('agreement_id'=>$agreement_id));
- $values =
$this->bo->read_single_item(array('agreement_id'=>$agreement_id,'id'=>$id));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiagreement.edit_item',
- 'agreement_id' => $agreement_id,
- 'id' => $id,
- 'role' => $this->role
- );
-
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- switch(substr($dateformat,0,1))
- {
- case 'M':
- $dateformat_validate=
"javascript:vDateType='1'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
- $onBlur =
"DateFormat(this,this.value,event,true,'1')";
- break;
- case 'y':
-
$dateformat_validate="javascript:vDateType='2'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
- $onBlur =
"DateFormat(this,this.value,event,true,'2')";
- break;
- case 'D':
-
$dateformat_validate="javascript:vDateType='3'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
- $onBlur =
"DateFormat(this,this.value,event,true,'3')";
- break;
- }
-
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True,link_data => array()));
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add detail'),
- 'lang_add_standardtext' => lang('add an item to
the details'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit_item&agreement_id='
. $agreement_id)
- );
-
-
- if($id)
- {
- $list =
$this->bo->read_prizing(array('agreement_id'=>$agreement_id,'activity_id'=>$id));
- $activity_descr
=$this->bo->get_activity_descr($id);
- }
-
- $uicols = $this->bo->uicols;
- $list =
$this->list_content($list,$uicols,$edit_item=True);
- $content = $list['content'];
- $table_header=$list['table_header'];
-
- for ($i=0; $i<count($list['content'][0]['row']); $i++)
- {
- $set_column[]=True;
- }
-
- $table_update[] = array
- (
- 'jsDateFormat'
=> $jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle'
=> lang('Select date'),
- 'calendar_setup' =>
"Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat .
"',button : 'date-trigger'});",
-
- 'lang_new_index' =>
lang('New index'),
- 'lang_new_index_statustext' => lang('Enter
a new index'),
- 'lang_date_statustext' => lang('Select
the date for the update'),
- 'lang_update' =>
lang('Update'),
- 'lang_update_statustext' => lang('update
selected investments')
- );
-
- $data = array
- (
- 'activity_descr' =>
$activity_descr,
- 'lang_descr' =>
lang('Descr'),
- 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'edit_url' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_id' =>
lang('ID'),
- 'value_id' =>
$values['id'],
- 'value_num' =>
$values['num'],
- 'value_agreement_id' =>
$agreement_id,
- 'lang_category' =>
lang('category'),
- 'lang_save' =>
lang('save'),
- 'lang_cancel' =>
lang('cancel'),
- 'lang_apply' =>
lang('apply'),
- 'lang_apply_statustext' =>
lang('Apply the values'),
- 'lang_cancel_statustext' =>
lang('Leave the agreement untouched and return back to the list'),
- 'lang_save_statustext' =>
lang('Save the agreement and return back to the list'),
-
- 'lang_dateformat' =>
lang(strtolower($dateformat)),
- 'dateformat_validate' =>
$dateformat_validate,
- 'onKeyUp' =>
$onKeyUp,
- 'onBlur' =>
$onBlur,
- 'dateformat_source' =>
'./'.$this->currentapp.'/inc/dateformat.js',
- 'lang_attributes' =>
lang('Attributes'),
- 'attributes_header' =>
$attributes_header,
- 'attributes_values' =>
$values['attributes'],
- 'lookup_functions' =>
$values['lookup_functions'],
- 'dateformat' =>
$dateformat,
-
- 'jsDateFormat' =>
$jsDateFormat,
- 'date_img' =>
$cal_info['img'],
- 'lang_datetitle' =>
lang('Select date'),
- 'calendar_setup_start' =>
"Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});",
- 'calendar_setup_end' =>
"Calendar.setup({inputField : 'end_date',ifFormat : '" . $jsDateFormat .
"',button : 'end_date-trigger'});",
-
- 'lang_agreement' =>
lang('Agreement'),
- 'agreement_name' =>
$agreement['name'],
-
- 'table_add'
=> $table_add,
- 'values'
=> $content,
- 'index_count'
=> $content[0]['index_count'],
- 'table_header'
=> $table_header,
- 'acl_manage'
=> $this->acl_manage,
- 'table_update'
=> $table_update,
- 'update_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit_item&agreement_id='
. $agreement_id . '&id=' . $id),
- 'lang_select_all'
=> lang('Select All'),
- 'img_check'
=>
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
- 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
-
- 'lang_m_cost'
=> lang('Material cost'),
- 'lang_m_cost_statustext' =>
lang('Material cost'),
- 'value_m_cost'
=> $values['m_cost'],
-
- 'lang_w_cost'
=> lang('Labour cost'),
- 'lang_w_cost_statustext' =>
lang('Labour cost'),
- 'value_w_cost'
=> $values['w_cost'],
-
- 'lang_total_cost'
=> lang('Total cost'),
- 'value_total_cost'
=> $values['total_cost'],
-
- 'set_column'
=> $set_column,
- 'lang_delete_last'
=> lang('delete last index'),
- 'lang_delete_last_statustext' => lang('delete
the last index'),
- 'delete_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit_item&delete_last=1&agreement_id='
. $agreement_id . '&id=' . $id),
-
- );
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('agreement') . ': ' . ($values['id']?lang('edit item') . ' ' .
$agreement['name']:lang('add item') . ' ' . $agreement['name']);
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_item' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function view_item()
- {
- $agreement_id =
get_var('agreement_id',array('POST','GET'));
- $id = get_var('id',array('POST','GET'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('agreement','attributes_view'));
-
- $agreement =
$this->bo->read_single(array('agreement_id'=>$agreement_id));
- $values =
$this->bo->read_single_item(array('agreement_id'=>$agreement_id,'id'=>$id));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiagreement.edit',
- 'id' => $agreement_id
- );
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- if($id)
- {
- $list =
$this->bo->read_prizing(array('agreement_id'=>$agreement_id,'activity_id'=>$id));
- $activity_descr
=$this->bo->get_activity_descr($id);
- }
-
- $uicols = $this->bo->uicols;
- $list =
$this->list_content($list,$uicols,$edit_item=True);
- $content = $list['content'];
- $table_header=$list['table_header'];
-
- $data = array
- (
- 'activity_descr' =>
$activity_descr,
- 'lang_descr' =>
lang('Descr'),
- 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'edit_url' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_id' =>
lang('ID'),
- 'value_id' =>
$values['id'],
- 'value_num' =>
$values['num'],
- 'value_agreement_id' =>
$agreement_id,
- 'lang_category' =>
lang('category'),
- 'lang_cancel' =>
lang('cancel'),
- 'lang_cancel_statustext' =>
lang('Leave the agreement untouched and return back to the list'),
-
- 'lang_dateformat'
=> lang(strtolower($dateformat)),
- 'attributes_view'
=> $values['attributes'],
-
- 'lang_agreement'
=> lang('Agreement'),
- 'agreement_name'
=> $agreement['name'],
-
- 'table_add'
=> $table_add,
- 'values'
=> $content,
- 'table_header'
=> $table_header,
- 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
-
- 'lang_m_cost'
=> lang('Material cost'),
- 'value_m_cost'
=> $values['m_cost'],
-
- 'lang_w_cost'
=> lang('Labour cost'),
- 'value_w_cost'
=> $values['w_cost'],
-
- 'lang_total_cost'
=> lang('Total cost'),
- 'value_total_cost'
=> $values['total_cost'],
- 'set_column'
=> $set_column,
- );
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('agreement') . ': ' . lang('view item') . ' ' . $agreement['name'];
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view_item' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- function delete()
- {
- $attrib = get_var('attrib',array('POST','GET'));
- $id = get_var('id',array('POST','GET'));
- $agreement_id =
get_var('agreement_id',array('POST','GET'));
- $delete = get_var('delete',array('POST'));
- $confirm = get_var('confirm',array('POST'));
-
-
- if($attrib)
- {
- $function='list_attribute';
- }
- else
- {
- $function='index';
- }
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiagreement.'.$function,
- 'role' => $this->role
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($agreement_id,$id,$attrib);
-// Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
-
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.delete&agreement_id='
. $agreement_id. '&id=' . $id . '&attrib=' . $attrib . '&role=' . $this->role),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('agreement');
- $function_msg =
lang('delete') . ' ' . lang($this->role);
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
-
- function view()
- {
- $agreement_id = get_var('id',array('POST','GET'));
- $config =
CreateObject('phpgwapi.config',$this->currentapp);
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('agreement','nextmatchs','attributes_view'));
-
-
- $agreement =
$this->bo->read_single(array('agreement_id'=>$agreement_id));
-
-
- if ($agreement_id)
- {
- $this->cat_id =
($agreement['cat_id']?$agreement['cat_id']:$this->cat_id);
- $this->member_id =
($agreement['member_of']?$agreement['member_of']:$this->member_id);
- $list = $this->bo->read_details($agreement_id);
-
- $uicols = $this->bo->uicols;
- $list =
$this->list_content($list,$uicols,$edit_item=False,$view_only=True);
- $content = $list['content'];
- $table_header=$list['table_header'];
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiagreement.index',
- 'agreement_id' => $agreement_id,
- );
-
-
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
- 'vendor_id' =>
$agreement['vendor_id'],
- 'vendor_name' =>
$agreement['vendor_name'],
- 'type' =>
'view'));
-
- $alarm_data=$this->bocommon->initiate_ui_alarm(array(
-
'acl_location'=>$this->acl2_location,
- 'alarm_type'=> 'agreement',
- 'type' => 'view',
- 'text' => 'Email
notification',
- 'times' => $times,
- 'id' =>
$agreement_id,
- 'method' => $method,
- 'data' => $data,
- 'account_id'=> $account_id
- ));
-
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True,link_data => array()));
-
- $link_file_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiagreement.view_file',
- 'id'
=>$agreement_id
- );
-
-
- $config->read_repository();
- $link_to_files = $config->config_data['files_url'];
-
- $j = count($agreement['files']);
- for ($i=0;$i<$j;$i++)
- {
-
$agreement['files'][$i]['file_name']=urlencode($agreement['files'][$i]['name']);
- }
-
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $link_data2 = array
- (
- 'menuaction' =>
$this->currentapp.'.uiagreement.view',
- 'id' => $agreement_id,
- );
-
- $data = array
- (
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($content),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data2),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
-
- 'alarm_data'
=> $alarm_data,
- 'lang_alarm'
=> lang('Alarm'),
- 'link_view_file'
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
- 'link_to_files'
=> $link_to_files,
- 'files'
=> $agreement['files'],
- 'lang_files'
=> lang('files'),
- 'lang_filename'
=> lang('Filename'),
- 'lang_view_file_statustext' =>
lang('Klick to view file'),
-
- 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_id'
=> lang('ID'),
- 'value_agreement_id' =>
$agreement_id,
- 'lang_category'
=> lang('category'),
- 'lang_save'
=> lang('save'),
- 'lang_cancel'
=> lang('done'),
- 'lang_apply'
=> lang('apply'),
- 'value_cat'
=> $agreement['cat'],
- 'lang_cancel_statustext' =>
lang('return back to the list'),
- 'cat_list'
=> $this->bo->select_category_list('select',$this->cat_id),
-
- 'lang_member_of'
=> lang('member of'),
- 'member_of_name'
=> 'member_id',
- 'member_of_list'
=> $member_of_data['cat_list'],
-
- 'lang_dateformat'
=> lang(strtolower($dateformat)),
- 'attributes_view'
=> $agreement['attributes'],
- 'dateformat'
=> $dateformat,
-
- 'lang_start_date'
=> lang('start date'),
- 'value_start_date'
=> $agreement['start_date'],
-
- 'lang_end_date'
=> lang('end date'),
- 'value_end_date'
=> $agreement['end_date'],
-
- 'lang_termination_date' =>
lang('termination date'),
- 'value_termination_date' =>
$agreement['termination_date'],
-
- 'vendor_data'
=> $vendor_data,
- 'lang_name'
=> lang('name'),
- 'value_name'
=> $agreement['name'],
- 'lang_descr'
=> lang('descr'),
- 'value_descr'
=> $agreement['descr'],
- 'table_add'
=> $table_add,
- 'values'
=> $content,
- 'table_header'
=> $table_header,
- 'lang_agreement_group' =>
lang('Agreement group'),
- 'agreement_group_list' =>
$this->bo->get_agreement_group_list($agreement['group_id']),
-
- 'lang_status'
=> lang('Status'),
- 'status_list'
=> $this->bo->select_status_list('select',$agreement['status']),
- );
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('agreement') . ': ' . lang('view');
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- function list_attribute()
- {
- $id = get_var('id',array('POST','GET'));
- $resort = get_var('resort',array('POST','GET'));
-
- $GLOBALS['phpgw']->xslttpl->add_file(array(
- 'agreement',
- 'nextmatchs',
-
'search_field'));
-
- if($resort)
- {
-
$this->bo->resort_attrib(array('resort'=>$resort,'id'=>$id));
- }
-
- $attrib_list = $this->bo->read_attrib();
-
- while (is_array($attrib_list) && list(,$attrib) =
each($attrib_list))
- {
- $content[] = array
- (
- 'name'
=> $attrib['name'],
- 'type_name'
=> $attrib['type_name'],
- 'datatype'
=> $attrib['datatype'],
- 'column_name'
=> $attrib['column_name'],
- 'input_text'
=> $attrib['input_text'],
- 'sorting'
=> $attrib['attrib_sort'],
- 'search'
=> $attrib['search'],
- 'link_up'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.list_attribute&resort=up&id='
. $attrib['id'] . '&allrows=' . $this->allrows . '&role=' . $this->role),
- 'link_down'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.list_attribute&resort=down&id='
. $attrib['id'] . '&allrows=' . $this->allrows . '&role=' . $this->role),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit_attrib&id='
. $attrib['id'] . '&role=' . $this->role),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.delete&id='
. $attrib['id'].'&attrib=true&role=' . $this->role),
- 'lang_view_attribtext' =>
lang('view the attrib'),
- 'lang_attribute_attribtext' =>
lang('attributes for the attrib'). ' ' . lang('location'),
- 'lang_edit_attribtext' =>
lang('edit the attrib'),
- 'lang_delete_attribtext' =>
lang('delete the attrib'),
- 'text_attribute'
=> lang('Attributes'),
- 'text_up'
=> lang('up'),
- 'text_down'
=> lang('down'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
-
- //html_print_r($content);
-
- $table_header[] = array
- (
- 'lang_descr' => lang('Descr'),
- 'lang_datatype' => lang('Datatype'),
- 'lang_sorting' => lang('sorting'),
- 'lang_search' => lang('search'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_sorting' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'attrib_sort',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiagreement.list_attribute',
-
'allrows'=>$this->allrows,
-
'role' => $this->role)
-
)),
-
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'column_name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiagreement.list_attribute',
-
'allrows'=>$this->allrows,
-
'role' => $this->role)
-
)),
- 'lang_name' => lang('Name'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_attribtext' => lang('add a attrib'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit_attrib&role='
. $this->role),
- 'lang_done' =>
lang('done'),
- 'lang_done_attribtext' => lang('back to
admin'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php'),
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiagreement.list_attribute',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'query'
=>$this->query,
- 'role' =>
$this->role
-
- );
-
- $data = array
- (
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($attrib_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_attribtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_attribtext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_attrib' =>
$table_header,
- 'values_attrib'
=> $content,
- 'table_add2'
=> $table_add
- );
-
- $appname
= lang('agreement');
- $function_msg =
lang('list attribute') . ': ' . lang($this->role);
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
- //$this->save_sessiondata();
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_attribute' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function edit_attrib()
- {
- $id =
get_var('id',array('POST','GET'));
- $values = get_var('values',array('POST'));
- // $GLOBALS['phpgw']->common->msgbox(lang('Altering
ColumnName OR Datatype - deletes your data in this Column'));
- //html_print_r($values);
-
$GLOBALS['phpgw']->xslttpl->add_file(array('agreement','choice',));
-
- if ($values['save'])
- {
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
- $type_id =
$values['type_id'];
-
- if (!$values['column_name'])
- {
- $receipt['error'][] =
array('msg'=>lang('Column name not entered!'));
- }
-
- if (!$values['input_text'])
- {
- $receipt['error'][] =
array('msg'=>lang('Input text not entered!'));
- }
- if (!$values['statustext'])
- {
- $receipt['error'][] =
array('msg'=>lang('Statustext not entered!'));
- }
-
- if (!$values['column_info']['type'])
- {
- $receipt['error'][] =
array('msg'=>lang('Datatype type not choosen!'));
- }
-
-
if(!ctype_digit($values['column_info']['precision']))
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter precision as integer !'));
-
unset($values['column_info']['precision']);
- }
-
-
if(!ctype_digit($values['column_info']['scale']))
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter scale as integer !'));
- unset($values['column_info']['scale']);
- }
-
- if (!$values['column_info']['nullable'])
- {
- $receipt['error'][] =
array('msg'=>lang('Nullable not choosen!'));
- }
-
-
- if (!$receipt['error'])
- {
- $receipt =
$this->bo->save_attrib($values,$action);
-
- if(!$id)
- {
- $id=$receipt['id'];
- }
- }
- else
- {
- $receipt['error'][] = array('msg'
=> lang('Attribute has NOT been saved'));
- }
-
- }
-
- if ($id)
- {
- $values = $this->bo->read_single_attrib($id);
- $function_msg = lang('edit attribute') . ': ' .
lang($this->role);
- $action='edit';
- }
- else
- {
- $function_msg = lang('add attribute') . ': ' .
lang($this->role);
- $action='add';
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiagreement.edit_attrib',
- 'id' => $id,
- 'role' => $this->role
-
- );
- //html_print_r($values);
-
- if($values['column_info']['type']=='R' ||
$values['column_info']['type']=='CH' || $values['column_info']['type']=='LB')
- {
- $multiple_choice= True;
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'lang_choice' =>
lang('Choice'),
- 'lang_new_value' =>
lang('New value'),
- 'lang_new_value_statustext' => lang('New
value for mulitple choice'),
- 'multiple_choice' =>
$multiple_choice,
- 'value_choice' =>
$values['choice'],
- 'lang_delete_value' =>
lang('Delete value'),
- 'lang_value' =>
lang('value'),
- 'lang_delete_choice_statustext'=> lang('Delete
this value from the list of multiple choice'),
- 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.list_attribute&type_id='.$type_id
. '&role=' . $this->role),
- 'lang_id'
=> lang('Attribute ID'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_id'
=> $id,
-
- 'lang_column_name'
=> lang('Column name'),
- 'value_column_name'
=> $values['column_name'],
- 'lang_column_name_statustext' => lang('enter
the name for the column'),
-
- 'lang_input_text'
=> lang('input text'),
- 'value_input_text'
=> $values['input_text'],
- 'lang_input_name_statustext' => lang('enter
the input text for records'),
-
- 'lang_id_attribtext' => lang('Enter
the attribute ID'),
- 'lang_entity_statustext' => lang('Select
a agreement type'),
-
- 'lang_statustext' =>
lang('Statustext'),
- 'lang_statustext_attribtext'=> lang('Enter a
statustext for the inputfield in forms'),
- 'value_statustext' =>
$values['statustext'],
-
- 'lang_done_attribtext' => lang('Back
to the list'),
- 'lang_save_attribtext' => lang('Save
the attribute'),
-
- 'lang_datatype' =>
lang('Datatype'),
- 'lang_datatype_statustext' => lang('Select
a datatype'),
- 'lang_no_datatype' =>
lang('No datatype'),
- 'datatype_list' =>
$this->bocommon->select_datatype($values['column_info']['type']),
-
- 'lang_precision' =>
lang('Precision'),
- 'lang_precision_statustext' => lang('enter
the record length'),
- 'value_precision' =>
$values['column_info']['precision'],
-
- 'lang_scale' =>
lang('scale'),
- 'lang_scale_statustext' => lang('enter
the scale if type is decimal'),
- 'value_scale' =>
$values['column_info']['scale'],
-
- 'lang_default' =>
lang('default'),
- 'lang_default_statustext' => lang('enter
the default value'),
- 'value_default' =>
$values['column_info']['default'],
-
- 'lang_nullable' =>
lang('Nullable'),
- 'lang_nullable_statustext' => lang('Chose
if this column is nullable'),
- 'lang_select_nullable' => lang('Select
nullable'),
- 'nullable_list' =>
$this->bocommon->select_nullable($values['column_info']['nullable']),
-
- 'value_list' =>
$values['list'],
- 'lang_list'
=> lang('show in list'),
- 'lang_list_statustext' => lang('check
to show this attribute in location list'),
-
- 'value_search' =>
$values['search'],
- 'lang_include_search' =>
lang('Include in search'),
- 'lang_include_search_statustext'=> lang('check
to show this attribute in location list'),
-
-
- );
- //html_print_r($data);
-
- $appname
= lang('agreement');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_attrib' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
- }
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage agreement
+ * @version $Id: class.uiagreement.inc.php,v 1.17 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uiagreement
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'view' => True,
+ 'edit' => True,
+ 'delete' => True,
+ 'list_attribute'=> True,
+ 'edit_attrib' => True,
+ 'columns' => True,
+ 'edit_item' => True,
+ 'view_item' => True,
+ 'view_file' => True,
+ 'excel' => True,
+ 'add_activity' => True
+ );
+
+ function uiagreement()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $this->bo =
CreateObject($this->currentapp.'.boagreement',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+
+ $this->role = $this->bo->role;
+
+ $this->cats =
CreateObject('phpgwapi.categories');
+ $this->cats->app_name = 'fm_vendor';
+
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+ $this->acl2_location= '.pricebook';
+
+ $this->acl_read =
$this->acl2->check($this->acl2_location,1);
+ $this->acl_add =
$this->acl2->check($this->acl2_location,2);
+ $this->acl_edit =
$this->acl2->check($this->acl2_location,4);
+ $this->acl_delete =
$this->acl2->check($this->acl2_location,8);
+ $this->acl_manage =
$this->acl2->check($this->acl2_location,16);
+
+ $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->vendor_id = $this->bo->vendor_id;
+ $this->allrows = $this->bo->allrows;
+ $this->member_id = $this->bo->member_id;
+ $this->fakebase = $this->bo->fakebase;
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' => $this->filter,
+ 'cat_id' => $this->cat_id,
+ 'vendor_id' => $this->vendor_id,
+ 'allrows' => $this->allrows,
+ 'member_id' => $this->member_id
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function columns()
+ {
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('columns'));
+
+ $GLOBALS['phpgw_info']['flags']['noframework'] = True;
+
+ $values =
get_var('values',array('POST','GET'));
+
+ if ($values['save'])
+ {
+
+
$GLOBALS['phpgw']->preferences->account_id=$this->account;
+
$GLOBALS['phpgw']->preferences->read_repository();
+
$GLOBALS['phpgw']->preferences->add($this->currentapp,'agreement_columns',$values['columns'],'user');
+
$GLOBALS['phpgw']->preferences->save_repository();
+
+ $receipt['message'][] = array('msg' =>
lang('columns is updated'));
+ }
+
+ $function_msg = lang('Select Column');
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiagreement.columns',
+ 'role' => $this->role
+ );
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'column_list' =>
$this->bo->column_list($values['columns'],$allrows=True),
+ 'function_msg' => $function_msg,
+ 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_columns' => lang('columns'),
+ 'lang_none' => lang('None'),
+ 'lang_save' => lang('save'),
+ 'select_name' => 'period'
+ );
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
$function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('columns' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function view_file()
+ {
+ $GLOBALS['phpgw_info']['flags'][noheader] = True;
+ $GLOBALS['phpgw_info']['flags'][nofooter] = True;
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
+
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $file_name =
urldecode(get_var('file_name',array('POST','GET')));
+ $id = get_var('id',array('POST','GET'));
+
+ $file = $this->fakebase. SEP . 'agreement' . SEP . $id
. SEP . $file_name;
+
+ if($this->bo->vfs->file_exists(array(
+ 'string' => $file,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+
+ $size =
$this->bo->vfs->get_size(array(
+ 'string' => $file,
+ 'relatives' =>
Array(RELATIVE_NONE),
+ 'checksubdirs' =>
True));
+
+ $document= $this->bo->vfs->read(array(
+ 'string' => $file,
+ 'relatives' => Array(RELATIVE_NONE)));
+
+ $filename =
basename($values['document_name']);
+ $filetype = array_pop(explode('.',
basename($file)));
+ $browser = CreateObject('phpgwapi.browser');
+
$browser->content_header($filename,$filetype,$size);
+
+ echo $document;
+
+ }
+ }
+
+ function index()
+ {
+ $this->menu->sub = 'agreement';
+
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('agreement',
+
'menu',
+
'receipt',
+
'search_field',
+
'nextmatchs',
+
'filter_member_of'));
+
+ $links = $this->menu->links('agreement','agreement');
+
+ $receipt =
$GLOBALS['phpgw']->session->appsession('session_data','agreement_receipt');
+
$GLOBALS['phpgw']->session->appsession('session_data','agreement_receipt','');
+
+ $list = $this->bo->read();
+
+ $uicols = $this->bo->uicols;
+
+ $j=0;
+
+ if (isset($list) AND is_array($list))
+ {
+ foreach($list as $entry)
+ {
+ for
($i=0;$i<count($uicols['name']);$i++)
+ {
+
if($uicols['input_type'][$i]!='hidden')
+ {
+
$content[$j]['row'][$i]['value'] =
$entry[$uicols['name'][$i]];
+
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
+ }
+ }
+
+ if($this->acl_read)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('view the
entity');
+ $content[$j]['row'][$i]['text']
= lang('view');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.view&id='
. $entry['id'] .'&role=' . $this->role);
+ }
+ if($this->acl_edit)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('edit the
agreement');
+ $content[$j]['row'][$i]['text']
= lang('edit');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit&id='
. $entry['id'] .'&role=' . $this->role);
+ }
+ if($this->acl_delete)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('delete the
agreement');
+ $content[$j]['row'][$i]['text']
= lang('delete');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.delete&agreement_id='
. $entry['id'] .'&role=' . $this->role);
+ }
+
+ $j++;
+ }
+ }
+
+//_debug_array($content);
+ for ($i=0;$i<count($uicols['descr']);$i++)
+ {
+ if($uicols['input_type'][$i]!='hidden')
+ {
+ $table_header[$i]['header'] =
$uicols['descr'][$i];
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ if($uicols['datatype'][$i]!='T' &&
$uicols['datatype'][$i]!='CH')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+ (
+ 'sort' =>
$this->sort,
+ 'var' =>
$uicols['name'][$i],
+ 'order' =>
$this->order,
+ 'extra'
=> array('menuaction' => $this->currentapp.'.uiagreement.index',
+
'query' =>$this->query,
+
'lookup' =>$lookup,
+
'district_id' => $this->district_id,
+
'start_date' => $start_date,
+
'role' => $this->role,
+
'member_id' => $this->member_id,
+
'allrows' => $this->allrows,
+
'end_date' => $end_date
+
)
+ ));
+ }
+ }
+ }
+
+ if($this->acl_read)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('view');
+ $i++;
+ }
+ if($this->acl_edit)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('edit');
+ $i++;
+ }
+ if($this->acl_delete)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('delete');
+ $i++;
+ }
+
+
+ if($this->acl_add)
+ {
+ $table_add = array
+ (
+ 'lang_add'
=> lang('add'),
+ 'lang_add_statustext' => lang('add a
agreement'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit&role='
. $this->role)
+ );
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiagreement.index',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query,
+ 'role' =>
$this->role,
+ 'member_id' =>
$this->member_id
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $link_columns = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiagreement.columns',
+ 'role' =>
$this->role
+ );
+
+ $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True,link_data =>$link_data));
+
+ $data = array
+ (
+ 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
+ 'lang_columns'
=> lang('columns'),
+ 'link_columns'
=> $GLOBALS['phpgw']->link('/index.php',$link_columns),
+ 'lang_columns_help'
=> lang('Choose columns'),
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'links'
=> $links,
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the agreement belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $this->bo->select_category_list('filter',$this->cat_id),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+
+ 'lang_no_vendor'
=> lang('no vendor'),
+ 'lang_vendor_statustext' =>
lang('Select the vendor the agreement belongs to.'),
+ 'vendor_list'
=> $this->bo->select_vendor_list('filter',$this->vendor_id),
+
+ 'lang_no_member'
=> lang('no member'),
+ 'member_of_name'
=> 'member_id',
+ 'member_of_list'
=> $member_of_data['cat_list'],
+
+ 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter)),
+ 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+ $this->save_sessiondata();
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('agreement') . ': ' . lang('list ' . $this->role);
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function list_content($list,$uicols,$edit_item='',$view_only='')
+ {
+ $j=0;
+//_debug_array($list);
+ if (isset($list) AND is_array($list))
+ {
+ foreach($list as $entry)
+ {
+ $content[$j]['id']
= $entry['id'];
+ $content[$j]['activity_id'] =
$entry['activity_id'];
+ $content[$j]['index_count']
= $entry['index_count'];
+ $content[$j]['m_cost']
= $entry['m_cost'];
+ $content[$j]['w_cost']
= $entry['w_cost'];
+ $content[$j]['total_cost']
= $entry['total_cost'];
+ $content[$j]['index_count'] =
$entry['index_count'];
+ for
($i=0;$i<count($uicols['name']);$i++)
+ {
+
if($uicols['input_type'][$i]!='hidden')
+ {
+
$content[$j]['row'][$i]['value'] =
$entry[$uicols['name'][$i]];
+
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
+ }
+ }
+
+ if($this->acl_read && !$edit_item &&
!$view_only)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('view the
entity');
+ $content[$j]['row'][$i]['text']
= lang('view');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.view_item&agreement_id='
. $entry['agreement_id'] .'&id=' . $entry['id']);
+ }
+ if($this->acl_edit && !$edit_item &&
!$view_only)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('edit the
agreement');
+ $content[$j]['row'][$i]['text']
= lang('edit');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit_item&agreement_id='
. $entry['agreement_id'] .'&id=' . $entry['id']);
+ }
+ if($this->acl_delete && !$edit_item &&
!$view_only)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('delete this
item');
+ $content[$j]['row'][$i]['text']
= lang('delete');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit&delete_item=1&agreement_id='
. $entry['agreement_id'] .'&activity_id=' . $entry['id']);
+ }
+
+ $j++;
+ }
+ }
+
+//html_print_r($content);
+ for ($i=0;$i<count($uicols['descr']);$i++)
+ {
+ if($uicols['input_type'][$i]!='hidden')
+ {
+ $table_header[$i]['header'] =
$uicols['descr'][$i];
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ }
+ }
+
+ if($this->acl_read && !$edit_item && !$view_only)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('view');
+ $i++;
+ }
+ if($this->acl_edit && !$edit_item && !$view_only)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('edit');
+ $i++;
+ }
+ if($this->acl_delete && !$edit_item && !$view_only)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('delete');
+ $i++;
+ }
+ if($this->acl_manage && !$edit_item && !$view_only)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('Update');
+ $i++;
+ }
+
+ return
array('content'=>$content,'table_header'=>$table_header);
+ }
+
+ function add_activity()
+ {
+ $agreement_id =
get_var('agreement_id',array('POST','GET'));
+ $group_id =
get_var('group_id',array('POST','GET'));
+ $values = get_var('values',array('POST','GET'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('agreement'));
+
+ $agreement =
$this->bo->read_single(array('agreement_id'=>$agreement_id));
+
+ if($this->acl_add && (is_array($values)))
+ {
+ if ($values['save'] || $values['apply'])
+ {
+ $receipt =
$this->bo->add_activity($values,$agreement_id);
+
+ if ($values['save'])
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','agreement_receipt',$receipt);
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit&id='
. $agreement_id);
+ }
+ }
+ else
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit&id='
. $agreement_id);
+
+ }
+ }
+
+ $content =
$this->bo->read_group_activity($group_id,$agreement_id);
+
+//_debug_array($content);
+ $uicols = $this->bo->uicols;
+ $uicols['descr'][] =
lang('select');
+
+ for ($i=0;$i<count($uicols['descr']);$i++)
+ {
+ if($uicols['input_type'][$i]!='hidden')
+ {
+ $table_header[$i]['header'] =
$uicols['descr'][$i];
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ }
+ }
+
+
+ $data = array
+ (
+ 'lang_id'
=> lang('ID'),
+ 'value_agreement_id' =>
$agreement_id,
+ 'lang_name'
=> lang('name'),
+ 'value_name'
=> $agreement['name'],
+ 'lang_descr'
=> lang('descr'),
+ 'value_descr'
=> $agreement['descr'],
+ 'lang_select_all'
=> lang('Select All'),
+ 'img_check'
=>
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
+ 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
+ 'add_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.add_activity&group_id='
. $group_id . '&agreement_id=' . $agreement_id),
+ 'agreement_id'
=> $agreement_id,
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'lang_save'
=> lang('save'),
+ 'lang_cancel'
=> lang('cancel'),
+ 'lang_apply'
=> lang('apply'),
+ 'lang_apply_statustext' =>
lang('Apply the values'),
+ 'lang_cancel_statustext' =>
lang('Leave the agreement untouched and return back to the list'),
+ 'lang_save_statustext' =>
lang('Save the agreement and return back to the list'),
+ );
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('agreement') . ': ' . lang('add activity');
+//_debug_array($data);
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('add_activity' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function edit()
+ {
+ $id = get_var('id',array('POST','GET'));
+ $values = get_var('values',array('POST'));
+ $delete_item = get_var('delete_item',array('GET'));
+ $activity_id = get_var('activity_id',array('GET'));
+
+ $config =
CreateObject('phpgwapi.config',$this->currentapp);
+ $boalarm =
CreateObject($this->currentapp.'.boalarm');
+
+ if($delete_item && $id && $activity_id)
+ {
+ $this->bo->delete_item($id,$activity_id);
+ }
+
+ $values_attribute =
get_var('values_attribute',array('POST'));
+
+ $insert_record_agreement =
$GLOBALS['phpgw']->session->appsession('insert_record_agreement',$this->currentapp);
+
+//_debug_array($insert_record_agreement);
+ for ($j=0;$j<count($insert_record_agreement);$j++)
+ {
+
$insert_record['extra'][$insert_record_agreement[$j]] =
$insert_record_agreement[$j];
+ }
+
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('agreement','nextmatchs','attributes_form'));
+
+ if (is_array($values))
+ {
+ while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
+ {
+ if($_POST[$key])
+ {
+ $values['extra'][$column]
= $_POST[$key];
+ }
+ }
+
+//_debug_array($values);
+
+ if ($values['save'] || $values['apply']):
+ {
+ $values['vendor_id'] =
get_var('vendor_id',array('POST'));
+ $values['vendor_name'] =
get_var('vendor_name',array('POST'));
+ $values['start_date'] =
get_var('start_date',array('POST'));
+ $values['end_date']
= get_var('end_date',array('POST'));
+ $values['termination_date'] =
get_var('termination_date',array('POST'));
+
+ if(!$values['cat_id'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
+ }
+
+ if(!$values['last_name'])
+ {
+//
$receipt['error'][]=array('msg'=>lang('Please enter a name !'));
+ }
+
+
+ if($id)
+ {
+ $values['agreement_id']=$id;
+ $action='edit';
+ }
+ else
+ {
+
$values['agreement_id']=$this->bo->request_next_id();
+ }
+
+
$values['file_name']=$_FILES['file']['name'];
+ $to_file = $this->fakebase. SEP .
'agreement' . SEP . $values['agreement_id'] . SEP . $values['file_name'];
+
+ if(!$values['document_name_orig'] &&
$this->bo->vfs->file_exists(array(
+ 'string' => $to_file,
+ 'relatives' =>
Array(RELATIVE_NONE)
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('This file already exists !'));
+ }
+
+
+ if(!$receipt['error'])
+ {
+// $values['agreement_id'] = $id;
+ $receipt =
$this->bo->create_home_dir($receipt);
+ $receipt =
$this->bo->save($values,$values_attribute,$action);
+ $id = $receipt['agreement_id'];
+ $this->cat_id =
($values['cat_id']?$values['cat_id']:$this->cat_id);
+
+ if($values['file_name'])
+ {
+
$this->bo->create_document_dir($id);
+
$this->bo->vfs->override_acl = 1;
+
+ if(!$this->bo->vfs->cp
(array (
+ 'from' =>
$_FILES['file']['tmp_name'],
+ 'to' =>
$to_file,
+ 'relatives'
=> array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
+ {
+
$receipt['error'][]=array('msg'=>lang('Failed to upload file !'));
+ }
+
$this->bo->vfs->override_acl = 0;
+ }
+
+
+ if ($values['save'])
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','agreement_receipt',$receipt);
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiagreement.index&role='
. $this->role);
+ }
+ }
+ }
+ elseif($values['update']):
+ {
+ $values['date'] =
get_var('date',array('POST'));
+
+ if(!$values['date'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a date !'));
+ }
+ if(!$values['new_index'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter a index !'));
+ }
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$this->bo->update($values);
+ }
+
+ }
+ elseif($values['delete_alarm'] &&
count($values['alarm'])):
+ {
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$boalarm->delete_alarm('agreement',$values['alarm']);
+ }
+
+ }
+ elseif(($values['enable_alarm'] ||
$values['disable_alarm']) && count($values['alarm'])):
+ {
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$boalarm->enable_alarm('agreement',$values['alarm'],$values['enable_alarm']);
+ }
+
+ }
+ elseif($values['add_alarm']):
+ {
+ $time =
intval($values['time']['days'])*24*3600 +
+
intval($values['time']['hours'])*3600 +
+
intval($values['time']['mins'])*60;
+
+ if ($time > 0)
+ {
+ $receipt =
$boalarm->add_alarm('agreement',$this->bo->read_event(array('agreement_id'=>$id)),$time,$values['user_id']);
+ }
+ }
+ elseif (!$values['save'] && !$values['apply']
&& !$values['update']):
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiagreement.index&role='
. $this->role);
+ }
+ endif;
+ }
+
+
+ $agreement =
$this->bo->read_single(array('agreement_id'=>$id));
+
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+ if ($id)
+ {
+ $this->cat_id =
($agreement['cat_id']?$agreement['cat_id']:$this->cat_id);
+ $this->member_id =
($agreement['member_of']?$agreement['member_of']:$this->member_id);
+ $list = $this->bo->read_details($id);
+
+ $content = $list;
+ //_debug_array($list);
+ if (isset($list) AND is_array($list))
+ {
+ $k=count($list);
+ for ($j=0;$j<$k;$j++)
+ {
+ if($this->acl_read &&
!$edit_item && !$view_only)
+ {
+
$content[$j]['lang_view_statustext'] = lang('view the entity');
+
$content[$j]['text_view'] = lang('view');
+
$content[$j]['link_view'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.view_item&agreement_id='
. $id .'&id=' . $content[$j]['activity_id']);
+ }
+ if($this->acl_edit &&
!$edit_item && !$view_only)
+ {
+
$content[$j]['lang_edit_statustext'] = lang('edit the agreement');
+
$content[$j]['text_edit'] = lang('edit');
+
$content[$j]['link_edit'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit_item&agreement_id='
. $id .'&id=' . $content[$j]['activity_id']);
+ }
+ if($this->acl_delete &&
!$edit_item && !$view_only)
+ {
+
$content[$j]['lang_delete_statustext'] = lang('delete this item');
+
$content[$j]['text_delete'] = lang('delete');
+
$content[$j]['link_delete'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit&delete_item=1&id='
. $id .'&activity_id=' . $content[$j]['activity_id']);
+ }
+
+ $content[$j]['acl_manage']
= $this->acl_manage;
+ $content[$j]['acl_read']
= $this->acl_read;
+ $content[$j]['acl_edit']
= $this->acl_edit;
+ $content[$j]['acl_delete']
= $this->acl_delete;
+ }
+ }
+
+
+ $uicols = $this->bo->uicols;
+
+ for ($i=0;$i<count($uicols['descr']);$i++)
+ {
+ if($uicols['input_type'][$i]!='hidden')
+ {
+ $table_header[$i]['header']
= $uicols['descr'][$i];
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ }
+ }
+
+ if($this->acl_read && !$edit_item &&
!$view_only)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('view');
+ $i++;
+ $set_column[]=True;
+ }
+ if($this->acl_edit && !$edit_item &&
!$view_only)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('edit');
+ $i++;
+ $set_column[]=True;
+ }
+ if($this->acl_delete && !$edit_item &&
!$view_only)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('delete');
+ $i++;
+ $set_column[]=True;
+ }
+ if($this->acl_manage && !$edit_item &&
!$view_only)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('Update');
+ $i++;
+ $set_column[]=True;
+ }
+
+// $table_header=$list['table_header'];
+ for ($i=0; $i<9; $i++)
+ {
+ $set_column[]=True;
+ }
+
+ if ($content)
+ {
+ $table_update[] = array
+ (
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle'
=> lang('Select date'),
+ 'calendar_setup'
=> "Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat
. "',button : 'date-trigger'});",
+
+ 'lang_new_index'
=> lang('New index'),
+ 'lang_new_index_statustext'
=> lang('Enter a new index'),
+ 'lang_date_statustext'
=> lang('Select the date for the update'),
+ 'lang_update'
=> lang('Update'),
+ 'lang_update_statustext'
=> lang('update selected investments')
+ );
+ }
+
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiagreement.edit',
+ 'sort' =>$this->sort,
+ 'order' =>$this->order,
+ 'id' => $id,
+ 'role' => $this->role
+ );
+
+
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
+ 'vendor_id' =>
$agreement['vendor_id'],
+ 'vendor_name' =>
$agreement['vendor_name']));
+
+ if($agreement['vendor_id'])
+ {
+ $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True, link_data => array()));
+ }
+
+ $alarm_data=$this->bocommon->initiate_ui_alarm(array(
+
'acl_location'=>$this->acl2_location,
+ 'alarm_type'=> 'agreement',
+ 'type' => 'form',
+ 'text' => 'Email
notification',
+ 'times' => $times,
+ 'id' => $id,
+ 'method' => $method,
+ 'data' => $data,
+ 'account_id'=> $account_id
+ ));
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ switch(substr($dateformat,0,1))
+ {
+ case 'M':
+ $dateformat_validate=
"javascript:vDateType='1'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'1')";
+ break;
+ case 'y':
+
$dateformat_validate="javascript:vDateType='2'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'2')";
+ break;
+ case 'D':
+
$dateformat_validate="javascript:vDateType='3'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'3')";
+ break;
+ }
+
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add detail'),
+ 'lang_add_standardtext' => lang('add an item to
the details'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.add_activity&agreement_id='
. $id . '&group_id=' . $agreement['group_id'])
+ );
+
+
+ $link_file_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiagreement.view_file',
+ 'id' =>$id
+ );
+
+ $config->read_repository();
+ $link_to_files = $config->config_data['files_url'];
+
+ $j = count($agreement['files']);
+ for ($i=0;$i<$j;$i++)
+ {
+
$agreement['files'][$i]['file_name']=urlencode($agreement['files'][$i]['name']);
+ }
+
+ $link_excel = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiagreement.excel',
+ 'id'
=>$id,
+ 'allrows'
=>$this->allrows
+ );
+
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $data = array
+ (
+
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+
+ 'alarm_data' =>
$alarm_data,
+ 'lang_alarm' =>
lang('Alarm'),
+ 'lang_excel' =>
'excel',
+ 'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
+ 'lang_excel_help' =>
lang('Download table to MS Excel'),
+ 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
+
+ 'fileupload'
=> True,
+ 'link_view_file'
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
+ 'link_to_files'
=> $link_to_files,
+ 'files'
=> $agreement['files'],
+ 'lang_files'
=> lang('files'),
+ 'lang_filename'
=> lang('Filename'),
+ 'lang_delete_file'
=> lang('Delete file'),
+ 'lang_view_file_statustext' =>
lang('Klick to view file'),
+ 'lang_delete_file_statustext' => lang('Check
to delete file'),
+ 'lang_upload_file'
=> lang('Upload file'),
+ 'lang_file_statustext' =>
lang('Select file to upload'),
+
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_id'
=> lang('ID'),
+ 'value_agreement_id' => $id,
+ 'lang_category'
=> lang('category'),
+ 'lang_save'
=> lang('save'),
+ 'lang_cancel'
=> lang('cancel'),
+ 'lang_apply'
=> lang('apply'),
+ 'value_cat'
=> $agreement['cat'],
+ 'lang_apply_statustext' =>
lang('Apply the values'),
+ 'lang_cancel_statustext' =>
lang('Leave the agreement untouched and return back to the list'),
+ 'lang_save_statustext' =>
lang('Save the agreement and return back to the list'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the agreement belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'values[cat_id]',
+ 'cat_list'
=> $this->bo->select_category_list('select',$this->cat_id),
+
+ 'lang_member_of'
=> lang('member of'),
+ 'member_of_name'
=> 'member_id',
+ 'member_of_list'
=> $member_of_data['cat_list'],
+
+ 'lang_dateformat'
=> lang(strtolower($dateformat)),
+ 'dateformat_validate' =>
$dateformat_validate,
+ 'onKeyUp'
=> $onKeyUp,
+ 'onBlur'
=> $onBlur,
+ 'dateformat_source'
=> './'.$this->currentapp.'/inc/dateformat.js',
+ 'lang_attributes'
=> lang('Attributes'),
+ 'attributes_header'
=> $attributes_header,
+ 'attributes_values'
=> $agreement['attributes'],
+ 'lookup_functions'
=> $agreement['lookup_functions'],
+ 'dateformat'
=> $dateformat,
+
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle'
=> lang('Select date'),
+ 'calendar_setup_start' =>
"Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});",
+ 'calendar_setup_end' =>
"Calendar.setup({inputField : 'end_date',ifFormat : '" . $jsDateFormat .
"',button : 'end_date-trigger'});",
+ 'calendar_setup_termination'
=> "Calendar.setup({inputField : 'termination_date',ifFormat : '" .
$jsDateFormat . "',button : 'termination_date-trigger'});",
+
+ 'lang_start_date_statustext' => lang('Select
the estimated end date for the agreement'),
+ 'lang_start_date'
=> lang('start date'),
+ 'value_start_date'
=> $agreement['start_date'],
+
+ 'lang_end_date_statustext' =>
lang('Select the estimated end date for the agreement'),
+ 'lang_end_date'
=> lang('end date'),
+ 'value_end_date'
=> $agreement['end_date'],
+
+ 'lang_termination_date_statustext'
=> lang('Select the estimated termination date'),
+ 'lang_termination_date'
=> lang('termination date'),
+ 'value_termination_date'
=> $agreement['termination_date'],
+
+ 'vendor_data'
=> $vendor_data,
+ 'lang_name'
=> lang('name'),
+ 'lang_name_statustext' =>
lang('name'),
+ 'value_name'
=> $agreement['name'],
+ 'lang_descr'
=> lang('descr'),
+ 'lang_descr_statustext' =>
lang('descr'),
+ 'value_descr'
=> $agreement['descr'],
+ 'table_add'
=> $table_add,
+ 'values'
=> $content,
+ 'table_header'
=> $table_header,
+ 'table_update'
=> $table_update,
+ 'update_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit&id='
. $id),
+ 'lang_select_all'
=> lang('Select All'),
+ 'img_check'
=>
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
+ 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
+ 'check_all_script'
=> $check_all_script,
+ 'set_column'
=> $set_column,
+
+ 'lang_agreement_group' =>
lang('Agreement group'),
+ 'lang_no_agreement_group' =>
lang('Select agreement group'),
+ 'agreement_group_list' =>
$this->bo->get_agreement_group_list($agreement['group_id']),
+
+ 'lang_status'
=> lang('Status'),
+ 'status_list'
=> $this->bo->select_status_list('select',$agreement['status']),
+ 'status_name'
=> 'values[status]',
+ 'lang_no_status'
=> lang('Select status'),
+
+ );
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('agreement') . ': ' . ($id?lang('edit') . ' ' .
lang($this->role):lang('add') . ' ' . lang($this->role));
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function excel()
+ {
+ $id = get_var('id',array('POST','GET'));
+ $list = $this->bo->read_details($id);
+ $uicols = $this->bo->uicols;
+
$this->bocommon->excel($list,$uicols['name'],$uicols['descr'],$uicols['input_type']);
+ }
+
+ function edit_item()
+ {
+ $agreement_id =
get_var('agreement_id',array('POST','GET'));
+ $id = get_var('id',array('POST','GET'));
+ $values = get_var('values',array('POST'));
+ $delete_last = get_var('delete_last',array('GET'));
+ if($delete_last)
+ {
+ $this->bo->delete_last_index($agreement_id,$id);
+ }
+
+ $values_attribute =
get_var('values_attribute',array('POST'));
+
+// $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
+// $insert_record_entity =
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp);
+
+ $insert_record_agreement =
$GLOBALS['phpgw']->session->appsession('insert_record_agreement',$this->currentapp);
+
+//_debug_array($insert_record_agreement);
+
+ for ($j=0;$j<count($insert_record_entity);$j++)
+ {
+
$insert_record['extra'][$insert_record_entity[$j]] =
$insert_record_entity[$j];
+ }
+
+ for ($j=0;$j<count($insert_record_agreement1);$j++)
+ {
+
$insert_record['extra'][$insert_record_agreement[$j]] =
$insert_record_agreement[$j];
+ }
+
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('agreement','attributes_form'));
+
+ if (is_array($values))
+ {
+
+/* for ($i=0;
$i<count($insert_record['location']); $i++)
+ {
+
if($_POST[$insert_record['location'][$i]])
+ {
+
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
+ }
+ }
+
+ while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
+ {
+ if($_POST[$key])
+ {
+ $values['extra'][$column]
= $_POST[$key];
+ }
+ }
+
+ $values['street_name'] =
$_POST['street_name'];
+ $values['street_number'] =
$_POST['street_number'];
+ $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
+
+*/
+//_debug_array($values);
+ if ($values['save'] || $values['apply']):
+ {
+
+ if(!$receipt['error'])
+ {
+ $values['agreement_id'] =
$agreement_id;
+ $values['id'] = $id;
+ $receipt =
$this->bo->save_item($values,$values_attribute);
+ $agreement_id =
$receipt['agreement_id'];
+ $id =
$receipt['id'];
+ $this->cat_id =
($values['cat_id']?$values['cat_id']:$this->cat_id);
+
+ if ($values['save'])
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','agreement_receipt',$receipt);
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit&id='
. $agreement_id);
+ }
+ }
+ }
+ elseif($values['update']):
+ {
+ $values['date'] =
get_var('date',array('POST'));
+
+ if(!$values['date'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a date !'));
+ }
+ if(!$values['new_index'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter a index !'));
+ }
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$this->bo->update($values);
+ }
+
+ }
+ elseif (!$values['save'] && !$values['apply']
&& !$values['update']):
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit&id='
. $agreement_id);
+ }
+ endif;
+ }
+
+ $agreement =
$this->bo->read_single(array('agreement_id'=>$agreement_id));
+ $values =
$this->bo->read_single_item(array('agreement_id'=>$agreement_id,'id'=>$id));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiagreement.edit_item',
+ 'agreement_id' => $agreement_id,
+ 'id' => $id,
+ 'role' => $this->role
+ );
+
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ switch(substr($dateformat,0,1))
+ {
+ case 'M':
+ $dateformat_validate=
"javascript:vDateType='1'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'1')";
+ break;
+ case 'y':
+
$dateformat_validate="javascript:vDateType='2'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'2')";
+ break;
+ case 'D':
+
$dateformat_validate="javascript:vDateType='3'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'3')";
+ break;
+ }
+
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True,link_data => array()));
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add detail'),
+ 'lang_add_standardtext' => lang('add an item to
the details'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit_item&agreement_id='
. $agreement_id)
+ );
+
+
+ if($id)
+ {
+ $list =
$this->bo->read_prizing(array('agreement_id'=>$agreement_id,'activity_id'=>$id));
+ $activity_descr
=$this->bo->get_activity_descr($id);
+ }
+
+ $uicols = $this->bo->uicols;
+ $list =
$this->list_content($list,$uicols,$edit_item=True);
+ $content = $list['content'];
+ $table_header=$list['table_header'];
+
+ for ($i=0; $i<count($list['content'][0]['row']); $i++)
+ {
+ $set_column[]=True;
+ }
+
+ $table_update[] = array
+ (
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle'
=> lang('Select date'),
+ 'calendar_setup' =>
"Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat .
"',button : 'date-trigger'});",
+
+ 'lang_new_index' =>
lang('New index'),
+ 'lang_new_index_statustext' => lang('Enter
a new index'),
+ 'lang_date_statustext' => lang('Select
the date for the update'),
+ 'lang_update' =>
lang('Update'),
+ 'lang_update_statustext' => lang('update
selected investments')
+ );
+
+ $data = array
+ (
+ 'activity_descr' =>
$activity_descr,
+ 'lang_descr' =>
lang('Descr'),
+ 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'edit_url' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_id' =>
lang('ID'),
+ 'value_id' =>
$values['id'],
+ 'value_num' =>
$values['num'],
+ 'value_agreement_id' =>
$agreement_id,
+ 'lang_category' =>
lang('category'),
+ 'lang_save' =>
lang('save'),
+ 'lang_cancel' =>
lang('cancel'),
+ 'lang_apply' =>
lang('apply'),
+ 'lang_apply_statustext' =>
lang('Apply the values'),
+ 'lang_cancel_statustext' =>
lang('Leave the agreement untouched and return back to the list'),
+ 'lang_save_statustext' =>
lang('Save the agreement and return back to the list'),
+
+ 'lang_dateformat' =>
lang(strtolower($dateformat)),
+ 'dateformat_validate' =>
$dateformat_validate,
+ 'onKeyUp' =>
$onKeyUp,
+ 'onBlur' =>
$onBlur,
+ 'dateformat_source' =>
'./'.$this->currentapp.'/inc/dateformat.js',
+ 'lang_attributes' =>
lang('Attributes'),
+ 'attributes_header' =>
$attributes_header,
+ 'attributes_values' =>
$values['attributes'],
+ 'lookup_functions' =>
$values['lookup_functions'],
+ 'dateformat' =>
$dateformat,
+
+ 'jsDateFormat' =>
$jsDateFormat,
+ 'date_img' =>
$cal_info['img'],
+ 'lang_datetitle' =>
lang('Select date'),
+ 'calendar_setup_start' =>
"Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});",
+ 'calendar_setup_end' =>
"Calendar.setup({inputField : 'end_date',ifFormat : '" . $jsDateFormat .
"',button : 'end_date-trigger'});",
+
+ 'lang_agreement' =>
lang('Agreement'),
+ 'agreement_name' =>
$agreement['name'],
+
+ 'table_add'
=> $table_add,
+ 'values'
=> $content,
+ 'index_count'
=> $content[0]['index_count'],
+ 'table_header'
=> $table_header,
+ 'acl_manage'
=> $this->acl_manage,
+ 'table_update'
=> $table_update,
+ 'update_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit_item&agreement_id='
. $agreement_id . '&id=' . $id),
+ 'lang_select_all'
=> lang('Select All'),
+ 'img_check'
=>
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
+ 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
+
+ 'lang_m_cost'
=> lang('Material cost'),
+ 'lang_m_cost_statustext' =>
lang('Material cost'),
+ 'value_m_cost'
=> $values['m_cost'],
+
+ 'lang_w_cost'
=> lang('Labour cost'),
+ 'lang_w_cost_statustext' =>
lang('Labour cost'),
+ 'value_w_cost'
=> $values['w_cost'],
+
+ 'lang_total_cost'
=> lang('Total cost'),
+ 'value_total_cost'
=> $values['total_cost'],
+
+ 'set_column'
=> $set_column,
+ 'lang_delete_last'
=> lang('delete last index'),
+ 'lang_delete_last_statustext' => lang('delete
the last index'),
+ 'delete_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit_item&delete_last=1&agreement_id='
. $agreement_id . '&id=' . $id),
+
+ );
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('agreement') . ': ' . ($values['id']?lang('edit item') . ' ' .
$agreement['name']:lang('add item') . ' ' . $agreement['name']);
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_item' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function view_item()
+ {
+ $agreement_id =
get_var('agreement_id',array('POST','GET'));
+ $id = get_var('id',array('POST','GET'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('agreement','attributes_view'));
+
+ $agreement =
$this->bo->read_single(array('agreement_id'=>$agreement_id));
+ $values =
$this->bo->read_single_item(array('agreement_id'=>$agreement_id,'id'=>$id));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiagreement.edit',
+ 'id' => $agreement_id
+ );
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ if($id)
+ {
+ $list =
$this->bo->read_prizing(array('agreement_id'=>$agreement_id,'activity_id'=>$id));
+ $activity_descr
=$this->bo->get_activity_descr($id);
+ }
+
+ $uicols = $this->bo->uicols;
+ $list =
$this->list_content($list,$uicols,$edit_item=True);
+ $content = $list['content'];
+ $table_header=$list['table_header'];
+
+ $data = array
+ (
+ 'activity_descr' =>
$activity_descr,
+ 'lang_descr' =>
lang('Descr'),
+ 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'edit_url' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_id' =>
lang('ID'),
+ 'value_id' =>
$values['id'],
+ 'value_num' =>
$values['num'],
+ 'value_agreement_id' =>
$agreement_id,
+ 'lang_category' =>
lang('category'),
+ 'lang_cancel' =>
lang('cancel'),
+ 'lang_cancel_statustext' =>
lang('Leave the agreement untouched and return back to the list'),
+
+ 'lang_dateformat'
=> lang(strtolower($dateformat)),
+ 'attributes_view'
=> $values['attributes'],
+
+ 'lang_agreement'
=> lang('Agreement'),
+ 'agreement_name'
=> $agreement['name'],
+
+ 'table_add'
=> $table_add,
+ 'values'
=> $content,
+ 'table_header'
=> $table_header,
+ 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
+
+ 'lang_m_cost'
=> lang('Material cost'),
+ 'value_m_cost'
=> $values['m_cost'],
+
+ 'lang_w_cost'
=> lang('Labour cost'),
+ 'value_w_cost'
=> $values['w_cost'],
+
+ 'lang_total_cost'
=> lang('Total cost'),
+ 'value_total_cost'
=> $values['total_cost'],
+ 'set_column'
=> $set_column,
+ );
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('agreement') . ': ' . lang('view item') . ' ' . $agreement['name'];
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view_item' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ function delete()
+ {
+ $attrib = get_var('attrib',array('POST','GET'));
+ $id = get_var('id',array('POST','GET'));
+ $agreement_id =
get_var('agreement_id',array('POST','GET'));
+ $delete = get_var('delete',array('POST'));
+ $confirm = get_var('confirm',array('POST'));
+
+
+ if($attrib)
+ {
+ $function='list_attribute';
+ }
+ else
+ {
+ $function='index';
+ }
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiagreement.'.$function,
+ 'role' => $this->role
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($agreement_id,$id,$attrib);
+// Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.delete&agreement_id='
. $agreement_id. '&id=' . $id . '&attrib=' . $attrib . '&role=' . $this->role),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('agreement');
+ $function_msg =
lang('delete') . ' ' . lang($this->role);
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+
+ function view()
+ {
+ $agreement_id = get_var('id',array('POST','GET'));
+ $config =
CreateObject('phpgwapi.config',$this->currentapp);
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('agreement','nextmatchs','attributes_view'));
+
+
+ $agreement =
$this->bo->read_single(array('agreement_id'=>$agreement_id));
+
+
+ if ($agreement_id)
+ {
+ $this->cat_id =
($agreement['cat_id']?$agreement['cat_id']:$this->cat_id);
+ $this->member_id =
($agreement['member_of']?$agreement['member_of']:$this->member_id);
+ $list = $this->bo->read_details($agreement_id);
+
+ $uicols = $this->bo->uicols;
+ $list =
$this->list_content($list,$uicols,$edit_item=False,$view_only=True);
+ $content = $list['content'];
+ $table_header=$list['table_header'];
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiagreement.index',
+ 'agreement_id' => $agreement_id,
+ );
+
+
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
+ 'vendor_id' =>
$agreement['vendor_id'],
+ 'vendor_name' =>
$agreement['vendor_name'],
+ 'type' =>
'view'));
+
+ $alarm_data=$this->bocommon->initiate_ui_alarm(array(
+
'acl_location'=>$this->acl2_location,
+ 'alarm_type'=> 'agreement',
+ 'type' => 'view',
+ 'text' => 'Email
notification',
+ 'times' => $times,
+ 'id' =>
$agreement_id,
+ 'method' => $method,
+ 'data' => $data,
+ 'account_id'=> $account_id
+ ));
+
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True,link_data => array()));
+
+ $link_file_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiagreement.view_file',
+ 'id'
=>$agreement_id
+ );
+
+
+ $config->read_repository();
+ $link_to_files = $config->config_data['files_url'];
+
+ $j = count($agreement['files']);
+ for ($i=0;$i<$j;$i++)
+ {
+
$agreement['files'][$i]['file_name']=urlencode($agreement['files'][$i]['name']);
+ }
+
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $link_data2 = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiagreement.view',
+ 'id' => $agreement_id,
+ );
+
+ $data = array
+ (
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($content),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data2),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+
+ 'alarm_data'
=> $alarm_data,
+ 'lang_alarm'
=> lang('Alarm'),
+ 'link_view_file'
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
+ 'link_to_files'
=> $link_to_files,
+ 'files'
=> $agreement['files'],
+ 'lang_files'
=> lang('files'),
+ 'lang_filename'
=> lang('Filename'),
+ 'lang_view_file_statustext' =>
lang('Klick to view file'),
+
+ 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_id'
=> lang('ID'),
+ 'value_agreement_id' =>
$agreement_id,
+ 'lang_category'
=> lang('category'),
+ 'lang_save'
=> lang('save'),
+ 'lang_cancel'
=> lang('done'),
+ 'lang_apply'
=> lang('apply'),
+ 'value_cat'
=> $agreement['cat'],
+ 'lang_cancel_statustext' =>
lang('return back to the list'),
+ 'cat_list'
=> $this->bo->select_category_list('select',$this->cat_id),
+
+ 'lang_member_of'
=> lang('member of'),
+ 'member_of_name'
=> 'member_id',
+ 'member_of_list'
=> $member_of_data['cat_list'],
+
+ 'lang_dateformat'
=> lang(strtolower($dateformat)),
+ 'attributes_view'
=> $agreement['attributes'],
+ 'dateformat'
=> $dateformat,
+
+ 'lang_start_date'
=> lang('start date'),
+ 'value_start_date'
=> $agreement['start_date'],
+
+ 'lang_end_date'
=> lang('end date'),
+ 'value_end_date'
=> $agreement['end_date'],
+
+ 'lang_termination_date' =>
lang('termination date'),
+ 'value_termination_date' =>
$agreement['termination_date'],
+
+ 'vendor_data'
=> $vendor_data,
+ 'lang_name'
=> lang('name'),
+ 'value_name'
=> $agreement['name'],
+ 'lang_descr'
=> lang('descr'),
+ 'value_descr'
=> $agreement['descr'],
+ 'table_add'
=> $table_add,
+ 'values'
=> $content,
+ 'table_header'
=> $table_header,
+ 'lang_agreement_group' =>
lang('Agreement group'),
+ 'agreement_group_list' =>
$this->bo->get_agreement_group_list($agreement['group_id']),
+
+ 'lang_status'
=> lang('Status'),
+ 'status_list'
=> $this->bo->select_status_list('select',$agreement['status']),
+ );
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('agreement') . ': ' . lang('view');
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ function list_attribute()
+ {
+ $id = get_var('id',array('POST','GET'));
+ $resort = get_var('resort',array('POST','GET'));
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array(
+ 'agreement',
+ 'nextmatchs',
+
'search_field'));
+
+ if($resort)
+ {
+
$this->bo->resort_attrib(array('resort'=>$resort,'id'=>$id));
+ }
+
+ $attrib_list = $this->bo->read_attrib();
+
+ while (is_array($attrib_list) && list(,$attrib) =
each($attrib_list))
+ {
+ $content[] = array
+ (
+ 'name'
=> $attrib['name'],
+ 'type_name'
=> $attrib['type_name'],
+ 'datatype'
=> $attrib['datatype'],
+ 'column_name'
=> $attrib['column_name'],
+ 'input_text'
=> $attrib['input_text'],
+ 'sorting'
=> $attrib['attrib_sort'],
+ 'search'
=> $attrib['search'],
+ 'link_up'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.list_attribute&resort=up&id='
. $attrib['id'] . '&allrows=' . $this->allrows . '&role=' . $this->role),
+ 'link_down'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.list_attribute&resort=down&id='
. $attrib['id'] . '&allrows=' . $this->allrows . '&role=' . $this->role),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit_attrib&id='
. $attrib['id'] . '&role=' . $this->role),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.delete&id='
. $attrib['id'].'&attrib=true&role=' . $this->role),
+ 'lang_view_attribtext' =>
lang('view the attrib'),
+ 'lang_attribute_attribtext' =>
lang('attributes for the attrib'). ' ' . lang('location'),
+ 'lang_edit_attribtext' =>
lang('edit the attrib'),
+ 'lang_delete_attribtext' =>
lang('delete the attrib'),
+ 'text_attribute'
=> lang('Attributes'),
+ 'text_up'
=> lang('up'),
+ 'text_down'
=> lang('down'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+
+ //html_print_r($content);
+
+ $table_header[] = array
+ (
+ 'lang_descr' => lang('Descr'),
+ 'lang_datatype' => lang('Datatype'),
+ 'lang_sorting' => lang('sorting'),
+ 'lang_search' => lang('search'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_sorting' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'attrib_sort',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiagreement.list_attribute',
+
'allrows'=>$this->allrows,
+
'role' => $this->role)
+
)),
+
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'column_name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiagreement.list_attribute',
+
'allrows'=>$this->allrows,
+
'role' => $this->role)
+
)),
+ 'lang_name' => lang('Name'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_attribtext' => lang('add a attrib'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.edit_attrib&role='
. $this->role),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_attribtext' => lang('back to
admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php'),
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiagreement.list_attribute',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'query'
=>$this->query,
+ 'role' =>
$this->role
+
+ );
+
+ $data = array
+ (
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($attrib_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_attribtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_attribtext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_attrib' =>
$table_header,
+ 'values_attrib'
=> $content,
+ 'table_add2'
=> $table_add
+ );
+
+ $appname
= lang('agreement');
+ $function_msg =
lang('list attribute') . ': ' . lang($this->role);
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+ //$this->save_sessiondata();
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_attribute' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function edit_attrib()
+ {
+ $id =
get_var('id',array('POST','GET'));
+ $values = get_var('values',array('POST'));
+ // $GLOBALS['phpgw']->common->msgbox(lang('Altering
ColumnName OR Datatype - deletes your data in this Column'));
+ //html_print_r($values);
+
$GLOBALS['phpgw']->xslttpl->add_file(array('agreement','choice',));
+
+ if ($values['save'])
+ {
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+ $type_id =
$values['type_id'];
+
+ if (!$values['column_name'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Column name not entered!'));
+ }
+
+ if (!$values['input_text'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Input text not entered!'));
+ }
+ if (!$values['statustext'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Statustext not entered!'));
+ }
+
+ if (!$values['column_info']['type'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Datatype type not choosen!'));
+ }
+
+
if(!ctype_digit($values['column_info']['precision']))
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter precision as integer !'));
+
unset($values['column_info']['precision']);
+ }
+
+
if(!ctype_digit($values['column_info']['scale']))
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter scale as integer !'));
+ unset($values['column_info']['scale']);
+ }
+
+ if (!$values['column_info']['nullable'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Nullable not choosen!'));
+ }
+
+
+ if (!$receipt['error'])
+ {
+ $receipt =
$this->bo->save_attrib($values,$action);
+
+ if(!$id)
+ {
+ $id=$receipt['id'];
+ }
+ }
+ else
+ {
+ $receipt['error'][] = array('msg'
=> lang('Attribute has NOT been saved'));
+ }
+
+ }
+
+ if ($id)
+ {
+ $values = $this->bo->read_single_attrib($id);
+ $function_msg = lang('edit attribute') . ': ' .
lang($this->role);
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add attribute') . ': ' .
lang($this->role);
+ $action='add';
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiagreement.edit_attrib',
+ 'id' => $id,
+ 'role' => $this->role
+
+ );
+ //html_print_r($values);
+
+ if($values['column_info']['type']=='R' ||
$values['column_info']['type']=='CH' || $values['column_info']['type']=='LB')
+ {
+ $multiple_choice= True;
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'lang_choice' =>
lang('Choice'),
+ 'lang_new_value' =>
lang('New value'),
+ 'lang_new_value_statustext' => lang('New
value for mulitple choice'),
+ 'multiple_choice' =>
$multiple_choice,
+ 'value_choice' =>
$values['choice'],
+ 'lang_delete_value' =>
lang('Delete value'),
+ 'lang_value' =>
lang('value'),
+ 'lang_delete_choice_statustext'=> lang('Delete
this value from the list of multiple choice'),
+ 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiagreement.list_attribute&type_id='.$type_id
. '&role=' . $this->role),
+ 'lang_id'
=> lang('Attribute ID'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id'
=> $id,
+
+ 'lang_column_name'
=> lang('Column name'),
+ 'value_column_name'
=> $values['column_name'],
+ 'lang_column_name_statustext' => lang('enter
the name for the column'),
+
+ 'lang_input_text'
=> lang('input text'),
+ 'value_input_text'
=> $values['input_text'],
+ 'lang_input_name_statustext' => lang('enter
the input text for records'),
+
+ 'lang_id_attribtext' => lang('Enter
the attribute ID'),
+ 'lang_entity_statustext' => lang('Select
a agreement type'),
+
+ 'lang_statustext' =>
lang('Statustext'),
+ 'lang_statustext_attribtext'=> lang('Enter a
statustext for the inputfield in forms'),
+ 'value_statustext' =>
$values['statustext'],
+
+ 'lang_done_attribtext' => lang('Back
to the list'),
+ 'lang_save_attribtext' => lang('Save
the attribute'),
+
+ 'lang_datatype' =>
lang('Datatype'),
+ 'lang_datatype_statustext' => lang('Select
a datatype'),
+ 'lang_no_datatype' =>
lang('No datatype'),
+ 'datatype_list' =>
$this->bocommon->select_datatype($values['column_info']['type']),
+
+ 'lang_precision' =>
lang('Precision'),
+ 'lang_precision_statustext' => lang('enter
the record length'),
+ 'value_precision' =>
$values['column_info']['precision'],
+
+ 'lang_scale' =>
lang('scale'),
+ 'lang_scale_statustext' => lang('enter
the scale if type is decimal'),
+ 'value_scale' =>
$values['column_info']['scale'],
+
+ 'lang_default' =>
lang('default'),
+ 'lang_default_statustext' => lang('enter
the default value'),
+ 'value_default' =>
$values['column_info']['default'],
+
+ 'lang_nullable' =>
lang('Nullable'),
+ 'lang_nullable_statustext' => lang('Chose
if this column is nullable'),
+ 'lang_select_nullable' => lang('Select
nullable'),
+ 'nullable_list' =>
$this->bocommon->select_nullable($values['column_info']['nullable']),
+
+ 'value_list' =>
$values['list'],
+ 'lang_list'
=> lang('show in list'),
+ 'lang_list_statustext' => lang('check
to show this attribute in location list'),
+
+ 'value_search' =>
$values['search'],
+ 'lang_include_search' =>
lang('Include in search'),
+ 'lang_include_search_statustext'=> lang('check
to show this attribute in location list'),
+
+
+ );
+ //html_print_r($data);
+
+ $appname
= lang('agreement');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_attrib' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+ }
?>
\ No newline at end of file
Index: property/inc/class.uialarm.inc.php
diff -u property/inc/class.uialarm.inc.php:1.9
property/inc/class.uialarm.inc.php:1.10
--- property/inc/class.uialarm.inc.php:1.9 Thu May 12 21:26:28 2005
+++ property/inc/class.uialarm.inc.php Fri Jan 27 14:05:43 2006
@@ -1,474 +1,474 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.uialarm.inc.php,v 1.9 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uialarm
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
-
- var $public_functions = array
- (
- 'index' => True,
- 'view' => True,
- 'edit' => True,
- 'delete' => True
- );
-
- function uialarm()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- $this->bo =
CreateObject($this->currentapp.'.boalarm',True);
- $this->boasync =
CreateObject($this->currentapp.'.boasync');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
-
- $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->method_id = $this->bo->method_id;
- $this->allrows = $this->bo->allrows;
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' => $this->filter,
- 'method_id' => $this->method_id,
- 'this->allrows' => $this->allrows
- );
- $this->bo->save_sessiondata($data);
- }
-
- function index()
- {
- $GLOBALS['phpgw']->xslttpl->add_file(array('alarm',
-
'menu',
-
'receipt',
-
'search_field',
-
'nextmatchs'));
-
- $links = $this->menu->links();
-
- $receipt =
$GLOBALS['phpgw']->session->appsession('session_data','alarm_receipt');
-
$GLOBALS['phpgw']->session->appsession('session_data','alarm_receipt','');
- $values = get_var('values',array('POST'));
- if($values['delete_alarm'] && count($values['alarm'])):
- {
- $receipt =
$this->bo->delete_alarm('fm_async',$values['alarm']);
- }
- elseif(($values['enable_alarm'] ||
$values['disable_alarm']) && count($values['alarm'])):
- {
- $receipt =
$this->bo->enable_alarm('fm_async',$values['alarm'],$values['enable_alarm']);
- }
- elseif($values['test_cron']):
- {
- $this->bo->test_cron();
- }
- endif;
-
- $list = $this->bo->read();
-//_debug_array($list);
-
- while (is_array($list) && list(,$alarm) = each($list))
- {
- if(is_array($alarm['times']))
- {
- while (is_array($alarm['times']) &&
list($key,$value) = each($alarm['times']))
- {
- $times .=$key . ' => ' .$value.
' ';
- }
-
- }
- else
- {
- $times =
$GLOBALS['phpgw']->common->show_date($alarm['times']);
- }
- if(is_array($alarm['data']))
- {
- while (is_array($alarm['data']) &&
list($key,$value) = each($alarm['data']))
- {
- $data .=$key . ' => ' .$value .
' ';
- }
-
- }
-
- if (substr($alarm['id'],0,8)=='fm_async')
- {
- $link_edit
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uialarm.edit&async_id='
. urlencode($alarm['id']));
- $lang_edit_statustext =
lang('edit the alarm');
- $text_edit
= lang('edit');
- }
-
- $content[] = array
- (
- 'id'
=> $alarm['id'],
- 'next_run'
=> $GLOBALS['phpgw']->common->show_date($alarm['next']),
- 'method'
=> $alarm['method'],
- 'times'
=> $times,
- 'data'
=> $data,
- 'enabled'
=> $alarm['enabled'],
- 'user'
=> $alarm['user'],
- 'link_edit'
=> $link_edit,
- 'lang_edit_statustext' =>
$lang_edit_statustext,
- 'text_edit'
=> $text_edit
- );
- unset($alarm);
- unset($data);
- unset($times);
- unset($link_edit);
- unset($lang_edit_statustext);
- unset($text_edit);
- }
-
- $table_header = array
- (
- 'lang_next_run' => lang('Next run'),
- 'lang_times' => lang('Times'),
- 'lang_method' => lang('Method'),
- 'lang_user' => lang('User'),
- 'lang_data' => lang('Data'),
- 'lang_select' => lang('select'),
- 'lang_edit' => lang('edit'),
- 'lang_alarm_id' => lang('alarm id'),
- 'lang_enabled' => lang('enabled'),
- 'sort_user' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'account_lid',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uialarm.index',
-
'cat_id' =>
$this->cat_id,
-
'query'
=>$this->query,
-
'allrows'
=>$this->allrows)
-
)),
- 'sort_method' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'method',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uialarm.index',
-
'cat_id' =>
$this->cat_id,
-
'query'
=>$this->query,
-
'allrows'
=>$this->allrows)
-
)),
- 'sort_next_run' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'next',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uialarm.index',
-
'cat_id' =>
$this->cat_id,
-
'query'
=>$this->query,
-
'allrows'
=>$this->allrows)
-
)),
- 'sort_alarm_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uialarm.index',
-
'cat_id' =>
$this->cat_id,
-
'query'
=>$this->query,
-
'allrows'
=>$this->allrows)
-
))
- );
-
- $alter_alarm = array
- (
- 'lang_enable' => lang('Enable'),
- 'lang_disable' => lang('Disable'),
- 'lang_delete' => lang('Delete'),
- 'lang_test_cron' => lang('test cron')
- );
-
- $table_add = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_statustext' => lang('add a alarm'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uialarm.edit')
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uialarm.index',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'links'
=> $links,
- 'allow_allrows'
=> true,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the alarm belongs to. To do not use a category select
NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> '',//$this->bo->select_category_list('filter',$this->cat_id),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter)),
- 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add,
- 'alter_alarm'
=> $alter_alarm,
- );
- $this->save_sessiondata();
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('alarm') . ': ' . lang('list alarm');
-//_debug_array($data);
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function edit()
- {
- $method_id = get_var('method_id',array('POST'));
- $async_id =
urldecode(get_var('async_id',array('POST','GET')));
- $values = get_var('values',array('POST'));
-
- if($async_id)
- {
- $async_id_elements = explode(':',$async_id);
- $method_id = $async_id_elements[1];
- }
-
- $this->method_id =
($method_id?$method_id:$this->method_id);
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('alarm'));
-
-
- if ($values['save'] || $values['apply'])
- {
-
- $units = array(
- 'year',
- 'month',
- 'day',
- 'dow',
- 'hour',
- 'min');
-
- $times = array();
- foreach($units as $u)
- {
- if ($values[$u] !== '')
- {
- $times[$u] = $values[$u];
- }
- }
-
- if(!$receipt['error'])
- {
- $this->method_id =
($values['method_id']?$values['method_id']:$this->method_id);
-
- $values['alarm_id'] = $alarm_id;
-
-
$async=$this->boasync->read_single($this->method_id);
-//_debug_array($async);
- $data_set = unserialize($async['data']);
- $data_set['enabled'] = True;
- $data_set['times'] =
$times;
- $data_set['owner'] =
$this->account;
- $data_set['event_id'] =
$this->method_id;
- $data_set['id'] =
$async_id;
-
- $async_id =
$this->bo->save_alarm($alarm_type='fm_async',$entity_id=$this->method_id,$alarm=$data_set,$async['name']);
-
- if ($values['save'])
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','alarm_receipt',$receipt);
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uialarm.index');
- }
- }
- }
-
- if ($values['cancel'])
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uialarm.index');
- }
-
- if ($async_id)
- {
- $alarm =
$this->bo->read_alarm($alarm_type='fm_async',$async_id);
- $this->method_id =
($alarm['event_id']?$alarm['event_id']:$this->method_id);
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uialarm.edit',
- 'async_id' => $async_id
- );
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
-//_debug_array($alarm);
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'abook_data'
=> $abook_data,
- 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_async_id'
=> lang('ID'),
- 'value_async_id'
=> $async_id,
- 'lang_method'
=> lang('method'),
- 'lang_save'
=> lang('save'),
- 'lang_cancel'
=> lang('cancel'),
- 'lang_apply'
=> lang('apply'),
- 'lang_apply_statustext' =>
lang('Apply the values'),
- 'lang_cancel_statustext' =>
lang('Leave the owner untouched and return back to the list'),
- 'lang_save_statustext' =>
lang('Save the owner and return back to the list'),
- 'lang_no_method'
=> lang('no method'),
- 'lang_method_statustext' =>
lang('Select the method for this times service'),
- 'method_list'
=> $this->bo->select_method_list($this->method_id),
- 'lang_timing'
=> lang('timing'),
- 'lang_year'
=> lang('year'),
- 'value_year'
=> $alarm['times']['year'],
- 'lang_month'
=> lang('month'),
- 'value_month'
=> $alarm['times']['month'],
- 'lang_day'
=> lang('day'),
- 'value_day'
=> $alarm['times']['day'],
- 'lang_dow'
=> lang('Day of week (0-6, 0=Sun)'),
- 'value_dow'
=> $alarm['times']['dow'],
- 'lang_hour'
=> lang('hour'),
- 'value_hour'
=> $alarm['times']['hour'],
- 'lang_minute'
=> lang('minute'),
- 'value_minute'
=> $alarm['times']['min'],
- 'lang_data'
=> lang('data'),
- 'lang_data_statustext' =>
lang('inputdata for the method')
- );
-//_debug_array($data);
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('async') . ': ' . ($async_id?lang('edit timer'):lang('add timer'));
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- /**
- * @todo remove or alter this function
- */
-
- function delete()
- {
- $owner_id =
get_var('owner_id',array('POST','GET'));
- $delete = get_var('delete',array('POST'));
- $confirm = get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiowner.index'
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($owner_id);
-// Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
-
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiowner.delete&owner_id='
. $owner_id),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('owner');
- $function_msg =
lang('delete owner');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
-
- function view()
- {
- $owner_id = get_var('owner_id',array('GET'));
- $action = get_var('action',array('GET'));
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('owner') . ': ' . lang('view owner');
-
- $GLOBALS['phpgw']->xslttpl->add_file('owner');
-
- $owner = $this->bo->read_single($owner_id);
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiowner.index'),
- 'lang_name' => lang('name'),
- 'lang_category' => lang('category'),
- 'lang_time_created' => lang('time created'),
- 'lang_done' => lang('done'),
- 'value_name' => $owner['name'],
- 'value_cat' =>
$this->bo->read_category_name($owner['cat_id']),
- 'value_date' =>
$GLOBALS['phpgw']->common->show_date($owner['entry_date'])
- );
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.uialarm.inc.php,v 1.10 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uialarm
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'view' => True,
+ 'edit' => True,
+ 'delete' => True
+ );
+
+ function uialarm()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $this->bo =
CreateObject($this->currentapp.'.boalarm',True);
+ $this->boasync =
CreateObject($this->currentapp.'.boasync');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+
+ $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->method_id = $this->bo->method_id;
+ $this->allrows = $this->bo->allrows;
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' => $this->filter,
+ 'method_id' => $this->method_id,
+ 'this->allrows' => $this->allrows
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function index()
+ {
+ $GLOBALS['phpgw']->xslttpl->add_file(array('alarm',
+
'menu',
+
'receipt',
+
'search_field',
+
'nextmatchs'));
+
+ $links = $this->menu->links();
+
+ $receipt =
$GLOBALS['phpgw']->session->appsession('session_data','alarm_receipt');
+
$GLOBALS['phpgw']->session->appsession('session_data','alarm_receipt','');
+ $values = get_var('values',array('POST'));
+ if($values['delete_alarm'] && count($values['alarm'])):
+ {
+ $receipt =
$this->bo->delete_alarm('fm_async',$values['alarm']);
+ }
+ elseif(($values['enable_alarm'] ||
$values['disable_alarm']) && count($values['alarm'])):
+ {
+ $receipt =
$this->bo->enable_alarm('fm_async',$values['alarm'],$values['enable_alarm']);
+ }
+ elseif($values['test_cron']):
+ {
+ $this->bo->test_cron();
+ }
+ endif;
+
+ $list = $this->bo->read();
+//_debug_array($list);
+
+ while (is_array($list) && list(,$alarm) = each($list))
+ {
+ if(is_array($alarm['times']))
+ {
+ while (is_array($alarm['times']) &&
list($key,$value) = each($alarm['times']))
+ {
+ $times .=$key . ' => ' .$value.
' ';
+ }
+
+ }
+ else
+ {
+ $times =
$GLOBALS['phpgw']->common->show_date($alarm['times']);
+ }
+ if(is_array($alarm['data']))
+ {
+ while (is_array($alarm['data']) &&
list($key,$value) = each($alarm['data']))
+ {
+ $data .=$key . ' => ' .$value .
' ';
+ }
+
+ }
+
+ if (substr($alarm['id'],0,8)=='fm_async')
+ {
+ $link_edit
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uialarm.edit&async_id='
. urlencode($alarm['id']));
+ $lang_edit_statustext =
lang('edit the alarm');
+ $text_edit
= lang('edit');
+ }
+
+ $content[] = array
+ (
+ 'id'
=> $alarm['id'],
+ 'next_run'
=> $GLOBALS['phpgw']->common->show_date($alarm['next']),
+ 'method'
=> $alarm['method'],
+ 'times'
=> $times,
+ 'data'
=> $data,
+ 'enabled'
=> $alarm['enabled'],
+ 'user'
=> $alarm['user'],
+ 'link_edit'
=> $link_edit,
+ 'lang_edit_statustext' =>
$lang_edit_statustext,
+ 'text_edit'
=> $text_edit
+ );
+ unset($alarm);
+ unset($data);
+ unset($times);
+ unset($link_edit);
+ unset($lang_edit_statustext);
+ unset($text_edit);
+ }
+
+ $table_header = array
+ (
+ 'lang_next_run' => lang('Next run'),
+ 'lang_times' => lang('Times'),
+ 'lang_method' => lang('Method'),
+ 'lang_user' => lang('User'),
+ 'lang_data' => lang('Data'),
+ 'lang_select' => lang('select'),
+ 'lang_edit' => lang('edit'),
+ 'lang_alarm_id' => lang('alarm id'),
+ 'lang_enabled' => lang('enabled'),
+ 'sort_user' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'account_lid',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uialarm.index',
+
'cat_id' =>
$this->cat_id,
+
'query'
=>$this->query,
+
'allrows'
=>$this->allrows)
+
)),
+ 'sort_method' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'method',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uialarm.index',
+
'cat_id' =>
$this->cat_id,
+
'query'
=>$this->query,
+
'allrows'
=>$this->allrows)
+
)),
+ 'sort_next_run' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'next',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uialarm.index',
+
'cat_id' =>
$this->cat_id,
+
'query'
=>$this->query,
+
'allrows'
=>$this->allrows)
+
)),
+ 'sort_alarm_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uialarm.index',
+
'cat_id' =>
$this->cat_id,
+
'query'
=>$this->query,
+
'allrows'
=>$this->allrows)
+
))
+ );
+
+ $alter_alarm = array
+ (
+ 'lang_enable' => lang('Enable'),
+ 'lang_disable' => lang('Disable'),
+ 'lang_delete' => lang('Delete'),
+ 'lang_test_cron' => lang('test cron')
+ );
+
+ $table_add = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_statustext' => lang('add a alarm'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uialarm.edit')
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uialarm.index',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'links'
=> $links,
+ 'allow_allrows'
=> true,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the alarm belongs to. To do not use a category select
NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> '',//$this->bo->select_category_list('filter',$this->cat_id),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter)),
+ 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add,
+ 'alter_alarm'
=> $alter_alarm,
+ );
+ $this->save_sessiondata();
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('alarm') . ': ' . lang('list alarm');
+//_debug_array($data);
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function edit()
+ {
+ $method_id = get_var('method_id',array('POST'));
+ $async_id =
urldecode(get_var('async_id',array('POST','GET')));
+ $values = get_var('values',array('POST'));
+
+ if($async_id)
+ {
+ $async_id_elements = explode(':',$async_id);
+ $method_id = $async_id_elements[1];
+ }
+
+ $this->method_id =
($method_id?$method_id:$this->method_id);
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('alarm'));
+
+
+ if ($values['save'] || $values['apply'])
+ {
+
+ $units = array(
+ 'year',
+ 'month',
+ 'day',
+ 'dow',
+ 'hour',
+ 'min');
+
+ $times = array();
+ foreach($units as $u)
+ {
+ if ($values[$u] !== '')
+ {
+ $times[$u] = $values[$u];
+ }
+ }
+
+ if(!$receipt['error'])
+ {
+ $this->method_id =
($values['method_id']?$values['method_id']:$this->method_id);
+
+ $values['alarm_id'] = $alarm_id;
+
+
$async=$this->boasync->read_single($this->method_id);
+//_debug_array($async);
+ $data_set = unserialize($async['data']);
+ $data_set['enabled'] = True;
+ $data_set['times'] =
$times;
+ $data_set['owner'] =
$this->account;
+ $data_set['event_id'] =
$this->method_id;
+ $data_set['id'] =
$async_id;
+
+ $async_id =
$this->bo->save_alarm($alarm_type='fm_async',$entity_id=$this->method_id,$alarm=$data_set,$async['name']);
+
+ if ($values['save'])
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','alarm_receipt',$receipt);
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uialarm.index');
+ }
+ }
+ }
+
+ if ($values['cancel'])
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uialarm.index');
+ }
+
+ if ($async_id)
+ {
+ $alarm =
$this->bo->read_alarm($alarm_type='fm_async',$async_id);
+ $this->method_id =
($alarm['event_id']?$alarm['event_id']:$this->method_id);
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uialarm.edit',
+ 'async_id' => $async_id
+ );
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+//_debug_array($alarm);
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'abook_data'
=> $abook_data,
+ 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_async_id'
=> lang('ID'),
+ 'value_async_id'
=> $async_id,
+ 'lang_method'
=> lang('method'),
+ 'lang_save'
=> lang('save'),
+ 'lang_cancel'
=> lang('cancel'),
+ 'lang_apply'
=> lang('apply'),
+ 'lang_apply_statustext' =>
lang('Apply the values'),
+ 'lang_cancel_statustext' =>
lang('Leave the owner untouched and return back to the list'),
+ 'lang_save_statustext' =>
lang('Save the owner and return back to the list'),
+ 'lang_no_method'
=> lang('no method'),
+ 'lang_method_statustext' =>
lang('Select the method for this times service'),
+ 'method_list'
=> $this->bo->select_method_list($this->method_id),
+ 'lang_timing'
=> lang('timing'),
+ 'lang_year'
=> lang('year'),
+ 'value_year'
=> $alarm['times']['year'],
+ 'lang_month'
=> lang('month'),
+ 'value_month'
=> $alarm['times']['month'],
+ 'lang_day'
=> lang('day'),
+ 'value_day'
=> $alarm['times']['day'],
+ 'lang_dow'
=> lang('Day of week (0-6, 0=Sun)'),
+ 'value_dow'
=> $alarm['times']['dow'],
+ 'lang_hour'
=> lang('hour'),
+ 'value_hour'
=> $alarm['times']['hour'],
+ 'lang_minute'
=> lang('minute'),
+ 'value_minute'
=> $alarm['times']['min'],
+ 'lang_data'
=> lang('data'),
+ 'lang_data_statustext' =>
lang('inputdata for the method')
+ );
+//_debug_array($data);
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('async') . ': ' . ($async_id?lang('edit timer'):lang('add timer'));
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ /**
+ * @todo remove or alter this function
+ */
+
+ function delete()
+ {
+ $owner_id =
get_var('owner_id',array('POST','GET'));
+ $delete = get_var('delete',array('POST'));
+ $confirm = get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiowner.index'
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($owner_id);
+// Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiowner.delete&owner_id='
. $owner_id),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('owner');
+ $function_msg =
lang('delete owner');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+
+ function view()
+ {
+ $owner_id = get_var('owner_id',array('GET'));
+ $action = get_var('action',array('GET'));
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('owner') . ': ' . lang('view owner');
+
+ $GLOBALS['phpgw']->xslttpl->add_file('owner');
+
+ $owner = $this->bo->read_single($owner_id);
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiowner.index'),
+ 'lang_name' => lang('name'),
+ 'lang_category' => lang('category'),
+ 'lang_time_created' => lang('time created'),
+ 'lang_done' => lang('done'),
+ 'value_name' => $owner['name'],
+ 'value_cat' =>
$this->bo->read_category_name($owner['cat_id']),
+ 'value_date' =>
$GLOBALS['phpgw']->common->show_date($owner['entry_date'])
+ );
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+ }
+?>
Index: property/inc/class.uiasync.inc.php
diff -u property/inc/class.uiasync.inc.php:1.9
property/inc/class.uiasync.inc.php:1.10
--- property/inc/class.uiasync.inc.php:1.9 Thu May 12 21:26:28 2005
+++ property/inc/class.uiasync.inc.php Fri Jan 27 14:05:43 2006
@@ -1,314 +1,314 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.uiasync.inc.php,v 1.9 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uiasync
- {
- var $grants;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'index' => True,
- 'view' => True,
- 'edit' => True,
- 'delete' => True
- );
-
- function uiasync()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bo =
CreateObject($this->currentapp.'.boasync',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->start =
$this->bo->start;
- $this->query =
$this->bo->query;
- $this->sort =
$this->bo->sort;
- $this->order =
$this->bo->order;
- $this->allrows =
$this->bo->allrows;
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'allrows' => $this->allrows,
- );
- $this->bo->save_sessiondata($data);
- }
-
- function index()
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('async','nextmatchs',
-
'search_field'));
-
- $method_list = $this->bo->read();
-
- while (is_array($method_list) && list(,$method) =
each($method_list))
- {
- $data_set = unserialize($method['data']);
-
- $method_data=array();
- while (is_array($data_set) && list($key,$value)
= each($data_set))
- {
-
- $method_data[] = $key . '=' . $value;
- }
-
-
- $content[] = array
- (
- 'id'
=> $method['id'],
- 'name'
=> $method['name'],
- 'first'
=> $method['descr'],
- 'data'
=> @implode (',',$method_data),
- 'link_run'
=> $GLOBALS['phpgw']->link('/index.php','menuaction='.$method['name'] .
'&' . @implode ('&',$method_data)),
- 'link_schedule'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uialarm.edit&method_id='
. $method['id']),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiasync.edit&id='
. $method['id']),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiasync.delete&id='
. $method['id']),
- 'lang_schedule_statustext'=>
lang('schedule the method'),
- 'lang_run_statustext' => lang('Run
the method now'),
- 'lang_view_statustext' => lang('view
the method'),
- 'lang_edit_statustext' => lang('edit
the method'),
- 'lang_delete_statustext' =>
lang('delete the method'),
- 'text_schedule'
=> lang('Schedule'),
- 'text_run'
=> lang('Run Now'),
- 'text_view'
=> lang('view'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
-
-//_debug_array($content);
-
- $table_header[] = array
- (
-
- 'lang_descr' => lang('Descr'),
- 'lang_data' => lang('Data'),
- 'lang_schedule' => lang('Schedule'),
- 'lang_run' => lang('Run
Now'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiasync.index')
-
)),
- 'lang_id' => lang('method id'),
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiasync.index')
-
)),
- 'lang_name' => lang('Name'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_statustext' => lang('add a method'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiasync.edit'),
- 'lang_done' =>
lang('done'),
- 'lang_done_statustext' => lang('back to
admin'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php')
- );
-
-
- $data = array
- (
- 'allow_allrows'
=> False,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($method_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiasync.index'),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('method');
- $function_msg =
lang('list async method');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit()
- {
- $id = get_var('id',array('POST','GET'));
- $values =
get_var('values',array('POST'));
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('async'));
-
- if ($values['save'])
- {
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
- else
- {
- $id = $values['id'];
- }
-
- $data = str_replace(' '
,'',stripslashes($values['data']));
- $data = stripslashes($values['data']);
-
- $data= explode(",", $data);
-
- if(is_array($data))
- {
- foreach($data as $set)
- {
- $set= explode("=", $set);
- $data_set[$set[0]]=$set[1];
- }
- }
-
- if($values['data'])
- {
- $values['data']=serialize($data_set);
- }
-
- $receipt = $this->bo->save($values,$action);
- $id = $receipt['id'];
- }
-
- if ($id)
- {
- $method = $this->bo->read_single($id);
- $data_set = unserialize($method['data']);
- while (is_array($data_set) && list($key,$value)
= each($data_set))
- {
- $method_data[] = $key . '=' . $value;
- }
-
- $method_data= @implode (',',$method_data);
- $function_msg = lang('edit method');
- $action='edit';
- }
- else
- {
- $function_msg = lang('add method');
- $action='add';
- }
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiasync.edit',
- 'id' => $id
- );
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiasync.index'),
- 'lang_id'
=> lang('method ID'),
- 'lang_name'
=> lang('Name'),
- 'lang_descr'
=> lang('Descr'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_id'
=> $id,
- 'value_name'
=> $method['name'],
- 'lang_id_statustext' =>
lang('Enter the method ID'),
- 'lang_descr_statustext' => lang('Enter
a description the method'),
- 'lang_done_statustext' => lang('Back
to the list'),
- 'lang_save_statustext' => lang('Save
the method'),
- 'type_id'
=> $method['type_id'],
- 'location_code'
=> $method['location_code'],
- 'value_descr'
=> $method['descr'],
- 'value_data'
=> $method_data,
- 'lang_data'
=> lang('Data'),
- 'lang_data_statustext' =>
lang('Input data for the nethod'),
- );
-
- $appname
= lang('async method');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function delete()
- {
- $id = get_var('id',array('POST','GET'));
- $confirm =
get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiasync.index'
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($id);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiasync.delete&id='
. $id),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('async method');
- $function_msg =
lang('delete async method');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.uiasync.inc.php,v 1.10 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uiasync
+ {
+ var $grants;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'view' => True,
+ 'edit' => True,
+ 'delete' => True
+ );
+
+ function uiasync()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bo =
CreateObject($this->currentapp.'.boasync',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+
+ $this->start =
$this->bo->start;
+ $this->query =
$this->bo->query;
+ $this->sort =
$this->bo->sort;
+ $this->order =
$this->bo->order;
+ $this->allrows =
$this->bo->allrows;
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'allrows' => $this->allrows,
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function index()
+ {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('async','nextmatchs',
+
'search_field'));
+
+ $method_list = $this->bo->read();
+
+ while (is_array($method_list) && list(,$method) =
each($method_list))
+ {
+ $data_set = unserialize($method['data']);
+
+ $method_data=array();
+ while (is_array($data_set) && list($key,$value)
= each($data_set))
+ {
+
+ $method_data[] = $key . '=' . $value;
+ }
+
+
+ $content[] = array
+ (
+ 'id'
=> $method['id'],
+ 'name'
=> $method['name'],
+ 'first'
=> $method['descr'],
+ 'data'
=> @implode (',',$method_data),
+ 'link_run'
=> $GLOBALS['phpgw']->link('/index.php','menuaction='.$method['name'] .
'&' . @implode ('&',$method_data)),
+ 'link_schedule'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uialarm.edit&method_id='
. $method['id']),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiasync.edit&id='
. $method['id']),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiasync.delete&id='
. $method['id']),
+ 'lang_schedule_statustext'=>
lang('schedule the method'),
+ 'lang_run_statustext' => lang('Run
the method now'),
+ 'lang_view_statustext' => lang('view
the method'),
+ 'lang_edit_statustext' => lang('edit
the method'),
+ 'lang_delete_statustext' =>
lang('delete the method'),
+ 'text_schedule'
=> lang('Schedule'),
+ 'text_run'
=> lang('Run Now'),
+ 'text_view'
=> lang('view'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+
+//_debug_array($content);
+
+ $table_header[] = array
+ (
+
+ 'lang_descr' => lang('Descr'),
+ 'lang_data' => lang('Data'),
+ 'lang_schedule' => lang('Schedule'),
+ 'lang_run' => lang('Run
Now'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiasync.index')
+
)),
+ 'lang_id' => lang('method id'),
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiasync.index')
+
)),
+ 'lang_name' => lang('Name'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_statustext' => lang('add a method'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiasync.edit'),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_statustext' => lang('back to
admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php')
+ );
+
+
+ $data = array
+ (
+ 'allow_allrows'
=> False,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($method_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiasync.index'),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('method');
+ $function_msg =
lang('list async method');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit()
+ {
+ $id = get_var('id',array('POST','GET'));
+ $values =
get_var('values',array('POST'));
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('async'));
+
+ if ($values['save'])
+ {
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+ else
+ {
+ $id = $values['id'];
+ }
+
+ $data = str_replace(' '
,'',stripslashes($values['data']));
+ $data = stripslashes($values['data']);
+
+ $data= explode(",", $data);
+
+ if(is_array($data))
+ {
+ foreach($data as $set)
+ {
+ $set= explode("=", $set);
+ $data_set[$set[0]]=$set[1];
+ }
+ }
+
+ if($values['data'])
+ {
+ $values['data']=serialize($data_set);
+ }
+
+ $receipt = $this->bo->save($values,$action);
+ $id = $receipt['id'];
+ }
+
+ if ($id)
+ {
+ $method = $this->bo->read_single($id);
+ $data_set = unserialize($method['data']);
+ while (is_array($data_set) && list($key,$value)
= each($data_set))
+ {
+ $method_data[] = $key . '=' . $value;
+ }
+
+ $method_data= @implode (',',$method_data);
+ $function_msg = lang('edit method');
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add method');
+ $action='add';
+ }
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiasync.edit',
+ 'id' => $id
+ );
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiasync.index'),
+ 'lang_id'
=> lang('method ID'),
+ 'lang_name'
=> lang('Name'),
+ 'lang_descr'
=> lang('Descr'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id'
=> $id,
+ 'value_name'
=> $method['name'],
+ 'lang_id_statustext' =>
lang('Enter the method ID'),
+ 'lang_descr_statustext' => lang('Enter
a description the method'),
+ 'lang_done_statustext' => lang('Back
to the list'),
+ 'lang_save_statustext' => lang('Save
the method'),
+ 'type_id'
=> $method['type_id'],
+ 'location_code'
=> $method['location_code'],
+ 'value_descr'
=> $method['descr'],
+ 'value_data'
=> $method_data,
+ 'lang_data'
=> lang('Data'),
+ 'lang_data_statustext' =>
lang('Input data for the nethod'),
+ );
+
+ $appname
= lang('async method');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function delete()
+ {
+ $id = get_var('id',array('POST','GET'));
+ $confirm =
get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiasync.index'
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($id);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiasync.delete&id='
. $id),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('async method');
+ $function_msg =
lang('delete async method');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ }
+?>
Index: property/inc/class.uib_account.inc.php
diff -u property/inc/class.uib_account.inc.php:1.9
property/inc/class.uib_account.inc.php:1.10
--- property/inc/class.uib_account.inc.php:1.9 Thu May 12 21:26:28 2005
+++ property/inc/class.uib_account.inc.php Fri Jan 27 14:05:43 2006
@@ -1,321 +1,321 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.uib_account.inc.php,v 1.9 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uib_account
- {
- var $grants;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'index' => True,
- 'edit' => True,
- 'delete' => True
- );
-
- function uib_account()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- $this->bo =
CreateObject($this->currentapp.'.bob_account',true);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->menu =
CreateObject($this->currentapp.'.menu');
- $this->menu->sub ='invoice';
-
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
- $this->acl2_location = '.b_account';
- $this->acl_read =
$this->acl2->check('.b_account',1);
- $this->acl_add =
$this->acl2->check('.b_account',2);
- $this->acl_edit =
$this->acl2->check('.b_account',4);
- $this->acl_delete =
$this->acl2->check('.b_account',8);
-
- $this->start =
$this->bo->start;
- $this->query =
$this->bo->query;
- $this->sort =
$this->bo->sort;
- $this->order =
$this->bo->order;
- $this->allrows =
$this->bo->allrows;
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'allrows' => $this->allrows
- );
- $this->bo->save_sessiondata($data);
- }
-
- function index()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('b_account','nextmatchs','menu',
-
'search_field'));
-
- $links = $this->menu->links('b_account');
-
- $b_account_list = $this->bo->read($type);
-
- while (is_array($b_account_list) && list(,$b_account) =
each($b_account_list))
- {
- $words = split(' ',$b_account['descr']);
- $first = "$words[0] $words[1] $words[2]
$words[3]";
-
- if($this->acl_edit)
- {
- $link_edit
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uib_account.edit&id='
. $b_account['id']);
- }
-
- if($this->acl_delete)
- {
- $link_delete
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uib_account.delete&id='
. $b_account['id']);
- }
-
- $content[] = array
- (
- 'id'
=> $b_account['id'],
- 'first'
=> $first,
- 'link_edit'
=> $link_edit,
- 'link_delete'
=> $link_delete,
- 'lang_view_b_accounttext' =>
lang('view the budget account'),
- 'lang_edit_b_accounttext' =>
lang('edit the budget account'),
- 'lang_delete_b_accounttext' =>
lang('delete the budget account'),
- 'text_view'
=> lang('view'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
-
- }
-
-//_debug_array($content);
-
- $table_header[] = array
- (
-
- 'lang_descr' => lang('Descr'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uib_account.index')
-
)),
- 'lang_id' => lang('budget account'),
- );
-
- $table_add[] = array
- (
- 'lang_add'
=> lang('add'),
- 'lang_add_b_accounttext' => lang('add a
budget account'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uib_account.edit'),
- 'lang_done'
=> lang('done'),
- 'lang_done_b_accounttext' => lang('back
to admin'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php')
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
-
- $data = array
- (
- 'links'
=> $links,
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($b_account_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uib_account.index&type='.$type),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_b_accounttext' =>
lang('Enter the search string. To show all entries, empty this field and press
the SUBMIT button again'),
- 'lang_searchbutton_b_accounttext' =>
lang('Submit the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('budget account');
- $function_msg =
lang('list budget account');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit()
- {
- if(!$this->acl_add && !$this->acl_edit)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
- }
-
- $id = get_var('id',array('POST','GET'));
- $values =
get_var('values',array('POST'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('b_account'));
-
- if ($values['save'])
- {
- if(!$id && !ctype_digit($values['id']))
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter an integer !'));
- unset($values['id']);
- }
-
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
- else
- {
- $id = $values['id'];
- }
-
- if(!$receipt['error'])
- {
- $receipt =
$this->bo->save($values,$action);
- }
- }
-
- if ($id)
- {
- $b_account = $this->bo->read_single($id);
- $function_msg = lang('edit budget account');
- $action='edit';
- }
- else
- {
- $function_msg = lang('add budget account');
- $action='add';
- }
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uib_account.edit',
- 'id' => $id
- );
-//_debug_array($link_data);
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uib_account.index&type='.$type),
- 'lang_id'
=> lang('budget account'),
- 'lang_descr'
=> lang('Descr'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_id'
=> $id,
- 'lang_group'
=> lang('group'),
- 'value_group'
=> $b_account['group'],
- 'lang_id_b_accounttext' =>
lang('Enter the budget account'),
- 'lang_descr_b_accounttext' =>
lang('Enter a description the budget account'),
- 'lang_done_b_accounttext' =>
lang('Back to the list'),
- 'lang_save_b_accounttext' =>
lang('Save the budget account'),
- 'value_descr'
=> $b_account['descr'],
- 'lang_responsible'
=> lang('Responsible'),
- 'lang_user_statustext' =>
lang('Select the budget responsible'),
- 'select_user_name'
=> 'values[responsible]',
- 'lang_no_user'
=> lang('Select responsible'),
- 'user_list'
=>
$this->bocommon->get_user_list_right2('select',128,$b_account['responsible'],'.invoice'),
-
- );
-
- $appname
= lang('budget account');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function delete()
- {
- if(!$this->acl_delete)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
- }
-
- $id = get_var('id',array('POST','GET'));
- $confirm =
get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uib_account.index'
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($id);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uib_account.delete&id='
. $id),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_b_accounttext' => lang('Delete
the entry'),
- 'lang_no_b_accounttext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('budget account');
- $function_msg =
lang('delete budget account');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.uib_account.inc.php,v 1.10 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uib_account
+ {
+ var $grants;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'edit' => True,
+ 'delete' => True
+ );
+
+ function uib_account()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $this->bo =
CreateObject($this->currentapp.'.bob_account',true);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+ $this->menu->sub ='invoice';
+
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+ $this->acl2_location = '.b_account';
+ $this->acl_read =
$this->acl2->check('.b_account',1);
+ $this->acl_add =
$this->acl2->check('.b_account',2);
+ $this->acl_edit =
$this->acl2->check('.b_account',4);
+ $this->acl_delete =
$this->acl2->check('.b_account',8);
+
+ $this->start =
$this->bo->start;
+ $this->query =
$this->bo->query;
+ $this->sort =
$this->bo->sort;
+ $this->order =
$this->bo->order;
+ $this->allrows =
$this->bo->allrows;
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'allrows' => $this->allrows
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function index()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('b_account','nextmatchs','menu',
+
'search_field'));
+
+ $links = $this->menu->links('b_account');
+
+ $b_account_list = $this->bo->read($type);
+
+ while (is_array($b_account_list) && list(,$b_account) =
each($b_account_list))
+ {
+ $words = split(' ',$b_account['descr']);
+ $first = "$words[0] $words[1] $words[2]
$words[3]";
+
+ if($this->acl_edit)
+ {
+ $link_edit
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uib_account.edit&id='
. $b_account['id']);
+ }
+
+ if($this->acl_delete)
+ {
+ $link_delete
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uib_account.delete&id='
. $b_account['id']);
+ }
+
+ $content[] = array
+ (
+ 'id'
=> $b_account['id'],
+ 'first'
=> $first,
+ 'link_edit'
=> $link_edit,
+ 'link_delete'
=> $link_delete,
+ 'lang_view_b_accounttext' =>
lang('view the budget account'),
+ 'lang_edit_b_accounttext' =>
lang('edit the budget account'),
+ 'lang_delete_b_accounttext' =>
lang('delete the budget account'),
+ 'text_view'
=> lang('view'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+
+ }
+
+//_debug_array($content);
+
+ $table_header[] = array
+ (
+
+ 'lang_descr' => lang('Descr'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uib_account.index')
+
)),
+ 'lang_id' => lang('budget account'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add'
=> lang('add'),
+ 'lang_add_b_accounttext' => lang('add a
budget account'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uib_account.edit'),
+ 'lang_done'
=> lang('done'),
+ 'lang_done_b_accounttext' => lang('back
to admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php')
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+
+ $data = array
+ (
+ 'links'
=> $links,
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($b_account_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uib_account.index&type='.$type),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_b_accounttext' =>
lang('Enter the search string. To show all entries, empty this field and press
the SUBMIT button again'),
+ 'lang_searchbutton_b_accounttext' =>
lang('Submit the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('budget account');
+ $function_msg =
lang('list budget account');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit()
+ {
+ if(!$this->acl_add && !$this->acl_edit)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
+ }
+
+ $id = get_var('id',array('POST','GET'));
+ $values =
get_var('values',array('POST'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('b_account'));
+
+ if ($values['save'])
+ {
+ if(!$id && !ctype_digit($values['id']))
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter an integer !'));
+ unset($values['id']);
+ }
+
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+ else
+ {
+ $id = $values['id'];
+ }
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$this->bo->save($values,$action);
+ }
+ }
+
+ if ($id)
+ {
+ $b_account = $this->bo->read_single($id);
+ $function_msg = lang('edit budget account');
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add budget account');
+ $action='add';
+ }
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uib_account.edit',
+ 'id' => $id
+ );
+//_debug_array($link_data);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uib_account.index&type='.$type),
+ 'lang_id'
=> lang('budget account'),
+ 'lang_descr'
=> lang('Descr'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id'
=> $id,
+ 'lang_group'
=> lang('group'),
+ 'value_group'
=> $b_account['group'],
+ 'lang_id_b_accounttext' =>
lang('Enter the budget account'),
+ 'lang_descr_b_accounttext' =>
lang('Enter a description the budget account'),
+ 'lang_done_b_accounttext' =>
lang('Back to the list'),
+ 'lang_save_b_accounttext' =>
lang('Save the budget account'),
+ 'value_descr'
=> $b_account['descr'],
+ 'lang_responsible'
=> lang('Responsible'),
+ 'lang_user_statustext' =>
lang('Select the budget responsible'),
+ 'select_user_name'
=> 'values[responsible]',
+ 'lang_no_user'
=> lang('Select responsible'),
+ 'user_list'
=>
$this->bocommon->get_user_list_right2('select',128,$b_account['responsible'],'.invoice'),
+
+ );
+
+ $appname
= lang('budget account');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function delete()
+ {
+ if(!$this->acl_delete)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
+ }
+
+ $id = get_var('id',array('POST','GET'));
+ $confirm =
get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uib_account.index'
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($id);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uib_account.delete&id='
. $id),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_b_accounttext' => lang('Delete
the entry'),
+ 'lang_no_b_accounttext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('budget account');
+ $function_msg =
lang('delete budget account');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ }
+?>
Index: property/inc/class.uicategory.inc.php
diff -u property/inc/class.uicategory.inc.php:1.8
property/inc/class.uicategory.inc.php:1.9
--- property/inc/class.uicategory.inc.php:1.8 Thu May 12 21:26:28 2005
+++ property/inc/class.uicategory.inc.php Fri Jan 27 14:05:43 2006
@@ -1,290 +1,290 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.uicategory.inc.php,v 1.8 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uicategory
- {
- var $grants;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'index' => True,
- 'view' => True,
- 'edit' => True,
- 'delete' => True
- );
-
- function uicategory()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bo =
CreateObject($this->currentapp.'.bocategory',true);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->start =
$this->bo->start;
- $this->query =
$this->bo->query;
- $this->sort =
$this->bo->sort;
- $this->order =
$this->bo->order;
- $this->allrows =
$this->bo->allrows;
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'allrows' => $this->allrows
- );
- $this->bo->save_sessiondata($data);
- }
-
- function index()
- {
- $type = get_var('type',array('POST','GET'));
- $type_id =
get_var('type_id',array('POST','GET'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('category','nextmatchs',
-
'search_field'));
-
- $category_list = $this->bo->read($type,$type_id);
-
- while (is_array($category_list) && list(,$category) =
each($category_list))
- {
- $words = split(' ',$category['descr']);
- $first = "$words[0] $words[1] $words[2]
$words[3]";
-
- $content[] = array
- (
- 'id'
=> $category['id'],
- 'first'
=> $first,
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicategory.edit&id='
. $category['id'].'&type='.$type . '&type_id=' . $type_id),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicategory.delete&id='
. $category['id'].'&type='.$type . '&type_id=' . $type_id),
- 'lang_view_categorytext' =>
lang('view the category'),
- 'lang_edit_categorytext' =>
lang('edit the category'),
- 'lang_delete_categorytext' =>
lang('delete the category'),
- 'text_view'
=> lang('view'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
-
-//_debug_array($content);
-
- $table_header[] = array
- (
-
- 'lang_descr' => lang('Descr'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uicategory.index',
-
'type' =>$type,
-
'type_id' => $type_id)
-
)),
- 'lang_id' => lang('category id'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_categorytext' => lang('add a
category'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicategory.edit&type='.$type
. '&type_id=' . $type_id),
- 'lang_done' =>
lang('done'),
- 'lang_done_categorytext' => lang('back
to admin'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php')
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
-
- $data = array
- (
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($category_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicategory.index&type='.$type
. '&type_id=' . $type_id),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_categorytext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_categorytext' =>
lang('Submit the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang($type). ' ' . $type_id;
-;
- $function_msg =
lang('list %1 category',$type);
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit()
- {
- $type = get_var('type',array('POST','GET'));
- $type_id =
get_var('type_id',array('POST','GET'));
- $id = get_var('id',array('POST','GET'));
- $values =
get_var('values',array('POST'));
-
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('category'));
-
- if ($values['save'])
- {
- if(!$id && !ctype_digit($values['id']))
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter an integer !'));
- unset($values['id']);
- }
-
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
- else
- {
- $id = $values['id'];
- }
-
- if(!$receipt['error'])
- {
- $receipt =
$this->bo->save($values,$action,$type,$type_id);
- }
- }
-
- if ($id)
- {
- $category =
$this->bo->read_single($id,$type,$type_id);
- $function_msg = lang('edit category');
- $action='edit';
- }
- else
- {
- $function_msg = lang('add category');
- $action='add';
- }
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uicategory.edit',
- 'id' => $id,
- 'type' => $type,
- 'type_id' => $type_id
- );
-//_debug_array($link_data);
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicategory.index&type='.$type
. '&type_id=' . $type_id),
- 'lang_id' =>
lang('category ID'),
- 'lang_descr'
=> lang('Descr'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_id' => $id,
- 'lang_id_categorytext' => lang('Enter the
category ID'),
- 'lang_descr_categorytext'
=> lang('Enter a description the category'),
- 'lang_done_categorytext'
=> lang('Back to the list'),
- 'lang_save_categorytext'
=> lang('Save the category'),
- 'type_id' =>
$category['type_id'],
- 'value_descr'
=> $category['descr']
- );
-
- $appname
= lang($type). ' ' . $type_id;
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function delete()
- {
- $type = get_var('type',array('POST','GET'));
- $type_id =
get_var('type_id',array('POST','GET'));
- $id = get_var('id',array('POST','GET'));
- $confirm =
get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uicategory.index',
- 'type' => $type,
- 'type_id' => $type_id
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($id,$type,$type_id);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicategory.delete&id='
. $id.'&type='.$type . '&type_id=' . $type_id),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_categorytext' => lang('Delete the
entry'),
- 'lang_no_categorytext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang($type). ' ' . $type_id;
- $function_msg =
lang('delete '.$type.' category');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.uicategory.inc.php,v 1.9 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uicategory
+ {
+ var $grants;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'view' => True,
+ 'edit' => True,
+ 'delete' => True
+ );
+
+ function uicategory()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bo =
CreateObject($this->currentapp.'.bocategory',true);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+
+ $this->start =
$this->bo->start;
+ $this->query =
$this->bo->query;
+ $this->sort =
$this->bo->sort;
+ $this->order =
$this->bo->order;
+ $this->allrows =
$this->bo->allrows;
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'allrows' => $this->allrows
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function index()
+ {
+ $type = get_var('type',array('POST','GET'));
+ $type_id =
get_var('type_id',array('POST','GET'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('category','nextmatchs',
+
'search_field'));
+
+ $category_list = $this->bo->read($type,$type_id);
+
+ while (is_array($category_list) && list(,$category) =
each($category_list))
+ {
+ $words = split(' ',$category['descr']);
+ $first = "$words[0] $words[1] $words[2]
$words[3]";
+
+ $content[] = array
+ (
+ 'id'
=> $category['id'],
+ 'first'
=> $first,
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicategory.edit&id='
. $category['id'].'&type='.$type . '&type_id=' . $type_id),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicategory.delete&id='
. $category['id'].'&type='.$type . '&type_id=' . $type_id),
+ 'lang_view_categorytext' =>
lang('view the category'),
+ 'lang_edit_categorytext' =>
lang('edit the category'),
+ 'lang_delete_categorytext' =>
lang('delete the category'),
+ 'text_view'
=> lang('view'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+
+//_debug_array($content);
+
+ $table_header[] = array
+ (
+
+ 'lang_descr' => lang('Descr'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uicategory.index',
+
'type' =>$type,
+
'type_id' => $type_id)
+
)),
+ 'lang_id' => lang('category id'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_categorytext' => lang('add a
category'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicategory.edit&type='.$type
. '&type_id=' . $type_id),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_categorytext' => lang('back
to admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php')
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+
+ $data = array
+ (
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($category_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicategory.index&type='.$type
. '&type_id=' . $type_id),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_categorytext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_categorytext' =>
lang('Submit the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang($type). ' ' . $type_id;
+;
+ $function_msg =
lang('list %1 category',$type);
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit()
+ {
+ $type = get_var('type',array('POST','GET'));
+ $type_id =
get_var('type_id',array('POST','GET'));
+ $id = get_var('id',array('POST','GET'));
+ $values =
get_var('values',array('POST'));
+
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('category'));
+
+ if ($values['save'])
+ {
+ if(!$id && !ctype_digit($values['id']))
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter an integer !'));
+ unset($values['id']);
+ }
+
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+ else
+ {
+ $id = $values['id'];
+ }
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$this->bo->save($values,$action,$type,$type_id);
+ }
+ }
+
+ if ($id)
+ {
+ $category =
$this->bo->read_single($id,$type,$type_id);
+ $function_msg = lang('edit category');
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add category');
+ $action='add';
+ }
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uicategory.edit',
+ 'id' => $id,
+ 'type' => $type,
+ 'type_id' => $type_id
+ );
+//_debug_array($link_data);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicategory.index&type='.$type
. '&type_id=' . $type_id),
+ 'lang_id' =>
lang('category ID'),
+ 'lang_descr'
=> lang('Descr'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id' => $id,
+ 'lang_id_categorytext' => lang('Enter the
category ID'),
+ 'lang_descr_categorytext'
=> lang('Enter a description the category'),
+ 'lang_done_categorytext'
=> lang('Back to the list'),
+ 'lang_save_categorytext'
=> lang('Save the category'),
+ 'type_id' =>
$category['type_id'],
+ 'value_descr'
=> $category['descr']
+ );
+
+ $appname
= lang($type). ' ' . $type_id;
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function delete()
+ {
+ $type = get_var('type',array('POST','GET'));
+ $type_id =
get_var('type_id',array('POST','GET'));
+ $id = get_var('id',array('POST','GET'));
+ $confirm =
get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uicategory.index',
+ 'type' => $type,
+ 'type_id' => $type_id
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($id,$type,$type_id);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicategory.delete&id='
. $id.'&type='.$type . '&type_id=' . $type_id),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_categorytext' => lang('Delete the
entry'),
+ 'lang_no_categorytext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang($type). ' ' . $type_id;
+ $function_msg =
lang('delete '.$type.' category');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ }
+?>
Index: property/inc/class.uicustom.inc.php
diff -u property/inc/class.uicustom.inc.php:1.11
property/inc/class.uicustom.inc.php:1.12
--- property/inc/class.uicustom.inc.php:1.11 Thu Jan 19 14:31:09 2006
+++ property/inc/class.uicustom.inc.php Fri Jan 27 14:05:43 2006
@@ -1,567 +1,567 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage custom
- * @version $Id: class.uicustom.inc.php,v 1.11 2006/01/19 14:31:09
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uicustom
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
-
- var $public_functions = array
- (
- 'index' => True,
- 'view' => True,
- 'edit' => True,
- 'excel' => True,
- 'delete' => True
- );
-
- function uicustom()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- $this->bo =
CreateObject($this->currentapp.'.bocustom',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
-
- $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->allrows = $this->bo->allrows;
- $this->menu->sub ='custom';
-
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
- $this->acl2_location = '.custom';
- $this->acl_read =
$this->acl2->check('.custom',1);
- $this->acl_add =
$this->acl2->check('.custom',2);
- $this->acl_edit =
$this->acl2->check('.custom',4);
- $this->acl_delete =
$this->acl2->check('.custom',8);
-
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' => $this->filter,
- 'cat_id' => $this->cat_id,
- 'this->allrows' => $this->allrows
- );
- $this->bo->save_sessiondata($data);
- }
-
- function index()
- {
- $GLOBALS['phpgw']->xslttpl->add_file(array('custom',
-
'menu',
-
'receipt',
-
'search_field',
-
'nextmatchs'));
-
- $links = $this->menu->links();
-
- $receipt =
$GLOBALS['phpgw']->session->appsession('session_data','custom_receipt');
-
$GLOBALS['phpgw']->session->appsession('session_data','custom_receipt','');
-
- $list = $this->bo->read();
-
- $uicols['name'][] = 'custom_id';
- $uicols['descr'][] = lang('ID');
- $uicols['name'][] = 'name';
- $uicols['descr'][] = lang('Name');
- $uicols['name'][] = 'entry_date';
- $uicols['descr'][] = lang('date');
- $uicols['name'][] = 'user';
- $uicols['descr'][] = lang('User');
-
- $j=0;
- if (isset($list) AND is_array($list))
- {
- foreach($list as $entry)
- {
- for
($i=0;$i<count($uicols['name']);$i++)
- {
-
if($uicols['input_type'][$i]!='hidden')
- {
-
$content[$j]['row'][$i]['value'] =
$entry[$uicols['name'][$i]];
-
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
- }
- }
-
- if($this->acl_read)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('view the
entity');
- $content[$j]['row'][$i]['text']
= lang('view');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicustom.view&custom_id='
. $entry['custom_id']);
- }
- if($this->acl_edit)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('edit the
actor');
- $content[$j]['row'][$i]['text']
= lang('edit');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicustom.edit&custom_id='
. $entry['custom_id']);
- }
- if($this->acl_delete)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('delete the
actor');
- $content[$j]['row'][$i]['text']
= lang('delete');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicustom.delete&custom_id='
. $entry['custom_id']);
- }
-
- $j++;
- }
- }
-
-//_debug_array($list);
- $i=0;
- $table_header[$i]['header'] = lang('ID');
- $table_header[$i]['width'] = '5%';
- $table_header[$i]['align'] = 'center';
- $table_header[$i]['sort_link'] =true;
- $table_header[$i]['sort'] =
$this->nextmatchs->show_sort_order(array
- (
- 'sort' => $this->sort,
- 'var' => 'id',
- 'order' => $this->order,
- 'extra' => array('menuaction'
=> $this->currentapp.'.uicustom.index',
-
'query' =>$this->query,
-
'start_date' => $start_date,
-
'end_date'=>$end_date)
- ));
- $i++;
- $table_header[$i]['header'] = lang('name');
- $table_header[$i]['width'] = '5%';
- $table_header[$i]['align'] = 'center';
- $table_header[$i]['sort_link'] =true;
- $table_header[$i]['sort'] =
$this->nextmatchs->show_sort_order(array
- (
- 'sort' => $this->sort,
- 'var' => 'name',
- 'order' => $this->order,
- 'extra' => array('menuaction'
=> $this->currentapp.'.uicustom.index',
-
'query' =>$this->query,
-
'start_date' => $start_date,
-
'end_date'=>$end_date)
- ));
- $i++;
-
- $table_header[$i]['header'] = lang('date');
- $table_header[$i]['width'] = '5%';
- $table_header[$i]['align'] = 'center';
- $table_header[$i]['sort_link'] =true;
- $table_header[$i]['sort'] =
$this->nextmatchs->show_sort_order(array
- (
- 'sort' => $this->sort,
- 'var' => 'name',
- 'order' => $this->order,
- 'extra' => array('menuaction'
=> $this->currentapp.'.uicustom.index',
-
'query' =>$this->query,
-
'start_date' => $start_date,
-
'end_date'=>$end_date)
- ));
- $i++;
- $table_header[$i]['header'] = lang('User');
- $table_header[$i]['width'] = '5%';
- $table_header[$i]['align'] = 'center';
- $table_header[$i]['sort_link'] =true;
- $table_header[$i]['sort'] =
$this->nextmatchs->show_sort_order(array
- (
- 'sort' => $this->sort,
- 'var' => 'user_id',
- 'order' => $this->order,
- 'extra' => array('menuaction'
=> $this->currentapp.'.uicustom.index',
-
'query' =>$this->query,
-
'start_date' => $start_date,
-
'end_date'=>$end_date)
- ));
- $i++;
-
-
- if($this->acl_read)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('view');
- $i++;
- }
- if($this->acl_edit)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('edit');
- $i++;
- }
- if($this->acl_delete)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('delete');
- $i++;
- }
-
-
- if($this->acl_add)
- {
- $table_add = array
- (
- 'lang_add'
=> lang('add'),
- 'lang_add_statustext' => lang('add a
custom query'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicustom.edit')
- );
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uicustom.index',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'links'
=> $links,
- 'allow_allrows'
=> true,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
- $this->save_sessiondata();
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('custom') . ': ' . lang('list custom');
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function edit()
- {
- if(!$this->acl_add && !$this->acl_edit)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
- }
-
- $custom_id =
get_var('custom_id',array('POST','GET'));
- $cols_id =
get_var('cols_id',array('POST','GET'));
- $resort = get_var('resort',array('POST','GET'));
- $values = get_var('values',array('POST'));
-
- if($cols_id)
- {
-
$this->bo->resort(array('custom_id'=>$custom_id,'id'=>$cols_id,'resort'=>$resort));
- }
-
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('custom'));
-
- if ($values['save'] || $values['apply'])
- {
- if(!$values['name'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter a name !'));
- }
-
- if(!$values['sql_text'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter a sql query !'));
- }
-
- if(!$receipt['error'])
- {
- $values['custom_id'] = $custom_id;
- $receipt = $this->bo->save($values);
- $custom_id = $receipt['custom_id'];
- $this->cat_id =
($values['cat_id']?$values['cat_id']:$this->cat_id);
-
- if ($values['save'])
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','custom_receipt',$receipt);
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uicustom.index');
- }
- }
- }
-
- if ($values['cancel'])
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uicustom.index');
- }
-
-
- if ($custom_id)
- {
- $custom = $this->bo->read_single($custom_id);
- $this->cat_id =
($custom['cat_id']?$custom['cat_id']:$this->cat_id);
- }
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uicustom.edit',
- 'custom_id' => $custom_id
- );
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- while (is_array($custom['cols']) && list(,$entry) =
each($custom['cols']))
- {
- $cols[] = array(
- 'id' => $entry['id'],
- 'name' => $entry['name'],
- 'descr' => $entry['descr'],
- 'sorting' => $entry['sorting'],
- 'text_up' => lang('Up'),
- 'text_down' => lang('Down'),
- 'link_up' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicustom.edit&resort=up&cols_id='
. $entry['id'] . '&custom_id=' . $custom_id),
- 'link_down' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicustom.edit&resort=down&cols_id='
. $entry['id'] . '&custom_id=' . $custom_id)
- );
- }
-
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_custom_id'
=> lang('ID'),
- 'value_custom_id'
=> $custom_id,
- 'lang_sql_text'
=> lang('sql'),
- 'lang_name'
=> lang('name'),
- 'lang_save'
=> lang('save'),
- 'lang_cancel'
=> lang('cancel'),
- 'lang_apply'
=> lang('apply'),
- 'value_sql_text'
=> $custom['sql_text'],
- 'value_name'
=> $custom['name'],
- 'lang_name_statustext' =>
lang('Enter a name for the query'),
- 'lang_sql_statustext' =>
lang('Enter a sql query'),
- 'lang_apply_statustext' =>
lang('Apply the values'),
- 'lang_cancel_statustext' =>
lang('Leave the custom untouched and return back to the list'),
- 'lang_save_statustext' =>
lang('Save the custom and return back to the list'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the custom belongs to. To do not use a category
select NO CATEGORY'),
- 'lang_descr'
=> lang('descr'),
- 'lang_new_name_statustext' =>
lang('name'),
- 'lang_new_descr_statustext' =>
lang('descr'),
- 'cols'
=> $cols,
- 'lang_col_name'
=> lang('Column name'),
- 'lang_col_descr'
=> lang('Column description'),
- 'lang_delete_column' =>
lang('Delete column'),
- 'lang_delete_cols_statustext' => lang('Delete
this column from the output'),
- 'lang_up_text'
=> lang('Up'),
- 'lang_down_text'
=> lang('Down'),
- 'lang_sorting'
=> lang('Sorting'),
-
- );
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('custom') . ': ' . ($custom_id?lang('edit custom'):lang('add custom'));
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- function delete()
- {
- $custom_id =
get_var('custom_id',array('POST','GET'));
- $delete = get_var('delete',array('POST'));
- $confirm = get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uicustom.index'
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($custom_id);
-
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicustom.delete&custom_id='
. $custom_id),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('custom');
- $function_msg =
lang('delete custom');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- function view()
- {
- $custom_id = get_var('custom_id',array('GET'));
- $action = get_var('action',array('GET'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('custom','nextmatchs'));
-
- $list= $this->bo->read_custom($custom_id);
- $uicols = $this->bo->uicols;
-
-//_debug_array($uicols);
-
- $j=0;
- if (isSet($list) AND is_array($list))
- {
- foreach($list as $entry)
- {
- for ($i=0;$i<count($uicols);$i++)
- {
-
$content[$j]['row'][$i]['value'] =
$entry[$uicols[$i]['name']];
- }
-
- $j++;
- }
- }
-
- for ($i=0;$i<count($uicols);$i++)
- {
- $table_header[$i]['header'] =
$uicols[$i]['descr'];
- $table_header[$i]['width'] = '15%';
- $table_header[$i]['align'] =
'left';
- }
-
-//_debug_array($content);
-
-
- $custom_name = $this->bo->read_custom_name($custom_id);
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('custom') . ': ' . $custom_name;
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uicustom.view',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'custom_id'
=>$custom_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query
- );
-
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $link_excel = array
- (
- 'menuaction' =>
$this->currentapp.'.uicustom.excel',
- 'sort' =>$this->sort,
- 'order' =>$this->order,
- 'filter' =>$this->filter,
- 'query' =>$this->query,
- 'custom_id' =>$custom_id,
- 'allrows' =>
$this->allrows
- );
-
- $data = array
- (
- 'lang_excel' =>
'excel',
- 'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
- 'lang_excel_help' =>
lang('Download table to MS Excel'),
- 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
-
- 'allow_allrows'
=> true,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
-
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicustom.index'),
- 'lang_done' => lang('done'),
- );
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function excel()
- {
- $custom_id =
get_var('custom_id',array('POST','GET'));
- $list= $this->bo->read_custom($custom_id,$allrows=True);
- $uicols = $this->bo->uicols;
- foreach($uicols as $col)
- {
- $names[] = $col['name'];
- $descr[] = $col['descr'];
- }
- $this->bocommon->excel($list,$names,$descr);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage custom
+ * @version $Id: class.uicustom.inc.php,v 1.12 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uicustom
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'view' => True,
+ 'edit' => True,
+ 'excel' => True,
+ 'delete' => True
+ );
+
+ function uicustom()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $this->bo =
CreateObject($this->currentapp.'.bocustom',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+
+ $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->allrows = $this->bo->allrows;
+ $this->menu->sub ='custom';
+
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+ $this->acl2_location = '.custom';
+ $this->acl_read =
$this->acl2->check('.custom',1);
+ $this->acl_add =
$this->acl2->check('.custom',2);
+ $this->acl_edit =
$this->acl2->check('.custom',4);
+ $this->acl_delete =
$this->acl2->check('.custom',8);
+
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' => $this->filter,
+ 'cat_id' => $this->cat_id,
+ 'this->allrows' => $this->allrows
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function index()
+ {
+ $GLOBALS['phpgw']->xslttpl->add_file(array('custom',
+
'menu',
+
'receipt',
+
'search_field',
+
'nextmatchs'));
+
+ $links = $this->menu->links();
+
+ $receipt =
$GLOBALS['phpgw']->session->appsession('session_data','custom_receipt');
+
$GLOBALS['phpgw']->session->appsession('session_data','custom_receipt','');
+
+ $list = $this->bo->read();
+
+ $uicols['name'][] = 'custom_id';
+ $uicols['descr'][] = lang('ID');
+ $uicols['name'][] = 'name';
+ $uicols['descr'][] = lang('Name');
+ $uicols['name'][] = 'entry_date';
+ $uicols['descr'][] = lang('date');
+ $uicols['name'][] = 'user';
+ $uicols['descr'][] = lang('User');
+
+ $j=0;
+ if (isset($list) AND is_array($list))
+ {
+ foreach($list as $entry)
+ {
+ for
($i=0;$i<count($uicols['name']);$i++)
+ {
+
if($uicols['input_type'][$i]!='hidden')
+ {
+
$content[$j]['row'][$i]['value'] =
$entry[$uicols['name'][$i]];
+
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
+ }
+ }
+
+ if($this->acl_read)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('view the
entity');
+ $content[$j]['row'][$i]['text']
= lang('view');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicustom.view&custom_id='
. $entry['custom_id']);
+ }
+ if($this->acl_edit)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('edit the
actor');
+ $content[$j]['row'][$i]['text']
= lang('edit');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicustom.edit&custom_id='
. $entry['custom_id']);
+ }
+ if($this->acl_delete)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('delete the
actor');
+ $content[$j]['row'][$i]['text']
= lang('delete');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicustom.delete&custom_id='
. $entry['custom_id']);
+ }
+
+ $j++;
+ }
+ }
+
+//_debug_array($list);
+ $i=0;
+ $table_header[$i]['header'] = lang('ID');
+ $table_header[$i]['width'] = '5%';
+ $table_header[$i]['align'] = 'center';
+ $table_header[$i]['sort_link'] =true;
+ $table_header[$i]['sort'] =
$this->nextmatchs->show_sort_order(array
+ (
+ 'sort' => $this->sort,
+ 'var' => 'id',
+ 'order' => $this->order,
+ 'extra' => array('menuaction'
=> $this->currentapp.'.uicustom.index',
+
'query' =>$this->query,
+
'start_date' => $start_date,
+
'end_date'=>$end_date)
+ ));
+ $i++;
+ $table_header[$i]['header'] = lang('name');
+ $table_header[$i]['width'] = '5%';
+ $table_header[$i]['align'] = 'center';
+ $table_header[$i]['sort_link'] =true;
+ $table_header[$i]['sort'] =
$this->nextmatchs->show_sort_order(array
+ (
+ 'sort' => $this->sort,
+ 'var' => 'name',
+ 'order' => $this->order,
+ 'extra' => array('menuaction'
=> $this->currentapp.'.uicustom.index',
+
'query' =>$this->query,
+
'start_date' => $start_date,
+
'end_date'=>$end_date)
+ ));
+ $i++;
+
+ $table_header[$i]['header'] = lang('date');
+ $table_header[$i]['width'] = '5%';
+ $table_header[$i]['align'] = 'center';
+ $table_header[$i]['sort_link'] =true;
+ $table_header[$i]['sort'] =
$this->nextmatchs->show_sort_order(array
+ (
+ 'sort' => $this->sort,
+ 'var' => 'name',
+ 'order' => $this->order,
+ 'extra' => array('menuaction'
=> $this->currentapp.'.uicustom.index',
+
'query' =>$this->query,
+
'start_date' => $start_date,
+
'end_date'=>$end_date)
+ ));
+ $i++;
+ $table_header[$i]['header'] = lang('User');
+ $table_header[$i]['width'] = '5%';
+ $table_header[$i]['align'] = 'center';
+ $table_header[$i]['sort_link'] =true;
+ $table_header[$i]['sort'] =
$this->nextmatchs->show_sort_order(array
+ (
+ 'sort' => $this->sort,
+ 'var' => 'user_id',
+ 'order' => $this->order,
+ 'extra' => array('menuaction'
=> $this->currentapp.'.uicustom.index',
+
'query' =>$this->query,
+
'start_date' => $start_date,
+
'end_date'=>$end_date)
+ ));
+ $i++;
+
+
+ if($this->acl_read)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('view');
+ $i++;
+ }
+ if($this->acl_edit)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('edit');
+ $i++;
+ }
+ if($this->acl_delete)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('delete');
+ $i++;
+ }
+
+
+ if($this->acl_add)
+ {
+ $table_add = array
+ (
+ 'lang_add'
=> lang('add'),
+ 'lang_add_statustext' => lang('add a
custom query'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicustom.edit')
+ );
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uicustom.index',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'links'
=> $links,
+ 'allow_allrows'
=> true,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+ $this->save_sessiondata();
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('custom') . ': ' . lang('list custom');
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function edit()
+ {
+ if(!$this->acl_add && !$this->acl_edit)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
+ }
+
+ $custom_id =
get_var('custom_id',array('POST','GET'));
+ $cols_id =
get_var('cols_id',array('POST','GET'));
+ $resort = get_var('resort',array('POST','GET'));
+ $values = get_var('values',array('POST'));
+
+ if($cols_id)
+ {
+
$this->bo->resort(array('custom_id'=>$custom_id,'id'=>$cols_id,'resort'=>$resort));
+ }
+
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('custom'));
+
+ if ($values['save'] || $values['apply'])
+ {
+ if(!$values['name'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter a name !'));
+ }
+
+ if(!$values['sql_text'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter a sql query !'));
+ }
+
+ if(!$receipt['error'])
+ {
+ $values['custom_id'] = $custom_id;
+ $receipt = $this->bo->save($values);
+ $custom_id = $receipt['custom_id'];
+ $this->cat_id =
($values['cat_id']?$values['cat_id']:$this->cat_id);
+
+ if ($values['save'])
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','custom_receipt',$receipt);
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uicustom.index');
+ }
+ }
+ }
+
+ if ($values['cancel'])
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uicustom.index');
+ }
+
+
+ if ($custom_id)
+ {
+ $custom = $this->bo->read_single($custom_id);
+ $this->cat_id =
($custom['cat_id']?$custom['cat_id']:$this->cat_id);
+ }
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uicustom.edit',
+ 'custom_id' => $custom_id
+ );
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ while (is_array($custom['cols']) && list(,$entry) =
each($custom['cols']))
+ {
+ $cols[] = array(
+ 'id' => $entry['id'],
+ 'name' => $entry['name'],
+ 'descr' => $entry['descr'],
+ 'sorting' => $entry['sorting'],
+ 'text_up' => lang('Up'),
+ 'text_down' => lang('Down'),
+ 'link_up' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicustom.edit&resort=up&cols_id='
. $entry['id'] . '&custom_id=' . $custom_id),
+ 'link_down' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicustom.edit&resort=down&cols_id='
. $entry['id'] . '&custom_id=' . $custom_id)
+ );
+ }
+
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_custom_id'
=> lang('ID'),
+ 'value_custom_id'
=> $custom_id,
+ 'lang_sql_text'
=> lang('sql'),
+ 'lang_name'
=> lang('name'),
+ 'lang_save'
=> lang('save'),
+ 'lang_cancel'
=> lang('cancel'),
+ 'lang_apply'
=> lang('apply'),
+ 'value_sql_text'
=> $custom['sql_text'],
+ 'value_name'
=> $custom['name'],
+ 'lang_name_statustext' =>
lang('Enter a name for the query'),
+ 'lang_sql_statustext' =>
lang('Enter a sql query'),
+ 'lang_apply_statustext' =>
lang('Apply the values'),
+ 'lang_cancel_statustext' =>
lang('Leave the custom untouched and return back to the list'),
+ 'lang_save_statustext' =>
lang('Save the custom and return back to the list'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the custom belongs to. To do not use a category
select NO CATEGORY'),
+ 'lang_descr'
=> lang('descr'),
+ 'lang_new_name_statustext' =>
lang('name'),
+ 'lang_new_descr_statustext' =>
lang('descr'),
+ 'cols'
=> $cols,
+ 'lang_col_name'
=> lang('Column name'),
+ 'lang_col_descr'
=> lang('Column description'),
+ 'lang_delete_column' =>
lang('Delete column'),
+ 'lang_delete_cols_statustext' => lang('Delete
this column from the output'),
+ 'lang_up_text'
=> lang('Up'),
+ 'lang_down_text'
=> lang('Down'),
+ 'lang_sorting'
=> lang('Sorting'),
+
+ );
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('custom') . ': ' . ($custom_id?lang('edit custom'):lang('add custom'));
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ function delete()
+ {
+ $custom_id =
get_var('custom_id',array('POST','GET'));
+ $delete = get_var('delete',array('POST'));
+ $confirm = get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uicustom.index'
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($custom_id);
+
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicustom.delete&custom_id='
. $custom_id),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('custom');
+ $function_msg =
lang('delete custom');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ function view()
+ {
+ $custom_id = get_var('custom_id',array('GET'));
+ $action = get_var('action',array('GET'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('custom','nextmatchs'));
+
+ $list= $this->bo->read_custom($custom_id);
+ $uicols = $this->bo->uicols;
+
+//_debug_array($uicols);
+
+ $j=0;
+ if (isSet($list) AND is_array($list))
+ {
+ foreach($list as $entry)
+ {
+ for ($i=0;$i<count($uicols);$i++)
+ {
+
$content[$j]['row'][$i]['value'] =
$entry[$uicols[$i]['name']];
+ }
+
+ $j++;
+ }
+ }
+
+ for ($i=0;$i<count($uicols);$i++)
+ {
+ $table_header[$i]['header'] =
$uicols[$i]['descr'];
+ $table_header[$i]['width'] = '15%';
+ $table_header[$i]['align'] =
'left';
+ }
+
+//_debug_array($content);
+
+
+ $custom_name = $this->bo->read_custom_name($custom_id);
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('custom') . ': ' . $custom_name;
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uicustom.view',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'custom_id'
=>$custom_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query
+ );
+
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $link_excel = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uicustom.excel',
+ 'sort' =>$this->sort,
+ 'order' =>$this->order,
+ 'filter' =>$this->filter,
+ 'query' =>$this->query,
+ 'custom_id' =>$custom_id,
+ 'allrows' =>
$this->allrows
+ );
+
+ $data = array
+ (
+ 'lang_excel' =>
'excel',
+ 'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
+ 'lang_excel_help' =>
lang('Download table to MS Excel'),
+ 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
+
+ 'allow_allrows'
=> true,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uicustom.index'),
+ 'lang_done' => lang('done'),
+ );
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function excel()
+ {
+ $custom_id =
get_var('custom_id',array('POST','GET'));
+ $list= $this->bo->read_custom($custom_id,$allrows=True);
+ $uicols = $this->bo->uicols;
+ foreach($uicols as $col)
+ {
+ $names[] = $col['name'];
+ $descr[] = $col['descr'];
+ }
+ $this->bocommon->excel($list,$names,$descr);
+ }
+ }
+?>
Index: property/inc/class.uidocument.inc.php
diff -u property/inc/class.uidocument.inc.php:1.10
property/inc/class.uidocument.inc.php:1.11
--- property/inc/class.uidocument.inc.php:1.10 Tue Nov 8 22:39:10 2005
+++ property/inc/class.uidocument.inc.php Fri Jan 27 14:05:43 2006
@@ -1,1195 +1,1195 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage document
- * @version $Id: class.uidocument.inc.php,v 1.10 2005/11/08 22:39:10
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uidocument
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
- var $part_of_town_id;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'index' => True,
- 'list_doc' => True,
- 'view' => True,
- 'view_file' => True,
- 'edit' => True,
- 'delete' => True
- );
-
- function uidocument()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bo =
CreateObject($this->currentapp.'.bodocument',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
- $this->bolocation =
CreateObject($this->currentapp.'.bolocation');
- $this->config =
CreateObject('phpgwapi.config',$this->currentapp);
- $this->boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
-
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
- $this->acl2_location = '.document';
- $this->acl_read =
$this->acl2->check('.document',1);
- $this->acl_add =
$this->acl2->check('.document',2);
- $this->acl_edit =
$this->acl2->check('.document',4);
- $this->acl_delete =
$this->acl2->check('.document',8);
-
- $this->rootdir =
$this->bo->rootdir;
- $this->fakebase =
$this->bo->fakebase;
- $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->status_id =
$this->bo->status_id;
- $this->entity_id =
$this->bo->entity_id;
- $this->doc_type =
$this->bo->doc_type;
- $this->query_location =
$this->bo->query_location;
-
- $this->menu->sub ='document';
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' => $this->filter,
- 'cat_id' => $this->cat_id,
- 'status_id' => $this->status_id,
- 'entity_id' => $this->entity_id,
- 'doc_type' => $this->doc_type,
- 'query_location' => $this->query_location
- );
- $this->bo->save_sessiondata($data);
- }
-
- function index()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('document','values','table_header',
-
'menu',
-
'nextmatchs',
-
'search_field'));
-
- $entity_id = get_var('entity_id',array('POST','GET'));
- $links = $this->menu->links('document_'.$entity_id);
-
- $preserve =
get_var('preserve',array('POST','GET'));
-
- if($preserve)
- {
- $this->bo->read_sessiondata();
-
- $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->status_id =
$this->bo->status_id;
- $this->entity_id =
$this->bo->entity_id;
- }
-
- $document_list = $this->bo->read();
-
-//_debug_array($document_list);
-
-
- $uicols = $this->bo->uicols;
-
- $j=0;
- while (is_array($document_list) &&
list(,$document_entry) = each($document_list))
- {
- for ($k=0;$k<count($uicols['name']);$k++)
- {
- if($uicols['input_type'][$k]!='hidden')
- {
-
-
if($document_entry['query_location'][$uicols['name'][$k]])
- {
-
- $content[$j]['row'][]=
array(
- 'statustext'
=> lang('search'),
- 'text'
=> $document_entry[$uicols['name'][$k]],
- 'link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.index&query='
. $document_entry['query_location'][$uicols['name'][$k]] . '&entity_id=' .
$document_entry['p_entity_id'] . '&cat_id=' . $document_entry['p_cat_id'])
- );
- }
- else
- {
- $content[$j]['row'][]=
array(
- 'value'
=> $document_entry[$uicols['name'][$k]],
- 'name'
=> $uicols['name'][$k],
- );
- }
-
- }
- }
-
- if($this->acl_read)
- {
- $content[$j]['row'][]= array(
- 'statustext'
=> lang('view documents for this location/entity'),
- 'text'
=> lang('documents'),
- 'link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.list_doc&location_code='
. $document_entry['location_code'] . '&p_num=' . $document_entry['p_num'] .
'&entity_id=' . $document_entry['p_entity_id'] . '&cat_id=' .
$document_entry['p_cat_id'] . '&doc_type=' . $this->doc_type)
- );
- }
-
- $j++;
- }
-
- for ($i=0;$i<count($uicols['descr']);$i++)
- {
- if($uicols['input_type'][$i]!='hidden')
- {
- $table_header[$i]['header'] =
$uicols['descr'][$i];
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- if($uicols['name'][$i]=='loc1')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'location_code',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uidocument.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'district_id' =>
$this->district_id,
-
'cat_id'
=>$this->cat_id,
-
'doc_type'
=>$this->doc_type,
-
'entity_id'
=>$this->entity_id)
-
));
- }
- if($uicols['name'][$i]=='document_id')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'document_id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uidocument.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'district_id' =>
$this->district_id,
-
'cat_id'
=>$this->cat_id,
-
'doc_type'
=>$this->doc_type,
-
'entity_id'
=>$this->entity_id)
-
));
- }
- if($uicols['name'][$i]=='address')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'address',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uidocument.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'district_id' =>
$this->district_id,
-
'cat_id'
=>$this->cat_id,
-
'doc_type'
=>$this->doc_type,
-
'entity_id'
=>$this->entity_id)
-
));
- }
- }
- }
-
- if($this->acl_read)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('view');
- $i++;
- }
-
- if($this->acl_add)
- {
- $table_add[] = array
- (
- 'lang_add'
=> lang('add'),
- 'lang_add_statustext' => lang('add a
document'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.edit&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id)
-
- );
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uidocument.index',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'district_id'
=>$this->district_id,
- 'filter'
=>$this->filter,
- 'status_id'
=>$this->status_id,
- 'query'
=>$this->query,
- 'doc_type'
=>$this->doc_type,
- 'entity_id'
=>$this->entity_id
- );
-
- if($this->entity_id)
- {
- $boentity =
CreateObject($this->currentapp.'.boentity');
- $boentity->entity_id=$this->entity_id;
- $cat_list =
$this->bo->select_category_list('filter',$this->cat_id);
- $entity =
$this->boadmin_entity->read_single($this->entity_id,false);
- $appname_sub = $entity['name'];
- }
- else
- {
- $appname_sub = lang('location');
- }
-
- $data = array
- (
- 'link_history'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.index&cat_id='
. $this->cat_id),
- 'lang_history_statustext' =>
lang('search for history at this location'),
- 'lang_select'
=> lang('select'),
- 'links'
=> $links,
- 'allow_allrows'
=> false,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($document_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'type'
=> $this->cat_id,
- 'district_list'
=> $this->bocommon->select_district_list('filter',$this->district_id),
- 'lang_no_district'
=> lang('no district'),
- 'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
- 'select_district_name' =>
'district_id',
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
-
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category. To do not use a category select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $cat_list,
-
- 'lang_no_doc_type'
=> lang('no document type'),
- 'lang_doc_type_statustext' =>
lang('Select the document type the document belongs to.'),
- 'doc_type'
=> $this->bo->select_doc_type_list('filter',$this->doc_type),
-
-
- 'lang_status_statustext' =>
lang('Select the status the document belongs to. To do not use a category
select NO STATUS'),
- 'status_name'
=> 'status_id',
- 'lang_no_status'
=> lang('No status'),
- 'status_list'
=> $this->bo->select_status_list('filter',$this->status_id),
-
- 'lang_user_statustext' =>
lang('Select the user the document belongs to. To do not use a category select
NO USER'),
- 'select_user_name'
=> 'filter',
- 'lang_no_user'
=> lang('No user'),
- 'user_list'
=>
$this->bocommon->get_user_list_right2('filter',4,$this->filter,$this->acl2_location,array('all'),$default=$this->account),
-
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname = lang('document');
- $function_msg = lang('list document');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg . ' - ' .
$appname_sub;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function list_doc()
- {
-
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $preserve =
get_var('preserve',array('POST','GET'));
-
- if($preserve)
- {
- $this->bo->read_sessiondata();
-
- $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->entity_id =
$this->bo->entity_id;
- $this->cat_id =
$this->bo->cat_id;
- $this->status_id =
$this->bo->status_id;
- }
-//_debug_array($this->cat_id);
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('document',
-
'menu',
-
'receipt',
-
'nextmatchs',
-
'search_field'));
-
- $receipt =
$GLOBALS['phpgw']->session->appsession('session_data','document_receipt');
-
$GLOBALS['phpgw']->session->appsession('session_data','document_receipt','');
-
- $location_code =
get_var('location_code',array('POST','GET'));
- if($this->query_location)
- {
- $location_code = $this->query_location;
- }
-
- $p_num = get_var('p_num',array('POST','GET'));
-
- $location=$this->bo->read_location_data($location_code);
-
- if($this->cat_id)
- {
- $entity_data[$this->entity_id]['p_num']=$p_num;
-
$entity_data[$this->entity_id]['p_entity_id']=$this->entity_id;
-
$entity_data[$this->entity_id]['p_cat_id']=$this->cat_id;
- $entity =
$this->boadmin_entity->read_single($this->entity_id,false);
- $category =
$this->boadmin_entity->read_single_category($this->entity_id,$this->cat_id);
- $lookup_entity =
$this->bocommon->get_lookup_entity('document');
- $appname_sub = $entity['name'];
- }
- else
- {
- $appname_sub = lang('location');
- }
-
- if($category['name'])
- {
-
$entity_data[$this->entity_id]['p_cat_name']=$category['name'];
- }
-
- $this->config->read_repository();
- $files_url = $this->config->config_data['files_url'];
-
- $links = $this->menu->links();
-
- $document_list =
$this->bo->read_at_location($location_code);
-
-//_debug_array($document_list);
-
- if($this->cat_id)
- {
- $directory = $this->fakebase. SEP .
'document' . SEP . $location['loc1'] . SEP . $entity['name'] . SEP .
$category['name'] . SEP . $p_num;
- }
- else
- {
- $directory = $this->fakebase. SEP .
'document' . SEP . $location['loc1'];
- }
-
- while (is_array($document_list) && list(,$document) =
each($document_list))
- {
- if($document['link'])
- {
- $link_view_file=$document['link'];
- $document['document_name']='link';
- unset($link_to_files);
- }
- else
- {
- if(!$link_to_files)
- {
- $link_view_file =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.view_file&document_id='
. $document['document_id'] . '&entity_id=' . $this->entity_id . '&cat_id=' .
$this->cat_id . '&p_num=' . $p_num);
- $link_to_files = $files_url;
- }
- }
-
- $content[] = array
- (
- 'directory'
=> $directory,
- 'document_id'
=> $document['document_id'],
- 'document_name'
=> $document['document_name'],
- 'title'
=> $document['title'],
- 'user'
=> $document['user'],
- 'doc_type'
=> $document['doc_type'],
- 'link_view_file'
=> $link_view_file,
- 'link_to_files'
=> $link_to_files,
- 'link_view'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.view&document_id='
. $document['document_id'] . '&from=list_doc'),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.edit&document_id='
. $document['document_id'] . '&from=list_doc'),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.delete&document_id='
. $document['document_id'] . '&location_code=' . $location_code . '&p_num=' .
$p_num),
- 'lang_view_file_statustext' =>
lang('view the document'),
- 'lang_view_statustext' =>
lang('view information about the document'),
- 'lang_edit_statustext' =>
lang('edit information about the document'),
- 'lang_delete_statustext' =>
lang('delete this document'),
- 'text_view'
=> lang('view'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
-
-
- $table_header[] = array
- (
- 'sort_document_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'document_name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uidocument.list_doc',
-
'entity_id'
=>$this->entity_id,
-
'cat_id'
=>$this->cat_id,
-
'doc_type'
=>$this->doc_type,
-
'p_num'
=>$p_num,
-
'location_code'
=>$location_code,
-
'filter'
=>$this->filter,
-
'query'
=>$this->query,
-
'query_location'
=>$this->query_location
-
)
-
)),
- 'lang_document_name' => lang('Document
name'),
- 'lang_doc_type' => lang('Doc
type'),
- 'lang_user' =>
lang('user'),
- 'lang_title' =>
lang('Title'),
- 'lang_view' => lang('view'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- );
-
-
- $link_data_add = array
- (
- 'menuaction' =>
$this->currentapp.'.uidocument.edit',
- 'location_code'
=>$location_code,
- 'p_entity_id'
=>$this->entity_id,
- 'entity_id'
=>$this->entity_id,
- 'p_cat_id'
=>$this->cat_id,
- 'cat_id'
=>$this->cat_id,
- 'p_num'
=>$p_num,
- 'from'
=>'list_doc',
- 'bypass'
=>True
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_statustext' => lang('add a
document'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data_add)
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uidocument.list_doc',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'entity_id'
=>$this->entity_id,
- 'cat_id'
=>$this->cat_id,
- 'p_num'
=>$p_num,
- 'doc_type'
=>$this->doc_type,
- 'location_code'
=>$location_code,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query,
- 'query_location'
=>$this->query_location
- );
-
-
-
$location_data=$this->bolocation->initiate_ui_location(array(
- 'values' =>
$location,
- 'type_id' =>
count(explode('-',$location_code)),
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' =>
False,
- 'lookup_type' => 'view',
- 'lookup_entity' =>
$lookup_entity,
- 'entity_data' => $entity_data,
- 'link_data' =>
$link_data,
- 'query_link' => True
- ));
-
-//_debug_array($location_data);
-
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'location_data'
=> $location_data,
- 'link_history'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.list_doc&cat_id='
. $this->cat_id),
- 'lang_history_statustext' =>
lang('search for history at this location'),
- 'lang_select'
=> lang('select'),
- 'lookup_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit'),
- 'lookup'
=> $lookup,
- 'links'
=> $links,
- 'allow_allrows'
=> false,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($document_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'type'
=> $this->doc_type,
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the document belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'doc_type',
- 'cat_list'
=> $this->bo->select_doc_type_list('filter',$this->doc_type),
-
-// 'district_list'
=> $this->bocommon->select_district_list('filter',$this->district_id),
-// 'lang_no_district'
=> lang('no district'),
-// 'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
-// 'select_district_name' =>
'district_id',
-
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
-
- 'lang_status_statustext' =>
lang('Select the status the document belongs to. To do not use a category
select NO STATUS'),
- 'status_name'
=> 'status_id',
- 'lang_no_status'
=> lang('No status'),
- 'status_list'
=> $this->bo->select_status_list('filter',$this->status_id),
-
- 'lang_user_statustext' =>
lang('Select the user the document belongs to. To do not use a category select
NO USER'),
- 'select_user_name'
=> 'filter',
- 'lang_no_user'
=> lang('No user'),
- 'user_list'
=>
$this->bocommon->get_user_list_right2('filter',4,$this->filter,$this->acl2_location,array('all'),$default=$this->account),
-
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_document' =>
$table_header,
- 'values_document'
=> $content,
- 'table_add'
=> $table_add,
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.index&preserve=1'),
- 'lang_done'
=> lang('done'),
- 'lang_done_statustext' =>
lang('Back to the list')
- );
-
- $appname = lang('document');
- $function_msg = lang('list document');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg . ' - ' .
$appname_sub;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_document' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function view_file()
- {
- $GLOBALS['phpgw_info']['flags'][noheader] = True;
- $GLOBALS['phpgw_info']['flags'][nofooter] = True;
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
-
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $document_id =
get_var('document_id',array('POST','GET'));
- $p_num = get_var('p_num',array('POST','GET'));
-
-
- $values = $this->bo->read_single($document_id);
-
- if($this->cat_id)
- {
- $entity =
$this->boadmin_entity->read_single($this->entity_id,false);
- $category =
$this->boadmin_entity->read_single_category($this->entity_id,$this->cat_id);
- $file = $this->fakebase. SEP . 'document' .
SEP . $values['location_data']['loc1'] . SEP . $entity['name'] . SEP .
$category['name'] . SEP . $p_num . SEP . $values['document_name'];
- }
- else
- {
- $file = $this->fakebase. SEP . 'document' .
SEP .$values['location_data']['loc1'] . SEP . $values['document_name'];
- }
-
- if($this->bo->vfs->file_exists(array(
- 'string' => $file,
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
-
- $size =
$this->bo->vfs->get_size(array(
- 'string' => $file,
- 'relatives' =>
Array(RELATIVE_NONE),
- 'checksubdirs' =>
True));
-
- $document= $this->bo->vfs->read(array(
- 'string' => $file,
- 'relatives' => Array(RELATIVE_NONE)));
-
- $filename =
basename($values['document_name']);
- $filetype = array_pop(explode('.',
basename($file)));
- $browser = CreateObject('phpgwapi.browser');
-
$browser->content_header($filename,$filetype,$size);
-
- echo $document;
- }
- }
-
-
- function edit()
- {
- if(!$this->acl_add && !$this->acl_edit)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
- }
-
- $from =
get_var('from',array('POST','GET'));
- $document_id =
get_var('document_id',array('POST','GET'));
-// $location_code =
get_var('location_code',array('POST','GET'));
- $values =
get_var('values',array('POST'));
- $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
- $insert_record_entity =
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp);
-
- for ($j=0;$j<count($insert_record_entity);$j++)
- {
-
$insert_record['extra'][$insert_record_entity[$j]] =
$insert_record_entity[$j];
- }
-
- if(!$from)
- {
- $from='index';
- }
- $GLOBALS['phpgw']->xslttpl->add_file(array('document'));
-
- $bypass =
get_var('bypass',array('POST','GET'));
-
- $receipt = $this->bo->create_home_dir();
-
- if($_POST && !$bypass)
- {
- for ($i=0;
$i<count($insert_record['location']); $i++)
- {
-
if($_POST[$insert_record['location'][$i]])
- {
-
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
- }
- }
-
- while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
- {
- if($_POST[$key])
- {
- $values['extra'][$column]
= $_POST[$key];
- }
- }
-
- $values['street_name'] =
$_POST['street_name'];
- $values['street_number'] =
$_POST['street_number'];
- $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
-
- }
- else
- {
- $location_code =
get_var('location_code',array('POST','GET'));
- $p_entity_id =
get_var('p_entity_id',array('POST','GET'));
- $p_cat_id =
get_var('p_cat_id',array('POST','GET'));
- $values['p'][$p_entity_id]['p_entity_id']
= $p_entity_id;
- $values['p'][$p_entity_id]['p_cat_id']
= $p_cat_id;
- $values['p'][$p_entity_id]['p_num']
= get_var('p_num',array('POST','GET'));
- $values['p_entity_id']=$p_entity_id;
- $values['p_cat_id']=$p_cat_id;
-
- if($p_entity_id && $p_cat_id)
- {
- $entity_category =
$this->boadmin_entity->read_single_category($p_entity_id,$p_cat_id);
-
$values['p'][$p_entity_id]['p_cat_name'] = $entity_category['name'];
- }
-
- if($location_code)
- {
- $values['location_data'] =
$this->bolocation->read_single($location_code,array());
- }
-
- }
-
-
-//_debug_array($values);
- if($values[extra]['p_entity_id'])
- {
- $this->entity_id=$values[extra]['p_entity_id'];
- $this->cat_id=$values[extra]['p_cat_id'];
- $p_num=$values['extra']['p_num'];
- }
-
- if($this->cat_id)
- {
- $entity =
$this->boadmin_entity->read_single($this->entity_id,false);
- $category =
$this->boadmin_entity->read_single_category($this->entity_id,$this->cat_id);
- $values['entity_name']=$entity['name'];
- $values['category_name']=$category['name'];
- }
-
- if ($values['save'])
- {
- $values['document_date'] =
get_var('document_date',array('POST'));
- $values['vendor_id'] =
get_var('vendor_id',array('POST'));
-
- if(!$values['link'])
- {
-
$values['document_name']=$_FILES['document_file']['name'];
- }
-
- if((!$values['document_name'] &&
!$values['document_name_orig']) && !$values['link'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a file to upload !'));
- }
-
- if(!$values['doc_type'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
- $error_id=true;
- }
-
- if(!$values['status'])
- {
-//
$receipt['error'][]=array('msg'=>lang('Please select a status !'));
- }
- if(!$values['location'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a location !'));
- }
-
- if($values['extra']['p_num'])
- {
- $to_file = $this->fakebase. SEP .
'document' . SEP . $values['location']['loc1'] . SEP . $entity['name'] . SEP .
$category['name'] . SEP . $values['extra']['p_num'] . SEP .
$values['document_name'];
- }
- else
- {
- $to_file = $this->fakebase. SEP .
'document' . SEP . $values['location']['loc1'] . SEP . $values['document_name'];
- }
-
- if(!$values['document_name_orig'] &&
$this->bo->vfs->file_exists(array(
- 'string' => $to_file,
- 'relatives' =>
Array(RELATIVE_NONE)
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('This file already exists !'));
- }
-
-
$receipt=$this->bo->create_document_dir(array('loc1'=>$values['location']['loc1'],'entity_name'=>$entity['name'],'category_name'=>$category['name'],
'p_num'=>$values['extra']['p_num']),$receipt);
-
- $values['document_id'] = $document_id;
-
-
- if(!$receipt['error'])
- {
- if($values['document_name'] &&
!$values['link'])
- {
- if(!$this->bo->vfs->cp (array (
- 'from' =>
$_FILES['document_file']['tmp_name'],
- 'to' => $to_file,
- 'relatives' =>
array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
- {
-
$receipt['error'][]=array('msg'=>lang('Failed to upload file !'));
- }
- }
-
- if(!$receipt['error'])
- {
- $receipt =
$this->bo->save($values);
- //
$document_id=$receipt['document_id'];
-
$GLOBALS['phpgw']->session->appsession('session_data','document_receipt',$receipt);
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uidocument.list_doc&location_code='
.implode("-", $values['location']) . '&entity_id=' . $this->entity_id .
'&cat_id=' . $this->cat_id . '&p_num=' . $values['extra']['p_num'] );
- }
- }
- else
- {
- $values['document_name']='';
- if($values['location'])
- {
- $location_code=implode("-",
$values['location']);
- $values['location_data'] =
$this->bolocation->read_single($location_code,$values['extra']);
- }
- if($values['extra']['p_num'])
- {
-
$values['p'][$values['extra']['p_entity_id']]['p_num']=$values['extra']['p_num'];
-
$values['p'][$values['extra']['p_entity_id']]['p_entity_id']=$values['extra']['p_entity_id'];
-
$values['p'][$values['extra']['p_entity_id']]['p_cat_id']=$values['extra']['p_cat_id'];
-
$values['p'][$values['extra']['p_entity_id']]['p_cat_name']=$_POST['entity_cat_name_'.$values['extra']['p_entity_id']];
- }
- }
- }
-
- if ($document_id ||(!$receipt['error'] &&
$values['document_id']))
- {
- $values = $this->bo->read_single($document_id);
- $record_history =
$this->bo->read_record_history($document_id);
- $function_msg = lang('Edit document');
- }
- else
- {
- $function_msg = lang('Add document');
- }
-
- $table_header_history[] = array
- (
- 'lang_date' => lang('Date'),
- 'lang_user' => lang('User'),
- 'lang_action' => lang('Action'),
- 'lang_new_value' => lang('New value')
- );
-
- if ($values['doc_type'])
- {
- $this->doc_type = $values['doc_type'];
- }
- if ($values['location_code'])
- {
- $location_code = $values['location_code'];
- }
-/* if ($values['p_num'])
- {
- $p_num = $values['p_num'];
- }
-*/
-
$location_data=$this->bolocation->initiate_ui_location(array(
- 'values' =>
$values['location_data'],
- 'type_id' => -1,
// calculated from location_types
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' =>
False,
- 'lookup_type' => 'form',
- 'lookup_entity' =>
$this->bocommon->get_lookup_entity('document'),
- 'entity_data' => $values['p']
- ));
-
-
-
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
- 'vendor_id' =>
$values['vendor_id'],
- 'vendor_name' =>
$values['vendor_name']));
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uidocument.edit',
- 'document_id' => $document_id,
- 'from' => $from,
- 'location_code' =>
$values['location_code'],
- 'entity_id'
=>$this->entity_id,
- 'cat_id' =>$this->cat_id,
- );
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'vendor_data'
=> $vendor_data,
- 'record_history'
=> $record_history,
- 'table_header_history' =>
$table_header_history,
- 'lang_history'
=> lang('History'),
- 'lang_no_history'
=> lang('No history'),
-
- 'jsDateFormat'
=> $jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle'
=> lang('Select date'),
- 'calendar_setup'
=> "Calendar.setup({inputField : 'document_date',ifFormat : '" .
$jsDateFormat . "',button : 'document_date-trigger'});",
-
- 'lang_document_date_statustext' => lang('Select
date the document was created'),
- 'lang_document_date' =>
lang('document date'),
- 'value_document_date' =>
$values['document_date'],
-
- 'vendor_data'
=> $vendor_data,
- 'location_data'
=> $location_data,
- 'location_type'
=> 'form',
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_year'
=> lang('Year'),
- 'lang_category'
=> lang('category'),
- 'lang_save'
=> lang('save'),
- 'lang_save_statustext' =>
lang('Save the document'),
-
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.'
.$from . '&location_code=' . $location_code . '&entity_id=' . $this->entity_id
. '&cat_id=' . $this->cat_id . '&p_num=' . $p_num . '&preserve=1'),
- 'lang_done'
=> lang('done'),
- 'lang_done_statustext' =>
lang('Back to the list'),
-
- 'lang_update_file'
=> lang('Update file'),
-
- 'lang_document_id'
=> lang('document ID'),
- 'value_document_id'
=> $document_id,
-
- 'lang_document_name'
=> lang('document name'),
- 'value_document_name' =>
$values['document_name'],
- 'lang_document_name_statustext'
=> lang('Enter document Name'),
-
- 'lang_floor_id'
=> lang('Floor ID'),
- 'value_floor_id'
=> $values['floor_id'],
- 'lang_floor_statustext' =>
lang('Enter the floor ID'),
-
- 'lang_title'
=> lang('title'),
- 'value_title'
=> $values['title'],
- 'lang_title_statustext' =>
lang('Enter document title'),
-
- 'lang_version'
=> lang('Version'),
- 'value_version'
=> $values['version'],
- 'lang_version_statustext' =>
lang('Enter document version'),
-
- 'lang_link'
=> lang('Link'),
- 'value_link'
=> $values['link'],
- 'lang_link_statustext' =>
lang('Alternative - link instead of uploading a file'),
-
- 'lang_descr_statustext' =>
lang('Enter a description of the document'),
- 'lang_descr'
=> lang('Description'),
- 'value_descr'
=> $values['descr'],
- 'lang_no_cat'
=> lang('Select category'),
- 'lang_cat_statustext' =>
lang('Select the category the document belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'values[doc_type]',
- 'value_cat_id'
=> $values['doc_type'],
- 'cat_list'
=> $this->bo->select_doc_type_list('select',$values['doc_type']),
-
- 'lang_coordinator'
=> lang('Coordinator'),
- 'lang_user_statustext' =>
lang('Select the coordinator the document belongs to. To do not use a category
select NO USER'),
- 'select_user_name'
=> 'values[coordinator]',
- 'lang_no_user'
=> lang('Select coordinator'),
- 'user_list'
=>
$this->bocommon->get_user_list_right2('select',4,$values['coordinator'],$this->acl2_location),
-
- 'status_list'
=> $this->bo->select_status_list('select',$values['status']),
- 'status_name' =>
'values[status]',
- 'lang_no_status'
=> lang('Select status'),
- 'lang_status'
=> lang('Status'),
- 'lang_status_statustext' =>
lang('What is the current status of this document ?'),
-
- 'value_location_code' =>
$values['location_code'],
-
- 'branch_list'
=> $this->bo->select_branch_list($values['branch_id']),
- 'lang_no_branch'
=> lang('No branch'),
- 'lang_branch'
=> lang('branch'),
- 'lang_branch_statustext' =>
lang('Select the branch for this document')
- );
-
- $appname = lang('document');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function delete()
- {
- if(!$this->acl_delete)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
- }
-
- $location_code =
get_var('location_code',array('POST','GET'));
- $p_num = get_var('p_num',array('POST','GET'));
- $document_id =
get_var('document_id',array('POST','GET'));
- $confirm = get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uidocument.list_doc',
- 'location_code' => $location_code,
- 'p_num' => $p_num
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($document_id);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.delete&document_id='
. $document_id . '&location_code=' . $location_code . '&p_num=' . $p_num),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('document');
- $function_msg =
lang('delete document');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function view()
- {
-
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $from =
get_var('from',array('POST','GET'));
- $document_id =
get_var('document_id',array('POST','GET'));
-
- if(!$from)
- {
- $from='index';
- }
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('document'));
-
- $values = $this->bo->read_single($document_id);
- $function_msg = lang('view document');
- $record_history =
$this->bo->read_record_history($document_id);
-
- $table_header_history[] = array
- (
- 'lang_date' => lang('Date'),
- 'lang_user' => lang('User'),
- 'lang_action' => lang('Action'),
- 'lang_new_value' => lang('New value')
- );
-
- if ($values['doc_type'])
- {
- $this->cat_id = $values['doc_type'];
- }
-
-
$location_data=$this->bolocation->initiate_ui_location(array(
- 'values' =>
$values['location_data'],
- 'type_id' =>
count(explode('-',$values['location_data']['location_code'])),
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' =>
False,
- 'lookup_type' => 'view',
- 'lookup_entity' =>
$this->bocommon->get_lookup_entity('document'),
- 'entity_data' => $values['p']
- ));
-
-
-
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
- 'type' =>
'view',
- 'vendor_id' =>
$values['vendor_id'],
- 'vendor_name' =>
$values['vendor_name']));
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uidocument.edit',
- 'document_id' => $document_id
- );
-
- $data = array
- (
- 'vendor_data'
=> $vendor_data,
- 'record_history'
=> $record_history,
- 'table_header_history' =>
$table_header_history,
- 'lang_history'
=> lang('History'),
- 'lang_no_history'
=> lang('No history'),
-
- 'lang_document_date'
=> lang('document date'),
- 'value_document_date' =>
$values['document_date'],
-
- 'vendor_data'
=> $vendor_data,
- 'location_data'
=> $location_data,
- 'location_type'
=> 'form',
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.'
.$from . '&location_code=' . $values['location_code'] . '&entity_id=' .
$values['p_entity_id'] . '&cat_id=' . $values['p_cat_id'] . '&preserve=1'),
- 'lang_year'
=> lang('Year'),
- 'lang_category'
=> lang('category'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
-
- 'lang_update_file'
=> lang('Update file'),
-
- 'lang_document_id'
=> lang('document ID'),
- 'value_document_id'
=> $document_id,
-
- 'lang_document_name'
=> lang('document name'),
- 'value_document_name' =>
$values['document_name'],
- 'lang_document_name_statustext'
=> lang('Enter document Name'),
-
- 'lang_floor_id'
=> lang('Floor ID'),
- 'value_floor_id'
=> $values['floor_id'],
- 'lang_floor_statustext' =>
lang('Enter the floor ID'),
-
- 'lang_title'
=> lang('title'),
- 'value_title'
=> $values['title'],
- 'lang_title_statustext' =>
lang('Enter document title'),
-
- 'lang_version'
=> lang('Version'),
- 'value_version'
=> $values['version'],
- 'lang_version_statustext' =>
lang('Enter document version'),
-
- 'lang_descr_statustext' =>
lang('Enter a description of the document'),
- 'lang_descr'
=> lang('Description'),
- 'value_descr'
=> $values['descr'],
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'lang_save_statustext' =>
lang('Save the document'),
- 'lang_no_cat'
=> lang('Select category'),
- 'lang_cat_statustext' =>
lang('Select the category the document belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'values[doc_type]',
- 'value_cat_id'
=> $values['doc_type'],
- 'cat_list'
=> $this->bo->select_doc_type_list('select',$values['doc_type']),
-
- 'lang_coordinator'
=> lang('Coordinator'),
- 'lang_user_statustext' =>
lang('Select the coordinator the document belongs to. To do not use a category
select NO USER'),
- 'select_user_name'
=> 'values[coordinator]',
- 'lang_no_user'
=> lang('Select coordinator'),
- 'user_list'
=>
$this->bocommon->get_user_list('select',$values['coordinator'],$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
-
- 'status_list'
=> $this->bo->select_status_list('select',$values['status']),
- 'status_name'
=> 'values[status]',
- 'lang_no_status'
=> lang('Select status'),
- 'lang_status'
=> lang('Status'),
- 'lang_status_statustext' =>
lang('What is the current status of this document ?'),
-
-
- 'branch_list'
=> $this->bo->select_branch_list($values['branch_id']),
- 'lang_no_branch'
=> lang('No branch'),
- 'lang_branch'
=> lang('branch'),
- 'lang_branch_statustext' =>
lang('Select the branch for this document'),
-
- 'edit_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.edit&document_id='
. $document_id . '&from=' . $from),
- 'lang_edit_statustext'
=> lang('Edit this entry'),
- 'lang_edit'
=> lang('Edit')
- );
-
- $appname = lang('document');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage document
+ * @version $Id: class.uidocument.inc.php,v 1.11 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uidocument
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+ var $part_of_town_id;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'list_doc' => True,
+ 'view' => True,
+ 'view_file' => True,
+ 'edit' => True,
+ 'delete' => True
+ );
+
+ function uidocument()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bo =
CreateObject($this->currentapp.'.bodocument',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+ $this->bolocation =
CreateObject($this->currentapp.'.bolocation');
+ $this->config =
CreateObject('phpgwapi.config',$this->currentapp);
+ $this->boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
+
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+ $this->acl2_location = '.document';
+ $this->acl_read =
$this->acl2->check('.document',1);
+ $this->acl_add =
$this->acl2->check('.document',2);
+ $this->acl_edit =
$this->acl2->check('.document',4);
+ $this->acl_delete =
$this->acl2->check('.document',8);
+
+ $this->rootdir =
$this->bo->rootdir;
+ $this->fakebase =
$this->bo->fakebase;
+ $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->status_id =
$this->bo->status_id;
+ $this->entity_id =
$this->bo->entity_id;
+ $this->doc_type =
$this->bo->doc_type;
+ $this->query_location =
$this->bo->query_location;
+
+ $this->menu->sub ='document';
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' => $this->filter,
+ 'cat_id' => $this->cat_id,
+ 'status_id' => $this->status_id,
+ 'entity_id' => $this->entity_id,
+ 'doc_type' => $this->doc_type,
+ 'query_location' => $this->query_location
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function index()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('document','values','table_header',
+
'menu',
+
'nextmatchs',
+
'search_field'));
+
+ $entity_id = get_var('entity_id',array('POST','GET'));
+ $links = $this->menu->links('document_'.$entity_id);
+
+ $preserve =
get_var('preserve',array('POST','GET'));
+
+ if($preserve)
+ {
+ $this->bo->read_sessiondata();
+
+ $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->status_id =
$this->bo->status_id;
+ $this->entity_id =
$this->bo->entity_id;
+ }
+
+ $document_list = $this->bo->read();
+
+//_debug_array($document_list);
+
+
+ $uicols = $this->bo->uicols;
+
+ $j=0;
+ while (is_array($document_list) &&
list(,$document_entry) = each($document_list))
+ {
+ for ($k=0;$k<count($uicols['name']);$k++)
+ {
+ if($uicols['input_type'][$k]!='hidden')
+ {
+
+
if($document_entry['query_location'][$uicols['name'][$k]])
+ {
+
+ $content[$j]['row'][]=
array(
+ 'statustext'
=> lang('search'),
+ 'text'
=> $document_entry[$uicols['name'][$k]],
+ 'link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.index&query='
. $document_entry['query_location'][$uicols['name'][$k]] . '&entity_id=' .
$document_entry['p_entity_id'] . '&cat_id=' . $document_entry['p_cat_id'])
+ );
+ }
+ else
+ {
+ $content[$j]['row'][]=
array(
+ 'value'
=> $document_entry[$uicols['name'][$k]],
+ 'name'
=> $uicols['name'][$k],
+ );
+ }
+
+ }
+ }
+
+ if($this->acl_read)
+ {
+ $content[$j]['row'][]= array(
+ 'statustext'
=> lang('view documents for this location/entity'),
+ 'text'
=> lang('documents'),
+ 'link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.list_doc&location_code='
. $document_entry['location_code'] . '&p_num=' . $document_entry['p_num'] .
'&entity_id=' . $document_entry['p_entity_id'] . '&cat_id=' .
$document_entry['p_cat_id'] . '&doc_type=' . $this->doc_type)
+ );
+ }
+
+ $j++;
+ }
+
+ for ($i=0;$i<count($uicols['descr']);$i++)
+ {
+ if($uicols['input_type'][$i]!='hidden')
+ {
+ $table_header[$i]['header'] =
$uicols['descr'][$i];
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ if($uicols['name'][$i]=='loc1')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'location_code',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uidocument.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'district_id' =>
$this->district_id,
+
'cat_id'
=>$this->cat_id,
+
'doc_type'
=>$this->doc_type,
+
'entity_id'
=>$this->entity_id)
+
));
+ }
+ if($uicols['name'][$i]=='document_id')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'document_id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uidocument.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'district_id' =>
$this->district_id,
+
'cat_id'
=>$this->cat_id,
+
'doc_type'
=>$this->doc_type,
+
'entity_id'
=>$this->entity_id)
+
));
+ }
+ if($uicols['name'][$i]=='address')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'address',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uidocument.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'district_id' =>
$this->district_id,
+
'cat_id'
=>$this->cat_id,
+
'doc_type'
=>$this->doc_type,
+
'entity_id'
=>$this->entity_id)
+
));
+ }
+ }
+ }
+
+ if($this->acl_read)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('view');
+ $i++;
+ }
+
+ if($this->acl_add)
+ {
+ $table_add[] = array
+ (
+ 'lang_add'
=> lang('add'),
+ 'lang_add_statustext' => lang('add a
document'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.edit&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id)
+
+ );
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uidocument.index',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'district_id'
=>$this->district_id,
+ 'filter'
=>$this->filter,
+ 'status_id'
=>$this->status_id,
+ 'query'
=>$this->query,
+ 'doc_type'
=>$this->doc_type,
+ 'entity_id'
=>$this->entity_id
+ );
+
+ if($this->entity_id)
+ {
+ $boentity =
CreateObject($this->currentapp.'.boentity');
+ $boentity->entity_id=$this->entity_id;
+ $cat_list =
$this->bo->select_category_list('filter',$this->cat_id);
+ $entity =
$this->boadmin_entity->read_single($this->entity_id,false);
+ $appname_sub = $entity['name'];
+ }
+ else
+ {
+ $appname_sub = lang('location');
+ }
+
+ $data = array
+ (
+ 'link_history'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.index&cat_id='
. $this->cat_id),
+ 'lang_history_statustext' =>
lang('search for history at this location'),
+ 'lang_select'
=> lang('select'),
+ 'links'
=> $links,
+ 'allow_allrows'
=> false,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($document_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'type'
=> $this->cat_id,
+ 'district_list'
=> $this->bocommon->select_district_list('filter',$this->district_id),
+ 'lang_no_district'
=> lang('no district'),
+ 'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
+ 'select_district_name' =>
'district_id',
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category. To do not use a category select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $cat_list,
+
+ 'lang_no_doc_type'
=> lang('no document type'),
+ 'lang_doc_type_statustext' =>
lang('Select the document type the document belongs to.'),
+ 'doc_type'
=> $this->bo->select_doc_type_list('filter',$this->doc_type),
+
+
+ 'lang_status_statustext' =>
lang('Select the status the document belongs to. To do not use a category
select NO STATUS'),
+ 'status_name'
=> 'status_id',
+ 'lang_no_status'
=> lang('No status'),
+ 'status_list'
=> $this->bo->select_status_list('filter',$this->status_id),
+
+ 'lang_user_statustext' =>
lang('Select the user the document belongs to. To do not use a category select
NO USER'),
+ 'select_user_name'
=> 'filter',
+ 'lang_no_user'
=> lang('No user'),
+ 'user_list'
=>
$this->bocommon->get_user_list_right2('filter',4,$this->filter,$this->acl2_location,array('all'),$default=$this->account),
+
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname = lang('document');
+ $function_msg = lang('list document');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg . ' - ' .
$appname_sub;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function list_doc()
+ {
+
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $preserve =
get_var('preserve',array('POST','GET'));
+
+ if($preserve)
+ {
+ $this->bo->read_sessiondata();
+
+ $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->entity_id =
$this->bo->entity_id;
+ $this->cat_id =
$this->bo->cat_id;
+ $this->status_id =
$this->bo->status_id;
+ }
+//_debug_array($this->cat_id);
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('document',
+
'menu',
+
'receipt',
+
'nextmatchs',
+
'search_field'));
+
+ $receipt =
$GLOBALS['phpgw']->session->appsession('session_data','document_receipt');
+
$GLOBALS['phpgw']->session->appsession('session_data','document_receipt','');
+
+ $location_code =
get_var('location_code',array('POST','GET'));
+ if($this->query_location)
+ {
+ $location_code = $this->query_location;
+ }
+
+ $p_num = get_var('p_num',array('POST','GET'));
+
+ $location=$this->bo->read_location_data($location_code);
+
+ if($this->cat_id)
+ {
+ $entity_data[$this->entity_id]['p_num']=$p_num;
+
$entity_data[$this->entity_id]['p_entity_id']=$this->entity_id;
+
$entity_data[$this->entity_id]['p_cat_id']=$this->cat_id;
+ $entity =
$this->boadmin_entity->read_single($this->entity_id,false);
+ $category =
$this->boadmin_entity->read_single_category($this->entity_id,$this->cat_id);
+ $lookup_entity =
$this->bocommon->get_lookup_entity('document');
+ $appname_sub = $entity['name'];
+ }
+ else
+ {
+ $appname_sub = lang('location');
+ }
+
+ if($category['name'])
+ {
+
$entity_data[$this->entity_id]['p_cat_name']=$category['name'];
+ }
+
+ $this->config->read_repository();
+ $files_url = $this->config->config_data['files_url'];
+
+ $links = $this->menu->links();
+
+ $document_list =
$this->bo->read_at_location($location_code);
+
+//_debug_array($document_list);
+
+ if($this->cat_id)
+ {
+ $directory = $this->fakebase. SEP .
'document' . SEP . $location['loc1'] . SEP . $entity['name'] . SEP .
$category['name'] . SEP . $p_num;
+ }
+ else
+ {
+ $directory = $this->fakebase. SEP .
'document' . SEP . $location['loc1'];
+ }
+
+ while (is_array($document_list) && list(,$document) =
each($document_list))
+ {
+ if($document['link'])
+ {
+ $link_view_file=$document['link'];
+ $document['document_name']='link';
+ unset($link_to_files);
+ }
+ else
+ {
+ if(!$link_to_files)
+ {
+ $link_view_file =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.view_file&document_id='
. $document['document_id'] . '&entity_id=' . $this->entity_id . '&cat_id=' .
$this->cat_id . '&p_num=' . $p_num);
+ $link_to_files = $files_url;
+ }
+ }
+
+ $content[] = array
+ (
+ 'directory'
=> $directory,
+ 'document_id'
=> $document['document_id'],
+ 'document_name'
=> $document['document_name'],
+ 'title'
=> $document['title'],
+ 'user'
=> $document['user'],
+ 'doc_type'
=> $document['doc_type'],
+ 'link_view_file'
=> $link_view_file,
+ 'link_to_files'
=> $link_to_files,
+ 'link_view'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.view&document_id='
. $document['document_id'] . '&from=list_doc'),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.edit&document_id='
. $document['document_id'] . '&from=list_doc'),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.delete&document_id='
. $document['document_id'] . '&location_code=' . $location_code . '&p_num=' .
$p_num),
+ 'lang_view_file_statustext' =>
lang('view the document'),
+ 'lang_view_statustext' =>
lang('view information about the document'),
+ 'lang_edit_statustext' =>
lang('edit information about the document'),
+ 'lang_delete_statustext' =>
lang('delete this document'),
+ 'text_view'
=> lang('view'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+
+
+ $table_header[] = array
+ (
+ 'sort_document_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'document_name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uidocument.list_doc',
+
'entity_id'
=>$this->entity_id,
+
'cat_id'
=>$this->cat_id,
+
'doc_type'
=>$this->doc_type,
+
'p_num'
=>$p_num,
+
'location_code'
=>$location_code,
+
'filter'
=>$this->filter,
+
'query'
=>$this->query,
+
'query_location'
=>$this->query_location
+
)
+
)),
+ 'lang_document_name' => lang('Document
name'),
+ 'lang_doc_type' => lang('Doc
type'),
+ 'lang_user' =>
lang('user'),
+ 'lang_title' =>
lang('Title'),
+ 'lang_view' => lang('view'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ );
+
+
+ $link_data_add = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uidocument.edit',
+ 'location_code'
=>$location_code,
+ 'p_entity_id'
=>$this->entity_id,
+ 'entity_id'
=>$this->entity_id,
+ 'p_cat_id'
=>$this->cat_id,
+ 'cat_id'
=>$this->cat_id,
+ 'p_num'
=>$p_num,
+ 'from'
=>'list_doc',
+ 'bypass'
=>True
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_statustext' => lang('add a
document'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data_add)
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uidocument.list_doc',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'entity_id'
=>$this->entity_id,
+ 'cat_id'
=>$this->cat_id,
+ 'p_num'
=>$p_num,
+ 'doc_type'
=>$this->doc_type,
+ 'location_code'
=>$location_code,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query,
+ 'query_location'
=>$this->query_location
+ );
+
+
+
$location_data=$this->bolocation->initiate_ui_location(array(
+ 'values' =>
$location,
+ 'type_id' =>
count(explode('-',$location_code)),
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' =>
False,
+ 'lookup_type' => 'view',
+ 'lookup_entity' =>
$lookup_entity,
+ 'entity_data' => $entity_data,
+ 'link_data' =>
$link_data,
+ 'query_link' => True
+ ));
+
+//_debug_array($location_data);
+
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'location_data'
=> $location_data,
+ 'link_history'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.list_doc&cat_id='
. $this->cat_id),
+ 'lang_history_statustext' =>
lang('search for history at this location'),
+ 'lang_select'
=> lang('select'),
+ 'lookup_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit'),
+ 'lookup'
=> $lookup,
+ 'links'
=> $links,
+ 'allow_allrows'
=> false,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($document_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'type'
=> $this->doc_type,
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the document belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'doc_type',
+ 'cat_list'
=> $this->bo->select_doc_type_list('filter',$this->doc_type),
+
+// 'district_list'
=> $this->bocommon->select_district_list('filter',$this->district_id),
+// 'lang_no_district'
=> lang('no district'),
+// 'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
+// 'select_district_name' =>
'district_id',
+
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+
+ 'lang_status_statustext' =>
lang('Select the status the document belongs to. To do not use a category
select NO STATUS'),
+ 'status_name'
=> 'status_id',
+ 'lang_no_status'
=> lang('No status'),
+ 'status_list'
=> $this->bo->select_status_list('filter',$this->status_id),
+
+ 'lang_user_statustext' =>
lang('Select the user the document belongs to. To do not use a category select
NO USER'),
+ 'select_user_name'
=> 'filter',
+ 'lang_no_user'
=> lang('No user'),
+ 'user_list'
=>
$this->bocommon->get_user_list_right2('filter',4,$this->filter,$this->acl2_location,array('all'),$default=$this->account),
+
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_document' =>
$table_header,
+ 'values_document'
=> $content,
+ 'table_add'
=> $table_add,
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.index&preserve=1'),
+ 'lang_done'
=> lang('done'),
+ 'lang_done_statustext' =>
lang('Back to the list')
+ );
+
+ $appname = lang('document');
+ $function_msg = lang('list document');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg . ' - ' .
$appname_sub;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_document' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function view_file()
+ {
+ $GLOBALS['phpgw_info']['flags'][noheader] = True;
+ $GLOBALS['phpgw_info']['flags'][nofooter] = True;
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
+
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $document_id =
get_var('document_id',array('POST','GET'));
+ $p_num = get_var('p_num',array('POST','GET'));
+
+
+ $values = $this->bo->read_single($document_id);
+
+ if($this->cat_id)
+ {
+ $entity =
$this->boadmin_entity->read_single($this->entity_id,false);
+ $category =
$this->boadmin_entity->read_single_category($this->entity_id,$this->cat_id);
+ $file = $this->fakebase. SEP . 'document' .
SEP . $values['location_data']['loc1'] . SEP . $entity['name'] . SEP .
$category['name'] . SEP . $p_num . SEP . $values['document_name'];
+ }
+ else
+ {
+ $file = $this->fakebase. SEP . 'document' .
SEP .$values['location_data']['loc1'] . SEP . $values['document_name'];
+ }
+
+ if($this->bo->vfs->file_exists(array(
+ 'string' => $file,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+
+ $size =
$this->bo->vfs->get_size(array(
+ 'string' => $file,
+ 'relatives' =>
Array(RELATIVE_NONE),
+ 'checksubdirs' =>
True));
+
+ $document= $this->bo->vfs->read(array(
+ 'string' => $file,
+ 'relatives' => Array(RELATIVE_NONE)));
+
+ $filename =
basename($values['document_name']);
+ $filetype = array_pop(explode('.',
basename($file)));
+ $browser = CreateObject('phpgwapi.browser');
+
$browser->content_header($filename,$filetype,$size);
+
+ echo $document;
+ }
+ }
+
+
+ function edit()
+ {
+ if(!$this->acl_add && !$this->acl_edit)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
+ }
+
+ $from =
get_var('from',array('POST','GET'));
+ $document_id =
get_var('document_id',array('POST','GET'));
+// $location_code =
get_var('location_code',array('POST','GET'));
+ $values =
get_var('values',array('POST'));
+ $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
+ $insert_record_entity =
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp);
+
+ for ($j=0;$j<count($insert_record_entity);$j++)
+ {
+
$insert_record['extra'][$insert_record_entity[$j]] =
$insert_record_entity[$j];
+ }
+
+ if(!$from)
+ {
+ $from='index';
+ }
+ $GLOBALS['phpgw']->xslttpl->add_file(array('document'));
+
+ $bypass =
get_var('bypass',array('POST','GET'));
+
+ $receipt = $this->bo->create_home_dir();
+
+ if($_POST && !$bypass)
+ {
+ for ($i=0;
$i<count($insert_record['location']); $i++)
+ {
+
if($_POST[$insert_record['location'][$i]])
+ {
+
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
+ }
+ }
+
+ while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
+ {
+ if($_POST[$key])
+ {
+ $values['extra'][$column]
= $_POST[$key];
+ }
+ }
+
+ $values['street_name'] =
$_POST['street_name'];
+ $values['street_number'] =
$_POST['street_number'];
+ $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
+
+ }
+ else
+ {
+ $location_code =
get_var('location_code',array('POST','GET'));
+ $p_entity_id =
get_var('p_entity_id',array('POST','GET'));
+ $p_cat_id =
get_var('p_cat_id',array('POST','GET'));
+ $values['p'][$p_entity_id]['p_entity_id']
= $p_entity_id;
+ $values['p'][$p_entity_id]['p_cat_id']
= $p_cat_id;
+ $values['p'][$p_entity_id]['p_num']
= get_var('p_num',array('POST','GET'));
+ $values['p_entity_id']=$p_entity_id;
+ $values['p_cat_id']=$p_cat_id;
+
+ if($p_entity_id && $p_cat_id)
+ {
+ $entity_category =
$this->boadmin_entity->read_single_category($p_entity_id,$p_cat_id);
+
$values['p'][$p_entity_id]['p_cat_name'] = $entity_category['name'];
+ }
+
+ if($location_code)
+ {
+ $values['location_data'] =
$this->bolocation->read_single($location_code,array());
+ }
+
+ }
+
+
+//_debug_array($values);
+ if($values[extra]['p_entity_id'])
+ {
+ $this->entity_id=$values[extra]['p_entity_id'];
+ $this->cat_id=$values[extra]['p_cat_id'];
+ $p_num=$values['extra']['p_num'];
+ }
+
+ if($this->cat_id)
+ {
+ $entity =
$this->boadmin_entity->read_single($this->entity_id,false);
+ $category =
$this->boadmin_entity->read_single_category($this->entity_id,$this->cat_id);
+ $values['entity_name']=$entity['name'];
+ $values['category_name']=$category['name'];
+ }
+
+ if ($values['save'])
+ {
+ $values['document_date'] =
get_var('document_date',array('POST'));
+ $values['vendor_id'] =
get_var('vendor_id',array('POST'));
+
+ if(!$values['link'])
+ {
+
$values['document_name']=$_FILES['document_file']['name'];
+ }
+
+ if((!$values['document_name'] &&
!$values['document_name_orig']) && !$values['link'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a file to upload !'));
+ }
+
+ if(!$values['doc_type'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
+ $error_id=true;
+ }
+
+ if(!$values['status'])
+ {
+//
$receipt['error'][]=array('msg'=>lang('Please select a status !'));
+ }
+ if(!$values['location'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a location !'));
+ }
+
+ if($values['extra']['p_num'])
+ {
+ $to_file = $this->fakebase. SEP .
'document' . SEP . $values['location']['loc1'] . SEP . $entity['name'] . SEP .
$category['name'] . SEP . $values['extra']['p_num'] . SEP .
$values['document_name'];
+ }
+ else
+ {
+ $to_file = $this->fakebase. SEP .
'document' . SEP . $values['location']['loc1'] . SEP . $values['document_name'];
+ }
+
+ if(!$values['document_name_orig'] &&
$this->bo->vfs->file_exists(array(
+ 'string' => $to_file,
+ 'relatives' =>
Array(RELATIVE_NONE)
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('This file already exists !'));
+ }
+
+
$receipt=$this->bo->create_document_dir(array('loc1'=>$values['location']['loc1'],'entity_name'=>$entity['name'],'category_name'=>$category['name'],
'p_num'=>$values['extra']['p_num']),$receipt);
+
+ $values['document_id'] = $document_id;
+
+
+ if(!$receipt['error'])
+ {
+ if($values['document_name'] &&
!$values['link'])
+ {
+ if(!$this->bo->vfs->cp (array (
+ 'from' =>
$_FILES['document_file']['tmp_name'],
+ 'to' => $to_file,
+ 'relatives' =>
array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
+ {
+
$receipt['error'][]=array('msg'=>lang('Failed to upload file !'));
+ }
+ }
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$this->bo->save($values);
+ //
$document_id=$receipt['document_id'];
+
$GLOBALS['phpgw']->session->appsession('session_data','document_receipt',$receipt);
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uidocument.list_doc&location_code='
.implode("-", $values['location']) . '&entity_id=' . $this->entity_id .
'&cat_id=' . $this->cat_id . '&p_num=' . $values['extra']['p_num'] );
+ }
+ }
+ else
+ {
+ $values['document_name']='';
+ if($values['location'])
+ {
+ $location_code=implode("-",
$values['location']);
+ $values['location_data'] =
$this->bolocation->read_single($location_code,$values['extra']);
+ }
+ if($values['extra']['p_num'])
+ {
+
$values['p'][$values['extra']['p_entity_id']]['p_num']=$values['extra']['p_num'];
+
$values['p'][$values['extra']['p_entity_id']]['p_entity_id']=$values['extra']['p_entity_id'];
+
$values['p'][$values['extra']['p_entity_id']]['p_cat_id']=$values['extra']['p_cat_id'];
+
$values['p'][$values['extra']['p_entity_id']]['p_cat_name']=$_POST['entity_cat_name_'.$values['extra']['p_entity_id']];
+ }
+ }
+ }
+
+ if ($document_id ||(!$receipt['error'] &&
$values['document_id']))
+ {
+ $values = $this->bo->read_single($document_id);
+ $record_history =
$this->bo->read_record_history($document_id);
+ $function_msg = lang('Edit document');
+ }
+ else
+ {
+ $function_msg = lang('Add document');
+ }
+
+ $table_header_history[] = array
+ (
+ 'lang_date' => lang('Date'),
+ 'lang_user' => lang('User'),
+ 'lang_action' => lang('Action'),
+ 'lang_new_value' => lang('New value')
+ );
+
+ if ($values['doc_type'])
+ {
+ $this->doc_type = $values['doc_type'];
+ }
+ if ($values['location_code'])
+ {
+ $location_code = $values['location_code'];
+ }
+/* if ($values['p_num'])
+ {
+ $p_num = $values['p_num'];
+ }
+*/
+
$location_data=$this->bolocation->initiate_ui_location(array(
+ 'values' =>
$values['location_data'],
+ 'type_id' => -1,
// calculated from location_types
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' =>
False,
+ 'lookup_type' => 'form',
+ 'lookup_entity' =>
$this->bocommon->get_lookup_entity('document'),
+ 'entity_data' => $values['p']
+ ));
+
+
+
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
+ 'vendor_id' =>
$values['vendor_id'],
+ 'vendor_name' =>
$values['vendor_name']));
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uidocument.edit',
+ 'document_id' => $document_id,
+ 'from' => $from,
+ 'location_code' =>
$values['location_code'],
+ 'entity_id'
=>$this->entity_id,
+ 'cat_id' =>$this->cat_id,
+ );
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'vendor_data'
=> $vendor_data,
+ 'record_history'
=> $record_history,
+ 'table_header_history' =>
$table_header_history,
+ 'lang_history'
=> lang('History'),
+ 'lang_no_history'
=> lang('No history'),
+
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle'
=> lang('Select date'),
+ 'calendar_setup'
=> "Calendar.setup({inputField : 'document_date',ifFormat : '" .
$jsDateFormat . "',button : 'document_date-trigger'});",
+
+ 'lang_document_date_statustext' => lang('Select
date the document was created'),
+ 'lang_document_date' =>
lang('document date'),
+ 'value_document_date' =>
$values['document_date'],
+
+ 'vendor_data'
=> $vendor_data,
+ 'location_data'
=> $location_data,
+ 'location_type'
=> 'form',
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_year'
=> lang('Year'),
+ 'lang_category'
=> lang('category'),
+ 'lang_save'
=> lang('save'),
+ 'lang_save_statustext' =>
lang('Save the document'),
+
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.'
.$from . '&location_code=' . $location_code . '&entity_id=' . $this->entity_id
. '&cat_id=' . $this->cat_id . '&p_num=' . $p_num . '&preserve=1'),
+ 'lang_done'
=> lang('done'),
+ 'lang_done_statustext' =>
lang('Back to the list'),
+
+ 'lang_update_file'
=> lang('Update file'),
+
+ 'lang_document_id'
=> lang('document ID'),
+ 'value_document_id'
=> $document_id,
+
+ 'lang_document_name'
=> lang('document name'),
+ 'value_document_name' =>
$values['document_name'],
+ 'lang_document_name_statustext'
=> lang('Enter document Name'),
+
+ 'lang_floor_id'
=> lang('Floor ID'),
+ 'value_floor_id'
=> $values['floor_id'],
+ 'lang_floor_statustext' =>
lang('Enter the floor ID'),
+
+ 'lang_title'
=> lang('title'),
+ 'value_title'
=> $values['title'],
+ 'lang_title_statustext' =>
lang('Enter document title'),
+
+ 'lang_version'
=> lang('Version'),
+ 'value_version'
=> $values['version'],
+ 'lang_version_statustext' =>
lang('Enter document version'),
+
+ 'lang_link'
=> lang('Link'),
+ 'value_link'
=> $values['link'],
+ 'lang_link_statustext' =>
lang('Alternative - link instead of uploading a file'),
+
+ 'lang_descr_statustext' =>
lang('Enter a description of the document'),
+ 'lang_descr'
=> lang('Description'),
+ 'value_descr'
=> $values['descr'],
+ 'lang_no_cat'
=> lang('Select category'),
+ 'lang_cat_statustext' =>
lang('Select the category the document belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'values[doc_type]',
+ 'value_cat_id'
=> $values['doc_type'],
+ 'cat_list'
=> $this->bo->select_doc_type_list('select',$values['doc_type']),
+
+ 'lang_coordinator'
=> lang('Coordinator'),
+ 'lang_user_statustext' =>
lang('Select the coordinator the document belongs to. To do not use a category
select NO USER'),
+ 'select_user_name'
=> 'values[coordinator]',
+ 'lang_no_user'
=> lang('Select coordinator'),
+ 'user_list'
=>
$this->bocommon->get_user_list_right2('select',4,$values['coordinator'],$this->acl2_location),
+
+ 'status_list'
=> $this->bo->select_status_list('select',$values['status']),
+ 'status_name' =>
'values[status]',
+ 'lang_no_status'
=> lang('Select status'),
+ 'lang_status'
=> lang('Status'),
+ 'lang_status_statustext' =>
lang('What is the current status of this document ?'),
+
+ 'value_location_code' =>
$values['location_code'],
+
+ 'branch_list'
=> $this->bo->select_branch_list($values['branch_id']),
+ 'lang_no_branch'
=> lang('No branch'),
+ 'lang_branch'
=> lang('branch'),
+ 'lang_branch_statustext' =>
lang('Select the branch for this document')
+ );
+
+ $appname = lang('document');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function delete()
+ {
+ if(!$this->acl_delete)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
+ }
+
+ $location_code =
get_var('location_code',array('POST','GET'));
+ $p_num = get_var('p_num',array('POST','GET'));
+ $document_id =
get_var('document_id',array('POST','GET'));
+ $confirm = get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uidocument.list_doc',
+ 'location_code' => $location_code,
+ 'p_num' => $p_num
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($document_id);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.delete&document_id='
. $document_id . '&location_code=' . $location_code . '&p_num=' . $p_num),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('document');
+ $function_msg =
lang('delete document');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function view()
+ {
+
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $from =
get_var('from',array('POST','GET'));
+ $document_id =
get_var('document_id',array('POST','GET'));
+
+ if(!$from)
+ {
+ $from='index';
+ }
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('document'));
+
+ $values = $this->bo->read_single($document_id);
+ $function_msg = lang('view document');
+ $record_history =
$this->bo->read_record_history($document_id);
+
+ $table_header_history[] = array
+ (
+ 'lang_date' => lang('Date'),
+ 'lang_user' => lang('User'),
+ 'lang_action' => lang('Action'),
+ 'lang_new_value' => lang('New value')
+ );
+
+ if ($values['doc_type'])
+ {
+ $this->cat_id = $values['doc_type'];
+ }
+
+
$location_data=$this->bolocation->initiate_ui_location(array(
+ 'values' =>
$values['location_data'],
+ 'type_id' =>
count(explode('-',$values['location_data']['location_code'])),
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' =>
False,
+ 'lookup_type' => 'view',
+ 'lookup_entity' =>
$this->bocommon->get_lookup_entity('document'),
+ 'entity_data' => $values['p']
+ ));
+
+
+
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
+ 'type' =>
'view',
+ 'vendor_id' =>
$values['vendor_id'],
+ 'vendor_name' =>
$values['vendor_name']));
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uidocument.edit',
+ 'document_id' => $document_id
+ );
+
+ $data = array
+ (
+ 'vendor_data'
=> $vendor_data,
+ 'record_history'
=> $record_history,
+ 'table_header_history' =>
$table_header_history,
+ 'lang_history'
=> lang('History'),
+ 'lang_no_history'
=> lang('No history'),
+
+ 'lang_document_date'
=> lang('document date'),
+ 'value_document_date' =>
$values['document_date'],
+
+ 'vendor_data'
=> $vendor_data,
+ 'location_data'
=> $location_data,
+ 'location_type'
=> 'form',
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.'
.$from . '&location_code=' . $values['location_code'] . '&entity_id=' .
$values['p_entity_id'] . '&cat_id=' . $values['p_cat_id'] . '&preserve=1'),
+ 'lang_year'
=> lang('Year'),
+ 'lang_category'
=> lang('category'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+
+ 'lang_update_file'
=> lang('Update file'),
+
+ 'lang_document_id'
=> lang('document ID'),
+ 'value_document_id'
=> $document_id,
+
+ 'lang_document_name'
=> lang('document name'),
+ 'value_document_name' =>
$values['document_name'],
+ 'lang_document_name_statustext'
=> lang('Enter document Name'),
+
+ 'lang_floor_id'
=> lang('Floor ID'),
+ 'value_floor_id'
=> $values['floor_id'],
+ 'lang_floor_statustext' =>
lang('Enter the floor ID'),
+
+ 'lang_title'
=> lang('title'),
+ 'value_title'
=> $values['title'],
+ 'lang_title_statustext' =>
lang('Enter document title'),
+
+ 'lang_version'
=> lang('Version'),
+ 'value_version'
=> $values['version'],
+ 'lang_version_statustext' =>
lang('Enter document version'),
+
+ 'lang_descr_statustext' =>
lang('Enter a description of the document'),
+ 'lang_descr'
=> lang('Description'),
+ 'value_descr'
=> $values['descr'],
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'lang_save_statustext' =>
lang('Save the document'),
+ 'lang_no_cat'
=> lang('Select category'),
+ 'lang_cat_statustext' =>
lang('Select the category the document belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'values[doc_type]',
+ 'value_cat_id'
=> $values['doc_type'],
+ 'cat_list'
=> $this->bo->select_doc_type_list('select',$values['doc_type']),
+
+ 'lang_coordinator'
=> lang('Coordinator'),
+ 'lang_user_statustext' =>
lang('Select the coordinator the document belongs to. To do not use a category
select NO USER'),
+ 'select_user_name'
=> 'values[coordinator]',
+ 'lang_no_user'
=> lang('Select coordinator'),
+ 'user_list'
=>
$this->bocommon->get_user_list('select',$values['coordinator'],$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
+
+ 'status_list'
=> $this->bo->select_status_list('select',$values['status']),
+ 'status_name'
=> 'values[status]',
+ 'lang_no_status'
=> lang('Select status'),
+ 'lang_status'
=> lang('Status'),
+ 'lang_status_statustext' =>
lang('What is the current status of this document ?'),
+
+
+ 'branch_list'
=> $this->bo->select_branch_list($values['branch_id']),
+ 'lang_no_branch'
=> lang('No branch'),
+ 'lang_branch'
=> lang('branch'),
+ 'lang_branch_statustext' =>
lang('Select the branch for this document'),
+
+ 'edit_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uidocument.edit&document_id='
. $document_id . '&from=' . $from),
+ 'lang_edit_statustext'
=> lang('Edit this entry'),
+ 'lang_edit'
=> lang('Edit')
+ );
+
+ $appname = lang('document');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+
+ }
+?>
Index: property/inc/class.uientity.inc.php
diff -u property/inc/class.uientity.inc.php:1.15
property/inc/class.uientity.inc.php:1.16
--- property/inc/class.uientity.inc.php:1.15 Wed Nov 9 22:49:12 2005
+++ property/inc/class.uientity.inc.php Fri Jan 27 14:05:43 2006
@@ -1,1184 +1,1184 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage entity
- * @version $Id: class.uientity.inc.php,v 1.15 2005/11/09 22:49:12
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uientity
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
- var $part_of_town_id;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'columns' => True,
- 'excel' => True,
- 'index' => True,
- 'view' => True,
- 'edit' => True,
- 'delete' => True,
- 'view_file' =>True
- );
-
- function uientity()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- $this->bo =
CreateObject($this->currentapp.'.boentity',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
-
- $this->boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity',True);
-
- $this->entity_id =
$this->bo->entity_id;
- $this->cat_id =
$this->bo->cat_id;
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
- if(!$this->cat_id)
- {
- $this->acl2_location = '.entity.' .
$this->entity_id;
- }
- else
- {
- $this->acl2_location = '.entity.' .
$this->entity_id . '.' . $this->cat_id;
- }
- $this->acl_read =
$this->acl2->check($this->acl2_location,1);
- $this->acl_add =
$this->acl2->check($this->acl2_location,2);
- $this->acl_edit =
$this->acl2->check($this->acl2_location,4);
- $this->acl_delete =
$this->acl2->check($this->acl2_location,8);
-
- $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->part_of_town_id =
$this->bo->part_of_town_id;
- $this->district_id =
$this->bo->district_id;
- $this->status =
$this->bo->status;
- $this->fakebase =
$this->bo->fakebase;
- $this->category_name =
$this->bo->category_name;
- $this->menu->sub
='entity_'.$this->entity_id;
-
$GLOBALS['phpgw']->session->appsession('entity_id',$this->currentapp,$this->entity_id);
- $this->start_date =
$this->bo->start_date;
- $this->end_date =
$this->bo->end_date;
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' => $this->filter,
- 'cat_id' => $this->cat_id,
- 'part_of_town_id' =>
$this->part_of_town_id,
- 'district_id' => $this->district_id,
- 'entity_id' => $this->entity_id,
- 'status' => $this->status,
- 'start_date' => $this->start_date,
- 'end_date' => $this->end_date
- );
- $this->bo->save_sessiondata($data);
- }
-
- function excel()
- {
- $GLOBALS['phpgw_info']['flags'][noheader] = True;
- $GLOBALS['phpgw_info']['flags'][nofooter] = True;
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
-
- $start_date = urldecode($this->start_date);
- $end_date = urldecode($this->end_date);
-
- $list =
$this->bo->read(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'allrows'=>true,'start_date'=>$start_date,'end_date'=>$end_date));
- $uicols = $this->bo->uicols;
-
- $filename=
$GLOBALS['phpgw_info']['user']['account_lid'].'.xls';
- $count_uicols_name=count($uicols['name']);
-
- $workbook =
CreateObject($this->currentapp.'.excel',"-");
- $browser = CreateObject('phpgwapi.browser');
-
$browser->content_header($filename,'application/vnd.ms-excel');
-
- $worksheet1 =& $workbook->add_worksheet('First One');
-
- $j=0;
- if (isset($list) AND is_array($list))
- {
- foreach($list as $entry)
- {
- $m=0;
- for ($k=0;$k<$count_uicols_name;$k++)
- {
-
if($uicols['input_type'][$k]!='hidden')
- {
- $content[$j][$m]
= $entry[$uicols['name'][$k]];
-
$worksheet1->write_string(0, $m, $uicols['descr'][$k]);
- $m++;
- }
- }
- $j++;
- }
-
- foreach($content as $row)
- {
- $line++;
- for ($i=0; $i<count($row); $i++)
- {
-
$worksheet1->write($line,$i,$row[$i]);
- }
- }
- }
- $workbook->close();
- }
-
-
- function columns()
- {
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('columns'));
-
- $GLOBALS['phpgw_info']['flags']['noframework'] = True;
-
- $values =
get_var('values',array('POST','GET'));
-
- if ($values['save'] && $this->cat_id)
- {
-
$GLOBALS['phpgw']->preferences->account_id=$this->account;
-
$GLOBALS['phpgw']->preferences->read_repository();
-
$GLOBALS['phpgw']->preferences->add($this->currentapp,"entity_columns_" .
$this->entity_id . '_' . $this->cat_id,$values['columns'],'user');
-
$GLOBALS['phpgw']->preferences->save_repository();
-
- $receipt['message'][] = array('msg' =>
lang('columns is updated'));
- }
-
- if(!$this->cat_id)
- {
- $receipt['error'][] = array('msg' =>
lang('Choose a category'));
- }
- $function_msg = lang('Select Column');
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uientity.columns',
- 'entity_id' =>
$this->entity_id,
- 'cat_id' => $this->cat_id
- );
-
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'column_list' =>
$this->bo->column_list($values['columns'],$entity_id=$this->entity_id,$cat_id=$this->cat_id,$allrows=True),
- 'function_msg' => $function_msg,
- 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_columns' => lang('columns'),
- 'lang_none' => lang('None'),
- 'lang_save' => lang('save'),
- 'select_name' => 'period'
- );
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
$function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('columns' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function view_file()
- {
- $GLOBALS['phpgw_info']['flags'][noheader] = True;
- $GLOBALS['phpgw_info']['flags'][nofooter] = True;
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
-
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $file_name =
urldecode(get_var('file_name',array('POST','GET')));
- $loc1 = get_var('loc1',array('POST','GET'));
- $id = get_var('id',array('POST','GET'));
-
- $file = $this->fakebase. SEP . $this->category_name .
SEP . $loc1 . SEP . $id . SEP . $file_name;
-
-//echo 'file: ' . $file . '<br>';
- if($this->bo->vfs->file_exists(array(
- 'string' => $file,
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
- $size =
$this->bo->vfs->get_size(array(
- 'string' => $file,
- 'relatives' =>
Array(RELATIVE_NONE),
- 'checksubdirs' =>
True));
-
- $document= $this->bo->vfs->read(array(
- 'string' => $file,
- 'relatives' => Array(RELATIVE_NONE)));
-
- $filename =
basename($values['document_name']);
- $filetype = array_pop(explode('.',
basename($file)));
- $browser = CreateObject('phpgwapi.browser');
-
$browser->content_header($filename,$filetype,$size);
-
- echo $document;
-
- }
- }
-
- function index()
- {
- if(!$this->acl_read && $this->cat_id)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('entity',
- 'menu',
-
'nextmatchs'));
-
- $links = $this->menu->links();
-
- $start_date = urldecode($this->start_date);
- $end_date = urldecode($this->end_date);
-
- $entity_list =
$this->bo->read(array('start_date'=>$start_date,'end_date'=>$end_date));
-
- $uicols = $this->bo->uicols;
-
- $j=0;
-
- if (isset($entity_list) AND is_array($entity_list))
- {
- foreach($entity_list as $entity_entry)
- {
- for
($i=0;$i<count($uicols['name']);$i++)
- {
-
if($uicols['input_type'][$i]!='hidden')
- {
-
if($entity_entry['query_location'][$uicols['name'][$i]])
- {
-
$content[$j]['row'][$i]['statustext'] = lang('search');
-
$content[$j]['row'][$i]['text'] =
$entity_entry[$uicols['name'][$i]];
-
$content[$j]['row'][$i]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.index&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id .'&query=' .
$entity_entry['query_location'][$uicols['name'][$i]]);
- }
- else
- {
-
$content[$j]['row'][$i]['value'] =
$entity_entry[$uicols['name'][$i]];
-
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
- }
- }
- }
-
- if($this->acl_read)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('view the
entity');
- $content[$j]['row'][$i]['text']
= lang('view');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.view&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id .'&id=' . $entity_entry['id']);
- }
- if($this->acl_edit)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('edit the
entity');
- $content[$j]['row'][$i]['text']
= lang('edit');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.edit&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id .'&id=' . $entity_entry['id']);
- }
- if($this->acl_delete)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('delete the
entity');
- $content[$j]['row'][$i]['text']
= lang('delete');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.delete&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id .'&id=' . $entity_entry['id']);
- }
-
- $j++;
- }
- }
-
- for ($i=0;$i<count($uicols['descr']);$i++)
- {
- if($uicols['input_type'][$i]!='hidden')
- {
- $table_header[$i]['header'] =
$uicols['descr'][$i];
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- if($uicols['datatype'][$i]!='T' &&
$uicols['datatype'][$i]!='CH')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
- (
- 'sort' =>
$this->sort,
- 'var' =>
$uicols['name'][$i],
- 'order' =>
$this->order,
- 'extra'
=> array('menuaction' => $this->currentapp.'.uientity.index',
-
'type_id' =>$type_id,
-
'query' =>$this->query,
-
'lookup' =>$lookup,
-
'district_id' => $this->district_id,
-
'entity_id' =>$this->entity_id,
-
'cat_id' =>$this->cat_id,
-
'start_date'=>$start_date,
-
'end_date'=>$end_date)
- ));
- }
- }
- }
-
- if($this->acl_read)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('view');
- $i++;
- }
- if($this->acl_edit)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('edit');
- $i++;
- }
- if($this->acl_delete)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('delete');
- $i++;
- }
-
-
- if($this->acl_add)
- {
- $table_add[] = array
- (
- 'lang_add'
=> lang('add'),
- 'lang_add_statustext' => lang('add a
entity'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.edit&entity_id='.
$this->entity_id .'&cat_id='. $this->cat_id)
- );
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uientity.index',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'entity_id'
=>$this->entity_id,
- 'district_id'
=>$this->district_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query,
- 'start_date' =>$start_date,
- 'end_date'
=>$end_date
- );
-
- $link_excel = array
- (
- 'menuaction' =>
$this->currentapp.'.uientity.excel',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'entity_id'
=>$this->entity_id,
- 'cat_id'
=>$this->cat_id,
- 'district_id'
=>$this->district_id,
- 'status_id'
=>$this->status,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query,
- 'start_date' =>$start_date,
- 'end_date'
=>$end_date,
- 'start' =>$this->start
- );
-
- $link_columns = array
- (
- 'menuaction' =>
$this->currentapp.'.uientity.columns',
- 'entity_id'
=>$this->entity_id,
- 'cat_id'
=>$this->cat_id
- );
-
- $link_date_search
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.date_search');
-
-
if($GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['group_filters'])
- {
- $group_filters = 'select';
-
$GLOBALS['phpgw']->xslttpl->add_file(array('search_field_grouped'));
- }
- else
- {
- $group_filters = 'filter';
-
$GLOBALS['phpgw']->xslttpl->add_file(array('search_field'));
- }
-
- $data = array
- (
- 'group_filters' =>
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['group_filters'],
- 'lang_excel' =>
'excel',
- 'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
- 'lang_excel_help' =>
lang('Download table to MS Excel'),
-
- 'lang_columns' =>
lang('columns'),
- 'link_columns' =>
$GLOBALS['phpgw']->link('/index.php',$link_columns),
- 'lang_columns_help' =>
lang('Choose columns'),
-
- 'start_date' =>
$start_date,
- 'end_date'
=> $end_date,
- 'lang_none'
=> lang('None'),
- 'lang_date_search' =>
lang('Date search'),
- 'lang_date_search_help' => lang('Narrow
the search by dates'),
- 'link_date_search' =>
$link_date_search,
- 'lang_date_search' =>
lang('Date search'),
- 'overlib_source' =>
'./'.$this->currentapp.'/inc/overlib.js',
-
-
- 'links'
=> $links,
- 'allow_allrows'
=> false,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($entity_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
-
- 'district_list'
=> $this->bocommon->select_district_list($group_filters,$this->district_id),
- 'lang_no_district'
=> lang('no district'),
- 'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
- 'select_district_name' =>
'district_id',
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
-
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category. To do not use a category select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $this->bo->select_category_list($group_filters,$this->cat_id),
-
- 'lang_status_statustext' =>
lang('Select the status. To do not use a status select NO STATUS'),
- 'status_name'
=> 'status',
- 'lang_no_status'
=> lang('No status'),
- 'status_list'
=> $this->bo->select_status_list($group_filters,$this->status),
-
- 'lang_user_statustext' =>
lang('Select the user. To do not use a category select NO USER'),
- 'select_user_name'
=> 'filter',
- 'lang_no_user'
=> lang('No user'),
- 'user_list'
=>
$this->bocommon->get_user_list_right2($group_filters,4,$this->filter,$this->acl2_location,array('all'),$default='all'),
-
- 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
-
- if($this->entity_id)
- {
- $entity =
$this->boadmin_entity->read_single($this->entity_id,false);
- $appname = $entity['name'];
- }
- if($this->cat_id)
- {
- $category =
$this->boadmin_entity->read_single_category($this->entity_id,$this->cat_id);
- $function_msg
= 'list ' . $category['name'];
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
- }
-
- if(!$this->entity_id || !$this->cat_id)
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- $receipt['error'][]=array('msg'=>lang('Please
select type'));
- $msgbox_data =
$this->bocommon->msgbox_data($receipt);
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('empty' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
- else
- {
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
- }
-
- function edit()
- {
- if(!$this->acl_add && !$this->acl_edit)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
- }
-
- $config =
CreateObject('phpgwapi.config',$this->currentapp);
- $bolocation =
CreateObject($this->currentapp.'.bolocation');
-
- $id =
get_var('id',array('POST','GET'));
- $values =
get_var('values',array('POST','GET'));
- $values_attribute =
get_var('values_attribute',array('POST','GET'));
- $bypass =
get_var('bypass',array('POST','GET'));
- $lookup_tenant =
get_var('lookup_tenant',array('POST','GET'));
- $tenant_id =
get_var('tenant_id',array('POST','GET'));
-
- $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
- $insert_record_entity =
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp);
-
- for ($j=0;$j<count($insert_record_entity);$j++)
- {
-
$insert_record['extra'][$insert_record_entity[$j]] =
$insert_record_entity[$j];
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('entity','attributes_form'));
-
- $values['vendor_id'] =
get_var('vendor_id',array('POST'));
- $values['vendor_name'] =
get_var('vendor_name',array('POST'));
- $values['date'] =
get_var('date',array('POST'));
- $ticket_id =
get_var('ticket_id',array('POST','GET'));
- $request_id =
get_var('request_id',array('POST','GET'));
-
- if($_POST && !$bypass)
- {
-
- for ($i=0;
$i<count($insert_record['location']); $i++)
- {
-
if($_POST[$insert_record['location'][$i]])
- {
-
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
- }
- }
-
- while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
- {
- if($_POST[$key])
- {
- $values['extra'][$column]
= $_POST[$key];
- }
- }
-
- $values['street_name'] =
$_POST['street_name'];
- $values['street_number'] =
$_POST['street_number'];
- $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
-
- }
- else
- {
- $location_code =
get_var('location_code',array('POST','GET'));
- $values['descr'] =
get_var('descr',array('POST','GET'));
- $p_entity_id =
get_var('p_entity_id',array('POST','GET'));
- $p_cat_id =
get_var('p_cat_id',array('POST','GET'));
- $values['p'][$p_entity_id]['p_entity_id']
= $p_entity_id;
- $values['p'][$p_entity_id]['p_cat_id']
= $p_cat_id;
- $values['p'][$p_entity_id]['p_num']
= get_var('p_num',array('POST','GET'));
-
-
- $origin =
get_var('origin',array('POST','GET'));
- $origin_id =
get_var('origin_id',array('POST','GET'));
-
-
- if($p_entity_id && $p_cat_id)
- {
- $entity_category =
$this->boadmin_entity->read_single_category($p_entity_id,$p_cat_id);
-
$values['p'][$p_entity_id]['p_cat_name'] = $entity_category['name'];
- }
-
-
- if($location_code)
- {
- $values['location_data'] =
$bolocation->read_single($location_code,array('tenant_id'=>$tenant_id,'p_num'=>$p_num));
- }
-
- }
-
- if($values['origin'])
- {
- $origin = $values['origin'];
- $origin_id = $values['origin_id'];
- }
-
- if($origin)
- {
- unset($values['origin']);
- unset($values['origin_id']);
- $values['origin'][0]['type']= $origin;
-
$values['origin'][0]['link']=$this->bocommon->get_origin_link($origin);
- $values['origin'][0]['data'][]= array(
- 'id'=> $origin_id,
- 'type'=> $origin
- );
- }
-
- if($tenant_id)
- {
- $lookup_tenant=True;
- }
-
- if ($values['save'])
- {
- if(!$values['location'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a location !'));
- $error_id=true;
- }
-
- if(!$this->cat_id)
- {
-
$receipt['error'][]=array('msg'=>lang('Please select entity type !'));
- $error_id=true;
- }
-
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
- else
- {
-
$values['id']=$this->bo->generate_id(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id));
- }
-
- $values['file_name']=$_FILES['file']['name'];
- $to_file = $this->fakebase. SEP .
$this->category_name . SEP . $values['location']['loc1'] . SEP . $values['id']
. SEP . $values['file_name'];
-
- if(!$values['document_name_orig'] &&
$this->bo->vfs->file_exists(array(
- 'string' => $to_file,
- 'relatives' =>
Array(RELATIVE_NONE)
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('This file already exists !'));
- }
-
- if(!$receipt['error'])
- {
- $receipt =
$this->bo->create_home_dir($receipt);
- $receipt =
$this->bo->save($values,$values_attribute,$action,$this->entity_id,$this->cat_id);
- $id = $values['id'];
- $function_msg = lang('edit entity');
-
- if($values['file_name'])
- {
-
$this->bo->create_document_dir($values['location']['loc1'], $values['id']);
- $this->bo->vfs->override_acl =
1;
-
- if(!$this->bo->vfs->cp (array (
- 'from' =>
$_FILES['file']['tmp_name'],
- 'to' => $to_file,
- 'relatives' =>
array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
- {
-
$receipt['error'][]=array('msg'=>lang('Failed to upload file !'));
- }
- $this->bo->vfs->override_acl =
0;
- }
- }
- else
- {
- if($values['location'])
- {
- $location_code=implode("-",
$values['location']);
- $values['location_data'] =
$bolocation->read_single($location_code,$values['extra']);
- }
- if($values['extra']['p_num'])
- {
-
$values['p'][$values['extra']['p_entity_id']]['p_num']=$values['extra']['p_num'];
-
$values['p'][$values['extra']['p_entity_id']]['p_entity_id']=$values['extra']['p_entity_id'];
-
$values['p'][$values['extra']['p_entity_id']]['p_cat_id']=$values['extra']['p_cat_id'];
-
$values['p'][$values['extra']['p_entity_id']]['p_cat_name']=$_POST['entity_cat_name_'.$values['extra']['p_entity_id']];
- }
- }
- }
-
- if ($id)
- {
- $values =
$this->bo->read_single(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'id'=>$id));
- }
- else
- {
- if($this->cat_id)
- {
- $values =
$this->bo->read_single(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id));
- }
- }
-
- if($this->cat_id)
- {
- $category =
$this->boadmin_entity->read_single_category($this->entity_id,$this->cat_id);
- }
- else
- {
- $cat_list =
$this->bo->select_category_list('select',$this->cat_id);
- }
-
- $lookup_type='form';
-
- $entity =
$this->boadmin_entity->read_single($this->entity_id,false);
-
- if ($id)
- {
- $function_msg = lang('edit') . ' ' .
$category['name'];
- }
- else
- {
- $function_msg = lang('add') . ' ' .
$category['name'];
- }
-
- if ($values['cat_id'])
- {
- $this->cat_id = $values['cat_id'];
- }
-
- if (isset($entity['lookup_entity']) &&
is_array($entity['lookup_entity']))
- { for
($i=0;$i<count($entity['lookup_entity']);$i++)
- {
- $lookup_entity[$i]['id'] =
$entity['lookup_entity'][$i];
- $entity_lookup =
$this->boadmin_entity->read_single($entity['lookup_entity'][$i],false);
- $lookup_entity[$i]['name'] =
$entity_lookup['name'];
- }
- }
-
- if($category['lookup_tenant'])
- {
- $lookup_tenant=True;
- }
-
- if(!$category['location_level'])
- {
- $category['location_level']= -1;
- }
-
-
-
- if($entity['location_form'])
- {
-
$location_data=$bolocation->initiate_ui_location(array(
- 'values' =>
$values['location_data'],
- 'type_id' =>
$category['location_level'],
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'lookup_type' => $lookup_type,
- 'tenant' =>
$lookup_tenant,
- 'lookup_entity' =>
$lookup_entity,
- 'entity_data' => $values['p']
- ));
- }
-
-/* if($category['lookup_vendor'])
- {
-
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
- 'vendor_id' =>
$values['vendor_id'],
- 'vendor_name' =>
$values['vendor_name']));
- }
-*/
-
- $attributes_header[] = array(
- 'lang_name' => lang('Name'),
- 'lang_descr' => lang('Description'),
- 'lang_datatype' => lang('Datatype'),
- 'lang_value' => lang('Value')
- );
-
- if($error_id)
- {
- unset($values['id']);
- unset($id);
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uientity.edit',
- 'id' => $id,
- 'entity_id' => $this->entity_id,
- 'cat_id' => $this->cat_id
- );
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- switch(substr($dateformat,0,1))
- {
- case 'M':
- $dateformat_validate=
"javascript:vDateType='1'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
- $onBlur =
"DateFormat(this,this.value,event,true,'1')";
- break;
- case 'y':
-
$dateformat_validate="javascript:vDateType='2'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
- $onBlur =
"DateFormat(this,this.value,event,true,'2')";
- break;
- case 'D':
-
$dateformat_validate="javascript:vDateType='3'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
- $onBlur =
"DateFormat(this,this.value,event,true,'3')";
- break;
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $link_file_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uientity.view_file',
- 'loc1'
=>$values['location_data']['loc1'],
- 'id' =>$id,
- 'cat_id'
=>$this->cat_id,
- 'entity_id'
=>$this->entity_id
- );
-
-
- $config->read_repository();
- $link_to_files = $config->config_data['files_url'];
-
- $j = count($values['files']);
- for ($i=0;$i<$j;$i++)
- {
-
$values['files'][$i]['file_name']=urlencode($values['files'][$i]['name']);
- }
-
- $project_link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiproject.edit',
- 'bypass' => true,
- 'location_code' =>
$values['location_code'],
- 'p_num' =>
$values['p_num'],
- 'p_entity_id' =>
$values['p_entity_id'],
- 'p_cat_id' =>
$values['p_cat_id'],
- 'tenant_id' =>
$values['tenant_id'],
- 'origin' => 'entity_' .
$this->entity_id . '_' . $this->cat_id,
- 'origin_id' => $id
- );
-
-//_debug_array($values['origin']);
- for ($i=0;$i<count($values['origin']);$i++)
- {
-
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
. $values['origin'][$i]['link']);
-
if(substr($values['origin'][$i]['type'],0,6)=='entity')
- {
- $type =
explode("_",$values['origin'][$i]['type']);
- $entity_id = $type[1];
- $cat_id = $type[2];
-
- if(!is_object($boadmin_entity))
- {
- $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
- }
- $entity_category =
$boadmin_entity->read_single_category($entity_id,$cat_id);
- $values['origin'][$i]['descr'] =
$entity_category['name'];
- }
- else
- {
- $values['origin'][$i]['descr']=
lang($values['origin'][$i]['type']);
- }
- }
-
- $data = array
- (
- 'start_project'
=> $category['start_project'],
- 'lang_start_project' =>
lang('start project'),
- 'project_link'
=> $GLOBALS['phpgw']->link('/index.php',$project_link_data),
- 'fileupload'
=> $category['fileupload'],
- 'link_view_file'
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
- 'link_to_files'
=> $link_to_files,
- 'files'
=> $values['files'],
- 'lang_files'
=> lang('files'),
- 'lang_filename'
=> lang('Filename'),
- 'lang_delete_file'
=> lang('Delete file'),
- 'lang_view_file_statustext' =>
lang('Klick to view file'),
- 'lang_delete_file_statustext' => lang('Check
to delete file'),
- 'lang_upload_file'
=> lang('Upload file'),
- 'lang_file_statustext' =>
lang('Select file to upload'),
-
- 'value_origin'
=> $values['origin'],
- 'value_origin_type'
=> $origin,
- 'value_origin_id'
=> $origin_id,
-
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category. To do not use a category select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $cat_list,
- 'location_code'
=> $location_code,
- 'lookup_tenant'
=> $lookup_tenant,
-
- 'lang_entity'
=> lang('entity'),
- 'entity_name'
=> $entity['name'],
- 'lang_category'
=> lang('category'),
- 'category_name'
=> $category['name'],
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'lang_dateformat'
=> lang(strtolower($dateformat)),
- 'dateformat_validate' =>
$dateformat_validate,
- 'onKeyUp'
=> $onKeyUp,
- 'onBlur'
=> $onBlur,
- 'dateformat_source'
=> './'.$this->currentapp.'/inc/dateformat.js',
- 'lang_attributes'
=> lang('Attributes'),
- 'attributes_header'
=> $attributes_header,
- 'attributes_values'
=> $values['attributes'],
- 'lookup_functions'
=> $values['lookup_functions'],
- 'dateformat'
=> $dateformat,
- 'lang_none'
=> lang('None'),
- 'vendor_data'
=> $vendor_data,
- 'location_data'
=> $location_data,
- 'lookup_type'
=> $lookup_type,
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.index&entity_id='
. $this->entity_id . '&cat_id='. $this->cat_id),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'lang_id'
=> lang('ID'),
- 'value_id'
=> $values['id'],
- 'value_num'
=> $values['num'],
- 'error_flag'
=> $error_id,
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'lang_save_statustext' =>
lang('Save the entity')
- );
-
- $appname = $entity['name'];
-//_debug_array($attributes_values);
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function delete()
- {
- if(!$this->acl_delete)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
- }
-
- $id = get_var('id',array('POST','GET'));
- $confirm = get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uientity.index',
- 'entity_id' => $this->entity_id,
- 'cat_id' => $this->cat_id
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($id);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.delete&entity_id='
. $this->entity_id .'&cat_id=' . $this->cat_id . '&id=' . $id),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('entity');
- $function_msg =
lang('delete entity');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function view()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $config =
CreateObject('phpgwapi.config',$this->currentapp);
- $bolocation =
CreateObject($this->currentapp.'.bolocation');
-
- $id = get_var('id',array('POST','GET'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('entity','attributes_view'));
-
-
- if ($id)
- {
- $values =
$this->bo->read_single(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'id'=>$id));
- }
-
- $lookup_type='view';
-
- if ($values['cat_id'])
- {
- $this->cat_id = $values['cat_id'];
- }
-
- $entity =
$this->boadmin_entity->read_single($this->entity_id,false);
- $category =
$this->boadmin_entity->read_single_category($this->entity_id,$this->cat_id);
-
- if (isset($entity['lookup_entity']) &&
is_array($entity['lookup_entity']))
- { for
($i=0;$i<count($entity['lookup_entity']);$i++)
- {
-
if($values['p'][$entity['lookup_entity'][$i]])
- {
- $lookup_entity[$i]['id'] =
$entity['lookup_entity'][$i];
- $entity_lookup =
$this->boadmin_entity->read_single($entity['lookup_entity'][$i],false);
- $lookup_entity[$i]['name'] =
$entity_lookup['name'];
- }
- }
- }
-
- $location_data=$bolocation->initiate_ui_location(array(
- 'values' =>
$values['location_data'],
- 'type_id' =>
count(explode('-',$values['location_data']['location_code'])),
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'lookup_type' => $lookup_type,
- 'tenant' =>
$category['lookup_tenant'],
- 'lookup_entity' =>
$lookup_entity,
- 'entity_data' => $values['p']
- ));
-
- $appname = $entity['name'];
- $function_msg = lang('view') . ' ' .
$category['name'];
-
-/* if($category['lookup_vendor'])
- {
-
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
- 'vendor_id' =>
$values['vendor_id'],
- 'vendor_name' =>
$values['vendor_name']));
- }
-*/
- $attributes_values=$values['attributes'];
-
- $attributes_header[] = array(
- 'lang_name' => lang('Name'),
- 'lang_descr' => lang('Description'),
- 'lang_datatype' => lang('Datatype'),
- 'lang_value' => lang('Value')
- );
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uientity.edit',
- 'id' => $id,
- 'entity_id' => $this->entity_id,
- 'cat_id' => $this->cat_id
- );
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $link_file_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uientity.view_file',
- 'loc1'
=>$values['location_data']['loc1'],
- 'id' =>$id,
- 'cat_id'
=>$this->cat_id,
- 'entity_id'
=>$this->entity_id
- );
-
- $config->read_repository();
- $link_to_files = $config->config_data['files_url'];
-
- $j = count($values['files']);
- for ($i=0;$i<$j;$i++)
- {
-
$values['files'][$i]['file_name']=urlencode($values['files'][$i]['name']);
- }
-
- if(is_array($values['origin']))
- {
- for ($i=0;$i<count($values['origin']);$i++)
- {
-
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
. $values['origin'][$i]['link']);
-
if(substr($values['origin'][$i]['type'],0,6)=='entity')
- {
- $type =
explode("_",$values['origin'][$i]['type']);
- $entity_id = $type[1];
- $cat_id = $type[2];
-
- if(!is_object($boadmin_entity))
- {
- $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
- }
- $entity_category =
$boadmin_entity->read_single_category($entity_id,$cat_id);
- $values['origin'][$i]['descr']
= $entity_category['name'];
- }
- else
- {
- $values['origin'][$i]['descr']=
lang($values['origin'][$i]['type']);
- }
- }
- }
-
- $data = array
- (
- 'link_view_file'
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
- 'link_to_files'
=> $link_to_files,
- 'files'
=> $values['files'],
- 'lang_files'
=> lang('files'),
- 'lang_filename'
=> lang('Filename'),
- 'lang_view_file_statustext' =>
lang('Klick to view file'),
-
- 'value_origin'
=> $values['origin'],
- 'value_origin_type'
=> $origin,
- 'value_origin_id'
=> $origin_id,
-
- 'lang_entity'
=> lang('entity'),
- 'entity_name'
=> $entity['name'],
- 'lang_category'
=> lang('category'),
- 'category_name'
=> $category['name'],
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'lang_dateformat'
=> lang(strtolower($dateformat)),
- 'lang_attributes'
=> lang('Attributes'),
- 'attributes_view'
=> $attributes_values,
- 'dateformat'
=> $dateformat,
-
- 'vendor_data'
=> $vendor_data,
- 'location_data'
=> $location_data,
- 'lookup_type'
=> $lookup_type,
- 'edit_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.index&entity_id='
. $this->entity_id . '&cat_id='. $this->cat_id),
- 'lang_category'
=> lang('category'),
- 'lang_edit'
=> lang('Edit'),
- 'lang_done'
=> lang('done'),
- 'lang_id'
=> lang('ID'),
- 'value_id' =>
$values['id'],
- 'value_num' =>
$values['num'],
- 'error_flag'
=> $error_id,
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'lang_save_statustext' =>
lang('Edit the entity'),
- 'status_list'
=> $this->bo->select_status_list('select',$values['status'])
- );
-
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage entity
+ * @version $Id: class.uientity.inc.php,v 1.16 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uientity
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+ var $part_of_town_id;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'columns' => True,
+ 'excel' => True,
+ 'index' => True,
+ 'view' => True,
+ 'edit' => True,
+ 'delete' => True,
+ 'view_file' =>True
+ );
+
+ function uientity()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $this->bo =
CreateObject($this->currentapp.'.boentity',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+
+ $this->boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity',True);
+
+ $this->entity_id =
$this->bo->entity_id;
+ $this->cat_id =
$this->bo->cat_id;
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+ if(!$this->cat_id)
+ {
+ $this->acl2_location = '.entity.' .
$this->entity_id;
+ }
+ else
+ {
+ $this->acl2_location = '.entity.' .
$this->entity_id . '.' . $this->cat_id;
+ }
+ $this->acl_read =
$this->acl2->check($this->acl2_location,1);
+ $this->acl_add =
$this->acl2->check($this->acl2_location,2);
+ $this->acl_edit =
$this->acl2->check($this->acl2_location,4);
+ $this->acl_delete =
$this->acl2->check($this->acl2_location,8);
+
+ $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->part_of_town_id =
$this->bo->part_of_town_id;
+ $this->district_id =
$this->bo->district_id;
+ $this->status =
$this->bo->status;
+ $this->fakebase =
$this->bo->fakebase;
+ $this->category_name =
$this->bo->category_name;
+ $this->menu->sub
='entity_'.$this->entity_id;
+
$GLOBALS['phpgw']->session->appsession('entity_id',$this->currentapp,$this->entity_id);
+ $this->start_date =
$this->bo->start_date;
+ $this->end_date =
$this->bo->end_date;
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' => $this->filter,
+ 'cat_id' => $this->cat_id,
+ 'part_of_town_id' =>
$this->part_of_town_id,
+ 'district_id' => $this->district_id,
+ 'entity_id' => $this->entity_id,
+ 'status' => $this->status,
+ 'start_date' => $this->start_date,
+ 'end_date' => $this->end_date
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function excel()
+ {
+ $GLOBALS['phpgw_info']['flags'][noheader] = True;
+ $GLOBALS['phpgw_info']['flags'][nofooter] = True;
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
+
+ $start_date = urldecode($this->start_date);
+ $end_date = urldecode($this->end_date);
+
+ $list =
$this->bo->read(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'allrows'=>true,'start_date'=>$start_date,'end_date'=>$end_date));
+ $uicols = $this->bo->uicols;
+
+ $filename=
$GLOBALS['phpgw_info']['user']['account_lid'].'.xls';
+ $count_uicols_name=count($uicols['name']);
+
+ $workbook =
CreateObject($this->currentapp.'.excel',"-");
+ $browser = CreateObject('phpgwapi.browser');
+
$browser->content_header($filename,'application/vnd.ms-excel');
+
+ $worksheet1 =& $workbook->add_worksheet('First One');
+
+ $j=0;
+ if (isset($list) AND is_array($list))
+ {
+ foreach($list as $entry)
+ {
+ $m=0;
+ for ($k=0;$k<$count_uicols_name;$k++)
+ {
+
if($uicols['input_type'][$k]!='hidden')
+ {
+ $content[$j][$m]
= $entry[$uicols['name'][$k]];
+
$worksheet1->write_string(0, $m, $uicols['descr'][$k]);
+ $m++;
+ }
+ }
+ $j++;
+ }
+
+ foreach($content as $row)
+ {
+ $line++;
+ for ($i=0; $i<count($row); $i++)
+ {
+
$worksheet1->write($line,$i,$row[$i]);
+ }
+ }
+ }
+ $workbook->close();
+ }
+
+
+ function columns()
+ {
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('columns'));
+
+ $GLOBALS['phpgw_info']['flags']['noframework'] = True;
+
+ $values =
get_var('values',array('POST','GET'));
+
+ if ($values['save'] && $this->cat_id)
+ {
+
$GLOBALS['phpgw']->preferences->account_id=$this->account;
+
$GLOBALS['phpgw']->preferences->read_repository();
+
$GLOBALS['phpgw']->preferences->add($this->currentapp,"entity_columns_" .
$this->entity_id . '_' . $this->cat_id,$values['columns'],'user');
+
$GLOBALS['phpgw']->preferences->save_repository();
+
+ $receipt['message'][] = array('msg' =>
lang('columns is updated'));
+ }
+
+ if(!$this->cat_id)
+ {
+ $receipt['error'][] = array('msg' =>
lang('Choose a category'));
+ }
+ $function_msg = lang('Select Column');
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uientity.columns',
+ 'entity_id' =>
$this->entity_id,
+ 'cat_id' => $this->cat_id
+ );
+
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'column_list' =>
$this->bo->column_list($values['columns'],$entity_id=$this->entity_id,$cat_id=$this->cat_id,$allrows=True),
+ 'function_msg' => $function_msg,
+ 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_columns' => lang('columns'),
+ 'lang_none' => lang('None'),
+ 'lang_save' => lang('save'),
+ 'select_name' => 'period'
+ );
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
$function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('columns' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function view_file()
+ {
+ $GLOBALS['phpgw_info']['flags'][noheader] = True;
+ $GLOBALS['phpgw_info']['flags'][nofooter] = True;
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
+
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $file_name =
urldecode(get_var('file_name',array('POST','GET')));
+ $loc1 = get_var('loc1',array('POST','GET'));
+ $id = get_var('id',array('POST','GET'));
+
+ $file = $this->fakebase. SEP . $this->category_name .
SEP . $loc1 . SEP . $id . SEP . $file_name;
+
+//echo 'file: ' . $file . '<br>';
+ if($this->bo->vfs->file_exists(array(
+ 'string' => $file,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $size =
$this->bo->vfs->get_size(array(
+ 'string' => $file,
+ 'relatives' =>
Array(RELATIVE_NONE),
+ 'checksubdirs' =>
True));
+
+ $document= $this->bo->vfs->read(array(
+ 'string' => $file,
+ 'relatives' => Array(RELATIVE_NONE)));
+
+ $filename =
basename($values['document_name']);
+ $filetype = array_pop(explode('.',
basename($file)));
+ $browser = CreateObject('phpgwapi.browser');
+
$browser->content_header($filename,$filetype,$size);
+
+ echo $document;
+
+ }
+ }
+
+ function index()
+ {
+ if(!$this->acl_read && $this->cat_id)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('entity',
+ 'menu',
+
'nextmatchs'));
+
+ $links = $this->menu->links();
+
+ $start_date = urldecode($this->start_date);
+ $end_date = urldecode($this->end_date);
+
+ $entity_list =
$this->bo->read(array('start_date'=>$start_date,'end_date'=>$end_date));
+
+ $uicols = $this->bo->uicols;
+
+ $j=0;
+
+ if (isset($entity_list) AND is_array($entity_list))
+ {
+ foreach($entity_list as $entity_entry)
+ {
+ for
($i=0;$i<count($uicols['name']);$i++)
+ {
+
if($uicols['input_type'][$i]!='hidden')
+ {
+
if($entity_entry['query_location'][$uicols['name'][$i]])
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('search');
+
$content[$j]['row'][$i]['text'] =
$entity_entry[$uicols['name'][$i]];
+
$content[$j]['row'][$i]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.index&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id .'&query=' .
$entity_entry['query_location'][$uicols['name'][$i]]);
+ }
+ else
+ {
+
$content[$j]['row'][$i]['value'] =
$entity_entry[$uicols['name'][$i]];
+
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
+ }
+ }
+ }
+
+ if($this->acl_read)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('view the
entity');
+ $content[$j]['row'][$i]['text']
= lang('view');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.view&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id .'&id=' . $entity_entry['id']);
+ }
+ if($this->acl_edit)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('edit the
entity');
+ $content[$j]['row'][$i]['text']
= lang('edit');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.edit&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id .'&id=' . $entity_entry['id']);
+ }
+ if($this->acl_delete)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('delete the
entity');
+ $content[$j]['row'][$i]['text']
= lang('delete');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.delete&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id .'&id=' . $entity_entry['id']);
+ }
+
+ $j++;
+ }
+ }
+
+ for ($i=0;$i<count($uicols['descr']);$i++)
+ {
+ if($uicols['input_type'][$i]!='hidden')
+ {
+ $table_header[$i]['header'] =
$uicols['descr'][$i];
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ if($uicols['datatype'][$i]!='T' &&
$uicols['datatype'][$i]!='CH')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+ (
+ 'sort' =>
$this->sort,
+ 'var' =>
$uicols['name'][$i],
+ 'order' =>
$this->order,
+ 'extra'
=> array('menuaction' => $this->currentapp.'.uientity.index',
+
'type_id' =>$type_id,
+
'query' =>$this->query,
+
'lookup' =>$lookup,
+
'district_id' => $this->district_id,
+
'entity_id' =>$this->entity_id,
+
'cat_id' =>$this->cat_id,
+
'start_date'=>$start_date,
+
'end_date'=>$end_date)
+ ));
+ }
+ }
+ }
+
+ if($this->acl_read)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('view');
+ $i++;
+ }
+ if($this->acl_edit)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('edit');
+ $i++;
+ }
+ if($this->acl_delete)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('delete');
+ $i++;
+ }
+
+
+ if($this->acl_add)
+ {
+ $table_add[] = array
+ (
+ 'lang_add'
=> lang('add'),
+ 'lang_add_statustext' => lang('add a
entity'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.edit&entity_id='.
$this->entity_id .'&cat_id='. $this->cat_id)
+ );
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uientity.index',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'entity_id'
=>$this->entity_id,
+ 'district_id'
=>$this->district_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query,
+ 'start_date' =>$start_date,
+ 'end_date'
=>$end_date
+ );
+
+ $link_excel = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uientity.excel',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'entity_id'
=>$this->entity_id,
+ 'cat_id'
=>$this->cat_id,
+ 'district_id'
=>$this->district_id,
+ 'status_id'
=>$this->status,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query,
+ 'start_date' =>$start_date,
+ 'end_date'
=>$end_date,
+ 'start' =>$this->start
+ );
+
+ $link_columns = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uientity.columns',
+ 'entity_id'
=>$this->entity_id,
+ 'cat_id'
=>$this->cat_id
+ );
+
+ $link_date_search
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.date_search');
+
+
if($GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['group_filters'])
+ {
+ $group_filters = 'select';
+
$GLOBALS['phpgw']->xslttpl->add_file(array('search_field_grouped'));
+ }
+ else
+ {
+ $group_filters = 'filter';
+
$GLOBALS['phpgw']->xslttpl->add_file(array('search_field'));
+ }
+
+ $data = array
+ (
+ 'group_filters' =>
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['group_filters'],
+ 'lang_excel' =>
'excel',
+ 'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
+ 'lang_excel_help' =>
lang('Download table to MS Excel'),
+
+ 'lang_columns' =>
lang('columns'),
+ 'link_columns' =>
$GLOBALS['phpgw']->link('/index.php',$link_columns),
+ 'lang_columns_help' =>
lang('Choose columns'),
+
+ 'start_date' =>
$start_date,
+ 'end_date'
=> $end_date,
+ 'lang_none'
=> lang('None'),
+ 'lang_date_search' =>
lang('Date search'),
+ 'lang_date_search_help' => lang('Narrow
the search by dates'),
+ 'link_date_search' =>
$link_date_search,
+ 'lang_date_search' =>
lang('Date search'),
+ 'overlib_source' =>
'./'.$this->currentapp.'/inc/overlib.js',
+
+
+ 'links'
=> $links,
+ 'allow_allrows'
=> false,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($entity_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+
+ 'district_list'
=> $this->bocommon->select_district_list($group_filters,$this->district_id),
+ 'lang_no_district'
=> lang('no district'),
+ 'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
+ 'select_district_name' =>
'district_id',
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category. To do not use a category select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $this->bo->select_category_list($group_filters,$this->cat_id),
+
+ 'lang_status_statustext' =>
lang('Select the status. To do not use a status select NO STATUS'),
+ 'status_name'
=> 'status',
+ 'lang_no_status'
=> lang('No status'),
+ 'status_list'
=> $this->bo->select_status_list($group_filters,$this->status),
+
+ 'lang_user_statustext' =>
lang('Select the user. To do not use a category select NO USER'),
+ 'select_user_name'
=> 'filter',
+ 'lang_no_user'
=> lang('No user'),
+ 'user_list'
=>
$this->bocommon->get_user_list_right2($group_filters,4,$this->filter,$this->acl2_location,array('all'),$default='all'),
+
+ 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ if($this->entity_id)
+ {
+ $entity =
$this->boadmin_entity->read_single($this->entity_id,false);
+ $appname = $entity['name'];
+ }
+ if($this->cat_id)
+ {
+ $category =
$this->boadmin_entity->read_single_category($this->entity_id,$this->cat_id);
+ $function_msg
= 'list ' . $category['name'];
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+ }
+
+ if(!$this->entity_id || !$this->cat_id)
+ {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ $receipt['error'][]=array('msg'=>lang('Please
select type'));
+ $msgbox_data =
$this->bocommon->msgbox_data($receipt);
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('empty' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+ else
+ {
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+ }
+
+ function edit()
+ {
+ if(!$this->acl_add && !$this->acl_edit)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
+ }
+
+ $config =
CreateObject('phpgwapi.config',$this->currentapp);
+ $bolocation =
CreateObject($this->currentapp.'.bolocation');
+
+ $id =
get_var('id',array('POST','GET'));
+ $values =
get_var('values',array('POST','GET'));
+ $values_attribute =
get_var('values_attribute',array('POST','GET'));
+ $bypass =
get_var('bypass',array('POST','GET'));
+ $lookup_tenant =
get_var('lookup_tenant',array('POST','GET'));
+ $tenant_id =
get_var('tenant_id',array('POST','GET'));
+
+ $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
+ $insert_record_entity =
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp);
+
+ for ($j=0;$j<count($insert_record_entity);$j++)
+ {
+
$insert_record['extra'][$insert_record_entity[$j]] =
$insert_record_entity[$j];
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('entity','attributes_form'));
+
+ $values['vendor_id'] =
get_var('vendor_id',array('POST'));
+ $values['vendor_name'] =
get_var('vendor_name',array('POST'));
+ $values['date'] =
get_var('date',array('POST'));
+ $ticket_id =
get_var('ticket_id',array('POST','GET'));
+ $request_id =
get_var('request_id',array('POST','GET'));
+
+ if($_POST && !$bypass)
+ {
+
+ for ($i=0;
$i<count($insert_record['location']); $i++)
+ {
+
if($_POST[$insert_record['location'][$i]])
+ {
+
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
+ }
+ }
+
+ while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
+ {
+ if($_POST[$key])
+ {
+ $values['extra'][$column]
= $_POST[$key];
+ }
+ }
+
+ $values['street_name'] =
$_POST['street_name'];
+ $values['street_number'] =
$_POST['street_number'];
+ $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
+
+ }
+ else
+ {
+ $location_code =
get_var('location_code',array('POST','GET'));
+ $values['descr'] =
get_var('descr',array('POST','GET'));
+ $p_entity_id =
get_var('p_entity_id',array('POST','GET'));
+ $p_cat_id =
get_var('p_cat_id',array('POST','GET'));
+ $values['p'][$p_entity_id]['p_entity_id']
= $p_entity_id;
+ $values['p'][$p_entity_id]['p_cat_id']
= $p_cat_id;
+ $values['p'][$p_entity_id]['p_num']
= get_var('p_num',array('POST','GET'));
+
+
+ $origin =
get_var('origin',array('POST','GET'));
+ $origin_id =
get_var('origin_id',array('POST','GET'));
+
+
+ if($p_entity_id && $p_cat_id)
+ {
+ $entity_category =
$this->boadmin_entity->read_single_category($p_entity_id,$p_cat_id);
+
$values['p'][$p_entity_id]['p_cat_name'] = $entity_category['name'];
+ }
+
+
+ if($location_code)
+ {
+ $values['location_data'] =
$bolocation->read_single($location_code,array('tenant_id'=>$tenant_id,'p_num'=>$p_num));
+ }
+
+ }
+
+ if($values['origin'])
+ {
+ $origin = $values['origin'];
+ $origin_id = $values['origin_id'];
+ }
+
+ if($origin)
+ {
+ unset($values['origin']);
+ unset($values['origin_id']);
+ $values['origin'][0]['type']= $origin;
+
$values['origin'][0]['link']=$this->bocommon->get_origin_link($origin);
+ $values['origin'][0]['data'][]= array(
+ 'id'=> $origin_id,
+ 'type'=> $origin
+ );
+ }
+
+ if($tenant_id)
+ {
+ $lookup_tenant=True;
+ }
+
+ if ($values['save'])
+ {
+ if(!$values['location'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a location !'));
+ $error_id=true;
+ }
+
+ if(!$this->cat_id)
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select entity type !'));
+ $error_id=true;
+ }
+
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+ else
+ {
+
$values['id']=$this->bo->generate_id(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id));
+ }
+
+ $values['file_name']=$_FILES['file']['name'];
+ $to_file = $this->fakebase. SEP .
$this->category_name . SEP . $values['location']['loc1'] . SEP . $values['id']
. SEP . $values['file_name'];
+
+ if(!$values['document_name_orig'] &&
$this->bo->vfs->file_exists(array(
+ 'string' => $to_file,
+ 'relatives' =>
Array(RELATIVE_NONE)
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('This file already exists !'));
+ }
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$this->bo->create_home_dir($receipt);
+ $receipt =
$this->bo->save($values,$values_attribute,$action,$this->entity_id,$this->cat_id);
+ $id = $values['id'];
+ $function_msg = lang('edit entity');
+
+ if($values['file_name'])
+ {
+
$this->bo->create_document_dir($values['location']['loc1'], $values['id']);
+ $this->bo->vfs->override_acl =
1;
+
+ if(!$this->bo->vfs->cp (array (
+ 'from' =>
$_FILES['file']['tmp_name'],
+ 'to' => $to_file,
+ 'relatives' =>
array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
+ {
+
$receipt['error'][]=array('msg'=>lang('Failed to upload file !'));
+ }
+ $this->bo->vfs->override_acl =
0;
+ }
+ }
+ else
+ {
+ if($values['location'])
+ {
+ $location_code=implode("-",
$values['location']);
+ $values['location_data'] =
$bolocation->read_single($location_code,$values['extra']);
+ }
+ if($values['extra']['p_num'])
+ {
+
$values['p'][$values['extra']['p_entity_id']]['p_num']=$values['extra']['p_num'];
+
$values['p'][$values['extra']['p_entity_id']]['p_entity_id']=$values['extra']['p_entity_id'];
+
$values['p'][$values['extra']['p_entity_id']]['p_cat_id']=$values['extra']['p_cat_id'];
+
$values['p'][$values['extra']['p_entity_id']]['p_cat_name']=$_POST['entity_cat_name_'.$values['extra']['p_entity_id']];
+ }
+ }
+ }
+
+ if ($id)
+ {
+ $values =
$this->bo->read_single(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'id'=>$id));
+ }
+ else
+ {
+ if($this->cat_id)
+ {
+ $values =
$this->bo->read_single(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id));
+ }
+ }
+
+ if($this->cat_id)
+ {
+ $category =
$this->boadmin_entity->read_single_category($this->entity_id,$this->cat_id);
+ }
+ else
+ {
+ $cat_list =
$this->bo->select_category_list('select',$this->cat_id);
+ }
+
+ $lookup_type='form';
+
+ $entity =
$this->boadmin_entity->read_single($this->entity_id,false);
+
+ if ($id)
+ {
+ $function_msg = lang('edit') . ' ' .
$category['name'];
+ }
+ else
+ {
+ $function_msg = lang('add') . ' ' .
$category['name'];
+ }
+
+ if ($values['cat_id'])
+ {
+ $this->cat_id = $values['cat_id'];
+ }
+
+ if (isset($entity['lookup_entity']) &&
is_array($entity['lookup_entity']))
+ { for
($i=0;$i<count($entity['lookup_entity']);$i++)
+ {
+ $lookup_entity[$i]['id'] =
$entity['lookup_entity'][$i];
+ $entity_lookup =
$this->boadmin_entity->read_single($entity['lookup_entity'][$i],false);
+ $lookup_entity[$i]['name'] =
$entity_lookup['name'];
+ }
+ }
+
+ if($category['lookup_tenant'])
+ {
+ $lookup_tenant=True;
+ }
+
+ if(!$category['location_level'])
+ {
+ $category['location_level']= -1;
+ }
+
+
+
+ if($entity['location_form'])
+ {
+
$location_data=$bolocation->initiate_ui_location(array(
+ 'values' =>
$values['location_data'],
+ 'type_id' =>
$category['location_level'],
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'lookup_type' => $lookup_type,
+ 'tenant' =>
$lookup_tenant,
+ 'lookup_entity' =>
$lookup_entity,
+ 'entity_data' => $values['p']
+ ));
+ }
+
+/* if($category['lookup_vendor'])
+ {
+
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
+ 'vendor_id' =>
$values['vendor_id'],
+ 'vendor_name' =>
$values['vendor_name']));
+ }
+*/
+
+ $attributes_header[] = array(
+ 'lang_name' => lang('Name'),
+ 'lang_descr' => lang('Description'),
+ 'lang_datatype' => lang('Datatype'),
+ 'lang_value' => lang('Value')
+ );
+
+ if($error_id)
+ {
+ unset($values['id']);
+ unset($id);
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uientity.edit',
+ 'id' => $id,
+ 'entity_id' => $this->entity_id,
+ 'cat_id' => $this->cat_id
+ );
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ switch(substr($dateformat,0,1))
+ {
+ case 'M':
+ $dateformat_validate=
"javascript:vDateType='1'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'1')";
+ break;
+ case 'y':
+
$dateformat_validate="javascript:vDateType='2'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'2')";
+ break;
+ case 'D':
+
$dateformat_validate="javascript:vDateType='3'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'3')";
+ break;
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $link_file_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uientity.view_file',
+ 'loc1'
=>$values['location_data']['loc1'],
+ 'id' =>$id,
+ 'cat_id'
=>$this->cat_id,
+ 'entity_id'
=>$this->entity_id
+ );
+
+
+ $config->read_repository();
+ $link_to_files = $config->config_data['files_url'];
+
+ $j = count($values['files']);
+ for ($i=0;$i<$j;$i++)
+ {
+
$values['files'][$i]['file_name']=urlencode($values['files'][$i]['name']);
+ }
+
+ $project_link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiproject.edit',
+ 'bypass' => true,
+ 'location_code' =>
$values['location_code'],
+ 'p_num' =>
$values['p_num'],
+ 'p_entity_id' =>
$values['p_entity_id'],
+ 'p_cat_id' =>
$values['p_cat_id'],
+ 'tenant_id' =>
$values['tenant_id'],
+ 'origin' => 'entity_' .
$this->entity_id . '_' . $this->cat_id,
+ 'origin_id' => $id
+ );
+
+//_debug_array($values['origin']);
+ for ($i=0;$i<count($values['origin']);$i++)
+ {
+
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
. $values['origin'][$i]['link']);
+
if(substr($values['origin'][$i]['type'],0,6)=='entity')
+ {
+ $type =
explode("_",$values['origin'][$i]['type']);
+ $entity_id = $type[1];
+ $cat_id = $type[2];
+
+ if(!is_object($boadmin_entity))
+ {
+ $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
+ }
+ $entity_category =
$boadmin_entity->read_single_category($entity_id,$cat_id);
+ $values['origin'][$i]['descr'] =
$entity_category['name'];
+ }
+ else
+ {
+ $values['origin'][$i]['descr']=
lang($values['origin'][$i]['type']);
+ }
+ }
+
+ $data = array
+ (
+ 'start_project'
=> $category['start_project'],
+ 'lang_start_project' =>
lang('start project'),
+ 'project_link'
=> $GLOBALS['phpgw']->link('/index.php',$project_link_data),
+ 'fileupload'
=> $category['fileupload'],
+ 'link_view_file'
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
+ 'link_to_files'
=> $link_to_files,
+ 'files'
=> $values['files'],
+ 'lang_files'
=> lang('files'),
+ 'lang_filename'
=> lang('Filename'),
+ 'lang_delete_file'
=> lang('Delete file'),
+ 'lang_view_file_statustext' =>
lang('Klick to view file'),
+ 'lang_delete_file_statustext' => lang('Check
to delete file'),
+ 'lang_upload_file'
=> lang('Upload file'),
+ 'lang_file_statustext' =>
lang('Select file to upload'),
+
+ 'value_origin'
=> $values['origin'],
+ 'value_origin_type'
=> $origin,
+ 'value_origin_id'
=> $origin_id,
+
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category. To do not use a category select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $cat_list,
+ 'location_code'
=> $location_code,
+ 'lookup_tenant'
=> $lookup_tenant,
+
+ 'lang_entity'
=> lang('entity'),
+ 'entity_name'
=> $entity['name'],
+ 'lang_category'
=> lang('category'),
+ 'category_name'
=> $category['name'],
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'lang_dateformat'
=> lang(strtolower($dateformat)),
+ 'dateformat_validate' =>
$dateformat_validate,
+ 'onKeyUp'
=> $onKeyUp,
+ 'onBlur'
=> $onBlur,
+ 'dateformat_source'
=> './'.$this->currentapp.'/inc/dateformat.js',
+ 'lang_attributes'
=> lang('Attributes'),
+ 'attributes_header'
=> $attributes_header,
+ 'attributes_values'
=> $values['attributes'],
+ 'lookup_functions'
=> $values['lookup_functions'],
+ 'dateformat'
=> $dateformat,
+ 'lang_none'
=> lang('None'),
+ 'vendor_data'
=> $vendor_data,
+ 'location_data'
=> $location_data,
+ 'lookup_type'
=> $lookup_type,
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.index&entity_id='
. $this->entity_id . '&cat_id='. $this->cat_id),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'lang_id'
=> lang('ID'),
+ 'value_id'
=> $values['id'],
+ 'value_num'
=> $values['num'],
+ 'error_flag'
=> $error_id,
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'lang_save_statustext' =>
lang('Save the entity')
+ );
+
+ $appname = $entity['name'];
+//_debug_array($attributes_values);
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function delete()
+ {
+ if(!$this->acl_delete)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
+ }
+
+ $id = get_var('id',array('POST','GET'));
+ $confirm = get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uientity.index',
+ 'entity_id' => $this->entity_id,
+ 'cat_id' => $this->cat_id
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($id);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.delete&entity_id='
. $this->entity_id .'&cat_id=' . $this->cat_id . '&id=' . $id),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('entity');
+ $function_msg =
lang('delete entity');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function view()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $config =
CreateObject('phpgwapi.config',$this->currentapp);
+ $bolocation =
CreateObject($this->currentapp.'.bolocation');
+
+ $id = get_var('id',array('POST','GET'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('entity','attributes_view'));
+
+
+ if ($id)
+ {
+ $values =
$this->bo->read_single(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'id'=>$id));
+ }
+
+ $lookup_type='view';
+
+ if ($values['cat_id'])
+ {
+ $this->cat_id = $values['cat_id'];
+ }
+
+ $entity =
$this->boadmin_entity->read_single($this->entity_id,false);
+ $category =
$this->boadmin_entity->read_single_category($this->entity_id,$this->cat_id);
+
+ if (isset($entity['lookup_entity']) &&
is_array($entity['lookup_entity']))
+ { for
($i=0;$i<count($entity['lookup_entity']);$i++)
+ {
+
if($values['p'][$entity['lookup_entity'][$i]])
+ {
+ $lookup_entity[$i]['id'] =
$entity['lookup_entity'][$i];
+ $entity_lookup =
$this->boadmin_entity->read_single($entity['lookup_entity'][$i],false);
+ $lookup_entity[$i]['name'] =
$entity_lookup['name'];
+ }
+ }
+ }
+
+ $location_data=$bolocation->initiate_ui_location(array(
+ 'values' =>
$values['location_data'],
+ 'type_id' =>
count(explode('-',$values['location_data']['location_code'])),
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'lookup_type' => $lookup_type,
+ 'tenant' =>
$category['lookup_tenant'],
+ 'lookup_entity' =>
$lookup_entity,
+ 'entity_data' => $values['p']
+ ));
+
+ $appname = $entity['name'];
+ $function_msg = lang('view') . ' ' .
$category['name'];
+
+/* if($category['lookup_vendor'])
+ {
+
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
+ 'vendor_id' =>
$values['vendor_id'],
+ 'vendor_name' =>
$values['vendor_name']));
+ }
+*/
+ $attributes_values=$values['attributes'];
+
+ $attributes_header[] = array(
+ 'lang_name' => lang('Name'),
+ 'lang_descr' => lang('Description'),
+ 'lang_datatype' => lang('Datatype'),
+ 'lang_value' => lang('Value')
+ );
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uientity.edit',
+ 'id' => $id,
+ 'entity_id' => $this->entity_id,
+ 'cat_id' => $this->cat_id
+ );
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $link_file_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uientity.view_file',
+ 'loc1'
=>$values['location_data']['loc1'],
+ 'id' =>$id,
+ 'cat_id'
=>$this->cat_id,
+ 'entity_id'
=>$this->entity_id
+ );
+
+ $config->read_repository();
+ $link_to_files = $config->config_data['files_url'];
+
+ $j = count($values['files']);
+ for ($i=0;$i<$j;$i++)
+ {
+
$values['files'][$i]['file_name']=urlencode($values['files'][$i]['name']);
+ }
+
+ if(is_array($values['origin']))
+ {
+ for ($i=0;$i<count($values['origin']);$i++)
+ {
+
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
. $values['origin'][$i]['link']);
+
if(substr($values['origin'][$i]['type'],0,6)=='entity')
+ {
+ $type =
explode("_",$values['origin'][$i]['type']);
+ $entity_id = $type[1];
+ $cat_id = $type[2];
+
+ if(!is_object($boadmin_entity))
+ {
+ $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
+ }
+ $entity_category =
$boadmin_entity->read_single_category($entity_id,$cat_id);
+ $values['origin'][$i]['descr']
= $entity_category['name'];
+ }
+ else
+ {
+ $values['origin'][$i]['descr']=
lang($values['origin'][$i]['type']);
+ }
+ }
+ }
+
+ $data = array
+ (
+ 'link_view_file'
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
+ 'link_to_files'
=> $link_to_files,
+ 'files'
=> $values['files'],
+ 'lang_files'
=> lang('files'),
+ 'lang_filename'
=> lang('Filename'),
+ 'lang_view_file_statustext' =>
lang('Klick to view file'),
+
+ 'value_origin'
=> $values['origin'],
+ 'value_origin_type'
=> $origin,
+ 'value_origin_id'
=> $origin_id,
+
+ 'lang_entity'
=> lang('entity'),
+ 'entity_name'
=> $entity['name'],
+ 'lang_category'
=> lang('category'),
+ 'category_name'
=> $category['name'],
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'lang_dateformat'
=> lang(strtolower($dateformat)),
+ 'lang_attributes'
=> lang('Attributes'),
+ 'attributes_view'
=> $attributes_values,
+ 'dateformat'
=> $dateformat,
+
+ 'vendor_data'
=> $vendor_data,
+ 'location_data'
=> $location_data,
+ 'lookup_type'
=> $lookup_type,
+ 'edit_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.index&entity_id='
. $this->entity_id . '&cat_id='. $this->cat_id),
+ 'lang_category'
=> lang('category'),
+ 'lang_edit'
=> lang('Edit'),
+ 'lang_done'
=> lang('done'),
+ 'lang_id'
=> lang('ID'),
+ 'value_id' =>
$values['id'],
+ 'value_num' =>
$values['num'],
+ 'error_flag'
=> $error_id,
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'lang_save_statustext' =>
lang('Edit the entity'),
+ 'status_list'
=> $this->bo->select_status_list('select',$values['status'])
+ );
+
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+ }
+?>
Index: property/inc/class.uigab.inc.php
diff -u property/inc/class.uigab.inc.php:1.11
property/inc/class.uigab.inc.php:1.12
--- property/inc/class.uigab.inc.php:1.11 Thu Aug 18 13:23:16 2005
+++ property/inc/class.uigab.inc.php Fri Jan 27 14:05:43 2006
@@ -1,846 +1,846 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage location
- * @version $Id: class.uigab.inc.php,v 1.11 2005/08/18 13:23:16 sigurdne
Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uigab
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
- var $part_of_town_id;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'index' => True,
- 'list_detail' => True,
- 'view' => True,
- 'edit' => True,
- 'delete' => True
- );
-
- function uigab()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bo =
CreateObject($this->currentapp.'.bogab',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
- $this->bolocation =
CreateObject($this->currentapp.'.bolocation');
-
- $this->config =
CreateObject('phpgwapi.config');
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
- $this->acl2_location = '.location';
- $this->acl_read =
$this->acl2->check('.location',1);
- $this->acl_add =
$this->acl2->check('.location',2);
- $this->acl_edit =
$this->acl2->check('.location',4);
- $this->acl_delete =
$this->acl2->check('.location',8);
-
- $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->status_id =
$this->bo->status_id;
- $this->allrows =
$this->bo->allrows;
- $this->gab_insert_level =
$this->bo->gab_insert_level;
-
- $this->menu->sub ='location';
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' => $this->filter,
- 'cat_id' => $this->cat_id,
- 'allrows' => $this->allrows
- );
- $this->bo->save_sessiondata($data);
- }
-
- function index()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('gab',
-
'menu',
-
'nextmatchs'));
-
- $address =
get_var('address',array('POST','GET'));
- $location_code =
get_var('location_code',array('POST','GET'));
- $gaards_nr =
get_var('gaards_nr',array('POST','GET'));
- $bruksnr =
get_var('bruksnr',array('POST','GET'));
- $feste_nr =
get_var('feste_nr',array('POST','GET'));
- $seksjons_nr =
get_var('seksjons_nr',array('POST','GET'));
- $reset_query =
get_var('reset_query',array('POST','GET'));
-
- if($reset_query)
- {
- unset($address);
- unset($location_code);
- unset($gaards_nr);
- unset($bruksnr);
- unset($feste_nr);
- unset($seksjons_nr);
- }
-
- $links = $this->menu->links('gab');
-
- $gab_list =
$this->bo->read($location_code,$gaards_nr,$bruksnr,$feste_nr,$seksjons_nr,$address);
-
- if($this->acl_read)
- {
- $text_view = lang('view');
- $lang_view_statustext = lang('view gab
detail');
- }
-
- $config =
CreateObject('phpgwapi.config',$this->currentapp);
-
- $config->read_repository();
- $link_to_map = $config->config_data['map_url'];
- if($link_to_map)
- {
- $text_map=lang('Map');
- $lang_map_statustext = lang('View map');
- }
- $link_to_gab = $config->config_data['gab_url'];
- if($link_to_gab)
- {
- $text_gab=lang('GAB');
- $lang_gab_statustext = lang('View gab-info');
- }
-
- while (is_array($gab_list) && list(,$gab) =
each($gab_list))
- {
-
- $value_gaards_nr =
substr($gab['gab_id'],4,5);
- $value_bruks_nr =
substr($gab['gab_id'],9,4);
- $value_feste_nr =
substr($gab['gab_id'],13,4);
- $value_seksjons_nr =
substr($gab['gab_id'],17,3);
-
- $content[] = array
- (
- 'owner' =>
lang($gab['owner']),
- 'hits' =>
$gab['hits'],
- 'address' =>
$gab['address'],
- 'gaards_nr' =>
$value_gaards_nr,
- 'bruks_nr' =>
$value_bruks_nr,
- 'feste_nr' =>
$value_feste_nr,
- 'seksjons_nr' =>
$value_seksjons_nr,
- 'location_code' =>
$gab['location_code'],
- 'link_view' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.list_detail&gab_id='
. $gab['gab_id']),
- 'lang_view_statustext' =>
$lang_view_statustext,
- 'text_view' =>
$text_view,
- 'link_map' =>
$link_to_map . '?maptype=Eiendomskart&gnr=' . (int)$value_gaards_nr . '&bnr=' .
(int)$value_bruks_nr . '&fnr=' . (int)$value_feste_nr,
- 'lang_map_statustext' =>
$lang_map_statustext,
- 'text_map' =>
$text_map,
- 'link_gab' =>
$link_to_gab . '?type=eiendom&Gnr=' . (int)$value_gaards_nr . '&Bnr=' .
(int)$value_bruks_nr . '&Fnr=' . (int)$value_feste_nr . '&Snr=' .
(int)$value_seksjons_nr,
- 'lang_gab_statustext' =>
$lang_gab_statustext,
- 'text_gab' =>
$text_gab
- );
- }
-
-
- $table_header[] = array
- (
- 'sort_gab_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'gab_id',
-
'order' => $this->order,
-
'extra' => array('menuaction'=> $this->currentapp.'.uigab.index',
-
'cat_id' =>$this->cat_id,
-
'district_id' => $this->district_id,
-
'filter' =>$this->filter,
-
'allrows' => $this->allrows,
-
'query' =>$this->query,
-
'location_code' =>$location_code,
-
'gaards_nr' =>$gaards_nr,
-
'bruksnr' =>$bruksnr,
-
'feste_nr' =>$feste_nr,
-
'seksjons_nr' =>$seksjons_nr,
-
'address' =>$address)
-
)),
- 'lang_gab' => lang('gab'),
- 'sort_hits' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'hits',
-
'order' => $this->order,
-
'extra' => array('menuaction'=> $this->currentapp.'.uigab.index',
-
'cat_id' =>$this->cat_id,
-
'district_id' => $this->district_id,
-
'filter' =>$this->filter,
-
'allrows' => $this->allrows,
-
'query' =>$this->query,
-
'location_code' =>$location_code,
-
'gaards_nr' =>$gaards_nr,
-
'bruksnr' =>$bruksnr,
-
'feste_nr' =>$feste_nr,
-
'seksjons_nr' =>$seksjons_nr,
-
'address' =>$address)
-
)),
- 'sort_location_code' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'location_code',
-
'order' => $this->order,
-
'extra' => array('menuaction'=> $this->currentapp.'.uigab.index',
-
'cat_id' =>$this->cat_id,
-
'district_id' => $this->district_id,
-
'filter' =>$this->filter,
-
'allrows' => $this->allrows,
-
'query' =>$this->query,
-
'location_code' =>$location_code,
-
'gaards_nr' =>$gaards_nr,
-
'bruksnr' =>$bruksnr,
-
'feste_nr' =>$feste_nr,
-
'seksjons_nr' =>$seksjons_nr,
-
'address' =>$address)
-
)),
- 'lang_owner' => lang('owner'),
- 'lang_hits' =>
lang('number'),
- 'lang_address' => lang('Address'),
- 'lang_gaards_nr' => lang('gaards nr'),
- 'lang_bruksnr' => lang('bruks nr'),
- 'lang_feste_nr' => lang('Feste nr'),
- 'lang_seksjons_nr' => lang('Seksjons nr'),
- 'lang_location_code'=> lang('Location'),
- 'lang_view' => lang('view'),
- 'lang_map' => $text_map
- );
-
- $search_field_header[] = array
- (
- 'lang_property' => lang('Property ID'),
- 'lang_gaards_nr' => lang('gaards nr'),
- 'lang_bruksnr' => lang('bruks nr'),
- 'lang_feste_nr' => lang('Feste nr'),
- 'lang_seksjons_nr' => lang('Seksjons nr')
- );
-
- if($this->acl_add)
- {
- $table_add[] = array
- (
- 'lang_add'
=> lang('add'),
- 'lang_add_statustext' => lang('add a
gab'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.edit&from=index')
- );
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uigab.index',
- 'sort' =>$this->sort,
- 'order' =>$this->order,
- 'cat_id' =>$this->cat_id,
- 'filter' =>$this->filter,
- 'location_code' =>$location_code,
- 'gaards_nr' =>$gaards_nr,
- 'bruksnr' =>$bruksnr,
- 'feste_nr' =>$feste_nr,
- 'seksjons_nr' =>$seksjons_nr,
- 'address' =>$address
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $data = array
- (
- 'search_field_header' =>
$search_field_header,
- 'links' =>
$links,
- 'allrows' =>
$this->allrows,
- 'allow_allrows' => true,
- 'start_record' =>
$this->start,
- 'record_limit' =>
$record_limit,
- 'num_records' =>
count($gab_list),
- 'all_records' =>
$this->bo->total_records,
- 'link_url' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path' =>
$GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'select_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'address' =>
$address,
- 'location_code' =>
$location_code,
- 'gaards_nr' =>
$gaards_nr,
- 'bruksnr' =>
$bruksnr,
- 'feste_nr' =>
$feste_nr,
- 'seksjons_nr' =>
$seksjons_nr,
- 'lang_search_location_statustext' =>
lang('search by location_code. To show all entries, empty all fields and press
the SUBMIT button again'),
- 'lang_search_gaard_statustext' =>
lang('search by gaards nr. To show all entries, empty all fields and press the
SUBMIT button again'),
- 'lang_search_bruk_statustext' =>
lang('search by bruk. To show all entries, empty all fields and press the
SUBMIT button again'),
- 'lang_search_feste_statustext' =>
lang('search by feste. To show all entries, empty all fields and press the
SUBMIT button again'),
- 'lang_search_seksjon_statustext' =>
lang('search by seksjon. To show all entries, empty all fields and press the
SUBMIT button again'),
- 'lang_searchbutton_statustext' =>
lang('Submit the search string'),
- 'lang_reset_query_statustext' =>
lang('check to reset the query'),
- 'lang_search' =>
lang('search'),
- 'table_header_gab' =>
$table_header,
- 'values_gab' =>
$content,
- 'table_add' =>
$table_add
- );
-
- $appname = lang('gab');
- $function_msg = lang('list gab');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_gab' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function list_detail()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('gab','values','table_header',
-
'menu',
-
'nextmatchs'));
-
- $gab_id =
get_var('gab_id',array('POST','GET'));
-
- $links = $this->menu->links('gab');
-
- $gab_list = $this->bo->read_detail($gab_id);
-
- $uicols = $this->bo->uicols;
-
- $j=0;
- while (is_array($gab_list) && list(,$gab_entry) =
each($gab_list))
- {
- for ($k=0;$k<count($uicols['name']);$k++)
- {
- if($uicols['input_type'][$k]!='hidden')
- {
-
$content[$j]['row'][$k]['value'] =
$gab_entry[$uicols['name'][$k]];
- $content[$j]['row'][$k]['name']
= $uicols['name'][$k];
- }
- }
-
- if(!$lookup)
- {
- if($this->acl_read)
- {
-
$content[$j]['row'][$k]['statustext'] = lang('view the gab');
- $content[$j]['row'][$k]['text']
= lang('view');
- $content[$j]['row'][$k]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.view&gab_id='
. $gab_entry['gab_id'] . '&location_code=' . $gab_entry['location_code']);
- $k++;
- }
-
- if($this->acl_edit)
- {
-
$content[$j]['row'][$k]['statustext'] = lang('edit the gab');
- $content[$j]['row'][$k]['text']
= lang('edit');
- $content[$j]['row'][$k]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.edit&gab_id='
. $gab_entry['gab_id'] . '&location_code=' . $gab_entry['location_code'] .
'&from=list_detail');
- $k++;
- }
-
- if($this->acl_delete)
- {
-
$content[$j]['row'][$k]['statustext'] = lang('delete the
gab');
- $content[$j]['row'][$k]['text']
= lang('delete');
- $content[$j]['row'][$k]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.delete&gab_id='
. $gab_entry['gab_id'] . '&location_code=' . $gab_entry['location_code']);
- $k++;
- }
- }
-
- $j++;
- }
-
- for ($i=0;$i<count($uicols['descr']);$i++)
- {
- if($uicols['input_type'][$i]!='hidden')
- {
- $table_header[$i]['header'] =
$uicols['descr'][$i];
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- if($uicols['name'][$i]=='loc1')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'location_code',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uigab.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'lookup'
=>$lookup,
-
'district_id' =>
$this->district_id,
-
'cat_id'
=>$this->cat_id)
-
));
- }
- if($uicols['name'][$i]=='gab_id')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'gab_id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uigab.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'lookup'
=>$lookup,
-
'district_id' =>
$this->district_id,
-
'cat_id'
=>$this->cat_id)
-
));
- }
- if($uicols['name'][$i]=='address')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'address',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uigab.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'lookup'
=>$lookup,
-
'district_id' =>
$this->district_id,
-
'cat_id'
=>$this->cat_id)
-
));
- }
- }
- }
-
- if(!$lookup)
- {
- if($this->acl_read)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('view');
- $i++;
- }
- if($this->acl_edit)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('edit');
- $i++;
- }
- if($this->acl_delete)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('delete');
- $i++;
- }
- }
- else
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header'] =
lang('select');
- }
-
-//_debug_array($content);
- if($this->acl_add)
- {
- $table_add[] = array
- (
- 'lang_add'
=> lang('add'),
- 'lang_add_statustext' => lang('add a
gab'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.edit&from=list_detail&gab_id='
. $gab_id . '&new=true')
-
- );
- }
-
-
- $table_done[] = array
- (
- 'lang_done' =>
lang('done'),
- 'lang_done_statustext' => lang('back to list'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.index')
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uigab.list_detail',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'filter'
=>$this->filter,
- 'gab_id'
=>$gab_id
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $data = array
- (
- 'gaards_nr'
=> substr($gab_id,4,5),
- 'bruks_nr'
=> substr($gab_id,9,4),
- 'feste_nr'
=> substr($gab_id,13,4),
- 'seksjons_nr'
=> substr($gab_id,17,3),
-
- 'value_owner'
=> lang($gab_list[0]['owner']),
- 'lang_owner'
=> lang('owner'),
- 'lang_gaards_nr'
=> lang('gaards nr'),
- 'lang_bruksnr'
=> lang('bruks nr'),
- 'lang_feste_nr'
=> lang('Feste nr'),
- 'lang_seksjons_nr'
=> lang('Seksjons nr'),
-
- 'links'
=> $links,
- 'allrows'
=> $this->allrows,
- 'allow_allrows'
=> true,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($gab_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add,
- 'table_done'
=> $table_done
- );
-
- $appname = lang('gab');
- $function_msg = lang('list gab detail');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_gab_detail' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
-
- function edit()
- {
- if(!$this->acl_add && !$this->acl_edit)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
- }
-
- $from =
get_var('from',array('POST','GET'));
- $new =
get_var('new',array('POST','GET'));
- $gab_id =
get_var('gab_id',array('POST','GET'));
- $location_code =
get_var('location_code',array('POST','GET'));
- $values =
get_var('values',array('POST'));
- $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('gab'));
-
- if(!$values && $location_code)
- {
- $values['location_data'] =
$this->bolocation->read_single($location_code,$values['extra']);
- }
-
-//_debug_array($values);
-
- if ($values['save'])
- {
-
- for ($i=0;
$i<count($insert_record['location']); $i++)
- {
-
if($_POST[$insert_record['location'][$i]])
- {
-
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
- }
- }
-
- while (is_array($insert_record['extra']) &&
list($key,) = each($insert_record['extra']))
- {
- if($_POST[$key])
- {
- $values['extra'][$key] =
$_POST[$key];
- }
- }
-
- $values['street_name'] =
$_POST['street_name'];
- $values['street_number'] =
$_POST['street_number'];
- $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
-
- $values['gab_id'] = $gab_id;
-
- $values['location_code'] = $location_code;
-
- if(!$values['location_code'] &&
!$values['location'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a location !'));
- }
-
- if((count($values['location']) <
$this->gab_insert_level) && !$values['propagate'] && !$values['location_code'])
- {
- $receipt['error'][] =
array('msg'=>lang('Either select propagate - or choose location level %1
!',$this->gab_insert_level));
- }
-
-//_debug_array($values);
- if(!$receipt['error'])
- {
- $receipt =
$this->bo->save($values);
- $location_code =
$receipt['location_code'];
- $gab_id =
$receipt['gab_id'];
-//_debug_array($receipt);
- }
- }
-
- if ($gab_id && !$new)
- {
- $values =
$this->bo->read_single($gab_id,$location_code);
- }
- if ($values['location_code'])
- {
- $function_msg = lang('Edit gab');
- $action='edit';
- $lookup_type ='view';
-
- }
- else
- {
- $function_msg = lang('Add gab');
- $action='add';
- $lookup_type ='form';
- }
-
- if ($values['cat_id'])
- {
- $this->cat_id = $values['cat_id'];
- }
-
-
- if($values['location_data'])
- {
- $type_id =
count(explode('-',$values['location_code']));
- }
- else
- {
- $type_id = $this->gab_insert_level;
- }
-
$location_data=$this->bolocation->initiate_ui_location(array(
- 'values' =>
$values['location_data'],
- 'type_id' =>
$type_id,
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' =>
False,
- 'lookup_type' => $lookup_type
- ));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uigab.edit',
- 'gab_id' => $gab_id,
- 'location_code' => $location_code,
- 'from' => $from
- );
-
-
- if($from=='list_detail')
- {
- $gab_done='&gab_id=' . $gab_id;
- }
-
- $kommune_nr = substr($gab_id,0,4);
- if(!$kommune_nr > 0)
- {
- $this->config->read_repository();
- $kommune_nr=
$this->config->config_data['default_municipal'];
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'value_owner'
=> $values['owner'],
- 'lang_owner'
=> lang('owner'),
- 'kommune_nr'
=> $kommune_nr,
- 'gaards_nr'
=> substr($gab_id,4,5),
- 'bruks_nr'
=> substr($gab_id,9,4),
- 'feste_nr'
=> substr($gab_id,13,4),
- 'seksjons_nr'
=> substr($gab_id,17,3),
-
- 'lang_kommune_nr'
=> lang('kommune nr'),
- 'lang_gaards_nr'
=> lang('gaards nr'),
- 'lang_bruksnr'
=> lang('bruks nr'),
- 'lang_feste_nr'
=> lang('Feste nr'),
- 'lang_seksjons_nr'
=> lang('Seksjons nr'),
-
- 'action'
=> $action,
- 'lookup_type'
=> $lookup_type,
- 'location_data'
=> $location_data,
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.'.$from.$gab_done),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
-
- 'lang_propagate'
=> lang('propagate'),
- 'lang_propagate_statustext' =>
lang('check to inherit from this location'),
-
- 'lang_remark_statustext' =>
lang('Enter a remark for this entity'),
- 'lang_remark'
=> lang('remark'),
- 'value_remark'
=> $values['remark'],
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'lang_save_statustext' =>
lang('Save the gab')
- );
-
- $appname = lang('gab');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function delete()
- {
- if(!$this->acl_delete)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
- }
-
- $gab_id = get_var('gab_id',array('POST','GET'));
- $location_code =
get_var('location_code',array('POST','GET'));
- $confirm = get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uigab.list_detail',
- 'gab_id' => $gab_id
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($gab_id,$location_code);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.delete&gab_id='
. $gab_id . '&location_code=' . $location_code),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('gab');
- $function_msg =
lang('delete gab at:') . ' ' . $location_code;
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function view()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $gab_id =
get_var('gab_id',array('POST','GET'));
- $location_code =
get_var('location_code',array('POST','GET'));
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('gab'));
-
-//_debug_array($values);
-
-
- if ($gab_id && !$new)
- {
- $values =
$this->bo->read_single($gab_id,$location_code);
- }
-
- $function_msg = lang('View gab');
- $location_type ='view';
-
-
-
$location_data=$this->bolocation->initiate_ui_location(array(
- 'values' =>
$values['location_data'],
- 'type_id' =>
count(explode('-',$values['location_code'])),
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' =>
False,
- 'lookup_type' => 'view'
- ));
-
-
- $data = array
- (
- 'kommune_nr'
=> substr($gab_id,0,4),
- 'gaards_nr'
=> substr($gab_id,4,5),
- 'bruks_nr'
=> substr($gab_id,9,4),
- 'feste_nr'
=> substr($gab_id,13,4),
- 'seksjons_nr'
=> substr($gab_id,17,3),
-
- 'value_owner'
=> lang($values['owner']),
- 'lang_owner'
=> lang('owner'),
-
- 'lang_kommune_nr'
=> lang('kommune nr'),
- 'lang_gaards_nr'
=> lang('gaards nr'),
- 'lang_bruksnr'
=> lang('bruks nr'),
- 'lang_feste_nr'
=> lang('Feste nr'),
- 'lang_seksjons_nr'
=> lang('Seksjons nr'),
-
- 'location_type'
=> $location_type,
- 'location_data'
=> $location_data,
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.list_detail&gab_id='
. $gab_id),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
-
- 'lang_remark'
=> lang('remark'),
- 'value_remark'
=> $values['remark'],
- 'lang_done_statustext' =>
lang('Back to the list'),
-
- 'edit_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.edit&from=list_detail&gab_id='
. $gab_id . '&location_code=' . $location_code),
- 'lang_edit_statustext'
=> lang('Edit this entry'),
- 'lang_edit'
=> lang('Edit')
- );
-
- $appname = lang('gab');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage location
+ * @version $Id: class.uigab.inc.php,v 1.12 2006/01/27 14:05:43 sigurdne
Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uigab
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+ var $part_of_town_id;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'list_detail' => True,
+ 'view' => True,
+ 'edit' => True,
+ 'delete' => True
+ );
+
+ function uigab()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bo =
CreateObject($this->currentapp.'.bogab',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+ $this->bolocation =
CreateObject($this->currentapp.'.bolocation');
+
+ $this->config =
CreateObject('phpgwapi.config');
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+ $this->acl2_location = '.location';
+ $this->acl_read =
$this->acl2->check('.location',1);
+ $this->acl_add =
$this->acl2->check('.location',2);
+ $this->acl_edit =
$this->acl2->check('.location',4);
+ $this->acl_delete =
$this->acl2->check('.location',8);
+
+ $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->status_id =
$this->bo->status_id;
+ $this->allrows =
$this->bo->allrows;
+ $this->gab_insert_level =
$this->bo->gab_insert_level;
+
+ $this->menu->sub ='location';
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' => $this->filter,
+ 'cat_id' => $this->cat_id,
+ 'allrows' => $this->allrows
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function index()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('gab',
+
'menu',
+
'nextmatchs'));
+
+ $address =
get_var('address',array('POST','GET'));
+ $location_code =
get_var('location_code',array('POST','GET'));
+ $gaards_nr =
get_var('gaards_nr',array('POST','GET'));
+ $bruksnr =
get_var('bruksnr',array('POST','GET'));
+ $feste_nr =
get_var('feste_nr',array('POST','GET'));
+ $seksjons_nr =
get_var('seksjons_nr',array('POST','GET'));
+ $reset_query =
get_var('reset_query',array('POST','GET'));
+
+ if($reset_query)
+ {
+ unset($address);
+ unset($location_code);
+ unset($gaards_nr);
+ unset($bruksnr);
+ unset($feste_nr);
+ unset($seksjons_nr);
+ }
+
+ $links = $this->menu->links('gab');
+
+ $gab_list =
$this->bo->read($location_code,$gaards_nr,$bruksnr,$feste_nr,$seksjons_nr,$address);
+
+ if($this->acl_read)
+ {
+ $text_view = lang('view');
+ $lang_view_statustext = lang('view gab
detail');
+ }
+
+ $config =
CreateObject('phpgwapi.config',$this->currentapp);
+
+ $config->read_repository();
+ $link_to_map = $config->config_data['map_url'];
+ if($link_to_map)
+ {
+ $text_map=lang('Map');
+ $lang_map_statustext = lang('View map');
+ }
+ $link_to_gab = $config->config_data['gab_url'];
+ if($link_to_gab)
+ {
+ $text_gab=lang('GAB');
+ $lang_gab_statustext = lang('View gab-info');
+ }
+
+ while (is_array($gab_list) && list(,$gab) =
each($gab_list))
+ {
+
+ $value_gaards_nr =
substr($gab['gab_id'],4,5);
+ $value_bruks_nr =
substr($gab['gab_id'],9,4);
+ $value_feste_nr =
substr($gab['gab_id'],13,4);
+ $value_seksjons_nr =
substr($gab['gab_id'],17,3);
+
+ $content[] = array
+ (
+ 'owner' =>
lang($gab['owner']),
+ 'hits' =>
$gab['hits'],
+ 'address' =>
$gab['address'],
+ 'gaards_nr' =>
$value_gaards_nr,
+ 'bruks_nr' =>
$value_bruks_nr,
+ 'feste_nr' =>
$value_feste_nr,
+ 'seksjons_nr' =>
$value_seksjons_nr,
+ 'location_code' =>
$gab['location_code'],
+ 'link_view' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.list_detail&gab_id='
. $gab['gab_id']),
+ 'lang_view_statustext' =>
$lang_view_statustext,
+ 'text_view' =>
$text_view,
+ 'link_map' =>
$link_to_map . '?maptype=Eiendomskart&gnr=' . (int)$value_gaards_nr . '&bnr=' .
(int)$value_bruks_nr . '&fnr=' . (int)$value_feste_nr,
+ 'lang_map_statustext' =>
$lang_map_statustext,
+ 'text_map' =>
$text_map,
+ 'link_gab' =>
$link_to_gab . '?type=eiendom&Gnr=' . (int)$value_gaards_nr . '&Bnr=' .
(int)$value_bruks_nr . '&Fnr=' . (int)$value_feste_nr . '&Snr=' .
(int)$value_seksjons_nr,
+ 'lang_gab_statustext' =>
$lang_gab_statustext,
+ 'text_gab' =>
$text_gab
+ );
+ }
+
+
+ $table_header[] = array
+ (
+ 'sort_gab_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'gab_id',
+
'order' => $this->order,
+
'extra' => array('menuaction'=> $this->currentapp.'.uigab.index',
+
'cat_id' =>$this->cat_id,
+
'district_id' => $this->district_id,
+
'filter' =>$this->filter,
+
'allrows' => $this->allrows,
+
'query' =>$this->query,
+
'location_code' =>$location_code,
+
'gaards_nr' =>$gaards_nr,
+
'bruksnr' =>$bruksnr,
+
'feste_nr' =>$feste_nr,
+
'seksjons_nr' =>$seksjons_nr,
+
'address' =>$address)
+
)),
+ 'lang_gab' => lang('gab'),
+ 'sort_hits' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'hits',
+
'order' => $this->order,
+
'extra' => array('menuaction'=> $this->currentapp.'.uigab.index',
+
'cat_id' =>$this->cat_id,
+
'district_id' => $this->district_id,
+
'filter' =>$this->filter,
+
'allrows' => $this->allrows,
+
'query' =>$this->query,
+
'location_code' =>$location_code,
+
'gaards_nr' =>$gaards_nr,
+
'bruksnr' =>$bruksnr,
+
'feste_nr' =>$feste_nr,
+
'seksjons_nr' =>$seksjons_nr,
+
'address' =>$address)
+
)),
+ 'sort_location_code' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'location_code',
+
'order' => $this->order,
+
'extra' => array('menuaction'=> $this->currentapp.'.uigab.index',
+
'cat_id' =>$this->cat_id,
+
'district_id' => $this->district_id,
+
'filter' =>$this->filter,
+
'allrows' => $this->allrows,
+
'query' =>$this->query,
+
'location_code' =>$location_code,
+
'gaards_nr' =>$gaards_nr,
+
'bruksnr' =>$bruksnr,
+
'feste_nr' =>$feste_nr,
+
'seksjons_nr' =>$seksjons_nr,
+
'address' =>$address)
+
)),
+ 'lang_owner' => lang('owner'),
+ 'lang_hits' =>
lang('number'),
+ 'lang_address' => lang('Address'),
+ 'lang_gaards_nr' => lang('gaards nr'),
+ 'lang_bruksnr' => lang('bruks nr'),
+ 'lang_feste_nr' => lang('Feste nr'),
+ 'lang_seksjons_nr' => lang('Seksjons nr'),
+ 'lang_location_code'=> lang('Location'),
+ 'lang_view' => lang('view'),
+ 'lang_map' => $text_map
+ );
+
+ $search_field_header[] = array
+ (
+ 'lang_property' => lang('Property ID'),
+ 'lang_gaards_nr' => lang('gaards nr'),
+ 'lang_bruksnr' => lang('bruks nr'),
+ 'lang_feste_nr' => lang('Feste nr'),
+ 'lang_seksjons_nr' => lang('Seksjons nr')
+ );
+
+ if($this->acl_add)
+ {
+ $table_add[] = array
+ (
+ 'lang_add'
=> lang('add'),
+ 'lang_add_statustext' => lang('add a
gab'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.edit&from=index')
+ );
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uigab.index',
+ 'sort' =>$this->sort,
+ 'order' =>$this->order,
+ 'cat_id' =>$this->cat_id,
+ 'filter' =>$this->filter,
+ 'location_code' =>$location_code,
+ 'gaards_nr' =>$gaards_nr,
+ 'bruksnr' =>$bruksnr,
+ 'feste_nr' =>$feste_nr,
+ 'seksjons_nr' =>$seksjons_nr,
+ 'address' =>$address
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $data = array
+ (
+ 'search_field_header' =>
$search_field_header,
+ 'links' =>
$links,
+ 'allrows' =>
$this->allrows,
+ 'allow_allrows' => true,
+ 'start_record' =>
$this->start,
+ 'record_limit' =>
$record_limit,
+ 'num_records' =>
count($gab_list),
+ 'all_records' =>
$this->bo->total_records,
+ 'link_url' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path' =>
$GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'select_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'address' =>
$address,
+ 'location_code' =>
$location_code,
+ 'gaards_nr' =>
$gaards_nr,
+ 'bruksnr' =>
$bruksnr,
+ 'feste_nr' =>
$feste_nr,
+ 'seksjons_nr' =>
$seksjons_nr,
+ 'lang_search_location_statustext' =>
lang('search by location_code. To show all entries, empty all fields and press
the SUBMIT button again'),
+ 'lang_search_gaard_statustext' =>
lang('search by gaards nr. To show all entries, empty all fields and press the
SUBMIT button again'),
+ 'lang_search_bruk_statustext' =>
lang('search by bruk. To show all entries, empty all fields and press the
SUBMIT button again'),
+ 'lang_search_feste_statustext' =>
lang('search by feste. To show all entries, empty all fields and press the
SUBMIT button again'),
+ 'lang_search_seksjon_statustext' =>
lang('search by seksjon. To show all entries, empty all fields and press the
SUBMIT button again'),
+ 'lang_searchbutton_statustext' =>
lang('Submit the search string'),
+ 'lang_reset_query_statustext' =>
lang('check to reset the query'),
+ 'lang_search' =>
lang('search'),
+ 'table_header_gab' =>
$table_header,
+ 'values_gab' =>
$content,
+ 'table_add' =>
$table_add
+ );
+
+ $appname = lang('gab');
+ $function_msg = lang('list gab');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_gab' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function list_detail()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('gab','values','table_header',
+
'menu',
+
'nextmatchs'));
+
+ $gab_id =
get_var('gab_id',array('POST','GET'));
+
+ $links = $this->menu->links('gab');
+
+ $gab_list = $this->bo->read_detail($gab_id);
+
+ $uicols = $this->bo->uicols;
+
+ $j=0;
+ while (is_array($gab_list) && list(,$gab_entry) =
each($gab_list))
+ {
+ for ($k=0;$k<count($uicols['name']);$k++)
+ {
+ if($uicols['input_type'][$k]!='hidden')
+ {
+
$content[$j]['row'][$k]['value'] =
$gab_entry[$uicols['name'][$k]];
+ $content[$j]['row'][$k]['name']
= $uicols['name'][$k];
+ }
+ }
+
+ if(!$lookup)
+ {
+ if($this->acl_read)
+ {
+
$content[$j]['row'][$k]['statustext'] = lang('view the gab');
+ $content[$j]['row'][$k]['text']
= lang('view');
+ $content[$j]['row'][$k]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.view&gab_id='
. $gab_entry['gab_id'] . '&location_code=' . $gab_entry['location_code']);
+ $k++;
+ }
+
+ if($this->acl_edit)
+ {
+
$content[$j]['row'][$k]['statustext'] = lang('edit the gab');
+ $content[$j]['row'][$k]['text']
= lang('edit');
+ $content[$j]['row'][$k]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.edit&gab_id='
. $gab_entry['gab_id'] . '&location_code=' . $gab_entry['location_code'] .
'&from=list_detail');
+ $k++;
+ }
+
+ if($this->acl_delete)
+ {
+
$content[$j]['row'][$k]['statustext'] = lang('delete the
gab');
+ $content[$j]['row'][$k]['text']
= lang('delete');
+ $content[$j]['row'][$k]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.delete&gab_id='
. $gab_entry['gab_id'] . '&location_code=' . $gab_entry['location_code']);
+ $k++;
+ }
+ }
+
+ $j++;
+ }
+
+ for ($i=0;$i<count($uicols['descr']);$i++)
+ {
+ if($uicols['input_type'][$i]!='hidden')
+ {
+ $table_header[$i]['header'] =
$uicols['descr'][$i];
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ if($uicols['name'][$i]=='loc1')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'location_code',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uigab.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'lookup'
=>$lookup,
+
'district_id' =>
$this->district_id,
+
'cat_id'
=>$this->cat_id)
+
));
+ }
+ if($uicols['name'][$i]=='gab_id')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'gab_id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uigab.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'lookup'
=>$lookup,
+
'district_id' =>
$this->district_id,
+
'cat_id'
=>$this->cat_id)
+
));
+ }
+ if($uicols['name'][$i]=='address')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'address',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uigab.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'lookup'
=>$lookup,
+
'district_id' =>
$this->district_id,
+
'cat_id'
=>$this->cat_id)
+
));
+ }
+ }
+ }
+
+ if(!$lookup)
+ {
+ if($this->acl_read)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('view');
+ $i++;
+ }
+ if($this->acl_edit)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('edit');
+ $i++;
+ }
+ if($this->acl_delete)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('delete');
+ $i++;
+ }
+ }
+ else
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header'] =
lang('select');
+ }
+
+//_debug_array($content);
+ if($this->acl_add)
+ {
+ $table_add[] = array
+ (
+ 'lang_add'
=> lang('add'),
+ 'lang_add_statustext' => lang('add a
gab'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.edit&from=list_detail&gab_id='
. $gab_id . '&new=true')
+
+ );
+ }
+
+
+ $table_done[] = array
+ (
+ 'lang_done' =>
lang('done'),
+ 'lang_done_statustext' => lang('back to list'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.index')
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uigab.list_detail',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'filter'
=>$this->filter,
+ 'gab_id'
=>$gab_id
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $data = array
+ (
+ 'gaards_nr'
=> substr($gab_id,4,5),
+ 'bruks_nr'
=> substr($gab_id,9,4),
+ 'feste_nr'
=> substr($gab_id,13,4),
+ 'seksjons_nr'
=> substr($gab_id,17,3),
+
+ 'value_owner'
=> lang($gab_list[0]['owner']),
+ 'lang_owner'
=> lang('owner'),
+ 'lang_gaards_nr'
=> lang('gaards nr'),
+ 'lang_bruksnr'
=> lang('bruks nr'),
+ 'lang_feste_nr'
=> lang('Feste nr'),
+ 'lang_seksjons_nr'
=> lang('Seksjons nr'),
+
+ 'links'
=> $links,
+ 'allrows'
=> $this->allrows,
+ 'allow_allrows'
=> true,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($gab_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add,
+ 'table_done'
=> $table_done
+ );
+
+ $appname = lang('gab');
+ $function_msg = lang('list gab detail');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_gab_detail' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+
+ function edit()
+ {
+ if(!$this->acl_add && !$this->acl_edit)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
+ }
+
+ $from =
get_var('from',array('POST','GET'));
+ $new =
get_var('new',array('POST','GET'));
+ $gab_id =
get_var('gab_id',array('POST','GET'));
+ $location_code =
get_var('location_code',array('POST','GET'));
+ $values =
get_var('values',array('POST'));
+ $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('gab'));
+
+ if(!$values && $location_code)
+ {
+ $values['location_data'] =
$this->bolocation->read_single($location_code,$values['extra']);
+ }
+
+//_debug_array($values);
+
+ if ($values['save'])
+ {
+
+ for ($i=0;
$i<count($insert_record['location']); $i++)
+ {
+
if($_POST[$insert_record['location'][$i]])
+ {
+
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
+ }
+ }
+
+ while (is_array($insert_record['extra']) &&
list($key,) = each($insert_record['extra']))
+ {
+ if($_POST[$key])
+ {
+ $values['extra'][$key] =
$_POST[$key];
+ }
+ }
+
+ $values['street_name'] =
$_POST['street_name'];
+ $values['street_number'] =
$_POST['street_number'];
+ $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
+
+ $values['gab_id'] = $gab_id;
+
+ $values['location_code'] = $location_code;
+
+ if(!$values['location_code'] &&
!$values['location'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a location !'));
+ }
+
+ if((count($values['location']) <
$this->gab_insert_level) && !$values['propagate'] && !$values['location_code'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Either select propagate - or choose location level %1
!',$this->gab_insert_level));
+ }
+
+//_debug_array($values);
+ if(!$receipt['error'])
+ {
+ $receipt =
$this->bo->save($values);
+ $location_code =
$receipt['location_code'];
+ $gab_id =
$receipt['gab_id'];
+//_debug_array($receipt);
+ }
+ }
+
+ if ($gab_id && !$new)
+ {
+ $values =
$this->bo->read_single($gab_id,$location_code);
+ }
+ if ($values['location_code'])
+ {
+ $function_msg = lang('Edit gab');
+ $action='edit';
+ $lookup_type ='view';
+
+ }
+ else
+ {
+ $function_msg = lang('Add gab');
+ $action='add';
+ $lookup_type ='form';
+ }
+
+ if ($values['cat_id'])
+ {
+ $this->cat_id = $values['cat_id'];
+ }
+
+
+ if($values['location_data'])
+ {
+ $type_id =
count(explode('-',$values['location_code']));
+ }
+ else
+ {
+ $type_id = $this->gab_insert_level;
+ }
+
$location_data=$this->bolocation->initiate_ui_location(array(
+ 'values' =>
$values['location_data'],
+ 'type_id' =>
$type_id,
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' =>
False,
+ 'lookup_type' => $lookup_type
+ ));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uigab.edit',
+ 'gab_id' => $gab_id,
+ 'location_code' => $location_code,
+ 'from' => $from
+ );
+
+
+ if($from=='list_detail')
+ {
+ $gab_done='&gab_id=' . $gab_id;
+ }
+
+ $kommune_nr = substr($gab_id,0,4);
+ if(!$kommune_nr > 0)
+ {
+ $this->config->read_repository();
+ $kommune_nr=
$this->config->config_data['default_municipal'];
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'value_owner'
=> $values['owner'],
+ 'lang_owner'
=> lang('owner'),
+ 'kommune_nr'
=> $kommune_nr,
+ 'gaards_nr'
=> substr($gab_id,4,5),
+ 'bruks_nr'
=> substr($gab_id,9,4),
+ 'feste_nr'
=> substr($gab_id,13,4),
+ 'seksjons_nr'
=> substr($gab_id,17,3),
+
+ 'lang_kommune_nr'
=> lang('kommune nr'),
+ 'lang_gaards_nr'
=> lang('gaards nr'),
+ 'lang_bruksnr'
=> lang('bruks nr'),
+ 'lang_feste_nr'
=> lang('Feste nr'),
+ 'lang_seksjons_nr'
=> lang('Seksjons nr'),
+
+ 'action'
=> $action,
+ 'lookup_type'
=> $lookup_type,
+ 'location_data'
=> $location_data,
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.'.$from.$gab_done),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+
+ 'lang_propagate'
=> lang('propagate'),
+ 'lang_propagate_statustext' =>
lang('check to inherit from this location'),
+
+ 'lang_remark_statustext' =>
lang('Enter a remark for this entity'),
+ 'lang_remark'
=> lang('remark'),
+ 'value_remark'
=> $values['remark'],
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'lang_save_statustext' =>
lang('Save the gab')
+ );
+
+ $appname = lang('gab');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function delete()
+ {
+ if(!$this->acl_delete)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
+ }
+
+ $gab_id = get_var('gab_id',array('POST','GET'));
+ $location_code =
get_var('location_code',array('POST','GET'));
+ $confirm = get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uigab.list_detail',
+ 'gab_id' => $gab_id
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($gab_id,$location_code);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.delete&gab_id='
. $gab_id . '&location_code=' . $location_code),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('gab');
+ $function_msg =
lang('delete gab at:') . ' ' . $location_code;
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function view()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $gab_id =
get_var('gab_id',array('POST','GET'));
+ $location_code =
get_var('location_code',array('POST','GET'));
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('gab'));
+
+//_debug_array($values);
+
+
+ if ($gab_id && !$new)
+ {
+ $values =
$this->bo->read_single($gab_id,$location_code);
+ }
+
+ $function_msg = lang('View gab');
+ $location_type ='view';
+
+
+
$location_data=$this->bolocation->initiate_ui_location(array(
+ 'values' =>
$values['location_data'],
+ 'type_id' =>
count(explode('-',$values['location_code'])),
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' =>
False,
+ 'lookup_type' => 'view'
+ ));
+
+
+ $data = array
+ (
+ 'kommune_nr'
=> substr($gab_id,0,4),
+ 'gaards_nr'
=> substr($gab_id,4,5),
+ 'bruks_nr'
=> substr($gab_id,9,4),
+ 'feste_nr'
=> substr($gab_id,13,4),
+ 'seksjons_nr'
=> substr($gab_id,17,3),
+
+ 'value_owner'
=> lang($values['owner']),
+ 'lang_owner'
=> lang('owner'),
+
+ 'lang_kommune_nr'
=> lang('kommune nr'),
+ 'lang_gaards_nr'
=> lang('gaards nr'),
+ 'lang_bruksnr'
=> lang('bruks nr'),
+ 'lang_feste_nr'
=> lang('Feste nr'),
+ 'lang_seksjons_nr'
=> lang('Seksjons nr'),
+
+ 'location_type'
=> $location_type,
+ 'location_data'
=> $location_data,
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.list_detail&gab_id='
. $gab_id),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+
+ 'lang_remark'
=> lang('remark'),
+ 'value_remark'
=> $values['remark'],
+ 'lang_done_statustext' =>
lang('Back to the list'),
+
+ 'edit_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uigab.edit&from=list_detail&gab_id='
. $gab_id . '&location_code=' . $location_code),
+ 'lang_edit_statustext'
=> lang('Edit this entry'),
+ 'lang_edit'
=> lang('Edit')
+ );
+
+ $appname = lang('gab');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+ }
+?>
Index: property/inc/class.uiinvestment.inc.php
diff -u property/inc/class.uiinvestment.inc.php:1.8
property/inc/class.uiinvestment.inc.php:1.9
--- property/inc/class.uiinvestment.inc.php:1.8 Thu May 12 21:26:28 2005
+++ property/inc/class.uiinvestment.inc.php Fri Jan 27 14:05:43 2006
@@ -1,690 +1,690 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage eco
- * @version $Id: class.uiinvestment.inc.php,v 1.8 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uiinvestment
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
- var $part_of_town_id;
- var $currentapp;
-
- var $public_functions = array
- (
- 'index' => True,
- 'history' => True,
- 'add' => True,
- 'delete' => True
- );
-
- function uiinvestment()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- $this->bo =
CreateObject($this->currentapp.'.boinvestment',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
- $this->bolocation =
CreateObject($this->currentapp.'.bolocation');
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
- $this->acl2_location = '.invoice';
- $this->acl_read =
$this->acl2->check('.invoice',1);
- $this->acl_add =
$this->acl2->check('.invoice',2);
- $this->acl_edit =
$this->acl2->check('.invoice',4);
- $this->acl_delete =
$this->acl2->check('.invoice',8);
-
- $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->allrows =
$this->bo->allrows;
- $this->admin_invoice =
$this->acl2->check('.invoice',16);
- $this->menu->sub ='invoice';
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' =>
$this->filter,
- 'cat_id' =>
$this->cat_id,
- 'part_of_town_id' =>
$this->part_of_town_id,
- 'this->allrows' => $this->allrows
- );
- $this->bo->save_sessiondata($data);
- }
-
- function index()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('investment',
-
'menu',
-
'nextmatchs'));
-
- $links = $this->menu->links('investment');
- $preserve =
get_var('preserve',array('POST','GET'));
- $values = get_var('values',array('POST'));
- $date = get_var('date',array('POST'));
-
- if($preserve)
- {
- $this->bo->read_sessiondata();
-
- $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->allrows =
$this->bo->allrows;
- }
-
- if($date)
- {
- $values['date'] = $date;
- }
-
- if($values)
- {
- $receipt=$this->update_investment($values);
- }
-
- $investment_list = $this->bo->read();
-
-//_debug_array($values);
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'Y';
- $dlarr[strpos($dateformat,'m')] = 'm';
- $dlarr[strpos($dateformat,'d')] = 'd';
- ksort($dlarr);
- $dateformat
= (implode($sep,$dlarr));
-
- while (is_array($investment_list) && list(,$investment)
= each($investment_list))
- {
-
- $content[] = array
- (
- 'entity_id'
=> $investment['entity_id'],
- 'investment_id'
=> $investment['investment_id'],
- 'district_id'
=> $investment['district_id'],
- 'date'
=> date($dateformat,strtotime($investment['date'])),
- 'counter'
=> $investment['counter'],
- 'part_of_town'
=> $investment['part_of_town'],
- 'descr'
=> $investment['descr'],
- 'initial_value_ex'
=> $investment['initial_value'],
- 'initial_value'
=> number_format($investment['initial_value'], 0, ',', ''),
- 'value_ex'
=> $investment['value'],
- 'value'
=> number_format($investment['value'], 0, ',', ''),
- 'this_index'
=> $investment['this_index'],
- 'index_count'
=> $investment['index_count'],
- 'entity_name'
=> $investment['entity_name'],
- 'this_write_off'
=> number_format($investment['this_write_off'], 0, ',', ''),
- 'link_history'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.history&entity_id='
. $investment['entity_id'].'&investment_id=' .
$investment['investment_id'].'&entity_type=' . $this->cat_id),
- 'lang_history'
=> lang('History'),
- 'lang_history_statustext' =>
lang('View/Edit the history'),
- 'is_admin'
=> $this->admin_invoice
- );
-
- $sum_initial_value
= $sum_initial_value + $investment['initial_value'];
- $sum_value
= $sum_value + $investment['value'];
-
- }
-
- $table_header[] = array
- (
- 'lang_district' =>
lang('District'),
- 'lang_part_of_town' => lang('Part
of town'),
- 'lang_entity_id' => lang('entity
id'),
- 'lang_investment_id' => lang('investment
id'),
- 'lang_descr' =>
lang('Descr'),
- 'lang_entity_name' => lang('Entity
name'),
- 'lang_initial_value' => lang('Initial
value'),
- 'lang_value' =>
lang('Value'),
- 'lang_last_index' => lang('Last
index'),
- 'lang_write_off' => lang('Write
off'),
- 'lang_date' =>
lang('Date'),
- 'lang_index_count' => lang('Index
count'),
- 'lang_history' =>
lang('History'),
- 'lang_select' =>
lang('Select')
- );
-
-
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
- $table_update[] = array
- (
- 'jsDateFormat'
=> $jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle'
=> lang('Select date'),
- 'calendar_setup' =>
"Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat .
"',button : 'date-trigger'});",
-
- 'lang_new_index' =>
lang('New index'),
- 'lang_new_index_statustext' => lang('Enter
a new index'),
- 'lang_date_statustext' => lang('Select
the date for the update'),
- 'lang_update' =>
lang('Update'),
- 'lang_update_statustext' => lang('update
selected investments')
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('Add'),
- 'lang_add_statustext' => lang('add a
investment'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.add')
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiinvestment.index',
- 'order' => $this->order,
- 'sort' => $this->sort,
- 'cat_id' =>
$this->cat_id,
- 'part_of_town_id' =>
$this->part_of_town_id,
- 'query' => $this->query,
- 'start' => $this->start,
- 'filter' => $this->filter
- );
-
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'links'
=> $links,
- 'lang_search'
=> lang('Search'),
- 'lang_search_statustext' =>
lang('Search for investment entries'),
-// 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'form_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.index'),
- 'lang_select_all'
=> lang('Select All'),
- 'img_check'
=>
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
- 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
- 'allow_allrows'
=> true,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($investment_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the investment belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $this->bo->select_category('select',$this->cat_id),
- 'lang_town_statustext' =>
lang('Select the part of town the investment belongs to. To do not use a part
of town - select NO PART OF TOWN'),
- 'lang_part_of_town'
=> lang('Part of town'),
- 'lang_no_part_of_town' =>
lang('Show all'),
- 'part_of_town_list'
=> $this->bocommon->select_part_of_town('select',$this->part_of_town_id),
- 'select_name_part_of_town' =>
'part_of_town_id',
- 'filter_list'
=> $this->bo->filter('select',$this->filter),
- 'filter_name'
=> 'filter',
- 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
- 'lang_show_all'
=> lang('Show all'),
-
- 'lang_submit'
=> lang('submit'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'sum_initial_value'
=> number_format($sum_initial_value, 0, ',', ''),
- 'sum_value'
=> number_format($sum_value, 0, ',', ''),
-
- 'table_update'
=> $table_update,
- 'update_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.index'),
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('investment');
- $function_msg =
lang('list investment');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function update_investment($values='')
- {
-//_debug_array($values);
-
- $errorcount = 0;
-
- if(!$values['date'])
- {
-
$receipt['error'][$errorcount++]=array('msg'=>lang('Please select a date !'));
- }
- if(!$values['new_index'])
- {
-
$receipt['error'][$errorcount++]=array('msg'=>lang('Please set a new index !'));
- }
- if(!$values['update'])
- {
-
$receipt['error'][$errorcount++]=array('msg'=>lang('Nothing to do!'));
- }
-
- if(!$receipt['error'])
- {
- $receipt=$this->bo->update_investment($values);
- }
- return $receipt;
- }
-
- function history()
- {
- $GLOBALS['phpgw']->xslttpl->add_file(array('investment',
-
'menu',
-
'nextmatchs'));
-
- $links = $this->menu->links();
- $values =
get_var('values',array('POST'));
- $date =
get_var('date',array('POST','GET'));
- $entity_type =
get_var('entity_type',array('POST','GET'));
- $entity_id =
get_var('entity_id',array('POST','GET'));
- $investment_id =
get_var('investment_id',array('POST','GET'));
-
- if($date)
- {
- $values['date'] = $date;
- }
-//_debug_array($values);
-
- if($values)
- {
- $receipt= $this->update_investment($values);
- }
-
- $investment_list =
$this->bo->read_single($entity_id,$investment_id);
-//_debug_array($investment_list);
-
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'Y';
- $dlarr[strpos($dateformat,'m')] = 'm';
- $dlarr[strpos($dateformat,'d')] = 'd';
- ksort($dlarr);
- $dateformat
= (implode($sep,$dlarr));
-
- while (is_array($investment_list) && list(,$investment)
= each($investment_list))
- {
-
- $content[] = array
- (
- 'date'
=> @date($dateformat,strtotime($investment['date'])),
- 'initial_value_ex'
=> $investment['initial_value'],
- 'initial_value'
=> number_format($investment['initial_value'], 0, ',', ''),
- 'value_ex'
=> $investment['value'],
- 'value'
=> number_format($investment['value'], 0, ',', ''),
- 'this_index'
=> $investment['this_index'],
- 'current_index'
=> $investment['current_index'],
- 'index_count'
=> $investment['index_count'],
- 'this_write_off'
=> number_format($investment['this_write_off'], 0, ',', ''),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.delete&entity_id='
. $entity_id.'&investment_id=' . $investment_id.'&index_count=' .
$investment['index_count'].'&entity_type='.$entity_type),
- 'lang_delete'
=> lang('Delete'),
- 'lang_delete_statustext' =>
lang('Delete last entry'),
- 'is_admin'
=> $this->admin_invoice
- );
-
- }
-
-//_debug_array($content);
- $table_header[] = array
- (
- 'lang_initial_value' => lang('Initial
value'),
- 'lang_value' =>
lang('Value'),
- 'lang_last_index' => lang('Last
index'),
- 'lang_write_off' => lang('Write
off'),
- 'lang_date' =>
lang('Date'),
- 'lang_index_count' => lang('Index
count'),
- 'lang_delete' =>
lang('Delete')
- );
-
-
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
- $table_update[] = array
- (
- 'lang_new_index' =>
lang('New index'),
- 'lang_new_index_statustext' => lang('Enter
a new index'),
-
- 'jsDateFormat'
=> $jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle'
=> lang('Select date'),
- 'calendar_setup' =>
"Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat .
"',button : 'date-trigger'});",
-
- 'lang_date_statustext' => lang('Select
the date for the update'),
- 'lang_update' =>
lang('Update'),
- 'lang_update_statustext' => lang('update
selected investments')
- );
-
- $table_done[] = array
- (
- 'lang_done' =>
lang('done'),
- 'lang_done_statustext' => lang('Back to
investment list '),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.index&preserve=1')
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiinvestment.index',
- 'order' => $this->order,
- 'sort' => $this->sort,
- 'cat_id' =>
$this->cat_id,
- 'part_of_town_id' =>
$this->part_of_town_id,
- 'sub' => $this->sub,
- 'query' => $this->query,
- 'start' => $this->start,
- 'filter' =>
$this->filter,
- 'entity_type' => $entity_type
- );
-
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'entity_id'
=> $entity_id,
- 'lang_entity_id'
=> lang('Entity Id'),
- 'investment_id'
=> $investment_id,
- 'lang_investment_id' =>
lang('Investment Id'),
- 'entity_type'
=> lang($entity_type),
- 'lang_entity_type'
=> lang('Entity Type'),
- 'links'
=> $links,
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'allow_allrows'
=> true,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($investment_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.history&entity_id='
. $entity_id.'&investment_id=' . $investment_id . '&entity_type=' .
$entity_type),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'entity_id'
=> $entity_id,
- 'investment_id'
=> $investment_id,
- 'table_header_history' =>
$table_header,
- 'values_history'
=> $content,
- 'table_update'
=> $table_update,
- 'update_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.history&entity_id='
. $entity_id.'&investment_id=' . $investment_id . '&entity_type=' .
$entity_type),
- 'table_done'
=> $table_done
- );
-
- $appname
= lang('investment');
- $function_msg =
lang('investment history');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('history' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
-// $this->save_sessiondata();
- }
-
-
- function add()
- {
- if(!$this->acl_add && !$this->acl_edit)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
- }
- $values =
get_var('values',array('POST'));
- $values['date'] =
get_var('date',array('POST'));
-
- $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
- $insert_record_entity =
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp);
-
- for ($j=0;$j<count($insert_record_entity);$j++)
- {
-
$insert_record['extra'][$insert_record_entity[$j]] =
$insert_record_entity[$j];
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('investment'));
-
- if ($values['save'])
- {
-
- for ($i=0;
$i<count($insert_record['location']); $i++)
- {
-
if($_POST[$insert_record['location'][$i]])
- {
-
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
- }
- }
-
- while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
- {
- if($_POST[$key])
- {
- $values['extra'][$column]
= $_POST[$key];
- }
- }
-
-
- $values['street_name'] =
$_POST['street_name'];
- $values['street_number'] =
$_POST['street_number'];
- $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
-
- if(!$values['type'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a type !'));
- }
-
- if(!$values['period'] && !$values['new_period'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a period for write off
!'));
- }
-
- if(!$values['date'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a date !'));
- }
-
- if(!$values['initial_value'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please set a initial value !'));
- }
-
- if(!$values['location']['loc1'] &&
!$values['extra']['p_num'])
- {
-
$receipt['error'][]=array('msg'=>lang('Pleace select a location - or an entity
!'));
- }
-
-//_debug_array($values['extra']);
- if(!$receipt['error'])
- {
-
$receipt=$this->bo->save_investment($values);
- unset($values);
- }
- else
- {
- if($values['location'])
- {
- $location_code=implode("-",
$values['location']);
- $values['location_data'] =
$this->bolocation->read_single($location_code,$values['extra']);
- }
-
- if($values['extra']['p_num'])
- {
-
$values['p'][$values['extra']['p_entity_id']]['p_num']=$values['extra']['p_num'];
-
$values['p'][$values['extra']['p_entity_id']]['p_entity_id']=$values['extra']['p_entity_id'];
-
$values['p'][$values['extra']['p_entity_id']]['p_cat_id']=$values['extra']['p_cat_id'];
-
$values['p'][$values['extra']['p_entity_id']]['p_cat_name']=$_POST['entity_cat_name_'.$values['extra']['p_entity_id']];
- }
- }
- }
-
-
$location_data=$this->bolocation->initiate_ui_location(array(
- 'values' =>
$values['location_data'],
- 'type_id' => -1,
// calculated from location_types
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'lookup_type' => 'form',
- 'lookup_entity' =>
$this->bocommon->get_lookup_entity('investment'),
- 'entity_data' => $values['p']
- ));
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiinvestment.add'
- );
-
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'location_data'
=> $location_data,
-
- 'jsDateFormat'
=> $jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle'
=> lang('Select date'),
- 'calendar_setup' =>
"Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat .
"',button : 'date-trigger'});",
-
- 'lang_date_statustext' =>
lang('insert the date for the initial value'),
-
- 'lang_date'
=> lang('Date'),
- 'lang_location'
=> lang('Location'),
- 'lang_select_location_statustext'=>
lang('select either a location or an entity'),
-
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.index&preserve=1'),
-
- 'lang_write_off_period' =>
lang('Write off period'),
- 'lang_new'
=> lang('New'),
- 'lang_select'
=> lang('Select'),
- 'cat_list'
=> $this->bo->write_off_period_list($values['period']),
- 'lang_descr'
=> lang('Description'),
- 'lang_type'
=> lang('Type'),
- 'lang_amount'
=> lang('Amount'),
- 'lang_value_statustext' =>
lang('insert the value at the start-date as a positive amount'),
- 'lang_new_period_statustext' => lang('Enter
a new writeoff period if it is NOT in the list'),
- 'filter_list'
=> $this->bo->filter('select',$values['type']),
- 'filter_name'
=> 'values[type]',
- 'lang_filter_statustext' =>
lang('Select the type of value'),
- 'lang_show_all'
=> lang('Select'),
-
- 'lang_name'
=> lang('name'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_new_period'
=> $values['new_period'],
- 'value_inital_value' =>
$values['initial_value'],
- 'value_date'
=> $values['date'],
- 'value_descr'
=> $values['descr'],
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'lang_save_statustext' =>
lang('Save the investment'),
- 'lang_no_cat'
=> lang('Select'),
- 'lang_cat_statustext' =>
lang('Select the category the investment belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'values[period]',
- 'investment_type_id' =>
$investment['investment_type_id']
- );
-
- $appname
= lang('investment');
- $function_msg =
lang('add investment');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
- $GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('add'
=> $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function delete()
- {
- $entity_id = get_var('entity_id',array('POST','GET'));
- $investment_id =
get_var('investment_id',array('POST','GET'));
- $index_count =
get_var('index_count',array('POST','GET'));
- $entity_type =
get_var('entity_type',array('POST','GET'));
-
- $confirm = get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiinvestment.history',
- 'entity_id' => $entity_id,
- 'investment_id' => $investment_id,
- 'index_count' => $index_count,
- 'entity_type' => $entity_type
- );
-
- if (get_var('confirm',array('POST')))
- {
-
-
$this->bo->delete($entity_id,$investment_id,$index_count);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.delete&entity_id='
. $entity_id.'&investment_id=' . $investment_id.'&index_count=' .
$index_count.'&entity_type='.$entity_type),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('investment');
- $function_msg =
lang('delete investment history element');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage eco
+ * @version $Id: class.uiinvestment.inc.php,v 1.9 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uiinvestment
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+ var $part_of_town_id;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'history' => True,
+ 'add' => True,
+ 'delete' => True
+ );
+
+ function uiinvestment()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $this->bo =
CreateObject($this->currentapp.'.boinvestment',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+ $this->bolocation =
CreateObject($this->currentapp.'.bolocation');
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+ $this->acl2_location = '.invoice';
+ $this->acl_read =
$this->acl2->check('.invoice',1);
+ $this->acl_add =
$this->acl2->check('.invoice',2);
+ $this->acl_edit =
$this->acl2->check('.invoice',4);
+ $this->acl_delete =
$this->acl2->check('.invoice',8);
+
+ $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->allrows =
$this->bo->allrows;
+ $this->admin_invoice =
$this->acl2->check('.invoice',16);
+ $this->menu->sub ='invoice';
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' =>
$this->filter,
+ 'cat_id' =>
$this->cat_id,
+ 'part_of_town_id' =>
$this->part_of_town_id,
+ 'this->allrows' => $this->allrows
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function index()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('investment',
+
'menu',
+
'nextmatchs'));
+
+ $links = $this->menu->links('investment');
+ $preserve =
get_var('preserve',array('POST','GET'));
+ $values = get_var('values',array('POST'));
+ $date = get_var('date',array('POST'));
+
+ if($preserve)
+ {
+ $this->bo->read_sessiondata();
+
+ $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->allrows =
$this->bo->allrows;
+ }
+
+ if($date)
+ {
+ $values['date'] = $date;
+ }
+
+ if($values)
+ {
+ $receipt=$this->update_investment($values);
+ }
+
+ $investment_list = $this->bo->read();
+
+//_debug_array($values);
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'Y';
+ $dlarr[strpos($dateformat,'m')] = 'm';
+ $dlarr[strpos($dateformat,'d')] = 'd';
+ ksort($dlarr);
+ $dateformat
= (implode($sep,$dlarr));
+
+ while (is_array($investment_list) && list(,$investment)
= each($investment_list))
+ {
+
+ $content[] = array
+ (
+ 'entity_id'
=> $investment['entity_id'],
+ 'investment_id'
=> $investment['investment_id'],
+ 'district_id'
=> $investment['district_id'],
+ 'date'
=> date($dateformat,strtotime($investment['date'])),
+ 'counter'
=> $investment['counter'],
+ 'part_of_town'
=> $investment['part_of_town'],
+ 'descr'
=> $investment['descr'],
+ 'initial_value_ex'
=> $investment['initial_value'],
+ 'initial_value'
=> number_format($investment['initial_value'], 0, ',', ''),
+ 'value_ex'
=> $investment['value'],
+ 'value'
=> number_format($investment['value'], 0, ',', ''),
+ 'this_index'
=> $investment['this_index'],
+ 'index_count'
=> $investment['index_count'],
+ 'entity_name'
=> $investment['entity_name'],
+ 'this_write_off'
=> number_format($investment['this_write_off'], 0, ',', ''),
+ 'link_history'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.history&entity_id='
. $investment['entity_id'].'&investment_id=' .
$investment['investment_id'].'&entity_type=' . $this->cat_id),
+ 'lang_history'
=> lang('History'),
+ 'lang_history_statustext' =>
lang('View/Edit the history'),
+ 'is_admin'
=> $this->admin_invoice
+ );
+
+ $sum_initial_value
= $sum_initial_value + $investment['initial_value'];
+ $sum_value
= $sum_value + $investment['value'];
+
+ }
+
+ $table_header[] = array
+ (
+ 'lang_district' =>
lang('District'),
+ 'lang_part_of_town' => lang('Part
of town'),
+ 'lang_entity_id' => lang('entity
id'),
+ 'lang_investment_id' => lang('investment
id'),
+ 'lang_descr' =>
lang('Descr'),
+ 'lang_entity_name' => lang('Entity
name'),
+ 'lang_initial_value' => lang('Initial
value'),
+ 'lang_value' =>
lang('Value'),
+ 'lang_last_index' => lang('Last
index'),
+ 'lang_write_off' => lang('Write
off'),
+ 'lang_date' =>
lang('Date'),
+ 'lang_index_count' => lang('Index
count'),
+ 'lang_history' =>
lang('History'),
+ 'lang_select' =>
lang('Select')
+ );
+
+
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+ $table_update[] = array
+ (
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle'
=> lang('Select date'),
+ 'calendar_setup' =>
"Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat .
"',button : 'date-trigger'});",
+
+ 'lang_new_index' =>
lang('New index'),
+ 'lang_new_index_statustext' => lang('Enter
a new index'),
+ 'lang_date_statustext' => lang('Select
the date for the update'),
+ 'lang_update' =>
lang('Update'),
+ 'lang_update_statustext' => lang('update
selected investments')
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('Add'),
+ 'lang_add_statustext' => lang('add a
investment'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.add')
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiinvestment.index',
+ 'order' => $this->order,
+ 'sort' => $this->sort,
+ 'cat_id' =>
$this->cat_id,
+ 'part_of_town_id' =>
$this->part_of_town_id,
+ 'query' => $this->query,
+ 'start' => $this->start,
+ 'filter' => $this->filter
+ );
+
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'links'
=> $links,
+ 'lang_search'
=> lang('Search'),
+ 'lang_search_statustext' =>
lang('Search for investment entries'),
+// 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'form_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.index'),
+ 'lang_select_all'
=> lang('Select All'),
+ 'img_check'
=>
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
+ 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
+ 'allow_allrows'
=> true,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($investment_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the investment belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $this->bo->select_category('select',$this->cat_id),
+ 'lang_town_statustext' =>
lang('Select the part of town the investment belongs to. To do not use a part
of town - select NO PART OF TOWN'),
+ 'lang_part_of_town'
=> lang('Part of town'),
+ 'lang_no_part_of_town' =>
lang('Show all'),
+ 'part_of_town_list'
=> $this->bocommon->select_part_of_town('select',$this->part_of_town_id),
+ 'select_name_part_of_town' =>
'part_of_town_id',
+ 'filter_list'
=> $this->bo->filter('select',$this->filter),
+ 'filter_name'
=> 'filter',
+ 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
+ 'lang_show_all'
=> lang('Show all'),
+
+ 'lang_submit'
=> lang('submit'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'sum_initial_value'
=> number_format($sum_initial_value, 0, ',', ''),
+ 'sum_value'
=> number_format($sum_value, 0, ',', ''),
+
+ 'table_update'
=> $table_update,
+ 'update_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.index'),
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('investment');
+ $function_msg =
lang('list investment');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function update_investment($values='')
+ {
+//_debug_array($values);
+
+ $errorcount = 0;
+
+ if(!$values['date'])
+ {
+
$receipt['error'][$errorcount++]=array('msg'=>lang('Please select a date !'));
+ }
+ if(!$values['new_index'])
+ {
+
$receipt['error'][$errorcount++]=array('msg'=>lang('Please set a new index !'));
+ }
+ if(!$values['update'])
+ {
+
$receipt['error'][$errorcount++]=array('msg'=>lang('Nothing to do!'));
+ }
+
+ if(!$receipt['error'])
+ {
+ $receipt=$this->bo->update_investment($values);
+ }
+ return $receipt;
+ }
+
+ function history()
+ {
+ $GLOBALS['phpgw']->xslttpl->add_file(array('investment',
+
'menu',
+
'nextmatchs'));
+
+ $links = $this->menu->links();
+ $values =
get_var('values',array('POST'));
+ $date =
get_var('date',array('POST','GET'));
+ $entity_type =
get_var('entity_type',array('POST','GET'));
+ $entity_id =
get_var('entity_id',array('POST','GET'));
+ $investment_id =
get_var('investment_id',array('POST','GET'));
+
+ if($date)
+ {
+ $values['date'] = $date;
+ }
+//_debug_array($values);
+
+ if($values)
+ {
+ $receipt= $this->update_investment($values);
+ }
+
+ $investment_list =
$this->bo->read_single($entity_id,$investment_id);
+//_debug_array($investment_list);
+
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'Y';
+ $dlarr[strpos($dateformat,'m')] = 'm';
+ $dlarr[strpos($dateformat,'d')] = 'd';
+ ksort($dlarr);
+ $dateformat
= (implode($sep,$dlarr));
+
+ while (is_array($investment_list) && list(,$investment)
= each($investment_list))
+ {
+
+ $content[] = array
+ (
+ 'date'
=> @date($dateformat,strtotime($investment['date'])),
+ 'initial_value_ex'
=> $investment['initial_value'],
+ 'initial_value'
=> number_format($investment['initial_value'], 0, ',', ''),
+ 'value_ex'
=> $investment['value'],
+ 'value'
=> number_format($investment['value'], 0, ',', ''),
+ 'this_index'
=> $investment['this_index'],
+ 'current_index'
=> $investment['current_index'],
+ 'index_count'
=> $investment['index_count'],
+ 'this_write_off'
=> number_format($investment['this_write_off'], 0, ',', ''),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.delete&entity_id='
. $entity_id.'&investment_id=' . $investment_id.'&index_count=' .
$investment['index_count'].'&entity_type='.$entity_type),
+ 'lang_delete'
=> lang('Delete'),
+ 'lang_delete_statustext' =>
lang('Delete last entry'),
+ 'is_admin'
=> $this->admin_invoice
+ );
+
+ }
+
+//_debug_array($content);
+ $table_header[] = array
+ (
+ 'lang_initial_value' => lang('Initial
value'),
+ 'lang_value' =>
lang('Value'),
+ 'lang_last_index' => lang('Last
index'),
+ 'lang_write_off' => lang('Write
off'),
+ 'lang_date' =>
lang('Date'),
+ 'lang_index_count' => lang('Index
count'),
+ 'lang_delete' =>
lang('Delete')
+ );
+
+
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+ $table_update[] = array
+ (
+ 'lang_new_index' =>
lang('New index'),
+ 'lang_new_index_statustext' => lang('Enter
a new index'),
+
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle'
=> lang('Select date'),
+ 'calendar_setup' =>
"Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat .
"',button : 'date-trigger'});",
+
+ 'lang_date_statustext' => lang('Select
the date for the update'),
+ 'lang_update' =>
lang('Update'),
+ 'lang_update_statustext' => lang('update
selected investments')
+ );
+
+ $table_done[] = array
+ (
+ 'lang_done' =>
lang('done'),
+ 'lang_done_statustext' => lang('Back to
investment list '),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.index&preserve=1')
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiinvestment.index',
+ 'order' => $this->order,
+ 'sort' => $this->sort,
+ 'cat_id' =>
$this->cat_id,
+ 'part_of_town_id' =>
$this->part_of_town_id,
+ 'sub' => $this->sub,
+ 'query' => $this->query,
+ 'start' => $this->start,
+ 'filter' =>
$this->filter,
+ 'entity_type' => $entity_type
+ );
+
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'entity_id'
=> $entity_id,
+ 'lang_entity_id'
=> lang('Entity Id'),
+ 'investment_id'
=> $investment_id,
+ 'lang_investment_id' =>
lang('Investment Id'),
+ 'entity_type'
=> lang($entity_type),
+ 'lang_entity_type'
=> lang('Entity Type'),
+ 'links'
=> $links,
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'allow_allrows'
=> true,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($investment_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.history&entity_id='
. $entity_id.'&investment_id=' . $investment_id . '&entity_type=' .
$entity_type),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'entity_id'
=> $entity_id,
+ 'investment_id'
=> $investment_id,
+ 'table_header_history' =>
$table_header,
+ 'values_history'
=> $content,
+ 'table_update'
=> $table_update,
+ 'update_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.history&entity_id='
. $entity_id.'&investment_id=' . $investment_id . '&entity_type=' .
$entity_type),
+ 'table_done'
=> $table_done
+ );
+
+ $appname
= lang('investment');
+ $function_msg =
lang('investment history');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('history' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+// $this->save_sessiondata();
+ }
+
+
+ function add()
+ {
+ if(!$this->acl_add && !$this->acl_edit)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
+ }
+ $values =
get_var('values',array('POST'));
+ $values['date'] =
get_var('date',array('POST'));
+
+ $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
+ $insert_record_entity =
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp);
+
+ for ($j=0;$j<count($insert_record_entity);$j++)
+ {
+
$insert_record['extra'][$insert_record_entity[$j]] =
$insert_record_entity[$j];
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('investment'));
+
+ if ($values['save'])
+ {
+
+ for ($i=0;
$i<count($insert_record['location']); $i++)
+ {
+
if($_POST[$insert_record['location'][$i]])
+ {
+
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
+ }
+ }
+
+ while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
+ {
+ if($_POST[$key])
+ {
+ $values['extra'][$column]
= $_POST[$key];
+ }
+ }
+
+
+ $values['street_name'] =
$_POST['street_name'];
+ $values['street_number'] =
$_POST['street_number'];
+ $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
+
+ if(!$values['type'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a type !'));
+ }
+
+ if(!$values['period'] && !$values['new_period'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a period for write off
!'));
+ }
+
+ if(!$values['date'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a date !'));
+ }
+
+ if(!$values['initial_value'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please set a initial value !'));
+ }
+
+ if(!$values['location']['loc1'] &&
!$values['extra']['p_num'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Pleace select a location - or an entity
!'));
+ }
+
+//_debug_array($values['extra']);
+ if(!$receipt['error'])
+ {
+
$receipt=$this->bo->save_investment($values);
+ unset($values);
+ }
+ else
+ {
+ if($values['location'])
+ {
+ $location_code=implode("-",
$values['location']);
+ $values['location_data'] =
$this->bolocation->read_single($location_code,$values['extra']);
+ }
+
+ if($values['extra']['p_num'])
+ {
+
$values['p'][$values['extra']['p_entity_id']]['p_num']=$values['extra']['p_num'];
+
$values['p'][$values['extra']['p_entity_id']]['p_entity_id']=$values['extra']['p_entity_id'];
+
$values['p'][$values['extra']['p_entity_id']]['p_cat_id']=$values['extra']['p_cat_id'];
+
$values['p'][$values['extra']['p_entity_id']]['p_cat_name']=$_POST['entity_cat_name_'.$values['extra']['p_entity_id']];
+ }
+ }
+ }
+
+
$location_data=$this->bolocation->initiate_ui_location(array(
+ 'values' =>
$values['location_data'],
+ 'type_id' => -1,
// calculated from location_types
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'lookup_type' => 'form',
+ 'lookup_entity' =>
$this->bocommon->get_lookup_entity('investment'),
+ 'entity_data' => $values['p']
+ ));
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiinvestment.add'
+ );
+
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'location_data'
=> $location_data,
+
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle'
=> lang('Select date'),
+ 'calendar_setup' =>
"Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat .
"',button : 'date-trigger'});",
+
+ 'lang_date_statustext' =>
lang('insert the date for the initial value'),
+
+ 'lang_date'
=> lang('Date'),
+ 'lang_location'
=> lang('Location'),
+ 'lang_select_location_statustext'=>
lang('select either a location or an entity'),
+
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.index&preserve=1'),
+
+ 'lang_write_off_period' =>
lang('Write off period'),
+ 'lang_new'
=> lang('New'),
+ 'lang_select'
=> lang('Select'),
+ 'cat_list'
=> $this->bo->write_off_period_list($values['period']),
+ 'lang_descr'
=> lang('Description'),
+ 'lang_type'
=> lang('Type'),
+ 'lang_amount'
=> lang('Amount'),
+ 'lang_value_statustext' =>
lang('insert the value at the start-date as a positive amount'),
+ 'lang_new_period_statustext' => lang('Enter
a new writeoff period if it is NOT in the list'),
+ 'filter_list'
=> $this->bo->filter('select',$values['type']),
+ 'filter_name'
=> 'values[type]',
+ 'lang_filter_statustext' =>
lang('Select the type of value'),
+ 'lang_show_all'
=> lang('Select'),
+
+ 'lang_name'
=> lang('name'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_new_period'
=> $values['new_period'],
+ 'value_inital_value' =>
$values['initial_value'],
+ 'value_date'
=> $values['date'],
+ 'value_descr'
=> $values['descr'],
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'lang_save_statustext' =>
lang('Save the investment'),
+ 'lang_no_cat'
=> lang('Select'),
+ 'lang_cat_statustext' =>
lang('Select the category the investment belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'values[period]',
+ 'investment_type_id' =>
$investment['investment_type_id']
+ );
+
+ $appname
= lang('investment');
+ $function_msg =
lang('add investment');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+ $GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('add'
=> $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function delete()
+ {
+ $entity_id = get_var('entity_id',array('POST','GET'));
+ $investment_id =
get_var('investment_id',array('POST','GET'));
+ $index_count =
get_var('index_count',array('POST','GET'));
+ $entity_type =
get_var('entity_type',array('POST','GET'));
+
+ $confirm = get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiinvestment.history',
+ 'entity_id' => $entity_id,
+ 'investment_id' => $investment_id,
+ 'index_count' => $index_count,
+ 'entity_type' => $entity_type
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+
+
$this->bo->delete($entity_id,$investment_id,$index_count);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.delete&entity_id='
. $entity_id.'&investment_id=' . $investment_id.'&index_count=' .
$index_count.'&entity_type='.$entity_type),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('investment');
+ $function_msg =
lang('delete investment history element');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ }
+?>
Index: property/inc/class.uiinvoice.inc.php
diff -u property/inc/class.uiinvoice.inc.php:1.20
property/inc/class.uiinvoice.inc.php:1.21
--- property/inc/class.uiinvoice.inc.php:1.20 Fri Aug 26 12:03:56 2005
+++ property/inc/class.uiinvoice.inc.php Fri Jan 27 14:05:43 2006
@@ -1,1372 +1,1372 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage eco
- * @version $Id: class.uiinvoice.inc.php,v 1.20 2005/08/26 12:03:56
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uiinvoice
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
- var $user_lid;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'index' => True,
- 'edit_period' => True,
- 'list_sub' => True,
- 'consume' => True,
- 'remark' => True,
- 'delete' => True,
- 'add' => True,
- 'debug' => True,
- 'view_order' => True,
- 'excel' => True
- );
-
- function uiinvoice()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- $this->bo =
CreateObject($this->currentapp.'.boinvoice',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
-
- $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->user_lid =
$this->bo->user_lid;
- $this->allrows =
$this->bo->allrows;
-
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
- $this->acl2_location = '.invoice';
- $this->acl_read =
$this->acl2->check('.invoice',1);
- $this->acl_add =
$this->acl2->check('.invoice',2);
- $this->acl_edit =
$this->acl2->check('.invoice',4);
- $this->acl_delete =
$this->acl2->check('.invoice',8);
-
- $this->menu->sub ='invoice';
-
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' => $this->filter,
- 'cat_id' => $this->cat_id,
- 'user_lid' => $this->user_lid,
- 'allrows' => $this->allrows
- );
- $this->bo->save_sessiondata($data);
- }
-
-
- function excel()
- {
- $paid = get_var('paid',array('POST','GET'));
- $start_date =
get_var('start_date',array('POST','GET'));
- $end_date =
get_var('end_date',array('POST','GET'));
- $submit_search =
get_var('submit_search',array('POST','GET'));
- $vendor_id =
get_var('vendor_id',array('POST','GET'));
- $workorder_id =
get_var('workorder_id',array('POST','GET'));
- $loc1 = get_var('loc1',array('POST','GET'));
- $voucher_id =
get_var('voucher_id',array('POST','GET'));
-
- $start_date=urldecode($start_date);
- $end_date=urldecode($end_date);
-
- if(!$end_date)
- {
- $end_date =
$GLOBALS['phpgw']->common->show_date(mktime(0,0,0,date("m"),date("d"),date("Y")),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $start_date = $end_date;
- }
-
- $list =
$this->bo->read_invoice($paid,$start_date,$end_date,$vendor_id,$loc1,$workorder_id,$voucher_id);
-
- while (is_array($list[0]) && list($name_entry,) =
each($list[0]))
- {
- $name[]=$name_entry;
- }
-
- $descr = $name;
-
- $this->bocommon->excel($list,$name,$descr);
- }
-
- function index()
- {
-// $start_time = explode(' ',microtime());
-// $start_time = $start_time[1]+$start_time[0];
-
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('invoice','menu',
-
'nextmatchs',
-
'search_field'));
-
- $paid = get_var('paid',array('POST','GET'));
- $start_date =
get_var('start_date',array('POST','GET'));
- $end_date =
get_var('end_date',array('POST','GET'));
- $submit_search =
get_var('submit_search',array('POST','GET'));
- $vendor_id =
get_var('vendor_id',array('POST','GET'));
- $workorder_id =
get_var('workorder_id',array('POST','GET'));
- $loc1 = get_var('loc1',array('POST','GET'));
- $voucher_id =
get_var('voucher_id',array('POST','GET'));
-
- $start_date=urldecode($start_date);
- $end_date=urldecode($end_date);
-
- if(!$end_date)
- {
- $end_date =
$GLOBALS['phpgw']->common->show_date(mktime(0,0,0,date("m"),date("d"),date("Y")),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $start_date = $end_date;
- }
-
- $links = $this->menu->links('invoice_'.!!$paid);
-
- $values = get_var('values',array('POST','GET'));
-
- if($values['save'][0] && $values['counter'])
- {
- $receipt=$this->bo->update_invoice($values);
-
- }
-
- $content =
$this->bo->read_invoice($paid,$start_date,$end_date,$vendor_id,$loc1,$workorder_id,$voucher_id);
-
- $i=0;
- if(is_array($content))
- {
- foreach($content as $extra)
- {
-
- $sum
= $sum + $extra['amount'];
- $content[$i]['amount']
= number_format($extra['amount'], 2, ',', '');
- $content[$i]['lang_payment_date']
= lang('Payment Date');
- $content[$i]['link_sub']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.list_sub&user_lid='.$this->user_lid
. '&query=' . $this->query);
- $content[$i]['lang_sub']
= lang('Voucher ID');
- $content[$i]['lang_sub_help']
= lang('Klick this link to enter the list of sub-invoices');
- $content[$i]['link_period']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.edit_period');
- $content[$i]['lang_period']
= lang('Period');
- $content[$i]['lang_period_help']
= lang('Klick this link to edit the period');
-
- if($this->acl_delete && !$paid)
- {
- $content[$i]['link_delete']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.delete&voucher_id='
. $extra['voucher_id']);
-
$content[$i]['lang_delete_statustext'] = lang('delete the voucher');
- $content[$i]['text_delete']
= lang('delete');
- }
-
- $i++;
- }
- }
-
- $table_header[] = array
- (
- 'sort_voucher' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'bilagsnr',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiinvoice.index',
-
'cat_id'
=>$this->cat_id,
-
'sub'
=>$this->sub,
-
'paid'
=> $paid,
-
'vendor_id'
=> $vendor_id,
-
'user_lid'
=> $this->user_lid)
-
)),
- 'lang_voucher' =>
lang('voucher'),
- 'sort_voucher_date'
=> $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'fakturadato',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiinvoice.index',
-
'cat_id'
=>$this->cat_id,
-
'sub'
=>$this->sub,
-
'paid'
=> $paid,
-
'vendor_id'
=> $vendor_id,
-
'user_lid'
=> $this->user_lid)
-
)),
- 'lang_voucher_date' =>
lang('Voucher Date'),
- 'lang_days'
=> lang('Days'),
- 'lang_sum'
=> lang('Sum'),
- 'sort_vendor_id'
=> $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'spvend_code',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiinvoice.index',
-
'cat_id'
=>$this->cat_id,
-
'sub'
=>$this->sub,
-
'paid'
=> $paid,
-
'vendor_id'
=> $vendor_id,
-
'user_lid'
=> $this->user_lid)
-
)),
- 'lang_vendor_id' =>
lang('Vendor'),
- 'lang_num_sub_invoice' =>
lang('Count'),
- 'lang_type'
=> lang('Type'),
- 'lang_period' =>
lang('Period'),
- 'lang_kredit' =>
lang('KreditNota'),
- 'lang_none'
=> lang('None'),
- 'lang_janitor' =>
lang('Janitor'),
- 'lang_supervisor' =>
lang('Supervisor'),
- 'lang_budget_responsible' => lang('Budget
Responsible'),
- 'lang_transfer' =>
lang('Transfer'),
- 'lang_delete' =>
lang('delete')
- );
-
- $table_done[] = array
- (
- 'lang_done' =>
lang('Done'),
- 'lang_done_statustext' => lang('Close this
window')
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiinvoice.index',
- 'order' => $this->order,
- 'sort' => $this->sort,
- 'cat_id' =>
$this->cat_id,
- 'user_lid' =>
$this->user_lid,
- 'sub' => $this->sub,
- 'query' => $this->query,
- 'start' => $this->start,
- 'paid' => $paid,
- 'vendor_id' => $vendor_id,
- 'workorder_id' => $workorder_id,
- 'start_date' => $start_date,
- 'end_date' => $end_date,
- 'filter' => $this->filter
- );
-
- if($this->acl_add)
- {
- $table_add[] = array
- (
- 'lang_add'
=> lang('add'),
- 'lang_add_statustext' => lang('add a
invoice'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.add')
- );
- }
-
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $link_excel = array
- (
- 'menuaction' =>
$this->currentapp.'.uiinvoice.excel',
- 'order' => $this->order,
- 'sort' => $this->sort,
- 'cat_id' => $this->cat_id,
- 'user_lid' => $this->user_lid,
- 'sub' => $this->sub,
- 'query' => $this->query,
- 'start' => $this->start,
- 'paid' => $paid,
- 'vendor_id' => $vendor_id,
- 'workorder_id' => $workorder_id,
- 'start_date' => $start_date,
- 'end_date' => $end_date,
- 'filter' => $this->filter,
- 'allrows' => $this->allrows
- );
-
- $data['lang_excel'] =
'excel';
- $data['link_excel'] =
$GLOBALS['phpgw']->link('/index.php',$link_excel);
- $data['lang_excel_help'] =
lang('Download table to MS Excel');
-
- $data['msgbox_data']
= $GLOBALS['phpgw']->common->msgbox($msgbox_data);
- $data['sum']
= number_format($sum, 2, ',', '');
- $data['overlib_source']
= './'.$this->currentapp.'/inc/overlib.js';
- $data['links']
= $links;
- $data['allow_allrows']
= true;
- $data['allrows']
= $this->allrows;
- $data['start_record']
= $this->start;
- $data['record_limit']
= $record_limit;
- $data['num_records']
= count($content);
- $data['all_records']
= $this->bo->total_records;
- $data['link_url']
= $GLOBALS['phpgw']->link('/index.php',$link_data);
- $data['img_path']
= $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default');
- $data['lang_no_cat']
= lang('no category');
- $data['lang_cat_statustext'] =
lang('Select the category the building belongs to. To do not use a category
select NO CATEGORY');
- $data['select_name']
= 'cat_id';
- $data['select_action']
= $GLOBALS['phpgw']->link('/index.php',$link_data);
- $data['lang_no_user']
= lang('None');
- $data['lang_user_statustext'] =
lang('Select the user the selection belongs to. To do not use a user select NO
USER');
- $data['select_user_name']
= 'user_lid';
- $data['lang_searchfield_statustext'] = lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again');
- $data['lang_searchbutton_statustext'] = lang('Submit
the search string');
- $data['lang_search']
= lang('search');
- $data['query']
= $this->query;
- $data['form_action']
= $GLOBALS['phpgw']->link('/index.php',$link_data);
-
-//_debug_array($content);
- $appname
= lang('invoice');
- $function_msg =
lang('list voucher');
-
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
- if ($paid)
- {
- $bolocation =
CreateObject($this->currentapp.'.bolocation');
- $data['user_list']
=
$this->bo->get_invoice_user_list('select',$this->user_lid,array('all'),$default='all');
-
$location_data=$bolocation->initiate_ui_location(array('type_id'=> 1));
-
- $data['cat_list']
= $this->bo->select_category('select',$this->cat_id);
- $data['start_date'] = $start_date;
- $data['end_date'] = $end_date;
- $data['vendor_id'] = $vendor_id;
-
-
- $data['jsDateFormat']
= $jsDateFormat;
- $data['date_img']
= $cal_info['img'];
- $data['lang_datetitle']
= lang('Select date');
- $data['calendar_setup_start']
= "Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});";
- $data['calendar_setup_end']
= "Calendar.setup({inputField : 'end_date',ifFormat : '" .
$jsDateFormat . "',button : 'end_date-trigger'});";
-
- $data['lang_workorder']
= lang('Workorder ID');
- $data['lang_workorder_statustext']
= lang('enter the Workorder ID to search by workorder - at any date');
- $data['workorder_id']
= $workorder_id;
-
- $data['addressbook_link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor');
- $data['lang_select_vendor_statustext'] =
lang('Select the vendor by klicking this link');
- $data['lang_vendor']
= lang('Vendor');
- $data['property_link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.index&lookup=1&type_id=1&lookup_name=0');
- $data['lang_select_property_statustext']=
lang('Select the property by klicking this link');
- $data['lang_property_statustext']
= lang('Search by property');
- $data['lang_property']
= lang('property');
- $data['loc1']
= $loc1;
- $data['lang_search']
= lang('Search');
- $data['lang_search_statustext']
= lang('Search for paid invoices');
-
- $data['table_header_list_voucher_paid'] =
$table_header;
- $data['values_list_voucher_paid']
= $content;
-
- $data['lang_voucher_id_statustext']
= lang('Search for voucher id');
- $data['lang_voucher_id']
= lang('Voucher ID');
- $data['voucher_id']
= $voucher_id;
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_voucher_paid' =>
$data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
- else
- {
- $data['user_list']
=
$this->bo->get_invoice_user_list('filter',$this->user_lid,array('all'),$default='none');
- $data['cat_list']
= $this->bo->select_category('filter',$this->cat_id);
- $data['table_done']
= $table_done;
- $data['img_check']
=
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif';
- $data['check_source']
= './'.$this->currentapp.'/inc/check.js';
- $data['lang_save']
= lang('save');
- $data['done_action']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.index');
- $data['lang_done_statustext']
= lang('Back to the list');
- $data['lang_save_statustext']
= lang('Save the voucher');
- $data['lang_select_all']
= lang('Select All');
- $data['message']
= $receipt['message'];
- $data['error']
= $receipt['error'];
- $data['table_header_list_voucher']
= $table_header;
- $data['values_list_voucher']
= $content;
- $data['acl_delete']
= $this->acl_delete;
- $data['table_add_invoice']
= $table_add;
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_voucher' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
- $this->save_sessiondata();
-
- $end_time = $this->bo->end_time;
-
- // $end_time = $end_time[1]+$end_time[0];
- // $process = ($end_time-$start_time);
- // echo "tidsforbruk: $process";
- }
-
- function list_sub()
- {
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('invoice','menu',
-
'nextmatchs'));
-
- $paid = get_var('paid',array('POST','GET'));
-
- $links = $this->menu->links('invoice_');
-
- $values =
get_var('values',array('POST','GET'));
- $voucher_id =
get_var('voucher_id',array('POST','GET'));
-
- if($values['save'][0] && $values['counter'])
- {
- $receipt=$this->bo->update_invoice_sub($values);
- }
-
-//_debug_array($values);
-
-//echo $voucher_id;
-
-
- if ($voucher_id)
- {
- $content =
$this->bo->read_invoice_sub($voucher_id,$paid);
- }
-
- $i=0;
- if(is_array($content))
- {
- while(each($content))
- {
- $sum
= $sum + $content[$i]['amount'];
- $content[$i]['amount']
= number_format($content[$i]['amount'], 2, ',', '');
- $content[$i]['paid']
= $paid;
-
$content[$i]['lang_tax_code_statustext'] = lang('select the appropriate
tax code');
- $content[$i]['tax_code_list']
= $this->bo->tax_code_list($content[$i]['tax_code']);
- $content[$i]['lang_remark']
= lang('Remark');
- $content[$i]['link_remark']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.remark');
- $content[$i]['lang_remark_help']
= lang('Klick this link to view the remark');
- $content[$i]['link_order']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.view_order');
- $content[$i]['link_claim']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant_claim.check');
- $i++;
- }
- }
-
-//_debug_array($content);
- $table_header[] = array
- (
- 'sort_workorder' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'pmwrkord_code',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiinvoice.list_sub',
-
'cat_id'
=> $this->cat_id,
-
'sub'
=> $this->sub,
-
'paid'
=> $paid,
-
'voucher_id'
=> $voucher_id,
-
'query'
=> $this->query)
-
)),
- 'lang_workorder' =>
lang('Workorder'),
- 'sort_budget_account' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'spbudact_code',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiinvoice.list_sub',
-
'cat_id'
=>$this->cat_id,
-
'sub'
=>$this->sub,
-
'paid'
=> $paid,
-
'voucher_id'
=> $voucher_id,
-
'query'
=> $this->query)
-
)),
- 'lang_budget_account' => lang('Budget
account'),
-
- 'sort_sum'
=> $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'belop',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiinvoice.list_sub',
-
'cat_id'
=>$this->cat_id,
-
'sub'
=>$this->sub,
-
'paid'
=> $paid,
-
'voucher_id'
=> $voucher_id,
-
'query'
=> $this->query)
-
)),
-
- 'lang_sum'
=> lang('Sum'),
- 'lang_type'
=> lang('Type'),
- 'lang_close_order' =>
lang('Close order'),
- 'lang_charge_tenant' => lang('Charge
tenant'),
- 'lang_invoice_id' =>
lang('Invoice Id'),
- 'sort_dima'
=> $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'dima',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiinvoice.list_sub',
-
'cat_id'
=>$this->cat_id,
-
'sub'
=>$this->sub,
-
'paid'
=> $paid,
-
'voucher_id'
=> $voucher_id,
-
'query'
=> $this->query)
-
)),
- 'lang_dima'
=> lang('Dim A'),
- 'lang_dimb'
=> lang('Dim B'),
- 'lang_dimd'
=> lang('Dim D'),
- 'lang_tax_code' =>
lang('Tax code'),
- 'lang_remark' =>
lang('Remark'),
- );
-
- $table_done[] = array
- (
- 'lang_done' =>
lang('Done'),
- 'lang_done_statustext' => lang('Close this
window')
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiinvoice.list_sub',
- 'order' => $this->order,
- 'sort' => $this->sort,
- 'cat_id' =>
$this->cat_id,
- 'user_lid' =>
$this->user_lid,
- 'sub' => $this->sub,
- 'query' => $this->query,
- 'start' => $this->start,
- 'paid' => $paid,
- 'voucher_id' => $voucher_id,
- 'user_lid' =>
$this->user_lid,
- 'query' => $this->query
- );
-
- if ($paid)
- {
- $function_msg = lang('list paid invoice');
-
- }
- else
- {
- $function_msg = lang('list invoice');
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'img_check'
=>
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
- 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'sum'
=> number_format($sum, 2, ',', ''),
- 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('Done'),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.index&user_lid='.$this->user_lid
. '&query='.$this->query),
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'lang_save_statustext' =>
lang('Save the voucher'),
- 'links'
=> $links,
- 'allow_allrows'
=> false,
- 'start_record'
=> $this->start,
- 'record_limit'
=>
count($content),//$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($content),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_submit'
=> lang('submit'),
- 'table_header_list_invoice_sub' =>
$table_header,
- 'values_list_invoice_sub' =>
$content,
- 'paid'
=> $paid,
- 'vendor'
=> $content[0]['vendor'],
- 'lang_vendor'
=> lang('Vendor'),
- 'voucher_id'
=> $voucher_id,
- 'lang_voucher_id'
=> lang('Voucher Id'),
- 'lang_claim'
=> lang('Claim'),
- 'table_done'
=> $table_done
- );
-
-//_debug_array($data);
-
- $appname
= lang('invoice');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_invoice_sub' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
-
- function edit_period()
- {
- $GLOBALS['phpgw']->xslttpl->add_file(array('invoice'));
-
- $GLOBALS['phpgw_info']['flags']['noframework'] = True;
-
- $voucher_id =
get_var('voucher_id',array('POST','GET'));
- $period =
get_var('period',array('POST','GET'));
- $submit =
get_var('submit',array('POST','GET'));
-
- if($submit)
- {
- $receipt =
$this->bo->update_period($voucher_id,$period);
- }
-
- $function_msg = lang('Edit period');
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiinvoice.edit_period',
- 'voucher_id' => $voucher_id);
-
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'period_list'
=> $this->bo->period_list($period),
- 'function_msg'
=> $function_msg,
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_save'
=> lang('save'),
- 'select_name'
=> 'period'
- );
-
-//_debug_array($data);
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
$function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_period' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function remark()
- {
- $GLOBALS['phpgw']->xslttpl->add_file(array('invoice'));
- $GLOBALS['phpgw_info']['flags']['noframework'] = True;
-
- $id = get_var('id',array('POST','GET'));
- $paid = get_var('paid',array('POST','GET'));
-
- $data = array
- (
- 'remark' => $this->bo->read_remark($id,$paid)
- );
-
-//_debug_array($data);
-
- $appname
= lang('invoice');
- $function_msg =
lang('remark');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('remark' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function consume()
- {
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('invoice','menu',
-
'nextmatchs',
-
'search_field'));
-
- $start_date =
get_var('start_date',array('POST','GET'));
- $end_date =
get_var('end_date',array('POST','GET'));
- $submit_search =
get_var('submit_search',array('POST','GET'));
- $vendor_id =
get_var('vendor_id',array('POST','GET'));
-
- $workorder_id =
get_var('workorder_id',array('POST','GET'));
- $loc1 =
get_var('loc1',array('POST','GET'));
- $district_id =
get_var('district_id',array('POST','GET'));
- $b_account_class =
get_var('b_account_class',array('POST','GET'));
-
- if($vendor_id)
- {
- $contacts =
CreateObject($this->currentapp.'.soactor');
- $contacts->role='vendor';
- $vendor =
$contacts->read_single(array('actor_id'=>(int)$vendor_id));
- if(is_array($vendor))
- {
- foreach($vendor['attributes'] as
$attribute)
- {
-
if($attribute['name']=='org_name')
- {
-
$vendor_name=$attribute['value'];
- break;
- }
- }
- }
- }
-
- $links = $this->menu->links('consume');
-
-
-//_debug_array($values);
- if(!$submit_search)
- {
- $start_date =
$GLOBALS['phpgw']->common->show_date(mktime(0,0,0,date("m"),date("d"),date("Y")),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $end_date = $start_date;
- }
- else
- {
- $content =
$this->bo->read_consume($start_date,$end_date,$vendor_id,$loc1,$workorder_id,$b_account_class,$district_id);
- }
-
- if(is_array($content))
- {
- $i=0;
- while(each($content))
- {
- $sum=$sum+$content[$i]['consume'];
- $content[$i]['consume']
=number_format($content[$i]['consume'], 2, ',', '');
- $i++;
- }
- }
-
-
- $table_header[] = array
- (
- 'lang_district' =>
lang('District'),
- 'lang_period' =>
lang('Period'),
- 'lang_budget_account' => lang('Budget
account'),
- 'lang_consume' =>
lang('Consume'),
- );
-
- $table_done[] = array
- (
- 'lang_done' =>
lang('Done'),
- 'lang_done_statustext' => lang('Close this
window')
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiinvoice.consume',
- 'order' => $this->order,
- 'sort' => $this->sort,
- 'cat_id' =>
$this->cat_id,
- 'district_id' => $district_id,
- 'sub' => $this->sub,
- 'query' => $this->query,
- 'start' => $this->start,
- 'filter' => $this->filter
- );
-
- $data['lang_sum']
= lang('Sum');
- $data['sum']
= number_format($sum, 2, ',', '');
- $data['overlib_source']
= './'.$this->currentapp.'/inc/overlib.js';
- $data['links']
= $links;
- $data['allow_allrows']
= false;
- $data['start_record']
= $this->start;
- $data['record_limit']
= $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- $data['num_records']
= count($content);
- $data['all_records']
= $this->bo->total_records;
- $data['link_url']
= $GLOBALS['phpgw']->link('/index.php',$link_data);
- $data['img_path']
= $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default');
- $data['lang_no_cat']
= lang('no category');
- $data['lang_cat_statustext'] =
lang('Select the category the building belongs to. To do not use a category
select NO CATEGORY');
- $data['select_name']
= 'cat_id';
- $data['select_action']
= $GLOBALS['phpgw']->link('/index.php',$link_data);
- $data['lang_no_district']
= lang('No district');
- $data['lang_district_statustext'] =
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT');
- $data['select_district_name'] =
'district_id';
- $data['lang_searchfield_statustext'] = lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again');
- $data['lang_searchbutton_statustext'] = lang('Submit
the search string');
- $data['lang_search']
= lang('search');
- $data['query']
= $this->query;
- $data['form_action']
= $GLOBALS['phpgw']->link('/index.php',$link_data);
-
-
- $data['district_list']
= $this->bocommon->select_district_list('select',$district_id);
- $data['cat_list']
= $this->bo->select_category('select',$this->cat_id);
- $data['start_date']
= $start_date;
- $data['end_date']
= $end_date;
- $data['vendor_id']
= $vendor_id;
- $data['vendor_name']
= $vendor_name;
-
- $data['account_class_list']
= $this->bo->select_account_class($b_account_class);
- $data['lang_no_account_class_'] =
lang('No account');
- $data['lang_account_class_statustext'] = lang('Select
the account class the selection belongs to');
- $data['select_account_class_name'] =
'b_account_class';
-
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
- $data['jsDateFormat']
= $jsDateFormat;
- $data['date_img']
= $cal_info['img'];
- $data['lang_datetitle']
= lang('Select date');
- $data['calendar_setup_start'] =
"Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});";
- $data['calendar_setup_end']
= "Calendar.setup({inputField : 'end_date',ifFormat : '" . $jsDateFormat .
"',button : 'end_date-trigger'});";
-
- $data['lang_workorder']
= lang('Workorder ID');
- $data['lang_workorder_statustext'] =
lang('enter the Workorder ID to search by workorder - at any date');
- $data['workorder_id']
= $workorder_id;
-
- $data['addressbook_link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor');
- $data['lang_select_vendor_statustext'] = lang('Select
the vendor by klicking this link');
- $data['lang_vendor']
= lang('Vendor');
-
- $bolocation =
CreateObject($this->currentapp.'.bolocation');
-
$location_data=$bolocation->initiate_ui_location(array('type_id'=> 1));
-
- $data['property_link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.index&lookup=1&type_id=1&lookup_name=0');
-
- $data['lang_select_property_statustext']= lang('Select
the property by klicking this link');
- $data['lang_property_statustext'] =
lang('Search by property');
-
- $data['lang_property']
= lang('property');
- $data['loc1']
= $loc1;
- $data['lang_search']
= lang('Search');
- $data['lang_search_statustext'] =
lang('Search for paid invoices');
-
- $data['table_header_consume'] =
$table_header;
- $data['values_consume']
= $content;
-
- $appname
= lang('consume');
- $function_msg
= lang('list consume');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('consume' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
-
- $this->save_sessiondata();
- }
-
- function delete()
- {
- if(!$this->acl_delete)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
- }
-
- $voucher_id = get_var('voucher_id',array('POST','GET'));
- $confirm = get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiinvoice.index'
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($voucher_id);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.delete&voucher_id='
. $voucher_id),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('invoice');
- $function_msg =
lang('delete voucher');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function add()
- {
- if(!$this->acl_add)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
- }
-
-// $receipt =
$GLOBALS['phpgw']->session->appsession('session_data','add_receipt');
-
$GLOBALS['phpgw']->session->appsession('session_data','add_receipt',False);
-
- $bolocation =
CreateObject($this->currentapp.'.bolocation');
-
- $values['art'] =
get_var('art',array('POST','GET'));
- $values['type'] =
get_var('type',array('POST','GET'));
- $values['dim_b'] =
get_var('dim_b',array('POST','GET'));
- $values['invoice_num'] =
get_var('invoice_num',array('POST','GET'));
- $values['kid_nr'] =
get_var('kid_nr',array('POST','GET'));
- $values['vendor_id'] =
get_var('vendor_id',array('POST','GET'));
- $values['vendor_name'] =
get_var('vendor_name',array('POST','GET'));
- $values['janitor'] =
get_var('janitor',array('POST','GET'));
- $values['supervisor'] =
get_var('supervisor',array('POST','GET'));
- $values['budget_responsible']=
get_var('budget_responsible',array('POST','GET'));
- $values['invoice_date'] =
urldecode(get_var('invoice_date',array('POST','GET')));
- $values['num_days'] =
get_var('num_days',array('POST','GET'));
- $values['payment_date'] =
urldecode(get_var('payment_date',array('POST','GET')));
- $values['sday'] =
get_var('sday',array('POST','GET'));
- $values['smonth'] =
get_var('smonth',array('POST','GET'));
- $values['syear'] =
get_var('syear',array('POST','GET'));
- $values['eday'] =
get_var('eday',array('POST','GET'));
- $values['emonth'] =
get_var('emonth',array('POST','GET'));
- $values['eyear'] =
get_var('eyear',array('POST','GET'));
- $values['auto_tax'] =
get_var('auto_tax',array('POST','GET'));
- $values['merknad'] =
get_var('merknad',array('POST','GET'));
- $values['b_account_id'] =
get_var('b_account_id',array('POST','GET'));
- $values['b_account_name'] =
get_var('b_account_name',array('POST','GET'));
- $values['amount'] =
get_var('amount',array('POST','GET'));
- $values['order'] =
get_var('order',array('POST','GET'));
- $location_code =
get_var('location_code',array('POST','GET'));
- $debug =
get_var('debug',array('POST','GET'));
- $add_invoice =
get_var('add_invoice',array('POST','GET'));
-
-
- $links = $this->menu->links('add_inv');
-
-
- if($location_code)
- {
- $values['location_data'] =
$bolocation->read_single($location_code,array('tenant_id'=>$tenant_id,'p_num'=>$p_num));
- }
-
-
-
- if($add_invoice && is_array($values))
- {
- $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
-
- for ($i=0;
$i<count($insert_record['location']); $i++)
- {
-
if($_POST[$insert_record['location'][$i]])
- {
-
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
- }
- }
-
- while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
- {
- if($_POST[$key])
- {
- $values['extra'][$column]
= $_POST[$key];
- }
- }
-
- $values['street_name'] =
$_POST['street_name'];
- $values['street_number'] =
$_POST['street_number'];
- $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
-
-
- if($values['order'] &&
!ctype_digit($values['order'])):
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter an integer for order!'));
- unset($values['order']);
- }
- elseif($values['order']):
- {
- $order=True;
- }
- endif;
-
- if (!$values['amount'])
- {
- $receipt['error'][] =
array('msg'=>lang('Please - enter an amount!'));
- }
- if (!$values['art'])
- {
- $receipt['error'][] =
array('msg'=>lang('Please - select type invoice!'));
- }
- if (!$values['vendor_id'] && !$order)
- {
- $receipt['error'][] =
array('msg'=>lang('Please - select Vendor!'));
- }
-
- if (!$values['type'])
- {
- $receipt['error'][] =
array('msg'=>lang('Please - select type order!'));
- }
-
- if (!$values['budget_responsible'] && !$order)
- {
- $receipt['error'][] =
array('msg'=>lang('Please - select budget responsible!'));
- }
-
- if(!$order && $values['vendor_id'])
- {
- if
(!$this->bo->check_vendor($values['vendor_id']))
- {
- $receipt['error'][] =
array('msg'=>lang('That Vendor ID is not valid !'). ' : ' .
$values['vendor_id']);
- }
- }
-
- if (!$values['payment_date'] &&
!$values['num_days'])
- {
- $receipt['error'][] =
array('msg'=>lang('Please - select either payment date or number of days from
invoice date !'));
- }
-
-//_debug_array($values);
- if (!is_array($receipt['error']))
- {
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $dateformat =
str_replace(".","",$dateformat);
- $dateformat =
str_replace("-","",$dateformat);
- $dateformat =
str_replace("/","",$dateformat);
- $y=strpos($dateformat,'y');
- $d=strpos($dateformat,'d');
- $m=strpos($dateformat,'m');
-
- if($values['invoice_date'])
- {
- $dateparts = explode('/',
$values['invoice_date']);
- $values['sday'] =
$dateparts[$d];
- $values['smonth'] =
$dateparts[$m];
- $values['syear'] =
$dateparts[$y];
-
- $dateparts = explode('/',
$values['payment_date']);
- $values['eday'] =
$dateparts[$d];
- $values['emonth'] =
$dateparts[$m];
- $values['eyear'] =
$dateparts[$y];
- }
-
- $values['bilagsnr'] =
$this->bo->next_bilagsnr();
- $values['regtid'] =
date($this->bocommon->datetimeformat);
-
- $receipt =
$this->bo->add($values,$debug);
- if($debug)
- {
- $this->debug($receipt);
- return;
- }
- unset($values);
-
$GLOBALS['phpgw']->session->appsession('session_data','add_receipt',$receipt);
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.add');
-
- }
- else
- {
- if($values['location'])
- {
- $location_code=implode("-",
$values['location']);
- $values['location_data'] =
$bolocation->read_single($location_code,$values['extra']);
- }
- }
- }
-
- $location_data=$bolocation->initiate_ui_location(array(
- 'values' =>
$values['location_data'],
- 'type_id' => -1,
// calculated from location_types
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' =>
False,
- 'lookup_type' => 'form',
- 'lookup_entity' => False,
//$this->bocommon->get_lookup_entity('project'),
- 'entity_data' => False
//$values['p']
- ));
-
-
$b_account_data=$this->bocommon->initiate_ui_budget_account_lookup(array(
- 'b_account_id' =>
$values['b_account_id'],
- 'b_account_name' =>
$values['b_account_name']));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiinvoice.add',
- 'debug' => True
- );
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'links'
=> $links,
-
- 'jsDateFormat'
=> $jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle'
=> lang('Select date'),
- 'calendar_setup_invoice' =>
"Calendar.setup({inputField : 'invoice_date',ifFormat : '" . $jsDateFormat .
"',button : 'invoice_date-trigger'});",
- 'calendar_setup_payment' =>
"Calendar.setup({inputField : 'payment_date',ifFormat : '" . $jsDateFormat .
"',button : 'payment_date-trigger'});",
-
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'cancel_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.index'),
- 'lang_cancel'
=> lang('Cancel'),
- 'lang_cancel_statustext' =>
lang('cancel'),
- 'action_url'
=> $GLOBALS['phpgw']->link('/index.php','menuaction='. $this->currentapp
.'.uiinvoice.add'),
- 'tsvfilename'
=> '',
-
- 'lang_add'
=> lang('add'),
- 'lang_add_statustext' => lang('Klick
this button to add a invice'),
-
- 'lang_invoice_date'
=> lang('invoice date'),
- 'lang_payment_date'
=> lang('Payment date'),
- 'lang_no_of_days'
=> lang('Days'),
- 'lang_invoice_number' =>
lang('Invoice Number'),
- 'lang_invoice_num_statustext' => lang('Enter
Invoice Number'),
-
- 'lang_select'
=> lang('Select per button !'),
- 'lang_kidnr'
=> lang('KID nr'),
- 'lang_kid_nr_statustext' =>
lang('Enter Kid nr'),
-
- 'lang_vendor'
=> lang('Vendor'),
- 'addressbook_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor'),
-
- 'lang_invoice_date_statustext' => lang('Enter
the invoice date'),
- 'lang_num_days_statustext' =>
lang('Enter the payment date or the payment delay'),
- 'lang_payment_date_statustext' => lang('Enter
the payment date or the payment delay'),
- 'lang_vendor_statustext'
=> lang('Select the vendor by klicking the button'),
- 'lang_vendor_name_statustext' => lang('Select
the vendor by klicking the button'),
- 'lang_select_vendor_statustext' => lang('Select
the vendor by klicking this button'),
-
- 'value_invoice_date' =>
$values['invoice_date'],
- 'value_payment_date' =>
$values['payment_date'],
- 'value_belop'
=> $values['belop'],
- 'value_vendor_id'
=> $values['vendor_id'],
- 'value_vendor_name'
=> $values['vendor_name'],
- 'value_kid_nr'
=> $values['kid_nr'],
- 'value_dim_b'
=> $values['dim_b'],
- 'value_invoice_num'
=> $values['invoice_num'],
- 'value_merknad'
=> $values['merknad'],
- 'value_num_days'
=> $values['num_days'],
- 'value_amount'
=> $values['amount'],
- 'value_order'
=> $values['order'],
-
- 'lang_auto_tax'
=> lang('Auto TAX'),
- 'lang_auto_tax_statustext' =>
lang('Set tax'),
-
- 'lang_amount'
=> lang('Amount'),
- 'lang_amount_statustext' =>
lang('Amount of the invoice'),
-
- 'lang_order'
=> lang('Order ID'),
- 'lang_order_statustext' => lang('Order
# that initiatet the invoice'),
-
- 'lang_art'
=> lang('Art'),
- 'art_list'
=> $this->bo->get_lisfm_ecoart($values['art']),
- 'select_art'
=> 'art',
- 'lang_select_art'
=> lang('Select Invoice Type'),
- 'lang_art_statustext' =>
lang('You have to select type of invoice'),
-
- 'lang_type'
=> lang('Type invoice II'),
- 'type_list'
=> $this->bo->get_type_list($values['type']),
- 'select_type'
=> 'type',
- 'lang_no_type'
=> lang('No type'),
- 'lang_type_statustext' =>
lang('Select the type invoice. To do not use type - select NO TYPE'),
-
- 'lang_dimb'
=> lang('Dim B'),
- 'dimb_list'
=> $this->bo->select_dimb_list($values['dim_b']),
- 'select_dimb'
=> 'dim_b',
- 'lang_no_dimb'
=> lang('No Dim B'),
- 'lang_dimb_statustext' =>
lang('Select the Dim B for this invoice. To do not use Dim B - select NO DIM
B'),
-
- 'lang_janitor'
=> lang('Janitor'),
- 'janitor_list'
=> $this->bocommon->get_user_list_right(32,$values['janitor'],'.invoice'),
- 'select_janitor'
=> 'janitor',
- 'lang_no_janitor'
=> lang('No janitor'),
- 'lang_janitor_statustext' =>
lang('Select the janitor responsible for this invoice. To do not use janitor -
select NO JANITOR'),
-
- 'lang_supervisor'
=> lang('Supervisor'),
- 'supervisor_list'
=> $this->bocommon->get_user_list_right(64,$values['supervisor'],'.invoice'),
- 'select_supervisor'
=> 'supervisor',
- 'lang_no_supervisor' =>
lang('No supervisor'),
- 'lang_supervisor_statustext' => lang('Select
the supervisor responsible for this invoice. To do not use supervisor - select
NO SUPERVISOR'),
-
- 'lang_budget_responsible' =>
lang('B - responsible'),
- 'budget_responsible_list' =>
$this->bocommon->get_user_list_right(128,$values['budget_responsible'],'.invoice'),
- 'select_budget_responsible' =>
'budget_responsible',
- 'lang_select_budget_responsible'=> lang('Select
B-Responsible'),
- 'lang_budget_responsible_statustext'
=> lang('You have to select a budget responsible for this invoice in order to
add the invoice'),
- 'lang_merknad'
=> lang('Descr'),
- 'lang_merknad_statustext' =>
lang('Descr'),
- 'location_data'
=> $location_data,
- 'b_account_data'
=> $b_account_data
- );
-
-//_debug_array($data);
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('invoice','menu'));
-
- $appname
= lang('Invoice');
- $function_msg =
lang('Add invoice');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
- $GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('add'
=> $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function debug($values)
- {
-// _debug_array($values);
-
$GLOBALS['phpgw']->xslttpl->add_file(array('invoice','menu','table_header'));
-
-
- $link_data_add = array
- (
- 'menuaction' =>
$this->currentapp.'.uiinvoice.add',
- 'add_invoice' => True
- );
-
- $link_data_cancel = array
- (
- 'menuaction' =>
$this->currentapp.'.uiinvoice.add'
- );
-
- $post_data = array
- (
- 'location_code' =>
$values[0]['location_code'],
- 'art' =>
$values[0]['art'],
- 'type' =>
$values[0]['type'],
- 'dim_b' =>
$values[0]['dim_b'],
- 'invoice_num' =>
$values[0]['invoice_num'],
- 'kid_nr' =>
$values[0]['kid_nr'],
- 'vendor_id' =>
$values[0]['spvend_code'],
- 'vendor_name' =>
$values[0]['vendor_name'],
- 'janitor' =>
$values[0]['janitor'],
- 'supervisor' =>
$values[0]['supervisor'],
- 'budget_responsible'=>
$values[0]['budget_responsible'],
- 'invoice_date' =>
urlencode($values[0]['invoice_date']),
- 'num_days' =>
$values[0]['num_days'],
- 'payment_date' =>
urlencode($values[0]['payment_date']),
- 'sday' =>
$values[0]['sday'],
- 'smonth' =>
$values[0]['smonth'],
- 'syear' =>
$values[0]['syear'],
- 'eday' =>
$values[0]['eday'],
- 'emonth' =>
$values[0]['emonth'],
- 'eyear' =>
$values[0]['eyear'],
- 'auto_tax' =>
$values[0]['auto_tax'],
- 'merknad' =>
$values[0]['merknad'],
- 'b_account_id' =>
$values[0]['spbudact_code'],
- 'b_account_name' =>
$values[0]['b_account_name'],
- 'amount' =>
$values[0]['amount'],
- 'order' =>
$values[0]['order'],
- );
-
- $link_data_add = $link_data_add +
$post_data;
- $link_data_cancel = $link_data_cancel
+ $post_data;
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('Add'),
- 'lang_add_statustext' => lang('Add this
invoice'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data_add),
- 'lang_cancel' =>
lang('cancel'),
- 'lang_cancel_statustext'=> lang('Do not add
this invoice'),
- 'cancel_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data_cancel)
- );
-
-
- $import = array(
- 'Bestilling' => 'pmwrkord_code',
- 'Fakt. Nr' => 'fakturanr',
- 'Konto' => 'spbudact_code',
- 'Objekt' => 'dima',
- 'Fag/Timer/Matr' => 'dimd',
- 'MVA' => 'mvakode',
- 'Tjeneste' => 'kostra_id',
- 'Beløp [kr]' => 'belop'
- );
-
- $header = array('Bestilling','Fakt.
Nr','Konto','Objekt','Fag/Timer/Matr','MVA','Tjeneste','Beløp [kr]');
-
- for ($i=0;$i<count($header);$i++)
- {
- $table_header[$i]['header'] = $header[$i];
- $table_header[$i]['width'] = '5%';
- $table_header[$i]['align'] =
'center';
- }
- // $sum=0;
-
- $import_count = count($import);
- $values_count = count($values);
- for ($i=0; $i<$values_count; $i++)
- {
- for ($k=0; $k<$import_count; $k++)
- {
- $content[$i]['row'][$k]['value']
= $values[$i][$import[$header[$k]]];
- if ($import[$header[$k]]=='belop')
- {
-
$content[$i]['row'][$k]['align'] = 'right';
- //
$sum=$sum+$values[$i][$import[$header[$k]]];
-
$content[$i]['row'][$k]['value'] =
number_format($values[$i][$import[$header[$k]]], 2, ',', '');
- }
- }
- }
-
-
-
- $data = array
- (
- 'artid'
=> $values[0]['artid'],
- 'lang_type'
=> lang('Type'),
- 'project_id'
=> $values[0]['project_id'],
- 'lang_project_id'
=> lang('Project id'),
- 'lang_bilagsnr'
=> lang('bilagsnr'),
- 'bilagsnr'
=> $values[0]['bilagsnr'],
- 'lang_vendor'
=> lang('Vendor'),
- 'vendor_name'
=> $values[0]['vendor_name'],
- 'spvend_code'
=> $values[0]['spvend_code'],
- 'lang_fakturadato'
=> lang('invoice date'),
- 'fakturadato'
=> $values[0]['fakturadato'],
- 'lang_forfallsdato'
=> lang('Payment date'),
- 'forfallsdato'
=> $values[0]['forfallsdato'],
- 'lang_janitor'
=> lang('Janitor'),
- 'oppsynsmannid'
=> $values[0]['oppsynsmannid'],
- 'lang_supervisor'
=> lang('Supervisor'),
- 'saksbehandlerid'
=> $values[0]['saksbehandlerid'],
- 'lang_budget_responsible' =>
lang('Budget Responsible'),
- 'budsjettansvarligid' =>
$values[0]['budsjettansvarligid'],
- 'lang_sum'
=> lang('Sum'),
- 'sum'
=> number_format($values[0]['amount'], 2, ',', ''),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
-
-//_debug_array($data);
- $appname
= lang('Invoice');
- $function_msg =
lang('Add invoice: Debug');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('debug' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function view_order()
- {
- $order_id =
get_var('order_id',array('POST','GET'));
- $soXport =
CreateObject($this->currentapp.'.soXport');
-
- $order_type = $soXport->check_order(intval($order_id));
- switch($order_type)
- {
- case 'workorder':
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.view&no_email=true&show_cost=true&workorder_id='
. $order_id);
- break;
- case 's_agreement':
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.view&id='
. $order_id);
- break;
- }
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage eco
+ * @version $Id: class.uiinvoice.inc.php,v 1.21 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uiinvoice
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+ var $user_lid;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'edit_period' => True,
+ 'list_sub' => True,
+ 'consume' => True,
+ 'remark' => True,
+ 'delete' => True,
+ 'add' => True,
+ 'debug' => True,
+ 'view_order' => True,
+ 'excel' => True
+ );
+
+ function uiinvoice()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $this->bo =
CreateObject($this->currentapp.'.boinvoice',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+
+ $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->user_lid =
$this->bo->user_lid;
+ $this->allrows =
$this->bo->allrows;
+
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+ $this->acl2_location = '.invoice';
+ $this->acl_read =
$this->acl2->check('.invoice',1);
+ $this->acl_add =
$this->acl2->check('.invoice',2);
+ $this->acl_edit =
$this->acl2->check('.invoice',4);
+ $this->acl_delete =
$this->acl2->check('.invoice',8);
+
+ $this->menu->sub ='invoice';
+
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' => $this->filter,
+ 'cat_id' => $this->cat_id,
+ 'user_lid' => $this->user_lid,
+ 'allrows' => $this->allrows
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+
+ function excel()
+ {
+ $paid = get_var('paid',array('POST','GET'));
+ $start_date =
get_var('start_date',array('POST','GET'));
+ $end_date =
get_var('end_date',array('POST','GET'));
+ $submit_search =
get_var('submit_search',array('POST','GET'));
+ $vendor_id =
get_var('vendor_id',array('POST','GET'));
+ $workorder_id =
get_var('workorder_id',array('POST','GET'));
+ $loc1 = get_var('loc1',array('POST','GET'));
+ $voucher_id =
get_var('voucher_id',array('POST','GET'));
+
+ $start_date=urldecode($start_date);
+ $end_date=urldecode($end_date);
+
+ if(!$end_date)
+ {
+ $end_date =
$GLOBALS['phpgw']->common->show_date(mktime(0,0,0,date("m"),date("d"),date("Y")),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $start_date = $end_date;
+ }
+
+ $list =
$this->bo->read_invoice($paid,$start_date,$end_date,$vendor_id,$loc1,$workorder_id,$voucher_id);
+
+ while (is_array($list[0]) && list($name_entry,) =
each($list[0]))
+ {
+ $name[]=$name_entry;
+ }
+
+ $descr = $name;
+
+ $this->bocommon->excel($list,$name,$descr);
+ }
+
+ function index()
+ {
+// $start_time = explode(' ',microtime());
+// $start_time = $start_time[1]+$start_time[0];
+
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('invoice','menu',
+
'nextmatchs',
+
'search_field'));
+
+ $paid = get_var('paid',array('POST','GET'));
+ $start_date =
get_var('start_date',array('POST','GET'));
+ $end_date =
get_var('end_date',array('POST','GET'));
+ $submit_search =
get_var('submit_search',array('POST','GET'));
+ $vendor_id =
get_var('vendor_id',array('POST','GET'));
+ $workorder_id =
get_var('workorder_id',array('POST','GET'));
+ $loc1 = get_var('loc1',array('POST','GET'));
+ $voucher_id =
get_var('voucher_id',array('POST','GET'));
+
+ $start_date=urldecode($start_date);
+ $end_date=urldecode($end_date);
+
+ if(!$end_date)
+ {
+ $end_date =
$GLOBALS['phpgw']->common->show_date(mktime(0,0,0,date("m"),date("d"),date("Y")),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $start_date = $end_date;
+ }
+
+ $links = $this->menu->links('invoice_'.!!$paid);
+
+ $values = get_var('values',array('POST','GET'));
+
+ if($values['save'] && $values['counter'])
+ {
+ $receipt=$this->bo->update_invoice($values);
+
+ }
+
+ $content =
$this->bo->read_invoice($paid,$start_date,$end_date,$vendor_id,$loc1,$workorder_id,$voucher_id);
+
+ $i=0;
+ if(is_array($content))
+ {
+ foreach($content as $extra)
+ {
+
+ $sum
= $sum + $extra['amount'];
+ $content[$i]['amount']
= number_format($extra['amount'], 2, ',', '');
+ $content[$i]['lang_payment_date']
= lang('Payment Date');
+ $content[$i]['link_sub']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.list_sub&user_lid='.$this->user_lid
. '&query=' . $this->query);
+ $content[$i]['lang_sub']
= lang('Voucher ID');
+ $content[$i]['lang_sub_help']
= lang('Klick this link to enter the list of sub-invoices');
+ $content[$i]['link_period']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.edit_period');
+ $content[$i]['lang_period']
= lang('Period');
+ $content[$i]['lang_period_help']
= lang('Klick this link to edit the period');
+
+ if($this->acl_delete && !$paid)
+ {
+ $content[$i]['link_delete']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.delete&voucher_id='
. $extra['voucher_id']);
+
$content[$i]['lang_delete_statustext'] = lang('delete the voucher');
+ $content[$i]['text_delete']
= lang('delete');
+ }
+
+ $i++;
+ }
+ }
+
+ $table_header[] = array
+ (
+ 'sort_voucher' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'bilagsnr',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiinvoice.index',
+
'cat_id'
=>$this->cat_id,
+
'sub'
=>$this->sub,
+
'paid'
=> $paid,
+
'vendor_id'
=> $vendor_id,
+
'user_lid'
=> $this->user_lid)
+
)),
+ 'lang_voucher' =>
lang('voucher'),
+ 'sort_voucher_date'
=> $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'fakturadato',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiinvoice.index',
+
'cat_id'
=>$this->cat_id,
+
'sub'
=>$this->sub,
+
'paid'
=> $paid,
+
'vendor_id'
=> $vendor_id,
+
'user_lid'
=> $this->user_lid)
+
)),
+ 'lang_voucher_date' =>
lang('Voucher Date'),
+ 'lang_days'
=> lang('Days'),
+ 'lang_sum'
=> lang('Sum'),
+ 'sort_vendor_id'
=> $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'spvend_code',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiinvoice.index',
+
'cat_id'
=>$this->cat_id,
+
'sub'
=>$this->sub,
+
'paid'
=> $paid,
+
'vendor_id'
=> $vendor_id,
+
'user_lid'
=> $this->user_lid)
+
)),
+ 'lang_vendor_id' =>
lang('Vendor'),
+ 'lang_num_sub_invoice' =>
lang('Count'),
+ 'lang_type'
=> lang('Type'),
+ 'lang_period' =>
lang('Period'),
+ 'lang_kredit' =>
lang('KreditNota'),
+ 'lang_none'
=> lang('None'),
+ 'lang_janitor' =>
lang('Janitor'),
+ 'lang_supervisor' =>
lang('Supervisor'),
+ 'lang_budget_responsible' => lang('Budget
Responsible'),
+ 'lang_transfer' =>
lang('Transfer'),
+ 'lang_delete' =>
lang('delete')
+ );
+
+ $table_done[] = array
+ (
+ 'lang_done' =>
lang('Done'),
+ 'lang_done_statustext' => lang('Close this
window')
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiinvoice.index',
+ 'order' => $this->order,
+ 'sort' => $this->sort,
+ 'cat_id' =>
$this->cat_id,
+ 'user_lid' =>
$this->user_lid,
+ 'sub' => $this->sub,
+ 'query' => $this->query,
+ 'start' => $this->start,
+ 'paid' => $paid,
+ 'vendor_id' => $vendor_id,
+ 'workorder_id' => $workorder_id,
+ 'start_date' => $start_date,
+ 'end_date' => $end_date,
+ 'filter' => $this->filter
+ );
+
+ if($this->acl_add)
+ {
+ $table_add[] = array
+ (
+ 'lang_add'
=> lang('add'),
+ 'lang_add_statustext' => lang('add a
invoice'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.add')
+ );
+ }
+
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $link_excel = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiinvoice.excel',
+ 'order' => $this->order,
+ 'sort' => $this->sort,
+ 'cat_id' => $this->cat_id,
+ 'user_lid' => $this->user_lid,
+ 'sub' => $this->sub,
+ 'query' => $this->query,
+ 'start' => $this->start,
+ 'paid' => $paid,
+ 'vendor_id' => $vendor_id,
+ 'workorder_id' => $workorder_id,
+ 'start_date' => $start_date,
+ 'end_date' => $end_date,
+ 'filter' => $this->filter,
+ 'allrows' => $this->allrows
+ );
+
+ $data['lang_excel'] =
'excel';
+ $data['link_excel'] =
$GLOBALS['phpgw']->link('/index.php',$link_excel);
+ $data['lang_excel_help'] =
lang('Download table to MS Excel');
+
+ $data['msgbox_data']
= $GLOBALS['phpgw']->common->msgbox($msgbox_data);
+ $data['sum']
= number_format($sum, 2, ',', '');
+ $data['overlib_source']
= './'.$this->currentapp.'/inc/overlib.js';
+ $data['links']
= $links;
+ $data['allow_allrows']
= true;
+ $data['allrows']
= $this->allrows;
+ $data['start_record']
= $this->start;
+ $data['record_limit']
= $record_limit;
+ $data['num_records']
= count($content);
+ $data['all_records']
= $this->bo->total_records;
+ $data['link_url']
= $GLOBALS['phpgw']->link('/index.php',$link_data);
+ $data['img_path']
= $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default');
+ $data['lang_no_cat']
= lang('no category');
+ $data['lang_cat_statustext'] =
lang('Select the category the building belongs to. To do not use a category
select NO CATEGORY');
+ $data['select_name']
= 'cat_id';
+ $data['select_action']
= $GLOBALS['phpgw']->link('/index.php',$link_data);
+ $data['lang_no_user']
= lang('None');
+ $data['lang_user_statustext'] =
lang('Select the user the selection belongs to. To do not use a user select NO
USER');
+ $data['select_user_name']
= 'user_lid';
+ $data['lang_searchfield_statustext'] = lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again');
+ $data['lang_searchbutton_statustext'] = lang('Submit
the search string');
+ $data['lang_search']
= lang('search');
+ $data['query']
= $this->query;
+ $data['form_action']
= $GLOBALS['phpgw']->link('/index.php',$link_data);
+
+//_debug_array($content);
+ $appname
= lang('invoice');
+ $function_msg =
lang('list voucher');
+
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
+ if ($paid)
+ {
+ $bolocation =
CreateObject($this->currentapp.'.bolocation');
+ $data['user_list']
=
$this->bo->get_invoice_user_list('select',$this->user_lid,array('all'),$default='all');
+
$location_data=$bolocation->initiate_ui_location(array('type_id'=> 1));
+
+ $data['cat_list']
= $this->bo->select_category('select',$this->cat_id);
+ $data['start_date'] = $start_date;
+ $data['end_date'] = $end_date;
+ $data['vendor_id'] = $vendor_id;
+
+
+ $data['jsDateFormat']
= $jsDateFormat;
+ $data['date_img']
= $cal_info['img'];
+ $data['lang_datetitle']
= lang('Select date');
+ $data['calendar_setup_start']
= "Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});";
+ $data['calendar_setup_end']
= "Calendar.setup({inputField : 'end_date',ifFormat : '" .
$jsDateFormat . "',button : 'end_date-trigger'});";
+
+ $data['lang_workorder']
= lang('Workorder ID');
+ $data['lang_workorder_statustext']
= lang('enter the Workorder ID to search by workorder - at any date');
+ $data['workorder_id']
= $workorder_id;
+
+ $data['addressbook_link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor');
+ $data['lang_select_vendor_statustext'] =
lang('Select the vendor by klicking this link');
+ $data['lang_vendor']
= lang('Vendor');
+ $data['property_link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.index&lookup=1&type_id=1&lookup_name=0');
+ $data['lang_select_property_statustext']=
lang('Select the property by klicking this link');
+ $data['lang_property_statustext']
= lang('Search by property');
+ $data['lang_property']
= lang('property');
+ $data['loc1']
= $loc1;
+ $data['lang_search']
= lang('Search');
+ $data['lang_search_statustext']
= lang('Search for paid invoices');
+
+ $data['table_header_list_voucher_paid'] =
$table_header;
+ $data['values_list_voucher_paid']
= $content;
+
+ $data['lang_voucher_id_statustext']
= lang('Search for voucher id');
+ $data['lang_voucher_id']
= lang('Voucher ID');
+ $data['voucher_id']
= $voucher_id;
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_voucher_paid' =>
$data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+ else
+ {
+ $data['user_list']
=
$this->bo->get_invoice_user_list('filter',$this->user_lid,array('all'),$default='none');
+ $data['cat_list']
= $this->bo->select_category('filter',$this->cat_id);
+ $data['table_done']
= $table_done;
+ $data['img_check']
=
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif';
+ $data['check_source']
= './'.$this->currentapp.'/inc/check.js';
+ $data['lang_save']
= lang('save');
+ $data['done_action']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.index');
+ $data['lang_done_statustext']
= lang('Back to the list');
+ $data['lang_save_statustext']
= lang('Save the voucher');
+ $data['lang_select_all']
= lang('Select All');
+ $data['message']
= $receipt['message'];
+ $data['error']
= $receipt['error'];
+ $data['table_header_list_voucher']
= $table_header;
+ $data['values_list_voucher']
= $content;
+ $data['acl_delete']
= $this->acl_delete;
+ $data['table_add_invoice']
= $table_add;
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_voucher' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+ $this->save_sessiondata();
+
+ $end_time = $this->bo->end_time;
+
+ // $end_time = $end_time[1]+$end_time[0];
+ // $process = ($end_time-$start_time);
+ // echo "tidsforbruk: $process";
+ }
+
+ function list_sub()
+ {
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('invoice','menu',
+
'nextmatchs'));
+
+ $paid = get_var('paid',array('POST','GET'));
+
+ $links = $this->menu->links('invoice_');
+
+ $values =
get_var('values',array('POST','GET'));
+ $voucher_id =
get_var('voucher_id',array('POST','GET'));
+
+ if($values['save'] && $values['counter'])
+ {
+ $receipt=$this->bo->update_invoice_sub($values);
+ }
+
+//_debug_array($values);
+
+//echo $voucher_id;
+
+
+ if ($voucher_id)
+ {
+ $content =
$this->bo->read_invoice_sub($voucher_id,$paid);
+ }
+
+ $i=0;
+ if(is_array($content))
+ {
+ while(each($content))
+ {
+ $sum
= $sum + $content[$i]['amount'];
+ $content[$i]['amount']
= number_format($content[$i]['amount'], 2, ',', '');
+ $content[$i]['paid']
= $paid;
+
$content[$i]['lang_tax_code_statustext'] = lang('select the appropriate
tax code');
+ $content[$i]['tax_code_list']
= $this->bo->tax_code_list($content[$i]['tax_code']);
+ $content[$i]['lang_remark']
= lang('Remark');
+ $content[$i]['link_remark']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.remark');
+ $content[$i]['lang_remark_help']
= lang('Klick this link to view the remark');
+ $content[$i]['link_order']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.view_order');
+ $content[$i]['link_claim']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant_claim.check');
+ $i++;
+ }
+ }
+
+//_debug_array($content);
+ $table_header[] = array
+ (
+ 'sort_workorder' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'pmwrkord_code',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiinvoice.list_sub',
+
'cat_id'
=> $this->cat_id,
+
'sub'
=> $this->sub,
+
'paid'
=> $paid,
+
'voucher_id'
=> $voucher_id,
+
'query'
=> $this->query)
+
)),
+ 'lang_workorder' =>
lang('Workorder'),
+ 'sort_budget_account' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'spbudact_code',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiinvoice.list_sub',
+
'cat_id'
=>$this->cat_id,
+
'sub'
=>$this->sub,
+
'paid'
=> $paid,
+
'voucher_id'
=> $voucher_id,
+
'query'
=> $this->query)
+
)),
+ 'lang_budget_account' => lang('Budget
account'),
+
+ 'sort_sum'
=> $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'belop',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiinvoice.list_sub',
+
'cat_id'
=>$this->cat_id,
+
'sub'
=>$this->sub,
+
'paid'
=> $paid,
+
'voucher_id'
=> $voucher_id,
+
'query'
=> $this->query)
+
)),
+
+ 'lang_sum'
=> lang('Sum'),
+ 'lang_type'
=> lang('Type'),
+ 'lang_close_order' =>
lang('Close order'),
+ 'lang_charge_tenant' => lang('Charge
tenant'),
+ 'lang_invoice_id' =>
lang('Invoice Id'),
+ 'sort_dima'
=> $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'dima',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiinvoice.list_sub',
+
'cat_id'
=>$this->cat_id,
+
'sub'
=>$this->sub,
+
'paid'
=> $paid,
+
'voucher_id'
=> $voucher_id,
+
'query'
=> $this->query)
+
)),
+ 'lang_dima'
=> lang('Dim A'),
+ 'lang_dimb'
=> lang('Dim B'),
+ 'lang_dimd'
=> lang('Dim D'),
+ 'lang_tax_code' =>
lang('Tax code'),
+ 'lang_remark' =>
lang('Remark'),
+ );
+
+ $table_done[] = array
+ (
+ 'lang_done' =>
lang('Done'),
+ 'lang_done_statustext' => lang('Close this
window')
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiinvoice.list_sub',
+ 'order' => $this->order,
+ 'sort' => $this->sort,
+ 'cat_id' =>
$this->cat_id,
+ 'user_lid' =>
$this->user_lid,
+ 'sub' => $this->sub,
+ 'query' => $this->query,
+ 'start' => $this->start,
+ 'paid' => $paid,
+ 'voucher_id' => $voucher_id,
+ 'user_lid' =>
$this->user_lid,
+ 'query' => $this->query
+ );
+
+ if ($paid)
+ {
+ $function_msg = lang('list paid invoice');
+
+ }
+ else
+ {
+ $function_msg = lang('list invoice');
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'img_check'
=>
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
+ 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'sum'
=> number_format($sum, 2, ',', ''),
+ 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('Done'),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.index&user_lid='.$this->user_lid
. '&query='.$this->query),
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'lang_save_statustext' =>
lang('Save the voucher'),
+ 'links'
=> $links,
+ 'allow_allrows'
=> false,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=>
count($content),//$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($content),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_submit'
=> lang('submit'),
+ 'table_header_list_invoice_sub' =>
$table_header,
+ 'values_list_invoice_sub' =>
$content,
+ 'paid'
=> $paid,
+ 'vendor'
=> $content[0]['vendor'],
+ 'lang_vendor'
=> lang('Vendor'),
+ 'voucher_id'
=> $voucher_id,
+ 'lang_voucher_id'
=> lang('Voucher Id'),
+ 'lang_claim'
=> lang('Claim'),
+ 'table_done'
=> $table_done
+ );
+
+//_debug_array($data);
+
+ $appname
= lang('invoice');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_invoice_sub' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+
+ function edit_period()
+ {
+ $GLOBALS['phpgw']->xslttpl->add_file(array('invoice'));
+
+ $GLOBALS['phpgw_info']['flags']['noframework'] = True;
+
+ $voucher_id =
get_var('voucher_id',array('POST','GET'));
+ $period =
get_var('period',array('POST','GET'));
+ $submit =
get_var('submit',array('POST','GET'));
+
+ if($submit)
+ {
+ $receipt =
$this->bo->update_period($voucher_id,$period);
+ }
+
+ $function_msg = lang('Edit period');
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiinvoice.edit_period',
+ 'voucher_id' => $voucher_id);
+
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'period_list'
=> $this->bo->period_list($period),
+ 'function_msg'
=> $function_msg,
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_save'
=> lang('save'),
+ 'select_name'
=> 'period'
+ );
+
+//_debug_array($data);
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
$function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_period' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function remark()
+ {
+ $GLOBALS['phpgw']->xslttpl->add_file(array('invoice'));
+ $GLOBALS['phpgw_info']['flags']['noframework'] = True;
+
+ $id = get_var('id',array('POST','GET'));
+ $paid = get_var('paid',array('POST','GET'));
+
+ $data = array
+ (
+ 'remark' => $this->bo->read_remark($id,$paid)
+ );
+
+//_debug_array($data);
+
+ $appname
= lang('invoice');
+ $function_msg =
lang('remark');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('remark' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function consume()
+ {
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('invoice','menu',
+
'nextmatchs',
+
'search_field'));
+
+ $start_date =
get_var('start_date',array('POST','GET'));
+ $end_date =
get_var('end_date',array('POST','GET'));
+ $submit_search =
get_var('submit_search',array('POST','GET'));
+ $vendor_id =
get_var('vendor_id',array('POST','GET'));
+
+ $workorder_id =
get_var('workorder_id',array('POST','GET'));
+ $loc1 =
get_var('loc1',array('POST','GET'));
+ $district_id =
get_var('district_id',array('POST','GET'));
+ $b_account_class =
get_var('b_account_class',array('POST','GET'));
+
+ if($vendor_id)
+ {
+ $contacts =
CreateObject($this->currentapp.'.soactor');
+ $contacts->role='vendor';
+ $vendor =
$contacts->read_single(array('actor_id'=>(int)$vendor_id));
+ if(is_array($vendor))
+ {
+ foreach($vendor['attributes'] as
$attribute)
+ {
+
if($attribute['name']=='org_name')
+ {
+
$vendor_name=$attribute['value'];
+ break;
+ }
+ }
+ }
+ }
+
+ $links = $this->menu->links('consume');
+
+
+//_debug_array($values);
+ if(!$submit_search)
+ {
+ $start_date =
$GLOBALS['phpgw']->common->show_date(mktime(0,0,0,date("m"),date("d"),date("Y")),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $end_date = $start_date;
+ }
+ else
+ {
+ $content =
$this->bo->read_consume($start_date,$end_date,$vendor_id,$loc1,$workorder_id,$b_account_class,$district_id);
+ }
+
+ if(is_array($content))
+ {
+ $i=0;
+ while(each($content))
+ {
+ $sum=$sum+$content[$i]['consume'];
+ $content[$i]['consume']
=number_format($content[$i]['consume'], 2, ',', '');
+ $i++;
+ }
+ }
+
+
+ $table_header[] = array
+ (
+ 'lang_district' =>
lang('District'),
+ 'lang_period' =>
lang('Period'),
+ 'lang_budget_account' => lang('Budget
account'),
+ 'lang_consume' =>
lang('Consume'),
+ );
+
+ $table_done[] = array
+ (
+ 'lang_done' =>
lang('Done'),
+ 'lang_done_statustext' => lang('Close this
window')
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiinvoice.consume',
+ 'order' => $this->order,
+ 'sort' => $this->sort,
+ 'cat_id' =>
$this->cat_id,
+ 'district_id' => $district_id,
+ 'sub' => $this->sub,
+ 'query' => $this->query,
+ 'start' => $this->start,
+ 'filter' => $this->filter
+ );
+
+ $data['lang_sum']
= lang('Sum');
+ $data['sum']
= number_format($sum, 2, ',', '');
+ $data['overlib_source']
= './'.$this->currentapp.'/inc/overlib.js';
+ $data['links']
= $links;
+ $data['allow_allrows']
= false;
+ $data['start_record']
= $this->start;
+ $data['record_limit']
= $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ $data['num_records']
= count($content);
+ $data['all_records']
= $this->bo->total_records;
+ $data['link_url']
= $GLOBALS['phpgw']->link('/index.php',$link_data);
+ $data['img_path']
= $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default');
+ $data['lang_no_cat']
= lang('no category');
+ $data['lang_cat_statustext'] =
lang('Select the category the building belongs to. To do not use a category
select NO CATEGORY');
+ $data['select_name']
= 'cat_id';
+ $data['select_action']
= $GLOBALS['phpgw']->link('/index.php',$link_data);
+ $data['lang_no_district']
= lang('No district');
+ $data['lang_district_statustext'] =
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT');
+ $data['select_district_name'] =
'district_id';
+ $data['lang_searchfield_statustext'] = lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again');
+ $data['lang_searchbutton_statustext'] = lang('Submit
the search string');
+ $data['lang_search']
= lang('search');
+ $data['query']
= $this->query;
+ $data['form_action']
= $GLOBALS['phpgw']->link('/index.php',$link_data);
+
+
+ $data['district_list']
= $this->bocommon->select_district_list('select',$district_id);
+ $data['cat_list']
= $this->bo->select_category('select',$this->cat_id);
+ $data['start_date']
= $start_date;
+ $data['end_date']
= $end_date;
+ $data['vendor_id']
= $vendor_id;
+ $data['vendor_name']
= $vendor_name;
+
+ $data['account_class_list']
= $this->bo->select_account_class($b_account_class);
+ $data['lang_no_account_class_'] =
lang('No account');
+ $data['lang_account_class_statustext'] = lang('Select
the account class the selection belongs to');
+ $data['select_account_class_name'] =
'b_account_class';
+
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+ $data['jsDateFormat']
= $jsDateFormat;
+ $data['date_img']
= $cal_info['img'];
+ $data['lang_datetitle']
= lang('Select date');
+ $data['calendar_setup_start'] =
"Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});";
+ $data['calendar_setup_end']
= "Calendar.setup({inputField : 'end_date',ifFormat : '" . $jsDateFormat .
"',button : 'end_date-trigger'});";
+
+ $data['lang_workorder']
= lang('Workorder ID');
+ $data['lang_workorder_statustext'] =
lang('enter the Workorder ID to search by workorder - at any date');
+ $data['workorder_id']
= $workorder_id;
+
+ $data['addressbook_link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor');
+ $data['lang_select_vendor_statustext'] = lang('Select
the vendor by klicking this link');
+ $data['lang_vendor']
= lang('Vendor');
+
+ $bolocation =
CreateObject($this->currentapp.'.bolocation');
+
$location_data=$bolocation->initiate_ui_location(array('type_id'=> 1));
+
+ $data['property_link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.index&lookup=1&type_id=1&lookup_name=0');
+
+ $data['lang_select_property_statustext']= lang('Select
the property by klicking this link');
+ $data['lang_property_statustext'] =
lang('Search by property');
+
+ $data['lang_property']
= lang('property');
+ $data['loc1']
= $loc1;
+ $data['lang_search']
= lang('Search');
+ $data['lang_search_statustext'] =
lang('Search for paid invoices');
+
+ $data['table_header_consume'] =
$table_header;
+ $data['values_consume']
= $content;
+
+ $appname
= lang('consume');
+ $function_msg
= lang('list consume');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('consume' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+
+ $this->save_sessiondata();
+ }
+
+ function delete()
+ {
+ if(!$this->acl_delete)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
+ }
+
+ $voucher_id = get_var('voucher_id',array('POST','GET'));
+ $confirm = get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiinvoice.index'
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($voucher_id);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.delete&voucher_id='
. $voucher_id),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('invoice');
+ $function_msg =
lang('delete voucher');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function add()
+ {
+ if(!$this->acl_add)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
+ }
+
+// $receipt =
$GLOBALS['phpgw']->session->appsession('session_data','add_receipt');
+
$GLOBALS['phpgw']->session->appsession('session_data','add_receipt',False);
+
+ $bolocation =
CreateObject($this->currentapp.'.bolocation');
+
+ $values['art'] =
get_var('art',array('POST','GET'));
+ $values['type'] =
get_var('type',array('POST','GET'));
+ $values['dim_b'] =
get_var('dim_b',array('POST','GET'));
+ $values['invoice_num'] =
get_var('invoice_num',array('POST','GET'));
+ $values['kid_nr'] =
get_var('kid_nr',array('POST','GET'));
+ $values['vendor_id'] =
get_var('vendor_id',array('POST','GET'));
+ $values['vendor_name'] =
get_var('vendor_name',array('POST','GET'));
+ $values['janitor'] =
get_var('janitor',array('POST','GET'));
+ $values['supervisor'] =
get_var('supervisor',array('POST','GET'));
+ $values['budget_responsible']=
get_var('budget_responsible',array('POST','GET'));
+ $values['invoice_date'] =
urldecode(get_var('invoice_date',array('POST','GET')));
+ $values['num_days'] =
get_var('num_days',array('POST','GET'));
+ $values['payment_date'] =
urldecode(get_var('payment_date',array('POST','GET')));
+ $values['sday'] =
get_var('sday',array('POST','GET'));
+ $values['smonth'] =
get_var('smonth',array('POST','GET'));
+ $values['syear'] =
get_var('syear',array('POST','GET'));
+ $values['eday'] =
get_var('eday',array('POST','GET'));
+ $values['emonth'] =
get_var('emonth',array('POST','GET'));
+ $values['eyear'] =
get_var('eyear',array('POST','GET'));
+ $values['auto_tax'] =
get_var('auto_tax',array('POST','GET'));
+ $values['merknad'] =
get_var('merknad',array('POST','GET'));
+ $values['b_account_id'] =
get_var('b_account_id',array('POST','GET'));
+ $values['b_account_name'] =
get_var('b_account_name',array('POST','GET'));
+ $values['amount'] =
get_var('amount',array('POST','GET'));
+ $values['order'] =
get_var('order',array('POST','GET'));
+ $location_code =
get_var('location_code',array('POST','GET'));
+ $debug =
get_var('debug',array('POST','GET'));
+ $add_invoice =
get_var('add_invoice',array('POST','GET'));
+
+
+ $links = $this->menu->links('add_inv');
+
+
+ if($location_code)
+ {
+ $values['location_data'] =
$bolocation->read_single($location_code,array('tenant_id'=>$tenant_id,'p_num'=>$p_num));
+ }
+
+
+
+ if($add_invoice && is_array($values))
+ {
+ $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
+
+ for ($i=0;
$i<count($insert_record['location']); $i++)
+ {
+
if($_POST[$insert_record['location'][$i]])
+ {
+
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
+ }
+ }
+
+ while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
+ {
+ if($_POST[$key])
+ {
+ $values['extra'][$column]
= $_POST[$key];
+ }
+ }
+
+ $values['street_name'] =
$_POST['street_name'];
+ $values['street_number'] =
$_POST['street_number'];
+ $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
+
+
+ if($values['order'] &&
!ctype_digit($values['order'])):
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter an integer for order!'));
+ unset($values['order']);
+ }
+ elseif($values['order']):
+ {
+ $order=True;
+ }
+ endif;
+
+ if (!$values['amount'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Please - enter an amount!'));
+ }
+ if (!$values['art'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Please - select type invoice!'));
+ }
+ if (!$values['vendor_id'] && !$order)
+ {
+ $receipt['error'][] =
array('msg'=>lang('Please - select Vendor!'));
+ }
+
+ if (!$values['type'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Please - select type order!'));
+ }
+
+ if (!$values['budget_responsible'] && !$order)
+ {
+ $receipt['error'][] =
array('msg'=>lang('Please - select budget responsible!'));
+ }
+
+ if(!$order && $values['vendor_id'])
+ {
+ if
(!$this->bo->check_vendor($values['vendor_id']))
+ {
+ $receipt['error'][] =
array('msg'=>lang('That Vendor ID is not valid !'). ' : ' .
$values['vendor_id']);
+ }
+ }
+
+ if (!$values['payment_date'] &&
!$values['num_days'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Please - select either payment date or number of days from
invoice date !'));
+ }
+
+//_debug_array($values);
+ if (!is_array($receipt['error']))
+ {
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $dateformat =
str_replace(".","",$dateformat);
+ $dateformat =
str_replace("-","",$dateformat);
+ $dateformat =
str_replace("/","",$dateformat);
+ $y=strpos($dateformat,'y');
+ $d=strpos($dateformat,'d');
+ $m=strpos($dateformat,'m');
+
+ if($values['invoice_date'])
+ {
+ $dateparts = explode('/',
$values['invoice_date']);
+ $values['sday'] =
$dateparts[$d];
+ $values['smonth'] =
$dateparts[$m];
+ $values['syear'] =
$dateparts[$y];
+
+ $dateparts = explode('/',
$values['payment_date']);
+ $values['eday'] =
$dateparts[$d];
+ $values['emonth'] =
$dateparts[$m];
+ $values['eyear'] =
$dateparts[$y];
+ }
+
+ $values['bilagsnr'] =
$this->bo->next_bilagsnr();
+ $values['regtid'] =
date($this->bocommon->datetimeformat);
+
+ $receipt =
$this->bo->add($values,$debug);
+ if($debug)
+ {
+ $this->debug($receipt);
+ return;
+ }
+ unset($values);
+
$GLOBALS['phpgw']->session->appsession('session_data','add_receipt',$receipt);
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.add');
+
+ }
+ else
+ {
+ if($values['location'])
+ {
+ $location_code=implode("-",
$values['location']);
+ $values['location_data'] =
$bolocation->read_single($location_code,$values['extra']);
+ }
+ }
+ }
+
+ $location_data=$bolocation->initiate_ui_location(array(
+ 'values' =>
$values['location_data'],
+ 'type_id' => -1,
// calculated from location_types
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' =>
False,
+ 'lookup_type' => 'form',
+ 'lookup_entity' => False,
//$this->bocommon->get_lookup_entity('project'),
+ 'entity_data' => False
//$values['p']
+ ));
+
+
$b_account_data=$this->bocommon->initiate_ui_budget_account_lookup(array(
+ 'b_account_id' =>
$values['b_account_id'],
+ 'b_account_name' =>
$values['b_account_name']));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiinvoice.add',
+ 'debug' => True
+ );
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'links'
=> $links,
+
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle'
=> lang('Select date'),
+ 'calendar_setup_invoice' =>
"Calendar.setup({inputField : 'invoice_date',ifFormat : '" . $jsDateFormat .
"',button : 'invoice_date-trigger'});",
+ 'calendar_setup_payment' =>
"Calendar.setup({inputField : 'payment_date',ifFormat : '" . $jsDateFormat .
"',button : 'payment_date-trigger'});",
+
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'cancel_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.index'),
+ 'lang_cancel'
=> lang('Cancel'),
+ 'lang_cancel_statustext' =>
lang('cancel'),
+ 'action_url'
=> $GLOBALS['phpgw']->link('/index.php','menuaction='. $this->currentapp
.'.uiinvoice.add'),
+ 'tsvfilename'
=> '',
+
+ 'lang_add'
=> lang('add'),
+ 'lang_add_statustext' => lang('Klick
this button to add a invice'),
+
+ 'lang_invoice_date'
=> lang('invoice date'),
+ 'lang_payment_date'
=> lang('Payment date'),
+ 'lang_no_of_days'
=> lang('Days'),
+ 'lang_invoice_number' =>
lang('Invoice Number'),
+ 'lang_invoice_num_statustext' => lang('Enter
Invoice Number'),
+
+ 'lang_select'
=> lang('Select per button !'),
+ 'lang_kidnr'
=> lang('KID nr'),
+ 'lang_kid_nr_statustext' =>
lang('Enter Kid nr'),
+
+ 'lang_vendor'
=> lang('Vendor'),
+ 'addressbook_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor'),
+
+ 'lang_invoice_date_statustext' => lang('Enter
the invoice date'),
+ 'lang_num_days_statustext' =>
lang('Enter the payment date or the payment delay'),
+ 'lang_payment_date_statustext' => lang('Enter
the payment date or the payment delay'),
+ 'lang_vendor_statustext'
=> lang('Select the vendor by klicking the button'),
+ 'lang_vendor_name_statustext' => lang('Select
the vendor by klicking the button'),
+ 'lang_select_vendor_statustext' => lang('Select
the vendor by klicking this button'),
+
+ 'value_invoice_date' =>
$values['invoice_date'],
+ 'value_payment_date' =>
$values['payment_date'],
+ 'value_belop'
=> $values['belop'],
+ 'value_vendor_id'
=> $values['vendor_id'],
+ 'value_vendor_name'
=> $values['vendor_name'],
+ 'value_kid_nr'
=> $values['kid_nr'],
+ 'value_dim_b'
=> $values['dim_b'],
+ 'value_invoice_num'
=> $values['invoice_num'],
+ 'value_merknad'
=> $values['merknad'],
+ 'value_num_days'
=> $values['num_days'],
+ 'value_amount'
=> $values['amount'],
+ 'value_order'
=> $values['order'],
+
+ 'lang_auto_tax'
=> lang('Auto TAX'),
+ 'lang_auto_tax_statustext' =>
lang('Set tax'),
+
+ 'lang_amount'
=> lang('Amount'),
+ 'lang_amount_statustext' =>
lang('Amount of the invoice'),
+
+ 'lang_order'
=> lang('Order ID'),
+ 'lang_order_statustext' => lang('Order
# that initiatet the invoice'),
+
+ 'lang_art'
=> lang('Art'),
+ 'art_list'
=> $this->bo->get_lisfm_ecoart($values['art']),
+ 'select_art'
=> 'art',
+ 'lang_select_art'
=> lang('Select Invoice Type'),
+ 'lang_art_statustext' =>
lang('You have to select type of invoice'),
+
+ 'lang_type'
=> lang('Type invoice II'),
+ 'type_list'
=> $this->bo->get_type_list($values['type']),
+ 'select_type'
=> 'type',
+ 'lang_no_type'
=> lang('No type'),
+ 'lang_type_statustext' =>
lang('Select the type invoice. To do not use type - select NO TYPE'),
+
+ 'lang_dimb'
=> lang('Dim B'),
+ 'dimb_list'
=> $this->bo->select_dimb_list($values['dim_b']),
+ 'select_dimb'
=> 'dim_b',
+ 'lang_no_dimb'
=> lang('No Dim B'),
+ 'lang_dimb_statustext' =>
lang('Select the Dim B for this invoice. To do not use Dim B - select NO DIM
B'),
+
+ 'lang_janitor'
=> lang('Janitor'),
+ 'janitor_list'
=> $this->bocommon->get_user_list_right(32,$values['janitor'],'.invoice'),
+ 'select_janitor'
=> 'janitor',
+ 'lang_no_janitor'
=> lang('No janitor'),
+ 'lang_janitor_statustext' =>
lang('Select the janitor responsible for this invoice. To do not use janitor -
select NO JANITOR'),
+
+ 'lang_supervisor'
=> lang('Supervisor'),
+ 'supervisor_list'
=> $this->bocommon->get_user_list_right(64,$values['supervisor'],'.invoice'),
+ 'select_supervisor'
=> 'supervisor',
+ 'lang_no_supervisor' =>
lang('No supervisor'),
+ 'lang_supervisor_statustext' => lang('Select
the supervisor responsible for this invoice. To do not use supervisor - select
NO SUPERVISOR'),
+
+ 'lang_budget_responsible' =>
lang('B - responsible'),
+ 'budget_responsible_list' =>
$this->bocommon->get_user_list_right(128,$values['budget_responsible'],'.invoice'),
+ 'select_budget_responsible' =>
'budget_responsible',
+ 'lang_select_budget_responsible'=> lang('Select
B-Responsible'),
+ 'lang_budget_responsible_statustext'
=> lang('You have to select a budget responsible for this invoice in order to
add the invoice'),
+ 'lang_merknad'
=> lang('Descr'),
+ 'lang_merknad_statustext' =>
lang('Descr'),
+ 'location_data'
=> $location_data,
+ 'b_account_data'
=> $b_account_data
+ );
+
+//_debug_array($data);
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('invoice','menu'));
+
+ $appname
= lang('Invoice');
+ $function_msg =
lang('Add invoice');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+ $GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('add'
=> $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function debug($values)
+ {
+// _debug_array($values);
+
$GLOBALS['phpgw']->xslttpl->add_file(array('invoice','menu','table_header'));
+
+
+ $link_data_add = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiinvoice.add',
+ 'add_invoice' => True
+ );
+
+ $link_data_cancel = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiinvoice.add'
+ );
+
+ $post_data = array
+ (
+ 'location_code' =>
$values[0]['location_code'],
+ 'art' =>
$values[0]['art'],
+ 'type' =>
$values[0]['type'],
+ 'dim_b' =>
$values[0]['dim_b'],
+ 'invoice_num' =>
$values[0]['invoice_num'],
+ 'kid_nr' =>
$values[0]['kid_nr'],
+ 'vendor_id' =>
$values[0]['spvend_code'],
+ 'vendor_name' =>
$values[0]['vendor_name'],
+ 'janitor' =>
$values[0]['janitor'],
+ 'supervisor' =>
$values[0]['supervisor'],
+ 'budget_responsible'=>
$values[0]['budget_responsible'],
+ 'invoice_date' =>
urlencode($values[0]['invoice_date']),
+ 'num_days' =>
$values[0]['num_days'],
+ 'payment_date' =>
urlencode($values[0]['payment_date']),
+ 'sday' =>
$values[0]['sday'],
+ 'smonth' =>
$values[0]['smonth'],
+ 'syear' =>
$values[0]['syear'],
+ 'eday' =>
$values[0]['eday'],
+ 'emonth' =>
$values[0]['emonth'],
+ 'eyear' =>
$values[0]['eyear'],
+ 'auto_tax' =>
$values[0]['auto_tax'],
+ 'merknad' =>
$values[0]['merknad'],
+ 'b_account_id' =>
$values[0]['spbudact_code'],
+ 'b_account_name' =>
$values[0]['b_account_name'],
+ 'amount' =>
$values[0]['amount'],
+ 'order' =>
$values[0]['order'],
+ );
+
+ $link_data_add = $link_data_add +
$post_data;
+ $link_data_cancel = $link_data_cancel
+ $post_data;
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('Add'),
+ 'lang_add_statustext' => lang('Add this
invoice'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data_add),
+ 'lang_cancel' =>
lang('cancel'),
+ 'lang_cancel_statustext'=> lang('Do not add
this invoice'),
+ 'cancel_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data_cancel)
+ );
+
+
+ $import = array(
+ 'Bestilling' => 'pmwrkord_code',
+ 'Fakt. Nr' => 'fakturanr',
+ 'Konto' => 'spbudact_code',
+ 'Objekt' => 'dima',
+ 'Fag/Timer/Matr' => 'dimd',
+ 'MVA' => 'mvakode',
+ 'Tjeneste' => 'kostra_id',
+ 'Beløp [kr]' => 'belop'
+ );
+
+ $header = array('Bestilling','Fakt.
Nr','Konto','Objekt','Fag/Timer/Matr','MVA','Tjeneste','Beløp [kr]');
+
+ for ($i=0;$i<count($header);$i++)
+ {
+ $table_header[$i]['header'] = $header[$i];
+ $table_header[$i]['width'] = '5%';
+ $table_header[$i]['align'] =
'center';
+ }
+ // $sum=0;
+
+ $import_count = count($import);
+ $values_count = count($values);
+ for ($i=0; $i<$values_count; $i++)
+ {
+ for ($k=0; $k<$import_count; $k++)
+ {
+ $content[$i]['row'][$k]['value']
= $values[$i][$import[$header[$k]]];
+ if ($import[$header[$k]]=='belop')
+ {
+
$content[$i]['row'][$k]['align'] = 'right';
+ //
$sum=$sum+$values[$i][$import[$header[$k]]];
+
$content[$i]['row'][$k]['value'] =
number_format($values[$i][$import[$header[$k]]], 2, ',', '');
+ }
+ }
+ }
+
+
+
+ $data = array
+ (
+ 'artid'
=> $values[0]['artid'],
+ 'lang_type'
=> lang('Type'),
+ 'project_id'
=> $values[0]['project_id'],
+ 'lang_project_id'
=> lang('Project id'),
+ 'lang_bilagsnr'
=> lang('bilagsnr'),
+ 'bilagsnr'
=> $values[0]['bilagsnr'],
+ 'lang_vendor'
=> lang('Vendor'),
+ 'vendor_name'
=> $values[0]['vendor_name'],
+ 'spvend_code'
=> $values[0]['spvend_code'],
+ 'lang_fakturadato'
=> lang('invoice date'),
+ 'fakturadato'
=> $values[0]['fakturadato'],
+ 'lang_forfallsdato'
=> lang('Payment date'),
+ 'forfallsdato'
=> $values[0]['forfallsdato'],
+ 'lang_janitor'
=> lang('Janitor'),
+ 'oppsynsmannid'
=> $values[0]['oppsynsmannid'],
+ 'lang_supervisor'
=> lang('Supervisor'),
+ 'saksbehandlerid'
=> $values[0]['saksbehandlerid'],
+ 'lang_budget_responsible' =>
lang('Budget Responsible'),
+ 'budsjettansvarligid' =>
$values[0]['budsjettansvarligid'],
+ 'lang_sum'
=> lang('Sum'),
+ 'sum'
=> number_format($values[0]['amount'], 2, ',', ''),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+//_debug_array($data);
+ $appname
= lang('Invoice');
+ $function_msg =
lang('Add invoice: Debug');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('debug' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function view_order()
+ {
+ $order_id =
get_var('order_id',array('POST','GET'));
+ $soXport =
CreateObject($this->currentapp.'.soXport');
+
+ $order_type = $soXport->check_order(intval($order_id));
+ switch($order_type)
+ {
+ case 'workorder':
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.view&no_email=true&show_cost=true&workorder_id='
. $order_id);
+ break;
+ case 's_agreement':
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.view&id='
. $order_id);
+ break;
+ }
+ }
+ }
+?>
Index: property/inc/class.uilocation.inc.php
diff -u property/inc/class.uilocation.inc.php:1.16
property/inc/class.uilocation.inc.php:1.17
--- property/inc/class.uilocation.inc.php:1.16 Wed Nov 9 22:49:12 2005
+++ property/inc/class.uilocation.inc.php Fri Jan 27 14:05:43 2006
@@ -1,1513 +1,1513 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage location
- * @version $Id: class.uilocation.inc.php,v 1.16 2005/11/09 22:49:12
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uilocation
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
- var $currentapp;
-
- var $public_functions = array
- (
- 'excel' => True,
- 'index' => True,
- 'view' => True,
- 'edit' => True,
- 'delete' => True,
- 'update_cat'=> True,
- 'stop' => True,
- 'summary' => True
- );
-
- function uilocation()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bo =
CreateObject($this->currentapp.'.bolocation',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
- $this->soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
-
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
- $this->acl2_location = '.location';
- $this->acl_read =
$this->acl2->check('.location',1);
- $this->acl_add =
$this->acl2->check('.location',2);
- $this->acl_edit =
$this->acl2->check('.location',4);
- $this->acl_delete =
$this->acl2->check('.location',8);
-
- $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->type_id =
$this->bo->type_id;
- $this->allrows =
$this->bo->allrows;
-
- $this->menu->sub ='location';
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' =>
$this->filter,
- 'cat_id' =>
$this->cat_id,
- 'part_of_town_id' =>
$this->part_of_town_id,
- 'district_id' => $this->district_id,
- 'status' =>
$this->status,
- 'type_id' =>
$this->type_id,
- 'allrows' =>
$this->allrows
- );
- $this->bo->save_sessiondata($data);
- }
-
- function excel()
- {
- $summary =
get_var('summary',array('GET'));
- $type_id =
get_var('type_id',array('GET'));
- $lookup =
get_var('lookup',array('POST','GET'));
- $lookup_name =
get_var('lookup_name',array('POST','GET'));
- $lookup_tenant =
get_var('lookup_tenant',array('POST','GET'));
-
- if(!$summary)
- {
- $list =
$this->bo->read(array('type_id'=>$type_id,'lookup_tenant'=>$lookup_tenant,'lookup'=>$lookup,'allrows'=>True));
- }
- else
- {
- $list= $this->bo->read_summary();
- }
-
- $uicols = $this->bo->uicols;
-
$this->bocommon->excel($list,$uicols['name'],$uicols['descr'],$uicols['input_type']);
- }
-
-
- function index()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('location',
-
'menu',
-
'nextmatchs',
-
'search_field'));
-
- $type_id =
get_var('type_id',array('GET'));
- $lookup =
get_var('lookup',array('POST','GET'));
- $lookup_name =
get_var('lookup_name',array('POST','GET'));
- $lookup_tenant =
get_var('lookup_tenant',array('POST','GET'));
-
- if(!$type_id)
- {
- $type_id=1;
- }
- if($lookup)
- {
- $GLOBALS['phpgw_info']['flags']['noframework']
= True;
- }
- $links = $this->menu->links('location'.$type_id . '_' .
!!$lookup_tenant);
-
-
- $location_list =
$this->bo->read(array('type_id'=>$type_id,'lookup_tenant'=>$lookup_tenant,'lookup'=>$lookup,'allrows'=>$this->allrows));
-
- $uicols = $this->bo->uicols;
-//_debug_array($location_list);
-//_debug_array($uicols);
-
- $j=0;
- if (isSet($location_list) AND is_array($location_list))
- {
- foreach($location_list as $location)
- {
- for
($i=0;$i<count($uicols['name']);$i++)
- {
-
-
if($uicols['input_type'][$i]!='hidden')
- {
-
-
if($location['query_location'][$uicols['name'][$i]])
- {
-
$content[$j]['row'][$i]['statustext'] = lang('search');
-
$content[$j]['row'][$i]['text'] =
$location[$uicols['name'][$i]];
-
$content[$j]['row'][$i]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.index&query='
. $location['query_location'][$uicols['name'][$i]] . '&lookup=' . $lookup .
'&type_id=' . $type_id . '&lookup_tenant=' . $lookup_tenant . '&lookup_name=' .
$lookup_name);
- }
- else
- {
-
$content[$j]['row'][$i]['value'] =
$location[$uicols['name'][$i]];
-
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
-
$content[$j]['row'][$i]['lookup'] = $lookup;
- }
- }
-
-
$content[$j]['hidden'][$i]['value'] =
$location[$uicols['name'][$i]];
-
$content[$j]['hidden'][$i]['name'] =
$uicols['name'][$i];
- }
-
- if(!$lookup)
- {
- if($this->acl_read)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('view the
location');
-
$content[$j]['row'][$i]['text'] = lang('view');
-
$content[$j]['row'][$i]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.view&location_code='
. $location['location_code'] . '&lookup_tenant=' . $lookup_tenant);
- $i++;
- }
-
- if($this->acl_edit)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('edit the
location');
-
$content[$j]['row'][$i]['text'] = lang('edit');
-
$content[$j]['row'][$i]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.edit&location_code='
. $location['location_code'] . '&lookup_tenant=' . $lookup_tenant);
- $i++;
- }
-
- if($this->acl_delete)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('delete the
location');
-
$content[$j]['row'][$i]['text'] =
lang('delete');
-
$content[$j]['row'][$i]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.delete&location_code='
. $location['location_code'] . '&type_id=' . $type_id . '&lookup_tenant=' .
$lookup_tenant);
- }
- }
- $j++;
- }
- }
-//_debug_array($content);
-
- $uicols_count = count($uicols['descr']);
- for ($i=0;$i<$uicols_count;$i++)
- {
- if($uicols['input_type'][$i]!='hidden')
- {
- $table_header[$i]['header'] =
$uicols['descr'][$i];
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- if($uicols['name'][$i]=='loc1')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'fm_location1.loc1',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uilocation.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'district_id'
=>$this->district_id,
-
'part_of_town_id'
=>$this->part_of_town_id,
-
'lookup'
=>$lookup,
-
'lookup_tenant'
=>$lookup_tenant,
-
'lookup_name'
=>$lookup_name,
-
'cat_id'
=>$this->cat_id,
-
'status'
=> $this->status)
-
));
- }
- if($uicols['name'][$i]=='street_name')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'street_name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uilocation.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'district_id'
=>$this->district_id,
-
'part_of_town_id'
=>$this->part_of_town_id,
-
'lookup'
=>$lookup,
-
'lookup_tenant'
=>$lookup_tenant,
-
'lookup_name'
=>$lookup_name,
-
'cat_id'
=>$this->cat_id,
-
'status'
=> $this->status)
-
));
- }
- }
- }
-
- if(!$lookup)
- {
- if($this->acl_read)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('view');
- $i++;
- }
- if($this->acl_edit)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('edit');
- $i++;
- }
- if($this->acl_delete)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('delete');
- $i++;
- }
- }
- else
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('select');
- }
-
- if($this->acl_add)
- {
- $table_add[] = array
- (
- 'lang_add'
=> lang('add'),
- 'lang_add_statustext' => lang('add a
location'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.edit&type_id='
. $type_id)
- );
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uilocation.index',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'district_id'
=>$this->district_id,
- 'part_of_town_id'
=>$this->part_of_town_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query,
- 'lookup'
=>$lookup,
- 'lookup_tenant'
=>$lookup_tenant,
- 'lookup_name'
=>$lookup_name,
- 'type_id'
=>$type_id,
- 'status'
=> $this->status
- );
-
- $input_name =
$GLOBALS['phpgw']->session->appsession('lookup_fields',$this->currentapp);
-
- for ($k=0;$k<count($input_name);$k++)
- {
- $function_exchange_values .=
"opener.document.form." . $input_name[$k] . ".value = '';" ."\r\n";
- }
-
- for ($i=0;$i<count($uicols['name']);$i++)
- {
- if($uicols['exchange'][$i])
- {
- $function_exchange_values .=
'opener.document.form.' . $uicols['name'][$i] .'.value = thisform.elements[' .
$i . '].value;' ."\r\n";
- }
- }
-
- $function_exchange_values .='window.close()';
-
-//_debug_array($input_name);
- $link_excel = array
- (
- 'menuaction' =>
$this->currentapp.'.uilocation.excel',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'district_id'
=>$this->district_id,
- 'part_of_town_id'
=>$this->part_of_town_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query,
- 'lookup'
=>$lookup,
- 'lookup_tenant'
=>$lookup_tenant,
- 'lookup_name'
=>$lookup_name,
- 'type_id'
=>$type_id,
- 'status'
=> $this->status,
- 'start' =>$this->start
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
-
- $data = array
- (
- 'lang_excel' =>
'excel',
- 'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
- 'lang_excel_help' =>
lang('Download table to MS Excel'),
-
- 'exchange_values'
=> 'Exchange_values(this.form);',
- 'function_exchange_values' =>
$function_exchange_values,
- 'lang_select'
=> lang('select'),
- 'lookup'
=> $lookup,
- 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
- 'lang_property_name' =>
lang('Property name'),
- 'links'
=> $links,
- 'allow_allrows'
=> True,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($location_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
-
- 'lang_status_statustext' =>
lang('Select the status. To do not use a status select NO STATUS'),
- 'status_name'
=> 'status',
- 'lang_no_status'
=> lang('No status'),
- 'status_list'
=> $this->bo->select_status_list('filter',$this->status),
-
- 'part_of_town_list'
=> $this->bocommon->select_part_of_town('filter',$this->part_of_town_id),
- 'lang_no_part_of_town'
=> lang('no part of town'),
- 'lang_town_statustext'
=> lang('Select the part of town the selection belongs to. To do not use a part
of town select NO PART OF TOWN'),
- 'select_name_part_of_town'
=> 'part_of_town_id',
-
- 'district_list'
=> $this->bocommon->select_district_list('filter',$this->district_id),
- 'lang_no_district'
=> lang('no district'),
- 'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
- 'select_district_name' =>
'district_id',
-
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the location belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $this->bo->select_category_list('filter',$this->cat_id,$type_id),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'owner_name'
=> 'filter',
- 'owner_list'
=> $this->bo->get_owner_type_list('filter', $this->filter),
- 'lang_show_all'
=> lang('Show all'),
- 'lang_owner_statustext' =>
lang('Select the owner type. To show all entries select SHOW ALL'),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('location');
-
- if($lookup)
- {
- $lookup_list =
$GLOBALS['phpgw']->session->appsession('lookup_name',$this->currentapp);
- $function_msg
= $lookup_list[$lookup_name];
- }
- else
- {
- if($lookup_tenant)
- {
- $function_msg
= lang('Tenant');
- }
- else
- {
- $function_msg
= $uicols['descr'][($type_id-1)];
- }
- }
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
-
- }
-
- function edit()
- {
- if(!$this->acl_add && !$this->acl_edit)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
- }
-
- $get_history =
get_var('get_history',array('POST'));
- $change_type =
get_var('change_type',array('POST'));
- $lookup_tenant =
get_var('lookup_tenant',array('POST','GET'));
- $location_code =
get_var('location_code',array('POST','GET'));
- $values_attribute =
get_var('values_attribute',array('POST','GET'));
- $location = split('-',$location_code);
-
- $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
-
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp,'');
-
- if($_POST['save'])
- {
- for ($i=0;
$i<count($insert_record['location']); $i++)
- {
-
$values[$insert_record['location'][$i]]= $_POST[$insert_record['location'][$i]];
- }
-
- for ($i=0; $i<count($insert_record['extra']);
$i++)
- {
- $values[$insert_record['extra'][$i]]=
$_POST[$insert_record['extra'][$i]];
- }
- }
-
- $type_id =
get_var('type_id',array('GET'));
-
- if($location_code)
- {
- $type_id = count($location);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('location','attributes_form'));
-
- if (is_array($values) )
- {
- for ($i=1; $i<($type_id+1); $i++)
- {
- if((!$values['loc' . $i] &&
!$location[($i-1)]) || !$values['loc' . $i])
- {
-
-
$receipt['error'][]=array('msg'=>lang('Please select a location %1 ID !',$i));
- $error_id=true;
- }
-
- $values['location_code'][]=
$values['loc' . $i];
-
- if($i<$type_id)
- {
- $location_parent[]=
$values['loc' . ($i)];
- }
- }
-
- $values['location_code']=implode("-",
$values['location_code']);
-
- if($values['location_code'] && !$location_code)
- {
-
if($this->bo->check_location($values['location_code'],$type_id))
- {
-
$receipt['error'][]=array('msg'=>lang('This location is already registered!') .
'[ '.$values['location_code'].' ]');
- $error_location_id=true;
- $error_id=true;
- }
- }
-
- if($location_code)
- {
- $action='edit';
- $values['change_type'] = $change_type;
-
-
- if(!$values['change_type'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select change type'));
- }
- }
- elseif(!$location_code && !$error_id )
- {
- $location_code=$values['location_code'];
- }
-
- if(!$receipt['error'])
- {
- $receipt =
$this->bo->save($values,$values_attribute,$action,$type_id,$location_parent);
- }
- else
- {
- if($location_parent)
- {
-
$location_code_parent=implode("-", $location_parent);
- $values =
$this->bo->read_single($location_code_parent);
- }
- }
- }
-
- if(!$error_id && $location_code)
- {
- $values =
$this->bo->read_single($location_code,array('tenant_id'=>'lookup'));
- $check_history =
$this->bo->check_history($location_code);
- if($get_history)
- {
- $history =
$this->bo->get_history($location_code);
- $uicols = $this->bo->uicols;
-
- $j=0;
- if (isSet($history) AND
is_array($history))
- {
- foreach($history as $entry)
- {
- $k=0;
- for
($i=0;$i<count($uicols['name']);$i++)
- {
-
if($uicols['input_type'][$i]!='hidden')
- {
-
$content[$j]['row'][$k]['value'] =
$entry[$uicols['name'][$i]];
-
$content[$j]['row'][$k]['name'] = $uicols['name'][$i];
-
$content[$j]['row'][$k]['lookup'] = $lookup;
- }
-
-
$content[$j]['hidden'][$k]['value'] =
$entry[$uicols['name'][$i]];
-
$content[$j]['hidden'][$k]['name'] =
$uicols['name'][$i];
- $k++;
- }
- $j++;
- }
- }
-
- $uicols_count =
count($uicols['descr']);
- for ($i=0;$i<$uicols_count;$i++)
- {
-
if($uicols['input_type'][$i]!='hidden')
- {
-
$table_header[$i]['header'] = $uicols['descr'][$i];
-
$table_header[$i]['width'] = '5%';
-
$table_header[$i]['align'] = 'center';
- }
- }
- }
- }
- else
- {
- unset($values['location_code']);
- }
-
- if ($values['cat_id'] > 0)
- {
- $this->cat_id = $values['cat_id'];
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uilocation.edit',
- 'location_code' => $location_code,
- 'type_id' => $type_id,
- 'lookup_tenant' => $lookup_tenant
- );
-
- if($values['location_code'])
- {
- $lookup_type='form';
- }
- else
- {
- $lookup_type='form';
- }
-
- $location_data=$this->bo->initiate_ui_location(array(
- 'values' =>
$values,
- 'type_id' =>
($type_id-1),
- 'no_link' =>
($type_id), // disable lookup links for location type less than type_id
- 'tenant' =>
False,
- 'lookup_type' => $lookup_type
- ));
-
- $location_types = $this->bo->location_types;
- $config = $this->bo->config;
-
- if ($location_code)
- {
- $function_msg = lang('edit');
- }
- else
- {
- $function_msg = lang('add');
- }
-
- $function_msg .= ' '
.$location_types[($type_id-1)]['name'];
-
- $custom_fields =
$this->soadmin_location->read_attrib(array('type_id'=>$type_id,'allrows'=>True));
- $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
-
- if(!is_array($insert_record))
- {
- $insert_record = array();
- }
-
- $j=0;
- $additional_fields[$j]['input_text'] =
$location_types[($type_id-1)]['name'];
- $additional_fields[$j]['statustext'] =
$location_types[($type_id-1)]['descr'];
- $additional_fields[$j]['datatype'] =
'varchar';
- $additional_fields[$j]['input_name'] = 'loc' .
$type_id;
- $additional_fields[$j]['name'] = 'loc' . $type_id;
- $additional_fields[$j]['value'] =
$values[$additional_fields[$j]['input_name']];
- $additional_fields[$j]['class'] =
'th_text';
- $insert_record['extra'][]
= $additional_fields[$j]['input_name'];
-
- $j++;
- $additional_fields[$j]['input_text'] = lang('name');
- $additional_fields[$j]['statustext'] = lang('enter
the name for this location');
- $additional_fields[$j]['datatype'] =
'varchar';
- $additional_fields[$j]['input_name'] = 'loc' .
$type_id . '_name';
- $additional_fields[$j]['name'] = 'loc' . $type_id .
'_name';
- $additional_fields[$j]['value'] =
$values[$additional_fields[$j]['input_name']];
- $insert_record['extra'][]
= $additional_fields[$j]['input_name'];
- $j++;
-
-
- $contacts =
CreateObject('phpgwapi.contacts');
-
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $sep = '/';
- $dlarr[strpos($dateformat,'Y')] = 'Y';
- $dlarr[strpos($dateformat,'m')] = 'm';
- $dlarr[strpos($dateformat,'d')] = 'd';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- $input_type_array = array(
- 'R' => 'radio',
- 'CH' => 'checkbox',
- 'LB' => 'listbox'
- );
-
- $vendor = CreateObject($this->currentapp.'.soactor');
- $vendor->role = 'vendor';
-
- $r=0;
- $m=0;
- while (is_array($custom_fields) && list(,$custom) =
each($custom_fields))
- {
- $location_datatype[]= array('input_name'
=> $custom['column_name'],
- 'datatype' =>
$custom['datatype']
- );
-
- $attributes_values[$r]['id'] = $custom['id'];
- $attributes_values[$r]['input_text'] =
$custom['input_text'];
- $attributes_values[$r]['statustext'] =
$custom['statustext'];
- $attributes_values[$r]['datatype']
= $custom['datatype'];
- $attributes_values[$r]['name'] =
$custom['column_name'];
- $attributes_values[$r]['input_name'] =
$custom['column_name'];
- $attributes_values[$r]['value']
= $values[$custom['column_name']];
- if($attributes_values[$r]['datatype']=='D' &&
$attributes_values[$r]['value'])
- {
- $timestamp_date=
mktime(0,0,0,date(m,strtotime($attributes_values[$r]['value'])),date(d,strtotime($attributes_values[$r]['value'])),date(y,strtotime($attributes_values[$r]['value'])));
- $attributes_values[$r]['value'] =
$GLOBALS['phpgw']->common->show_date($timestamp_date,$dateformat);
- }
- if($attributes_values[$r]['datatype']=='AB')
- {
- if($attributes_values[$r]['value'])
- {
- $contact_data =
$contacts->read_single_entry($attributes_values[$r]['value'],array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
-
$attributes_values[$r]['contact_name'] = $contact_data[0]['n_family'] . ', ' .
$contact_data[0]['n_given'];
- }
-
- $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.addressbook&column='
. $attributes_values[$r]['name']);
-
- $functions[$m]['name'] = 'lookup_'.
$attributes_values[$r]['name'] .'()';
- $functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
- $m++;
- }
-
- if($attributes_values[$r]['datatype']=='VENDOR')
- {
- if($attributes_values[$r]['value'])
- {
- $vendor_data =
$vendor->read_single(array('actor_id'=>$attributes_values[$r]['value']));
-
- for
($n=0;$n<count($vendor_data['attributes']);$n++)
- {
-
if($vendor_data['attributes'][$n]['name'] == 'org_name')
- {
-
$attributes_values[$r]['vendor_name']= $vendor_data['attributes'][$n]['value'];
- $n
=count($vendor_data['attributes']);
- }
- }
- }
-
- $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor&column='
. $attributes_values[$r]['name']);
-
- $lookup_functions[$m]['name'] =
'lookup_'. $attributes_values[$r]['name'] .'()';
- $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
- $m++;
- }
-
-
- if($attributes_values[$r]['datatype']=='R' ||
$attributes_values[$r]['datatype']=='CH' ||
$attributes_values[$r]['datatype']=='LB')
- {
- $attributes_values[$r]['choice']
=
$this->soadmin_location->read_attrib_choice($type_id,$attributes_values[$r]['id']);
-
$input_type=$input_type_array[$attributes_values[$r]['datatype']];
-
-
if($attributes_values[$r]['datatype']=='CH')
- {
-
$attributes_values[$r]['value']=unserialize($attributes_values[$r]['value']);
-
$attributes_values[$r]['choice'] =
$this->bocommon->select_multi_list_2($attributes_values[$r]['value'],$attributes_values[$r]['choice'],$input_type);
-
- }
- else
- {
- for
($j=0;$j<count($attributes_values[$r]['choice']);$j++)
- {
-
$attributes_values[$r]['choice'][$j]['input_type']=$input_type;
-
if($attributes_values[$r]['choice'][$j]['id']==$attributes_values[$r]['value'])
- {
-
$attributes_values[$r]['choice'][$j]['checked']='checked';
- }
- }
- }
- }
-
- $attributes_values[$r]['datatype_text'] =
$this->bocommon->translate_datatype($attributes_values[$r]['datatype']);
- $attributes_values[$r]['counter'] = $r;
- $attributes_values[$r]['type_id'] =
$type_id;
- $r++;
-
- for ($j=0;$j<count($functions);$j++)
- {
- $lookup_functions .= 'function ' .
$functions[$j]['name'] ."\r\n";
- $lookup_functions .= '{'."\r\n";
- $lookup_functions .=
$functions[$j]['action'] ."\r\n";
- $lookup_functions .= '}'."\r\n";
- }
- }
-
-
$GLOBALS['phpgw']->session->appsession('location_datatype',$this->currentapp,$location_datatype);
-
- $insert_record['extra'][]
= 'cat_id';
-
- $config_count=count($config);
- for ($j=0;$j<$config_count;$j++)
- {
- if($config[$j]['location_type'] == $type_id)
- {
-
-
if($config[$j]['column_name']=='street_id')
- {
- $edit_street=True;
- $insert_record['extra'][]
= 'street_id';
- $insert_record['extra'][]
= 'street_number';
- }
-
-
if($config[$j]['column_name']=='tenant_id')
- {
- $edit_tenant=True;
- $insert_record['extra'][]
= 'tenant_id';
- }
-
-
if($config[$j]['column_name']=='part_of_town_id')
- {
- $edit_part_of_town=True;
- $select_name_part_of_town
= 'part_of_town_id';
- $part_of_town_list
=
$this->bocommon->select_part_of_town('select',$values['part_of_town_id']);
- $lang_town_statustext
= lang('Select the part of town the property belongs to. To do not use
a part of town - select NO PART OF TOWN');
- $insert_record['extra'][]
= 'part_of_town_id';
- }
-
if($config[$j]['column_name']=='owner_id')
- {
- $edit_owner=True;
- $lang_owner
= lang('Owner');
- $owner_list
= $this->bo->get_owner_list('',$values['owner_id']);
- $lang_select_owner
= lang('Select owner');
- $lang_owner_statustext
= lang('Select the owner');
- $insert_record['extra'][]
= 'owner_id';
- }
- }
- }
-
-
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp,$insert_record);
-
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- switch(substr($dateformat,0,1))
- {
- case 'M':
- $dateformat_validate=
"javascript:vDateType='1'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
- $onBlur =
"DateFormat(this,this.value,event,true,'1')";
- break;
- case 'y':
-
$dateformat_validate="javascript:vDateType='2'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
- $onBlur =
"DateFormat(this,this.value,event,true,'2')";
- break;
- case 'D':
-
$dateformat_validate="javascript:vDateType='3'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
- $onBlur =
"DateFormat(this,this.value,event,true,'3')";
- break;
- }
-
- if($receipt)
- {
- $msgbox_data =
$this->bocommon->msgbox_data($receipt);
- }
-
-
- $entities= $this->bo->read_entity_to_link();
-
- if (isset($entities) AND is_array($entities))
- {
- foreach($entities as $entity_entry)
-
- {
- $entities_link[] = array
- (
- 'entity_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.index&entity_id='
. $entity_entry['entity_id'] . '&cat_id=' . $entity_entry['cat_id'] .
'&query=' . $location_code),
- 'lang_entity_statustext'
=> $entity_entry['descr'],
- 'text_entity'
=> $entity_entry['name'],
- );
- }
- }
-
-
- if($location_code)
- {
- $change_type_list =
$this->bo->select_change_type($values['change_type']);
- }
-
- $data = array
- (
- 'lang_change_type'
=> lang('Change type'),
- 'lang_no_change_type' =>
lang('No Change type'),
- 'lang_change_type_statustext' => lang('Type
of changes'),
- 'change_type_list'
=> $change_type_list,
- 'check_history'
=> $check_history,
- 'lang_history'
=> lang('History'),
- 'lang_history_statustext' =>
lang('Fetch the history for this item'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
-
- 'lang_related_info'
=> lang('related info'),
- 'entities_link'
=> $entities_link,
- 'edit_street'
=> $edit_street,
- 'edit_tenant'
=> $edit_tenant,
- 'edit_part_of_town'
=> $edit_part_of_town,
- 'edit_owner'
=> $edit_owner,
- 'select_name_part_of_town' =>
$select_name_part_of_town,
- 'part_of_town_list'
=> $part_of_town_list,
- 'lang_town_statustext' =>
$lang_town_statustext,
- 'lang_part_of_town'
=> lang('Part of town'),
- 'lang_no_part_of_town' =>
lang('No part of town'),
- 'lang_owner'
=> $lang_owner,
- 'owner_list'
=> $owner_list,
- 'lang_select_owner'
=> $lang_select_owner,
- 'lang_owner_statustext' =>
$lang_owner_statustext,
- 'additional_fields'
=> $additional_fields,
- 'attributes_values'
=> $attributes_values,
- 'lookup_functions'
=> $lookup_functions,
- 'lang_none'
=> lang('None'),
-
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'lang_dateformat'
=> lang(strtolower($dateformat)),
- 'dateformat_validate' =>
$dateformat_validate,
- 'onKeyUp'
=> $onKeyUp,
- 'onBlur'
=> $onBlur,
- 'dateformat_source'
=> './'.$this->currentapp.'/inc/dateformat.js',
- 'street_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.street'),
- 'lang_street'
=> lang('Street'),
- 'lang_select_street_help' =>
lang('Select the street name'),
- 'lang_street_num_statustext' => lang('Enter
the street number'),
- 'value_street_id'
=> $values['street_id'],
- 'value_street_name'
=> $values['street_name'],
- 'value_street_number' =>
$values['street_number'],
-
- 'tenant_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.tenant'),
- 'lang_tenant'
=> lang('tenant'),
- 'value_tenant_id'
=> $values['tenant_id'],
- 'value_last_name'
=> $values['last_name'],
- 'value_first_name'
=> $values['first_name'],
- 'lang_tenant_statustext' =>
lang('Select a tenant'),
- 'size_last_name'
=> strlen($values['last_name']),
- 'size_first_name'
=> strlen($values['first_name']),
- 'lookup_type'
=> $lookup_type,
- 'location_data'
=> $location_data,
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.index&type_id='
. $type_id . '&lookup_tenant=' . $lookup_tenant),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'lang_save_statustext' =>
lang('Save the location'),
- 'lang_category'
=> lang('category'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the location belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $this->bo->select_category_list('select',$values['cat_id'],$type_id)
- );
-
- $appname
= lang('location');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- function delete()
- {
- if(!$this->acl_delete)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
- }
-
- $location_code =
get_var('location_code',array('GET'));
- $type_id =
get_var('type_id',array('GET',POST));
-
-
- $confirm = get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uilocation.index',
- 'type_id' =>$type_id
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($location_code);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.delete&location_code='
. $location_code . '&type_id=' . $type_id),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('location');
- $function_msg =
lang('delete location');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function view()
- {
-
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $get_history =
get_var('get_history',array('POST'));
- $lookup_tenant =
get_var('lookup_tenant',array('POST','GET'));
- $location_code =
get_var('location_code',array('POST','GET'));
- $location = split('-',$location_code);
-
- $type_id =
get_var('type_id',array('GET'));
-
- if($location_code)
- {
- $type_id = count($location);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('location','attributes_view'));
-
- $values =
$this->bo->read_single($location_code,array('tenant_id'=>'lookup'));
-
- $check_history =
$this->bo->check_history($location_code);
- if($get_history)
- {
- $history =
$this->bo->get_history($location_code);
- $uicols = $this->bo->uicols;
-
- $j=0;
- if (isSet($history) AND is_array($history))
- {
- foreach($history as $entry)
- {
- $k=0;
- for
($i=0;$i<count($uicols['name']);$i++)
- {
-
if($uicols['input_type'][$i]!='hidden')
- {
-
$content[$j]['row'][$k]['value'] =
$entry[$uicols['name'][$i]];
-
$content[$j]['row'][$k]['name'] = $uicols['name'][$i];
-
$content[$j]['row'][$k]['lookup'] = $lookup;
- }
-
-
$content[$j]['hidden'][$k]['value'] =
$entry[$uicols['name'][$i]];
-
$content[$j]['hidden'][$k]['name'] =
$uicols['name'][$i];
- $k++;
- }
- $j++;
- }
- }
-
- $uicols_count = count($uicols['descr']);
- for ($i=0;$i<$uicols_count;$i++)
- {
- if($uicols['input_type'][$i]!='hidden')
- {
- $table_header[$i]['header']
= $uicols['descr'][$i];
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- }
- }
- }
-
- $lookup_type='view';
-
- $location_data=$this->bo->initiate_ui_location(array(
- 'values' =>
$values,
- 'type_id' =>
($type_id-1),
- 'lookup_type' => $lookup_type
- ));
-
- $location_types = $this->bo->location_types;
- $config = $this->bo->config;
-
- $function_msg = lang('view');
-
- $function_msg .= ' '
.$location_types[($type_id-1)]['name'];
-
- $custom_fields =
$this->soadmin_location->read_attrib(array('type_id'=>$type_id,'allrows'=>True));
-
- $j=0;
- $additional_fields[$j]['input_text'] =
$location_types[($type_id-1)]['name'];
- $additional_fields[$j]['input_name'] = 'loc' .
$type_id;
- $additional_fields[$j]['datatype'] =
'varchar';
- $additional_fields[$j]['value'] =
$values[$additional_fields[$j]['input_name']];
- $additional_fields[$j]['class'] =
'th_text';
-
- $j++;
- $additional_fields[$j]['input_text'] = lang('name');
- $additional_fields[$j]['input_name'] = 'loc' .
$type_id . '_name';
- $additional_fields[$j]['datatype'] =
'varchar';
- $additional_fields[$j]['value'] =
$values[$additional_fields[$j]['input_name']];
- $j++;
-
-
- $contacts =
CreateObject('phpgwapi.contacts');
-
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $sep = '/';
- $dlarr[strpos($dateformat,'Y')] = 'Y';
- $dlarr[strpos($dateformat,'m')] = 'm';
- $dlarr[strpos($dateformat,'d')] = 'd';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- $input_type_array = array(
- 'R' => 'radio',
- 'CH' => 'checkbox',
- 'LB' => 'listbox'
- );
-
- $vendor = CreateObject($this->currentapp.'.soactor');
- $vendor->role = 'vendor';
-
- $r=0;
- $m=0;
-
- while (is_array($custom_fields) && list(,$custom) =
each($custom_fields))
- {
- $location_datatype[]= array('input_name'
=> $custom['column_name'],
- 'datatype' =>
$custom['datatype']
- );
-
- $attributes_values[$r]['id'] = $custom['id'];
- $attributes_values[$r]['input_text'] =
$custom['input_text'];
- $attributes_values[$r]['statustext'] =
$custom['statustext'];
- $attributes_values[$r]['datatype']
= $custom['datatype'];
- $attributes_values[$r]['name'] =
$custom['column_name'];
- $attributes_values[$r]['input_name'] =
$custom['column_name'];
- $attributes_values[$r]['value']
= $values[$custom['column_name']];
- if($attributes_values[$r]['datatype']=='D' &&
$attributes_values[$r]['value'])
- {
- $timestamp_date=
mktime(0,0,0,date(m,strtotime($attributes_values[$r]['value'])),date(d,strtotime($attributes_values[$r]['value'])),date(y,strtotime($attributes_values[$r]['value'])));
- $attributes_values[$r]['value'] =
$GLOBALS['phpgw']->common->show_date($timestamp_date,$dateformat);
- }
- if($attributes_values[$r]['datatype']=='AB')
- {
- if($attributes_values[$r]['value'])
- {
- $contact_data =
$contacts->read_single_entry($attributes_values[$r]['value'],array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
-
$attributes_values[$r]['contact_name'] = $contact_data[0]['n_family'] . ', ' .
$contact_data[0]['n_given'];
- }
-
- $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.addressbook&column='
. $attributes_values[$r]['name']);
-
- $functions[$m]['name'] = 'lookup_'.
$attributes_values[$r]['name'] .'()';
- $functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
- $m++;
- }
-
- if($attributes_values[$r]['datatype']=='VENDOR')
- {
- if($attributes_values[$r]['value'])
- {
- $vendor_data =
$vendor->read_single(array('actor_id'=>$attributes_values[$r]['value']));
-
- for
($n=0;$n<count($vendor_data['attributes']);$n++)
- {
-
if($vendor_data['attributes'][$n]['name'] == 'org_name')
- {
-
$attributes_values[$r]['vendor_name']= $vendor_data['attributes'][$n]['value'];
- $n
=count($vendor_data['attributes']);
- }
- }
- }
-
- $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor&column='
. $attributes_values[$r]['name']);
-
- $lookup_functions[$m]['name'] =
'lookup_'. $attributes_values[$r]['name'] .'()';
- $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
- $m++;
- }
-
- if($attributes_values[$r]['datatype']=='R' ||
$attributes_values[$r]['datatype']=='CH' ||
$attributes_values[$r]['datatype']=='LB')
- {
- $attributes_values[$r]['choice']
=
$this->soadmin_location->read_attrib_choice($type_id,$attributes_values[$r]['id']);
-
$input_type=$input_type_array[$attributes_values[$r]['datatype']];
-
-
if($attributes_values[$r]['datatype']=='CH')
- {
-
$attributes_values[$r]['value']=unserialize($attributes_values[$r]['value']);
-
$attributes_values[$r]['choice'] =
$this->bocommon->select_multi_list_2($attributes_values[$r]['value'],$attributes_values[$r]['choice'],$input_type);
-
- }
- else
- {
- for
($j=0;$j<count($attributes_values[$r]['choice']);$j++)
- {
-
$attributes_values[$r]['choice'][$j]['input_type']=$input_type;
-
if($attributes_values[$r]['choice'][$j]['id']==$attributes_values[$r]['value'])
- {
-
$attributes_values[$r]['choice'][$j]['checked']='checked';
- }
- }
- }
- }
-
- $attributes_values[$r]['datatype_text'] =
$this->bocommon->translate_datatype($attributes_values[$r]['datatype']);
- $r++;
- }
-
-
-// _debug_array($custom_fields);
-
- for ($j=0;$j<count($config);$j++)
- {
- if($config[$j]['location_type'] == $type_id)
- {
-
-
if($config[$j]['column_name']=='street_id')
- {
- $edit_street=True;
- $insert_record[] =
'street_id';
- }
-
-
if($config[$j]['column_name']=='tenant_id')
- {
- $edit_tenant=True;
- $insert_record[] =
'tenant_id';
- }
-
-
if($config[$j]['column_name']=='part_of_town_id')
- {
- $edit_part_of_town=True;
- $select_name_part_of_town
= 'part_of_town_id';
- $part_of_town_list
=
$this->bocommon->select_part_of_town('select',$values['part_of_town_id']);
- $lang_town_statustext
= lang('Select the part of town the property belongs to. To do not use
a part of town - select NO PART OF TOWN');
- $insert_record[] =
'part_of_town_id';
- }
-
if($config[$j]['column_name']=='owner_id')
- {
- $edit_owner=True;
- $lang_owner
= lang('Owner');
- $owner_list
= $this->bo->get_owner_list('',$values['owner_id']);
- $lang_select_owner
= lang('Select owner');
- $lang_owner_statustext
= lang('Select the owner');
- $insert_record[] =
'owner_id';
- }
- }
- }
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
-
- $entities= $this->bo->read_entity_to_link();
-
- if (isset($entities) AND is_array($entities))
- {
- foreach($entities as $entity_entry)
-
- {
- $entities_link[] = array
- (
- 'entity_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.index&entity_id='
. $entity_entry['entity_id'] . '&cat_id=' . $entity_entry['cat_id'] .
'&query=' . $location_code),
- 'lang_entity_statustext'
=> $entity_entry['descr'],
- 'text_entity'
=> $entity_entry['name'],
- );
- }
- }
-
- $change_type_list =
$this->bo->select_change_type($values['change_type']);
-
- $data = array
- (
- 'lang_change_type'
=> lang('Change type'),
- 'check_history'
=> $check_history,
- 'lang_history'
=> lang('History'),
- 'lang_history_statustext' =>
lang('Fetch the history for this item'),
- 'table_header'
=> $table_header,
- 'change_type_list'
=> $change_type_list,
- 'values'
=> $content,
-
- 'lang_related_info'
=> lang('related info'),
- 'entities_link'
=> $entities_link,
- 'edit_street'
=> $edit_street,
- 'edit_tenant'
=> $edit_tenant,
- 'edit_part_of_town'
=> $edit_part_of_town,
- 'edit_owner'
=> $edit_owner,
- 'select_name_part_of_town' =>
$select_name_part_of_town,
- 'part_of_town_list'
=> $part_of_town_list,
- 'lang_town_statustext' =>
$lang_town_statustext,
- 'lang_part_of_town'
=> lang('Part of town'),
- 'lang_no_part_of_town' =>
lang('No part of town'),
- 'lang_owner'
=> $lang_owner,
- 'owner_list'
=> $owner_list,
- 'lang_select_owner'
=> $lang_select_owner,
- 'lang_owner_statustext' =>
$lang_owner_statustext,
- 'additional_fields'
=> $additional_fields,
- 'lang_street'
=> lang('Street'),
- 'lang_select_street_help' =>
lang('Select the street name'),
- 'lang_street_num_statustext' => lang('Enter
the street number'),
- 'value_street_id'
=> $values['street_id'],
- 'value_street_name'
=> $values['street_name'],
- 'value_street_number' =>
$values['street_number'],
-
- 'attributes_view'
=> $attributes_values,
- 'dateformat'
=> $dateformat,
- 'lang_dateformat'
=> strtolower($dateformat),
- 'lang_none'
=> lang('None'),
-
- 'lang_tenant'
=> lang('tenant'),
- 'value_tenant_id'
=> $values['tenant_id'],
- 'value_last_name'
=> $values['last_name'],
- 'value_first_name'
=> $values['first_name'],
- 'lang_tenant_statustext' =>
lang('Select a tenant'),
- 'size_last_name'
=> strlen($values['last_name']),
- 'size_first_name'
=> strlen($values['first_name']),
- 'lookup_type'
=> $lookup_type,
- 'location_data'
=> $location_data,
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.index&type_id='
. $type_id . '&lookup_tenant=' . $lookup_tenant),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'lang_save_statustext' =>
lang('Save the location'),
- 'lang_edit'
=> lang('Edit'),
- 'edit_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.edit&location_code='
. $location_code . '&lookup_tenant=' . $lookup_tenant),
- 'lang_edit_statustext' => lang('Edit
this entry'),
- 'lang_category'
=> lang('category'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the location belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $this->bo->select_category_list('select',$values['cat_id'],$type_id)
- );
-
- $appname
= lang('location');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function update_cat()
- {
- $confirm = get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uilocation.index'
- );
-
- if (get_var('confirm',array('POST')))
- {
- $receipt= $this->bo->update_cat();
- $lang_confirm_msg = lang('Do you really want to
update the categories again');
- $lang_yes = lang('again');
- }
- else
- {
- $lang_confirm_msg = lang('Do you really
want to update the categories');
- $lang_yes = lang('yes');
- }
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('location'));
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php'),
- 'update_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.update_cat'),
- 'message' =>
$receipt['message'],
- 'lang_confirm_msg' =>
$lang_confirm_msg,
- 'lang_yes' =>
$lang_yes,
- 'lang_yes_statustext' => lang('Update the
category to not active based on if there is only nonactive apartments'),
- 'lang_no_statustext' => lang('Back to
Admin'),
- 'lang_no' =>
lang('no')
- );
-
- $appname = lang('location');
- $function_msg = lang('Update the not active category
for locations');
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('update_cat' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function stop()
- {
- $perm =
get_var('perm',array('POST','GET'));
- $location =
get_var('acl_location',array('POST','GET'));
-
- $right =
array(1=>'read',2=>'add',4=>'edit',8=>'delete',16=>'manage');
-
- $links = $this->menu->links();
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('location','menu'));
-
- $receipt['error'][]=array('msg'=>lang('You need the
right "%1" for this application at "%2" to access this
function',lang($right[$perm]),$location));
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'links' => $links
- );
-
- $appname = lang('Access error');
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' : ' . $appname;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('stop' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function summary()
- {
- $links = $this->menu->links('summary');
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('location','menu'));
-
- $summary_list= $this->bo->read_summary();
- $uicols = $this->bo->uicols;
-
- $j=0;
- if (isSet($summary_list) AND is_array($summary_list))
- {
- foreach($summary_list as $summary)
- {
- for
($i=0;$i<count($uicols['name']);$i++)
- {
-
$content[$j]['row'][$i]['value'] =
$summary[$uicols['name'][$i]];
- $content[$j]['row'][$i]['name']
= $summary['name'][$i];
- }
-
- $j++;
- }
- }
-
- $uicols_count = count($uicols['descr']);
- for ($i=0;$i<$uicols_count;$i++)
- {
- if($uicols['input_type'][$i]!='hidden')
- {
- $table_header[$i]['header'] =
$uicols['descr'][$i];
- $table_header[$i]['width']
= '15%';
- $table_header[$i]['align']
= 'left';
-
- }
- }
-
-
-
- $link_excel = array
- (
- 'menuaction' =>
$this->currentapp.'.uilocation.excel',
- 'district_id'
=>$this->district_id,
- 'part_of_town_id'
=>$this->part_of_town_id,
- 'filter'
=>$this->filter,
- 'type_id'
=>$type_id,
- 'summary'
=>True
- );
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uilocation.summary',
- 'district_id'
=>$this->district_id,
- 'part_of_town_id'
=>$this->part_of_town_id,
- 'filter'
=>$this->filter,
- 'type_id'
=>$type_id
- );
-
-
- $data = array
- (
- 'links'
=> $links,
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'owner_name'
=> 'filter',
- 'owner_list'
=> $this->bo->get_owner_type_list('filter', $this->filter),
- 'lang_show_all'
=> lang('Show all'),
- 'lang_owner_statustext' =>
lang('Select the owner type. To show all entries select SHOW ALL'),
- 'select_name_part_of_town' =>
'part_of_town_id',
- 'part_of_town_list'
=> $this->bocommon->select_part_of_town('filter',$this->part_of_town_id),
- 'lang_town_statustext' =>
lang('Select the part of town the property belongs to. To do not use a part of
town - select NO PART OF TOWN'),
- 'lang_no_part_of_town' =>
lang('No Part of town'),
-
- 'district_list'
=> $this->bocommon->select_district_list('filter',$this->district_id),
- 'lang_no_district'
=> lang('no district'),
- 'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
- 'select_district_name' =>
'district_id',
- 'lang_excel'
=> 'excel',
- 'link_excel'
=> $GLOBALS['phpgw']->link('/index.php',$link_excel),
- 'lang_excel_help'
=> lang('Download table to MS Excel'),
- 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
- 'table_header_summary' =>
$table_header,
- 'values'
=> $content
- );
-
-//_debug_array($data);
-
- $appname = lang('Summary');
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' : ' . $appname;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('summary' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage location
+ * @version $Id: class.uilocation.inc.php,v 1.17 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uilocation
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'excel' => True,
+ 'index' => True,
+ 'view' => True,
+ 'edit' => True,
+ 'delete' => True,
+ 'update_cat'=> True,
+ 'stop' => True,
+ 'summary' => True
+ );
+
+ function uilocation()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bo =
CreateObject($this->currentapp.'.bolocation',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+ $this->soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
+
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+ $this->acl2_location = '.location';
+ $this->acl_read =
$this->acl2->check('.location',1);
+ $this->acl_add =
$this->acl2->check('.location',2);
+ $this->acl_edit =
$this->acl2->check('.location',4);
+ $this->acl_delete =
$this->acl2->check('.location',8);
+
+ $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->type_id =
$this->bo->type_id;
+ $this->allrows =
$this->bo->allrows;
+
+ $this->menu->sub ='location';
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' =>
$this->filter,
+ 'cat_id' =>
$this->cat_id,
+ 'part_of_town_id' =>
$this->part_of_town_id,
+ 'district_id' => $this->district_id,
+ 'status' =>
$this->status,
+ 'type_id' =>
$this->type_id,
+ 'allrows' =>
$this->allrows
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function excel()
+ {
+ $summary =
get_var('summary',array('GET'));
+ $type_id =
get_var('type_id',array('GET'));
+ $lookup =
get_var('lookup',array('POST','GET'));
+ $lookup_name =
get_var('lookup_name',array('POST','GET'));
+ $lookup_tenant =
get_var('lookup_tenant',array('POST','GET'));
+
+ if(!$summary)
+ {
+ $list =
$this->bo->read(array('type_id'=>$type_id,'lookup_tenant'=>$lookup_tenant,'lookup'=>$lookup,'allrows'=>True));
+ }
+ else
+ {
+ $list= $this->bo->read_summary();
+ }
+
+ $uicols = $this->bo->uicols;
+
$this->bocommon->excel($list,$uicols['name'],$uicols['descr'],$uicols['input_type']);
+ }
+
+
+ function index()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('location',
+
'menu',
+
'nextmatchs',
+
'search_field'));
+
+ $type_id =
get_var('type_id',array('GET'));
+ $lookup =
get_var('lookup',array('POST','GET'));
+ $lookup_name =
get_var('lookup_name',array('POST','GET'));
+ $lookup_tenant =
get_var('lookup_tenant',array('POST','GET'));
+
+ if(!$type_id)
+ {
+ $type_id=1;
+ }
+ if($lookup)
+ {
+ $GLOBALS['phpgw_info']['flags']['noframework']
= True;
+ }
+ $links = $this->menu->links('location'.$type_id . '_' .
!!$lookup_tenant);
+
+
+ $location_list =
$this->bo->read(array('type_id'=>$type_id,'lookup_tenant'=>$lookup_tenant,'lookup'=>$lookup,'allrows'=>$this->allrows));
+
+ $uicols = $this->bo->uicols;
+//_debug_array($location_list);
+//_debug_array($uicols);
+
+ $j=0;
+ if (isSet($location_list) AND is_array($location_list))
+ {
+ foreach($location_list as $location)
+ {
+ for
($i=0;$i<count($uicols['name']);$i++)
+ {
+
+
if($uicols['input_type'][$i]!='hidden')
+ {
+
+
if($location['query_location'][$uicols['name'][$i]])
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('search');
+
$content[$j]['row'][$i]['text'] =
$location[$uicols['name'][$i]];
+
$content[$j]['row'][$i]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.index&query='
. $location['query_location'][$uicols['name'][$i]] . '&lookup=' . $lookup .
'&type_id=' . $type_id . '&lookup_tenant=' . $lookup_tenant . '&lookup_name=' .
$lookup_name);
+ }
+ else
+ {
+
$content[$j]['row'][$i]['value'] =
$location[$uicols['name'][$i]];
+
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
+
$content[$j]['row'][$i]['lookup'] = $lookup;
+ }
+ }
+
+
$content[$j]['hidden'][$i]['value'] =
$location[$uicols['name'][$i]];
+
$content[$j]['hidden'][$i]['name'] =
$uicols['name'][$i];
+ }
+
+ if(!$lookup)
+ {
+ if($this->acl_read)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('view the
location');
+
$content[$j]['row'][$i]['text'] = lang('view');
+
$content[$j]['row'][$i]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.view&location_code='
. $location['location_code'] . '&lookup_tenant=' . $lookup_tenant);
+ $i++;
+ }
+
+ if($this->acl_edit)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('edit the
location');
+
$content[$j]['row'][$i]['text'] = lang('edit');
+
$content[$j]['row'][$i]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.edit&location_code='
. $location['location_code'] . '&lookup_tenant=' . $lookup_tenant);
+ $i++;
+ }
+
+ if($this->acl_delete)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('delete the
location');
+
$content[$j]['row'][$i]['text'] =
lang('delete');
+
$content[$j]['row'][$i]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.delete&location_code='
. $location['location_code'] . '&type_id=' . $type_id . '&lookup_tenant=' .
$lookup_tenant);
+ }
+ }
+ $j++;
+ }
+ }
+//_debug_array($content);
+
+ $uicols_count = count($uicols['descr']);
+ for ($i=0;$i<$uicols_count;$i++)
+ {
+ if($uicols['input_type'][$i]!='hidden')
+ {
+ $table_header[$i]['header'] =
$uicols['descr'][$i];
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ if($uicols['name'][$i]=='loc1')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'fm_location1.loc1',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uilocation.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'district_id'
=>$this->district_id,
+
'part_of_town_id'
=>$this->part_of_town_id,
+
'lookup'
=>$lookup,
+
'lookup_tenant'
=>$lookup_tenant,
+
'lookup_name'
=>$lookup_name,
+
'cat_id'
=>$this->cat_id,
+
'status'
=> $this->status)
+
));
+ }
+ if($uicols['name'][$i]=='street_name')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'street_name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uilocation.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'district_id'
=>$this->district_id,
+
'part_of_town_id'
=>$this->part_of_town_id,
+
'lookup'
=>$lookup,
+
'lookup_tenant'
=>$lookup_tenant,
+
'lookup_name'
=>$lookup_name,
+
'cat_id'
=>$this->cat_id,
+
'status'
=> $this->status)
+
));
+ }
+ }
+ }
+
+ if(!$lookup)
+ {
+ if($this->acl_read)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('view');
+ $i++;
+ }
+ if($this->acl_edit)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('edit');
+ $i++;
+ }
+ if($this->acl_delete)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('delete');
+ $i++;
+ }
+ }
+ else
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('select');
+ }
+
+ if($this->acl_add)
+ {
+ $table_add[] = array
+ (
+ 'lang_add'
=> lang('add'),
+ 'lang_add_statustext' => lang('add a
location'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.edit&type_id='
. $type_id)
+ );
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uilocation.index',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'district_id'
=>$this->district_id,
+ 'part_of_town_id'
=>$this->part_of_town_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query,
+ 'lookup'
=>$lookup,
+ 'lookup_tenant'
=>$lookup_tenant,
+ 'lookup_name'
=>$lookup_name,
+ 'type_id'
=>$type_id,
+ 'status'
=> $this->status
+ );
+
+ $input_name =
$GLOBALS['phpgw']->session->appsession('lookup_fields',$this->currentapp);
+
+ for ($k=0;$k<count($input_name);$k++)
+ {
+ $function_exchange_values .=
"opener.document.form." . $input_name[$k] . ".value = '';" ."\r\n";
+ }
+
+ for ($i=0;$i<count($uicols['name']);$i++)
+ {
+ if($uicols['exchange'][$i])
+ {
+ $function_exchange_values .=
'opener.document.form.' . $uicols['name'][$i] .'.value = thisform.elements[' .
$i . '].value;' ."\r\n";
+ }
+ }
+
+ $function_exchange_values .='window.close()';
+
+//_debug_array($input_name);
+ $link_excel = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uilocation.excel',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'district_id'
=>$this->district_id,
+ 'part_of_town_id'
=>$this->part_of_town_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query,
+ 'lookup'
=>$lookup,
+ 'lookup_tenant'
=>$lookup_tenant,
+ 'lookup_name'
=>$lookup_name,
+ 'type_id'
=>$type_id,
+ 'status'
=> $this->status,
+ 'start' =>$this->start
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+
+ $data = array
+ (
+ 'lang_excel' =>
'excel',
+ 'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
+ 'lang_excel_help' =>
lang('Download table to MS Excel'),
+
+ 'exchange_values'
=> 'Exchange_values(this.form);',
+ 'function_exchange_values' =>
$function_exchange_values,
+ 'lang_select'
=> lang('select'),
+ 'lookup'
=> $lookup,
+ 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
+ 'lang_property_name' =>
lang('Property name'),
+ 'links'
=> $links,
+ 'allow_allrows'
=> True,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($location_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+
+ 'lang_status_statustext' =>
lang('Select the status. To do not use a status select NO STATUS'),
+ 'status_name'
=> 'status',
+ 'lang_no_status'
=> lang('No status'),
+ 'status_list'
=> $this->bo->select_status_list('filter',$this->status),
+
+ 'part_of_town_list'
=> $this->bocommon->select_part_of_town('filter',$this->part_of_town_id),
+ 'lang_no_part_of_town'
=> lang('no part of town'),
+ 'lang_town_statustext'
=> lang('Select the part of town the selection belongs to. To do not use a part
of town select NO PART OF TOWN'),
+ 'select_name_part_of_town'
=> 'part_of_town_id',
+
+ 'district_list'
=> $this->bocommon->select_district_list('filter',$this->district_id),
+ 'lang_no_district'
=> lang('no district'),
+ 'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
+ 'select_district_name' =>
'district_id',
+
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the location belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $this->bo->select_category_list('filter',$this->cat_id,$type_id),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'owner_name'
=> 'filter',
+ 'owner_list'
=> $this->bo->get_owner_type_list('filter', $this->filter),
+ 'lang_show_all'
=> lang('Show all'),
+ 'lang_owner_statustext' =>
lang('Select the owner type. To show all entries select SHOW ALL'),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('location');
+
+ if($lookup)
+ {
+ $lookup_list =
$GLOBALS['phpgw']->session->appsession('lookup_name',$this->currentapp);
+ $function_msg
= $lookup_list[$lookup_name];
+ }
+ else
+ {
+ if($lookup_tenant)
+ {
+ $function_msg
= lang('Tenant');
+ }
+ else
+ {
+ $function_msg
= $uicols['descr'][($type_id-1)];
+ }
+ }
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+
+ }
+
+ function edit()
+ {
+ if(!$this->acl_add && !$this->acl_edit)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
+ }
+
+ $get_history =
get_var('get_history',array('POST'));
+ $change_type =
get_var('change_type',array('POST'));
+ $lookup_tenant =
get_var('lookup_tenant',array('POST','GET'));
+ $location_code =
get_var('location_code',array('POST','GET'));
+ $values_attribute =
get_var('values_attribute',array('POST','GET'));
+ $location = split('-',$location_code);
+
+ $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
+
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp,'');
+
+ if($_POST['save'])
+ {
+ for ($i=0;
$i<count($insert_record['location']); $i++)
+ {
+
$values[$insert_record['location'][$i]]= $_POST[$insert_record['location'][$i]];
+ }
+
+ for ($i=0; $i<count($insert_record['extra']);
$i++)
+ {
+ $values[$insert_record['extra'][$i]]=
$_POST[$insert_record['extra'][$i]];
+ }
+ }
+
+ $type_id =
get_var('type_id',array('GET'));
+
+ if($location_code)
+ {
+ $type_id = count($location);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('location','attributes_form'));
+
+ if (is_array($values) )
+ {
+ for ($i=1; $i<($type_id+1); $i++)
+ {
+ if((!$values['loc' . $i] &&
!$location[($i-1)]) || !$values['loc' . $i])
+ {
+
+
$receipt['error'][]=array('msg'=>lang('Please select a location %1 ID !',$i));
+ $error_id=true;
+ }
+
+ $values['location_code'][]=
$values['loc' . $i];
+
+ if($i<$type_id)
+ {
+ $location_parent[]=
$values['loc' . ($i)];
+ }
+ }
+
+ $values['location_code']=implode("-",
$values['location_code']);
+
+ if($values['location_code'] && !$location_code)
+ {
+
if($this->bo->check_location($values['location_code'],$type_id))
+ {
+
$receipt['error'][]=array('msg'=>lang('This location is already registered!') .
'[ '.$values['location_code'].' ]');
+ $error_location_id=true;
+ $error_id=true;
+ }
+ }
+
+ if($location_code)
+ {
+ $action='edit';
+ $values['change_type'] = $change_type;
+
+
+ if(!$values['change_type'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select change type'));
+ }
+ }
+ elseif(!$location_code && !$error_id )
+ {
+ $location_code=$values['location_code'];
+ }
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$this->bo->save($values,$values_attribute,$action,$type_id,$location_parent);
+ }
+ else
+ {
+ if($location_parent)
+ {
+
$location_code_parent=implode("-", $location_parent);
+ $values =
$this->bo->read_single($location_code_parent);
+ }
+ }
+ }
+
+ if(!$error_id && $location_code)
+ {
+ $values =
$this->bo->read_single($location_code,array('tenant_id'=>'lookup'));
+ $check_history =
$this->bo->check_history($location_code);
+ if($get_history)
+ {
+ $history =
$this->bo->get_history($location_code);
+ $uicols = $this->bo->uicols;
+
+ $j=0;
+ if (isSet($history) AND
is_array($history))
+ {
+ foreach($history as $entry)
+ {
+ $k=0;
+ for
($i=0;$i<count($uicols['name']);$i++)
+ {
+
if($uicols['input_type'][$i]!='hidden')
+ {
+
$content[$j]['row'][$k]['value'] =
$entry[$uicols['name'][$i]];
+
$content[$j]['row'][$k]['name'] = $uicols['name'][$i];
+
$content[$j]['row'][$k]['lookup'] = $lookup;
+ }
+
+
$content[$j]['hidden'][$k]['value'] =
$entry[$uicols['name'][$i]];
+
$content[$j]['hidden'][$k]['name'] =
$uicols['name'][$i];
+ $k++;
+ }
+ $j++;
+ }
+ }
+
+ $uicols_count =
count($uicols['descr']);
+ for ($i=0;$i<$uicols_count;$i++)
+ {
+
if($uicols['input_type'][$i]!='hidden')
+ {
+
$table_header[$i]['header'] = $uicols['descr'][$i];
+
$table_header[$i]['width'] = '5%';
+
$table_header[$i]['align'] = 'center';
+ }
+ }
+ }
+ }
+ else
+ {
+ unset($values['location_code']);
+ }
+
+ if ($values['cat_id'] > 0)
+ {
+ $this->cat_id = $values['cat_id'];
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uilocation.edit',
+ 'location_code' => $location_code,
+ 'type_id' => $type_id,
+ 'lookup_tenant' => $lookup_tenant
+ );
+
+ if($values['location_code'])
+ {
+ $lookup_type='form';
+ }
+ else
+ {
+ $lookup_type='form';
+ }
+
+ $location_data=$this->bo->initiate_ui_location(array(
+ 'values' =>
$values,
+ 'type_id' =>
($type_id-1),
+ 'no_link' =>
($type_id), // disable lookup links for location type less than type_id
+ 'tenant' =>
False,
+ 'lookup_type' => $lookup_type
+ ));
+
+ $location_types = $this->bo->location_types;
+ $config = $this->bo->config;
+
+ if ($location_code)
+ {
+ $function_msg = lang('edit');
+ }
+ else
+ {
+ $function_msg = lang('add');
+ }
+
+ $function_msg .= ' '
.$location_types[($type_id-1)]['name'];
+
+ $custom_fields =
$this->soadmin_location->read_attrib(array('type_id'=>$type_id,'allrows'=>True));
+ $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
+
+ if(!is_array($insert_record))
+ {
+ $insert_record = array();
+ }
+
+ $j=0;
+ $additional_fields[$j]['input_text'] =
$location_types[($type_id-1)]['name'];
+ $additional_fields[$j]['statustext'] =
$location_types[($type_id-1)]['descr'];
+ $additional_fields[$j]['datatype'] =
'varchar';
+ $additional_fields[$j]['input_name'] = 'loc' .
$type_id;
+ $additional_fields[$j]['name'] = 'loc' . $type_id;
+ $additional_fields[$j]['value'] =
$values[$additional_fields[$j]['input_name']];
+ $additional_fields[$j]['class'] =
'th_text';
+ $insert_record['extra'][]
= $additional_fields[$j]['input_name'];
+
+ $j++;
+ $additional_fields[$j]['input_text'] = lang('name');
+ $additional_fields[$j]['statustext'] = lang('enter
the name for this location');
+ $additional_fields[$j]['datatype'] =
'varchar';
+ $additional_fields[$j]['input_name'] = 'loc' .
$type_id . '_name';
+ $additional_fields[$j]['name'] = 'loc' . $type_id .
'_name';
+ $additional_fields[$j]['value'] =
$values[$additional_fields[$j]['input_name']];
+ $insert_record['extra'][]
= $additional_fields[$j]['input_name'];
+ $j++;
+
+
+ $contacts =
CreateObject('phpgwapi.contacts');
+
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $sep = '/';
+ $dlarr[strpos($dateformat,'Y')] = 'Y';
+ $dlarr[strpos($dateformat,'m')] = 'm';
+ $dlarr[strpos($dateformat,'d')] = 'd';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ $input_type_array = array(
+ 'R' => 'radio',
+ 'CH' => 'checkbox',
+ 'LB' => 'listbox'
+ );
+
+ $vendor = CreateObject($this->currentapp.'.soactor');
+ $vendor->role = 'vendor';
+
+ $r=0;
+ $m=0;
+ while (is_array($custom_fields) && list(,$custom) =
each($custom_fields))
+ {
+ $location_datatype[]= array('input_name'
=> $custom['column_name'],
+ 'datatype' =>
$custom['datatype']
+ );
+
+ $attributes_values[$r]['id'] = $custom['id'];
+ $attributes_values[$r]['input_text'] =
$custom['input_text'];
+ $attributes_values[$r]['statustext'] =
$custom['statustext'];
+ $attributes_values[$r]['datatype']
= $custom['datatype'];
+ $attributes_values[$r]['name'] =
$custom['column_name'];
+ $attributes_values[$r]['input_name'] =
$custom['column_name'];
+ $attributes_values[$r]['value']
= $values[$custom['column_name']];
+ if($attributes_values[$r]['datatype']=='D' &&
$attributes_values[$r]['value'])
+ {
+ $timestamp_date=
mktime(0,0,0,date(m,strtotime($attributes_values[$r]['value'])),date(d,strtotime($attributes_values[$r]['value'])),date(y,strtotime($attributes_values[$r]['value'])));
+ $attributes_values[$r]['value'] =
$GLOBALS['phpgw']->common->show_date($timestamp_date,$dateformat);
+ }
+ if($attributes_values[$r]['datatype']=='AB')
+ {
+ if($attributes_values[$r]['value'])
+ {
+ $contact_data =
$contacts->read_single_entry($attributes_values[$r]['value'],array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
+
$attributes_values[$r]['contact_name'] = $contact_data[0]['n_family'] . ', ' .
$contact_data[0]['n_given'];
+ }
+
+ $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.addressbook&column='
. $attributes_values[$r]['name']);
+
+ $functions[$m]['name'] = 'lookup_'.
$attributes_values[$r]['name'] .'()';
+ $functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+ $m++;
+ }
+
+ if($attributes_values[$r]['datatype']=='VENDOR')
+ {
+ if($attributes_values[$r]['value'])
+ {
+ $vendor_data =
$vendor->read_single(array('actor_id'=>$attributes_values[$r]['value']));
+
+ for
($n=0;$n<count($vendor_data['attributes']);$n++)
+ {
+
if($vendor_data['attributes'][$n]['name'] == 'org_name')
+ {
+
$attributes_values[$r]['vendor_name']= $vendor_data['attributes'][$n]['value'];
+ $n
=count($vendor_data['attributes']);
+ }
+ }
+ }
+
+ $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor&column='
. $attributes_values[$r]['name']);
+
+ $lookup_functions[$m]['name'] =
'lookup_'. $attributes_values[$r]['name'] .'()';
+ $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+ $m++;
+ }
+
+
+ if($attributes_values[$r]['datatype']=='R' ||
$attributes_values[$r]['datatype']=='CH' ||
$attributes_values[$r]['datatype']=='LB')
+ {
+ $attributes_values[$r]['choice']
=
$this->soadmin_location->read_attrib_choice($type_id,$attributes_values[$r]['id']);
+
$input_type=$input_type_array[$attributes_values[$r]['datatype']];
+
+
if($attributes_values[$r]['datatype']=='CH')
+ {
+
$attributes_values[$r]['value']=unserialize($attributes_values[$r]['value']);
+
$attributes_values[$r]['choice'] =
$this->bocommon->select_multi_list_2($attributes_values[$r]['value'],$attributes_values[$r]['choice'],$input_type);
+
+ }
+ else
+ {
+ for
($j=0;$j<count($attributes_values[$r]['choice']);$j++)
+ {
+
$attributes_values[$r]['choice'][$j]['input_type']=$input_type;
+
if($attributes_values[$r]['choice'][$j]['id']==$attributes_values[$r]['value'])
+ {
+
$attributes_values[$r]['choice'][$j]['checked']='checked';
+ }
+ }
+ }
+ }
+
+ $attributes_values[$r]['datatype_text'] =
$this->bocommon->translate_datatype($attributes_values[$r]['datatype']);
+ $attributes_values[$r]['counter'] = $r;
+ $attributes_values[$r]['type_id'] =
$type_id;
+ $r++;
+
+ for ($j=0;$j<count($functions);$j++)
+ {
+ $lookup_functions .= 'function ' .
$functions[$j]['name'] ."\r\n";
+ $lookup_functions .= '{'."\r\n";
+ $lookup_functions .=
$functions[$j]['action'] ."\r\n";
+ $lookup_functions .= '}'."\r\n";
+ }
+ }
+
+
$GLOBALS['phpgw']->session->appsession('location_datatype',$this->currentapp,$location_datatype);
+
+ $insert_record['extra'][]
= 'cat_id';
+
+ $config_count=count($config);
+ for ($j=0;$j<$config_count;$j++)
+ {
+ if($config[$j]['location_type'] == $type_id)
+ {
+
+
if($config[$j]['column_name']=='street_id')
+ {
+ $edit_street=True;
+ $insert_record['extra'][]
= 'street_id';
+ $insert_record['extra'][]
= 'street_number';
+ }
+
+
if($config[$j]['column_name']=='tenant_id')
+ {
+ $edit_tenant=True;
+ $insert_record['extra'][]
= 'tenant_id';
+ }
+
+
if($config[$j]['column_name']=='part_of_town_id')
+ {
+ $edit_part_of_town=True;
+ $select_name_part_of_town
= 'part_of_town_id';
+ $part_of_town_list
=
$this->bocommon->select_part_of_town('select',$values['part_of_town_id']);
+ $lang_town_statustext
= lang('Select the part of town the property belongs to. To do not use
a part of town - select NO PART OF TOWN');
+ $insert_record['extra'][]
= 'part_of_town_id';
+ }
+
if($config[$j]['column_name']=='owner_id')
+ {
+ $edit_owner=True;
+ $lang_owner
= lang('Owner');
+ $owner_list
= $this->bo->get_owner_list('',$values['owner_id']);
+ $lang_select_owner
= lang('Select owner');
+ $lang_owner_statustext
= lang('Select the owner');
+ $insert_record['extra'][]
= 'owner_id';
+ }
+ }
+ }
+
+
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp,$insert_record);
+
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ switch(substr($dateformat,0,1))
+ {
+ case 'M':
+ $dateformat_validate=
"javascript:vDateType='1'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'1')";
+ break;
+ case 'y':
+
$dateformat_validate="javascript:vDateType='2'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'2')";
+ break;
+ case 'D':
+
$dateformat_validate="javascript:vDateType='3'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'3')";
+ break;
+ }
+
+ if($receipt)
+ {
+ $msgbox_data =
$this->bocommon->msgbox_data($receipt);
+ }
+
+
+ $entities= $this->bo->read_entity_to_link();
+
+ if (isset($entities) AND is_array($entities))
+ {
+ foreach($entities as $entity_entry)
+
+ {
+ $entities_link[] = array
+ (
+ 'entity_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.index&entity_id='
. $entity_entry['entity_id'] . '&cat_id=' . $entity_entry['cat_id'] .
'&query=' . $location_code),
+ 'lang_entity_statustext'
=> $entity_entry['descr'],
+ 'text_entity'
=> $entity_entry['name'],
+ );
+ }
+ }
+
+
+ if($location_code)
+ {
+ $change_type_list =
$this->bo->select_change_type($values['change_type']);
+ }
+
+ $data = array
+ (
+ 'lang_change_type'
=> lang('Change type'),
+ 'lang_no_change_type' =>
lang('No Change type'),
+ 'lang_change_type_statustext' => lang('Type
of changes'),
+ 'change_type_list'
=> $change_type_list,
+ 'check_history'
=> $check_history,
+ 'lang_history'
=> lang('History'),
+ 'lang_history_statustext' =>
lang('Fetch the history for this item'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+
+ 'lang_related_info'
=> lang('related info'),
+ 'entities_link'
=> $entities_link,
+ 'edit_street'
=> $edit_street,
+ 'edit_tenant'
=> $edit_tenant,
+ 'edit_part_of_town'
=> $edit_part_of_town,
+ 'edit_owner'
=> $edit_owner,
+ 'select_name_part_of_town' =>
$select_name_part_of_town,
+ 'part_of_town_list'
=> $part_of_town_list,
+ 'lang_town_statustext' =>
$lang_town_statustext,
+ 'lang_part_of_town'
=> lang('Part of town'),
+ 'lang_no_part_of_town' =>
lang('No part of town'),
+ 'lang_owner'
=> $lang_owner,
+ 'owner_list'
=> $owner_list,
+ 'lang_select_owner'
=> $lang_select_owner,
+ 'lang_owner_statustext' =>
$lang_owner_statustext,
+ 'additional_fields'
=> $additional_fields,
+ 'attributes_values'
=> $attributes_values,
+ 'lookup_functions'
=> $lookup_functions,
+ 'lang_none'
=> lang('None'),
+
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'lang_dateformat'
=> lang(strtolower($dateformat)),
+ 'dateformat_validate' =>
$dateformat_validate,
+ 'onKeyUp'
=> $onKeyUp,
+ 'onBlur'
=> $onBlur,
+ 'dateformat_source'
=> './'.$this->currentapp.'/inc/dateformat.js',
+ 'street_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.street'),
+ 'lang_street'
=> lang('Street'),
+ 'lang_select_street_help' =>
lang('Select the street name'),
+ 'lang_street_num_statustext' => lang('Enter
the street number'),
+ 'value_street_id'
=> $values['street_id'],
+ 'value_street_name'
=> $values['street_name'],
+ 'value_street_number' =>
$values['street_number'],
+
+ 'tenant_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.tenant'),
+ 'lang_tenant'
=> lang('tenant'),
+ 'value_tenant_id'
=> $values['tenant_id'],
+ 'value_last_name'
=> $values['last_name'],
+ 'value_first_name'
=> $values['first_name'],
+ 'lang_tenant_statustext' =>
lang('Select a tenant'),
+ 'size_last_name'
=> strlen($values['last_name']),
+ 'size_first_name'
=> strlen($values['first_name']),
+ 'lookup_type'
=> $lookup_type,
+ 'location_data'
=> $location_data,
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.index&type_id='
. $type_id . '&lookup_tenant=' . $lookup_tenant),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'lang_save_statustext' =>
lang('Save the location'),
+ 'lang_category'
=> lang('category'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the location belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $this->bo->select_category_list('select',$values['cat_id'],$type_id)
+ );
+
+ $appname
= lang('location');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ function delete()
+ {
+ if(!$this->acl_delete)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
+ }
+
+ $location_code =
get_var('location_code',array('GET'));
+ $type_id =
get_var('type_id',array('GET',POST));
+
+
+ $confirm = get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uilocation.index',
+ 'type_id' =>$type_id
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($location_code);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.delete&location_code='
. $location_code . '&type_id=' . $type_id),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('location');
+ $function_msg =
lang('delete location');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function view()
+ {
+
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $get_history =
get_var('get_history',array('POST'));
+ $lookup_tenant =
get_var('lookup_tenant',array('POST','GET'));
+ $location_code =
get_var('location_code',array('POST','GET'));
+ $location = split('-',$location_code);
+
+ $type_id =
get_var('type_id',array('GET'));
+
+ if($location_code)
+ {
+ $type_id = count($location);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('location','attributes_view'));
+
+ $values =
$this->bo->read_single($location_code,array('tenant_id'=>'lookup'));
+
+ $check_history =
$this->bo->check_history($location_code);
+ if($get_history)
+ {
+ $history =
$this->bo->get_history($location_code);
+ $uicols = $this->bo->uicols;
+
+ $j=0;
+ if (isSet($history) AND is_array($history))
+ {
+ foreach($history as $entry)
+ {
+ $k=0;
+ for
($i=0;$i<count($uicols['name']);$i++)
+ {
+
if($uicols['input_type'][$i]!='hidden')
+ {
+
$content[$j]['row'][$k]['value'] =
$entry[$uicols['name'][$i]];
+
$content[$j]['row'][$k]['name'] = $uicols['name'][$i];
+
$content[$j]['row'][$k]['lookup'] = $lookup;
+ }
+
+
$content[$j]['hidden'][$k]['value'] =
$entry[$uicols['name'][$i]];
+
$content[$j]['hidden'][$k]['name'] =
$uicols['name'][$i];
+ $k++;
+ }
+ $j++;
+ }
+ }
+
+ $uicols_count = count($uicols['descr']);
+ for ($i=0;$i<$uicols_count;$i++)
+ {
+ if($uicols['input_type'][$i]!='hidden')
+ {
+ $table_header[$i]['header']
= $uicols['descr'][$i];
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ }
+ }
+ }
+
+ $lookup_type='view';
+
+ $location_data=$this->bo->initiate_ui_location(array(
+ 'values' =>
$values,
+ 'type_id' =>
($type_id-1),
+ 'lookup_type' => $lookup_type
+ ));
+
+ $location_types = $this->bo->location_types;
+ $config = $this->bo->config;
+
+ $function_msg = lang('view');
+
+ $function_msg .= ' '
.$location_types[($type_id-1)]['name'];
+
+ $custom_fields =
$this->soadmin_location->read_attrib(array('type_id'=>$type_id,'allrows'=>True));
+
+ $j=0;
+ $additional_fields[$j]['input_text'] =
$location_types[($type_id-1)]['name'];
+ $additional_fields[$j]['input_name'] = 'loc' .
$type_id;
+ $additional_fields[$j]['datatype'] =
'varchar';
+ $additional_fields[$j]['value'] =
$values[$additional_fields[$j]['input_name']];
+ $additional_fields[$j]['class'] =
'th_text';
+
+ $j++;
+ $additional_fields[$j]['input_text'] = lang('name');
+ $additional_fields[$j]['input_name'] = 'loc' .
$type_id . '_name';
+ $additional_fields[$j]['datatype'] =
'varchar';
+ $additional_fields[$j]['value'] =
$values[$additional_fields[$j]['input_name']];
+ $j++;
+
+
+ $contacts =
CreateObject('phpgwapi.contacts');
+
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $sep = '/';
+ $dlarr[strpos($dateformat,'Y')] = 'Y';
+ $dlarr[strpos($dateformat,'m')] = 'm';
+ $dlarr[strpos($dateformat,'d')] = 'd';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ $input_type_array = array(
+ 'R' => 'radio',
+ 'CH' => 'checkbox',
+ 'LB' => 'listbox'
+ );
+
+ $vendor = CreateObject($this->currentapp.'.soactor');
+ $vendor->role = 'vendor';
+
+ $r=0;
+ $m=0;
+
+ while (is_array($custom_fields) && list(,$custom) =
each($custom_fields))
+ {
+ $location_datatype[]= array('input_name'
=> $custom['column_name'],
+ 'datatype' =>
$custom['datatype']
+ );
+
+ $attributes_values[$r]['id'] = $custom['id'];
+ $attributes_values[$r]['input_text'] =
$custom['input_text'];
+ $attributes_values[$r]['statustext'] =
$custom['statustext'];
+ $attributes_values[$r]['datatype']
= $custom['datatype'];
+ $attributes_values[$r]['name'] =
$custom['column_name'];
+ $attributes_values[$r]['input_name'] =
$custom['column_name'];
+ $attributes_values[$r]['value']
= $values[$custom['column_name']];
+ if($attributes_values[$r]['datatype']=='D' &&
$attributes_values[$r]['value'])
+ {
+ $timestamp_date=
mktime(0,0,0,date(m,strtotime($attributes_values[$r]['value'])),date(d,strtotime($attributes_values[$r]['value'])),date(y,strtotime($attributes_values[$r]['value'])));
+ $attributes_values[$r]['value'] =
$GLOBALS['phpgw']->common->show_date($timestamp_date,$dateformat);
+ }
+ if($attributes_values[$r]['datatype']=='AB')
+ {
+ if($attributes_values[$r]['value'])
+ {
+ $contact_data =
$contacts->read_single_entry($attributes_values[$r]['value'],array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
+
$attributes_values[$r]['contact_name'] = $contact_data[0]['n_family'] . ', ' .
$contact_data[0]['n_given'];
+ }
+
+ $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.addressbook&column='
. $attributes_values[$r]['name']);
+
+ $functions[$m]['name'] = 'lookup_'.
$attributes_values[$r]['name'] .'()';
+ $functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+ $m++;
+ }
+
+ if($attributes_values[$r]['datatype']=='VENDOR')
+ {
+ if($attributes_values[$r]['value'])
+ {
+ $vendor_data =
$vendor->read_single(array('actor_id'=>$attributes_values[$r]['value']));
+
+ for
($n=0;$n<count($vendor_data['attributes']);$n++)
+ {
+
if($vendor_data['attributes'][$n]['name'] == 'org_name')
+ {
+
$attributes_values[$r]['vendor_name']= $vendor_data['attributes'][$n]['value'];
+ $n
=count($vendor_data['attributes']);
+ }
+ }
+ }
+
+ $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor&column='
. $attributes_values[$r]['name']);
+
+ $lookup_functions[$m]['name'] =
'lookup_'. $attributes_values[$r]['name'] .'()';
+ $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+ $m++;
+ }
+
+ if($attributes_values[$r]['datatype']=='R' ||
$attributes_values[$r]['datatype']=='CH' ||
$attributes_values[$r]['datatype']=='LB')
+ {
+ $attributes_values[$r]['choice']
=
$this->soadmin_location->read_attrib_choice($type_id,$attributes_values[$r]['id']);
+
$input_type=$input_type_array[$attributes_values[$r]['datatype']];
+
+
if($attributes_values[$r]['datatype']=='CH')
+ {
+
$attributes_values[$r]['value']=unserialize($attributes_values[$r]['value']);
+
$attributes_values[$r]['choice'] =
$this->bocommon->select_multi_list_2($attributes_values[$r]['value'],$attributes_values[$r]['choice'],$input_type);
+
+ }
+ else
+ {
+ for
($j=0;$j<count($attributes_values[$r]['choice']);$j++)
+ {
+
$attributes_values[$r]['choice'][$j]['input_type']=$input_type;
+
if($attributes_values[$r]['choice'][$j]['id']==$attributes_values[$r]['value'])
+ {
+
$attributes_values[$r]['choice'][$j]['checked']='checked';
+ }
+ }
+ }
+ }
+
+ $attributes_values[$r]['datatype_text'] =
$this->bocommon->translate_datatype($attributes_values[$r]['datatype']);
+ $r++;
+ }
+
+
+// _debug_array($custom_fields);
+
+ for ($j=0;$j<count($config);$j++)
+ {
+ if($config[$j]['location_type'] == $type_id)
+ {
+
+
if($config[$j]['column_name']=='street_id')
+ {
+ $edit_street=True;
+ $insert_record[] =
'street_id';
+ }
+
+
if($config[$j]['column_name']=='tenant_id')
+ {
+ $edit_tenant=True;
+ $insert_record[] =
'tenant_id';
+ }
+
+
if($config[$j]['column_name']=='part_of_town_id')
+ {
+ $edit_part_of_town=True;
+ $select_name_part_of_town
= 'part_of_town_id';
+ $part_of_town_list
=
$this->bocommon->select_part_of_town('select',$values['part_of_town_id']);
+ $lang_town_statustext
= lang('Select the part of town the property belongs to. To do not use
a part of town - select NO PART OF TOWN');
+ $insert_record[] =
'part_of_town_id';
+ }
+
if($config[$j]['column_name']=='owner_id')
+ {
+ $edit_owner=True;
+ $lang_owner
= lang('Owner');
+ $owner_list
= $this->bo->get_owner_list('',$values['owner_id']);
+ $lang_select_owner
= lang('Select owner');
+ $lang_owner_statustext
= lang('Select the owner');
+ $insert_record[] =
'owner_id';
+ }
+ }
+ }
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+
+ $entities= $this->bo->read_entity_to_link();
+
+ if (isset($entities) AND is_array($entities))
+ {
+ foreach($entities as $entity_entry)
+
+ {
+ $entities_link[] = array
+ (
+ 'entity_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.index&entity_id='
. $entity_entry['entity_id'] . '&cat_id=' . $entity_entry['cat_id'] .
'&query=' . $location_code),
+ 'lang_entity_statustext'
=> $entity_entry['descr'],
+ 'text_entity'
=> $entity_entry['name'],
+ );
+ }
+ }
+
+ $change_type_list =
$this->bo->select_change_type($values['change_type']);
+
+ $data = array
+ (
+ 'lang_change_type'
=> lang('Change type'),
+ 'check_history'
=> $check_history,
+ 'lang_history'
=> lang('History'),
+ 'lang_history_statustext' =>
lang('Fetch the history for this item'),
+ 'table_header'
=> $table_header,
+ 'change_type_list'
=> $change_type_list,
+ 'values'
=> $content,
+
+ 'lang_related_info'
=> lang('related info'),
+ 'entities_link'
=> $entities_link,
+ 'edit_street'
=> $edit_street,
+ 'edit_tenant'
=> $edit_tenant,
+ 'edit_part_of_town'
=> $edit_part_of_town,
+ 'edit_owner'
=> $edit_owner,
+ 'select_name_part_of_town' =>
$select_name_part_of_town,
+ 'part_of_town_list'
=> $part_of_town_list,
+ 'lang_town_statustext' =>
$lang_town_statustext,
+ 'lang_part_of_town'
=> lang('Part of town'),
+ 'lang_no_part_of_town' =>
lang('No part of town'),
+ 'lang_owner'
=> $lang_owner,
+ 'owner_list'
=> $owner_list,
+ 'lang_select_owner'
=> $lang_select_owner,
+ 'lang_owner_statustext' =>
$lang_owner_statustext,
+ 'additional_fields'
=> $additional_fields,
+ 'lang_street'
=> lang('Street'),
+ 'lang_select_street_help' =>
lang('Select the street name'),
+ 'lang_street_num_statustext' => lang('Enter
the street number'),
+ 'value_street_id'
=> $values['street_id'],
+ 'value_street_name'
=> $values['street_name'],
+ 'value_street_number' =>
$values['street_number'],
+
+ 'attributes_view'
=> $attributes_values,
+ 'dateformat'
=> $dateformat,
+ 'lang_dateformat'
=> strtolower($dateformat),
+ 'lang_none'
=> lang('None'),
+
+ 'lang_tenant'
=> lang('tenant'),
+ 'value_tenant_id'
=> $values['tenant_id'],
+ 'value_last_name'
=> $values['last_name'],
+ 'value_first_name'
=> $values['first_name'],
+ 'lang_tenant_statustext' =>
lang('Select a tenant'),
+ 'size_last_name'
=> strlen($values['last_name']),
+ 'size_first_name'
=> strlen($values['first_name']),
+ 'lookup_type'
=> $lookup_type,
+ 'location_data'
=> $location_data,
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.index&type_id='
. $type_id . '&lookup_tenant=' . $lookup_tenant),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'lang_save_statustext' =>
lang('Save the location'),
+ 'lang_edit'
=> lang('Edit'),
+ 'edit_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.edit&location_code='
. $location_code . '&lookup_tenant=' . $lookup_tenant),
+ 'lang_edit_statustext' => lang('Edit
this entry'),
+ 'lang_category'
=> lang('category'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the location belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $this->bo->select_category_list('select',$values['cat_id'],$type_id)
+ );
+
+ $appname
= lang('location');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function update_cat()
+ {
+ $confirm = get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uilocation.index'
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $receipt= $this->bo->update_cat();
+ $lang_confirm_msg = lang('Do you really want to
update the categories again');
+ $lang_yes = lang('again');
+ }
+ else
+ {
+ $lang_confirm_msg = lang('Do you really
want to update the categories');
+ $lang_yes = lang('yes');
+ }
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('location'));
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php'),
+ 'update_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.update_cat'),
+ 'message' =>
$receipt['message'],
+ 'lang_confirm_msg' =>
$lang_confirm_msg,
+ 'lang_yes' =>
$lang_yes,
+ 'lang_yes_statustext' => lang('Update the
category to not active based on if there is only nonactive apartments'),
+ 'lang_no_statustext' => lang('Back to
Admin'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname = lang('location');
+ $function_msg = lang('Update the not active category
for locations');
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('update_cat' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function stop()
+ {
+ $perm =
get_var('perm',array('POST','GET'));
+ $location =
get_var('acl_location',array('POST','GET'));
+
+ $right =
array(1=>'read',2=>'add',4=>'edit',8=>'delete',16=>'manage');
+
+ $links = $this->menu->links();
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('location','menu'));
+
+ $receipt['error'][]=array('msg'=>lang('You need the
right "%1" for this application at "%2" to access this
function',lang($right[$perm]),$location));
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'links' => $links
+ );
+
+ $appname = lang('Access error');
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' : ' . $appname;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('stop' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function summary()
+ {
+ $links = $this->menu->links('summary');
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('location','menu'));
+
+ $summary_list= $this->bo->read_summary();
+ $uicols = $this->bo->uicols;
+
+ $j=0;
+ if (isSet($summary_list) AND is_array($summary_list))
+ {
+ foreach($summary_list as $summary)
+ {
+ for
($i=0;$i<count($uicols['name']);$i++)
+ {
+
$content[$j]['row'][$i]['value'] =
$summary[$uicols['name'][$i]];
+ $content[$j]['row'][$i]['name']
= $summary['name'][$i];
+ }
+
+ $j++;
+ }
+ }
+
+ $uicols_count = count($uicols['descr']);
+ for ($i=0;$i<$uicols_count;$i++)
+ {
+ if($uicols['input_type'][$i]!='hidden')
+ {
+ $table_header[$i]['header'] =
$uicols['descr'][$i];
+ $table_header[$i]['width']
= '15%';
+ $table_header[$i]['align']
= 'left';
+
+ }
+ }
+
+
+
+ $link_excel = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uilocation.excel',
+ 'district_id'
=>$this->district_id,
+ 'part_of_town_id'
=>$this->part_of_town_id,
+ 'filter'
=>$this->filter,
+ 'type_id'
=>$type_id,
+ 'summary'
=>True
+ );
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uilocation.summary',
+ 'district_id'
=>$this->district_id,
+ 'part_of_town_id'
=>$this->part_of_town_id,
+ 'filter'
=>$this->filter,
+ 'type_id'
=>$type_id
+ );
+
+
+ $data = array
+ (
+ 'links'
=> $links,
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'owner_name'
=> 'filter',
+ 'owner_list'
=> $this->bo->get_owner_type_list('filter', $this->filter),
+ 'lang_show_all'
=> lang('Show all'),
+ 'lang_owner_statustext' =>
lang('Select the owner type. To show all entries select SHOW ALL'),
+ 'select_name_part_of_town' =>
'part_of_town_id',
+ 'part_of_town_list'
=> $this->bocommon->select_part_of_town('filter',$this->part_of_town_id),
+ 'lang_town_statustext' =>
lang('Select the part of town the property belongs to. To do not use a part of
town - select NO PART OF TOWN'),
+ 'lang_no_part_of_town' =>
lang('No Part of town'),
+
+ 'district_list'
=> $this->bocommon->select_district_list('filter',$this->district_id),
+ 'lang_no_district'
=> lang('no district'),
+ 'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
+ 'select_district_name' =>
'district_id',
+ 'lang_excel'
=> 'excel',
+ 'link_excel'
=> $GLOBALS['phpgw']->link('/index.php',$link_excel),
+ 'lang_excel_help'
=> lang('Download table to MS Excel'),
+ 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
+ 'table_header_summary' =>
$table_header,
+ 'values'
=> $content
+ );
+
+//_debug_array($data);
+
+ $appname = lang('Summary');
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' : ' . $appname;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('summary' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+ }
+?>
Index: property/inc/class.uilookup.inc.php
diff -u property/inc/class.uilookup.inc.php:1.11
property/inc/class.uilookup.inc.php:1.12
--- property/inc/class.uilookup.inc.php:1.11 Thu May 12 21:26:28 2005
+++ property/inc/class.uilookup.inc.php Fri Jan 27 14:05:43 2006
@@ -1,901 +1,901 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage core
- * @version $Id: class.uilookup.inc.php,v 1.11 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uilookup
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
- var $part_of_town_id;
- var $district_id;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'addressbook' => True,
- 'vendor' => True,
- 'b_account' => True,
- 'location' => True,
- 'entity' => True,
- 'ns3420' => True,
- 'street' => True,
- 'tenant' => True
- );
-
- function uilookup()
- {
- $GLOBALS['phpgw_info']['flags']['noframework'] = True;
- $GLOBALS['phpgw_info']['flags']['headonly']=true;
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->bo =
CreateObject($this->currentapp.'.bolookup',True);
-
- $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;
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' =>
$this->filter,
- 'cat_id' =>
$this->cat_id,
- 'part_of_town_id' =>
$this->part_of_town_id,
- 'district_id' => $this->district_id
- );
- $this->bo->save_sessiondata($data);
- }
-
- function addressbook()
- {
-
- $this->cats =
CreateObject('phpgwapi.categories');
- $this->cats->app_name = 'addressbook';
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('lookup',
-
'nextmatchs',
-
'search_field',
-
'cat_filter'));
-
- $second_display =
get_var('second_display',array('POST','GET'));
- $column = get_var('column',array('POST','GET'));
-
-
- $default_category =
$GLOBALS['phpgw_info']['user']['preferences']['addressbook']['default_category'];
-
- if ($default_category && !$second_display)
- {
- $this->bo->cat_id = $default_category;
- $this->cat_id = $default_category;
- }
-
- $addressbook_list = $this->bo->read_addressbook();
-
- while (is_array($addressbook_list) &&
list(,$addressbook_entry) = each($addressbook_list))
- {
- $content[] = array
- (
- 'id' =>
$addressbook_entry['contact_id'],
- 'contact_name' =>
$addressbook_entry['per_last_name'] . ', ' .
$addressbook_entry['per_first_name'],
- 'lang_select' =>
lang('Select'),
- 'lang_select_statustext' =>
lang('Select this contact')
- );
- }
-
- $table_header[] = array
- (
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'last_name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.addressbook',
-
'cat_id' =>
$this->cat_id,
-
'column' =>
$column)
-
)),
- 'lang_name' => lang('Name'),
- 'sort_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'person_id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.addressbook',
-
'cat_id'
=>$this->cat_id,
-
'column' =>
$column)
-
)),
- 'lang_id' => lang('ID'),
- 'lang_select' => lang('Select')
- );
-
- $table_done[] = array
- (
- 'lang_done' =>
lang('Done'),
- 'lang_done_statustext' => lang('Close this
window')
- );
-
- $link_select = array
- (
- 'menuaction' =>
$this->currentapp.'.uilookup.addressbook',
- 'second_display' => true,
- 'order' => $this->order,
- 'sort' => $this->sort,
- 'cat_id' =>
$this->cat_id,
- 'query' => $this->query,
- 'filter' =>
$this->filter,
- 'column' => $column
- );
-
- if($column)
- {
- $contact_id =$column;
- $contact_name =$column . '_name';
- }
- else
- {
- $contact_id ='contact_id';
- $contact_name ='contact_name';
- }
-
- $cat_data =
$this->cats->formatted_xslt_list(array('selected' => $this->cat_id,'globals' =>
True, 'link_data' =>$link_select));
- $data = array
- (
- 'allow_allrows'
=> false,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($addressbook_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the building belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $cat_data['cat_list'],
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
- 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' =>
'yes')),
- 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_contact' =>
$table_header,
- 'values_contact'
=> $content,
- 'table_done'
=> $table_done,
- 'contact_id'
=> $contact_id,
- 'contact_name'
=> $contact_name
- );
-
- $appname
= lang('addressbook');
- $function_msg =
lang('list vendors');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_contact' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function vendor()
- {
-
- $this->cats =
CreateObject('phpgwapi.categories');
- $this->cats->app_name = 'fm_vendor';
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('lookup',
-
'nextmatchs',
-
'search_field',
-
'cat_filter'));
-
- $second_display =
get_var('second_display',array('POST','GET'));
- $column = get_var('column',array('POST','GET'));
-
-
- $default_category =
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['default_vendor_category'];
-
- if ($default_category && !$second_display)
- {
- $this->bo->cat_id = $default_category;
- $this->cat_id = $default_category;
- }
-
- $vendor_list = $this->bo->read_vendor();
-
- while (is_array($vendor_list) && list(,$vendor_entry) =
each($vendor_list))
- {
- $content[] = array
- (
- 'id' =>
$vendor_entry['id'],
- 'vendor_name' =>
$vendor_entry['org_name'],
- 'lang_select' =>
lang('Select'),
- 'lang_select_statustext' =>
lang('Select this vendor')
- );
- }
-
- $table_header[] = array
- (
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'org_name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.vendor',
-
'cat_id' =>
$this->cat_id,
-
'column' =>
$column)
-
)),
- 'lang_name' => lang('Name'),
- 'sort_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.vendor',
-
'cat_id'
=>$this->cat_id,
-
'column' =>
$column)
-
)),
- 'lang_id' => lang('ID'),
- 'lang_select' => lang('Select')
- );
-
- $table_done[] = array
- (
- 'lang_done' =>
lang('Done'),
- 'lang_done_statustext' => lang('Close this
window')
- );
-
- $link_select = array
- (
- 'menuaction' =>
$this->currentapp.'.uilookup.vendor',
- 'second_display' => true,
- 'order' => $this->order,
- 'sort' => $this->sort,
- 'cat_id' =>
$this->cat_id,
- 'query' => $this->query,
- 'filter' =>
$this->filter,
- 'column' => $column
- );
-
- if($column)
- {
- $contact_id =$column;
- $org_name =$column . '_org_name';
- }
- else
- {
- $contact_id ='vendor_id';
- $org_name ='vendor_name';
- }
-
- $cat_data =
$this->cats->formatted_xslt_list(array('selected' => $this->cat_id,'globals' =>
True, 'link_data' =>$link_select));
- $data = array
- (
- 'allow_allrows'
=> false,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($vendor_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the building belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $cat_data['cat_list'],
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
- 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' =>
'yes')),
- 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_vendor' =>
$table_header,
- 'values_vendor'
=> $content,
- 'table_done'
=> $table_done,
- 'contact_id'
=> $contact_id,
- 'org_name'
=> $org_name
- );
-
- $appname
= lang('vendor');
- $function_msg =
lang('list vendors');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_vendor' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function b_account()
- {
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('lookup',
-
'nextmatchs',
-
'search_field'));
-
- $b_account_list = $this->bo->read_b_account();
-
- while (is_array($b_account_list) &&
list(,$b_account_entry) = each($b_account_list))
- {
- $content[] = array
- (
- 'id' =>
$b_account_entry['id'],
- 'b_account_name' =>
$b_account_entry['descr'],
- 'lang_select' =>
lang('Select'),
- 'lang_select_statustext' =>
lang('Select this budget account')
- );
- }
-
- $table_header[] = array
- (
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'descr',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.b_account',
-
'cat_id'
=>$this->cat_id)
-
)),
- 'lang_name' => lang('Name'),
- 'sort_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.b_account',
-
'cat_id'
=>$this->cat_id)
-
)),
- 'lang_id' => lang('ID'),
- 'lang_select' => lang('Select')
- );
-
- $table_done[] = array
- (
- 'lang_done' =>
lang('Done'),
- 'lang_done_statustext' => lang('Close this
window')
- );
-
- $link_select = array
- (
- 'menuaction' =>
$this->currentapp.'.uilookup.b_account',
- 'second_display' => true,
- 'order' => $this->order,
- 'sort' => $this->sort,
- 'cat_id' =>
$this->cat_id,
- 'query' => $this->query,
- 'filter' => $this->filter
- );
-
-
- $data = array
- (
- 'allow_allrows'
=> false,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($b_account_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
- 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' =>
'yes')),
- 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_b_account' =>
$table_header,
- 'values_b_account' =>
$content,
- 'table_done'
=> $table_done
- );
-
- $appname
= lang('budget account');
- $function_msg =
lang('list budget account');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_b_account' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
-
- function street()
- {
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('lookup',
-
'nextmatchs',
-
'search_field'));
-
- $street_list = $this->bo->read_street();
-
- while (is_array($street_list) && list(,$street_entry) =
each($street_list))
- {
- $content[] = array
- (
- 'id' =>
$street_entry['id'],
- 'street_name' =>
$street_entry['street_name'],
- 'lang_select' =>
lang('Select'),
- 'lang_select_statustext' =>
lang('Select this street')
- );
- }
-
- $table_header[] = array
- (
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'street_name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.street',
-
'cat_id'
=>$this->cat_id)
-
)),
- 'lang_name' => lang('Street name'),
- 'sort_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.street',
-
'cat_id'
=>$this->cat_id)
-
)),
- 'lang_id' => lang('ID'),
- 'lang_select' => lang('Select')
- );
-
- $table_done[] = array
- (
- 'lang_done' =>
lang('Done'),
- 'lang_done_statustext' => lang('Close this
window')
- );
-
- $link_select = array
- (
- 'menuaction' =>
$this->currentapp.'.uilookup.street',
- 'second_display' => true,
- 'order' => $this->order,
- 'sort' => $this->sort,
- 'cat_id' =>
$this->cat_id,
- 'query' => $this->query,
- 'filter' => $this->filter
- );
-
-
- $data = array
- (
- 'allow_allrows'
=> false,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($street_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the building belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
- 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' =>
'yes')),
- 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_street' =>
$table_header,
- 'values_street' => $content,
- 'table_done'
=> $table_done
- );
-
- $appname
= lang('street');
- $function_msg =
lang('list street');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_street' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function tenant()
- {
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('lookup',
-
'nextmatchs',
-
'search_field'));
-
- $tenant_list = $this->bo->read_tenant();
-
- while (is_array($tenant_list) && list(,$tenant_entry) =
each($tenant_list))
- {
- $content[] = array
- (
- 'id' =>
$tenant_entry['id'],
- 'last_name' =>
$tenant_entry['last_name'],
- 'first_name' =>
$tenant_entry['first_name'],
- 'lang_select' =>
lang('Select'),
- 'lang_select_statustext' =>
lang('Select this tenant')
- );
- }
-
- $table_header[] = array
- (
- 'sort_last_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'last_name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.tenant',
-
'cat_id'
=>$this->cat_id)
-
)),
- 'sort_first_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'first_name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.tenant',
-
'cat_id'
=>$this->cat_id)
-
)),
- 'lang_last_name' => lang('last
name'),
- 'lang_first_name' => lang('first
name'),
- 'sort_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.tenant',
-
'cat_id'
=>$this->cat_id)
-
)),
- 'lang_id' => lang('ID'),
- 'lang_select' => lang('Select')
- );
-
- $table_done[] = array
- (
- 'lang_done' =>
lang('Done'),
- 'lang_done_statustext' => lang('Close this
window')
- );
-
- $link_select = array
- (
- 'menuaction' =>
$this->currentapp.'.uilookup.tenant',
- 'second_display' => true,
- 'order' => $this->order,
- 'sort' => $this->sort,
- 'cat_id' =>
$this->cat_id,
- 'query' => $this->query,
- 'filter' => $this->filter
- );
-
-
- $data = array
- (
- 'allow_allrows'
=> false,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($tenant_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the building belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_tenant_new' =>
$table_header,
- 'values_tenant_new'
=> $content,
- 'table_done'
=> $table_done
- );
-
- $appname
= lang('tenant');
- $function_msg =
lang('list tenant');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_tenant' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function ns3420()
- {
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('lookup',
-
'nextmatchs',
-
'search_field'));
-
- $ns3420_list = $this->bo->read_ns3420();
-
- while (is_array($ns3420_list) && list(,$ns3420_entry) =
each($ns3420_list))
- {
- $content[] = array
- (
- 'id' =>
$ns3420_entry['id'],
- 'ns3420_descr' =>
$ns3420_entry['ns3420_descr'],
- 'lang_select' =>
lang('Select'),
- 'lang_select_statustext' =>
lang('Select this ns3420 - code')
- );
- }
-
- $table_header[] = array
- (
- 'sort_descr' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'tekst1',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.ns3420',
-
'query' =>$this->query)
-
)),
- 'lang_descr' => lang('ns3420
description'),
- 'sort_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.ns3420',
-
'query' =>$this->query)
-
)),
- 'lang_id' => lang('ID'),
- 'lang_select' => lang('Select')
- );
-
- $table_done[] = array
- (
- 'lang_done' =>
lang('Done'),
- 'lang_done_statustext' => lang('Close this
window')
- );
-
- $link_select = array
- (
- 'menuaction' =>
$this->currentapp.'.uilookup.ns3420',
- 'second_display' => true,
- 'order' => $this->order,
- 'sort' => $this->sort,
- 'cat_id' =>
$this->cat_id,
- 'query' => $this->query,
- 'filter' => $this->filter
- );
-
-
- $data = array
- (
- 'allow_allrows'
=> false,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($ns3420_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'lang_search'
=> lang('search'),
- 'query'
=> $this->query,
- 'table_header_ns3420' =>
$table_header,
- 'values_ns3420' => $content,
- 'table_done'
=> $table_done
- );
-
- $appname
= lang('standard description');
- $function_msg =
lang('list standard description');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_ns3420' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
-
- function entity()
- {
- $bocommon =
CreateObject($this->currentapp.'.bocommon');
- $boentity =
CreateObject($this->currentapp.'.boentity');
- $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
- $this->start =
$boentity->start;
- $this->query =
$boentity->query;
- $this->sort =
$boentity->sort;
- $this->order =
$boentity->order;
- $this->filter =
$boentity->filter;
- $this->cat_id =
$boentity->cat_id;
- $this->part_of_town_id =
$boentity->part_of_town_id;
- $this->district_id =
$boentity->district_id;
- $this->entity_id =
$boentity->entity_id;
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('lookup',
-
'nextmatchs',
-
'search_field'));
-
- $entity_list = $boentity->read(array('lookup'=>True));
-
- $input_name =
$GLOBALS['phpgw']->session->appsession('lookup_fields',$this->currentapp);
-//_debug_array($input_name);
-
- $uicols = $boentity->uicols;
-
-//_debug_array($uicols);
-
- $j=0;
-
- if (isset($entity_list) AND is_array($entity_list))
- {
- foreach($entity_list as $entity_entry)
- {
-
- for
($i=0;$i<count($uicols['name']);$i++)
- {
-
if($uicols['input_type'][$i]!='hidden')
- {
-
$content[$j]['row'][$i]['value'] = $entity_entry[$uicols['name'][$i]];
-
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
- }
- }
-
- for ($i=0;$i<count($input_name);$i++)
- {
-
$content[$j]['hidden'][$i]['value'] = $entity_entry[$input_name[$i]];
-
$content[$j]['hidden'][$i]['name'] = $input_name[$i];
- }
-
- $j++;
- }
- }
-
-//_debug_array($content);
- for ($i=0;$i<count($uicols['descr']);$i++)
- {
- if($uicols['input_type'][$i]!='hidden')
- {
- $table_header[$i]['header'] =
$uicols['descr'][$i];
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- if($uicols['name'][$i]=='loc1')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'loc1',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.entity',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'district_id' =>
$this->district_id,
-
'lookup'
=>$lookup,
-
'entity_id'
=>$this->entity_id,
-
'cat_id'
=>$this->cat_id)
-
));
- }
- if($uicols['name'][$i]=='num')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'num',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.entity',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'lookup'
=>$lookup,
-
'district_id' =>
$this->district_id,
-
'entity_id'
=>$this->entity_id,
-
'cat_id'
=>$this->cat_id)
-
));
- }
- }
- }
-
- $table_header[$i]['width'] = '5%';
- $table_header[$i]['align'] =
'center';
- $table_header[$i]['header'] =
lang('select');
-
-
-//_debug_array($table_header);
-//_debug_array($uicols);
-
- $table_done[] = array
- (
- 'lang_done' =>
lang('Done'),
- 'lang_done_statustext' => lang('Close this
window')
- );
-
- $link_select = array
- (
- 'menuaction' =>
$this->currentapp.'.uilookup.entity',
- 'order' => $this->order,
- 'sort' => $this->sort,
- 'cat_id' =>
$this->cat_id,
- 'entity_id' =>
$this->entity_id,
- 'district_id' => $this->district_id,
- 'query' => $this->query,
- 'filter' => $this->filter
- );
-
-
- for ($i=0;$i<count($input_name);$i++)
- {
- $function_exchange_values .=
'opener.document.form.' . $input_name[$i] .'.value = thisform.elements[' . $i .
'].value;' ."\r\n";
- }
-
- $function_exchange_values .='window.close()';
-
-
- $data = array
- (
- 'exchange_values'
=> 'Exchange_values(this.form);',
- 'function_exchange_values' =>
$function_exchange_values,
- 'lang_select'
=> lang('select'),
- 'lookup'
=> 1,//$lookup,
- 'allow_allrows'
=> false,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($entity_list),
- 'all_records'
=> $boentity->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the building belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $boentity->select_category_list('filter',$this->cat_id),
- 'district_list'
=> $bocommon->select_district_list('filter',$this->district_id),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
- 'lang_no_district'
=> lang('no district'),
- 'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
- 'select_district_name' =>
'district_id',
- 'lang_select'
=> lang('Select'),
-
- 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' =>
'yes')),
- 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_entity' =>
$table_header,
- 'values_entity'
=> $content,
- 'table_done'
=> $table_done
- );
-
-//_debug_array($content);
- if($this->entity_id)
- {
- $entity =
$boadmin_entity->read_single($this->entity_id,false);
- $appname = $entity['name'];
- }
- if($this->cat_id)
- {
- $category =
$boadmin_entity->read_single_category($this->entity_id,$this->cat_id);
- $function_msg
= lang('lookup') . ' ' . $category['name'];
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
- }
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_entity' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage core
+ * @version $Id: class.uilookup.inc.php,v 1.12 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uilookup
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+ var $part_of_town_id;
+ var $district_id;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'addressbook' => True,
+ 'vendor' => True,
+ 'b_account' => True,
+ 'location' => True,
+ 'entity' => True,
+ 'ns3420' => True,
+ 'street' => True,
+ 'tenant' => True
+ );
+
+ function uilookup()
+ {
+ $GLOBALS['phpgw_info']['flags']['noframework'] = True;
+ $GLOBALS['phpgw_info']['flags']['headonly']=true;
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->bo =
CreateObject($this->currentapp.'.bolookup',True);
+
+ $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;
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' =>
$this->filter,
+ 'cat_id' =>
$this->cat_id,
+ 'part_of_town_id' =>
$this->part_of_town_id,
+ 'district_id' => $this->district_id
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function addressbook()
+ {
+
+ $this->cats =
CreateObject('phpgwapi.categories');
+ $this->cats->app_name = 'addressbook';
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('lookup',
+
'nextmatchs',
+
'search_field',
+
'cat_filter'));
+
+ $second_display =
get_var('second_display',array('POST','GET'));
+ $column = get_var('column',array('POST','GET'));
+
+
+ $default_category =
$GLOBALS['phpgw_info']['user']['preferences']['addressbook']['default_category'];
+
+ if ($default_category && !$second_display)
+ {
+ $this->bo->cat_id = $default_category;
+ $this->cat_id = $default_category;
+ }
+
+ $addressbook_list = $this->bo->read_addressbook();
+
+ while (is_array($addressbook_list) &&
list(,$addressbook_entry) = each($addressbook_list))
+ {
+ $content[] = array
+ (
+ 'id' =>
$addressbook_entry['contact_id'],
+ 'contact_name' =>
$addressbook_entry['per_last_name'] . ', ' .
$addressbook_entry['per_first_name'],
+ 'lang_select' =>
lang('Select'),
+ 'lang_select_statustext' =>
lang('Select this contact')
+ );
+ }
+
+ $table_header[] = array
+ (
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'last_name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.addressbook',
+
'cat_id' =>
$this->cat_id,
+
'column' =>
$column)
+
)),
+ 'lang_name' => lang('Name'),
+ 'sort_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'person_id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.addressbook',
+
'cat_id'
=>$this->cat_id,
+
'column' =>
$column)
+
)),
+ 'lang_id' => lang('ID'),
+ 'lang_select' => lang('Select')
+ );
+
+ $table_done[] = array
+ (
+ 'lang_done' =>
lang('Done'),
+ 'lang_done_statustext' => lang('Close this
window')
+ );
+
+ $link_select = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uilookup.addressbook',
+ 'second_display' => true,
+ 'order' => $this->order,
+ 'sort' => $this->sort,
+ 'cat_id' =>
$this->cat_id,
+ 'query' => $this->query,
+ 'filter' =>
$this->filter,
+ 'column' => $column
+ );
+
+ if($column)
+ {
+ $contact_id =$column;
+ $contact_name =$column . '_name';
+ }
+ else
+ {
+ $contact_id ='contact_id';
+ $contact_name ='contact_name';
+ }
+
+ $cat_data =
$this->cats->formatted_xslt_list(array('selected' => $this->cat_id,'globals' =>
True, 'link_data' =>$link_select));
+ $data = array
+ (
+ 'allow_allrows'
=> false,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($addressbook_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the building belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $cat_data['cat_list'],
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
+ 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' =>
'yes')),
+ 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_contact' =>
$table_header,
+ 'values_contact'
=> $content,
+ 'table_done'
=> $table_done,
+ 'contact_id'
=> $contact_id,
+ 'contact_name'
=> $contact_name
+ );
+
+ $appname
= lang('addressbook');
+ $function_msg =
lang('list vendors');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_contact' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function vendor()
+ {
+
+ $this->cats =
CreateObject('phpgwapi.categories');
+ $this->cats->app_name = 'fm_vendor';
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('lookup',
+
'nextmatchs',
+
'search_field',
+
'cat_filter'));
+
+ $second_display =
get_var('second_display',array('POST','GET'));
+ $column = get_var('column',array('POST','GET'));
+
+
+ $default_category =
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['default_vendor_category'];
+
+ if ($default_category && !$second_display)
+ {
+ $this->bo->cat_id = $default_category;
+ $this->cat_id = $default_category;
+ }
+
+ $vendor_list = $this->bo->read_vendor();
+
+ while (is_array($vendor_list) && list(,$vendor_entry) =
each($vendor_list))
+ {
+ $content[] = array
+ (
+ 'id' =>
$vendor_entry['id'],
+ 'vendor_name' =>
$vendor_entry['org_name'],
+ 'lang_select' =>
lang('Select'),
+ 'lang_select_statustext' =>
lang('Select this vendor')
+ );
+ }
+
+ $table_header[] = array
+ (
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'org_name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.vendor',
+
'cat_id' =>
$this->cat_id,
+
'column' =>
$column)
+
)),
+ 'lang_name' => lang('Name'),
+ 'sort_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.vendor',
+
'cat_id'
=>$this->cat_id,
+
'column' =>
$column)
+
)),
+ 'lang_id' => lang('ID'),
+ 'lang_select' => lang('Select')
+ );
+
+ $table_done[] = array
+ (
+ 'lang_done' =>
lang('Done'),
+ 'lang_done_statustext' => lang('Close this
window')
+ );
+
+ $link_select = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uilookup.vendor',
+ 'second_display' => true,
+ 'order' => $this->order,
+ 'sort' => $this->sort,
+ 'cat_id' =>
$this->cat_id,
+ 'query' => $this->query,
+ 'filter' =>
$this->filter,
+ 'column' => $column
+ );
+
+ if($column)
+ {
+ $contact_id =$column;
+ $org_name =$column . '_org_name';
+ }
+ else
+ {
+ $contact_id ='vendor_id';
+ $org_name ='vendor_name';
+ }
+
+ $cat_data =
$this->cats->formatted_xslt_list(array('selected' => $this->cat_id,'globals' =>
True, 'link_data' =>$link_select));
+ $data = array
+ (
+ 'allow_allrows'
=> false,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($vendor_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the building belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $cat_data['cat_list'],
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
+ 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' =>
'yes')),
+ 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_vendor' =>
$table_header,
+ 'values_vendor'
=> $content,
+ 'table_done'
=> $table_done,
+ 'contact_id'
=> $contact_id,
+ 'org_name'
=> $org_name
+ );
+
+ $appname
= lang('vendor');
+ $function_msg =
lang('list vendors');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_vendor' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function b_account()
+ {
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('lookup',
+
'nextmatchs',
+
'search_field'));
+
+ $b_account_list = $this->bo->read_b_account();
+
+ while (is_array($b_account_list) &&
list(,$b_account_entry) = each($b_account_list))
+ {
+ $content[] = array
+ (
+ 'id' =>
$b_account_entry['id'],
+ 'b_account_name' =>
$b_account_entry['descr'],
+ 'lang_select' =>
lang('Select'),
+ 'lang_select_statustext' =>
lang('Select this budget account')
+ );
+ }
+
+ $table_header[] = array
+ (
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'descr',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.b_account',
+
'cat_id'
=>$this->cat_id)
+
)),
+ 'lang_name' => lang('Name'),
+ 'sort_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.b_account',
+
'cat_id'
=>$this->cat_id)
+
)),
+ 'lang_id' => lang('ID'),
+ 'lang_select' => lang('Select')
+ );
+
+ $table_done[] = array
+ (
+ 'lang_done' =>
lang('Done'),
+ 'lang_done_statustext' => lang('Close this
window')
+ );
+
+ $link_select = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uilookup.b_account',
+ 'second_display' => true,
+ 'order' => $this->order,
+ 'sort' => $this->sort,
+ 'cat_id' =>
$this->cat_id,
+ 'query' => $this->query,
+ 'filter' => $this->filter
+ );
+
+
+ $data = array
+ (
+ 'allow_allrows'
=> false,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($b_account_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
+ 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' =>
'yes')),
+ 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_b_account' =>
$table_header,
+ 'values_b_account' =>
$content,
+ 'table_done'
=> $table_done
+ );
+
+ $appname
= lang('budget account');
+ $function_msg =
lang('list budget account');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_b_account' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+
+ function street()
+ {
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('lookup',
+
'nextmatchs',
+
'search_field'));
+
+ $street_list = $this->bo->read_street();
+
+ while (is_array($street_list) && list(,$street_entry) =
each($street_list))
+ {
+ $content[] = array
+ (
+ 'id' =>
$street_entry['id'],
+ 'street_name' =>
$street_entry['street_name'],
+ 'lang_select' =>
lang('Select'),
+ 'lang_select_statustext' =>
lang('Select this street')
+ );
+ }
+
+ $table_header[] = array
+ (
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'street_name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.street',
+
'cat_id'
=>$this->cat_id)
+
)),
+ 'lang_name' => lang('Street name'),
+ 'sort_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.street',
+
'cat_id'
=>$this->cat_id)
+
)),
+ 'lang_id' => lang('ID'),
+ 'lang_select' => lang('Select')
+ );
+
+ $table_done[] = array
+ (
+ 'lang_done' =>
lang('Done'),
+ 'lang_done_statustext' => lang('Close this
window')
+ );
+
+ $link_select = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uilookup.street',
+ 'second_display' => true,
+ 'order' => $this->order,
+ 'sort' => $this->sort,
+ 'cat_id' =>
$this->cat_id,
+ 'query' => $this->query,
+ 'filter' => $this->filter
+ );
+
+
+ $data = array
+ (
+ 'allow_allrows'
=> false,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($street_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the building belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
+ 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' =>
'yes')),
+ 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_street' =>
$table_header,
+ 'values_street' => $content,
+ 'table_done'
=> $table_done
+ );
+
+ $appname
= lang('street');
+ $function_msg =
lang('list street');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_street' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function tenant()
+ {
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('lookup',
+
'nextmatchs',
+
'search_field'));
+
+ $tenant_list = $this->bo->read_tenant();
+
+ while (is_array($tenant_list) && list(,$tenant_entry) =
each($tenant_list))
+ {
+ $content[] = array
+ (
+ 'id' =>
$tenant_entry['id'],
+ 'last_name' =>
$tenant_entry['last_name'],
+ 'first_name' =>
$tenant_entry['first_name'],
+ 'lang_select' =>
lang('Select'),
+ 'lang_select_statustext' =>
lang('Select this tenant')
+ );
+ }
+
+ $table_header[] = array
+ (
+ 'sort_last_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'last_name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.tenant',
+
'cat_id'
=>$this->cat_id)
+
)),
+ 'sort_first_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'first_name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.tenant',
+
'cat_id'
=>$this->cat_id)
+
)),
+ 'lang_last_name' => lang('last
name'),
+ 'lang_first_name' => lang('first
name'),
+ 'sort_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.tenant',
+
'cat_id'
=>$this->cat_id)
+
)),
+ 'lang_id' => lang('ID'),
+ 'lang_select' => lang('Select')
+ );
+
+ $table_done[] = array
+ (
+ 'lang_done' =>
lang('Done'),
+ 'lang_done_statustext' => lang('Close this
window')
+ );
+
+ $link_select = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uilookup.tenant',
+ 'second_display' => true,
+ 'order' => $this->order,
+ 'sort' => $this->sort,
+ 'cat_id' =>
$this->cat_id,
+ 'query' => $this->query,
+ 'filter' => $this->filter
+ );
+
+
+ $data = array
+ (
+ 'allow_allrows'
=> false,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($tenant_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the building belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_tenant_new' =>
$table_header,
+ 'values_tenant_new'
=> $content,
+ 'table_done'
=> $table_done
+ );
+
+ $appname
= lang('tenant');
+ $function_msg =
lang('list tenant');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_tenant' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function ns3420()
+ {
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('lookup',
+
'nextmatchs',
+
'search_field'));
+
+ $ns3420_list = $this->bo->read_ns3420();
+
+ while (is_array($ns3420_list) && list(,$ns3420_entry) =
each($ns3420_list))
+ {
+ $content[] = array
+ (
+ 'id' =>
$ns3420_entry['id'],
+ 'ns3420_descr' =>
$ns3420_entry['ns3420_descr'],
+ 'lang_select' =>
lang('Select'),
+ 'lang_select_statustext' =>
lang('Select this ns3420 - code')
+ );
+ }
+
+ $table_header[] = array
+ (
+ 'sort_descr' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'tekst1',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.ns3420',
+
'query' =>$this->query)
+
)),
+ 'lang_descr' => lang('ns3420
description'),
+ 'sort_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.ns3420',
+
'query' =>$this->query)
+
)),
+ 'lang_id' => lang('ID'),
+ 'lang_select' => lang('Select')
+ );
+
+ $table_done[] = array
+ (
+ 'lang_done' =>
lang('Done'),
+ 'lang_done_statustext' => lang('Close this
window')
+ );
+
+ $link_select = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uilookup.ns3420',
+ 'second_display' => true,
+ 'order' => $this->order,
+ 'sort' => $this->sort,
+ 'cat_id' =>
$this->cat_id,
+ 'query' => $this->query,
+ 'filter' => $this->filter
+ );
+
+
+ $data = array
+ (
+ 'allow_allrows'
=> false,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($ns3420_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'lang_search'
=> lang('search'),
+ 'query'
=> $this->query,
+ 'table_header_ns3420' =>
$table_header,
+ 'values_ns3420' => $content,
+ 'table_done'
=> $table_done
+ );
+
+ $appname
= lang('standard description');
+ $function_msg =
lang('list standard description');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_ns3420' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+
+ function entity()
+ {
+ $bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $boentity =
CreateObject($this->currentapp.'.boentity');
+ $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
+ $this->start =
$boentity->start;
+ $this->query =
$boentity->query;
+ $this->sort =
$boentity->sort;
+ $this->order =
$boentity->order;
+ $this->filter =
$boentity->filter;
+ $this->cat_id =
$boentity->cat_id;
+ $this->part_of_town_id =
$boentity->part_of_town_id;
+ $this->district_id =
$boentity->district_id;
+ $this->entity_id =
$boentity->entity_id;
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('lookup',
+
'nextmatchs',
+
'search_field'));
+
+ $entity_list = $boentity->read(array('lookup'=>True));
+
+ $input_name =
$GLOBALS['phpgw']->session->appsession('lookup_fields',$this->currentapp);
+//_debug_array($input_name);
+
+ $uicols = $boentity->uicols;
+
+//_debug_array($uicols);
+
+ $j=0;
+
+ if (isset($entity_list) AND is_array($entity_list))
+ {
+ foreach($entity_list as $entity_entry)
+ {
+
+ for
($i=0;$i<count($uicols['name']);$i++)
+ {
+
if($uicols['input_type'][$i]!='hidden')
+ {
+
$content[$j]['row'][$i]['value'] = $entity_entry[$uicols['name'][$i]];
+
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
+ }
+ }
+
+ for ($i=0;$i<count($input_name);$i++)
+ {
+
$content[$j]['hidden'][$i]['value'] = $entity_entry[$input_name[$i]];
+
$content[$j]['hidden'][$i]['name'] = $input_name[$i];
+ }
+
+ $j++;
+ }
+ }
+
+//_debug_array($content);
+ for ($i=0;$i<count($uicols['descr']);$i++)
+ {
+ if($uicols['input_type'][$i]!='hidden')
+ {
+ $table_header[$i]['header'] =
$uicols['descr'][$i];
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ if($uicols['name'][$i]=='loc1')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'loc1',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.entity',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'district_id' =>
$this->district_id,
+
'lookup'
=>$lookup,
+
'entity_id'
=>$this->entity_id,
+
'cat_id'
=>$this->cat_id)
+
));
+ }
+ if($uicols['name'][$i]=='num')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'num',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uilookup.entity',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'lookup'
=>$lookup,
+
'district_id' =>
$this->district_id,
+
'entity_id'
=>$this->entity_id,
+
'cat_id'
=>$this->cat_id)
+
));
+ }
+ }
+ }
+
+ $table_header[$i]['width'] = '5%';
+ $table_header[$i]['align'] =
'center';
+ $table_header[$i]['header'] =
lang('select');
+
+
+//_debug_array($table_header);
+//_debug_array($uicols);
+
+ $table_done[] = array
+ (
+ 'lang_done' =>
lang('Done'),
+ 'lang_done_statustext' => lang('Close this
window')
+ );
+
+ $link_select = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uilookup.entity',
+ 'order' => $this->order,
+ 'sort' => $this->sort,
+ 'cat_id' =>
$this->cat_id,
+ 'entity_id' =>
$this->entity_id,
+ 'district_id' => $this->district_id,
+ 'query' => $this->query,
+ 'filter' => $this->filter
+ );
+
+
+ for ($i=0;$i<count($input_name);$i++)
+ {
+ $function_exchange_values .=
'opener.document.form.' . $input_name[$i] .'.value = thisform.elements[' . $i .
'].value;' ."\r\n";
+ }
+
+ $function_exchange_values .='window.close()';
+
+
+ $data = array
+ (
+ 'exchange_values'
=> 'Exchange_values(this.form);',
+ 'function_exchange_values' =>
$function_exchange_values,
+ 'lang_select'
=> lang('select'),
+ 'lookup'
=> 1,//$lookup,
+ 'allow_allrows'
=> false,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($entity_list),
+ 'all_records'
=> $boentity->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the building belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $boentity->select_category_list('filter',$this->cat_id),
+ 'district_list'
=> $bocommon->select_district_list('filter',$this->district_id),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_select),
+ 'lang_no_district'
=> lang('no district'),
+ 'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
+ 'select_district_name' =>
'district_id',
+ 'lang_select'
=> lang('Select'),
+
+ 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' =>
'yes')),
+ 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_entity' =>
$table_header,
+ 'values_entity'
=> $content,
+ 'table_done'
=> $table_done
+ );
+
+//_debug_array($content);
+ if($this->entity_id)
+ {
+ $entity =
$boadmin_entity->read_single($this->entity_id,false);
+ $appname = $entity['name'];
+ }
+ if($this->cat_id)
+ {
+ $category =
$boadmin_entity->read_single_category($this->entity_id,$this->cat_id);
+ $function_msg
= lang('lookup') . ' ' . $category['name'];
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+ }
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_entity' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ }
+?>
Index: property/inc/class.uimeter.inc.php
diff -u property/inc/class.uimeter.inc.php:1.8
property/inc/class.uimeter.inc.php:1.9
--- property/inc/class.uimeter.inc.php:1.8 Thu May 12 21:26:28 2005
+++ property/inc/class.uimeter.inc.php Fri Jan 27 14:05:43 2006
@@ -1,583 +1,583 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage entity
- * @version $Id: class.uimeter.inc.php,v 1.8 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uimeter
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
- var $part_of_town_id;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'index' => True,
- 'view' => True,
- 'edit' => True,
- 'delete' => True,
- );
-
- function uimeter()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- $this->bo =
CreateObject($this->currentapp.'.bometer');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
-
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
- $this->acl2_location = '.meter';
- $this->acl_read =
$this->acl2->check('.meter',1);
- $this->acl_add =
$this->acl2->check('.meter',2);
- $this->acl_edit =
$this->acl2->check('.meter',4);
- $this->acl_delete =
$this->acl2->check('.meter',8);
-
- $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->menu->sub ='meter';
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' => $this->filter,
- 'cat_id' => $this->cat_id
- );
- $this->bo->save_sessiondata($data);
- }
-
- function index()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('meter','values','table_header',
-
'menu',
-
'nextmatchs',
-
'search_field'));
-
- $links = $this->menu->links();
-
- $meter_list = $this->bo->read();
-
- $uicols = $this->bo->uicols;
-//_debug_array($uicols);
-
- $m = count($uicols['name']);
- $j=0;
- if (isset($meter_list) AND is_array($meter_list))
- {
- foreach($meter_list as $meter_entry)
- {
- for ($k=0;$k<$m;$k++)
- {
-
if($uicols['input_type'][$k]!='hidden')
- {
-
-
if($meter_entry['query_location'][$uicols['name'][$k]])
- {
-
$content[$j]['row'][$k]['statustext'] = lang('search');
-
$content[$j]['row'][$k]['text'] =
$meter_entry[$uicols['name'][$k]];
-
$content[$j]['row'][$k]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uimeter.index&query='
. $meter_entry['query_location'][$uicols['name'][$k]] . '&lookup=' . $lookup);
- }
- else
- {
-
$content[$j]['row'][$k]['value'] =
$meter_entry[$uicols['name'][$k]];
-
$content[$j]['row'][$k]['name'] = $uicols['name'][$k];
- }
- }
- }
-
- if(!$lookup)
- {
- if($this->acl_read)
- {
-
$content[$j]['row'][$k]['statustext'] = lang('view the
meter');
-
$content[$j]['row'][$k]['text'] = lang('view');
-
$content[$j]['row'][$k]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uimeter.view&id='
. $meter_entry['meter_id']);
- $k++;
- }
-
- if($this->acl_edit)
- {
-
$content[$j]['row'][$k]['statustext'] = lang('edit the
meter');
-
$content[$j]['row'][$k]['text'] = lang('edit');
-
$content[$j]['row'][$k]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uimeter.edit&id='
. $meter_entry['meter_id']);
- $k++;
- }
-
- if($this->acl_delete)
- {
-
$content[$j]['row'][$k]['statustext'] = lang('delete the
meter');
-
$content[$j]['row'][$k]['text'] =
lang('delete');
-
$content[$j]['row'][$k]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uimeter.delete&id='
. $meter_entry['meter_id']);
- $k++;
- }
- }
- $j++;
- }
- }
-
- $m = count($uicols['descr']);
- for ($i=0;$i<$m;$i++)
- {
- if($uicols['input_type'][$i]!='hidden')
- {
- $table_header[$i]['header'] =
$uicols['descr'][$i];
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- if($uicols['name'][$i]=='loc1')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'location_code',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uimeter.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'lookup'
=>$lookup,
-
'district_id' =>
$this->district_id,
-
'cat_id'
=>$this->cat_id)
-
));
- }
- if($uicols['name'][$i]=='num')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'num',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uimeter.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'lookup'
=>$lookup,
-
'district_id' =>
$this->district_id,
-
'cat_id'
=>$this->cat_id)
-
));
- }
- if($uicols['name'][$i]=='address')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'address',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uimeter.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'lookup'
=>$lookup,
-
'district_id' =>
$this->district_id,
-
'cat_id'
=>$this->cat_id)
-
));
- }
- }
- }
-
- if(!$lookup)
- {
- if($this->acl_read)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('view');
- $i++;
- }
- if($this->acl_edit)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('edit');
- $i++;
- }
- if($this->acl_delete)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('delete');
- $i++;
- }
- }
- else
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header'] =
lang('select');
- }
-
-//_debug_array($content);
- if($this->acl_add)
- {
- $table_add[] = array
- (
- 'lang_add'
=> lang('add'),
- 'lang_add_statustext' => lang('add a
meter'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uimeter.edit')
-
- );
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uimeter.index',
- 'start' =>
$this->start,
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query
- );
-
-
- $data = array
- (
- 'links'
=> $links,
- 'allow_allrows'
=> False,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($meter_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the meter belongs to. To do not use a category select
NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $this->bo->get_category_list('filter',$this->cat_id),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' =>
'yes')),
- 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('meter');
- $function_msg =
lang('list meter');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit()
- {
- if(!$this->acl_add && !$this->acl_edit)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
- }
-
- $bolocation =
CreateObject($this->currentapp.'.bolocation');
-
- $id =
get_var('id',array('POST','GET'));
- $values =
get_var('values',array('POST'));
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('meter'));
-
- $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
- $insert_record_entity =
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp);
-
- for ($j=0;$j<count($insert_record_entity);$j++)
- {
-
$insert_record['extra'][$insert_record_entity[$j]] =
$insert_record_entity[$j];
- }
-
- if ($values['save'])
- {
- for ($i=0;
$i<count($insert_record['location']); $i++)
- {
-
if($_POST[$insert_record['location'][$i]])
- {
-
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
- }
- }
-
- while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
- {
- if($_POST[$key])
- {
- $values['extra'][$column]
= $_POST[$key];
- }
- }
-
- $values['street_name'] =
$_POST['street_name'];
- $values['street_number'] =
$_POST['street_number'];
- $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
-
- if(!$values['num'] && !$id)
- {
-
$receipt['error'][]=array('msg'=>lang('Enter a meter ID !'));
- }
-
- if($id)
- {
- $values['meter_id']=$id;
- $action='edit';
- }
- else
- {
-
if($this->bo->check_meter_num($values['num']))
- {
-
$receipt['error'][]=array('msg'=>lang('This meter id is already registered!') .
'[ '.$values['num'].' ]');
- $error_id=true;
- unset($values['num']);
- }
- else
- {
- $id = $values['meter_id'];
- }
- }
-
- if(!$values['location'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a location !'));
- }
-
- if(!$values['cat_id'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
- }
-
- if(!$receipt['error'])
- {
- $receipt =
$this->bo->save($values,$action);
- $id = $receipt['meter_id'];
- }
- else
- {
- if($values['location'])
- {
- $location_code=implode("-",
$values['location']);
- $values['location_data'] =
$bolocation->read_single($location_code,$values['extra']);
- }
- if($values['extra']['p_num'])
- {
-
$values['p'][$values['extra']['p_entity_id']]['p_num']=$values['extra']['p_num'];
-
$values['p'][$values['extra']['p_entity_id']]['p_entity_id']=$values['extra']['p_entity_id'];
-
$values['p'][$values['extra']['p_entity_id']]['p_cat_id']=$values['extra']['p_cat_id'];
-
$values['p'][$values['extra']['p_entity_id']]['p_cat_name']=$_POST['entity_cat_name_'.$values['extra']['p_entity_id']];
- }
- }
- }
-
- if ($id)
- {
- $values = $this->bo->read_single($id);
-// _debug_array($meter);
- $function_msg = lang('edit meter');
- $action='edit';
- }
- else
- {
- $function_msg = lang('add meter');
- $action='add';
- }
-
- if ($values['cat_id'])
- {
- $this->cat_id = $values['cat_id'];
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uimeter.edit',
- 'id' => $id
- );
-
- $location_data=$bolocation->initiate_ui_location(array(
- 'values' =>
$values['location_data'],
- 'type_id' => -1,
// calculated from location_types
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' =>
False,
- 'lookup_type' => 'form',
- 'lookup_entity' =>
$this->bocommon->get_lookup_entity('meter'),
- 'entity_data' => $values['p']
- ));
-
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'location_data'
=> $location_data,
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uimeter.index'),
- 'lang_meter_id'
=> lang('meter ID'),
- 'lang_name'
=> lang('name'),
- 'lang_remark'
=> lang('Remark'),
- 'lang_category'
=> lang('category'),
- 'lang_access'
=> lang('private'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_meter_id'
=> $values['num'],
- 'value_name'
=> $values['name'],
- 'value_remark'
=> $values['remark'],
- 'lang_meter_id_statustext' =>
lang('Enter the meter ID'),
- 'lang_name_statustext' =>
lang('Enter the name of the meter'),
- 'lang_remark_statustext' =>
lang('Enter a remark - if any'),
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'lang_save_statustext' =>
lang('Save the meter'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the meter belongs to. To do not use a category select
NO CATEGORY'),
- 'select_name'
=> 'values[cat_id]',
- 'cat_list'
=> $this->bo->get_category_list('select',$this->cat_id)
- );
-
- $appname
= lang('meter');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function delete()
- {
- if(!$this->acl_delete)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
- }
-
- $id = get_var('id',array('POST','GET'));
- $confirm = get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uimeter.index'
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($id);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uimeter.delete&id='
. $id),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('meter');
- $function_msg =
lang('delete meter');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function view()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $bolocation =
CreateObject($this->currentapp.'.bolocation');
- $id =
get_var('id',array('POST','GET'));
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('meter'));
-
-
- $values = $this->bo->read_single($id);
- $function_msg = lang('View meter');
-
- if ($values['cat_id'])
- {
- $this->cat_id = $values['cat_id'];
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uimeter.edit',
- 'id' => $id
- );
-
- $location_data=$bolocation->initiate_ui_location(array(
- 'values' =>
$values['location_data'],
- 'type_id' =>
count(explode('-',$values['location_data']['location_code'])),
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' =>
False,
- 'lookup_type' => 'view',
- 'lookup_entity' =>
$this->bocommon->get_lookup_entity('meter'),
- 'entity_data' => $values['p']
- ));
-
- $data = array
- (
- 'location_data'
=> $location_data,
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uimeter.index'),
- 'edit_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uimeter.edit&id='
. $id),
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'lang_edit_statustext' =>
lang('Edit this meter'),
- 'lang_done'
=> lang('done'),
- 'lang_edit'
=> lang('edit'),
- 'lang_meter_id'
=> lang('meter ID'),
- 'lang_name'
=> lang('name'),
- 'lang_remark'
=> lang('Remark'),
- 'lang_category'
=> lang('category'),
- 'lang_access'
=> lang('private'),
- 'value_meter_id'
=> $id,
- 'value_name'
=> $values['name'],
- 'value_remark'
=> $values['remark'],
- 'cat_list'
=> $this->bo->get_category_list('',$this->cat_id),
- );
-
- $appname
= lang('meter');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage entity
+ * @version $Id: class.uimeter.inc.php,v 1.9 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uimeter
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+ var $part_of_town_id;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'view' => True,
+ 'edit' => True,
+ 'delete' => True,
+ );
+
+ function uimeter()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $this->bo =
CreateObject($this->currentapp.'.bometer');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+ $this->acl2_location = '.meter';
+ $this->acl_read =
$this->acl2->check('.meter',1);
+ $this->acl_add =
$this->acl2->check('.meter',2);
+ $this->acl_edit =
$this->acl2->check('.meter',4);
+ $this->acl_delete =
$this->acl2->check('.meter',8);
+
+ $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->menu->sub ='meter';
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' => $this->filter,
+ 'cat_id' => $this->cat_id
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function index()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('meter','values','table_header',
+
'menu',
+
'nextmatchs',
+
'search_field'));
+
+ $links = $this->menu->links();
+
+ $meter_list = $this->bo->read();
+
+ $uicols = $this->bo->uicols;
+//_debug_array($uicols);
+
+ $m = count($uicols['name']);
+ $j=0;
+ if (isset($meter_list) AND is_array($meter_list))
+ {
+ foreach($meter_list as $meter_entry)
+ {
+ for ($k=0;$k<$m;$k++)
+ {
+
if($uicols['input_type'][$k]!='hidden')
+ {
+
+
if($meter_entry['query_location'][$uicols['name'][$k]])
+ {
+
$content[$j]['row'][$k]['statustext'] = lang('search');
+
$content[$j]['row'][$k]['text'] =
$meter_entry[$uicols['name'][$k]];
+
$content[$j]['row'][$k]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uimeter.index&query='
. $meter_entry['query_location'][$uicols['name'][$k]] . '&lookup=' . $lookup);
+ }
+ else
+ {
+
$content[$j]['row'][$k]['value'] =
$meter_entry[$uicols['name'][$k]];
+
$content[$j]['row'][$k]['name'] = $uicols['name'][$k];
+ }
+ }
+ }
+
+ if(!$lookup)
+ {
+ if($this->acl_read)
+ {
+
$content[$j]['row'][$k]['statustext'] = lang('view the
meter');
+
$content[$j]['row'][$k]['text'] = lang('view');
+
$content[$j]['row'][$k]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uimeter.view&id='
. $meter_entry['meter_id']);
+ $k++;
+ }
+
+ if($this->acl_edit)
+ {
+
$content[$j]['row'][$k]['statustext'] = lang('edit the
meter');
+
$content[$j]['row'][$k]['text'] = lang('edit');
+
$content[$j]['row'][$k]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uimeter.edit&id='
. $meter_entry['meter_id']);
+ $k++;
+ }
+
+ if($this->acl_delete)
+ {
+
$content[$j]['row'][$k]['statustext'] = lang('delete the
meter');
+
$content[$j]['row'][$k]['text'] =
lang('delete');
+
$content[$j]['row'][$k]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uimeter.delete&id='
. $meter_entry['meter_id']);
+ $k++;
+ }
+ }
+ $j++;
+ }
+ }
+
+ $m = count($uicols['descr']);
+ for ($i=0;$i<$m;$i++)
+ {
+ if($uicols['input_type'][$i]!='hidden')
+ {
+ $table_header[$i]['header'] =
$uicols['descr'][$i];
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ if($uicols['name'][$i]=='loc1')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'location_code',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uimeter.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'lookup'
=>$lookup,
+
'district_id' =>
$this->district_id,
+
'cat_id'
=>$this->cat_id)
+
));
+ }
+ if($uicols['name'][$i]=='num')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'num',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uimeter.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'lookup'
=>$lookup,
+
'district_id' =>
$this->district_id,
+
'cat_id'
=>$this->cat_id)
+
));
+ }
+ if($uicols['name'][$i]=='address')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'address',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uimeter.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'lookup'
=>$lookup,
+
'district_id' =>
$this->district_id,
+
'cat_id'
=>$this->cat_id)
+
));
+ }
+ }
+ }
+
+ if(!$lookup)
+ {
+ if($this->acl_read)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('view');
+ $i++;
+ }
+ if($this->acl_edit)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('edit');
+ $i++;
+ }
+ if($this->acl_delete)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('delete');
+ $i++;
+ }
+ }
+ else
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header'] =
lang('select');
+ }
+
+//_debug_array($content);
+ if($this->acl_add)
+ {
+ $table_add[] = array
+ (
+ 'lang_add'
=> lang('add'),
+ 'lang_add_statustext' => lang('add a
meter'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uimeter.edit')
+
+ );
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uimeter.index',
+ 'start' =>
$this->start,
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query
+ );
+
+
+ $data = array
+ (
+ 'links'
=> $links,
+ 'allow_allrows'
=> False,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($meter_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the meter belongs to. To do not use a category select
NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $this->bo->get_category_list('filter',$this->cat_id),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' =>
'yes')),
+ 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('meter');
+ $function_msg =
lang('list meter');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit()
+ {
+ if(!$this->acl_add && !$this->acl_edit)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
+ }
+
+ $bolocation =
CreateObject($this->currentapp.'.bolocation');
+
+ $id =
get_var('id',array('POST','GET'));
+ $values =
get_var('values',array('POST'));
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('meter'));
+
+ $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
+ $insert_record_entity =
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp);
+
+ for ($j=0;$j<count($insert_record_entity);$j++)
+ {
+
$insert_record['extra'][$insert_record_entity[$j]] =
$insert_record_entity[$j];
+ }
+
+ if ($values['save'])
+ {
+ for ($i=0;
$i<count($insert_record['location']); $i++)
+ {
+
if($_POST[$insert_record['location'][$i]])
+ {
+
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
+ }
+ }
+
+ while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
+ {
+ if($_POST[$key])
+ {
+ $values['extra'][$column]
= $_POST[$key];
+ }
+ }
+
+ $values['street_name'] =
$_POST['street_name'];
+ $values['street_number'] =
$_POST['street_number'];
+ $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
+
+ if(!$values['num'] && !$id)
+ {
+
$receipt['error'][]=array('msg'=>lang('Enter a meter ID !'));
+ }
+
+ if($id)
+ {
+ $values['meter_id']=$id;
+ $action='edit';
+ }
+ else
+ {
+
if($this->bo->check_meter_num($values['num']))
+ {
+
$receipt['error'][]=array('msg'=>lang('This meter id is already registered!') .
'[ '.$values['num'].' ]');
+ $error_id=true;
+ unset($values['num']);
+ }
+ else
+ {
+ $id = $values['meter_id'];
+ }
+ }
+
+ if(!$values['location'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a location !'));
+ }
+
+ if(!$values['cat_id'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
+ }
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$this->bo->save($values,$action);
+ $id = $receipt['meter_id'];
+ }
+ else
+ {
+ if($values['location'])
+ {
+ $location_code=implode("-",
$values['location']);
+ $values['location_data'] =
$bolocation->read_single($location_code,$values['extra']);
+ }
+ if($values['extra']['p_num'])
+ {
+
$values['p'][$values['extra']['p_entity_id']]['p_num']=$values['extra']['p_num'];
+
$values['p'][$values['extra']['p_entity_id']]['p_entity_id']=$values['extra']['p_entity_id'];
+
$values['p'][$values['extra']['p_entity_id']]['p_cat_id']=$values['extra']['p_cat_id'];
+
$values['p'][$values['extra']['p_entity_id']]['p_cat_name']=$_POST['entity_cat_name_'.$values['extra']['p_entity_id']];
+ }
+ }
+ }
+
+ if ($id)
+ {
+ $values = $this->bo->read_single($id);
+// _debug_array($meter);
+ $function_msg = lang('edit meter');
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add meter');
+ $action='add';
+ }
+
+ if ($values['cat_id'])
+ {
+ $this->cat_id = $values['cat_id'];
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uimeter.edit',
+ 'id' => $id
+ );
+
+ $location_data=$bolocation->initiate_ui_location(array(
+ 'values' =>
$values['location_data'],
+ 'type_id' => -1,
// calculated from location_types
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' =>
False,
+ 'lookup_type' => 'form',
+ 'lookup_entity' =>
$this->bocommon->get_lookup_entity('meter'),
+ 'entity_data' => $values['p']
+ ));
+
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'location_data'
=> $location_data,
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uimeter.index'),
+ 'lang_meter_id'
=> lang('meter ID'),
+ 'lang_name'
=> lang('name'),
+ 'lang_remark'
=> lang('Remark'),
+ 'lang_category'
=> lang('category'),
+ 'lang_access'
=> lang('private'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_meter_id'
=> $values['num'],
+ 'value_name'
=> $values['name'],
+ 'value_remark'
=> $values['remark'],
+ 'lang_meter_id_statustext' =>
lang('Enter the meter ID'),
+ 'lang_name_statustext' =>
lang('Enter the name of the meter'),
+ 'lang_remark_statustext' =>
lang('Enter a remark - if any'),
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'lang_save_statustext' =>
lang('Save the meter'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the meter belongs to. To do not use a category select
NO CATEGORY'),
+ 'select_name'
=> 'values[cat_id]',
+ 'cat_list'
=> $this->bo->get_category_list('select',$this->cat_id)
+ );
+
+ $appname
= lang('meter');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function delete()
+ {
+ if(!$this->acl_delete)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
+ }
+
+ $id = get_var('id',array('POST','GET'));
+ $confirm = get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uimeter.index'
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($id);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uimeter.delete&id='
. $id),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('meter');
+ $function_msg =
lang('delete meter');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function view()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $bolocation =
CreateObject($this->currentapp.'.bolocation');
+ $id =
get_var('id',array('POST','GET'));
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('meter'));
+
+
+ $values = $this->bo->read_single($id);
+ $function_msg = lang('View meter');
+
+ if ($values['cat_id'])
+ {
+ $this->cat_id = $values['cat_id'];
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uimeter.edit',
+ 'id' => $id
+ );
+
+ $location_data=$bolocation->initiate_ui_location(array(
+ 'values' =>
$values['location_data'],
+ 'type_id' =>
count(explode('-',$values['location_data']['location_code'])),
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' =>
False,
+ 'lookup_type' => 'view',
+ 'lookup_entity' =>
$this->bocommon->get_lookup_entity('meter'),
+ 'entity_data' => $values['p']
+ ));
+
+ $data = array
+ (
+ 'location_data'
=> $location_data,
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uimeter.index'),
+ 'edit_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uimeter.edit&id='
. $id),
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'lang_edit_statustext' =>
lang('Edit this meter'),
+ 'lang_done'
=> lang('done'),
+ 'lang_edit'
=> lang('edit'),
+ 'lang_meter_id'
=> lang('meter ID'),
+ 'lang_name'
=> lang('name'),
+ 'lang_remark'
=> lang('Remark'),
+ 'lang_category'
=> lang('category'),
+ 'lang_access'
=> lang('private'),
+ 'value_meter_id'
=> $id,
+ 'value_name'
=> $values['name'],
+ 'value_remark'
=> $values['remark'],
+ 'cat_list'
=> $this->bo->get_category_list('',$this->cat_id),
+ );
+
+ $appname
= lang('meter');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ }
+?>
Index: property/inc/class.uip_of_town.inc.php
diff -u property/inc/class.uip_of_town.inc.php:1.8
property/inc/class.uip_of_town.inc.php:1.9
--- property/inc/class.uip_of_town.inc.php:1.8 Thu May 12 21:26:28 2005
+++ property/inc/class.uip_of_town.inc.php Fri Jan 27 14:05:43 2006
@@ -1,366 +1,366 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.uip_of_town.inc.php,v 1.8 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uip_of_town
- {
- var $grants;
- var $district_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
-
- var $public_functions = array
- (
- 'index' => True,
- 'view' => True,
- 'edit' => True,
- 'delete' => True
- );
-
- function uip_of_town()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- $this->bo =
CreateObject($this->currentapp.'.bop_of_town',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
-
- $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->district_id =
$this->bo->district_id;
- $this->allrows = $this->bo->allrows;
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' => $this->filter,
- 'district_id' => $this->district_id,
- 'this->allrows' => $this->allrows
- );
- $this->bo->save_sessiondata($data);
- }
-
- function index()
- {
- $GLOBALS['phpgw']->xslttpl->add_file(array('p_of_town',
-
'menu',
-
'receipt',
-
'search_field',
-
'nextmatchs'));
-
- $links = $this->menu->links();
-
- $receipt =
$GLOBALS['phpgw']->session->appsession('session_data','p_of_town_receipt');
-
$GLOBALS['phpgw']->session->appsession('session_data','p_of_town_receipt','');
-
- $p_of_towns_list = $this->bo->read();
-
- if (isSet($p_of_towns_list) AND
is_array($p_of_towns_list))
- {
- foreach($p_of_towns_list as $p_of_town)
- {
- $content[] = array
- (
- 'part_of_town_id'
=> $p_of_town['part_of_town_id'],
- 'name'
=> $p_of_town['name'],
- 'category'
=> $p_of_town['category'],
- 'link_view'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uip_of_town.view&part_of_town_id='
. $p_of_town['part_of_town_id']),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uip_of_town.edit&part_of_town_id='
. $p_of_town['part_of_town_id']),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uip_of_town.delete&part_of_town_id='
. $p_of_town['part_of_town_id']),
- 'lang_view_statustext'
=> lang('view the p_of_town'),
- 'lang_edit_statustext'
=> lang('edit the p_of_town'),
- 'lang_delete_statustext'
=> lang('delete the p_of_town'),
- 'text_view'
=> lang('view'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
- }
-
- $table_header = array
- (
- 'lang_name' => lang('name'),
- 'lang_time_created' => lang('time created'),
- 'lang_view' => lang('view'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'lang_part_of_town_id' => lang('Part
of town id'),
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uip_of_town.index',
-
'district_id' =>
$this->district_id,
-
'query'
=>$this->query,
-
'allrows'
=>$this->allrows)
-
)),
- 'sort_part_of_town_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'part_of_town_id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uip_of_town.index',
-
'district_id' =>
$this->district_id,
-
'query'
=>$this->query,
-
'allrows'
=>$this->allrows)
-
)),
- 'sort_category' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'descr',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uip_of_town.index',
-
'district_id'
=>$this->district_id,
-
'query'
=>$this->query,
-
'allrows'
=>$this->allrows)
-
)),
- 'lang_category' => lang('category')
- );
-
- $table_add = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_statustext' => lang('add a part of
town'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uip_of_town.edit')
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uip_of_town.index',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'district_id'
=>$this->district_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'links'
=> $links,
- 'allow_allrows'
=> true,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($p_of_towns_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
-
- 'district_list'
=> $this->bocommon->select_district_list('filter',$this->district_id),
- 'lang_no_district'
=> lang('no district'),
- 'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
- 'select_district_name' =>
'district_id',
-
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
- $this->save_sessiondata();
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('part of town') . ': ' . lang('list part of town');
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- function edit()
- {
- $part_of_town_id =
get_var('part_of_town_id',array('POST','GET'));
- $values = get_var('values',array('POST'));
-
- if($GLOBALS['phpgw']->is_repost())
- {
-// $receipt['error'][]=array('msg'=>lang('Repost
!'));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('p_of_town'));
-
- if ($values['save'] || $values['apply'])
- {
- if(!$values['district_id'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a district !'));
- }
-
- if(!$values['name'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter a name !'));
- }
-
- if(!$receipt['error'])
- {
- $values['part_of_town_id'] =
$part_of_town_id;
- $receipt = $this->bo->save($values);
- $part_of_town_id =
$receipt['part_of_town_id'];
- $this->district_id =
($values['district_id']?$values['district_id']:$this->district_id);
-
- if ($values['save'])
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','p_of_town_receipt',$receipt);
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uip_of_town.index');
- }
- }
- }
-
- if ($values['cancel'])
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uip_of_town.index');
- }
-
-
- if ($part_of_town_id)
- {
- $values =
$this->bo->read_single($part_of_town_id);
- $this->district_id =
($values['district_id']?$values['district_id']:$this->district_id);
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uip_of_town.edit',
- 'part_of_town_id' =>
$part_of_town_id
- );
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'abook_data'
=> $abook_data,
- 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_part_of_town_id' =>
lang('ID'),
- 'value_part_of_town_id' =>
$part_of_town_id,
- 'lang_name'
=> lang('name'),
- 'lang_district'
=> lang('District'),
- 'lang_save'
=> lang('save'),
- 'lang_cancel'
=> lang('cancel'),
- 'lang_apply'
=> lang('apply'),
- 'value_name'
=> $values['name'],
- 'lang_name_statustext' =>
lang('Enter a name for this part of town'),
- 'lang_apply_statustext' =>
lang('Apply the values'),
- 'lang_cancel_statustext' =>
lang('Leave the part of town untouched and return back to the list'),
- 'lang_save_statustext' =>
lang('Save the part of town and return back to the list'),
- 'lang_no_district'
=> lang('no district'),
- 'lang_district_statustext'
=> lang('Select the district the part of town belongs to.'),
- 'select_district_name' =>
'values[district_id]',
- 'district_list'
=> $this->bocommon->select_district_list('select',$this->district_id)
- );
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('part of town') . ': ' . ($part_of_town_id?lang('edit part og
town'):lang('add part of town'));
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- function delete()
- {
- $part_of_town_id =
get_var('part_of_town_id',array('POST','GET'));
- $delete = get_var('delete',array('POST'));
- $confirm = get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uip_of_town.index'
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($part_of_town_id);
-
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uip_of_town.delete&part_of_town_id='
. $part_of_town_id),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('aprt of town');
- $function_msg =
lang('delete part of town');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function view()
- {
- $part_of_town_id =
get_var('part_of_town_id',array('GET'));
- $action = get_var('action',array('GET'));
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('part of town') . ': ' . lang('view part of town');
-
- $GLOBALS['phpgw']->xslttpl->add_file('p_of_town');
-
- $p_of_town = $this->bo->read_single($part_of_town_id);
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uip_of_town.index'),
- 'lang_id' => lang('ID'),
- 'lang_name' => lang('name'),
- 'lang_district' => lang('District'),
- 'lang_done' => lang('done'),
- 'value_id' =>
$p_of_town['id'],
- 'value_name' => $p_of_town['name'],
- 'value_district' =>
$this->bo->read_district_name($p_of_town['district_id']),
- 'value_date' =>
$GLOBALS['phpgw']->common->show_date($p_of_town['entry_date'])
- );
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.uip_of_town.inc.php,v 1.9 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uip_of_town
+ {
+ var $grants;
+ var $district_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'view' => True,
+ 'edit' => True,
+ 'delete' => True
+ );
+
+ function uip_of_town()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $this->bo =
CreateObject($this->currentapp.'.bop_of_town',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+
+ $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->district_id =
$this->bo->district_id;
+ $this->allrows = $this->bo->allrows;
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' => $this->filter,
+ 'district_id' => $this->district_id,
+ 'this->allrows' => $this->allrows
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function index()
+ {
+ $GLOBALS['phpgw']->xslttpl->add_file(array('p_of_town',
+
'menu',
+
'receipt',
+
'search_field',
+
'nextmatchs'));
+
+ $links = $this->menu->links();
+
+ $receipt =
$GLOBALS['phpgw']->session->appsession('session_data','p_of_town_receipt');
+
$GLOBALS['phpgw']->session->appsession('session_data','p_of_town_receipt','');
+
+ $p_of_towns_list = $this->bo->read();
+
+ if (isSet($p_of_towns_list) AND
is_array($p_of_towns_list))
+ {
+ foreach($p_of_towns_list as $p_of_town)
+ {
+ $content[] = array
+ (
+ 'part_of_town_id'
=> $p_of_town['part_of_town_id'],
+ 'name'
=> $p_of_town['name'],
+ 'category'
=> $p_of_town['category'],
+ 'link_view'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uip_of_town.view&part_of_town_id='
. $p_of_town['part_of_town_id']),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uip_of_town.edit&part_of_town_id='
. $p_of_town['part_of_town_id']),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uip_of_town.delete&part_of_town_id='
. $p_of_town['part_of_town_id']),
+ 'lang_view_statustext'
=> lang('view the p_of_town'),
+ 'lang_edit_statustext'
=> lang('edit the p_of_town'),
+ 'lang_delete_statustext'
=> lang('delete the p_of_town'),
+ 'text_view'
=> lang('view'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+ }
+
+ $table_header = array
+ (
+ 'lang_name' => lang('name'),
+ 'lang_time_created' => lang('time created'),
+ 'lang_view' => lang('view'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'lang_part_of_town_id' => lang('Part
of town id'),
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uip_of_town.index',
+
'district_id' =>
$this->district_id,
+
'query'
=>$this->query,
+
'allrows'
=>$this->allrows)
+
)),
+ 'sort_part_of_town_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'part_of_town_id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uip_of_town.index',
+
'district_id' =>
$this->district_id,
+
'query'
=>$this->query,
+
'allrows'
=>$this->allrows)
+
)),
+ 'sort_category' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'descr',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uip_of_town.index',
+
'district_id'
=>$this->district_id,
+
'query'
=>$this->query,
+
'allrows'
=>$this->allrows)
+
)),
+ 'lang_category' => lang('category')
+ );
+
+ $table_add = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_statustext' => lang('add a part of
town'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uip_of_town.edit')
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uip_of_town.index',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'district_id'
=>$this->district_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'links'
=> $links,
+ 'allow_allrows'
=> true,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($p_of_towns_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+
+ 'district_list'
=> $this->bocommon->select_district_list('filter',$this->district_id),
+ 'lang_no_district'
=> lang('no district'),
+ 'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
+ 'select_district_name' =>
'district_id',
+
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+ $this->save_sessiondata();
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('part of town') . ': ' . lang('list part of town');
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ function edit()
+ {
+ $part_of_town_id =
get_var('part_of_town_id',array('POST','GET'));
+ $values = get_var('values',array('POST'));
+
+ if($GLOBALS['phpgw']->is_repost())
+ {
+// $receipt['error'][]=array('msg'=>lang('Repost
!'));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('p_of_town'));
+
+ if ($values['save'] || $values['apply'])
+ {
+ if(!$values['district_id'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a district !'));
+ }
+
+ if(!$values['name'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter a name !'));
+ }
+
+ if(!$receipt['error'])
+ {
+ $values['part_of_town_id'] =
$part_of_town_id;
+ $receipt = $this->bo->save($values);
+ $part_of_town_id =
$receipt['part_of_town_id'];
+ $this->district_id =
($values['district_id']?$values['district_id']:$this->district_id);
+
+ if ($values['save'])
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','p_of_town_receipt',$receipt);
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uip_of_town.index');
+ }
+ }
+ }
+
+ if ($values['cancel'])
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uip_of_town.index');
+ }
+
+
+ if ($part_of_town_id)
+ {
+ $values =
$this->bo->read_single($part_of_town_id);
+ $this->district_id =
($values['district_id']?$values['district_id']:$this->district_id);
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uip_of_town.edit',
+ 'part_of_town_id' =>
$part_of_town_id
+ );
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'abook_data'
=> $abook_data,
+ 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_part_of_town_id' =>
lang('ID'),
+ 'value_part_of_town_id' =>
$part_of_town_id,
+ 'lang_name'
=> lang('name'),
+ 'lang_district'
=> lang('District'),
+ 'lang_save'
=> lang('save'),
+ 'lang_cancel'
=> lang('cancel'),
+ 'lang_apply'
=> lang('apply'),
+ 'value_name'
=> $values['name'],
+ 'lang_name_statustext' =>
lang('Enter a name for this part of town'),
+ 'lang_apply_statustext' =>
lang('Apply the values'),
+ 'lang_cancel_statustext' =>
lang('Leave the part of town untouched and return back to the list'),
+ 'lang_save_statustext' =>
lang('Save the part of town and return back to the list'),
+ 'lang_no_district'
=> lang('no district'),
+ 'lang_district_statustext'
=> lang('Select the district the part of town belongs to.'),
+ 'select_district_name' =>
'values[district_id]',
+ 'district_list'
=> $this->bocommon->select_district_list('select',$this->district_id)
+ );
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('part of town') . ': ' . ($part_of_town_id?lang('edit part og
town'):lang('add part of town'));
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ function delete()
+ {
+ $part_of_town_id =
get_var('part_of_town_id',array('POST','GET'));
+ $delete = get_var('delete',array('POST'));
+ $confirm = get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uip_of_town.index'
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($part_of_town_id);
+
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uip_of_town.delete&part_of_town_id='
. $part_of_town_id),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('aprt of town');
+ $function_msg =
lang('delete part of town');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function view()
+ {
+ $part_of_town_id =
get_var('part_of_town_id',array('GET'));
+ $action = get_var('action',array('GET'));
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('part of town') . ': ' . lang('view part of town');
+
+ $GLOBALS['phpgw']->xslttpl->add_file('p_of_town');
+
+ $p_of_town = $this->bo->read_single($part_of_town_id);
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uip_of_town.index'),
+ 'lang_id' => lang('ID'),
+ 'lang_name' => lang('name'),
+ 'lang_district' => lang('District'),
+ 'lang_done' => lang('done'),
+ 'value_id' =>
$p_of_town['id'],
+ 'value_name' => $p_of_town['name'],
+ 'value_district' =>
$this->bo->read_district_name($p_of_town['district_id']),
+ 'value_date' =>
$GLOBALS['phpgw']->common->show_date($p_of_town['entry_date'])
+ );
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+ }
+?>
Index: property/inc/class.uipricebook.inc.php
diff -u property/inc/class.uipricebook.inc.php:1.12
property/inc/class.uipricebook.inc.php:1.13
--- property/inc/class.uipricebook.inc.php:1.12 Tue Nov 8 22:39:10 2005
+++ property/inc/class.uipricebook.inc.php Fri Jan 27 14:05:43 2006
@@ -1,1366 +1,1366 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage agreement
- * @version $Id: class.uipricebook.inc.php,v 1.12 2005/11/08 22:39:10
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uipricebook
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
- var $part_of_town_id;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'activity' => True,
- 'index' => True,
- 'agreement_group' => True,
- 'edit_agreement_group' => True,
- 'edit_activity' => True,
- 'activity_vendor' => True,
- 'prizing' => True,
- 'delete' => True,
- 'excel' => True,
- 'excel_2' => True
- );
-
- function uipricebook()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
-
- $this->bo =
CreateObject($this->currentapp.'.bopricebook',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
- $this->contacts =
CreateObject($this->currentapp.'.soactor');
- $this->contacts->role = 'vendor';
-
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
- $this->acl2_location = '.pricebook';
- $this->acl_read =
$this->acl2->check('.pricebook',1);
- $this->acl_add =
$this->acl2->check('.pricebook',2);
- $this->acl_edit =
$this->acl2->check('.pricebook',4);
- $this->acl_delete =
$this->acl2->check('.pricebook',8);
- $this->acl_manage =
$this->acl2->check('.pricebook',16);
-
- $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->allrows =
$this->bo->allrows;
-
- $this->menu->sub ='agreement';
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' => $this->filter,
- 'cat_id' => $this->cat_id,
- 'allrows' => $this->allrows
- );
- $this->bo->save_sessiondata($data);
- }
-
-
- function excel()
- {
-
- $list = $this->bo->read();
-
- $name =
array('num','branch','vendor_id','m_cost','w_cost','total_cost','this_index','unit','descr','index_count');
- $descr = array(lang('Activity Num'),
-
lang('Branch'),
-
lang('Vendor'),
-
lang('Material cost'),
-
lang('Labour cost'),
-
lang('Total Cost'),
-
lang('Last index'),
-
lang('Unit'),
-
lang('Description'),
-
lang('Index Count')
- );
-
- $this->bocommon->excel($list,$name,$descr);
- }
-
-
- function index()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
-
$GLOBALS['phpgw']->session->appsession('referer',$this->currentapp,'');
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('pricebook',
-
'menu',
-
'nextmatchs',
-
'search_field'));
-
- $links = $this->menu->links('price_vendor');
-
- $values =
get_var('values',array('POST'));
- $values['date'] = get_var('date',array('POST'));
-
-//_debug_array($values);
- if($values['submit_update'])
- {
- $receipt=$this->bo->update_pricebook($values);
- }
-
-
- $pricebook_list = $this->bo->read();
-
- $i=0;
- if (isSet($pricebook_list) AND
is_array($pricebook_list))
- {
- foreach($pricebook_list as $pricebook)
- {
- if($this->acl_manage)
- {
- $link_edit
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.edit_activity&activity_id='
. $pricebook['activity_id']);
- $link_prizing
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.prizing&activity_id='
. $pricebook['activity_id'].'&vendor_id=' . $pricebook['vendor_id']
.'&cat_id=' .$this->cat_id);
- $lang_edit_statustext
= lang('edit the pricebook');
- $lang_prizing_statustext
= lang('view or edit prizing history of this element');
- $text_edit
= lang('edit');
- $text_prizing
= lang('prizing');
- }
-
- $content[] = array
- (
- 'counter'
=> $i,
- 'activity_id'
=> $pricebook['activity_id'],
- 'num'
=> $pricebook['num'],
- 'branch'
=> $pricebook['branch'],
- 'vendor_id'
=> $pricebook['vendor_id'],
- 'm_cost'
=> $pricebook['m_cost'],
- 'w_cost'
=> $pricebook['w_cost'],
- 'total_cost'
=> $pricebook['total_cost'],
- 'this_index'
=> $pricebook['this_index'],
- 'unit'
=> $pricebook['unit'],
- 'descr'
=> $pricebook['descr'],
- 'index_count'
=> $pricebook['index_count'],
- 'link_edit'
=> $link_edit,
- 'link_prizing'
=> $link_prizing,
- 'lang_edit_statustext'
=> $lang_edit_statustext,
- 'lang_prizing_statustext'
=> $lang_prizing_statustext,
- 'text_edit'
=> $text_edit,
- 'text_prizing'
=> $text_prizing
- );
-
- $i++;
- }
- }
-
- $table_header[] = array
- (
- 'sort_num' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'num',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uipricebook.index',
-
'cat_id'
=>$this->cat_id,
-
'allrows'
=>$this->allrows)
-
)),
- 'lang_index_count' => lang('Index Count'),
- 'lang_num' =>
lang('Activity Num'),
- 'lang_branch' => lang('Branch'),
- 'lang_vendor' => lang('Vendor'),
- 'lang_select' => lang('Select'),
- 'lang_total_cost' => lang('Total Cost'),
- 'lang_prizing' => lang('Prizing'),
- 'lang_last_index' => lang('Last index'),
- 'lang_descr' => lang('Description'),
- 'lang_m_cost' => lang('Material
cost'),
- 'lang_w_cost' => lang('Labour cost'),
- 'lang_prizing' => lang('Prizing'),
- 'lang_unit' => lang('Unit'),
- 'lang_view' => lang('view'),
- 'lang_edit' => lang('edit'),
- 'sort_total_cost' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'total_cost',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uipricebook.index',
-
'cat_id'
=>$this->cat_id,
-
'allrows'
=>$this->allrows)
-
))
- );
-
-
- if($this->acl_manage)
- {
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
- $table_update[] = array
- (
- 'jsDateFormat'
=> $jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle'
=> lang('Select date'),
- 'calendar_setup'
=> "Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat .
"',button : 'date-trigger'});",
- 'lang_new_index'
=> lang('New index'),
- 'lang_new_index_statustext' =>
lang('Enter a new index'),
- 'lang_date_statustext' =>
lang('Select the date for the update'),
- 'lang_update'
=> lang('Update'),
- 'lang_update_statustext' =>
lang('update selected investments')
- );
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uipricebook.index',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $link_excel = array
- (
- 'menuaction' =>
$this->currentapp.'.uipricebook.excel',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query,
- 'allrows'
=>$this->allrows,
- 'start' =>$this->start
- );
-
- $data = array
- (
- 'lang_excel' =>
'excel',
- 'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
- 'lang_excel_help' =>
lang('Download table to MS Excel'),
-
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'links'
=> $links,
- 'allrows'
=> $this->allrows,
- 'allow_allrows'
=> true,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($pricebook_list),
- 'all_records'
=> $this->bo->total_records,
- 'lang_select_all'
=> lang('Select All'),
- 'img_check'
=>
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
- 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the pricebook belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $this->bo->get_vendor_list('filter',$this->cat_id),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' =>
'yes')),
- 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_update'
=> $table_update,
- 'update_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.index')
);
-
- $appname
= lang('pricebook');
- $function_msg =
lang('list pricebook per vendor');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function agreement_group()
- {
- if(!$this->acl_manage)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=16&acl_location='
. $this->acl2_location);
- }
-
-
$GLOBALS['phpgw']->session->appsession('referer',$this->currentapp,'');
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('pricebook',
-
'menu',
-
'nextmatchs',
-
'search_field'));
-
- $links =
$this->menu->links('agreement','agreement_group');
-
- $agreement_list = $this->bo->read_agreement_group();
-
- while (is_array($agreement_list) && list(,$agreement) =
each($agreement_list))
- {
- $content[] = array
- (
- 'agreement_group_id'
=> $agreement['agreement_group_id'],
- 'num'
=> $agreement['num'],
- 'status'
=> lang($agreement['status']),
- 'descr'
=> $agreement['descr'],
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.edit_agreement_group&agreement_group_id='
. $agreement['agreement_group_id']),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.delete&method=agreement_group&agreement_group_id='
. $agreement['agreement_group_id'] .'&start=' . $this->start),
- 'lang_edit_statustext' =>
lang('edit the agreement_group'),
- 'lang_delete_statustext' =>
lang('Delete this agreement_group'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
-
- $table_header[] = array
- (
- 'lang_id' => lang('ID'),
- 'sort_num' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'num',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uipricebook.agreement_group',
-
'cat_id'
=>$this->cat_id,
-
'allrows'
=>$this->allrows)
-
)),
- 'lang_num' =>
lang('Activity Num'),
- 'lang_delete' => lang('Delete'),
- 'lang_descr' => lang('Description'),
- 'lang_edit' => lang('edit')
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uipricebook.agreement_group',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_statustext' => lang('add an
activity'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.edit_agreement_group')
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $data = array
- (
- 'links'
=> $links,
- 'allrows'
=> $this->allrows,
- 'allow_allrows'
=> true,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($agreement_list),
- 'all_records'
=> $this->bo->total_records,
- 'lang_select_all'
=> lang('Select All'),
- 'img_check'
=>
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
- 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_status_statustext' =>
lang('Select the status the agreement group belongs to. To do not use a
category select NO STATUS'),
- 'status_name'
=> 'cat_id',
- 'lang_no_status'
=> lang('No status'),
- 'status_list'
=> $this->bo->select_status_list('filter',$this->cat_id),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' =>
'yes')),
- 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_agreement_group' =>
$table_header,
- 'values_agreement_group'
=> $content,
- 'table_add'
=> $table_add,
- 'update_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.agreement_group')
- );
-
- $appname
= lang('pricebook');
- $function_msg =
lang('list agreement group');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('agreement_group' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit_agreement_group()
- {
- if(!$this->acl_manage)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=16&acl_location='
. $this->acl2_location);
- }
-
- $agreement_group_id =
get_var('agreement_group_id',array('POST','GET'));
- $values =
get_var('values',array('POST','GET'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('pricebook'));
-
- if ($values['save'])
- {
- $values['agreement_group_id'] =
$agreement_group_id;
-
- if(!$values['num'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter an agreement group code
!'));
- $error_id=true;
- }
- if(!$values['status'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a status !'));
- }
-
-
- if($values['num'] && !$agreement_group_id)
- {
-
if($this->bo->check_agreement_group_num($values['num']))
- {
-
$receipt['error'][]=array('msg'=>lang('This agreement group code is already
registered!') . '[ '.$values['num'] .' ]');
- $error_id=true;
- }
- }
-
- if($agreement_group_id)
- {
- $action='edit';
- }
-
- if(!$receipt['error'])
- {
- $receipt =
$this->bo->save_agreement_group($values,$action);
- if(!$agreement_group_id)
- {
-
$agreement_group_id=$receipt['agreement_group_id'];
- }
-
- }
-
- if($agreement_group_id)
- {
-
$values['agreement_group_id']=$agreement_group_id;
- $action='edit';
- }
- else
- {
- $agreement_group_id =
$values['agreement_group_id'];
- }
- }
- else
- {
- $values['agreement_group_id']=
$agreement_group_id;
- if($agreement_group_id)
- {
- $values =
$this->bo->read_single_agreement_group($agreement_group_id);
- }
- }
-
-//_debug_array($values);
- if ($agreement_group_id)
- {
- $function_msg = lang('edit agreement group');
- }
- else
- {
- $function_msg = lang('add agreement_group');
- }
-
- if ($values['cat_id'] > 0)
- {
- $this->cat_id = $values['cat_id'];
- }
-
- if($error_id)
- {
- unset($values['num']);
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uipricebook.edit_agreement_group',
- 'agreement_group_id' => $agreement_group_id
- );
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.agreement_group'),
- 'lang_agreement_group_id' =>
lang('Agreement group ID'),
- 'lang_num'
=> lang('Agreement group code'),
- 'lang_status'
=> lang('Status'),
- 'status_list'
=> $this->bo->select_status_list('select',$values['status']),
- 'status_name'
=> 'values[status]',
- 'lang_no_status'
=> lang('Select status'),
-
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'lang_descr'
=> lang('description'),
- 'value_agreement_group_id' =>
$values['agreement_group_id'],
- 'value_num'
=> $values['num'],
- 'value_descr'
=> $values['descr'],
- 'lang_num_statustext' =>
lang('A unique code for this activity'),
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'lang_save_statustext' =>
lang('Save the building'),
- 'lang_descr_statustext' =>
lang('Enter the description for this activity')
- );
-
- $appname
= lang('pricebook');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_agreement_group' =>
$data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- function prizing()
- {
- if(!$this->acl_manage)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=16&acl_location='
. $this->acl2_location);
- }
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('pricebook',
-
'menu',
-
'nextmatchs',
-
'search_field'));
-
- $links = $this->menu->links();
-
- $cat_id =
get_var('cat_id',array('GET'));
- $activity_id =
get_var('activity_id',array('GET'));
- $vendor_id =
get_var('vendor_id',array('GET'));
- $values =
get_var('values',array('POST'));
- $values['date'] = get_var('date',array('POST'));
-
-
- $referer =
$GLOBALS['phpgw']->session->appsession('referer',$this->currentapp);
- if(!$referer)
- {
- $referer =
$GLOBALS['HTTP_SERVER_VARS']['HTTP_REFERER'] ?
$GLOBALS['HTTP_SERVER_VARS']['HTTP_REFERER'] : $GLOBALS['HTTP_REFERER'];
- $referer = $referer . '&cat_id=' . $cat_id;
-
$GLOBALS['phpgw']->session->appsession('referer',$this->currentapp,$referer);
- }
-
- if($values['submit_update'])
- {
- if(!$values['date'])
- {
- $receipt['error'][] =
array('msg'=>lang('Please select a date !'));
- }
-
- if(!$values['new_index'])
- {
- $receipt['error'][] =
array('msg'=>lang('Please enter a new index for calkulating next value(s)!'));
- }
-
- if(!$receipt['error'])
- {
-
$receipt=$this->bo->update_pricebook($values);
- }
- }
-
- if($values['submit_add'])
- {
- if(!$values['date'])
- {
- $receipt['error'][] =
array('msg'=>lang('Please select a date !'));
- }
-
- if(!$values['m_cost'] && !$values['w_cost'])
- {
- $receipt['error'][] =
array('msg'=>lang('Please enter a value for either material cost, labour cost
or both !'));
- }
-
- if(!$receipt['error'])
- {
-
$receipt=$this->bo->add_activity_first_prize($values);
- }
- }
-
-
- $pricebook_list =
$this->bo->read_activity_prize($activity_id,$vendor_id);
-
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-
- if (isSet($pricebook_list) AND
is_array($pricebook_list))
- {
- foreach($pricebook_list as $pricebook)
- {
-
- if($pricebook['current_index'])
- {
- $link_delete =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.delete&method=prize&activity_id='
. $activity_id .'&vendor_id=' . $vendor_id .'&index_count=' .
$pricebook['index_count']);
- $value_m_cost =
$pricebook['m_cost'];
- $value_w_cost =
$pricebook['w_cost'];
- $value_total_cost =
$pricebook['total_cost'];
- }
-
- $content[] = array
- (
- 'm_cost'
=> $pricebook['m_cost'],
- 'w_cost'
=> $pricebook['w_cost'],
- 'total_cost'
=> $pricebook['total_cost'],
- 'this_index'
=> $pricebook['this_index'],
- 'date'
=>
$GLOBALS['phpgw']->common->show_date($pricebook['date'],$dateformat),
- 'current_index'
=> $pricebook['current_index'],
- 'index_count'
=> $pricebook['index_count'],
- 'link_delete'
=> $link_delete,
- 'lang_delete_statustext'
=> lang('Delete this entry'),
- 'text_delete'
=> lang('delete'),
- );
- }
- }
-
-//_debug_array($content);
- $table_header[] = array
- (
- 'lang_index_count' => lang('Index Count'),
- 'lang_total_cost' => lang('Total Cost'),
- 'lang_prizing' => lang('Prizing'),
- 'lang_last_index' => lang('Last index'),
- 'lang_m_cost' => lang('Material
cost'),
- 'lang_w_cost' => lang('Labour cost'),
- 'lang_date' => lang('Date'),
- 'lang_delete' => lang('Delete')
- );
-
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
- $table_update[] = array
- (
- 'jsDateFormat' =>
$jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle' =>
lang('Select date'),
- 'calendar_setup' =>
"Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat .
"',button : 'date-trigger'});",
- 'lang_new_index' =>
lang('New index'),
- 'lang_new_index_statustext' => lang('Enter
a new index'),
- 'lang_date_statustext' => lang('Select
the date for the update'),
- 'lang_update' =>
lang('Update'),
- 'lang_update_statustext' => lang('update
selected investments')
- );
-
- $table_first_entry[] = array
- (
- 'jsDateFormat' =>
$jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle' =>
lang('Select date'),
- 'calendar_setup' =>
"Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat .
"',button : 'date-trigger'});",
- 'lang_m_cost' =>
lang('Material cost'),
- 'lang_m_cost_statustext' => lang('Enter
a value for the material cost'),
- 'lang_w_cost' =>
lang('Labour cost'),
- 'lang_w_cost_statustext' => lang('Enter
a value for the labour cost'),
- 'lang_date'
=> lang('Date'),
- 'lang_date_statustext' => lang('Select
the date for the first value'),
- 'lang_add' =>
lang('Add'),
- 'lang_add_statustext' => lang('Add first
value for this prizing')
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uipricebook.prizing',
- 'activity_id' =>$activity_id,
- 'vendor_id'
=>$vendor_id
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $num_records = count($pricebook_list);
-
-
- $vendor_data =
$this->contacts->read_single(array('actor_id'=>$vendor_id));
-
- if(is_array($vendor_data))
- {
- foreach($vendor_data['attributes'] as
$attribute)
- {
- if($attribute['name']=='org_name')
- {
-
$value_vendor_name=$attribute['value'];
- break;
- }
- }
- }
-
- $activity =
$this->bo->read_single_activity($activity_id);
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'done_action'
=> $referer,
- 'lang_done'
=> lang('done'),
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'links'
=> $links,
- 'allrows'
=> $this->allrows,
- 'allow_allrows'
=> true,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> $num_records,
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_vendor'
=> lang('Vendor'),
- 'lang_activity'
=> lang('Activity'),
-
- 'value_vendor_name'
=> $value_vendor_name,
- 'value_activity_id'
=> $activity_id,
- 'value_activity_code' =>
$activity['num'],
- 'value_vendor_id'
=> $vendor_id,
- 'value_m_cost'
=> $value_m_cost,
- 'value_w_cost'
=> $value_w_cost,
- 'value_total_cost'
=> $value_total_cost,
- 'table_header_prizing' =>
$table_header,
- 'values_prizing'
=> $content,
- 'table_update'
=> $table_update,
- 'table_first_entry'
=> $table_first_entry,
- 'update_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.prizing&activity_id='
. $activity_id . '&vendor_id=' . $vendor_id)
- );
-
- $appname
= lang('pricebook');
- $function_msg =
lang('edit pricing');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('prizing' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
-
- function excel_2()
- {
-
- $list = $this->bo->read_activities_pr_agreement_group();
-
- $name = array(
- 'activity_id',
- 'base_descr',
- 'num',
- 'descr',
- // 'branch',
- // 'dim_d',
- 'ns3420',
- 'unit',
- );
-
- $descr = array(
- 'ID',
- lang('Base'),
- lang('Activity Num'),
- lang('Description'),
- // lang('Branch'),
- // lang('Dim d'),
- lang('NS3420'),
- lang('Unit'),
- );
-
-
- $this->bocommon->excel($list,$name,$descr);
- }
-
-
- function activity()
- {
- if(!$this->acl_manage)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=16&acl_location='
. $this->acl2_location);
- }
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('pricebook',
-
'menu',
-
'nextmatchs',
-
'search_field'));
-
- $links = $this->menu->links('agreement','activity');
-
- $pricebook_list =
$this->bo->read_activities_pr_agreement_group();
-//_debug_array($pricebook_list);
- while (is_array($pricebook_list) && list(,$pricebook) =
each($pricebook_list))
- {
- $content[] = array
- (
- 'activity_id'
=> $pricebook['activity_id'],
- 'num'
=> $pricebook['num'],
- 'branch'
=> $pricebook['branch'],
- 'base_descr'
=> $pricebook['base_descr'],
- 'dim_d'
=> $pricebook['dim_d'],
- 'ns3420'
=> $pricebook['ns3420'],
- 'unit'
=> $pricebook['unit'],
- 'descr'
=> $pricebook['descr'],
- 'link_vendor'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.activity_vendor&activity_id='
. $pricebook['activity_id'].'&agreement_group=' . $this->cat_id),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.edit_activity&activity_id='
. $pricebook['activity_id'].'&agreement_group=' . $this->cat_id),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.delete&method=activity&activity_id='
. $pricebook['activity_id']),
- 'lang_vendor_statustext' =>
lang('view the vendor(s) for this activity'),
- 'lang_edit_statustext' =>
lang('edit this activity'),
- 'lang_delete_statustext' =>
lang('delete this activity'),
- 'text_vendor'
=> lang('vendor'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
-
- $table_header[] = array
- (
- 'sort_num' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'num',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uipricebook.activity',
-
'cat_id'
=>$this->cat_id,
-
'allrows'
=>$this->allrows)
-
)),
- 'lang_num' =>
lang('Activity Num'),
- 'lang_branch' => lang('Branch'),
- 'lang_vendor' => lang('Vendor'),
- 'lang_descr' => lang('Description'),
- 'lang_base_descr' => lang('Base'),
- 'lang_dim_d' => lang('Dim d'),
- 'lang_ns3420' => lang('NS3420'),
- 'lang_unit' => lang('Unit'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete')
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_statustext' => lang('add an
activity'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.edit_activity&agreement_group='
. $this->cat_id)
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uipricebook.activity',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $link_excel = array
- (
- 'menuaction' =>
$this->currentapp.'.uipricebook.excel_2',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query,
- 'allrows'
=>$this->allrows,
- 'start' =>$this->start
- );
-
- $data = array
- (
- 'lang_excel' =>
'excel',
- 'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
- 'lang_excel_help' =>
lang('Download table to MS Excel'),
- 'links'
=> $links,
- 'allrows'
=> $this->allrows,
- 'allow_allrows'
=> true,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($pricebook_list),
- 'all_records'
=> $this->bo->total_records,
- 'lang_select_all'
=> lang('Select All'),
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_no_cat'
=> lang('select agreement_group'),
- 'lang_cat_statustext' =>
lang('Select the agreement_group the pricebook belongs to. To do not use a
category select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $this->bo->get_agreement_group_list('filter',$this->cat_id),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' =>
'yes')),
- 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_activities' =>
$table_header,
- 'values_activities'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('pricebook');
- $function_msg =
lang('list activities per agreement_group');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_activities' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function activity_vendor()
- {
- if(!$this->acl_manage)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=16&acl_location='
. $this->acl2_location);
- }
-
-
$GLOBALS['phpgw']->session->appsession('referer',$this->currentapp,'');
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('pricebook',
-
'menu',
-
'nextmatchs',
-
'search_field'));
-
- $links = $this->menu->links('agreement','activity');
-
- $activity_id =
get_var('activity_id',array('GET'));
- $values =
get_var('values',array('POST'));
- $values['vendor_id'] =
get_var('vendor_id',array('POST'));
-
- if($values['add'])
- {
- if(!$values['vendor_id'])
- {
- $receipt['error'][] =
array('msg'=>lang('Please - select a vendor!'));
- }
- else
- {
- $receipt =
$this->bo->add_activity_vendor($values);
- }
- }
-
- $pricebook_list =
$this->bo->read_vendor_pr_activity($activity_id);
-
- while (is_array($pricebook_list) && list(,$pricebook) =
each($pricebook_list))
- {
- $content[] = array
- (
- 'activity_id'
=> $pricebook['activity_id'],
- 'num'
=> $pricebook['num'],
- 'branch'
=> $pricebook['branch'],
- 'vendor_name'
=> $pricebook['vendor_name'],
- 'link_prizing'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.prizing&activity_id='
. $pricebook['activity_id'].'&vendor_id=' . $pricebook['vendor_id']),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.delete&method=activity_vendor&activity_id='
. $pricebook['activity_id'].'&vendor_id=' . $pricebook['vendor_id']),
- 'lang_prizing_statustext' =>
lang('view edit the prize for this activity'),
- 'lang_delete_statustext' =>
lang('delete this vendor from this activity'),
- 'text_prizing'
=> lang('Prizing'),
- 'text_delete'
=> lang('delete')
- );
- }
-
- $table_header[] = array
- (
- 'sort_vendor' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'org_name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uipricebook.activity_vendor',
-
'cat_id'
=>$this->cat_id,
-
'activity_id'
=>$activity_id,
-
'allrows'
=>$this->allrows)
-
)),
- 'lang_num' =>
lang('Activity Num'),
- 'lang_branch' => lang('Branch'),
- 'lang_vendor' => lang('Vendor'),
- 'lang_prizing' => lang('Prizing'),
- 'lang_delete' => lang('delete')
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uipricebook.activity_vendor',
- 'sort' =>
$this->sort,
- 'order' =>
$this->order,
- 'cat_id' =>
$this->cat_id,
- 'filter' =>
$this->filter,
- 'query' =>
$this->query,
- 'activity_id' => $activity_id
- );
-
-
-
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
- 'vendor_id' => ''));
-
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'activity_id'
=> $activity_id,
- 'vendor_data'
=> $vendor_data,
- 'links'
=> $links,
- 'allrows'
=> $this->allrows,
- 'allow_allrows'
=> true,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($pricebook_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_no_cat'
=> lang('select agreement_group'),
- 'lang_cat_statustext' =>
lang('Select the agreement_group the pricebook belongs to. To do not use a
category select NO CATEGORY'),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_activity_vendor' =>
$table_header,
- 'values_activity_vendor' =>
$content,
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'lang_save_statustext' =>
lang('Add this vendor to this activity'),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.activity&cat_id='
. $values['cat_id']),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
-
- );
-
- $appname
= lang('pricebook');
- $function_msg =
lang('list vendors per activity');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_activity_vendor' =>
$data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit_activity()
- {
- if(!$this->acl_manage)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=16&acl_location='
. $this->acl2_location);
- }
-
- $activity_id =
get_var('activity_id',array('POST','GET'));
- $agreement_group =
get_var('agreement_group',array('GET'));
- $values =
get_var('values',array('POST','GET'));
- $values['ns3420_id']=
get_var('ns3420_id',array('POST','GET'));
-
- if(!$values['cat_id'])
- {
- $values['cat_id'] = $agreement_group;
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('pricebook'));
-
- if ($values['save'])
- {
- if(!$values['num'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter an activity code !'));
- $error_id=true;
- }
- if(!$values['cat_id'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select an agreement_group !'));
- }
-
- if(!$values['branch_id'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a branch !'));
- }
-
- if($values['num'] && !$activity_id)
- {
-
if($this->bo->check_activity_num($values['num'],$values['cat_id']))
- {
-
$receipt['error'][]=array('msg'=>lang('This activity code is already
registered!') . '[ '.$values['num'] .' ]');
- $error_id=true;
- }
- }
-
- if($activity_id)
- {
- $values['activity_id']=$activity_id;
- $action='edit';
- }
- else
- {
- $activity_id = $values['activity_id'];
- }
-
- if(!$receipt['error'])
- {
- $receipt =
$this->bo->save_activity($values,$action);
- $activity_id= $receipt['activity_id'];
- $values['activity_id']= $activity_id;
- }
-
- }
- else
- {
- $values['activity_id']= $activity_id;
- if($activity_id)
- {
- $values =
$this->bo->read_single_activity($activity_id);
- }
- }
-
-//_debug_array($values);
- if ($activity_id)
- {
- $function_msg = lang('edit activity');
- }
- else
- {
- $function_msg = lang('add activity');
- }
-
- if ($values['cat_id'] > 0)
- {
- $this->cat_id = $values['cat_id'];
- }
-
- if($error_id)
- {
- unset($values['num']);
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uipricebook.edit_activity',
- 'activity_id' => $activity_id,
- 'agreement_group' =>
$agreement_group
- );
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.activity&cat_id='
. $values['cat_id']),
- 'lang_activity_id'
=> lang('Activity ID'),
- 'lang_num'
=> lang('Activity code'),
- 'lang_category'
=> lang('Agreement group'),
- 'lang_unit'
=> lang('Unit'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'lang_descr'
=> lang('description'),
- 'lang_base_descr'
=> lang('Base description'),
- 'value_activity_id'
=> $values['activity_id'],
- 'value_num'
=> $values['num'],
- 'value_general_address' =>
$values['general_address'],
- 'value_access'
=> $values['access'],
- 'value_descr'
=> $values['descr'],
- 'value_base_descr'
=> $values['base_descr'],
- 'lang_num_statustext' =>
lang('A unique code for this activity'),
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'lang_save_statustext' =>
lang('Save the building'),
- 'lang_no_cat'
=> lang('Select agreement group'),
- 'lang_cat_statustext' =>
lang('Select the agreement group this activity belongs to.'),
- 'select_name'
=> 'values[cat_id]',
- 'lang_descr_statustext' =>
lang('Enter the description for this activity'),
- 'lang_base_descr_statustext' => lang('Enter
a description for prerequisitions for this activity - if any'),
- 'cat_list'
=> $this->bo->get_agreement_group_list('select',$values['cat_id']),
-
- 'lang_dim_d'
=> lang('Dim D'),
- 'dim_d_list'
=> $this->bo->get_dim_d_list($values['dim_d']),
- 'select_dim_d'
=> 'values[dim_d]',
- 'lang_no_dim_d'
=> lang('No Dim D'),
- 'lang_dim_d_statustext' =>
lang('Select the Dim D for this activity. To do not use Dim D - select NO DIM
D'),
-
- 'lang_unit'
=> lang('Unit'),
- 'unit_list'
=> $this->bo->get_unit_list($values['unit']),
- 'select_unit'
=> 'values[unit]',
- 'lang_no_unit'
=> lang('Select Unit'),
- 'lang_unit_statustext' =>
lang('Select the unit for this activity.'),
-
- 'lang_branch'
=> lang('Branch'),
- 'branch_list'
=> $this->bo->get_branch_list($values['branch_id']),
- 'select_branch'
=> 'values[branch_id]',
- 'lang_no_branch'
=> lang('Select branch'),
- 'lang_branch_statustext' =>
lang('Select the branch for this activity.'),
-
- 'ns3420_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.ns3420'),
- 'lang_ns3420'
=> lang('NS3420'),
- 'value_ns3420_id'
=> $values['ns3420_id'],
- 'lang_ns3420_statustext' =>
lang('Select a standard-code from the norwegian standard'),
- );
-
- $appname
= lang('pricebook');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_activity' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function delete()
- {
- if(!$this->acl_manage)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=16&acl_location='
. $this->acl2_location);
- }
-
- $method =
get_var('method',array('GET'));
- $activity_id = get_var('activity_id',array('GET'));
- $vendor_id =
get_var('vendor_id',array('GET'));
- $index_count = get_var('index_count',array('GET'));
- $agreement_group_id =
get_var('agreement_group_id',array('GET'));
- $confirm =
get_var('confirm',array('POST'));
-
- if($method=='activity_vendor')
- {
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uipricebook.activity_vendor',
- 'activity_id' => $activity_id
- );
-
- $function_msg =lang('delete vendor activity');
- $delete_action =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.delete&method='
. $method . '&activity_id=' . $activity_id . '&vendor_id=' . $vendor_id);
-
- if (get_var('confirm',array('POST')))
- {
-
$this->bo->delete_activity_vendor($activity_id,$vendor_id);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
- }
- elseif($method=='activity')
- {
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uipricebook.activity'
- );
-
- $function_msg =lang('delete activity');
- $delete_action =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.delete&method='
. $method . '&activity_id=' . $activity_id);
-
- if (get_var('confirm',array('POST')))
- {
-
$this->bo->delete_activity($activity_id);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
- }
- elseif($method=='prize')
- {
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uipricebook.prizing',
- 'activity_id' => $activity_id,
- 'vendor_id' => $vendor_id
- );
-
- $function_msg =lang('delete prize-index');
- $delete_action =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.delete&method='
. $method . '&activity_id=' . $activity_id . '&vendor_id=' . $vendor_id .
'&index_count=' . $index_count);
-
- if (get_var('confirm',array('POST')))
- {
-
$this->bo->delete_prize_index($activity_id,$vendor_id,$index_count);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
- }
- elseif($method=='agreement_group')
- {
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uipricebook.agreement_group',
- 'start' => $this->start
- );
-
- $function_msg =lang('Delete agreement group
and all the activities associated with it!');
- $delete_action =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.delete&method='
. $method . '&agreement_group_id=' . $agreement_group_id . '&start=' .
$this->start);
-
- if (get_var('confirm',array('POST')))
- {
-
$this->bo->delete_agreement_group($agreement_group_id);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$delete_action,
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('pricebook');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage agreement
+ * @version $Id: class.uipricebook.inc.php,v 1.13 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uipricebook
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+ var $part_of_town_id;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'activity' => True,
+ 'index' => True,
+ 'agreement_group' => True,
+ 'edit_agreement_group' => True,
+ 'edit_activity' => True,
+ 'activity_vendor' => True,
+ 'prizing' => True,
+ 'delete' => True,
+ 'excel' => True,
+ 'excel_2' => True
+ );
+
+ function uipricebook()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+
+ $this->bo =
CreateObject($this->currentapp.'.bopricebook',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+ $this->contacts =
CreateObject($this->currentapp.'.soactor');
+ $this->contacts->role = 'vendor';
+
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+ $this->acl2_location = '.pricebook';
+ $this->acl_read =
$this->acl2->check('.pricebook',1);
+ $this->acl_add =
$this->acl2->check('.pricebook',2);
+ $this->acl_edit =
$this->acl2->check('.pricebook',4);
+ $this->acl_delete =
$this->acl2->check('.pricebook',8);
+ $this->acl_manage =
$this->acl2->check('.pricebook',16);
+
+ $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->allrows =
$this->bo->allrows;
+
+ $this->menu->sub ='agreement';
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' => $this->filter,
+ 'cat_id' => $this->cat_id,
+ 'allrows' => $this->allrows
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+
+ function excel()
+ {
+
+ $list = $this->bo->read();
+
+ $name =
array('num','branch','vendor_id','m_cost','w_cost','total_cost','this_index','unit','descr','index_count');
+ $descr = array(lang('Activity Num'),
+
lang('Branch'),
+
lang('Vendor'),
+
lang('Material cost'),
+
lang('Labour cost'),
+
lang('Total Cost'),
+
lang('Last index'),
+
lang('Unit'),
+
lang('Description'),
+
lang('Index Count')
+ );
+
+ $this->bocommon->excel($list,$name,$descr);
+ }
+
+
+ function index()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+
$GLOBALS['phpgw']->session->appsession('referer',$this->currentapp,'');
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('pricebook',
+
'menu',
+
'nextmatchs',
+
'search_field'));
+
+ $links = $this->menu->links('price_vendor');
+
+ $values =
get_var('values',array('POST'));
+ $values['date'] = get_var('date',array('POST'));
+
+//_debug_array($values);
+ if($values['submit_update'])
+ {
+ $receipt=$this->bo->update_pricebook($values);
+ }
+
+
+ $pricebook_list = $this->bo->read();
+
+ $i=0;
+ if (isSet($pricebook_list) AND
is_array($pricebook_list))
+ {
+ foreach($pricebook_list as $pricebook)
+ {
+ if($this->acl_manage)
+ {
+ $link_edit
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.edit_activity&activity_id='
. $pricebook['activity_id']);
+ $link_prizing
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.prizing&activity_id='
. $pricebook['activity_id'].'&vendor_id=' . $pricebook['vendor_id']
.'&cat_id=' .$this->cat_id);
+ $lang_edit_statustext
= lang('edit the pricebook');
+ $lang_prizing_statustext
= lang('view or edit prizing history of this element');
+ $text_edit
= lang('edit');
+ $text_prizing
= lang('prizing');
+ }
+
+ $content[] = array
+ (
+ 'counter'
=> $i,
+ 'activity_id'
=> $pricebook['activity_id'],
+ 'num'
=> $pricebook['num'],
+ 'branch'
=> $pricebook['branch'],
+ 'vendor_id'
=> $pricebook['vendor_id'],
+ 'm_cost'
=> $pricebook['m_cost'],
+ 'w_cost'
=> $pricebook['w_cost'],
+ 'total_cost'
=> $pricebook['total_cost'],
+ 'this_index'
=> $pricebook['this_index'],
+ 'unit'
=> $pricebook['unit'],
+ 'descr'
=> $pricebook['descr'],
+ 'index_count'
=> $pricebook['index_count'],
+ 'link_edit'
=> $link_edit,
+ 'link_prizing'
=> $link_prizing,
+ 'lang_edit_statustext'
=> $lang_edit_statustext,
+ 'lang_prizing_statustext'
=> $lang_prizing_statustext,
+ 'text_edit'
=> $text_edit,
+ 'text_prizing'
=> $text_prizing
+ );
+
+ $i++;
+ }
+ }
+
+ $table_header[] = array
+ (
+ 'sort_num' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'num',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uipricebook.index',
+
'cat_id'
=>$this->cat_id,
+
'allrows'
=>$this->allrows)
+
)),
+ 'lang_index_count' => lang('Index Count'),
+ 'lang_num' =>
lang('Activity Num'),
+ 'lang_branch' => lang('Branch'),
+ 'lang_vendor' => lang('Vendor'),
+ 'lang_select' => lang('Select'),
+ 'lang_total_cost' => lang('Total Cost'),
+ 'lang_prizing' => lang('Prizing'),
+ 'lang_last_index' => lang('Last index'),
+ 'lang_descr' => lang('Description'),
+ 'lang_m_cost' => lang('Material
cost'),
+ 'lang_w_cost' => lang('Labour cost'),
+ 'lang_prizing' => lang('Prizing'),
+ 'lang_unit' => lang('Unit'),
+ 'lang_view' => lang('view'),
+ 'lang_edit' => lang('edit'),
+ 'sort_total_cost' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'total_cost',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uipricebook.index',
+
'cat_id'
=>$this->cat_id,
+
'allrows'
=>$this->allrows)
+
))
+ );
+
+
+ if($this->acl_manage)
+ {
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+ $table_update[] = array
+ (
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle'
=> lang('Select date'),
+ 'calendar_setup'
=> "Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat .
"',button : 'date-trigger'});",
+ 'lang_new_index'
=> lang('New index'),
+ 'lang_new_index_statustext' =>
lang('Enter a new index'),
+ 'lang_date_statustext' =>
lang('Select the date for the update'),
+ 'lang_update'
=> lang('Update'),
+ 'lang_update_statustext' =>
lang('update selected investments')
+ );
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uipricebook.index',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $link_excel = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uipricebook.excel',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query,
+ 'allrows'
=>$this->allrows,
+ 'start' =>$this->start
+ );
+
+ $data = array
+ (
+ 'lang_excel' =>
'excel',
+ 'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
+ 'lang_excel_help' =>
lang('Download table to MS Excel'),
+
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'links'
=> $links,
+ 'allrows'
=> $this->allrows,
+ 'allow_allrows'
=> true,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($pricebook_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'lang_select_all'
=> lang('Select All'),
+ 'img_check'
=>
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
+ 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the pricebook belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $this->bo->get_vendor_list('filter',$this->cat_id),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' =>
'yes')),
+ 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_update'
=> $table_update,
+ 'update_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.index')
);
+
+ $appname
= lang('pricebook');
+ $function_msg =
lang('list pricebook per vendor');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function agreement_group()
+ {
+ if(!$this->acl_manage)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=16&acl_location='
. $this->acl2_location);
+ }
+
+
$GLOBALS['phpgw']->session->appsession('referer',$this->currentapp,'');
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('pricebook',
+
'menu',
+
'nextmatchs',
+
'search_field'));
+
+ $links =
$this->menu->links('agreement','agreement_group');
+
+ $agreement_list = $this->bo->read_agreement_group();
+
+ while (is_array($agreement_list) && list(,$agreement) =
each($agreement_list))
+ {
+ $content[] = array
+ (
+ 'agreement_group_id'
=> $agreement['agreement_group_id'],
+ 'num'
=> $agreement['num'],
+ 'status'
=> lang($agreement['status']),
+ 'descr'
=> $agreement['descr'],
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.edit_agreement_group&agreement_group_id='
. $agreement['agreement_group_id']),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.delete&method=agreement_group&agreement_group_id='
. $agreement['agreement_group_id'] .'&start=' . $this->start),
+ 'lang_edit_statustext' =>
lang('edit the agreement_group'),
+ 'lang_delete_statustext' =>
lang('Delete this agreement_group'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+
+ $table_header[] = array
+ (
+ 'lang_id' => lang('ID'),
+ 'sort_num' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'num',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uipricebook.agreement_group',
+
'cat_id'
=>$this->cat_id,
+
'allrows'
=>$this->allrows)
+
)),
+ 'lang_num' =>
lang('Activity Num'),
+ 'lang_delete' => lang('Delete'),
+ 'lang_descr' => lang('Description'),
+ 'lang_edit' => lang('edit')
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uipricebook.agreement_group',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_statustext' => lang('add an
activity'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.edit_agreement_group')
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $data = array
+ (
+ 'links'
=> $links,
+ 'allrows'
=> $this->allrows,
+ 'allow_allrows'
=> true,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($agreement_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'lang_select_all'
=> lang('Select All'),
+ 'img_check'
=>
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
+ 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_status_statustext' =>
lang('Select the status the agreement group belongs to. To do not use a
category select NO STATUS'),
+ 'status_name'
=> 'cat_id',
+ 'lang_no_status'
=> lang('No status'),
+ 'status_list'
=> $this->bo->select_status_list('filter',$this->cat_id),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' =>
'yes')),
+ 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_agreement_group' =>
$table_header,
+ 'values_agreement_group'
=> $content,
+ 'table_add'
=> $table_add,
+ 'update_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.agreement_group')
+ );
+
+ $appname
= lang('pricebook');
+ $function_msg =
lang('list agreement group');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('agreement_group' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit_agreement_group()
+ {
+ if(!$this->acl_manage)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=16&acl_location='
. $this->acl2_location);
+ }
+
+ $agreement_group_id =
get_var('agreement_group_id',array('POST','GET'));
+ $values =
get_var('values',array('POST','GET'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('pricebook'));
+
+ if ($values['save'])
+ {
+ $values['agreement_group_id'] =
$agreement_group_id;
+
+ if(!$values['num'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter an agreement group code
!'));
+ $error_id=true;
+ }
+ if(!$values['status'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a status !'));
+ }
+
+
+ if($values['num'] && !$agreement_group_id)
+ {
+
if($this->bo->check_agreement_group_num($values['num']))
+ {
+
$receipt['error'][]=array('msg'=>lang('This agreement group code is already
registered!') . '[ '.$values['num'] .' ]');
+ $error_id=true;
+ }
+ }
+
+ if($agreement_group_id)
+ {
+ $action='edit';
+ }
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$this->bo->save_agreement_group($values,$action);
+ if(!$agreement_group_id)
+ {
+
$agreement_group_id=$receipt['agreement_group_id'];
+ }
+
+ }
+
+ if($agreement_group_id)
+ {
+
$values['agreement_group_id']=$agreement_group_id;
+ $action='edit';
+ }
+ else
+ {
+ $agreement_group_id =
$values['agreement_group_id'];
+ }
+ }
+ else
+ {
+ $values['agreement_group_id']=
$agreement_group_id;
+ if($agreement_group_id)
+ {
+ $values =
$this->bo->read_single_agreement_group($agreement_group_id);
+ }
+ }
+
+//_debug_array($values);
+ if ($agreement_group_id)
+ {
+ $function_msg = lang('edit agreement group');
+ }
+ else
+ {
+ $function_msg = lang('add agreement_group');
+ }
+
+ if ($values['cat_id'] > 0)
+ {
+ $this->cat_id = $values['cat_id'];
+ }
+
+ if($error_id)
+ {
+ unset($values['num']);
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uipricebook.edit_agreement_group',
+ 'agreement_group_id' => $agreement_group_id
+ );
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.agreement_group'),
+ 'lang_agreement_group_id' =>
lang('Agreement group ID'),
+ 'lang_num'
=> lang('Agreement group code'),
+ 'lang_status'
=> lang('Status'),
+ 'status_list'
=> $this->bo->select_status_list('select',$values['status']),
+ 'status_name'
=> 'values[status]',
+ 'lang_no_status'
=> lang('Select status'),
+
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'lang_descr'
=> lang('description'),
+ 'value_agreement_group_id' =>
$values['agreement_group_id'],
+ 'value_num'
=> $values['num'],
+ 'value_descr'
=> $values['descr'],
+ 'lang_num_statustext' =>
lang('A unique code for this activity'),
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'lang_save_statustext' =>
lang('Save the building'),
+ 'lang_descr_statustext' =>
lang('Enter the description for this activity')
+ );
+
+ $appname
= lang('pricebook');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_agreement_group' =>
$data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ function prizing()
+ {
+ if(!$this->acl_manage)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=16&acl_location='
. $this->acl2_location);
+ }
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('pricebook',
+
'menu',
+
'nextmatchs',
+
'search_field'));
+
+ $links = $this->menu->links();
+
+ $cat_id =
get_var('cat_id',array('GET'));
+ $activity_id =
get_var('activity_id',array('GET'));
+ $vendor_id =
get_var('vendor_id',array('GET'));
+ $values =
get_var('values',array('POST'));
+ $values['date'] = get_var('date',array('POST'));
+
+
+ $referer =
$GLOBALS['phpgw']->session->appsession('referer',$this->currentapp);
+ if(!$referer)
+ {
+ $referer =
$GLOBALS['HTTP_SERVER_VARS']['HTTP_REFERER'] ?
$GLOBALS['HTTP_SERVER_VARS']['HTTP_REFERER'] : $GLOBALS['HTTP_REFERER'];
+ $referer = $referer . '&cat_id=' . $cat_id;
+
$GLOBALS['phpgw']->session->appsession('referer',$this->currentapp,$referer);
+ }
+
+ if($values['submit_update'])
+ {
+ if(!$values['date'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Please select a date !'));
+ }
+
+ if(!$values['new_index'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Please enter a new index for calkulating next value(s)!'));
+ }
+
+ if(!$receipt['error'])
+ {
+
$receipt=$this->bo->update_pricebook($values);
+ }
+ }
+
+ if($values['submit_add'])
+ {
+ if(!$values['date'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Please select a date !'));
+ }
+
+ if(!$values['m_cost'] && !$values['w_cost'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Please enter a value for either material cost, labour cost
or both !'));
+ }
+
+ if(!$receipt['error'])
+ {
+
$receipt=$this->bo->add_activity_first_prize($values);
+ }
+ }
+
+
+ $pricebook_list =
$this->bo->read_activity_prize($activity_id,$vendor_id);
+
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ if (isSet($pricebook_list) AND
is_array($pricebook_list))
+ {
+ foreach($pricebook_list as $pricebook)
+ {
+
+ if($pricebook['current_index'])
+ {
+ $link_delete =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.delete&method=prize&activity_id='
. $activity_id .'&vendor_id=' . $vendor_id .'&index_count=' .
$pricebook['index_count']);
+ $value_m_cost =
$pricebook['m_cost'];
+ $value_w_cost =
$pricebook['w_cost'];
+ $value_total_cost =
$pricebook['total_cost'];
+ }
+
+ $content[] = array
+ (
+ 'm_cost'
=> $pricebook['m_cost'],
+ 'w_cost'
=> $pricebook['w_cost'],
+ 'total_cost'
=> $pricebook['total_cost'],
+ 'this_index'
=> $pricebook['this_index'],
+ 'date'
=>
$GLOBALS['phpgw']->common->show_date($pricebook['date'],$dateformat),
+ 'current_index'
=> $pricebook['current_index'],
+ 'index_count'
=> $pricebook['index_count'],
+ 'link_delete'
=> $link_delete,
+ 'lang_delete_statustext'
=> lang('Delete this entry'),
+ 'text_delete'
=> lang('delete'),
+ );
+ }
+ }
+
+//_debug_array($content);
+ $table_header[] = array
+ (
+ 'lang_index_count' => lang('Index Count'),
+ 'lang_total_cost' => lang('Total Cost'),
+ 'lang_prizing' => lang('Prizing'),
+ 'lang_last_index' => lang('Last index'),
+ 'lang_m_cost' => lang('Material
cost'),
+ 'lang_w_cost' => lang('Labour cost'),
+ 'lang_date' => lang('Date'),
+ 'lang_delete' => lang('Delete')
+ );
+
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+ $table_update[] = array
+ (
+ 'jsDateFormat' =>
$jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle' =>
lang('Select date'),
+ 'calendar_setup' =>
"Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat .
"',button : 'date-trigger'});",
+ 'lang_new_index' =>
lang('New index'),
+ 'lang_new_index_statustext' => lang('Enter
a new index'),
+ 'lang_date_statustext' => lang('Select
the date for the update'),
+ 'lang_update' =>
lang('Update'),
+ 'lang_update_statustext' => lang('update
selected investments')
+ );
+
+ $table_first_entry[] = array
+ (
+ 'jsDateFormat' =>
$jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle' =>
lang('Select date'),
+ 'calendar_setup' =>
"Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat .
"',button : 'date-trigger'});",
+ 'lang_m_cost' =>
lang('Material cost'),
+ 'lang_m_cost_statustext' => lang('Enter
a value for the material cost'),
+ 'lang_w_cost' =>
lang('Labour cost'),
+ 'lang_w_cost_statustext' => lang('Enter
a value for the labour cost'),
+ 'lang_date'
=> lang('Date'),
+ 'lang_date_statustext' => lang('Select
the date for the first value'),
+ 'lang_add' =>
lang('Add'),
+ 'lang_add_statustext' => lang('Add first
value for this prizing')
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uipricebook.prizing',
+ 'activity_id' =>$activity_id,
+ 'vendor_id'
=>$vendor_id
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $num_records = count($pricebook_list);
+
+
+ $vendor_data =
$this->contacts->read_single(array('actor_id'=>$vendor_id));
+
+ if(is_array($vendor_data))
+ {
+ foreach($vendor_data['attributes'] as
$attribute)
+ {
+ if($attribute['name']=='org_name')
+ {
+
$value_vendor_name=$attribute['value'];
+ break;
+ }
+ }
+ }
+
+ $activity =
$this->bo->read_single_activity($activity_id);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'done_action'
=> $referer,
+ 'lang_done'
=> lang('done'),
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'links'
=> $links,
+ 'allrows'
=> $this->allrows,
+ 'allow_allrows'
=> true,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> $num_records,
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_vendor'
=> lang('Vendor'),
+ 'lang_activity'
=> lang('Activity'),
+
+ 'value_vendor_name'
=> $value_vendor_name,
+ 'value_activity_id'
=> $activity_id,
+ 'value_activity_code' =>
$activity['num'],
+ 'value_vendor_id'
=> $vendor_id,
+ 'value_m_cost'
=> $value_m_cost,
+ 'value_w_cost'
=> $value_w_cost,
+ 'value_total_cost'
=> $value_total_cost,
+ 'table_header_prizing' =>
$table_header,
+ 'values_prizing'
=> $content,
+ 'table_update'
=> $table_update,
+ 'table_first_entry'
=> $table_first_entry,
+ 'update_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.prizing&activity_id='
. $activity_id . '&vendor_id=' . $vendor_id)
+ );
+
+ $appname
= lang('pricebook');
+ $function_msg =
lang('edit pricing');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('prizing' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+
+ function excel_2()
+ {
+
+ $list = $this->bo->read_activities_pr_agreement_group();
+
+ $name = array(
+ 'activity_id',
+ 'base_descr',
+ 'num',
+ 'descr',
+ // 'branch',
+ // 'dim_d',
+ 'ns3420',
+ 'unit',
+ );
+
+ $descr = array(
+ 'ID',
+ lang('Base'),
+ lang('Activity Num'),
+ lang('Description'),
+ // lang('Branch'),
+ // lang('Dim d'),
+ lang('NS3420'),
+ lang('Unit'),
+ );
+
+
+ $this->bocommon->excel($list,$name,$descr);
+ }
+
+
+ function activity()
+ {
+ if(!$this->acl_manage)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=16&acl_location='
. $this->acl2_location);
+ }
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('pricebook',
+
'menu',
+
'nextmatchs',
+
'search_field'));
+
+ $links = $this->menu->links('agreement','activity');
+
+ $pricebook_list =
$this->bo->read_activities_pr_agreement_group();
+//_debug_array($pricebook_list);
+ while (is_array($pricebook_list) && list(,$pricebook) =
each($pricebook_list))
+ {
+ $content[] = array
+ (
+ 'activity_id'
=> $pricebook['activity_id'],
+ 'num'
=> $pricebook['num'],
+ 'branch'
=> $pricebook['branch'],
+ 'base_descr'
=> $pricebook['base_descr'],
+ 'dim_d'
=> $pricebook['dim_d'],
+ 'ns3420'
=> $pricebook['ns3420'],
+ 'unit'
=> $pricebook['unit'],
+ 'descr'
=> $pricebook['descr'],
+ 'link_vendor'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.activity_vendor&activity_id='
. $pricebook['activity_id'].'&agreement_group=' . $this->cat_id),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.edit_activity&activity_id='
. $pricebook['activity_id'].'&agreement_group=' . $this->cat_id),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.delete&method=activity&activity_id='
. $pricebook['activity_id']),
+ 'lang_vendor_statustext' =>
lang('view the vendor(s) for this activity'),
+ 'lang_edit_statustext' =>
lang('edit this activity'),
+ 'lang_delete_statustext' =>
lang('delete this activity'),
+ 'text_vendor'
=> lang('vendor'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+
+ $table_header[] = array
+ (
+ 'sort_num' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'num',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uipricebook.activity',
+
'cat_id'
=>$this->cat_id,
+
'allrows'
=>$this->allrows)
+
)),
+ 'lang_num' =>
lang('Activity Num'),
+ 'lang_branch' => lang('Branch'),
+ 'lang_vendor' => lang('Vendor'),
+ 'lang_descr' => lang('Description'),
+ 'lang_base_descr' => lang('Base'),
+ 'lang_dim_d' => lang('Dim d'),
+ 'lang_ns3420' => lang('NS3420'),
+ 'lang_unit' => lang('Unit'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete')
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_statustext' => lang('add an
activity'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.edit_activity&agreement_group='
. $this->cat_id)
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uipricebook.activity',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $link_excel = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uipricebook.excel_2',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query,
+ 'allrows'
=>$this->allrows,
+ 'start' =>$this->start
+ );
+
+ $data = array
+ (
+ 'lang_excel' =>
'excel',
+ 'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
+ 'lang_excel_help' =>
lang('Download table to MS Excel'),
+ 'links'
=> $links,
+ 'allrows'
=> $this->allrows,
+ 'allow_allrows'
=> true,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($pricebook_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'lang_select_all'
=> lang('Select All'),
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_no_cat'
=> lang('select agreement_group'),
+ 'lang_cat_statustext' =>
lang('Select the agreement_group the pricebook belongs to. To do not use a
category select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $this->bo->get_agreement_group_list('filter',$this->cat_id),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter,'yours' =>
'yes')),
+ 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_activities' =>
$table_header,
+ 'values_activities'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('pricebook');
+ $function_msg =
lang('list activities per agreement_group');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_activities' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function activity_vendor()
+ {
+ if(!$this->acl_manage)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=16&acl_location='
. $this->acl2_location);
+ }
+
+
$GLOBALS['phpgw']->session->appsession('referer',$this->currentapp,'');
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('pricebook',
+
'menu',
+
'nextmatchs',
+
'search_field'));
+
+ $links = $this->menu->links('agreement','activity');
+
+ $activity_id =
get_var('activity_id',array('GET'));
+ $values =
get_var('values',array('POST'));
+ $values['vendor_id'] =
get_var('vendor_id',array('POST'));
+
+ if($values['add'])
+ {
+ if(!$values['vendor_id'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Please - select a vendor!'));
+ }
+ else
+ {
+ $receipt =
$this->bo->add_activity_vendor($values);
+ }
+ }
+
+ $pricebook_list =
$this->bo->read_vendor_pr_activity($activity_id);
+
+ while (is_array($pricebook_list) && list(,$pricebook) =
each($pricebook_list))
+ {
+ $content[] = array
+ (
+ 'activity_id'
=> $pricebook['activity_id'],
+ 'num'
=> $pricebook['num'],
+ 'branch'
=> $pricebook['branch'],
+ 'vendor_name'
=> $pricebook['vendor_name'],
+ 'link_prizing'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.prizing&activity_id='
. $pricebook['activity_id'].'&vendor_id=' . $pricebook['vendor_id']),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.delete&method=activity_vendor&activity_id='
. $pricebook['activity_id'].'&vendor_id=' . $pricebook['vendor_id']),
+ 'lang_prizing_statustext' =>
lang('view edit the prize for this activity'),
+ 'lang_delete_statustext' =>
lang('delete this vendor from this activity'),
+ 'text_prizing'
=> lang('Prizing'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+
+ $table_header[] = array
+ (
+ 'sort_vendor' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'org_name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uipricebook.activity_vendor',
+
'cat_id'
=>$this->cat_id,
+
'activity_id'
=>$activity_id,
+
'allrows'
=>$this->allrows)
+
)),
+ 'lang_num' =>
lang('Activity Num'),
+ 'lang_branch' => lang('Branch'),
+ 'lang_vendor' => lang('Vendor'),
+ 'lang_prizing' => lang('Prizing'),
+ 'lang_delete' => lang('delete')
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uipricebook.activity_vendor',
+ 'sort' =>
$this->sort,
+ 'order' =>
$this->order,
+ 'cat_id' =>
$this->cat_id,
+ 'filter' =>
$this->filter,
+ 'query' =>
$this->query,
+ 'activity_id' => $activity_id
+ );
+
+
+
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
+ 'vendor_id' => ''));
+
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'activity_id'
=> $activity_id,
+ 'vendor_data'
=> $vendor_data,
+ 'links'
=> $links,
+ 'allrows'
=> $this->allrows,
+ 'allow_allrows'
=> true,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($pricebook_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_no_cat'
=> lang('select agreement_group'),
+ 'lang_cat_statustext' =>
lang('Select the agreement_group the pricebook belongs to. To do not use a
category select NO CATEGORY'),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_activity_vendor' =>
$table_header,
+ 'values_activity_vendor' =>
$content,
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'lang_save_statustext' =>
lang('Add this vendor to this activity'),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.activity&cat_id='
. $values['cat_id']),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+
+ );
+
+ $appname
= lang('pricebook');
+ $function_msg =
lang('list vendors per activity');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_activity_vendor' =>
$data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit_activity()
+ {
+ if(!$this->acl_manage)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=16&acl_location='
. $this->acl2_location);
+ }
+
+ $activity_id =
get_var('activity_id',array('POST','GET'));
+ $agreement_group =
get_var('agreement_group',array('GET'));
+ $values =
get_var('values',array('POST','GET'));
+ $values['ns3420_id']=
get_var('ns3420_id',array('POST','GET'));
+
+ if(!$values['cat_id'])
+ {
+ $values['cat_id'] = $agreement_group;
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('pricebook'));
+
+ if ($values['save'])
+ {
+ if(!$values['num'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter an activity code !'));
+ $error_id=true;
+ }
+ if(!$values['cat_id'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select an agreement_group !'));
+ }
+
+ if(!$values['branch_id'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a branch !'));
+ }
+
+ if($values['num'] && !$activity_id)
+ {
+
if($this->bo->check_activity_num($values['num'],$values['cat_id']))
+ {
+
$receipt['error'][]=array('msg'=>lang('This activity code is already
registered!') . '[ '.$values['num'] .' ]');
+ $error_id=true;
+ }
+ }
+
+ if($activity_id)
+ {
+ $values['activity_id']=$activity_id;
+ $action='edit';
+ }
+ else
+ {
+ $activity_id = $values['activity_id'];
+ }
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$this->bo->save_activity($values,$action);
+ $activity_id= $receipt['activity_id'];
+ $values['activity_id']= $activity_id;
+ }
+
+ }
+ else
+ {
+ $values['activity_id']= $activity_id;
+ if($activity_id)
+ {
+ $values =
$this->bo->read_single_activity($activity_id);
+ }
+ }
+
+//_debug_array($values);
+ if ($activity_id)
+ {
+ $function_msg = lang('edit activity');
+ }
+ else
+ {
+ $function_msg = lang('add activity');
+ }
+
+ if ($values['cat_id'] > 0)
+ {
+ $this->cat_id = $values['cat_id'];
+ }
+
+ if($error_id)
+ {
+ unset($values['num']);
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uipricebook.edit_activity',
+ 'activity_id' => $activity_id,
+ 'agreement_group' =>
$agreement_group
+ );
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.activity&cat_id='
. $values['cat_id']),
+ 'lang_activity_id'
=> lang('Activity ID'),
+ 'lang_num'
=> lang('Activity code'),
+ 'lang_category'
=> lang('Agreement group'),
+ 'lang_unit'
=> lang('Unit'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'lang_descr'
=> lang('description'),
+ 'lang_base_descr'
=> lang('Base description'),
+ 'value_activity_id'
=> $values['activity_id'],
+ 'value_num'
=> $values['num'],
+ 'value_general_address' =>
$values['general_address'],
+ 'value_access'
=> $values['access'],
+ 'value_descr'
=> $values['descr'],
+ 'value_base_descr'
=> $values['base_descr'],
+ 'lang_num_statustext' =>
lang('A unique code for this activity'),
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'lang_save_statustext' =>
lang('Save the building'),
+ 'lang_no_cat'
=> lang('Select agreement group'),
+ 'lang_cat_statustext' =>
lang('Select the agreement group this activity belongs to.'),
+ 'select_name'
=> 'values[cat_id]',
+ 'lang_descr_statustext' =>
lang('Enter the description for this activity'),
+ 'lang_base_descr_statustext' => lang('Enter
a description for prerequisitions for this activity - if any'),
+ 'cat_list'
=> $this->bo->get_agreement_group_list('select',$values['cat_id']),
+
+ 'lang_dim_d'
=> lang('Dim D'),
+ 'dim_d_list'
=> $this->bo->get_dim_d_list($values['dim_d']),
+ 'select_dim_d'
=> 'values[dim_d]',
+ 'lang_no_dim_d'
=> lang('No Dim D'),
+ 'lang_dim_d_statustext' =>
lang('Select the Dim D for this activity. To do not use Dim D - select NO DIM
D'),
+
+ 'lang_unit'
=> lang('Unit'),
+ 'unit_list'
=> $this->bo->get_unit_list($values['unit']),
+ 'select_unit'
=> 'values[unit]',
+ 'lang_no_unit'
=> lang('Select Unit'),
+ 'lang_unit_statustext' =>
lang('Select the unit for this activity.'),
+
+ 'lang_branch'
=> lang('Branch'),
+ 'branch_list'
=> $this->bo->get_branch_list($values['branch_id']),
+ 'select_branch'
=> 'values[branch_id]',
+ 'lang_no_branch'
=> lang('Select branch'),
+ 'lang_branch_statustext' =>
lang('Select the branch for this activity.'),
+
+ 'ns3420_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.ns3420'),
+ 'lang_ns3420'
=> lang('NS3420'),
+ 'value_ns3420_id'
=> $values['ns3420_id'],
+ 'lang_ns3420_statustext' =>
lang('Select a standard-code from the norwegian standard'),
+ );
+
+ $appname
= lang('pricebook');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_activity' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function delete()
+ {
+ if(!$this->acl_manage)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=16&acl_location='
. $this->acl2_location);
+ }
+
+ $method =
get_var('method',array('GET'));
+ $activity_id = get_var('activity_id',array('GET'));
+ $vendor_id =
get_var('vendor_id',array('GET'));
+ $index_count = get_var('index_count',array('GET'));
+ $agreement_group_id =
get_var('agreement_group_id',array('GET'));
+ $confirm =
get_var('confirm',array('POST'));
+
+ if($method=='activity_vendor')
+ {
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uipricebook.activity_vendor',
+ 'activity_id' => $activity_id
+ );
+
+ $function_msg =lang('delete vendor activity');
+ $delete_action =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.delete&method='
. $method . '&activity_id=' . $activity_id . '&vendor_id=' . $vendor_id);
+
+ if (get_var('confirm',array('POST')))
+ {
+
$this->bo->delete_activity_vendor($activity_id,$vendor_id);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+ }
+ elseif($method=='activity')
+ {
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uipricebook.activity'
+ );
+
+ $function_msg =lang('delete activity');
+ $delete_action =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.delete&method='
. $method . '&activity_id=' . $activity_id);
+
+ if (get_var('confirm',array('POST')))
+ {
+
$this->bo->delete_activity($activity_id);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+ }
+ elseif($method=='prize')
+ {
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uipricebook.prizing',
+ 'activity_id' => $activity_id,
+ 'vendor_id' => $vendor_id
+ );
+
+ $function_msg =lang('delete prize-index');
+ $delete_action =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.delete&method='
. $method . '&activity_id=' . $activity_id . '&vendor_id=' . $vendor_id .
'&index_count=' . $index_count);
+
+ if (get_var('confirm',array('POST')))
+ {
+
$this->bo->delete_prize_index($activity_id,$vendor_id,$index_count);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+ }
+ elseif($method=='agreement_group')
+ {
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uipricebook.agreement_group',
+ 'start' => $this->start
+ );
+
+ $function_msg =lang('Delete agreement group
and all the activities associated with it!');
+ $delete_action =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.delete&method='
. $method . '&agreement_group_id=' . $agreement_group_id . '&start=' .
$this->start);
+
+ if (get_var('confirm',array('POST')))
+ {
+
$this->bo->delete_agreement_group($agreement_group_id);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$delete_action,
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('pricebook');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ }
+?>
Index: property/inc/class.uiproject.inc.php
diff -u property/inc/class.uiproject.inc.php:1.22
property/inc/class.uiproject.inc.php:1.23
--- property/inc/class.uiproject.inc.php:1.22 Wed Nov 9 22:49:12 2005
+++ property/inc/class.uiproject.inc.php Fri Jan 27 14:05:43 2006
@@ -1,1326 +1,1326 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage project
- * @version $Id: class.uiproject.inc.php,v 1.22 2005/11/09 22:49:12
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uiproject
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
- var $part_of_town_id;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'excel' => True,
- 'index' => True,
- 'view' => True,
- 'edit' => True,
- 'delete' => True,
- 'date_search'=>True
- );
-
- function uiproject()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- $this->bo =
CreateObject($this->currentapp.'.boproject',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
-
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
- $this->acl2_location = '.project';
- $this->acl_read =
$this->acl2->check('.project',1);
- $this->acl_add =
$this->acl2->check('.project',2);
- $this->acl_edit =
$this->acl2->check('.project',4);
- $this->acl_delete =
$this->acl2->check('.project',8);
-
- $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->status_id =
$this->bo->status_id;
- $this->wo_hour_cat_id =
$this->bo->wo_hour_cat_id;
-
-
- $this->menu->sub ='project';
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' => $this->filter,
- 'cat_id' => $this->cat_id,
- 'status_id' => $this->status_id,
- 'wo_hour_cat_id'=> $this->wo_hour_cat_id
- );
- $this->bo->save_sessiondata($data);
- }
-
- function excel()
- {
- $start_date =
urldecode(get_var('start_date',array('POST','GET')));
- $end_date =
urldecode(get_var('end_date',array('POST','GET')));
- $list =
$this->bo->read($start_date,$end_date,$allrows=True);
- $uicols = $this->bo->uicols;
-
$this->bocommon->excel($list,$uicols['name'],$uicols['descr'],$uicols['input_type']);
- }
-
- function index()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('project','values','table_header',
-
'menu',
-
'nextmatchs',
-
'search_field',
-
'wo_hour_cat_filter'));
-
- $lookup =
get_var('lookup',array('POST','GET'));
- $from =
get_var('from',array('POST','GET'));
- $start_date =
urldecode(get_var('start_date',array('POST','GET')));
- $end_date =
urldecode(get_var('end_date',array('POST','GET')));
-
- $links = $this->menu->links('project');
-
- $project_list = $this->bo->read($start_date,$end_date);
- $uicols = $this->bo->uicols;
- $count_uicols_name=count($uicols['name']);
-
- $j=0;
- if (isSet($project_list) AND is_array($project_list))
- {
- foreach($project_list as $project_entry)
-
- {
- for ($k=0;$k<$count_uicols_name;$k++)
- {
-
if($uicols['input_type'][$k]=='text')
- {
-
-
if($project_entry['query_location'][$uicols['name'][$k]])
- {
-
$content[$j]['row'][]= array(
-
'statustext' => lang('search'),
- 'text'
=> $project_entry[$uicols['name'][$k]],
- 'link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.index&query='
. $project_entry['query_location'][$uicols['name'][$k]] . '&lookup=' . $lookup
. '&from=' . $from . '&filter=' . $this->filter)
- );
- }
- else
- {
-
$content[$j]['row'][]= array(
- 'value'
=> $project_entry[$uicols['name'][$k]],
- 'name'
=> $uicols['name'][$k]
- );
- }
- }
-
elseif($uicols['input_type'][$k]=='link')
- {
-
$content[$j]['row'][]= array(
- 'statustext'
=> lang('search'),
- 'text'
=> $project_entry[$uicols['name'][$k]],
- 'link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitts.view&id='
. $project_entry[$uicols['name'][$k]])
- );
- }
-
- if($lookup &&
$k==($count_uicols_name-1))
- {
- $content[$j]['row'][]=
array(
- 'lookup_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.ui' .
$from . '.edit&project_id=' . $project_entry['project_id'])
- );
- }
- }
-
- if(!$lookup)
- {
- if ($this->acl_read &&
$this->bocommon->check_perms($project_entry['grants'],PHPGW_ACL_READ))
- {
- $content[$j]['row'][]=
array(
- 'statustext'
=> lang('view the project'),
- 'text'
=> lang('view'),
- 'link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.view&id='
. $project_entry['project_id'])
- );
- }
- else
- {
- $content[$j]['row'][]=
array('link'=>'dummy');
- }
-
- if ($this->acl_edit &&
$this->bocommon->check_perms($project_entry['grants'],PHPGW_ACL_EDIT))
- {
- $content[$j]['row'][]=
array(
- 'statustext' =>
lang('edit the project'),
- 'text'
=> lang('edit'),
- 'link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit&id='
. $project_entry['project_id'])
- );
- }
- else
- {
- $content[$j]['row'][]=
array('link'=>'dummy');
- }
-
- if ($this->acl_delete &&
$this->bocommon->check_perms($project_entry['grants'],PHPGW_ACL_DELETE))
- {
- $content[$j]['row'][]=
array(
- 'statustext' =>
lang('delete the project'),
- 'text'
=> lang('delete'),
- 'link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.delete&project_id='
. $project_entry['project_id'])
- );
- }
- else
- {
- $content[$j]['row'][]=
array('link'=>'dummy');
- }
- }
-
- $j++;
- }
- }
-
- $count_uicols_descr=count($uicols['descr']);
- for ($i=0;$i<$count_uicols_descr;$i++)
- {
- if($uicols['input_type'][$i]!='hidden')
- {
- $table_header[$i]['header'] =
$uicols['descr'][$i];
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- if($uicols['name'][$i]=='loc1')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'location_code',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiproject.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'lookup'
=>$lookup,
-
'from' =>$from,
-
'district_id' =>
$this->district_id,
-
'cat_id'
=>$this->cat_id,
-
'start_date'=>$start_date,
-
'end_date'=>$end_date,
-
'wo_hour_cat_id'
=>$this->wo_hour_cat_id
-
)
-
));
- }
- if($uicols['name'][$i]=='project_id')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'project_id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiproject.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'lookup'
=>$lookup,
-
'from' =>$from,
-
'district_id' =>
$this->district_id,
-
'cat_id'
=>$this->cat_id,
-
'start_date'=>$start_date,
-
'end_date'=>$end_date,
-
'wo_hour_cat_id'
=>$this->wo_hour_cat_id
-
)
-
));
- }
- if($uicols['name'][$i]=='address')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'address',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiproject.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'lookup'
=>$lookup,
-
'from' =>$from,
-
'district_id' =>
$this->district_id,
-
'cat_id'
=>$this->cat_id,
-
'start_date'=>$start_date,
-
'end_date'=>$end_date,
-
'wo_hour_cat_id'
=>$this->wo_hour_cat_id
-
)
-
));
- }
- }
- }
-
- if(!$lookup)
- {
- if($this->acl_read)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('view');
- $i++;
- }
- if($this->acl_edit)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('edit');
- $i++;
- }
- if($this->acl_delete)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('delete');
- $i++;
- }
- }
- else
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header'] =
lang('select');
- }
-
-//_debug_array($content);
- if($this->acl_add)
- {
- $table_add[] = array
- (
- 'lang_add'
=> lang('add'),
- 'lang_add_statustext' => lang('add a
project'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit')
- );
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiproject.index',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'district_id'
=>$this->district_id,
- 'filter'
=>$this->filter,
- 'status_id'
=>$this->status_id,
- 'lookup'
=>$lookup,
- 'from' =>$from,
- 'query'
=>$this->query,
- 'start_date' =>$start_date,
- 'end_date'
=>$end_date,
- 'wo_hour_cat_id'
=>$this->wo_hour_cat_id,
- );
-
- $link_date_search
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.date_search');
-
- $link_excel = array
- (
- 'menuaction' =>
$this->currentapp.'.uiproject.excel',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'district_id'
=>$this->district_id,
- 'filter'
=>$this->filter,
- 'status_id'
=>$this->status_id,
- 'lookup'
=>$lookup,
- 'from' =>$from,
- 'query'
=>$this->query,
- 'start_date'
=>$start_date,
- 'end_date'
=>$end_date,
- 'start'
=>$this->start,
- 'wo_hour_cat_id'
=>$this->wo_hour_cat_id,
- );
-
- $data = array
- (
- 'lang_excel' =>
'excel',
- 'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
- 'lang_excel_help' =>
lang('Download table to MS Excel'),
-
- 'start_date'
=>$start_date,
- 'end_date'
=>$end_date,
- 'lang_none'
=>lang('None'),
- 'lang_date_search' =>
lang('Date search'),
- 'lang_date_search_help' => lang('Narrow
the search by dates'),
- 'link_date_search' =>
$link_date_search,
- 'overlib_source' =>
'./'.$this->currentapp.'/inc/overlib.js',
-
- 'lang_select'
=> lang('select'),
- 'lookup_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit'),
- 'lookup'
=> $lookup,
- 'links'
=> $links,
- 'allow_allrows'
=> false,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($project_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the project belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $this->bo->select_category_project_list('filter',$this->cat_id),
- 'district_list'
=> $this->bocommon->select_district_list('filter',$this->district_id),
- 'lang_no_district'
=> lang('no district'),
- 'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
- 'select_district_name' =>
'district_id',
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
-
- 'lang_status_statustext' =>
lang('Select the status the agreement belongs to. To do not use a category
select NO STATUS'),
- 'status_name'
=> 'status_id',
- 'lang_no_status'
=> lang('No status'),
- 'status_list'
=> $this->bo->select_status_list('filter',$this->status_id),
-
- 'lang_wo_hour_cat_statustext' =>
lang('Select the workorder hour category'),
- 'lang_no_wo_hour_cat' =>
lang('no hour category'),
- 'wo_hour_cat_list'
=> $this->bocommon->select_wo_hours_category_list($this->wo_hour_cat_id),
-
- 'lang_user_statustext' =>
lang('Select the user the project belongs to. To do not use a category select
NO USER'),
- 'select_user_name'
=> 'filter',
- 'lang_no_user'
=> lang('No user'),
- 'user_list'
=>
$this->bocommon->get_user_list_right2('filter',4,$this->filter,$this->acl2_location,array('all'),$default=$this->account),
-
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('Project');
- $function_msg =
lang('list Project');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_project' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function date_search()
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('date_search'));
- $GLOBALS['phpgw_info']['flags']['noframework'] = True;
- $GLOBALS['phpgw_info']['flags'][noheader] = True;
- $GLOBALS['phpgw_info']['flags'][nofooter] = True;
- $values['start_date'] =
get_var('start_date',array('POST'));
- $values['end_date'] =
get_var('end_date',array('POST'));
-
- $function_msg = lang('Date search');
- $appname = lang('project');
-
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- if(!$values['end_date'])
- {
- $values['end_date'] =
$GLOBALS['phpgw']->common->show_date(mktime(0,0,0,date("m"),date("d"),date("Y")),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- }
-
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
- $data = array
- (
- 'jsDateFormat'
=> $jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle'
=> lang('Select date'),
- 'calendar_setup_start' =>
"Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});",
- 'calendar_setup_end' =>
"Calendar.setup({inputField : 'end_date',ifFormat : '" . $jsDateFormat .
"',button : 'end_date-trigger'});",
-
- 'lang_start_date_statustext' => lang('Select
the estimated end date for the Project'),
- 'lang_start_date'
=> lang('Start date'),
- 'value_start_date'
=> $values['start_date'],
-
- 'lang_end_date_statustext' =>
lang('Select the estimated end date for the Project'),
- 'lang_end_date'
=> lang('End date'),
- 'value_end_date'
=> $values['end_date'],
-
- 'dateformat'
=> $dateformat,
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_submit_statustext' =>
lang('Select this dates'),
- 'lang_submit' =>
lang('Submit')
- );
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('date_search' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function edit()
- {
- if(!$this->acl_add && !$this->acl_edit)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
- }
- $id =
get_var('id',array('POST','GET'));
- $values =
get_var('values',array('POST'));
- $add_request =
get_var('add_request',array('POST'));
-
- $config =
CreateObject('phpgwapi.config');
- $bolocation =
CreateObject($this->currentapp.'.bolocation');
-
- $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
- $insert_record_entity =
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp);
-
- for ($j=0;$j<count($insert_record_entity);$j++)
- {
-
$insert_record['extra'][$insert_record_entity[$j]] =
$insert_record_entity[$j];
- }
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('project'));
-
- $bypass =
get_var('bypass',array('POST','GET'));
-
- if($add_request)
- {
- $receipt =
$this->bo->add_request($add_request,$id);
- }
-
- if($_POST && !$bypass)
- {
- for ($i=0;
$i<count($insert_record['location']); $i++)
- {
-
if($_POST[$insert_record['location'][$i]])
- {
-
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
- }
- }
-
- while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
- {
- if($_POST[$key])
- {
- $values['extra'][$column]
= $_POST[$key];
- }
- }
-
- $values['street_name'] =
$_POST['street_name'];
- $values['street_number'] =
$_POST['street_number'];
- $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
-
- }
- else
- {
- $location_code =
get_var('location_code',array('POST','GET'));
- $tenant_id =
get_var('tenant_id',array('POST','GET'));
- $values['descr'] =
get_var('descr',array('POST','GET'));
- $p_entity_id =
get_var('p_entity_id',array('POST','GET'));
- $p_cat_id =
get_var('p_cat_id',array('POST','GET'));
- $values['p'][$p_entity_id]['p_entity_id']
= $p_entity_id;
- $values['p'][$p_entity_id]['p_cat_id']
= $p_cat_id;
- $values['p'][$p_entity_id]['p_num']
= get_var('p_num',array('POST','GET'));
-
- $origin =
get_var('origin',array('POST','GET'));
- $origin_id =
get_var('origin_id',array('POST','GET'));
-
- if($p_entity_id && $p_cat_id)
- {
-
- if(!is_object($boadmin_entity))
- {
- $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
- }
-
- $entity_category =
$boadmin_entity->read_single_category($p_entity_id,$p_cat_id);
-
$values['p'][$p_entity_id]['p_cat_name'] = $entity_category['name'];
- }
-
- if($location_code)
- {
- $values['location_data'] =
$bolocation->read_single($location_code,array('tenant_id'=>$tenant_id,'p_num'=>$p_num));
- }
-
- }
-
- if($values['origin'])
- {
- $origin = $values['origin'];
- $origin_id = $values['origin_id'];
- }
-
- if($origin)
- {
- unset($values['origin']);
- unset($values['origin_id']);
- $values['origin'][0]['type']= $origin;
-
$values['origin'][0]['link']=$this->bocommon->get_origin_link($origin);
- $values['origin'][0]['data'][]= array(
- 'id'=> $origin_id,
- 'type'=> $origin
- );
- }
-
- $values['start_date'] =
get_var('start_date',array('POST'));
- $values['end_date'] =
get_var('end_date',array('POST'));
-
- $config->read_repository();
-
- if ($values['save'])
- {
- $save=true;
-
- if(!$values['location'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a location !'));
- $error_id=true;
- }
-
- if(!$values['name'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter a project NAME !'));
- $error_id=true;
- }
-
- if(!$values['cat_id'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
- $error_id=true;
- }
-
- if(!$values['coordinator'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a coordinator !'));
- $error_id=true;
- }
-
- if(!$values['status'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a status !'));
- }
-
- if($id)
- {
- $values['project_id']=$id;
- $action='edit';
- }
-
- if(!$receipt['error'])
- {
- if(!$id)
- {
-
$values['project_id']=$this->bo->next_project_id();
- $id = $values['project_id'];
- }
-
- if($values['copy_project'])
- {
- $action='add';
- $values['project_id'] =
$this->bo->next_project_id();
- $id = $values['project_id'];
- }
- $receipt =
$this->bo->save($values,$action);
- if($receipt['error'])
- {
- unset($id);
- unset($values['project_id']);
- }
-
- if ($values['approval'] &&
$values['mail_address'])
- {
-
$from_name=$GLOBALS['phpgw_info']['user']['fullname'];
-
$from_email=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['email'];
- $headers = "Return-Path: <".
$from_email .">\r\n";
- $headers .= "From: " .
$from_name . "<" . $from_email .">\r\n";
- $headers .= "Bcc: " .
$from_name . "<" . $from_email .">\r\n";
- $headers .= "Content-type:
text/plain; charset=iso-8859-1\r\n";
-
- $subject = lang(Approval).": ".
$values['project_id'];
- $message = lang(Project) . " "
. $values['project_id'] ." ". lang('needs approval');
-
- $mail_method=
$config->config_data['fmwrkorder_mail'];
- if ($mail_method=='smtp'):
- {
- $bcc = $from_email;
- if
(!is_object($GLOBALS['phpgw']->send))
- {
-
$GLOBALS['phpgw']->send = CreateObject('phpgwapi.send');
- }
-
- $rcpt =
$GLOBALS['phpgw']->send->msg('email',$values['mail_address'], $subject,
stripslashes($message), '', $cc, $bcc, $from_email, $from_name, 'plain');
-
- if(!$rcpt)
- {
-
$receipt['error'][]=array('msg'=>"uiproject::edit: sending message to '" .
$values['mail_address'] . "', subject='$subject' failed !!!");
-
$receipt['error'][]=array('msg'=> $GLOBALS['phpgw']->send->err['desc']);
-
$bypass_error=True;
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('%1 is
notified',$values['mail_address']));
- }
-
- }
- elseif
($mail_method=='sendmail'):
- {
-
$rcpt=mail($values['mail_address'],$subject,$message, $headers);
- }
- else:
- {
-
$receipt['error'][]=array('msg'=>lang('Mailing method is not chosen! (admin
section)'));
- $bypass_error=True;
- }
- endif;
- }
- }
-
- if (isset($receipt['notice_owner']) AND
is_array($receipt['notice_owner']))
- {
-
if($this->account!=$values['coordinator'] &&
$config->config_data['workorder_approval'])
- {
-
- $prefs_coordinator =
$this->bocommon->create_preferences($this->currentapp,$values['coordinator']);
- $to =
$prefs_coordinator['email'];
-
-
$from_name=$GLOBALS['phpgw_info']['user']['fullname'];
-
$from_email=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['email'];
-
-
foreach($receipt['notice_owner'] as $notice)
- {
- $body .= $notice . "\n";
- }
-
- $body .= lang('Altered by') .
': ' . $from_name . "\n";
-
- if
(!is_object($GLOBALS['phpgw']->send))
- {
- $GLOBALS['phpgw']->send
= CreateObject('phpgwapi.send');
- }
-
- $returncode =
$GLOBALS['phpgw']->send->msg('email',$to,$subject=lang('Project %1 is
altered',$id),$body, False,False,False, $from_email, $from_name, 'plain');
-
- if (!$returncode) // not
nice, but better than failing silently
- {
-
$receipt['error'][]=array('msg'=>"uiproject::edit: sending message to '$to'
subject='$subject' failed !!!");
-
$receipt['error'][]=array('msg'=> $GLOBALS['phpgw']->send->err['desc']);
- $bypass_error=True;
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('%1 is notified',$to));
- }
- }
- }
-
-
- if($receipt['error'] && !$bypass_error)
- {
- if($values['location'])
- {
- $location_code=implode("-",
$values['location']);
- $values['location_data'] =
$bolocation->read_single($location_code,$values['extra']);
- }
-
- if($values['extra']['p_num'])
- {
-
$values['p'][$values['extra']['p_entity_id']]['p_num']=$values['extra']['p_num'];
-
$values['p'][$values['extra']['p_entity_id']]['p_entity_id']=$values['extra']['p_entity_id'];
-
$values['p'][$values['extra']['p_entity_id']]['p_cat_id']=$values['extra']['p_cat_id'];
-
$values['p'][$values['extra']['p_entity_id']]['p_cat_name']=$_POST['entity_cat_name_'.$values['extra']['p_entity_id']];
- }
- }
- }
-
- if($bypass_error || ((!$receipt['error'] ||
$add_request) && !$bypass) && $id)
- {
- $values = $this->bo->read_single($id);
-
- if(!$values['workorder_budget'] && $save)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit&project_id='
. $id);
- }
-
- if
(!$this->bocommon->check_perms($values['grants'],PHPGW_ACL_EDIT))
- {
-
$receipt['error'][]=array('msg'=>lang('You have no edit right for this
project'));
-
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp,$receipt);
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiproject.view&id='
. $id);
- }
- else
- {
- $record_history =
$this->bo->read_record_history($id);
- }
- }
-
-
- $table_header_history[] = array
- (
- 'lang_date' => lang('Date'),
- 'lang_user' => lang('User'),
- 'lang_action' => lang('Action'),
- 'lang_new_value' => lang('New value')
- );
-
- $table_header_workorder_budget[] = array
- (
- 'lang_workorder_id' => lang('Workorder'),
- 'lang_budget' => lang('Budget'),
- 'lang_calculation' => lang('Calculation'),
- 'lang_vendor' => lang('Vendor')
- );
-
- if ($id)
- {
- $function_msg = lang('Edit Project');
- }
- else
- {
- $function_msg = lang('Add Project');
- }
-
- if ($values['cat_id'])
- {
- $this->cat_id = $values['cat_id'];
- }
-
- $lookup_type='form';
-
-//_debug_array($values);
- $location_data=$bolocation->initiate_ui_location(array(
- 'values' =>
$values['location_data'],
- 'type_id' => -1,
// calculated from location_types
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' => True,
- 'lookup_type' => $lookup_type,
- 'lookup_entity' =>
$this->bocommon->get_lookup_entity('project'),
- 'entity_data' => $values['p']
- ));
-
- if($values['contact_phone'])
- {
- for
($i=0;$i<count($location_data['location']);$i++)
- {
-
if($location_data['location'][$i]['input_name'] == 'contact_phone')
- {
-
$location_data['location'][$i]['value'] = $values['contact_phone'];
- }
- }
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiproject.edit',
- 'id' => $id
- );
-
- $link_request_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uirequest.index',
- 'query' =>
$values['location_data']['loc1'],
- 'project_id' => $values['project_id']
- );
-
-
-
$supervisor_id=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['approval_from'];
- $need_approval =
$config->config_data['workorder_approval'];
-
-
$project_status=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['project_status'];
-
$project_category=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['project_category'];
- if(!$values['status'])
- {
- $values['status']=$project_status;
- }
-
- if(!$values['cat_id'])
- {
- $values['cat_id']=$project_category;
- }
-
- if(!$values['coordinator'])
- {
- $values['coordinator']=$this->account;
- }
-
- if ($supervisor_id && $need_approval=='yes')
- {
- $prefs =
$this->bocommon->create_preferences($this->currentapp,$supervisor_id);
- $supervisor_email = $prefs['email'];
- }
-
- if(!$values['start_date'])
- {
- $values['start_date'] =
$GLOBALS['phpgw']->common->show_date(mktime(0,0,0,date("m"),date("d"),date("Y")),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- }
-
- if($receipt)
- {
- $msgbox_data =
$this->bocommon->msgbox_data($receipt);
- }
-
- if($values['reserve'])
- {
-
$reserve_remainder=$values['reserve']-$values['deviation'];
- $remainder_percent=
number_format(($reserve_remainder/$values['reserve'])*100, 2, ',', '');
- }
-
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
-
- if (isset($values['origin']) AND
is_array($values['origin']))
- {
- for ($i=0;$i<count($values['origin']);$i++)
- {
-
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
. $values['origin'][$i]['link']);
-
if(substr($values['origin'][$i]['type'],0,6)=='entity')
- {
- $type =
explode("_",$values['origin'][$i]['type']);
- $entity_id = $type[1];
- $cat_id = $type[2];
-
- if(!is_object($boadmin_entity))
- {
- $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
- }
- $entity_category =
$boadmin_entity->read_single_category($entity_id,$cat_id);
- $values['origin'][$i]['descr']
= $entity_category['name'];
- }
- else
- {
- $values['origin'][$i]['descr']=
lang($values['origin'][$i]['type']);
-
if($values['origin'][$i]['type'] == 'request')
- {
- $selected_request =
True;
- }
- }
- }
- }
-
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
-
- 'value_origin'
=> $values['origin'],
- 'value_origin_type'
=> $origin,
- 'value_origin_id'
=> $origin_id,
- 'selected_request'
=> $selected_request,
-
- 'lang_select_request' =>
lang('Select request'),
- 'lang_select_request_statustext' =>
lang('Add request for this project'),
- 'lang_request_statustext' =>
lang('Link to the request for this project'),
- 'lang_delete_request_statustext'=> lang('Check
to delete this request from this project'),
- 'link_select_request' =>
$GLOBALS['phpgw']->link('/index.php',$link_request_data),
- 'link_request'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.view'),
-
- 'add_workorder_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit'),
- 'lang_add_workorder'
=> lang('Add Workorder'),
- 'lang_add_workorder_statustext' =>
lang('Add a workorder to this project'),
-
- 'table_header_workorder_budget' =>
$table_header_workorder_budget,
- 'lang_no_workorders' =>
lang('No workorder bugdet'),
- 'workorder_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit'),
- 'record_history'
=> $record_history,
- 'table_header_history' =>
$table_header_history,
- 'lang_history'
=> lang('History'),
- 'lang_no_history'
=> lang('No history'),
-
-// 'cal_info'
=> $cal_info,
- 'jsDateFormat'
=> $jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle'
=> lang('Select date'),
- 'calendar_setup_start' =>
"Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});",
- 'calendar_setup_end' =>
"Calendar.setup({inputField : 'end_date',ifFormat : '" . $jsDateFormat .
"',button : 'end_date-trigger'});",
-
- 'lang_start_date_statustext' => lang('Select
the estimated end date for the Project'),
- 'lang_start_date'
=> lang('Project start date'),
- 'value_start_date'
=> $values['start_date'],
-
- 'lang_end_date_statustext' =>
lang('Select the estimated end date for the Project'),
- 'lang_end_date'
=> lang('Project end date'),
- 'value_end_date'
=> $values['end_date'],
-
- 'lang_copy_project'
=> lang('Copy project ?'),
- 'lang_copy_project_statustext' => lang('Choose
Copy Project to copy this project to a new project'),
-
- 'lang_charge_tenant' =>
lang('Charge tenant'),
- 'lang_charge_tenant_statustext' => lang('Choose
charge tenant if the tenant i to pay for this project'),
- 'charge_tenant'
=> $values['charge_tenant'],
-
- 'lang_power_meter'
=> lang('Power meter'),
- 'lang_power_meter_statustext' => lang('Enter
the power_meter'),
- 'value_power_meter'
=> $values['power_meter'],
-
- 'lang_budget'
=> lang('Budget'),
- 'value_budget'
=> $values['budget'],
- 'lang_budget_statustext' =>
lang('Enter the budget'),
-
- 'lang_reserve'
=> lang('reserve'),
- 'value_reserve'
=> $values['reserve'],
- 'lang_reserve_statustext' =>
lang('Enter the reserve'),
-
- 'lang_reserve_remainder' =>
lang('reserve remainder'),
- 'value_reserve_remainder' =>
$reserve_remainder,
- 'value_reserve_remainder_percent'=>
$remainder_percent,
-
- 'vendor_data'
=> $vendor_data,
- 'location_data'
=> $location_data,
- 'location_type'
=> 'form',
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.index'),
- 'lang_year'
=> lang('Year'),
- 'lang_category'
=> lang('category'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'lang_name'
=> lang('Name'),
-
- 'lang_project_id'
=> lang('Project ID'),
- 'value_project_id'
=> $values['project_id'],
- 'value_name'
=> $values['name'],
- 'lang_name_statustext' =>
lang('Enter Project Name'),
-
- 'lang_other_branch'
=> lang('Other branch'),
- 'lang_other_branch_statustext' =>
lang('Enter other branch if not found in the list'),
- 'value_other_branch'
=> $values['other_branch'],
-
- 'lang_descr_statustext' =>
lang('Enter a description of the project'),
- 'lang_descr'
=> lang('Description'),
- 'value_descr'
=> $values['descr'],
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'lang_save_statustext' =>
lang('Save the project'),
- 'lang_no_cat'
=> lang('Select category'),
- 'lang_cat_statustext' =>
lang('Select the category the project belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'values[cat_id]',
- 'value_cat_id'
=> $values['cat_id'],
- 'cat_list'
=> $this->bo->select_category_project_list('select',$values['cat_id']),
-
- 'lang_workorder_id'
=> lang('Workorder ID'),
- 'sum_workorder_budget' =>
$values['sum_workorder_budget'],
- 'sum_workorder_calculation' =>
$values['sum_workorder_calculation'],
- 'workorder_budget'
=> $values['workorder_budget'],
- 'sum_workorder_actual_cost' =>
$values['sum_workorder_actual_cost'],
-
- 'lang_actual_cost'
=> lang('Actual cost'),
- 'lang_coordinator'
=> lang('Coordinator'),
- 'lang_sum'
=> lang('Sum'),
- 'lang_user_statustext' =>
lang('Select the coordinator the project belongs to. To do not use a category
select NO USER'),
- 'select_user_name'
=> 'values[coordinator]',
- 'lang_no_user'
=> lang('Select coordinator'),
- 'user_list'
=>
$this->bocommon->get_user_list_right2('select',4,$values['coordinator'],$this->acl2_location),
-
- 'status_list'
=> $this->bo->select_status_list('select',$values['status']),
- 'status_name'
=> 'values[status]',
- 'lang_no_status'
=> lang('Select status'),
- 'lang_status'
=> lang('Status'),
- 'lang_status_statustext' =>
lang('What is the current status of this project ?'),
-
- 'branch_list'
=> $this->bo->select_branch_p_list($values['project_id']),
- 'lang_branch'
=> lang('branch'),
- 'lang_branch_statustext' =>
lang('Select the branches for this project'),
-
- 'key_responsible_list'
=> $this->bo->select_branch_list($values['key_responsible']),
- 'lang_no_key_responsible'
=> lang('Select key responsible'),
- 'lang_key_responsible'
=> lang('key responsible'),
- 'lang_key_responsible_statustext'
=> lang('Select the key responsible for this project'),
-
- 'key_fetch_list'
=> $this->bo->select_key_location_list($values['key_fetch']),
- 'lang_no_key_fetch'
=> lang('Where to fetch the key'),
- 'lang_key_fetch'
=> lang('key fetch location'),
- 'lang_key_fetch_statustext'
=> lang('Select where to fetch the key'),
-
- 'key_deliver_list'
=> $this->bo->select_key_location_list($values['key_deliver']),
- 'lang_no_key_deliver'
=> lang('Where to deliver the key'),
- 'lang_key_deliver'
=> lang('key deliver location'),
- 'lang_key_deliver_statustext' =>
lang('Select where to deliver the key'),
-
- 'need_approval'
=> $need_approval,
- 'lang_ask_approval'
=> lang('Ask for approval'),
- 'lang_ask_approval_statustext' =>
lang('Check this to send a mail to your supervisor for approval'),
- 'value_approval_mail_address' =>
$supervisor_email,
-
-
- 'currency'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['currency']
- );
-
- $appname = lang('project');
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function delete()
- {
- if(!$this->acl_delete)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
- }
-
- $project_id = get_var('project_id',array('POST','GET'));
- $confirm = get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiproject.index',
- 'project_id' => $project_id
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($project_id);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.delete&project_id='
. $project_id),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('project');
- $function_msg =
lang('delete project');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function view()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $receipt =
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp);
-
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp,'');
- $bolocation =
CreateObject($this->currentapp.'.bolocation');
-
- $id = get_var('id',array('POST','GET'));
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('project'));
-
- $values = $this->bo->read_single($id);
-
- $record_history = $this->bo->read_record_history($id);
-
- $table_header_history[] = array
- (
- 'lang_date' => lang('Date'),
- 'lang_user' => lang('User'),
- 'lang_action' => lang('Action'),
- 'lang_new_value' => lang('New value')
- );
-
- $table_header_workorder_budget[] = array
- (
- 'lang_workorder_id' => lang('Workorder'),
- 'lang_budget' => lang('Budget'),
- 'lang_calculation' => lang('Calculation'),
- 'lang_vendor' => lang('Vendor')
- );
-
- $function_msg = lang('View Project');
-
- if ($values['cat_id'])
- {
- $this->cat_id = $values['cat_id'];
- }
-
- $location_data=$bolocation->initiate_ui_location(array(
- 'values' =>
$values['location_data'],
- 'type_id' =>
count(explode('-',$values['location_data']['location_code'])),
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' =>
$values['location_data']['tenant_id'],
- 'lookup_type' => 'view',
- 'lookup_entity' =>
$this->bocommon->get_lookup_entity('project'),
- 'entity_data' => $values['p']
- ));
-
- if($values['contact_phone'])
- {
- for
($i=0;$i<count($location_data['location']);$i++)
- {
-
if($location_data['location'][$i]['input_name'] == 'contact_phone')
- {
-
unset($location_data['location'][$i]['value']);
- }
- }
- }
-
- if($values['reserve'])
- {
-
$reserve_remainder=$values['reserve']-$values['deviation'];
- $remainder_percent=
number_format(($reserve_remainder/$values['reserve'])*100, 2, ',', '');
- }
-
-//_debug_array($values);
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- if (isset($values['origin']) AND
is_array($values['origin']))
- {
- for ($i=0;$i<count($values['origin']);$i++)
- {
-
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
. $values['origin'][$i]['link']);
-
if(substr($values['origin'][$i]['type'],0,6)=='entity')
- {
- $type =
explode("_",$values['origin'][$i]['type']);
- $entity_id = $type[1];
- $cat_id = $type[2];
-
- if(!is_object($boadmin_entity))
- {
- $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
- }
- $entity_category =
$boadmin_entity->read_single_category($entity_id,$cat_id);
- $values['origin'][$i]['descr']
= $entity_category['name'];
- }
- else
- {
- $values['origin'][$i]['descr']=
lang($values['origin'][$i]['type']);
- }
- }
- }
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
-
- 'value_origin'
=> $values['origin'],
- 'value_origin_type'
=> $origin,
- 'value_origin_id'
=> $origin_id,
-
- 'table_header_workorder_budget' =>
$table_header_workorder_budget,
- 'lang_no_workorders' =>
lang('No workorder bugdet'),
- 'workorder_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.view'),
- 'record_history'
=> $record_history,
- 'table_header_history' =>
$table_header_history,
- 'lang_history'
=> lang('History'),
- 'lang_no_history'
=> lang('No history'),
-
- 'lang_start_date'
=> lang('Project start date'),
- 'value_start_date'
=> $values['start_date'],
-
- 'lang_end_date'
=> lang('Project end date'),
- 'value_end_date'
=> $values['end_date'],
-
- 'lang_charge_tenant' =>
lang('Charge tenant'),
- 'charge_tenant'
=> $values['charge_tenant'],
-
- 'lang_power_meter'
=> lang('Power meter'),
- 'value_power_meter'
=> $values['power_meter'],
-
- 'lang_budget'
=> lang('Budget'),
- 'value_budget'
=> $values['budget'],
-
- 'lang_reserve'
=> lang('reserve'),
- 'value_reserve'
=> $values['reserve'],
- 'lang_reserve_statustext' =>
lang('Enter the reserve'),
-
- 'lang_reserve_remainder' =>
lang('reserve remainder'),
- 'value_reserve_remainder' =>
$reserve_remainder,
- 'value_reserve_remainder_percent'=>
$remainder_percent,
-
- 'vendor_data'
=> $vendor_data,
- 'location_data'
=> $location_data,
- 'location_type'
=> 'view',
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.index'),
- 'lang_year'
=> lang('Year'),
- 'lang_category'
=> lang('category'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'lang_name'
=> lang('Name'),
-
- 'lang_project_id'
=> lang('Project ID'),
- 'value_project_id'
=> $values['project_id'],
- 'value_name'
=> $values['name'],
-
- 'lang_other_branch'
=> lang('Other branch'),
- 'value_other_branch' =>
$values['other_branch'],
-
- 'lang_descr'
=> lang('Description'),
- 'value_descr'
=> $values['descr'],
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'select_name'
=> 'values[cat_id]',
- 'cat_list'
=> $this->bo->select_category_project_list('select',$values['cat_id']),
-
- 'lang_workorder_id'
=> lang('Workorder ID'),
- 'sum_workorder_budget' =>
$values['sum_workorder_budget'],
- 'sum_workorder_calculation' =>
$values['sum_workorder_calculation'],
- 'workorder_budget'
=> $values['workorder_budget'],
- 'sum_workorder_actual_cost' =>
$values['sum_workorder_actual_cost'],
- 'lang_actual_cost'
=> lang('Actual cost'),
- 'lang_coordinator'
=> lang('Coordinator'),
- 'lang_sum'
=> lang('Sum'),
- 'select_user_name'
=> 'values[coordinator]',
- 'lang_no_user'
=> lang('Select coordinator'),
- 'user_list'
=>
$this->bocommon->get_user_list('select',$values['coordinator'],$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
-
- 'status_list'
=> $this->bo->select_status_list('select',$values['status']),
- 'lang_no_status'
=> lang('Select status'),
- 'lang_status'
=> lang('Status'),
-
- 'branch_list'
=> $this->bo->select_branch_p_list($values['project_id']),
- 'lang_branch'
=> lang('branch'),
-
- 'key_responsible_list' =>
$this->bo->select_branch_list($values['key_responsible']),
- 'lang_key_responsible' =>
lang('key responsible'),
-
- 'key_fetch_list'
=> $this->bo->select_key_location_list($values['key_fetch']),
- 'lang_key_fetch'
=> lang('key fetch location'),
-
- 'key_deliver_list'
=> $this->bo->select_key_location_list($values['key_deliver']),
- 'lang_key_deliver'
=> lang('key deliver location'),
-
- 'edit_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit&id='
. $id),
- 'lang_edit_statustext'
=> lang('Edit this entry project'),
- 'lang_edit'
=> lang('Edit'),
- 'currency'
=>
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
-
- 'lang_contact_phone' =>
lang('Contact phone'),
- 'contact_phone'
=> $values['contact_phone'],
- );
-
- $appname = lang('project');
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage project
+ * @version $Id: class.uiproject.inc.php,v 1.23 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uiproject
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+ var $part_of_town_id;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'excel' => True,
+ 'index' => True,
+ 'view' => True,
+ 'edit' => True,
+ 'delete' => True,
+ 'date_search'=>True
+ );
+
+ function uiproject()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $this->bo =
CreateObject($this->currentapp.'.boproject',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+ $this->acl2_location = '.project';
+ $this->acl_read =
$this->acl2->check('.project',1);
+ $this->acl_add =
$this->acl2->check('.project',2);
+ $this->acl_edit =
$this->acl2->check('.project',4);
+ $this->acl_delete =
$this->acl2->check('.project',8);
+
+ $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->status_id =
$this->bo->status_id;
+ $this->wo_hour_cat_id =
$this->bo->wo_hour_cat_id;
+
+
+ $this->menu->sub ='project';
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' => $this->filter,
+ 'cat_id' => $this->cat_id,
+ 'status_id' => $this->status_id,
+ 'wo_hour_cat_id'=> $this->wo_hour_cat_id
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function excel()
+ {
+ $start_date =
urldecode(get_var('start_date',array('POST','GET')));
+ $end_date =
urldecode(get_var('end_date',array('POST','GET')));
+ $list =
$this->bo->read($start_date,$end_date,$allrows=True);
+ $uicols = $this->bo->uicols;
+
$this->bocommon->excel($list,$uicols['name'],$uicols['descr'],$uicols['input_type']);
+ }
+
+ function index()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('project','values','table_header',
+
'menu',
+
'nextmatchs',
+
'search_field',
+
'wo_hour_cat_filter'));
+
+ $lookup =
get_var('lookup',array('POST','GET'));
+ $from =
get_var('from',array('POST','GET'));
+ $start_date =
urldecode(get_var('start_date',array('POST','GET')));
+ $end_date =
urldecode(get_var('end_date',array('POST','GET')));
+
+ $links = $this->menu->links('project');
+
+ $project_list = $this->bo->read($start_date,$end_date);
+ $uicols = $this->bo->uicols;
+ $count_uicols_name=count($uicols['name']);
+
+ $j=0;
+ if (isSet($project_list) AND is_array($project_list))
+ {
+ foreach($project_list as $project_entry)
+
+ {
+ for ($k=0;$k<$count_uicols_name;$k++)
+ {
+
if($uicols['input_type'][$k]=='text')
+ {
+
+
if($project_entry['query_location'][$uicols['name'][$k]])
+ {
+
$content[$j]['row'][]= array(
+
'statustext' => lang('search'),
+ 'text'
=> $project_entry[$uicols['name'][$k]],
+ 'link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.index&query='
. $project_entry['query_location'][$uicols['name'][$k]] . '&lookup=' . $lookup
. '&from=' . $from . '&filter=' . $this->filter)
+ );
+ }
+ else
+ {
+
$content[$j]['row'][]= array(
+ 'value'
=> $project_entry[$uicols['name'][$k]],
+ 'name'
=> $uicols['name'][$k]
+ );
+ }
+ }
+
elseif($uicols['input_type'][$k]=='link')
+ {
+
$content[$j]['row'][]= array(
+ 'statustext'
=> lang('search'),
+ 'text'
=> $project_entry[$uicols['name'][$k]],
+ 'link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitts.view&id='
. $project_entry[$uicols['name'][$k]])
+ );
+ }
+
+ if($lookup &&
$k==($count_uicols_name-1))
+ {
+ $content[$j]['row'][]=
array(
+ 'lookup_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.ui' .
$from . '.edit&project_id=' . $project_entry['project_id'])
+ );
+ }
+ }
+
+ if(!$lookup)
+ {
+ if ($this->acl_read &&
$this->bocommon->check_perms($project_entry['grants'],PHPGW_ACL_READ))
+ {
+ $content[$j]['row'][]=
array(
+ 'statustext'
=> lang('view the project'),
+ 'text'
=> lang('view'),
+ 'link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.view&id='
. $project_entry['project_id'])
+ );
+ }
+ else
+ {
+ $content[$j]['row'][]=
array('link'=>'dummy');
+ }
+
+ if ($this->acl_edit &&
$this->bocommon->check_perms($project_entry['grants'],PHPGW_ACL_EDIT))
+ {
+ $content[$j]['row'][]=
array(
+ 'statustext' =>
lang('edit the project'),
+ 'text'
=> lang('edit'),
+ 'link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit&id='
. $project_entry['project_id'])
+ );
+ }
+ else
+ {
+ $content[$j]['row'][]=
array('link'=>'dummy');
+ }
+
+ if ($this->acl_delete &&
$this->bocommon->check_perms($project_entry['grants'],PHPGW_ACL_DELETE))
+ {
+ $content[$j]['row'][]=
array(
+ 'statustext' =>
lang('delete the project'),
+ 'text'
=> lang('delete'),
+ 'link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.delete&project_id='
. $project_entry['project_id'])
+ );
+ }
+ else
+ {
+ $content[$j]['row'][]=
array('link'=>'dummy');
+ }
+ }
+
+ $j++;
+ }
+ }
+
+ $count_uicols_descr=count($uicols['descr']);
+ for ($i=0;$i<$count_uicols_descr;$i++)
+ {
+ if($uicols['input_type'][$i]!='hidden')
+ {
+ $table_header[$i]['header'] =
$uicols['descr'][$i];
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ if($uicols['name'][$i]=='loc1')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'location_code',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiproject.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'lookup'
=>$lookup,
+
'from' =>$from,
+
'district_id' =>
$this->district_id,
+
'cat_id'
=>$this->cat_id,
+
'start_date'=>$start_date,
+
'end_date'=>$end_date,
+
'wo_hour_cat_id'
=>$this->wo_hour_cat_id
+
)
+
));
+ }
+ if($uicols['name'][$i]=='project_id')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'project_id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiproject.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'lookup'
=>$lookup,
+
'from' =>$from,
+
'district_id' =>
$this->district_id,
+
'cat_id'
=>$this->cat_id,
+
'start_date'=>$start_date,
+
'end_date'=>$end_date,
+
'wo_hour_cat_id'
=>$this->wo_hour_cat_id
+
)
+
));
+ }
+ if($uicols['name'][$i]=='address')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'address',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiproject.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'lookup'
=>$lookup,
+
'from' =>$from,
+
'district_id' =>
$this->district_id,
+
'cat_id'
=>$this->cat_id,
+
'start_date'=>$start_date,
+
'end_date'=>$end_date,
+
'wo_hour_cat_id'
=>$this->wo_hour_cat_id
+
)
+
));
+ }
+ }
+ }
+
+ if(!$lookup)
+ {
+ if($this->acl_read)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('view');
+ $i++;
+ }
+ if($this->acl_edit)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('edit');
+ $i++;
+ }
+ if($this->acl_delete)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('delete');
+ $i++;
+ }
+ }
+ else
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header'] =
lang('select');
+ }
+
+//_debug_array($content);
+ if($this->acl_add)
+ {
+ $table_add[] = array
+ (
+ 'lang_add'
=> lang('add'),
+ 'lang_add_statustext' => lang('add a
project'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit')
+ );
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiproject.index',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'district_id'
=>$this->district_id,
+ 'filter'
=>$this->filter,
+ 'status_id'
=>$this->status_id,
+ 'lookup'
=>$lookup,
+ 'from' =>$from,
+ 'query'
=>$this->query,
+ 'start_date' =>$start_date,
+ 'end_date'
=>$end_date,
+ 'wo_hour_cat_id'
=>$this->wo_hour_cat_id,
+ );
+
+ $link_date_search
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.date_search');
+
+ $link_excel = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiproject.excel',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'district_id'
=>$this->district_id,
+ 'filter'
=>$this->filter,
+ 'status_id'
=>$this->status_id,
+ 'lookup'
=>$lookup,
+ 'from' =>$from,
+ 'query'
=>$this->query,
+ 'start_date'
=>$start_date,
+ 'end_date'
=>$end_date,
+ 'start'
=>$this->start,
+ 'wo_hour_cat_id'
=>$this->wo_hour_cat_id,
+ );
+
+ $data = array
+ (
+ 'lang_excel' =>
'excel',
+ 'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
+ 'lang_excel_help' =>
lang('Download table to MS Excel'),
+
+ 'start_date'
=>$start_date,
+ 'end_date'
=>$end_date,
+ 'lang_none'
=>lang('None'),
+ 'lang_date_search' =>
lang('Date search'),
+ 'lang_date_search_help' => lang('Narrow
the search by dates'),
+ 'link_date_search' =>
$link_date_search,
+ 'overlib_source' =>
'./'.$this->currentapp.'/inc/overlib.js',
+
+ 'lang_select'
=> lang('select'),
+ 'lookup_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit'),
+ 'lookup'
=> $lookup,
+ 'links'
=> $links,
+ 'allow_allrows'
=> false,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($project_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the project belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $this->bo->select_category_project_list('filter',$this->cat_id),
+ 'district_list'
=> $this->bocommon->select_district_list('filter',$this->district_id),
+ 'lang_no_district'
=> lang('no district'),
+ 'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
+ 'select_district_name' =>
'district_id',
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+
+ 'lang_status_statustext' =>
lang('Select the status the agreement belongs to. To do not use a category
select NO STATUS'),
+ 'status_name'
=> 'status_id',
+ 'lang_no_status'
=> lang('No status'),
+ 'status_list'
=> $this->bo->select_status_list('filter',$this->status_id),
+
+ 'lang_wo_hour_cat_statustext' =>
lang('Select the workorder hour category'),
+ 'lang_no_wo_hour_cat' =>
lang('no hour category'),
+ 'wo_hour_cat_list'
=> $this->bocommon->select_wo_hours_category_list($this->wo_hour_cat_id),
+
+ 'lang_user_statustext' =>
lang('Select the user the project belongs to. To do not use a category select
NO USER'),
+ 'select_user_name'
=> 'filter',
+ 'lang_no_user'
=> lang('No user'),
+ 'user_list'
=>
$this->bocommon->get_user_list_right2('filter',4,$this->filter,$this->acl2_location,array('all'),$default=$this->account),
+
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('Project');
+ $function_msg =
lang('list Project');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_project' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function date_search()
+ {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('date_search'));
+ $GLOBALS['phpgw_info']['flags']['noframework'] = True;
+ $GLOBALS['phpgw_info']['flags'][noheader] = True;
+ $GLOBALS['phpgw_info']['flags'][nofooter] = True;
+ $values['start_date'] =
get_var('start_date',array('POST'));
+ $values['end_date'] =
get_var('end_date',array('POST'));
+
+ $function_msg = lang('Date search');
+ $appname = lang('project');
+
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ if(!$values['end_date'])
+ {
+ $values['end_date'] =
$GLOBALS['phpgw']->common->show_date(mktime(0,0,0,date("m"),date("d"),date("Y")),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ }
+
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+ $data = array
+ (
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle'
=> lang('Select date'),
+ 'calendar_setup_start' =>
"Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});",
+ 'calendar_setup_end' =>
"Calendar.setup({inputField : 'end_date',ifFormat : '" . $jsDateFormat .
"',button : 'end_date-trigger'});",
+
+ 'lang_start_date_statustext' => lang('Select
the estimated end date for the Project'),
+ 'lang_start_date'
=> lang('Start date'),
+ 'value_start_date'
=> $values['start_date'],
+
+ 'lang_end_date_statustext' =>
lang('Select the estimated end date for the Project'),
+ 'lang_end_date'
=> lang('End date'),
+ 'value_end_date'
=> $values['end_date'],
+
+ 'dateformat'
=> $dateformat,
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_submit_statustext' =>
lang('Select this dates'),
+ 'lang_submit' =>
lang('Submit')
+ );
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('date_search' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function edit()
+ {
+ if(!$this->acl_add && !$this->acl_edit)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
+ }
+ $id =
get_var('id',array('POST','GET'));
+ $values =
get_var('values',array('POST'));
+ $add_request =
get_var('add_request',array('POST'));
+
+ $config =
CreateObject('phpgwapi.config');
+ $bolocation =
CreateObject($this->currentapp.'.bolocation');
+
+ $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
+ $insert_record_entity =
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp);
+
+ for ($j=0;$j<count($insert_record_entity);$j++)
+ {
+
$insert_record['extra'][$insert_record_entity[$j]] =
$insert_record_entity[$j];
+ }
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('project'));
+
+ $bypass =
get_var('bypass',array('POST','GET'));
+
+ if($add_request)
+ {
+ $receipt =
$this->bo->add_request($add_request,$id);
+ }
+
+ if($_POST && !$bypass)
+ {
+ for ($i=0;
$i<count($insert_record['location']); $i++)
+ {
+
if($_POST[$insert_record['location'][$i]])
+ {
+
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
+ }
+ }
+
+ while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
+ {
+ if($_POST[$key])
+ {
+ $values['extra'][$column]
= $_POST[$key];
+ }
+ }
+
+ $values['street_name'] =
$_POST['street_name'];
+ $values['street_number'] =
$_POST['street_number'];
+ $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
+
+ }
+ else
+ {
+ $location_code =
get_var('location_code',array('POST','GET'));
+ $tenant_id =
get_var('tenant_id',array('POST','GET'));
+ $values['descr'] =
get_var('descr',array('POST','GET'));
+ $p_entity_id =
get_var('p_entity_id',array('POST','GET'));
+ $p_cat_id =
get_var('p_cat_id',array('POST','GET'));
+ $values['p'][$p_entity_id]['p_entity_id']
= $p_entity_id;
+ $values['p'][$p_entity_id]['p_cat_id']
= $p_cat_id;
+ $values['p'][$p_entity_id]['p_num']
= get_var('p_num',array('POST','GET'));
+
+ $origin =
get_var('origin',array('POST','GET'));
+ $origin_id =
get_var('origin_id',array('POST','GET'));
+
+ if($p_entity_id && $p_cat_id)
+ {
+
+ if(!is_object($boadmin_entity))
+ {
+ $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
+ }
+
+ $entity_category =
$boadmin_entity->read_single_category($p_entity_id,$p_cat_id);
+
$values['p'][$p_entity_id]['p_cat_name'] = $entity_category['name'];
+ }
+
+ if($location_code)
+ {
+ $values['location_data'] =
$bolocation->read_single($location_code,array('tenant_id'=>$tenant_id,'p_num'=>$p_num));
+ }
+
+ }
+
+ if($values['origin'])
+ {
+ $origin = $values['origin'];
+ $origin_id = $values['origin_id'];
+ }
+
+ if($origin)
+ {
+ unset($values['origin']);
+ unset($values['origin_id']);
+ $values['origin'][0]['type']= $origin;
+
$values['origin'][0]['link']=$this->bocommon->get_origin_link($origin);
+ $values['origin'][0]['data'][]= array(
+ 'id'=> $origin_id,
+ 'type'=> $origin
+ );
+ }
+
+ $values['start_date'] =
get_var('start_date',array('POST'));
+ $values['end_date'] =
get_var('end_date',array('POST'));
+
+ $config->read_repository();
+
+ if ($values['save'])
+ {
+ $save=true;
+
+ if(!$values['location'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a location !'));
+ $error_id=true;
+ }
+
+ if(!$values['name'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter a project NAME !'));
+ $error_id=true;
+ }
+
+ if(!$values['cat_id'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
+ $error_id=true;
+ }
+
+ if(!$values['coordinator'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a coordinator !'));
+ $error_id=true;
+ }
+
+ if(!$values['status'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a status !'));
+ }
+
+ if($id)
+ {
+ $values['project_id']=$id;
+ $action='edit';
+ }
+
+ if(!$receipt['error'])
+ {
+ if(!$id)
+ {
+
$values['project_id']=$this->bo->next_project_id();
+ $id = $values['project_id'];
+ }
+
+ if($values['copy_project'])
+ {
+ $action='add';
+ $values['project_id'] =
$this->bo->next_project_id();
+ $id = $values['project_id'];
+ }
+ $receipt =
$this->bo->save($values,$action);
+ if($receipt['error'])
+ {
+ unset($id);
+ unset($values['project_id']);
+ }
+
+ if ($values['approval'] &&
$values['mail_address'])
+ {
+
$from_name=$GLOBALS['phpgw_info']['user']['fullname'];
+
$from_email=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['email'];
+ $headers = "Return-Path: <".
$from_email .">\r\n";
+ $headers .= "From: " .
$from_name . "<" . $from_email .">\r\n";
+ $headers .= "Bcc: " .
$from_name . "<" . $from_email .">\r\n";
+ $headers .= "Content-type:
text/plain; charset=iso-8859-1\r\n";
+
+ $subject = lang(Approval).": ".
$values['project_id'];
+ $message = lang(Project) . " "
. $values['project_id'] ." ". lang('needs approval');
+
+ $mail_method=
$config->config_data['fmwrkorder_mail'];
+ if ($mail_method=='smtp'):
+ {
+ $bcc = $from_email;
+ if
(!is_object($GLOBALS['phpgw']->send))
+ {
+
$GLOBALS['phpgw']->send = CreateObject('phpgwapi.send');
+ }
+
+ $rcpt =
$GLOBALS['phpgw']->send->msg('email',$values['mail_address'], $subject,
stripslashes($message), '', $cc, $bcc, $from_email, $from_name, 'plain');
+
+ if(!$rcpt)
+ {
+
$receipt['error'][]=array('msg'=>"uiproject::edit: sending message to '" .
$values['mail_address'] . "', subject='$subject' failed !!!");
+
$receipt['error'][]=array('msg'=> $GLOBALS['phpgw']->send->err['desc']);
+
$bypass_error=True;
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('%1 is
notified',$values['mail_address']));
+ }
+
+ }
+ elseif
($mail_method=='sendmail'):
+ {
+
$rcpt=mail($values['mail_address'],$subject,$message, $headers);
+ }
+ else:
+ {
+
$receipt['error'][]=array('msg'=>lang('Mailing method is not chosen! (admin
section)'));
+ $bypass_error=True;
+ }
+ endif;
+ }
+ }
+
+ if (isset($receipt['notice_owner']) AND
is_array($receipt['notice_owner']))
+ {
+
if($this->account!=$values['coordinator'] &&
$config->config_data['workorder_approval'])
+ {
+
+ $prefs_coordinator =
$this->bocommon->create_preferences($this->currentapp,$values['coordinator']);
+ $to =
$prefs_coordinator['email'];
+
+
$from_name=$GLOBALS['phpgw_info']['user']['fullname'];
+
$from_email=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['email'];
+
+
foreach($receipt['notice_owner'] as $notice)
+ {
+ $body .= $notice . "\n";
+ }
+
+ $body .= lang('Altered by') .
': ' . $from_name . "\n";
+
+ if
(!is_object($GLOBALS['phpgw']->send))
+ {
+ $GLOBALS['phpgw']->send
= CreateObject('phpgwapi.send');
+ }
+
+ $returncode =
$GLOBALS['phpgw']->send->msg('email',$to,$subject=lang('Project %1 is
altered',$id),$body, False,False,False, $from_email, $from_name, 'plain');
+
+ if (!$returncode) // not
nice, but better than failing silently
+ {
+
$receipt['error'][]=array('msg'=>"uiproject::edit: sending message to '$to'
subject='$subject' failed !!!");
+
$receipt['error'][]=array('msg'=> $GLOBALS['phpgw']->send->err['desc']);
+ $bypass_error=True;
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('%1 is notified',$to));
+ }
+ }
+ }
+
+
+ if($receipt['error'] && !$bypass_error)
+ {
+ if($values['location'])
+ {
+ $location_code=implode("-",
$values['location']);
+ $values['location_data'] =
$bolocation->read_single($location_code,$values['extra']);
+ }
+
+ if($values['extra']['p_num'])
+ {
+
$values['p'][$values['extra']['p_entity_id']]['p_num']=$values['extra']['p_num'];
+
$values['p'][$values['extra']['p_entity_id']]['p_entity_id']=$values['extra']['p_entity_id'];
+
$values['p'][$values['extra']['p_entity_id']]['p_cat_id']=$values['extra']['p_cat_id'];
+
$values['p'][$values['extra']['p_entity_id']]['p_cat_name']=$_POST['entity_cat_name_'.$values['extra']['p_entity_id']];
+ }
+ }
+ }
+
+ if($bypass_error || ((!$receipt['error'] ||
$add_request) && !$bypass) && $id)
+ {
+ $values = $this->bo->read_single($id);
+
+ if(!$values['workorder_budget'] && $save)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit&project_id='
. $id);
+ }
+
+ if
(!$this->bocommon->check_perms($values['grants'],PHPGW_ACL_EDIT))
+ {
+
$receipt['error'][]=array('msg'=>lang('You have no edit right for this
project'));
+
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp,$receipt);
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiproject.view&id='
. $id);
+ }
+ else
+ {
+ $record_history =
$this->bo->read_record_history($id);
+ }
+ }
+
+
+ $table_header_history[] = array
+ (
+ 'lang_date' => lang('Date'),
+ 'lang_user' => lang('User'),
+ 'lang_action' => lang('Action'),
+ 'lang_new_value' => lang('New value')
+ );
+
+ $table_header_workorder_budget[] = array
+ (
+ 'lang_workorder_id' => lang('Workorder'),
+ 'lang_budget' => lang('Budget'),
+ 'lang_calculation' => lang('Calculation'),
+ 'lang_vendor' => lang('Vendor')
+ );
+
+ if ($id)
+ {
+ $function_msg = lang('Edit Project');
+ }
+ else
+ {
+ $function_msg = lang('Add Project');
+ }
+
+ if ($values['cat_id'])
+ {
+ $this->cat_id = $values['cat_id'];
+ }
+
+ $lookup_type='form';
+
+//_debug_array($values);
+ $location_data=$bolocation->initiate_ui_location(array(
+ 'values' =>
$values['location_data'],
+ 'type_id' => -1,
// calculated from location_types
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' => True,
+ 'lookup_type' => $lookup_type,
+ 'lookup_entity' =>
$this->bocommon->get_lookup_entity('project'),
+ 'entity_data' => $values['p']
+ ));
+
+ if($values['contact_phone'])
+ {
+ for
($i=0;$i<count($location_data['location']);$i++)
+ {
+
if($location_data['location'][$i]['input_name'] == 'contact_phone')
+ {
+
$location_data['location'][$i]['value'] = $values['contact_phone'];
+ }
+ }
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiproject.edit',
+ 'id' => $id
+ );
+
+ $link_request_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uirequest.index',
+ 'query' =>
$values['location_data']['loc1'],
+ 'project_id' => $values['project_id']
+ );
+
+
+
$supervisor_id=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['approval_from'];
+ $need_approval =
$config->config_data['workorder_approval'];
+
+
$project_status=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['project_status'];
+
$project_category=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['project_category'];
+ if(!$values['status'])
+ {
+ $values['status']=$project_status;
+ }
+
+ if(!$values['cat_id'])
+ {
+ $values['cat_id']=$project_category;
+ }
+
+ if(!$values['coordinator'])
+ {
+ $values['coordinator']=$this->account;
+ }
+
+ if ($supervisor_id && $need_approval=='yes')
+ {
+ $prefs =
$this->bocommon->create_preferences($this->currentapp,$supervisor_id);
+ $supervisor_email = $prefs['email'];
+ }
+
+ if(!$values['start_date'])
+ {
+ $values['start_date'] =
$GLOBALS['phpgw']->common->show_date(mktime(0,0,0,date("m"),date("d"),date("Y")),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ }
+
+ if($receipt)
+ {
+ $msgbox_data =
$this->bocommon->msgbox_data($receipt);
+ }
+
+ if($values['reserve'])
+ {
+
$reserve_remainder=$values['reserve']-$values['deviation'];
+ $remainder_percent=
number_format(($reserve_remainder/$values['reserve'])*100, 2, ',', '');
+ }
+
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+
+ if (isset($values['origin']) AND
is_array($values['origin']))
+ {
+ for ($i=0;$i<count($values['origin']);$i++)
+ {
+
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
. $values['origin'][$i]['link']);
+
if(substr($values['origin'][$i]['type'],0,6)=='entity')
+ {
+ $type =
explode("_",$values['origin'][$i]['type']);
+ $entity_id = $type[1];
+ $cat_id = $type[2];
+
+ if(!is_object($boadmin_entity))
+ {
+ $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
+ }
+ $entity_category =
$boadmin_entity->read_single_category($entity_id,$cat_id);
+ $values['origin'][$i]['descr']
= $entity_category['name'];
+ }
+ else
+ {
+ $values['origin'][$i]['descr']=
lang($values['origin'][$i]['type']);
+
if($values['origin'][$i]['type'] == 'request')
+ {
+ $selected_request =
True;
+ }
+ }
+ }
+ }
+
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+
+ 'value_origin'
=> $values['origin'],
+ 'value_origin_type'
=> $origin,
+ 'value_origin_id'
=> $origin_id,
+ 'selected_request'
=> $selected_request,
+
+ 'lang_select_request' =>
lang('Select request'),
+ 'lang_select_request_statustext' =>
lang('Add request for this project'),
+ 'lang_request_statustext' =>
lang('Link to the request for this project'),
+ 'lang_delete_request_statustext'=> lang('Check
to delete this request from this project'),
+ 'link_select_request' =>
$GLOBALS['phpgw']->link('/index.php',$link_request_data),
+ 'link_request'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.view'),
+
+ 'add_workorder_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit'),
+ 'lang_add_workorder'
=> lang('Add Workorder'),
+ 'lang_add_workorder_statustext' =>
lang('Add a workorder to this project'),
+
+ 'table_header_workorder_budget' =>
$table_header_workorder_budget,
+ 'lang_no_workorders' =>
lang('No workorder bugdet'),
+ 'workorder_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit'),
+ 'record_history'
=> $record_history,
+ 'table_header_history' =>
$table_header_history,
+ 'lang_history'
=> lang('History'),
+ 'lang_no_history'
=> lang('No history'),
+
+// 'cal_info'
=> $cal_info,
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle'
=> lang('Select date'),
+ 'calendar_setup_start' =>
"Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});",
+ 'calendar_setup_end' =>
"Calendar.setup({inputField : 'end_date',ifFormat : '" . $jsDateFormat .
"',button : 'end_date-trigger'});",
+
+ 'lang_start_date_statustext' => lang('Select
the estimated end date for the Project'),
+ 'lang_start_date'
=> lang('Project start date'),
+ 'value_start_date'
=> $values['start_date'],
+
+ 'lang_end_date_statustext' =>
lang('Select the estimated end date for the Project'),
+ 'lang_end_date'
=> lang('Project end date'),
+ 'value_end_date'
=> $values['end_date'],
+
+ 'lang_copy_project'
=> lang('Copy project ?'),
+ 'lang_copy_project_statustext' => lang('Choose
Copy Project to copy this project to a new project'),
+
+ 'lang_charge_tenant' =>
lang('Charge tenant'),
+ 'lang_charge_tenant_statustext' => lang('Choose
charge tenant if the tenant i to pay for this project'),
+ 'charge_tenant'
=> $values['charge_tenant'],
+
+ 'lang_power_meter'
=> lang('Power meter'),
+ 'lang_power_meter_statustext' => lang('Enter
the power_meter'),
+ 'value_power_meter'
=> $values['power_meter'],
+
+ 'lang_budget'
=> lang('Budget'),
+ 'value_budget'
=> $values['budget'],
+ 'lang_budget_statustext' =>
lang('Enter the budget'),
+
+ 'lang_reserve'
=> lang('reserve'),
+ 'value_reserve'
=> $values['reserve'],
+ 'lang_reserve_statustext' =>
lang('Enter the reserve'),
+
+ 'lang_reserve_remainder' =>
lang('reserve remainder'),
+ 'value_reserve_remainder' =>
$reserve_remainder,
+ 'value_reserve_remainder_percent'=>
$remainder_percent,
+
+ 'vendor_data'
=> $vendor_data,
+ 'location_data'
=> $location_data,
+ 'location_type'
=> 'form',
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.index'),
+ 'lang_year'
=> lang('Year'),
+ 'lang_category'
=> lang('category'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'lang_name'
=> lang('Name'),
+
+ 'lang_project_id'
=> lang('Project ID'),
+ 'value_project_id'
=> $values['project_id'],
+ 'value_name'
=> $values['name'],
+ 'lang_name_statustext' =>
lang('Enter Project Name'),
+
+ 'lang_other_branch'
=> lang('Other branch'),
+ 'lang_other_branch_statustext' =>
lang('Enter other branch if not found in the list'),
+ 'value_other_branch'
=> $values['other_branch'],
+
+ 'lang_descr_statustext' =>
lang('Enter a description of the project'),
+ 'lang_descr'
=> lang('Description'),
+ 'value_descr'
=> $values['descr'],
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'lang_save_statustext' =>
lang('Save the project'),
+ 'lang_no_cat'
=> lang('Select category'),
+ 'lang_cat_statustext' =>
lang('Select the category the project belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'values[cat_id]',
+ 'value_cat_id'
=> $values['cat_id'],
+ 'cat_list'
=> $this->bo->select_category_project_list('select',$values['cat_id']),
+
+ 'lang_workorder_id'
=> lang('Workorder ID'),
+ 'sum_workorder_budget' =>
$values['sum_workorder_budget'],
+ 'sum_workorder_calculation' =>
$values['sum_workorder_calculation'],
+ 'workorder_budget'
=> $values['workorder_budget'],
+ 'sum_workorder_actual_cost' =>
$values['sum_workorder_actual_cost'],
+
+ 'lang_actual_cost'
=> lang('Actual cost'),
+ 'lang_coordinator'
=> lang('Coordinator'),
+ 'lang_sum'
=> lang('Sum'),
+ 'lang_user_statustext' =>
lang('Select the coordinator the project belongs to. To do not use a category
select NO USER'),
+ 'select_user_name'
=> 'values[coordinator]',
+ 'lang_no_user'
=> lang('Select coordinator'),
+ 'user_list'
=>
$this->bocommon->get_user_list_right2('select',4,$values['coordinator'],$this->acl2_location),
+
+ 'status_list'
=> $this->bo->select_status_list('select',$values['status']),
+ 'status_name'
=> 'values[status]',
+ 'lang_no_status'
=> lang('Select status'),
+ 'lang_status'
=> lang('Status'),
+ 'lang_status_statustext' =>
lang('What is the current status of this project ?'),
+
+ 'branch_list'
=> $this->bo->select_branch_p_list($values['project_id']),
+ 'lang_branch'
=> lang('branch'),
+ 'lang_branch_statustext' =>
lang('Select the branches for this project'),
+
+ 'key_responsible_list'
=> $this->bo->select_branch_list($values['key_responsible']),
+ 'lang_no_key_responsible'
=> lang('Select key responsible'),
+ 'lang_key_responsible'
=> lang('key responsible'),
+ 'lang_key_responsible_statustext'
=> lang('Select the key responsible for this project'),
+
+ 'key_fetch_list'
=> $this->bo->select_key_location_list($values['key_fetch']),
+ 'lang_no_key_fetch'
=> lang('Where to fetch the key'),
+ 'lang_key_fetch'
=> lang('key fetch location'),
+ 'lang_key_fetch_statustext'
=> lang('Select where to fetch the key'),
+
+ 'key_deliver_list'
=> $this->bo->select_key_location_list($values['key_deliver']),
+ 'lang_no_key_deliver'
=> lang('Where to deliver the key'),
+ 'lang_key_deliver'
=> lang('key deliver location'),
+ 'lang_key_deliver_statustext' =>
lang('Select where to deliver the key'),
+
+ 'need_approval'
=> $need_approval,
+ 'lang_ask_approval'
=> lang('Ask for approval'),
+ 'lang_ask_approval_statustext' =>
lang('Check this to send a mail to your supervisor for approval'),
+ 'value_approval_mail_address' =>
$supervisor_email,
+
+
+ 'currency'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['currency']
+ );
+
+ $appname = lang('project');
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function delete()
+ {
+ if(!$this->acl_delete)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
+ }
+
+ $project_id = get_var('project_id',array('POST','GET'));
+ $confirm = get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiproject.index',
+ 'project_id' => $project_id
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($project_id);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.delete&project_id='
. $project_id),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('project');
+ $function_msg =
lang('delete project');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function view()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $receipt =
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp);
+
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp,'');
+ $bolocation =
CreateObject($this->currentapp.'.bolocation');
+
+ $id = get_var('id',array('POST','GET'));
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('project'));
+
+ $values = $this->bo->read_single($id);
+
+ $record_history = $this->bo->read_record_history($id);
+
+ $table_header_history[] = array
+ (
+ 'lang_date' => lang('Date'),
+ 'lang_user' => lang('User'),
+ 'lang_action' => lang('Action'),
+ 'lang_new_value' => lang('New value')
+ );
+
+ $table_header_workorder_budget[] = array
+ (
+ 'lang_workorder_id' => lang('Workorder'),
+ 'lang_budget' => lang('Budget'),
+ 'lang_calculation' => lang('Calculation'),
+ 'lang_vendor' => lang('Vendor')
+ );
+
+ $function_msg = lang('View Project');
+
+ if ($values['cat_id'])
+ {
+ $this->cat_id = $values['cat_id'];
+ }
+
+ $location_data=$bolocation->initiate_ui_location(array(
+ 'values' =>
$values['location_data'],
+ 'type_id' =>
count(explode('-',$values['location_data']['location_code'])),
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' =>
$values['location_data']['tenant_id'],
+ 'lookup_type' => 'view',
+ 'lookup_entity' =>
$this->bocommon->get_lookup_entity('project'),
+ 'entity_data' => $values['p']
+ ));
+
+ if($values['contact_phone'])
+ {
+ for
($i=0;$i<count($location_data['location']);$i++)
+ {
+
if($location_data['location'][$i]['input_name'] == 'contact_phone')
+ {
+
unset($location_data['location'][$i]['value']);
+ }
+ }
+ }
+
+ if($values['reserve'])
+ {
+
$reserve_remainder=$values['reserve']-$values['deviation'];
+ $remainder_percent=
number_format(($reserve_remainder/$values['reserve'])*100, 2, ',', '');
+ }
+
+//_debug_array($values);
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ if (isset($values['origin']) AND
is_array($values['origin']))
+ {
+ for ($i=0;$i<count($values['origin']);$i++)
+ {
+
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
. $values['origin'][$i]['link']);
+
if(substr($values['origin'][$i]['type'],0,6)=='entity')
+ {
+ $type =
explode("_",$values['origin'][$i]['type']);
+ $entity_id = $type[1];
+ $cat_id = $type[2];
+
+ if(!is_object($boadmin_entity))
+ {
+ $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
+ }
+ $entity_category =
$boadmin_entity->read_single_category($entity_id,$cat_id);
+ $values['origin'][$i]['descr']
= $entity_category['name'];
+ }
+ else
+ {
+ $values['origin'][$i]['descr']=
lang($values['origin'][$i]['type']);
+ }
+ }
+ }
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+
+ 'value_origin'
=> $values['origin'],
+ 'value_origin_type'
=> $origin,
+ 'value_origin_id'
=> $origin_id,
+
+ 'table_header_workorder_budget' =>
$table_header_workorder_budget,
+ 'lang_no_workorders' =>
lang('No workorder bugdet'),
+ 'workorder_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.view'),
+ 'record_history'
=> $record_history,
+ 'table_header_history' =>
$table_header_history,
+ 'lang_history'
=> lang('History'),
+ 'lang_no_history'
=> lang('No history'),
+
+ 'lang_start_date'
=> lang('Project start date'),
+ 'value_start_date'
=> $values['start_date'],
+
+ 'lang_end_date'
=> lang('Project end date'),
+ 'value_end_date'
=> $values['end_date'],
+
+ 'lang_charge_tenant' =>
lang('Charge tenant'),
+ 'charge_tenant'
=> $values['charge_tenant'],
+
+ 'lang_power_meter'
=> lang('Power meter'),
+ 'value_power_meter'
=> $values['power_meter'],
+
+ 'lang_budget'
=> lang('Budget'),
+ 'value_budget'
=> $values['budget'],
+
+ 'lang_reserve'
=> lang('reserve'),
+ 'value_reserve'
=> $values['reserve'],
+ 'lang_reserve_statustext' =>
lang('Enter the reserve'),
+
+ 'lang_reserve_remainder' =>
lang('reserve remainder'),
+ 'value_reserve_remainder' =>
$reserve_remainder,
+ 'value_reserve_remainder_percent'=>
$remainder_percent,
+
+ 'vendor_data'
=> $vendor_data,
+ 'location_data'
=> $location_data,
+ 'location_type'
=> 'view',
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.index'),
+ 'lang_year'
=> lang('Year'),
+ 'lang_category'
=> lang('category'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'lang_name'
=> lang('Name'),
+
+ 'lang_project_id'
=> lang('Project ID'),
+ 'value_project_id'
=> $values['project_id'],
+ 'value_name'
=> $values['name'],
+
+ 'lang_other_branch'
=> lang('Other branch'),
+ 'value_other_branch' =>
$values['other_branch'],
+
+ 'lang_descr'
=> lang('Description'),
+ 'value_descr'
=> $values['descr'],
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'select_name'
=> 'values[cat_id]',
+ 'cat_list'
=> $this->bo->select_category_project_list('select',$values['cat_id']),
+
+ 'lang_workorder_id'
=> lang('Workorder ID'),
+ 'sum_workorder_budget' =>
$values['sum_workorder_budget'],
+ 'sum_workorder_calculation' =>
$values['sum_workorder_calculation'],
+ 'workorder_budget'
=> $values['workorder_budget'],
+ 'sum_workorder_actual_cost' =>
$values['sum_workorder_actual_cost'],
+ 'lang_actual_cost'
=> lang('Actual cost'),
+ 'lang_coordinator'
=> lang('Coordinator'),
+ 'lang_sum'
=> lang('Sum'),
+ 'select_user_name'
=> 'values[coordinator]',
+ 'lang_no_user'
=> lang('Select coordinator'),
+ 'user_list'
=>
$this->bocommon->get_user_list('select',$values['coordinator'],$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
+
+ 'status_list'
=> $this->bo->select_status_list('select',$values['status']),
+ 'lang_no_status'
=> lang('Select status'),
+ 'lang_status'
=> lang('Status'),
+
+ 'branch_list'
=> $this->bo->select_branch_p_list($values['project_id']),
+ 'lang_branch'
=> lang('branch'),
+
+ 'key_responsible_list' =>
$this->bo->select_branch_list($values['key_responsible']),
+ 'lang_key_responsible' =>
lang('key responsible'),
+
+ 'key_fetch_list'
=> $this->bo->select_key_location_list($values['key_fetch']),
+ 'lang_key_fetch'
=> lang('key fetch location'),
+
+ 'key_deliver_list'
=> $this->bo->select_key_location_list($values['key_deliver']),
+ 'lang_key_deliver'
=> lang('key deliver location'),
+
+ 'edit_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit&id='
. $id),
+ 'lang_edit_statustext'
=> lang('Edit this entry project'),
+ 'lang_edit'
=> lang('Edit'),
+ 'currency'
=>
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
+
+ 'lang_contact_phone' =>
lang('Contact phone'),
+ 'contact_phone'
=> $values['contact_phone'],
+ );
+
+ $appname = lang('project');
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+ }
+?>
Index: property/inc/class.uirequest.inc.php
diff -u property/inc/class.uirequest.inc.php:1.17
property/inc/class.uirequest.inc.php:1.18
--- property/inc/class.uirequest.inc.php:1.17 Wed Nov 9 13:32:47 2005
+++ property/inc/class.uirequest.inc.php Fri Jan 27 14:05:43 2006
@@ -1,1229 +1,1229 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage project
- * @version $Id: class.uirequest.inc.php,v 1.17 2005/11/09 13:32:47
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uirequest
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
- var $part_of_town_id;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'index' => True,
- 'view' => True,
- 'edit' => True,
- 'delete' => True,
- 'priority_key' => True,
- 'view_file' => True
- );
-
- function uirequest()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bo =
CreateObject($this->currentapp.'.borequest',True);
- $this->boproject =
CreateObject($this->currentapp.'.boproject');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
- $this->bolocation =
CreateObject($this->currentapp.'.bolocation');
- $this->config =
CreateObject('phpgwapi.config');
-
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
- $this->acl2_location = '.project';
- $this->acl_read =
$this->acl2->check('.project',1);
- $this->acl_add =
$this->acl2->check('.project',2);
- $this->acl_edit =
$this->acl2->check('.project',4);
- $this->acl_delete =
$this->acl2->check('.project',8);
- $this->acl_manage =
$this->acl2->check('.project',16);
-
- $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->status_id =
$this->bo->status_id;
-
- $this->menu->sub ='project';
- $this->fakebase =
$this->bo->fakebase;
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' => $this->filter,
- 'cat_id' => $this->cat_id,
- 'status_id' => $this->status_id
- );
- $this->bo->save_sessiondata($data);
- }
-
- function view_file()
- {
- $GLOBALS['phpgw_info']['flags'][noheader] = True;
- $GLOBALS['phpgw_info']['flags'][nofooter] = True;
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
-
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $file_name =
urldecode(get_var('file_name',array('POST','GET')));
- $location_code =
get_var('location_code',array('POST','GET'));
- $id = get_var('id',array('POST','GET'));
-
- $file = $this->fakebase. SEP . 'request' . SEP .
$location_code . SEP . $id . SEP . $file_name;
-
- if($this->bo->vfs->file_exists(array(
- 'string' => $file,
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
- $size =
$this->bo->vfs->get_size(array(
- 'string' => $file,
- 'relatives' =>
Array(RELATIVE_NONE),
- 'checksubdirs' =>
True));
-
- $document= $this->bo->vfs->read(array(
- 'string' => $file,
- 'relatives' => Array(RELATIVE_NONE)));
-
- $filename =
basename($values['document_name']);
- $filetype = array_pop(explode('.',
basename($file)));
- $browser = CreateObject('phpgwapi.browser');
-
$browser->content_header($filename,$filetype,$size);
-
- echo $document;
-
- }
- }
-
-
- function index()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('request','table_header',
-
'menu',
-
'nextmatchs',
-
'search_field'));
-
- $project_id =
get_var('project_id',array('POST','GET')); // lookup for maintenance planning
-
- if($project_id)
- {
- $lookup = True;
- }
- $links = $this->menu->links('request');
-
- $request_list = $this->bo->read($project_id);
-
-//_debug_array($request_list);
-
- $uicols = $this->bo->uicols;
-//_debug_array($uicols);
-
- $j=0;
- while (is_array($request_list) && list(,$request_entry)
= each($request_list))
- {
- for ($k=0;$k<count($uicols['name']);$k++)
- {
- if($uicols['input_type'][$k]!='hidden')
- {
-
-
if($request_entry['query_location'][$uicols['name'][$k]])
- {
-
$content[$j]['row'][$k]['statustext'] = lang('search');
-
$content[$j]['row'][$k]['text'] =
$request_entry[$uicols['name'][$k]];
-
$content[$j]['row'][$k]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.index&query='
. $request_entry['query_location'][$uicols['name'][$k]] . '&project_id=' .
$project_id);
- }
- else
- {
-
$content[$j]['row'][$k]['value'] =
$request_entry[$uicols['name'][$k]];
-
$content[$j]['row'][$k]['name'] = $uicols['name'][$k];
- }
-
- }
-
- }
-
- if(!$lookup)
- {
- if($this->acl_read)
- {
-
$content[$j]['row'][$k]['statustext'] = lang('view the
request');
- $content[$j]['row'][$k]['text']
= lang('view');
- $content[$j]['row'][$k]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.view&id='
. $request_entry['request_id']);
- $k++;
- }
-
- if($this->acl_edit)
- {
-
$content[$j]['row'][$k]['statustext'] = lang('edit the
request');
- $content[$j]['row'][$k]['text']
= lang('edit');
- $content[$j]['row'][$k]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.edit&id='
. $request_entry['request_id']);
- $k++;
- }
-
- if($this->acl_delete)
- {
-
$content[$j]['row'][$k]['statustext'] = lang('delete the
request');
- $content[$j]['row'][$k]['text']
= lang('delete');
- $content[$j]['row'][$k]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.delete&id='
. $request_entry['request_id']);
- $k++;
- }
-
- }
- else
- {
- if($this->acl_read)
- {
-
$content[$j]['row'][$k]['statustext'] = lang('view the
request');
- $content[$j]['row'][$k]['text']
= lang('view');
-
$content[$j]['row'][$k]['target'] = '_blank';
- $content[$j]['row'][$k]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.view&id='
. $request_entry['request_id']);
-
$content[$j]['row'][$k]['request_id'] =
$request_entry['request_id'];
- $k++;
- }
-
- }
-
- $j++;
- }
-
- for ($i=0;$i<count($uicols['descr']);$i++)
- {
- if($uicols['input_type'][$i]!='hidden')
- {
- $table_header[$i]['header'] =
$uicols['descr'][$i];
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- if($uicols['name'][$i]=='loc1')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'location_code',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uirequest.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'project_id'
=>$project_id,
-
'district_id' =>
$this->district_id,
-
'cat_id'
=>$this->cat_id)
-
));
- }
- if($uicols['name'][$i]=='request_id')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'request_id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uirequest.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'project_id'
=>$project_id,
-
'district_id' =>
$this->district_id,
-
'cat_id'
=>$this->cat_id)
-
));
- }
- if($uicols['name'][$i]=='score')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'score',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uirequest.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'project_id'
=>$project_id,
-
'district_id' =>
$this->district_id,
-
'cat_id'
=>$this->cat_id)
-
));
- }
- if($uicols['name'][$i]=='address')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'address',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uirequest.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'project_id'
=>$project_id,
-
'district_id' =>
$this->district_id,
-
'cat_id'
=>$this->cat_id)
-
));
- }
- }
- }
-
- if($this->acl_read)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('view');
- $i++;
- }
-
- if(!$lookup)
- {
- if($this->acl_edit)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('edit');
- $i++;
- }
- if($this->acl_delete)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('delete');
- $i++;
- }
- }
- else
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header'] =
lang('select');
- }
-
-//_debug_array($content);
- if($this->acl_add)
- {
- $table_add[] = array
- (
- 'lang_add'
=> lang('add'),
- 'lang_add_statustext' => lang('add a
request'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.edit')
- );
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uirequest.index',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'district_id'
=>$this->district_id,
- 'filter'
=>$this->filter,
- 'status_id'
=>$this->status_id,
- 'project_id' =>$project_id,
- 'query'
=>$this->query
- );
-
-
- if($this->acl_manage)
- {
- $link_priority_key
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.priority_key');
- }
-
- $data = array
- (
- 'lang_priority_key'
=> lang('Priority key'),
- 'lang_priority_help'
=> lang('To alter the priority key'),
- 'link_priority_key'
=> $link_priority_key,
- 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
- 'lang_select'
=> lang('select'),
-
- 'lang_update_project'
=> lang('Update project'),
- 'lang_add_to_project_statustext' =>
lang('add selected request to project'),
- 'add_to_project_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit&id='
. $project_id),
- 'project_id'
=> $project_id,
-
- 'lookup'
=> $lookup,
- 'links'
=> $links,
- 'allow_allrows'
=> false,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($request_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the request belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $this->bo->select_category_request_list('filter',$this->cat_id),
- 'district_list'
=> $this->bocommon->select_district_list('filter',$this->district_id),
- 'lang_no_district'
=> lang('no district'),
- 'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
- 'select_district_name' =>
'district_id',
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
-
- 'lang_status_statustext' =>
lang('Select the status the agreement belongs to. To do not use a category
select NO STATUS'),
- 'status_name'
=> 'status_id',
- 'lang_no_status'
=> lang('No status'),
- 'status_list'
=> $this->boproject->select_status_list('filter',$this->status_id),
-
- 'lang_user_statustext' =>
lang('Select the user the request belongs to. To do not use a category select
NO USER'),
- 'select_user_name'
=> 'filter',
- 'lang_no_user'
=> lang('No user'),
- 'user_list'
=>
$this->bocommon->get_user_list('filter',$this->filter,$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
-
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('request');
- $function_msg =
lang('list request');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
-
- function priority_key()
- {
- if(!$this->acl_manage)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=16&acl_location='
. $this->acl2_location);
- }
- $GLOBALS['phpgw']->xslttpl->add_file(array('request'));
- $GLOBALS['phpgw_info']['flags'][noheader] = True;
- $GLOBALS['phpgw_info']['flags'][nofooter] = True;
- $GLOBALS['phpgw_info']['flags']['noframework'] = True;
- $values = get_var('values',array('POST','GET'));
-
- if($values['update'])
- {
- $receipt =
$this->bo->update_priority_key($values);
- }
-
- $function_msg = lang('Edit priority key');
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uirequest.priority_key');
-
- $priority_key = $this->bo->read_priority_key();
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'function_msg'
=> $function_msg,
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_priority_key_statustext'
=> lang('Weight for prioritising'),
- 'lang_save'
=> lang('save'),
- 'priority_key' =>
$priority_key,
- );
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('priority_form' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- function edit()
- {
- if(!$this->acl_add && !$this->acl_edit)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
- }
- $id =
get_var('id',array('POST','GET'));
- $values =
get_var('values',array('POST'));
-
- $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
- $insert_record_entity =
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp);
-
- for ($j=0;$j<count($insert_record_entity);$j++)
- {
-
$insert_record['extra'][$insert_record_entity[$j]] =
$insert_record_entity[$j];
- }
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('request'));
-
- $bypass =
get_var('bypass',array('POST','GET'));
-
- if($_POST && !$bypass)
- {
- for ($i=0;
$i<count($insert_record['location']); $i++)
- {
-
if($_POST[$insert_record['location'][$i]])
- {
-
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
- }
- }
-
- while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
- {
- if($_POST[$key])
- {
- $values['extra'][$column]
= $_POST[$key];
- }
- }
-
- $values['street_name'] =
$_POST['street_name'];
- $values['street_number'] =
$_POST['street_number'];
- $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
- }
- else
- {
- $location_code =
get_var('location_code',array('POST','GET'));
- $tenant_id
= get_var('tenant_id',array('POST','GET'));
-
- $p_entity_id =
get_var('p_entity_id',array('POST','GET'));
- $p_cat_id =
get_var('p_cat_id',array('POST','GET'));
- $values['p'][$p_entity_id]['p_entity_id']
= $p_entity_id;
- $values['p'][$p_entity_id]['p_cat_id']
= $p_cat_id;
- $values['p'][$p_entity_id]['p_num']
= get_var('p_num',array('POST','GET'));
-
- $origin =
get_var('origin',array('POST','GET'));
- $origin_id =
get_var('origin_id',array('POST','GET'));
-
- if($p_entity_id && $p_cat_id)
- {
- $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
- $entity_category =
$boadmin_entity->read_single_category($p_entity_id,$p_cat_id);
-
$values['p'][$p_entity_id]['p_cat_name'] = $entity_category['name'];
- }
-
-
- if($location_code)
- {
- $values['location_data'] =
$this->bolocation->read_single($location_code,array('tenant_id'=>$tenant_id,'p_num'=>$p_num));
- }
-
- }
-
- if($values['origin'])
- {
- $origin = $values['origin'];
- $origin_id = $values['origin_id'];
- }
-
- if($origin)
- {
- unset($values['origin']);
- unset($values['origin_id']);
- $values['origin'][0]['type']= $origin;
-
$values['origin'][0]['link']=$this->bocommon->get_origin_link($origin);
- $values['origin'][0]['data'][]= array(
- 'id'=> $origin_id,
- 'type'=> $origin
- );
- }
-
- $values['start_date'] =
get_var('start_date',array('POST'));
- $values['end_date'] =
get_var('end_date',array('POST'));
-
-//_debug_array($values);
- $this->config->read_repository();
-
- if ($values['save'])
- {
- if(!$values['location'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a location !'));
- $error_id=true;
- }
-
- if(!$values['title'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter a request TITLE !'));
- $error_id=true;
- }
-
- if(!$values['cat_id'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
- $error_id=true;
- }
-
- if(!$values['status'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a status !'));
- }
-
- if($id)
- {
- $values['request_id']=$id;
- $action='edit';
- }
- else
- {
-
$values['request_id']=$this->bo->next_id();
- }
-
- $values['file_name']=str_replace("
","_",$_FILES['file']['name']);
- $to_file = $this->fakebase. SEP . 'request' .
SEP . implode("-",$values['location']) . SEP . $values['request_id'] . SEP .
$values['file_name'];
-
- if(!$values['document_name_orig'] &&
$this->bo->vfs->file_exists(array(
- 'string' => $to_file,
- 'relatives' =>
Array(RELATIVE_NONE)
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('This file already exists !'));
- }
-
- if(!$receipt['error'])
- {
- $receipt =
$this->bo->create_home_dir($receipt);
-
- if($values['copy_request'])
- {
- $action='add';
- $values['request_id'] =
$this->bo->next_id();
- $id = $values['request_id'];
- }
- $receipt =
$this->bo->save($values,$action);
-//_debug_array($values);
-
- if($values['file_name'])
- {
-
$this->bo->create_document_dir(implode("-",$values['location']),
$values['request_id']);
- $this->bo->vfs->override_acl =
1;
-
- if(!$this->bo->vfs->cp (array (
- 'from' =>
$_FILES['file']['tmp_name'],
- 'to' => $to_file,
- 'relatives' =>
array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
- {
-
$receipt['error'][]=array('msg'=>lang('Failed to upload file !'));
- }
- $this->bo->vfs->override_acl =
0;
- }
-
- $id = $values['request_id'];
- $function_msg = lang('Edit request');
-
- if ($values['notify'])
- {
-
$coordinator_name=$GLOBALS['phpgw_info']['user']['fullname'];
-
$coordinator_email=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['email'];
- $headers = "Return-Path: <".
$coordinator_email .">\r\n";
- $headers .= "From: " .
$coordinator_name . "<" . $coordinator_email .">\r\n";
- $headers .= "Bcc: " .
$coordinator_name . "<" . $coordinator_email .">\r\n";
- $headers .= "Content-type:
text/plain; charset=iso-8859-1\r\n";
-
- $subject = lang(notify).": ".
$values['request_id'];
- $message = lang(request) . " "
. $values['request_id'] ." ". lang('is registered');
-
- $mail_method=
$this->config->config_data['fmwrkorder_mail'];
- if ($mail_method=='smtp'):
- {
- $bcc =
$coordinator_email;
- $send =
CreateObject('phpgwapi.send');
- $rcpt =
$send->msg('email', $values['mail_address'], $subject, stripslashes($message),
'', $cc, $bcc, $coordinator_email, $coordinator_name, 'plain');
- }
- elseif
($mail_method=='sendmail'):
- {
-
$rcpt=mail($values['mail_address'],$subject,$message, $headers);
- }
- else:
- {
-
$receipt['error'][]=array('msg'=>lang('Mailing method is not chosen! (admin
section)'));
- }
- endif;
- }
-
- if($rcpt)
- {
-
$receipt['message'][]=array('msg'=>lang('%1 is
notified',$values['mail_address']));
- }
- }
- else
- {
- if($values['location'])
- {
- $location_code=implode("-",
$values['location']);
- $values['location_data'] =
$this->bolocation->read_single($location_code,$values['extra']);
- }
-
- if($values['extra']['p_num'])
- {
-
$values['p'][$values['extra']['p_entity_id']]['p_num']=$values['extra']['p_num'];
-
$values['p'][$values['extra']['p_entity_id']]['p_entity_id']=$values['extra']['p_entity_id'];
-
$values['p'][$values['extra']['p_entity_id']]['p_cat_id']=$values['extra']['p_cat_id'];
-
$values['p'][$values['extra']['p_entity_id']]['p_cat_name']=$_POST['entity_cat_name_'.$values['extra']['p_entity_id']];
- }
- }
- }
-
- if(!$receipt['error'] && !$bypass && $id)
- {
- $values = $this->bo->read_single($id);
- $record_history =
$this->bo->read_record_history($id);
- }
-
- $table_header_history[] = array
- (
- 'lang_date' => lang('Date'),
- 'lang_user' => lang('User'),
- 'lang_action' => lang('Action'),
- 'lang_new_value' => lang('New value')
- );
-
- if ($id)
- {
- $function_msg = lang('Edit request');
- }
- else
- {
- $function_msg = lang('Add request');
- }
-
- if ($values['cat_id'])
- {
- $this->cat_id = $values['cat_id'];
- }
- $lookup_type='form';
-
-
$location_data=$this->bolocation->initiate_ui_location(array(
- 'values' =>
$values['location_data'],
- 'type_id' => -1,
// calculated from location_types
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' => True,
- 'lookup_type' => $lookup_type,
- 'lookup_entity' =>
$this->bocommon->get_lookup_entity('request'),
- 'entity_data' => $values['p']
- ));
-
-
- if($values['contact_phone'])
- {
- for
($i=0;$i<count($location_data['location']);$i++)
- {
-
if($location_data['location'][$i]['input_name'] == 'contact_phone')
- {
-
$location_data['location'][$i]['value'] = $values['contact_phone'];
- }
- }
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uirequest.edit',
- 'id' => $id
- );
-
- if(!$values['coordinator'])
- {
- $values['coordinator']=$this->account;
- }
-
-
$supervisor_id=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['approval_from'];
-
- $notify =
$this->config->config_data['workorder_approval'];
-
- if ($supervisor_id && ($notify=='yes'))
- {
- $prefs =
$this->bocommon->create_preferences($this->currentapp,$supervisor_id);
- $supervisor_email = $prefs['email'];
- }
-
-
-
- $table_header_importance[] = array
- (
- 'lang_subject' =>
lang('Subject'),
- 'lang_condition_degree' => lang('Condidtion
degree'),
- 'lang_prob_worsening' => lang('Probability'),
- 'lang_consequence' =>
lang('Consequence')
- );
-
-
- if($values['project_id'])
- {
- $project_lookup_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiproject.view'
- );
- }
-
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $link_file_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uirequest.view_file',
- 'location_code'
=>$values['location_data']['location_code'],
- 'id' =>$id
- );
-
- $link_to_files =
$this->config->config_data['files_url'];
-
- $j = count($values['files']);
- for ($i=0;$i<$j;$i++)
- {
-
$values['files'][$i]['file_name']=urlencode($values['files'][$i]['name']);
- }
-
- if (isset($values['origin']) AND
is_array($values['origin']))
- {
- for ($i=0;$i<count($values['origin']);$i++)
- {
-
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
. $values['origin'][$i]['link']);
-
if(substr($values['origin'][$i]['type'],0,6)=='entity')
- {
- $type =
explode("_",$values['origin'][$i]['type']);
- $entity_id = $type[1];
- $cat_id = $type[2];
-
- if(!is_object($boadmin_entity))
- {
- $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
- }
- $entity_category =
$boadmin_entity->read_single_category($entity_id,$cat_id);
- $values['origin'][$i]['descr']
= $entity_category['name'];
- }
- else
- {
- $values['origin'][$i]['descr']=
lang($values['origin'][$i]['type']);
- }
- }
- }
-
- $data = array
- (
- 'fileupload'
=> True,
- 'link_view_file'
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
- 'link_to_files'
=> $link_to_files,
- 'files'
=> $values['files'],
- 'lang_files'
=> lang('files'),
- 'lang_filename'
=> lang('Filename'),
- 'lang_delete_file'
=> lang('Delete file'),
- 'lang_view_file_statustext' =>
lang('Klick to view file'),
- 'lang_delete_file_statustext' => lang('Check
to delete file'),
- 'lang_upload_file'
=> lang('Upload file'),
- 'lang_file_statustext' =>
lang('Select file to upload'),
-
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
-
- 'value_origin'
=> $values['origin'],
- 'value_origin_type'
=> $origin,
- 'value_origin_id'
=> $origin_id,
- 'lang_origin_statustext' =>
lang('Link to the origin for this request'),
-
- 'generate_project_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit'),
- 'lang_generate_project'
=> lang('Generate project'),
- 'lang_generate_project_statustext' =>
lang('Generate a project from this request'),
- 'location_code'
=> $values['location_code'],
- 'p_num'
=> $values['p_num'],
- 'p_entity_id'
=> $values['p_entity_id'],
- 'p_cat_id'
=> $values['p_cat_id'],
- 'tenant_id'
=> $values['tenant_id'],
-
- 'lang_importance'
=> lang('Importance'),
- 'table_header_importance' =>
$table_header_importance,
- 'importance_weight'
=> $importance_weight,
-
- 'lang_no_workorders' =>
lang('No workorder bugdet'),
- 'workorder_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit'),
- 'record_history'
=> $record_history,
- 'table_header_history' =>
$table_header_history,
- 'lang_history'
=> lang('History'),
- 'lang_no_history'
=> lang('No history'),
-
- 'jsDateFormat'
=> $jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle'
=> lang('Select date'),
- 'calendar_setup_start' =>
"Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});",
- 'calendar_setup_end' =>
"Calendar.setup({inputField : 'end_date',ifFormat : '" . $jsDateFormat .
"',button : 'end_date-trigger'});",
-
- 'lang_start_date_statustext' => lang('Select
the estimated end date for the request'),
- 'lang_start_date'
=> lang('request start date'),
- 'value_start_date'
=> $values['start_date'],
-
- 'lang_end_date_statustext' =>
lang('Select the estimated end date for the request'),
- 'lang_end_date'
=> lang('request end date'),
- 'value_end_date'
=> $values['end_date'],
-
- 'lang_copy_request'
=> lang('Copy request ?'),
- 'lang_copy_request_statustext' => lang('Choose
Copy request to copy this request to a new request'),
-
- 'lang_power_meter'
=> lang('Power meter'),
- 'lang_power_meter_statustext' => lang('Enter
the power_meter'),
- 'value_power_meter'
=> $values['power_meter'],
-
- 'lang_budget'
=> lang('Budget'),
- 'value_budget'
=> $values['budget'],
- 'lang_budget_statustext' =>
lang('Enter the budget'),
-
- 'location_data'
=> $location_data,
- 'location_type'
=> 'form',
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.index'),
- 'lang_category'
=> lang('category'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
-
- 'lang_request_id'
=> lang('request ID'),
- 'value_request_id'
=> $values['request_id'],
-
- 'lang_title'
=> lang('Title'),
- 'value_title'
=> $values['title'],
- 'lang_title_statustext' =>
lang('Enter request Title'),
-
- 'lang_descr_statustext' =>
lang('Enter a description of the request'),
- 'lang_descr'
=> lang('Description'),
- 'value_descr'
=> $values['descr'],
- 'lang_score'
=> lang('Score'),
- 'value_score'
=> $values['score'],
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'lang_save_statustext' =>
lang('Save the request'),
- 'lang_no_cat'
=> lang('Select category'),
- 'lang_cat_statustext' =>
lang('Select the category the request belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'values[cat_id]',
- 'value_cat_id'
=> $values['cat_id'],
- 'cat_list'
=> $this->bo->select_category_request_list('select',$values['cat_id']),
-
- 'lang_coordinator'
=> lang('Coordinator'),
- 'lang_user_statustext' =>
lang('Select the coordinator the request belongs to. To do not use a category
select NO USER'),
- 'select_user_name'
=> 'values[coordinator]',
- 'lang_no_user'
=> lang('Select coordinator'),
- 'user_list'
=>
$this->bocommon->get_user_list_right2('select',4,$values['coordinator'],$this->acl2_location),
-
- 'status_list'
=> $this->boproject->select_status_list('select',$values['status']),
- 'status_name'
=> 'values[status]',
- 'lang_no_status'
=> lang('Select status'),
- 'lang_status'
=> lang('Status'),
- 'lang_status_statustext' =>
lang('What is the current status of this request ?'),
-
- 'branch_list'
=> $this->boproject->select_branch_list($values['branch_id']),
- 'lang_branch'
=> lang('branch'),
- 'lang_no_branch'
=> lang('Select branch'),
- 'lang_branch_statustext' =>
lang('Select the branches for this request'),
-
- 'notify'
=> $notify,
- 'lang_notify'
=> lang('Notify'),
- 'lang_notify_statustext' =>
lang('Check this to notify your supervisor by email'),
- 'value_notify_mail_address' =>
$supervisor_email,
-
- 'currency' =>
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
-
- 'lang_authorities_demands'
=> lang('Authorities Demands'),
- 'lang_authorities_demands_statustext'
=> lang('Is there a demand from the authorities to correct this condition?'),
- 'authorities_demands'
=> $values['authorities_demands'],
-
- 'condition_list'
=> $this->bo->select_conditions($id),
-
- );
-
- $appname
= lang('request');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function delete()
- {
- if(!$this->acl_delete)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
- }
-
- $id = get_var('id',array('POST','GET'));
- $confirm = get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uirequest.index'
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($id);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.delete&id='
. $id),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('request');
- $function_msg =
lang('delete request');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function view()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $id =
get_var('id',array('POST','GET'));
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('request'));
-
- $values = $this->bo->read_single($id);
-
- $record_history = $this->bo->read_record_history($id);
-
- $table_header_history[] = array
- (
- 'lang_date' => lang('Date'),
- 'lang_user' => lang('User'),
- 'lang_action' => lang('Action'),
- 'lang_new_value' => lang('New value')
- );
-
- $function_msg = lang('View request');
-
- if ($values['cat_id'])
- {
- $this->cat_id = $values['cat_id'];
- }
-
-
$location_data=$this->bolocation->initiate_ui_location(array(
- 'values' =>
$values['location_data'],
- 'type_id' =>
count(explode('-',$values['location_data']['location_code'])),
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' =>
$values['location_data']['tenant_id'],
- 'lookup_type' => 'view',
- 'lookup_entity' =>
$this->bocommon->get_lookup_entity('project'),
- 'entity_data' => $values['p']
- ));
-
- if($values['contact_phone'])
- {
- for
($i=0;$i<count($location_data['location']);$i++)
- {
-
if($location_data['location'][$i]['input_name'] == 'contact_phone')
- {
-
unset($location_data['location'][$i]['value']);
- }
- }
- }
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uirequest.edit',
- 'id' => $id
- );
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
-
- $table_header_importance[] = array
- (
- 'lang_subject' =>
lang('Subject'),
- 'lang_condition_degree' => lang('Condidtion
degree'),
- 'lang_prob_worsening' => lang('Probability'),
- 'lang_consequence' =>
lang('Consequence')
- );
-
-
-
- if($values['origin']== 'tts')
- {
- $origin_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uitts.view',
- 'id' =>
$values['origin_id']
- );
- }
-
- if($values['project_id'])
- {
- $project_lookup_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiproject.view'
- );
- }
-
- $link_file_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uirequest.view_file',
- 'location_code'
=>$values['location_data']['location_code'],
- 'id' =>$id
- );
-
- $this->config->read_repository();
- $link_to_files =
$this->config->config_data['files_url'];
-
- $j = count($values['files']);
- for ($i=0;$i<$j;$i++)
- {
-
$values['files'][$i]['file_name']=urlencode($values['files'][$i]['name']);
- }
-
- if (isset($values['origin']) AND
is_array($values['origin']))
- {
- for ($i=0;$i<count($values['origin']);$i++)
- {
-
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
. $values['origin'][$i]['link']);
-
if(substr($values['origin'][$i]['type'],0,6)=='entity')
- {
- $type =
explode("_",$values['origin'][$i]['type']);
- $entity_id = $type[1];
- $cat_id = $type[2];
-
- if(!is_object($boadmin_entity))
- {
- $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
- }
- $entity_category =
$boadmin_entity->read_single_category($entity_id,$cat_id);
- $values['origin'][$i]['descr']
= $entity_category['name'];
- }
- else
- {
- $values['origin'][$i]['descr']=
lang($values['origin'][$i]['type']);
- }
- }
- }
-
- $data = array
- (
- 'link_view_file'
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
- 'link_to_files'
=> $link_to_files,
- 'files'
=> $values['files'],
- 'lang_files'
=> lang('files'),
- 'lang_filename'
=> lang('Filename'),
- 'lang_view_file_statustext' =>
lang('Klick to view file'),
-
- 'value_origin'
=> $values['origin'],
- 'value_origin_type'
=> $origin,
- 'value_origin_id'
=> $origin_id,
-
- 'lang_project'
=> lang('Project'),
- 'lang_project_statustext' =>
lang('Link to the project originatet from this request'),
- 'link_project'
=> $GLOBALS['phpgw']->link('/index.php',$project_lookup_data),
- 'value_project_id'
=> $values['project_id'],
-
- 'lang_importance'
=> lang('Importance'),
- 'table_header_importance' =>
$table_header_importance,
- 'importance_weight_view' =>
$importance_weight,
-
- 'workorder_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit'),
- 'record_history'
=> $record_history,
- 'table_header_history' =>
$table_header_history,
- 'lang_history'
=> lang('History'),
- 'lang_no_history'
=> lang('No history'),
-
- 'lang_start_date'
=> lang('request start date'),
- 'value_start_date'
=> $values['start_date'],
-
- 'lang_end_date'
=> lang('request end date'),
- 'value_end_date'
=> $values['end_date'],
-
- 'lang_power_meter'
=> lang('Power meter'),
- 'value_power_meter'
=> $values['power_meter'],
-
- 'lang_budget'
=> lang('Budget'),
- 'value_budget'
=> $values['budget'],
-
- 'location_data'
=> $location_data,
- 'location_type'
=> 'view',
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.index'),
- 'lang_category'
=> lang('category'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
-
- 'lang_request_id'
=> lang('request ID'),
- 'value_request_id'
=> $values['request_id'],
-
- 'lang_title'
=> lang('Title'),
- 'value_title'
=> $values['title'],
-
- 'lang_descr'
=> lang('Description'),
- 'value_descr'
=> $values['descr'],
- 'lang_score'
=> lang('Score'),
- 'value_score'
=> $values['score'],
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'value_cat_id'
=> $values['cat_id'],
- 'cat_list'
=> $this->bo->select_category_request_list('select',$values['cat_id']),
-
- 'lang_coordinator'
=> lang('Coordinator'),
- 'lang_no_user'
=> lang('Select coordinator'),
- 'user_list'
=>
$this->bocommon->get_user_list('select',$values['coordinator'],$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
-
- 'status_list'
=> $this->boproject->select_status_list('select',$values['status']),
- 'lang_status'
=> lang('Status'),
-
- 'branch_list'
=> $this->boproject->select_branch_list($values['branch_id']),
- 'lang_branch'
=> lang('branch'),
-
- 'edit_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.edit&id='
. $id),
- 'lang_edit_statustext'
=> lang('Edit this entry request'),
- 'lang_edit'
=> lang('Edit'),
- 'currency'
=>
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
- 'lang_contact_phone' =>
lang('Contact phone'),
- 'contact_phone'
=> $values['contact_phone'],
-
- 'lang_authorities_demands'
=> lang('Authorities Demands'),
- 'authorities_demands'
=> $values['authorities_demands'],
-
- 'condition_list_view'
=> $this->bo->select_conditions($id),
- );
-
- $appname
= lang('request');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage project
+ * @version $Id: class.uirequest.inc.php,v 1.18 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uirequest
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+ var $part_of_town_id;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'view' => True,
+ 'edit' => True,
+ 'delete' => True,
+ 'priority_key' => True,
+ 'view_file' => True
+ );
+
+ function uirequest()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bo =
CreateObject($this->currentapp.'.borequest',True);
+ $this->boproject =
CreateObject($this->currentapp.'.boproject');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+ $this->bolocation =
CreateObject($this->currentapp.'.bolocation');
+ $this->config =
CreateObject('phpgwapi.config');
+
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+ $this->acl2_location = '.project';
+ $this->acl_read =
$this->acl2->check('.project',1);
+ $this->acl_add =
$this->acl2->check('.project',2);
+ $this->acl_edit =
$this->acl2->check('.project',4);
+ $this->acl_delete =
$this->acl2->check('.project',8);
+ $this->acl_manage =
$this->acl2->check('.project',16);
+
+ $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->status_id =
$this->bo->status_id;
+
+ $this->menu->sub ='project';
+ $this->fakebase =
$this->bo->fakebase;
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' => $this->filter,
+ 'cat_id' => $this->cat_id,
+ 'status_id' => $this->status_id
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function view_file()
+ {
+ $GLOBALS['phpgw_info']['flags'][noheader] = True;
+ $GLOBALS['phpgw_info']['flags'][nofooter] = True;
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
+
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $file_name =
urldecode(get_var('file_name',array('POST','GET')));
+ $location_code =
get_var('location_code',array('POST','GET'));
+ $id = get_var('id',array('POST','GET'));
+
+ $file = $this->fakebase. SEP . 'request' . SEP .
$location_code . SEP . $id . SEP . $file_name;
+
+ if($this->bo->vfs->file_exists(array(
+ 'string' => $file,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $size =
$this->bo->vfs->get_size(array(
+ 'string' => $file,
+ 'relatives' =>
Array(RELATIVE_NONE),
+ 'checksubdirs' =>
True));
+
+ $document= $this->bo->vfs->read(array(
+ 'string' => $file,
+ 'relatives' => Array(RELATIVE_NONE)));
+
+ $filename =
basename($values['document_name']);
+ $filetype = array_pop(explode('.',
basename($file)));
+ $browser = CreateObject('phpgwapi.browser');
+
$browser->content_header($filename,$filetype,$size);
+
+ echo $document;
+
+ }
+ }
+
+
+ function index()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('request','table_header',
+
'menu',
+
'nextmatchs',
+
'search_field'));
+
+ $project_id =
get_var('project_id',array('POST','GET')); // lookup for maintenance planning
+
+ if($project_id)
+ {
+ $lookup = True;
+ }
+ $links = $this->menu->links('request');
+
+ $request_list = $this->bo->read($project_id);
+
+//_debug_array($request_list);
+
+ $uicols = $this->bo->uicols;
+//_debug_array($uicols);
+
+ $j=0;
+ while (is_array($request_list) && list(,$request_entry)
= each($request_list))
+ {
+ for ($k=0;$k<count($uicols['name']);$k++)
+ {
+ if($uicols['input_type'][$k]!='hidden')
+ {
+
+
if($request_entry['query_location'][$uicols['name'][$k]])
+ {
+
$content[$j]['row'][$k]['statustext'] = lang('search');
+
$content[$j]['row'][$k]['text'] =
$request_entry[$uicols['name'][$k]];
+
$content[$j]['row'][$k]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.index&query='
. $request_entry['query_location'][$uicols['name'][$k]] . '&project_id=' .
$project_id);
+ }
+ else
+ {
+
$content[$j]['row'][$k]['value'] =
$request_entry[$uicols['name'][$k]];
+
$content[$j]['row'][$k]['name'] = $uicols['name'][$k];
+ }
+
+ }
+
+ }
+
+ if(!$lookup)
+ {
+ if($this->acl_read)
+ {
+
$content[$j]['row'][$k]['statustext'] = lang('view the
request');
+ $content[$j]['row'][$k]['text']
= lang('view');
+ $content[$j]['row'][$k]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.view&id='
. $request_entry['request_id']);
+ $k++;
+ }
+
+ if($this->acl_edit)
+ {
+
$content[$j]['row'][$k]['statustext'] = lang('edit the
request');
+ $content[$j]['row'][$k]['text']
= lang('edit');
+ $content[$j]['row'][$k]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.edit&id='
. $request_entry['request_id']);
+ $k++;
+ }
+
+ if($this->acl_delete)
+ {
+
$content[$j]['row'][$k]['statustext'] = lang('delete the
request');
+ $content[$j]['row'][$k]['text']
= lang('delete');
+ $content[$j]['row'][$k]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.delete&id='
. $request_entry['request_id']);
+ $k++;
+ }
+
+ }
+ else
+ {
+ if($this->acl_read)
+ {
+
$content[$j]['row'][$k]['statustext'] = lang('view the
request');
+ $content[$j]['row'][$k]['text']
= lang('view');
+
$content[$j]['row'][$k]['target'] = '_blank';
+ $content[$j]['row'][$k]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.view&id='
. $request_entry['request_id']);
+
$content[$j]['row'][$k]['request_id'] =
$request_entry['request_id'];
+ $k++;
+ }
+
+ }
+
+ $j++;
+ }
+
+ for ($i=0;$i<count($uicols['descr']);$i++)
+ {
+ if($uicols['input_type'][$i]!='hidden')
+ {
+ $table_header[$i]['header'] =
$uicols['descr'][$i];
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ if($uicols['name'][$i]=='loc1')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'location_code',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uirequest.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'project_id'
=>$project_id,
+
'district_id' =>
$this->district_id,
+
'cat_id'
=>$this->cat_id)
+
));
+ }
+ if($uicols['name'][$i]=='request_id')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'request_id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uirequest.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'project_id'
=>$project_id,
+
'district_id' =>
$this->district_id,
+
'cat_id'
=>$this->cat_id)
+
));
+ }
+ if($uicols['name'][$i]=='score')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'score',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uirequest.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'project_id'
=>$project_id,
+
'district_id' =>
$this->district_id,
+
'cat_id'
=>$this->cat_id)
+
));
+ }
+ if($uicols['name'][$i]=='address')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'address',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uirequest.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'project_id'
=>$project_id,
+
'district_id' =>
$this->district_id,
+
'cat_id'
=>$this->cat_id)
+
));
+ }
+ }
+ }
+
+ if($this->acl_read)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('view');
+ $i++;
+ }
+
+ if(!$lookup)
+ {
+ if($this->acl_edit)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('edit');
+ $i++;
+ }
+ if($this->acl_delete)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('delete');
+ $i++;
+ }
+ }
+ else
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header'] =
lang('select');
+ }
+
+//_debug_array($content);
+ if($this->acl_add)
+ {
+ $table_add[] = array
+ (
+ 'lang_add'
=> lang('add'),
+ 'lang_add_statustext' => lang('add a
request'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.edit')
+ );
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uirequest.index',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'district_id'
=>$this->district_id,
+ 'filter'
=>$this->filter,
+ 'status_id'
=>$this->status_id,
+ 'project_id' =>$project_id,
+ 'query'
=>$this->query
+ );
+
+
+ if($this->acl_manage)
+ {
+ $link_priority_key
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.priority_key');
+ }
+
+ $data = array
+ (
+ 'lang_priority_key'
=> lang('Priority key'),
+ 'lang_priority_help'
=> lang('To alter the priority key'),
+ 'link_priority_key'
=> $link_priority_key,
+ 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
+ 'lang_select'
=> lang('select'),
+
+ 'lang_update_project'
=> lang('Update project'),
+ 'lang_add_to_project_statustext' =>
lang('add selected request to project'),
+ 'add_to_project_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit&id='
. $project_id),
+ 'project_id'
=> $project_id,
+
+ 'lookup'
=> $lookup,
+ 'links'
=> $links,
+ 'allow_allrows'
=> false,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($request_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the request belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $this->bo->select_category_request_list('filter',$this->cat_id),
+ 'district_list'
=> $this->bocommon->select_district_list('filter',$this->district_id),
+ 'lang_no_district'
=> lang('no district'),
+ 'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
+ 'select_district_name' =>
'district_id',
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+
+ 'lang_status_statustext' =>
lang('Select the status the agreement belongs to. To do not use a category
select NO STATUS'),
+ 'status_name'
=> 'status_id',
+ 'lang_no_status'
=> lang('No status'),
+ 'status_list'
=> $this->boproject->select_status_list('filter',$this->status_id),
+
+ 'lang_user_statustext' =>
lang('Select the user the request belongs to. To do not use a category select
NO USER'),
+ 'select_user_name'
=> 'filter',
+ 'lang_no_user'
=> lang('No user'),
+ 'user_list'
=>
$this->bocommon->get_user_list('filter',$this->filter,$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
+
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('request');
+ $function_msg =
lang('list request');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+
+ function priority_key()
+ {
+ if(!$this->acl_manage)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=16&acl_location='
. $this->acl2_location);
+ }
+ $GLOBALS['phpgw']->xslttpl->add_file(array('request'));
+ $GLOBALS['phpgw_info']['flags'][noheader] = True;
+ $GLOBALS['phpgw_info']['flags'][nofooter] = True;
+ $GLOBALS['phpgw_info']['flags']['noframework'] = True;
+ $values = get_var('values',array('POST','GET'));
+
+ if($values['update'])
+ {
+ $receipt =
$this->bo->update_priority_key($values);
+ }
+
+ $function_msg = lang('Edit priority key');
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uirequest.priority_key');
+
+ $priority_key = $this->bo->read_priority_key();
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'function_msg'
=> $function_msg,
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_priority_key_statustext'
=> lang('Weight for prioritising'),
+ 'lang_save'
=> lang('save'),
+ 'priority_key' =>
$priority_key,
+ );
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('priority_form' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ function edit()
+ {
+ if(!$this->acl_add && !$this->acl_edit)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
+ }
+ $id =
get_var('id',array('POST','GET'));
+ $values =
get_var('values',array('POST'));
+
+ $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
+ $insert_record_entity =
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp);
+
+ for ($j=0;$j<count($insert_record_entity);$j++)
+ {
+
$insert_record['extra'][$insert_record_entity[$j]] =
$insert_record_entity[$j];
+ }
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('request'));
+
+ $bypass =
get_var('bypass',array('POST','GET'));
+
+ if($_POST && !$bypass)
+ {
+ for ($i=0;
$i<count($insert_record['location']); $i++)
+ {
+
if($_POST[$insert_record['location'][$i]])
+ {
+
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
+ }
+ }
+
+ while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
+ {
+ if($_POST[$key])
+ {
+ $values['extra'][$column]
= $_POST[$key];
+ }
+ }
+
+ $values['street_name'] =
$_POST['street_name'];
+ $values['street_number'] =
$_POST['street_number'];
+ $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
+ }
+ else
+ {
+ $location_code =
get_var('location_code',array('POST','GET'));
+ $tenant_id
= get_var('tenant_id',array('POST','GET'));
+
+ $p_entity_id =
get_var('p_entity_id',array('POST','GET'));
+ $p_cat_id =
get_var('p_cat_id',array('POST','GET'));
+ $values['p'][$p_entity_id]['p_entity_id']
= $p_entity_id;
+ $values['p'][$p_entity_id]['p_cat_id']
= $p_cat_id;
+ $values['p'][$p_entity_id]['p_num']
= get_var('p_num',array('POST','GET'));
+
+ $origin =
get_var('origin',array('POST','GET'));
+ $origin_id =
get_var('origin_id',array('POST','GET'));
+
+ if($p_entity_id && $p_cat_id)
+ {
+ $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
+ $entity_category =
$boadmin_entity->read_single_category($p_entity_id,$p_cat_id);
+
$values['p'][$p_entity_id]['p_cat_name'] = $entity_category['name'];
+ }
+
+
+ if($location_code)
+ {
+ $values['location_data'] =
$this->bolocation->read_single($location_code,array('tenant_id'=>$tenant_id,'p_num'=>$p_num));
+ }
+
+ }
+
+ if($values['origin'])
+ {
+ $origin = $values['origin'];
+ $origin_id = $values['origin_id'];
+ }
+
+ if($origin)
+ {
+ unset($values['origin']);
+ unset($values['origin_id']);
+ $values['origin'][0]['type']= $origin;
+
$values['origin'][0]['link']=$this->bocommon->get_origin_link($origin);
+ $values['origin'][0]['data'][]= array(
+ 'id'=> $origin_id,
+ 'type'=> $origin
+ );
+ }
+
+ $values['start_date'] =
get_var('start_date',array('POST'));
+ $values['end_date'] =
get_var('end_date',array('POST'));
+
+//_debug_array($values);
+ $this->config->read_repository();
+
+ if ($values['save'])
+ {
+ if(!$values['location'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a location !'));
+ $error_id=true;
+ }
+
+ if(!$values['title'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter a request TITLE !'));
+ $error_id=true;
+ }
+
+ if(!$values['cat_id'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
+ $error_id=true;
+ }
+
+ if(!$values['status'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a status !'));
+ }
+
+ if($id)
+ {
+ $values['request_id']=$id;
+ $action='edit';
+ }
+ else
+ {
+
$values['request_id']=$this->bo->next_id();
+ }
+
+ $values['file_name']=str_replace("
","_",$_FILES['file']['name']);
+ $to_file = $this->fakebase. SEP . 'request' .
SEP . implode("-",$values['location']) . SEP . $values['request_id'] . SEP .
$values['file_name'];
+
+ if(!$values['document_name_orig'] &&
$this->bo->vfs->file_exists(array(
+ 'string' => $to_file,
+ 'relatives' =>
Array(RELATIVE_NONE)
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('This file already exists !'));
+ }
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$this->bo->create_home_dir($receipt);
+
+ if($values['copy_request'])
+ {
+ $action='add';
+ $values['request_id'] =
$this->bo->next_id();
+ $id = $values['request_id'];
+ }
+ $receipt =
$this->bo->save($values,$action);
+//_debug_array($values);
+
+ if($values['file_name'])
+ {
+
$this->bo->create_document_dir(implode("-",$values['location']),
$values['request_id']);
+ $this->bo->vfs->override_acl =
1;
+
+ if(!$this->bo->vfs->cp (array (
+ 'from' =>
$_FILES['file']['tmp_name'],
+ 'to' => $to_file,
+ 'relatives' =>
array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
+ {
+
$receipt['error'][]=array('msg'=>lang('Failed to upload file !'));
+ }
+ $this->bo->vfs->override_acl =
0;
+ }
+
+ $id = $values['request_id'];
+ $function_msg = lang('Edit request');
+
+ if ($values['notify'])
+ {
+
$coordinator_name=$GLOBALS['phpgw_info']['user']['fullname'];
+
$coordinator_email=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['email'];
+ $headers = "Return-Path: <".
$coordinator_email .">\r\n";
+ $headers .= "From: " .
$coordinator_name . "<" . $coordinator_email .">\r\n";
+ $headers .= "Bcc: " .
$coordinator_name . "<" . $coordinator_email .">\r\n";
+ $headers .= "Content-type:
text/plain; charset=iso-8859-1\r\n";
+
+ $subject = lang(notify).": ".
$values['request_id'];
+ $message = lang(request) . " "
. $values['request_id'] ." ". lang('is registered');
+
+ $mail_method=
$this->config->config_data['fmwrkorder_mail'];
+ if ($mail_method=='smtp'):
+ {
+ $bcc =
$coordinator_email;
+ $send =
CreateObject('phpgwapi.send');
+ $rcpt =
$send->msg('email', $values['mail_address'], $subject, stripslashes($message),
'', $cc, $bcc, $coordinator_email, $coordinator_name, 'plain');
+ }
+ elseif
($mail_method=='sendmail'):
+ {
+
$rcpt=mail($values['mail_address'],$subject,$message, $headers);
+ }
+ else:
+ {
+
$receipt['error'][]=array('msg'=>lang('Mailing method is not chosen! (admin
section)'));
+ }
+ endif;
+ }
+
+ if($rcpt)
+ {
+
$receipt['message'][]=array('msg'=>lang('%1 is
notified',$values['mail_address']));
+ }
+ }
+ else
+ {
+ if($values['location'])
+ {
+ $location_code=implode("-",
$values['location']);
+ $values['location_data'] =
$this->bolocation->read_single($location_code,$values['extra']);
+ }
+
+ if($values['extra']['p_num'])
+ {
+
$values['p'][$values['extra']['p_entity_id']]['p_num']=$values['extra']['p_num'];
+
$values['p'][$values['extra']['p_entity_id']]['p_entity_id']=$values['extra']['p_entity_id'];
+
$values['p'][$values['extra']['p_entity_id']]['p_cat_id']=$values['extra']['p_cat_id'];
+
$values['p'][$values['extra']['p_entity_id']]['p_cat_name']=$_POST['entity_cat_name_'.$values['extra']['p_entity_id']];
+ }
+ }
+ }
+
+ if(!$receipt['error'] && !$bypass && $id)
+ {
+ $values = $this->bo->read_single($id);
+ $record_history =
$this->bo->read_record_history($id);
+ }
+
+ $table_header_history[] = array
+ (
+ 'lang_date' => lang('Date'),
+ 'lang_user' => lang('User'),
+ 'lang_action' => lang('Action'),
+ 'lang_new_value' => lang('New value')
+ );
+
+ if ($id)
+ {
+ $function_msg = lang('Edit request');
+ }
+ else
+ {
+ $function_msg = lang('Add request');
+ }
+
+ if ($values['cat_id'])
+ {
+ $this->cat_id = $values['cat_id'];
+ }
+ $lookup_type='form';
+
+
$location_data=$this->bolocation->initiate_ui_location(array(
+ 'values' =>
$values['location_data'],
+ 'type_id' => -1,
// calculated from location_types
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' => True,
+ 'lookup_type' => $lookup_type,
+ 'lookup_entity' =>
$this->bocommon->get_lookup_entity('request'),
+ 'entity_data' => $values['p']
+ ));
+
+
+ if($values['contact_phone'])
+ {
+ for
($i=0;$i<count($location_data['location']);$i++)
+ {
+
if($location_data['location'][$i]['input_name'] == 'contact_phone')
+ {
+
$location_data['location'][$i]['value'] = $values['contact_phone'];
+ }
+ }
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uirequest.edit',
+ 'id' => $id
+ );
+
+ if(!$values['coordinator'])
+ {
+ $values['coordinator']=$this->account;
+ }
+
+
$supervisor_id=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['approval_from'];
+
+ $notify =
$this->config->config_data['workorder_approval'];
+
+ if ($supervisor_id && ($notify=='yes'))
+ {
+ $prefs =
$this->bocommon->create_preferences($this->currentapp,$supervisor_id);
+ $supervisor_email = $prefs['email'];
+ }
+
+
+
+ $table_header_importance[] = array
+ (
+ 'lang_subject' =>
lang('Subject'),
+ 'lang_condition_degree' => lang('Condidtion
degree'),
+ 'lang_prob_worsening' => lang('Probability'),
+ 'lang_consequence' =>
lang('Consequence')
+ );
+
+
+ if($values['project_id'])
+ {
+ $project_lookup_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiproject.view'
+ );
+ }
+
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $link_file_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uirequest.view_file',
+ 'location_code'
=>$values['location_data']['location_code'],
+ 'id' =>$id
+ );
+
+ $link_to_files =
$this->config->config_data['files_url'];
+
+ $j = count($values['files']);
+ for ($i=0;$i<$j;$i++)
+ {
+
$values['files'][$i]['file_name']=urlencode($values['files'][$i]['name']);
+ }
+
+ if (isset($values['origin']) AND
is_array($values['origin']))
+ {
+ for ($i=0;$i<count($values['origin']);$i++)
+ {
+
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
. $values['origin'][$i]['link']);
+
if(substr($values['origin'][$i]['type'],0,6)=='entity')
+ {
+ $type =
explode("_",$values['origin'][$i]['type']);
+ $entity_id = $type[1];
+ $cat_id = $type[2];
+
+ if(!is_object($boadmin_entity))
+ {
+ $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
+ }
+ $entity_category =
$boadmin_entity->read_single_category($entity_id,$cat_id);
+ $values['origin'][$i]['descr']
= $entity_category['name'];
+ }
+ else
+ {
+ $values['origin'][$i]['descr']=
lang($values['origin'][$i]['type']);
+ }
+ }
+ }
+
+ $data = array
+ (
+ 'fileupload'
=> True,
+ 'link_view_file'
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
+ 'link_to_files'
=> $link_to_files,
+ 'files'
=> $values['files'],
+ 'lang_files'
=> lang('files'),
+ 'lang_filename'
=> lang('Filename'),
+ 'lang_delete_file'
=> lang('Delete file'),
+ 'lang_view_file_statustext' =>
lang('Klick to view file'),
+ 'lang_delete_file_statustext' => lang('Check
to delete file'),
+ 'lang_upload_file'
=> lang('Upload file'),
+ 'lang_file_statustext' =>
lang('Select file to upload'),
+
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+
+ 'value_origin'
=> $values['origin'],
+ 'value_origin_type'
=> $origin,
+ 'value_origin_id'
=> $origin_id,
+ 'lang_origin_statustext' =>
lang('Link to the origin for this request'),
+
+ 'generate_project_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit'),
+ 'lang_generate_project'
=> lang('Generate project'),
+ 'lang_generate_project_statustext' =>
lang('Generate a project from this request'),
+ 'location_code'
=> $values['location_code'],
+ 'p_num'
=> $values['p_num'],
+ 'p_entity_id'
=> $values['p_entity_id'],
+ 'p_cat_id'
=> $values['p_cat_id'],
+ 'tenant_id'
=> $values['tenant_id'],
+
+ 'lang_importance'
=> lang('Importance'),
+ 'table_header_importance' =>
$table_header_importance,
+ 'importance_weight'
=> $importance_weight,
+
+ 'lang_no_workorders' =>
lang('No workorder bugdet'),
+ 'workorder_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit'),
+ 'record_history'
=> $record_history,
+ 'table_header_history' =>
$table_header_history,
+ 'lang_history'
=> lang('History'),
+ 'lang_no_history'
=> lang('No history'),
+
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle'
=> lang('Select date'),
+ 'calendar_setup_start' =>
"Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});",
+ 'calendar_setup_end' =>
"Calendar.setup({inputField : 'end_date',ifFormat : '" . $jsDateFormat .
"',button : 'end_date-trigger'});",
+
+ 'lang_start_date_statustext' => lang('Select
the estimated end date for the request'),
+ 'lang_start_date'
=> lang('request start date'),
+ 'value_start_date'
=> $values['start_date'],
+
+ 'lang_end_date_statustext' =>
lang('Select the estimated end date for the request'),
+ 'lang_end_date'
=> lang('request end date'),
+ 'value_end_date'
=> $values['end_date'],
+
+ 'lang_copy_request'
=> lang('Copy request ?'),
+ 'lang_copy_request_statustext' => lang('Choose
Copy request to copy this request to a new request'),
+
+ 'lang_power_meter'
=> lang('Power meter'),
+ 'lang_power_meter_statustext' => lang('Enter
the power_meter'),
+ 'value_power_meter'
=> $values['power_meter'],
+
+ 'lang_budget'
=> lang('Budget'),
+ 'value_budget'
=> $values['budget'],
+ 'lang_budget_statustext' =>
lang('Enter the budget'),
+
+ 'location_data'
=> $location_data,
+ 'location_type'
=> 'form',
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.index'),
+ 'lang_category'
=> lang('category'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+
+ 'lang_request_id'
=> lang('request ID'),
+ 'value_request_id'
=> $values['request_id'],
+
+ 'lang_title'
=> lang('Title'),
+ 'value_title'
=> $values['title'],
+ 'lang_title_statustext' =>
lang('Enter request Title'),
+
+ 'lang_descr_statustext' =>
lang('Enter a description of the request'),
+ 'lang_descr'
=> lang('Description'),
+ 'value_descr'
=> $values['descr'],
+ 'lang_score'
=> lang('Score'),
+ 'value_score'
=> $values['score'],
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'lang_save_statustext' =>
lang('Save the request'),
+ 'lang_no_cat'
=> lang('Select category'),
+ 'lang_cat_statustext' =>
lang('Select the category the request belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'values[cat_id]',
+ 'value_cat_id'
=> $values['cat_id'],
+ 'cat_list'
=> $this->bo->select_category_request_list('select',$values['cat_id']),
+
+ 'lang_coordinator'
=> lang('Coordinator'),
+ 'lang_user_statustext' =>
lang('Select the coordinator the request belongs to. To do not use a category
select NO USER'),
+ 'select_user_name'
=> 'values[coordinator]',
+ 'lang_no_user'
=> lang('Select coordinator'),
+ 'user_list'
=>
$this->bocommon->get_user_list_right2('select',4,$values['coordinator'],$this->acl2_location),
+
+ 'status_list'
=> $this->boproject->select_status_list('select',$values['status']),
+ 'status_name'
=> 'values[status]',
+ 'lang_no_status'
=> lang('Select status'),
+ 'lang_status'
=> lang('Status'),
+ 'lang_status_statustext' =>
lang('What is the current status of this request ?'),
+
+ 'branch_list'
=> $this->boproject->select_branch_list($values['branch_id']),
+ 'lang_branch'
=> lang('branch'),
+ 'lang_no_branch'
=> lang('Select branch'),
+ 'lang_branch_statustext' =>
lang('Select the branches for this request'),
+
+ 'notify'
=> $notify,
+ 'lang_notify'
=> lang('Notify'),
+ 'lang_notify_statustext' =>
lang('Check this to notify your supervisor by email'),
+ 'value_notify_mail_address' =>
$supervisor_email,
+
+ 'currency' =>
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
+
+ 'lang_authorities_demands'
=> lang('Authorities Demands'),
+ 'lang_authorities_demands_statustext'
=> lang('Is there a demand from the authorities to correct this condition?'),
+ 'authorities_demands'
=> $values['authorities_demands'],
+
+ 'condition_list'
=> $this->bo->select_conditions($id),
+
+ );
+
+ $appname
= lang('request');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function delete()
+ {
+ if(!$this->acl_delete)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
+ }
+
+ $id = get_var('id',array('POST','GET'));
+ $confirm = get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uirequest.index'
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($id);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.delete&id='
. $id),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('request');
+ $function_msg =
lang('delete request');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function view()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $id =
get_var('id',array('POST','GET'));
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('request'));
+
+ $values = $this->bo->read_single($id);
+
+ $record_history = $this->bo->read_record_history($id);
+
+ $table_header_history[] = array
+ (
+ 'lang_date' => lang('Date'),
+ 'lang_user' => lang('User'),
+ 'lang_action' => lang('Action'),
+ 'lang_new_value' => lang('New value')
+ );
+
+ $function_msg = lang('View request');
+
+ if ($values['cat_id'])
+ {
+ $this->cat_id = $values['cat_id'];
+ }
+
+
$location_data=$this->bolocation->initiate_ui_location(array(
+ 'values' =>
$values['location_data'],
+ 'type_id' =>
count(explode('-',$values['location_data']['location_code'])),
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' =>
$values['location_data']['tenant_id'],
+ 'lookup_type' => 'view',
+ 'lookup_entity' =>
$this->bocommon->get_lookup_entity('project'),
+ 'entity_data' => $values['p']
+ ));
+
+ if($values['contact_phone'])
+ {
+ for
($i=0;$i<count($location_data['location']);$i++)
+ {
+
if($location_data['location'][$i]['input_name'] == 'contact_phone')
+ {
+
unset($location_data['location'][$i]['value']);
+ }
+ }
+ }
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uirequest.edit',
+ 'id' => $id
+ );
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+
+ $table_header_importance[] = array
+ (
+ 'lang_subject' =>
lang('Subject'),
+ 'lang_condition_degree' => lang('Condidtion
degree'),
+ 'lang_prob_worsening' => lang('Probability'),
+ 'lang_consequence' =>
lang('Consequence')
+ );
+
+
+
+ if($values['origin']== 'tts')
+ {
+ $origin_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uitts.view',
+ 'id' =>
$values['origin_id']
+ );
+ }
+
+ if($values['project_id'])
+ {
+ $project_lookup_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiproject.view'
+ );
+ }
+
+ $link_file_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uirequest.view_file',
+ 'location_code'
=>$values['location_data']['location_code'],
+ 'id' =>$id
+ );
+
+ $this->config->read_repository();
+ $link_to_files =
$this->config->config_data['files_url'];
+
+ $j = count($values['files']);
+ for ($i=0;$i<$j;$i++)
+ {
+
$values['files'][$i]['file_name']=urlencode($values['files'][$i]['name']);
+ }
+
+ if (isset($values['origin']) AND
is_array($values['origin']))
+ {
+ for ($i=0;$i<count($values['origin']);$i++)
+ {
+
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
. $values['origin'][$i]['link']);
+
if(substr($values['origin'][$i]['type'],0,6)=='entity')
+ {
+ $type =
explode("_",$values['origin'][$i]['type']);
+ $entity_id = $type[1];
+ $cat_id = $type[2];
+
+ if(!is_object($boadmin_entity))
+ {
+ $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
+ }
+ $entity_category =
$boadmin_entity->read_single_category($entity_id,$cat_id);
+ $values['origin'][$i]['descr']
= $entity_category['name'];
+ }
+ else
+ {
+ $values['origin'][$i]['descr']=
lang($values['origin'][$i]['type']);
+ }
+ }
+ }
+
+ $data = array
+ (
+ 'link_view_file'
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
+ 'link_to_files'
=> $link_to_files,
+ 'files'
=> $values['files'],
+ 'lang_files'
=> lang('files'),
+ 'lang_filename'
=> lang('Filename'),
+ 'lang_view_file_statustext' =>
lang('Klick to view file'),
+
+ 'value_origin'
=> $values['origin'],
+ 'value_origin_type'
=> $origin,
+ 'value_origin_id'
=> $origin_id,
+
+ 'lang_project'
=> lang('Project'),
+ 'lang_project_statustext' =>
lang('Link to the project originatet from this request'),
+ 'link_project'
=> $GLOBALS['phpgw']->link('/index.php',$project_lookup_data),
+ 'value_project_id'
=> $values['project_id'],
+
+ 'lang_importance'
=> lang('Importance'),
+ 'table_header_importance' =>
$table_header_importance,
+ 'importance_weight_view' =>
$importance_weight,
+
+ 'workorder_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit'),
+ 'record_history'
=> $record_history,
+ 'table_header_history' =>
$table_header_history,
+ 'lang_history'
=> lang('History'),
+ 'lang_no_history'
=> lang('No history'),
+
+ 'lang_start_date'
=> lang('request start date'),
+ 'value_start_date'
=> $values['start_date'],
+
+ 'lang_end_date'
=> lang('request end date'),
+ 'value_end_date'
=> $values['end_date'],
+
+ 'lang_power_meter'
=> lang('Power meter'),
+ 'value_power_meter'
=> $values['power_meter'],
+
+ 'lang_budget'
=> lang('Budget'),
+ 'value_budget'
=> $values['budget'],
+
+ 'location_data'
=> $location_data,
+ 'location_type'
=> 'view',
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.index'),
+ 'lang_category'
=> lang('category'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+
+ 'lang_request_id'
=> lang('request ID'),
+ 'value_request_id'
=> $values['request_id'],
+
+ 'lang_title'
=> lang('Title'),
+ 'value_title'
=> $values['title'],
+
+ 'lang_descr'
=> lang('Description'),
+ 'value_descr'
=> $values['descr'],
+ 'lang_score'
=> lang('Score'),
+ 'value_score'
=> $values['score'],
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'value_cat_id'
=> $values['cat_id'],
+ 'cat_list'
=> $this->bo->select_category_request_list('select',$values['cat_id']),
+
+ 'lang_coordinator'
=> lang('Coordinator'),
+ 'lang_no_user'
=> lang('Select coordinator'),
+ 'user_list'
=>
$this->bocommon->get_user_list('select',$values['coordinator'],$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
+
+ 'status_list'
=> $this->boproject->select_status_list('select',$values['status']),
+ 'lang_status'
=> lang('Status'),
+
+ 'branch_list'
=> $this->boproject->select_branch_list($values['branch_id']),
+ 'lang_branch'
=> lang('branch'),
+
+ 'edit_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.edit&id='
. $id),
+ 'lang_edit_statustext'
=> lang('Edit this entry request'),
+ 'lang_edit'
=> lang('Edit'),
+ 'currency'
=>
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
+ 'lang_contact_phone' =>
lang('Contact phone'),
+ 'contact_phone'
=> $values['contact_phone'],
+
+ 'lang_authorities_demands'
=> lang('Authorities Demands'),
+ 'authorities_demands'
=> $values['authorities_demands'],
+
+ 'condition_list_view'
=> $this->bo->select_conditions($id),
+ );
+
+ $appname
= lang('request');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+ }
+?>
Index: property/inc/class.uis_agreement.inc.php
diff -u property/inc/class.uis_agreement.inc.php:1.22
property/inc/class.uis_agreement.inc.php:1.23
--- property/inc/class.uis_agreement.inc.php:1.22 Wed Nov 9 22:49:12 2005
+++ property/inc/class.uis_agreement.inc.php Fri Jan 27 14:05:43 2006
@@ -1,1762 +1,1762 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage agreement
- * @version $Id: class.uis_agreement.inc.php,v 1.22 2005/11/09 22:49:12
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uis_agreement
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
-
- var $public_functions = array
- (
- 'index' => True,
- 'view' => True,
- 'edit' => True,
- 'delete' => True,
- 'list_attribute'=> True,
- 'edit_attrib' => True,
- 'columns' => True,
- 'edit_item' => True,
- 'view_item' => True,
- 'view_file' => True,
- 'excel' => True
- );
-
- function uis_agreement()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- $this->bo =
CreateObject($this->currentapp.'.bos_agreement',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
-
- $this->role = $this->bo->role;
-
- $this->cats =
CreateObject('phpgwapi.categories');
- $this->cats->app_name = 'fm_vendor';
-
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
- $this->acl2_location= '.s_agreement';
-
- $this->acl_read =
$this->acl2->check($this->acl2_location,1);
- $this->acl_add =
$this->acl2->check($this->acl2_location,2);
- $this->acl_edit =
$this->acl2->check($this->acl2_location,4);
- $this->acl_delete =
$this->acl2->check($this->acl2_location,8);
- $this->acl_manage =
$this->acl2->check($this->acl2_location,16);
-
- $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->vendor_id = $this->bo->vendor_id;
- $this->allrows = $this->bo->allrows;
- $this->member_id = $this->bo->member_id;
- $this->fakebase = $this->bo->fakebase;
-
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' => $this->filter,
- 'cat_id' => $this->cat_id,
- 'vendor_id' => $this->vendor_id,
- 'allrows' => $this->allrows,
- 'member_id' => $this->member_id
- );
- $this->bo->save_sessiondata($data);
- }
-
- function columns()
- {
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('columns'));
-
- $GLOBALS['phpgw_info']['flags']['noframework'] = True;
-
- $values =
get_var('values',array('POST','GET'));
-
- if ($values['save'])
- {
-
-
$GLOBALS['phpgw']->preferences->account_id=$this->account;
-
$GLOBALS['phpgw']->preferences->read_repository();
-
$GLOBALS['phpgw']->preferences->add($this->currentapp,'s_agreement_columns',$values['columns'],'user');
-
$GLOBALS['phpgw']->preferences->save_repository();
-
- $receipt['message'][] = array('msg' =>
lang('columns is updated'));
- }
-
- $function_msg = lang('Select Column');
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uis_agreement.columns',
- 'role' => $this->role
- );
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'column_list' =>
$this->bo->column_list($values['columns'],$allrows=True),
- 'function_msg' => $function_msg,
- 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_columns' => lang('columns'),
- 'lang_none' => lang('None'),
- 'lang_save' => lang('save'),
- 'select_name' => 'period'
- );
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
$function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('columns' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function view_file()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $GLOBALS['phpgw_info']['flags'][noheader] = True;
- $GLOBALS['phpgw_info']['flags'][nofooter] = True;
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
-
- $file_name =
urldecode(get_var('file_name',array('POST','GET')));
- $id = get_var('id',array('POST','GET'));
-
- $file = $this->fakebase. SEP . 'service_agreement' .
SEP . $id . SEP . $file_name;
-
- if($this->bo->vfs->file_exists(array(
- 'string' => $file,
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
- $size =
$this->bo->vfs->get_size(array(
- 'string' => $file,
- 'relatives' =>
Array(RELATIVE_NONE),
- 'checksubdirs' =>
True));
-
- $document= $this->bo->vfs->read(array(
- 'string' => $file,
- 'relatives' => Array(RELATIVE_NONE)));
-
- $filename =
basename($values['document_name']);
- $filetype = array_pop(explode('.',
basename($file)));
- $browser = CreateObject('phpgwapi.browser');
-
$browser->content_header($filename,$filetype,$size);
-
- echo $document;
- }
- }
-
- function index()
- {
- $this->menu->sub = 'agreement';
-
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('s_agreement',
-
'menu',
-
'receipt',
-
'search_field',
-
'nextmatchs',
-
'filter_member_of'));
-
- $links = $this->menu->links('s_agreement');
-
- $receipt =
$GLOBALS['phpgw']->session->appsession('session_data','s_agreement_receipt');
-
$GLOBALS['phpgw']->session->appsession('session_data','s_agreement_receipt','');
-
- $list = $this->bo->read();
-
- $uicols = $this->bo->uicols;
-
- $j=0;
-
- if (isset($list) AND is_array($list))
- {
- foreach($list as $entry)
- {
- for
($i=0;$i<count($uicols['name']);$i++)
- {
-
if($uicols['input_type'][$i]!='hidden')
- {
-
$content[$j]['row'][$i]['value'] =
$entry[$uicols['name'][$i]];
-
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
- }
- }
-
- if($this->acl_read)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('view the
entity');
- $content[$j]['row'][$i]['text']
= lang('view');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.view&id='
. $entry['id'] .'&role=' . $this->role);
- }
- if($this->acl_edit)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('edit the
s_agreement');
- $content[$j]['row'][$i]['text']
= lang('edit');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit&id='
. $entry['id'] .'&role=' . $this->role);
- }
- if($this->acl_delete)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('delete the
s_agreement');
- $content[$j]['row'][$i]['text']
= lang('delete');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.delete&s_agreement_id='
. $entry['id'] .'&role=' . $this->role);
- }
-
- $j++;
- }
- }
-
-//html_print_r($content);
- for ($i=0;$i<count($uicols['descr']);$i++)
- {
- if($uicols['input_type'][$i]!='hidden')
- {
- $table_header[$i]['header'] =
$uicols['descr'][$i];
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- if($uicols['datatype'][$i]!='T' &&
$uicols['datatype'][$i]!='CH')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
- (
- 'sort' =>
$this->sort,
- 'var' =>
$uicols['name'][$i],
- 'order' =>
$this->order,
- 'extra'
=> array('menuaction' => $this->currentapp.'.uis_agreement.index',
-
'query' =>$this->query,
-
'lookup' =>$lookup,
-
'district_id' => $this->district_id,
-
'start_date' => $start_date,
-
'role' => $this->role,
-
'member_id' => $this->member_id,
-
'allrows' => $this->allrows,
-
'end_date' => $end_date
-
)
- ));
- }
- }
- }
-
- if($this->acl_read)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('view');
- $i++;
- }
- if($this->acl_edit)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('edit');
- $i++;
- }
- if($this->acl_delete)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('delete');
- $i++;
- }
-
-
- if($this->acl_add)
- {
- $table_add = array
- (
- 'lang_add'
=> lang('add'),
- 'lang_add_statustext' => lang('add a
s_agreement'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit&role='
. $this->role)
- );
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uis_agreement.index',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query,
- 'role' =>
$this->role,
- 'member_id' =>
$this->member_id
-
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $link_columns = array
- (
- 'menuaction' =>
$this->currentapp.'.uis_agreement.columns',
- 'role' =>
$this->role
- );
-
- $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True,link_data => $link_data));
-
-//_debug_array($member_of_data);
- $data = array
- (
- 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
- 'lang_columns'
=> lang('columns'),
- 'link_columns'
=> $GLOBALS['phpgw']->link('/index.php',$link_columns),
- 'lang_columns_help'
=> lang('Choose columns'),
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'links'
=> $links,
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the s_agreement belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $this->bo->select_category_list('filter',$this->cat_id),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
-
- 'lang_no_vendor'
=> lang('no vendor'),
- 'lang_vendor_statustext' =>
lang('Select the vendor the s_agreement belongs to.'),
- 'vendor_list'
=> $this->bo->select_vendor_list('filter',$this->vendor_id),
-
- 'lang_no_member'
=> lang('no member'),
- 'member_of_name'
=> 'member_id',
- 'member_of_list'
=> $member_of_data['cat_list'],
-
- 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter)),
- 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
- $this->save_sessiondata();
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('service agreement') . ': ' . lang('list ' . $this->role);
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function list_content($list,$uicols,$edit_item='',$view_only='')
- {
- $j=0;
-
- if (isset($list) AND is_array($list))
- {
- foreach($list as $entry)
- {
- $content[$j]['id']
= $entry['id'];
- $content[$j]['item_id'] =
$entry['item_id'];
- $content[$j]['index_count'] =
$entry['index_count'];
- $content[$j]['cost'] =
$entry['cost'];
- for
($i=0;$i<count($uicols['name']);$i++)
- {
-
if($uicols['input_type'][$i]!='hidden')
- {
-
$content[$j]['row'][$i]['value'] =
$entry[$uicols['name'][$i]];
-
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
- }
- }
-
- if($this->acl_read && !$edit_item &&
!$view_only)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('view the
entity');
- $content[$j]['row'][$i]['text']
= lang('view');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.view_item&s_agreement_id='
. $entry['agreement_id'] .'&id=' . $entry['id']);
- }
- if($this->acl_edit && !$edit_item &&
!$view_only)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('edit the
s_agreement');
- $content[$j]['row'][$i]['text']
= lang('edit');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit_item&s_agreement_id='
. $entry['agreement_id'] .'&id=' . $entry['id']);
- }
- if($this->acl_delete && !$edit_item &&
!$view_only)
- {
-
$content[$j]['row'][$i]['statustext'] = lang('delete this
item');
- $content[$j]['row'][$i]['text']
= lang('delete');
-
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit&delete_item=1&id='
. $entry['agreement_id'] .'&item_id=' . $entry['id']);
- }
-
- $j++;
- }
- }
-
-//html_print_r($content);
- for ($i=0;$i<count($uicols['descr']);$i++)
- {
- if($uicols['input_type'][$i]!='hidden')
- {
- $table_header[$i]['header'] =
$uicols['descr'][$i];
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- }
- }
-
- if($this->acl_read && !$edit_item && !$view_only)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('view');
- $i++;
- }
- if($this->acl_edit && !$edit_item && !$view_only)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('edit');
- $i++;
- }
- if($this->acl_delete && !$edit_item && !$view_only)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('delete');
- $i++;
- }
- if($this->acl_manage && !$edit_item && !$view_only)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('Update');
- $i++;
- }
-
- return
array('content'=>$content,'table_header'=>$table_header);
- }
-
-
- function edit()
- {
- $id = get_var('id',array('POST','GET'));
- $values = get_var('values',array('POST'));
- $delete_item = get_var('delete_item',array('GET'));
- $item_id = get_var('item_id',array('GET'));
-
- $config =
CreateObject('phpgwapi.config',$this->currentapp);
- $boalarm =
CreateObject($this->currentapp.'.boalarm');
-
- if($delete_item && $id && $item_id)
- {
- $this->bo->delete_item($id,$item_id);
- }
-
- $values_attribute =
get_var('values_attribute',array('POST'));
-
- $insert_record_s_agreement =
$GLOBALS['phpgw']->session->appsession('insert_record_s_agreement',$this->currentapp);
-
-//_debug_array($insert_record_s_agreement);
- for ($j=0;$j<count($insert_record_s_agreement);$j++)
- {
-
$insert_record['extra'][$insert_record_s_agreement[$j]] =
$insert_record_s_agreement[$j];
- }
-
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('s_agreement','attributes_form'));
-
- if (is_array($values))
- {
- while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
- {
- if($_POST[$key])
- {
- $values['extra'][$column]
= $_POST[$key];
- }
- }
-
-//_debug_array($values);
-
- if ($values['save'] || $values['apply']):
- {
- $values['vendor_id'] =
get_var('vendor_id',array('POST'));
- $values['vendor_name'] =
get_var('vendor_name',array('POST'));
- $values['b_account_id'] =
get_var('b_account_id',array('POST'));
- $values['b_account_name'] =
get_var('b_account_name',array('POST'));
- $values['start_date'] =
get_var('start_date',array('POST'));
- $values['end_date']
= get_var('end_date',array('POST'));
- $values['termination_date'] =
get_var('termination_date',array('POST'));
-
- if(!$values['cat_id'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
- }
-
- if(!$values['last_name'])
- {
-//
$receipt['error'][]=array('msg'=>lang('Please enter a name !'));
- }
-
-
- if($id)
- {
- $values['s_agreement_id']=$id;
- $action='edit';
- }
- else
- {
-
$values['s_agreement_id']=$this->bo->request_next_id();
- }
-
-
$values['file_name']=$_FILES['file']['name'];
- $to_file = $this->fakebase. SEP .
'service_agreement' . SEP . $values['s_agreement_id'] . SEP .
$values['file_name'];
-
- if(!$values['document_name_orig'] &&
$this->bo->vfs->file_exists(array(
- 'string' => $to_file,
- 'relatives' =>
Array(RELATIVE_NONE)
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('This file already exists !'));
- }
-
-
- if(!$receipt['error'])
- {
-// $values['s_agreement_id']
= $id;
- $receipt =
$this->bo->create_home_dir($receipt);
- $receipt =
$this->bo->save($values,$values_attribute,$action);
- $id =
$receipt['s_agreement_id'];
- $this->cat_id =
($values['cat_id']?$values['cat_id']:$this->cat_id);
-
- if($values['file_name'])
- {
-
$this->bo->create_document_dir($id);
-
$this->bo->vfs->override_acl = 1;
-
- if(!$this->bo->vfs->cp
(array (
- 'from' =>
$_FILES['file']['tmp_name'],
- 'to' =>
$to_file,
- 'relatives'
=> array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
- {
-
$receipt['error'][]=array('msg'=>lang('Failed to upload file !'));
- }
-
$this->bo->vfs->override_acl = 0;
- }
-
-
- if ($values['save'])
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','s_agreement_receipt',$receipt);
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.index&role='
. $this->role);
- }
- }
- }
- elseif($values['update']):
- {
- $values['date'] =
get_var('date',array('POST'));
-
- if(!$values['date'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a date !'));
- }
- if(!$values['new_index'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter a index !'));
- }
-
- if(!$receipt['error'])
- {
- $receipt =
$this->bo->update($values);
- }
-
- }
- elseif($values['delete_alarm'] &&
count($values['alarm'])):
- {
-
- if(!$receipt['error'])
- {
- $receipt =
$boalarm->delete_alarm('s_agreement',$values['alarm']);
- }
-
- }
- elseif(($values['enable_alarm'] ||
$values['disable_alarm']) && count($values['alarm'])):
- {
-
- if(!$receipt['error'])
- {
- $receipt =
$boalarm->enable_alarm('s_agreement',$values['alarm'],$values['enable_alarm']);
- }
-
- }
- elseif($values['add_alarm']):
- {
- $time =
intval($values['time']['days'])*24*3600 +
-
intval($values['time']['hours'])*3600 +
-
intval($values['time']['mins'])*60;
-
- if ($time > 0)
- {
- $receipt =
$boalarm->add_alarm('s_agreement',$this->bo->read_event(array('s_agreement_id'=>$id)),$time,$values['user_id']);
- }
- }
- elseif (!$values['save'] && !$values['apply']
&& !$values['update']):
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.index&role='
. $this->role);
- }
- endif;
- }
-
-
- $s_agreement =
$this->bo->read_single(array('s_agreement_id'=>$id));
-
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
- if ($id)
- {
- $this->cat_id =
($s_agreement['cat_id']?$s_agreement['cat_id']:$this->cat_id);
- $this->member_id =
($s_agreement['member_of']?$s_agreement['member_of']:$this->member_id);
- $list = $this->bo->read_details($id);
-
- $uicols = $this->bo->uicols;
- $list =
$this->list_content($list,$uicols);
- $content = $list['content'];
- $table_header=$list['table_header'];
- for ($i=0;
$i<count($list['content'][0]['row']); $i++)
- {
- $set_column[]=True;
- }
-
- if ($content)
- {
- $table_update[] = array
- (
- 'jsDateFormat'
=> $jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle'
=> lang('Select date'),
- 'calendar_setup'
=> "Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat
. "',button : 'date-trigger'});",
-
- 'lang_new_index'
=> lang('New index'),
- 'lang_new_index_statustext'
=> lang('Enter a new index'),
- 'lang_date_statustext'
=> lang('Select the date for the update'),
- 'lang_update'
=> lang('Update'),
- 'lang_update_statustext'
=> lang('update selected investments')
- );
- }
-
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uis_agreement.edit',
- 'id' => $id,
- 'role' => $this->role
- );
-
-
-
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
- 'vendor_id' =>
$s_agreement['vendor_id'],
- 'vendor_name' =>
$s_agreement['vendor_name']));
-
-
$b_account_data=$this->bocommon->initiate_ui_budget_account_lookup(array(
- 'b_account_id' =>
$s_agreement['b_account_id'],
- 'b_account_name' =>
$s_agreement['b_account_name']));
-
-
- $alarm_data=$this->bocommon->initiate_ui_alarm(array(
-
'acl_location'=>$this->acl2_location,
- 'alarm_type'=> 's_agreement',
- 'type' => 'form',
- 'text' => 'Email
notification',
- 'times' => $times,
- 'id' => $id,
- 'method' => $method,
- 'data' => $data,
- 'account_id'=> $account_id
- ));
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- switch(substr($dateformat,0,1))
- {
- case 'M':
- $dateformat_validate=
"javascript:vDateType='1'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
- $onBlur =
"DateFormat(this,this.value,event,true,'1')";
- break;
- case 'y':
-
$dateformat_validate="javascript:vDateType='2'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
- $onBlur =
"DateFormat(this,this.value,event,true,'2')";
- break;
- case 'D':
-
$dateformat_validate="javascript:vDateType='3'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
- $onBlur =
"DateFormat(this,this.value,event,true,'3')";
- break;
- }
-
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True,link_data => array()));
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add detail'),
- 'lang_add_standardtext' => lang('add an item to
the details'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit_item&s_agreement_id='
. $id)
- );
-
-
- $link_file_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uis_agreement.view_file',
- 'id' =>$id
- );
-
- $config->read_repository();
- $link_to_files = $config->config_data['files_url'];
-
- $j = count($s_agreement['files']);
- for ($i=0;$i<$j;$i++)
- {
-
$s_agreement['files'][$i]['file_name']=urlencode($s_agreement['files'][$i]['name']);
- }
-
- $link_excel = array
- (
- 'menuaction' =>
$this->currentapp.'.uis_agreement.excel',
- 'id'
=>$id
- );
-
-
- $data = array
- (
-
- 'alarm_data' =>
$alarm_data,
- 'lang_alarm' =>
lang('Alarm'),
- 'lang_excel' =>
'excel',
- 'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
- 'lang_excel_help' =>
lang('Download table to MS Excel'),
- 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
-
- 'fileupload'
=> True,
- 'link_view_file'
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
- 'link_to_files'
=> $link_to_files,
- 'files'
=> $s_agreement['files'],
- 'lang_files'
=> lang('files'),
- 'lang_filename'
=> lang('Filename'),
- 'lang_delete_file'
=> lang('Delete file'),
- 'lang_view_file_statustext' =>
lang('Klick to view file'),
- 'lang_delete_file_statustext' => lang('Check
to delete file'),
- 'lang_upload_file'
=> lang('Upload file'),
- 'lang_file_statustext' =>
lang('Select file to upload'),
-
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_id'
=> lang('ID'),
- 'value_s_agreement_id' => $id,
- 'lang_category'
=> lang('category'),
- 'lang_save'
=> lang('save'),
- 'lang_cancel'
=> lang('cancel'),
- 'lang_apply'
=> lang('apply'),
- 'value_cat'
=> $s_agreement['cat'],
- 'lang_apply_statustext' =>
lang('Apply the values'),
- 'lang_cancel_statustext' =>
lang('Leave the service agreement untouched and return back to the list'),
- 'lang_save_statustext' =>
lang('Save the s_agreement and return back to the list'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the s_agreement belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'values[cat_id]',
- 'cat_list'
=> $this->bo->select_category_list('select',$this->cat_id),
-
- 'lang_member_of'
=> lang('member of'),
- 'member_of_name'
=> 'member_id',
- 'member_of_list'
=> $member_of_data['cat_list'],
-
- 'lang_dateformat'
=> lang(strtolower($dateformat)),
- 'dateformat_validate' =>
$dateformat_validate,
- 'onKeyUp'
=> $onKeyUp,
- 'onBlur'
=> $onBlur,
- 'dateformat_source'
=> './'.$this->currentapp.'/inc/dateformat.js',
- 'lang_attributes'
=> lang('Attributes'),
- 'attributes_header'
=> $attributes_header,
- 'attributes_values'
=> $s_agreement['attributes'],
- 'lookup_functions'
=> $s_agreement['lookup_functions'],
- 'dateformat'
=> $dateformat,
-
- 'jsDateFormat'
=> $jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle'
=> lang('Select date'),
- 'calendar_setup_start' =>
"Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});",
- 'calendar_setup_end' =>
"Calendar.setup({inputField : 'end_date',ifFormat : '" . $jsDateFormat .
"',button : 'end_date-trigger'});",
- 'calendar_setup_termination'
=> "Calendar.setup({inputField : 'termination_date',ifFormat : '" .
$jsDateFormat . "',button : 'termination_date-trigger'});",
-
- 'lang_start_date_statustext' => lang('Select
the estimated end date for the Project'),
- 'lang_start_date'
=> lang('start date'),
- 'value_start_date'
=> $s_agreement['start_date'],
-
- 'lang_end_date_statustext' =>
lang('Select the estimated end date for the Project'),
- 'lang_end_date'
=> lang('end date'),
- 'value_end_date'
=> $s_agreement['end_date'],
-
- 'lang_termination_date_statustext'
=> lang('Select the estimated termination date'),
- 'lang_termination_date'
=> lang('termination date'),
- 'value_termination_date'
=> $s_agreement['termination_date'],
-
- 'vendor_data'
=> $vendor_data,
- 'b_account_data'
=> $b_account_data,
- 'lang_name'
=> lang('name'),
- 'lang_name_statustext' =>
lang('name'),
- 'value_name'
=> $s_agreement['name'],
- 'lang_descr'
=> lang('descr'),
- 'lang_descr_statustext' =>
lang('descr'),
- 'value_descr'
=> $s_agreement['descr'],
- 'table_add'
=> $table_add,
- 'values'
=> $content,
- 'table_header'
=> $table_header,
- 'acl_manage'
=> $this->acl_manage,
- 'table_update'
=> $table_update,
- 'update_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit&id='
. $id),
- 'lang_select_all'
=> lang('Select All'),
- 'img_check'
=>
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
- 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
- 'check_all_script'
=> $check_all_script,
- 'set_column'
=> $set_column,
-
- );
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('service agreement') . ': ' . ($id?lang('edit') . ' ' .
lang($this->role):lang('add') . ' ' . lang($this->role));
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function excel()
- {
- $id = get_var('id',array('POST','GET'));
- $list = $this->bo->read_details($id);
- $uicols = $this->bo->uicols;
-
$this->bocommon->excel($list,$uicols['name'],$uicols['descr'],$uicols['input_type']);
- }
-
- function edit_item()
- {
- $s_agreement_id =
get_var('s_agreement_id',array('POST','GET'));
- $id = get_var('id',array('POST','GET'));
- $values = get_var('values',array('POST'));
- $delete_last = get_var('delete_last',array('GET'));
- if($delete_last)
- {
-
$this->bo->delete_last_index($s_agreement_id,$id);
- }
-
-
- $bolocation =
CreateObject($this->currentapp.'.bolocation');
-
- $values_attribute =
get_var('values_attribute',array('POST'));
-
- $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
- $insert_record_entity =
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp);
-
- $insert_record_s_agreement1 =
$GLOBALS['phpgw']->session->appsession('insert_record_s_agreement1',$this->currentapp);
-
-//_debug_array($insert_record_s_agreement1);
-
- for ($j=0;$j<count($insert_record_entity);$j++)
- {
-
$insert_record['extra'][$insert_record_entity[$j]] =
$insert_record_entity[$j];
- }
-
- for ($j=0;$j<count($insert_record_s_agreement1);$j++)
- {
-
$insert_record['extra'][$insert_record_s_agreement1[$j]] =
$insert_record_s_agreement1[$j];
- }
-
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('s_agreement','attributes_form'));
-
- if (is_array($values))
- {
-
- for ($i=0;
$i<count($insert_record['location']); $i++)
- {
-
if($_POST[$insert_record['location'][$i]])
- {
-
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
- }
- }
-
- while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
- {
- if($_POST[$key])
- {
- $values['extra'][$column]
= $_POST[$key];
- }
- }
-
- $values['street_name'] =
$_POST['street_name'];
- $values['street_number'] =
$_POST['street_number'];
- $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
-
-//_debug_array($values);
- if ($values['save'] || $values['apply']):
- {
-
- if(!$receipt['error'])
- {
- $values['s_agreement_id']
= $s_agreement_id;
- $values['id'] = $id;
- $receipt =
$this->bo->save_item($values,$values_attribute);
- $s_agreement_id =
$receipt['s_agreement_id'];
- $id =
$receipt['id'];
- $this->cat_id =
($values['cat_id']?$values['cat_id']:$this->cat_id);
-
- if ($values['save'])
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','s_agreement_receipt',$receipt);
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit&id='
. $s_agreement_id);
- }
- }
- else
- {
- if($values['location'])
- {
-
$location_code=implode("-", $values['location']);
-
$values['location_data'] =
$bolocation->read_single($location_code,$values['extra']);
- }
- if($values['extra']['p_num'])
- {
-
$values['p'][$values['extra']['p_entity_id']]['p_num']=$values['extra']['p_num'];
-
$values['p'][$values['extra']['p_entity_id']]['p_entity_id']=$values['extra']['p_entity_id'];
-
$values['p'][$values['extra']['p_entity_id']]['p_cat_id']=$values['extra']['p_cat_id'];
-
$values['p'][$values['extra']['p_entity_id']]['p_cat_name']=$_POST['entity_cat_name_'.$values['extra']['p_entity_id']];
- }
- }
- }
- elseif($values['update']):
- {
- $values['date'] =
get_var('date',array('POST'));
-
- if(!$values['date'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a date !'));
- }
- if(!$values['new_index'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter a index !'));
- }
-
- if(!$receipt['error'])
- {
- $receipt =
$this->bo->update($values);
- }
-
- }
- elseif (!$values['save'] && !$values['apply']
&& !$values['update']):
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit&id='
. $s_agreement_id);
- }
- endif;
- }
-
- $s_agreement =
$this->bo->read_single(array('s_agreement_id'=>$s_agreement_id));
- $values =
$this->bo->read_single_item(array('s_agreement_id'=>$s_agreement_id,'id'=>$id));
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uis_agreement.edit_item',
- 's_agreement_id' => $s_agreement_id,
- 'id' => $id,
- 'role' => $this->role
- );
-
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- switch(substr($dateformat,0,1))
- {
- case 'M':
- $dateformat_validate=
"javascript:vDateType='1'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
- $onBlur =
"DateFormat(this,this.value,event,true,'1')";
- break;
- case 'y':
-
$dateformat_validate="javascript:vDateType='2'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
- $onBlur =
"DateFormat(this,this.value,event,true,'2')";
- break;
- case 'D':
-
$dateformat_validate="javascript:vDateType='3'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
- $onBlur =
"DateFormat(this,this.value,event,true,'3')";
- break;
- }
-
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True,link_data => array()));
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add detail'),
- 'lang_add_standardtext' => lang('add an item to
the details'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit_item&s_agreement_id='
. $s_agreement_id)
- );
-
-
- if($id)
- {
- $list =
$this->bo->read_prizing(array('s_agreement_id'=>$s_agreement_id,'item_id'=>$id));
- }
-
- $uicols = $this->bo->uicols;
- $list =
$this->list_content($list,$uicols,$edit_item=True);
- $content = $list['content'];
- $table_header=$list['table_header'];
-
- for ($i=0; $i<count($list['content'][0]['row']); $i++)
- {
- $set_column[]=True;
- }
-//_debug_array($list);
-
- $table_update[] = array
- (
- 'jsDateFormat'
=> $jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle'
=> lang('Select date'),
- 'calendar_setup' =>
"Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat .
"',button : 'date-trigger'});",
-
- 'lang_new_index' =>
lang('New index'),
- 'lang_new_index_statustext' => lang('Enter
a new index'),
- 'lang_date_statustext' => lang('Select
the date for the update'),
- 'lang_update' =>
lang('Update'),
- 'lang_update_statustext' => lang('update
selected investments')
- );
-
-
- $lookup_type='form';
-
-//_debug_array($values);
- $location_data=$bolocation->initiate_ui_location(array(
- 'values' =>
$values['location_data'],
- 'type_id' => -1,
// calculated from location_types
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' =>
False,
- 'lookup_type' => $lookup_type,
- 'lookup_entity' =>
$this->bocommon->get_lookup_entity('s_agreement'),
- 'entity_data' => $values['p']
- ));
-
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_id'
=> lang('ID'),
- 'value_id'
=> $values['id'],
- 'value_s_agreement_id' =>
$s_agreement_id,
- 'lang_category'
=> lang('category'),
- 'lang_save'
=> lang('save'),
- 'lang_cancel'
=> lang('cancel'),
- 'lang_apply'
=> lang('apply'),
- 'lang_apply_statustext' =>
lang('Apply the values'),
- 'lang_cancel_statustext' =>
lang('Leave the service agreement untouched and return back to the list'),
- 'lang_save_statustext' =>
lang('Save the s_agreement and return back to the list'),
-
- 'lang_dateformat'
=> lang(strtolower($dateformat)),
- 'dateformat_validate' =>
$dateformat_validate,
- 'onKeyUp'
=> $onKeyUp,
- 'onBlur'
=> $onBlur,
- 'dateformat_source'
=> './'.$this->currentapp.'/inc/dateformat.js',
- 'lang_attributes'
=> lang('Attributes'),
- 'attributes_header'
=> $attributes_header,
- 'attributes_values'
=> $values['attributes'],
- 'lookup_functions'
=> $values['lookup_functions'],
- 'dateformat'
=> $dateformat,
-
- 'jsDateFormat'
=> $jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle'
=> lang('Select date'),
- 'calendar_setup_start' =>
"Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});",
- 'calendar_setup_end' =>
"Calendar.setup({inputField : 'end_date',ifFormat : '" . $jsDateFormat .
"',button : 'end_date-trigger'});",
-
- 'lang_agreement'
=> lang('Agreement'),
- 'agreement_name'
=> $s_agreement['name'],
-
- 'table_add'
=> $table_add,
- 'values'
=> $content,
- 'table_header'
=> $table_header,
- 'acl_manage'
=> $this->acl_manage,
- 'table_update'
=> $table_update,
- 'update_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit_item&s_agreement_id='
. $s_agreement_id . '&id=' . $id),
- 'lang_select_all'
=> lang('Select All'),
- 'img_check'
=>
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
- 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
- 'location_data'
=> $location_data,
-
- 'lang_cost'
=> lang('cost'),
- 'lang_cost_statustext' =>
lang('cost'),
- 'value_cost'
=> $values['cost'],
- 'set_column'
=> $set_column,
- 'lang_delete_last'
=> lang('delete last index'),
- 'lang_delete_last_statustext' => lang('delete
the last index'),
- 'delete_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit_item&delete_last=1&s_agreement_id='
. $s_agreement_id . '&id=' . $id),
-
- );
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('service agreement') . ': ' . ($values['id']?lang('edit item') . ' ' .
$s_agreement['name']:lang('add item') . ' ' . $s_agreement['name']);
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_item' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function view_item()
- {
- $s_agreement_id =
get_var('s_agreement_id',array('POST','GET'));
- $id = get_var('id',array('POST','GET'));
-
- $bolocation =
CreateObject($this->currentapp.'.bolocation');
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('s_agreement','attributes_view'));
-
- $s_agreement =
$this->bo->read_single(array('s_agreement_id'=>$s_agreement_id));
- $values =
$this->bo->read_single_item(array('s_agreement_id'=>$s_agreement_id,'id'=>$id));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uis_agreement.edit',
- 'id' =>
$s_agreement_id
- );
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- if($id)
- {
- $list =
$this->bo->read_prizing(array('s_agreement_id'=>$s_agreement_id,'item_id'=>$id));
- }
-
- $uicols = $this->bo->uicols;
- $list =
$this->list_content($list,$uicols,$edit_item=True);
- $content = $list['content'];
- $table_header=$list['table_header'];
-
- $lookup_type='view';
-
- $location_data=$bolocation->initiate_ui_location(array(
- 'values' =>
$values['location_data'],
- 'type_id' => -1,
// calculated from location_types
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' =>
False,
- 'lookup_type' => $lookup_type,
- 'lookup_entity' =>
$this->bocommon->get_lookup_entity('s_agreement'),
- 'entity_data' => $values['p']
- ));
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_id'
=> lang('ID'),
- 'value_id'
=> $values['id'],
- 'value_s_agreement_id' =>
$s_agreement_id,
- 'lang_category'
=> lang('category'),
- 'lang_cancel'
=> lang('cancel'),
- 'lang_cancel_statustext' =>
lang('Leave the service agreement untouched and return back to the list'),
-
- 'lang_dateformat'
=> lang(strtolower($dateformat)),
- 'attributes_view'
=> $values['attributes'],
-
- 'lang_agreement'
=> lang('Agreement'),
- 'agreement_name'
=> $s_agreement['name'],
-
- 'table_add'
=> $table_add,
- 'values'
=> $content,
- 'table_header'
=> $table_header,
- 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
- 'location_data'
=> $location_data,
-
- 'lang_cost'
=> lang('cost'),
- 'lang_cost_statustext' =>
lang('cost'),
- 'value_cost'
=> $values['cost'],
- 'set_column'
=> $set_column,
- );
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('service agreement') . ': ' . lang('view item') . ' ' .
$s_agreement['name'];
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view_item' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- function delete()
- {
- $attrib = get_var('attrib',array('POST','GET'));
- $id = get_var('id',array('POST','GET'));
- $s_agreement_id =
get_var('s_agreement_id',array('POST','GET'));
- $delete = get_var('delete',array('POST'));
- $confirm = get_var('confirm',array('POST'));
-
-
- if($attrib)
- {
- $function='list_attribute';
- }
- else
- {
- $function='index';
- }
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uis_agreement.'.$function,
- 'role' => $this->role
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($s_agreement_id,$id,$attrib);
-// Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
-
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.delete&s_agreement_id='
. $s_agreement_id. '&id=' . $id . '&attrib=' . $attrib . '&role=' .
$this->role),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('service agreement');
- $function_msg =
lang('delete') . ' ' . lang($this->role);
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
-
- function view()
- {
- $s_agreement_id = get_var('id',array('POST','GET'));
- $config =
CreateObject('phpgwapi.config',$this->currentapp);
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('s_agreement','attributes_view'));
-
-
- $s_agreement =
$this->bo->read_single(array('s_agreement_id'=>$s_agreement_id));
-
-
- if ($s_agreement_id)
- {
- $this->cat_id =
($s_agreement['cat_id']?$s_agreement['cat_id']:$this->cat_id);
- $this->member_id =
($s_agreement['member_of']?$s_agreement['member_of']:$this->member_id);
- $list =
$this->bo->read_details($s_agreement_id);
- $total_records = count($list);
-
- $uicols = $this->bo->uicols;
- $list =
$this->list_content($list,$uicols,$edit_item=False,$view_only=True);
- $content = $list['content'];
- $table_header=$list['table_header'];
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uis_agreement.index',
- 's_agreement_id' => $s_agreement_id,
- );
-
-
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
- 'vendor_id' =>
$s_agreement['vendor_id'],
- 'vendor_name' =>
$s_agreement['vendor_name'],
- 'type' =>
'view'));
-
-
$b_account_data=$this->bocommon->initiate_ui_budget_account_lookup(array(
- 'b_account_id' =>
$s_agreement['b_account_id'],
- 'b_account_name' =>
$s_agreement['b_account_name'],
- 'type' =>
'view'));
-
-
- $alarm_data=$this->bocommon->initiate_ui_alarm(array(
-
'acl_location'=>$this->acl2_location,
- 'alarm_type'=> 's_agreement',
- 'type' => 'view',
- 'text' => 'Email
notification',
- 'times' => $times,
- 'id' =>
$s_agreement_id,
- 'method' => $method,
- 'data' => $data,
- 'account_id'=> $account_id
- ));
-
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True,link_data => array()));
-
- $link_file_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uis_agreement.view_file',
- 'id'
=>$s_agreement_id
- );
-
-
- $config->read_repository();
- $link_to_files = $config->config_data['files_url'];
-
- $j = count($s_agreement['files']);
- for ($i=0;$i<$j;$i++)
- {
-
$s_agreement['files'][$i]['file_name']=urlencode($s_agreement['files'][$i]['name']);
- }
-
-
- $data = array
- (
- 'lang_total_records' =>
lang('Total'),
- 'total_records'
=> $total_records,
- 'alarm_data'
=> $alarm_data,
- 'lang_alarm'
=> lang('Alarm'),
- 'link_view_file'
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
- 'link_to_files'
=> $link_to_files,
- 'files'
=> $s_agreement['files'],
- 'lang_files'
=> lang('files'),
- 'lang_filename'
=> lang('Filename'),
- 'lang_view_file_statustext' =>
lang('Klick to view file'),
-
- 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_id'
=> lang('ID'),
- 'value_s_agreement_id' =>
$s_agreement_id,
- 'lang_category'
=> lang('category'),
- 'lang_save'
=> lang('save'),
- 'lang_cancel'
=> lang('done'),
- 'lang_apply'
=> lang('apply'),
- 'value_cat'
=> $s_agreement['cat'],
- 'lang_cancel_statustext' =>
lang('return back to the list'),
- 'cat_list'
=> $this->bo->select_category_list('select',$this->cat_id),
-
- 'lang_member_of'
=> lang('member of'),
- 'member_of_name'
=> 'member_id',
- 'member_of_list'
=> $member_of_data['cat_list'],
-
- 'lang_dateformat'
=> lang(strtolower($dateformat)),
- 'attributes_view'
=> $s_agreement['attributes'],
- 'dateformat'
=> $dateformat,
-
- 'lang_start_date'
=> lang('start date'),
- 'value_start_date'
=> $s_agreement['start_date'],
-
- 'lang_end_date'
=> lang('end date'),
- 'value_end_date'
=> $s_agreement['end_date'],
-
- 'lang_termination_date' =>
lang('termination date'),
- 'value_termination_date' =>
$s_agreement['termination_date'],
-
- 'vendor_data'
=> $vendor_data,
- 'b_account_data'
=> $b_account_data,
- 'lang_name'
=> lang('name'),
- 'value_name'
=> $s_agreement['name'],
- 'lang_descr'
=> lang('descr'),
- 'value_descr'
=> $s_agreement['descr'],
- 'table_add'
=> $table_add,
- 'values'
=> $content,
- 'table_header'
=> $table_header,
- );
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('service agreement') . ': ' . lang('view');
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- function list_attribute()
- {
- $id = get_var('id',array('POST','GET'));
- $resort = get_var('resort',array('POST','GET'));
-
- $GLOBALS['phpgw']->xslttpl->add_file(array(
- 's_agreement',
- 'nextmatchs',
-
'search_field'));
-
- if($resort)
- {
-
$this->bo->resort_attrib(array('resort'=>$resort,'id'=>$id));
- }
-
- $attrib_list = $this->bo->read_attrib();
-
- while (is_array($attrib_list) && list(,$attrib) =
each($attrib_list))
- {
- $content[] = array
- (
- 'name'
=> $attrib['name'],
- 'type_name'
=> $attrib['type_name'],
- 'datatype'
=> $attrib['datatype'],
- 'column_name'
=> $attrib['column_name'],
- 'input_text'
=> $attrib['input_text'],
- 'sorting'
=> $attrib['attrib_sort'],
- 'search'
=> $attrib['search'],
- 'link_up'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.list_attribute&resort=up&id='
. $attrib['id'] . '&allrows=' . $this->allrows . '&role=' . $this->role),
- 'link_down'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.list_attribute&resort=down&id='
. $attrib['id'] . '&allrows=' . $this->allrows . '&role=' . $this->role),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit_attrib&id='
. $attrib['id'] . '&role=' . $this->role),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.delete&id='
. $attrib['id'].'&attrib=true&role=' . $this->role),
- 'lang_view_attribtext' =>
lang('view the attrib'),
- 'lang_attribute_attribtext' =>
lang('attributes for the attrib'). ' ' . lang('location'),
- 'lang_edit_attribtext' =>
lang('edit the attrib'),
- 'lang_delete_attribtext' =>
lang('delete the attrib'),
- 'text_attribute'
=> lang('Attributes'),
- 'text_up'
=> lang('up'),
- 'text_down'
=> lang('down'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
-
- //html_print_r($content);
-
- $table_header[] = array
- (
- 'lang_descr' => lang('Descr'),
- 'lang_datatype' => lang('Datatype'),
- 'lang_sorting' => lang('sorting'),
- 'lang_search' => lang('search'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_sorting' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'attrib_sort',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uis_agreement.list_attribute',
-
'allrows'=>$this->allrows,
-
'role' => $this->role)
-
)),
-
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'column_name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uis_agreement.list_attribute',
-
'allrows'=>$this->allrows,
-
'role' => $this->role)
-
)),
- 'lang_name' => lang('Name'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_attribtext' => lang('add a attrib'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit_attrib&role='
. $this->role),
- 'lang_done' =>
lang('done'),
- 'lang_done_attribtext' => lang('back to
admin'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php'),
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uis_agreement.list_attribute',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'query'
=>$this->query,
- 'role' =>
$this->role
-
- );
-
- $data = array
- (
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($attrib_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_attribtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_attribtext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_attrib' =>
$table_header,
- 'values_attrib'
=> $content,
- 'table_add2'
=> $table_add
- );
-
- $appname
= lang('service agreement');
- $function_msg =
lang('list attribute') . ': ' . lang($this->role);
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
- //$this->save_sessiondata();
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_attribute' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function edit_attrib()
- {
- $id =
get_var('id',array('POST','GET'));
- $values = get_var('values',array('POST'));
- // $GLOBALS['phpgw']->common->msgbox(lang('Altering
ColumnName OR Datatype - deletes your data in this Column'));
- //html_print_r($values);
-
$GLOBALS['phpgw']->xslttpl->add_file(array('s_agreement','choice',));
-
- if ($values['save'])
- {
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
- $type_id =
$values['type_id'];
-
- if (!$values['column_name'])
- {
- $receipt['error'][] =
array('msg'=>lang('Column name not entered!'));
- }
-
- if (!$values['input_text'])
- {
- $receipt['error'][] =
array('msg'=>lang('Input text not entered!'));
- }
- if (!$values['statustext'])
- {
- $receipt['error'][] =
array('msg'=>lang('Statustext not entered!'));
- }
-
- if (!$values['column_info']['type'])
- {
- $receipt['error'][] =
array('msg'=>lang('Datatype type not choosen!'));
- }
-
-
if(!ctype_digit($values['column_info']['precision']))
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter precision as integer !'));
-
unset($values['column_info']['precision']);
- }
-
-
if(!ctype_digit($values['column_info']['scale']))
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter scale as integer !'));
- unset($values['column_info']['scale']);
- }
-
- if (!$values['column_info']['nullable'])
- {
- $receipt['error'][] =
array('msg'=>lang('Nullable not choosen!'));
- }
-
-
- if (!$receipt['error'])
- {
- $receipt =
$this->bo->save_attrib($values,$action);
-
- if(!$id)
- {
- $id=$receipt['id'];
- }
- }
- else
- {
- $receipt['error'][] = array('msg'
=> lang('Attribute has NOT been saved'));
- }
-
- }
-
- if ($id)
- {
- $values = $this->bo->read_single_attrib($id);
- $function_msg = lang('edit attribute') . ': ' .
lang($this->role);
- $action='edit';
- }
- else
- {
- $function_msg = lang('add attribute') . ': ' .
lang($this->role);
- $action='add';
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uis_agreement.edit_attrib',
- 'id' => $id,
- 'role' => $this->role
-
- );
- //html_print_r($values);
-
- if($values['column_info']['type']=='R' ||
$values['column_info']['type']=='CH' || $values['column_info']['type']=='LB')
- {
- $multiple_choice= True;
- }
-
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'lang_choice' =>
lang('Choice'),
- 'lang_new_value' =>
lang('New value'),
- 'lang_new_value_statustext' => lang('New
value for mulitple choice'),
- 'multiple_choice' =>
$multiple_choice,
- 'value_choice' =>
$values['choice'],
- 'lang_delete_value' =>
lang('Delete value'),
- 'lang_value' =>
lang('value'),
- 'lang_delete_choice_statustext'=> lang('Delete
this value from the list of multiple choice'),
- 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.list_attribute&type_id='.$type_id
. '&role=' . $this->role),
- 'lang_id'
=> lang('Attribute ID'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_id'
=> $id,
-
- 'lang_column_name'
=> lang('Column name'),
- 'value_column_name'
=> $values['column_name'],
- 'lang_column_name_statustext' => lang('enter
the name for the column'),
-
- 'lang_input_text'
=> lang('input text'),
- 'value_input_text'
=> $values['input_text'],
- 'lang_input_name_statustext' => lang('enter
the input text for records'),
-
- 'lang_id_attribtext' => lang('Enter
the attribute ID'),
- 'lang_entity_statustext' => lang('Select
a s_agreement type'),
-
- 'lang_statustext' =>
lang('Statustext'),
- 'lang_statustext_attribtext'=> lang('Enter a
statustext for the inputfield in forms'),
- 'value_statustext' =>
$values['statustext'],
-
- 'lang_done_attribtext' => lang('Back
to the list'),
- 'lang_save_attribtext' => lang('Save
the attribute'),
-
- 'lang_datatype' =>
lang('Datatype'),
- 'lang_datatype_statustext' => lang('Select
a datatype'),
- 'lang_no_datatype' =>
lang('No datatype'),
- 'datatype_list' =>
$this->bocommon->select_datatype($values['column_info']['type']),
-
- 'lang_precision' =>
lang('Precision'),
- 'lang_precision_statustext' => lang('enter
the record length'),
- 'value_precision' =>
$values['column_info']['precision'],
-
- 'lang_scale' =>
lang('scale'),
- 'lang_scale_statustext' => lang('enter
the scale if type is decimal'),
- 'value_scale' =>
$values['column_info']['scale'],
-
- 'lang_default' =>
lang('default'),
- 'lang_default_statustext' => lang('enter
the default value'),
- 'value_default' =>
$values['column_info']['default'],
-
- 'lang_nullable' =>
lang('Nullable'),
- 'lang_nullable_statustext' => lang('Chose
if this column is nullable'),
- 'lang_select_nullable' => lang('Select
nullable'),
- 'nullable_list' =>
$this->bocommon->select_nullable($values['column_info']['nullable']),
-
- 'value_list' =>
$values['list'],
- 'lang_list'
=> lang('show in list'),
- 'lang_list_statustext' => lang('check
to show this attribute in location list'),
-
- 'value_search' =>
$values['search'],
- 'lang_include_search' =>
lang('Include in search'),
- 'lang_include_search_statustext'=> lang('check
to show this attribute in location list'),
-
-
- );
- //html_print_r($data);
-
- $appname
= lang('service agreement');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_attrib' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
- }
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage agreement
+ * @version $Id: class.uis_agreement.inc.php,v 1.23 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uis_agreement
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'view' => True,
+ 'edit' => True,
+ 'delete' => True,
+ 'list_attribute'=> True,
+ 'edit_attrib' => True,
+ 'columns' => True,
+ 'edit_item' => True,
+ 'view_item' => True,
+ 'view_file' => True,
+ 'excel' => True
+ );
+
+ function uis_agreement()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $this->bo =
CreateObject($this->currentapp.'.bos_agreement',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+
+ $this->role = $this->bo->role;
+
+ $this->cats =
CreateObject('phpgwapi.categories');
+ $this->cats->app_name = 'fm_vendor';
+
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+ $this->acl2_location= '.s_agreement';
+
+ $this->acl_read =
$this->acl2->check($this->acl2_location,1);
+ $this->acl_add =
$this->acl2->check($this->acl2_location,2);
+ $this->acl_edit =
$this->acl2->check($this->acl2_location,4);
+ $this->acl_delete =
$this->acl2->check($this->acl2_location,8);
+ $this->acl_manage =
$this->acl2->check($this->acl2_location,16);
+
+ $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->vendor_id = $this->bo->vendor_id;
+ $this->allrows = $this->bo->allrows;
+ $this->member_id = $this->bo->member_id;
+ $this->fakebase = $this->bo->fakebase;
+
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' => $this->filter,
+ 'cat_id' => $this->cat_id,
+ 'vendor_id' => $this->vendor_id,
+ 'allrows' => $this->allrows,
+ 'member_id' => $this->member_id
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function columns()
+ {
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('columns'));
+
+ $GLOBALS['phpgw_info']['flags']['noframework'] = True;
+
+ $values =
get_var('values',array('POST','GET'));
+
+ if ($values['save'])
+ {
+
+
$GLOBALS['phpgw']->preferences->account_id=$this->account;
+
$GLOBALS['phpgw']->preferences->read_repository();
+
$GLOBALS['phpgw']->preferences->add($this->currentapp,'s_agreement_columns',$values['columns'],'user');
+
$GLOBALS['phpgw']->preferences->save_repository();
+
+ $receipt['message'][] = array('msg' =>
lang('columns is updated'));
+ }
+
+ $function_msg = lang('Select Column');
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uis_agreement.columns',
+ 'role' => $this->role
+ );
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'column_list' =>
$this->bo->column_list($values['columns'],$allrows=True),
+ 'function_msg' => $function_msg,
+ 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_columns' => lang('columns'),
+ 'lang_none' => lang('None'),
+ 'lang_save' => lang('save'),
+ 'select_name' => 'period'
+ );
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
$function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('columns' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function view_file()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $GLOBALS['phpgw_info']['flags'][noheader] = True;
+ $GLOBALS['phpgw_info']['flags'][nofooter] = True;
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
+
+ $file_name =
urldecode(get_var('file_name',array('POST','GET')));
+ $id = get_var('id',array('POST','GET'));
+
+ $file = $this->fakebase. SEP . 'service_agreement' .
SEP . $id . SEP . $file_name;
+
+ if($this->bo->vfs->file_exists(array(
+ 'string' => $file,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $size =
$this->bo->vfs->get_size(array(
+ 'string' => $file,
+ 'relatives' =>
Array(RELATIVE_NONE),
+ 'checksubdirs' =>
True));
+
+ $document= $this->bo->vfs->read(array(
+ 'string' => $file,
+ 'relatives' => Array(RELATIVE_NONE)));
+
+ $filename =
basename($values['document_name']);
+ $filetype = array_pop(explode('.',
basename($file)));
+ $browser = CreateObject('phpgwapi.browser');
+
$browser->content_header($filename,$filetype,$size);
+
+ echo $document;
+ }
+ }
+
+ function index()
+ {
+ $this->menu->sub = 'agreement';
+
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('s_agreement',
+
'menu',
+
'receipt',
+
'search_field',
+
'nextmatchs',
+
'filter_member_of'));
+
+ $links = $this->menu->links('s_agreement');
+
+ $receipt =
$GLOBALS['phpgw']->session->appsession('session_data','s_agreement_receipt');
+
$GLOBALS['phpgw']->session->appsession('session_data','s_agreement_receipt','');
+
+ $list = $this->bo->read();
+
+ $uicols = $this->bo->uicols;
+
+ $j=0;
+
+ if (isset($list) AND is_array($list))
+ {
+ foreach($list as $entry)
+ {
+ for
($i=0;$i<count($uicols['name']);$i++)
+ {
+
if($uicols['input_type'][$i]!='hidden')
+ {
+
$content[$j]['row'][$i]['value'] =
$entry[$uicols['name'][$i]];
+
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
+ }
+ }
+
+ if($this->acl_read)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('view the
entity');
+ $content[$j]['row'][$i]['text']
= lang('view');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.view&id='
. $entry['id'] .'&role=' . $this->role);
+ }
+ if($this->acl_edit)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('edit the
s_agreement');
+ $content[$j]['row'][$i]['text']
= lang('edit');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit&id='
. $entry['id'] .'&role=' . $this->role);
+ }
+ if($this->acl_delete)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('delete the
s_agreement');
+ $content[$j]['row'][$i]['text']
= lang('delete');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.delete&s_agreement_id='
. $entry['id'] .'&role=' . $this->role);
+ }
+
+ $j++;
+ }
+ }
+
+//html_print_r($content);
+ for ($i=0;$i<count($uicols['descr']);$i++)
+ {
+ if($uicols['input_type'][$i]!='hidden')
+ {
+ $table_header[$i]['header'] =
$uicols['descr'][$i];
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ if($uicols['datatype'][$i]!='T' &&
$uicols['datatype'][$i]!='CH')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+ (
+ 'sort' =>
$this->sort,
+ 'var' =>
$uicols['name'][$i],
+ 'order' =>
$this->order,
+ 'extra'
=> array('menuaction' => $this->currentapp.'.uis_agreement.index',
+
'query' =>$this->query,
+
'lookup' =>$lookup,
+
'district_id' => $this->district_id,
+
'start_date' => $start_date,
+
'role' => $this->role,
+
'member_id' => $this->member_id,
+
'allrows' => $this->allrows,
+
'end_date' => $end_date
+
)
+ ));
+ }
+ }
+ }
+
+ if($this->acl_read)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('view');
+ $i++;
+ }
+ if($this->acl_edit)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('edit');
+ $i++;
+ }
+ if($this->acl_delete)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('delete');
+ $i++;
+ }
+
+
+ if($this->acl_add)
+ {
+ $table_add = array
+ (
+ 'lang_add'
=> lang('add'),
+ 'lang_add_statustext' => lang('add a
s_agreement'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit&role='
. $this->role)
+ );
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uis_agreement.index',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query,
+ 'role' =>
$this->role,
+ 'member_id' =>
$this->member_id
+
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $link_columns = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uis_agreement.columns',
+ 'role' =>
$this->role
+ );
+
+ $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True,link_data => $link_data));
+
+//_debug_array($member_of_data);
+ $data = array
+ (
+ 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
+ 'lang_columns'
=> lang('columns'),
+ 'link_columns'
=> $GLOBALS['phpgw']->link('/index.php',$link_columns),
+ 'lang_columns_help'
=> lang('Choose columns'),
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'links'
=> $links,
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the s_agreement belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $this->bo->select_category_list('filter',$this->cat_id),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+
+ 'lang_no_vendor'
=> lang('no vendor'),
+ 'lang_vendor_statustext' =>
lang('Select the vendor the s_agreement belongs to.'),
+ 'vendor_list'
=> $this->bo->select_vendor_list('filter',$this->vendor_id),
+
+ 'lang_no_member'
=> lang('no member'),
+ 'member_of_name'
=> 'member_id',
+ 'member_of_list'
=> $member_of_data['cat_list'],
+
+ 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter)),
+ 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+ $this->save_sessiondata();
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('service agreement') . ': ' . lang('list ' . $this->role);
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function list_content($list,$uicols,$edit_item='',$view_only='')
+ {
+ $j=0;
+
+ if (isset($list) AND is_array($list))
+ {
+ foreach($list as $entry)
+ {
+ $content[$j]['id']
= $entry['id'];
+ $content[$j]['item_id'] =
$entry['item_id'];
+ $content[$j]['index_count'] =
$entry['index_count'];
+ $content[$j]['cost'] =
$entry['cost'];
+ for
($i=0;$i<count($uicols['name']);$i++)
+ {
+
if($uicols['input_type'][$i]!='hidden')
+ {
+
$content[$j]['row'][$i]['value'] =
$entry[$uicols['name'][$i]];
+
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
+ }
+ }
+
+ if($this->acl_read && !$edit_item &&
!$view_only)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('view the
entity');
+ $content[$j]['row'][$i]['text']
= lang('view');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.view_item&s_agreement_id='
. $entry['agreement_id'] .'&id=' . $entry['id']);
+ }
+ if($this->acl_edit && !$edit_item &&
!$view_only)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('edit the
s_agreement');
+ $content[$j]['row'][$i]['text']
= lang('edit');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit_item&s_agreement_id='
. $entry['agreement_id'] .'&id=' . $entry['id']);
+ }
+ if($this->acl_delete && !$edit_item &&
!$view_only)
+ {
+
$content[$j]['row'][$i]['statustext'] = lang('delete this
item');
+ $content[$j]['row'][$i]['text']
= lang('delete');
+
$content[$j]['row'][$i++]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit&delete_item=1&id='
. $entry['agreement_id'] .'&item_id=' . $entry['id']);
+ }
+
+ $j++;
+ }
+ }
+
+//html_print_r($content);
+ for ($i=0;$i<count($uicols['descr']);$i++)
+ {
+ if($uicols['input_type'][$i]!='hidden')
+ {
+ $table_header[$i]['header'] =
$uicols['descr'][$i];
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ }
+ }
+
+ if($this->acl_read && !$edit_item && !$view_only)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('view');
+ $i++;
+ }
+ if($this->acl_edit && !$edit_item && !$view_only)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('edit');
+ $i++;
+ }
+ if($this->acl_delete && !$edit_item && !$view_only)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('delete');
+ $i++;
+ }
+ if($this->acl_manage && !$edit_item && !$view_only)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('Update');
+ $i++;
+ }
+
+ return
array('content'=>$content,'table_header'=>$table_header);
+ }
+
+
+ function edit()
+ {
+ $id = get_var('id',array('POST','GET'));
+ $values = get_var('values',array('POST'));
+ $delete_item = get_var('delete_item',array('GET'));
+ $item_id = get_var('item_id',array('GET'));
+
+ $config =
CreateObject('phpgwapi.config',$this->currentapp);
+ $boalarm =
CreateObject($this->currentapp.'.boalarm');
+
+ if($delete_item && $id && $item_id)
+ {
+ $this->bo->delete_item($id,$item_id);
+ }
+
+ $values_attribute =
get_var('values_attribute',array('POST'));
+
+ $insert_record_s_agreement =
$GLOBALS['phpgw']->session->appsession('insert_record_s_agreement',$this->currentapp);
+
+//_debug_array($insert_record_s_agreement);
+ for ($j=0;$j<count($insert_record_s_agreement);$j++)
+ {
+
$insert_record['extra'][$insert_record_s_agreement[$j]] =
$insert_record_s_agreement[$j];
+ }
+
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('s_agreement','attributes_form'));
+
+ if (is_array($values))
+ {
+ while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
+ {
+ if($_POST[$key])
+ {
+ $values['extra'][$column]
= $_POST[$key];
+ }
+ }
+
+//_debug_array($values);
+
+ if ($values['save'] || $values['apply']):
+ {
+ $values['vendor_id'] =
get_var('vendor_id',array('POST'));
+ $values['vendor_name'] =
get_var('vendor_name',array('POST'));
+ $values['b_account_id'] =
get_var('b_account_id',array('POST'));
+ $values['b_account_name'] =
get_var('b_account_name',array('POST'));
+ $values['start_date'] =
get_var('start_date',array('POST'));
+ $values['end_date']
= get_var('end_date',array('POST'));
+ $values['termination_date'] =
get_var('termination_date',array('POST'));
+
+ if(!$values['cat_id'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
+ }
+
+ if(!$values['last_name'])
+ {
+//
$receipt['error'][]=array('msg'=>lang('Please enter a name !'));
+ }
+
+
+ if($id)
+ {
+ $values['s_agreement_id']=$id;
+ $action='edit';
+ }
+ else
+ {
+
$values['s_agreement_id']=$this->bo->request_next_id();
+ }
+
+
$values['file_name']=$_FILES['file']['name'];
+ $to_file = $this->fakebase. SEP .
'service_agreement' . SEP . $values['s_agreement_id'] . SEP .
$values['file_name'];
+
+ if(!$values['document_name_orig'] &&
$this->bo->vfs->file_exists(array(
+ 'string' => $to_file,
+ 'relatives' =>
Array(RELATIVE_NONE)
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('This file already exists !'));
+ }
+
+
+ if(!$receipt['error'])
+ {
+// $values['s_agreement_id']
= $id;
+ $receipt =
$this->bo->create_home_dir($receipt);
+ $receipt =
$this->bo->save($values,$values_attribute,$action);
+ $id =
$receipt['s_agreement_id'];
+ $this->cat_id =
($values['cat_id']?$values['cat_id']:$this->cat_id);
+
+ if($values['file_name'])
+ {
+
$this->bo->create_document_dir($id);
+
$this->bo->vfs->override_acl = 1;
+
+ if(!$this->bo->vfs->cp
(array (
+ 'from' =>
$_FILES['file']['tmp_name'],
+ 'to' =>
$to_file,
+ 'relatives'
=> array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
+ {
+
$receipt['error'][]=array('msg'=>lang('Failed to upload file !'));
+ }
+
$this->bo->vfs->override_acl = 0;
+ }
+
+
+ if ($values['save'])
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','s_agreement_receipt',$receipt);
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.index&role='
. $this->role);
+ }
+ }
+ }
+ elseif($values['update']):
+ {
+ $values['date'] =
get_var('date',array('POST'));
+
+ if(!$values['date'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a date !'));
+ }
+ if(!$values['new_index'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter a index !'));
+ }
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$this->bo->update($values);
+ }
+
+ }
+ elseif($values['delete_alarm'] &&
count($values['alarm'])):
+ {
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$boalarm->delete_alarm('s_agreement',$values['alarm']);
+ }
+
+ }
+ elseif(($values['enable_alarm'] ||
$values['disable_alarm']) && count($values['alarm'])):
+ {
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$boalarm->enable_alarm('s_agreement',$values['alarm'],$values['enable_alarm']);
+ }
+
+ }
+ elseif($values['add_alarm']):
+ {
+ $time =
intval($values['time']['days'])*24*3600 +
+
intval($values['time']['hours'])*3600 +
+
intval($values['time']['mins'])*60;
+
+ if ($time > 0)
+ {
+ $receipt =
$boalarm->add_alarm('s_agreement',$this->bo->read_event(array('s_agreement_id'=>$id)),$time,$values['user_id']);
+ }
+ }
+ elseif (!$values['save'] && !$values['apply']
&& !$values['update']):
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.index&role='
. $this->role);
+ }
+ endif;
+ }
+
+
+ $s_agreement =
$this->bo->read_single(array('s_agreement_id'=>$id));
+
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+ if ($id)
+ {
+ $this->cat_id =
($s_agreement['cat_id']?$s_agreement['cat_id']:$this->cat_id);
+ $this->member_id =
($s_agreement['member_of']?$s_agreement['member_of']:$this->member_id);
+ $list = $this->bo->read_details($id);
+
+ $uicols = $this->bo->uicols;
+ $list =
$this->list_content($list,$uicols);
+ $content = $list['content'];
+ $table_header=$list['table_header'];
+ for ($i=0;
$i<count($list['content'][0]['row']); $i++)
+ {
+ $set_column[]=True;
+ }
+
+ if ($content)
+ {
+ $table_update[] = array
+ (
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle'
=> lang('Select date'),
+ 'calendar_setup'
=> "Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat
. "',button : 'date-trigger'});",
+
+ 'lang_new_index'
=> lang('New index'),
+ 'lang_new_index_statustext'
=> lang('Enter a new index'),
+ 'lang_date_statustext'
=> lang('Select the date for the update'),
+ 'lang_update'
=> lang('Update'),
+ 'lang_update_statustext'
=> lang('update selected investments')
+ );
+ }
+
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uis_agreement.edit',
+ 'id' => $id,
+ 'role' => $this->role
+ );
+
+
+
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
+ 'vendor_id' =>
$s_agreement['vendor_id'],
+ 'vendor_name' =>
$s_agreement['vendor_name']));
+
+
$b_account_data=$this->bocommon->initiate_ui_budget_account_lookup(array(
+ 'b_account_id' =>
$s_agreement['b_account_id'],
+ 'b_account_name' =>
$s_agreement['b_account_name']));
+
+
+ $alarm_data=$this->bocommon->initiate_ui_alarm(array(
+
'acl_location'=>$this->acl2_location,
+ 'alarm_type'=> 's_agreement',
+ 'type' => 'form',
+ 'text' => 'Email
notification',
+ 'times' => $times,
+ 'id' => $id,
+ 'method' => $method,
+ 'data' => $data,
+ 'account_id'=> $account_id
+ ));
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ switch(substr($dateformat,0,1))
+ {
+ case 'M':
+ $dateformat_validate=
"javascript:vDateType='1'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'1')";
+ break;
+ case 'y':
+
$dateformat_validate="javascript:vDateType='2'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'2')";
+ break;
+ case 'D':
+
$dateformat_validate="javascript:vDateType='3'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'3')";
+ break;
+ }
+
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True,link_data => array()));
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add detail'),
+ 'lang_add_standardtext' => lang('add an item to
the details'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit_item&s_agreement_id='
. $id)
+ );
+
+
+ $link_file_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uis_agreement.view_file',
+ 'id' =>$id
+ );
+
+ $config->read_repository();
+ $link_to_files = $config->config_data['files_url'];
+
+ $j = count($s_agreement['files']);
+ for ($i=0;$i<$j;$i++)
+ {
+
$s_agreement['files'][$i]['file_name']=urlencode($s_agreement['files'][$i]['name']);
+ }
+
+ $link_excel = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uis_agreement.excel',
+ 'id'
=>$id
+ );
+
+
+ $data = array
+ (
+
+ 'alarm_data' =>
$alarm_data,
+ 'lang_alarm' =>
lang('Alarm'),
+ 'lang_excel' =>
'excel',
+ 'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
+ 'lang_excel_help' =>
lang('Download table to MS Excel'),
+ 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
+
+ 'fileupload'
=> True,
+ 'link_view_file'
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
+ 'link_to_files'
=> $link_to_files,
+ 'files'
=> $s_agreement['files'],
+ 'lang_files'
=> lang('files'),
+ 'lang_filename'
=> lang('Filename'),
+ 'lang_delete_file'
=> lang('Delete file'),
+ 'lang_view_file_statustext' =>
lang('Klick to view file'),
+ 'lang_delete_file_statustext' => lang('Check
to delete file'),
+ 'lang_upload_file'
=> lang('Upload file'),
+ 'lang_file_statustext' =>
lang('Select file to upload'),
+
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_id'
=> lang('ID'),
+ 'value_s_agreement_id' => $id,
+ 'lang_category'
=> lang('category'),
+ 'lang_save'
=> lang('save'),
+ 'lang_cancel'
=> lang('cancel'),
+ 'lang_apply'
=> lang('apply'),
+ 'value_cat'
=> $s_agreement['cat'],
+ 'lang_apply_statustext' =>
lang('Apply the values'),
+ 'lang_cancel_statustext' =>
lang('Leave the service agreement untouched and return back to the list'),
+ 'lang_save_statustext' =>
lang('Save the s_agreement and return back to the list'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the s_agreement belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'values[cat_id]',
+ 'cat_list'
=> $this->bo->select_category_list('select',$this->cat_id),
+
+ 'lang_member_of'
=> lang('member of'),
+ 'member_of_name'
=> 'member_id',
+ 'member_of_list'
=> $member_of_data['cat_list'],
+
+ 'lang_dateformat'
=> lang(strtolower($dateformat)),
+ 'dateformat_validate' =>
$dateformat_validate,
+ 'onKeyUp'
=> $onKeyUp,
+ 'onBlur'
=> $onBlur,
+ 'dateformat_source'
=> './'.$this->currentapp.'/inc/dateformat.js',
+ 'lang_attributes'
=> lang('Attributes'),
+ 'attributes_header'
=> $attributes_header,
+ 'attributes_values'
=> $s_agreement['attributes'],
+ 'lookup_functions'
=> $s_agreement['lookup_functions'],
+ 'dateformat'
=> $dateformat,
+
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle'
=> lang('Select date'),
+ 'calendar_setup_start' =>
"Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});",
+ 'calendar_setup_end' =>
"Calendar.setup({inputField : 'end_date',ifFormat : '" . $jsDateFormat .
"',button : 'end_date-trigger'});",
+ 'calendar_setup_termination'
=> "Calendar.setup({inputField : 'termination_date',ifFormat : '" .
$jsDateFormat . "',button : 'termination_date-trigger'});",
+
+ 'lang_start_date_statustext' => lang('Select
the estimated end date for the Project'),
+ 'lang_start_date'
=> lang('start date'),
+ 'value_start_date'
=> $s_agreement['start_date'],
+
+ 'lang_end_date_statustext' =>
lang('Select the estimated end date for the Project'),
+ 'lang_end_date'
=> lang('end date'),
+ 'value_end_date'
=> $s_agreement['end_date'],
+
+ 'lang_termination_date_statustext'
=> lang('Select the estimated termination date'),
+ 'lang_termination_date'
=> lang('termination date'),
+ 'value_termination_date'
=> $s_agreement['termination_date'],
+
+ 'vendor_data'
=> $vendor_data,
+ 'b_account_data'
=> $b_account_data,
+ 'lang_name'
=> lang('name'),
+ 'lang_name_statustext' =>
lang('name'),
+ 'value_name'
=> $s_agreement['name'],
+ 'lang_descr'
=> lang('descr'),
+ 'lang_descr_statustext' =>
lang('descr'),
+ 'value_descr'
=> $s_agreement['descr'],
+ 'table_add'
=> $table_add,
+ 'values'
=> $content,
+ 'table_header'
=> $table_header,
+ 'acl_manage'
=> $this->acl_manage,
+ 'table_update'
=> $table_update,
+ 'update_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit&id='
. $id),
+ 'lang_select_all'
=> lang('Select All'),
+ 'img_check'
=>
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
+ 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
+ 'check_all_script'
=> $check_all_script,
+ 'set_column'
=> $set_column,
+
+ );
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('service agreement') . ': ' . ($id?lang('edit') . ' ' .
lang($this->role):lang('add') . ' ' . lang($this->role));
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function excel()
+ {
+ $id = get_var('id',array('POST','GET'));
+ $list = $this->bo->read_details($id);
+ $uicols = $this->bo->uicols;
+
$this->bocommon->excel($list,$uicols['name'],$uicols['descr'],$uicols['input_type']);
+ }
+
+ function edit_item()
+ {
+ $s_agreement_id =
get_var('s_agreement_id',array('POST','GET'));
+ $id = get_var('id',array('POST','GET'));
+ $values = get_var('values',array('POST'));
+ $delete_last = get_var('delete_last',array('GET'));
+ if($delete_last)
+ {
+
$this->bo->delete_last_index($s_agreement_id,$id);
+ }
+
+
+ $bolocation =
CreateObject($this->currentapp.'.bolocation');
+
+ $values_attribute =
get_var('values_attribute',array('POST'));
+
+ $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
+ $insert_record_entity =
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp);
+
+ $insert_record_s_agreement1 =
$GLOBALS['phpgw']->session->appsession('insert_record_s_agreement1',$this->currentapp);
+
+//_debug_array($insert_record_s_agreement1);
+
+ for ($j=0;$j<count($insert_record_entity);$j++)
+ {
+
$insert_record['extra'][$insert_record_entity[$j]] =
$insert_record_entity[$j];
+ }
+
+ for ($j=0;$j<count($insert_record_s_agreement1);$j++)
+ {
+
$insert_record['extra'][$insert_record_s_agreement1[$j]] =
$insert_record_s_agreement1[$j];
+ }
+
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('s_agreement','attributes_form'));
+
+ if (is_array($values))
+ {
+
+ for ($i=0;
$i<count($insert_record['location']); $i++)
+ {
+
if($_POST[$insert_record['location'][$i]])
+ {
+
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
+ }
+ }
+
+ while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
+ {
+ if($_POST[$key])
+ {
+ $values['extra'][$column]
= $_POST[$key];
+ }
+ }
+
+ $values['street_name'] =
$_POST['street_name'];
+ $values['street_number'] =
$_POST['street_number'];
+ $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
+
+//_debug_array($values);
+ if ($values['save'] || $values['apply']):
+ {
+
+ if(!$receipt['error'])
+ {
+ $values['s_agreement_id']
= $s_agreement_id;
+ $values['id'] = $id;
+ $receipt =
$this->bo->save_item($values,$values_attribute);
+ $s_agreement_id =
$receipt['s_agreement_id'];
+ $id =
$receipt['id'];
+ $this->cat_id =
($values['cat_id']?$values['cat_id']:$this->cat_id);
+
+ if ($values['save'])
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','s_agreement_receipt',$receipt);
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit&id='
. $s_agreement_id);
+ }
+ }
+ else
+ {
+ if($values['location'])
+ {
+
$location_code=implode("-", $values['location']);
+
$values['location_data'] =
$bolocation->read_single($location_code,$values['extra']);
+ }
+ if($values['extra']['p_num'])
+ {
+
$values['p'][$values['extra']['p_entity_id']]['p_num']=$values['extra']['p_num'];
+
$values['p'][$values['extra']['p_entity_id']]['p_entity_id']=$values['extra']['p_entity_id'];
+
$values['p'][$values['extra']['p_entity_id']]['p_cat_id']=$values['extra']['p_cat_id'];
+
$values['p'][$values['extra']['p_entity_id']]['p_cat_name']=$_POST['entity_cat_name_'.$values['extra']['p_entity_id']];
+ }
+ }
+ }
+ elseif($values['update']):
+ {
+ $values['date'] =
get_var('date',array('POST'));
+
+ if(!$values['date'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a date !'));
+ }
+ if(!$values['new_index'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter a index !'));
+ }
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$this->bo->update($values);
+ }
+
+ }
+ elseif (!$values['save'] && !$values['apply']
&& !$values['update']):
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit&id='
. $s_agreement_id);
+ }
+ endif;
+ }
+
+ $s_agreement =
$this->bo->read_single(array('s_agreement_id'=>$s_agreement_id));
+ $values =
$this->bo->read_single_item(array('s_agreement_id'=>$s_agreement_id,'id'=>$id));
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uis_agreement.edit_item',
+ 's_agreement_id' => $s_agreement_id,
+ 'id' => $id,
+ 'role' => $this->role
+ );
+
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ switch(substr($dateformat,0,1))
+ {
+ case 'M':
+ $dateformat_validate=
"javascript:vDateType='1'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'1')";
+ break;
+ case 'y':
+
$dateformat_validate="javascript:vDateType='2'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'2')";
+ break;
+ case 'D':
+
$dateformat_validate="javascript:vDateType='3'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'3')";
+ break;
+ }
+
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True,link_data => array()));
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add detail'),
+ 'lang_add_standardtext' => lang('add an item to
the details'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit_item&s_agreement_id='
. $s_agreement_id)
+ );
+
+
+ if($id)
+ {
+ $list =
$this->bo->read_prizing(array('s_agreement_id'=>$s_agreement_id,'item_id'=>$id));
+ }
+
+ $uicols = $this->bo->uicols;
+ $list =
$this->list_content($list,$uicols,$edit_item=True);
+ $content = $list['content'];
+ $table_header=$list['table_header'];
+
+ for ($i=0; $i<count($list['content'][0]['row']); $i++)
+ {
+ $set_column[]=True;
+ }
+//_debug_array($list);
+
+ $table_update[] = array
+ (
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle'
=> lang('Select date'),
+ 'calendar_setup' =>
"Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat .
"',button : 'date-trigger'});",
+
+ 'lang_new_index' =>
lang('New index'),
+ 'lang_new_index_statustext' => lang('Enter
a new index'),
+ 'lang_date_statustext' => lang('Select
the date for the update'),
+ 'lang_update' =>
lang('Update'),
+ 'lang_update_statustext' => lang('update
selected investments')
+ );
+
+
+ $lookup_type='form';
+
+//_debug_array($values);
+ $location_data=$bolocation->initiate_ui_location(array(
+ 'values' =>
$values['location_data'],
+ 'type_id' => -1,
// calculated from location_types
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' =>
False,
+ 'lookup_type' => $lookup_type,
+ 'lookup_entity' =>
$this->bocommon->get_lookup_entity('s_agreement'),
+ 'entity_data' => $values['p']
+ ));
+
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_id'
=> lang('ID'),
+ 'value_id'
=> $values['id'],
+ 'value_s_agreement_id' =>
$s_agreement_id,
+ 'lang_category'
=> lang('category'),
+ 'lang_save'
=> lang('save'),
+ 'lang_cancel'
=> lang('cancel'),
+ 'lang_apply'
=> lang('apply'),
+ 'lang_apply_statustext' =>
lang('Apply the values'),
+ 'lang_cancel_statustext' =>
lang('Leave the service agreement untouched and return back to the list'),
+ 'lang_save_statustext' =>
lang('Save the s_agreement and return back to the list'),
+
+ 'lang_dateformat'
=> lang(strtolower($dateformat)),
+ 'dateformat_validate' =>
$dateformat_validate,
+ 'onKeyUp'
=> $onKeyUp,
+ 'onBlur'
=> $onBlur,
+ 'dateformat_source'
=> './'.$this->currentapp.'/inc/dateformat.js',
+ 'lang_attributes'
=> lang('Attributes'),
+ 'attributes_header'
=> $attributes_header,
+ 'attributes_values'
=> $values['attributes'],
+ 'lookup_functions'
=> $values['lookup_functions'],
+ 'dateformat'
=> $dateformat,
+
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle'
=> lang('Select date'),
+ 'calendar_setup_start' =>
"Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});",
+ 'calendar_setup_end' =>
"Calendar.setup({inputField : 'end_date',ifFormat : '" . $jsDateFormat .
"',button : 'end_date-trigger'});",
+
+ 'lang_agreement'
=> lang('Agreement'),
+ 'agreement_name'
=> $s_agreement['name'],
+
+ 'table_add'
=> $table_add,
+ 'values'
=> $content,
+ 'table_header'
=> $table_header,
+ 'acl_manage'
=> $this->acl_manage,
+ 'table_update'
=> $table_update,
+ 'update_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit_item&s_agreement_id='
. $s_agreement_id . '&id=' . $id),
+ 'lang_select_all'
=> lang('Select All'),
+ 'img_check'
=>
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
+ 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
+ 'location_data'
=> $location_data,
+
+ 'lang_cost'
=> lang('cost'),
+ 'lang_cost_statustext' =>
lang('cost'),
+ 'value_cost'
=> $values['cost'],
+ 'set_column'
=> $set_column,
+ 'lang_delete_last'
=> lang('delete last index'),
+ 'lang_delete_last_statustext' => lang('delete
the last index'),
+ 'delete_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit_item&delete_last=1&s_agreement_id='
. $s_agreement_id . '&id=' . $id),
+
+ );
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('service agreement') . ': ' . ($values['id']?lang('edit item') . ' ' .
$s_agreement['name']:lang('add item') . ' ' . $s_agreement['name']);
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_item' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function view_item()
+ {
+ $s_agreement_id =
get_var('s_agreement_id',array('POST','GET'));
+ $id = get_var('id',array('POST','GET'));
+
+ $bolocation =
CreateObject($this->currentapp.'.bolocation');
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('s_agreement','attributes_view'));
+
+ $s_agreement =
$this->bo->read_single(array('s_agreement_id'=>$s_agreement_id));
+ $values =
$this->bo->read_single_item(array('s_agreement_id'=>$s_agreement_id,'id'=>$id));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uis_agreement.edit',
+ 'id' =>
$s_agreement_id
+ );
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ if($id)
+ {
+ $list =
$this->bo->read_prizing(array('s_agreement_id'=>$s_agreement_id,'item_id'=>$id));
+ }
+
+ $uicols = $this->bo->uicols;
+ $list =
$this->list_content($list,$uicols,$edit_item=True);
+ $content = $list['content'];
+ $table_header=$list['table_header'];
+
+ $lookup_type='view';
+
+ $location_data=$bolocation->initiate_ui_location(array(
+ 'values' =>
$values['location_data'],
+ 'type_id' => -1,
// calculated from location_types
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' =>
False,
+ 'lookup_type' => $lookup_type,
+ 'lookup_entity' =>
$this->bocommon->get_lookup_entity('s_agreement'),
+ 'entity_data' => $values['p']
+ ));
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_id'
=> lang('ID'),
+ 'value_id'
=> $values['id'],
+ 'value_s_agreement_id' =>
$s_agreement_id,
+ 'lang_category'
=> lang('category'),
+ 'lang_cancel'
=> lang('cancel'),
+ 'lang_cancel_statustext' =>
lang('Leave the service agreement untouched and return back to the list'),
+
+ 'lang_dateformat'
=> lang(strtolower($dateformat)),
+ 'attributes_view'
=> $values['attributes'],
+
+ 'lang_agreement'
=> lang('Agreement'),
+ 'agreement_name'
=> $s_agreement['name'],
+
+ 'table_add'
=> $table_add,
+ 'values'
=> $content,
+ 'table_header'
=> $table_header,
+ 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
+ 'location_data'
=> $location_data,
+
+ 'lang_cost'
=> lang('cost'),
+ 'lang_cost_statustext' =>
lang('cost'),
+ 'value_cost'
=> $values['cost'],
+ 'set_column'
=> $set_column,
+ );
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('service agreement') . ': ' . lang('view item') . ' ' .
$s_agreement['name'];
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view_item' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ function delete()
+ {
+ $attrib = get_var('attrib',array('POST','GET'));
+ $id = get_var('id',array('POST','GET'));
+ $s_agreement_id =
get_var('s_agreement_id',array('POST','GET'));
+ $delete = get_var('delete',array('POST'));
+ $confirm = get_var('confirm',array('POST'));
+
+
+ if($attrib)
+ {
+ $function='list_attribute';
+ }
+ else
+ {
+ $function='index';
+ }
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uis_agreement.'.$function,
+ 'role' => $this->role
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($s_agreement_id,$id,$attrib);
+// Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.delete&s_agreement_id='
. $s_agreement_id. '&id=' . $id . '&attrib=' . $attrib . '&role=' .
$this->role),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('service agreement');
+ $function_msg =
lang('delete') . ' ' . lang($this->role);
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+
+ function view()
+ {
+ $s_agreement_id = get_var('id',array('POST','GET'));
+ $config =
CreateObject('phpgwapi.config',$this->currentapp);
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('s_agreement','attributes_view'));
+
+
+ $s_agreement =
$this->bo->read_single(array('s_agreement_id'=>$s_agreement_id));
+
+
+ if ($s_agreement_id)
+ {
+ $this->cat_id =
($s_agreement['cat_id']?$s_agreement['cat_id']:$this->cat_id);
+ $this->member_id =
($s_agreement['member_of']?$s_agreement['member_of']:$this->member_id);
+ $list =
$this->bo->read_details($s_agreement_id);
+ $total_records = count($list);
+
+ $uicols = $this->bo->uicols;
+ $list =
$this->list_content($list,$uicols,$edit_item=False,$view_only=True);
+ $content = $list['content'];
+ $table_header=$list['table_header'];
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uis_agreement.index',
+ 's_agreement_id' => $s_agreement_id,
+ );
+
+
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
+ 'vendor_id' =>
$s_agreement['vendor_id'],
+ 'vendor_name' =>
$s_agreement['vendor_name'],
+ 'type' =>
'view'));
+
+
$b_account_data=$this->bocommon->initiate_ui_budget_account_lookup(array(
+ 'b_account_id' =>
$s_agreement['b_account_id'],
+ 'b_account_name' =>
$s_agreement['b_account_name'],
+ 'type' =>
'view'));
+
+
+ $alarm_data=$this->bocommon->initiate_ui_alarm(array(
+
'acl_location'=>$this->acl2_location,
+ 'alarm_type'=> 's_agreement',
+ 'type' => 'view',
+ 'text' => 'Email
notification',
+ 'times' => $times,
+ 'id' =>
$s_agreement_id,
+ 'method' => $method,
+ 'data' => $data,
+ 'account_id'=> $account_id
+ ));
+
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True,link_data => array()));
+
+ $link_file_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uis_agreement.view_file',
+ 'id'
=>$s_agreement_id
+ );
+
+
+ $config->read_repository();
+ $link_to_files = $config->config_data['files_url'];
+
+ $j = count($s_agreement['files']);
+ for ($i=0;$i<$j;$i++)
+ {
+
$s_agreement['files'][$i]['file_name']=urlencode($s_agreement['files'][$i]['name']);
+ }
+
+
+ $data = array
+ (
+ 'lang_total_records' =>
lang('Total'),
+ 'total_records'
=> $total_records,
+ 'alarm_data'
=> $alarm_data,
+ 'lang_alarm'
=> lang('Alarm'),
+ 'link_view_file'
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
+ 'link_to_files'
=> $link_to_files,
+ 'files'
=> $s_agreement['files'],
+ 'lang_files'
=> lang('files'),
+ 'lang_filename'
=> lang('Filename'),
+ 'lang_view_file_statustext' =>
lang('Klick to view file'),
+
+ 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_id'
=> lang('ID'),
+ 'value_s_agreement_id' =>
$s_agreement_id,
+ 'lang_category'
=> lang('category'),
+ 'lang_save'
=> lang('save'),
+ 'lang_cancel'
=> lang('done'),
+ 'lang_apply'
=> lang('apply'),
+ 'value_cat'
=> $s_agreement['cat'],
+ 'lang_cancel_statustext' =>
lang('return back to the list'),
+ 'cat_list'
=> $this->bo->select_category_list('select',$this->cat_id),
+
+ 'lang_member_of'
=> lang('member of'),
+ 'member_of_name'
=> 'member_id',
+ 'member_of_list'
=> $member_of_data['cat_list'],
+
+ 'lang_dateformat'
=> lang(strtolower($dateformat)),
+ 'attributes_view'
=> $s_agreement['attributes'],
+ 'dateformat'
=> $dateformat,
+
+ 'lang_start_date'
=> lang('start date'),
+ 'value_start_date'
=> $s_agreement['start_date'],
+
+ 'lang_end_date'
=> lang('end date'),
+ 'value_end_date'
=> $s_agreement['end_date'],
+
+ 'lang_termination_date' =>
lang('termination date'),
+ 'value_termination_date' =>
$s_agreement['termination_date'],
+
+ 'vendor_data'
=> $vendor_data,
+ 'b_account_data'
=> $b_account_data,
+ 'lang_name'
=> lang('name'),
+ 'value_name'
=> $s_agreement['name'],
+ 'lang_descr'
=> lang('descr'),
+ 'value_descr'
=> $s_agreement['descr'],
+ 'table_add'
=> $table_add,
+ 'values'
=> $content,
+ 'table_header'
=> $table_header,
+ );
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('service agreement') . ': ' . lang('view');
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ function list_attribute()
+ {
+ $id = get_var('id',array('POST','GET'));
+ $resort = get_var('resort',array('POST','GET'));
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array(
+ 's_agreement',
+ 'nextmatchs',
+
'search_field'));
+
+ if($resort)
+ {
+
$this->bo->resort_attrib(array('resort'=>$resort,'id'=>$id));
+ }
+
+ $attrib_list = $this->bo->read_attrib();
+
+ while (is_array($attrib_list) && list(,$attrib) =
each($attrib_list))
+ {
+ $content[] = array
+ (
+ 'name'
=> $attrib['name'],
+ 'type_name'
=> $attrib['type_name'],
+ 'datatype'
=> $attrib['datatype'],
+ 'column_name'
=> $attrib['column_name'],
+ 'input_text'
=> $attrib['input_text'],
+ 'sorting'
=> $attrib['attrib_sort'],
+ 'search'
=> $attrib['search'],
+ 'link_up'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.list_attribute&resort=up&id='
. $attrib['id'] . '&allrows=' . $this->allrows . '&role=' . $this->role),
+ 'link_down'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.list_attribute&resort=down&id='
. $attrib['id'] . '&allrows=' . $this->allrows . '&role=' . $this->role),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit_attrib&id='
. $attrib['id'] . '&role=' . $this->role),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.delete&id='
. $attrib['id'].'&attrib=true&role=' . $this->role),
+ 'lang_view_attribtext' =>
lang('view the attrib'),
+ 'lang_attribute_attribtext' =>
lang('attributes for the attrib'). ' ' . lang('location'),
+ 'lang_edit_attribtext' =>
lang('edit the attrib'),
+ 'lang_delete_attribtext' =>
lang('delete the attrib'),
+ 'text_attribute'
=> lang('Attributes'),
+ 'text_up'
=> lang('up'),
+ 'text_down'
=> lang('down'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+
+ //html_print_r($content);
+
+ $table_header[] = array
+ (
+ 'lang_descr' => lang('Descr'),
+ 'lang_datatype' => lang('Datatype'),
+ 'lang_sorting' => lang('sorting'),
+ 'lang_search' => lang('search'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_sorting' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'attrib_sort',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uis_agreement.list_attribute',
+
'allrows'=>$this->allrows,
+
'role' => $this->role)
+
)),
+
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'column_name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uis_agreement.list_attribute',
+
'allrows'=>$this->allrows,
+
'role' => $this->role)
+
)),
+ 'lang_name' => lang('Name'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_attribtext' => lang('add a attrib'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit_attrib&role='
. $this->role),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_attribtext' => lang('back to
admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php'),
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uis_agreement.list_attribute',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'query'
=>$this->query,
+ 'role' =>
$this->role
+
+ );
+
+ $data = array
+ (
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($attrib_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_attribtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_attribtext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_attrib' =>
$table_header,
+ 'values_attrib'
=> $content,
+ 'table_add2'
=> $table_add
+ );
+
+ $appname
= lang('service agreement');
+ $function_msg =
lang('list attribute') . ': ' . lang($this->role);
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+ //$this->save_sessiondata();
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_attribute' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function edit_attrib()
+ {
+ $id =
get_var('id',array('POST','GET'));
+ $values = get_var('values',array('POST'));
+ // $GLOBALS['phpgw']->common->msgbox(lang('Altering
ColumnName OR Datatype - deletes your data in this Column'));
+ //html_print_r($values);
+
$GLOBALS['phpgw']->xslttpl->add_file(array('s_agreement','choice',));
+
+ if ($values['save'])
+ {
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+ $type_id =
$values['type_id'];
+
+ if (!$values['column_name'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Column name not entered!'));
+ }
+
+ if (!$values['input_text'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Input text not entered!'));
+ }
+ if (!$values['statustext'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Statustext not entered!'));
+ }
+
+ if (!$values['column_info']['type'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Datatype type not choosen!'));
+ }
+
+
if(!ctype_digit($values['column_info']['precision']))
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter precision as integer !'));
+
unset($values['column_info']['precision']);
+ }
+
+
if(!ctype_digit($values['column_info']['scale']))
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter scale as integer !'));
+ unset($values['column_info']['scale']);
+ }
+
+ if (!$values['column_info']['nullable'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Nullable not choosen!'));
+ }
+
+
+ if (!$receipt['error'])
+ {
+ $receipt =
$this->bo->save_attrib($values,$action);
+
+ if(!$id)
+ {
+ $id=$receipt['id'];
+ }
+ }
+ else
+ {
+ $receipt['error'][] = array('msg'
=> lang('Attribute has NOT been saved'));
+ }
+
+ }
+
+ if ($id)
+ {
+ $values = $this->bo->read_single_attrib($id);
+ $function_msg = lang('edit attribute') . ': ' .
lang($this->role);
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add attribute') . ': ' .
lang($this->role);
+ $action='add';
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uis_agreement.edit_attrib',
+ 'id' => $id,
+ 'role' => $this->role
+
+ );
+ //html_print_r($values);
+
+ if($values['column_info']['type']=='R' ||
$values['column_info']['type']=='CH' || $values['column_info']['type']=='LB')
+ {
+ $multiple_choice= True;
+ }
+
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'lang_choice' =>
lang('Choice'),
+ 'lang_new_value' =>
lang('New value'),
+ 'lang_new_value_statustext' => lang('New
value for mulitple choice'),
+ 'multiple_choice' =>
$multiple_choice,
+ 'value_choice' =>
$values['choice'],
+ 'lang_delete_value' =>
lang('Delete value'),
+ 'lang_value' =>
lang('value'),
+ 'lang_delete_choice_statustext'=> lang('Delete
this value from the list of multiple choice'),
+ 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.list_attribute&type_id='.$type_id
. '&role=' . $this->role),
+ 'lang_id'
=> lang('Attribute ID'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id'
=> $id,
+
+ 'lang_column_name'
=> lang('Column name'),
+ 'value_column_name'
=> $values['column_name'],
+ 'lang_column_name_statustext' => lang('enter
the name for the column'),
+
+ 'lang_input_text'
=> lang('input text'),
+ 'value_input_text'
=> $values['input_text'],
+ 'lang_input_name_statustext' => lang('enter
the input text for records'),
+
+ 'lang_id_attribtext' => lang('Enter
the attribute ID'),
+ 'lang_entity_statustext' => lang('Select
a s_agreement type'),
+
+ 'lang_statustext' =>
lang('Statustext'),
+ 'lang_statustext_attribtext'=> lang('Enter a
statustext for the inputfield in forms'),
+ 'value_statustext' =>
$values['statustext'],
+
+ 'lang_done_attribtext' => lang('Back
to the list'),
+ 'lang_save_attribtext' => lang('Save
the attribute'),
+
+ 'lang_datatype' =>
lang('Datatype'),
+ 'lang_datatype_statustext' => lang('Select
a datatype'),
+ 'lang_no_datatype' =>
lang('No datatype'),
+ 'datatype_list' =>
$this->bocommon->select_datatype($values['column_info']['type']),
+
+ 'lang_precision' =>
lang('Precision'),
+ 'lang_precision_statustext' => lang('enter
the record length'),
+ 'value_precision' =>
$values['column_info']['precision'],
+
+ 'lang_scale' =>
lang('scale'),
+ 'lang_scale_statustext' => lang('enter
the scale if type is decimal'),
+ 'value_scale' =>
$values['column_info']['scale'],
+
+ 'lang_default' =>
lang('default'),
+ 'lang_default_statustext' => lang('enter
the default value'),
+ 'value_default' =>
$values['column_info']['default'],
+
+ 'lang_nullable' =>
lang('Nullable'),
+ 'lang_nullable_statustext' => lang('Chose
if this column is nullable'),
+ 'lang_select_nullable' => lang('Select
nullable'),
+ 'nullable_list' =>
$this->bocommon->select_nullable($values['column_info']['nullable']),
+
+ 'value_list' =>
$values['list'],
+ 'lang_list'
=> lang('show in list'),
+ 'lang_list_statustext' => lang('check
to show this attribute in location list'),
+
+ 'value_search' =>
$values['search'],
+ 'lang_include_search' =>
lang('Include in search'),
+ 'lang_include_search_statustext'=> lang('check
to show this attribute in location list'),
+
+
+ );
+ //html_print_r($data);
+
+ $appname
= lang('service agreement');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_attrib' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+ }
?>
\ No newline at end of file
Index: property/inc/class.uistandard_2.inc.php
diff -u property/inc/class.uistandard_2.inc.php:1.8
property/inc/class.uistandard_2.inc.php:1.9
--- property/inc/class.uistandard_2.inc.php:1.8 Thu May 12 21:26:28 2005
+++ property/inc/class.uistandard_2.inc.php Fri Jan 27 14:05:43 2006
@@ -1,277 +1,277 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.uistandard_2.inc.php,v 1.8 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uistandard_2
- {
- var $grants;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'index' => True,
- 'view' => True,
- 'edit' => True,
- 'delete' => True
- );
-
- function uistandard_2()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bo =
CreateObject($this->currentapp.'.bostandard_2',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->start =
$this->bo->start;
- $this->query =
$this->bo->query;
- $this->sort =
$this->bo->sort;
- $this->order =
$this->bo->order;
- $this->allrows =
$this->bo->allrows;
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'allrows' => $this->allrows,
- );
- $this->bo->save_sessiondata($data);
- }
-
- function index()
- {
- $type = get_var('type',array('POST','GET'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('standard_2','nextmatchs',
-
'search_field'));
-
- $standard_list = $this->bo->read($type);
-
- while (is_array($standard_list) && list(,$standard) =
each($standard_list))
- {
- $words = split(' ',$standard['descr']);
- $first = "$words[0] $words[1] $words[2]
$words[3]";
-
- $content[] = array
- (
- 'id'
=> $standard['id'],
- 'first'
=> $first,
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_2.edit&id='
. $standard['id'].'&type='.$type),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_2.delete&id='
. $standard['id'].'&type='.$type),
- 'lang_view_standardtext' =>
lang('view the standard'),
- 'lang_edit_standardtext' =>
lang('edit the standard'),
- 'lang_delete_standardtext' =>
lang('delete the standard'),
- 'text_view'
=> lang('view'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
-
-//_debug_array($content);
-
- $table_header[] = array
- (
-
- 'lang_descr' => lang('Descr'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uistandard_2.index',
-
'type' =>$type)
-
)),
- 'lang_id' => lang('standard id'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_standardtext' => lang('add a
standard'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_2.edit&type='.$type),
- 'lang_done' =>
lang('done'),
- 'lang_done_standardtext' => lang('back
to admin'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php')
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
-
- $data = array
- (
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($standard_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_2.index&type='.$type),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang($type);
- $function_msg =
lang('list '.$type.' standard');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit()
- {
- $type = get_var('type',array('POST','GET'));
- $id = get_var('id',array('POST','GET'));
- $values =
get_var('values',array('POST'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('standard_2'));
-
- if ($values['save'])
- {
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
- else
- {
- $id = $values['id'];
- }
-
-
- $receipt =
$this->bo->save($values,$action,$type);
- }
-
- if ($id)
- {
- $standard = $this->bo->read_single($id,$type);
- $function_msg = lang('edit standard');
- $action='edit';
- }
- else
- {
- $function_msg = lang('add standard');
- $action='add';
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uistandard_2.edit',
- 'id' => $id,
- 'type' => $type
- );
-//_debug_array($link_data);
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_2.index&type='.$type),
- 'lang_id'
=> lang('standard ID'),
- 'lang_name'
=> lang('name'),
- 'lang_descr'
=> lang('Descr'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_id'
=> $id,
- 'value_name'
=> $standard['name'],
- 'value_generaladdress'
=> $standard['general_address'],
- 'lang_id_standardtext'
=> lang('Enter the standard ID'),
- 'lang_descr_standardtext'
=> lang('Enter a description the standard'),
- 'lang_generaladdress_standardtext' =>
lang('Enter the general address'),
- 'lang_done_standardtext'
=> lang('Back to the list'),
- 'lang_save_standardtext'
=> lang('Save the standard'),
- 'type_id'
=> $standard['type_id'],
- 'location_code'
=> $standard['location_code'],
- 'value_descr'
=> $standard['descr']
- );
-
- $appname
= lang($type);
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function delete()
- {
- $type = get_var('type',array('POST','GET'));
- $id = get_var('id',array('POST','GET'));
- $confirm =
get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uistandard_2.index',
- 'type' => $type
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($id,$type);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_2.delete&id='
. $id.'&type='.$type),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_standardtext' => lang('Delete the
entry'),
- 'lang_no_standardtext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang($type);
- $function_msg =
lang('delete '.$type.' standard');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.uistandard_2.inc.php,v 1.9 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uistandard_2
+ {
+ var $grants;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'view' => True,
+ 'edit' => True,
+ 'delete' => True
+ );
+
+ function uistandard_2()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bo =
CreateObject($this->currentapp.'.bostandard_2',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+
+ $this->start =
$this->bo->start;
+ $this->query =
$this->bo->query;
+ $this->sort =
$this->bo->sort;
+ $this->order =
$this->bo->order;
+ $this->allrows =
$this->bo->allrows;
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'allrows' => $this->allrows,
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function index()
+ {
+ $type = get_var('type',array('POST','GET'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('standard_2','nextmatchs',
+
'search_field'));
+
+ $standard_list = $this->bo->read($type);
+
+ while (is_array($standard_list) && list(,$standard) =
each($standard_list))
+ {
+ $words = split(' ',$standard['descr']);
+ $first = "$words[0] $words[1] $words[2]
$words[3]";
+
+ $content[] = array
+ (
+ 'id'
=> $standard['id'],
+ 'first'
=> $first,
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_2.edit&id='
. $standard['id'].'&type='.$type),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_2.delete&id='
. $standard['id'].'&type='.$type),
+ 'lang_view_standardtext' =>
lang('view the standard'),
+ 'lang_edit_standardtext' =>
lang('edit the standard'),
+ 'lang_delete_standardtext' =>
lang('delete the standard'),
+ 'text_view'
=> lang('view'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+
+//_debug_array($content);
+
+ $table_header[] = array
+ (
+
+ 'lang_descr' => lang('Descr'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uistandard_2.index',
+
'type' =>$type)
+
)),
+ 'lang_id' => lang('standard id'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_standardtext' => lang('add a
standard'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_2.edit&type='.$type),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_standardtext' => lang('back
to admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php')
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+
+ $data = array
+ (
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($standard_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_2.index&type='.$type),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang($type);
+ $function_msg =
lang('list '.$type.' standard');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit()
+ {
+ $type = get_var('type',array('POST','GET'));
+ $id = get_var('id',array('POST','GET'));
+ $values =
get_var('values',array('POST'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('standard_2'));
+
+ if ($values['save'])
+ {
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+ else
+ {
+ $id = $values['id'];
+ }
+
+
+ $receipt =
$this->bo->save($values,$action,$type);
+ }
+
+ if ($id)
+ {
+ $standard = $this->bo->read_single($id,$type);
+ $function_msg = lang('edit standard');
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add standard');
+ $action='add';
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uistandard_2.edit',
+ 'id' => $id,
+ 'type' => $type
+ );
+//_debug_array($link_data);
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_2.index&type='.$type),
+ 'lang_id'
=> lang('standard ID'),
+ 'lang_name'
=> lang('name'),
+ 'lang_descr'
=> lang('Descr'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id'
=> $id,
+ 'value_name'
=> $standard['name'],
+ 'value_generaladdress'
=> $standard['general_address'],
+ 'lang_id_standardtext'
=> lang('Enter the standard ID'),
+ 'lang_descr_standardtext'
=> lang('Enter a description the standard'),
+ 'lang_generaladdress_standardtext' =>
lang('Enter the general address'),
+ 'lang_done_standardtext'
=> lang('Back to the list'),
+ 'lang_save_standardtext'
=> lang('Save the standard'),
+ 'type_id'
=> $standard['type_id'],
+ 'location_code'
=> $standard['location_code'],
+ 'value_descr'
=> $standard['descr']
+ );
+
+ $appname
= lang($type);
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function delete()
+ {
+ $type = get_var('type',array('POST','GET'));
+ $id = get_var('id',array('POST','GET'));
+ $confirm =
get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uistandard_2.index',
+ 'type' => $type
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($id,$type);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_2.delete&id='
. $id.'&type='.$type),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_standardtext' => lang('Delete the
entry'),
+ 'lang_no_standardtext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang($type);
+ $function_msg =
lang('delete '.$type.' standard');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ }
+?>
Index: property/inc/class.uistandard_3.inc.php
diff -u property/inc/class.uistandard_3.inc.php:1.8
property/inc/class.uistandard_3.inc.php:1.9
--- property/inc/class.uistandard_3.inc.php:1.8 Thu May 12 21:26:28 2005
+++ property/inc/class.uistandard_3.inc.php Fri Jan 27 14:05:43 2006
@@ -1,276 +1,276 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.uistandard_3.inc.php,v 1.8 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uistandard_3
- {
- var $grants;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'index' => True,
- 'view' => True,
- 'edit' => True,
- 'delete' => True
- );
-
- function uistandard_3()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bo =
CreateObject($this->currentapp.'.bostandard_3',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->start =
$this->bo->start;
- $this->query =
$this->bo->query;
- $this->sort =
$this->bo->sort;
- $this->order =
$this->bo->order;
- $this->allrows =
$this->bo->allrows;
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'allrows' => $this->allrows,
- );
- $this->bo->save_sessiondata($data);
- }
-
- function index()
- {
- $type = get_var('type',array('POST','GET'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('standard_3','nextmatchs',
-
'search_field'));
-
- $standard_list = $this->bo->read($type);
-
- while (is_array($standard_list) && list(,$standard) =
each($standard_list))
- {
- $words = split(' ',$standard['descr']);
- $first = "$words[0] $words[1] $words[2]
$words[3]";
-
- $content[] = array
- (
- 'id'
=> $standard['id'],
- 'num'
=> $standard['num'],
- 'first'
=> $first,
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_3.edit&id='
. $standard['id'].'&type='.$type),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_3.delete&id='
. $standard['id'].'&type='.$type),
- 'lang_view_standardtext' =>
lang('view the standard'),
- 'lang_edit_standardtext' =>
lang('edit the standard'),
- 'lang_delete_standardtext' =>
lang('delete the standard'),
- 'text_view'
=> lang('view'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
-
-//_debug_array($content);
-
- $table_header[] = array
- (
-
- 'lang_descr' => lang('Descr'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uistandard_3.index',
-
'type' =>$type)
-
)),
- 'lang_id' => lang('standard id'),
- 'sort_num' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'num',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uistandard_3.index',
-
'type' =>$type)
-
)),
- 'lang_num' => lang('Name'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_standardtext' => lang('add a
standard'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_3.edit&type='.$type),
- 'lang_done' =>
lang('done'),
- 'lang_done_standardtext' => lang('back
to admin'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php')
- );
-
-
- $data = array
- (
- 'allow_allrows'
=> False,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($standard_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_3.index&type='.$type),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('Standard');
- $function_msg =
lang('list '.$type.' attribute');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit()
- {
- $type = get_var('type',array('POST','GET'));
- $id = get_var('id',array('POST','GET'));
- $values =
get_var('values',array('POST'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('standard_3'));
-
- if ($values['save'])
- {
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
- else
- {
- $id = $values['id'];
- }
-
- $receipt =
$this->bo->save($values,$action,$type);
- }
-
- if ($id)
- {
- $standard = $this->bo->read_single($id,$type);
- $function_msg = lang('edit standard');
- $action='edit';
- }
- else
- {
- $function_msg = lang('add standard');
- $action='add';
- }
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uistandard_3.edit',
- 'id' => $id,
- 'type' => $type
- );
-//_debug_array($link_data);
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_3.index&type='.$type),
- 'lang_id'
=> lang('standard ID'),
- 'lang_num'
=> lang('Name'),
- 'lang_descr'
=> lang('Descr'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_id'
=> $id,
- 'value_num'
=> $standard['num'],
- 'value_generaladdress' =>
$standard['general_address'],
- 'lang_id_standardtext' =>
lang('Enter the standard ID'),
- 'lang_descr_standardtext' =>
lang('Enter a description the standard'),
- 'lang_done_standardtext' =>
lang('Back to the list'),
- 'lang_save_standardtext' =>
lang('Save the standard'),
- 'type_id'
=> $standard['type_id'],
- 'location_code'
=> $standard['location_code'],
- 'value_descr'
=> $standard['descr']
- );
-
- $appname
= lang($type);
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function delete()
- {
- $type = get_var('type',array('POST','GET'));
- $id = get_var('id',array('POST','GET'));
- $confirm =
get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uistandard_3.index',
- 'type' => $type
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($id,$type);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_3.delete&id='
. $id.'&type='.$type),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_standardtext' => lang('Delete the
entry'),
- 'lang_no_standardtext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang($type);
- $function_msg =
lang('delete '.$type.' standard');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.uistandard_3.inc.php,v 1.9 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uistandard_3
+ {
+ var $grants;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'view' => True,
+ 'edit' => True,
+ 'delete' => True
+ );
+
+ function uistandard_3()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bo =
CreateObject($this->currentapp.'.bostandard_3',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+
+ $this->start =
$this->bo->start;
+ $this->query =
$this->bo->query;
+ $this->sort =
$this->bo->sort;
+ $this->order =
$this->bo->order;
+ $this->allrows =
$this->bo->allrows;
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'allrows' => $this->allrows,
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function index()
+ {
+ $type = get_var('type',array('POST','GET'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('standard_3','nextmatchs',
+
'search_field'));
+
+ $standard_list = $this->bo->read($type);
+
+ while (is_array($standard_list) && list(,$standard) =
each($standard_list))
+ {
+ $words = split(' ',$standard['descr']);
+ $first = "$words[0] $words[1] $words[2]
$words[3]";
+
+ $content[] = array
+ (
+ 'id'
=> $standard['id'],
+ 'num'
=> $standard['num'],
+ 'first'
=> $first,
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_3.edit&id='
. $standard['id'].'&type='.$type),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_3.delete&id='
. $standard['id'].'&type='.$type),
+ 'lang_view_standardtext' =>
lang('view the standard'),
+ 'lang_edit_standardtext' =>
lang('edit the standard'),
+ 'lang_delete_standardtext' =>
lang('delete the standard'),
+ 'text_view'
=> lang('view'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+
+//_debug_array($content);
+
+ $table_header[] = array
+ (
+
+ 'lang_descr' => lang('Descr'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uistandard_3.index',
+
'type' =>$type)
+
)),
+ 'lang_id' => lang('standard id'),
+ 'sort_num' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'num',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uistandard_3.index',
+
'type' =>$type)
+
)),
+ 'lang_num' => lang('Name'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_standardtext' => lang('add a
standard'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_3.edit&type='.$type),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_standardtext' => lang('back
to admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php')
+ );
+
+
+ $data = array
+ (
+ 'allow_allrows'
=> False,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($standard_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_3.index&type='.$type),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('Standard');
+ $function_msg =
lang('list '.$type.' attribute');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit()
+ {
+ $type = get_var('type',array('POST','GET'));
+ $id = get_var('id',array('POST','GET'));
+ $values =
get_var('values',array('POST'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('standard_3'));
+
+ if ($values['save'])
+ {
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+ else
+ {
+ $id = $values['id'];
+ }
+
+ $receipt =
$this->bo->save($values,$action,$type);
+ }
+
+ if ($id)
+ {
+ $standard = $this->bo->read_single($id,$type);
+ $function_msg = lang('edit standard');
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add standard');
+ $action='add';
+ }
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uistandard_3.edit',
+ 'id' => $id,
+ 'type' => $type
+ );
+//_debug_array($link_data);
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_3.index&type='.$type),
+ 'lang_id'
=> lang('standard ID'),
+ 'lang_num'
=> lang('Name'),
+ 'lang_descr'
=> lang('Descr'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id'
=> $id,
+ 'value_num'
=> $standard['num'],
+ 'value_generaladdress' =>
$standard['general_address'],
+ 'lang_id_standardtext' =>
lang('Enter the standard ID'),
+ 'lang_descr_standardtext' =>
lang('Enter a description the standard'),
+ 'lang_done_standardtext' =>
lang('Back to the list'),
+ 'lang_save_standardtext' =>
lang('Save the standard'),
+ 'type_id'
=> $standard['type_id'],
+ 'location_code'
=> $standard['location_code'],
+ 'value_descr'
=> $standard['descr']
+ );
+
+ $appname
= lang($type);
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function delete()
+ {
+ $type = get_var('type',array('POST','GET'));
+ $id = get_var('id',array('POST','GET'));
+ $confirm =
get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uistandard_3.index',
+ 'type' => $type
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($id,$type);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_3.delete&id='
. $id.'&type='.$type),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_standardtext' => lang('Delete the
entry'),
+ 'lang_no_standardtext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang($type);
+ $function_msg =
lang('delete '.$type.' standard');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ }
+?>
Index: property/inc/class.uistandard_entity.inc.php
diff -u property/inc/class.uistandard_entity.inc.php:1.8
property/inc/class.uistandard_entity.inc.php:1.9
--- property/inc/class.uistandard_entity.inc.php:1.8 Thu May 12 21:26:28 2005
+++ property/inc/class.uistandard_entity.inc.php Fri Jan 27 14:05:43 2006
@@ -1,519 +1,519 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: class.uistandard_entity.inc.php,v 1.8 2005/05/12
21:26:28 sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uistandard_entity
- {
- var $grants;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'index' => True,
- 'view' => True,
- 'edit' => True,
- 'delete' => True,
- 'list_attribute' => True,
- 'edit_attrib' => True,
- );
-
- function uistandard_entity()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- $this->bo =
CreateObject($this->currentapp.'.bostandard_entity',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
-
- $this->start =
$this->bo->start;
- $this->query =
$this->bo->query;
- $this->sort =
$this->bo->sort;
- $this->order =
$this->bo->order;
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- );
- $this->bo->save_sessiondata($data);
- }
-
- function index()
- {
- $type = get_var('type',array('POST','GET'));
-
- $GLOBALS['phpgw']->xslttpl->add_file(array(
-
'standard_entity',
-
'nextmatchs',
-
'menu',
-
'search_field'));
- $links = $this->menu->links();
-
- $standard_list = $this->bo->read($type);
-
- while (is_array($standard_list) && list(,$standard) =
each($standard_list))
- {
- $words = split(' ',$standard['descr']);
- $first = "$words[0] $words[1] $words[2]
$words[3]";
-
- $content[] = array
- (
- 'id'
=> $standard['id'],
- 'name'
=> $standard['name'],
- 'prefix'
=> $standard['prefix'],
- 'first'
=> $first,
- 'link_attribute'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.list_attribute&type_id='
. $standard['id'].'&type='.$type),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.edit&id='
. $standard['id'].'&type='.$type),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.delete&id='
. $standard['id'].'&type='.$type),
- 'lang_view_standardtext' =>
lang('view the standard'),
- 'lang_attribute_standardtext' =>
lang('attributes for the standard'). ' ' . lang($type),
- 'lang_edit_standardtext' =>
lang('edit the standard'),
- 'lang_delete_standardtext' =>
lang('delete the standard'),
- 'text_attribute'
=> lang('Attributes'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
-
-//_debug_array($content);
-
- $table_header[] = array
- (
-
- 'lang_descr' => lang('Descr'),
- 'lang_prefix' => lang('prefix'),
- 'lang_attribute' => lang('Attributes'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uistandard_entity.index',
-
'type' =>$type)
-
)),
- 'lang_id' => lang('standard id'),
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uistandard_entity.index',
-
'type' =>$type)
-
)),
- 'lang_name' => lang('Name'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_standardtext' => lang('add a
standard'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.edit&type='.$type),
- 'lang_done' =>
lang('done'),
- 'lang_done_standardtext' => lang('back
to admin'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php')
- );
-
-
- $data = array
- (
- 'links'
=> $links,
- 'allow_allrows'
=> False,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($standard_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.index&type='.$type),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang($type);
- $function_msg =
lang('list '.$type.' standard');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit()
- {
- $type = get_var('type',array('POST','GET'));
- $id = get_var('id',array('POST','GET'));
- $values =
get_var('values',array('POST'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('standard_entity'));
-
- if ($values['save'])
- {
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
- else
- {
- // $id =
$values['id'];
- $standard['name'] =
$values['name'];
- $standard['descr'] =
$values['descr'];
- $standard['prefix'] =
$values['prefix'];
- }
-
-
- $receipt =
$this->bo->save($values,$action,$type);
- if(!$id)
- {
- $id=$receipt['id'];
- }
-
- }
-
- if ($id)
- {
- $standard = $this->bo->read_single($id,$type);
- $function_msg = lang('edit standard');
- $action='edit';
- }
- else
- {
- $function_msg = lang('add standard');
- $action='add';
- }
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uistandard_entity.edit',
- 'id' => $id,
- 'type' => $type
- );
-//_debug_array($link_data);
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'lang_prefix'
=> lang('Standard prefix'),
- 'lang_prefix_standardtext' =>
lang('Enter a standard prefix for the id'),
- 'lang_name_standardtext' =>
lang('Enter a name of the standard'),
-
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.index&type='.$type),
- 'lang_id'
=> lang('standard ID'),
- 'lang_name'
=> lang('Name'),
- 'lang_descr'
=> lang('Descr'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_id'
=> $id,
- 'value_name'
=> $standard['name'],
- 'value_prefix'
=> $standard['prefix'],
- 'lang_id_standardtext' =>
lang('Enter the standard ID'),
- 'lang_descr_standardtext' =>
lang('Enter a description of the standard'),
- 'lang_done_standardtext' =>
lang('Back to the list'),
- 'lang_save_standardtext' =>
lang('Save the standard'),
- 'type_id'
=> $standard['type_id'],
- 'value_descr'
=> $standard['descr']
-
-
- );
-
- $appname
= lang($type);
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function delete()
- {
- $attrib = get_var('attrib',array('POST','GET'));
- $type = get_var('type',array('POST','GET'));
- $type_id =
get_var('type_id',array('POST','GET'));
- $id =
get_var('id',array('POST','GET'));
- $confirm = get_var('confirm',array('POST'));
-
- if($attrib)
- {
- $function='list_attribute';
- }
- else
- {
- $function='index';
- }
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uistandard_entity.'.$function,
- 'type' => $type,
- 'type_id' => $type_id
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($id,$type,$attrib);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.delete&id='
. $id.'&type='.$type.'&type_id='.$type_id),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_standardtext' => lang('Delete the
entry'),
- 'lang_no_standardtext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang($type);
- $function_msg =
lang('delete '.$type.' standard');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- function list_attribute()
- {
- $type = get_var('type',array('POST','GET'));
- $type_id =
get_var('type_id',array('POST','GET'));
-
- $GLOBALS['phpgw']->xslttpl->add_file(array(
-
'standard_entity',
-
'nextmatchs',
-
'search_field'));
-
- $attrib_list = $this->bo->read_attrib($type,$type_id);
-
- while (is_array($attrib_list) && list(,$attrib) =
each($attrib_list))
- {
- $words = split(' ',$attrib['descr']);
- $first = "$words[0] $words[1] $words[2]
$words[3]";
-
-
- $content[] = array
- (
- 'name'
=> $attrib['name'],
- 'type_name'
=> $attrib['type_name'],
- 'datatype'
=> $attrib['datatype'],
- 'first'
=> $first,
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.edit_attrib&id='
. $attrib['id'].'&type='.$type.'&type_id='.$type_id),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.delete&id='
. $attrib['id'].'&type='.$type.'&type_id='.$type_id.'&attrib=true'),
- 'lang_view_attribtext' =>
lang('view the attrib'),
- 'lang_attribute_attribtext' =>
lang('attributes for the attrib'). ' ' . lang($type),
- 'lang_edit_attribtext' =>
lang('edit the attrib'),
- 'lang_delete_attribtext' =>
lang('delete the attrib'),
- 'text_attribute'
=> lang('Attributes'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
-
-//_debug_array($content);
-
- $table_header[] = array
- (
- 'lang_type_name' => lang('Type'),
- 'lang_descr' => lang('Descr'),
- 'lang_datatype' => lang('Datatype'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uistandard_entity.list_attribute',
-
'type' =>$type,
-
'type_id'
=>$type_id)
-
)),
- 'lang_name' => lang('Name'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_attribtext' => lang('add a attrib'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.edit_attrib&type='.$type.'&type_id='.$type_id),
- 'lang_done' =>
lang('done'),
- 'lang_done_attribtext' => lang('back to
admin'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.index&type='.$type),
- );
-
-
- $data = array
- (
- 'allow_allrows'
=> False,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($attrib_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.list_attribute&type='.$type
.'&type_id=' . $type_id),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_attribtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_attribtext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_attrib' =>
$table_header,
- 'values_attrib'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('attribute');
- $function_msg =
lang('list '.$type.' attribute');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_attribute' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit_attrib()
- {
- $type_id =
get_var('type_id',array('POST','GET'));
- $type = get_var('type',array('POST','GET'));
- $id =
get_var('id',array('POST','GET'));
- $values = get_var('values',array('POST'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('standard_entity'));
-
- if ($values['save'])
- {
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
- $attrib['name'] = $values['name'];
- $attrib['descr'] = $values['descr'];
- $type_id =
$values['type_id'];
-
- $receipt =
$this->bo->save_attrib($values,$action,$type);
-//_debug_array($receipt);
-
- if(!$id)
- {
- $id=$receipt['id'];
- }
-
- }
-
- if ($id)
- {
- $attrib =
$this->bo->read_single_attrib($id,$type);
- $type_name=$attrib['type_name'];
- $function_msg = lang('edit attribute'). ' ' .
lang($type_name);
- $action='edit';
- }
- else
- {
- $function_msg = lang('add attribute');
- $action='add';
- }
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uistandard_entity.edit_attrib',
- 'id' => $id,
- 'type' => $type
- );
-//_debug_array($link_data);
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- if($attrib['datatype']=='R' ||
$attrib['datatype']=='CH')
- {
- $multiple_choice= True;
- }
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.list_attribute&type='.$type.'&type_id='.$type_id),
- 'lang_id'
=> lang('Attribute ID'),
- 'lang_name'
=> lang('Name'),
- 'lang_descr' =>
lang('Descr'),
- 'lang_entity_type' =>
lang('Type'),
- 'lang_no_entity_type' => lang('No
entity type'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'lang_choice' =>
lang('Choice'),
- 'lang_new_value' =>
lang('New value'),
- 'lang_new_value_statustext' => lang('New
value for mulitple choice'),
- 'multiple_choice' =>
$multiple_choice,
- 'value_choice' =>
$attrib['choice'],
-
- 'lang_delete_value' =>
lang('Delete value'),
- 'lang_value' =>
lang('value'),
- 'lang_delete_choice_statustext'=> lang('Delete
this value from the list of multiple choice'),
- 'value_id'
=> $id,
- 'value_name'
=> $attrib['name'],
- 'lang_id_attribtext' => lang('Enter
the attribute ID'),
- 'lang_entity_statustext' => lang('Select
a entity type'),
- 'lang_descr_attribtext' => lang('Enter
a description the attribute'),
- 'lang_done_attribtext' => lang('Back
to the list'),
- 'lang_save_attribtext' => lang('Save
the attribute'),
- 'type_id'
=> $attrib['type_id'],
- 'value_descr' =>
$attrib['descr'],
- 'entity_list' =>
$this->bo->select_entity_type($type,$type_id),
- 'select_entity_type' =>
'values[type_id]',
- 'lang_datatype' =>
lang('Datatype'),
- 'lang_datatype_statustext' => lang('Select
a datatype'),
- 'lang_no_datatype' =>
lang('No datatype'),
- 'datatype_list' =>
$this->bo->select_datatype($attrib['datatype']),
- 'select_datatype' =>
'values[datatype]',
-// 'value_list' =>
$values['list'],
-// 'lang_list'
=> lang('show in list'),
-// 'lang_list_statustext' => lang('check
to show this attribute in list')
- );
-//_debug_array($data);
-
- $appname
= lang($type);
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_attrib' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: class.uistandard_entity.inc.php,v 1.9 2006/01/27
14:05:43 sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uistandard_entity
+ {
+ var $grants;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'view' => True,
+ 'edit' => True,
+ 'delete' => True,
+ 'list_attribute' => True,
+ 'edit_attrib' => True,
+ );
+
+ function uistandard_entity()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $this->bo =
CreateObject($this->currentapp.'.bostandard_entity',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+
+ $this->start =
$this->bo->start;
+ $this->query =
$this->bo->query;
+ $this->sort =
$this->bo->sort;
+ $this->order =
$this->bo->order;
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function index()
+ {
+ $type = get_var('type',array('POST','GET'));
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array(
+
'standard_entity',
+
'nextmatchs',
+
'menu',
+
'search_field'));
+ $links = $this->menu->links();
+
+ $standard_list = $this->bo->read($type);
+
+ while (is_array($standard_list) && list(,$standard) =
each($standard_list))
+ {
+ $words = split(' ',$standard['descr']);
+ $first = "$words[0] $words[1] $words[2]
$words[3]";
+
+ $content[] = array
+ (
+ 'id'
=> $standard['id'],
+ 'name'
=> $standard['name'],
+ 'prefix'
=> $standard['prefix'],
+ 'first'
=> $first,
+ 'link_attribute'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.list_attribute&type_id='
. $standard['id'].'&type='.$type),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.edit&id='
. $standard['id'].'&type='.$type),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.delete&id='
. $standard['id'].'&type='.$type),
+ 'lang_view_standardtext' =>
lang('view the standard'),
+ 'lang_attribute_standardtext' =>
lang('attributes for the standard'). ' ' . lang($type),
+ 'lang_edit_standardtext' =>
lang('edit the standard'),
+ 'lang_delete_standardtext' =>
lang('delete the standard'),
+ 'text_attribute'
=> lang('Attributes'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+
+//_debug_array($content);
+
+ $table_header[] = array
+ (
+
+ 'lang_descr' => lang('Descr'),
+ 'lang_prefix' => lang('prefix'),
+ 'lang_attribute' => lang('Attributes'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uistandard_entity.index',
+
'type' =>$type)
+
)),
+ 'lang_id' => lang('standard id'),
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uistandard_entity.index',
+
'type' =>$type)
+
)),
+ 'lang_name' => lang('Name'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_standardtext' => lang('add a
standard'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.edit&type='.$type),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_standardtext' => lang('back
to admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php')
+ );
+
+
+ $data = array
+ (
+ 'links'
=> $links,
+ 'allow_allrows'
=> False,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($standard_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.index&type='.$type),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang($type);
+ $function_msg =
lang('list '.$type.' standard');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit()
+ {
+ $type = get_var('type',array('POST','GET'));
+ $id = get_var('id',array('POST','GET'));
+ $values =
get_var('values',array('POST'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('standard_entity'));
+
+ if ($values['save'])
+ {
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+ else
+ {
+ // $id =
$values['id'];
+ $standard['name'] =
$values['name'];
+ $standard['descr'] =
$values['descr'];
+ $standard['prefix'] =
$values['prefix'];
+ }
+
+
+ $receipt =
$this->bo->save($values,$action,$type);
+ if(!$id)
+ {
+ $id=$receipt['id'];
+ }
+
+ }
+
+ if ($id)
+ {
+ $standard = $this->bo->read_single($id,$type);
+ $function_msg = lang('edit standard');
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add standard');
+ $action='add';
+ }
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uistandard_entity.edit',
+ 'id' => $id,
+ 'type' => $type
+ );
+//_debug_array($link_data);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'lang_prefix'
=> lang('Standard prefix'),
+ 'lang_prefix_standardtext' =>
lang('Enter a standard prefix for the id'),
+ 'lang_name_standardtext' =>
lang('Enter a name of the standard'),
+
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.index&type='.$type),
+ 'lang_id'
=> lang('standard ID'),
+ 'lang_name'
=> lang('Name'),
+ 'lang_descr'
=> lang('Descr'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id'
=> $id,
+ 'value_name'
=> $standard['name'],
+ 'value_prefix'
=> $standard['prefix'],
+ 'lang_id_standardtext' =>
lang('Enter the standard ID'),
+ 'lang_descr_standardtext' =>
lang('Enter a description of the standard'),
+ 'lang_done_standardtext' =>
lang('Back to the list'),
+ 'lang_save_standardtext' =>
lang('Save the standard'),
+ 'type_id'
=> $standard['type_id'],
+ 'value_descr'
=> $standard['descr']
+
+
+ );
+
+ $appname
= lang($type);
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function delete()
+ {
+ $attrib = get_var('attrib',array('POST','GET'));
+ $type = get_var('type',array('POST','GET'));
+ $type_id =
get_var('type_id',array('POST','GET'));
+ $id =
get_var('id',array('POST','GET'));
+ $confirm = get_var('confirm',array('POST'));
+
+ if($attrib)
+ {
+ $function='list_attribute';
+ }
+ else
+ {
+ $function='index';
+ }
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uistandard_entity.'.$function,
+ 'type' => $type,
+ 'type_id' => $type_id
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($id,$type,$attrib);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.delete&id='
. $id.'&type='.$type.'&type_id='.$type_id),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_standardtext' => lang('Delete the
entry'),
+ 'lang_no_standardtext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang($type);
+ $function_msg =
lang('delete '.$type.' standard');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ function list_attribute()
+ {
+ $type = get_var('type',array('POST','GET'));
+ $type_id =
get_var('type_id',array('POST','GET'));
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array(
+
'standard_entity',
+
'nextmatchs',
+
'search_field'));
+
+ $attrib_list = $this->bo->read_attrib($type,$type_id);
+
+ while (is_array($attrib_list) && list(,$attrib) =
each($attrib_list))
+ {
+ $words = split(' ',$attrib['descr']);
+ $first = "$words[0] $words[1] $words[2]
$words[3]";
+
+
+ $content[] = array
+ (
+ 'name'
=> $attrib['name'],
+ 'type_name'
=> $attrib['type_name'],
+ 'datatype'
=> $attrib['datatype'],
+ 'first'
=> $first,
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.edit_attrib&id='
. $attrib['id'].'&type='.$type.'&type_id='.$type_id),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.delete&id='
. $attrib['id'].'&type='.$type.'&type_id='.$type_id.'&attrib=true'),
+ 'lang_view_attribtext' =>
lang('view the attrib'),
+ 'lang_attribute_attribtext' =>
lang('attributes for the attrib'). ' ' . lang($type),
+ 'lang_edit_attribtext' =>
lang('edit the attrib'),
+ 'lang_delete_attribtext' =>
lang('delete the attrib'),
+ 'text_attribute'
=> lang('Attributes'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+
+//_debug_array($content);
+
+ $table_header[] = array
+ (
+ 'lang_type_name' => lang('Type'),
+ 'lang_descr' => lang('Descr'),
+ 'lang_datatype' => lang('Datatype'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uistandard_entity.list_attribute',
+
'type' =>$type,
+
'type_id'
=>$type_id)
+
)),
+ 'lang_name' => lang('Name'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_attribtext' => lang('add a attrib'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.edit_attrib&type='.$type.'&type_id='.$type_id),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_attribtext' => lang('back to
admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.index&type='.$type),
+ );
+
+
+ $data = array
+ (
+ 'allow_allrows'
=> False,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($attrib_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.list_attribute&type='.$type
.'&type_id=' . $type_id),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_attribtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_attribtext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_attrib' =>
$table_header,
+ 'values_attrib'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('attribute');
+ $function_msg =
lang('list '.$type.' attribute');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_attribute' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit_attrib()
+ {
+ $type_id =
get_var('type_id',array('POST','GET'));
+ $type = get_var('type',array('POST','GET'));
+ $id =
get_var('id',array('POST','GET'));
+ $values = get_var('values',array('POST'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('standard_entity'));
+
+ if ($values['save'])
+ {
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+ $attrib['name'] = $values['name'];
+ $attrib['descr'] = $values['descr'];
+ $type_id =
$values['type_id'];
+
+ $receipt =
$this->bo->save_attrib($values,$action,$type);
+//_debug_array($receipt);
+
+ if(!$id)
+ {
+ $id=$receipt['id'];
+ }
+
+ }
+
+ if ($id)
+ {
+ $attrib =
$this->bo->read_single_attrib($id,$type);
+ $type_name=$attrib['type_name'];
+ $function_msg = lang('edit attribute'). ' ' .
lang($type_name);
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add attribute');
+ $action='add';
+ }
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uistandard_entity.edit_attrib',
+ 'id' => $id,
+ 'type' => $type
+ );
+//_debug_array($link_data);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ if($attrib['datatype']=='R' ||
$attrib['datatype']=='CH')
+ {
+ $multiple_choice= True;
+ }
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uistandard_entity.list_attribute&type='.$type.'&type_id='.$type_id),
+ 'lang_id'
=> lang('Attribute ID'),
+ 'lang_name'
=> lang('Name'),
+ 'lang_descr' =>
lang('Descr'),
+ 'lang_entity_type' =>
lang('Type'),
+ 'lang_no_entity_type' => lang('No
entity type'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'lang_choice' =>
lang('Choice'),
+ 'lang_new_value' =>
lang('New value'),
+ 'lang_new_value_statustext' => lang('New
value for mulitple choice'),
+ 'multiple_choice' =>
$multiple_choice,
+ 'value_choice' =>
$attrib['choice'],
+
+ 'lang_delete_value' =>
lang('Delete value'),
+ 'lang_value' =>
lang('value'),
+ 'lang_delete_choice_statustext'=> lang('Delete
this value from the list of multiple choice'),
+ 'value_id'
=> $id,
+ 'value_name'
=> $attrib['name'],
+ 'lang_id_attribtext' => lang('Enter
the attribute ID'),
+ 'lang_entity_statustext' => lang('Select
a entity type'),
+ 'lang_descr_attribtext' => lang('Enter
a description the attribute'),
+ 'lang_done_attribtext' => lang('Back
to the list'),
+ 'lang_save_attribtext' => lang('Save
the attribute'),
+ 'type_id'
=> $attrib['type_id'],
+ 'value_descr' =>
$attrib['descr'],
+ 'entity_list' =>
$this->bo->select_entity_type($type,$type_id),
+ 'select_entity_type' =>
'values[type_id]',
+ 'lang_datatype' =>
lang('Datatype'),
+ 'lang_datatype_statustext' => lang('Select
a datatype'),
+ 'lang_no_datatype' =>
lang('No datatype'),
+ 'datatype_list' =>
$this->bo->select_datatype($attrib['datatype']),
+ 'select_datatype' =>
'values[datatype]',
+// 'value_list' =>
$values['list'],
+// 'lang_list'
=> lang('show in list'),
+// 'lang_list_statustext' => lang('check
to show this attribute in list')
+ );
+//_debug_array($data);
+
+ $appname
= lang($type);
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_attrib' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ }
+?>
Index: property/inc/class.uitemplate.inc.php
diff -u property/inc/class.uitemplate.inc.php:1.8
property/inc/class.uitemplate.inc.php:1.9
--- property/inc/class.uitemplate.inc.php:1.8 Thu May 12 21:26:28 2005
+++ property/inc/class.uitemplate.inc.php Fri Jan 27 14:05:43 2006
@@ -1,734 +1,734 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage project
- * @version $Id: class.uitemplate.inc.php,v 1.8 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uitemplate
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
- var $currentapp;
-
- var $public_functions = array
- (
- 'index' => True,
- 'view' => True,
- 'edit_template' => True,
- 'edit_hour' => True,
- 'delete' => True,
- 'hour' => True
- );
-
- function uitemplate()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->bo =
CreateObject($this->currentapp.'.botemplate',True);
- $this->bowo_hour =
CreateObject($this->currentapp.'.bowo_hour');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
-
- $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->chapter_id =
$this->bo->chapter_id;
- $this->allrows =
$this->bo->allrows;
-
- $this->menu->sub ='project';
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' =>
$this->filter,
- 'cat_id' =>
$this->cat_id,
- 'chapter_id' => $this->chapter_id,
- 'allrows' =>
$this->allrows
- );
- $this->bo->save_sessiondata($data);
- }
-
- function index()
- {
- $GLOBALS['phpgw']->xslttpl->add_file(array('template',
-
'menu',
-
'nextmatchs',
-
'search_field'));
-
- $workorder_id =
get_var('workorder_id',array('POST','GET'));
- $lookup = get_var('lookup',array('POST','GET'));
-
- $links = $this->menu->links('template');
-
- $template_list = $this->bo->read();
-
- while (is_array($template_list) && list(,$template) =
each($template_list))
- {
- $content_template[] = array
- (
- 'workorder_id' =>
$workorder_id,
- 'template_id' =>
$template['template_id'],
- 'name'
=> $template['name'],
- 'descr'
=> $template['descr'],
- 'owner'
=> $template['owner'],
- 'entry_date' =>
$template['entry_date'],
- 'chapter'
=> $template['chapter'],
- 'lang_select' =>
lang('Select'),
- 'form_action_select' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.template'),
- 'lang_select_statustext' =>
lang('Select this template to view the details'),
- 'link_view'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.hour&template_id='
. $template['template_id']),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.edit_template&template_id='
. $template['template_id']),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.delete&id='
. $template['template_id']),
- 'lang_view_statustext' =>
lang('view the template'),
- 'lang_edit_statustext' =>
lang('edit the template'),
- 'lang_delete_statustext' =>
lang('delete the template'),
- 'text_view'
=> lang('view'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
-
- $i++;
- }
-
- $table_header_template[] = array
- (
-
- 'sort_template_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'fm_template.id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uitemplate.index',
-
'chapter_id'
=>$this->chapter_id,
-
'query'
=>$this->query,
-
'workorder_id'
=>$workorder_id,
-
'allrows'
=>$this->allrows)
-
)),
- 'lang_template_id' =>
lang('ID'),
- 'lang_name' => lang('Name'),
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uitemplate.index',
-
'chapter_id'
=>$this->chapter_id,
-
'query'
=>$this->query,
-
'workorder_id'
=>$workorder_id,
-
'allrows'
=>$this->allrows)
-
)),
- 'lang_name' => lang('Name'),
- 'lang_chapter' => lang('Chapter'),
- 'lang_owner' => lang('owner'),
- 'lang_entry_date' => lang('Entry Date'),
- 'lang_descr' => lang('Description'),
- 'lang_view' => lang('view'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'lang_select' => lang('select')
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uitemplate.index',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'chapter_id'
=>$this->chapter_id,
- 'workorder_id' =>$workorder_id,
- 'query'
=>$this->query
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_statustext' => lang('add a
template'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.edit_template')
- );
-
- $table_done[] = array
- (
- 'lang_done' =>
lang('Done'),
- 'lang_done_statustext' => lang('Back to list'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index&workorder_id='
. $workorder_id)
- );
-
- $data = array
- (
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_add_statustext' =>
lang('Add the selected items'),
- 'lang_add'
=> lang('Add'),
- 'link_delete'
=> $GLOBALS['phpgw']->link('/index.php',$link_data_delete),
-
- 'chapter_list'
=> $this->bowo_hour->get_chapter_list('filter',$this->chapter_id),
- 'select_chapter'
=> 'chapter_id',
- 'lang_no_chapter'
=> lang('Select chapter'),
- 'lang_chapter_statustext' =>
lang('Select the template-chapter'),
-
- 'lookup'
=> $lookup,
- 'function'
=> 'template',
- 'links'
=> $links,
- 'allrows'
=> $this->allrows,
- 'allow_allrows'
=> true,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($template_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
-
- 'lang_user_statustext' =>
lang('Select the user the template belongs to. To do not use a category select
NO USER'),
- 'select_user_name'
=> 'filter',
- 'lang_no_user'
=> lang('No user'),
- 'user_list'
=>
$this->bocommon->get_user_list('filter',$this->filter,$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
-
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_template' =>
$table_header_template,
- 'values_template'
=> $content_template,
- 'table_add'
=> $table_add,
- 'table_done'
=> $table_done
- );
-
- $appname
= lang('template');
- $function_msg =
lang('list template');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function hour()
- {
- $GLOBALS['phpgw']->xslttpl->add_file(array('template',
-
'menu',
-
'nextmatchs',
-
'search_field'));
-
- $delete = get_var('delete',array('POST','GET'));
- $hour_id = get_var('hour_id',array('POST','GET'));
-
- $template_id =
get_var('template_id',array('POST','GET'));
-
- if($delete && $hour_id)
- {
- $receipt =
$this->bo->delete_hour($hour_id,$template_id);
- }
-
- $links = $this->menu->links();
-
- $template_list =
$this->bo->read_template_hour($template_id);
-
- $i=0;
- $grouping_descr_old='';
-
- while (is_array($template_list) && list(,$template) =
each($template_list))
- {
-
-
if($template['grouping_descr']!=$grouping_descr_old)
- {
- $new_grouping = true;
- }
- else
- {
- $new_grouping = false;
- }
-
- $grouping_descr_old =
$template['grouping_descr'];
-
- if($template['activity_num'])
- {
- $code = $template['activity_num'];
- }
- else
- {
- $code =
str_replace("-",$template['tolerance'],$template['ns3420_id']);
- }
-
-
- $content[] = array
- (
- 'counter'
=> $i,
- 'record'
=> $template['record'],
- 'chapter_id' =>
$template['chapter_id'],
- 'grouping_descr' =>
$template['grouping_descr'],
- 'building_part' =>
$template['building_part'],
- 'new_grouping' =>
$new_grouping,
- 'code'
=> $code,
- 'activity_id' =>
$template['activity_id'],
- 'activity_num' =>
$template['activity_num'],
- 'hours_descr' =>
$template['hours_descr'],
- 'remark'
=> $template['remark'],
- 'ns3420_id'
=> $template['ns3420_id'],
- 'tolerance'
=> $template['tolerance'],
- 'cost'
=> $template['cost'],
- 'unit'
=> $template['unit'],
- 'billperae'
=> $template['billperae'],
- 'building_part' =>
$template['building_part'],
- 'dim_d'
=> $template['dim_d'],
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.edit_hour&hour_id='
. $template['hour_id'] . '&template_id=' . $template_id),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.hour&delete=true&template_id='
. $template_id . '&hour_id=' . $template['hour_id']),
- 'lang_edit_statustext' =>
lang('edit the template'),
- 'lang_delete_statustext' =>
lang('delete the template'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
-
- $i++;
- }
-
- $table_header[] = array
- (
- 'lang_record' => lang('Record'),
- 'lang_code' => lang('Code'),
- 'lang_descr' => lang('Description'),
- 'lang_unit' => lang('Unit'),
- 'lang_quantity' => lang('Quantity'),
- 'lang_billperae' => lang('Bill per
unit'),
- 'lang_cost' => lang('Cost'),
-
- 'sort_billperae' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'billperae',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uitemplate.hour',
-
'workorder_id'
=>$workorder_id,
-
'template_id'
=>$template_id,
-
'query'
=>$this->query,
-
'allrows'
=>$this->allrows)
-
)),
- 'lang_select' => lang('Select'),
- 'sort_building_part' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'building_part',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uitemplate.hour',
-
'workorder_id'
=>$workorder_id,
-
'template_id'
=>$template_id,
-
'query'
=>$this->query,
-
'allrows'
=>$this->allrows)
-
)),
- 'lang_building_part' =>
lang('Building part'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete')
- );
-
-
- $table_done[] = array
- (
- 'lang_done' =>
lang('Done'),
- 'lang_done_statustext' => lang('Back to list'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.index')
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uitemplate.hour',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'workorder_id' =>$workorder_id,
- 'template_id' =>$template_id,
- 'allrows'
=>$this->allrows,
- 'query'
=>$this->query
- );
-
- $link_data_nextmatch = array
- (
- 'menuaction' =>
$this->currentapp.'.uitemplate.hour',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'workorder_id' =>$workorder_id,
- 'template_id' =>$template_id,
- 'query'
=>$this->query
- );
-
- $link_data_delete = array
- (
- 'menuaction' =>
$this->currentapp.'.uitemplate.hour',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'workorder_id' =>$workorder_id,
- 'allrows'
=>$this->allrows,
- 'delete' =>true,
- 'query'
=>$this->query
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_statustext' => lang('add a hour'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.edit_hour&template_id='
. $template_id)
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_add_statustext' =>
lang('Add the selected items'),
- 'lang_add'
=> lang('Add'),
- 'link_delete'
=> $GLOBALS['phpgw']->link('/index.php',$link_data_delete),
-
- 'function'
=> 'template',
- 'links'
=> $links,
- 'allrows'
=> $this->allrows,
- 'allow_allrows'
=> true,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($template_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data_nextmatch),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
-
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'workorder_data'
=> $common_data['workorder_data'],
- 'table_header_template_hour' =>
$table_header,
- 'values_template_hour' =>
$content,
- 'table_add'
=> $table_add,
- 'table_done'
=> $table_done
- );
- $appname
= lang('template');
- $function_msg =
lang('view template detail');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_template_hour' =>
$data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit_template()
- {
- $template_id =
get_var('template_id',array('POST','GET'));
- $values =
get_var('values',array('POST','GET'));
-
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('template'));
-
- if ($values['save'])
- {
- $values['template_id'] = $template_id;
-
- if(!$receipt['error'])
- {
- $receipt =
$this->bo->save_template($values);
-
- $template_id=$receipt['template_id'];
- }
- }
-
- if ($template_id)
- {
- $values =
$this->bo->read_single_template($template_id);
- $function_msg = lang('Edit template');
- }
- else
- {
- $function_msg = lang('Add template');
- }
-
- if($error_id)
- {
- unset($values['template_id']);
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uitemplate.edit_template',
- 'template_id' => $template_id
- );
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.index&template_id='
. $template_id),
-
- 'lang_template_id'
=> lang('Template ID'),
- 'value_template_id'
=> $template_id,
-
- 'lang_name'
=> lang('Name'),
- 'value_name'
=> $values['name'],
-
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'lang_descr'
=> lang('description'),
- 'value_descr'
=> $values['descr'],
- 'lang_descr_statustext' =>
lang('Enter the description for this template'),
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'lang_save_statustext' =>
lang('Save the building'),
-
- 'lang_remark'
=> lang('Remark'),
- 'value_remark'
=> $values['remark'],
- 'lang_remark_statustext' =>
lang('Enter additional remarks to the description - if any'),
-
- 'lang_chapter'
=> lang('chapter'),
- 'chapter_list'
=> $this->bowo_hour->get_chapter_list('select',$values['chapter_id']),
- 'select_chapter'
=> 'values[chapter_id]',
- 'lang_no_chapter'
=> lang('Select chapter'),
- 'lang_chapter_statustext' =>
lang('Select the chapter (for tender) for this activity.'),
- 'lang_add'
=> lang('add a hour'),
- 'lang_add_statustext' =>
lang('add a hour to this template'),
- 'add_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.edit_hour&template_id='
. $template_id)
- );
-
- $appname
= lang('Workorder template');
- $function_msg =
lang('view ticket detail');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_template' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function edit_hour()
- {
- $template_id =
get_var('template_id',array('POST','GET'));
- $activity_id =
get_var('activity_id',array('POST','GET'));
- $hour_id =
get_var('hour_id',array('POST','GET'));
- $values =
get_var('values',array('POST','GET'));
- $values['ns3420_id'] =
get_var('ns3420_id',array('POST','GET'));
- $values['ns3420_descr'] =
get_var('ns3420_descr',array('POST','GET'));
-
- $bopricebook =
CreateObject($this->currentapp.'.bopricebook');
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('template'));
-
- if ($values['save'])
- {
- if($values['copy_hour'])
- {
- unset($hour_id);
- }
-
- $values['hour_id'] = $hour_id;
-
- if(!$receipt['error'])
- {
- $receipt =
$this->bo->save_hour($values,$template_id);
-
- $hour_id=$receipt['hour_id'];
- }
- }
-
- if ($hour_id)
- {
- $values = $this->bo->read_single_hour($hour_id);
- $function_msg = lang('Edit hour');
- }
- else
- {
- $function_msg = lang('Add hour');
- }
-
- $template =
$this->bo->read_single_template($template_id);
-
- if($error_id)
- {
- unset($values['hour_id']);
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uitemplate.edit_hour',
- 'template_id' => $template_id,
- 'hour_id' => $hour_id
- );
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.hour&template_id='
. $template_id),
- 'lang_template'
=> lang('template'),
- 'value_template_id'
=> $template['template_id'],
- 'value_template_name' =>
$template['name'],
-
- 'lang_hour_id'
=> lang('Hour ID'),
- 'value_hour_id'
=> $hour_id,
-
- 'lang_copy_hour' =>
lang('Copy hour ?'),
- 'lang_copy_hour_statustext' => lang('Choose
Copy Hour to copy this hour to a new hour'),
-
- 'lang_activity_num'
=> lang('Activity code'),
- 'value_activity_num' =>
$values['activity_num'],
- 'value_activity_id'
=> $values['activity_id'],
-
- 'lang_unit'
=> lang('Unit'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'lang_descr'
=> lang('description'),
- 'value_descr'
=> $values['hours_descr'],
- 'lang_descr_statustext' =>
lang('Enter the description for this activity'),
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'lang_save_statustext' =>
lang('Save the building'),
-
- 'lang_remark'
=> lang('Remark'),
- 'value_remark'
=> $values['remark'],
- 'lang_remark_statustext' =>
lang('Enter additional remarks to the description - if any'),
-
- 'lang_quantity'
=> lang('quantity'),
- 'value_quantity'
=> $values['quantity'],
- 'lang_quantity_statustext' =>
lang('Enter quantity of unit'),
-
- 'lang_billperae'
=> lang('Cost per unit'),
- 'value_billperae'
=> $values['billperae'],
- 'lang_billperae_statustext' =>
lang('Enter the cost per unit'),
-
- 'lang_total_cost'
=> lang('Total cost'),
- 'value_total_cost'
=> $values['cost'],
- 'lang_total_cost_statustext' => lang('Enter
the total cost of this activity - if not to be calculated from unit-cost'),
-
- 'lang_dim_d'
=> lang('Dim D'),
- 'dim_d_list'
=> $bopricebook->get_dim_d_list($values['dim_d']),
- 'select_dim_d'
=> 'values[dim_d]',
- 'lang_no_dim_d'
=> lang('No Dim D'),
- 'lang_dim_d_statustext' =>
lang('Select the Dim D for this activity. To do not use Dim D - select NO DIM
D'),
-
- 'lang_unit'
=> lang('Unit'),
- 'unit_list'
=> $bopricebook->get_unit_list($values['unit']),
- 'select_unit'
=> 'values[unit]',
- 'lang_no_unit'
=> lang('Select Unit'),
- 'lang_unit_statustext' =>
lang('Select the unit for this activity.'),
-
- 'lang_chapter'
=> lang('chapter'),
- 'chapter_list'
=> $this->bowo_hour->get_chapter_list('select',$template['chapter_id']),
- 'select_chapter'
=> 'values[chapter_id]',
- 'lang_no_chapter'
=> lang('Select chapter'),
- 'lang_chapter_statustext' =>
lang('Select the chapter (for tender) for this activity.'),
-
- 'lang_tolerance'
=> lang('tolerance'),
- 'tolerance_list'
=> $this->bowo_hour->get_tolerance_list($values['tolerance_id']),
- 'select_tolerance'
=> 'values[tolerance_id]',
- 'lang_no_tolerance'
=> lang('Select tolerance'),
- 'lang_tolerance_statustext' =>
lang('Select the tolerance for this activity.'),
-
- 'lang_grouping'
=> lang('grouping'),
- 'grouping_list'
=> $this->bo->get_grouping_list($values['grouping_id'],$template_id),
- 'select_grouping'
=> 'values[grouping_id]',
- 'lang_no_grouping'
=> lang('Select grouping'),
- 'lang_grouping_statustext' =>
lang('Select the grouping for this activity.'),
-
- 'lang_new_grouping'
=> lang('New grouping'),
- 'lang_new_grouping_statustext' =>
lang('Enter a new grouping for this activity if not found in the list'),
-
- 'lang_building_part'
=> lang('building_part'),
- 'building_part_list'
=> $this->bowo_hour->get_building_part_list($values['building_part_id']),
- 'select_building_part'
=> 'values[building_part_id]',
- 'lang_no_building_part'
=> lang('Select building part'),
- 'lang_building_part_statustext' =>
lang('Select the building part for this activity.'),
-
-
- 'ns3420_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.ns3420'),
- 'lang_ns3420'
=> lang('NS3420'),
- 'value_ns3420_id'
=> $values['ns3420_id'],
- 'lang_ns3420_statustext' =>
lang('Select a standard-code from the norwegian standard'),
- 'currency'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['currency']
-
- );
-
- $appname
= lang('Workorder template');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_hour' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function delete()
- {
- $id = get_var('id',array('POST','GET'));
- $confirm = get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uitemplate.index'
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($id);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.delete&id='
. $id),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('Workorder template');
- $function_msg =
lang('delete template');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage project
+ * @version $Id: class.uitemplate.inc.php,v 1.9 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uitemplate
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'view' => True,
+ 'edit_template' => True,
+ 'edit_hour' => True,
+ 'delete' => True,
+ 'hour' => True
+ );
+
+ function uitemplate()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->bo =
CreateObject($this->currentapp.'.botemplate',True);
+ $this->bowo_hour =
CreateObject($this->currentapp.'.bowo_hour');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+
+ $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->chapter_id =
$this->bo->chapter_id;
+ $this->allrows =
$this->bo->allrows;
+
+ $this->menu->sub ='project';
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' =>
$this->filter,
+ 'cat_id' =>
$this->cat_id,
+ 'chapter_id' => $this->chapter_id,
+ 'allrows' =>
$this->allrows
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function index()
+ {
+ $GLOBALS['phpgw']->xslttpl->add_file(array('template',
+
'menu',
+
'nextmatchs',
+
'search_field'));
+
+ $workorder_id =
get_var('workorder_id',array('POST','GET'));
+ $lookup = get_var('lookup',array('POST','GET'));
+
+ $links = $this->menu->links('template');
+
+ $template_list = $this->bo->read();
+
+ while (is_array($template_list) && list(,$template) =
each($template_list))
+ {
+ $content_template[] = array
+ (
+ 'workorder_id' =>
$workorder_id,
+ 'template_id' =>
$template['template_id'],
+ 'name'
=> $template['name'],
+ 'descr'
=> $template['descr'],
+ 'owner'
=> $template['owner'],
+ 'entry_date' =>
$template['entry_date'],
+ 'chapter'
=> $template['chapter'],
+ 'lang_select' =>
lang('Select'),
+ 'form_action_select' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.template'),
+ 'lang_select_statustext' =>
lang('Select this template to view the details'),
+ 'link_view'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.hour&template_id='
. $template['template_id']),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.edit_template&template_id='
. $template['template_id']),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.delete&id='
. $template['template_id']),
+ 'lang_view_statustext' =>
lang('view the template'),
+ 'lang_edit_statustext' =>
lang('edit the template'),
+ 'lang_delete_statustext' =>
lang('delete the template'),
+ 'text_view'
=> lang('view'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+
+ $i++;
+ }
+
+ $table_header_template[] = array
+ (
+
+ 'sort_template_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'fm_template.id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uitemplate.index',
+
'chapter_id'
=>$this->chapter_id,
+
'query'
=>$this->query,
+
'workorder_id'
=>$workorder_id,
+
'allrows'
=>$this->allrows)
+
)),
+ 'lang_template_id' =>
lang('ID'),
+ 'lang_name' => lang('Name'),
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uitemplate.index',
+
'chapter_id'
=>$this->chapter_id,
+
'query'
=>$this->query,
+
'workorder_id'
=>$workorder_id,
+
'allrows'
=>$this->allrows)
+
)),
+ 'lang_name' => lang('Name'),
+ 'lang_chapter' => lang('Chapter'),
+ 'lang_owner' => lang('owner'),
+ 'lang_entry_date' => lang('Entry Date'),
+ 'lang_descr' => lang('Description'),
+ 'lang_view' => lang('view'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'lang_select' => lang('select')
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uitemplate.index',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'chapter_id'
=>$this->chapter_id,
+ 'workorder_id' =>$workorder_id,
+ 'query'
=>$this->query
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_statustext' => lang('add a
template'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.edit_template')
+ );
+
+ $table_done[] = array
+ (
+ 'lang_done' =>
lang('Done'),
+ 'lang_done_statustext' => lang('Back to list'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index&workorder_id='
. $workorder_id)
+ );
+
+ $data = array
+ (
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_add_statustext' =>
lang('Add the selected items'),
+ 'lang_add'
=> lang('Add'),
+ 'link_delete'
=> $GLOBALS['phpgw']->link('/index.php',$link_data_delete),
+
+ 'chapter_list'
=> $this->bowo_hour->get_chapter_list('filter',$this->chapter_id),
+ 'select_chapter'
=> 'chapter_id',
+ 'lang_no_chapter'
=> lang('Select chapter'),
+ 'lang_chapter_statustext' =>
lang('Select the template-chapter'),
+
+ 'lookup'
=> $lookup,
+ 'function'
=> 'template',
+ 'links'
=> $links,
+ 'allrows'
=> $this->allrows,
+ 'allow_allrows'
=> true,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($template_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+
+ 'lang_user_statustext' =>
lang('Select the user the template belongs to. To do not use a category select
NO USER'),
+ 'select_user_name'
=> 'filter',
+ 'lang_no_user'
=> lang('No user'),
+ 'user_list'
=>
$this->bocommon->get_user_list('filter',$this->filter,$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
+
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_template' =>
$table_header_template,
+ 'values_template'
=> $content_template,
+ 'table_add'
=> $table_add,
+ 'table_done'
=> $table_done
+ );
+
+ $appname
= lang('template');
+ $function_msg =
lang('list template');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function hour()
+ {
+ $GLOBALS['phpgw']->xslttpl->add_file(array('template',
+
'menu',
+
'nextmatchs',
+
'search_field'));
+
+ $delete = get_var('delete',array('POST','GET'));
+ $hour_id = get_var('hour_id',array('POST','GET'));
+
+ $template_id =
get_var('template_id',array('POST','GET'));
+
+ if($delete && $hour_id)
+ {
+ $receipt =
$this->bo->delete_hour($hour_id,$template_id);
+ }
+
+ $links = $this->menu->links();
+
+ $template_list =
$this->bo->read_template_hour($template_id);
+
+ $i=0;
+ $grouping_descr_old='';
+
+ while (is_array($template_list) && list(,$template) =
each($template_list))
+ {
+
+
if($template['grouping_descr']!=$grouping_descr_old)
+ {
+ $new_grouping = true;
+ }
+ else
+ {
+ $new_grouping = false;
+ }
+
+ $grouping_descr_old =
$template['grouping_descr'];
+
+ if($template['activity_num'])
+ {
+ $code = $template['activity_num'];
+ }
+ else
+ {
+ $code =
str_replace("-",$template['tolerance'],$template['ns3420_id']);
+ }
+
+
+ $content[] = array
+ (
+ 'counter'
=> $i,
+ 'record'
=> $template['record'],
+ 'chapter_id' =>
$template['chapter_id'],
+ 'grouping_descr' =>
$template['grouping_descr'],
+ 'building_part' =>
$template['building_part'],
+ 'new_grouping' =>
$new_grouping,
+ 'code'
=> $code,
+ 'activity_id' =>
$template['activity_id'],
+ 'activity_num' =>
$template['activity_num'],
+ 'hours_descr' =>
$template['hours_descr'],
+ 'remark'
=> $template['remark'],
+ 'ns3420_id'
=> $template['ns3420_id'],
+ 'tolerance'
=> $template['tolerance'],
+ 'cost'
=> $template['cost'],
+ 'unit'
=> $template['unit'],
+ 'billperae'
=> $template['billperae'],
+ 'building_part' =>
$template['building_part'],
+ 'dim_d'
=> $template['dim_d'],
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.edit_hour&hour_id='
. $template['hour_id'] . '&template_id=' . $template_id),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.hour&delete=true&template_id='
. $template_id . '&hour_id=' . $template['hour_id']),
+ 'lang_edit_statustext' =>
lang('edit the template'),
+ 'lang_delete_statustext' =>
lang('delete the template'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+
+ $i++;
+ }
+
+ $table_header[] = array
+ (
+ 'lang_record' => lang('Record'),
+ 'lang_code' => lang('Code'),
+ 'lang_descr' => lang('Description'),
+ 'lang_unit' => lang('Unit'),
+ 'lang_quantity' => lang('Quantity'),
+ 'lang_billperae' => lang('Bill per
unit'),
+ 'lang_cost' => lang('Cost'),
+
+ 'sort_billperae' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'billperae',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uitemplate.hour',
+
'workorder_id'
=>$workorder_id,
+
'template_id'
=>$template_id,
+
'query'
=>$this->query,
+
'allrows'
=>$this->allrows)
+
)),
+ 'lang_select' => lang('Select'),
+ 'sort_building_part' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'building_part',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uitemplate.hour',
+
'workorder_id'
=>$workorder_id,
+
'template_id'
=>$template_id,
+
'query'
=>$this->query,
+
'allrows'
=>$this->allrows)
+
)),
+ 'lang_building_part' =>
lang('Building part'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete')
+ );
+
+
+ $table_done[] = array
+ (
+ 'lang_done' =>
lang('Done'),
+ 'lang_done_statustext' => lang('Back to list'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.index')
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uitemplate.hour',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'workorder_id' =>$workorder_id,
+ 'template_id' =>$template_id,
+ 'allrows'
=>$this->allrows,
+ 'query'
=>$this->query
+ );
+
+ $link_data_nextmatch = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uitemplate.hour',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'workorder_id' =>$workorder_id,
+ 'template_id' =>$template_id,
+ 'query'
=>$this->query
+ );
+
+ $link_data_delete = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uitemplate.hour',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'workorder_id' =>$workorder_id,
+ 'allrows'
=>$this->allrows,
+ 'delete' =>true,
+ 'query'
=>$this->query
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_statustext' => lang('add a hour'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.edit_hour&template_id='
. $template_id)
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_add_statustext' =>
lang('Add the selected items'),
+ 'lang_add'
=> lang('Add'),
+ 'link_delete'
=> $GLOBALS['phpgw']->link('/index.php',$link_data_delete),
+
+ 'function'
=> 'template',
+ 'links'
=> $links,
+ 'allrows'
=> $this->allrows,
+ 'allow_allrows'
=> true,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($template_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data_nextmatch),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'workorder_data'
=> $common_data['workorder_data'],
+ 'table_header_template_hour' =>
$table_header,
+ 'values_template_hour' =>
$content,
+ 'table_add'
=> $table_add,
+ 'table_done'
=> $table_done
+ );
+ $appname
= lang('template');
+ $function_msg =
lang('view template detail');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_template_hour' =>
$data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit_template()
+ {
+ $template_id =
get_var('template_id',array('POST','GET'));
+ $values =
get_var('values',array('POST','GET'));
+
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('template'));
+
+ if ($values['save'])
+ {
+ $values['template_id'] = $template_id;
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$this->bo->save_template($values);
+
+ $template_id=$receipt['template_id'];
+ }
+ }
+
+ if ($template_id)
+ {
+ $values =
$this->bo->read_single_template($template_id);
+ $function_msg = lang('Edit template');
+ }
+ else
+ {
+ $function_msg = lang('Add template');
+ }
+
+ if($error_id)
+ {
+ unset($values['template_id']);
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uitemplate.edit_template',
+ 'template_id' => $template_id
+ );
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.index&template_id='
. $template_id),
+
+ 'lang_template_id'
=> lang('Template ID'),
+ 'value_template_id'
=> $template_id,
+
+ 'lang_name'
=> lang('Name'),
+ 'value_name'
=> $values['name'],
+
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'lang_descr'
=> lang('description'),
+ 'value_descr'
=> $values['descr'],
+ 'lang_descr_statustext' =>
lang('Enter the description for this template'),
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'lang_save_statustext' =>
lang('Save the building'),
+
+ 'lang_remark'
=> lang('Remark'),
+ 'value_remark'
=> $values['remark'],
+ 'lang_remark_statustext' =>
lang('Enter additional remarks to the description - if any'),
+
+ 'lang_chapter'
=> lang('chapter'),
+ 'chapter_list'
=> $this->bowo_hour->get_chapter_list('select',$values['chapter_id']),
+ 'select_chapter'
=> 'values[chapter_id]',
+ 'lang_no_chapter'
=> lang('Select chapter'),
+ 'lang_chapter_statustext' =>
lang('Select the chapter (for tender) for this activity.'),
+ 'lang_add'
=> lang('add a hour'),
+ 'lang_add_statustext' =>
lang('add a hour to this template'),
+ 'add_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.edit_hour&template_id='
. $template_id)
+ );
+
+ $appname
= lang('Workorder template');
+ $function_msg =
lang('view ticket detail');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_template' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function edit_hour()
+ {
+ $template_id =
get_var('template_id',array('POST','GET'));
+ $activity_id =
get_var('activity_id',array('POST','GET'));
+ $hour_id =
get_var('hour_id',array('POST','GET'));
+ $values =
get_var('values',array('POST','GET'));
+ $values['ns3420_id'] =
get_var('ns3420_id',array('POST','GET'));
+ $values['ns3420_descr'] =
get_var('ns3420_descr',array('POST','GET'));
+
+ $bopricebook =
CreateObject($this->currentapp.'.bopricebook');
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('template'));
+
+ if ($values['save'])
+ {
+ if($values['copy_hour'])
+ {
+ unset($hour_id);
+ }
+
+ $values['hour_id'] = $hour_id;
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$this->bo->save_hour($values,$template_id);
+
+ $hour_id=$receipt['hour_id'];
+ }
+ }
+
+ if ($hour_id)
+ {
+ $values = $this->bo->read_single_hour($hour_id);
+ $function_msg = lang('Edit hour');
+ }
+ else
+ {
+ $function_msg = lang('Add hour');
+ }
+
+ $template =
$this->bo->read_single_template($template_id);
+
+ if($error_id)
+ {
+ unset($values['hour_id']);
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uitemplate.edit_hour',
+ 'template_id' => $template_id,
+ 'hour_id' => $hour_id
+ );
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.hour&template_id='
. $template_id),
+ 'lang_template'
=> lang('template'),
+ 'value_template_id'
=> $template['template_id'],
+ 'value_template_name' =>
$template['name'],
+
+ 'lang_hour_id'
=> lang('Hour ID'),
+ 'value_hour_id'
=> $hour_id,
+
+ 'lang_copy_hour' =>
lang('Copy hour ?'),
+ 'lang_copy_hour_statustext' => lang('Choose
Copy Hour to copy this hour to a new hour'),
+
+ 'lang_activity_num'
=> lang('Activity code'),
+ 'value_activity_num' =>
$values['activity_num'],
+ 'value_activity_id'
=> $values['activity_id'],
+
+ 'lang_unit'
=> lang('Unit'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'lang_descr'
=> lang('description'),
+ 'value_descr'
=> $values['hours_descr'],
+ 'lang_descr_statustext' =>
lang('Enter the description for this activity'),
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'lang_save_statustext' =>
lang('Save the building'),
+
+ 'lang_remark'
=> lang('Remark'),
+ 'value_remark'
=> $values['remark'],
+ 'lang_remark_statustext' =>
lang('Enter additional remarks to the description - if any'),
+
+ 'lang_quantity'
=> lang('quantity'),
+ 'value_quantity'
=> $values['quantity'],
+ 'lang_quantity_statustext' =>
lang('Enter quantity of unit'),
+
+ 'lang_billperae'
=> lang('Cost per unit'),
+ 'value_billperae'
=> $values['billperae'],
+ 'lang_billperae_statustext' =>
lang('Enter the cost per unit'),
+
+ 'lang_total_cost'
=> lang('Total cost'),
+ 'value_total_cost'
=> $values['cost'],
+ 'lang_total_cost_statustext' => lang('Enter
the total cost of this activity - if not to be calculated from unit-cost'),
+
+ 'lang_dim_d'
=> lang('Dim D'),
+ 'dim_d_list'
=> $bopricebook->get_dim_d_list($values['dim_d']),
+ 'select_dim_d'
=> 'values[dim_d]',
+ 'lang_no_dim_d'
=> lang('No Dim D'),
+ 'lang_dim_d_statustext' =>
lang('Select the Dim D for this activity. To do not use Dim D - select NO DIM
D'),
+
+ 'lang_unit'
=> lang('Unit'),
+ 'unit_list'
=> $bopricebook->get_unit_list($values['unit']),
+ 'select_unit'
=> 'values[unit]',
+ 'lang_no_unit'
=> lang('Select Unit'),
+ 'lang_unit_statustext' =>
lang('Select the unit for this activity.'),
+
+ 'lang_chapter'
=> lang('chapter'),
+ 'chapter_list'
=> $this->bowo_hour->get_chapter_list('select',$template['chapter_id']),
+ 'select_chapter'
=> 'values[chapter_id]',
+ 'lang_no_chapter'
=> lang('Select chapter'),
+ 'lang_chapter_statustext' =>
lang('Select the chapter (for tender) for this activity.'),
+
+ 'lang_tolerance'
=> lang('tolerance'),
+ 'tolerance_list'
=> $this->bowo_hour->get_tolerance_list($values['tolerance_id']),
+ 'select_tolerance'
=> 'values[tolerance_id]',
+ 'lang_no_tolerance'
=> lang('Select tolerance'),
+ 'lang_tolerance_statustext' =>
lang('Select the tolerance for this activity.'),
+
+ 'lang_grouping'
=> lang('grouping'),
+ 'grouping_list'
=> $this->bo->get_grouping_list($values['grouping_id'],$template_id),
+ 'select_grouping'
=> 'values[grouping_id]',
+ 'lang_no_grouping'
=> lang('Select grouping'),
+ 'lang_grouping_statustext' =>
lang('Select the grouping for this activity.'),
+
+ 'lang_new_grouping'
=> lang('New grouping'),
+ 'lang_new_grouping_statustext' =>
lang('Enter a new grouping for this activity if not found in the list'),
+
+ 'lang_building_part'
=> lang('building_part'),
+ 'building_part_list'
=> $this->bowo_hour->get_building_part_list($values['building_part_id']),
+ 'select_building_part'
=> 'values[building_part_id]',
+ 'lang_no_building_part'
=> lang('Select building part'),
+ 'lang_building_part_statustext' =>
lang('Select the building part for this activity.'),
+
+
+ 'ns3420_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.ns3420'),
+ 'lang_ns3420'
=> lang('NS3420'),
+ 'value_ns3420_id'
=> $values['ns3420_id'],
+ 'lang_ns3420_statustext' =>
lang('Select a standard-code from the norwegian standard'),
+ 'currency'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['currency']
+
+ );
+
+ $appname
= lang('Workorder template');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_hour' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function delete()
+ {
+ $id = get_var('id',array('POST','GET'));
+ $confirm = get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uitemplate.index'
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($id);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.delete&id='
. $id),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('Workorder template');
+ $function_msg =
lang('delete template');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ }
+?>
Index: property/inc/class.uitenant_claim.inc.php
diff -u property/inc/class.uitenant_claim.inc.php:1.8
property/inc/class.uitenant_claim.inc.php:1.9
--- property/inc/class.uitenant_claim.inc.php:1.8 Tue Nov 8 22:39:10 2005
+++ property/inc/class.uitenant_claim.inc.php Fri Jan 27 14:05:43 2006
@@ -1,840 +1,840 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage project
- * @version $Id: class.uitenant_claim.inc.php,v 1.8 2005/11/08 22:39:10
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
-
- class uitenant_claim
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
-
- var $public_functions = array
- (
- 'index' => True,
- 'check' => True,
- 'view' => True,
- 'edit' => True,
- 'delete' => True
- );
-
- function uitenant_claim()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- $this->bo =
CreateObject($this->currentapp.'.botenant_claim',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
-
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
- $this->acl2_location= '.tenant_claim';
-
- $this->acl_read =
$this->acl2->check($this->acl2_location,1);
- $this->acl_add =
$this->acl2->check($this->acl2_location,2);
- $this->acl_edit =
$this->acl2->check($this->acl2_location,4);
- $this->acl_delete =
$this->acl2->check($this->acl2_location,8);
- $this->acl_manage =
$this->acl2->check($this->acl2_location,16);
-
- $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->status = $this->bo->status;
- $this->cat_id = $this->bo->cat_id;
- $this->allrows = $this->bo->allrows;
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' => $this->filter,
- 'status' => $this->status,
- 'cat_id' => $this->cat_id,
- 'this->allrows' => $this->allrows
- );
- $this->bo->save_sessiondata($data);
- }
-
- function index($project_id='')
- {
-
$GLOBALS['phpgw']->xslttpl->add_file(array('tenant_claim',
-
'menu',
-
'receipt',
-
'search_field',
-
'nextmatchs'));
-
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
-
- $this->menu->sub = 'project';
- $links = $this->menu->links('tenant_claim');
-
- $receipt =
$GLOBALS['phpgw']->session->appsession('session_data','tenant_claim_receipt');
-
$GLOBALS['phpgw']->session->appsession('session_data','tenant_claim_receipt','');
-
- $claim_list = $this->bo->read(array('project_id' =>
$project_id));
-
- while (is_array($claim_list) && list(,$claim) =
each($claim_list))
- {
- if($claim['tenant_id'])
- {
- $tenant=
$this->bocommon->read_single_tenant($claim['tenant_id']);
- $name = $tenant['last_name'] . ', ' .
$tenant['first_name'];
- }
-
- $content[] = array
- (
- 'claim_id'
=> $claim['claim_id'],
- 'project_id'
=> $claim['project_id'],
- 'status'
=> lang($claim['status']),
- 'name'
=> $name,
- 'entry_date'
=> $claim['entry_date'],
- 'category'
=> $claim['category'],
- 'link_view'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant_claim.view&claim_id='
. $claim['claim_id']),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant_claim.edit&claim_id='
. $claim['claim_id']),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant_claim.delete&claim_id='
. $claim['claim_id']),
- 'lang_view_statustext' =>
lang('view the claim'),
- 'lang_edit_statustext' =>
lang('edit the claim'),
- 'lang_delete_statustext' =>
lang('delete the claim'),
- 'text_view'
=> lang('view'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- unset ($tenant);
- unset ($name);
- }
-
- $table_header = array
- (
- 'lang_project' => lang('Project'),
- 'lang_name' => lang('name'),
- 'lang_status' => lang('Status'),
- 'lang_time_created' => lang('time created'),
- 'lang_view' => lang('view'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'lang_claim_id' => lang('claim id'),
- 'sort_project' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'project_id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uitenant_claim.index',
-
'cat_id' =>
$this->cat_id,
-
'query'
=>$this->query,
-
'status'
=>$this->status,
-
'allrows'
=>$this->allrows)
-
)),
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'org_name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uitenant_claim.index',
-
'cat_id' =>
$this->cat_id,
-
'query'
=>$this->query,
-
'status'
=>$this->status,
-
'allrows'
=>$this->allrows)
-
)),
- 'sort_claim_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'claim_id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uitenant_claim.index',
-
'cat_id' =>
$this->cat_id,
-
'query'
=>$this->query,
-
'status'
=>$this->status,
-
'allrows'
=>$this->allrows)
-
)),
- 'sort_time_created' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'entry_date',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uitenant_claim.index',
-
'cat_id'
=>$this->cat_id,
-
'query'
=>$this->query,
-
'status'
=>$this->status,
-
'allrows'
=>$this->allrows)
-
)),
- 'sort_category' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'descr',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uitenant_claim.index',
-
'cat_id'
=>$this->cat_id,
-
'query'
=>$this->query,
-
'status'
=>$this->status,
-
'allrows'
=>$this->allrows)
-
)),
- 'lang_category' => lang('category')
- );
-
- if ($project_id)
- {
- $lang_add = lang('add another');
- $add_action =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant_claim.edit&project_id='
. $project_id);
- }
- else
- {
- $lang_add = lang('add');
- $add_action =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.index&lookup=true&from=tenant_claim');
-
- }
-
- $table_add = array
- (
- 'lang_add' =>
$lang_add,
- 'lang_add_statustext' => lang('add a claim'),
- 'add_action' => $add_action
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uitenant_claim.index',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'filter'
=>$this->filter,
- 'status' =>$this->status,
- 'query'
=>$this->query
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'links'
=> $links,
- 'allow_allrows'
=> true,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($claim_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the claim belongs to. To do not use a category select
NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $this->bo->select_category_list('filter',$this->cat_id),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter)),
- 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
-
- 'status_name'
=> 'status',
- 'status_list'
=> $this->bo->get_status_list(array('format' => 'filter', 'selected' =>
$this->status,'default' => 'open')),
- 'lang_no_status'
=> lang('Open'),
- 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
-
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
- $this->save_sessiondata();
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('Tenant claim') . ': ' . lang('list claim');
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- function check()
- {
- $project_id =
get_var('project_id',array('POST','GET'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('tenant_claim'));
-
- $claim = $this->bo->check_claim_project($project_id);
- $total_records = $this->bo->total_records;
-
- if($total_records > 0)
- {
- $receipt['message'][] = array('msg'=>lang('%1
claim is already registered for this project',$total_records));
-
$GLOBALS['phpgw']->session->appsession('session_data','tenant_claim_receipt',$receipt);
- $this->bo->status = 'all';
- $this->status = 'all';
- $this->index($project_id);
- }
- else
- {
- $this->edit($project_id);
- }
-
- return;
- }
-
- function edit($project_id='')
- {
- if(!$this->acl_add && !$this->acl_edit)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
- }
-
- $claim_id =
get_var('claim_id',array('POST','GET'));
-
- $values = get_var('values',array('POST'));
- $values['project_id'] =
get_var('project_id',array('POST','GET'));
- $values['b_account_id'] =
get_var('b_account_id',array('POST'));
- $values['b_account_name'] =
get_var('b_account_name',array('POST'));
- $values['tenant_id'] =
get_var('tenant_id',array('POST'));
- $values['last_name'] =
get_var('last_name',array('POST'));
- $values['first_name'] =
get_var('first_name',array('POST'));
-
- if($project_id)
- {
- $values['project_id'] = $project_id;
- }
-
- $this->boproject=
CreateObject($this->currentapp.'.boproject');
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('tenant_claim'));
-
- if ($values['save'] || $values['apply'])
- {
- if(!$values['cat_id'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
- }
-
- if(!$values['b_account_id'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a budget account !'));
- }
-
- if(!$values['workorder'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a workorder !'));
- }
-
- if(!$receipt['error'])
- {
- $values['claim_id'] = $claim_id;
- $receipt = $this->bo->save($values);
- $claim_id = $receipt['claim_id'];
- $this->cat_id =
($values['cat_id']?$values['cat_id']:$this->cat_id);
-
- if ($values['save'])
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','tenant_claim_receipt',$receipt);
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uitenant_claim.index');
- }
- }
- }
-
- if ($values['cancel'])
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uitenant_claim.index');
- }
-
-
- if ($claim_id)
- {
- $values = $this->bo->read_single($claim_id);
- }
-
-//_debug_array($values);
-
- $project_values =
$this->boproject->read_single($values['project_id']);
-
-//_debug_array($project_values);
-
- $table_header_workorder[] = array
- (
- 'lang_workorder_id' =>
lang('Workorder'),
- 'lang_budget' =>
lang('Budget'),
- 'lang_calculation' =>
lang('Calculation'),
- 'lang_vendor' =>
lang('Vendor'),
- 'lang_charge_tenant' => lang('Charge
tenant'),
- 'lang_select' =>
lang('Select')
- );
-
- $bolocation =
CreateObject($this->currentapp.'.bolocation');
-
- $location_data=$bolocation->initiate_ui_location(array(
- 'values' =>
$project_values['location_data'],
- 'type_id' =>
count(explode('-',$project_values['location_data']['location_code'])),
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' =>
$project_values['location_data']['tenant_id'],
- 'lookup_type' => 'view',
- 'lookup_entity' =>
$this->bocommon->get_lookup_entity('project'),
- 'entity_data' =>
$project_values['p']
- ));
-
- if($project_values['contact_phone'])
- {
- for
($i=0;$i<count($location_data['location']);$i++)
- {
-
if($location_data['location'][$i]['input_name'] == 'contact_phone')
- {
-
unset($location_data['location'][$i]['value']);
- }
- }
- }
-
-
- if($project_values['location_data']['tenant_id'] &&
!$values['tenant_id']):
- {
- $values['tenant_id'] =
$project_values['location_data']['tenant_id'];
- $values['last_name'] =
$project_values['location_data']['last_name'];
- $values['first_name'] =
$project_values['location_data']['first_name'];
- }
- elseif($values['tenant_id']):
- {
- $tenant=
$this->bocommon->read_single_tenant($values['tenant_id']);
- $values['last_name'] =
$tenant['last_name'];
- $values['first_name'] =
$tenant['first_name'];
- }
- endif;
-
-
- if($values['workorder'] &&
$project_values['workorder_budget'])
- {
- foreach ($values['workorder'] as $workorder_id)
- {
- for
($i=0;$i<count($project_values['workorder_budget']);$i++)
- {
-
if($project_values['workorder_budget'][$i]['workorder_id'] == $workorder_id)
- {
-
$project_values['workorder_budget'][$i]['selected'] = True;
- }
- }
- }
- }
-
-
- for
($i=0;$i<count($project_values['workorder_budget']);$i++)
- {
- $claimed=
$this->bo->check_claim_workorder($project_values['workorder_budget'][$i]['workorder_id']);
-
- if($claimed)
- {
-
$project_values['workorder_budget'][$i]['claimed'] = $claimed;
- }
- }
-
-
-
- $this->cat_id =
($values['cat_id']?$values['cat_id']:$this->cat_id);
-
$b_account_data=$this->bocommon->initiate_ui_budget_account_lookup(array(
- 'b_account_id' =>
$values['b_account_id'],
- 'b_account_name' =>
$values['b_account_name']));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uitenant_claim.edit',
- 'claim_id' => $claim_id,
- 'project_id' => $values['project_id']
- );
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'table_header_workorder' =>
$table_header_workorder,
- 'lang_no_workorders' =>
lang('No workorder bugdet'),
- 'workorder_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.view'),
- 'lang_start_date'
=> lang('Project start date'),
- 'value_start_date'
=> $project_values['start_date'],
-
- 'lang_end_date'
=> lang('Project end date'),
- 'value_end_date'
=> $project_values['end_date'],
-
- 'lang_charge_tenant' =>
lang('Charge tenant'),
- 'charge_tenant'
=> $project_values['charge_tenant'],
-
- 'lang_power_meter'
=> lang('Power meter'),
- 'value_power_meter'
=> $project_values['power_meter'],
-
- 'lang_budget'
=> lang('Budget'),
- 'value_budget'
=> $project_values['budget'],
-
- 'lang_reserve'
=> lang('reserve'),
- 'value_reserve'
=> $project_values['reserve'],
- 'lang_reserve_statustext' =>
lang('Enter the reserve'),
-
- 'lang_reserve_remainder' =>
lang('reserve remainder'),
- 'value_reserve_remainder' =>
$reserve_remainder,
- 'value_reserve_remainder_percent'=>
$remainder_percent,
-
- 'vendor_data'
=> $vendor_data,
- 'location_data'
=> $location_data,
- 'location_type'
=> 'view',
-
- 'lang_project_id'
=> lang('Project ID'),
- 'value_project_id'
=> $project_values['project_id'],
- 'lang_name'
=> lang('Name'),
- 'value_name'
=> $project_values['name'],
-
- 'lang_descr'
=> lang('Description'),
-
- 'sum_workorder_budget' =>
$project_values['sum_workorder_budget'],
- 'sum_workorder_calculation' =>
$project_values['sum_workorder_calculation'],
- 'workorder_budget'
=> $project_values['workorder_budget'],
- 'sum_workorder_actual_cost' =>
$project_values['sum_workorder_actual_cost'],
- 'lang_actual_cost'
=> lang('Actual cost'),
- 'lang_coordinator'
=> lang('Coordinator'),
- 'lang_sum'
=> lang('Sum'),
- 'select_user_name'
=> 'project_values[coordinator]',
- 'lang_no_user'
=> lang('Select coordinator'),
- 'user_list'
=>
$this->bocommon->get_user_list('select',$project_values['coordinator'],$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
-
- 'status_list'
=> $this->boproject->select_status_list('select',$project_values['status']),
- 'lang_no_status'
=> lang('Select status'),
- 'lang_status'
=> lang('Status'),
-
- 'currency'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
-
- 'lang_contact_phone' =>
lang('Contact phone'),
- 'contact_phone'
=> $project_values['contact_phone'],
-
- 'b_account_data'
=> $b_account_data,
-
- 'lang_select_workorder_statustext' =>
lang('Include the workorder to this claim'),
-
- 'cat_list_project'
=>
$this->boproject->select_category_project_list('select',$project_values['cat_id']),
-
-//------------------
-
- 'lang_status'
=> lang('Status'),
- 'lang_status_statustext' =>
lang('Select status'),
- 'status_list'
=> $this->bo->get_status_list(array('format' => 'select', 'selected' =>
$values['status'],'default' => 'open')),
- 'lang_no_status'
=> lang('No status'),
- 'status_name'
=> 'values[status]',
-
- 'lang_amount'
=> lang('amount'),
- 'lang_amount_statustext' =>
lang('The total amount to claim'),
- 'value_amount'
=> $values['amount'],
-
- 'tenant_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.tenant'),
- 'lang_tenant'
=> lang('tenant'),
- 'value_tenant_id'
=> $values['tenant_id'],
- 'value_last_name'
=> $values['last_name'],
- 'value_first_name'
=> $values['first_name'],
- 'lang_tenant_statustext' =>
lang('Select a tenant'),
- 'size_last_name'
=> strlen($values['last_name']),
- 'size_first_name'
=> strlen($values['first_name']),
-
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_claim_id'
=> lang('ID'),
- 'value_claim_id'
=> $claim_id,
- 'lang_remark'
=> lang('remark'),
- 'lang_category'
=> lang('category'),
- 'lang_save'
=> lang('save'),
- 'lang_cancel'
=> lang('cancel'),
- 'lang_apply'
=> lang('apply'),
- 'value_remark'
=> $values['remark'],
- 'value_cat'
=> $values['cat'],
- 'lang_remark_statustext' =>
lang('Enter a remark for this claim'),
- 'lang_apply_statustext' =>
lang('Apply the values'),
- 'lang_cancel_statustext' =>
lang('Leave the claim untouched and return back to the list'),
- 'lang_save_statustext' =>
lang('Save the claim and return back to the list'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the claim belongs to. To do not use a category select
NO CATEGORY'),
- 'select_name'
=> 'values[cat_id]',
- 'cat_list'
=> $this->bo->select_category_list('select',$this->cat_id)
- );
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('Tenant claim') . ': ' . ($claim_id?lang('edit claim'):lang('add claim'));
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- function delete()
- {
-
- if(!$this->acl_delete)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
- }
-
-
- $claim_id =
get_var('claim_id',array('POST','GET'));
- $delete = get_var('delete',array('POST'));
- $confirm = get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uitenant_claim.index'
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($claim_id);
-// Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
-
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant_claim.delete&claim_id='
. $claim_id),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('Tenant claim');
- $function_msg =
lang('delete claim');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- function view()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $claim_id =
get_var('claim_id',array('POST','GET'));
-
- $this->boproject=
CreateObject($this->currentapp.'.boproject');
-
$GLOBALS['phpgw']->xslttpl->add_file(array('tenant_claim'));
-
- $values = $this->bo->read_single($claim_id);
-
- $project_values =
$this->boproject->read_single($values['project_id']);
-
- $table_header_workorder[] = array
- (
- 'lang_workorder_id' =>
lang('Workorder'),
- 'lang_budget' =>
lang('Budget'),
- 'lang_calculation' =>
lang('Calculation'),
- 'lang_vendor' =>
lang('Vendor'),
- 'lang_charge_tenant' => lang('Charge
tenant'),
- 'lang_select' =>
lang('Select')
- );
-
- $bolocation =
CreateObject($this->currentapp.'.bolocation');
-
- $location_data=$bolocation->initiate_ui_location(array(
- 'values' =>
$project_values['location_data'],
- 'type_id' =>
count(explode('-',$project_values['location_data']['location_code'])),
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' =>
$project_values['location_data']['tenant_id'],
- 'lookup_type' => 'view',
- 'lookup_entity' =>
$this->bocommon->get_lookup_entity('project'),
- 'entity_data' =>
$project_values['p']
- ));
-
- if($project_values['contact_phone'])
- {
- for
($i=0;$i<count($location_data['location']);$i++)
- {
-
if($location_data['location'][$i]['input_name'] == 'contact_phone')
- {
-
unset($location_data['location'][$i]['value']);
- }
- }
- }
-
-
- if($project_values['location_data']['tenant_id'] &&
!$values['tenant_id']):
- {
- $values['tenant_id'] =
$project_values['location_data']['tenant_id'];
- $values['last_name'] =
$project_values['location_data']['last_name'];
- $values['first_name'] =
$project_values['location_data']['first_name'];
- }
- elseif($values['tenant_id']):
- {
- $tenant=
$this->bocommon->read_single_tenant($values['tenant_id']);
- $values['last_name'] =
$tenant['last_name'];
- $values['first_name'] =
$tenant['first_name'];
- }
- endif;
-
-
- if($values['workorder'] &&
$project_values['workorder_budget'])
- {
- foreach ($values['workorder'] as $workorder_id)
- {
- for
($i=0;$i<count($project_values['workorder_budget']);$i++)
- {
-
if($project_values['workorder_budget'][$i]['workorder_id'] == $workorder_id)
- {
-
$project_values['workorder_budget'][$i]['selected'] = True;
- }
- }
- }
- }
-
-
- for
($i=0;$i<count($project_values['workorder_budget']);$i++)
- {
- $claimed=
$this->bo->check_claim_workorder($project_values['workorder_budget'][$i]['workorder_id']);
-
- if($claimed)
- {
-
$project_values['workorder_budget'][$i]['claimed'] = $claimed;
- }
- }
-
-
-
-
$b_account_data=$this->bocommon->initiate_ui_budget_account_lookup(array(
- 'b_account_id' =>
$values['b_account_id'],
- 'b_account_name' =>
$values['b_account_name'],
- 'type' => 'view'));
-
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'table_header_workorder' =>
$table_header_workorder,
- 'lang_no_workorders' =>
lang('No workorder bugdet'),
- 'workorder_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.view'),
- 'lang_start_date'
=> lang('Project start date'),
- 'value_start_date'
=> $project_values['start_date'],
-
- 'lang_end_date'
=> lang('Project end date'),
- 'value_end_date'
=> $project_values['end_date'],
-
- 'lang_charge_tenant' =>
lang('Charge tenant'),
- 'charge_tenant'
=> $project_values['charge_tenant'],
-
- 'lang_power_meter'
=> lang('Power meter'),
- 'value_power_meter'
=> $project_values['power_meter'],
-
- 'lang_budget'
=> lang('Budget'),
- 'value_budget'
=> $project_values['budget'],
-
- 'lang_reserve'
=> lang('reserve'),
- 'value_reserve'
=> $project_values['reserve'],
- 'lang_reserve_statustext' =>
lang('Enter the reserve'),
-
- 'lang_reserve_remainder' =>
lang('reserve remainder'),
- 'value_reserve_remainder' =>
$reserve_remainder,
- 'value_reserve_remainder_percent'=>
$remainder_percent,
-
- 'location_data'
=> $location_data,
- 'location_type'
=> 'view',
-
- 'lang_project_id'
=> lang('Project ID'),
- 'value_project_id'
=> $project_values['project_id'],
- 'lang_name'
=> lang('Name'),
- 'value_name'
=> $project_values['name'],
-
- 'lang_descr'
=> lang('Description'),
-
- 'sum_workorder_budget' =>
$project_values['sum_workorder_budget'],
- 'sum_workorder_calculation' =>
$project_values['sum_workorder_calculation'],
- 'workorder_budget'
=> $project_values['workorder_budget'],
- 'sum_workorder_actual_cost' =>
$project_values['sum_workorder_actual_cost'],
- 'lang_actual_cost'
=> lang('Actual cost'),
- 'lang_coordinator'
=> lang('Coordinator'),
- 'lang_sum'
=> lang('Sum'),
- 'select_user_name'
=> 'project_values[coordinator]',
- 'lang_no_user'
=> lang('Select coordinator'),
- 'user_list'
=>
$this->bocommon->get_user_list('select',$project_values['coordinator'],$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
-
- 'status_list'
=> $this->boproject->select_status_list('select',$project_values['status']),
- 'lang_no_status'
=> lang('Select status'),
- 'lang_status'
=> lang('Status'),
-
- 'currency'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
-
- 'lang_contact_phone' =>
lang('Contact phone'),
- 'contact_phone'
=> $project_values['contact_phone'],
-
- 'b_account_data'
=> $b_account_data,
-
- 'cat_list_project'
=>
$this->boproject->select_category_project_list('select',$project_values['cat_id']),
-
-//------------------
-
- 'lang_status'
=> lang('Status'),
- 'status_list'
=> $this->bo->get_status_list(array('format' => 'select', 'selected' =>
$values['status'],'default' => 'open')),
-
- 'lang_amount'
=> lang('amount'),
- 'value_amount'
=> $values['amount'],
-
- 'lang_tenant'
=> lang('tenant'),
- 'value_tenant_id'
=> $values['tenant_id'],
- 'value_last_name'
=> $values['last_name'],
- 'value_first_name'
=> $values['first_name'],
- 'size_last_name'
=> strlen($values['last_name']),
- 'size_first_name'
=> strlen($values['first_name']),
-
- 'lang_claim_id'
=> lang('ID'),
- 'value_claim_id'
=> $claim_id,
- 'lang_remark'
=> lang('remark'),
- 'lang_category'
=> lang('category'),
- 'lang_save'
=> lang('save'),
- 'lang_cancel'
=> lang('cancel'),
- 'lang_apply'
=> lang('apply'),
- 'value_remark'
=> $values['remark'],
- 'value_cat'
=> $values['cat'],
- 'cat_list'
=> $this->bo->select_category_list('select',$values['cat_id']),
-
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant_claim.index'),
- 'lang_done' => lang('done'),
- 'value_date' =>
$GLOBALS['phpgw']->common->show_date($tenant_claim['entry_date'])
-
- );
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('Tenant claim') . ': ' . ($claim_id?lang('edit claim'):lang('add claim'));
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
-
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage project
+ * @version $Id: class.uitenant_claim.inc.php,v 1.9 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+
+ class uitenant_claim
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'check' => True,
+ 'view' => True,
+ 'edit' => True,
+ 'delete' => True
+ );
+
+ function uitenant_claim()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $this->bo =
CreateObject($this->currentapp.'.botenant_claim',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+ $this->acl2_location= '.tenant_claim';
+
+ $this->acl_read =
$this->acl2->check($this->acl2_location,1);
+ $this->acl_add =
$this->acl2->check($this->acl2_location,2);
+ $this->acl_edit =
$this->acl2->check($this->acl2_location,4);
+ $this->acl_delete =
$this->acl2->check($this->acl2_location,8);
+ $this->acl_manage =
$this->acl2->check($this->acl2_location,16);
+
+ $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->status = $this->bo->status;
+ $this->cat_id = $this->bo->cat_id;
+ $this->allrows = $this->bo->allrows;
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' => $this->filter,
+ 'status' => $this->status,
+ 'cat_id' => $this->cat_id,
+ 'this->allrows' => $this->allrows
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function index($project_id='')
+ {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('tenant_claim',
+
'menu',
+
'receipt',
+
'search_field',
+
'nextmatchs'));
+
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+
+ $this->menu->sub = 'project';
+ $links = $this->menu->links('tenant_claim');
+
+ $receipt =
$GLOBALS['phpgw']->session->appsession('session_data','tenant_claim_receipt');
+
$GLOBALS['phpgw']->session->appsession('session_data','tenant_claim_receipt','');
+
+ $claim_list = $this->bo->read(array('project_id' =>
$project_id));
+
+ while (is_array($claim_list) && list(,$claim) =
each($claim_list))
+ {
+ if($claim['tenant_id'])
+ {
+ $tenant=
$this->bocommon->read_single_tenant($claim['tenant_id']);
+ $name = $tenant['last_name'] . ', ' .
$tenant['first_name'];
+ }
+
+ $content[] = array
+ (
+ 'claim_id'
=> $claim['claim_id'],
+ 'project_id'
=> $claim['project_id'],
+ 'status'
=> lang($claim['status']),
+ 'name'
=> $name,
+ 'entry_date'
=> $claim['entry_date'],
+ 'category'
=> $claim['category'],
+ 'link_view'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant_claim.view&claim_id='
. $claim['claim_id']),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant_claim.edit&claim_id='
. $claim['claim_id']),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant_claim.delete&claim_id='
. $claim['claim_id']),
+ 'lang_view_statustext' =>
lang('view the claim'),
+ 'lang_edit_statustext' =>
lang('edit the claim'),
+ 'lang_delete_statustext' =>
lang('delete the claim'),
+ 'text_view'
=> lang('view'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ unset ($tenant);
+ unset ($name);
+ }
+
+ $table_header = array
+ (
+ 'lang_project' => lang('Project'),
+ 'lang_name' => lang('name'),
+ 'lang_status' => lang('Status'),
+ 'lang_time_created' => lang('time created'),
+ 'lang_view' => lang('view'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'lang_claim_id' => lang('claim id'),
+ 'sort_project' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'project_id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uitenant_claim.index',
+
'cat_id' =>
$this->cat_id,
+
'query'
=>$this->query,
+
'status'
=>$this->status,
+
'allrows'
=>$this->allrows)
+
)),
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'org_name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uitenant_claim.index',
+
'cat_id' =>
$this->cat_id,
+
'query'
=>$this->query,
+
'status'
=>$this->status,
+
'allrows'
=>$this->allrows)
+
)),
+ 'sort_claim_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'claim_id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uitenant_claim.index',
+
'cat_id' =>
$this->cat_id,
+
'query'
=>$this->query,
+
'status'
=>$this->status,
+
'allrows'
=>$this->allrows)
+
)),
+ 'sort_time_created' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'entry_date',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uitenant_claim.index',
+
'cat_id'
=>$this->cat_id,
+
'query'
=>$this->query,
+
'status'
=>$this->status,
+
'allrows'
=>$this->allrows)
+
)),
+ 'sort_category' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'descr',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uitenant_claim.index',
+
'cat_id'
=>$this->cat_id,
+
'query'
=>$this->query,
+
'status'
=>$this->status,
+
'allrows'
=>$this->allrows)
+
)),
+ 'lang_category' => lang('category')
+ );
+
+ if ($project_id)
+ {
+ $lang_add = lang('add another');
+ $add_action =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant_claim.edit&project_id='
. $project_id);
+ }
+ else
+ {
+ $lang_add = lang('add');
+ $add_action =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.index&lookup=true&from=tenant_claim');
+
+ }
+
+ $table_add = array
+ (
+ 'lang_add' =>
$lang_add,
+ 'lang_add_statustext' => lang('add a claim'),
+ 'add_action' => $add_action
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uitenant_claim.index',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'filter'
=>$this->filter,
+ 'status' =>$this->status,
+ 'query'
=>$this->query
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'links'
=> $links,
+ 'allow_allrows'
=> true,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($claim_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the claim belongs to. To do not use a category select
NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $this->bo->select_category_list('filter',$this->cat_id),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'filter_list'
=> $this->nextmatchs->xslt_filter(array('filter' => $this->filter)),
+ 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
+
+ 'status_name'
=> 'status',
+ 'status_list'
=> $this->bo->get_status_list(array('format' => 'filter', 'selected' =>
$this->status,'default' => 'open')),
+ 'lang_no_status'
=> lang('Open'),
+ 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
+
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+ $this->save_sessiondata();
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('Tenant claim') . ': ' . lang('list claim');
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ function check()
+ {
+ $project_id =
get_var('project_id',array('POST','GET'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('tenant_claim'));
+
+ $claim = $this->bo->check_claim_project($project_id);
+ $total_records = $this->bo->total_records;
+
+ if($total_records > 0)
+ {
+ $receipt['message'][] = array('msg'=>lang('%1
claim is already registered for this project',$total_records));
+
$GLOBALS['phpgw']->session->appsession('session_data','tenant_claim_receipt',$receipt);
+ $this->bo->status = 'all';
+ $this->status = 'all';
+ $this->index($project_id);
+ }
+ else
+ {
+ $this->edit($project_id);
+ }
+
+ return;
+ }
+
+ function edit($project_id='')
+ {
+ if(!$this->acl_add && !$this->acl_edit)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
+ }
+
+ $claim_id =
get_var('claim_id',array('POST','GET'));
+
+ $values = get_var('values',array('POST'));
+ $values['project_id'] =
get_var('project_id',array('POST','GET'));
+ $values['b_account_id'] =
get_var('b_account_id',array('POST'));
+ $values['b_account_name'] =
get_var('b_account_name',array('POST'));
+ $values['tenant_id'] =
get_var('tenant_id',array('POST'));
+ $values['last_name'] =
get_var('last_name',array('POST'));
+ $values['first_name'] =
get_var('first_name',array('POST'));
+
+ if($project_id)
+ {
+ $values['project_id'] = $project_id;
+ }
+
+ $this->boproject=
CreateObject($this->currentapp.'.boproject');
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('tenant_claim'));
+
+ if ($values['save'] || $values['apply'])
+ {
+ if(!$values['cat_id'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
+ }
+
+ if(!$values['b_account_id'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a budget account !'));
+ }
+
+ if(!$values['workorder'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a workorder !'));
+ }
+
+ if(!$receipt['error'])
+ {
+ $values['claim_id'] = $claim_id;
+ $receipt = $this->bo->save($values);
+ $claim_id = $receipt['claim_id'];
+ $this->cat_id =
($values['cat_id']?$values['cat_id']:$this->cat_id);
+
+ if ($values['save'])
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','tenant_claim_receipt',$receipt);
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uitenant_claim.index');
+ }
+ }
+ }
+
+ if ($values['cancel'])
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uitenant_claim.index');
+ }
+
+
+ if ($claim_id)
+ {
+ $values = $this->bo->read_single($claim_id);
+ }
+
+//_debug_array($values);
+
+ $project_values =
$this->boproject->read_single($values['project_id']);
+
+//_debug_array($project_values);
+
+ $table_header_workorder[] = array
+ (
+ 'lang_workorder_id' =>
lang('Workorder'),
+ 'lang_budget' =>
lang('Budget'),
+ 'lang_calculation' =>
lang('Calculation'),
+ 'lang_vendor' =>
lang('Vendor'),
+ 'lang_charge_tenant' => lang('Charge
tenant'),
+ 'lang_select' =>
lang('Select')
+ );
+
+ $bolocation =
CreateObject($this->currentapp.'.bolocation');
+
+ $location_data=$bolocation->initiate_ui_location(array(
+ 'values' =>
$project_values['location_data'],
+ 'type_id' =>
count(explode('-',$project_values['location_data']['location_code'])),
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' =>
$project_values['location_data']['tenant_id'],
+ 'lookup_type' => 'view',
+ 'lookup_entity' =>
$this->bocommon->get_lookup_entity('project'),
+ 'entity_data' =>
$project_values['p']
+ ));
+
+ if($project_values['contact_phone'])
+ {
+ for
($i=0;$i<count($location_data['location']);$i++)
+ {
+
if($location_data['location'][$i]['input_name'] == 'contact_phone')
+ {
+
unset($location_data['location'][$i]['value']);
+ }
+ }
+ }
+
+
+ if($project_values['location_data']['tenant_id'] &&
!$values['tenant_id']):
+ {
+ $values['tenant_id'] =
$project_values['location_data']['tenant_id'];
+ $values['last_name'] =
$project_values['location_data']['last_name'];
+ $values['first_name'] =
$project_values['location_data']['first_name'];
+ }
+ elseif($values['tenant_id']):
+ {
+ $tenant=
$this->bocommon->read_single_tenant($values['tenant_id']);
+ $values['last_name'] =
$tenant['last_name'];
+ $values['first_name'] =
$tenant['first_name'];
+ }
+ endif;
+
+
+ if($values['workorder'] &&
$project_values['workorder_budget'])
+ {
+ foreach ($values['workorder'] as $workorder_id)
+ {
+ for
($i=0;$i<count($project_values['workorder_budget']);$i++)
+ {
+
if($project_values['workorder_budget'][$i]['workorder_id'] == $workorder_id)
+ {
+
$project_values['workorder_budget'][$i]['selected'] = True;
+ }
+ }
+ }
+ }
+
+
+ for
($i=0;$i<count($project_values['workorder_budget']);$i++)
+ {
+ $claimed=
$this->bo->check_claim_workorder($project_values['workorder_budget'][$i]['workorder_id']);
+
+ if($claimed)
+ {
+
$project_values['workorder_budget'][$i]['claimed'] = $claimed;
+ }
+ }
+
+
+
+ $this->cat_id =
($values['cat_id']?$values['cat_id']:$this->cat_id);
+
$b_account_data=$this->bocommon->initiate_ui_budget_account_lookup(array(
+ 'b_account_id' =>
$values['b_account_id'],
+ 'b_account_name' =>
$values['b_account_name']));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uitenant_claim.edit',
+ 'claim_id' => $claim_id,
+ 'project_id' => $values['project_id']
+ );
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'table_header_workorder' =>
$table_header_workorder,
+ 'lang_no_workorders' =>
lang('No workorder bugdet'),
+ 'workorder_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.view'),
+ 'lang_start_date'
=> lang('Project start date'),
+ 'value_start_date'
=> $project_values['start_date'],
+
+ 'lang_end_date'
=> lang('Project end date'),
+ 'value_end_date'
=> $project_values['end_date'],
+
+ 'lang_charge_tenant' =>
lang('Charge tenant'),
+ 'charge_tenant'
=> $project_values['charge_tenant'],
+
+ 'lang_power_meter'
=> lang('Power meter'),
+ 'value_power_meter'
=> $project_values['power_meter'],
+
+ 'lang_budget'
=> lang('Budget'),
+ 'value_budget'
=> $project_values['budget'],
+
+ 'lang_reserve'
=> lang('reserve'),
+ 'value_reserve'
=> $project_values['reserve'],
+ 'lang_reserve_statustext' =>
lang('Enter the reserve'),
+
+ 'lang_reserve_remainder' =>
lang('reserve remainder'),
+ 'value_reserve_remainder' =>
$reserve_remainder,
+ 'value_reserve_remainder_percent'=>
$remainder_percent,
+
+ 'vendor_data'
=> $vendor_data,
+ 'location_data'
=> $location_data,
+ 'location_type'
=> 'view',
+
+ 'lang_project_id'
=> lang('Project ID'),
+ 'value_project_id'
=> $project_values['project_id'],
+ 'lang_name'
=> lang('Name'),
+ 'value_name'
=> $project_values['name'],
+
+ 'lang_descr'
=> lang('Description'),
+
+ 'sum_workorder_budget' =>
$project_values['sum_workorder_budget'],
+ 'sum_workorder_calculation' =>
$project_values['sum_workorder_calculation'],
+ 'workorder_budget'
=> $project_values['workorder_budget'],
+ 'sum_workorder_actual_cost' =>
$project_values['sum_workorder_actual_cost'],
+ 'lang_actual_cost'
=> lang('Actual cost'),
+ 'lang_coordinator'
=> lang('Coordinator'),
+ 'lang_sum'
=> lang('Sum'),
+ 'select_user_name'
=> 'project_values[coordinator]',
+ 'lang_no_user'
=> lang('Select coordinator'),
+ 'user_list'
=>
$this->bocommon->get_user_list('select',$project_values['coordinator'],$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
+
+ 'status_list'
=> $this->boproject->select_status_list('select',$project_values['status']),
+ 'lang_no_status'
=> lang('Select status'),
+ 'lang_status'
=> lang('Status'),
+
+ 'currency'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
+
+ 'lang_contact_phone' =>
lang('Contact phone'),
+ 'contact_phone'
=> $project_values['contact_phone'],
+
+ 'b_account_data'
=> $b_account_data,
+
+ 'lang_select_workorder_statustext' =>
lang('Include the workorder to this claim'),
+
+ 'cat_list_project'
=>
$this->boproject->select_category_project_list('select',$project_values['cat_id']),
+
+//------------------
+
+ 'lang_status'
=> lang('Status'),
+ 'lang_status_statustext' =>
lang('Select status'),
+ 'status_list'
=> $this->bo->get_status_list(array('format' => 'select', 'selected' =>
$values['status'],'default' => 'open')),
+ 'lang_no_status'
=> lang('No status'),
+ 'status_name'
=> 'values[status]',
+
+ 'lang_amount'
=> lang('amount'),
+ 'lang_amount_statustext' =>
lang('The total amount to claim'),
+ 'value_amount'
=> $values['amount'],
+
+ 'tenant_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.tenant'),
+ 'lang_tenant'
=> lang('tenant'),
+ 'value_tenant_id'
=> $values['tenant_id'],
+ 'value_last_name'
=> $values['last_name'],
+ 'value_first_name'
=> $values['first_name'],
+ 'lang_tenant_statustext' =>
lang('Select a tenant'),
+ 'size_last_name'
=> strlen($values['last_name']),
+ 'size_first_name'
=> strlen($values['first_name']),
+
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_claim_id'
=> lang('ID'),
+ 'value_claim_id'
=> $claim_id,
+ 'lang_remark'
=> lang('remark'),
+ 'lang_category'
=> lang('category'),
+ 'lang_save'
=> lang('save'),
+ 'lang_cancel'
=> lang('cancel'),
+ 'lang_apply'
=> lang('apply'),
+ 'value_remark'
=> $values['remark'],
+ 'value_cat'
=> $values['cat'],
+ 'lang_remark_statustext' =>
lang('Enter a remark for this claim'),
+ 'lang_apply_statustext' =>
lang('Apply the values'),
+ 'lang_cancel_statustext' =>
lang('Leave the claim untouched and return back to the list'),
+ 'lang_save_statustext' =>
lang('Save the claim and return back to the list'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the claim belongs to. To do not use a category select
NO CATEGORY'),
+ 'select_name'
=> 'values[cat_id]',
+ 'cat_list'
=> $this->bo->select_category_list('select',$this->cat_id)
+ );
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('Tenant claim') . ': ' . ($claim_id?lang('edit claim'):lang('add claim'));
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ function delete()
+ {
+
+ if(!$this->acl_delete)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
+ }
+
+
+ $claim_id =
get_var('claim_id',array('POST','GET'));
+ $delete = get_var('delete',array('POST'));
+ $confirm = get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uitenant_claim.index'
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($claim_id);
+// Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant_claim.delete&claim_id='
. $claim_id),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('Tenant claim');
+ $function_msg =
lang('delete claim');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ function view()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $claim_id =
get_var('claim_id',array('POST','GET'));
+
+ $this->boproject=
CreateObject($this->currentapp.'.boproject');
+
$GLOBALS['phpgw']->xslttpl->add_file(array('tenant_claim'));
+
+ $values = $this->bo->read_single($claim_id);
+
+ $project_values =
$this->boproject->read_single($values['project_id']);
+
+ $table_header_workorder[] = array
+ (
+ 'lang_workorder_id' =>
lang('Workorder'),
+ 'lang_budget' =>
lang('Budget'),
+ 'lang_calculation' =>
lang('Calculation'),
+ 'lang_vendor' =>
lang('Vendor'),
+ 'lang_charge_tenant' => lang('Charge
tenant'),
+ 'lang_select' =>
lang('Select')
+ );
+
+ $bolocation =
CreateObject($this->currentapp.'.bolocation');
+
+ $location_data=$bolocation->initiate_ui_location(array(
+ 'values' =>
$project_values['location_data'],
+ 'type_id' =>
count(explode('-',$project_values['location_data']['location_code'])),
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' =>
$project_values['location_data']['tenant_id'],
+ 'lookup_type' => 'view',
+ 'lookup_entity' =>
$this->bocommon->get_lookup_entity('project'),
+ 'entity_data' =>
$project_values['p']
+ ));
+
+ if($project_values['contact_phone'])
+ {
+ for
($i=0;$i<count($location_data['location']);$i++)
+ {
+
if($location_data['location'][$i]['input_name'] == 'contact_phone')
+ {
+
unset($location_data['location'][$i]['value']);
+ }
+ }
+ }
+
+
+ if($project_values['location_data']['tenant_id'] &&
!$values['tenant_id']):
+ {
+ $values['tenant_id'] =
$project_values['location_data']['tenant_id'];
+ $values['last_name'] =
$project_values['location_data']['last_name'];
+ $values['first_name'] =
$project_values['location_data']['first_name'];
+ }
+ elseif($values['tenant_id']):
+ {
+ $tenant=
$this->bocommon->read_single_tenant($values['tenant_id']);
+ $values['last_name'] =
$tenant['last_name'];
+ $values['first_name'] =
$tenant['first_name'];
+ }
+ endif;
+
+
+ if($values['workorder'] &&
$project_values['workorder_budget'])
+ {
+ foreach ($values['workorder'] as $workorder_id)
+ {
+ for
($i=0;$i<count($project_values['workorder_budget']);$i++)
+ {
+
if($project_values['workorder_budget'][$i]['workorder_id'] == $workorder_id)
+ {
+
$project_values['workorder_budget'][$i]['selected'] = True;
+ }
+ }
+ }
+ }
+
+
+ for
($i=0;$i<count($project_values['workorder_budget']);$i++)
+ {
+ $claimed=
$this->bo->check_claim_workorder($project_values['workorder_budget'][$i]['workorder_id']);
+
+ if($claimed)
+ {
+
$project_values['workorder_budget'][$i]['claimed'] = $claimed;
+ }
+ }
+
+
+
+
$b_account_data=$this->bocommon->initiate_ui_budget_account_lookup(array(
+ 'b_account_id' =>
$values['b_account_id'],
+ 'b_account_name' =>
$values['b_account_name'],
+ 'type' => 'view'));
+
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'table_header_workorder' =>
$table_header_workorder,
+ 'lang_no_workorders' =>
lang('No workorder bugdet'),
+ 'workorder_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.view'),
+ 'lang_start_date'
=> lang('Project start date'),
+ 'value_start_date'
=> $project_values['start_date'],
+
+ 'lang_end_date'
=> lang('Project end date'),
+ 'value_end_date'
=> $project_values['end_date'],
+
+ 'lang_charge_tenant' =>
lang('Charge tenant'),
+ 'charge_tenant'
=> $project_values['charge_tenant'],
+
+ 'lang_power_meter'
=> lang('Power meter'),
+ 'value_power_meter'
=> $project_values['power_meter'],
+
+ 'lang_budget'
=> lang('Budget'),
+ 'value_budget'
=> $project_values['budget'],
+
+ 'lang_reserve'
=> lang('reserve'),
+ 'value_reserve'
=> $project_values['reserve'],
+ 'lang_reserve_statustext' =>
lang('Enter the reserve'),
+
+ 'lang_reserve_remainder' =>
lang('reserve remainder'),
+ 'value_reserve_remainder' =>
$reserve_remainder,
+ 'value_reserve_remainder_percent'=>
$remainder_percent,
+
+ 'location_data'
=> $location_data,
+ 'location_type'
=> 'view',
+
+ 'lang_project_id'
=> lang('Project ID'),
+ 'value_project_id'
=> $project_values['project_id'],
+ 'lang_name'
=> lang('Name'),
+ 'value_name'
=> $project_values['name'],
+
+ 'lang_descr'
=> lang('Description'),
+
+ 'sum_workorder_budget' =>
$project_values['sum_workorder_budget'],
+ 'sum_workorder_calculation' =>
$project_values['sum_workorder_calculation'],
+ 'workorder_budget'
=> $project_values['workorder_budget'],
+ 'sum_workorder_actual_cost' =>
$project_values['sum_workorder_actual_cost'],
+ 'lang_actual_cost'
=> lang('Actual cost'),
+ 'lang_coordinator'
=> lang('Coordinator'),
+ 'lang_sum'
=> lang('Sum'),
+ 'select_user_name'
=> 'project_values[coordinator]',
+ 'lang_no_user'
=> lang('Select coordinator'),
+ 'user_list'
=>
$this->bocommon->get_user_list('select',$project_values['coordinator'],$extra=False,$default=False,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1),
+
+ 'status_list'
=> $this->boproject->select_status_list('select',$project_values['status']),
+ 'lang_no_status'
=> lang('Select status'),
+ 'lang_status'
=> lang('Status'),
+
+ 'currency'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
+
+ 'lang_contact_phone' =>
lang('Contact phone'),
+ 'contact_phone'
=> $project_values['contact_phone'],
+
+ 'b_account_data'
=> $b_account_data,
+
+ 'cat_list_project'
=>
$this->boproject->select_category_project_list('select',$project_values['cat_id']),
+
+//------------------
+
+ 'lang_status'
=> lang('Status'),
+ 'status_list'
=> $this->bo->get_status_list(array('format' => 'select', 'selected' =>
$values['status'],'default' => 'open')),
+
+ 'lang_amount'
=> lang('amount'),
+ 'value_amount'
=> $values['amount'],
+
+ 'lang_tenant'
=> lang('tenant'),
+ 'value_tenant_id'
=> $values['tenant_id'],
+ 'value_last_name'
=> $values['last_name'],
+ 'value_first_name'
=> $values['first_name'],
+ 'size_last_name'
=> strlen($values['last_name']),
+ 'size_first_name'
=> strlen($values['first_name']),
+
+ 'lang_claim_id'
=> lang('ID'),
+ 'value_claim_id'
=> $claim_id,
+ 'lang_remark'
=> lang('remark'),
+ 'lang_category'
=> lang('category'),
+ 'lang_save'
=> lang('save'),
+ 'lang_cancel'
=> lang('cancel'),
+ 'lang_apply'
=> lang('apply'),
+ 'value_remark'
=> $values['remark'],
+ 'value_cat'
=> $values['cat'],
+ 'cat_list'
=> $this->bo->select_category_list('select',$values['cat_id']),
+
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant_claim.index'),
+ 'lang_done' => lang('done'),
+ 'value_date' =>
$GLOBALS['phpgw']->common->show_date($tenant_claim['entry_date'])
+
+ );
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('Tenant claim') . ': ' . ($claim_id?lang('edit claim'):lang('add claim'));
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+
+
+ }
+?>
Index: property/inc/class.uitts.inc.php
diff -u property/inc/class.uitts.inc.php:1.27
property/inc/class.uitts.inc.php:1.28
--- property/inc/class.uitts.inc.php:1.27 Tue Jan 3 13:00:54 2006
+++ property/inc/class.uitts.inc.php Fri Jan 27 14:05:43 2006
@@ -1,1121 +1,1121 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage helpdesk
- * @version $Id: class.uitts.inc.php,v 1.27 2006/01/03 13:00:54 sigurdne
Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uitts
- {
- var $public_functions = array
- (
- 'index' => True,
- 'view' => True,
- 'add' => True,
- 'delete' => True,
- 'excel' => True
- );
-
- function uitts()
- {
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
-
- $this->bo =
CreateObject($this->currentapp.'.botts',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
-
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
- $this->acl2_location = '.ticket';
- $this->acl_read =
$this->acl2->check('.ticket',1);
- $this->acl_add =
$this->acl2->check('.ticket',2);
- $this->acl_edit =
$this->acl2->check('.ticket',4);
- $this->acl_delete =
$this->acl2->check('.ticket',8);
- $this->acl_manage =
$this->acl2->check('.ticket',16);
-
- $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->user_filter =
$this->bo->user_filter;
- $this->cat_id =
$this->bo->cat_id;
- $this->district_id =
$this->bo->district_id;
- $this->allrows =
$this->bo->allrows;
- $this->start_date =
$this->bo->start_date;
- $this->end_date =
$this->bo->end_date;
-
- $this->menu->sub ='ticket';
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' => $this->filter,
- 'user_filter'=> $this->user_filter,
- 'cat_id' => $this->cat_id,
- 'district_id' => $this->district_id,
- 'allrows' => $this->allrows,
- 'start_date' => $this->start_date,
- 'end_date' => $this->end_date
- );
- $this->bo->save_sessiondata($data);
- }
-
-
- function excel()
- {
- $start_date = urldecode($this->start_date);
- $end_date = urldecode($this->end_date);
-
- $this->bo->allrows = True;
- $list = $this->bo->read($start_date,$end_date);
-
- if (isset($list) AND is_array($list))
- {
- $i=0;
- foreach($list as $entry)
- {
- if($entry['subject'])
- {
- $list[$i]['category'] =
$entry['subject'];
- }
-
- if (isset($entry['child_date']) AND
is_array($entry['child_date']))
- {
- $j=0;
- foreach($entry['child_date'] as
$date)
- {
-
if($date['date_info'][0]['descr'])
- {
-
$list[$i]['date_' . $j]=$date['date_info'][0]['entry_date'];
-
$name_temp['date_' . $j]=True;
-
$descr_temp[$date['date_info'][0]['descr']]=True;
- }
- $j++;
- }
- }
- $i++;
- }
- }
-//_debug_array($descr_temp);
-
- $name = array('id',
- 'category',
- 'location_code',
- 'address',
- 'user',
- 'assignedto',
- 'timestampopened'
- );
-
- while (is_array($name_temp) && list($name_entry,) =
each($name_temp))
- {
- array_push($name,$name_entry);
- }
-
- array_push($name,'finnish_date','delay');
-
- $descr = array(lang('ID'),
- lang('category'),
- lang('location'),
- lang('address'),
- lang('user'),
- lang('Assigned to'),
- lang('Started')
- );
-
- while (is_array($descr_temp) && list($descr_entry,) =
each($descr_temp))
- {
- array_push($descr,$descr_entry);
- }
-
- array_push($descr,lang('finnish date'),lang('delay'));
-
-//_debug_array($descr);
-
- $this->bocommon->excel($list,$name,$descr);
- }
-
-
- function index()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- if(get_var('edit_status',array('POST','GET')))
- {
- if(!$this->acl_edit)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=4&acl_location='
. $this->acl2_location);
- }
-
- $new_status =
get_var('new_status',array('POST','GET'));
- $id = get_var('id',array('POST','GET'));
- $so2 =
CreateObject($this->currentapp.'.sotts2');
- $receipt =
$so2->update_status(array('status'=>$new_status),$id);
-
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp,$receipt);
- }
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('tts',
-
'menu',
-
'nextmatchs'));
-
-
- $second_display =
get_var('second_display',array('POST','GET'));
-
- $default_category =
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['default_district'];
- $default_status =
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['tts_status'];
- $start_date = urldecode($this->start_date);
- $end_date = urldecode($this->end_date);
-
- if ($default_category && !$second_display &&
!$this->district_id)
- {
- $this->bo->district_id = $default_category;
- $this->district_id =
$default_category;
- }
-
- if ($default_status && !$second_display)
- {
- $this->bo->filter = $default_status;
- $this->filter = $default_status;
- }
-
- $bgcolor['1'] = '#dadada';
- $bgcolor['2'] = '#dad0d0';
- $bgcolor['3'] = '#dacaca';
- $bgcolor['4'] = '#dac0c0';
- $bgcolor['5'] = '#dababa';
- $bgcolor['6'] = '#dab0b0';
- $bgcolor['7'] = '#daaaaa';
- $bgcolor['8'] = '#da9090';
- $bgcolor['9'] = '#da8a8a';
- $bgcolor['10'] = '#da7a7a';
-
-
- $links = $this->menu->links();
-
- $ticket_list = $this->bo->read($start_date,$end_date);
-
- $uicols=$this->bo->uicols;
-
-//_debug_array($uicols);
-//_debug_array($ticket_list);
- while (is_array($ticket_list) && list(,$ticket) =
each($ticket_list))
- {
- if($ticket['subject'])
- {
- $first= $ticket['subject'];
- }
- else
- {
- $first= $ticket['category'];
- }
-
- if ($ticket['status']=='O')
- {
- $status = lang('Open');
- $text_edit_status = lang('Close');
- $new_status = 'X';
- }
- else
- {
- $status = lang('Closed');
- $text_edit_status = lang('Open');
- $new_status = 'O';
- }
-
-
- $link_status_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uitts.index',
- 'id'
=> $ticket['id'],
- 'edit_status' => true,
- 'new_status' =>
$new_status,
- 'second_display'
=> true,
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'filter'
=>$this->filter,
- 'user_filter'
=>$this->user_filter,
- 'query'
=>$this->query,
- 'district_id' =>
$this->district_id,
- 'allrows'
=>$this->allrows
- );
-
-
- $content[] = array
- (
- 'id'
=> $ticket['id'],
- 'bgcolor'
=> $bgcolor[$ticket['priority']],
- 'new_ticket'
=> $ticket['new_ticket'],
- 'priostr'
=> str_repeat("||", $ticket['priority']),
- 'first'
=> $first,
- 'location_code'
=> $ticket['location_code'],
- 'address'
=> $ticket['address'],
- 'date'
=> $ticket['timestampopened'],
- 'finnish_date'
=> $ticket['finnish_date'],
- 'delay'
=> $ticket['delay'],
- 'user'
=> $ticket['user'],
- 'assignedto'
=> $ticket['assignedto'],
- 'child_date'
=> $ticket['child_date'],
- 'link_view'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitts.view&id='
. $ticket['id']),
- 'lang_view_statustext' =>
lang('view the ticket'),
- 'text_view'
=> lang('view'),
- 'status'
=> $status,
- 'link_edit_status'
=> $GLOBALS['phpgw']->link('/index.php',$link_status_data),
- 'lang_edit_status'
=> lang('Edit status'),
- 'text_edit_status'
=> $text_edit_status
- );
- }
-
- $table_header[] = array
- (
- 'sort_priority' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'priority',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uitts.index',
-
'cat_id'
=>$this->cat_id,
-
'filter'
=>$this->filter,
-
'user_filter'
=>$this->user_filter,
-
'district_id' =>
$this->district_id,
-
'query'
=>$this->query,
-
'second_display'
=> true,
-
'allrows'=>$this->allrows,
-
'start_date'
=>$start_date,
-
'end_date'
=>$end_date
-
)
-
)),
-
- 'lang_priority' => lang('Priority'),
- 'lang_priority_statustext' =>
lang('Sort the tickets by their priority'),
-
- 'sort_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'fm_tts_tickets.id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uitts.index',
-
'cat_id'
=>$this->cat_id,
-
'filter'
=>$this->filter,
-
'user_filter'
=>$this->user_filter,
-
'district_id' =>
$this->district_id,
-
'query'
=>$this->query,
-
'second_display'
=> true,
-
'allrows'=>$this->allrows,
-
'start_date'
=>$start_date,
-
'end_date'
=>$end_date
-
)
-
)),
-
- 'lang_id' => lang('ID'),
- 'lang_id_statustext' => lang('Sort
the tickets by their ID'),
-
- 'lang_subject' =>
lang('Subject'),
- 'lang_time_created' => lang('Started'),
- 'lang_view' => lang('view'),
- 'lang_location_code' => lang('Location'),
- 'lang_address' => lang('Address'),
- 'lang_user' => lang('user'),
- 'sort_assigned_to' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'assignedto',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uitts.index',
-
'cat_id'
=>$this->cat_id,
-
'filter'
=>$this->filter,
-
'user_filter'
=>$this->user_filter,
-
'district_id' =>
$this->district_id,
-
'query'
=>$this->query,
-
'second_display'
=> true,
-
'allrows'=>$this->allrows,
-
'start_date'
=>$start_date,
-
'end_date'
=>$end_date
-
)
-
)),
- 'lang_assigned_to' =>
lang('Assigned to'),
- 'sort_opened_by' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'user_lid',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uitts.index',
-
'cat_id'
=>$this->cat_id,
-
'filter'
=>$this->filter,
-
'user_filter'
=>$this->user_filter,
-
'district_id' =>
$this->district_id,
-
'query'
=>$this->query,
-
'second_display'
=> true,
-
'allrows'=>$this->allrows,
-
'start_date'
=>$start_date,
-
'end_date'
=>$end_date
-
)
-
)),
- 'sort_date' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'fm_tts_tickets.entry_date',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uitts.index',
-
'cat_id'
=>$this->cat_id,
-
'filter'
=>$this->filter,
-
'user_filter'
=>$this->user_filter,
-
'district_id' =>
$this->district_id,
-
'query'
=>$this->query,
-
'second_display'
=> true,
-
'allrows'=>$this->allrows,
-
'start_date'
=>$start_date,
-
'end_date'
=>$end_date
-
)
-
)),
- 'sort_finnish_date' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'finnish_date',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uitts.index',
-
'cat_id'
=>$this->cat_id,
-
'filter'
=>$this->filter,
-
'user_filter'
=>$this->user_filter,
-
'district_id' =>
$this->district_id,
-
'query'
=>$this->query,
-
'second_display'
=> true,
-
'allrows'=>$this->allrows,
-
'start_date'
=>$start_date,
-
'end_date'
=>$end_date
-
)
-
)),
- 'lang_finnish_date' =>
lang('finnish date'),
- 'lang_delay' =>
lang('delay'),
- 'lang_finnish_statustext'=> lang('presumed
finnish date'),
- 'lang_opened_by' => lang('Opened
by'),
- 'lang_status' => lang('Status')
- );
-
- for ($i=0;$i<count($uicols);$i++)
- {
- $table_header[0]['extra'][$i]['header']
= $uicols[$i];
- }
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_statustext' => lang('add a ticket'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitts.add')
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uitts.index',
- 'second_display' => true,
- 'sort' =>$this->sort,
- 'order' =>$this->order,
- 'cat_id' =>$this->cat_id,
- 'filter' =>$this->filter,
- 'user_filter'
=>$this->user_filter,
- 'query' =>$this->query,
- 'district_id' =>
$this->district_id,
- 'start_date' =>$start_date,
- 'end_date' =>$end_date,
- 'allrows' =>$this->allrows
- );
-
- $receipt =
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp);
-
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp,'');
-
- $GLOBALS['phpgw']->preferences->read_repository();
- if
($GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['refreshinterval'])
- {
- $autorefresh =
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['refreshinterval'].';
URL='.$GLOBALS['phpgw']->link('/index.php',$link_data);
- }
-
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $link_date_search =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.date_search');
-
- $link_excel = array
- (
- 'menuaction' =>
$this->currentapp.'.uitts.excel',
- 'second_display' => true,
- 'sort' =>$this->sort,
- 'order' =>$this->order,
- 'cat_id' =>$this->cat_id,
- 'filter' =>$this->filter,
- 'user_filter'
=>$this->user_filter,
- 'query' =>$this->query,
- 'district_id' =>
$this->district_id,
- 'allrows'
=>$this->allrows,
- 'start_date' =>$start_date,
- 'end_date' =>$end_date,
- 'start' =>$this->start
- );
-
-
if($GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['group_filters'])
- {
- $group_filters = 'select';
-
$GLOBALS['phpgw']->xslttpl->add_file(array('search_field_grouped'));
- }
- else
- {
- $group_filters = 'filter';
-
$GLOBALS['phpgw']->xslttpl->add_file(array('search_field'));
- }
-
- $data = array
- (
- 'group_filters' =>
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['group_filters'],
- 'lang_excel' =>
'excel',
- 'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
- 'lang_excel_help' =>
lang('Download table to MS Excel'),
-
- 'start_date'
=>$start_date,
- 'end_date'
=>$end_date,
- 'lang_none'
=>lang('None'),
- 'lang_date_search' =>
lang('Date search'),
- 'lang_date_search_help' =>
lang('Narrow the search by dates'),
- 'link_date_search' =>
$link_date_search,
-
- 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
-
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'autorefresh'
=> $autorefresh,
- 'links'
=> $links,
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($ticket_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the ticket belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=> $this->bo->select_category_list($group_filters,$this->cat_id),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'filter_name'
=> 'filter',
- 'filter_list'
=> $this->bo->filter(array('format' => $group_filters, 'filter'=>
$this->filter,'default' => 'open')),
- 'lang_show_all'
=> lang('Open'),
- 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add,
-
- 'district_list'
=> $this->bocommon->select_district_list($group_filters,$this->district_id),
- 'lang_no_district'
=> lang('no district'),
- 'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
- 'select_district_name' =>
'district_id',
-
- 'lang_user_statustext' =>
lang('Assigned to'),
- 'select_user_name'
=> 'user_filter',
- 'lang_no_user'
=> lang('No user'),
- 'user_list'
=>
$this->bocommon->get_user_list_right2($group_filters,4,$this->user_filter,$this->acl2_location,'',$default='')
- );
-
- $appname
= lang('helpdesk');
- $function_msg =
lang('list ticket');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function add()
- {
- if(!$this->acl_add)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
- }
-
- $bolocation =
CreateObject($this->currentapp.'.bolocation');
-
- $values = get_var('values',array('POST'));
- $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
- $insert_record_entity =
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp);
-
- for ($j=0;$j<count($insert_record_entity);$j++)
- {
-
$insert_record['extra'][$insert_record_entity[$j]] =
$insert_record_entity[$j];
- }
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('tts'));
-
-//_debug_array($insert_record);
- if ($values['save'])
- {
- for ($i=0;
$i<count($insert_record['location']); $i++)
- {
-
if($_POST[$insert_record['location'][$i]])
- {
-
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
- }
- }
-
- while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
- {
- if($_POST[$key])
- {
- $values['extra'][$column]
= $_POST[$key];
- }
- }
-
- $values['street_name'] =
$_POST['street_name'];
- $values['street_number'] =
$_POST['street_number'];
- $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
-
-/* if(!$values['subject'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please type a subject for this ticket
!'));
- }
-
-*/ if(!$values['assignedto'] &&
!$values['group_id'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a person or a group to
handle the ticket !'));
- }
-
- if(!$values['cat_id'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
- }
-
-/* if(!$values['details'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please give som details !'));
- }
-*/
- if(!$values['location']['loc1'] &&
!$values['extra']['p_num'])
- {
-
$receipt['error'][]=array('msg'=>lang('Pleace select a location - or an entity
!'));
- }
-
- if(!$receipt['error'])
- {
- $receipt = $this->bo->add($values);
-
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp,$receipt);
-
$GLOBALS['phpgw']->session->appsession('session_data','fm_tts','');
- header('Location: '.
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitts.index'));
- }
- else
- {
- if($values['location'])
- {
- $location_code=implode("-",
$values['location']);
- $values['location_data'] =
$bolocation->read_single($location_code,$values['extra']);
- }
- if($values['extra']['p_num'])
- {
-
$values['p'][$values['extra']['p_entity_id']]['p_num']=$values['extra']['p_num'];
-
$values['p'][$values['extra']['p_entity_id']]['p_entity_id']=$values['extra']['p_entity_id'];
-
$values['p'][$values['extra']['p_entity_id']]['p_cat_id']=$values['extra']['p_cat_id'];
-
$values['p'][$values['extra']['p_entity_id']]['p_cat_name']=$_POST['entity_cat_name_'.$values['extra']['p_entity_id']];
- }
- }
- }
-
- $location_data=$bolocation->initiate_ui_location(array(
- 'values' =>
$values['location_data'],
- 'type_id' => -1,
// calculated from location_types
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' => True,
- 'lookup_type' => 'form',
- 'lookup_entity' =>
$this->bocommon->get_lookup_entity('ticket'),
- 'entity_data' => $values['p']
- ));
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uitts.add'
- );
-
- if(!$values['assignedto'])
- {
- $values['assignedto']=
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['assigntodefault'];
- }
- if(!$values['group_id'])
- {
- $values['group_id']=
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['groupdefault'];
- }
-
- if(!$values['cat_id'])
- {
- $this->cat_id =
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['tts_category'];
- }
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- switch(substr($dateformat,0,1))
- {
- case 'M':
- $dateformat_validate=
"javascript:vDateType='1'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
- $onBlur =
"DateFormat(this,this.value,event,true,'1')";
- break;
- case 'y':
-
$dateformat_validate="javascript:vDateType='2'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
- $onBlur =
"DateFormat(this,this.value,event,true,'2')";
- break;
- case 'D':
-
$dateformat_validate="javascript:vDateType='3'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
- $onBlur =
"DateFormat(this,this.value,event,true,'3')";
- break;
- }
-
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'lang_dateformat'
=> strtolower($dateformat),
- 'dateformat_validate' =>
$dateformat_validate,
- 'onKeyUp'
=> $onKeyUp,
- 'onBlur'
=> $onBlur,
- 'dateformat_source'
=> './'.$this->currentapp.'/inc/dateformat.js',
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'location_data'
=> $location_data,
- 'lang_assign_to'
=> lang('Assign to'),
- 'lang_no_user'
=> lang('Select user'),
- 'lang_user_statustext' =>
lang('Select the user the selection belongs to. To do not use a user select NO
USER'),
- 'select_user_name'
=> 'values[assignedto]',
- 'user_list'
=>
$this->bocommon->get_user_list_right2('select',4,$values['assignedto'],$this->acl2_location),
-
- 'lang_group'
=> lang('Group'),
- 'lang_no_group'
=> lang('No group'),
- 'group_list'
=>
$this->bocommon->get_group_list('select',$values['group_id'],$start=-1,$sort='ASC',$order='account_firstname',$query='',$offset=-1),
- 'select_group_name'
=> 'values[group_id]',
-
- 'lang_priority'
=> lang('Priority'),
- 'lang_priority_statustext' =>
lang('Select the priority the selection belongs to.'),
- 'select_priority_name' =>
'values[priority]',
- 'priority_list'
=> $this->bo->get_priority_list($values['priority']),
-
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitts.index'),
- 'lang_subject'
=> lang('Subject'),
- 'lang_subject_statustext' =>
lang('Enter the subject of this ticket'),
-
- 'lang_details'
=> lang('Details'),
- 'lang_details_statustext' =>
lang('Enter the details of this ticket'),
- 'lang_category'
=> lang('category'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_details'
=> $values['details'],
- 'value_subject'
=> $values['subject'],
-
- 'lang_finnish_date'
=> lang('finnish date'),
- 'value_finnish_date' =>
$values['finnish_date'],
-
- 'lang_done_statustext' =>
lang('Back to the ticket list'),
- 'lang_save_statustext' =>
lang('Save the ticket'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the building belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'values[cat_id]',
- 'lang_town_statustext' =>
lang('Select the part of town the building belongs to. To do not use a part of
town - select NO PART OF TOWN'),
- 'lang_part_of_town'
=> lang('Part of town'),
- 'lang_no_part_of_town' =>
lang('No part of town'),
- 'cat_list'
=> $this->bo->select_category_list('select',$this->cat_id),
- 'mailnotification'
=> $this->bo->config->config_data['mailnotification'],
- 'lang_mailnotification' =>
lang('Send e-mail'),
- 'lang_mailnotification_statustext' =>
lang('Choose to send mailnotification'),
- 'pref_send_mail'
=>
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['tts_user_mailnotification'],
- );
-
-//_debug_array($data);
- $appname
= lang('helpdesk');
- $function_msg =
lang('add ticket');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
- $GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('add'
=> $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- function view()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $bolocation =
CreateObject($this->currentapp.'.bolocation');
-
- $id = get_var('id',array('GET'));
- $values = get_var('values',array('POST','GET'));
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('tts'));
-
- if($values['save'])
- {
- if(!$this->acl_edit)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=4&acl_location='
. $this->acl2_location);
- }
-
- $so2 =
CreateObject($this->currentapp.'.sotts2');
- $receipt = $so2->update_ticket($values,$id);
- }
-
- $ticket = $this->bo->read_single($id);
-
- $additional_notes =
$this->bo->read_additional_notes($id);
- $record_history = $this->bo->read_record_history($id);
-
- $request_link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uirequest.edit',
- 'bypass' => true,
- 'location_code' =>
$ticket['location_code'],
- 'p_num' =>
$ticket['p_num'],
- 'p_entity_id' =>
$ticket['p_entity_id'],
- 'p_cat_id' =>
$ticket['p_cat_id'],
- 'tenant_id' =>
$ticket['tenant_id'],
- 'origin' => 'tts',
- 'origin_id' => $id
- );
-
- for ($i=0;$i<count($ticket['origin']);$i++)
- {
- if($ticket['origin'][$i]['type'] ==
'project')
- {
- $order_link_data = array
- (
- 'menuaction'
=> $this->currentapp.'.uiproject.edit',
- 'id'
=> $ticket['origin'][$i]['data'][0]['id']
- );
- break;
- }
- }
-
-
- if(!$order_link_data)
- {
- $order_link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiproject.edit',
- 'bypass' => true,
- 'location_code' =>
$ticket['location_code'],
- 'p_num' =>
$ticket['p_num'],
- 'p_entity_id' =>
$ticket['p_entity_id'],
- 'p_cat_id' =>
$ticket['p_cat_id'],
- 'tenant_id' =>
$ticket['tenant_id'],
- 'origin' =>
'tts',
- 'origin_id' => $id
- );
- }
-
- $form_link = array
- (
- 'menuaction' =>
$this->currentapp.'.uitts.view',
- 'id' => $id
- );
-
- $table_header_history[] = array
- (
- 'lang_date' => lang('Date'),
- 'lang_user' => lang('User'),
- 'lang_action' => lang('Action'),
- 'lang_new_value' => lang('New value')
- );
-
- $table_header_additional_notes[] = array
- (
- 'lang_count' => '#',
- 'lang_date' => lang('Date'),
- 'lang_user' => lang('User'),
- 'lang_note' => lang('Note'),
- );
-
-//_debug_array($ticket['location_data']);
-
- $location_data=$bolocation->initiate_ui_location(array(
- 'values' =>
$ticket['location_data'],
- 'type_id' =>
count(explode('-',$ticket['location_data']['location_code'])),
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' =>
$ticket['location_data']['tenant_id'],
- 'lookup_type' => 'view',
- 'lookup_entity' =>
$this->bocommon->get_lookup_entity('ticket'),
- 'entity_data' => $ticket['p']
- ));
-
-
- if($ticket['contact_phone'])
- {
- for
($i=0;$i<count($location_data['location']);$i++)
- {
-
if($location_data['location'][$i]['input_name'] == 'contact_phone')
- {
-
unset($location_data['location'][$i]['value']);
- }
- }
- }
-
-
- if ($ticket['cat_id'])
- {
- $this->cat_id = $ticket['cat_id'];
- }
-
-
-/*
- if($ticket['request_id'])
- {
- $request_lookup_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uirequest.view'
- );
- }
- if($ticket['project_id'])
- {
- $project_lookup_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiproject.view'
- );
- }
-
-*/
- $start_entity =
$this->bocommon->get_start_entity('ticket');
-//_debug_array($start_entity);
-
- if (isset($start_entity) AND is_array($start_entity))
- {
- $i=0;
- foreach($start_entity as $entry)
- {
- $link_entity[$i]['link'] =
$GLOBALS['phpgw']->link('/index.php',array
- (
- 'menuaction' =>
$this->currentapp.'.uientity.edit',
- 'bypass'
=> true,
- 'location_code' =>
$ticket['location_code'],
- 'entity_id'
=> $entry['id'],
- 'p_num'
=> $ticket['p_num'],
- 'p_entity_id' =>
$ticket['p_entity_id'],
- 'p_cat_id'
=> $ticket['p_cat_id'],
- 'tenant_id'
=> $ticket['tenant_id'],
- 'origin'
=> 'tts',
- 'origin_id'
=> $id
- ));
- $link_entity[$i]['name'] =
$entry['name'];
- $i++;
- }
- }
-
-//_debug_array($link_entity);
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- switch(substr($dateformat,0,1))
- {
- case 'M':
- $dateformat_validate=
"javascript:vDateType='1'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
- $onBlur =
"DateFormat(this,this.value,event,true,'1')";
- break;
- case 'y':
-
$dateformat_validate="javascript:vDateType='2'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
- $onBlur =
"DateFormat(this,this.value,event,true,'2')";
- break;
- case 'D':
-
$dateformat_validate="javascript:vDateType='3'";
- $onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
- $onBlur =
"DateFormat(this,this.value,event,true,'3')";
- break;
- }
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
-
- if (isset($ticket['origin']) AND
is_array($ticket['origin']))
- {
- for ($i=0;$i<count($ticket['origin']);$i++)
- {
-
$ticket['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
. $ticket['origin'][$i]['link']);
-
if(substr($ticket['origin'][$i]['type'],0,6)=='entity')
- {
- $type =
explode("_",$ticket['origin'][$i]['type']);
- $entity_id = $type[1];
- $cat_id = $type[2];
-
- if(!is_object($boadmin_entity))
- {
- $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
- }
- $entity_category =
$boadmin_entity->read_single_category($entity_id,$cat_id);
- $ticket['origin'][$i]['descr']
= $entity_category['name'];
- }
- else
- {
- $ticket['origin'][$i]['descr']=
lang($ticket['origin'][$i]['type']);
- }
- }
- }
-
- $data = array
- (
- 'value_origin'
=> $ticket['origin'],
- 'value_origin_type'
=> $origin,
- 'value_origin_id'
=> $origin_id,
-
- 'lang_dateformat'
=> strtolower($dateformat),
- 'dateformat_validate' =>
$dateformat_validate,
- 'onKeyUp'
=> $onKeyUp,
- 'onBlur'
=> $onBlur,
- 'dateformat_source'
=> './'.$this->currentapp.'/inc/dateformat.js',
- 'lang_finnish_date'
=> lang('finnish date'),
- 'value_finnish_date' =>
$ticket['finnish_date'],
-
- 'link_entity'
=> $link_entity,
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
-
- 'lang_request'
=> lang('Request'),
- 'lang_request_statustext' =>
lang('Link to the request originatet from this ticket'),
- 'link_request'
=> $GLOBALS['phpgw']->link('/index.php',$request_lookup_data),
- 'value_request_id'
=> $ticket['request_id'],
-
- 'lang_project'
=> lang('Project'),
- 'lang_project_statustext' =>
lang('Link to the project originatet from this ticket'),
- 'link_project'
=> $GLOBALS['phpgw']->link('/index.php',$project_lookup_data),
- 'value_project_id'
=> $ticket['project_id'],
-
- 'location_data'
=> $location_data,
- 'lang_location_code' =>
lang('Location Code'),
-
- 'lang_ticket'
=> lang('Ticket'),
- 'table_header_additional_notes' =>
$table_header_additional_notes,
- 'table_header_history' =>
$table_header_history,
- 'lang_status'
=> lang('Status'),
- 'status_name'
=> 'values[status]',
- 'status_list'
=> $this->bo->get_status_list($ticket['status']),
- 'lang_status_statustext' =>
lang('Set the status of the ticket'),
-
- 'lang_no_user'
=> lang('Select user'),
- 'lang_user_statustext' =>
lang('Select the user the selection belongs to. To do not use a user select NO
USER'),
- 'select_user_name'
=> 'values[assignedto]',
- 'user_list'
=>
$this->bocommon->get_user_list_right2('select',4,$ticket['assignedto'],$this->acl2_location),
-
- 'lang_group'
=> lang('Group'),
- 'lang_no_group'
=> lang('No group'),
- 'group_list'
=>
$this->bocommon->get_group_list('select',$ticket['group_id'],$start=-1,$sort='ASC',$order='account_firstname',$query='',$offset=-1),
- 'select_group_name'
=> 'values[group_id]',
-
- 'lang_priority'
=> lang('Priority'),
- 'value_priority'
=> $ticket['priority'],
- 'lang_priority_statustext' =>
lang('Select the priority the selection belongs to.'),
- 'select_priority_name' =>
'values[priority]',
- 'priority_list'
=> $this->bo->get_priority_list($ticket['priority']),
-
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the building belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'values[cat_id]',
- 'cat_list'
=> $this->bo->select_category_list('select',$this->cat_id),
- 'lang_category'
=> lang('category'),
- 'value_category_name' =>
$ticket['category_name'],
-
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$form_link),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitts.index'),
- 'value_subject'
=> $ticket['subject'],
- 'lang_subject_statustext' =>
lang('update subject'),
- 'value_id'
=> '[ #'. $id . ' ] - ',
-
- 'lang_details'
=> lang('Details'),
- 'value_details'
=> $ticket['details'],
- 'lang_details_statustext' =>
lang('Add new comments'),
-
- 'lang_additional_notes' =>
lang('Additional notes'),
-
- 'lang_new_note'
=> lang('New Note'),
- 'lang_opendate'
=> lang('Open Date'),
- 'value_opendate'
=> $ticket['timestampopened'],
-
- 'lang_assignedfrom'
=> lang('Assigned from'),
- 'value_assignedfrom' =>
$ticket['user_name'],
- 'lang_assignedto'
=> lang('Assigned to'),
- 'value_assignedto'
=> $ticket['assignedto_name'],
-
- 'lang_no_additional_notes' =>
lang('No additional notes'),
- 'lang_history'
=> lang('History'),
- 'lang_no_history'
=> lang('No history for this record'),
- 'additional_notes'
=> $additional_notes,
- 'record_history'
=> $record_history,
- 'request_link'
=> $GLOBALS['phpgw']->link('/index.php',$request_link_data),
- 'order_link'
=> $GLOBALS['phpgw']->link('/index.php',$order_link_data),
-
- 'lang_generate_request' =>
lang('Generate Request'),
- 'lang_generate_request_statustext'
=> lang('Klick this to generate a request with this information'),
- 'lang_generate_order' =>
lang('Generate order'),
- 'lang_generate_order_statustext'
=> lang('Klick this to generate an order with this information'),
-
- 'lang_save'
=> lang('save'),
- 'lang_name'
=> lang('name'),
- 'lang_done'
=> lang('done'),
- 'lang_contact_phone' =>
lang('Contact phone'),
- 'contact_phone'
=> $ticket['contact_phone'],
- 'mailnotification'
=> $this->bo->config->config_data['mailnotification'],
- 'lang_mailnotification' =>
lang('Send e-mail'),
- 'lang_mailnotification_statustext' =>
lang('Choose to send mailnotification'),
- 'pref_send_mail'
=>
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['tts_user_mailnotification'],
- );
-
- $appname
= lang('helpdesk');
- $function_msg =
lang('view ticket detail');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage helpdesk
+ * @version $Id: class.uitts.inc.php,v 1.28 2006/01/27 14:05:43 sigurdne
Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uitts
+ {
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'view' => True,
+ 'add' => True,
+ 'delete' => True,
+ 'excel' => True
+ );
+
+ function uitts()
+ {
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+
+ $this->bo =
CreateObject($this->currentapp.'.botts',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+ $this->acl2_location = '.ticket';
+ $this->acl_read =
$this->acl2->check('.ticket',1);
+ $this->acl_add =
$this->acl2->check('.ticket',2);
+ $this->acl_edit =
$this->acl2->check('.ticket',4);
+ $this->acl_delete =
$this->acl2->check('.ticket',8);
+ $this->acl_manage =
$this->acl2->check('.ticket',16);
+
+ $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->user_filter =
$this->bo->user_filter;
+ $this->cat_id =
$this->bo->cat_id;
+ $this->district_id =
$this->bo->district_id;
+ $this->allrows =
$this->bo->allrows;
+ $this->start_date =
$this->bo->start_date;
+ $this->end_date =
$this->bo->end_date;
+
+ $this->menu->sub ='ticket';
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' => $this->filter,
+ 'user_filter'=> $this->user_filter,
+ 'cat_id' => $this->cat_id,
+ 'district_id' => $this->district_id,
+ 'allrows' => $this->allrows,
+ 'start_date' => $this->start_date,
+ 'end_date' => $this->end_date
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+
+ function excel()
+ {
+ $start_date = urldecode($this->start_date);
+ $end_date = urldecode($this->end_date);
+
+ $this->bo->allrows = True;
+ $list = $this->bo->read($start_date,$end_date);
+
+ if (isset($list) AND is_array($list))
+ {
+ $i=0;
+ foreach($list as $entry)
+ {
+ if($entry['subject'])
+ {
+ $list[$i]['category'] =
$entry['subject'];
+ }
+
+ if (isset($entry['child_date']) AND
is_array($entry['child_date']))
+ {
+ $j=0;
+ foreach($entry['child_date'] as
$date)
+ {
+
if($date['date_info'][0]['descr'])
+ {
+
$list[$i]['date_' . $j]=$date['date_info'][0]['entry_date'];
+
$name_temp['date_' . $j]=True;
+
$descr_temp[$date['date_info'][0]['descr']]=True;
+ }
+ $j++;
+ }
+ }
+ $i++;
+ }
+ }
+//_debug_array($descr_temp);
+
+ $name = array('id',
+ 'category',
+ 'location_code',
+ 'address',
+ 'user',
+ 'assignedto',
+ 'timestampopened'
+ );
+
+ while (is_array($name_temp) && list($name_entry,) =
each($name_temp))
+ {
+ array_push($name,$name_entry);
+ }
+
+ array_push($name,'finnish_date','delay');
+
+ $descr = array(lang('ID'),
+ lang('category'),
+ lang('location'),
+ lang('address'),
+ lang('user'),
+ lang('Assigned to'),
+ lang('Started')
+ );
+
+ while (is_array($descr_temp) && list($descr_entry,) =
each($descr_temp))
+ {
+ array_push($descr,$descr_entry);
+ }
+
+ array_push($descr,lang('finnish date'),lang('delay'));
+
+//_debug_array($descr);
+
+ $this->bocommon->excel($list,$name,$descr);
+ }
+
+
+ function index()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ if(get_var('edit_status',array('POST','GET')))
+ {
+ if(!$this->acl_edit)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=4&acl_location='
. $this->acl2_location);
+ }
+
+ $new_status =
get_var('new_status',array('POST','GET'));
+ $id = get_var('id',array('POST','GET'));
+ $so2 =
CreateObject($this->currentapp.'.sotts2');
+ $receipt =
$so2->update_status(array('status'=>$new_status),$id);
+
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp,$receipt);
+ }
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('tts',
+
'menu',
+
'nextmatchs'));
+
+
+ $second_display =
get_var('second_display',array('POST','GET'));
+
+ $default_category =
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['default_district'];
+ $default_status =
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['tts_status'];
+ $start_date = urldecode($this->start_date);
+ $end_date = urldecode($this->end_date);
+
+ if ($default_category && !$second_display &&
!$this->district_id)
+ {
+ $this->bo->district_id = $default_category;
+ $this->district_id =
$default_category;
+ }
+
+ if ($default_status && !$second_display)
+ {
+ $this->bo->filter = $default_status;
+ $this->filter = $default_status;
+ }
+
+ $bgcolor['1'] = '#dadada';
+ $bgcolor['2'] = '#dad0d0';
+ $bgcolor['3'] = '#dacaca';
+ $bgcolor['4'] = '#dac0c0';
+ $bgcolor['5'] = '#dababa';
+ $bgcolor['6'] = '#dab0b0';
+ $bgcolor['7'] = '#daaaaa';
+ $bgcolor['8'] = '#da9090';
+ $bgcolor['9'] = '#da8a8a';
+ $bgcolor['10'] = '#da7a7a';
+
+
+ $links = $this->menu->links();
+
+ $ticket_list = $this->bo->read($start_date,$end_date);
+
+ $uicols=$this->bo->uicols;
+
+//_debug_array($uicols);
+//_debug_array($ticket_list);
+ while (is_array($ticket_list) && list(,$ticket) =
each($ticket_list))
+ {
+ if($ticket['subject'])
+ {
+ $first= $ticket['subject'];
+ }
+ else
+ {
+ $first= $ticket['category'];
+ }
+
+ if ($ticket['status']=='O')
+ {
+ $status = lang('Open');
+ $text_edit_status = lang('Close');
+ $new_status = 'X';
+ }
+ else
+ {
+ $status = lang('Closed');
+ $text_edit_status = lang('Open');
+ $new_status = 'O';
+ }
+
+
+ $link_status_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uitts.index',
+ 'id'
=> $ticket['id'],
+ 'edit_status' => true,
+ 'new_status' =>
$new_status,
+ 'second_display'
=> true,
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'filter'
=>$this->filter,
+ 'user_filter'
=>$this->user_filter,
+ 'query'
=>$this->query,
+ 'district_id' =>
$this->district_id,
+ 'allrows'
=>$this->allrows
+ );
+
+
+ $content[] = array
+ (
+ 'id'
=> $ticket['id'],
+ 'bgcolor'
=> $bgcolor[$ticket['priority']],
+ 'new_ticket'
=> $ticket['new_ticket'],
+ 'priostr'
=> str_repeat("||", $ticket['priority']),
+ 'first'
=> $first,
+ 'location_code'
=> $ticket['location_code'],
+ 'address'
=> $ticket['address'],
+ 'date'
=> $ticket['timestampopened'],
+ 'finnish_date'
=> $ticket['finnish_date'],
+ 'delay'
=> $ticket['delay'],
+ 'user'
=> $ticket['user'],
+ 'assignedto'
=> $ticket['assignedto'],
+ 'child_date'
=> $ticket['child_date'],
+ 'link_view'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitts.view&id='
. $ticket['id']),
+ 'lang_view_statustext' =>
lang('view the ticket'),
+ 'text_view'
=> lang('view'),
+ 'status'
=> $status,
+ 'link_edit_status'
=> $GLOBALS['phpgw']->link('/index.php',$link_status_data),
+ 'lang_edit_status'
=> lang('Edit status'),
+ 'text_edit_status'
=> $text_edit_status
+ );
+ }
+
+ $table_header[] = array
+ (
+ 'sort_priority' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'priority',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uitts.index',
+
'cat_id'
=>$this->cat_id,
+
'filter'
=>$this->filter,
+
'user_filter'
=>$this->user_filter,
+
'district_id' =>
$this->district_id,
+
'query'
=>$this->query,
+
'second_display'
=> true,
+
'allrows'=>$this->allrows,
+
'start_date'
=>$start_date,
+
'end_date'
=>$end_date
+
)
+
)),
+
+ 'lang_priority' => lang('Priority'),
+ 'lang_priority_statustext' =>
lang('Sort the tickets by their priority'),
+
+ 'sort_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'fm_tts_tickets.id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uitts.index',
+
'cat_id'
=>$this->cat_id,
+
'filter'
=>$this->filter,
+
'user_filter'
=>$this->user_filter,
+
'district_id' =>
$this->district_id,
+
'query'
=>$this->query,
+
'second_display'
=> true,
+
'allrows'=>$this->allrows,
+
'start_date'
=>$start_date,
+
'end_date'
=>$end_date
+
)
+
)),
+
+ 'lang_id' => lang('ID'),
+ 'lang_id_statustext' => lang('Sort
the tickets by their ID'),
+
+ 'lang_subject' =>
lang('Subject'),
+ 'lang_time_created' => lang('Started'),
+ 'lang_view' => lang('view'),
+ 'lang_location_code' => lang('Location'),
+ 'lang_address' => lang('Address'),
+ 'lang_user' => lang('user'),
+ 'sort_assigned_to' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'assignedto',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uitts.index',
+
'cat_id'
=>$this->cat_id,
+
'filter'
=>$this->filter,
+
'user_filter'
=>$this->user_filter,
+
'district_id' =>
$this->district_id,
+
'query'
=>$this->query,
+
'second_display'
=> true,
+
'allrows'=>$this->allrows,
+
'start_date'
=>$start_date,
+
'end_date'
=>$end_date
+
)
+
)),
+ 'lang_assigned_to' =>
lang('Assigned to'),
+ 'sort_opened_by' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'user_lid',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uitts.index',
+
'cat_id'
=>$this->cat_id,
+
'filter'
=>$this->filter,
+
'user_filter'
=>$this->user_filter,
+
'district_id' =>
$this->district_id,
+
'query'
=>$this->query,
+
'second_display'
=> true,
+
'allrows'=>$this->allrows,
+
'start_date'
=>$start_date,
+
'end_date'
=>$end_date
+
)
+
)),
+ 'sort_date' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'fm_tts_tickets.entry_date',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uitts.index',
+
'cat_id'
=>$this->cat_id,
+
'filter'
=>$this->filter,
+
'user_filter'
=>$this->user_filter,
+
'district_id' =>
$this->district_id,
+
'query'
=>$this->query,
+
'second_display'
=> true,
+
'allrows'=>$this->allrows,
+
'start_date'
=>$start_date,
+
'end_date'
=>$end_date
+
)
+
)),
+ 'sort_finnish_date' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'finnish_date',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uitts.index',
+
'cat_id'
=>$this->cat_id,
+
'filter'
=>$this->filter,
+
'user_filter'
=>$this->user_filter,
+
'district_id' =>
$this->district_id,
+
'query'
=>$this->query,
+
'second_display'
=> true,
+
'allrows'=>$this->allrows,
+
'start_date'
=>$start_date,
+
'end_date'
=>$end_date
+
)
+
)),
+ 'lang_finnish_date' =>
lang('finnish date'),
+ 'lang_delay' =>
lang('delay'),
+ 'lang_finnish_statustext'=> lang('presumed
finnish date'),
+ 'lang_opened_by' => lang('Opened
by'),
+ 'lang_status' => lang('Status')
+ );
+
+ for ($i=0;$i<count($uicols);$i++)
+ {
+ $table_header[0]['extra'][$i]['header']
= $uicols[$i];
+ }
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_statustext' => lang('add a ticket'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitts.add')
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uitts.index',
+ 'second_display' => true,
+ 'sort' =>$this->sort,
+ 'order' =>$this->order,
+ 'cat_id' =>$this->cat_id,
+ 'filter' =>$this->filter,
+ 'user_filter'
=>$this->user_filter,
+ 'query' =>$this->query,
+ 'district_id' =>
$this->district_id,
+ 'start_date' =>$start_date,
+ 'end_date' =>$end_date,
+ 'allrows' =>$this->allrows
+ );
+
+ $receipt =
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp);
+
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp,'');
+
+ $GLOBALS['phpgw']->preferences->read_repository();
+ if
($GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['refreshinterval'])
+ {
+ $autorefresh =
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['refreshinterval'].';
URL='.$GLOBALS['phpgw']->link('/index.php',$link_data);
+ }
+
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $link_date_search =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.date_search');
+
+ $link_excel = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uitts.excel',
+ 'second_display' => true,
+ 'sort' =>$this->sort,
+ 'order' =>$this->order,
+ 'cat_id' =>$this->cat_id,
+ 'filter' =>$this->filter,
+ 'user_filter'
=>$this->user_filter,
+ 'query' =>$this->query,
+ 'district_id' =>
$this->district_id,
+ 'allrows'
=>$this->allrows,
+ 'start_date' =>$start_date,
+ 'end_date' =>$end_date,
+ 'start' =>$this->start
+ );
+
+
if($GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['group_filters'])
+ {
+ $group_filters = 'select';
+
$GLOBALS['phpgw']->xslttpl->add_file(array('search_field_grouped'));
+ }
+ else
+ {
+ $group_filters = 'filter';
+
$GLOBALS['phpgw']->xslttpl->add_file(array('search_field'));
+ }
+
+ $data = array
+ (
+ 'group_filters' =>
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['group_filters'],
+ 'lang_excel' =>
'excel',
+ 'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
+ 'lang_excel_help' =>
lang('Download table to MS Excel'),
+
+ 'start_date'
=>$start_date,
+ 'end_date'
=>$end_date,
+ 'lang_none'
=>lang('None'),
+ 'lang_date_search' =>
lang('Date search'),
+ 'lang_date_search_help' =>
lang('Narrow the search by dates'),
+ 'link_date_search' =>
$link_date_search,
+
+ 'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
+
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'autorefresh'
=> $autorefresh,
+ 'links'
=> $links,
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($ticket_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the ticket belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=> $this->bo->select_category_list($group_filters,$this->cat_id),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'filter_name'
=> 'filter',
+ 'filter_list'
=> $this->bo->filter(array('format' => $group_filters, 'filter'=>
$this->filter,'default' => 'open')),
+ 'lang_show_all'
=> lang('Open'),
+ 'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add,
+
+ 'district_list'
=> $this->bocommon->select_district_list($group_filters,$this->district_id),
+ 'lang_no_district'
=> lang('no district'),
+ 'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
+ 'select_district_name' =>
'district_id',
+
+ 'lang_user_statustext' =>
lang('Assigned to'),
+ 'select_user_name'
=> 'user_filter',
+ 'lang_no_user'
=> lang('No user'),
+ 'user_list'
=>
$this->bocommon->get_user_list_right2($group_filters,4,$this->user_filter,$this->acl2_location,'',$default='')
+ );
+
+ $appname
= lang('helpdesk');
+ $function_msg =
lang('list ticket');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function add()
+ {
+ if(!$this->acl_add)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
+ }
+
+ $bolocation =
CreateObject($this->currentapp.'.bolocation');
+
+ $values = get_var('values',array('POST'));
+ $insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
+ $insert_record_entity =
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp);
+
+ for ($j=0;$j<count($insert_record_entity);$j++)
+ {
+
$insert_record['extra'][$insert_record_entity[$j]] =
$insert_record_entity[$j];
+ }
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('tts'));
+
+//_debug_array($insert_record);
+ if ($values['save'])
+ {
+ for ($i=0;
$i<count($insert_record['location']); $i++)
+ {
+
if($_POST[$insert_record['location'][$i]])
+ {
+
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
+ }
+ }
+
+ while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
+ {
+ if($_POST[$key])
+ {
+ $values['extra'][$column]
= $_POST[$key];
+ }
+ }
+
+ $values['street_name'] =
$_POST['street_name'];
+ $values['street_number'] =
$_POST['street_number'];
+ $values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
+
+/* if(!$values['subject'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please type a subject for this ticket
!'));
+ }
+
+*/ if(!$values['assignedto'] &&
!$values['group_id'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a person or a group to
handle the ticket !'));
+ }
+
+ if(!$values['cat_id'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
+ }
+
+/* if(!$values['details'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please give som details !'));
+ }
+*/
+ if(!$values['location']['loc1'] &&
!$values['extra']['p_num'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Pleace select a location - or an entity
!'));
+ }
+
+ if(!$receipt['error'])
+ {
+ $receipt = $this->bo->add($values);
+
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp,$receipt);
+
$GLOBALS['phpgw']->session->appsession('session_data','fm_tts','');
+ header('Location: '.
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitts.index'));
+ }
+ else
+ {
+ if($values['location'])
+ {
+ $location_code=implode("-",
$values['location']);
+ $values['location_data'] =
$bolocation->read_single($location_code,$values['extra']);
+ }
+ if($values['extra']['p_num'])
+ {
+
$values['p'][$values['extra']['p_entity_id']]['p_num']=$values['extra']['p_num'];
+
$values['p'][$values['extra']['p_entity_id']]['p_entity_id']=$values['extra']['p_entity_id'];
+
$values['p'][$values['extra']['p_entity_id']]['p_cat_id']=$values['extra']['p_cat_id'];
+
$values['p'][$values['extra']['p_entity_id']]['p_cat_name']=$_POST['entity_cat_name_'.$values['extra']['p_entity_id']];
+ }
+ }
+ }
+
+ $location_data=$bolocation->initiate_ui_location(array(
+ 'values' =>
$values['location_data'],
+ 'type_id' => -1,
// calculated from location_types
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' => True,
+ 'lookup_type' => 'form',
+ 'lookup_entity' =>
$this->bocommon->get_lookup_entity('ticket'),
+ 'entity_data' => $values['p']
+ ));
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uitts.add'
+ );
+
+ if(!$values['assignedto'])
+ {
+ $values['assignedto']=
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['assigntodefault'];
+ }
+ if(!$values['group_id'])
+ {
+ $values['group_id']=
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['groupdefault'];
+ }
+
+ if(!$values['cat_id'])
+ {
+ $this->cat_id =
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['tts_category'];
+ }
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ switch(substr($dateformat,0,1))
+ {
+ case 'M':
+ $dateformat_validate=
"javascript:vDateType='1'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'1')";
+ break;
+ case 'y':
+
$dateformat_validate="javascript:vDateType='2'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'2')";
+ break;
+ case 'D':
+
$dateformat_validate="javascript:vDateType='3'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'3')";
+ break;
+ }
+
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'lang_dateformat'
=> strtolower($dateformat),
+ 'dateformat_validate' =>
$dateformat_validate,
+ 'onKeyUp'
=> $onKeyUp,
+ 'onBlur'
=> $onBlur,
+ 'dateformat_source'
=> './'.$this->currentapp.'/inc/dateformat.js',
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'location_data'
=> $location_data,
+ 'lang_assign_to'
=> lang('Assign to'),
+ 'lang_no_user'
=> lang('Select user'),
+ 'lang_user_statustext' =>
lang('Select the user the selection belongs to. To do not use a user select NO
USER'),
+ 'select_user_name'
=> 'values[assignedto]',
+ 'user_list'
=>
$this->bocommon->get_user_list_right2('select',4,$values['assignedto'],$this->acl2_location),
+
+ 'lang_group'
=> lang('Group'),
+ 'lang_no_group'
=> lang('No group'),
+ 'group_list'
=>
$this->bocommon->get_group_list('select',$values['group_id'],$start=-1,$sort='ASC',$order='account_firstname',$query='',$offset=-1),
+ 'select_group_name'
=> 'values[group_id]',
+
+ 'lang_priority'
=> lang('Priority'),
+ 'lang_priority_statustext' =>
lang('Select the priority the selection belongs to.'),
+ 'select_priority_name' =>
'values[priority]',
+ 'priority_list'
=> $this->bo->get_priority_list($values['priority']),
+
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitts.index'),
+ 'lang_subject'
=> lang('Subject'),
+ 'lang_subject_statustext' =>
lang('Enter the subject of this ticket'),
+
+ 'lang_details'
=> lang('Details'),
+ 'lang_details_statustext' =>
lang('Enter the details of this ticket'),
+ 'lang_category'
=> lang('category'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_details'
=> $values['details'],
+ 'value_subject'
=> $values['subject'],
+
+ 'lang_finnish_date'
=> lang('finnish date'),
+ 'value_finnish_date' =>
$values['finnish_date'],
+
+ 'lang_done_statustext' =>
lang('Back to the ticket list'),
+ 'lang_save_statustext' =>
lang('Save the ticket'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the building belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'values[cat_id]',
+ 'lang_town_statustext' =>
lang('Select the part of town the building belongs to. To do not use a part of
town - select NO PART OF TOWN'),
+ 'lang_part_of_town'
=> lang('Part of town'),
+ 'lang_no_part_of_town' =>
lang('No part of town'),
+ 'cat_list'
=> $this->bo->select_category_list('select',$this->cat_id),
+ 'mailnotification'
=> $this->bo->config->config_data['mailnotification'],
+ 'lang_mailnotification' =>
lang('Send e-mail'),
+ 'lang_mailnotification_statustext' =>
lang('Choose to send mailnotification'),
+ 'pref_send_mail'
=>
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['tts_user_mailnotification'],
+ );
+
+//_debug_array($data);
+ $appname
= lang('helpdesk');
+ $function_msg =
lang('add ticket');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+ $GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('add'
=> $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ function view()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $bolocation =
CreateObject($this->currentapp.'.bolocation');
+
+ $id = get_var('id',array('GET'));
+ $values = get_var('values',array('POST','GET'));
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('tts'));
+
+ if($values['save'])
+ {
+ if(!$this->acl_edit)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=4&acl_location='
. $this->acl2_location);
+ }
+
+ $so2 =
CreateObject($this->currentapp.'.sotts2');
+ $receipt = $so2->update_ticket($values,$id);
+ }
+
+ $ticket = $this->bo->read_single($id);
+
+ $additional_notes =
$this->bo->read_additional_notes($id);
+ $record_history = $this->bo->read_record_history($id);
+
+ $request_link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uirequest.edit',
+ 'bypass' => true,
+ 'location_code' =>
$ticket['location_code'],
+ 'p_num' =>
$ticket['p_num'],
+ 'p_entity_id' =>
$ticket['p_entity_id'],
+ 'p_cat_id' =>
$ticket['p_cat_id'],
+ 'tenant_id' =>
$ticket['tenant_id'],
+ 'origin' => 'tts',
+ 'origin_id' => $id
+ );
+
+ for ($i=0;$i<count($ticket['origin']);$i++)
+ {
+ if($ticket['origin'][$i]['type'] ==
'project')
+ {
+ $order_link_data = array
+ (
+ 'menuaction'
=> $this->currentapp.'.uiproject.edit',
+ 'id'
=> $ticket['origin'][$i]['data'][0]['id']
+ );
+ break;
+ }
+ }
+
+
+ if(!$order_link_data)
+ {
+ $order_link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiproject.edit',
+ 'bypass' => true,
+ 'location_code' =>
$ticket['location_code'],
+ 'p_num' =>
$ticket['p_num'],
+ 'p_entity_id' =>
$ticket['p_entity_id'],
+ 'p_cat_id' =>
$ticket['p_cat_id'],
+ 'tenant_id' =>
$ticket['tenant_id'],
+ 'origin' =>
'tts',
+ 'origin_id' => $id
+ );
+ }
+
+ $form_link = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uitts.view',
+ 'id' => $id
+ );
+
+ $table_header_history[] = array
+ (
+ 'lang_date' => lang('Date'),
+ 'lang_user' => lang('User'),
+ 'lang_action' => lang('Action'),
+ 'lang_new_value' => lang('New value')
+ );
+
+ $table_header_additional_notes[] = array
+ (
+ 'lang_count' => '#',
+ 'lang_date' => lang('Date'),
+ 'lang_user' => lang('User'),
+ 'lang_note' => lang('Note'),
+ );
+
+//_debug_array($ticket['location_data']);
+
+ $location_data=$bolocation->initiate_ui_location(array(
+ 'values' =>
$ticket['location_data'],
+ 'type_id' =>
count(explode('-',$ticket['location_data']['location_code'])),
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' =>
$ticket['location_data']['tenant_id'],
+ 'lookup_type' => 'view',
+ 'lookup_entity' =>
$this->bocommon->get_lookup_entity('ticket'),
+ 'entity_data' => $ticket['p']
+ ));
+
+
+ if($ticket['contact_phone'])
+ {
+ for
($i=0;$i<count($location_data['location']);$i++)
+ {
+
if($location_data['location'][$i]['input_name'] == 'contact_phone')
+ {
+
unset($location_data['location'][$i]['value']);
+ }
+ }
+ }
+
+
+ if ($ticket['cat_id'])
+ {
+ $this->cat_id = $ticket['cat_id'];
+ }
+
+
+/*
+ if($ticket['request_id'])
+ {
+ $request_lookup_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uirequest.view'
+ );
+ }
+ if($ticket['project_id'])
+ {
+ $project_lookup_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiproject.view'
+ );
+ }
+
+*/
+ $start_entity =
$this->bocommon->get_start_entity('ticket');
+//_debug_array($start_entity);
+
+ if (isset($start_entity) AND is_array($start_entity))
+ {
+ $i=0;
+ foreach($start_entity as $entry)
+ {
+ $link_entity[$i]['link'] =
$GLOBALS['phpgw']->link('/index.php',array
+ (
+ 'menuaction' =>
$this->currentapp.'.uientity.edit',
+ 'bypass'
=> true,
+ 'location_code' =>
$ticket['location_code'],
+ 'entity_id'
=> $entry['id'],
+ 'p_num'
=> $ticket['p_num'],
+ 'p_entity_id' =>
$ticket['p_entity_id'],
+ 'p_cat_id'
=> $ticket['p_cat_id'],
+ 'tenant_id'
=> $ticket['tenant_id'],
+ 'origin'
=> 'tts',
+ 'origin_id'
=> $id
+ ));
+ $link_entity[$i]['name'] =
$entry['name'];
+ $i++;
+ }
+ }
+
+//_debug_array($link_entity);
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ switch(substr($dateformat,0,1))
+ {
+ case 'M':
+ $dateformat_validate=
"javascript:vDateType='1'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'1')";
+ break;
+ case 'y':
+
$dateformat_validate="javascript:vDateType='2'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'2')";
+ break;
+ case 'D':
+
$dateformat_validate="javascript:vDateType='3'";
+ $onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
+ $onBlur =
"DateFormat(this,this.value,event,true,'3')";
+ break;
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+
+ if (isset($ticket['origin']) AND
is_array($ticket['origin']))
+ {
+ for ($i=0;$i<count($ticket['origin']);$i++)
+ {
+
$ticket['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
. $ticket['origin'][$i]['link']);
+
if(substr($ticket['origin'][$i]['type'],0,6)=='entity')
+ {
+ $type =
explode("_",$ticket['origin'][$i]['type']);
+ $entity_id = $type[1];
+ $cat_id = $type[2];
+
+ if(!is_object($boadmin_entity))
+ {
+ $boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity');
+ }
+ $entity_category =
$boadmin_entity->read_single_category($entity_id,$cat_id);
+ $ticket['origin'][$i]['descr']
= $entity_category['name'];
+ }
+ else
+ {
+ $ticket['origin'][$i]['descr']=
lang($ticket['origin'][$i]['type']);
+ }
+ }
+ }
+
+ $data = array
+ (
+ 'value_origin'
=> $ticket['origin'],
+ 'value_origin_type'
=> $origin,
+ 'value_origin_id'
=> $origin_id,
+
+ 'lang_dateformat'
=> strtolower($dateformat),
+ 'dateformat_validate' =>
$dateformat_validate,
+ 'onKeyUp'
=> $onKeyUp,
+ 'onBlur'
=> $onBlur,
+ 'dateformat_source'
=> './'.$this->currentapp.'/inc/dateformat.js',
+ 'lang_finnish_date'
=> lang('finnish date'),
+ 'value_finnish_date' =>
$ticket['finnish_date'],
+
+ 'link_entity'
=> $link_entity,
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+
+ 'lang_request'
=> lang('Request'),
+ 'lang_request_statustext' =>
lang('Link to the request originatet from this ticket'),
+ 'link_request'
=> $GLOBALS['phpgw']->link('/index.php',$request_lookup_data),
+ 'value_request_id'
=> $ticket['request_id'],
+
+ 'lang_project'
=> lang('Project'),
+ 'lang_project_statustext' =>
lang('Link to the project originatet from this ticket'),
+ 'link_project'
=> $GLOBALS['phpgw']->link('/index.php',$project_lookup_data),
+ 'value_project_id'
=> $ticket['project_id'],
+
+ 'location_data'
=> $location_data,
+ 'lang_location_code' =>
lang('Location Code'),
+
+ 'lang_ticket'
=> lang('Ticket'),
+ 'table_header_additional_notes' =>
$table_header_additional_notes,
+ 'table_header_history' =>
$table_header_history,
+ 'lang_status'
=> lang('Status'),
+ 'status_name'
=> 'values[status]',
+ 'status_list'
=> $this->bo->get_status_list($ticket['status']),
+ 'lang_status_statustext' =>
lang('Set the status of the ticket'),
+
+ 'lang_no_user'
=> lang('Select user'),
+ 'lang_user_statustext' =>
lang('Select the user the selection belongs to. To do not use a user select NO
USER'),
+ 'select_user_name'
=> 'values[assignedto]',
+ 'user_list'
=>
$this->bocommon->get_user_list_right2('select',4,$ticket['assignedto'],$this->acl2_location),
+
+ 'lang_group'
=> lang('Group'),
+ 'lang_no_group'
=> lang('No group'),
+ 'group_list'
=>
$this->bocommon->get_group_list('select',$ticket['group_id'],$start=-1,$sort='ASC',$order='account_firstname',$query='',$offset=-1),
+ 'select_group_name'
=> 'values[group_id]',
+
+ 'lang_priority'
=> lang('Priority'),
+ 'value_priority'
=> $ticket['priority'],
+ 'lang_priority_statustext' =>
lang('Select the priority the selection belongs to.'),
+ 'select_priority_name' =>
'values[priority]',
+ 'priority_list'
=> $this->bo->get_priority_list($ticket['priority']),
+
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the building belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'values[cat_id]',
+ 'cat_list'
=> $this->bo->select_category_list('select',$this->cat_id),
+ 'lang_category'
=> lang('category'),
+ 'value_category_name' =>
$ticket['category_name'],
+
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$form_link),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitts.index'),
+ 'value_subject'
=> $ticket['subject'],
+ 'lang_subject_statustext' =>
lang('update subject'),
+ 'value_id'
=> '[ #'. $id . ' ] - ',
+
+ 'lang_details'
=> lang('Details'),
+ 'value_details'
=> $ticket['details'],
+ 'lang_details_statustext' =>
lang('Add new comments'),
+
+ 'lang_additional_notes' =>
lang('Additional notes'),
+
+ 'lang_new_note'
=> lang('New Note'),
+ 'lang_opendate'
=> lang('Open Date'),
+ 'value_opendate'
=> $ticket['timestampopened'],
+
+ 'lang_assignedfrom'
=> lang('Assigned from'),
+ 'value_assignedfrom' =>
$ticket['user_name'],
+ 'lang_assignedto'
=> lang('Assigned to'),
+ 'value_assignedto'
=> $ticket['assignedto_name'],
+
+ 'lang_no_additional_notes' =>
lang('No additional notes'),
+ 'lang_history'
=> lang('History'),
+ 'lang_no_history'
=> lang('No history for this record'),
+ 'additional_notes'
=> $additional_notes,
+ 'record_history'
=> $record_history,
+ 'request_link'
=> $GLOBALS['phpgw']->link('/index.php',$request_link_data),
+ 'order_link'
=> $GLOBALS['phpgw']->link('/index.php',$order_link_data),
+
+ 'lang_generate_request' =>
lang('Generate Request'),
+ 'lang_generate_request_statustext'
=> lang('Klick this to generate a request with this information'),
+ 'lang_generate_order' =>
lang('Generate order'),
+ 'lang_generate_order_statustext'
=> lang('Klick this to generate an order with this information'),
+
+ 'lang_save'
=> lang('save'),
+ 'lang_name'
=> lang('name'),
+ 'lang_done'
=> lang('done'),
+ 'lang_contact_phone' =>
lang('Contact phone'),
+ 'contact_phone'
=> $ticket['contact_phone'],
+ 'mailnotification'
=> $this->bo->config->config_data['mailnotification'],
+ 'lang_mailnotification' =>
lang('Send e-mail'),
+ 'lang_mailnotification_statustext' =>
lang('Choose to send mailnotification'),
+ 'pref_send_mail'
=>
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['tts_user_mailnotification'],
+ );
+
+ $appname
= lang('helpdesk');
+ $function_msg =
lang('view ticket detail');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+ }
+?>
Index: property/inc/class.uiwo_hour.inc.php
diff -u property/inc/class.uiwo_hour.inc.php:1.16
property/inc/class.uiwo_hour.inc.php:1.17
--- property/inc/class.uiwo_hour.inc.php:1.16 Mon Sep 12 08:19:02 2005
+++ property/inc/class.uiwo_hour.inc.php Fri Jan 27 14:05:43 2006
@@ -1,1681 +1,1681 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage project
- * @version $Id: class.uiwo_hour.inc.php,v 1.16 2005/09/12 08:19:02
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uiwo_hour
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
- var $currentapp;
-
- var $public_functions = array
- (
- 'index' => True,
- 'tender' => True,
- 'view' => True,
- 'template' => True,
- 'save_template' => True,
- 'prizebook' => True,
- 'add' => True,
- 'edit' => True,
- 'delete' => True,
- 'deviation' => True,
- 'edit_deviation'=> True
- );
-
- function uiwo_hour()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->create_html =
CreateObject('phpgwapi.xslttemplates');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- $this->bo =
CreateObject($this->currentapp.'.bowo_hour',True);
- $this->boworkorder =
CreateObject($this->currentapp.'.boworkorder');
- $this->boproject =
CreateObject($this->currentapp.'.boproject');
- $this->bopricebook =
CreateObject($this->currentapp.'.bopricebook');
-
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
- $this->config =
CreateObject('phpgwapi.config');
-
- $this->config->read_repository();
-
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
- $this->acl2_location = '.project';
- $this->acl_read =
$this->acl2->check('.project',1);
- $this->acl_add =
$this->acl2->check('.project',2);
- $this->acl_edit =
$this->acl2->check('.project',4);
- $this->acl_delete =
$this->acl2->check('.project',8);
-
- $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->chapter_id =
$this->bo->chapter_id;
- $this->allrows =
$this->bo->allrows;
-
- $this->menu->sub ='project';
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' =>
$this->filter,
- 'cat_id' =>
$this->cat_id,
- 'chapter_id' => $this->chapter_id,
- 'allrows' =>
$this->allrows
- );
- $this->bo->save_sessiondata($data);
- }
-
- function deviation()
- {
- $workorder_id =
get_var('workorder_id',array('POST','GET'));
- $hour_id =
get_var('hour_id',array('POST','GET'));
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour'));
- $list =
$this->bo->read_deviation(array('workorder_id'=>$workorder_id,'hour_id'=>$hour_id));
-
- $sum_deviation = 0;
-
- if (isset($list) AND is_array($list))
- {
- $dateformat
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- foreach($list as $entry)
- {
- $sum_deviation = $sum_deviation +
$entry['amount'];
-
- $entry_date =
(isset($entry['entry_date'])?$GLOBALS['phpgw']->common->show_date($entry['entry_date'],$dateformat):'');
-
- $content[] = array
- (
- 'id'
=> $entry['id'],
- 'amount'
=> $entry['amount'],
- 'descr'
=> $entry['descr'],
- 'entry_date'
=> $entry_date,
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.edit_deviation&workorder_id='
. $workorder_id . '&hour_id=' . $hour_id . '&id=' . $entry['id']),
- 'lang_edit_statustext'
=> lang('edit the deviation'),
- 'text_edit'
=> lang('edit'),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.delete&workorder_id='
. $workorder_id . '&hour_id=' . $hour_id . '&deviation_id=' . $entry['id']),
- 'lang_delete_statustext'
=> lang('delete the deviation'),
- 'text_delete'
=> lang('delete'),
- );
- }
- }
-
-
- $table_header[] = array
- (
- 'lang_id' => lang('ID'),
- 'lang_amount' => lang('amount'),
- 'lang_descr' => lang('Descr'),
- 'lang_date' => lang('date'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete')
- );
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiwo_hour.edit_deviation',
- 'workorder_id' =>$workorder_id,
- 'hour_id'
=>$hour_id
- );
-
-
- $data = array
- (
- 'sum_deviation'
=> $sum_deviation,
- 'table_header_deviation' =>
$table_header,
- 'values_deviation'
=> $content,
- 'lang_add'
=> lang('add'),
- 'lang_add_statustext' =>
lang('add a deviation'),
- 'add_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_done'
=> lang('done'),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index&workorder_id='
. $workorder_id)
- );
-
- $appname =
lang('Workorder');
- $function_msg = lang('list
deviation');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_deviation' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function edit_deviation()
- {
- $workorder_id =
get_var('workorder_id',array('POST','GET'));
- $hour_id =
get_var('hour_id',array('POST','GET'));
- $id =
get_var('id',array('POST','GET'));
- $values =
get_var('values',array('POST','GET'));
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour'));
-
- if ($values['save'])
- {
- $values['workorder_id']=$workorder_id;
- $values['hour_id']=$hour_id;
- if (!$values['amount'])
- {
- $receipt['error'][] =
array('msg'=>lang('amount not entered!'));
- }
-
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
-
- if (!$receipt['error'])
- {
- $receipt =
$this->bo->save_deviation($values,$action);
- if(!$id)
- {
- $id=$receipt['id'];
- }
- }
- else
- {
- $receipt['error'][] = array('msg'=>
lang('Status has NOT been saved'));
- }
-
- }
-
- if ($id)
- {
- $values =
$this->bo->read_single_deviation(array('workorder_id'=>$workorder_id,'hour_id'=>$hour_id,'id'=>$id));
- $function_msg = lang('edit deviation');
- $action='edit';
- }
- else
- {
- $function_msg = lang('add deviation');
- $action='add';
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiwo_hour.edit_deviation',
- 'entity_id' => $this->entity_id,
- 'cat_id' => $this->cat_id,
- 'id' => $id
- );
-
- $hour = $this->bo->read_single_hour($hour_id);
-
-//_debug_array($workorder);
-//_debug_array($hour);
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $entry_date =
(isset($values['entry_date'])?$GLOBALS['phpgw']->common->show_date($values['entry_date'],$dateformat):'');
-
- $data = array
- (
- 'lang_workorder'
=> lang('Workorder ID'),
- 'lang_hour_id'
=> lang('Post'),
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.deviation&workorder_id='
. $workorder_id . '&hour_id=' . $hour_id),
- 'lang_id'
=> lang('deviation ID'),
- 'lang_descr'
=> lang('Descr'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'lang_date'
=> lang('date'),
- 'value_id'
=> $id,
- 'value_workorder_id' =>
$workorder_id,
- 'value_hour_id'
=> $hour_id,
- 'entry_date'
=> $entry_date,
- 'value_id'
=> $id,
- 'lang_descr_standardtext' =>
lang('Enter a description of the deviation'),
- 'lang_done_standardtext' =>
lang('Back to the list'),
- 'lang_save_standardtext' =>
lang('Save the deviation'),
- 'lang_amount'
=> lang('amount'),
- 'value_amount'
=> $values['amount'],
- 'value_descr'
=> $values['descr']
- );
-
- $appname
= lang('workorder');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_deviation' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function common_data($workorder_id,$view='')
- {
-
- $workorder =
$this->boworkorder->read_single($workorder_id);
-/* if
(!$this->bocommon->check_perms($workorder['grants'],PHPGW_ACL_EDIT))
- {
- $receipt['error'][]=array('msg'=>lang('You have
no edit right for this project'));
-
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp,$receipt);
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.view&id='
. $workorder_id);
- }
-*/
- $hour_list = $this->bo->read($workorder_id);
-//_debug_array($hour_list);
- $grouping_descr_old='';
-
- if (isset($hour_list) AND is_array($hour_list))
- {
- foreach($hour_list as $hour)
- {
- $sum_hour = $sum_hour +
$hour['cost'];
- $sum_deviation = $sum_deviation +
$hour['deviation'];
-
-
if($hour['grouping_descr']!=$grouping_descr_old)
- {
- $new_grouping = true;
- }
- else
- {
- $new_grouping = false;
- }
-
- $grouping_descr_old =
$hour['grouping_descr'];
-
- if($hour['activity_num'])
- {
- $code = $hour['activity_num'];
- }
- else
- {
- $code =
str_replace("-",$hour['tolerance'],$hour['ns3420_id']);
- }
-
- if($hour['count_deviation'] || $view)
- {
- $deviation=$hour['deviation'];
- }
- else
- {
- $deviation=lang('edit');
- }
-
- $content[] = array
- (
-
- 'post'
=> sprintf("%02s",$workorder['chapter_id']) . '.' .
sprintf("%02s",$hour['building_part']) . '.' .
sprintf("%02s",$hour['grouping_id']) . '.' . sprintf("%03s",$hour['record']),
- 'hour_id'
=> $hour['hour_id'],
- 'activity_num'
=> $hour['activity_num'],
- 'hours_descr'
=> $hour['hours_descr'],
- 'activity_descr'
=> $hour['activity_descr'],
- 'new_grouping'
=> $new_grouping,
- 'grouping_id'
=> $hour['grouping_id'],
- 'grouping_descr'
=> $hour['grouping_descr'],
- 'ns3420_id'
=> $hour['ns3420_id'],
- 'code'
=> $code,
- 'remark'
=> $hour['remark'],
- 'building_part'
=> $hour['building_part'],
- 'quantity'
=> $hour['quantity'],
- 'cost'
=> $hour['cost'],
- 'unit'
=> $hour['unit'],
- 'billperae'
=> $hour['billperae'],
- 'deviation'
=> $deviation,
- 'result'
=> ($hour['deviation']+$hour['cost']),
- 'wo_hour_category'
=> $hour['wo_hour_category'],
- 'link_deviation'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.deviation&workorder_id='
. $workorder_id . '&hour_id=' . $hour['hour_id']),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.edit&workorder_id='
. $workorder_id . '&hour_id=' . $hour['hour_id']),
- 'lang_edit_statustext'
=> lang('edit/customise this hour'),
- 'lang_delete_statustext'
=> lang('delete this hour'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
- }
-
-
$this->bo->update_deviation(array('workorder_id'=>$workorder_id,'sum_deviation'=>$sum_deviation));
-
-//_debug_array($content);
-
- $table_header[] = array
- (
- 'lang_post' => lang('Post'),
- 'lang_code' => lang('Code'),
- 'lang_descr' => lang('descr'),
- 'lang_unit' => lang('Unit'),
- 'lang_billperae' => lang('Bill per
unit'),
- 'lang_quantity' => lang('Quantity'),
- 'lang_cost' => lang('cost'),
- 'lang_deviation ' => lang('deviation'),
- 'lang_result' => lang('result'),
- 'lang_view' => lang('view'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'lang_category' => lang('category')
- );
-
- $tax = $this->config->config_data['fm_tax'];
-
- $sum_result = $sum_hour+$sum_deviation;
-
- $addition_percentage = $sum_result *
$workorder['addition_percentage']/100;
- $sum_tax = ($sum_result + $addition_percentage +
$workorder['addition_rs'])*$tax/100;
- $total_sum = $sum_result + $addition_percentage +
$workorder['addition_rs'] + $sum_tax;
-
-
$this->bo->update_calculation(array('workorder_id'=>$workorder_id,'calculation'=>($sum_result+$addition_percentage
+ $workorder['addition_rs'])));
-
- $table_sum[] = array
- (
- 'lang_sum_calculation' =>
lang('Sum calculation'),
- 'value_sum_calculation' =>
number_format($sum_hour, 2, ',', ''),
- 'lang_addition_rs'
=> lang('Rig addition'),
- 'value_addition_rs'
=> number_format($workorder['addition_rs'], 2, ',', ''),
- 'lang_addition_percentage' =>
lang('Percentage addition'),
- 'value_addition_percentage' =>
number_format($addition_percentage, 2, ',', ''),
- 'lang_sum_tax'
=> lang('Sum tax'),
- 'value_sum_tax'
=> number_format($sum_tax, 2, ',', ''),
- 'lang_total_sum'
=> lang('Total sum'),
- 'value_total_sum'
=> number_format($total_sum, 2, ',', ''),
- 'lang_sum_deviation' =>
lang('Sum deviation'),
- 'sum_deviation'
=> number_format($sum_deviation, 2, ',', ''),
- 'sum_result'
=> number_format($sum_result, 2, ',', '')
- );
-
- $workorder_data = array(
- 'link_workorder'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit&id='
. $workorder_id),
- 'lang_vendor_name'
=> lang('Vendor'),
- 'vendor_name'
=> $workorder['vendor_name'],
- 'vendor_email'
=> $workorder['vendor_email'],
- 'descr'
=> $workorder['descr'],
-
- 'lang_workorder_id'
=> lang('Workorder ID'),
- 'workorder_id'
=> $workorder['workorder_id'],
- 'lang_project_id'
=> lang('Project ID'),
- 'link_project'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit&id='
. $workorder['project_id']),
- 'project_id'
=> $workorder['project_id'],
-
- 'lang_workorder_title' =>
lang('Workorder title'),
- 'workorder_title'
=> $workorder['title']
- );
-
-
-
- $common_data = array(
- 'content' =>
$content,
- 'total_hours_records' => count($content),
- 'table_header' =>
$table_header,
- 'table_sum' => $table_sum,
- 'workorder' => $workorder,
- 'workorder_data' =>
$workorder_data,
- );
-
- return $common_data;
- }
-
- function save_template()
- {
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour',
-
'menu'));
-
- $values =
get_var('values',array('POST'));
- $workorder_id =
get_var('workorder_id',array('POST','GET'));
-
- if($values['name'])
- {
- $receipt =
$this->bo->add_template($values,$workorder_id);
- }
-
- $common_data=$this->common_data($workorder_id);
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiwo_hour.index',
- 'workorder_id' => $workorder_id
- );
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'done_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'add_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.save_template&workorder_id='
. $workorder_id),
-
- 'lang_done_statustext' =>
lang('Back to the workorder list'),
- 'lang_add_statustext' =>
lang('Adds this workorders calculation as a template for later use'),
- 'lang_search_statustext' =>
lang('Adds a new workorder to an existing project'),
-
- 'lang_done'
=> lang('Done'),
- 'lang_add'
=> lang('Add'),
- 'lang_search'
=> lang('Search'),
-
- 'lang_name'
=> lang('name'),
- 'lang_name_statustext' => lang('Enter
the name the template'),
-
- 'lang_descr'
=> lang('Description'),
- 'lang_descr_statustext' => lang('Enter
a short description of this template'),
-
- 'total_hours_records' =>
$common_data['total_hours_records'],
- 'lang_total_records' =>
lang('Total records'),
- 'table_header_hour'
=> $common_data['table_header'],
- 'values_hour'
=> $common_data['content'],
- 'workorder_data'
=> $common_data['workorder_data']
- );
-
- $appname
= lang('Workorder');
- $function_msg =
lang('Add template');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('add_template' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function index()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour','menu'));
-
- $delete = get_var('delete',array('POST','GET'));
- $hour_id = get_var('hour_id',array('POST','GET'));
- $workorder_id =
get_var('workorder_id',array('POST','GET'));
- $links = $this->menu->links();
-
- if($delete && $hour_id)
- {
- $receipt =
$this->bo->delete($hour_id,$workorder_id);
- }
-
- $common_data=$this->common_data($workorder_id);
-
- $table_add[] = array
- (
- 'lang_add_prizebook'
=> lang('Add from prizebook'),
- 'lang_add_prizebook_statustext' =>
lang('add items from this vendors prizebook'),
- 'add_prizebook_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.prizebook&workorder_id='
. $workorder_id),
-
- 'lang_add_template'
=> lang('Add from template'),
- 'lang_add_template_statustext' =>
lang('add items from a predefined template'),
- 'add_template_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.index&lookup=true&workorder_id='
. $workorder_id),
-
- 'lang_add_custom'
=> lang('Add custom'),
- 'lang_add_custom_statustext' =>
lang('Add single custom line'),
- 'add_custom_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.edit&from=index&workorder_id='
. $workorder_id),
-
- 'lang_save_template'
=> lang('Save as template'),
- 'lang_save_template_statustext' =>
lang('Save this workorder as a template for later use'),
- 'save_template_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.save_template&from=index&workorder_id='
. $workorder_id),
-
- 'lang_print_view'
=> lang('Print view'),
- 'lang_print_view_statustext' =>
lang('View the complete workorder'),
- 'print_view_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.view&from=index&workorder_id='
. $workorder_id),
-
- 'lang_view_tender'
=> lang('View tender'),
- 'lang_view_tender_statustext' =>
lang('View the complete workorder as a tender for bidding'),
- 'view_tender_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.tender&from=index&workorder_id='
. $workorder_id),
-
- 'lang_show_cost'
=> lang('Show calculated cost'),
- 'lang_show_cost_statustext'
=> lang('Show calculated cost on the printview'),
-
- 'lang_show_details'
=> lang('Show details'),
- 'lang_show_details_statustext' =>
lang('Show details'),
-
- 'lang_mark_draft'
=> lang('Mark as DRAFT'),
- 'lang_mark_draft_statustext' =>
lang('Mark the tender as DRAFT')
-
- );
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index&delete=true&workorder_id='
. $workorder_id),
- 'function'
=> 'index',
- 'links'
=> $links,
- 'num_records'
=> count($hours_list),
- 'total_hours_records' =>
$common_data['total_hours_records'],
- 'lang_total_records' =>
lang('Total records'),
- 'table_header_hour'
=> $common_data['table_header'],
- 'values_hour'
=> $common_data['content'],
- 'workorder_data'
=> $common_data['workorder_data'],
- 'table_add'
=> $table_add,
- 'table_sum'
=> $common_data['table_sum']
- );
-
-//_debug_array($common_data['content']);
-
- $appname
= lang('Workorder');
- $function_msg =
lang('list hours');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_hour' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function view()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour','menu'));
-
- $show_cost =
get_var('show_cost',array('POST','GET'));
- $show_details =
get_var('show_details',array('POST','GET'));
- $workorder_id =
get_var('workorder_id',array('POST','GET'));
- $to_email =
get_var('to_email',array('POST','GET'));
- $update_email =
get_var('update_email',array('POST','GET'));
- $send_order =
get_var('send_order',array('POST','GET'));
- $no_email =
get_var('no_email',array('POST','GET'));
-
- if($update_email)
- {
-
$this->bo->update_email($to_email,$workorder_id);
- }
- $workorder =
$this->boworkorder->read_single($workorder_id);
-
- $table_header_history[] = array
- (
- 'lang_date' => lang('Date'),
- 'lang_user' => lang('User'),
- 'lang_action' => lang('Action'),
- 'lang_new_value' => lang('New value')
- );
-
-
- $common_data =
$this->common_data($workorder_id);
- if($show_details)
- {
- $values_hour =
$common_data['content'];
- }
- $project =
$this->boproject->read_single($common_data['workorder']['project_id']);
-
- $bolocation =
CreateObject($this->currentapp.'.bolocation');
-
- $location_data=$bolocation->initiate_ui_location(array(
- 'values' =>
$project['location_data'],
- 'type_id' =>
count(explode('-',$project['location_data']['location_code'])),
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' =>
$project['location_data']['tenant_id'],
- 'lookup_type' => 'view'
- ));
-
- if($project['contact_phone'])
- {
- for
($i=0;$i<count($location_data['location']);$i++)
- {
-
if($location_data['location'][$i]['input_name'] == 'contact_phone')
- {
-
unset($location_data['location'][$i]['value']);
- }
- }
- }
-
- if(!$show_cost)
- {
- $m = count($values_hour);
- for ($i=0;$i<$m;$i++)
- {
- unset($values_hour[$i]['cost']);
- unset($values_hour[$i]['billperae']);
- }
-
unset($common_data['table_sum'][0]['value_total_sum']);
- }
-
- $table_header[] = array
- (
- 'lang_post' => lang('Post'),
- 'lang_code' => lang('Code'),
- 'lang_descr' => lang('descr'),
- 'lang_unit' => lang('Unit'),
- 'lang_billperae' => lang('Bill per
unit'),
- 'lang_quantity' => lang('Quantity'),
- 'lang_cost' => lang('cost')
- );
-
-
- $table_send[] = array
- (
- 'lang_send_order'
=> lang('Send Order'),
- 'lang_send_order_statustext' => lang('Send
this order by email')
- );
-
- $table_done[] = array
- (
- 'lang_done'
=> lang('Done'),
- 'lang_done_statustext' =>
lang('Back to calculation'),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index&workorder_id='
. $workorder_id)
- );
-
- $dateformat
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $date
= $GLOBALS['phpgw']->common->show_date(time(),$dateformat);
-
- $from_name =
$GLOBALS['phpgw_info']['user']['fullname'];
- $from_email =
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['email'];
-
- $email_data = array
- (
- 'location_data'
=> $location_data,
- 'lang_workorder'
=> lang('Workorder ID'),
- 'workorder_id'
=> $workorder_id,
-
- 'lang_date'
=> lang('Date'),
- 'date'
=> $date,
-
- 'lang_start_date'
=> lang('Start date'),
- 'start_date'
=> $workorder['start_date'],
-
- 'lang_end_date'
=> lang('End date'),
- 'end_date'
=> $workorder['end_date'],
-
- 'lang_from'
=> lang('From'),
- 'from_name'
=> $from_name,
- 'from_email'
=> $from_email,
- 'from_phone'
=>
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['cellphone'],
- 'lang_district'
=> lang('District'),
- 'district'
=> $project['location_data']['district_id'],
-
- 'lang_to'
=> lang('To'),
- 'to_name'
=> $workorder['vendor_name'],
-
- 'lang_title'
=> lang('Title'),
- 'title'
=> $workorder['title'],
-
- 'lang_descr'
=> lang('Description'),
- 'descr'
=> $workorder['descr'],
-
- 'lang_budget_account' =>
lang('Budget account'),
- 'budget_account'
=> $workorder['b_account_id'],
-
- 'lang_sum_calculation' =>
lang('Sum of calculation'),
- 'sum_calculation'
=> $common_data['table_sum'][0]['value_total_sum'],
-
- 'lang_contact_phone' =>
lang('Contact phone'),
- 'contact_phone'
=> $project['contact_phone'],
-
-// 'lang_vendor'
=> lang('vendor'),
-
- 'lang_branch'
=> lang('branch'),
- 'branch_list'
=> $this->boproject->select_branch_p_list($project['project_id']),
- 'other_branch'
=> $project['other_branch'],
-
- 'key_responsible_list' =>
$this->boproject->select_branch_list($project['key_responsible']),
- 'lang_key_responsible' =>
lang('key responsible'),
-
- 'key_fetch_list'
=> $this->boproject->select_key_location_list($workorder['key_fetch']),
- 'lang_key_fetch'
=> lang('Where to pick up the key'),
-
- 'key_deliver_list'
=> $this->boproject->select_key_location_list($workorder['key_deliver']),
- 'lang_key_deliver'
=> lang('Where to deliver the key'),
-
- 'currency'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
-
- 'lang_cost_tax'
=> lang('Cost (incl tax):'),
- 'lang_materials'
=> lang('Materials:__________'),
- 'lang_work'
=> lang('work:____________'),
-
- 'table_header_view_order' =>
$table_header,
- 'values_view_order'
=> $values_hour
- );
-
-
- if($send_order && !$to_email)
- {
-
$receipt['error'][]=array('msg'=>lang('No mailaddress is selected'));
- }
-
- if($to_email)
- {
-
$this->create_html->add_file(array(PHPGW_SERVER_ROOT . SEP . $this->currentapp
. SEP . 'templates' . SEP . 'default' . SEP . 'wo_hour'));
-
$this->create_html->add_file(array(PHPGW_SERVER_ROOT . SEP . $this->currentapp
. SEP . 'templates' . SEP . 'default' . SEP . 'location_view'));
-
-
$this->create_html->set_var('phpgw',array('email_data' => $email_data));
-
- $this->create_html->xsl_parse();
- $this->create_html->xml_parse();
- $xsltproc = xslt_create();
- $arguments = array('/_xml' =>
$this->create_html->xmldata, '/_xsl' => $this->create_html->xsldata);
- $html =
xslt_process($xsltproc,'arg:/_xml','arg:/_xsl',NULL,$arguments);
- xslt_free($xsltproc);
-
-// print $html;
-
- $headers = "Return-Path: <". $from_email
.">\r\n";
- $headers .= "From: " . $from_name . "<" .
$from_email .">\r\n";
-
if($GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['order_email_rcpt']==1)
- {
- $headers .= "Bcc: " . $from_name . "<"
. $from_email .">\r\n";
- $bcc = $from_email;
- }
- $headers .= "Content-type: text/html;
charset=iso-8859-1\r\n";
- $headers .= "MIME-Version: 1.0\r\n";
- $subject = lang('Workorder').": ".$workorder_id;
-
- $mail_method=
$this->config->config_data['fmwrkorder_mail'];
-
- if ($mail_method=='smtp'):
- {
- $send = CreateObject('phpgwapi.send');
- $rcpt = $send->msg('email', $to_email,
$subject, $html, '', $cc, $bcc, $from_email, $from_name, 'html');
- }
- elseif ($mail_method=='sendmail'):
- {
- $rcpt=mail($to_email,$subject,$html,
$headers);
- }
- else:
- {
-
$receipt['error'][]=array('msg'=>lang('Mailing method is not chosen! (admin
section)'));
- }
- endif;
-
- if ($rcpt)
- {
- $historylog =
CreateObject($this->currentapp.'.historylog','workorder');
-
$historylog->add('M',$workorder_id,$to_email);
-
$receipt['message'][]=array('msg'=>lang('Workorder is sent by email!'));
- }
- else
- {
-
$receipt['error'][]=array('msg'=>lang('The recipient did not get the email:'));
-
$receipt['error'][]=array('msg'=>lang('From') . ' ' . $from_email);
-
$receipt['error'][]=array('msg'=>lang('To') . ' ' . $to_email);
- }
- }
-
- $workorder_history =
$this->boworkorder->read_record_history($workorder_id);
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $email_list =
$this->bo->get_email($to_email,$workorder['vendor_id']);
- if(count($email_list)==1)
- {
- $to_email= $email_list[0]['email'];
- unset($email_list);
- }
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'lang_mail'
=> lang('E-Mail'),
- 'lang_update_email'
=> lang('Update email'),
- 'lang_update_email_statustext' =>
lang('Check to update the email-address for this vendor'),
- 'lang_to_email_address_statustext' =>
lang('The address to which this order will be sendt'),
- 'to_email'
=> $to_email,
- 'email_list'
=> $email_list,
- 'lang_select_email'
=> lang('Select email'),
- 'send_order_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.view&send=true&workorder_id='
. $workorder_id . '&show_details=' . $show_details),
-
- 'lang_no_history'
=> lang('No history'),
- 'lang_history'
=> lang('History'),
- 'workorder_history'
=> $workorder_history,
- 'table_header_history' =>
$table_header_history,
- 'email_data'
=> $email_data,
- 'no_email'
=> $no_email,
- 'table_send'
=> $table_send,
- 'table_done'
=> $table_done
- );
-
-//_debug_array($data);
-
- $appname
= lang('Workorder');
- $function_msg =
lang('Send order');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
-
- $this->save_sessiondata();
- }
-
-
- function tender()
- {
- $GLOBALS['phpgw_info']['flags'][noheader] = True;
- $GLOBALS['phpgw_info']['flags'][nofooter] = True;
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
-
- $pdf =
CreateObject($this->currentapp.'.pdf');
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
- $show_cost = get_var('show_cost',array('POST','GET'));
- $mark_draft = get_var('mark_draft',array('POST','GET'));
- $workorder_id =
get_var('workorder_id',array('POST','GET'));
-
- $common_data =
$this->common_data($workorder_id);
- $values_hour = $common_data['content'];
- $project =
$this->boproject->read_single($common_data['workorder']['project_id']);
-
- $grouping_descr_old = '';
-
- if (isSet($values_hour) AND is_array($values_hour))
- {
- foreach($values_hour as $hour)
- {
- $descr= $hour['hours_descr'];
-
- if($hour['remark'])
- {
- $descr .= "\n" .
$hour['remark'];
- }
-
- if(!$show_cost)
- {
- unset($hour['billperae']);
- unset($hour['cost']);
- }
-
-
if($hour['grouping_descr']!=$grouping_descr_old)
- {
- $content[] = array
- (
- lang('post')
=> $hour['grouping_descr'],
- lang('code')
=> '',
- lang('descr')
=> '',
- lang('unit')
=> '',
- lang('quantity')
=> '',
- lang('bill per unit')
=> '',
- lang('cost')
=> ''
- );
- }
-
- $grouping_descr_old =
$hour['grouping_descr'];
-
- $content[] = array
- (
- lang('post')
=> $hour['post'],
- lang('code')
=> $hour['code'],
- lang('descr')
=> $descr,
- lang('unit')
=> $hour['unit'],
- lang('quantity')
=> $hour['quantity'],
- lang('bill per unit')
=> $hour['billperae'],
- lang('cost')
=> $hour['cost']
- );
- }
- }
-
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $date =
$GLOBALS['phpgw']->common->show_date('',$dateformat);
-
- // don't want any warnings turning up in the pdf code
if the server is set to 'anal' mode.
- //error_reporting(7);
- //error_reporting(E_ALL);
- set_time_limit(1800);
- $pdf -> ezSetMargins(50,70,50,50);
- $pdf->selectFont(PHPGW_APP_INC .
'/pdf/fonts/Helvetica.afm');
-
- // put a line top and bottom on all the pages
- $all = $pdf->openObject();
- $pdf->saveState();
- $pdf->setStrokeColor(0,0,0,1);
- $pdf->line(20,40,578,40);
- $pdf->line(20,822,578,822);
- $pdf->addText(50,823,6,lang('Chapter') . ' '
.$common_data['workorder']['chapter_id'] . ' ' .
$common_data['workorder']['chapter'] );
- $pdf->addText(50,34,6,'BBB');
- $pdf->addText(300,34,6,$date);
- if($mark_draft)
- {
- $pdf->setColor(1,0,0);
- // $pdf->setColor(66,66,99);
- $pdf->addText(200,400,40,lang('DRAFT'),-10);
- $pdf->setColor(1,0,0);
- }
- $pdf->restoreState();
- $pdf->closeObject();
- // note that object can be told to appear on just odd
or even pages by changing 'all' to 'odd'
- // or 'even'.
- $pdf->addObject($all,'all');
-
- $pdf->ezSetDy(-100);
-
-
- $pdf->ezStartPageNumbers(500,28,10,'right','{PAGENUM} '
. lang('of') . ' {TOTALPAGENUM}',1);
-
- $pdf->ezText($project['name'],20);
- $pdf->ezText($project['descr'],14);
- $pdf->ezSetDy(-50);
- $pdf->ezText(lang('Order') . ': ' . $workorder_id . ' '
.$common_data['workorder']['title'],14);
- $pdf->ezText(lang('Chapter') . ' '
.$common_data['workorder']['chapter_id'] . ' ' .
$common_data['workorder']['chapter'] ,14);
-
- if(is_array($values_hour))
- {
- $pdf->ezNewPage();
- $pdf->ezTable($content,'',$project['name'],
-
array('xPos'=>70,'xOrientation'=>'right','width'=>500,0,'shaded'=>0,'fontSize'
=> 8,'showLines'=> 2,'titleFontSize' => 12,'outerLineThickness'=>2
- ,'cols'=>array(
- lang('bill per
unit')=>array('justification'=>'right','width'=>50)
-
,lang('quantity')=>array('justification'=>'right','width'=>50)
-
,lang('cost')=>array('justification'=>'right','width'=>50)
-
,lang('unit')=>array('width'=>40)
-
,lang('descr')=>array('width'=>120))
- ));
- }
-
- // $pdf->ezStream();
- $document= $pdf->ezOutput();
- $size=strlen($document);
-
- $browser = CreateObject('phpgwapi.browser');
-
$browser->content_header('tender.pdf','application/pdf',$size);
-
- echo $document;
- }
-
- function prizebook()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour',
-
'menu',
-
'nextmatchs',
-
'search_field'));
-
- $delete = get_var('delete',array('POST','GET'));
- $hour_id = get_var('hour_id',array('POST','GET'));
-
- $workorder_id =
get_var('workorder_id',array('POST','GET'));
- $values = get_var('values',array('POST'));
-//_debug_array($values);
-
- if($delete && $hour_id)
- {
- $receipt =
$this->bo->delete($hour_id,$workorder_id);
- }
-
-
- if($values['add'])
- {
-
$receipt=$this->bo->add_hour($values,$workorder_id);
- }
-
- $links = $this->menu->links();
-
- $common_data=$this->common_data($workorder_id);
-
- $workorder = $common_data['workorder'];
-
- if($workorder['vendor_id'])
- {
- $this->bopricebook->cat_id =
$workorder['vendor_id'];
- $this->bopricebook->start = $this->start;
- $this->bopricebook->query = $this->query;
- $pricebook_list = $this->bopricebook->read();
- }
-
-//_debug_array($pricebook_list);
- $i=0;
- while (is_array($pricebook_list) && list(,$pricebook) =
each($pricebook_list))
- {
- $content_prizebook[] = array
- (
- 'counter'
=> $i,
- 'activity_id' =>
$pricebook['activity_id'],
- 'num'
=> $pricebook['num'],
- 'branch'
=> $pricebook['branch'],
- 'vendor_id'
=> $pricebook['vendor_id'],
- 'm_cost'
=> $pricebook['m_cost'],
- 'w_cost'
=> $pricebook['w_cost'],
- 'total_cost' =>
$pricebook['total_cost'],
- 'this_index' =>
$pricebook['this_index'],
- 'unit'
=> $pricebook['unit'],
- 'descr'
=> $pricebook['descr'],
- 'base_descr' =>
$pricebook['base_descr']
- );
-
- $i++;
- }
-
- $table_header_prizebook[] = array
- (
- 'sort_num' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'num',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiwo_hour.prizebook',
-
'workorder_id'
=>$workorder_id,
-
'allrows'
=>$this->allrows)
-
)),
- 'lang_num' =>
lang('Activity Num'),
- 'lang_branch' => lang('Branch'),
- 'lang_vendor' => lang('Vendor'),
- 'lang_select' => lang('Select'),
- 'lang_total_cost' => lang('Total Cost'),
- 'lang_descr' => lang('Description'),
- 'lang_base_descr' => lang('Base'),
- 'lang_m_cost' => lang('Material
cost'),
- 'lang_w_cost' => lang('Labour cost'),
- 'lang_unit' => lang('Unit'),
- 'lang_quantity' => lang('Quantity'),
-
- 'lang_view' => lang('view'),
- 'lang_edit' => lang('edit'),
- 'sort_total_cost' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'total_cost',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiwo_hour.prizebook',
-
'workorder_id'
=>$workorder_id,
-
'allrows'
=>$this->allrows)
-
)),
- 'lang_category' =>
lang('category'),
- );
-
-
- $table_done[] = array
- (
- 'lang_done' =>
lang('Done'),
- 'lang_done_statustext' => lang('Back to list'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index&workorder_id='
. $workorder_id)
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiwo_hour.prizebook',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'workorder_id' =>$workorder_id,
- 'allrows'
=>$this->allrows,
- 'query'
=>$this->query
- );
-
- $link_data_nextmatch = array
- (
- 'menuaction' =>
$this->currentapp.'.uiwo_hour.prizebook',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'workorder_id' =>$workorder_id,
- 'query'
=>$this->query
- );
-
- $link_data_delete = array
- (
- 'menuaction' =>
$this->currentapp.'.uiwo_hour.prizebook',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'workorder_id' =>$workorder_id,
- 'allrows'
=>$this->allrows,
- 'delete' =>true,
- 'query'
=>$this->query
- );
-
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit =
$this->bopricebook->total_records;
- }
-
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_add_statustext' =>
lang('Add the selected items'),
- 'lang_add' =>
lang('Add'),
- 'link_delete' =>
$GLOBALS['phpgw']->link('/index.php',$link_data_delete),
- 'function' =>
'prizebook',
- 'links' =>
$links,
- 'allrows' =>
$this->allrows,
- 'allow_allrows' => true,
- 'start_record' =>
$this->start,
- 'record_limit' =>
$record_limit,
- 'num_records' =>
count($pricebook_list),
- 'all_records' =>
$this->bopricebook->total_records,
- 'link_url' =>
$GLOBALS['phpgw']->link('/index.php',$link_data_nextmatch),
- 'img_path' =>
$GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'select_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
-
- 'lang_searchfield_statustext' =>
lang('Enter the search string. To show all entries, empty this field and press
the SUBMIT button again'),
- 'lang_searchbutton_statustext' =>
lang('Submit the search string'),
- 'query' =>
$this->query,
- 'lang_search' =>
lang('search'),
- 'workorder_data' =>
$common_data['workorder_data'],
- 'table_header_prizebook' =>
$table_header_prizebook,
- 'values_prizebook' =>
$content_prizebook,
- 'total_hours_records' =>
$common_data['total_hours_records'],
- 'lang_total_records' =>
lang('Total records'),
- 'table_header_hour' =>
$common_data['table_header'],
- 'values_hour' =>
$common_data['content'],
- 'table_sum' =>
$common_data['table_sum'],
- 'table_done' =>
$table_done,
- 'lang_no_wo_hour_cat' =>
lang('no category'),
- 'wo_hour_cat_list' =>
$this->bocommon->select_wo_hours_category_list(),
- );
-//_debug_array($data);
-
- $appname =
lang('pricebook');
- $function_msg =
lang('list pricebook');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('prizebook' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
-
- function template()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour',
-
'menu',
-
'nextmatchs',
-
'search_field'));
-
- $delete = get_var('delete',array('POST','GET'));
- $hour_id = get_var('hour_id',array('POST','GET'));
-
- $workorder_id =
get_var('workorder_id',array('POST','GET'));
- $template_id =
get_var('template_id',array('POST','GET'));
-
- $values = get_var('values',array('POST'));
-//_debug_array($values);
-
- if($delete && $hour_id)
- {
- $receipt =
$this->bo->delete($hour_id,$workorder_id);
- }
-
-
- if($values['add'])
- {
-
$receipt=$this->bo->add_hour_from_template($values,$workorder_id);
- }
-
- $links = $this->menu->links();
-
- $common_data=$this->common_data($workorder_id);
-
- $workorder = $common_data['workorder'];
-
- $botemplate =
CreateObject($this->currentapp.'.botemplate');
- $template_list =
$botemplate->read_template_hour($template_id);
-
- $i=0;
- $grouping_descr_old='';
-
- while (is_array($template_list) && list(,$template) =
each($template_list))
- {
-
-
if($template['grouping_descr']!=$grouping_descr_old)
- {
- $new_grouping = true;
- }
- else
- {
- $new_grouping = false;
- }
-
- $grouping_descr_old =
$template['grouping_descr'];
-
- if($template['activity_num'])
- {
- $code = $template['activity_num'];
- }
- else
- {
- $code =
str_replace("-",$template['tolerance'],$template['ns3420_id']);
- }
-
-
- $content_template_hour[] = array
- (
- 'counter'
=> $i,
- 'chapter_id' =>
$template['chapter_id'],
- 'grouping_descr' =>
$template['grouping_descr'],
- 'building_part' =>
$template['building_part'],
- 'new_grouping' =>
$new_grouping,
- 'code'
=> $code,
- 'activity_id' =>
$template['activity_id'],
- 'activity_num' =>
$template['activity_num'],
- 'hours_descr' =>
$template['hours_descr'],
- 'remark'
=> $template['remark'],
- 'ns3420_id'
=> $template['ns3420_id'],
- 'tolerance'
=> $template['tolerance'],
- 'cost'
=> $template['cost'],
- 'unit'
=> $template['unit'],
- 'billperae'
=> $template['billperae'],
- 'building_part' =>
$template['building_part'],
- 'dim_d'
=> $template['dim_d']
- );
-
- $i++;
- }
-
- $table_header_template_hour[] = array
- (
- 'lang_code' => lang('Code'),
- 'lang_descr' => lang('Description'),
- 'lang_unit' => lang('Unit'),
- 'lang_quantity' => lang('Quantity'),
- 'lang_billperae' => lang('Bill per
unit'),
- 'lang_cost' => lang('Cost'),
-
- 'sort_billperae' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'billperae',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiwo_hour.template',
-
'workorder_id'
=>$workorder_id,
-
'template_id'
=>$template_id,
-
'query'
=>$this->query,
-
'allrows'
=>$this->allrows)
-
)),
- 'lang_select' => lang('Select'),
- 'sort_building_part' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'building_part',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiwo_hour.template',
-
'workorder_id'
=>$workorder_id,
-
'template_id'
=>$template_id,
-
'query'
=>$this->query,
-
'allrows'
=>$this->allrows)
-
)),
- 'lang_building_part' =>
lang('Building part')
- );
-
-
- $table_done[] = array
- (
- 'lang_done' =>
lang('Done'),
- 'lang_done_statustext' => lang('Back to list'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index&workorder_id='
. $workorder_id)
- );
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiwo_hour.template',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'workorder_id' =>$workorder_id,
- 'template_id' =>$template_id,
- 'allrows'
=>$this->allrows,
- 'query'
=>$this->query
- );
-
- $link_data_nextmatch = array
- (
- 'menuaction' =>
$this->currentapp.'.uiwo_hour.template',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'workorder_id' =>$workorder_id,
- 'template_id' =>$template_id,
- 'query'
=>$this->query
- );
-
- $link_data_delete = array
- (
- 'menuaction' =>
$this->currentapp.'.uiwo_hour.template',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'workorder_id' =>$workorder_id,
- 'allrows'
=>$this->allrows,
- 'delete' =>true,
- 'query'
=>$this->query
- );
-
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'lang_select_all'
=> lang('Select All'),
- 'img_check'
=>
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
- 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
-
- 'template_id'
=> $template_id,
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'lang_add_statustext' =>
lang('Add the selected items'),
- 'lang_add'
=> lang('Add'),
- 'link_delete'
=> $GLOBALS['phpgw']->link('/index.php',$link_data_delete),
-
- 'function'
=> 'template',
- 'links'
=> $links,
- 'allrows'
=> $this->allrows,
- 'allow_allrows'
=> true,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($template_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data_nextmatch),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
-
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'workorder_data'
=> $common_data['workorder_data'],
- 'table_header_template_hour' =>
$table_header_template_hour,
- 'values_template_hour'
=> $content_template_hour,
- 'total_hours_records' =>
$common_data['total_hours_records'],
- 'lang_total_records' =>
lang('Total records'),
- 'table_header_hour'
=> $common_data['table_header'],
- 'values_hour'
=> $common_data['content'],
- 'table_sum'
=> $common_data['table_sum'],
- 'table_done'
=> $table_done
- );
-
-//_debug_array($data);
- $appname
= lang('Template');
- $function_msg =
lang('list template');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_template_hour' =>
$data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit()
- {
- if(!$this->acl_edit)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
- }
- $from =
get_var('from',array('POST','GET'));
- $template_id =
get_var('template_id',array('POST','GET'));
- $workorder_id =
get_var('workorder_id',array('POST','GET'));
- $activity_id =
get_var('activity_id',array('POST','GET'));
- $hour_id =
get_var('hour_id',array('POST','GET'));
- $values =
get_var('values',array('POST','GET'));
- $values['ns3420_id'] =
get_var('ns3420_id',array('POST','GET'));
- $values['ns3420_descr'] =
get_var('ns3420_descr',array('POST','GET'));
-
-
-//_debug_array($workorder);
-
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour'));
-
- if ($values['save'])
- {
- if($values['copy_hour'])
- {
- unset($hour_id);
- }
-
- $values['hour_id'] = $hour_id;
-
- if(!$receipt['error'])
- {
- $receipt =
$this->bo->save_hour($values,$workorder_id);
-
- $hour_id=$receipt['hour_id'];
- }
- }
-
- if ($hour_id)
- {
- $values = $this->bo->read_single_hour($hour_id);
- $function_msg = lang('Edit hour');
- }
- else
- {
- $function_msg = lang('Add hour');
- }
-
- $workorder =
$this->boworkorder->read_single($workorder_id);
-
-//_debug_array($values);
-
- if($error_id)
- {
- unset($values['hour_id']);
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiwo_hour.edit',
- 'activity_id' => $activity_id,
- 'workorder_id' => $workorder_id,
- 'template_id' => $template_id,
- 'hour_id' => $hour_id,
- 'from' => $from
- );
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.'
. $from . '&workorder_id=' . $workorder_id . '&template_id=' . $template_id),
- 'lang_workorder'
=> lang('Workorder'),
- 'value_workorder_id' =>
$workorder['workorder_id'],
- 'value_workorder_title' =>
$workorder['title'],
-
- 'lang_hour_id'
=> lang('Hour ID'),
- 'value_hour_id'
=> $hour_id,
-
- 'lang_copy_hour' =>
lang('Copy hour ?'),
- 'lang_copy_hour_statustext' => lang('Choose
Copy Hour to copy this hour to a new hour'),
-
- 'lang_activity_num'
=> lang('Activity code'),
- 'value_activity_num' =>
$values['activity_num'],
- 'value_activity_id'
=> $values['activity_id'],
-
- 'lang_unit'
=> lang('Unit'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'lang_descr'
=> lang('description'),
- 'value_descr'
=> $values['hours_descr'],
- 'lang_descr_statustext' =>
lang('Enter the description for this activity'),
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'lang_save_statustext' =>
lang('Save the building'),
-
- 'lang_remark'
=> lang('Remark'),
- 'value_remark'
=> $values['remark'],
- 'lang_remark_statustext' =>
lang('Enter additional remarks to the description - if any'),
-
- 'lang_quantity'
=> lang('quantity'),
- 'value_quantity'
=> $values['quantity'],
- 'lang_quantity_statustext' =>
lang('Enter quantity of unit'),
-
- 'lang_billperae'
=> lang('Cost per unit'),
- 'value_billperae'
=> $values['billperae'],
- 'lang_billperae_statustext' =>
lang('Enter the cost per unit'),
-
- 'lang_total_cost'
=> lang('Total cost'),
- 'value_total_cost'
=> $values['cost'],
- 'lang_total_cost_statustext' => lang('Enter
the total cost of this activity - if not to be calculated from unit-cost'),
-
-
- 'lang_vendor'
=> lang('Vendor'),
- 'value_vendor_id'
=> $workorder['vendor_id'],
- 'value_vendor_name'
=> $workorder['vendor_name'],
-
- 'lang_dim_d'
=> lang('Dim D'),
- 'dim_d_list'
=> $this->bopricebook->get_dim_d_list($values['dim_d']),
- 'select_dim_d'
=> 'values[dim_d]',
- 'lang_no_dim_d'
=> lang('No Dim D'),
- 'lang_dim_d_statustext' =>
lang('Select the Dim D for this activity. To do not use Dim D - select NO DIM
D'),
-
- 'lang_unit'
=> lang('Unit'),
- 'unit_list'
=> $this->bopricebook->get_unit_list($values['unit']),
- 'select_unit'
=> 'values[unit]',
- 'lang_no_unit'
=> lang('Select Unit'),
- 'lang_unit_statustext' =>
lang('Select the unit for this activity.'),
-
- 'lang_chapter'
=> lang('chapter'),
- 'chapter_list'
=> $this->bo->get_chapter_list('select',$workorder['chapter_id']),
- 'select_chapter'
=> 'values[chapter_id]',
- 'lang_no_chapter'
=> lang('Select chapter'),
- 'lang_chapter_statustext' =>
lang('Select the chapter (for tender) for this activity.'),
-
- 'lang_tolerance'
=> lang('tolerance'),
- 'tolerance_list'
=> $this->bo->get_tolerance_list($values['tolerance_id']),
- 'select_tolerance'
=> 'values[tolerance_id]',
- 'lang_no_tolerance'
=> lang('Select tolerance'),
- 'lang_tolerance_statustext' =>
lang('Select the tolerance for this activity.'),
-
- 'lang_grouping'
=> lang('grouping'),
- 'grouping_list'
=> $this->bo->get_grouping_list($values['grouping_id'],$workorder_id),
- 'select_grouping'
=> 'values[grouping_id]',
- 'lang_no_grouping'
=> lang('Select grouping'),
- 'lang_grouping_statustext' =>
lang('Select the grouping for this activity.'),
-
- 'lang_new_grouping'
=> lang('New grouping'),
- 'lang_new_grouping_statustext' =>
lang('Enter a new grouping for this activity if not found in the list'),
-
- 'lang_building_part'
=> lang('building_part'),
- 'building_part_list'
=> $this->bo->get_building_part_list($values['building_part_id']),
- 'select_building_part'
=> 'values[building_part_id]',
- 'lang_no_building_part'
=> lang('Select building part'),
- 'lang_building_part_statustext' =>
lang('Select the building part for this activity.'),
-
-
- 'ns3420_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.ns3420'),
- 'lang_ns3420'
=> lang('NS3420'),
- 'value_ns3420_id'
=> $values['ns3420_id'],
- 'lang_ns3420_statustext' =>
lang('Select a standard-code from the norwegian standard'),
- 'currency'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
- 'lang_wo_hour_category' =>
lang('category'),
- 'lang_select_wo_hour_category' =>
lang('no category'),
- 'wo_hour_cat_list' =>
$this->bocommon->select_wo_hours_category_list($values['wo_hour_cat']),
- );
-
- $appname
= lang('Workorder');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_hour' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function delete()
- {
- if(!$this->acl_edit)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
- }
- $id =
get_var('id',array('POST','GET'));
- $workorder_id =
get_var('workorder_id',array('POST','GET'));
- $hour_id =
get_var('hour_id',array('POST','GET'));
- $deviation_id =
get_var('deviation_id',array('POST','GET'));
- $confirm =
get_var('confirm',array('POST'));
-
-
- if($deviation_id)
- {
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiwo_hour.deviation',
- 'workorder_id'=>$workorder_id,
- 'hour_id'=>$hour_id
- );
- $delete_link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiwo_hour.delete',
- 'workorder_id'=>$workorder_id,
- 'hour_id'=>$hour_id,
- 'deviation_id'=>$deviation_id
- );
-
- $function_msg
= lang('delete deviation');
- }
- else
- {
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiwo_hour.index'
- );
- $delete_link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiwo_hour.delete',
- 'id'=>$id
- );
- $function_msg
= lang('delete hour');
- }
-
- if (get_var('confirm',array('POST')))
- {
- if($deviation_id)
- {
-
$this->bo->delete_deviation($workorder_id,$hour_id,$deviation_id);
- }
- else
- {
- $this->bo->delete($id);
- }
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php',$delete_link_data),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('workorder');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage project
+ * @version $Id: class.uiwo_hour.inc.php,v 1.17 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uiwo_hour
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'tender' => True,
+ 'view' => True,
+ 'template' => True,
+ 'save_template' => True,
+ 'prizebook' => True,
+ 'add' => True,
+ 'edit' => True,
+ 'delete' => True,
+ 'deviation' => True,
+ 'edit_deviation'=> True
+ );
+
+ function uiwo_hour()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->create_html =
CreateObject('phpgwapi.xslttemplates');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $this->bo =
CreateObject($this->currentapp.'.bowo_hour',True);
+ $this->boworkorder =
CreateObject($this->currentapp.'.boworkorder');
+ $this->boproject =
CreateObject($this->currentapp.'.boproject');
+ $this->bopricebook =
CreateObject($this->currentapp.'.bopricebook');
+
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+ $this->config =
CreateObject('phpgwapi.config');
+
+ $this->config->read_repository();
+
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+ $this->acl2_location = '.project';
+ $this->acl_read =
$this->acl2->check('.project',1);
+ $this->acl_add =
$this->acl2->check('.project',2);
+ $this->acl_edit =
$this->acl2->check('.project',4);
+ $this->acl_delete =
$this->acl2->check('.project',8);
+
+ $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->chapter_id =
$this->bo->chapter_id;
+ $this->allrows =
$this->bo->allrows;
+
+ $this->menu->sub ='project';
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' =>
$this->filter,
+ 'cat_id' =>
$this->cat_id,
+ 'chapter_id' => $this->chapter_id,
+ 'allrows' =>
$this->allrows
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function deviation()
+ {
+ $workorder_id =
get_var('workorder_id',array('POST','GET'));
+ $hour_id =
get_var('hour_id',array('POST','GET'));
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour'));
+ $list =
$this->bo->read_deviation(array('workorder_id'=>$workorder_id,'hour_id'=>$hour_id));
+
+ $sum_deviation = 0;
+
+ if (isset($list) AND is_array($list))
+ {
+ $dateformat
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ foreach($list as $entry)
+ {
+ $sum_deviation = $sum_deviation +
$entry['amount'];
+
+ $entry_date =
(isset($entry['entry_date'])?$GLOBALS['phpgw']->common->show_date($entry['entry_date'],$dateformat):'');
+
+ $content[] = array
+ (
+ 'id'
=> $entry['id'],
+ 'amount'
=> $entry['amount'],
+ 'descr'
=> $entry['descr'],
+ 'entry_date'
=> $entry_date,
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.edit_deviation&workorder_id='
. $workorder_id . '&hour_id=' . $hour_id . '&id=' . $entry['id']),
+ 'lang_edit_statustext'
=> lang('edit the deviation'),
+ 'text_edit'
=> lang('edit'),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.delete&workorder_id='
. $workorder_id . '&hour_id=' . $hour_id . '&deviation_id=' . $entry['id']),
+ 'lang_delete_statustext'
=> lang('delete the deviation'),
+ 'text_delete'
=> lang('delete'),
+ );
+ }
+ }
+
+
+ $table_header[] = array
+ (
+ 'lang_id' => lang('ID'),
+ 'lang_amount' => lang('amount'),
+ 'lang_descr' => lang('Descr'),
+ 'lang_date' => lang('date'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete')
+ );
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiwo_hour.edit_deviation',
+ 'workorder_id' =>$workorder_id,
+ 'hour_id'
=>$hour_id
+ );
+
+
+ $data = array
+ (
+ 'sum_deviation'
=> $sum_deviation,
+ 'table_header_deviation' =>
$table_header,
+ 'values_deviation'
=> $content,
+ 'lang_add'
=> lang('add'),
+ 'lang_add_statustext' =>
lang('add a deviation'),
+ 'add_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_done'
=> lang('done'),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index&workorder_id='
. $workorder_id)
+ );
+
+ $appname =
lang('Workorder');
+ $function_msg = lang('list
deviation');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_deviation' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function edit_deviation()
+ {
+ $workorder_id =
get_var('workorder_id',array('POST','GET'));
+ $hour_id =
get_var('hour_id',array('POST','GET'));
+ $id =
get_var('id',array('POST','GET'));
+ $values =
get_var('values',array('POST','GET'));
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour'));
+
+ if ($values['save'])
+ {
+ $values['workorder_id']=$workorder_id;
+ $values['hour_id']=$hour_id;
+ if (!$values['amount'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('amount not entered!'));
+ }
+
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+
+ if (!$receipt['error'])
+ {
+ $receipt =
$this->bo->save_deviation($values,$action);
+ if(!$id)
+ {
+ $id=$receipt['id'];
+ }
+ }
+ else
+ {
+ $receipt['error'][] = array('msg'=>
lang('Status has NOT been saved'));
+ }
+
+ }
+
+ if ($id)
+ {
+ $values =
$this->bo->read_single_deviation(array('workorder_id'=>$workorder_id,'hour_id'=>$hour_id,'id'=>$id));
+ $function_msg = lang('edit deviation');
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add deviation');
+ $action='add';
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiwo_hour.edit_deviation',
+ 'entity_id' => $this->entity_id,
+ 'cat_id' => $this->cat_id,
+ 'id' => $id
+ );
+
+ $hour = $this->bo->read_single_hour($hour_id);
+
+//_debug_array($workorder);
+//_debug_array($hour);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $entry_date =
(isset($values['entry_date'])?$GLOBALS['phpgw']->common->show_date($values['entry_date'],$dateformat):'');
+
+ $data = array
+ (
+ 'lang_workorder'
=> lang('Workorder ID'),
+ 'lang_hour_id'
=> lang('Post'),
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.deviation&workorder_id='
. $workorder_id . '&hour_id=' . $hour_id),
+ 'lang_id'
=> lang('deviation ID'),
+ 'lang_descr'
=> lang('Descr'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'lang_date'
=> lang('date'),
+ 'value_id'
=> $id,
+ 'value_workorder_id' =>
$workorder_id,
+ 'value_hour_id'
=> $hour_id,
+ 'entry_date'
=> $entry_date,
+ 'value_id'
=> $id,
+ 'lang_descr_standardtext' =>
lang('Enter a description of the deviation'),
+ 'lang_done_standardtext' =>
lang('Back to the list'),
+ 'lang_save_standardtext' =>
lang('Save the deviation'),
+ 'lang_amount'
=> lang('amount'),
+ 'value_amount'
=> $values['amount'],
+ 'value_descr'
=> $values['descr']
+ );
+
+ $appname
= lang('workorder');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_deviation' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function common_data($workorder_id,$view='')
+ {
+
+ $workorder =
$this->boworkorder->read_single($workorder_id);
+/* if
(!$this->bocommon->check_perms($workorder['grants'],PHPGW_ACL_EDIT))
+ {
+ $receipt['error'][]=array('msg'=>lang('You have
no edit right for this project'));
+
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp,$receipt);
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.view&id='
. $workorder_id);
+ }
+*/
+ $hour_list = $this->bo->read($workorder_id);
+//_debug_array($hour_list);
+ $grouping_descr_old='';
+
+ if (isset($hour_list) AND is_array($hour_list))
+ {
+ foreach($hour_list as $hour)
+ {
+ $sum_hour = $sum_hour +
$hour['cost'];
+ $sum_deviation = $sum_deviation +
$hour['deviation'];
+
+
if($hour['grouping_descr']!=$grouping_descr_old)
+ {
+ $new_grouping = true;
+ }
+ else
+ {
+ $new_grouping = false;
+ }
+
+ $grouping_descr_old =
$hour['grouping_descr'];
+
+ if($hour['activity_num'])
+ {
+ $code = $hour['activity_num'];
+ }
+ else
+ {
+ $code =
str_replace("-",$hour['tolerance'],$hour['ns3420_id']);
+ }
+
+ if($hour['count_deviation'] || $view)
+ {
+ $deviation=$hour['deviation'];
+ }
+ else
+ {
+ $deviation=lang('edit');
+ }
+
+ $content[] = array
+ (
+
+ 'post'
=> sprintf("%02s",$workorder['chapter_id']) . '.' .
sprintf("%02s",$hour['building_part']) . '.' .
sprintf("%02s",$hour['grouping_id']) . '.' . sprintf("%03s",$hour['record']),
+ 'hour_id'
=> $hour['hour_id'],
+ 'activity_num'
=> $hour['activity_num'],
+ 'hours_descr'
=> $hour['hours_descr'],
+ 'activity_descr'
=> $hour['activity_descr'],
+ 'new_grouping'
=> $new_grouping,
+ 'grouping_id'
=> $hour['grouping_id'],
+ 'grouping_descr'
=> $hour['grouping_descr'],
+ 'ns3420_id'
=> $hour['ns3420_id'],
+ 'code'
=> $code,
+ 'remark'
=> $hour['remark'],
+ 'building_part'
=> $hour['building_part'],
+ 'quantity'
=> $hour['quantity'],
+ 'cost'
=> $hour['cost'],
+ 'unit'
=> $hour['unit'],
+ 'billperae'
=> $hour['billperae'],
+ 'deviation'
=> $deviation,
+ 'result'
=> ($hour['deviation']+$hour['cost']),
+ 'wo_hour_category'
=> $hour['wo_hour_category'],
+ 'link_deviation'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.deviation&workorder_id='
. $workorder_id . '&hour_id=' . $hour['hour_id']),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.edit&workorder_id='
. $workorder_id . '&hour_id=' . $hour['hour_id']),
+ 'lang_edit_statustext'
=> lang('edit/customise this hour'),
+ 'lang_delete_statustext'
=> lang('delete this hour'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+ }
+
+
$this->bo->update_deviation(array('workorder_id'=>$workorder_id,'sum_deviation'=>$sum_deviation));
+
+//_debug_array($content);
+
+ $table_header[] = array
+ (
+ 'lang_post' => lang('Post'),
+ 'lang_code' => lang('Code'),
+ 'lang_descr' => lang('descr'),
+ 'lang_unit' => lang('Unit'),
+ 'lang_billperae' => lang('Bill per
unit'),
+ 'lang_quantity' => lang('Quantity'),
+ 'lang_cost' => lang('cost'),
+ 'lang_deviation ' => lang('deviation'),
+ 'lang_result' => lang('result'),
+ 'lang_view' => lang('view'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'lang_category' => lang('category')
+ );
+
+ $tax = $this->config->config_data['fm_tax'];
+
+ $sum_result = $sum_hour+$sum_deviation;
+
+ $addition_percentage = $sum_result *
$workorder['addition_percentage']/100;
+ $sum_tax = ($sum_result + $addition_percentage +
$workorder['addition_rs'])*$tax/100;
+ $total_sum = $sum_result + $addition_percentage +
$workorder['addition_rs'] + $sum_tax;
+
+
$this->bo->update_calculation(array('workorder_id'=>$workorder_id,'calculation'=>($sum_result+$addition_percentage
+ $workorder['addition_rs'])));
+
+ $table_sum[] = array
+ (
+ 'lang_sum_calculation' =>
lang('Sum calculation'),
+ 'value_sum_calculation' =>
number_format($sum_hour, 2, ',', ''),
+ 'lang_addition_rs'
=> lang('Rig addition'),
+ 'value_addition_rs'
=> number_format($workorder['addition_rs'], 2, ',', ''),
+ 'lang_addition_percentage' =>
lang('Percentage addition'),
+ 'value_addition_percentage' =>
number_format($addition_percentage, 2, ',', ''),
+ 'lang_sum_tax'
=> lang('Sum tax'),
+ 'value_sum_tax'
=> number_format($sum_tax, 2, ',', ''),
+ 'lang_total_sum'
=> lang('Total sum'),
+ 'value_total_sum'
=> number_format($total_sum, 2, ',', ''),
+ 'lang_sum_deviation' =>
lang('Sum deviation'),
+ 'sum_deviation'
=> number_format($sum_deviation, 2, ',', ''),
+ 'sum_result'
=> number_format($sum_result, 2, ',', '')
+ );
+
+ $workorder_data = array(
+ 'link_workorder'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit&id='
. $workorder_id),
+ 'lang_vendor_name'
=> lang('Vendor'),
+ 'vendor_name'
=> $workorder['vendor_name'],
+ 'vendor_email'
=> $workorder['vendor_email'],
+ 'descr'
=> $workorder['descr'],
+
+ 'lang_workorder_id'
=> lang('Workorder ID'),
+ 'workorder_id'
=> $workorder['workorder_id'],
+ 'lang_project_id'
=> lang('Project ID'),
+ 'link_project'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit&id='
. $workorder['project_id']),
+ 'project_id'
=> $workorder['project_id'],
+
+ 'lang_workorder_title' =>
lang('Workorder title'),
+ 'workorder_title'
=> $workorder['title']
+ );
+
+
+
+ $common_data = array(
+ 'content' =>
$content,
+ 'total_hours_records' => count($content),
+ 'table_header' =>
$table_header,
+ 'table_sum' => $table_sum,
+ 'workorder' => $workorder,
+ 'workorder_data' =>
$workorder_data,
+ );
+
+ return $common_data;
+ }
+
+ function save_template()
+ {
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour',
+
'menu'));
+
+ $values =
get_var('values',array('POST'));
+ $workorder_id =
get_var('workorder_id',array('POST','GET'));
+
+ if($values['name'])
+ {
+ $receipt =
$this->bo->add_template($values,$workorder_id);
+ }
+
+ $common_data=$this->common_data($workorder_id);
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiwo_hour.index',
+ 'workorder_id' => $workorder_id
+ );
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'done_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'add_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.save_template&workorder_id='
. $workorder_id),
+
+ 'lang_done_statustext' =>
lang('Back to the workorder list'),
+ 'lang_add_statustext' =>
lang('Adds this workorders calculation as a template for later use'),
+ 'lang_search_statustext' =>
lang('Adds a new workorder to an existing project'),
+
+ 'lang_done'
=> lang('Done'),
+ 'lang_add'
=> lang('Add'),
+ 'lang_search'
=> lang('Search'),
+
+ 'lang_name'
=> lang('name'),
+ 'lang_name_statustext' => lang('Enter
the name the template'),
+
+ 'lang_descr'
=> lang('Description'),
+ 'lang_descr_statustext' => lang('Enter
a short description of this template'),
+
+ 'total_hours_records' =>
$common_data['total_hours_records'],
+ 'lang_total_records' =>
lang('Total records'),
+ 'table_header_hour'
=> $common_data['table_header'],
+ 'values_hour'
=> $common_data['content'],
+ 'workorder_data'
=> $common_data['workorder_data']
+ );
+
+ $appname
= lang('Workorder');
+ $function_msg =
lang('Add template');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('add_template' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function index()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour','menu'));
+
+ $delete = get_var('delete',array('POST','GET'));
+ $hour_id = get_var('hour_id',array('POST','GET'));
+ $workorder_id =
get_var('workorder_id',array('POST','GET'));
+ $links = $this->menu->links();
+
+ if($delete && $hour_id)
+ {
+ $receipt =
$this->bo->delete($hour_id,$workorder_id);
+ }
+
+ $common_data=$this->common_data($workorder_id);
+
+ $table_add[] = array
+ (
+ 'lang_add_prizebook'
=> lang('Add from prizebook'),
+ 'lang_add_prizebook_statustext' =>
lang('add items from this vendors prizebook'),
+ 'add_prizebook_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.prizebook&workorder_id='
. $workorder_id),
+
+ 'lang_add_template'
=> lang('Add from template'),
+ 'lang_add_template_statustext' =>
lang('add items from a predefined template'),
+ 'add_template_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitemplate.index&lookup=true&workorder_id='
. $workorder_id),
+
+ 'lang_add_custom'
=> lang('Add custom'),
+ 'lang_add_custom_statustext' =>
lang('Add single custom line'),
+ 'add_custom_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.edit&from=index&workorder_id='
. $workorder_id),
+
+ 'lang_save_template'
=> lang('Save as template'),
+ 'lang_save_template_statustext' =>
lang('Save this workorder as a template for later use'),
+ 'save_template_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.save_template&from=index&workorder_id='
. $workorder_id),
+
+ 'lang_print_view'
=> lang('Print view'),
+ 'lang_print_view_statustext' =>
lang('View the complete workorder'),
+ 'print_view_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.view&from=index&workorder_id='
. $workorder_id),
+
+ 'lang_view_tender'
=> lang('View tender'),
+ 'lang_view_tender_statustext' =>
lang('View the complete workorder as a tender for bidding'),
+ 'view_tender_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.tender&from=index&workorder_id='
. $workorder_id),
+
+ 'lang_show_cost'
=> lang('Show calculated cost'),
+ 'lang_show_cost_statustext'
=> lang('Show calculated cost on the printview'),
+
+ 'lang_show_details'
=> lang('Show details'),
+ 'lang_show_details_statustext' =>
lang('Show details'),
+
+ 'lang_mark_draft'
=> lang('Mark as DRAFT'),
+ 'lang_mark_draft_statustext' =>
lang('Mark the tender as DRAFT')
+
+ );
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index&delete=true&workorder_id='
. $workorder_id),
+ 'function'
=> 'index',
+ 'links'
=> $links,
+ 'num_records'
=> count($hours_list),
+ 'total_hours_records' =>
$common_data['total_hours_records'],
+ 'lang_total_records' =>
lang('Total records'),
+ 'table_header_hour'
=> $common_data['table_header'],
+ 'values_hour'
=> $common_data['content'],
+ 'workorder_data'
=> $common_data['workorder_data'],
+ 'table_add'
=> $table_add,
+ 'table_sum'
=> $common_data['table_sum']
+ );
+
+//_debug_array($common_data['content']);
+
+ $appname
= lang('Workorder');
+ $function_msg =
lang('list hours');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_hour' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function view()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour','menu'));
+
+ $show_cost =
get_var('show_cost',array('POST','GET'));
+ $show_details =
get_var('show_details',array('POST','GET'));
+ $workorder_id =
get_var('workorder_id',array('POST','GET'));
+ $to_email =
get_var('to_email',array('POST','GET'));
+ $update_email =
get_var('update_email',array('POST','GET'));
+ $send_order =
get_var('send_order',array('POST','GET'));
+ $no_email =
get_var('no_email',array('POST','GET'));
+
+ if($update_email)
+ {
+
$this->bo->update_email($to_email,$workorder_id);
+ }
+ $workorder =
$this->boworkorder->read_single($workorder_id);
+
+ $table_header_history[] = array
+ (
+ 'lang_date' => lang('Date'),
+ 'lang_user' => lang('User'),
+ 'lang_action' => lang('Action'),
+ 'lang_new_value' => lang('New value')
+ );
+
+
+ $common_data =
$this->common_data($workorder_id);
+ if($show_details)
+ {
+ $values_hour =
$common_data['content'];
+ }
+ $project =
$this->boproject->read_single($common_data['workorder']['project_id']);
+
+ $bolocation =
CreateObject($this->currentapp.'.bolocation');
+
+ $location_data=$bolocation->initiate_ui_location(array(
+ 'values' =>
$project['location_data'],
+ 'type_id' =>
count(explode('-',$project['location_data']['location_code'])),
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' =>
$project['location_data']['tenant_id'],
+ 'lookup_type' => 'view'
+ ));
+
+ if($project['contact_phone'])
+ {
+ for
($i=0;$i<count($location_data['location']);$i++)
+ {
+
if($location_data['location'][$i]['input_name'] == 'contact_phone')
+ {
+
unset($location_data['location'][$i]['value']);
+ }
+ }
+ }
+
+ if(!$show_cost)
+ {
+ $m = count($values_hour);
+ for ($i=0;$i<$m;$i++)
+ {
+ unset($values_hour[$i]['cost']);
+ unset($values_hour[$i]['billperae']);
+ }
+
unset($common_data['table_sum'][0]['value_total_sum']);
+ }
+
+ $table_header[] = array
+ (
+ 'lang_post' => lang('Post'),
+ 'lang_code' => lang('Code'),
+ 'lang_descr' => lang('descr'),
+ 'lang_unit' => lang('Unit'),
+ 'lang_billperae' => lang('Bill per
unit'),
+ 'lang_quantity' => lang('Quantity'),
+ 'lang_cost' => lang('cost')
+ );
+
+
+ $table_send[] = array
+ (
+ 'lang_send_order'
=> lang('Send Order'),
+ 'lang_send_order_statustext' => lang('Send
this order by email')
+ );
+
+ $table_done[] = array
+ (
+ 'lang_done'
=> lang('Done'),
+ 'lang_done_statustext' =>
lang('Back to calculation'),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index&workorder_id='
. $workorder_id)
+ );
+
+ $dateformat
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $date
= $GLOBALS['phpgw']->common->show_date(time(),$dateformat);
+
+ $from_name =
$GLOBALS['phpgw_info']['user']['fullname'];
+ $from_email =
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['email'];
+
+ $email_data = array
+ (
+ 'location_data'
=> $location_data,
+ 'lang_workorder'
=> lang('Workorder ID'),
+ 'workorder_id'
=> $workorder_id,
+
+ 'lang_date'
=> lang('Date'),
+ 'date'
=> $date,
+
+ 'lang_start_date'
=> lang('Start date'),
+ 'start_date'
=> $workorder['start_date'],
+
+ 'lang_end_date'
=> lang('End date'),
+ 'end_date'
=> $workorder['end_date'],
+
+ 'lang_from'
=> lang('From'),
+ 'from_name'
=> $from_name,
+ 'from_email'
=> $from_email,
+ 'from_phone'
=>
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['cellphone'],
+ 'lang_district'
=> lang('District'),
+ 'district'
=> $project['location_data']['district_id'],
+
+ 'lang_to'
=> lang('To'),
+ 'to_name'
=> $workorder['vendor_name'],
+
+ 'lang_title'
=> lang('Title'),
+ 'title'
=> $workorder['title'],
+
+ 'lang_descr'
=> lang('Description'),
+ 'descr'
=> $workorder['descr'],
+
+ 'lang_budget_account' =>
lang('Budget account'),
+ 'budget_account'
=> $workorder['b_account_id'],
+
+ 'lang_sum_calculation' =>
lang('Sum of calculation'),
+ 'sum_calculation'
=> $common_data['table_sum'][0]['value_total_sum'],
+
+ 'lang_contact_phone' =>
lang('Contact phone'),
+ 'contact_phone'
=> $project['contact_phone'],
+
+// 'lang_vendor'
=> lang('vendor'),
+
+ 'lang_branch'
=> lang('branch'),
+ 'branch_list'
=> $this->boproject->select_branch_p_list($project['project_id']),
+ 'other_branch'
=> $project['other_branch'],
+
+ 'key_responsible_list' =>
$this->boproject->select_branch_list($project['key_responsible']),
+ 'lang_key_responsible' =>
lang('key responsible'),
+
+ 'key_fetch_list'
=> $this->boproject->select_key_location_list($workorder['key_fetch']),
+ 'lang_key_fetch'
=> lang('Where to pick up the key'),
+
+ 'key_deliver_list'
=> $this->boproject->select_key_location_list($workorder['key_deliver']),
+ 'lang_key_deliver'
=> lang('Where to deliver the key'),
+
+ 'currency'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
+
+ 'lang_cost_tax'
=> lang('Cost (incl tax):'),
+ 'lang_materials'
=> lang('Materials:__________'),
+ 'lang_work'
=> lang('work:____________'),
+
+ 'table_header_view_order' =>
$table_header,
+ 'values_view_order'
=> $values_hour
+ );
+
+
+ if($send_order && !$to_email)
+ {
+
$receipt['error'][]=array('msg'=>lang('No mailaddress is selected'));
+ }
+
+ if($to_email)
+ {
+
$this->create_html->add_file(array(PHPGW_SERVER_ROOT . SEP . $this->currentapp
. SEP . 'templates' . SEP . 'default' . SEP . 'wo_hour'));
+
$this->create_html->add_file(array(PHPGW_SERVER_ROOT . SEP . $this->currentapp
. SEP . 'templates' . SEP . 'default' . SEP . 'location_view'));
+
+
$this->create_html->set_var('phpgw',array('email_data' => $email_data));
+
+ $this->create_html->xsl_parse();
+ $this->create_html->xml_parse();
+ $xsltproc = xslt_create();
+ $arguments = array('/_xml' =>
$this->create_html->xmldata, '/_xsl' => $this->create_html->xsldata);
+ $html =
xslt_process($xsltproc,'arg:/_xml','arg:/_xsl',NULL,$arguments);
+ xslt_free($xsltproc);
+
+// print $html;
+
+ $headers = "Return-Path: <". $from_email
.">\r\n";
+ $headers .= "From: " . $from_name . "<" .
$from_email .">\r\n";
+
if($GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['order_email_rcpt']==1)
+ {
+ $headers .= "Bcc: " . $from_name . "<"
. $from_email .">\r\n";
+ $bcc = $from_email;
+ }
+ $headers .= "Content-type: text/html;
charset=iso-8859-1\r\n";
+ $headers .= "MIME-Version: 1.0\r\n";
+ $subject = lang('Workorder').": ".$workorder_id;
+
+ $mail_method=
$this->config->config_data['fmwrkorder_mail'];
+
+ if ($mail_method=='smtp'):
+ {
+ $send = CreateObject('phpgwapi.send');
+ $rcpt = $send->msg('email', $to_email,
$subject, $html, '', $cc, $bcc, $from_email, $from_name, 'html');
+ }
+ elseif ($mail_method=='sendmail'):
+ {
+ $rcpt=mail($to_email,$subject,$html,
$headers);
+ }
+ else:
+ {
+
$receipt['error'][]=array('msg'=>lang('Mailing method is not chosen! (admin
section)'));
+ }
+ endif;
+
+ if ($rcpt)
+ {
+ $historylog =
CreateObject($this->currentapp.'.historylog','workorder');
+
$historylog->add('M',$workorder_id,$to_email);
+
$receipt['message'][]=array('msg'=>lang('Workorder is sent by email!'));
+ }
+ else
+ {
+
$receipt['error'][]=array('msg'=>lang('The recipient did not get the email:'));
+
$receipt['error'][]=array('msg'=>lang('From') . ' ' . $from_email);
+
$receipt['error'][]=array('msg'=>lang('To') . ' ' . $to_email);
+ }
+ }
+
+ $workorder_history =
$this->boworkorder->read_record_history($workorder_id);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $email_list =
$this->bo->get_email($to_email,$workorder['vendor_id']);
+ if(count($email_list)==1)
+ {
+ $to_email= $email_list[0]['email'];
+ unset($email_list);
+ }
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'lang_mail'
=> lang('E-Mail'),
+ 'lang_update_email'
=> lang('Update email'),
+ 'lang_update_email_statustext' =>
lang('Check to update the email-address for this vendor'),
+ 'lang_to_email_address_statustext' =>
lang('The address to which this order will be sendt'),
+ 'to_email'
=> $to_email,
+ 'email_list'
=> $email_list,
+ 'lang_select_email'
=> lang('Select email'),
+ 'send_order_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.view&send=true&workorder_id='
. $workorder_id . '&show_details=' . $show_details),
+
+ 'lang_no_history'
=> lang('No history'),
+ 'lang_history'
=> lang('History'),
+ 'workorder_history'
=> $workorder_history,
+ 'table_header_history' =>
$table_header_history,
+ 'email_data'
=> $email_data,
+ 'no_email'
=> $no_email,
+ 'table_send'
=> $table_send,
+ 'table_done'
=> $table_done
+ );
+
+//_debug_array($data);
+
+ $appname
= lang('Workorder');
+ $function_msg =
lang('Send order');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+
+ $this->save_sessiondata();
+ }
+
+
+ function tender()
+ {
+ $GLOBALS['phpgw_info']['flags'][noheader] = True;
+ $GLOBALS['phpgw_info']['flags'][nofooter] = True;
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = False;
+
+ $pdf =
CreateObject($this->currentapp.'.pdf');
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+ $show_cost = get_var('show_cost',array('POST','GET'));
+ $mark_draft = get_var('mark_draft',array('POST','GET'));
+ $workorder_id =
get_var('workorder_id',array('POST','GET'));
+
+ $common_data =
$this->common_data($workorder_id);
+ $values_hour = $common_data['content'];
+ $project =
$this->boproject->read_single($common_data['workorder']['project_id']);
+
+ $grouping_descr_old = '';
+
+ if (isSet($values_hour) AND is_array($values_hour))
+ {
+ foreach($values_hour as $hour)
+ {
+ $descr= $hour['hours_descr'];
+
+ if($hour['remark'])
+ {
+ $descr .= "\n" .
$hour['remark'];
+ }
+
+ if(!$show_cost)
+ {
+ unset($hour['billperae']);
+ unset($hour['cost']);
+ }
+
+
if($hour['grouping_descr']!=$grouping_descr_old)
+ {
+ $content[] = array
+ (
+ lang('post')
=> $hour['grouping_descr'],
+ lang('code')
=> '',
+ lang('descr')
=> '',
+ lang('unit')
=> '',
+ lang('quantity')
=> '',
+ lang('bill per unit')
=> '',
+ lang('cost')
=> ''
+ );
+ }
+
+ $grouping_descr_old =
$hour['grouping_descr'];
+
+ $content[] = array
+ (
+ lang('post')
=> $hour['post'],
+ lang('code')
=> $hour['code'],
+ lang('descr')
=> $descr,
+ lang('unit')
=> $hour['unit'],
+ lang('quantity')
=> $hour['quantity'],
+ lang('bill per unit')
=> $hour['billperae'],
+ lang('cost')
=> $hour['cost']
+ );
+ }
+ }
+
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $date =
$GLOBALS['phpgw']->common->show_date('',$dateformat);
+
+ // don't want any warnings turning up in the pdf code
if the server is set to 'anal' mode.
+ //error_reporting(7);
+ //error_reporting(E_ALL);
+ set_time_limit(1800);
+ $pdf -> ezSetMargins(50,70,50,50);
+ $pdf->selectFont(PHPGW_APP_INC .
'/pdf/fonts/Helvetica.afm');
+
+ // put a line top and bottom on all the pages
+ $all = $pdf->openObject();
+ $pdf->saveState();
+ $pdf->setStrokeColor(0,0,0,1);
+ $pdf->line(20,40,578,40);
+ $pdf->line(20,822,578,822);
+ $pdf->addText(50,823,6,lang('Chapter') . ' '
.$common_data['workorder']['chapter_id'] . ' ' .
$common_data['workorder']['chapter'] );
+ $pdf->addText(50,34,6,'BBB');
+ $pdf->addText(300,34,6,$date);
+ if($mark_draft)
+ {
+ $pdf->setColor(1,0,0);
+ // $pdf->setColor(66,66,99);
+ $pdf->addText(200,400,40,lang('DRAFT'),-10);
+ $pdf->setColor(1,0,0);
+ }
+ $pdf->restoreState();
+ $pdf->closeObject();
+ // note that object can be told to appear on just odd
or even pages by changing 'all' to 'odd'
+ // or 'even'.
+ $pdf->addObject($all,'all');
+
+ $pdf->ezSetDy(-100);
+
+
+ $pdf->ezStartPageNumbers(500,28,10,'right','{PAGENUM} '
. lang('of') . ' {TOTALPAGENUM}',1);
+
+ $pdf->ezText($project['name'],20);
+ $pdf->ezText($project['descr'],14);
+ $pdf->ezSetDy(-50);
+ $pdf->ezText(lang('Order') . ': ' . $workorder_id . ' '
.$common_data['workorder']['title'],14);
+ $pdf->ezText(lang('Chapter') . ' '
.$common_data['workorder']['chapter_id'] . ' ' .
$common_data['workorder']['chapter'] ,14);
+
+ if(is_array($values_hour))
+ {
+ $pdf->ezNewPage();
+ $pdf->ezTable($content,'',$project['name'],
+
array('xPos'=>70,'xOrientation'=>'right','width'=>500,0,'shaded'=>0,'fontSize'
=> 8,'showLines'=> 2,'titleFontSize' => 12,'outerLineThickness'=>2
+ ,'cols'=>array(
+ lang('bill per
unit')=>array('justification'=>'right','width'=>50)
+
,lang('quantity')=>array('justification'=>'right','width'=>50)
+
,lang('cost')=>array('justification'=>'right','width'=>50)
+
,lang('unit')=>array('width'=>40)
+
,lang('descr')=>array('width'=>120))
+ ));
+ }
+
+ // $pdf->ezStream();
+ $document= $pdf->ezOutput();
+ $size=strlen($document);
+
+ $browser = CreateObject('phpgwapi.browser');
+
$browser->content_header('tender.pdf','application/pdf',$size);
+
+ echo $document;
+ }
+
+ function prizebook()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour',
+
'menu',
+
'nextmatchs',
+
'search_field'));
+
+ $delete = get_var('delete',array('POST','GET'));
+ $hour_id = get_var('hour_id',array('POST','GET'));
+
+ $workorder_id =
get_var('workorder_id',array('POST','GET'));
+ $values = get_var('values',array('POST'));
+//_debug_array($values);
+
+ if($delete && $hour_id)
+ {
+ $receipt =
$this->bo->delete($hour_id,$workorder_id);
+ }
+
+
+ if($values['add'])
+ {
+
$receipt=$this->bo->add_hour($values,$workorder_id);
+ }
+
+ $links = $this->menu->links();
+
+ $common_data=$this->common_data($workorder_id);
+
+ $workorder = $common_data['workorder'];
+
+ if($workorder['vendor_id'])
+ {
+ $this->bopricebook->cat_id =
$workorder['vendor_id'];
+ $this->bopricebook->start = $this->start;
+ $this->bopricebook->query = $this->query;
+ $pricebook_list = $this->bopricebook->read();
+ }
+
+//_debug_array($pricebook_list);
+ $i=0;
+ while (is_array($pricebook_list) && list(,$pricebook) =
each($pricebook_list))
+ {
+ $content_prizebook[] = array
+ (
+ 'counter'
=> $i,
+ 'activity_id' =>
$pricebook['activity_id'],
+ 'num'
=> $pricebook['num'],
+ 'branch'
=> $pricebook['branch'],
+ 'vendor_id'
=> $pricebook['vendor_id'],
+ 'm_cost'
=> $pricebook['m_cost'],
+ 'w_cost'
=> $pricebook['w_cost'],
+ 'total_cost' =>
$pricebook['total_cost'],
+ 'this_index' =>
$pricebook['this_index'],
+ 'unit'
=> $pricebook['unit'],
+ 'descr'
=> $pricebook['descr'],
+ 'base_descr' =>
$pricebook['base_descr']
+ );
+
+ $i++;
+ }
+
+ $table_header_prizebook[] = array
+ (
+ 'sort_num' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'num',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiwo_hour.prizebook',
+
'workorder_id'
=>$workorder_id,
+
'allrows'
=>$this->allrows)
+
)),
+ 'lang_num' =>
lang('Activity Num'),
+ 'lang_branch' => lang('Branch'),
+ 'lang_vendor' => lang('Vendor'),
+ 'lang_select' => lang('Select'),
+ 'lang_total_cost' => lang('Total Cost'),
+ 'lang_descr' => lang('Description'),
+ 'lang_base_descr' => lang('Base'),
+ 'lang_m_cost' => lang('Material
cost'),
+ 'lang_w_cost' => lang('Labour cost'),
+ 'lang_unit' => lang('Unit'),
+ 'lang_quantity' => lang('Quantity'),
+
+ 'lang_view' => lang('view'),
+ 'lang_edit' => lang('edit'),
+ 'sort_total_cost' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'total_cost',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiwo_hour.prizebook',
+
'workorder_id'
=>$workorder_id,
+
'allrows'
=>$this->allrows)
+
)),
+ 'lang_category' =>
lang('category'),
+ );
+
+
+ $table_done[] = array
+ (
+ 'lang_done' =>
lang('Done'),
+ 'lang_done_statustext' => lang('Back to list'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index&workorder_id='
. $workorder_id)
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiwo_hour.prizebook',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'workorder_id' =>$workorder_id,
+ 'allrows'
=>$this->allrows,
+ 'query'
=>$this->query
+ );
+
+ $link_data_nextmatch = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiwo_hour.prizebook',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'workorder_id' =>$workorder_id,
+ 'query'
=>$this->query
+ );
+
+ $link_data_delete = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiwo_hour.prizebook',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'workorder_id' =>$workorder_id,
+ 'allrows'
=>$this->allrows,
+ 'delete' =>true,
+ 'query'
=>$this->query
+ );
+
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit =
$this->bopricebook->total_records;
+ }
+
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_add_statustext' =>
lang('Add the selected items'),
+ 'lang_add' =>
lang('Add'),
+ 'link_delete' =>
$GLOBALS['phpgw']->link('/index.php',$link_data_delete),
+ 'function' =>
'prizebook',
+ 'links' =>
$links,
+ 'allrows' =>
$this->allrows,
+ 'allow_allrows' => true,
+ 'start_record' =>
$this->start,
+ 'record_limit' =>
$record_limit,
+ 'num_records' =>
count($pricebook_list),
+ 'all_records' =>
$this->bopricebook->total_records,
+ 'link_url' =>
$GLOBALS['phpgw']->link('/index.php',$link_data_nextmatch),
+ 'img_path' =>
$GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'select_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+
+ 'lang_searchfield_statustext' =>
lang('Enter the search string. To show all entries, empty this field and press
the SUBMIT button again'),
+ 'lang_searchbutton_statustext' =>
lang('Submit the search string'),
+ 'query' =>
$this->query,
+ 'lang_search' =>
lang('search'),
+ 'workorder_data' =>
$common_data['workorder_data'],
+ 'table_header_prizebook' =>
$table_header_prizebook,
+ 'values_prizebook' =>
$content_prizebook,
+ 'total_hours_records' =>
$common_data['total_hours_records'],
+ 'lang_total_records' =>
lang('Total records'),
+ 'table_header_hour' =>
$common_data['table_header'],
+ 'values_hour' =>
$common_data['content'],
+ 'table_sum' =>
$common_data['table_sum'],
+ 'table_done' =>
$table_done,
+ 'lang_no_wo_hour_cat' =>
lang('no category'),
+ 'wo_hour_cat_list' =>
$this->bocommon->select_wo_hours_category_list(),
+ );
+//_debug_array($data);
+
+ $appname =
lang('pricebook');
+ $function_msg =
lang('list pricebook');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('prizebook' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+
+ function template()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour',
+
'menu',
+
'nextmatchs',
+
'search_field'));
+
+ $delete = get_var('delete',array('POST','GET'));
+ $hour_id = get_var('hour_id',array('POST','GET'));
+
+ $workorder_id =
get_var('workorder_id',array('POST','GET'));
+ $template_id =
get_var('template_id',array('POST','GET'));
+
+ $values = get_var('values',array('POST'));
+//_debug_array($values);
+
+ if($delete && $hour_id)
+ {
+ $receipt =
$this->bo->delete($hour_id,$workorder_id);
+ }
+
+
+ if($values['add'])
+ {
+
$receipt=$this->bo->add_hour_from_template($values,$workorder_id);
+ }
+
+ $links = $this->menu->links();
+
+ $common_data=$this->common_data($workorder_id);
+
+ $workorder = $common_data['workorder'];
+
+ $botemplate =
CreateObject($this->currentapp.'.botemplate');
+ $template_list =
$botemplate->read_template_hour($template_id);
+
+ $i=0;
+ $grouping_descr_old='';
+
+ while (is_array($template_list) && list(,$template) =
each($template_list))
+ {
+
+
if($template['grouping_descr']!=$grouping_descr_old)
+ {
+ $new_grouping = true;
+ }
+ else
+ {
+ $new_grouping = false;
+ }
+
+ $grouping_descr_old =
$template['grouping_descr'];
+
+ if($template['activity_num'])
+ {
+ $code = $template['activity_num'];
+ }
+ else
+ {
+ $code =
str_replace("-",$template['tolerance'],$template['ns3420_id']);
+ }
+
+
+ $content_template_hour[] = array
+ (
+ 'counter'
=> $i,
+ 'chapter_id' =>
$template['chapter_id'],
+ 'grouping_descr' =>
$template['grouping_descr'],
+ 'building_part' =>
$template['building_part'],
+ 'new_grouping' =>
$new_grouping,
+ 'code'
=> $code,
+ 'activity_id' =>
$template['activity_id'],
+ 'activity_num' =>
$template['activity_num'],
+ 'hours_descr' =>
$template['hours_descr'],
+ 'remark'
=> $template['remark'],
+ 'ns3420_id'
=> $template['ns3420_id'],
+ 'tolerance'
=> $template['tolerance'],
+ 'cost'
=> $template['cost'],
+ 'unit'
=> $template['unit'],
+ 'billperae'
=> $template['billperae'],
+ 'building_part' =>
$template['building_part'],
+ 'dim_d'
=> $template['dim_d']
+ );
+
+ $i++;
+ }
+
+ $table_header_template_hour[] = array
+ (
+ 'lang_code' => lang('Code'),
+ 'lang_descr' => lang('Description'),
+ 'lang_unit' => lang('Unit'),
+ 'lang_quantity' => lang('Quantity'),
+ 'lang_billperae' => lang('Bill per
unit'),
+ 'lang_cost' => lang('Cost'),
+
+ 'sort_billperae' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'billperae',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiwo_hour.template',
+
'workorder_id'
=>$workorder_id,
+
'template_id'
=>$template_id,
+
'query'
=>$this->query,
+
'allrows'
=>$this->allrows)
+
)),
+ 'lang_select' => lang('Select'),
+ 'sort_building_part' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'building_part',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiwo_hour.template',
+
'workorder_id'
=>$workorder_id,
+
'template_id'
=>$template_id,
+
'query'
=>$this->query,
+
'allrows'
=>$this->allrows)
+
)),
+ 'lang_building_part' =>
lang('Building part')
+ );
+
+
+ $table_done[] = array
+ (
+ 'lang_done' =>
lang('Done'),
+ 'lang_done_statustext' => lang('Back to list'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index&workorder_id='
. $workorder_id)
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiwo_hour.template',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'workorder_id' =>$workorder_id,
+ 'template_id' =>$template_id,
+ 'allrows'
=>$this->allrows,
+ 'query'
=>$this->query
+ );
+
+ $link_data_nextmatch = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiwo_hour.template',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'workorder_id' =>$workorder_id,
+ 'template_id' =>$template_id,
+ 'query'
=>$this->query
+ );
+
+ $link_data_delete = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiwo_hour.template',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'workorder_id' =>$workorder_id,
+ 'allrows'
=>$this->allrows,
+ 'delete' =>true,
+ 'query'
=>$this->query
+ );
+
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'lang_select_all'
=> lang('Select All'),
+ 'img_check'
=>
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
+ 'check_source'
=> './'.$this->currentapp.'/inc/check.js',
+
+ 'template_id'
=> $template_id,
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'lang_add_statustext' =>
lang('Add the selected items'),
+ 'lang_add'
=> lang('Add'),
+ 'link_delete'
=> $GLOBALS['phpgw']->link('/index.php',$link_data_delete),
+
+ 'function'
=> 'template',
+ 'links'
=> $links,
+ 'allrows'
=> $this->allrows,
+ 'allow_allrows'
=> true,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($template_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data_nextmatch),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'workorder_data'
=> $common_data['workorder_data'],
+ 'table_header_template_hour' =>
$table_header_template_hour,
+ 'values_template_hour'
=> $content_template_hour,
+ 'total_hours_records' =>
$common_data['total_hours_records'],
+ 'lang_total_records' =>
lang('Total records'),
+ 'table_header_hour'
=> $common_data['table_header'],
+ 'values_hour'
=> $common_data['content'],
+ 'table_sum'
=> $common_data['table_sum'],
+ 'table_done'
=> $table_done
+ );
+
+//_debug_array($data);
+ $appname
= lang('Template');
+ $function_msg =
lang('list template');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_template_hour' =>
$data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit()
+ {
+ if(!$this->acl_edit)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
+ }
+ $from =
get_var('from',array('POST','GET'));
+ $template_id =
get_var('template_id',array('POST','GET'));
+ $workorder_id =
get_var('workorder_id',array('POST','GET'));
+ $activity_id =
get_var('activity_id',array('POST','GET'));
+ $hour_id =
get_var('hour_id',array('POST','GET'));
+ $values =
get_var('values',array('POST','GET'));
+ $values['ns3420_id'] =
get_var('ns3420_id',array('POST','GET'));
+ $values['ns3420_descr'] =
get_var('ns3420_descr',array('POST','GET'));
+
+
+//_debug_array($workorder);
+
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour'));
+
+ if ($values['save'])
+ {
+ if($values['copy_hour'])
+ {
+ unset($hour_id);
+ }
+
+ $values['hour_id'] = $hour_id;
+
+ if(!$receipt['error'])
+ {
+ $receipt =
$this->bo->save_hour($values,$workorder_id);
+
+ $hour_id=$receipt['hour_id'];
+ }
+ }
+
+ if ($hour_id)
+ {
+ $values = $this->bo->read_single_hour($hour_id);
+ $function_msg = lang('Edit hour');
+ }
+ else
+ {
+ $function_msg = lang('Add hour');
+ }
+
+ $workorder =
$this->boworkorder->read_single($workorder_id);
+
+//_debug_array($values);
+
+ if($error_id)
+ {
+ unset($values['hour_id']);
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiwo_hour.edit',
+ 'activity_id' => $activity_id,
+ 'workorder_id' => $workorder_id,
+ 'template_id' => $template_id,
+ 'hour_id' => $hour_id,
+ 'from' => $from
+ );
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.'
. $from . '&workorder_id=' . $workorder_id . '&template_id=' . $template_id),
+ 'lang_workorder'
=> lang('Workorder'),
+ 'value_workorder_id' =>
$workorder['workorder_id'],
+ 'value_workorder_title' =>
$workorder['title'],
+
+ 'lang_hour_id'
=> lang('Hour ID'),
+ 'value_hour_id'
=> $hour_id,
+
+ 'lang_copy_hour' =>
lang('Copy hour ?'),
+ 'lang_copy_hour_statustext' => lang('Choose
Copy Hour to copy this hour to a new hour'),
+
+ 'lang_activity_num'
=> lang('Activity code'),
+ 'value_activity_num' =>
$values['activity_num'],
+ 'value_activity_id'
=> $values['activity_id'],
+
+ 'lang_unit'
=> lang('Unit'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'lang_descr'
=> lang('description'),
+ 'value_descr'
=> $values['hours_descr'],
+ 'lang_descr_statustext' =>
lang('Enter the description for this activity'),
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'lang_save_statustext' =>
lang('Save the building'),
+
+ 'lang_remark'
=> lang('Remark'),
+ 'value_remark'
=> $values['remark'],
+ 'lang_remark_statustext' =>
lang('Enter additional remarks to the description - if any'),
+
+ 'lang_quantity'
=> lang('quantity'),
+ 'value_quantity'
=> $values['quantity'],
+ 'lang_quantity_statustext' =>
lang('Enter quantity of unit'),
+
+ 'lang_billperae'
=> lang('Cost per unit'),
+ 'value_billperae'
=> $values['billperae'],
+ 'lang_billperae_statustext' =>
lang('Enter the cost per unit'),
+
+ 'lang_total_cost'
=> lang('Total cost'),
+ 'value_total_cost'
=> $values['cost'],
+ 'lang_total_cost_statustext' => lang('Enter
the total cost of this activity - if not to be calculated from unit-cost'),
+
+
+ 'lang_vendor'
=> lang('Vendor'),
+ 'value_vendor_id'
=> $workorder['vendor_id'],
+ 'value_vendor_name'
=> $workorder['vendor_name'],
+
+ 'lang_dim_d'
=> lang('Dim D'),
+ 'dim_d_list'
=> $this->bopricebook->get_dim_d_list($values['dim_d']),
+ 'select_dim_d'
=> 'values[dim_d]',
+ 'lang_no_dim_d'
=> lang('No Dim D'),
+ 'lang_dim_d_statustext' =>
lang('Select the Dim D for this activity. To do not use Dim D - select NO DIM
D'),
+
+ 'lang_unit'
=> lang('Unit'),
+ 'unit_list'
=> $this->bopricebook->get_unit_list($values['unit']),
+ 'select_unit'
=> 'values[unit]',
+ 'lang_no_unit'
=> lang('Select Unit'),
+ 'lang_unit_statustext' =>
lang('Select the unit for this activity.'),
+
+ 'lang_chapter'
=> lang('chapter'),
+ 'chapter_list'
=> $this->bo->get_chapter_list('select',$workorder['chapter_id']),
+ 'select_chapter'
=> 'values[chapter_id]',
+ 'lang_no_chapter'
=> lang('Select chapter'),
+ 'lang_chapter_statustext' =>
lang('Select the chapter (for tender) for this activity.'),
+
+ 'lang_tolerance'
=> lang('tolerance'),
+ 'tolerance_list'
=> $this->bo->get_tolerance_list($values['tolerance_id']),
+ 'select_tolerance'
=> 'values[tolerance_id]',
+ 'lang_no_tolerance'
=> lang('Select tolerance'),
+ 'lang_tolerance_statustext' =>
lang('Select the tolerance for this activity.'),
+
+ 'lang_grouping'
=> lang('grouping'),
+ 'grouping_list'
=> $this->bo->get_grouping_list($values['grouping_id'],$workorder_id),
+ 'select_grouping'
=> 'values[grouping_id]',
+ 'lang_no_grouping'
=> lang('Select grouping'),
+ 'lang_grouping_statustext' =>
lang('Select the grouping for this activity.'),
+
+ 'lang_new_grouping'
=> lang('New grouping'),
+ 'lang_new_grouping_statustext' =>
lang('Enter a new grouping for this activity if not found in the list'),
+
+ 'lang_building_part'
=> lang('building_part'),
+ 'building_part_list'
=> $this->bo->get_building_part_list($values['building_part_id']),
+ 'select_building_part'
=> 'values[building_part_id]',
+ 'lang_no_building_part'
=> lang('Select building part'),
+ 'lang_building_part_statustext' =>
lang('Select the building part for this activity.'),
+
+
+ 'ns3420_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.ns3420'),
+ 'lang_ns3420'
=> lang('NS3420'),
+ 'value_ns3420_id'
=> $values['ns3420_id'],
+ 'lang_ns3420_statustext' =>
lang('Select a standard-code from the norwegian standard'),
+ 'currency'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
+ 'lang_wo_hour_category' =>
lang('category'),
+ 'lang_select_wo_hour_category' =>
lang('no category'),
+ 'wo_hour_cat_list' =>
$this->bocommon->select_wo_hours_category_list($values['wo_hour_cat']),
+ );
+
+ $appname
= lang('Workorder');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_hour' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function delete()
+ {
+ if(!$this->acl_edit)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
+ }
+ $id =
get_var('id',array('POST','GET'));
+ $workorder_id =
get_var('workorder_id',array('POST','GET'));
+ $hour_id =
get_var('hour_id',array('POST','GET'));
+ $deviation_id =
get_var('deviation_id',array('POST','GET'));
+ $confirm =
get_var('confirm',array('POST'));
+
+
+ if($deviation_id)
+ {
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiwo_hour.deviation',
+ 'workorder_id'=>$workorder_id,
+ 'hour_id'=>$hour_id
+ );
+ $delete_link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiwo_hour.delete',
+ 'workorder_id'=>$workorder_id,
+ 'hour_id'=>$hour_id,
+ 'deviation_id'=>$deviation_id
+ );
+
+ $function_msg
= lang('delete deviation');
+ }
+ else
+ {
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiwo_hour.index'
+ );
+ $delete_link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiwo_hour.delete',
+ 'id'=>$id
+ );
+ $function_msg
= lang('delete hour');
+ }
+
+ if (get_var('confirm',array('POST')))
+ {
+ if($deviation_id)
+ {
+
$this->bo->delete_deviation($workorder_id,$hour_id,$deviation_id);
+ }
+ else
+ {
+ $this->bo->delete($id);
+ }
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php',$delete_link_data),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('workorder');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ }
+?>
Index: property/inc/class.uiworkorder.inc.php
diff -u property/inc/class.uiworkorder.inc.php:1.16
property/inc/class.uiworkorder.inc.php:1.17
--- property/inc/class.uiworkorder.inc.php:1.16 Wed Nov 9 22:49:12 2005
+++ property/inc/class.uiworkorder.inc.php Fri Jan 27 14:05:43 2006
@@ -1,1128 +1,1128 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage project
- * @version $Id: class.uiworkorder.inc.php,v 1.16 2005/11/09 22:49:12
sigurdne Exp $
- */
-
- /**
- * Description
- * @package property
- */
-
- class uiworkorder
- {
- var $grants;
- var $cat_id;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $filter;
- var $part_of_town_id;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'excel' => True,
- 'index' => True,
- 'view' => True,
- 'add' => True,
- 'edit' => True,
- 'delete' => True
- );
-
- function uiworkorder()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- $this->bo =
CreateObject($this->currentapp.'.boworkorder',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
- $this->acl2 =
CreateObject($this->currentapp.'.acl2');
- $this->acl2_location = '.project';
- $this->acl_read =
$this->acl2->check('.project',1);
- $this->acl_add =
$this->acl2->check('.project',2);
- $this->acl_edit =
$this->acl2->check('.project',4);
- $this->acl_delete =
$this->acl2->check('.project',8);
-
- $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->status_id =
$this->bo->status_id;
- $this->search_vendor =
$this->bo->search_vendor;
- $this->wo_hour_cat_id =
$this->bo->wo_hour_cat_id;
- $this->start_date =
$this->bo->start_date;
- $this->end_date =
$this->bo->end_date;
-
- $this->menu->sub ='project';
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' =>
$this->filter,
- 'cat_id' =>
$this->cat_id,
- 'search_vendor' =>
$this->search_vendor,
- 'status_id' =>
$this->status_id,
- 'wo_hour_cat_id' =>
$this->wo_hour_cat_id,
- 'start_date' =>
$this->start_date,
- 'end_date' =>
$this->end_date
- );
- $this->bo->save_sessiondata($data);
- }
-
- function excel()
- {
- $start_date = urldecode($this->start_date);
- $end_date = urldecode($this->end_date);
- $list =
$this->bo->read($start_date,$end_date,$allrows=True);
- $uicols = $this->bo->uicols;
-
$this->bocommon->excel($list,$uicols['name'],$uicols['descr'],$uicols['input_type']);
- }
-
-
- function index()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('workorder','values','table_header',
-
'menu',
-
'nextmatchs'));
-
- $links = $this->menu->links('workorder');
-
- $start_date = urldecode($this->start_date);
- $end_date = urldecode($this->end_date);
- $workorder_list =
$this->bo->read($start_date,$end_date);
-
- $uicols = $this->bo->uicols;
- $count_uicols_name=count($uicols['name']);
-
- $j=0;
- if (isSet($workorder_list) AND
is_array($workorder_list))
- {
- foreach($workorder_list as $workorder_entry)
- {
- for ($k=0;$k<$count_uicols_name;$k++)
- {
-
if($uicols['input_type'][$k]!='hidden')
- {
-
if($workorder_entry['query_location'][$uicols['name'][$k]])
- {
-
$content[$j]['row'][$k]['statustext'] = lang('search');
-
$content[$j]['row'][$k]['text'] =
$workorder_entry[$uicols['name'][$k]];
-
$content[$j]['row'][$k]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.index&query='
. $workorder_entry['query_location'][$uicols['name'][$k]] . '&lookup=' .
$lookup . '&filter=' . $this->filter);
- }
- else
- {
-
$content[$j]['row'][$k]['value'] =
$workorder_entry[$uicols['name'][$k]];
-
$content[$j]['row'][$k]['name'] = $uicols['name'][$k];
-
if($uicols['name'][$k]=='vendor_id')
- {
-
$content[$j]['row'][$k]['statustext'] = $workorder_entry['org_name'];
-
$content[$j]['row'][$k]['overlib'] = True;
-
$content[$j]['row'][$k]['text'] =
$workorder_entry[$uicols['name'][$k]];
- }
- }
- }
- if($lookup &&
$k==($count_uicols_name - 2))
-
$content[$j]['row'][$k]['lookup_action'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit&workorder_id='
. $workorder_entry['workorder_id']);
- }
- if(!$lookup)
- {
- if ($this->acl_read &&
$this->bocommon->check_perms($workorder_entry['grants'],PHPGW_ACL_READ))
- if($this->acl_read)
- {
-
$content[$j]['row'][$k]['statustext'] = lang('view the
workorder');
-
$content[$j]['row'][$k]['text'] = lang('view');
-
$content[$j]['row'][$k]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.view&id='
. $workorder_entry['workorder_id']);
- $k++;
- }
- else
- {
-
$content[$j]['row'][$k++]['link']='dummy';
- }
-
- if ($this->acl_edit &&
$this->bocommon->check_perms($workorder_entry['grants'],PHPGW_ACL_EDIT))
- {
-
$content[$j]['row'][$k]['statustext'] = lang('edit the
workorder');
-
$content[$j]['row'][$k]['text'] = lang('edit');
-
$content[$j]['row'][$k]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit&id='
. $workorder_entry['workorder_id']);
- $k++;
-
-
$content[$j]['row'][$k]['statustext'] = lang('calculate the
workorder');
-
$content[$j]['row'][$k]['text'] =
lang('calculate');
-
$content[$j]['row'][$k]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index&workorder_id='
. $workorder_entry['workorder_id']);
- $k++;
- }
- else
- {
-
$content[$j]['row'][$k++]['link']='dummy';
-
$content[$j]['row'][$k++]['link']='dummy';
- }
-
- if ($this->acl_delete &&
$this->bocommon->check_perms($workorder_entry['grants'],PHPGW_ACL_DELETE))
- {
-
$content[$j]['row'][$k]['statustext'] = lang('delete the
workorder');
-
$content[$j]['row'][$k]['text'] =
lang('delete');
-
$content[$j]['row'][$k]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.delete&id='
. $workorder_entry['workorder_id']);
- $k++;
- }
- else
- {
-
$content[$j]['row'][$k++]['link']='dummy';
- }
- }
- $j++;
- }
- }
-
- $count_uicols_descr=count($uicols['descr']);
- for ($i=0;$i<$count_uicols_descr;$i++)
- {
- if($uicols['input_type'][$i]!='hidden')
- {
- $table_header[$i]['header'] =
$uicols['descr'][$i];
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- if($uicols['name'][$i]=='loc1')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'fm_location1.loc1',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiworkorder.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'lookup'
=>$lookup,
-
'district_id' =>
$this->district_id,
-
'search_vendor'
=>$this->search_vendor,
-
'cat_id'
=>$this->cat_id,
-
'start_date'=>$start_date,
-
'end_date'=>$end_date,
-
'wo_hour_cat_id'
=>$this->wo_hour_cat_id
-
)
-
));
- }
- if($uicols['name'][$i]=='project_id')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'project_id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiworkorder.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'lookup'
=>$lookup,
-
'district_id' =>
$this->district_id,
-
'search_vendor'
=>$this->search_vendor,
-
'cat_id'
=>$this->cat_id,
-
'start_date'=>$start_date,
-
'end_date'=>$end_date,
-
'wo_hour_cat_id'
=>$this->wo_hour_cat_id
-
)
-
));
- }
if($uicols['name'][$i]=='workorder_id')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'workorder_id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiworkorder.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'lookup'
=>$lookup,
-
'district_id' =>
$this->district_id,
-
'search_vendor'
=>$this->search_vendor,
-
'cat_id'
=>$this->cat_id,
-
'start_date'=>$start_date,
-
'end_date'=>$end_date,
-
'wo_hour_cat_id'
=>$this->wo_hour_cat_id
-
)
-
));
- }
- if($uicols['name'][$i]=='address')
- {
- $table_header[$i]['sort_link']
=true;
- $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'address',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiworkorder.index',
-
'type_id'
=>$type_id,
-
'query'
=>$this->query,
-
'lookup'
=>$lookup,
-
'district_id' =>
$this->district_id,
-
'search_vendor'
=>$this->search_vendor,
-
'cat_id'
=>$this->cat_id,
-
'start_date'=>$start_date,
-
'end_date'=>$end_date,
-
'wo_hour_cat_id'
=>$this->wo_hour_cat_id
-
)
-
));
- }
-
- }
- }
-
- if(!$lookup)
- {
- if($this->acl_read)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('view');
- $i++;
- }
- if($this->acl_edit)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('edit');
- $i++;
-
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('calculate');
- $i++;
- }
- if($this->acl_delete)
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header']
= lang('delete');
- $i++;
- }
- }
- else
- {
- $table_header[$i]['width']
= '5%';
- $table_header[$i]['align']
= 'center';
- $table_header[$i]['header'] =
lang('select');
- }
-
-//_debug_array($content);
- if($this->acl_add)
- {
- $table_add[] = array
- (
- 'lang_add'
=> lang('add'),
- 'lang_add_statustext' => lang('add a
workorder'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.add')
- );
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiworkorder.index',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'district_id'
=>$this->district_id,
- 'status_id'
=>$this->status_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query,
- 'search_vendor'
=>$this->search_vendor,
- 'start_date'
=>$start_date,
- 'end_date'
=>$end_date,
- 'wo_hour_cat_id'
=>$this->wo_hour_cat_id
- );
-
- $link_date_search
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.date_search');
-
- $link_excel = array
- (
- 'menuaction' =>
$this->currentapp.'.uiworkorder.excel',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'cat_id'
=>$this->cat_id,
- 'district_id'
=>$this->district_id,
- 'status_id'
=>$this->status_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query,
- 'search_vendor'
=>$this->search_vendor,
- 'start_date'
=>$start_date,
- 'end_date'
=>$end_date,
- 'start'
=>$this->start,
- 'wo_hour_cat_id'
=>$this->wo_hour_cat_id,
- );
-
-
-
if($GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['group_filters'])
- {
- $group_filters = 'select';
-
$GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour_cat_select'));
- }
- else
- {
- $group_filters = 'filter';
-
$GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour_cat_filter'));
- }
-
- $data = array
- (
- 'group_filters' =>
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['group_filters'],
- 'lang_excel' =>
'excel',
- 'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
- 'lang_excel_help' =>
lang('Download table to MS Excel'),
-
- 'start_date'
=>$start_date,
- 'end_date'
=>$end_date,
- 'lang_none'
=>lang('None'),
- 'lang_date_search' =>
lang('Date search'),
- 'lang_date_search_help' => lang('Narrow
the search by dates'),
- 'link_date_search' =>
$link_date_search,
- 'overlib_source' =>
'./'.$this->currentapp.'/inc/overlib.js',
-
- 'link_history'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.index'),
- 'lang_history_statustext' =>
lang('search for history at this location'),
- 'links'
=> $links,
- 'allow_allrows'
=> false,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
- 'num_records'
=> count($workorder_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_no_cat'
=> lang('no category'),
- 'lang_cat_statustext' =>
lang('Select the category the workorder belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'cat_id',
- 'cat_list'
=>
$this->bo->select_category_workorder_list($group_filters,$this->cat_id),
- 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
-
- 'lang_status_statustext' =>
lang('Select the status the agreement belongs to. To do not use a category
select NO STATUS'),
- 'status_name'
=> 'status_id',
- 'lang_no_status'
=> lang('No status'),
- 'status_list'
=> $this->bo->select_status_list($group_filters,$this->status_id),
-
- 'lang_wo_hour_cat_statustext' =>
lang('Select the workorder hour category'),
- 'lang_no_wo_hour_cat' =>
lang('no hour category'),
- 'wo_hour_cat_list'
=> $this->bocommon->select_wo_hours_category_list($this->wo_hour_cat_id),
-
- 'lang_user_statustext' =>
lang('Select the user the workorder belongs to. To do not use a category select
NO USER'),
- 'select_user_name'
=> 'filter',
- 'lang_no_user'
=> lang('No user'),
- 'user_list'
=>
$this->bocommon->get_user_list_right2($group_filters,4,$this->filter,$this->acl2_location,array('all'),$default=$this->account),
-
- 'lang_searchvendor_statustext' => lang('Enter
the vendor name to search for'),
- 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_statustext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'search_vendor'
=> $this->search_vendor,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('Workorder');
- $function_msg =
lang('list workorder');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_workorder' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit()
- {
- if(!$this->acl_add && !$this->acl_edit)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
- }
- $boproject =
CreateObject($this->currentapp.'.boproject');
- $bolocation =
CreateObject($this->currentapp.'.bolocation');
- $config =
CreateObject('phpgwapi.config');
- $id =
get_var('id',array('POST','GET'));
- $project_id =
get_var('project_id',array('POST','GET'));
- $values =
get_var('values',array('POST'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('workorder'));
-
- $values['vendor_id'] =
get_var('vendor_id',array('POST'));
- $values['vendor_name'] =
get_var('vendor_name',array('POST'));
- $values['b_account_id'] =
get_var('b_account_id',array('POST'));
- $values['b_account_name'] =
get_var('b_account_name',array('POST'));
-
-
- $values['start_date'] =
get_var('start_date',array('POST'));
- $values['end_date'] =
get_var('end_date',array('POST'));
-
- $config->read_repository();
-
- if ($values['save'])
- {
- if(!$values['title'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter a workorder title !'));
- $error_id=true;
- }
- if(!$values['project_id'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a valid project !'));
- $error_id=true;
- }
-
- if(!$values['status'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a status !'));
- }
- if(!$values['b_account_id'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a budget account !'));
- }
-
- if($id)
- {
- $values['workorder_id']=$id;
- $action='edit';
- }
-
- if(!$receipt['error'])
- {
- if(!$id)
- {
-
$values['workorder_id']=$this->bo->next_id();
- $id =
$values['workorder_id'];
- }
- if($values['copy_workorder'])
- {
- $action='add';
- $values['workorder_id'] =
$this->bo->next_id();
- $id =
$values['workorder_id'];
- }
- $receipt =
$this->bo->save($values,$action);
- $id = $values['workorder_id'];
- $function_msg = lang('Edit Workorder');
-
- if ($values['approval'] &&
$values['mail_address'])
- {
-
$coordinator_name=$GLOBALS['phpgw_info']['user']['fullname'];
-
$coordinator_email=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['email'];
- $headers = "Return-Path: <".
$coordinator_email .">\r\n";
- $headers .= "From: " .
$coordinator_name . "<" . $coordinator_email .">\r\n";
- $headers .= "Bcc: " .
$coordinator_name . "<" . $coordinator_email .">\r\n";
- $headers .= "Content-type:
text/plain; charset=iso-8859-1\r\n";
-
- $subject = lang(Approval).": ".
$values['workorder_id'];
- $message = lang('Workorder %1
needs approval',$values['workorder_id']);
-
- $mail_method=
$config->config_data['fmwrkorder_mail'];
- if ($mail_method=='smtp'):
- {
- $bcc =
$coordinator_email;
- $send =
CreateObject('phpgwapi.send');
- $rcpt =
$send->msg('email', $values['mail_address'], $subject, stripslashes($message),
'', $cc, $bcc, $coordinator_email, $coordinator_name, 'plain');
- }
- elseif
($mail_method=='sendmail'):
- {
-
$rcpt=mail($values['mail_address'],$subject,$message, $headers);
- }
- else:
- {
-
$receipt['error'][]=array('msg'=>lang('Mailing method is not chosen! (admin
section)'));
- }
- endif;
- }
-
- if($rcpt)
- {
-
$receipt['message'][]=array('msg'=>lang('%1 is
notified',$values['mail_address']));
- }
- }
- }
-
- if(!$receipt['error'])
- {
- if($id)
- {
- $values =
$this->bo->read_single($id);
- }
- if($project_id && !$values['project_id'])
- {
- $values['project_id']=$project_id;
- }
- $project =
$boproject->read_single_mini($values['project_id']);
-
- if
(!$this->bocommon->check_perms($project['grants'],PHPGW_ACL_EDIT))
- {
-
$receipt['error'][]=array('msg'=>lang('You have no edit right for this
project'));
-
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp,$receipt);
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.view&id='
. $id);
- }
-
- if( $project['key_fetch'] &&
!$values['key_fetch'])
- {
-
$values['key_fetch']=$project['key_fetch'];
- }
-
- if( $project['key_deliver'] &&
!$values['key_deliver'])
- {
-
$values['key_deliver']=$project['key_deliver'];
- }
-
-/* if( $project['charge_tenant'] &&
!$values['workorder_id'])
- {
-
$values['charge_tenant']=$project['charge_tenant'];
- }
-*/
- if( $project['start_date'] &&
!$values['start_date'])
- {
-
$values['start_date']=$project['start_date'];
- }
- if( $project['end_date'] &&
!$values['end_date'])
- {
-
$values['end_date']=$project['end_date'];
- }
- if( $project['name'] && !$values['title'])
- {
- $values['title']=$project['name'];
- }
- if( $project['descr'] && !$values['descr'])
- {
- $values['descr']=$project['descr'];
- }
- if( $project['status'] && !$values['status'])
- {
- $values['status']=$project['status'];
- }
- }
-
- if($id)
- {
- $record_history =
$this->bo->read_record_history($id);
- }
-
-//_debug_array($hour_data);
- $table_header_history[] = array
- (
- 'lang_date' => lang('Date'),
- 'lang_user' => lang('User'),
- 'lang_action' => lang('Action'),
- 'lang_new_value' => lang('New value')
- );
-
- $table_header_workorder_budget[] = array
- (
- 'lang_workorder_id' => lang('Workorder'),
- 'lang_sum' => lang('Sum')
- );
-
- if ($id)
- {
- $function_msg = lang('Edit Workorder');
- }
- else
- {
- $function_msg = lang('Add Workorder');
- }
-
- if ($values['cat_id'])
- {
- $this->cat_id = $values['cat_id'];
- }
-
-
- $location_data=$bolocation->initiate_ui_location(array(
- 'values' =>
$project['location_data'],
- 'type_id' =>
count(explode('-',$project['location_data']['location_code'])),
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' =>
$project['location_data']['tenant_id'],
- 'lookup_type' => 'view'
- ));
-
-
- if($project['contact_phone'])
- {
- for
($i=0;$i<count($location_data['location']);$i++)
- {
-
if($location_data['location'][$i]['input_name'] == 'contact_phone')
- {
-
unset($location_data['location'][$i]['value']);
- }
- }
- }
-
-
-
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
- 'vendor_id' =>
$values['vendor_id'],
- 'vendor_name' =>
$values['vendor_name']));
-
-
$b_account_data=$this->bocommon->initiate_ui_budget_account_lookup(array(
- 'b_account_id' =>
$values['b_account_id'],
- 'b_account_name' =>
$values['b_account_name']));
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiworkorder.edit',
- 'id' => $id
- );
-
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $sep = '/';
- $dlarr[strpos($dateformat,'y')] = 'yyyy';
- $dlarr[strpos($dateformat,'m')] = 'MM';
- $dlarr[strpos($dateformat,'d')] = 'DD';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
-
-
$supervisor_id=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['approval_from'];
-
- $need_approval =
$config->config_data['workorder_approval'];
-
- if ($supervisor_id && ($need_approval=='yes'))
- {
- $prefs =
$this->bocommon->create_preferences($this->currentapp,$supervisor_id);
- $supervisor_email = $prefs['email'];
- }
-
-
$project_status=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['project_status'];
- if(!$values['status'])
- {
- $values['status']=$project_status;
- }
-
- $cal_info = $this->bocommon->jscalendar();
- $jsDateFormat=$cal_info['jsDateFormat'];
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'calculate_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index'),
- 'lang_calculate'
=> lang('Calculate Workorder'),
- 'lang_calculate_statustext' =>
lang('Calculate workorder by adding items from vendors prizebook or adding
general hours'),
-
- 'send_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.view&from=index'),
- 'lang_send'
=> lang('Send Workorder'),
- 'lang_send_statustext' =>
lang('send this workorder to vendor'),
-
- 'project_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit'),
- 'b_account_data'
=> $b_account_data,
- 'table_header_workorder_budget' =>
$table_header_workorder_budget,
- 'lang_no_workorders' =>
lang('No workorder bugdet'),
- 'workorder_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.w_edit'),
- 'record_history'
=> $record_history,
- 'table_header_history' =>
$table_header_history,
- 'lang_history'
=> lang('History'),
- 'lang_no_history'
=> lang('No history'),
-
- 'jsDateFormat'
=> $jsDateFormat,
- 'date_img'
=> $cal_info['img'],
- 'lang_datetitle'
=> lang('Select date'),
- 'calendar_setup_start' =>
"Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});",
- 'calendar_setup_end' =>
"Calendar.setup({inputField : 'end_date',ifFormat : '" . $jsDateFormat .
"',button : 'end_date-trigger'});",
-
- 'lang_start_date_statustext' => lang('Select
the estimated end date for the Project'),
- 'lang_start_date'
=> lang('Workorder start date'),
- 'value_start_date'
=> $values['start_date'],
-
- 'lang_end_date_statustext' =>
lang('Select the estimated end date for the Project'),
- 'lang_end_date'
=> lang('Workorder end date'),
- 'value_end_date'
=> $values['end_date'],
-
- 'lang_copy_workorder' =>
lang('Copy workorder ?'),
- 'lang_copy_workorder_statustext' =>
lang('Choose Copy Workorder to copy this workorder to a new workorder'),
-
- 'lang_contact_phone' =>
lang('Contact phone'),
- 'contact_phone'
=> $project['contact_phone'],
-
- 'lang_charge_tenant' =>
lang('Charge tenant'),
- 'lang_charge_tenant_statustext' => lang('Choose
charge tenant if the tenant i to pay for this project'),
- 'charge_tenant'
=> $values['charge_tenant'],
-
- 'lang_power_meter'
=> lang('Power meter'),
- 'lang_power_meter_statustext' => lang('Enter
the power_meter'),
- 'value_power_meter'
=> $project['power_meter'],
-
- 'lang_addition_rs'
=> lang('Rig addition'),
- 'lang_addition_rs_statustext' => lang('Enter
any round sum addition per order'),
- 'value_addition_rs'
=> $values['addition_rs'],
-
- 'lang_addition_percentage'
=> lang('Percentage addition'),
- 'lang_addition_percentage_statustext' =>
lang('Enter any persentage addition per unit'),
- 'value_addition_percentage'
=> $values['addition_percentage'],
-
- 'lang_budget'
=> lang('Budget'),
- 'value_budget'
=> $values['budget'],
- 'lang_budget_statustext' =>
lang('Enter the budget'),
-
- 'lang_incl_tax'
=> lang('incl tax'),
- 'lang_calculation'
=> lang('Calculation'),
- 'value_calculation'
=> $values['calculation'],
-
- 'actual_cost'
=> $values['actual_cost'],
- 'lang_actual_cost'
=> lang('Actual cost'),
-
- 'vendor_data'
=> $vendor_data,
- 'location_data'
=> $location_data,
- 'location_type'
=> 'view',
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.index'),
- 'lang_year'
=> lang('Year'),
- 'lang_category'
=> lang('category'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'lang_title'
=> lang('Title'),
- 'value_title'
=> $values['title'],
- 'lang_project_name'
=> lang('Project name'),
- 'value_project_name' =>
$project['name'],
-
- 'lang_project_id'
=> lang('Project ID'),
- 'value_project_id'
=> $values['project_id'],
-
- 'lang_workorder_id'
=> lang('Workorder ID'),
- 'value_workorder_id' =>
$values['workorder_id'],
-
- 'lang_title_statustext' =>
lang('Enter Workorder title'),
-
- 'lang_other_branch'
=> lang('Other branch'),
- 'lang_other_branch_statustext' =>
lang('Enter other branch if not found in the list'),
- 'value_other_branch'
=> $project['other_branch'],
-
- 'lang_descr_statustext' =>
lang('Enter a short description of the workorder'),
- 'lang_descr'
=> lang('Description'),
- 'value_descr'
=> $values['descr'],
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'lang_save_statustext' =>
lang('Save the workorder'),
- 'lang_no_cat'
=> lang('Select category'),
- 'lang_cat_statustext' =>
lang('Select the category the project belongs to. To do not use a category
select NO CATEGORY'),
- 'select_name'
=> 'values[cat_id]',
- 'value_cat_id'
=> $values['cat_id'],
- 'cat_list'
=>
$this->bo->select_category_workorder_list('select',$project['cat_id']),
-
- 'sum_workorder_budget' =>
$values['sum_workorder_budget'],
- 'workorder_budget'
=> $values['workorder_budget'],
-
- 'lang_coordinator'
=> lang('Coordinator'),
- 'lang_sum'
=> lang('Sum'),
- 'select_user_name'
=> 'values[coordinator]',
- 'user_list'
=>
$this->bocommon->get_user_list('select',$project['coordinator'],$extra=False,$default=False,$start=-1,$sort=False,$order=False,$query='',$offset=-1),
-
- 'status_list'
=> $this->bo->select_status_list('select',$values['status']),
- 'status_name'
=> 'values[status]',
- 'lang_no_status'
=> lang('Select status'),
- 'lang_status'
=> lang('Status'),
- 'lang_status_statustext' =>
lang('What is the current status of this workorder ?'),
-
- 'branch_list'
=> $boproject->select_branch_p_list($project['project_id']),
- 'lang_branch'
=> lang('branch'),
- 'lang_branch_statustext' =>
lang('Select the branches for this project'),
-
- 'key_responsible_list'
=> $boproject->select_branch_list($project['key_responsible']),
- 'lang_key_responsible'
=> lang('key responsible'),
-
- 'key_fetch_list'
=> $this->bo->select_key_location_list($values['key_fetch']),
- 'lang_no_key_fetch'
=> lang('Where to fetch the key'),
- 'lang_key_fetch'
=> lang('key fetch location'),
- 'lang_key_fetch_statustext'
=> lang('Select where to fetch the key'),
-
- 'key_deliver_list'
=> $this->bo->select_key_location_list($values['key_deliver']),
- 'lang_no_key_deliver'
=> lang('Where to deliver the key'),
- 'lang_key_deliver'
=> lang('key deliver location'),
- 'lang_key_deliver_statustext' =>
lang('Select where to deliver the key'),
-
- 'need_approval'
=> $need_approval,
- 'lang_ask_approval'
=> lang('Ask for approval'),
- 'lang_ask_approval_statustext' =>
lang('Check this to send a mail to your supervisor for approval'),
- 'value_approval_mail_address' =>
$supervisor_email,
- 'currency'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['currency']
- );
-
- $appname
= lang('Workorder');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function add()
- {
- if(!$this->acl_edit)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiworkorder.index'
- );
-
- $GLOBALS['phpgw']->xslttpl->add_file(array('workorder',
-
'menu',
-
'search_field'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit'),
- 'search_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.index&lookup=true&from=workorder'),
-
- 'lang_done_statustext' =>
lang('Back to the workorder list'),
- 'lang_add_statustext' =>
lang('Adds a new project - then a new workorder'),
- 'lang_search_statustext' =>
lang('Adds a new workorder to an existing project'),
-
- 'lang_done' =>
lang('Done'),
- 'lang_add' =>
lang('Add'),
- 'lang_search' =>
lang('Search')
- );
-
- $appname
= lang('Workorder');
- $function_msg =
lang('Add workorder');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
- $GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('add'
=> $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function delete()
- {
- if(!$this->acl_delete)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
- }
- $id = get_var('id',array('POST','GET'));
- $confirm = get_var('confirm',array('POST'));
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiworkorder.index'
- );
-
- if (get_var('confirm',array('POST')))
- {
- $this->bo->delete($id);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.delete&id='
. $id),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_statustext' => lang('Delete the
entry'),
- 'lang_no_statustext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('workorder');
- $function_msg =
lang('delete workorder');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function view()
- {
- if(!$this->acl_read)
- {
-
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
- }
-
- $boproject =
CreateObject($this->currentapp.'.boproject');
- $bolocation =
CreateObject($this->currentapp.'.bolocation');
-
- $receipt =
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp);
-
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp,'');
-
- $id = get_var('id',array('POST','GET'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('workorder','hour_data_view'));
-
- $uiwo_hour =
CreateObject($this->currentapp.'.uiwo_hour');
- $hour_data =
$uiwo_hour->common_data($id,$view=True);
- $values = $this->bo->read_single($id);
- $project =
$boproject->read_single($values['project_id']);
- $record_history = $this->bo->read_record_history($id);
-
- $table_header_history[] = array
- (
- 'lang_date' => lang('Date'),
- 'lang_user' => lang('User'),
- 'lang_action' => lang('Action'),
- 'lang_new_value' => lang('New value')
- );
-
- $table_header_workorder_budget[] = array
- (
- 'lang_workorder_id' => lang('Workorder'),
- 'lang_sum' => lang('Sum')
- );
-
- $function_msg = lang('View Workorder');
-
- $location_data=$bolocation->initiate_ui_location(array(
- 'values' =>
$project['location_data'],
- 'type_id' =>
count(explode('-',$project['location_data']['location_code'])),
- 'no_link' =>
False, // disable lookup links for location type less than type_id
- 'tenant' =>
$project['location_data']['tenant_id'],
- 'lookup_type' => 'view'
- ));
-
-
- if($project['contact_phone'])
- {
- for
($i=0;$i<count($location_data['location']);$i++)
- {
-
if($location_data['location'][$i]['input_name'] == 'contact_phone')
- {
-
unset($location_data['location'][$i]['value']);
- }
- }
- }
-
-
- $data = array
- (
- 'project_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.view'),
- 'table_header_workorder_budget' =>
$table_header_workorder_budget,
- 'lang_no_workorders' =>
lang('No workorder bugdet'),
- 'workorder_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.view'),
- 'record_history'
=> $record_history,
- 'table_header_history' =>
$table_header_history,
- 'lang_history'
=> lang('History'),
- 'lang_no_history'
=> lang('No history'),
-
- 'lang_project_name'
=> lang('Project name'),
- 'value_project_name' =>
$project['name'],
-
- 'lang_vendor'
=> lang('Vendor'),
- 'value_vendor_id'
=> $values['vendor_id'],
- 'value_vendor_name'
=> $values['vendor_name'],
-
- 'lang_b_account'
=> lang('Budget account'),
- 'value_b_account_id' =>
$values['b_account_id'],
- 'value_b_account_name' =>
$values['b_account_name'],
-
- 'lang_start_date'
=> lang('Project start date'),
- 'value_start_date'
=> $values['start_date'],
-
- 'lang_end_date'
=> lang('Project end date'),
- 'value_end_date'
=> $values['end_date'],
-
- 'lang_charge_tenant' =>
lang('Charge tenant'),
- 'charge_tenant'
=> $values['charge_tenant'],
-
- 'lang_power_meter'
=> lang('Power meter'),
- 'value_power_meter'
=> $project['power_meter'],
-
- 'lang_addition_rs'
=> lang('Rig addition'),
- 'lang_addition_rs_statustext' => lang('Enter
any round sum addition per order'),
- 'value_addition_rs'
=> $values['addition_rs'],
-
- 'lang_addition_percentage'
=> lang('Percentage addition'),
- 'lang_addition_percentage_statustext' =>
lang('Enter any persentage addition per unit'),
- 'value_addition_percentage'
=> $values['addition_percentage'],
-
- 'lang_budget'
=> lang('Budget'),
- 'value_budget'
=> $values['budget'],
-
- 'actual_cost'
=> $values['actual_cost'],
- 'lang_actual_cost'
=> lang('Actual cost'),
-
- 'location_data'
=> $location_data,
- 'location_type'
=> 'view',
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.index'),
- 'lang_year'
=> lang('Year'),
- 'lang_category'
=> lang('category'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'lang_name'
=> lang('Name'),
-
- 'lang_title'
=> lang('Title'),
- 'value_title'
=> $values['title'],
-
- 'lang_project_id'
=> lang('Project ID'),
- 'value_project_id'
=> $values['project_id'],
- 'value_name'
=> $values['name'],
-
- 'lang_other_branch'
=> lang('Other branch'),
- 'value_other_branch'
=> $project['other_branch'],
-
- 'lang_descr'
=> lang('Description'),
- 'value_descr'
=> $values['descr'],
- 'lang_done_statustext' =>
lang('Back to the list'),
- 'cat_list'
=>
$this->bo->select_category_workorder_list('select',$project['cat_id']),
-
- 'lang_workorder_id'
=> lang('Workorder ID'),
- 'value_workorder_id' =>
$values['workorder_id'],
-
- 'lang_coordinator'
=> lang('Coordinator'),
- 'lang_sum'
=> lang('Sum'),
- 'user_list'
=>
$this->bocommon->get_user_list('select',$project['coordinator'],$extra=False,$default=False,$start=-1,$sort=False,$order=False,$query='',$offset=-1),
-
- 'status_list'
=> $this->bo->select_status_list('select',$values['status']),
- 'lang_no_status'
=> lang('Select status'),
- 'lang_status'
=> lang('Status'),
-
- 'branch_list'
=> $this->bo->select_branch_p_list($values['project_id']),
- 'lang_branch'
=> lang('branch'),
-
- 'key_responsible_list' =>
$this->bo->select_branch_list($project['key_responsible']),
- 'lang_key_responsible' =>
lang('key responsible'),
-
- 'key_fetch_list'
=> $this->bo->select_key_location_list($values['key_fetch']),
- 'lang_key_fetch'
=> lang('key fetch location'),
-
- 'key_deliver_list'
=> $this->bo->select_key_location_list($values['key_deliver']),
- 'lang_key_deliver'
=> lang('key deliver location'),
-
- 'edit_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit&id='
. $id),
- 'lang_edit_statustext' =>
lang('Edit this entry workorder'),
- 'lang_edit'
=> lang('Edit'),
- 'currency'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
- 'lang_total_records' =>
lang('Total records'),
- 'total_hours_records' =>
$hour_data['total_hours_records'],
- 'table_header_hour'
=> $hour_data['table_header'],
- 'values_hour'
=> $hour_data['content'],
- 'table_sum'
=> $hour_data['table_sum'],
- 'lang_contact_phone' =>
lang('Contact phone'),
- 'contact_phone'
=> $project['contact_phone']
- );
-
- $appname
= lang('Workorder');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage project
+ * @version $Id: class.uiworkorder.inc.php,v 1.17 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uiworkorder
+ {
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+ var $part_of_town_id;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'excel' => True,
+ 'index' => True,
+ 'view' => True,
+ 'add' => True,
+ 'edit' => True,
+ 'delete' => True
+ );
+
+ function uiworkorder()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $this->bo =
CreateObject($this->currentapp.'.boworkorder',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+ $this->acl2 =
CreateObject($this->currentapp.'.acl2');
+ $this->acl2_location = '.project';
+ $this->acl_read =
$this->acl2->check('.project',1);
+ $this->acl_add =
$this->acl2->check('.project',2);
+ $this->acl_edit =
$this->acl2->check('.project',4);
+ $this->acl_delete =
$this->acl2->check('.project',8);
+
+ $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->status_id =
$this->bo->status_id;
+ $this->search_vendor =
$this->bo->search_vendor;
+ $this->wo_hour_cat_id =
$this->bo->wo_hour_cat_id;
+ $this->start_date =
$this->bo->start_date;
+ $this->end_date =
$this->bo->end_date;
+
+ $this->menu->sub ='project';
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' =>
$this->filter,
+ 'cat_id' =>
$this->cat_id,
+ 'search_vendor' =>
$this->search_vendor,
+ 'status_id' =>
$this->status_id,
+ 'wo_hour_cat_id' =>
$this->wo_hour_cat_id,
+ 'start_date' =>
$this->start_date,
+ 'end_date' =>
$this->end_date
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function excel()
+ {
+ $start_date = urldecode($this->start_date);
+ $end_date = urldecode($this->end_date);
+ $list =
$this->bo->read($start_date,$end_date,$allrows=True);
+ $uicols = $this->bo->uicols;
+
$this->bocommon->excel($list,$uicols['name'],$uicols['descr'],$uicols['input_type']);
+ }
+
+
+ function index()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('workorder','values','table_header',
+
'menu',
+
'nextmatchs'));
+
+ $links = $this->menu->links('workorder');
+
+ $start_date = urldecode($this->start_date);
+ $end_date = urldecode($this->end_date);
+ $workorder_list =
$this->bo->read($start_date,$end_date);
+
+ $uicols = $this->bo->uicols;
+ $count_uicols_name=count($uicols['name']);
+
+ $j=0;
+ if (isSet($workorder_list) AND
is_array($workorder_list))
+ {
+ foreach($workorder_list as $workorder_entry)
+ {
+ for ($k=0;$k<$count_uicols_name;$k++)
+ {
+
if($uicols['input_type'][$k]!='hidden')
+ {
+
if($workorder_entry['query_location'][$uicols['name'][$k]])
+ {
+
$content[$j]['row'][$k]['statustext'] = lang('search');
+
$content[$j]['row'][$k]['text'] =
$workorder_entry[$uicols['name'][$k]];
+
$content[$j]['row'][$k]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.index&query='
. $workorder_entry['query_location'][$uicols['name'][$k]] . '&lookup=' .
$lookup . '&filter=' . $this->filter);
+ }
+ else
+ {
+
$content[$j]['row'][$k]['value'] =
$workorder_entry[$uicols['name'][$k]];
+
$content[$j]['row'][$k]['name'] = $uicols['name'][$k];
+
if($uicols['name'][$k]=='vendor_id')
+ {
+
$content[$j]['row'][$k]['statustext'] = $workorder_entry['org_name'];
+
$content[$j]['row'][$k]['overlib'] = True;
+
$content[$j]['row'][$k]['text'] =
$workorder_entry[$uicols['name'][$k]];
+ }
+ }
+ }
+ if($lookup &&
$k==($count_uicols_name - 2))
+
$content[$j]['row'][$k]['lookup_action'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit&workorder_id='
. $workorder_entry['workorder_id']);
+ }
+ if(!$lookup)
+ {
+ if ($this->acl_read &&
$this->bocommon->check_perms($workorder_entry['grants'],PHPGW_ACL_READ))
+ if($this->acl_read)
+ {
+
$content[$j]['row'][$k]['statustext'] = lang('view the
workorder');
+
$content[$j]['row'][$k]['text'] = lang('view');
+
$content[$j]['row'][$k]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.view&id='
. $workorder_entry['workorder_id']);
+ $k++;
+ }
+ else
+ {
+
$content[$j]['row'][$k++]['link']='dummy';
+ }
+
+ if ($this->acl_edit &&
$this->bocommon->check_perms($workorder_entry['grants'],PHPGW_ACL_EDIT))
+ {
+
$content[$j]['row'][$k]['statustext'] = lang('edit the
workorder');
+
$content[$j]['row'][$k]['text'] = lang('edit');
+
$content[$j]['row'][$k]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit&id='
. $workorder_entry['workorder_id']);
+ $k++;
+
+
$content[$j]['row'][$k]['statustext'] = lang('calculate the
workorder');
+
$content[$j]['row'][$k]['text'] =
lang('calculate');
+
$content[$j]['row'][$k]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index&workorder_id='
. $workorder_entry['workorder_id']);
+ $k++;
+ }
+ else
+ {
+
$content[$j]['row'][$k++]['link']='dummy';
+
$content[$j]['row'][$k++]['link']='dummy';
+ }
+
+ if ($this->acl_delete &&
$this->bocommon->check_perms($workorder_entry['grants'],PHPGW_ACL_DELETE))
+ {
+
$content[$j]['row'][$k]['statustext'] = lang('delete the
workorder');
+
$content[$j]['row'][$k]['text'] =
lang('delete');
+
$content[$j]['row'][$k]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.delete&id='
. $workorder_entry['workorder_id']);
+ $k++;
+ }
+ else
+ {
+
$content[$j]['row'][$k++]['link']='dummy';
+ }
+ }
+ $j++;
+ }
+ }
+
+ $count_uicols_descr=count($uicols['descr']);
+ for ($i=0;$i<$count_uicols_descr;$i++)
+ {
+ if($uicols['input_type'][$i]!='hidden')
+ {
+ $table_header[$i]['header'] =
$uicols['descr'][$i];
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ if($uicols['name'][$i]=='loc1')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'fm_location1.loc1',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiworkorder.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'lookup'
=>$lookup,
+
'district_id' =>
$this->district_id,
+
'search_vendor'
=>$this->search_vendor,
+
'cat_id'
=>$this->cat_id,
+
'start_date'=>$start_date,
+
'end_date'=>$end_date,
+
'wo_hour_cat_id'
=>$this->wo_hour_cat_id
+
)
+
));
+ }
+ if($uicols['name'][$i]=='project_id')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'project_id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiworkorder.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'lookup'
=>$lookup,
+
'district_id' =>
$this->district_id,
+
'search_vendor'
=>$this->search_vendor,
+
'cat_id'
=>$this->cat_id,
+
'start_date'=>$start_date,
+
'end_date'=>$end_date,
+
'wo_hour_cat_id'
=>$this->wo_hour_cat_id
+
)
+
));
+ }
if($uicols['name'][$i]=='workorder_id')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'workorder_id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiworkorder.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'lookup'
=>$lookup,
+
'district_id' =>
$this->district_id,
+
'search_vendor'
=>$this->search_vendor,
+
'cat_id'
=>$this->cat_id,
+
'start_date'=>$start_date,
+
'end_date'=>$end_date,
+
'wo_hour_cat_id'
=>$this->wo_hour_cat_id
+
)
+
));
+ }
+ if($uicols['name'][$i]=='address')
+ {
+ $table_header[$i]['sort_link']
=true;
+ $table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'address',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiworkorder.index',
+
'type_id'
=>$type_id,
+
'query'
=>$this->query,
+
'lookup'
=>$lookup,
+
'district_id' =>
$this->district_id,
+
'search_vendor'
=>$this->search_vendor,
+
'cat_id'
=>$this->cat_id,
+
'start_date'=>$start_date,
+
'end_date'=>$end_date,
+
'wo_hour_cat_id'
=>$this->wo_hour_cat_id
+
)
+
));
+ }
+
+ }
+ }
+
+ if(!$lookup)
+ {
+ if($this->acl_read)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('view');
+ $i++;
+ }
+ if($this->acl_edit)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('edit');
+ $i++;
+
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('calculate');
+ $i++;
+ }
+ if($this->acl_delete)
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header']
= lang('delete');
+ $i++;
+ }
+ }
+ else
+ {
+ $table_header[$i]['width']
= '5%';
+ $table_header[$i]['align']
= 'center';
+ $table_header[$i]['header'] =
lang('select');
+ }
+
+//_debug_array($content);
+ if($this->acl_add)
+ {
+ $table_add[] = array
+ (
+ 'lang_add'
=> lang('add'),
+ 'lang_add_statustext' => lang('add a
workorder'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.add')
+ );
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiworkorder.index',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'district_id'
=>$this->district_id,
+ 'status_id'
=>$this->status_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query,
+ 'search_vendor'
=>$this->search_vendor,
+ 'start_date'
=>$start_date,
+ 'end_date'
=>$end_date,
+ 'wo_hour_cat_id'
=>$this->wo_hour_cat_id
+ );
+
+ $link_date_search
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.date_search');
+
+ $link_excel = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiworkorder.excel',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'cat_id'
=>$this->cat_id,
+ 'district_id'
=>$this->district_id,
+ 'status_id'
=>$this->status_id,
+ 'filter'
=>$this->filter,
+ 'query'
=>$this->query,
+ 'search_vendor'
=>$this->search_vendor,
+ 'start_date'
=>$start_date,
+ 'end_date'
=>$end_date,
+ 'start'
=>$this->start,
+ 'wo_hour_cat_id'
=>$this->wo_hour_cat_id,
+ );
+
+
+
if($GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['group_filters'])
+ {
+ $group_filters = 'select';
+
$GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour_cat_select'));
+ }
+ else
+ {
+ $group_filters = 'filter';
+
$GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour_cat_filter'));
+ }
+
+ $data = array
+ (
+ 'group_filters' =>
$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['group_filters'],
+ 'lang_excel' =>
'excel',
+ 'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
+ 'lang_excel_help' =>
lang('Download table to MS Excel'),
+
+ 'start_date'
=>$start_date,
+ 'end_date'
=>$end_date,
+ 'lang_none'
=>lang('None'),
+ 'lang_date_search' =>
lang('Date search'),
+ 'lang_date_search_help' => lang('Narrow
the search by dates'),
+ 'link_date_search' =>
$link_date_search,
+ 'overlib_source' =>
'./'.$this->currentapp.'/inc/overlib.js',
+
+ 'link_history'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.index'),
+ 'lang_history_statustext' =>
lang('search for history at this location'),
+ 'links'
=> $links,
+ 'allow_allrows'
=> false,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records'
=> count($workorder_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_no_cat'
=> lang('no category'),
+ 'lang_cat_statustext' =>
lang('Select the category the workorder belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'cat_id',
+ 'cat_list'
=>
$this->bo->select_category_workorder_list($group_filters,$this->cat_id),
+ 'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+
+ 'lang_status_statustext' =>
lang('Select the status the agreement belongs to. To do not use a category
select NO STATUS'),
+ 'status_name'
=> 'status_id',
+ 'lang_no_status'
=> lang('No status'),
+ 'status_list'
=> $this->bo->select_status_list($group_filters,$this->status_id),
+
+ 'lang_wo_hour_cat_statustext' =>
lang('Select the workorder hour category'),
+ 'lang_no_wo_hour_cat' =>
lang('no hour category'),
+ 'wo_hour_cat_list'
=> $this->bocommon->select_wo_hours_category_list($this->wo_hour_cat_id),
+
+ 'lang_user_statustext' =>
lang('Select the user the workorder belongs to. To do not use a category select
NO USER'),
+ 'select_user_name'
=> 'filter',
+ 'lang_no_user'
=> lang('No user'),
+ 'user_list'
=>
$this->bocommon->get_user_list_right2($group_filters,4,$this->filter,$this->acl2_location,array('all'),$default=$this->account),
+
+ 'lang_searchvendor_statustext' => lang('Enter
the vendor name to search for'),
+ 'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_statustext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'search_vendor'
=> $this->search_vendor,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('Workorder');
+ $function_msg =
lang('list workorder');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_workorder' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit()
+ {
+ if(!$this->acl_add && !$this->acl_edit)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
+ }
+ $boproject =
CreateObject($this->currentapp.'.boproject');
+ $bolocation =
CreateObject($this->currentapp.'.bolocation');
+ $config =
CreateObject('phpgwapi.config');
+ $id =
get_var('id',array('POST','GET'));
+ $project_id =
get_var('project_id',array('POST','GET'));
+ $values =
get_var('values',array('POST'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('workorder'));
+
+ $values['vendor_id'] =
get_var('vendor_id',array('POST'));
+ $values['vendor_name'] =
get_var('vendor_name',array('POST'));
+ $values['b_account_id'] =
get_var('b_account_id',array('POST'));
+ $values['b_account_name'] =
get_var('b_account_name',array('POST'));
+
+
+ $values['start_date'] =
get_var('start_date',array('POST'));
+ $values['end_date'] =
get_var('end_date',array('POST'));
+
+ $config->read_repository();
+
+ if ($values['save'])
+ {
+ if(!$values['title'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter a workorder title !'));
+ $error_id=true;
+ }
+ if(!$values['project_id'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a valid project !'));
+ $error_id=true;
+ }
+
+ if(!$values['status'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a status !'));
+ }
+ if(!$values['b_account_id'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a budget account !'));
+ }
+
+ if($id)
+ {
+ $values['workorder_id']=$id;
+ $action='edit';
+ }
+
+ if(!$receipt['error'])
+ {
+ if(!$id)
+ {
+
$values['workorder_id']=$this->bo->next_id();
+ $id =
$values['workorder_id'];
+ }
+ if($values['copy_workorder'])
+ {
+ $action='add';
+ $values['workorder_id'] =
$this->bo->next_id();
+ $id =
$values['workorder_id'];
+ }
+ $receipt =
$this->bo->save($values,$action);
+ $id = $values['workorder_id'];
+ $function_msg = lang('Edit Workorder');
+
+ if ($values['approval'] &&
$values['mail_address'])
+ {
+
$coordinator_name=$GLOBALS['phpgw_info']['user']['fullname'];
+
$coordinator_email=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['email'];
+ $headers = "Return-Path: <".
$coordinator_email .">\r\n";
+ $headers .= "From: " .
$coordinator_name . "<" . $coordinator_email .">\r\n";
+ $headers .= "Bcc: " .
$coordinator_name . "<" . $coordinator_email .">\r\n";
+ $headers .= "Content-type:
text/plain; charset=iso-8859-1\r\n";
+
+ $subject = lang(Approval).": ".
$values['workorder_id'];
+ $message = lang('Workorder %1
needs approval',$values['workorder_id']);
+
+ $mail_method=
$config->config_data['fmwrkorder_mail'];
+ if ($mail_method=='smtp'):
+ {
+ $bcc =
$coordinator_email;
+ $send =
CreateObject('phpgwapi.send');
+ $rcpt =
$send->msg('email', $values['mail_address'], $subject, stripslashes($message),
'', $cc, $bcc, $coordinator_email, $coordinator_name, 'plain');
+ }
+ elseif
($mail_method=='sendmail'):
+ {
+
$rcpt=mail($values['mail_address'],$subject,$message, $headers);
+ }
+ else:
+ {
+
$receipt['error'][]=array('msg'=>lang('Mailing method is not chosen! (admin
section)'));
+ }
+ endif;
+ }
+
+ if($rcpt)
+ {
+
$receipt['message'][]=array('msg'=>lang('%1 is
notified',$values['mail_address']));
+ }
+ }
+ }
+
+ if(!$receipt['error'])
+ {
+ if($id)
+ {
+ $values =
$this->bo->read_single($id);
+ }
+ if($project_id && !$values['project_id'])
+ {
+ $values['project_id']=$project_id;
+ }
+ $project =
$boproject->read_single_mini($values['project_id']);
+
+ if
(!$this->bocommon->check_perms($project['grants'],PHPGW_ACL_EDIT))
+ {
+
$receipt['error'][]=array('msg'=>lang('You have no edit right for this
project'));
+
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp,$receipt);
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.view&id='
. $id);
+ }
+
+ if( $project['key_fetch'] &&
!$values['key_fetch'])
+ {
+
$values['key_fetch']=$project['key_fetch'];
+ }
+
+ if( $project['key_deliver'] &&
!$values['key_deliver'])
+ {
+
$values['key_deliver']=$project['key_deliver'];
+ }
+
+/* if( $project['charge_tenant'] &&
!$values['workorder_id'])
+ {
+
$values['charge_tenant']=$project['charge_tenant'];
+ }
+*/
+ if( $project['start_date'] &&
!$values['start_date'])
+ {
+
$values['start_date']=$project['start_date'];
+ }
+ if( $project['end_date'] &&
!$values['end_date'])
+ {
+
$values['end_date']=$project['end_date'];
+ }
+ if( $project['name'] && !$values['title'])
+ {
+ $values['title']=$project['name'];
+ }
+ if( $project['descr'] && !$values['descr'])
+ {
+ $values['descr']=$project['descr'];
+ }
+ if( $project['status'] && !$values['status'])
+ {
+ $values['status']=$project['status'];
+ }
+ }
+
+ if($id)
+ {
+ $record_history =
$this->bo->read_record_history($id);
+ }
+
+//_debug_array($hour_data);
+ $table_header_history[] = array
+ (
+ 'lang_date' => lang('Date'),
+ 'lang_user' => lang('User'),
+ 'lang_action' => lang('Action'),
+ 'lang_new_value' => lang('New value')
+ );
+
+ $table_header_workorder_budget[] = array
+ (
+ 'lang_workorder_id' => lang('Workorder'),
+ 'lang_sum' => lang('Sum')
+ );
+
+ if ($id)
+ {
+ $function_msg = lang('Edit Workorder');
+ }
+ else
+ {
+ $function_msg = lang('Add Workorder');
+ }
+
+ if ($values['cat_id'])
+ {
+ $this->cat_id = $values['cat_id'];
+ }
+
+
+ $location_data=$bolocation->initiate_ui_location(array(
+ 'values' =>
$project['location_data'],
+ 'type_id' =>
count(explode('-',$project['location_data']['location_code'])),
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' =>
$project['location_data']['tenant_id'],
+ 'lookup_type' => 'view'
+ ));
+
+
+ if($project['contact_phone'])
+ {
+ for
($i=0;$i<count($location_data['location']);$i++)
+ {
+
if($location_data['location'][$i]['input_name'] == 'contact_phone')
+ {
+
unset($location_data['location'][$i]['value']);
+ }
+ }
+ }
+
+
+
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
+ 'vendor_id' =>
$values['vendor_id'],
+ 'vendor_name' =>
$values['vendor_name']));
+
+
$b_account_data=$this->bocommon->initiate_ui_budget_account_lookup(array(
+ 'b_account_id' =>
$values['b_account_id'],
+ 'b_account_name' =>
$values['b_account_name']));
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiworkorder.edit',
+ 'id' => $id
+ );
+
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $sep = '/';
+ $dlarr[strpos($dateformat,'y')] = 'yyyy';
+ $dlarr[strpos($dateformat,'m')] = 'MM';
+ $dlarr[strpos($dateformat,'d')] = 'DD';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+
+
$supervisor_id=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['approval_from'];
+
+ $need_approval =
$config->config_data['workorder_approval'];
+
+ if ($supervisor_id && ($need_approval=='yes'))
+ {
+ $prefs =
$this->bocommon->create_preferences($this->currentapp,$supervisor_id);
+ $supervisor_email = $prefs['email'];
+ }
+
+
$project_status=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['project_status'];
+ if(!$values['status'])
+ {
+ $values['status']=$project_status;
+ }
+
+ $cal_info = $this->bocommon->jscalendar();
+ $jsDateFormat=$cal_info['jsDateFormat'];
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'calculate_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index'),
+ 'lang_calculate'
=> lang('Calculate Workorder'),
+ 'lang_calculate_statustext' =>
lang('Calculate workorder by adding items from vendors prizebook or adding
general hours'),
+
+ 'send_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.view&from=index'),
+ 'lang_send'
=> lang('Send Workorder'),
+ 'lang_send_statustext' =>
lang('send this workorder to vendor'),
+
+ 'project_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit'),
+ 'b_account_data'
=> $b_account_data,
+ 'table_header_workorder_budget' =>
$table_header_workorder_budget,
+ 'lang_no_workorders' =>
lang('No workorder bugdet'),
+ 'workorder_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.w_edit'),
+ 'record_history'
=> $record_history,
+ 'table_header_history' =>
$table_header_history,
+ 'lang_history'
=> lang('History'),
+ 'lang_no_history'
=> lang('No history'),
+
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'date_img'
=> $cal_info['img'],
+ 'lang_datetitle'
=> lang('Select date'),
+ 'calendar_setup_start' =>
"Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});",
+ 'calendar_setup_end' =>
"Calendar.setup({inputField : 'end_date',ifFormat : '" . $jsDateFormat .
"',button : 'end_date-trigger'});",
+
+ 'lang_start_date_statustext' => lang('Select
the estimated end date for the Project'),
+ 'lang_start_date'
=> lang('Workorder start date'),
+ 'value_start_date'
=> $values['start_date'],
+
+ 'lang_end_date_statustext' =>
lang('Select the estimated end date for the Project'),
+ 'lang_end_date'
=> lang('Workorder end date'),
+ 'value_end_date'
=> $values['end_date'],
+
+ 'lang_copy_workorder' =>
lang('Copy workorder ?'),
+ 'lang_copy_workorder_statustext' =>
lang('Choose Copy Workorder to copy this workorder to a new workorder'),
+
+ 'lang_contact_phone' =>
lang('Contact phone'),
+ 'contact_phone'
=> $project['contact_phone'],
+
+ 'lang_charge_tenant' =>
lang('Charge tenant'),
+ 'lang_charge_tenant_statustext' => lang('Choose
charge tenant if the tenant i to pay for this project'),
+ 'charge_tenant'
=> $values['charge_tenant'],
+
+ 'lang_power_meter'
=> lang('Power meter'),
+ 'lang_power_meter_statustext' => lang('Enter
the power_meter'),
+ 'value_power_meter'
=> $project['power_meter'],
+
+ 'lang_addition_rs'
=> lang('Rig addition'),
+ 'lang_addition_rs_statustext' => lang('Enter
any round sum addition per order'),
+ 'value_addition_rs'
=> $values['addition_rs'],
+
+ 'lang_addition_percentage'
=> lang('Percentage addition'),
+ 'lang_addition_percentage_statustext' =>
lang('Enter any persentage addition per unit'),
+ 'value_addition_percentage'
=> $values['addition_percentage'],
+
+ 'lang_budget'
=> lang('Budget'),
+ 'value_budget'
=> $values['budget'],
+ 'lang_budget_statustext' =>
lang('Enter the budget'),
+
+ 'lang_incl_tax'
=> lang('incl tax'),
+ 'lang_calculation'
=> lang('Calculation'),
+ 'value_calculation'
=> $values['calculation'],
+
+ 'actual_cost'
=> $values['actual_cost'],
+ 'lang_actual_cost'
=> lang('Actual cost'),
+
+ 'vendor_data'
=> $vendor_data,
+ 'location_data'
=> $location_data,
+ 'location_type'
=> 'view',
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.index'),
+ 'lang_year'
=> lang('Year'),
+ 'lang_category'
=> lang('category'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'lang_title'
=> lang('Title'),
+ 'value_title'
=> $values['title'],
+ 'lang_project_name'
=> lang('Project name'),
+ 'value_project_name' =>
$project['name'],
+
+ 'lang_project_id'
=> lang('Project ID'),
+ 'value_project_id'
=> $values['project_id'],
+
+ 'lang_workorder_id'
=> lang('Workorder ID'),
+ 'value_workorder_id' =>
$values['workorder_id'],
+
+ 'lang_title_statustext' =>
lang('Enter Workorder title'),
+
+ 'lang_other_branch'
=> lang('Other branch'),
+ 'lang_other_branch_statustext' =>
lang('Enter other branch if not found in the list'),
+ 'value_other_branch'
=> $project['other_branch'],
+
+ 'lang_descr_statustext' =>
lang('Enter a short description of the workorder'),
+ 'lang_descr'
=> lang('Description'),
+ 'value_descr'
=> $values['descr'],
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'lang_save_statustext' =>
lang('Save the workorder'),
+ 'lang_no_cat'
=> lang('Select category'),
+ 'lang_cat_statustext' =>
lang('Select the category the project belongs to. To do not use a category
select NO CATEGORY'),
+ 'select_name'
=> 'values[cat_id]',
+ 'value_cat_id'
=> $values['cat_id'],
+ 'cat_list'
=>
$this->bo->select_category_workorder_list('select',$project['cat_id']),
+
+ 'sum_workorder_budget' =>
$values['sum_workorder_budget'],
+ 'workorder_budget'
=> $values['workorder_budget'],
+
+ 'lang_coordinator'
=> lang('Coordinator'),
+ 'lang_sum'
=> lang('Sum'),
+ 'select_user_name'
=> 'values[coordinator]',
+ 'user_list'
=>
$this->bocommon->get_user_list('select',$project['coordinator'],$extra=False,$default=False,$start=-1,$sort=False,$order=False,$query='',$offset=-1),
+
+ 'status_list'
=> $this->bo->select_status_list('select',$values['status']),
+ 'status_name'
=> 'values[status]',
+ 'lang_no_status'
=> lang('Select status'),
+ 'lang_status'
=> lang('Status'),
+ 'lang_status_statustext' =>
lang('What is the current status of this workorder ?'),
+
+ 'branch_list'
=> $boproject->select_branch_p_list($project['project_id']),
+ 'lang_branch'
=> lang('branch'),
+ 'lang_branch_statustext' =>
lang('Select the branches for this project'),
+
+ 'key_responsible_list'
=> $boproject->select_branch_list($project['key_responsible']),
+ 'lang_key_responsible'
=> lang('key responsible'),
+
+ 'key_fetch_list'
=> $this->bo->select_key_location_list($values['key_fetch']),
+ 'lang_no_key_fetch'
=> lang('Where to fetch the key'),
+ 'lang_key_fetch'
=> lang('key fetch location'),
+ 'lang_key_fetch_statustext'
=> lang('Select where to fetch the key'),
+
+ 'key_deliver_list'
=> $this->bo->select_key_location_list($values['key_deliver']),
+ 'lang_no_key_deliver'
=> lang('Where to deliver the key'),
+ 'lang_key_deliver'
=> lang('key deliver location'),
+ 'lang_key_deliver_statustext' =>
lang('Select where to deliver the key'),
+
+ 'need_approval'
=> $need_approval,
+ 'lang_ask_approval'
=> lang('Ask for approval'),
+ 'lang_ask_approval_statustext' =>
lang('Check this to send a mail to your supervisor for approval'),
+ 'value_approval_mail_address' =>
$supervisor_email,
+ 'currency'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['currency']
+ );
+
+ $appname
= lang('Workorder');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function add()
+ {
+ if(!$this->acl_edit)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiworkorder.index'
+ );
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('workorder',
+
'menu',
+
'search_field'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit'),
+ 'search_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.index&lookup=true&from=workorder'),
+
+ 'lang_done_statustext' =>
lang('Back to the workorder list'),
+ 'lang_add_statustext' =>
lang('Adds a new project - then a new workorder'),
+ 'lang_search_statustext' =>
lang('Adds a new workorder to an existing project'),
+
+ 'lang_done' =>
lang('Done'),
+ 'lang_add' =>
lang('Add'),
+ 'lang_search' =>
lang('Search')
+ );
+
+ $appname
= lang('Workorder');
+ $function_msg =
lang('Add workorder');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+ $GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('add'
=> $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function delete()
+ {
+ if(!$this->acl_delete)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
+ }
+ $id = get_var('id',array('POST','GET'));
+ $confirm = get_var('confirm',array('POST'));
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiworkorder.index'
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+ $this->bo->delete($id);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.delete&id='
. $id),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_statustext' => lang('Delete the
entry'),
+ 'lang_no_statustext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('workorder');
+ $function_msg =
lang('delete workorder');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function view()
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
+ }
+
+ $boproject =
CreateObject($this->currentapp.'.boproject');
+ $bolocation =
CreateObject($this->currentapp.'.bolocation');
+
+ $receipt =
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp);
+
$GLOBALS['phpgw']->session->appsession('receipt',$this->currentapp,'');
+
+ $id = get_var('id',array('POST','GET'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('workorder','hour_data_view'));
+
+ $uiwo_hour =
CreateObject($this->currentapp.'.uiwo_hour');
+ $hour_data =
$uiwo_hour->common_data($id,$view=True);
+ $values = $this->bo->read_single($id);
+ $project =
$boproject->read_single($values['project_id']);
+ $record_history = $this->bo->read_record_history($id);
+
+ $table_header_history[] = array
+ (
+ 'lang_date' => lang('Date'),
+ 'lang_user' => lang('User'),
+ 'lang_action' => lang('Action'),
+ 'lang_new_value' => lang('New value')
+ );
+
+ $table_header_workorder_budget[] = array
+ (
+ 'lang_workorder_id' => lang('Workorder'),
+ 'lang_sum' => lang('Sum')
+ );
+
+ $function_msg = lang('View Workorder');
+
+ $location_data=$bolocation->initiate_ui_location(array(
+ 'values' =>
$project['location_data'],
+ 'type_id' =>
count(explode('-',$project['location_data']['location_code'])),
+ 'no_link' =>
False, // disable lookup links for location type less than type_id
+ 'tenant' =>
$project['location_data']['tenant_id'],
+ 'lookup_type' => 'view'
+ ));
+
+
+ if($project['contact_phone'])
+ {
+ for
($i=0;$i<count($location_data['location']);$i++)
+ {
+
if($location_data['location'][$i]['input_name'] == 'contact_phone')
+ {
+
unset($location_data['location'][$i]['value']);
+ }
+ }
+ }
+
+
+ $data = array
+ (
+ 'project_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.view'),
+ 'table_header_workorder_budget' =>
$table_header_workorder_budget,
+ 'lang_no_workorders' =>
lang('No workorder bugdet'),
+ 'workorder_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.view'),
+ 'record_history'
=> $record_history,
+ 'table_header_history' =>
$table_header_history,
+ 'lang_history'
=> lang('History'),
+ 'lang_no_history'
=> lang('No history'),
+
+ 'lang_project_name'
=> lang('Project name'),
+ 'value_project_name' =>
$project['name'],
+
+ 'lang_vendor'
=> lang('Vendor'),
+ 'value_vendor_id'
=> $values['vendor_id'],
+ 'value_vendor_name'
=> $values['vendor_name'],
+
+ 'lang_b_account'
=> lang('Budget account'),
+ 'value_b_account_id' =>
$values['b_account_id'],
+ 'value_b_account_name' =>
$values['b_account_name'],
+
+ 'lang_start_date'
=> lang('Project start date'),
+ 'value_start_date'
=> $values['start_date'],
+
+ 'lang_end_date'
=> lang('Project end date'),
+ 'value_end_date'
=> $values['end_date'],
+
+ 'lang_charge_tenant' =>
lang('Charge tenant'),
+ 'charge_tenant'
=> $values['charge_tenant'],
+
+ 'lang_power_meter'
=> lang('Power meter'),
+ 'value_power_meter'
=> $project['power_meter'],
+
+ 'lang_addition_rs'
=> lang('Rig addition'),
+ 'lang_addition_rs_statustext' => lang('Enter
any round sum addition per order'),
+ 'value_addition_rs'
=> $values['addition_rs'],
+
+ 'lang_addition_percentage'
=> lang('Percentage addition'),
+ 'lang_addition_percentage_statustext' =>
lang('Enter any persentage addition per unit'),
+ 'value_addition_percentage'
=> $values['addition_percentage'],
+
+ 'lang_budget'
=> lang('Budget'),
+ 'value_budget'
=> $values['budget'],
+
+ 'actual_cost'
=> $values['actual_cost'],
+ 'lang_actual_cost'
=> lang('Actual cost'),
+
+ 'location_data'
=> $location_data,
+ 'location_type'
=> 'view',
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.index'),
+ 'lang_year'
=> lang('Year'),
+ 'lang_category'
=> lang('category'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'lang_name'
=> lang('Name'),
+
+ 'lang_title'
=> lang('Title'),
+ 'value_title'
=> $values['title'],
+
+ 'lang_project_id'
=> lang('Project ID'),
+ 'value_project_id'
=> $values['project_id'],
+ 'value_name'
=> $values['name'],
+
+ 'lang_other_branch'
=> lang('Other branch'),
+ 'value_other_branch'
=> $project['other_branch'],
+
+ 'lang_descr'
=> lang('Description'),
+ 'value_descr'
=> $values['descr'],
+ 'lang_done_statustext' =>
lang('Back to the list'),
+ 'cat_list'
=>
$this->bo->select_category_workorder_list('select',$project['cat_id']),
+
+ 'lang_workorder_id'
=> lang('Workorder ID'),
+ 'value_workorder_id' =>
$values['workorder_id'],
+
+ 'lang_coordinator'
=> lang('Coordinator'),
+ 'lang_sum'
=> lang('Sum'),
+ 'user_list'
=>
$this->bocommon->get_user_list('select',$project['coordinator'],$extra=False,$default=False,$start=-1,$sort=False,$order=False,$query='',$offset=-1),
+
+ 'status_list'
=> $this->bo->select_status_list('select',$values['status']),
+ 'lang_no_status'
=> lang('Select status'),
+ 'lang_status'
=> lang('Status'),
+
+ 'branch_list'
=> $this->bo->select_branch_p_list($values['project_id']),
+ 'lang_branch'
=> lang('branch'),
+
+ 'key_responsible_list' =>
$this->bo->select_branch_list($project['key_responsible']),
+ 'lang_key_responsible' =>
lang('key responsible'),
+
+ 'key_fetch_list'
=> $this->bo->select_key_location_list($values['key_fetch']),
+ 'lang_key_fetch'
=> lang('key fetch location'),
+
+ 'key_deliver_list'
=> $this->bo->select_key_location_list($values['key_deliver']),
+ 'lang_key_deliver'
=> lang('key deliver location'),
+
+ 'edit_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit&id='
. $id),
+ 'lang_edit_statustext' =>
lang('Edit this entry workorder'),
+ 'lang_edit'
=> lang('Edit'),
+ 'currency'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
+ 'lang_total_records' =>
lang('Total records'),
+ 'total_hours_records' =>
$hour_data['total_hours_records'],
+ 'table_header_hour'
=> $hour_data['table_header'],
+ 'values_hour'
=> $hour_data['content'],
+ 'table_sum'
=> $hour_data['table_sum'],
+ 'lang_contact_phone' =>
lang('Contact phone'),
+ 'contact_phone'
=> $project['contact_phone']
+ );
+
+ $appname
= lang('Workorder');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+ }
+?>
Index: property/inc/hook_admin.inc.php
diff -u property/inc/hook_admin.inc.php:1.17
property/inc/hook_admin.inc.php:1.18
--- property/inc/hook_admin.inc.php:1.17 Wed Sep 21 14:18:20 2005
+++ property/inc/hook_admin.inc.php Fri Jan 27 14:05:43 2006
@@ -1,67 +1,67 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id: hook_admin.inc.php,v 1.17 2005/09/21 14:18:20 sigurdne
Exp $
- */
-
- {
- $file = array
- (
- 'Configuration' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname='
. $appname),
- 'Street'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=street'),
- 'District'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=district'),
- 'Part of town'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uip_of_town.index'),
- 'Admin entity'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiadmin_entity.index'),
- 'Admin Location'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiadmin_location.index'),
- 'Update the not active category for
locations'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uilocation.update_cat'),
-// 'Request Categories'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=request'),
- 'Workorder Categories' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=wo'),
- 'Workorder Detail Categories'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=wo_hours'),
- 'Ticket Categories'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=ticket'),
- 'Tenant Claim Categories'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=tenant_claim'),
- 'Tenant Categories'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=tenant'),
- 'Tenant Attributes'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiactor.list_attribute&role=tenant'),
- 'Tenant'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiactor.index&role=tenant'),
- 'Owner'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiactor.index&role=owner'),
- 'Owner Categories'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=owner'),
- 'Owner Attributes'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiactor.list_attribute&role=owner'),
- 'Vendor'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiactor.index&role=vendor'),
- 'Vendor Categories'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=vendor'),
- 'Vendor Global Categories'=>
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicategories.index&appname=fm_vendor&global_cats=True'),
- 'Vendor Attributes'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiactor.list_attribute&role=vendor'),
- 'Document Categories'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=document'),
- 'Building Part'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uistandard_2.index&type=building_part'),
- 'Tender chapter'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=tender_chapter'),
- 'ID Controle'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiadmin.edit_id'),
- 'Permissions'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiadmin.list_acl2'),
- 'User contact info'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiadmin.contact_info'),
- 'Request status'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uistandard_2.index&type=request_status'),
- 'Request condition_type'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=r_condition_type'),
- 'Workorders status'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uistandard_2.index&type=workorder_status'),
- 'Agreement status'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uistandard_2.index&type=agreement_status'),
- 'Agreement Attributes'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiagreement.list_attribute'),
- 'service agreement categories'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=s_agreement'),
- 'service agreement Attributes'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uis_agreement.list_attribute'),
- 'service agreement item Attributes'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uis_agreement.list_attribute&role=detail'),
- 'Document Status'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uistandard_2.index&type=document_status'),
- 'Unit'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uistandard_2.index&type=unit'),
- 'Key location'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uistandard_3.index&type=key_location'),
- 'Branch'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uistandard_3.index&type=branch'),
- 'Accounting'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uib_account.index'),
- 'Accounting extra'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=dim_d'),
- 'Import'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiXport.import'),
- 'Export'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiXport.export'),
- 'Admin Async servises'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uialarm.index'),
- 'Async servises'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiasync.index'),
- );
- display_section($appname,$appname,$file);
-//
$GLOBALS['phpgw']->common->display_mainscreen($appname,$file);
- }
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id: hook_admin.inc.php,v 1.18 2006/01/27 14:05:43 sigurdne
Exp $
+ */
+
+ {
+ $file = array
+ (
+ 'Configuration' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname='
. $appname),
+ 'Street'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=street'),
+ 'District'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=district'),
+ 'Part of town'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uip_of_town.index'),
+ 'Admin entity'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiadmin_entity.index'),
+ 'Admin Location'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiadmin_location.index'),
+ 'Update the not active category for
locations'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uilocation.update_cat'),
+// 'Request Categories'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=request'),
+ 'Workorder Categories' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=wo'),
+ 'Workorder Detail Categories'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=wo_hours'),
+ 'Ticket Categories'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=ticket'),
+ 'Tenant Claim Categories'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=tenant_claim'),
+ 'Tenant Categories'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=tenant'),
+ 'Tenant Attributes'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiactor.list_attribute&role=tenant'),
+ 'Tenant'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiactor.index&role=tenant'),
+ 'Owner'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiactor.index&role=owner'),
+ 'Owner Categories'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=owner'),
+ 'Owner Attributes'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiactor.list_attribute&role=owner'),
+ 'Vendor'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiactor.index&role=vendor'),
+ 'Vendor Categories'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=vendor'),
+ 'Vendor Global Categories'=>
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicategories.index&appname=fm_vendor&global_cats=True'),
+ 'Vendor Attributes'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiactor.list_attribute&role=vendor'),
+ 'Document Categories'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=document'),
+ 'Building Part'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uistandard_2.index&type=building_part'),
+ 'Tender chapter'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=tender_chapter'),
+ 'ID Controle'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiadmin.edit_id'),
+ 'Permissions'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiadmin.list_acl2'),
+ 'User contact info'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiadmin.contact_info'),
+ 'Request status'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uistandard_2.index&type=request_status'),
+ 'Request condition_type'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=r_condition_type'),
+ 'Workorders status'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uistandard_2.index&type=workorder_status'),
+ 'Agreement status'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uistandard_2.index&type=agreement_status'),
+ 'Agreement Attributes'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiagreement.list_attribute'),
+ 'service agreement categories'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=s_agreement'),
+ 'service agreement Attributes'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uis_agreement.list_attribute'),
+ 'service agreement item Attributes'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uis_agreement.list_attribute&role=detail'),
+ 'Document Status'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uistandard_2.index&type=document_status'),
+ 'Unit'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uistandard_2.index&type=unit'),
+ 'Key location'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uistandard_3.index&type=key_location'),
+ 'Branch'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uistandard_3.index&type=branch'),
+ 'Accounting'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uib_account.index'),
+ 'Accounting extra'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uicategory.index&type=dim_d'),
+ 'Import'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiXport.import'),
+ 'Export'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiXport.export'),
+ 'Admin Async servises'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uialarm.index'),
+ 'Async servises'=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiasync.index'),
+ );
+ display_section($appname,$appname,$file);
+//
$GLOBALS['phpgw']->common->display_mainscreen($appname,$file);
+ }
?>
\ No newline at end of file
Index: property/inc/hook_help.inc.php
diff -u property/inc/hook_help.inc.php:1.5 property/inc/hook_help.inc.php:1.6
--- property/inc/hook_help.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/hook_help.inc.php Fri Jan 27 14:05:43 2006
@@ -1,47 +1,47 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage manual
- * @version $Id: hook_help.inc.php,v 1.5 2005/05/12 21:26:28 sigurdne
Exp $
- */
-
-
- /**
- * Description
- */
-
- include(PHPGW_SERVER_ROOT.'/'.'property'.'/setup/setup.inc.php');
-
- $GLOBALS['phpgw']->help->set_params(array('app_name' =>
'property',
-
'title' => lang('property'),
-
'app_version' => $setup_info['property']['version']));
- $GLOBALS['phpgw']->help->data[] = array
- (
- 'text' => lang('overview'),
- 'link' =>
$GLOBALS['phpgw']->help->check_help_file('overview.php'),
- 'lang_link_statustext' => lang('overview')
- );
-
-
- $GLOBALS['phpgw']->help->data[] = array
- (
- 'text' => lang('property'),
- 'link' =>
$GLOBALS['phpgw']->help->check_help_file('property.php'),
- 'lang_link_statustext' => lang('property')
- );
-
- $GLOBALS['phpgw']->help->data[] = array
- (
- 'text' => lang('project'),
- 'link' =>
$GLOBALS['phpgw']->help->check_help_file('project.php'),
- 'lang_link_statustext' => lang('project')
- );
-
- $GLOBALS['phpgw']->help->draw();
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage manual
+ * @version $Id: hook_help.inc.php,v 1.6 2006/01/27 14:05:43 sigurdne
Exp $
+ */
+
+
+ /**
+ * Description
+ */
+
+ include(PHPGW_SERVER_ROOT.'/'.'property'.'/setup/setup.inc.php');
+
+ $GLOBALS['phpgw']->help->set_params(array('app_name' =>
'property',
+
'title' => lang('property'),
+
'app_version' => $setup_info['property']['version']));
+ $GLOBALS['phpgw']->help->data[] = array
+ (
+ 'text' => lang('overview'),
+ 'link' =>
$GLOBALS['phpgw']->help->check_help_file('overview.php'),
+ 'lang_link_statustext' => lang('overview')
+ );
+
+
+ $GLOBALS['phpgw']->help->data[] = array
+ (
+ 'text' => lang('property'),
+ 'link' =>
$GLOBALS['phpgw']->help->check_help_file('property.php'),
+ 'lang_link_statustext' => lang('property')
+ );
+
+ $GLOBALS['phpgw']->help->data[] = array
+ (
+ 'text' => lang('project'),
+ 'link' =>
$GLOBALS['phpgw']->help->check_help_file('project.php'),
+ 'lang_link_statustext' => lang('project')
+ );
+
+ $GLOBALS['phpgw']->help->draw();
+?>
Index: property/inc/hook_home.inc.php
diff -u property/inc/hook_home.inc.php:1.5 property/inc/hook_home.inc.php:1.6
--- property/inc/hook_home.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/hook_home.inc.php Fri Jan 27 14:05:43 2006
@@ -1,55 +1,55 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage core
- * @version $Id: hook_home.inc.php,v 1.5 2005/05/12 21:26:28 sigurdne
Exp $
- */
-
- if
($GLOBALS['phpgw_info']['user']['preferences']['property']['mainscreen_show_new_updated'])
- {
- $save_app = $GLOBALS['phpgw_info']['flags']['currentapp'];
- $GLOBALS['phpgw_info']['flags']['currentapp'] = 'property';
-
- $GLOBALS['phpgw']->translation->add_app('property');
-
- $app_id = $GLOBALS['phpgw']->applications->name2id('property');
- $GLOBALS['portal_order'][] = $app_id;
-
- $GLOBALS['phpgw']->portalbox->set_params(array('app_id' =>
$app_id,
-
'title' => lang('property')));
-
- $GLOBALS['HTTP_POST_VARS']['filter'] = $GLOBALS['filter'] =
'open';
- $property = CreateObject('property.uitts');
-
- $GLOBALS['phpgw']->portalbox->draw($property->index());
-
- unset($property);
- $GLOBALS['phpgw_info']['flags']['currentapp'] = $save_app;
- }
-
-
-/*
-
if($GLOBALS['phpgw_info']['user']['preferences']['property']['mainscreen_show_new_updated'])
- {
- $property = CreateObject('property.uitts');
- $property->bo->start = 0;
- $property->bo->limit = 5;
- $property->start = 0;
- $property->limit = 5;
- $extra_data = '<td>'."\n".$property->index(False).'</td>'."\n";
-
- $app_id = $GLOBALS['phpgw']->applications->name2id('property');
- $GLOBALS['portal_order'][] = $app_id;
-
- $GLOBALS['phpgw']->portalbox->set_params(array('app_id' =>
$app_id,
-
'title' => lang('property')));
- $GLOBALS['phpgw']->portalbox->draw($extra_data);
- }
-*/
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage core
+ * @version $Id: hook_home.inc.php,v 1.6 2006/01/27 14:05:43 sigurdne
Exp $
+ */
+
+ if
($GLOBALS['phpgw_info']['user']['preferences']['property']['mainscreen_show_new_updated'])
+ {
+ $save_app = $GLOBALS['phpgw_info']['flags']['currentapp'];
+ $GLOBALS['phpgw_info']['flags']['currentapp'] = 'property';
+
+ $GLOBALS['phpgw']->translation->add_app('property');
+
+ $app_id = $GLOBALS['phpgw']->applications->name2id('property');
+ $GLOBALS['portal_order'][] = $app_id;
+
+ $GLOBALS['phpgw']->portalbox->set_params(array('app_id' =>
$app_id,
+
'title' => lang('property')));
+
+ $GLOBALS['HTTP_POST_VARS']['filter'] = $GLOBALS['filter'] =
'open';
+ $property = CreateObject('property.uitts');
+
+ $GLOBALS['phpgw']->portalbox->draw($property->index());
+
+ unset($property);
+ $GLOBALS['phpgw_info']['flags']['currentapp'] = $save_app;
+ }
+
+
+/*
+
if($GLOBALS['phpgw_info']['user']['preferences']['property']['mainscreen_show_new_updated'])
+ {
+ $property = CreateObject('property.uitts');
+ $property->bo->start = 0;
+ $property->bo->limit = 5;
+ $property->start = 0;
+ $property->limit = 5;
+ $extra_data = '<td>'."\n".$property->index(False).'</td>'."\n";
+
+ $app_id = $GLOBALS['phpgw']->applications->name2id('property');
+ $GLOBALS['portal_order'][] = $app_id;
+
+ $GLOBALS['phpgw']->portalbox->set_params(array('app_id' =>
$app_id,
+
'title' => lang('property')));
+ $GLOBALS['phpgw']->portalbox->draw($extra_data);
+ }
+*/
+?>
Index: property/inc/hook_manual.inc.php
diff -u property/inc/hook_manual.inc.php:1.6
property/inc/hook_manual.inc.php:1.7
--- property/inc/hook_manual.inc.php:1.6 Thu May 12 21:26:28 2005
+++ property/inc/hook_manual.inc.php Fri Jan 27 14:05:43 2006
@@ -1,27 +1,27 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage core
- * @version $Id: hook_manual.inc.php,v 1.6 2005/05/12 21:26:28 sigurdne
Exp $
- */
-
- // Only Modify the $file variable.....
- $file = Array(
- 'Location'
=> 'location.php',
- 'Entities'
=> 'entities.php',
- 'Project management' =>
'project.php',
- 'Deviation / requirement' =>
'requirement.php',
- 'Electronic invoice handling ' => 'invoice.php',
- 'Vendor agreements' =>
'agreements.php',
- 'Document register/Drawing register' => 'document.php',
- 'Helpdesk'
=> 'helpdesk.php'
- );
-//Do not modify below this line
- display_manual_section($appname,$file);
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage core
+ * @version $Id: hook_manual.inc.php,v 1.7 2006/01/27 14:05:43 sigurdne
Exp $
+ */
+
+ // Only Modify the $file variable.....
+ $file = Array(
+ 'Location'
=> 'location.php',
+ 'Entities'
=> 'entities.php',
+ 'Project management' =>
'project.php',
+ 'Deviation / requirement' =>
'requirement.php',
+ 'Electronic invoice handling ' => 'invoice.php',
+ 'Vendor agreements' =>
'agreements.php',
+ 'Document register/Drawing register' => 'document.php',
+ 'Helpdesk'
=> 'helpdesk.php'
+ );
+//Do not modify below this line
+ display_manual_section($appname,$file);
+?>
Index: property/inc/hook_preferences.inc.php
diff -u property/inc/hook_preferences.inc.php:1.5
property/inc/hook_preferences.inc.php:1.6
--- property/inc/hook_preferences.inc.php:1.5 Thu May 12 21:26:28 2005
+++ property/inc/hook_preferences.inc.php Fri Jan 27 14:05:43 2006
@@ -1,22 +1,22 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage core
- * @version $Id: hook_preferences.inc.php,v 1.5 2005/05/12 21:26:28
sigurdne Exp $
- */
-
- $title = $appname;
- $file = Array(
- 'Preferences' =>
$GLOBALS['phpgw']->link('/preferences/preferences.php','appname='.$appname .
'&type=user'),
- 'Grant Access' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiadmin.aclprefs&acl_app='.$appname)
- );
- display_section($appname,$file);
-
-
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage core
+ * @version $Id: hook_preferences.inc.php,v 1.6 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ $title = $appname;
+ $file = Array(
+ 'Preferences' =>
$GLOBALS['phpgw']->link('/preferences/preferences.php','appname='.$appname .
'&type=user'),
+ 'Grant Access' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$appname.'.uiadmin.aclprefs&acl_app='.$appname)
+ );
+ display_section($appname,$file);
+
+
+?>
Index: property/inc/hook_settings.inc.php
diff -u property/inc/hook_settings.inc.php:1.11
property/inc/hook_settings.inc.php:1.12
--- property/inc/hook_settings.inc.php:1.11 Tue Nov 8 15:19:36 2005
+++ property/inc/hook_settings.inc.php Fri Jan 27 14:05:43 2006
@@ -1,170 +1,170 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @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/bbb_/ekstern/
- * @package property
- * @subpackage core
- * @version $Id: hook_settings.inc.php,v 1.11 2005/11/08 15:19:36
sigurdne Exp $
- */
-
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
-
- $yes_and_no = array(
- 'True' => 'Yes',
- '' => 'No'
- );
- create_select_box('show new/updated tickets on main
screen','mainscreen_show_new_updated',$yes_and_no,'Dont think this is working -
yet');
-
- create_select_box('Group filters in single
query','group_filters',$yes_and_no,'Group filters - means that one has to hit
the search button to apply the filter');
-
- $tts_status = array(
- '' => lang('Open'),
- 'closed' => lang('Closed'),
- 'all' => lang('All')
- );
-
- create_select_box('Default ticket status','tts_status',$tts_status,'The
default status when entering the helpdesk');
-
- $acc = CreateObject('phpgwapi.accounts');
- $group_list = $acc->get_list('groups');
- while (list($key,$entry) = each($group_list))
- {
- $_groups[$entry['account_id']] = $entry['account_lid'];
- }
- create_select_box('Default group TTS','groupdefault',$_groups,'The
default group to assign a ticket in Helpdesk-submodule');
-
- $account_list = $acc->get_list('accounts');
- while (list($key,$entry) = each($account_list))
- {
- $_accounts[$entry['account_id']] = $entry['account_lid'];
- }
- create_select_box('Default assign to
TTS','assigntodefault',$_accounts,'The default user to assign a ticket in
Helpdesk-submodule');
-
- // Choose the correct priority to display
- $priority_comment[1] = ' - ' . lang('Lowest');
- $priority_comment[5] = ' - ' . lang('Medium');
- $priority_comment[10] = ' - ' . lang('Highest');
- for ($i=1; $i<=10; $i++)
- {
- $priority[$i] = $i . $priority_comment[$i];
- }
-
-
- // Choose the correct degree to display
- $degree_comment[0]=' - '.lang('None');
- $degree_comment[1]=' - '.lang('Minor');
- $degree_comment[2]=' - '.lang('Medium');
- $degree_comment[3]=' - '.lang('Serious');
- for ($i=0; $i<=3; $i++)
- {
- $degree[$i] = $i . $degree_comment[$i];
- }
- create_select_box('Default Priority
TTS','prioritydefault',$priority,'The default priority for tickets in the
Helpdesk-submodule');
-
-
- $sotts= CreateObject($this->currentapp.'.sotts');
- $category_tts= $sotts->select_category_list();
- if ($category_tts)
- {
- while (list($key,$entry) = each($category_tts))
- {
- $_categories_tts[$entry['id']] = $entry['name'];
- }
- }
-
- unset($sotts);
- create_select_box('Default TTS
categories','tts_category',$_categories_tts,'The default category for TTS');
-
- $yes_and_no = array(
- '1' => 'Yes',
- '2' => 'No'
- );
-
- create_select_box('Send e-mail from
TTS','tts_user_mailnotification',$yes_and_no,'Send e-mail from TTS as default');
- create_input_box('Refresh TTS every (seconds)','refreshinterval','The
intervall for Helpdesk refresh - cheking for new tickets');
-
- create_select_box('Default Degree Request
safety','default_safety',$degree,'The degree of seriousness');
- create_select_box('Default Degree Request
aesthetics','default_aesthetics',$degree);
- create_select_box('Default Degree Request indoor
climate','default_climate',$degree);
- create_select_box('Default Degree Request consequential
damage','default_consequential_damage',$degree);
- create_select_box('Default Degree Request user
gratification','default_gratification',$degree);
- create_select_box('Default Degree Request residential
environment','default_environment',$degree);
-
- create_select_box('Send order receipt as email
','order_email_rcpt',$yes_and_no,'Send the order as BCC to the user');
-
- $default_start_page = array(
- 'location' => lang('Location'),
- 'project' => lang('Project'),
- 'tts' => lang('Ticket'),
- 'invoice' => lang('Invoice'),
- 'document'=> lang(Document)
- );
- create_select_box('Default start
page','default_start_page',$default_start_page,'Select your start-submodule');
-
- $soworkorder= CreateObject($this->currentapp.'.soworkorder');
- $socommon= CreateObject($this->currentapp.'.socommon');
-
- $status_list= $soworkorder->select_status_list();
- $category_list= $soworkorder->select_category_workorder_list();
- $district_list= $socommon->select_district_list();
-
- if ($status_list)
- {
- while (list($key,$entry) = each($status_list))
- {
- $_status[$entry['id']] = $entry['name'];
- }
- }
- if ($category_list)
- {
- while (list($key,$entry) = each($category_list))
- {
- $_categories[$entry['id']] = $entry['name'];
- }
- }
- if ($district_list)
- {
- while (list($key,$entry) = each($district_list))
- {
- $_districts[$entry['id']] = $entry['name'];
- }
- }
-
- unset($soworkorder);
- unset($socommon);
- create_select_box('Default project
status','project_status',$_status,'The default status for your projects and
workorders');
- create_select_box('Default project
categories','project_category',$_categories,'The default category for your
projects and workorders');
- create_select_box('Default
district-filter','default_district',$_districts,'Your default district-filter
');
-
- create_input_box('Your Cellphone','cellphone');
-
- create_select_box('Workorder Approval
From','approval_from',$_accounts,'If you need approval from your supervisor for
projects/workorders');
-
- if(!$email_org)
- {
- create_input_box('Your Email','email','Insert your email
address');
- }
-
-
$email_property=$GLOBALS['phpgw_info']['user']['preferences']['property']['email'];
- $GLOBALS['phpgw']->preferences->add("email","address",$email_property);
- $GLOBALS['phpgw']->preferences->save_repository();
-
- $cats = CreateObject('phpgwapi.categories');
- $cats->app_name = 'fm_vendor';
- $cat_data = $cats->formatted_xslt_list(array('globals' => True,
'link_data' =>array()));
- $cat_list = $cat_data['cat_list'];
-
- if (is_array($cat_list))
- {
- while (list($key,$entry) = each($cat_list))
- {
- $_categories_vendor[$entry['cat_id']] = $entry['name'];
- }
- }
-
- create_select_box('Default vendor
type','default_vendor_category',$_categories_vendor,'which agreement');
-
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @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/bbb_/ekstern/
+ * @package property
+ * @subpackage core
+ * @version $Id: hook_settings.inc.php,v 1.12 2006/01/27 14:05:43
sigurdne Exp $
+ */
+
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+
+ $yes_and_no = array(
+ 'True' => 'Yes',
+ '' => 'No'
+ );
+ create_select_box('show new/updated tickets on main
screen','mainscreen_show_new_updated',$yes_and_no,'Dont think this is working -
yet');
+
+ create_select_box('Group filters in single
query','group_filters',$yes_and_no,'Group filters - means that one has to hit
the search button to apply the filter');
+
+ $tts_status = array(
+ '' => lang('Open'),
+ 'closed' => lang('Closed'),
+ 'all' => lang('All')
+ );
+
+ create_select_box('Default ticket status','tts_status',$tts_status,'The
default status when entering the helpdesk');
+
+ $acc = CreateObject('phpgwapi.accounts');
+ $group_list = $acc->get_list('groups');
+ while (list($key,$entry) = each($group_list))
+ {
+ $_groups[$entry['account_id']] = $entry['account_lid'];
+ }
+ create_select_box('Default group TTS','groupdefault',$_groups,'The
default group to assign a ticket in Helpdesk-submodule');
+
+ $account_list = $acc->get_list('accounts');
+ while (list($key,$entry) = each($account_list))
+ {
+ $_accounts[$entry['account_id']] = $entry['account_lid'];
+ }
+ create_select_box('Default assign to
TTS','assigntodefault',$_accounts,'The default user to assign a ticket in
Helpdesk-submodule');
+
+ // Choose the correct priority to display
+ $priority_comment[1] = ' - ' . lang('Lowest');
+ $priority_comment[5] = ' - ' . lang('Medium');
+ $priority_comment[10] = ' - ' . lang('Highest');
+ for ($i=1; $i<=10; $i++)
+ {
+ $priority[$i] = $i . $priority_comment[$i];
+ }
+
+
+ // Choose the correct degree to display
+ $degree_comment[0]=' - '.lang('None');
+ $degree_comment[1]=' - '.lang('Minor');
+ $degree_comment[2]=' - '.lang('Medium');
+ $degree_comment[3]=' - '.lang('Serious');
+ for ($i=0; $i<=3; $i++)
+ {
+ $degree[$i] = $i . $degree_comment[$i];
+ }
+ create_select_box('Default Priority
TTS','prioritydefault',$priority,'The default priority for tickets in the
Helpdesk-submodule');
+
+
+ $sotts= CreateObject($this->currentapp.'.sotts');
+ $category_tts= $sotts->select_category_list();
+ if ($category_tts)
+ {
+ while (list($key,$entry) = each($category_tts))
+ {
+ $_categories_tts[$entry['id']] = $entry['name'];
+ }
+ }
+
+ unset($sotts);
+ create_select_box('Default TTS
categories','tts_category',$_categories_tts,'The default category for TTS');
+
+ $yes_and_no = array(
+ '1' => 'Yes',
+ '2' => 'No'
+ );
+
+ create_select_box('Send e-mail from
TTS','tts_user_mailnotification',$yes_and_no,'Send e-mail from TTS as default');
+ create_input_box('Refresh TTS every (seconds)','refreshinterval','The
intervall for Helpdesk refresh - cheking for new tickets');
+
+ create_select_box('Default Degree Request
safety','default_safety',$degree,'The degree of seriousness');
+ create_select_box('Default Degree Request
aesthetics','default_aesthetics',$degree);
+ create_select_box('Default Degree Request indoor
climate','default_climate',$degree);
+ create_select_box('Default Degree Request consequential
damage','default_consequential_damage',$degree);
+ create_select_box('Default Degree Request user
gratification','default_gratification',$degree);
+ create_select_box('Default Degree Request residential
environment','default_environment',$degree);
+
+ create_select_box('Send order receipt as email
','order_email_rcpt',$yes_and_no,'Send the order as BCC to the user');
+
+ $default_start_page = array(
+ 'location' => lang('Location'),
+ 'project' => lang('Project'),
+ 'tts' => lang('Ticket'),
+ 'invoice' => lang('Invoice'),
+ 'document'=> lang(Document)
+ );
+ create_select_box('Default start
page','default_start_page',$default_start_page,'Select your start-submodule');
+
+ $soworkorder= CreateObject($this->currentapp.'.soworkorder');
+ $socommon= CreateObject($this->currentapp.'.socommon');
+
+ $status_list= $soworkorder->select_status_list();
+ $category_list= $soworkorder->select_category_workorder_list();
+ $district_list= $socommon->select_district_list();
+
+ if ($status_list)
+ {
+ while (list($key,$entry) = each($status_list))
+ {
+ $_status[$entry['id']] = $entry['name'];
+ }
+ }
+ if ($category_list)
+ {
+ while (list($key,$entry) = each($category_list))
+ {
+ $_categories[$entry['id']] = $entry['name'];
+ }
+ }
+ if ($district_list)
+ {
+ while (list($key,$entry) = each($district_list))
+ {
+ $_districts[$entry['id']] = $entry['name'];
+ }
+ }
+
+ unset($soworkorder);
+ unset($socommon);
+ create_select_box('Default project
status','project_status',$_status,'The default status for your projects and
workorders');
+ create_select_box('Default project
categories','project_category',$_categories,'The default category for your
projects and workorders');
+ create_select_box('Default
district-filter','default_district',$_districts,'Your default district-filter
');
+
+ create_input_box('Your Cellphone','cellphone');
+
+ create_select_box('Workorder Approval
From','approval_from',$_accounts,'If you need approval from your supervisor for
projects/workorders');
+
+ if(!$email_org)
+ {
+ create_input_box('Your Email','email','Insert your email
address');
+ }
+
+
$email_property=$GLOBALS['phpgw_info']['user']['preferences']['property']['email'];
+ $GLOBALS['phpgw']->preferences->add("email","address",$email_property);
+ $GLOBALS['phpgw']->preferences->save_repository();
+
+ $cats = CreateObject('phpgwapi.categories');
+ $cats->app_name = 'fm_vendor';
+ $cat_data = $cats->formatted_xslt_list(array('globals' => True,
'link_data' =>array()));
+ $cat_list = $cat_data['cat_list'];
+
+ if (is_array($cat_list))
+ {
+ while (list($key,$entry) = each($cat_list))
+ {
+ $_categories_vendor[$entry['cat_id']] = $entry['name'];
+ }
+ }
+
+ create_select_box('Default vendor
type','default_vendor_category',$_categories_vendor,'which agreement');
+
Index: property/templates/base/invoice.xsl
diff -u property/templates/base/invoice.xsl:1.5
property/templates/base/invoice.xsl:1.6
--- property/templates/base/invoice.xsl:1.5 Wed Jan 25 18:19:12 2006
+++ property/templates/base/invoice.xsl Fri Jan 27 14:05:59 2006
@@ -1,2542 +1,2542 @@
-<!-- $Id: invoice.xsl,v 1.5 2006/01/25 18:19:12 sigurdne Exp $ -->
-
- <xsl:template name="app_data">
- <xsl:choose>
- <xsl:when test="add">
- <xsl:apply-templates select="add"/>
- </xsl:when>
- <xsl:when test="edit">
- <xsl:apply-templates select="edit"/>
- </xsl:when>
- <xsl:when test="import">
- <xsl:apply-templates select="import"/>
- </xsl:when>
- <xsl:when test="export">
- <xsl:apply-templates select="export"/>
- </xsl:when>
- <xsl:when test="rollback">
- <xsl:apply-templates select="rollback"/>
- </xsl:when>
- <xsl:when test="debug">
- <xsl:apply-templates select="debug"/>
- </xsl:when>
- <xsl:when test="edit_period">
- <xsl:apply-templates select="edit_period"/>
- </xsl:when>
- <xsl:when test="list_voucher">
- <xsl:apply-templates select="list_voucher"/>
- </xsl:when>
- <xsl:when test="list_voucher_paid">
- <xsl:apply-templates
select="list_voucher_paid"/>
- </xsl:when>
- <xsl:when test="consume">
- <xsl:apply-templates select="consume"/>
- </xsl:when>
- <xsl:when test="remark">
- <xsl:apply-templates select="remark"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select="list_invoice_sub"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template match="edit_period">
- <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
- <form method="post" action="{$form_action}">
- <div align="center">
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <xsl:choose>
- <xsl:when test="msgbox_data != ''">
- <tr>
- <td align="left" colspan="3">
- <xsl:call-template
name="msgbox"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <tr>
- <td>
- <xsl:variable name="select_name"><xsl:value-of
select="select_name"/></xsl:variable>
- <select name="{$select_name}" class="forms" >
- <xsl:apply-templates
select="period_list"/>
- </select>
- </td>
- </tr>
- <tr height="50">
- <td>
- <xsl:variable
name="lang_save"><xsl:value-of select="lang_save"/></xsl:variable>
- <input type="submit" name="submit"
value="{$lang_save}" >
- </input>
- </td>
- </tr>
- </table>
- </div>
- </form>
- </xsl:template>
-
- <xsl:template match="period_list">
- <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="name"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="name"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <xsl:template match="remark">
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <tr>
- <td colspan="2" align="center">
- <xsl:value-of select="message"/>
- </td>
- </tr>
- <tr>
- <td align="center">
- <textarea cols="60" rows="15"
name="remark" readonly="readonly" wrap="virtual"
onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_content_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- <xsl:value-of select="remark"/>
- </textarea>
- </td>
- </tr>
-
- </table>
- </xsl:template>
-
- <xsl:template name="excel">
- <xsl:variable name="link_excel"><xsl:value-of
select="link_excel"/></xsl:variable>
- <xsl:variable name="lang_excel_help"><xsl:value-of
select="lang_excel_help"/></xsl:variable>
- <xsl:variable name="lang_excel"><xsl:value-of
select="lang_excel"/></xsl:variable>
- <a href="javascript:var
w=window.open('{$link_excel}','','')"
- onMouseOver="overlib('{$lang_excel_help}',
CAPTION, '{$lang_excel}')"
- onMouseOut="nd()">
- <xsl:value-of select="lang_excel"/></a>
- </xsl:template>
-
-
-<!-- list_voucher -->
-
- <xsl:template match="list_voucher">
- <div id="overDiv" style="position:absolute;
visibility:hide;z-index:1;"></div>
- <xsl:variable name="overlib_source"><xsl:value-of
select="overlib_source"/></xsl:variable>
- <SCRIPT LANGUAGE="JavaScript" SRC="{$overlib_source}"></SCRIPT>
- <xsl:variable name="check_source"><xsl:value-of
select="check_source"/></xsl:variable>
- <SCRIPT LANGUAGE="JavaScript" SRC="{$check_source}"></SCRIPT>
- <xsl:call-template name="menu"/>
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <xsl:choose>
- <xsl:when test="msgbox_data != ''">
- <tr>
- <td align="left" colspan="3">
- <xsl:call-template
name="msgbox"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
-
- <tr>
- <td>
- <xsl:call-template name="cat_filter"/>
- </td>
- <td align="center">
- <xsl:call-template
name="user_lid_filter"/>
- </td>
- <td align="right">
- <xsl:call-template name="search_field"/>
- </td>
- </tr>
- <tr>
- <td colspan="3" width="100%">
- <xsl:call-template name="nextmatchs"/>
- </td>
- <td colspan="3" width="100%" class="small_text"
valign="top" align="left">
- <xsl:call-template name="excel"/>
- </td>
- </tr>
- </table>
- <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
- <form method="post" name="form" action="{$form_action}">
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <xsl:apply-templates
select="table_header_list_voucher"/>
-
- <xsl:choose>
- <xsl:when
test="values_list_voucher[voucher_id]">
- <xsl:apply-templates
select="values_list_voucher"/>
-
- </xsl:when>
- </xsl:choose>
- <xsl:variable name="img_check"><xsl:value-of
select="img_check"/></xsl:variable>
- <tr>
- <td></td>
- <td></td>
- <td></td>
- <td class="small_text" align="right">
- <xsl:value-of select="sum"/>
- </td>
- <td></td>
- <td></td>
- <td></td>
- <td></td>
- <td></td>
- <td align="center">
- <a
href="javascript:check_all_radio('sign_none')"><img src="{$img_check}"
border="0" height="16" width="21" alt="{lang_select_all}"/></a>
- </td>
- <td align="center">
- <a
href="javascript:check_all_radio('sign_janitor')"><img src="{$img_check}"
border="0" height="16" width="21" alt="{lang_select_all}"/></a>
- </td>
- <td align="center">
- <a
href="javascript:check_all_radio('sign_supervisor')"><img src="{$img_check}"
border="0" height="16" width="21" alt="{lang_select_all}"/></a>
- </td>
- <td align="center">
- <a
href="javascript:check_all_radio('sign_budget_responsible')"><img
src="{$img_check}" border="0" height="16" width="21"
alt="{lang_select_all}"/></a>
- </td>
- <td align="right">
- <a
href="javascript:check_all_checkbox('values[transfer]')"><img
src="{$img_check}" border="0" height="16" width="21"
alt="{lang_select_all}"/></a>
- </td>
- </tr>
-
- <tr height="50">
- <td>
- <xsl:variable
name="lang_save"><xsl:value-of select="lang_save"/></xsl:variable>
- <input type="submit"
name="values[save][0]" value="{$lang_save}" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_save_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
-
- </table>
- </form>
- <xsl:choose>
- <xsl:when test="table_add_invoice !=''">
- <xsl:apply-templates
select="table_add_invoice"/>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template match="table_add_invoice">
- <table align = "left">
- <tr>
- <td height="50" align="left" valign="top">
- <xsl:variable
name="add_action"><xsl:value-of select="add_action"/></xsl:variable>
- <xsl:variable
name="lang_add"><xsl:value-of select="lang_add"/></xsl:variable>
- <form method="post"
action="{$add_action}">
- <input type="submit" name=""
value="{$lang_add}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="lang_add_statustext"/>
- <xsl:text>';
return true;</xsl:text>
- </xsl:attribute>
- </input>
- </form>
- </td>
- </tr>
- </table>
- </xsl:template>
-
-
- <xsl:template match="table_header_list_voucher">
- <xsl:variable name="sort_voucher"><xsl:value-of
select="sort_voucher"/></xsl:variable>
- <xsl:variable name="sort_voucher_date"><xsl:value-of
select="sort_voucher_date"/></xsl:variable>
- <xsl:variable name="sort_vendor_id"><xsl:value-of
select="sort_vendor_id"/></xsl:variable>
- <tr class="th">
- <td class="th_text" width="5%" align="right">
- <a href="{$sort_voucher}"><xsl:value-of
select="lang_voucher"/></a>
- </td>
- <td class="th_text" width="2%" align="right">
- <a
href="{$sort_voucher_date}"><xsl:value-of select="lang_voucher_date"/></a>
- </td>
- <td class="th_text" width="2%" align="right">
- <xsl:value-of select="lang_days"/>
- </td>
- <td class="th_text" width="8%" align="right">
- <xsl:value-of select="lang_sum"/>
- </td>
- <td class="th_text" width="4%" align="right">
- <a
href="{$sort_vendor_id}"><xsl:value-of select="lang_vendor_id"/></a>
- </td>
- <td class="th_text" width="3%" align="right">
- <xsl:value-of
select="lang_num_sub_invoice"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of select="lang_type"/>
- </td>
- <td class="th_text" width="3%" align="right">
- <xsl:value-of select="lang_period"/>
- </td>
- <td class="th_text" width="3%" align="right">
- <xsl:value-of select="lang_kredit"/>
- </td>
- <td class="th_text" width="3%" align="right">
- <xsl:value-of select="lang_none"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of select="lang_janitor"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of select="lang_supervisor"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of
select="lang_budget_responsible"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of select="lang_transfer"/>
- </td>
- <xsl:choose>
- <xsl:when test="//acl_delete!=''">
- <td class="th_text" width="5%"
align="center">
- <xsl:value-of
select="lang_delete"/>
- </td>
- </xsl:when>
- </xsl:choose>
- </tr>
- </xsl:template>
-
- <xsl:template match="values_list_voucher">
-
- <xsl:variable name="counter"><xsl:value-of
select="counter"/></xsl:variable>
- <xsl:variable name="current_user"><xsl:value-of
select="current_user"/></xsl:variable>
- <tr>
- <xsl:attribute name="class">
- <xsl:choose>
- <xsl:when test="@class">
- <xsl:value-of
select="@class"/>
- </xsl:when>
- <xsl:when test="position() mod
2 = 0">
-
<xsl:text>row_off</xsl:text>
- </xsl:when>
- <xsl:otherwise>
-
<xsl:text>row_on</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
-
- <td class="small_text" align="right">
- <input type="hidden"
name="values[counter][{$counter}]" value="{counter}">
- </input>
- <input type="hidden"
name="values[voucher_id][{$counter}]" value="{voucher_id}">
- </input>
- <xsl:variable
name="link_sub"><xsl:value-of select="link_sub"/>&voucher_id=<xsl:value-of
select="voucher_id"/></xsl:variable>
- <xsl:variable
name="lang_sub_help"><xsl:value-of select="lang_sub_help"/></xsl:variable>
- <xsl:variable
name="lang_sub"><xsl:value-of select="lang_sub"/></xsl:variable>
- <a href="{$link_sub}"
-
onMouseOver="overlib('{$lang_sub_help}', CAPTION, '{$lang_sub}')"
- onMouseOut="nd()">
- <xsl:value-of select="voucher_id"/></a>
- </td>
- <td class="small_text" align="right">
- <xsl:variable
name="lang_payment_date"><xsl:value-of
select="lang_payment_date"/></xsl:variable>
- <xsl:variable
name="payment_date"><xsl:value-of select="payment_date"/></xsl:variable>
- <a href="javascript:void()"
- onMouseOver="overlib('{$payment_date}',
CAPTION, '{$lang_payment_date}')"
- onMouseOut="nd()">
- <xsl:value-of
select="voucher_date"/></a>
- </td>
- <td class="small_text" align="right">
- <input type="hidden"
name="values[sign_orig][{$counter}]" value="{sign_orig}">
- </input>
- <input type="hidden"
name="values[num_days_orig][{$counter}]" value="{num_days}">
- </input>
- <input type="hidden"
name="values[timestamp_voucher_date][{$counter}]"
value="{timestamp_voucher_date}">
- </input>
- <input type="text" size="2"
name="values[num_days][{$counter}]" value="{num_days}">
- </input>
- </td>
- <td class="small_text" align="right">
- <xsl:value-of select="amount"/>
- </td>
- <td class="small_text" align="right">
- <xsl:variable
name="vendor"><xsl:value-of select="vendor"/></xsl:variable>
- <xsl:variable
name="vendor_id"><xsl:value-of select="vendor_id"/></xsl:variable>
- <a href="javascript:void()"
- onMouseOver="overlib('{$vendor}',
CAPTION, '{$vendor_id}')"
- onMouseOut="nd()">
- <xsl:value-of select="vendor_id"/></a>
-
- </td>
- <td class="small_text" align="right">
- <input type="hidden"
name="values[invoice_count][{$counter}]" value="{invoice_count}">
- </input>
- <xsl:value-of select="invoice_count"/>
- </td>
- <td class="small_text" align="center">
- <xsl:value-of select="type"/>
- </td>
- <td class="small_text" align="right">
- <xsl:variable
name="link_period"><xsl:value-of
select="link_period"/>&voucher_id=<xsl:value-of
select="voucher_id"/>&period=<xsl:value-of select="period"/></xsl:variable>
- <xsl:variable
name="lang_period_help"><xsl:value-of select="lang_period_help"/></xsl:variable>
- <xsl:variable
name="lang_period"><xsl:value-of select="lang_period"/></xsl:variable>
- <a href="javascript:var
w=window.open('{$link_period}','','width=150,height=150')"
-
onMouseOver="overlib('{$lang_period_help}', CAPTION, '{$lang_period}')"
- onMouseOut="nd()">
- <xsl:value-of select="period"/></a>
- </td>
- <td align="center">
- <xsl:choose>
- <xsl:when test="kreditnota='1'">
- <input type="checkbox"
name="values[kreditnota][{$counter}]" value="true" checked="checked"
onMouseout="window.status='';return true;">
- </input>
- </xsl:when>
- <xsl:otherwise>
- <input type="checkbox"
name="values[kreditnota][{$counter}]" value="true"
onMouseout="window.status='';return true;">
- </input>
- </xsl:otherwise>
- </xsl:choose>
- </td>
- <td class="small_text" align="center">
- <xsl:choose>
- <xsl:when test="is_janitor">
- <input type="radio"
name="values[sign][{$counter}]" value="sign_none"
onMouseout="window.status='';return true;">
- </input>
- </xsl:when>
- <xsl:when test="is_supervisor">
- <input type="radio"
name="values[sign][{$counter}]" value="sign_none"
onMouseout="window.status='';return true;">
- </input>
- </xsl:when>
- <xsl:when
test="is_budget_responsible">
- <input type="radio"
name="values[sign][{$counter}]" value="sign_none"
onMouseout="window.status='';return true;">
- </input>
- </xsl:when>
- <xsl:otherwise>
- </xsl:otherwise>
- </xsl:choose>
- </td>
- <td class="small_text" align="right">
-
- <xsl:choose>
- <xsl:when
test="is_janitor='32'">
- <xsl:choose>
- <xsl:when
test="jan_date=''">
- <input
type="radio" name="values[sign][{$counter}]" value="sign_janitor"
onMouseout="window.status='';return true;">
-
</input>
- </xsl:when>
- <xsl:otherwise>
-
<xsl:choose>
-
<xsl:when test="janitor = $current_user">
-
<input type="radio" name="values[sign][{$counter}]"
value="sign_janitor" checked="checked" onMouseout="window.status='';return
true;">
-
</input>
-
</xsl:when>
-
<xsl:otherwise>
-
<input type="checkbox" name="" value="" checked="checked"
disabled="disabled" ></input>
-
</xsl:otherwise>
-
</xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when
test="jan_date=''">
- </xsl:when>
- <xsl:otherwise>
- <input
type="checkbox" name="" value="" checked="checked" disabled="disabled" ></input>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
-
- <xsl:value-of select="janitor"/>
- </td>
- <td class="small_text" align="right">
-
- <xsl:choose>
- <xsl:when
test="is_supervisor='64'"><xsl:value-of select="super_date"/>
- <xsl:choose>
- <xsl:when
test="super_date=''">
- <input
type="radio" name="values[sign][{$counter}]" value="sign_supervisor"
onMouseout="window.status='';return true;">
-
</input>
- </xsl:when>
- <xsl:when
test="super_date!=''">
-
<xsl:choose>
-
<xsl:when test="supervisor = $current_user">
-
<input type="radio" name="values[sign][{$counter}]"
value="sign_supervisor" checked="checked" onMouseout="window.status='';return
true;">
-
</input>
-
</xsl:when>
-
<xsl:otherwise>
-
<input type="checkbox" name="" value="" checked="checked"
disabled="disabled" ></input>
-
</xsl:otherwise>
-
</xsl:choose>
- </xsl:when>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when
test="super_date=''">
- </xsl:when>
- <xsl:otherwise>
- <input
type="checkbox" name="" value="" checked="checked" disabled="disabled" ></input>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
-
- <xsl:value-of select="supervisor"/>
- </td>
- <td class="small_text" align="right">
- <xsl:choose>
- <xsl:when
test="is_budget_responsible='128'">
- <xsl:choose>
- <xsl:when
test="budget_date=''">
- <input
type="radio" name="values[sign][{$counter}]" value="sign_budget_responsible"
onMouseout="window.status='';return true;">
-
</input>
- </xsl:when>
- <xsl:otherwise>
-
<xsl:choose>
-
<xsl:when test="budget_responsible = $current_user">
-
<input type="radio" name="values[sign][{$counter}]"
value="sign_budget_responsible" checked="checked"
onMouseout="window.status='';return true;">
-
</input>
-
</xsl:when>
-
<xsl:otherwise>
-
<input type="checkbox" name="" value="" checked="checked"
disabled="disabled" ></input>
-
</xsl:otherwise>
-
</xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when
test="budget_date=''">
- </xsl:when>
- <xsl:otherwise>
- <input
type="checkbox" name="" value="" checked="checked" disabled="disabled" ></input>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:value-of
select="budget_responsible"/>
- </td>
- <td class="small_text" align="right">
- <xsl:choose>
- <xsl:when
test="is_transfer='16'">
- <xsl:choose>
- <xsl:when
test="transfer_date=''">
- <input
type="checkbox" name="values[transfer][{$counter}]" value="true"
onMouseout="window.status='';return true;">
- </input>
- </xsl:when>
- <xsl:otherwise>
- <input
type="checkbox" name="values[transfer][{$counter}]" value="true"
checked="checked" onMouseout="window.status='';return true;">
-
</input>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when
test="transfer_id!=''">
- <input
type="checkbox" name="" value="" checked="checked" disabled="disabled" ></input>
- </xsl:when>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:value-of select="transfer_id"/>
- </td>
- <xsl:choose>
- <xsl:when test="//acl_delete!=''">
- <xsl:variable
name="lang_delete_statustext"><xsl:value-of
select="lang_delete_statustext"/></xsl:variable>
- <td class="small_text"
align="center">
- <xsl:variable
name="link_delete"><xsl:value-of select="link_delete"/></xsl:variable>
- <a href="{$link_delete}"
onMouseover="window.status='{$lang_delete_statustext}';return true;"
onMouseout="window.status='';return true;"><xsl:value-of
select="text_delete"/></a>
- </td>
- </xsl:when>
- </xsl:choose>
- </tr>
- </xsl:template>
-
-
-
-<!-- list_voucher_paid -->
-
- <xsl:template match="list_voucher_paid">
- <div id="overDiv" style="position:absolute;
visibility:hide;z-index:1;"></div>
- <xsl:variable name="overlib_source"><xsl:value-of
select="overlib_source"/></xsl:variable>
- <SCRIPT LANGUAGE="JavaScript" SRC="{$overlib_source}"></SCRIPT>
-
- <script language="JavaScript">
- self.name="first_Window";
- function abook()
- {
- Window1=window.open('<xsl:value-of
select="addressbook_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
- }
- function property_lookup()
- {
- Window1=window.open('<xsl:value-of
select="property_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
- }
- </script>
-
- <xsl:call-template name="menu"/>
- <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
- <div align="left">
- <form method="post" name="form" action="{$form_action}">
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <xsl:choose>
- <xsl:when test="msgbox_data != ''">
- <tr>
- <td align="left" colspan="3">
- <xsl:call-template
name="msgbox"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
-
- <tr>
- <td>
- <input type="text" id="start_date"
name="start_date" size="10" value="{start_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_start_date_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- <script type="text/javascript">
- document.writeln('<img
id="start_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
- <xsl:value-of
select="calendar_setup_start"/>
- </script>
- </td>
- <td>
- <input type="text" id="end_date"
name="end_date" size="10" value="{end_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_end_date_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- <script type="text/javascript">
- document.writeln('<img
id="end_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
- <xsl:value-of
select="calendar_setup_end"/>
- </script>
- </td>
- <td>
- <input type="text" size="8"
name="workorder_id" value="{workorder_id}" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_workorder_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- <a href="javascript:void()"
-
onMouseOver="overlib('{lang_workorder_statustext}', CAPTION,
'{lang_workorder}')"
- onMouseOut="nd()">
- <xsl:value-of
select="lang_workorder"/></a>
- </td>
-
- <td align="left">
- <input type="text" name="vendor_id"
value="{vendor_id}" size="4" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_vendor_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- <a href="javascript:abook()"
-
onMouseOver="overlib('{lang_select_vendor_statustext}', CAPTION,
'{lang_vendor}')"
- onMouseOut="nd()">
- <xsl:value-of
select="lang_vendor"/></a>
-
- <input type="hidden"
name="vendor_name"></input>
- </td>
- </tr>
-
- <tr>
- <td>
- <xsl:call-template name="cat_select"/>
- </td>
- <td align="left">
- <xsl:call-template
name="user_lid_select"/>
- </td>
- <td align="left">
- <input type="text" name="loc1"
value="{loc1}" size="4" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_property_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- <a href="javascript:property_lookup()"
-
onMouseOver="overlib('{lang_select_property_statustext}', CAPTION,
'{lang_property}')"
- onMouseOut="nd()">
- <xsl:value-of
select="lang_property"/></a>
-
- <input type="hidden"
name="loc1_name"></input>
- </td>
-
- <td align="left">
- <input type="text" name="voucher_id"
value="{voucher_id}" size="8" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_voucher_id_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- <xsl:text> </xsl:text>
- <xsl:value-of select="lang_voucher_id"/>
- </td>
-
- <td align="left">
- <xsl:variable
name="lang_search"><xsl:value-of select="lang_search"/></xsl:variable>
- <input type="submit"
name="submit_search" value="{$lang_search}" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_search_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- <tr>
- <td colspan="11" width="100%">
- <xsl:call-template name="nextmatchs"/>
- </td>
- </tr>
- </table>
- </form>
- </div>
-
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <xsl:apply-templates
select="table_header_list_voucher_paid"/>
-
- <xsl:choose>
- <xsl:when
test="values_list_voucher_paid[voucher_id]">
- <xsl:apply-templates
select="values_list_voucher_paid"/>
- <tr>
- <td></td>
- <td></td>
- <td></td>
- <td class="th_text"
align="right">
- <xsl:value-of
select="sum"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <xsl:variable name="img_check"><xsl:value-of
select="img_check"/></xsl:variable>
- </table>
- </xsl:template>
-
-
- <xsl:template match="table_header_list_voucher_paid">
- <xsl:variable name="sort_voucher"><xsl:value-of
select="sort_voucher"/></xsl:variable>
- <xsl:variable name="sort_voucher_date"><xsl:value-of
select="sort_voucher_date"/></xsl:variable>
- <xsl:variable name="sort_vendor_id"><xsl:value-of
select="sort_vendor_id"/></xsl:variable>
- <tr class="th">
- <td class="th_text" width="5%" align="right">
- <a href="{$sort_voucher}"><xsl:value-of
select="lang_voucher"/></a>
- </td>
- <td class="th_text" width="2%" align="right">
- <a
href="{$sort_voucher_date}"><xsl:value-of select="lang_voucher_date"/></a>
- </td>
- <td class="th_text" width="2%" align="right">
- <xsl:value-of select="lang_days"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of select="lang_sum"/>
- </td>
- <td class="th_text" width="4%" align="right">
- <a
href="{$sort_vendor_id}"><xsl:value-of select="lang_vendor_id"/></a>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of
select="lang_num_sub_invoice"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of select="lang_type"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of select="lang_janitor"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of select="lang_supervisor"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of
select="lang_budget_responsible"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of select="lang_transfer"/>
- </td>
- </tr>
- </xsl:template>
-
- <xsl:template match="values_list_voucher_paid">
-
- <xsl:variable name="counter"><xsl:value-of
select="counter"/></xsl:variable>
- <xsl:variable name="current_user"><xsl:value-of
select="current_user"/></xsl:variable>
- <tr>
- <xsl:attribute name="class">
- <xsl:choose>
- <xsl:when test="@class">
- <xsl:value-of
select="@class"/>
- </xsl:when>
- <xsl:when test="position() mod
2 = 0">
-
<xsl:text>row_off</xsl:text>
- </xsl:when>
- <xsl:otherwise>
-
<xsl:text>row_on</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
-
- <td align="right">
- <xsl:variable
name="link_sub"><xsl:value-of select="link_sub"/>&voucher_id=<xsl:value-of
select="voucher_id"/>&paid=true</xsl:variable>
- <xsl:variable
name="lang_sub_help"><xsl:value-of select="lang_sub_help"/></xsl:variable>
- <xsl:variable
name="lang_sub"><xsl:value-of select="lang_sub"/></xsl:variable>
- <a href="{$link_sub}"
-
onMouseOver="overlib('{$lang_sub_help}', CAPTION, '{$lang_sub}')"
- onMouseOut="nd()">
- <xsl:value-of select="voucher_id"/></a>
- </td>
- <td align="right">
- <xsl:variable
name="lang_payment_date"><xsl:value-of
select="lang_payment_date"/></xsl:variable>
- <xsl:variable
name="payment_date"><xsl:value-of select="payment_date"/></xsl:variable>
- <a href="javascript:void()"
- onMouseOver="overlib('{$payment_date}',
CAPTION, '{$lang_payment_date}')"
- onMouseOut="nd()">
- <xsl:value-of
select="voucher_date"/></a>
- </td>
- <td align="right">
- <xsl:value-of select="num_days"/>
- </td>
- <td align="right">
- <xsl:value-of select="amount"/>
- </td>
- <td align="right">
- <xsl:variable
name="vendor"><xsl:value-of select="vendor"/></xsl:variable>
- <xsl:variable
name="vendor_id"><xsl:value-of select="vendor_id"/></xsl:variable>
- <a href="javascript:void()"
- onMouseOver="overlib('{$vendor}',
CAPTION, '{$vendor_id}')"
- onMouseOut="nd()">
- <xsl:value-of select="vendor_id"/></a>
-
- </td>
- <td align="right">
- <xsl:value-of select="invoice_count"/>
- </td>
- <td align="center">
- <xsl:value-of select="type"/>
- </td>
- <td align="center">
- <xsl:value-of select="jan_date"/> -
<xsl:value-of select="janitor"/>
- </td>
- <td align="center">
- <xsl:value-of select="super_date"/> -
<xsl:value-of select="supervisor"/>
- </td>
- <td align="center">
- <xsl:value-of select="budget_date"/> -
<xsl:value-of select="budget_responsible"/>
- </td>
- <td align="center">
- <xsl:value-of select="transfer_date"/>
- <xsl:value-of select="transfer_id"/>
- </td>
- </tr>
- </xsl:template>
-
-
-<!-- consume -->
-
- <xsl:template match="consume">
- <div id="overDiv" style="position:absolute;
visibility:hide;z-index:1;"></div>
- <xsl:variable name="overlib_source"><xsl:value-of
select="overlib_source"/></xsl:variable>
- <SCRIPT LANGUAGE="JavaScript" SRC="{$overlib_source}"></SCRIPT>
-
- <script language="JavaScript">
- self.name="first_Window";
- function abook()
- {
- Window1=window.open('<xsl:value-of
select="addressbook_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
- }
- function property_lookup()
- {
- Window1=window.open('<xsl:value-of
select="property_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
- }
- </script>
-
- <xsl:call-template name="menu"/>
- <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
- <div align="left">
- <form method="post" name="form" action="{$form_action}">
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <xsl:choose>
- <xsl:when test="msgbox_data != ''">
- <tr>
- <td align="left" colspan="3">
- <xsl:call-template
name="msgbox"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <tr>
- <td>
- <input type="text" id="start_date"
name="start_date" size="10" value="{start_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_start_date_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- <script type="text/javascript">
- document.writeln('<img
id="start_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
- <xsl:value-of
select="calendar_setup_start"/>
- </script>
- </td>
- <td>
- <input type="text" id="end_date"
name="end_date" size="10" value="{end_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_end_date_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- <script type="text/javascript">
- document.writeln('<img
id="end_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
- <xsl:value-of
select="calendar_setup_end"/>
- </script>
- </td>
- <td>
- <input type="text" size="8"
name="workorder_id" value="{workorder_id}" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_workorder_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- <a href="javascript:void()"
-
onMouseOver="overlib('{lang_workorder_statustext}', CAPTION,
'{lang_workorder}')"
- onMouseOut="nd()">
- <xsl:value-of
select="lang_workorder"/></a>
- </td>
-
- <td align="left">
- <input type="text" name="vendor_id"
onClick="abook()" value="{vendor_id}" size="4"
onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_vendor_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- <a href="javascript:abook()"
-
onMouseOver="overlib('{lang_select_vendor_statustext}', CAPTION,
'{lang_vendor}')"
- onMouseOut="nd()">
- <xsl:value-of
select="lang_vendor"/></a>
-
- <input type="hidden" name="vendor_name"
value="{vendor_name}"></input>
- </td>
- </tr>
-
- <tr>
- <td>
- <xsl:call-template name="cat_select"/>
- </td>
- <td align="left">
- <xsl:call-template
name="select_district"/>
- </td>
- <td align="left">
- <xsl:variable
name="lang_account_class_statustext"><xsl:value-of
select="lang_account_class_statustext"/></xsl:variable>
- <xsl:variable
name="select_account_class_name"><xsl:value-of
select="select_account_class_name"/></xsl:variable>
- <select
name="{$select_account_class_name}" class="forms"
onMouseover="window.status='{$lang_account_class_statustext}'; return true;"
onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_no_account_class_"/></option>
- <xsl:apply-templates
select="account_class_list"/>
- </select>
-
- </td>
-
- <td align="left">
- <input type="text" name="loc1"
onClick="property_lookup()" value="{loc1}" size="4"
onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_property_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- <a href="javascript:property_lookup()"
-
onMouseOver="overlib('{lang_select_property_statustext}', CAPTION,
'{lang_property}')"
- onMouseOut="nd()">
- <xsl:value-of
select="lang_property"/></a>
-
- <input type="hidden"
name="loc1_name"></input>
- </td>
- <td align="left">
- <xsl:variable
name="lang_search"><xsl:value-of select="lang_search"/></xsl:variable>
- <input type="submit"
name="submit_search" value="{$lang_search}" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_search_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- </table>
- </form>
- </div>
-
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <xsl:choose>
- <xsl:when test="vendor_name!=''">
- <tr>
- <td width="25%" class="th_text"
align="left">
- <xsl:value-of
select="lang_vendor"/>
- </td>
- <td width="25%" class="th_text"
align="left">
- <xsl:value-of
select="vendor_name"/>
- </td>
- <td width="50%">
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test="loc1!=''">
- <tr>
- <td width="25%" class="th_text"
align="left">
- <xsl:value-of
select="lang_property"/>
- </td>
- <td width="25%" class="th_text"
align="left">
- <xsl:value-of
select="loc1"/>
- </td>
- <td width="50%">
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test="workorder_id!=''">
- <tr>
- <td width="25%" class="th_text"
align="left">
- <xsl:value-of
select="lang_workorder"/>
- </td>
- <td width="25%" class="th_text"
align="left">
- <xsl:value-of
select="workorder_id"/>
- </td>
- <td width="50%">
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
-
- </table>
-
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <xsl:apply-templates select="table_header_consume"/>
-
- <xsl:choose>
- <xsl:when test="values_consume[consume]">
- <xsl:apply-templates
select="values_consume"/>
-
- </xsl:when>
- </xsl:choose>
- <tr>
- <td>
- </td>
- <td>
- </td>
- <td class="th_text" align="right">
- <xsl:value-of select="lang_sum"/>
- </td>
- <td class="th_text" align="right">
- <xsl:value-of select="sum"/>
- </td>
- </tr>
- </table>
- </xsl:template>
-
- <xsl:template match="account_class_list">
- <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="id"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="id"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template match="table_header_consume">
- <tr class="th">
- <td class="th_text" width="10%" align="right">
- <xsl:value-of select="lang_district"/>
- </td>
- <td class="th_text" width="10%" align="right">
- <xsl:value-of select="lang_period"/>
- </td>
- <td class="th_text" width="25%" align="right">
- <xsl:value-of
select="lang_budget_account"/>
- </td>
- <td class="th_text" width="55%" align="right">
- <xsl:value-of select="lang_consume"/>
- </td>
- </tr>
- </xsl:template>
-
- <xsl:template match="values_consume">
- <tr>
- <xsl:attribute name="class">
- <xsl:choose>
- <xsl:when test="@class">
- <xsl:value-of
select="@class"/>
- </xsl:when>
- <xsl:when test="position() mod
2 = 0">
-
<xsl:text>row_off</xsl:text>
- </xsl:when>
- <xsl:otherwise>
-
<xsl:text>row_on</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
-
- <td align="right">
- <xsl:value-of select="district_id"/>
- </td>
- <td align="center">
- <xsl:value-of select="period"/>
- </td>
- <td align="center">
- <xsl:value-of select="account_class"/>
- </td>
- <td align="right">
- <xsl:value-of select="consume"/>
- </td>
- </tr>
- </xsl:template>
-
-<!-- debug-->
-
- <xsl:template match="debug">
- <div align="left">
- <table width="50%" cellpadding="2" cellspacing="2"
align="center">
-
- <tr>
- <td class="th_text">
- <xsl:value-of select="lang_bilagsnr"/>
- </td>
- <td>
- <xsl:value-of select="bilagsnr"/>
- </td>
- </tr>
- <tr>
- <td class="th_text">
- <xsl:value-of select="lang_type"/>
- </td>
- <td>
- <xsl:value-of select="artid"/>
- </td>
- </tr>
- <tr>
- <td class="th_text">
- <xsl:value-of select="lang_vendor"/>
- </td>
- <td>
- <xsl:value-of select="spvend_code"/>
- <xsl:text> </xsl:text>
- <xsl:value-of select="vendor_name"/>
- </td>
- </tr>
- <tr>
- <td class="th_text">
- <xsl:value-of
select="lang_fakturadato"/>
- </td>
- <td>
- <xsl:value-of select="fakturadato"/>
- </td>
- </tr>
- <tr>
- <td class="th_text">
- <xsl:value-of
select="lang_forfallsdato"/>
- </td>
- <td>
- <xsl:value-of select="forfallsdato"/>
- </td>
- </tr>
- <tr>
- <td class="th_text">
- <xsl:value-of select="lang_janitor"/>
- </td>
- <td>
- <xsl:value-of select="oppsynsmannid"/>
- </td>
- </tr>
- <tr>
- <td class="th_text">
- <xsl:value-of select="lang_supervisor"/>
- </td>
- <td>
- <xsl:value-of select="saksbehandlerid"/>
- </td>
- </tr>
- <tr>
- <td class="th_text">
- <xsl:value-of
select="lang_budget_responsible"/>
- </td>
- <td>
- <xsl:value-of
select="budsjettansvarligid"/>
- </td>
- </tr>
- <tr>
- <td class="th_text">
- <xsl:value-of select="lang_project_id"/>
- </td>
- <td>
- <xsl:value-of select="project_id"/>
- </td>
- </tr>
- <tr>
- <td class="th_text">
- <xsl:value-of select="lang_sum"/>
- </td>
- <td>
- <xsl:value-of select="sum"/>
- </td>
- </tr>
- </table>
- </div>
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <tr class="th">
- <xsl:call-template name="table_header"/>
- </tr>
- <xsl:call-template name="values_debug"/>
- <xsl:apply-templates select="table_add"/>
- </table>
- </xsl:template>
-
- <xsl:template name="values_debug">
- <xsl:for-each select="values" >
- <tr>
- <xsl:attribute name="class">
- <xsl:choose>
- <xsl:when test="@class">
- <xsl:value-of select="@class"/>
- </xsl:when>
- <xsl:when test="position() mod 2 = 0">
- <xsl:text>row_off</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>row_on</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <xsl:for-each select="row" >
- <td align="{align}">
- <xsl:value-of select="value"/>
- </td>
- </xsl:for-each>
- </tr>
- </xsl:for-each>
- </xsl:template>
-
- <xsl:template match="table_add">
- <tr>
- <td height="50">
- <xsl:variable
name="add_action"><xsl:value-of select="add_action"/></xsl:variable>
- <xsl:variable
name="lang_add"><xsl:value-of select="lang_add"/></xsl:variable>
- <form method="post"
action="{$add_action}">
- <input type="submit" name="add"
value="{$lang_add}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="lang_add_statustext"/>
- <xsl:text>';
return true;</xsl:text>
- </xsl:attribute>
- </input>
- </form>
- </td>
- <td height="50">
- <xsl:variable
name="cancel_action"><xsl:value-of select="cancel_action"/></xsl:variable>
- <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
- <form method="post"
action="{$cancel_action}">
- <input type="submit"
name="cancel" value="{$lang_cancel}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="lang_cancel_statustext"/>
- <xsl:text>';
return true;</xsl:text>
- </xsl:attribute>
- </input>
- </form>
- </td>
- </tr>
- </xsl:template>
-
-<!-- add / edit -->
- <xsl:template match="add">
-
- <script language="JavaScript">
- self.name="first_Window";
- function abook()
- {
- Window1=window.open('<xsl:value-of
select="addressbook_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
- }
- </script>
-
- <xsl:call-template name="menu"/>
- <div align="left">
- <table cellpadding="2" cellspacing="2" width="80%"
align="center">
- <tr>
- <td colspan="2" align="center">
- <xsl:value-of select="message"/>
- </td>
- </tr>
- <xsl:choose>
- <xsl:when test="msgbox_data != ''">
- <tr>
- <td align="left" colspan="3">
- <xsl:call-template
name="msgbox"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
- <form method="post" name="form" action="{$form_action}">
-
- <tr>
- <td>
- <xsl:value-of select="lang_auto_tax"/>
- </td>
- <td>
- <input type="checkbox" name="auto_tax"
value="True" checked="checked" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_auto_tax_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- <xsl:call-template name="location_form"/>
- <xsl:call-template name="b_account_form"/>
- <tr>
- <td valign="top">
- <xsl:variable
name="lang_vendor"><xsl:value-of select="lang_vendor"/></xsl:variable>
- <input type="button" name="convert"
value="{$lang_vendor}" onClick="abook();" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_select_vendor_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- <td>
- <input type="text" name="vendor_id"
value="{value_vendor_id}" size="4" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_vendor_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- <input type="text" name="vendor_name"
value="{value_vendor_name}" size="20" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_vendor_name_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_janitor"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_janitor_statustext"><xsl:value-of
select="lang_janitor_statustext"/></xsl:variable>
- <xsl:variable
name="select_janitor"><xsl:value-of select="select_janitor"/></xsl:variable>
- <select name="{$select_janitor}"
class="forms" onMouseover="window.status='{$lang_janitor_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_no_janitor"/></option>
- <xsl:apply-templates
select="janitor_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_supervisor"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_supervisor_statustext"><xsl:value-of
select="lang_supervisor_statustext"/></xsl:variable>
- <xsl:variable
name="select_supervisor"><xsl:value-of
select="select_supervisor"/></xsl:variable>
- <select name="{$select_supervisor}"
class="forms" onMouseover="window.status='{$lang_supervisor_statustext}';
return true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_no_supervisor"/></option>
- <xsl:apply-templates
select="supervisor_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of
select="lang_budget_responsible"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_budget_responsible_statustext"><xsl:value-of
select="lang_budget_responsible_statustext"/></xsl:variable>
- <xsl:variable
name="select_budget_responsible"><xsl:value-of
select="select_budget_responsible"/></xsl:variable>
- <select
name="{$select_budget_responsible}" class="forms"
onMouseover="window.status='{$lang_budget_responsible_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_select_budget_responsible"/></option>
- <xsl:apply-templates
select="budget_responsible_list"/>
- </select>
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_order"/>
- </td>
- <td>
- <input type="text" name="order"
value="{value_order}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_order_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_art"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_art_statustext"><xsl:value-of
select="lang_art_statustext"/></xsl:variable>
- <xsl:variable
name="select_art"><xsl:value-of select="select_art"/></xsl:variable>
- <select name="{$select_art}"
class="forms" onMouseover="window.status='{$lang_art_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_select_art"/></option>
- <xsl:apply-templates
select="art_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_type"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_type_statustext"><xsl:value-of
select="lang_type_statustext"/></xsl:variable>
- <xsl:variable
name="select_type"><xsl:value-of select="select_type"/></xsl:variable>
- <select name="{$select_type}"
class="forms" onMouseover="window.status='{$lang_type_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_no_type"/></option>
- <xsl:apply-templates
select="type_list"/>
- </select>
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_dimb"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_dimb_statustext"><xsl:value-of
select="lang_dimb_statustext"/></xsl:variable>
- <xsl:variable
name="select_dimb"><xsl:value-of select="select_dimb"/></xsl:variable>
- <select name="{$select_dimb}"
class="forms" onMouseover="window.status='{$lang_dimb_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_no_dimb"/></option>
- <xsl:apply-templates
select="dimb_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of
select="lang_invoice_number"/>
- </td>
- <td>
- <input type="text" name="invoice_num"
value="{value_invoice_num}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_invoice_num_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_kidnr"/>
- </td>
- <td>
- <input type="text" name="kid_nr"
value="{value_kid_nr}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_kid_nr_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_amount"/>
- </td>
- <td>
- <input type="text" name="amount"
value="{value_amount}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_amount_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of
select="lang_invoice_date"/>
- </td>
- <td>
- <input type="text" id="invoice_date"
name="invoice_date" size="10" value="{value_invoice_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_invoice_date_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- <script type="text/javascript">
- document.writeln('<img
id="invoice_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
- <xsl:value-of
select="calendar_setup_invoice"/>
- </script>
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_no_of_days"/>
- </td>
- <td>
- <input type="text" name="num_days"
value="{value_num_days}" size="4" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_num_days_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- </td>
- </tr>
-
- <tr>
-
- <td valign="top">
- <xsl:value-of
select="lang_payment_date"/>
- </td>
- <td>
- <input type="text" id="payment_date"
name="payment_date" size="10" value="{value_payment_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_payment_date_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- <script type="text/javascript">
- document.writeln('<img
id="payment_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
- <xsl:value-of
select="calendar_setup_payment"/>
- </script>
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_merknad"/>
- </td>
- <td>
- <textarea cols="60" rows="10"
name="merknad" wrap="virtual" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_merknad_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- <xsl:value-of
select="value_merknad"/>
- </textarea>
-
- </td>
- </tr>
-
- <tr height="50">
- <td>
- <xsl:variable
name="lang_add"><xsl:value-of select="lang_add"/></xsl:variable>
- <input type="submit" name="add_invoice"
value="{$lang_add}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_add_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- </form>
- <tr>
- <td>
- <xsl:variable
name="cancel_action"><xsl:value-of select="cancel_action"/></xsl:variable>
- <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
- <form method="post"
action="{$cancel_action}">
- <input type="submit"
name="done" value="{$lang_cancel}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="lang_cancel_statustext"/>
- <xsl:text>';
return true;</xsl:text>
- </xsl:attribute>
- </input>
- </form>
- </td>
- </tr>
- </table>
- </div>
- </xsl:template>
-
-<!-- import -->
-
- <xsl:template match="import">
-
- <script language="JavaScript">
- self.name="first_Window";
- function abook()
- {
- Window1=window.open('<xsl:value-of
select="addressbook_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
- }
- </script>
-
- <xsl:call-template name="menu"/>
- <div align="left">
- <table cellpadding="2" cellspacing="2" width="80%"
align="center">
- <tr>
- <td colspan="2" align="center">
- <xsl:value-of select="message"/>
- </td>
- </tr>
- <xsl:choose>
- <xsl:when test="msgbox_data != ''">
- <tr>
- <td align="left" colspan="3">
- <xsl:call-template
name="msgbox"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
- <form ENCTYPE="multipart/form-data" method="post"
name="form" action="{$form_action}">
-
- <tr>
- <td>
- <xsl:value-of select="lang_auto_tax"/>
- </td>
- <td>
- <input type="checkbox" name="auto_tax"
value="True" checked="checked" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_auto_tax_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_art"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_art_statustext"><xsl:value-of
select="lang_art_statustext"/></xsl:variable>
- <xsl:variable
name="select_art"><xsl:value-of select="select_art"/></xsl:variable>
- <select name="{$select_art}"
class="forms" onMouseover="window.status='{$lang_art_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_select_art"/></option>
- <xsl:apply-templates
select="art_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_type"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_type_statustext"><xsl:value-of
select="lang_type_statustext"/></xsl:variable>
- <xsl:variable
name="select_type"><xsl:value-of select="select_type"/></xsl:variable>
- <select name="{$select_type}"
class="forms" onMouseover="window.status='{$lang_type_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_no_type"/></option>
- <xsl:apply-templates
select="type_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_dimb"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_dimb_statustext"><xsl:value-of
select="lang_dimb_statustext"/></xsl:variable>
- <xsl:variable
name="select_dimb"><xsl:value-of select="select_dimb"/></xsl:variable>
- <select name="{$select_dimb}"
class="forms" onMouseover="window.status='{$lang_dimb_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_no_dimb"/></option>
- <xsl:apply-templates
select="dimb_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of
select="lang_invoice_number"/>
- </td>
- <td>
- <input type="text" name="invoice_num"
value="{value_invoice_num}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_invoice_num_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_kidnr"/>
- </td>
- <td>
- <input type="text" name="kid_nr"
value="{value_kid_nr}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_kid_nr_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:variable
name="lang_vendor"><xsl:value-of select="lang_vendor"/></xsl:variable>
- <input type="button" name="convert"
value="{$lang_vendor}" onClick="abook();" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_select_vendor_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- <td>
- <input type="text" name="vendor_id"
value="{value_vendor_id}" size="6" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_vendor_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- <input type="text" name="vendor_name"
value="{value_vendor_name}" size="20" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_vendor_name_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_janitor"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_janitor_statustext"><xsl:value-of
select="lang_janitor_statustext"/></xsl:variable>
- <xsl:variable
name="select_janitor"><xsl:value-of select="select_janitor"/></xsl:variable>
- <select name="{$select_janitor}"
class="forms" onMouseover="window.status='{$lang_janitor_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_no_janitor"/></option>
- <xsl:apply-templates
select="janitor_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_supervisor"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_supervisor_statustext"><xsl:value-of
select="lang_supervisor_statustext"/></xsl:variable>
- <xsl:variable
name="select_supervisor"><xsl:value-of
select="select_supervisor"/></xsl:variable>
- <select name="{$select_supervisor}"
class="forms" onMouseover="window.status='{$lang_supervisor_statustext}';
return true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_no_supervisor"/></option>
- <xsl:apply-templates
select="supervisor_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of
select="lang_budget_responsible"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_budget_responsible_statustext"><xsl:value-of
select="lang_budget_responsible_statustext"/></xsl:variable>
- <xsl:variable
name="select_budget_responsible"><xsl:value-of
select="select_budget_responsible"/></xsl:variable>
- <select
name="{$select_budget_responsible}" class="forms"
onMouseover="window.status='{$lang_budget_responsible_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_select_budget_responsible"/></option>
- <xsl:apply-templates
select="budget_responsible_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of
select="lang_invoice_date"/>
- </td>
- <td>
- <input type="text" id="invoice_date"
name="invoice_date" size="10" value="{value_invoice_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_invoice_date_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- <script type="text/javascript">
- document.writeln('<img
id="invoice_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
- <xsl:value-of
select="calendar_setup_invoice"/>
- </script>
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_no_of_days"/>
- </td>
- <td>
- <input type="text" name="num_days"
value="{value_num_days}" size="4" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_num_days_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- </td>
- </tr>
-
- <tr>
-
- <td valign="top">
- <xsl:value-of
select="lang_payment_date"/>
- </td>
- <td>
- <input type="text" id="payment_date"
name="payment_date" size="10" value="{value_payment_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_payment_date_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- <script type="text/javascript">
- document.writeln('<img
id="payment_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
- <xsl:value-of
select="calendar_setup_payment"/>
- </script>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_file"/>
- </td>
- <td>
- <input type="file" name="tsvfile"
onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_file_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_conv"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_conv_statustext"><xsl:value-of
select="lang_conv_statustext"/></xsl:variable>
- <xsl:variable
name="select_conv"><xsl:value-of select="select_conv"/></xsl:variable>
- <select name="{$select_conv}"
class="forms" onMouseover="window.status='{$lang_conv_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_select_conversion"/></option>
- <xsl:apply-templates
select="conv_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td>
- <xsl:value-of select="lang_debug"/>
- </td>
- <td>
- <input type="checkbox" name="download"
value="True" checked="checked" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_debug_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- <tr height="50">
- <td>
- <xsl:variable
name="lang_import"><xsl:value-of select="lang_import"/></xsl:variable>
- <input type="submit" name="convert"
value="{$lang_import}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_import_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- </form>
- <tr>
- <td>
- <xsl:variable
name="cancel_action"><xsl:value-of select="cancel_action"/></xsl:variable>
- <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
- <form method="post"
action="{$cancel_action}">
- <input type="submit"
name="done" value="{$lang_cancel}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="lang_cancel_statustext"/>
- <xsl:text>';
return true;</xsl:text>
- </xsl:attribute>
- </input>
- </form>
- </td>
- </tr>
- </table>
- </div>
- </xsl:template>
-
-<!-- art_list -->
-
- <xsl:template match="art_list">
- <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="num"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="num"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-<!-- type_list -->
-
- <xsl:template match="type_list">
- <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="num"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="num"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-<!-- dimb_list -->
-
- <xsl:template match="dimb_list">
- <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="num"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="num"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-<!-- janitor_list -->
-
- <xsl:template match="janitor_list">
- <xsl:variable name="lid"><xsl:value-of select="lid"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$lid}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="firstname"/> <xsl:value-of select="lastname"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$lid}"><xsl:value-of
disable-output-escaping="yes" select="firstname"/> <xsl:value-of
select="lastname"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-<!-- supervisor_list -->
-
- <xsl:template match="supervisor_list">
- <xsl:variable name="lid"><xsl:value-of select="lid"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$lid}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="firstname"/> <xsl:value-of select="lastname"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$lid}"><xsl:value-of
disable-output-escaping="yes" select="firstname"/> <xsl:value-of
select="lastname"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-<!-- budget_responsible_list -->
-
- <xsl:template match="budget_responsible_list">
- <xsl:variable name="lid"><xsl:value-of select="lid"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$lid}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="firstname"/> <xsl:value-of select="lastname"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$lid}"><xsl:value-of
disable-output-escaping="yes" select="firstname"/> <xsl:value-of
select="lastname"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-<!-- conv_list -->
-
- <xsl:template match="conv_list">
- <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="name"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="name"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-<!-- rollback_file_list -->
-
- <xsl:template match="rollback_file_list">
- <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="name"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="name"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-<!-- tax_code_list -->
-
- <xsl:template match="tax_code_list">
- <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="id"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="id"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-<!-- export -->
-
- <xsl:template match="export">
- <xsl:call-template name="menu"/>
- <div align="left">
- <table cellpadding="2" cellspacing="2" width="80%"
align="center">
- <xsl:choose>
- <xsl:when test="msgbox_data != ''">
- <tr>
- <td align="left" colspan="3">
- <xsl:call-template
name="msgbox"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
- <form method="post" name="form" action="{$form_action}">
-
-
- <tr>
- <td valign="top">
- <xsl:value-of
select="lang_select_conv"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_conv_statustext"><xsl:value-of
select="lang_conv_statustext"/></xsl:variable>
- <xsl:variable
name="select_conv"><xsl:value-of select="select_conv"/></xsl:variable>
- <select name="{$select_conv}"
class="forms" onMouseover="window.status='{$lang_conv_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_select_conv"/></option>
- <xsl:apply-templates
select="conv_list"/>
- </select>
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of
select="lang_force_period_year"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_force_period_year_statustext"><xsl:value-of
select="lang_force_period_year_statustext"/></xsl:variable>
- <select
name="values[force_period_year]" class="forms"
onMouseover="window.status='{$lang_force_period_year_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_select_year"/></option>
- <xsl:apply-templates
select="force_period_year"/>
- </select>
- </td>
- </tr>
- <tr>
- <td>
- <xsl:value-of
select="lang_export_to_file"/>
- </td>
- <td>
- <input type="checkbox"
name="values[download]" value="on" checked="checked"
onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_debug_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
-
- <tr>
- <td>
- </td>
- <td>
- <xsl:variable
name="link_rollback_file"><xsl:value-of
select="link_rollback_file"/></xsl:variable>
- <a
href="{$link_rollback_file}"><xsl:value-of select="lang_rollback_file"/></a>
- </td>
- </tr>
-
- <tr height="50">
- <td>
- <xsl:variable
name="lang_submit"><xsl:value-of select="lang_submit"/></xsl:variable>
- <input type="submit"
name="values[submit]" value="{$lang_submit}"
onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_import_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- </form>
- <tr>
- <td>
- <xsl:variable
name="cancel_action"><xsl:value-of select="cancel_action"/></xsl:variable>
- <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
- <form method="post"
action="{$cancel_action}">
- <input type="submit"
name="done" value="{$lang_cancel}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="lang_cancel_statustext"/>
- <xsl:text>';
return true;</xsl:text>
- </xsl:attribute>
- </input>
- </form>
- </td>
- </tr>
- </table>
- </div>
- </xsl:template>
-
-
-<!-- rollback -->
-
- <xsl:template match="rollback">
- <xsl:call-template name="menu"/>
- <div align="left">
- <table cellpadding="2" cellspacing="2" width="80%"
align="center">
- <xsl:choose>
- <xsl:when test="msgbox_data != ''">
- <tr>
- <td align="left" colspan="3">
- <xsl:call-template
name="msgbox"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
- <form method="post" name="form" action="{$form_action}">
-
-
- <tr>
- <td valign="top">
- <xsl:value-of
select="lang_select_conv"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_conv_statustext"><xsl:value-of
select="lang_conv_statustext"/></xsl:variable>
- <xsl:variable
name="select_conv"><xsl:value-of select="select_conv"/></xsl:variable>
- <select name="{$select_conv}"
class="forms" onMouseover="window.status='{$lang_conv_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_select_conv"/></option>
- <xsl:apply-templates
select="conv_list"/>
- </select>
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of
select="lang_select_file"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_file_statustext"><xsl:value-of
select="lang_file_statustext"/></xsl:variable>
- <xsl:variable
name="select_file"><xsl:value-of select="select_file"/></xsl:variable>
- <select name="{$select_file}"
class="forms" onMouseover="window.status='{$lang_file_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_no_file"/></option>
- <xsl:apply-templates
select="rollback_file_list"/>
- </select>
- </td>
- </tr>
-
-
- <tr>
-
- <td valign="top">
- <xsl:value-of select="lang_date"/>
- </td>
- <td>
- <input type="text" id="date"
name="date" size="10" value="{value_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_date_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- <script type="text/javascript">
- document.writeln('<img
id="date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
- <xsl:value-of select="calendar_setup"/>
- </script>
- </td>
- </tr>
-
- <tr height="50">
- <td>
- <xsl:variable
name="lang_submit"><xsl:value-of select="lang_submit"/></xsl:variable>
- <input type="submit"
name="values[submit]" value="{$lang_submit}"
onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_import_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- </form>
- <tr>
- <td>
- <xsl:variable
name="cancel_action"><xsl:value-of select="cancel_action"/></xsl:variable>
- <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
- <form method="post"
action="{$cancel_action}">
- <input type="submit"
name="done" value="{$lang_cancel}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="lang_cancel_statustext"/>
- <xsl:text>';
return true;</xsl:text>
- </xsl:attribute>
- </input>
- </form>
- </td>
- </tr>
- </table>
- </div>
- </xsl:template>
-
-
-<!--list_invoice_sub-->
-
- <xsl:template match="list_invoice_sub">
- <div id="overDiv" style="position:absolute;
visibility:hide;z-index:1;"></div>
- <xsl:variable name="overlib_source"><xsl:value-of
select="overlib_source"/></xsl:variable>
- <SCRIPT LANGUAGE="JavaScript" SRC="{$overlib_source}"></SCRIPT>
- <SCRIPT LANGUAGE="JavaScript" SRC="{check_source}"></SCRIPT>
-
- <xsl:call-template name="menu"/>
- <table width="80%" cellpadding="2" cellspacing="2"
align="center">
- <xsl:choose>
- <xsl:when test="msgbox_data != ''">
- <tr>
- <td align="left" colspan="3">
- <xsl:call-template
name="msgbox"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test="vendor!=''">
- <tr>
- <td width="25%" class="th_text"
align="left">
- <xsl:value-of
select="lang_vendor"/>
- </td>
- <td width="25%" class="th_text"
align="left">
- <xsl:value-of
select="vendor"/>
- </td>
- <td width="50%">
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test="voucher_id!=''">
- <tr>
- <td width="25%" class="th_text"
align="left">
- <xsl:value-of
select="lang_voucher_id"/>
- </td>
- <td width="25%" class="th_text"
align="left">
- <xsl:value-of
select="voucher_id"/>
- </td>
- <td width="50%">
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- </table>
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
- <form method="post" name="form" action="{$form_action}">
- <xsl:apply-templates
select="table_header_list_invoice_sub"/>
-
- <xsl:choose>
- <xsl:when test="values_list_invoice_sub[id]">
- <xsl:apply-templates
select="values_list_invoice_sub"/>
- <xsl:variable
name="img_check"><xsl:value-of select="img_check"/></xsl:variable>
- <tr>
- <td></td>
- <td align="center">
- <a
href="javascript:check_all_checkbox('values[close_order]')"><img
src="{$img_check}" border="0" height="16" width="21"
alt="{lang_select_all}"/></a>
- </td>
- <td></td>
- <td></td>
- <td></td>
- <td class="small_text"
align="right">
- <xsl:value-of
select="sum"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <tr height="50">
- <td>
- <xsl:choose>
- <xsl:when test="paid=''">
- <xsl:variable
name="lang_save"><xsl:value-of select="lang_save"/></xsl:variable>
- <input type="submit"
name="values[save][0]" value="{$lang_save}" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="lang_save_statustext"/>
-
<xsl:text>'; return true;</xsl:text>
- </xsl:attribute>
- </input>
- </xsl:when>
- </xsl:choose>
- </td>
- </tr>
- </form>
- <tr>
- <td>
- <xsl:variable
name="done_action"><xsl:value-of select="done_action"/></xsl:variable>
- <xsl:variable
name="lang_done"><xsl:value-of select="lang_done"/></xsl:variable>
- <form method="post"
action="{$done_action}">
- <input type="submit"
name="done" value="{$lang_done}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="lang_done_statustext"/>
- <xsl:text>';
return true;</xsl:text>
- </xsl:attribute>
- </input>
- </form>
- </td>
- </tr>
-
- </table>
- </xsl:template>
-
- <xsl:template match="table_header_list_invoice_sub">
- <xsl:variable name="sort_workorder"><xsl:value-of
select="sort_workorder"/></xsl:variable>
- <xsl:variable name="sort_budget_account"><xsl:value-of
select="sort_budget_account"/></xsl:variable>
- <xsl:variable name="sort_sum"><xsl:value-of
select="sort_sum"/></xsl:variable>
- <xsl:variable name="sort_dima"><xsl:value-of
select="sort_dima"/></xsl:variable>
- <tr class="th">
- <td class="th_text" width="5%" align="right">
- <a
href="{$sort_workorder}"><xsl:value-of select="lang_workorder"/></a>
- </td>
- <td class="th_text" width="2%" align="right">
- <xsl:value-of
select="lang_close_order"/>
- </td>
- <td class="th_text" width="2%" align="right">
- <xsl:value-of
select="lang_charge_tenant"/>
- </td>
- <td class="th_text" width="2%" align="right">
- <xsl:value-of select="lang_invoice_id"/>
- </td>
- <td class="th_text" width="2%" align="right">
- <a
href="{$sort_budget_account}"><xsl:value-of select="lang_budget_account"/></a>
- </td>
- <td class="th_text" width="5%" align="right">
- <a href="{$sort_sum}"><xsl:value-of
select="lang_sum"/></a>
- </td>
- <td class="th_text" width="5%" align="right">
- <a href="{$sort_dima}"><xsl:value-of
select="lang_dima"/></a>
- </td>
- <td class="th_text" width="2%" align="right">
- <xsl:value-of select="lang_dimb"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of select="lang_dimd"/>
- </td>
- <td class="th_text" width="2%" align="right">
- <xsl:value-of select="lang_tax_code"/>
- </td>
- <td class="th_text" width="2%" align="right">
- <xsl:value-of select="lang_remark"/>
- </td>
- </tr>
- </xsl:template>
-
- <xsl:template match="values_list_invoice_sub">
-
- <xsl:variable name="counter"><xsl:value-of
select="counter"/></xsl:variable>
- <xsl:variable name="current_user"><xsl:value-of
select="current_user"/></xsl:variable>
- <tr>
- <xsl:attribute name="class">
- <xsl:choose>
- <xsl:when test="@class">
- <xsl:value-of
select="@class"/>
- </xsl:when>
- <xsl:when test="position() mod
2 = 0">
-
<xsl:text>row_off</xsl:text>
- </xsl:when>
- <xsl:otherwise>
-
<xsl:text>row_on</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
-
- <td align="right">
- <input type="hidden"
name="values[counter][{$counter}]" value="{counter}">
- </input>
- <input type="hidden"
name="values[id][{$counter}]" value="{id}">
- </input>
- <input type="hidden"
name="values[workorder_id][{$counter}]" value="{workorder_id}">
- </input>
- <xsl:variable
name="link_order"><xsl:value-of
select="link_order"/>&order_id=<xsl:value-of
select="workorder_id"/></xsl:variable>
- <a href="{$link_order}"
target="_blank"><xsl:value-of select="workorder_id"/></a>
- </td>
- <td class="small_text" align="center">
- <xsl:choose>
- <xsl:when
test="workorder_id=''">
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when
test="paid=''">
- <input
type="hidden" name="values[close_order_orig][{$counter}]" value="{closed}">
- </input>
-
<xsl:choose>
-
<xsl:when test="closed='1'">
-
<input type="checkbox" name="values[close_order][{$counter}]"
value="true" checked="checked" onMouseout="window.status='';return true;">
-
</input>
-
</xsl:when>
-
<xsl:otherwise>
-
<input type="checkbox" name="values[close_order][{$counter}]"
value="true" onMouseout="window.status='';return true;">
-
</input>
-
</xsl:otherwise>
-
</xsl:choose>
- </xsl:when>
- <xsl:otherwise>
-
<xsl:choose>
-
<xsl:when test="closed='1'">
-
<b>x</b>
-
</xsl:when>
-
</xsl:choose>
-
</xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </td>
- <td class="small_text" align="center">
- <xsl:choose>
- <xsl:when
test="charge_tenant='1'">
- <xsl:choose>
- <xsl:when
test="claim_issued=''">
-
<xsl:variable name="link_claim"><xsl:value-of
select="link_claim"/>&project_id=<xsl:value-of
select="project_id"/></xsl:variable>
- <a
href="{$link_claim}" target="_blank"><xsl:value-of select="//lang_claim"/></a>
- </xsl:when>
- </xsl:choose>
- <b>x</b>
- </xsl:when>
- </xsl:choose>
- </td>
- <td class="small_text" align="right">
- <xsl:value-of select="invoice_id"/>
- </td>
- <td class="small_text" align="right">
- <xsl:choose>
- <xsl:when test="paid='true'">
- <xsl:value-of
select="budget_account"/>
- </xsl:when>
- <xsl:otherwise>
- <input type="text"
size="7" name="values[budget_account][{$counter}]" value="{budget_account}">
- </input>
- </xsl:otherwise>
- </xsl:choose>
- </td>
- <td class="small_text" align="right">
- <xsl:value-of select="amount"/>
- </td>
- <td class="small_text" align="center">
- <xsl:choose>
- <xsl:when test="paid='true'">
- <xsl:value-of
select="dima"/>
- </xsl:when>
- <xsl:otherwise>
- <input type="text"
size="7" name="values[dima][{$counter}]" value="{dima}">
- </input>
- </xsl:otherwise>
- </xsl:choose>
- </td>
- <td class="small_text" align="right">
- <xsl:value-of select="dimb"/>
- </td>
- <td class="small_text" align="center">
- <xsl:choose>
- <xsl:when test="paid='true'">
- <xsl:value-of
select="dimd"/>
- </xsl:when>
- <xsl:otherwise>
- <input type="text"
size="4" name="values[dimd][{$counter}]" value="{dimd}">
- </input>
- </xsl:otherwise>
- </xsl:choose>
- </td>
- <td class="small_text" align="center">
- <xsl:choose>
- <xsl:when test="paid='true'">
- <xsl:value-of
select="tax_code"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable
name="lang_tax_code_statustext"><xsl:value-of
select="lang_tax_code_statustext"/></xsl:variable>
- <select
name="values[tax_code][{$counter}]" class="forms"
onMouseover="window.status='{$lang_tax_code_statustext}'; return true;"
onMouseout="window.status='';return true;">
-
<xsl:apply-templates select="tax_code_list"/>
- </select>
- </xsl:otherwise>
- </xsl:choose>
- </td>
- <td class="small_text" align="right">
- <xsl:choose>
- <xsl:when test="remark='1'">
- <xsl:variable
name="link_remark"><xsl:value-of select="link_remark"/>&id=<xsl:value-of
select="id"/>&paid=<xsl:value-of select="paid"/></xsl:variable>
- <xsl:variable
name="lang_remark_help"><xsl:value-of select="lang_remark_help"/></xsl:variable>
- <xsl:variable
name="lang_remark"><xsl:value-of select="lang_remark"/></xsl:variable>
- <a href="javascript:var
w=window.open('{$link_remark}','','width=550,height=400,scrollbars')"
-
onMouseOver="overlib('{$lang_remark_help}', CAPTION, '{$lang_remark}')"
- onMouseOut="nd()">
- <xsl:value-of
select="lang_remark"/></a>
- </xsl:when>
- </xsl:choose>
- </td>
-
- </tr>
- </xsl:template>
-
- <xsl:template match="force_period_year">
- <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected='selected'">
- <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="id"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="id"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
+<!-- $Id: invoice.xsl,v 1.6 2006/01/27 14:05:59 sigurdne Exp $ -->
+
+ <xsl:template name="app_data">
+ <xsl:choose>
+ <xsl:when test="add">
+ <xsl:apply-templates select="add"/>
+ </xsl:when>
+ <xsl:when test="edit">
+ <xsl:apply-templates select="edit"/>
+ </xsl:when>
+ <xsl:when test="import">
+ <xsl:apply-templates select="import"/>
+ </xsl:when>
+ <xsl:when test="export">
+ <xsl:apply-templates select="export"/>
+ </xsl:when>
+ <xsl:when test="rollback">
+ <xsl:apply-templates select="rollback"/>
+ </xsl:when>
+ <xsl:when test="debug">
+ <xsl:apply-templates select="debug"/>
+ </xsl:when>
+ <xsl:when test="edit_period">
+ <xsl:apply-templates select="edit_period"/>
+ </xsl:when>
+ <xsl:when test="list_voucher">
+ <xsl:apply-templates select="list_voucher"/>
+ </xsl:when>
+ <xsl:when test="list_voucher_paid">
+ <xsl:apply-templates
select="list_voucher_paid"/>
+ </xsl:when>
+ <xsl:when test="consume">
+ <xsl:apply-templates select="consume"/>
+ </xsl:when>
+ <xsl:when test="remark">
+ <xsl:apply-templates select="remark"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="list_invoice_sub"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="edit_period">
+ <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
+ <form method="post" action="{$form_action}">
+ <div align="center">
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <xsl:choose>
+ <xsl:when test="msgbox_data != ''">
+ <tr>
+ <td align="left" colspan="3">
+ <xsl:call-template
name="msgbox"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <tr>
+ <td>
+ <xsl:variable name="select_name"><xsl:value-of
select="select_name"/></xsl:variable>
+ <select name="{$select_name}" class="forms" >
+ <xsl:apply-templates
select="period_list"/>
+ </select>
+ </td>
+ </tr>
+ <tr height="50">
+ <td>
+ <xsl:variable
name="lang_save"><xsl:value-of select="lang_save"/></xsl:variable>
+ <input type="submit" name="submit"
value="{$lang_save}" >
+ </input>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </form>
+ </xsl:template>
+
+ <xsl:template match="period_list">
+ <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="name"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="name"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <xsl:template match="remark">
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <tr>
+ <td colspan="2" align="center">
+ <xsl:value-of select="message"/>
+ </td>
+ </tr>
+ <tr>
+ <td align="center">
+ <textarea cols="60" rows="15"
name="remark" readonly="readonly" wrap="virtual"
onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_content_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ <xsl:value-of select="remark"/>
+ </textarea>
+ </td>
+ </tr>
+
+ </table>
+ </xsl:template>
+
+ <xsl:template name="excel">
+ <xsl:variable name="link_excel"><xsl:value-of
select="link_excel"/></xsl:variable>
+ <xsl:variable name="lang_excel_help"><xsl:value-of
select="lang_excel_help"/></xsl:variable>
+ <xsl:variable name="lang_excel"><xsl:value-of
select="lang_excel"/></xsl:variable>
+ <a href="javascript:var
w=window.open('{$link_excel}','','')"
+ onMouseOver="overlib('{$lang_excel_help}',
CAPTION, '{$lang_excel}')"
+ onMouseOut="nd()">
+ <xsl:value-of select="lang_excel"/></a>
+ </xsl:template>
+
+
+<!-- list_voucher -->
+
+ <xsl:template match="list_voucher">
+ <div id="overDiv" style="position:absolute;
visibility:hide;z-index:1;"></div>
+ <xsl:variable name="overlib_source"><xsl:value-of
select="overlib_source"/></xsl:variable>
+ <SCRIPT LANGUAGE="JavaScript" SRC="{$overlib_source}"></SCRIPT>
+ <xsl:variable name="check_source"><xsl:value-of
select="check_source"/></xsl:variable>
+ <SCRIPT LANGUAGE="JavaScript" SRC="{$check_source}"></SCRIPT>
+ <xsl:call-template name="menu"/>
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <xsl:choose>
+ <xsl:when test="msgbox_data != ''">
+ <tr>
+ <td align="left" colspan="3">
+ <xsl:call-template
name="msgbox"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+
+ <tr>
+ <td>
+ <xsl:call-template name="cat_filter"/>
+ </td>
+ <td align="center">
+ <xsl:call-template
name="user_lid_filter"/>
+ </td>
+ <td align="right">
+ <xsl:call-template name="search_field"/>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3" width="100%">
+ <xsl:call-template name="nextmatchs"/>
+ </td>
+ <td colspan="3" width="100%" class="small_text"
valign="top" align="left">
+ <xsl:call-template name="excel"/>
+ </td>
+ </tr>
+ </table>
+ <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
+ <form method="post" name="form" action="{$form_action}">
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <xsl:apply-templates
select="table_header_list_voucher"/>
+
+ <xsl:choose>
+ <xsl:when
test="values_list_voucher[voucher_id]">
+ <xsl:apply-templates
select="values_list_voucher"/>
+
+ </xsl:when>
+ </xsl:choose>
+ <xsl:variable name="img_check"><xsl:value-of
select="img_check"/></xsl:variable>
+ <tr>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td class="small_text" align="right">
+ <xsl:value-of select="sum"/>
+ </td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td align="center">
+ <a
href="javascript:check_all_radio('sign_none')"><img src="{$img_check}"
border="0" height="16" width="21" alt="{lang_select_all}"/></a>
+ </td>
+ <td align="center">
+ <a
href="javascript:check_all_radio('sign_janitor')"><img src="{$img_check}"
border="0" height="16" width="21" alt="{lang_select_all}"/></a>
+ </td>
+ <td align="center">
+ <a
href="javascript:check_all_radio('sign_supervisor')"><img src="{$img_check}"
border="0" height="16" width="21" alt="{lang_select_all}"/></a>
+ </td>
+ <td align="center">
+ <a
href="javascript:check_all_radio('sign_budget_responsible')"><img
src="{$img_check}" border="0" height="16" width="21"
alt="{lang_select_all}"/></a>
+ </td>
+ <td align="right">
+ <a
href="javascript:check_all_checkbox('values[transfer]')"><img
src="{$img_check}" border="0" height="16" width="21"
alt="{lang_select_all}"/></a>
+ </td>
+ </tr>
+
+ <tr height="50">
+ <td>
+ <xsl:variable
name="lang_save"><xsl:value-of select="lang_save"/></xsl:variable>
+ <input type="submit"
name="values[save]" value="{$lang_save}" onMouseout="window.status='';return
true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_save_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+
+ </table>
+ </form>
+ <xsl:choose>
+ <xsl:when test="table_add_invoice !=''">
+ <xsl:apply-templates
select="table_add_invoice"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="table_add_invoice">
+ <table align = "left">
+ <tr>
+ <td height="50" align="left" valign="top">
+ <xsl:variable
name="add_action"><xsl:value-of select="add_action"/></xsl:variable>
+ <xsl:variable
name="lang_add"><xsl:value-of select="lang_add"/></xsl:variable>
+ <form method="post"
action="{$add_action}">
+ <input type="submit" name=""
value="{$lang_add}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="lang_add_statustext"/>
+ <xsl:text>';
return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </form>
+ </td>
+ </tr>
+ </table>
+ </xsl:template>
+
+
+ <xsl:template match="table_header_list_voucher">
+ <xsl:variable name="sort_voucher"><xsl:value-of
select="sort_voucher"/></xsl:variable>
+ <xsl:variable name="sort_voucher_date"><xsl:value-of
select="sort_voucher_date"/></xsl:variable>
+ <xsl:variable name="sort_vendor_id"><xsl:value-of
select="sort_vendor_id"/></xsl:variable>
+ <tr class="th">
+ <td class="th_text" width="5%" align="right">
+ <a href="{$sort_voucher}"><xsl:value-of
select="lang_voucher"/></a>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <a
href="{$sort_voucher_date}"><xsl:value-of select="lang_voucher_date"/></a>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <xsl:value-of select="lang_days"/>
+ </td>
+ <td class="th_text" width="8%" align="right">
+ <xsl:value-of select="lang_sum"/>
+ </td>
+ <td class="th_text" width="4%" align="right">
+ <a
href="{$sort_vendor_id}"><xsl:value-of select="lang_vendor_id"/></a>
+ </td>
+ <td class="th_text" width="3%" align="right">
+ <xsl:value-of
select="lang_num_sub_invoice"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of select="lang_type"/>
+ </td>
+ <td class="th_text" width="3%" align="right">
+ <xsl:value-of select="lang_period"/>
+ </td>
+ <td class="th_text" width="3%" align="right">
+ <xsl:value-of select="lang_kredit"/>
+ </td>
+ <td class="th_text" width="3%" align="right">
+ <xsl:value-of select="lang_none"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of select="lang_janitor"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of select="lang_supervisor"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of
select="lang_budget_responsible"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of select="lang_transfer"/>
+ </td>
+ <xsl:choose>
+ <xsl:when test="//acl_delete!=''">
+ <td class="th_text" width="5%"
align="center">
+ <xsl:value-of
select="lang_delete"/>
+ </td>
+ </xsl:when>
+ </xsl:choose>
+ </tr>
+ </xsl:template>
+
+ <xsl:template match="values_list_voucher">
+
+ <xsl:variable name="counter"><xsl:value-of
select="counter"/></xsl:variable>
+ <xsl:variable name="current_user"><xsl:value-of
select="current_user"/></xsl:variable>
+ <tr>
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="@class">
+ <xsl:value-of
select="@class"/>
+ </xsl:when>
+ <xsl:when test="position() mod
2 = 0">
+
<xsl:text>row_off</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+
<xsl:text>row_on</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+
+ <td class="small_text" align="right">
+ <input type="hidden"
name="values[counter][{$counter}]" value="{counter}">
+ </input>
+ <input type="hidden"
name="values[voucher_id][{$counter}]" value="{voucher_id}">
+ </input>
+ <xsl:variable
name="link_sub"><xsl:value-of select="link_sub"/>&voucher_id=<xsl:value-of
select="voucher_id"/></xsl:variable>
+ <xsl:variable
name="lang_sub_help"><xsl:value-of select="lang_sub_help"/></xsl:variable>
+ <xsl:variable
name="lang_sub"><xsl:value-of select="lang_sub"/></xsl:variable>
+ <a href="{$link_sub}"
+
onMouseOver="overlib('{$lang_sub_help}', CAPTION, '{$lang_sub}')"
+ onMouseOut="nd()">
+ <xsl:value-of select="voucher_id"/></a>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:variable
name="lang_payment_date"><xsl:value-of
select="lang_payment_date"/></xsl:variable>
+ <xsl:variable
name="payment_date"><xsl:value-of select="payment_date"/></xsl:variable>
+ <a href="javascript:void()"
+ onMouseOver="overlib('{$payment_date}',
CAPTION, '{$lang_payment_date}')"
+ onMouseOut="nd()">
+ <xsl:value-of
select="voucher_date"/></a>
+ </td>
+ <td class="small_text" align="right">
+ <input type="hidden"
name="values[sign_orig][{$counter}]" value="{sign_orig}">
+ </input>
+ <input type="hidden"
name="values[num_days_orig][{$counter}]" value="{num_days}">
+ </input>
+ <input type="hidden"
name="values[timestamp_voucher_date][{$counter}]"
value="{timestamp_voucher_date}">
+ </input>
+ <input type="text" size="2"
name="values[num_days][{$counter}]" value="{num_days}">
+ </input>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:value-of select="amount"/>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:variable
name="vendor"><xsl:value-of select="vendor"/></xsl:variable>
+ <xsl:variable
name="vendor_id"><xsl:value-of select="vendor_id"/></xsl:variable>
+ <a href="javascript:void()"
+ onMouseOver="overlib('{$vendor}',
CAPTION, '{$vendor_id}')"
+ onMouseOut="nd()">
+ <xsl:value-of select="vendor_id"/></a>
+
+ </td>
+ <td class="small_text" align="right">
+ <input type="hidden"
name="values[invoice_count][{$counter}]" value="{invoice_count}">
+ </input>
+ <xsl:value-of select="invoice_count"/>
+ </td>
+ <td class="small_text" align="center">
+ <xsl:value-of select="type"/>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:variable
name="link_period"><xsl:value-of
select="link_period"/>&voucher_id=<xsl:value-of
select="voucher_id"/>&period=<xsl:value-of select="period"/></xsl:variable>
+ <xsl:variable
name="lang_period_help"><xsl:value-of select="lang_period_help"/></xsl:variable>
+ <xsl:variable
name="lang_period"><xsl:value-of select="lang_period"/></xsl:variable>
+ <a href="javascript:var
w=window.open('{$link_period}','','width=150,height=150')"
+
onMouseOver="overlib('{$lang_period_help}', CAPTION, '{$lang_period}')"
+ onMouseOut="nd()">
+ <xsl:value-of select="period"/></a>
+ </td>
+ <td align="center">
+ <xsl:choose>
+ <xsl:when test="kreditnota='1'">
+ <input type="checkbox"
name="values[kreditnota][{$counter}]" value="true" checked="checked"
onMouseout="window.status='';return true;">
+ </input>
+ </xsl:when>
+ <xsl:otherwise>
+ <input type="checkbox"
name="values[kreditnota][{$counter}]" value="true"
onMouseout="window.status='';return true;">
+ </input>
+ </xsl:otherwise>
+ </xsl:choose>
+ </td>
+ <td class="small_text" align="center">
+ <xsl:choose>
+ <xsl:when test="is_janitor">
+ <input type="radio"
name="values[sign][{$counter}]" value="sign_none"
onMouseout="window.status='';return true;">
+ </input>
+ </xsl:when>
+ <xsl:when test="is_supervisor">
+ <input type="radio"
name="values[sign][{$counter}]" value="sign_none"
onMouseout="window.status='';return true;">
+ </input>
+ </xsl:when>
+ <xsl:when
test="is_budget_responsible">
+ <input type="radio"
name="values[sign][{$counter}]" value="sign_none"
onMouseout="window.status='';return true;">
+ </input>
+ </xsl:when>
+ <xsl:otherwise>
+ </xsl:otherwise>
+ </xsl:choose>
+ </td>
+ <td class="small_text" align="right">
+
+ <xsl:choose>
+ <xsl:when
test="is_janitor='32'">
+ <xsl:choose>
+ <xsl:when
test="jan_date=''">
+ <input
type="radio" name="values[sign][{$counter}]" value="sign_janitor"
onMouseout="window.status='';return true;">
+
</input>
+ </xsl:when>
+ <xsl:otherwise>
+
<xsl:choose>
+
<xsl:when test="janitor = $current_user">
+
<input type="radio" name="values[sign][{$counter}]"
value="sign_janitor" checked="checked" onMouseout="window.status='';return
true;">
+
</input>
+
</xsl:when>
+
<xsl:otherwise>
+
<input type="checkbox" name="" value="" checked="checked"
disabled="disabled" ></input>
+
</xsl:otherwise>
+
</xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when
test="jan_date=''">
+ </xsl:when>
+ <xsl:otherwise>
+ <input
type="checkbox" name="" value="" checked="checked" disabled="disabled" ></input>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:value-of select="janitor"/>
+ </td>
+ <td class="small_text" align="right">
+
+ <xsl:choose>
+ <xsl:when
test="is_supervisor='64'"><xsl:value-of select="super_date"/>
+ <xsl:choose>
+ <xsl:when
test="super_date=''">
+ <input
type="radio" name="values[sign][{$counter}]" value="sign_supervisor"
onMouseout="window.status='';return true;">
+
</input>
+ </xsl:when>
+ <xsl:when
test="super_date!=''">
+
<xsl:choose>
+
<xsl:when test="supervisor = $current_user">
+
<input type="radio" name="values[sign][{$counter}]"
value="sign_supervisor" checked="checked" onMouseout="window.status='';return
true;">
+
</input>
+
</xsl:when>
+
<xsl:otherwise>
+
<input type="checkbox" name="" value="" checked="checked"
disabled="disabled" ></input>
+
</xsl:otherwise>
+
</xsl:choose>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when
test="super_date=''">
+ </xsl:when>
+ <xsl:otherwise>
+ <input
type="checkbox" name="" value="" checked="checked" disabled="disabled" ></input>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:value-of select="supervisor"/>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:choose>
+ <xsl:when
test="is_budget_responsible='128'">
+ <xsl:choose>
+ <xsl:when
test="budget_date=''">
+ <input
type="radio" name="values[sign][{$counter}]" value="sign_budget_responsible"
onMouseout="window.status='';return true;">
+
</input>
+ </xsl:when>
+ <xsl:otherwise>
+
<xsl:choose>
+
<xsl:when test="budget_responsible = $current_user">
+
<input type="radio" name="values[sign][{$counter}]"
value="sign_budget_responsible" checked="checked"
onMouseout="window.status='';return true;">
+
</input>
+
</xsl:when>
+
<xsl:otherwise>
+
<input type="checkbox" name="" value="" checked="checked"
disabled="disabled" ></input>
+
</xsl:otherwise>
+
</xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when
test="budget_date=''">
+ </xsl:when>
+ <xsl:otherwise>
+ <input
type="checkbox" name="" value="" checked="checked" disabled="disabled" ></input>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:value-of
select="budget_responsible"/>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:choose>
+ <xsl:when
test="is_transfer='16'">
+ <xsl:choose>
+ <xsl:when
test="transfer_date=''">
+ <input
type="checkbox" name="values[transfer][{$counter}]" value="true"
onMouseout="window.status='';return true;">
+ </input>
+ </xsl:when>
+ <xsl:otherwise>
+ <input
type="checkbox" name="values[transfer][{$counter}]" value="true"
checked="checked" onMouseout="window.status='';return true;">
+
</input>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when
test="transfer_id!=''">
+ <input
type="checkbox" name="" value="" checked="checked" disabled="disabled" ></input>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:value-of select="transfer_id"/>
+ </td>
+ <xsl:choose>
+ <xsl:when test="//acl_delete!=''">
+ <xsl:variable
name="lang_delete_statustext"><xsl:value-of
select="lang_delete_statustext"/></xsl:variable>
+ <td class="small_text"
align="center">
+ <xsl:variable
name="link_delete"><xsl:value-of select="link_delete"/></xsl:variable>
+ <a href="{$link_delete}"
onMouseover="window.status='{$lang_delete_statustext}';return true;"
onMouseout="window.status='';return true;"><xsl:value-of
select="text_delete"/></a>
+ </td>
+ </xsl:when>
+ </xsl:choose>
+ </tr>
+ </xsl:template>
+
+
+
+<!-- list_voucher_paid -->
+
+ <xsl:template match="list_voucher_paid">
+ <div id="overDiv" style="position:absolute;
visibility:hide;z-index:1;"></div>
+ <xsl:variable name="overlib_source"><xsl:value-of
select="overlib_source"/></xsl:variable>
+ <SCRIPT LANGUAGE="JavaScript" SRC="{$overlib_source}"></SCRIPT>
+
+ <script language="JavaScript">
+ self.name="first_Window";
+ function abook()
+ {
+ Window1=window.open('<xsl:value-of
select="addressbook_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
+ }
+ function property_lookup()
+ {
+ Window1=window.open('<xsl:value-of
select="property_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
+ }
+ </script>
+
+ <xsl:call-template name="menu"/>
+ <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
+ <div align="left">
+ <form method="post" name="form" action="{$form_action}">
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <xsl:choose>
+ <xsl:when test="msgbox_data != ''">
+ <tr>
+ <td align="left" colspan="3">
+ <xsl:call-template
name="msgbox"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+
+ <tr>
+ <td>
+ <input type="text" id="start_date"
name="start_date" size="10" value="{start_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_start_date_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ <script type="text/javascript">
+ document.writeln('<img
id="start_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
+ <xsl:value-of
select="calendar_setup_start"/>
+ </script>
+ </td>
+ <td>
+ <input type="text" id="end_date"
name="end_date" size="10" value="{end_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_end_date_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ <script type="text/javascript">
+ document.writeln('<img
id="end_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
+ <xsl:value-of
select="calendar_setup_end"/>
+ </script>
+ </td>
+ <td>
+ <input type="text" size="8"
name="workorder_id" value="{workorder_id}" onMouseout="window.status='';return
true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_workorder_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ <a href="javascript:void()"
+
onMouseOver="overlib('{lang_workorder_statustext}', CAPTION,
'{lang_workorder}')"
+ onMouseOut="nd()">
+ <xsl:value-of
select="lang_workorder"/></a>
+ </td>
+
+ <td align="left">
+ <input type="text" name="vendor_id"
value="{vendor_id}" size="4" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_vendor_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ <a href="javascript:abook()"
+
onMouseOver="overlib('{lang_select_vendor_statustext}', CAPTION,
'{lang_vendor}')"
+ onMouseOut="nd()">
+ <xsl:value-of
select="lang_vendor"/></a>
+
+ <input type="hidden"
name="vendor_name"></input>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <xsl:call-template name="cat_select"/>
+ </td>
+ <td align="left">
+ <xsl:call-template
name="user_lid_select"/>
+ </td>
+ <td align="left">
+ <input type="text" name="loc1"
value="{loc1}" size="4" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_property_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ <a href="javascript:property_lookup()"
+
onMouseOver="overlib('{lang_select_property_statustext}', CAPTION,
'{lang_property}')"
+ onMouseOut="nd()">
+ <xsl:value-of
select="lang_property"/></a>
+
+ <input type="hidden"
name="loc1_name"></input>
+ </td>
+
+ <td align="left">
+ <input type="text" name="voucher_id"
value="{voucher_id}" size="8" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_voucher_id_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="lang_voucher_id"/>
+ </td>
+
+ <td align="left">
+ <xsl:variable
name="lang_search"><xsl:value-of select="lang_search"/></xsl:variable>
+ <input type="submit"
name="submit_search" value="{$lang_search}" onMouseout="window.status='';return
true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_search_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="11" width="100%">
+ <xsl:call-template name="nextmatchs"/>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <xsl:apply-templates
select="table_header_list_voucher_paid"/>
+
+ <xsl:choose>
+ <xsl:when
test="values_list_voucher_paid[voucher_id]">
+ <xsl:apply-templates
select="values_list_voucher_paid"/>
+ <tr>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td class="th_text"
align="right">
+ <xsl:value-of
select="sum"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:variable name="img_check"><xsl:value-of
select="img_check"/></xsl:variable>
+ </table>
+ </xsl:template>
+
+
+ <xsl:template match="table_header_list_voucher_paid">
+ <xsl:variable name="sort_voucher"><xsl:value-of
select="sort_voucher"/></xsl:variable>
+ <xsl:variable name="sort_voucher_date"><xsl:value-of
select="sort_voucher_date"/></xsl:variable>
+ <xsl:variable name="sort_vendor_id"><xsl:value-of
select="sort_vendor_id"/></xsl:variable>
+ <tr class="th">
+ <td class="th_text" width="5%" align="right">
+ <a href="{$sort_voucher}"><xsl:value-of
select="lang_voucher"/></a>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <a
href="{$sort_voucher_date}"><xsl:value-of select="lang_voucher_date"/></a>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <xsl:value-of select="lang_days"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of select="lang_sum"/>
+ </td>
+ <td class="th_text" width="4%" align="right">
+ <a
href="{$sort_vendor_id}"><xsl:value-of select="lang_vendor_id"/></a>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of
select="lang_num_sub_invoice"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of select="lang_type"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of select="lang_janitor"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of select="lang_supervisor"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of
select="lang_budget_responsible"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of select="lang_transfer"/>
+ </td>
+ </tr>
+ </xsl:template>
+
+ <xsl:template match="values_list_voucher_paid">
+
+ <xsl:variable name="counter"><xsl:value-of
select="counter"/></xsl:variable>
+ <xsl:variable name="current_user"><xsl:value-of
select="current_user"/></xsl:variable>
+ <tr>
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="@class">
+ <xsl:value-of
select="@class"/>
+ </xsl:when>
+ <xsl:when test="position() mod
2 = 0">
+
<xsl:text>row_off</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+
<xsl:text>row_on</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+
+ <td align="right">
+ <xsl:variable
name="link_sub"><xsl:value-of select="link_sub"/>&voucher_id=<xsl:value-of
select="voucher_id"/>&paid=true</xsl:variable>
+ <xsl:variable
name="lang_sub_help"><xsl:value-of select="lang_sub_help"/></xsl:variable>
+ <xsl:variable
name="lang_sub"><xsl:value-of select="lang_sub"/></xsl:variable>
+ <a href="{$link_sub}"
+
onMouseOver="overlib('{$lang_sub_help}', CAPTION, '{$lang_sub}')"
+ onMouseOut="nd()">
+ <xsl:value-of select="voucher_id"/></a>
+ </td>
+ <td align="right">
+ <xsl:variable
name="lang_payment_date"><xsl:value-of
select="lang_payment_date"/></xsl:variable>
+ <xsl:variable
name="payment_date"><xsl:value-of select="payment_date"/></xsl:variable>
+ <a href="javascript:void()"
+ onMouseOver="overlib('{$payment_date}',
CAPTION, '{$lang_payment_date}')"
+ onMouseOut="nd()">
+ <xsl:value-of
select="voucher_date"/></a>
+ </td>
+ <td align="right">
+ <xsl:value-of select="num_days"/>
+ </td>
+ <td align="right">
+ <xsl:value-of select="amount"/>
+ </td>
+ <td align="right">
+ <xsl:variable
name="vendor"><xsl:value-of select="vendor"/></xsl:variable>
+ <xsl:variable
name="vendor_id"><xsl:value-of select="vendor_id"/></xsl:variable>
+ <a href="javascript:void()"
+ onMouseOver="overlib('{$vendor}',
CAPTION, '{$vendor_id}')"
+ onMouseOut="nd()">
+ <xsl:value-of select="vendor_id"/></a>
+
+ </td>
+ <td align="right">
+ <xsl:value-of select="invoice_count"/>
+ </td>
+ <td align="center">
+ <xsl:value-of select="type"/>
+ </td>
+ <td align="center">
+ <xsl:value-of select="jan_date"/> -
<xsl:value-of select="janitor"/>
+ </td>
+ <td align="center">
+ <xsl:value-of select="super_date"/> -
<xsl:value-of select="supervisor"/>
+ </td>
+ <td align="center">
+ <xsl:value-of select="budget_date"/> -
<xsl:value-of select="budget_responsible"/>
+ </td>
+ <td align="center">
+ <xsl:value-of select="transfer_date"/>
- <xsl:value-of select="transfer_id"/>
+ </td>
+ </tr>
+ </xsl:template>
+
+
+<!-- consume -->
+
+ <xsl:template match="consume">
+ <div id="overDiv" style="position:absolute;
visibility:hide;z-index:1;"></div>
+ <xsl:variable name="overlib_source"><xsl:value-of
select="overlib_source"/></xsl:variable>
+ <SCRIPT LANGUAGE="JavaScript" SRC="{$overlib_source}"></SCRIPT>
+
+ <script language="JavaScript">
+ self.name="first_Window";
+ function abook()
+ {
+ Window1=window.open('<xsl:value-of
select="addressbook_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
+ }
+ function property_lookup()
+ {
+ Window1=window.open('<xsl:value-of
select="property_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
+ }
+ </script>
+
+ <xsl:call-template name="menu"/>
+ <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
+ <div align="left">
+ <form method="post" name="form" action="{$form_action}">
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <xsl:choose>
+ <xsl:when test="msgbox_data != ''">
+ <tr>
+ <td align="left" colspan="3">
+ <xsl:call-template
name="msgbox"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <tr>
+ <td>
+ <input type="text" id="start_date"
name="start_date" size="10" value="{start_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_start_date_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ <script type="text/javascript">
+ document.writeln('<img
id="start_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
+ <xsl:value-of
select="calendar_setup_start"/>
+ </script>
+ </td>
+ <td>
+ <input type="text" id="end_date"
name="end_date" size="10" value="{end_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_end_date_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ <script type="text/javascript">
+ document.writeln('<img
id="end_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
+ <xsl:value-of
select="calendar_setup_end"/>
+ </script>
+ </td>
+ <td>
+ <input type="text" size="8"
name="workorder_id" value="{workorder_id}" onMouseout="window.status='';return
true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_workorder_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ <a href="javascript:void()"
+
onMouseOver="overlib('{lang_workorder_statustext}', CAPTION,
'{lang_workorder}')"
+ onMouseOut="nd()">
+ <xsl:value-of
select="lang_workorder"/></a>
+ </td>
+
+ <td align="left">
+ <input type="text" name="vendor_id"
onClick="abook()" value="{vendor_id}" size="4"
onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_vendor_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ <a href="javascript:abook()"
+
onMouseOver="overlib('{lang_select_vendor_statustext}', CAPTION,
'{lang_vendor}')"
+ onMouseOut="nd()">
+ <xsl:value-of
select="lang_vendor"/></a>
+
+ <input type="hidden" name="vendor_name"
value="{vendor_name}"></input>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <xsl:call-template name="cat_select"/>
+ </td>
+ <td align="left">
+ <xsl:call-template
name="select_district"/>
+ </td>
+ <td align="left">
+ <xsl:variable
name="lang_account_class_statustext"><xsl:value-of
select="lang_account_class_statustext"/></xsl:variable>
+ <xsl:variable
name="select_account_class_name"><xsl:value-of
select="select_account_class_name"/></xsl:variable>
+ <select
name="{$select_account_class_name}" class="forms"
onMouseover="window.status='{$lang_account_class_statustext}'; return true;"
onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_no_account_class_"/></option>
+ <xsl:apply-templates
select="account_class_list"/>
+ </select>
+
+ </td>
+
+ <td align="left">
+ <input type="text" name="loc1"
onClick="property_lookup()" value="{loc1}" size="4"
onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_property_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ <a href="javascript:property_lookup()"
+
onMouseOver="overlib('{lang_select_property_statustext}', CAPTION,
'{lang_property}')"
+ onMouseOut="nd()">
+ <xsl:value-of
select="lang_property"/></a>
+
+ <input type="hidden"
name="loc1_name"></input>
+ </td>
+ <td align="left">
+ <xsl:variable
name="lang_search"><xsl:value-of select="lang_search"/></xsl:variable>
+ <input type="submit"
name="submit_search" value="{$lang_search}" onMouseout="window.status='';return
true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_search_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <xsl:choose>
+ <xsl:when test="vendor_name!=''">
+ <tr>
+ <td width="25%" class="th_text"
align="left">
+ <xsl:value-of
select="lang_vendor"/>
+ </td>
+ <td width="25%" class="th_text"
align="left">
+ <xsl:value-of
select="vendor_name"/>
+ </td>
+ <td width="50%">
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="loc1!=''">
+ <tr>
+ <td width="25%" class="th_text"
align="left">
+ <xsl:value-of
select="lang_property"/>
+ </td>
+ <td width="25%" class="th_text"
align="left">
+ <xsl:value-of
select="loc1"/>
+ </td>
+ <td width="50%">
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="workorder_id!=''">
+ <tr>
+ <td width="25%" class="th_text"
align="left">
+ <xsl:value-of
select="lang_workorder"/>
+ </td>
+ <td width="25%" class="th_text"
align="left">
+ <xsl:value-of
select="workorder_id"/>
+ </td>
+ <td width="50%">
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+
+ </table>
+
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <xsl:apply-templates select="table_header_consume"/>
+
+ <xsl:choose>
+ <xsl:when test="values_consume[consume]">
+ <xsl:apply-templates
select="values_consume"/>
+
+ </xsl:when>
+ </xsl:choose>
+ <tr>
+ <td>
+ </td>
+ <td>
+ </td>
+ <td class="th_text" align="right">
+ <xsl:value-of select="lang_sum"/>
+ </td>
+ <td class="th_text" align="right">
+ <xsl:value-of select="sum"/>
+ </td>
+ </tr>
+ </table>
+ </xsl:template>
+
+ <xsl:template match="account_class_list">
+ <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="id"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="id"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="table_header_consume">
+ <tr class="th">
+ <td class="th_text" width="10%" align="right">
+ <xsl:value-of select="lang_district"/>
+ </td>
+ <td class="th_text" width="10%" align="right">
+ <xsl:value-of select="lang_period"/>
+ </td>
+ <td class="th_text" width="25%" align="right">
+ <xsl:value-of
select="lang_budget_account"/>
+ </td>
+ <td class="th_text" width="55%" align="right">
+ <xsl:value-of select="lang_consume"/>
+ </td>
+ </tr>
+ </xsl:template>
+
+ <xsl:template match="values_consume">
+ <tr>
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="@class">
+ <xsl:value-of
select="@class"/>
+ </xsl:when>
+ <xsl:when test="position() mod
2 = 0">
+
<xsl:text>row_off</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+
<xsl:text>row_on</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+
+ <td align="right">
+ <xsl:value-of select="district_id"/>
+ </td>
+ <td align="center">
+ <xsl:value-of select="period"/>
+ </td>
+ <td align="center">
+ <xsl:value-of select="account_class"/>
+ </td>
+ <td align="right">
+ <xsl:value-of select="consume"/>
+ </td>
+ </tr>
+ </xsl:template>
+
+<!-- debug-->
+
+ <xsl:template match="debug">
+ <div align="left">
+ <table width="50%" cellpadding="2" cellspacing="2"
align="center">
+
+ <tr>
+ <td class="th_text">
+ <xsl:value-of select="lang_bilagsnr"/>
+ </td>
+ <td>
+ <xsl:value-of select="bilagsnr"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="th_text">
+ <xsl:value-of select="lang_type"/>
+ </td>
+ <td>
+ <xsl:value-of select="artid"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="th_text">
+ <xsl:value-of select="lang_vendor"/>
+ </td>
+ <td>
+ <xsl:value-of select="spvend_code"/>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="vendor_name"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="th_text">
+ <xsl:value-of
select="lang_fakturadato"/>
+ </td>
+ <td>
+ <xsl:value-of select="fakturadato"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="th_text">
+ <xsl:value-of
select="lang_forfallsdato"/>
+ </td>
+ <td>
+ <xsl:value-of select="forfallsdato"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="th_text">
+ <xsl:value-of select="lang_janitor"/>
+ </td>
+ <td>
+ <xsl:value-of select="oppsynsmannid"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="th_text">
+ <xsl:value-of select="lang_supervisor"/>
+ </td>
+ <td>
+ <xsl:value-of select="saksbehandlerid"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="th_text">
+ <xsl:value-of
select="lang_budget_responsible"/>
+ </td>
+ <td>
+ <xsl:value-of
select="budsjettansvarligid"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="th_text">
+ <xsl:value-of select="lang_project_id"/>
+ </td>
+ <td>
+ <xsl:value-of select="project_id"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="th_text">
+ <xsl:value-of select="lang_sum"/>
+ </td>
+ <td>
+ <xsl:value-of select="sum"/>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <tr class="th">
+ <xsl:call-template name="table_header"/>
+ </tr>
+ <xsl:call-template name="values_debug"/>
+ <xsl:apply-templates select="table_add"/>
+ </table>
+ </xsl:template>
+
+ <xsl:template name="values_debug">
+ <xsl:for-each select="values" >
+ <tr>
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="@class">
+ <xsl:value-of select="@class"/>
+ </xsl:when>
+ <xsl:when test="position() mod 2 = 0">
+ <xsl:text>row_off</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>row_on</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <xsl:for-each select="row" >
+ <td align="{align}">
+ <xsl:value-of select="value"/>
+ </td>
+ </xsl:for-each>
+ </tr>
+ </xsl:for-each>
+ </xsl:template>
+
+ <xsl:template match="table_add">
+ <tr>
+ <td height="50">
+ <xsl:variable
name="add_action"><xsl:value-of select="add_action"/></xsl:variable>
+ <xsl:variable
name="lang_add"><xsl:value-of select="lang_add"/></xsl:variable>
+ <form method="post"
action="{$add_action}">
+ <input type="submit" name="add"
value="{$lang_add}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="lang_add_statustext"/>
+ <xsl:text>';
return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </form>
+ </td>
+ <td height="50">
+ <xsl:variable
name="cancel_action"><xsl:value-of select="cancel_action"/></xsl:variable>
+ <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
+ <form method="post"
action="{$cancel_action}">
+ <input type="submit"
name="cancel" value="{$lang_cancel}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="lang_cancel_statustext"/>
+ <xsl:text>';
return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </form>
+ </td>
+ </tr>
+ </xsl:template>
+
+<!-- add / edit -->
+ <xsl:template match="add">
+
+ <script language="JavaScript">
+ self.name="first_Window";
+ function abook()
+ {
+ Window1=window.open('<xsl:value-of
select="addressbook_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
+ }
+ </script>
+
+ <xsl:call-template name="menu"/>
+ <div align="left">
+ <table cellpadding="2" cellspacing="2" width="80%"
align="center">
+ <tr>
+ <td colspan="2" align="center">
+ <xsl:value-of select="message"/>
+ </td>
+ </tr>
+ <xsl:choose>
+ <xsl:when test="msgbox_data != ''">
+ <tr>
+ <td align="left" colspan="3">
+ <xsl:call-template
name="msgbox"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
+ <form method="post" name="form" action="{$form_action}">
+
+ <tr>
+ <td>
+ <xsl:value-of select="lang_auto_tax"/>
+ </td>
+ <td>
+ <input type="checkbox" name="auto_tax"
value="True" checked="checked" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_auto_tax_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ <xsl:call-template name="location_form"/>
+ <xsl:call-template name="b_account_form"/>
+ <tr>
+ <td valign="top">
+ <xsl:variable
name="lang_vendor"><xsl:value-of select="lang_vendor"/></xsl:variable>
+ <input type="button" name="convert"
value="{$lang_vendor}" onClick="abook();" onMouseout="window.status='';return
true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_select_vendor_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ <td>
+ <input type="text" name="vendor_id"
value="{value_vendor_id}" size="4" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_vendor_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ <input type="text" name="vendor_name"
value="{value_vendor_name}" size="20" onMouseout="window.status='';return
true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_vendor_name_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_janitor"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_janitor_statustext"><xsl:value-of
select="lang_janitor_statustext"/></xsl:variable>
+ <xsl:variable
name="select_janitor"><xsl:value-of select="select_janitor"/></xsl:variable>
+ <select name="{$select_janitor}"
class="forms" onMouseover="window.status='{$lang_janitor_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_no_janitor"/></option>
+ <xsl:apply-templates
select="janitor_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_supervisor"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_supervisor_statustext"><xsl:value-of
select="lang_supervisor_statustext"/></xsl:variable>
+ <xsl:variable
name="select_supervisor"><xsl:value-of
select="select_supervisor"/></xsl:variable>
+ <select name="{$select_supervisor}"
class="forms" onMouseover="window.status='{$lang_supervisor_statustext}';
return true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_no_supervisor"/></option>
+ <xsl:apply-templates
select="supervisor_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_budget_responsible"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_budget_responsible_statustext"><xsl:value-of
select="lang_budget_responsible_statustext"/></xsl:variable>
+ <xsl:variable
name="select_budget_responsible"><xsl:value-of
select="select_budget_responsible"/></xsl:variable>
+ <select
name="{$select_budget_responsible}" class="forms"
onMouseover="window.status='{$lang_budget_responsible_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_select_budget_responsible"/></option>
+ <xsl:apply-templates
select="budget_responsible_list"/>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_order"/>
+ </td>
+ <td>
+ <input type="text" name="order"
value="{value_order}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_order_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_art"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_art_statustext"><xsl:value-of
select="lang_art_statustext"/></xsl:variable>
+ <xsl:variable
name="select_art"><xsl:value-of select="select_art"/></xsl:variable>
+ <select name="{$select_art}"
class="forms" onMouseover="window.status='{$lang_art_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_select_art"/></option>
+ <xsl:apply-templates
select="art_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_type"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_type_statustext"><xsl:value-of
select="lang_type_statustext"/></xsl:variable>
+ <xsl:variable
name="select_type"><xsl:value-of select="select_type"/></xsl:variable>
+ <select name="{$select_type}"
class="forms" onMouseover="window.status='{$lang_type_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_no_type"/></option>
+ <xsl:apply-templates
select="type_list"/>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_dimb"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_dimb_statustext"><xsl:value-of
select="lang_dimb_statustext"/></xsl:variable>
+ <xsl:variable
name="select_dimb"><xsl:value-of select="select_dimb"/></xsl:variable>
+ <select name="{$select_dimb}"
class="forms" onMouseover="window.status='{$lang_dimb_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_no_dimb"/></option>
+ <xsl:apply-templates
select="dimb_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_invoice_number"/>
+ </td>
+ <td>
+ <input type="text" name="invoice_num"
value="{value_invoice_num}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_invoice_num_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_kidnr"/>
+ </td>
+ <td>
+ <input type="text" name="kid_nr"
value="{value_kid_nr}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_kid_nr_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_amount"/>
+ </td>
+ <td>
+ <input type="text" name="amount"
value="{value_amount}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_amount_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_invoice_date"/>
+ </td>
+ <td>
+ <input type="text" id="invoice_date"
name="invoice_date" size="10" value="{value_invoice_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_invoice_date_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ <script type="text/javascript">
+ document.writeln('<img
id="invoice_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
+ <xsl:value-of
select="calendar_setup_invoice"/>
+ </script>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_no_of_days"/>
+ </td>
+ <td>
+ <input type="text" name="num_days"
value="{value_num_days}" size="4" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_num_days_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ </td>
+ </tr>
+
+ <tr>
+
+ <td valign="top">
+ <xsl:value-of
select="lang_payment_date"/>
+ </td>
+ <td>
+ <input type="text" id="payment_date"
name="payment_date" size="10" value="{value_payment_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_payment_date_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ <script type="text/javascript">
+ document.writeln('<img
id="payment_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
+ <xsl:value-of
select="calendar_setup_payment"/>
+ </script>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_merknad"/>
+ </td>
+ <td>
+ <textarea cols="60" rows="10"
name="merknad" wrap="virtual" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_merknad_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ <xsl:value-of
select="value_merknad"/>
+ </textarea>
+
+ </td>
+ </tr>
+
+ <tr height="50">
+ <td>
+ <xsl:variable
name="lang_add"><xsl:value-of select="lang_add"/></xsl:variable>
+ <input type="submit" name="add_invoice"
value="{$lang_add}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_add_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ </form>
+ <tr>
+ <td>
+ <xsl:variable
name="cancel_action"><xsl:value-of select="cancel_action"/></xsl:variable>
+ <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
+ <form method="post"
action="{$cancel_action}">
+ <input type="submit"
name="done" value="{$lang_cancel}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="lang_cancel_statustext"/>
+ <xsl:text>';
return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </form>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </xsl:template>
+
+<!-- import -->
+
+ <xsl:template match="import">
+
+ <script language="JavaScript">
+ self.name="first_Window";
+ function abook()
+ {
+ Window1=window.open('<xsl:value-of
select="addressbook_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
+ }
+ </script>
+
+ <xsl:call-template name="menu"/>
+ <div align="left">
+ <table cellpadding="2" cellspacing="2" width="80%"
align="center">
+ <tr>
+ <td colspan="2" align="center">
+ <xsl:value-of select="message"/>
+ </td>
+ </tr>
+ <xsl:choose>
+ <xsl:when test="msgbox_data != ''">
+ <tr>
+ <td align="left" colspan="3">
+ <xsl:call-template
name="msgbox"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
+ <form ENCTYPE="multipart/form-data" method="post"
name="form" action="{$form_action}">
+
+ <tr>
+ <td>
+ <xsl:value-of select="lang_auto_tax"/>
+ </td>
+ <td>
+ <input type="checkbox" name="auto_tax"
value="True" checked="checked" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_auto_tax_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_art"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_art_statustext"><xsl:value-of
select="lang_art_statustext"/></xsl:variable>
+ <xsl:variable
name="select_art"><xsl:value-of select="select_art"/></xsl:variable>
+ <select name="{$select_art}"
class="forms" onMouseover="window.status='{$lang_art_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_select_art"/></option>
+ <xsl:apply-templates
select="art_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_type"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_type_statustext"><xsl:value-of
select="lang_type_statustext"/></xsl:variable>
+ <xsl:variable
name="select_type"><xsl:value-of select="select_type"/></xsl:variable>
+ <select name="{$select_type}"
class="forms" onMouseover="window.status='{$lang_type_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_no_type"/></option>
+ <xsl:apply-templates
select="type_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_dimb"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_dimb_statustext"><xsl:value-of
select="lang_dimb_statustext"/></xsl:variable>
+ <xsl:variable
name="select_dimb"><xsl:value-of select="select_dimb"/></xsl:variable>
+ <select name="{$select_dimb}"
class="forms" onMouseover="window.status='{$lang_dimb_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_no_dimb"/></option>
+ <xsl:apply-templates
select="dimb_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_invoice_number"/>
+ </td>
+ <td>
+ <input type="text" name="invoice_num"
value="{value_invoice_num}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_invoice_num_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_kidnr"/>
+ </td>
+ <td>
+ <input type="text" name="kid_nr"
value="{value_kid_nr}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_kid_nr_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:variable
name="lang_vendor"><xsl:value-of select="lang_vendor"/></xsl:variable>
+ <input type="button" name="convert"
value="{$lang_vendor}" onClick="abook();" onMouseout="window.status='';return
true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_select_vendor_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ <td>
+ <input type="text" name="vendor_id"
value="{value_vendor_id}" size="6" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_vendor_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ <input type="text" name="vendor_name"
value="{value_vendor_name}" size="20" onMouseout="window.status='';return
true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_vendor_name_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_janitor"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_janitor_statustext"><xsl:value-of
select="lang_janitor_statustext"/></xsl:variable>
+ <xsl:variable
name="select_janitor"><xsl:value-of select="select_janitor"/></xsl:variable>
+ <select name="{$select_janitor}"
class="forms" onMouseover="window.status='{$lang_janitor_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_no_janitor"/></option>
+ <xsl:apply-templates
select="janitor_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_supervisor"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_supervisor_statustext"><xsl:value-of
select="lang_supervisor_statustext"/></xsl:variable>
+ <xsl:variable
name="select_supervisor"><xsl:value-of
select="select_supervisor"/></xsl:variable>
+ <select name="{$select_supervisor}"
class="forms" onMouseover="window.status='{$lang_supervisor_statustext}';
return true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_no_supervisor"/></option>
+ <xsl:apply-templates
select="supervisor_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_budget_responsible"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_budget_responsible_statustext"><xsl:value-of
select="lang_budget_responsible_statustext"/></xsl:variable>
+ <xsl:variable
name="select_budget_responsible"><xsl:value-of
select="select_budget_responsible"/></xsl:variable>
+ <select
name="{$select_budget_responsible}" class="forms"
onMouseover="window.status='{$lang_budget_responsible_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_select_budget_responsible"/></option>
+ <xsl:apply-templates
select="budget_responsible_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_invoice_date"/>
+ </td>
+ <td>
+ <input type="text" id="invoice_date"
name="invoice_date" size="10" value="{value_invoice_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_invoice_date_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ <script type="text/javascript">
+ document.writeln('<img
id="invoice_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
+ <xsl:value-of
select="calendar_setup_invoice"/>
+ </script>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_no_of_days"/>
+ </td>
+ <td>
+ <input type="text" name="num_days"
value="{value_num_days}" size="4" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_num_days_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ </td>
+ </tr>
+
+ <tr>
+
+ <td valign="top">
+ <xsl:value-of
select="lang_payment_date"/>
+ </td>
+ <td>
+ <input type="text" id="payment_date"
name="payment_date" size="10" value="{value_payment_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_payment_date_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ <script type="text/javascript">
+ document.writeln('<img
id="payment_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
+ <xsl:value-of
select="calendar_setup_payment"/>
+ </script>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_file"/>
+ </td>
+ <td>
+ <input type="file" name="tsvfile"
onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_file_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_conv"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_conv_statustext"><xsl:value-of
select="lang_conv_statustext"/></xsl:variable>
+ <xsl:variable
name="select_conv"><xsl:value-of select="select_conv"/></xsl:variable>
+ <select name="{$select_conv}"
class="forms" onMouseover="window.status='{$lang_conv_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_select_conversion"/></option>
+ <xsl:apply-templates
select="conv_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <xsl:value-of select="lang_debug"/>
+ </td>
+ <td>
+ <input type="checkbox" name="download"
value="True" checked="checked" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_debug_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ <tr height="50">
+ <td>
+ <xsl:variable
name="lang_import"><xsl:value-of select="lang_import"/></xsl:variable>
+ <input type="submit" name="convert"
value="{$lang_import}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_import_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ </form>
+ <tr>
+ <td>
+ <xsl:variable
name="cancel_action"><xsl:value-of select="cancel_action"/></xsl:variable>
+ <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
+ <form method="post"
action="{$cancel_action}">
+ <input type="submit"
name="done" value="{$lang_cancel}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="lang_cancel_statustext"/>
+ <xsl:text>';
return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </form>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </xsl:template>
+
+<!-- art_list -->
+
+ <xsl:template match="art_list">
+ <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="num"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="num"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- type_list -->
+
+ <xsl:template match="type_list">
+ <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="num"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="num"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- dimb_list -->
+
+ <xsl:template match="dimb_list">
+ <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="num"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="num"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+<!-- janitor_list -->
+
+ <xsl:template match="janitor_list">
+ <xsl:variable name="lid"><xsl:value-of select="lid"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$lid}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="firstname"/> <xsl:value-of select="lastname"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$lid}"><xsl:value-of
disable-output-escaping="yes" select="firstname"/> <xsl:value-of
select="lastname"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- supervisor_list -->
+
+ <xsl:template match="supervisor_list">
+ <xsl:variable name="lid"><xsl:value-of select="lid"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$lid}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="firstname"/> <xsl:value-of select="lastname"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$lid}"><xsl:value-of
disable-output-escaping="yes" select="firstname"/> <xsl:value-of
select="lastname"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- budget_responsible_list -->
+
+ <xsl:template match="budget_responsible_list">
+ <xsl:variable name="lid"><xsl:value-of select="lid"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$lid}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="firstname"/> <xsl:value-of select="lastname"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$lid}"><xsl:value-of
disable-output-escaping="yes" select="firstname"/> <xsl:value-of
select="lastname"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+<!-- conv_list -->
+
+ <xsl:template match="conv_list">
+ <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="name"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="name"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- rollback_file_list -->
+
+ <xsl:template match="rollback_file_list">
+ <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="name"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="name"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- tax_code_list -->
+
+ <xsl:template match="tax_code_list">
+ <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="id"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="id"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- export -->
+
+ <xsl:template match="export">
+ <xsl:call-template name="menu"/>
+ <div align="left">
+ <table cellpadding="2" cellspacing="2" width="80%"
align="center">
+ <xsl:choose>
+ <xsl:when test="msgbox_data != ''">
+ <tr>
+ <td align="left" colspan="3">
+ <xsl:call-template
name="msgbox"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
+ <form method="post" name="form" action="{$form_action}">
+
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_select_conv"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_conv_statustext"><xsl:value-of
select="lang_conv_statustext"/></xsl:variable>
+ <xsl:variable
name="select_conv"><xsl:value-of select="select_conv"/></xsl:variable>
+ <select name="{$select_conv}"
class="forms" onMouseover="window.status='{$lang_conv_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_select_conv"/></option>
+ <xsl:apply-templates
select="conv_list"/>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_force_period_year"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_force_period_year_statustext"><xsl:value-of
select="lang_force_period_year_statustext"/></xsl:variable>
+ <select
name="values[force_period_year]" class="forms"
onMouseover="window.status='{$lang_force_period_year_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_select_year"/></option>
+ <xsl:apply-templates
select="force_period_year"/>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <xsl:value-of
select="lang_export_to_file"/>
+ </td>
+ <td>
+ <input type="checkbox"
name="values[download]" value="on" checked="checked"
onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_debug_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ </td>
+ <td>
+ <xsl:variable
name="link_rollback_file"><xsl:value-of
select="link_rollback_file"/></xsl:variable>
+ <a
href="{$link_rollback_file}"><xsl:value-of select="lang_rollback_file"/></a>
+ </td>
+ </tr>
+
+ <tr height="50">
+ <td>
+ <xsl:variable
name="lang_submit"><xsl:value-of select="lang_submit"/></xsl:variable>
+ <input type="submit"
name="values[submit]" value="{$lang_submit}"
onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_import_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ </form>
+ <tr>
+ <td>
+ <xsl:variable
name="cancel_action"><xsl:value-of select="cancel_action"/></xsl:variable>
+ <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
+ <form method="post"
action="{$cancel_action}">
+ <input type="submit"
name="done" value="{$lang_cancel}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="lang_cancel_statustext"/>
+ <xsl:text>';
return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </form>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </xsl:template>
+
+
+<!-- rollback -->
+
+ <xsl:template match="rollback">
+ <xsl:call-template name="menu"/>
+ <div align="left">
+ <table cellpadding="2" cellspacing="2" width="80%"
align="center">
+ <xsl:choose>
+ <xsl:when test="msgbox_data != ''">
+ <tr>
+ <td align="left" colspan="3">
+ <xsl:call-template
name="msgbox"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
+ <form method="post" name="form" action="{$form_action}">
+
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_select_conv"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_conv_statustext"><xsl:value-of
select="lang_conv_statustext"/></xsl:variable>
+ <xsl:variable
name="select_conv"><xsl:value-of select="select_conv"/></xsl:variable>
+ <select name="{$select_conv}"
class="forms" onMouseover="window.status='{$lang_conv_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_select_conv"/></option>
+ <xsl:apply-templates
select="conv_list"/>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_select_file"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_file_statustext"><xsl:value-of
select="lang_file_statustext"/></xsl:variable>
+ <xsl:variable
name="select_file"><xsl:value-of select="select_file"/></xsl:variable>
+ <select name="{$select_file}"
class="forms" onMouseover="window.status='{$lang_file_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_no_file"/></option>
+ <xsl:apply-templates
select="rollback_file_list"/>
+ </select>
+ </td>
+ </tr>
+
+
+ <tr>
+
+ <td valign="top">
+ <xsl:value-of select="lang_date"/>
+ </td>
+ <td>
+ <input type="text" id="date"
name="date" size="10" value="{value_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_date_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ <script type="text/javascript">
+ document.writeln('<img
id="date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
+ <xsl:value-of select="calendar_setup"/>
+ </script>
+ </td>
+ </tr>
+
+ <tr height="50">
+ <td>
+ <xsl:variable
name="lang_submit"><xsl:value-of select="lang_submit"/></xsl:variable>
+ <input type="submit"
name="values[submit]" value="{$lang_submit}"
onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_import_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ </form>
+ <tr>
+ <td>
+ <xsl:variable
name="cancel_action"><xsl:value-of select="cancel_action"/></xsl:variable>
+ <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
+ <form method="post"
action="{$cancel_action}">
+ <input type="submit"
name="done" value="{$lang_cancel}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="lang_cancel_statustext"/>
+ <xsl:text>';
return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </form>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </xsl:template>
+
+
+<!--list_invoice_sub-->
+
+ <xsl:template match="list_invoice_sub">
+ <div id="overDiv" style="position:absolute;
visibility:hide;z-index:1;"></div>
+ <xsl:variable name="overlib_source"><xsl:value-of
select="overlib_source"/></xsl:variable>
+ <SCRIPT LANGUAGE="JavaScript" SRC="{$overlib_source}"></SCRIPT>
+ <SCRIPT LANGUAGE="JavaScript" SRC="{check_source}"></SCRIPT>
+
+ <xsl:call-template name="menu"/>
+ <table width="80%" cellpadding="2" cellspacing="2"
align="center">
+ <xsl:choose>
+ <xsl:when test="msgbox_data != ''">
+ <tr>
+ <td align="left" colspan="3">
+ <xsl:call-template
name="msgbox"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="vendor!=''">
+ <tr>
+ <td width="25%" class="th_text"
align="left">
+ <xsl:value-of
select="lang_vendor"/>
+ </td>
+ <td width="25%" class="th_text"
align="left">
+ <xsl:value-of
select="vendor"/>
+ </td>
+ <td width="50%">
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="voucher_id!=''">
+ <tr>
+ <td width="25%" class="th_text"
align="left">
+ <xsl:value-of
select="lang_voucher_id"/>
+ </td>
+ <td width="25%" class="th_text"
align="left">
+ <xsl:value-of
select="voucher_id"/>
+ </td>
+ <td width="50%">
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ </table>
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
+ <form method="post" name="form" action="{$form_action}">
+ <xsl:apply-templates
select="table_header_list_invoice_sub"/>
+
+ <xsl:choose>
+ <xsl:when test="values_list_invoice_sub[id]">
+ <xsl:apply-templates
select="values_list_invoice_sub"/>
+ <xsl:variable
name="img_check"><xsl:value-of select="img_check"/></xsl:variable>
+ <tr>
+ <td></td>
+ <td align="center">
+ <a
href="javascript:check_all_checkbox('values[close_order]')"><img
src="{$img_check}" border="0" height="16" width="21"
alt="{lang_select_all}"/></a>
+ </td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td class="small_text"
align="right">
+ <xsl:value-of
select="sum"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <tr height="50">
+ <td>
+ <xsl:choose>
+ <xsl:when test="paid=''">
+ <xsl:variable
name="lang_save"><xsl:value-of select="lang_save"/></xsl:variable>
+ <input type="submit"
name="values[save]" value="{$lang_save}" onMouseout="window.status='';return
true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="lang_save_statustext"/>
+
<xsl:text>'; return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </xsl:when>
+ </xsl:choose>
+ </td>
+ </tr>
+ </form>
+ <tr>
+ <td>
+ <xsl:variable
name="done_action"><xsl:value-of select="done_action"/></xsl:variable>
+ <xsl:variable
name="lang_done"><xsl:value-of select="lang_done"/></xsl:variable>
+ <form method="post"
action="{$done_action}">
+ <input type="submit"
name="done" value="{$lang_done}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="lang_done_statustext"/>
+ <xsl:text>';
return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </form>
+ </td>
+ </tr>
+
+ </table>
+ </xsl:template>
+
+ <xsl:template match="table_header_list_invoice_sub">
+ <xsl:variable name="sort_workorder"><xsl:value-of
select="sort_workorder"/></xsl:variable>
+ <xsl:variable name="sort_budget_account"><xsl:value-of
select="sort_budget_account"/></xsl:variable>
+ <xsl:variable name="sort_sum"><xsl:value-of
select="sort_sum"/></xsl:variable>
+ <xsl:variable name="sort_dima"><xsl:value-of
select="sort_dima"/></xsl:variable>
+ <tr class="th">
+ <td class="th_text" width="5%" align="right">
+ <a
href="{$sort_workorder}"><xsl:value-of select="lang_workorder"/></a>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <xsl:value-of
select="lang_close_order"/>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <xsl:value-of
select="lang_charge_tenant"/>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <xsl:value-of select="lang_invoice_id"/>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <a
href="{$sort_budget_account}"><xsl:value-of select="lang_budget_account"/></a>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <a href="{$sort_sum}"><xsl:value-of
select="lang_sum"/></a>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <a href="{$sort_dima}"><xsl:value-of
select="lang_dima"/></a>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <xsl:value-of select="lang_dimb"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of select="lang_dimd"/>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <xsl:value-of select="lang_tax_code"/>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <xsl:value-of select="lang_remark"/>
+ </td>
+ </tr>
+ </xsl:template>
+
+ <xsl:template match="values_list_invoice_sub">
+
+ <xsl:variable name="counter"><xsl:value-of
select="counter"/></xsl:variable>
+ <xsl:variable name="current_user"><xsl:value-of
select="current_user"/></xsl:variable>
+ <tr>
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="@class">
+ <xsl:value-of
select="@class"/>
+ </xsl:when>
+ <xsl:when test="position() mod
2 = 0">
+
<xsl:text>row_off</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+
<xsl:text>row_on</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+
+ <td align="right">
+ <input type="hidden"
name="values[counter][{$counter}]" value="{counter}">
+ </input>
+ <input type="hidden"
name="values[id][{$counter}]" value="{id}">
+ </input>
+ <input type="hidden"
name="values[workorder_id][{$counter}]" value="{workorder_id}">
+ </input>
+ <xsl:variable
name="link_order"><xsl:value-of
select="link_order"/>&order_id=<xsl:value-of
select="workorder_id"/></xsl:variable>
+ <a href="{$link_order}"
target="_blank"><xsl:value-of select="workorder_id"/></a>
+ </td>
+ <td class="small_text" align="center">
+ <xsl:choose>
+ <xsl:when
test="workorder_id=''">
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when
test="paid=''">
+ <input
type="hidden" name="values[close_order_orig][{$counter}]" value="{closed}">
+ </input>
+
<xsl:choose>
+
<xsl:when test="closed='1'">
+
<input type="checkbox" name="values[close_order][{$counter}]"
value="true" checked="checked" onMouseout="window.status='';return true;">
+
</input>
+
</xsl:when>
+
<xsl:otherwise>
+
<input type="checkbox" name="values[close_order][{$counter}]"
value="true" onMouseout="window.status='';return true;">
+
</input>
+
</xsl:otherwise>
+
</xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+
<xsl:choose>
+
<xsl:when test="closed='1'">
+
<b>x</b>
+
</xsl:when>
+
</xsl:choose>
+
</xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </td>
+ <td class="small_text" align="center">
+ <xsl:choose>
+ <xsl:when
test="charge_tenant='1'">
+ <xsl:choose>
+ <xsl:when
test="claim_issued=''">
+
<xsl:variable name="link_claim"><xsl:value-of
select="link_claim"/>&project_id=<xsl:value-of
select="project_id"/></xsl:variable>
+ <a
href="{$link_claim}" target="_blank"><xsl:value-of select="//lang_claim"/></a>
+ </xsl:when>
+ </xsl:choose>
+ <b>x</b>
+ </xsl:when>
+ </xsl:choose>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:value-of select="invoice_id"/>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:choose>
+ <xsl:when test="paid='true'">
+ <xsl:value-of
select="budget_account"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <input type="text"
size="7" name="values[budget_account][{$counter}]" value="{budget_account}">
+ </input>
+ </xsl:otherwise>
+ </xsl:choose>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:value-of select="amount"/>
+ </td>
+ <td class="small_text" align="center">
+ <xsl:choose>
+ <xsl:when test="paid='true'">
+ <xsl:value-of
select="dima"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <input type="text"
size="7" name="values[dima][{$counter}]" value="{dima}">
+ </input>
+ </xsl:otherwise>
+ </xsl:choose>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:value-of select="dimb"/>
+ </td>
+ <td class="small_text" align="center">
+ <xsl:choose>
+ <xsl:when test="paid='true'">
+ <xsl:value-of
select="dimd"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <input type="text"
size="4" name="values[dimd][{$counter}]" value="{dimd}">
+ </input>
+ </xsl:otherwise>
+ </xsl:choose>
+ </td>
+ <td class="small_text" align="center">
+ <xsl:choose>
+ <xsl:when test="paid='true'">
+ <xsl:value-of
select="tax_code"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable
name="lang_tax_code_statustext"><xsl:value-of
select="lang_tax_code_statustext"/></xsl:variable>
+ <select
name="values[tax_code][{$counter}]" class="forms"
onMouseover="window.status='{$lang_tax_code_statustext}'; return true;"
onMouseout="window.status='';return true;">
+
<xsl:apply-templates select="tax_code_list"/>
+ </select>
+ </xsl:otherwise>
+ </xsl:choose>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:choose>
+ <xsl:when test="remark='1'">
+ <xsl:variable
name="link_remark"><xsl:value-of select="link_remark"/>&id=<xsl:value-of
select="id"/>&paid=<xsl:value-of select="paid"/></xsl:variable>
+ <xsl:variable
name="lang_remark_help"><xsl:value-of select="lang_remark_help"/></xsl:variable>
+ <xsl:variable
name="lang_remark"><xsl:value-of select="lang_remark"/></xsl:variable>
+ <a href="javascript:var
w=window.open('{$link_remark}','','width=550,height=400,scrollbars')"
+
onMouseOver="overlib('{$lang_remark_help}', CAPTION, '{$lang_remark}')"
+ onMouseOut="nd()">
+ <xsl:value-of
select="lang_remark"/></a>
+ </xsl:when>
+ </xsl:choose>
+ </td>
+
+ </tr>
+ </xsl:template>
+
+ <xsl:template match="force_period_year">
+ <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected='selected'">
+ <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="id"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="id"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
Index: property/templates/default/invoice.xsl
diff -u property/templates/default/invoice.xsl:1.12
property/templates/default/invoice.xsl:1.13
--- property/templates/default/invoice.xsl:1.12 Wed Jan 25 18:19:12 2006
+++ property/templates/default/invoice.xsl Fri Jan 27 14:05:59 2006
@@ -1,2542 +1,2542 @@
-<!-- $Id: invoice.xsl,v 1.12 2006/01/25 18:19:12 sigurdne Exp $ -->
-
- <xsl:template name="app_data">
- <xsl:choose>
- <xsl:when test="add">
- <xsl:apply-templates select="add"/>
- </xsl:when>
- <xsl:when test="edit">
- <xsl:apply-templates select="edit"/>
- </xsl:when>
- <xsl:when test="import">
- <xsl:apply-templates select="import"/>
- </xsl:when>
- <xsl:when test="export">
- <xsl:apply-templates select="export"/>
- </xsl:when>
- <xsl:when test="rollback">
- <xsl:apply-templates select="rollback"/>
- </xsl:when>
- <xsl:when test="debug">
- <xsl:apply-templates select="debug"/>
- </xsl:when>
- <xsl:when test="edit_period">
- <xsl:apply-templates select="edit_period"/>
- </xsl:when>
- <xsl:when test="list_voucher">
- <xsl:apply-templates select="list_voucher"/>
- </xsl:when>
- <xsl:when test="list_voucher_paid">
- <xsl:apply-templates
select="list_voucher_paid"/>
- </xsl:when>
- <xsl:when test="consume">
- <xsl:apply-templates select="consume"/>
- </xsl:when>
- <xsl:when test="remark">
- <xsl:apply-templates select="remark"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select="list_invoice_sub"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template match="edit_period">
- <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
- <form method="post" action="{$form_action}">
- <div align="center">
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <xsl:choose>
- <xsl:when test="msgbox_data != ''">
- <tr>
- <td align="left" colspan="3">
- <xsl:call-template
name="msgbox"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <tr>
- <td>
- <xsl:variable name="select_name"><xsl:value-of
select="select_name"/></xsl:variable>
- <select name="{$select_name}" class="forms" >
- <xsl:apply-templates
select="period_list"/>
- </select>
- </td>
- </tr>
- <tr height="50">
- <td>
- <xsl:variable
name="lang_save"><xsl:value-of select="lang_save"/></xsl:variable>
- <input type="submit" name="submit"
value="{$lang_save}" >
- </input>
- </td>
- </tr>
- </table>
- </div>
- </form>
- </xsl:template>
-
- <xsl:template match="period_list">
- <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="name"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="name"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <xsl:template match="remark">
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <tr>
- <td colspan="2" align="center">
- <xsl:value-of select="message"/>
- </td>
- </tr>
- <tr>
- <td align="center">
- <textarea cols="60" rows="15"
name="remark" readonly="readonly" wrap="virtual"
onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_content_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- <xsl:value-of select="remark"/>
- </textarea>
- </td>
- </tr>
-
- </table>
- </xsl:template>
-
- <xsl:template name="excel">
- <xsl:variable name="link_excel"><xsl:value-of
select="link_excel"/></xsl:variable>
- <xsl:variable name="lang_excel_help"><xsl:value-of
select="lang_excel_help"/></xsl:variable>
- <xsl:variable name="lang_excel"><xsl:value-of
select="lang_excel"/></xsl:variable>
- <a href="javascript:var
w=window.open('{$link_excel}','','')"
- onMouseOver="overlib('{$lang_excel_help}',
CAPTION, '{$lang_excel}')"
- onMouseOut="nd()">
- <xsl:value-of select="lang_excel"/></a>
- </xsl:template>
-
-
-<!-- list_voucher -->
-
- <xsl:template match="list_voucher">
- <div id="overDiv" style="position:absolute;
visibility:hide;z-index:1;"></div>
- <xsl:variable name="overlib_source"><xsl:value-of
select="overlib_source"/></xsl:variable>
- <SCRIPT LANGUAGE="JavaScript" SRC="{$overlib_source}"></SCRIPT>
- <xsl:variable name="check_source"><xsl:value-of
select="check_source"/></xsl:variable>
- <SCRIPT LANGUAGE="JavaScript" SRC="{$check_source}"></SCRIPT>
- <xsl:call-template name="menu"/>
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <xsl:choose>
- <xsl:when test="msgbox_data != ''">
- <tr>
- <td align="left" colspan="3">
- <xsl:call-template
name="msgbox"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
-
- <tr>
- <td>
- <xsl:call-template name="cat_filter"/>
- </td>
- <td align="center">
- <xsl:call-template
name="user_lid_filter"/>
- </td>
- <td align="right">
- <xsl:call-template name="search_field"/>
- </td>
- </tr>
- <tr>
- <td colspan="3" width="100%">
- <xsl:call-template name="nextmatchs"/>
- </td>
- <td colspan="3" width="100%" class="small_text"
valign="top" align="left">
- <xsl:call-template name="excel"/>
- </td>
- </tr>
- </table>
- <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
- <form method="post" name="form" action="{$form_action}">
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <xsl:apply-templates
select="table_header_list_voucher"/>
-
- <xsl:choose>
- <xsl:when
test="values_list_voucher[voucher_id]">
- <xsl:apply-templates
select="values_list_voucher"/>
-
- </xsl:when>
- </xsl:choose>
- <xsl:variable name="img_check"><xsl:value-of
select="img_check"/></xsl:variable>
- <tr>
- <td></td>
- <td></td>
- <td></td>
- <td class="small_text" align="right">
- <xsl:value-of select="sum"/>
- </td>
- <td></td>
- <td></td>
- <td></td>
- <td></td>
- <td></td>
- <td align="center">
- <a
href="javascript:check_all_radio('sign_none')"><img src="{$img_check}"
border="0" height="16" width="21" alt="{lang_select_all}"/></a>
- </td>
- <td align="center">
- <a
href="javascript:check_all_radio('sign_janitor')"><img src="{$img_check}"
border="0" height="16" width="21" alt="{lang_select_all}"/></a>
- </td>
- <td align="center">
- <a
href="javascript:check_all_radio('sign_supervisor')"><img src="{$img_check}"
border="0" height="16" width="21" alt="{lang_select_all}"/></a>
- </td>
- <td align="center">
- <a
href="javascript:check_all_radio('sign_budget_responsible')"><img
src="{$img_check}" border="0" height="16" width="21"
alt="{lang_select_all}"/></a>
- </td>
- <td align="right">
- <a
href="javascript:check_all_checkbox('values[transfer]')"><img
src="{$img_check}" border="0" height="16" width="21"
alt="{lang_select_all}"/></a>
- </td>
- </tr>
-
- <tr height="50">
- <td>
- <xsl:variable
name="lang_save"><xsl:value-of select="lang_save"/></xsl:variable>
- <input type="submit"
name="values[save][0]" value="{$lang_save}" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_save_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
-
- </table>
- </form>
- <xsl:choose>
- <xsl:when test="table_add_invoice !=''">
- <xsl:apply-templates
select="table_add_invoice"/>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template match="table_add_invoice">
- <table align = "left">
- <tr>
- <td height="50" align="left" valign="top">
- <xsl:variable
name="add_action"><xsl:value-of select="add_action"/></xsl:variable>
- <xsl:variable
name="lang_add"><xsl:value-of select="lang_add"/></xsl:variable>
- <form method="post"
action="{$add_action}">
- <input type="submit" name=""
value="{$lang_add}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="lang_add_statustext"/>
- <xsl:text>';
return true;</xsl:text>
- </xsl:attribute>
- </input>
- </form>
- </td>
- </tr>
- </table>
- </xsl:template>
-
-
- <xsl:template match="table_header_list_voucher">
- <xsl:variable name="sort_voucher"><xsl:value-of
select="sort_voucher"/></xsl:variable>
- <xsl:variable name="sort_voucher_date"><xsl:value-of
select="sort_voucher_date"/></xsl:variable>
- <xsl:variable name="sort_vendor_id"><xsl:value-of
select="sort_vendor_id"/></xsl:variable>
- <tr class="th">
- <td class="th_text" width="5%" align="right">
- <a href="{$sort_voucher}"><xsl:value-of
select="lang_voucher"/></a>
- </td>
- <td class="th_text" width="2%" align="right">
- <a
href="{$sort_voucher_date}"><xsl:value-of select="lang_voucher_date"/></a>
- </td>
- <td class="th_text" width="2%" align="right">
- <xsl:value-of select="lang_days"/>
- </td>
- <td class="th_text" width="8%" align="right">
- <xsl:value-of select="lang_sum"/>
- </td>
- <td class="th_text" width="4%" align="right">
- <a
href="{$sort_vendor_id}"><xsl:value-of select="lang_vendor_id"/></a>
- </td>
- <td class="th_text" width="3%" align="right">
- <xsl:value-of
select="lang_num_sub_invoice"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of select="lang_type"/>
- </td>
- <td class="th_text" width="3%" align="right">
- <xsl:value-of select="lang_period"/>
- </td>
- <td class="th_text" width="3%" align="right">
- <xsl:value-of select="lang_kredit"/>
- </td>
- <td class="th_text" width="3%" align="right">
- <xsl:value-of select="lang_none"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of select="lang_janitor"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of select="lang_supervisor"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of
select="lang_budget_responsible"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of select="lang_transfer"/>
- </td>
- <xsl:choose>
- <xsl:when test="//acl_delete!=''">
- <td class="th_text" width="5%"
align="center">
- <xsl:value-of
select="lang_delete"/>
- </td>
- </xsl:when>
- </xsl:choose>
- </tr>
- </xsl:template>
-
- <xsl:template match="values_list_voucher">
-
- <xsl:variable name="counter"><xsl:value-of
select="counter"/></xsl:variable>
- <xsl:variable name="current_user"><xsl:value-of
select="current_user"/></xsl:variable>
- <tr>
- <xsl:attribute name="class">
- <xsl:choose>
- <xsl:when test="@class">
- <xsl:value-of
select="@class"/>
- </xsl:when>
- <xsl:when test="position() mod
2 = 0">
-
<xsl:text>row_off</xsl:text>
- </xsl:when>
- <xsl:otherwise>
-
<xsl:text>row_on</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
-
- <td class="small_text" align="right">
- <input type="hidden"
name="values[counter][{$counter}]" value="{counter}">
- </input>
- <input type="hidden"
name="values[voucher_id][{$counter}]" value="{voucher_id}">
- </input>
- <xsl:variable
name="link_sub"><xsl:value-of select="link_sub"/>&voucher_id=<xsl:value-of
select="voucher_id"/></xsl:variable>
- <xsl:variable
name="lang_sub_help"><xsl:value-of select="lang_sub_help"/></xsl:variable>
- <xsl:variable
name="lang_sub"><xsl:value-of select="lang_sub"/></xsl:variable>
- <a href="{$link_sub}"
-
onMouseOver="overlib('{$lang_sub_help}', CAPTION, '{$lang_sub}')"
- onMouseOut="nd()">
- <xsl:value-of select="voucher_id"/></a>
- </td>
- <td class="small_text" align="right">
- <xsl:variable
name="lang_payment_date"><xsl:value-of
select="lang_payment_date"/></xsl:variable>
- <xsl:variable
name="payment_date"><xsl:value-of select="payment_date"/></xsl:variable>
- <a href="javascript:void()"
- onMouseOver="overlib('{$payment_date}',
CAPTION, '{$lang_payment_date}')"
- onMouseOut="nd()">
- <xsl:value-of
select="voucher_date"/></a>
- </td>
- <td class="small_text" align="right">
- <input type="hidden"
name="values[sign_orig][{$counter}]" value="{sign_orig}">
- </input>
- <input type="hidden"
name="values[num_days_orig][{$counter}]" value="{num_days}">
- </input>
- <input type="hidden"
name="values[timestamp_voucher_date][{$counter}]"
value="{timestamp_voucher_date}">
- </input>
- <input type="text" size="2"
name="values[num_days][{$counter}]" value="{num_days}">
- </input>
- </td>
- <td class="small_text" align="right">
- <xsl:value-of select="amount"/>
- </td>
- <td class="small_text" align="right">
- <xsl:variable
name="vendor"><xsl:value-of select="vendor"/></xsl:variable>
- <xsl:variable
name="vendor_id"><xsl:value-of select="vendor_id"/></xsl:variable>
- <a href="javascript:void()"
- onMouseOver="overlib('{$vendor}',
CAPTION, '{$vendor_id}')"
- onMouseOut="nd()">
- <xsl:value-of select="vendor_id"/></a>
-
- </td>
- <td class="small_text" align="right">
- <input type="hidden"
name="values[invoice_count][{$counter}]" value="{invoice_count}">
- </input>
- <xsl:value-of select="invoice_count"/>
- </td>
- <td class="small_text" align="center">
- <xsl:value-of select="type"/>
- </td>
- <td class="small_text" align="right">
- <xsl:variable
name="link_period"><xsl:value-of
select="link_period"/>&voucher_id=<xsl:value-of
select="voucher_id"/>&period=<xsl:value-of select="period"/></xsl:variable>
- <xsl:variable
name="lang_period_help"><xsl:value-of select="lang_period_help"/></xsl:variable>
- <xsl:variable
name="lang_period"><xsl:value-of select="lang_period"/></xsl:variable>
- <a href="javascript:var
w=window.open('{$link_period}','','width=150,height=150')"
-
onMouseOver="overlib('{$lang_period_help}', CAPTION, '{$lang_period}')"
- onMouseOut="nd()">
- <xsl:value-of select="period"/></a>
- </td>
- <td align="center">
- <xsl:choose>
- <xsl:when test="kreditnota='1'">
- <input type="checkbox"
name="values[kreditnota][{$counter}]" value="true" checked="checked"
onMouseout="window.status='';return true;">
- </input>
- </xsl:when>
- <xsl:otherwise>
- <input type="checkbox"
name="values[kreditnota][{$counter}]" value="true"
onMouseout="window.status='';return true;">
- </input>
- </xsl:otherwise>
- </xsl:choose>
- </td>
- <td class="small_text" align="center">
- <xsl:choose>
- <xsl:when test="is_janitor">
- <input type="radio"
name="values[sign][{$counter}]" value="sign_none"
onMouseout="window.status='';return true;">
- </input>
- </xsl:when>
- <xsl:when test="is_supervisor">
- <input type="radio"
name="values[sign][{$counter}]" value="sign_none"
onMouseout="window.status='';return true;">
- </input>
- </xsl:when>
- <xsl:when
test="is_budget_responsible">
- <input type="radio"
name="values[sign][{$counter}]" value="sign_none"
onMouseout="window.status='';return true;">
- </input>
- </xsl:when>
- <xsl:otherwise>
- </xsl:otherwise>
- </xsl:choose>
- </td>
- <td class="small_text" align="right">
-
- <xsl:choose>
- <xsl:when
test="is_janitor='32'">
- <xsl:choose>
- <xsl:when
test="jan_date=''">
- <input
type="radio" name="values[sign][{$counter}]" value="sign_janitor"
onMouseout="window.status='';return true;">
-
</input>
- </xsl:when>
- <xsl:otherwise>
-
<xsl:choose>
-
<xsl:when test="janitor = $current_user">
-
<input type="radio" name="values[sign][{$counter}]"
value="sign_janitor" checked="checked" onMouseout="window.status='';return
true;">
-
</input>
-
</xsl:when>
-
<xsl:otherwise>
-
<input type="checkbox" name="" value="" checked="checked"
disabled="disabled" ></input>
-
</xsl:otherwise>
-
</xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when
test="jan_date=''">
- </xsl:when>
- <xsl:otherwise>
- <input
type="checkbox" name="" value="" checked="checked" disabled="disabled" ></input>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
-
- <xsl:value-of select="janitor"/>
- </td>
- <td class="small_text" align="right">
-
- <xsl:choose>
- <xsl:when
test="is_supervisor='64'"><xsl:value-of select="super_date"/>
- <xsl:choose>
- <xsl:when
test="super_date=''">
- <input
type="radio" name="values[sign][{$counter}]" value="sign_supervisor"
onMouseout="window.status='';return true;">
-
</input>
- </xsl:when>
- <xsl:when
test="super_date!=''">
-
<xsl:choose>
-
<xsl:when test="supervisor = $current_user">
-
<input type="radio" name="values[sign][{$counter}]"
value="sign_supervisor" checked="checked" onMouseout="window.status='';return
true;">
-
</input>
-
</xsl:when>
-
<xsl:otherwise>
-
<input type="checkbox" name="" value="" checked="checked"
disabled="disabled" ></input>
-
</xsl:otherwise>
-
</xsl:choose>
- </xsl:when>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when
test="super_date=''">
- </xsl:when>
- <xsl:otherwise>
- <input
type="checkbox" name="" value="" checked="checked" disabled="disabled" ></input>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
-
- <xsl:value-of select="supervisor"/>
- </td>
- <td class="small_text" align="right">
- <xsl:choose>
- <xsl:when
test="is_budget_responsible='128'">
- <xsl:choose>
- <xsl:when
test="budget_date=''">
- <input
type="radio" name="values[sign][{$counter}]" value="sign_budget_responsible"
onMouseout="window.status='';return true;">
-
</input>
- </xsl:when>
- <xsl:otherwise>
-
<xsl:choose>
-
<xsl:when test="budget_responsible = $current_user">
-
<input type="radio" name="values[sign][{$counter}]"
value="sign_budget_responsible" checked="checked"
onMouseout="window.status='';return true;">
-
</input>
-
</xsl:when>
-
<xsl:otherwise>
-
<input type="checkbox" name="" value="" checked="checked"
disabled="disabled" ></input>
-
</xsl:otherwise>
-
</xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when
test="budget_date=''">
- </xsl:when>
- <xsl:otherwise>
- <input
type="checkbox" name="" value="" checked="checked" disabled="disabled" ></input>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:value-of
select="budget_responsible"/>
- </td>
- <td class="small_text" align="right">
- <xsl:choose>
- <xsl:when
test="is_transfer='16'">
- <xsl:choose>
- <xsl:when
test="transfer_date=''">
- <input
type="checkbox" name="values[transfer][{$counter}]" value="true"
onMouseout="window.status='';return true;">
- </input>
- </xsl:when>
- <xsl:otherwise>
- <input
type="checkbox" name="values[transfer][{$counter}]" value="true"
checked="checked" onMouseout="window.status='';return true;">
-
</input>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when
test="transfer_id!=''">
- <input
type="checkbox" name="" value="" checked="checked" disabled="disabled" ></input>
- </xsl:when>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:value-of select="transfer_id"/>
- </td>
- <xsl:choose>
- <xsl:when test="//acl_delete!=''">
- <xsl:variable
name="lang_delete_statustext"><xsl:value-of
select="lang_delete_statustext"/></xsl:variable>
- <td class="small_text"
align="center">
- <xsl:variable
name="link_delete"><xsl:value-of select="link_delete"/></xsl:variable>
- <a href="{$link_delete}"
onMouseover="window.status='{$lang_delete_statustext}';return true;"
onMouseout="window.status='';return true;"><xsl:value-of
select="text_delete"/></a>
- </td>
- </xsl:when>
- </xsl:choose>
- </tr>
- </xsl:template>
-
-
-
-<!-- list_voucher_paid -->
-
- <xsl:template match="list_voucher_paid">
- <div id="overDiv" style="position:absolute;
visibility:hide;z-index:1;"></div>
- <xsl:variable name="overlib_source"><xsl:value-of
select="overlib_source"/></xsl:variable>
- <SCRIPT LANGUAGE="JavaScript" SRC="{$overlib_source}"></SCRIPT>
-
- <script language="JavaScript">
- self.name="first_Window";
- function abook()
- {
- Window1=window.open('<xsl:value-of
select="addressbook_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
- }
- function property_lookup()
- {
- Window1=window.open('<xsl:value-of
select="property_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
- }
- </script>
-
- <xsl:call-template name="menu"/>
- <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
- <div align="left">
- <form method="post" name="form" action="{$form_action}">
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <xsl:choose>
- <xsl:when test="msgbox_data != ''">
- <tr>
- <td align="left" colspan="3">
- <xsl:call-template
name="msgbox"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
-
- <tr>
- <td>
- <input type="text" id="start_date"
name="start_date" size="10" value="{start_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_start_date_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- <script type="text/javascript">
- document.writeln('<img
id="start_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
- <xsl:value-of
select="calendar_setup_start"/>
- </script>
- </td>
- <td>
- <input type="text" id="end_date"
name="end_date" size="10" value="{end_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_end_date_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- <script type="text/javascript">
- document.writeln('<img
id="end_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
- <xsl:value-of
select="calendar_setup_end"/>
- </script>
- </td>
- <td>
- <input type="text" size="8"
name="workorder_id" value="{workorder_id}" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_workorder_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- <a href="javascript:void()"
-
onMouseOver="overlib('{lang_workorder_statustext}', CAPTION,
'{lang_workorder}')"
- onMouseOut="nd()">
- <xsl:value-of
select="lang_workorder"/></a>
- </td>
-
- <td align="left">
- <input type="text" name="vendor_id"
value="{vendor_id}" size="4" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_vendor_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- <a href="javascript:abook()"
-
onMouseOver="overlib('{lang_select_vendor_statustext}', CAPTION,
'{lang_vendor}')"
- onMouseOut="nd()">
- <xsl:value-of
select="lang_vendor"/></a>
-
- <input type="hidden"
name="vendor_name"></input>
- </td>
- </tr>
-
- <tr>
- <td>
- <xsl:call-template name="cat_select"/>
- </td>
- <td align="left">
- <xsl:call-template
name="user_lid_select"/>
- </td>
- <td align="left">
- <input type="text" name="loc1"
value="{loc1}" size="4" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_property_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- <a href="javascript:property_lookup()"
-
onMouseOver="overlib('{lang_select_property_statustext}', CAPTION,
'{lang_property}')"
- onMouseOut="nd()">
- <xsl:value-of
select="lang_property"/></a>
-
- <input type="hidden"
name="loc1_name"></input>
- </td>
-
- <td align="left">
- <input type="text" name="voucher_id"
value="{voucher_id}" size="8" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_voucher_id_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- <xsl:text> </xsl:text>
- <xsl:value-of select="lang_voucher_id"/>
- </td>
-
- <td align="left">
- <xsl:variable
name="lang_search"><xsl:value-of select="lang_search"/></xsl:variable>
- <input type="submit"
name="submit_search" value="{$lang_search}" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_search_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- <tr>
- <td colspan="11" width="100%">
- <xsl:call-template name="nextmatchs"/>
- </td>
- </tr>
- </table>
- </form>
- </div>
-
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <xsl:apply-templates
select="table_header_list_voucher_paid"/>
-
- <xsl:choose>
- <xsl:when
test="values_list_voucher_paid[voucher_id]">
- <xsl:apply-templates
select="values_list_voucher_paid"/>
- <tr>
- <td></td>
- <td></td>
- <td></td>
- <td class="th_text"
align="right">
- <xsl:value-of
select="sum"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <xsl:variable name="img_check"><xsl:value-of
select="img_check"/></xsl:variable>
- </table>
- </xsl:template>
-
-
- <xsl:template match="table_header_list_voucher_paid">
- <xsl:variable name="sort_voucher"><xsl:value-of
select="sort_voucher"/></xsl:variable>
- <xsl:variable name="sort_voucher_date"><xsl:value-of
select="sort_voucher_date"/></xsl:variable>
- <xsl:variable name="sort_vendor_id"><xsl:value-of
select="sort_vendor_id"/></xsl:variable>
- <tr class="th">
- <td class="th_text" width="5%" align="right">
- <a href="{$sort_voucher}"><xsl:value-of
select="lang_voucher"/></a>
- </td>
- <td class="th_text" width="2%" align="right">
- <a
href="{$sort_voucher_date}"><xsl:value-of select="lang_voucher_date"/></a>
- </td>
- <td class="th_text" width="2%" align="right">
- <xsl:value-of select="lang_days"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of select="lang_sum"/>
- </td>
- <td class="th_text" width="4%" align="right">
- <a
href="{$sort_vendor_id}"><xsl:value-of select="lang_vendor_id"/></a>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of
select="lang_num_sub_invoice"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of select="lang_type"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of select="lang_janitor"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of select="lang_supervisor"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of
select="lang_budget_responsible"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of select="lang_transfer"/>
- </td>
- </tr>
- </xsl:template>
-
- <xsl:template match="values_list_voucher_paid">
-
- <xsl:variable name="counter"><xsl:value-of
select="counter"/></xsl:variable>
- <xsl:variable name="current_user"><xsl:value-of
select="current_user"/></xsl:variable>
- <tr>
- <xsl:attribute name="class">
- <xsl:choose>
- <xsl:when test="@class">
- <xsl:value-of
select="@class"/>
- </xsl:when>
- <xsl:when test="position() mod
2 = 0">
-
<xsl:text>row_off</xsl:text>
- </xsl:when>
- <xsl:otherwise>
-
<xsl:text>row_on</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
-
- <td align="right">
- <xsl:variable
name="link_sub"><xsl:value-of select="link_sub"/>&voucher_id=<xsl:value-of
select="voucher_id"/>&paid=true</xsl:variable>
- <xsl:variable
name="lang_sub_help"><xsl:value-of select="lang_sub_help"/></xsl:variable>
- <xsl:variable
name="lang_sub"><xsl:value-of select="lang_sub"/></xsl:variable>
- <a href="{$link_sub}"
-
onMouseOver="overlib('{$lang_sub_help}', CAPTION, '{$lang_sub}')"
- onMouseOut="nd()">
- <xsl:value-of select="voucher_id"/></a>
- </td>
- <td align="right">
- <xsl:variable
name="lang_payment_date"><xsl:value-of
select="lang_payment_date"/></xsl:variable>
- <xsl:variable
name="payment_date"><xsl:value-of select="payment_date"/></xsl:variable>
- <a href="javascript:void()"
- onMouseOver="overlib('{$payment_date}',
CAPTION, '{$lang_payment_date}')"
- onMouseOut="nd()">
- <xsl:value-of
select="voucher_date"/></a>
- </td>
- <td align="right">
- <xsl:value-of select="num_days"/>
- </td>
- <td align="right">
- <xsl:value-of select="amount"/>
- </td>
- <td align="right">
- <xsl:variable
name="vendor"><xsl:value-of select="vendor"/></xsl:variable>
- <xsl:variable
name="vendor_id"><xsl:value-of select="vendor_id"/></xsl:variable>
- <a href="javascript:void()"
- onMouseOver="overlib('{$vendor}',
CAPTION, '{$vendor_id}')"
- onMouseOut="nd()">
- <xsl:value-of select="vendor_id"/></a>
-
- </td>
- <td align="right">
- <xsl:value-of select="invoice_count"/>
- </td>
- <td align="center">
- <xsl:value-of select="type"/>
- </td>
- <td align="center">
- <xsl:value-of select="jan_date"/> -
<xsl:value-of select="janitor"/>
- </td>
- <td align="center">
- <xsl:value-of select="super_date"/> -
<xsl:value-of select="supervisor"/>
- </td>
- <td align="center">
- <xsl:value-of select="budget_date"/> -
<xsl:value-of select="budget_responsible"/>
- </td>
- <td align="center">
- <xsl:value-of select="transfer_date"/>
- <xsl:value-of select="transfer_id"/>
- </td>
- </tr>
- </xsl:template>
-
-
-<!-- consume -->
-
- <xsl:template match="consume">
- <div id="overDiv" style="position:absolute;
visibility:hide;z-index:1;"></div>
- <xsl:variable name="overlib_source"><xsl:value-of
select="overlib_source"/></xsl:variable>
- <SCRIPT LANGUAGE="JavaScript" SRC="{$overlib_source}"></SCRIPT>
-
- <script language="JavaScript">
- self.name="first_Window";
- function abook()
- {
- Window1=window.open('<xsl:value-of
select="addressbook_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
- }
- function property_lookup()
- {
- Window1=window.open('<xsl:value-of
select="property_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
- }
- </script>
-
- <xsl:call-template name="menu"/>
- <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
- <div align="left">
- <form method="post" name="form" action="{$form_action}">
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <xsl:choose>
- <xsl:when test="msgbox_data != ''">
- <tr>
- <td align="left" colspan="3">
- <xsl:call-template
name="msgbox"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <tr>
- <td>
- <input type="text" id="start_date"
name="start_date" size="10" value="{start_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_start_date_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- <script type="text/javascript">
- document.writeln('<img
id="start_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
- <xsl:value-of
select="calendar_setup_start"/>
- </script>
- </td>
- <td>
- <input type="text" id="end_date"
name="end_date" size="10" value="{end_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_end_date_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- <script type="text/javascript">
- document.writeln('<img
id="end_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
- <xsl:value-of
select="calendar_setup_end"/>
- </script>
- </td>
- <td>
- <input type="text" size="8"
name="workorder_id" value="{workorder_id}" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_workorder_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- <a href="javascript:void()"
-
onMouseOver="overlib('{lang_workorder_statustext}', CAPTION,
'{lang_workorder}')"
- onMouseOut="nd()">
- <xsl:value-of
select="lang_workorder"/></a>
- </td>
-
- <td align="left">
- <input type="text" name="vendor_id"
onClick="abook()" value="{vendor_id}" size="4"
onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_vendor_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- <a href="javascript:abook()"
-
onMouseOver="overlib('{lang_select_vendor_statustext}', CAPTION,
'{lang_vendor}')"
- onMouseOut="nd()">
- <xsl:value-of
select="lang_vendor"/></a>
-
- <input type="hidden" name="vendor_name"
value="{vendor_name}"></input>
- </td>
- </tr>
-
- <tr>
- <td>
- <xsl:call-template name="cat_select"/>
- </td>
- <td align="left">
- <xsl:call-template
name="select_district"/>
- </td>
- <td align="left">
- <xsl:variable
name="lang_account_class_statustext"><xsl:value-of
select="lang_account_class_statustext"/></xsl:variable>
- <xsl:variable
name="select_account_class_name"><xsl:value-of
select="select_account_class_name"/></xsl:variable>
- <select
name="{$select_account_class_name}" class="forms"
onMouseover="window.status='{$lang_account_class_statustext}'; return true;"
onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_no_account_class_"/></option>
- <xsl:apply-templates
select="account_class_list"/>
- </select>
-
- </td>
-
- <td align="left">
- <input type="text" name="loc1"
onClick="property_lookup()" value="{loc1}" size="4"
onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_property_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- <a href="javascript:property_lookup()"
-
onMouseOver="overlib('{lang_select_property_statustext}', CAPTION,
'{lang_property}')"
- onMouseOut="nd()">
- <xsl:value-of
select="lang_property"/></a>
-
- <input type="hidden"
name="loc1_name"></input>
- </td>
- <td align="left">
- <xsl:variable
name="lang_search"><xsl:value-of select="lang_search"/></xsl:variable>
- <input type="submit"
name="submit_search" value="{$lang_search}" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_search_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- </table>
- </form>
- </div>
-
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <xsl:choose>
- <xsl:when test="vendor_name!=''">
- <tr>
- <td width="25%" class="th_text"
align="left">
- <xsl:value-of
select="lang_vendor"/>
- </td>
- <td width="25%" class="th_text"
align="left">
- <xsl:value-of
select="vendor_name"/>
- </td>
- <td width="50%">
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test="loc1!=''">
- <tr>
- <td width="25%" class="th_text"
align="left">
- <xsl:value-of
select="lang_property"/>
- </td>
- <td width="25%" class="th_text"
align="left">
- <xsl:value-of
select="loc1"/>
- </td>
- <td width="50%">
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test="workorder_id!=''">
- <tr>
- <td width="25%" class="th_text"
align="left">
- <xsl:value-of
select="lang_workorder"/>
- </td>
- <td width="25%" class="th_text"
align="left">
- <xsl:value-of
select="workorder_id"/>
- </td>
- <td width="50%">
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
-
- </table>
-
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <xsl:apply-templates select="table_header_consume"/>
-
- <xsl:choose>
- <xsl:when test="values_consume[consume]">
- <xsl:apply-templates
select="values_consume"/>
-
- </xsl:when>
- </xsl:choose>
- <tr>
- <td>
- </td>
- <td>
- </td>
- <td class="th_text" align="right">
- <xsl:value-of select="lang_sum"/>
- </td>
- <td class="th_text" align="right">
- <xsl:value-of select="sum"/>
- </td>
- </tr>
- </table>
- </xsl:template>
-
- <xsl:template match="account_class_list">
- <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="id"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="id"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template match="table_header_consume">
- <tr class="th">
- <td class="th_text" width="10%" align="right">
- <xsl:value-of select="lang_district"/>
- </td>
- <td class="th_text" width="10%" align="right">
- <xsl:value-of select="lang_period"/>
- </td>
- <td class="th_text" width="25%" align="right">
- <xsl:value-of
select="lang_budget_account"/>
- </td>
- <td class="th_text" width="55%" align="right">
- <xsl:value-of select="lang_consume"/>
- </td>
- </tr>
- </xsl:template>
-
- <xsl:template match="values_consume">
- <tr>
- <xsl:attribute name="class">
- <xsl:choose>
- <xsl:when test="@class">
- <xsl:value-of
select="@class"/>
- </xsl:when>
- <xsl:when test="position() mod
2 = 0">
-
<xsl:text>row_off</xsl:text>
- </xsl:when>
- <xsl:otherwise>
-
<xsl:text>row_on</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
-
- <td align="right">
- <xsl:value-of select="district_id"/>
- </td>
- <td align="center">
- <xsl:value-of select="period"/>
- </td>
- <td align="center">
- <xsl:value-of select="account_class"/>
- </td>
- <td align="right">
- <xsl:value-of select="consume"/>
- </td>
- </tr>
- </xsl:template>
-
-<!-- debug-->
-
- <xsl:template match="debug">
- <div align="left">
- <table width="50%" cellpadding="2" cellspacing="2"
align="center">
-
- <tr>
- <td class="th_text">
- <xsl:value-of select="lang_bilagsnr"/>
- </td>
- <td>
- <xsl:value-of select="bilagsnr"/>
- </td>
- </tr>
- <tr>
- <td class="th_text">
- <xsl:value-of select="lang_type"/>
- </td>
- <td>
- <xsl:value-of select="artid"/>
- </td>
- </tr>
- <tr>
- <td class="th_text">
- <xsl:value-of select="lang_vendor"/>
- </td>
- <td>
- <xsl:value-of select="spvend_code"/>
- <xsl:text> </xsl:text>
- <xsl:value-of select="vendor_name"/>
- </td>
- </tr>
- <tr>
- <td class="th_text">
- <xsl:value-of
select="lang_fakturadato"/>
- </td>
- <td>
- <xsl:value-of select="fakturadato"/>
- </td>
- </tr>
- <tr>
- <td class="th_text">
- <xsl:value-of
select="lang_forfallsdato"/>
- </td>
- <td>
- <xsl:value-of select="forfallsdato"/>
- </td>
- </tr>
- <tr>
- <td class="th_text">
- <xsl:value-of select="lang_janitor"/>
- </td>
- <td>
- <xsl:value-of select="oppsynsmannid"/>
- </td>
- </tr>
- <tr>
- <td class="th_text">
- <xsl:value-of select="lang_supervisor"/>
- </td>
- <td>
- <xsl:value-of select="saksbehandlerid"/>
- </td>
- </tr>
- <tr>
- <td class="th_text">
- <xsl:value-of
select="lang_budget_responsible"/>
- </td>
- <td>
- <xsl:value-of
select="budsjettansvarligid"/>
- </td>
- </tr>
- <tr>
- <td class="th_text">
- <xsl:value-of select="lang_project_id"/>
- </td>
- <td>
- <xsl:value-of select="project_id"/>
- </td>
- </tr>
- <tr>
- <td class="th_text">
- <xsl:value-of select="lang_sum"/>
- </td>
- <td>
- <xsl:value-of select="sum"/>
- </td>
- </tr>
- </table>
- </div>
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <tr class="th">
- <xsl:call-template name="table_header"/>
- </tr>
- <xsl:call-template name="values_debug"/>
- <xsl:apply-templates select="table_add"/>
- </table>
- </xsl:template>
-
- <xsl:template name="values_debug">
- <xsl:for-each select="values" >
- <tr>
- <xsl:attribute name="class">
- <xsl:choose>
- <xsl:when test="@class">
- <xsl:value-of select="@class"/>
- </xsl:when>
- <xsl:when test="position() mod 2 = 0">
- <xsl:text>row_off</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>row_on</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <xsl:for-each select="row" >
- <td align="{align}">
- <xsl:value-of select="value"/>
- </td>
- </xsl:for-each>
- </tr>
- </xsl:for-each>
- </xsl:template>
-
- <xsl:template match="table_add">
- <tr>
- <td height="50">
- <xsl:variable
name="add_action"><xsl:value-of select="add_action"/></xsl:variable>
- <xsl:variable
name="lang_add"><xsl:value-of select="lang_add"/></xsl:variable>
- <form method="post"
action="{$add_action}">
- <input type="submit" name="add"
value="{$lang_add}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="lang_add_statustext"/>
- <xsl:text>';
return true;</xsl:text>
- </xsl:attribute>
- </input>
- </form>
- </td>
- <td height="50">
- <xsl:variable
name="cancel_action"><xsl:value-of select="cancel_action"/></xsl:variable>
- <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
- <form method="post"
action="{$cancel_action}">
- <input type="submit"
name="cancel" value="{$lang_cancel}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="lang_cancel_statustext"/>
- <xsl:text>';
return true;</xsl:text>
- </xsl:attribute>
- </input>
- </form>
- </td>
- </tr>
- </xsl:template>
-
-<!-- add / edit -->
- <xsl:template match="add">
-
- <script language="JavaScript">
- self.name="first_Window";
- function abook()
- {
- Window1=window.open('<xsl:value-of
select="addressbook_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
- }
- </script>
-
- <xsl:call-template name="menu"/>
- <div align="left">
- <table cellpadding="2" cellspacing="2" width="80%"
align="center">
- <tr>
- <td colspan="2" align="center">
- <xsl:value-of select="message"/>
- </td>
- </tr>
- <xsl:choose>
- <xsl:when test="msgbox_data != ''">
- <tr>
- <td align="left" colspan="3">
- <xsl:call-template
name="msgbox"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
- <form method="post" name="form" action="{$form_action}">
-
- <tr>
- <td>
- <xsl:value-of select="lang_auto_tax"/>
- </td>
- <td>
- <input type="checkbox" name="auto_tax"
value="True" checked="checked" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_auto_tax_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- <xsl:call-template name="location_form"/>
- <xsl:call-template name="b_account_form"/>
- <tr>
- <td valign="top">
- <xsl:variable
name="lang_vendor"><xsl:value-of select="lang_vendor"/></xsl:variable>
- <input type="button" name="convert"
value="{$lang_vendor}" onClick="abook();" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_select_vendor_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- <td>
- <input type="text" name="vendor_id"
value="{value_vendor_id}" size="4" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_vendor_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- <input type="text" name="vendor_name"
value="{value_vendor_name}" size="20" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_vendor_name_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_janitor"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_janitor_statustext"><xsl:value-of
select="lang_janitor_statustext"/></xsl:variable>
- <xsl:variable
name="select_janitor"><xsl:value-of select="select_janitor"/></xsl:variable>
- <select name="{$select_janitor}"
class="forms" onMouseover="window.status='{$lang_janitor_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_no_janitor"/></option>
- <xsl:apply-templates
select="janitor_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_supervisor"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_supervisor_statustext"><xsl:value-of
select="lang_supervisor_statustext"/></xsl:variable>
- <xsl:variable
name="select_supervisor"><xsl:value-of
select="select_supervisor"/></xsl:variable>
- <select name="{$select_supervisor}"
class="forms" onMouseover="window.status='{$lang_supervisor_statustext}';
return true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_no_supervisor"/></option>
- <xsl:apply-templates
select="supervisor_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of
select="lang_budget_responsible"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_budget_responsible_statustext"><xsl:value-of
select="lang_budget_responsible_statustext"/></xsl:variable>
- <xsl:variable
name="select_budget_responsible"><xsl:value-of
select="select_budget_responsible"/></xsl:variable>
- <select
name="{$select_budget_responsible}" class="forms"
onMouseover="window.status='{$lang_budget_responsible_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_select_budget_responsible"/></option>
- <xsl:apply-templates
select="budget_responsible_list"/>
- </select>
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_order"/>
- </td>
- <td>
- <input type="text" name="order"
value="{value_order}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_order_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_art"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_art_statustext"><xsl:value-of
select="lang_art_statustext"/></xsl:variable>
- <xsl:variable
name="select_art"><xsl:value-of select="select_art"/></xsl:variable>
- <select name="{$select_art}"
class="forms" onMouseover="window.status='{$lang_art_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_select_art"/></option>
- <xsl:apply-templates
select="art_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_type"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_type_statustext"><xsl:value-of
select="lang_type_statustext"/></xsl:variable>
- <xsl:variable
name="select_type"><xsl:value-of select="select_type"/></xsl:variable>
- <select name="{$select_type}"
class="forms" onMouseover="window.status='{$lang_type_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_no_type"/></option>
- <xsl:apply-templates
select="type_list"/>
- </select>
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_dimb"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_dimb_statustext"><xsl:value-of
select="lang_dimb_statustext"/></xsl:variable>
- <xsl:variable
name="select_dimb"><xsl:value-of select="select_dimb"/></xsl:variable>
- <select name="{$select_dimb}"
class="forms" onMouseover="window.status='{$lang_dimb_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_no_dimb"/></option>
- <xsl:apply-templates
select="dimb_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of
select="lang_invoice_number"/>
- </td>
- <td>
- <input type="text" name="invoice_num"
value="{value_invoice_num}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_invoice_num_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_kidnr"/>
- </td>
- <td>
- <input type="text" name="kid_nr"
value="{value_kid_nr}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_kid_nr_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_amount"/>
- </td>
- <td>
- <input type="text" name="amount"
value="{value_amount}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_amount_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of
select="lang_invoice_date"/>
- </td>
- <td>
- <input type="text" id="invoice_date"
name="invoice_date" size="10" value="{value_invoice_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_invoice_date_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- <script type="text/javascript">
- document.writeln('<img
id="invoice_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
- <xsl:value-of
select="calendar_setup_invoice"/>
- </script>
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_no_of_days"/>
- </td>
- <td>
- <input type="text" name="num_days"
value="{value_num_days}" size="4" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_num_days_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- </td>
- </tr>
-
- <tr>
-
- <td valign="top">
- <xsl:value-of
select="lang_payment_date"/>
- </td>
- <td>
- <input type="text" id="payment_date"
name="payment_date" size="10" value="{value_payment_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_payment_date_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- <script type="text/javascript">
- document.writeln('<img
id="payment_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
- <xsl:value-of
select="calendar_setup_payment"/>
- </script>
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_merknad"/>
- </td>
- <td>
- <textarea cols="60" rows="10"
name="merknad" wrap="virtual" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_merknad_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- <xsl:value-of
select="value_merknad"/>
- </textarea>
-
- </td>
- </tr>
-
- <tr height="50">
- <td>
- <xsl:variable
name="lang_add"><xsl:value-of select="lang_add"/></xsl:variable>
- <input type="submit" name="add_invoice"
value="{$lang_add}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_add_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- </form>
- <tr>
- <td>
- <xsl:variable
name="cancel_action"><xsl:value-of select="cancel_action"/></xsl:variable>
- <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
- <form method="post"
action="{$cancel_action}">
- <input type="submit"
name="done" value="{$lang_cancel}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="lang_cancel_statustext"/>
- <xsl:text>';
return true;</xsl:text>
- </xsl:attribute>
- </input>
- </form>
- </td>
- </tr>
- </table>
- </div>
- </xsl:template>
-
-<!-- import -->
-
- <xsl:template match="import">
-
- <script language="JavaScript">
- self.name="first_Window";
- function abook()
- {
- Window1=window.open('<xsl:value-of
select="addressbook_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
- }
- </script>
-
- <xsl:call-template name="menu"/>
- <div align="left">
- <table cellpadding="2" cellspacing="2" width="80%"
align="center">
- <tr>
- <td colspan="2" align="center">
- <xsl:value-of select="message"/>
- </td>
- </tr>
- <xsl:choose>
- <xsl:when test="msgbox_data != ''">
- <tr>
- <td align="left" colspan="3">
- <xsl:call-template
name="msgbox"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
- <form ENCTYPE="multipart/form-data" method="post"
name="form" action="{$form_action}">
-
- <tr>
- <td>
- <xsl:value-of select="lang_auto_tax"/>
- </td>
- <td>
- <input type="checkbox" name="auto_tax"
value="True" checked="checked" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_auto_tax_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_art"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_art_statustext"><xsl:value-of
select="lang_art_statustext"/></xsl:variable>
- <xsl:variable
name="select_art"><xsl:value-of select="select_art"/></xsl:variable>
- <select name="{$select_art}"
class="forms" onMouseover="window.status='{$lang_art_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_select_art"/></option>
- <xsl:apply-templates
select="art_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_type"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_type_statustext"><xsl:value-of
select="lang_type_statustext"/></xsl:variable>
- <xsl:variable
name="select_type"><xsl:value-of select="select_type"/></xsl:variable>
- <select name="{$select_type}"
class="forms" onMouseover="window.status='{$lang_type_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_no_type"/></option>
- <xsl:apply-templates
select="type_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_dimb"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_dimb_statustext"><xsl:value-of
select="lang_dimb_statustext"/></xsl:variable>
- <xsl:variable
name="select_dimb"><xsl:value-of select="select_dimb"/></xsl:variable>
- <select name="{$select_dimb}"
class="forms" onMouseover="window.status='{$lang_dimb_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_no_dimb"/></option>
- <xsl:apply-templates
select="dimb_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of
select="lang_invoice_number"/>
- </td>
- <td>
- <input type="text" name="invoice_num"
value="{value_invoice_num}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_invoice_num_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_kidnr"/>
- </td>
- <td>
- <input type="text" name="kid_nr"
value="{value_kid_nr}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_kid_nr_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:variable
name="lang_vendor"><xsl:value-of select="lang_vendor"/></xsl:variable>
- <input type="button" name="convert"
value="{$lang_vendor}" onClick="abook();" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_select_vendor_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- <td>
- <input type="text" name="vendor_id"
value="{value_vendor_id}" size="6" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_vendor_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- <input type="text" name="vendor_name"
value="{value_vendor_name}" size="20" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_vendor_name_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_janitor"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_janitor_statustext"><xsl:value-of
select="lang_janitor_statustext"/></xsl:variable>
- <xsl:variable
name="select_janitor"><xsl:value-of select="select_janitor"/></xsl:variable>
- <select name="{$select_janitor}"
class="forms" onMouseover="window.status='{$lang_janitor_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_no_janitor"/></option>
- <xsl:apply-templates
select="janitor_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_supervisor"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_supervisor_statustext"><xsl:value-of
select="lang_supervisor_statustext"/></xsl:variable>
- <xsl:variable
name="select_supervisor"><xsl:value-of
select="select_supervisor"/></xsl:variable>
- <select name="{$select_supervisor}"
class="forms" onMouseover="window.status='{$lang_supervisor_statustext}';
return true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_no_supervisor"/></option>
- <xsl:apply-templates
select="supervisor_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of
select="lang_budget_responsible"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_budget_responsible_statustext"><xsl:value-of
select="lang_budget_responsible_statustext"/></xsl:variable>
- <xsl:variable
name="select_budget_responsible"><xsl:value-of
select="select_budget_responsible"/></xsl:variable>
- <select
name="{$select_budget_responsible}" class="forms"
onMouseover="window.status='{$lang_budget_responsible_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_select_budget_responsible"/></option>
- <xsl:apply-templates
select="budget_responsible_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of
select="lang_invoice_date"/>
- </td>
- <td>
- <input type="text" id="invoice_date"
name="invoice_date" size="10" value="{value_invoice_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_invoice_date_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- <script type="text/javascript">
- document.writeln('<img
id="invoice_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
- <xsl:value-of
select="calendar_setup_invoice"/>
- </script>
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_no_of_days"/>
- </td>
- <td>
- <input type="text" name="num_days"
value="{value_num_days}" size="4" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_num_days_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- </td>
- </tr>
-
- <tr>
-
- <td valign="top">
- <xsl:value-of
select="lang_payment_date"/>
- </td>
- <td>
- <input type="text" id="payment_date"
name="payment_date" size="10" value="{value_payment_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_payment_date_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- <script type="text/javascript">
- document.writeln('<img
id="payment_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
- <xsl:value-of
select="calendar_setup_payment"/>
- </script>
- </td>
- </tr>
-
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_file"/>
- </td>
- <td>
- <input type="file" name="tsvfile"
onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_file_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of select="lang_conv"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_conv_statustext"><xsl:value-of
select="lang_conv_statustext"/></xsl:variable>
- <xsl:variable
name="select_conv"><xsl:value-of select="select_conv"/></xsl:variable>
- <select name="{$select_conv}"
class="forms" onMouseover="window.status='{$lang_conv_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_select_conversion"/></option>
- <xsl:apply-templates
select="conv_list"/>
- </select>
- </td>
- </tr>
-
- <tr>
- <td>
- <xsl:value-of select="lang_debug"/>
- </td>
- <td>
- <input type="checkbox" name="download"
value="True" checked="checked" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_debug_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- <tr height="50">
- <td>
- <xsl:variable
name="lang_import"><xsl:value-of select="lang_import"/></xsl:variable>
- <input type="submit" name="convert"
value="{$lang_import}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_import_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- </form>
- <tr>
- <td>
- <xsl:variable
name="cancel_action"><xsl:value-of select="cancel_action"/></xsl:variable>
- <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
- <form method="post"
action="{$cancel_action}">
- <input type="submit"
name="done" value="{$lang_cancel}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="lang_cancel_statustext"/>
- <xsl:text>';
return true;</xsl:text>
- </xsl:attribute>
- </input>
- </form>
- </td>
- </tr>
- </table>
- </div>
- </xsl:template>
-
-<!-- art_list -->
-
- <xsl:template match="art_list">
- <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="num"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="num"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-<!-- type_list -->
-
- <xsl:template match="type_list">
- <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="num"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="num"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-<!-- dimb_list -->
-
- <xsl:template match="dimb_list">
- <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="num"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="num"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-<!-- janitor_list -->
-
- <xsl:template match="janitor_list">
- <xsl:variable name="lid"><xsl:value-of select="lid"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$lid}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="firstname"/> <xsl:value-of select="lastname"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$lid}"><xsl:value-of
disable-output-escaping="yes" select="firstname"/> <xsl:value-of
select="lastname"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-<!-- supervisor_list -->
-
- <xsl:template match="supervisor_list">
- <xsl:variable name="lid"><xsl:value-of select="lid"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$lid}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="firstname"/> <xsl:value-of select="lastname"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$lid}"><xsl:value-of
disable-output-escaping="yes" select="firstname"/> <xsl:value-of
select="lastname"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-<!-- budget_responsible_list -->
-
- <xsl:template match="budget_responsible_list">
- <xsl:variable name="lid"><xsl:value-of select="lid"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$lid}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="firstname"/> <xsl:value-of select="lastname"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$lid}"><xsl:value-of
disable-output-escaping="yes" select="firstname"/> <xsl:value-of
select="lastname"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-<!-- conv_list -->
-
- <xsl:template match="conv_list">
- <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="name"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="name"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-<!-- rollback_file_list -->
-
- <xsl:template match="rollback_file_list">
- <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="name"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="name"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-<!-- tax_code_list -->
-
- <xsl:template match="tax_code_list">
- <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected">
- <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="id"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="id"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-<!-- export -->
-
- <xsl:template match="export">
- <xsl:call-template name="menu"/>
- <div align="left">
- <table cellpadding="2" cellspacing="2" width="80%"
align="center">
- <xsl:choose>
- <xsl:when test="msgbox_data != ''">
- <tr>
- <td align="left" colspan="3">
- <xsl:call-template
name="msgbox"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
- <form method="post" name="form" action="{$form_action}">
-
-
- <tr>
- <td valign="top">
- <xsl:value-of
select="lang_select_conv"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_conv_statustext"><xsl:value-of
select="lang_conv_statustext"/></xsl:variable>
- <xsl:variable
name="select_conv"><xsl:value-of select="select_conv"/></xsl:variable>
- <select name="{$select_conv}"
class="forms" onMouseover="window.status='{$lang_conv_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_select_conv"/></option>
- <xsl:apply-templates
select="conv_list"/>
- </select>
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of
select="lang_force_period_year"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_force_period_year_statustext"><xsl:value-of
select="lang_force_period_year_statustext"/></xsl:variable>
- <select
name="values[force_period_year]" class="forms"
onMouseover="window.status='{$lang_force_period_year_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_select_year"/></option>
- <xsl:apply-templates
select="force_period_year"/>
- </select>
- </td>
- </tr>
- <tr>
- <td>
- <xsl:value-of
select="lang_export_to_file"/>
- </td>
- <td>
- <input type="checkbox"
name="values[download]" value="on" checked="checked"
onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_debug_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
-
- <tr>
- <td>
- </td>
- <td>
- <xsl:variable
name="link_rollback_file"><xsl:value-of
select="link_rollback_file"/></xsl:variable>
- <a
href="{$link_rollback_file}"><xsl:value-of select="lang_rollback_file"/></a>
- </td>
- </tr>
-
- <tr height="50">
- <td>
- <xsl:variable
name="lang_submit"><xsl:value-of select="lang_submit"/></xsl:variable>
- <input type="submit"
name="values[submit]" value="{$lang_submit}"
onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_import_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- </form>
- <tr>
- <td>
- <xsl:variable
name="cancel_action"><xsl:value-of select="cancel_action"/></xsl:variable>
- <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
- <form method="post"
action="{$cancel_action}">
- <input type="submit"
name="done" value="{$lang_cancel}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="lang_cancel_statustext"/>
- <xsl:text>';
return true;</xsl:text>
- </xsl:attribute>
- </input>
- </form>
- </td>
- </tr>
- </table>
- </div>
- </xsl:template>
-
-
-<!-- rollback -->
-
- <xsl:template match="rollback">
- <xsl:call-template name="menu"/>
- <div align="left">
- <table cellpadding="2" cellspacing="2" width="80%"
align="center">
- <xsl:choose>
- <xsl:when test="msgbox_data != ''">
- <tr>
- <td align="left" colspan="3">
- <xsl:call-template
name="msgbox"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
- <form method="post" name="form" action="{$form_action}">
-
-
- <tr>
- <td valign="top">
- <xsl:value-of
select="lang_select_conv"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_conv_statustext"><xsl:value-of
select="lang_conv_statustext"/></xsl:variable>
- <xsl:variable
name="select_conv"><xsl:value-of select="select_conv"/></xsl:variable>
- <select name="{$select_conv}"
class="forms" onMouseover="window.status='{$lang_conv_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_select_conv"/></option>
- <xsl:apply-templates
select="conv_list"/>
- </select>
- </td>
- </tr>
- <tr>
- <td valign="top">
- <xsl:value-of
select="lang_select_file"/>
- </td>
- <td valign="top">
- <xsl:variable
name="lang_file_statustext"><xsl:value-of
select="lang_file_statustext"/></xsl:variable>
- <xsl:variable
name="select_file"><xsl:value-of select="select_file"/></xsl:variable>
- <select name="{$select_file}"
class="forms" onMouseover="window.status='{$lang_file_statustext}'; return
true;" onMouseout="window.status='';return true;">
- <option value=""><xsl:value-of
select="lang_no_file"/></option>
- <xsl:apply-templates
select="rollback_file_list"/>
- </select>
- </td>
- </tr>
-
-
- <tr>
-
- <td valign="top">
- <xsl:value-of select="lang_date"/>
- </td>
- <td>
- <input type="text" id="date"
name="date" size="10" value="{value_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_date_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
-
- <script type="text/javascript">
- document.writeln('<img
id="date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
- <xsl:value-of select="calendar_setup"/>
- </script>
- </td>
- </tr>
-
- <tr height="50">
- <td>
- <xsl:variable
name="lang_submit"><xsl:value-of select="lang_submit"/></xsl:variable>
- <input type="submit"
name="values[submit]" value="{$lang_submit}"
onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
- <xsl:value-of
select="lang_import_statustext"/>
- <xsl:text>'; return
true;</xsl:text>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- </form>
- <tr>
- <td>
- <xsl:variable
name="cancel_action"><xsl:value-of select="cancel_action"/></xsl:variable>
- <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
- <form method="post"
action="{$cancel_action}">
- <input type="submit"
name="done" value="{$lang_cancel}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="lang_cancel_statustext"/>
- <xsl:text>';
return true;</xsl:text>
- </xsl:attribute>
- </input>
- </form>
- </td>
- </tr>
- </table>
- </div>
- </xsl:template>
-
-
-<!--list_invoice_sub-->
-
- <xsl:template match="list_invoice_sub">
- <div id="overDiv" style="position:absolute;
visibility:hide;z-index:1;"></div>
- <xsl:variable name="overlib_source"><xsl:value-of
select="overlib_source"/></xsl:variable>
- <SCRIPT LANGUAGE="JavaScript" SRC="{$overlib_source}"></SCRIPT>
- <SCRIPT LANGUAGE="JavaScript" SRC="{check_source}"></SCRIPT>
-
- <xsl:call-template name="menu"/>
- <table width="80%" cellpadding="2" cellspacing="2"
align="center">
- <xsl:choose>
- <xsl:when test="msgbox_data != ''">
- <tr>
- <td align="left" colspan="3">
- <xsl:call-template
name="msgbox"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test="vendor!=''">
- <tr>
- <td width="25%" class="th_text"
align="left">
- <xsl:value-of
select="lang_vendor"/>
- </td>
- <td width="25%" class="th_text"
align="left">
- <xsl:value-of
select="vendor"/>
- </td>
- <td width="50%">
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test="voucher_id!=''">
- <tr>
- <td width="25%" class="th_text"
align="left">
- <xsl:value-of
select="lang_voucher_id"/>
- </td>
- <td width="25%" class="th_text"
align="left">
- <xsl:value-of
select="voucher_id"/>
- </td>
- <td width="50%">
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- </table>
- <table width="100%" cellpadding="2" cellspacing="2"
align="center">
- <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
- <form method="post" name="form" action="{$form_action}">
- <xsl:apply-templates
select="table_header_list_invoice_sub"/>
-
- <xsl:choose>
- <xsl:when test="values_list_invoice_sub[id]">
- <xsl:apply-templates
select="values_list_invoice_sub"/>
- <xsl:variable
name="img_check"><xsl:value-of select="img_check"/></xsl:variable>
- <tr>
- <td></td>
- <td align="center">
- <a
href="javascript:check_all_checkbox('values[close_order]')"><img
src="{$img_check}" border="0" height="16" width="21"
alt="{lang_select_all}"/></a>
- </td>
- <td></td>
- <td></td>
- <td></td>
- <td class="small_text"
align="right">
- <xsl:value-of
select="sum"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- <tr height="50">
- <td>
- <xsl:choose>
- <xsl:when test="paid=''">
- <xsl:variable
name="lang_save"><xsl:value-of select="lang_save"/></xsl:variable>
- <input type="submit"
name="values[save][0]" value="{$lang_save}" onMouseout="window.status='';return
true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="lang_save_statustext"/>
-
<xsl:text>'; return true;</xsl:text>
- </xsl:attribute>
- </input>
- </xsl:when>
- </xsl:choose>
- </td>
- </tr>
- </form>
- <tr>
- <td>
- <xsl:variable
name="done_action"><xsl:value-of select="done_action"/></xsl:variable>
- <xsl:variable
name="lang_done"><xsl:value-of select="lang_done"/></xsl:variable>
- <form method="post"
action="{$done_action}">
- <input type="submit"
name="done" value="{$lang_done}" onMouseout="window.status='';return true;">
- <xsl:attribute
name="onMouseover">
-
<xsl:text>window.status='</xsl:text>
-
<xsl:value-of select="lang_done_statustext"/>
- <xsl:text>';
return true;</xsl:text>
- </xsl:attribute>
- </input>
- </form>
- </td>
- </tr>
-
- </table>
- </xsl:template>
-
- <xsl:template match="table_header_list_invoice_sub">
- <xsl:variable name="sort_workorder"><xsl:value-of
select="sort_workorder"/></xsl:variable>
- <xsl:variable name="sort_budget_account"><xsl:value-of
select="sort_budget_account"/></xsl:variable>
- <xsl:variable name="sort_sum"><xsl:value-of
select="sort_sum"/></xsl:variable>
- <xsl:variable name="sort_dima"><xsl:value-of
select="sort_dima"/></xsl:variable>
- <tr class="th">
- <td class="th_text" width="5%" align="right">
- <a
href="{$sort_workorder}"><xsl:value-of select="lang_workorder"/></a>
- </td>
- <td class="th_text" width="2%" align="right">
- <xsl:value-of
select="lang_close_order"/>
- </td>
- <td class="th_text" width="2%" align="right">
- <xsl:value-of
select="lang_charge_tenant"/>
- </td>
- <td class="th_text" width="2%" align="right">
- <xsl:value-of select="lang_invoice_id"/>
- </td>
- <td class="th_text" width="2%" align="right">
- <a
href="{$sort_budget_account}"><xsl:value-of select="lang_budget_account"/></a>
- </td>
- <td class="th_text" width="5%" align="right">
- <a href="{$sort_sum}"><xsl:value-of
select="lang_sum"/></a>
- </td>
- <td class="th_text" width="5%" align="right">
- <a href="{$sort_dima}"><xsl:value-of
select="lang_dima"/></a>
- </td>
- <td class="th_text" width="2%" align="right">
- <xsl:value-of select="lang_dimb"/>
- </td>
- <td class="th_text" width="5%" align="right">
- <xsl:value-of select="lang_dimd"/>
- </td>
- <td class="th_text" width="2%" align="right">
- <xsl:value-of select="lang_tax_code"/>
- </td>
- <td class="th_text" width="2%" align="right">
- <xsl:value-of select="lang_remark"/>
- </td>
- </tr>
- </xsl:template>
-
- <xsl:template match="values_list_invoice_sub">
-
- <xsl:variable name="counter"><xsl:value-of
select="counter"/></xsl:variable>
- <xsl:variable name="current_user"><xsl:value-of
select="current_user"/></xsl:variable>
- <tr>
- <xsl:attribute name="class">
- <xsl:choose>
- <xsl:when test="@class">
- <xsl:value-of
select="@class"/>
- </xsl:when>
- <xsl:when test="position() mod
2 = 0">
-
<xsl:text>row_off</xsl:text>
- </xsl:when>
- <xsl:otherwise>
-
<xsl:text>row_on</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
-
- <td align="right">
- <input type="hidden"
name="values[counter][{$counter}]" value="{counter}">
- </input>
- <input type="hidden"
name="values[id][{$counter}]" value="{id}">
- </input>
- <input type="hidden"
name="values[workorder_id][{$counter}]" value="{workorder_id}">
- </input>
- <xsl:variable
name="link_order"><xsl:value-of
select="link_order"/>&order_id=<xsl:value-of
select="workorder_id"/></xsl:variable>
- <a href="{$link_order}"
target="_blank"><xsl:value-of select="workorder_id"/></a>
- </td>
- <td class="small_text" align="center">
- <xsl:choose>
- <xsl:when
test="workorder_id=''">
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when
test="paid=''">
- <input
type="hidden" name="values[close_order_orig][{$counter}]" value="{closed}">
- </input>
-
<xsl:choose>
-
<xsl:when test="closed='1'">
-
<input type="checkbox" name="values[close_order][{$counter}]"
value="true" checked="checked" onMouseout="window.status='';return true;">
-
</input>
-
</xsl:when>
-
<xsl:otherwise>
-
<input type="checkbox" name="values[close_order][{$counter}]"
value="true" onMouseout="window.status='';return true;">
-
</input>
-
</xsl:otherwise>
-
</xsl:choose>
- </xsl:when>
- <xsl:otherwise>
-
<xsl:choose>
-
<xsl:when test="closed='1'">
-
<b>x</b>
-
</xsl:when>
-
</xsl:choose>
-
</xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </td>
- <td class="small_text" align="center">
- <xsl:choose>
- <xsl:when
test="charge_tenant='1'">
- <xsl:choose>
- <xsl:when
test="claim_issued=''">
-
<xsl:variable name="link_claim"><xsl:value-of
select="link_claim"/>&project_id=<xsl:value-of
select="project_id"/></xsl:variable>
- <a
href="{$link_claim}" target="_blank"><xsl:value-of select="//lang_claim"/></a>
- </xsl:when>
- </xsl:choose>
- <b>x</b>
- </xsl:when>
- </xsl:choose>
- </td>
- <td class="small_text" align="right">
- <xsl:value-of select="invoice_id"/>
- </td>
- <td class="small_text" align="right">
- <xsl:choose>
- <xsl:when test="paid='true'">
- <xsl:value-of
select="budget_account"/>
- </xsl:when>
- <xsl:otherwise>
- <input type="text"
size="7" name="values[budget_account][{$counter}]" value="{budget_account}">
- </input>
- </xsl:otherwise>
- </xsl:choose>
- </td>
- <td class="small_text" align="right">
- <xsl:value-of select="amount"/>
- </td>
- <td class="small_text" align="center">
- <xsl:choose>
- <xsl:when test="paid='true'">
- <xsl:value-of
select="dima"/>
- </xsl:when>
- <xsl:otherwise>
- <input type="text"
size="7" name="values[dima][{$counter}]" value="{dima}">
- </input>
- </xsl:otherwise>
- </xsl:choose>
- </td>
- <td class="small_text" align="right">
- <xsl:value-of select="dimb"/>
- </td>
- <td class="small_text" align="center">
- <xsl:choose>
- <xsl:when test="paid='true'">
- <xsl:value-of
select="dimd"/>
- </xsl:when>
- <xsl:otherwise>
- <input type="text"
size="4" name="values[dimd][{$counter}]" value="{dimd}">
- </input>
- </xsl:otherwise>
- </xsl:choose>
- </td>
- <td class="small_text" align="center">
- <xsl:choose>
- <xsl:when test="paid='true'">
- <xsl:value-of
select="tax_code"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable
name="lang_tax_code_statustext"><xsl:value-of
select="lang_tax_code_statustext"/></xsl:variable>
- <select
name="values[tax_code][{$counter}]" class="forms"
onMouseover="window.status='{$lang_tax_code_statustext}'; return true;"
onMouseout="window.status='';return true;">
-
<xsl:apply-templates select="tax_code_list"/>
- </select>
- </xsl:otherwise>
- </xsl:choose>
- </td>
- <td class="small_text" align="right">
- <xsl:choose>
- <xsl:when test="remark='1'">
- <xsl:variable
name="link_remark"><xsl:value-of select="link_remark"/>&id=<xsl:value-of
select="id"/>&paid=<xsl:value-of select="paid"/></xsl:variable>
- <xsl:variable
name="lang_remark_help"><xsl:value-of select="lang_remark_help"/></xsl:variable>
- <xsl:variable
name="lang_remark"><xsl:value-of select="lang_remark"/></xsl:variable>
- <a href="javascript:var
w=window.open('{$link_remark}','','width=550,height=400,scrollbars')"
-
onMouseOver="overlib('{$lang_remark_help}', CAPTION, '{$lang_remark}')"
- onMouseOut="nd()">
- <xsl:value-of
select="lang_remark"/></a>
- </xsl:when>
- </xsl:choose>
- </td>
-
- </tr>
- </xsl:template>
-
- <xsl:template match="force_period_year">
- <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="selected='selected'">
- <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="id"/></option>
- </xsl:when>
- <xsl:otherwise>
- <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="id"/></option>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
+<!-- $Id: invoice.xsl,v 1.13 2006/01/27 14:05:59 sigurdne Exp $ -->
+
+ <xsl:template name="app_data">
+ <xsl:choose>
+ <xsl:when test="add">
+ <xsl:apply-templates select="add"/>
+ </xsl:when>
+ <xsl:when test="edit">
+ <xsl:apply-templates select="edit"/>
+ </xsl:when>
+ <xsl:when test="import">
+ <xsl:apply-templates select="import"/>
+ </xsl:when>
+ <xsl:when test="export">
+ <xsl:apply-templates select="export"/>
+ </xsl:when>
+ <xsl:when test="rollback">
+ <xsl:apply-templates select="rollback"/>
+ </xsl:when>
+ <xsl:when test="debug">
+ <xsl:apply-templates select="debug"/>
+ </xsl:when>
+ <xsl:when test="edit_period">
+ <xsl:apply-templates select="edit_period"/>
+ </xsl:when>
+ <xsl:when test="list_voucher">
+ <xsl:apply-templates select="list_voucher"/>
+ </xsl:when>
+ <xsl:when test="list_voucher_paid">
+ <xsl:apply-templates
select="list_voucher_paid"/>
+ </xsl:when>
+ <xsl:when test="consume">
+ <xsl:apply-templates select="consume"/>
+ </xsl:when>
+ <xsl:when test="remark">
+ <xsl:apply-templates select="remark"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="list_invoice_sub"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="edit_period">
+ <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
+ <form method="post" action="{$form_action}">
+ <div align="center">
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <xsl:choose>
+ <xsl:when test="msgbox_data != ''">
+ <tr>
+ <td align="left" colspan="3">
+ <xsl:call-template
name="msgbox"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <tr>
+ <td>
+ <xsl:variable name="select_name"><xsl:value-of
select="select_name"/></xsl:variable>
+ <select name="{$select_name}" class="forms" >
+ <xsl:apply-templates
select="period_list"/>
+ </select>
+ </td>
+ </tr>
+ <tr height="50">
+ <td>
+ <xsl:variable
name="lang_save"><xsl:value-of select="lang_save"/></xsl:variable>
+ <input type="submit" name="submit"
value="{$lang_save}" >
+ </input>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </form>
+ </xsl:template>
+
+ <xsl:template match="period_list">
+ <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="name"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="name"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <xsl:template match="remark">
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <tr>
+ <td colspan="2" align="center">
+ <xsl:value-of select="message"/>
+ </td>
+ </tr>
+ <tr>
+ <td align="center">
+ <textarea cols="60" rows="15"
name="remark" readonly="readonly" wrap="virtual"
onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_content_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ <xsl:value-of select="remark"/>
+ </textarea>
+ </td>
+ </tr>
+
+ </table>
+ </xsl:template>
+
+ <xsl:template name="excel">
+ <xsl:variable name="link_excel"><xsl:value-of
select="link_excel"/></xsl:variable>
+ <xsl:variable name="lang_excel_help"><xsl:value-of
select="lang_excel_help"/></xsl:variable>
+ <xsl:variable name="lang_excel"><xsl:value-of
select="lang_excel"/></xsl:variable>
+ <a href="javascript:var
w=window.open('{$link_excel}','','')"
+ onMouseOver="overlib('{$lang_excel_help}',
CAPTION, '{$lang_excel}')"
+ onMouseOut="nd()">
+ <xsl:value-of select="lang_excel"/></a>
+ </xsl:template>
+
+
+<!-- list_voucher -->
+
+ <xsl:template match="list_voucher">
+ <div id="overDiv" style="position:absolute;
visibility:hide;z-index:1;"></div>
+ <xsl:variable name="overlib_source"><xsl:value-of
select="overlib_source"/></xsl:variable>
+ <SCRIPT LANGUAGE="JavaScript" SRC="{$overlib_source}"></SCRIPT>
+ <xsl:variable name="check_source"><xsl:value-of
select="check_source"/></xsl:variable>
+ <SCRIPT LANGUAGE="JavaScript" SRC="{$check_source}"></SCRIPT>
+ <xsl:call-template name="menu"/>
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <xsl:choose>
+ <xsl:when test="msgbox_data != ''">
+ <tr>
+ <td align="left" colspan="3">
+ <xsl:call-template
name="msgbox"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+
+ <tr>
+ <td>
+ <xsl:call-template name="cat_filter"/>
+ </td>
+ <td align="center">
+ <xsl:call-template
name="user_lid_filter"/>
+ </td>
+ <td align="right">
+ <xsl:call-template name="search_field"/>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3" width="100%">
+ <xsl:call-template name="nextmatchs"/>
+ </td>
+ <td colspan="3" width="100%" class="small_text"
valign="top" align="left">
+ <xsl:call-template name="excel"/>
+ </td>
+ </tr>
+ </table>
+ <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
+ <form method="post" name="form" action="{$form_action}">
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <xsl:apply-templates
select="table_header_list_voucher"/>
+
+ <xsl:choose>
+ <xsl:when
test="values_list_voucher[voucher_id]">
+ <xsl:apply-templates
select="values_list_voucher"/>
+
+ </xsl:when>
+ </xsl:choose>
+ <xsl:variable name="img_check"><xsl:value-of
select="img_check"/></xsl:variable>
+ <tr>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td class="small_text" align="right">
+ <xsl:value-of select="sum"/>
+ </td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td align="center">
+ <a
href="javascript:check_all_radio('sign_none')"><img src="{$img_check}"
border="0" height="16" width="21" alt="{lang_select_all}"/></a>
+ </td>
+ <td align="center">
+ <a
href="javascript:check_all_radio('sign_janitor')"><img src="{$img_check}"
border="0" height="16" width="21" alt="{lang_select_all}"/></a>
+ </td>
+ <td align="center">
+ <a
href="javascript:check_all_radio('sign_supervisor')"><img src="{$img_check}"
border="0" height="16" width="21" alt="{lang_select_all}"/></a>
+ </td>
+ <td align="center">
+ <a
href="javascript:check_all_radio('sign_budget_responsible')"><img
src="{$img_check}" border="0" height="16" width="21"
alt="{lang_select_all}"/></a>
+ </td>
+ <td align="right">
+ <a
href="javascript:check_all_checkbox('values[transfer]')"><img
src="{$img_check}" border="0" height="16" width="21"
alt="{lang_select_all}"/></a>
+ </td>
+ </tr>
+
+ <tr height="50">
+ <td>
+ <xsl:variable
name="lang_save"><xsl:value-of select="lang_save"/></xsl:variable>
+ <input type="submit"
name="values[save]" value="{$lang_save}" onMouseout="window.status='';return
true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_save_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+
+ </table>
+ </form>
+ <xsl:choose>
+ <xsl:when test="table_add_invoice !=''">
+ <xsl:apply-templates
select="table_add_invoice"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="table_add_invoice">
+ <table align = "left">
+ <tr>
+ <td height="50" align="left" valign="top">
+ <xsl:variable
name="add_action"><xsl:value-of select="add_action"/></xsl:variable>
+ <xsl:variable
name="lang_add"><xsl:value-of select="lang_add"/></xsl:variable>
+ <form method="post"
action="{$add_action}">
+ <input type="submit" name=""
value="{$lang_add}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="lang_add_statustext"/>
+ <xsl:text>';
return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </form>
+ </td>
+ </tr>
+ </table>
+ </xsl:template>
+
+
+ <xsl:template match="table_header_list_voucher">
+ <xsl:variable name="sort_voucher"><xsl:value-of
select="sort_voucher"/></xsl:variable>
+ <xsl:variable name="sort_voucher_date"><xsl:value-of
select="sort_voucher_date"/></xsl:variable>
+ <xsl:variable name="sort_vendor_id"><xsl:value-of
select="sort_vendor_id"/></xsl:variable>
+ <tr class="th">
+ <td class="th_text" width="5%" align="right">
+ <a href="{$sort_voucher}"><xsl:value-of
select="lang_voucher"/></a>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <a
href="{$sort_voucher_date}"><xsl:value-of select="lang_voucher_date"/></a>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <xsl:value-of select="lang_days"/>
+ </td>
+ <td class="th_text" width="8%" align="right">
+ <xsl:value-of select="lang_sum"/>
+ </td>
+ <td class="th_text" width="4%" align="right">
+ <a
href="{$sort_vendor_id}"><xsl:value-of select="lang_vendor_id"/></a>
+ </td>
+ <td class="th_text" width="3%" align="right">
+ <xsl:value-of
select="lang_num_sub_invoice"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of select="lang_type"/>
+ </td>
+ <td class="th_text" width="3%" align="right">
+ <xsl:value-of select="lang_period"/>
+ </td>
+ <td class="th_text" width="3%" align="right">
+ <xsl:value-of select="lang_kredit"/>
+ </td>
+ <td class="th_text" width="3%" align="right">
+ <xsl:value-of select="lang_none"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of select="lang_janitor"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of select="lang_supervisor"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of
select="lang_budget_responsible"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of select="lang_transfer"/>
+ </td>
+ <xsl:choose>
+ <xsl:when test="//acl_delete!=''">
+ <td class="th_text" width="5%"
align="center">
+ <xsl:value-of
select="lang_delete"/>
+ </td>
+ </xsl:when>
+ </xsl:choose>
+ </tr>
+ </xsl:template>
+
+ <xsl:template match="values_list_voucher">
+
+ <xsl:variable name="counter"><xsl:value-of
select="counter"/></xsl:variable>
+ <xsl:variable name="current_user"><xsl:value-of
select="current_user"/></xsl:variable>
+ <tr>
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="@class">
+ <xsl:value-of
select="@class"/>
+ </xsl:when>
+ <xsl:when test="position() mod
2 = 0">
+
<xsl:text>row_off</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+
<xsl:text>row_on</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+
+ <td class="small_text" align="right">
+ <input type="hidden"
name="values[counter][{$counter}]" value="{counter}">
+ </input>
+ <input type="hidden"
name="values[voucher_id][{$counter}]" value="{voucher_id}">
+ </input>
+ <xsl:variable
name="link_sub"><xsl:value-of select="link_sub"/>&voucher_id=<xsl:value-of
select="voucher_id"/></xsl:variable>
+ <xsl:variable
name="lang_sub_help"><xsl:value-of select="lang_sub_help"/></xsl:variable>
+ <xsl:variable
name="lang_sub"><xsl:value-of select="lang_sub"/></xsl:variable>
+ <a href="{$link_sub}"
+
onMouseOver="overlib('{$lang_sub_help}', CAPTION, '{$lang_sub}')"
+ onMouseOut="nd()">
+ <xsl:value-of select="voucher_id"/></a>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:variable
name="lang_payment_date"><xsl:value-of
select="lang_payment_date"/></xsl:variable>
+ <xsl:variable
name="payment_date"><xsl:value-of select="payment_date"/></xsl:variable>
+ <a href="javascript:void()"
+ onMouseOver="overlib('{$payment_date}',
CAPTION, '{$lang_payment_date}')"
+ onMouseOut="nd()">
+ <xsl:value-of
select="voucher_date"/></a>
+ </td>
+ <td class="small_text" align="right">
+ <input type="hidden"
name="values[sign_orig][{$counter}]" value="{sign_orig}">
+ </input>
+ <input type="hidden"
name="values[num_days_orig][{$counter}]" value="{num_days}">
+ </input>
+ <input type="hidden"
name="values[timestamp_voucher_date][{$counter}]"
value="{timestamp_voucher_date}">
+ </input>
+ <input type="text" size="2"
name="values[num_days][{$counter}]" value="{num_days}">
+ </input>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:value-of select="amount"/>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:variable
name="vendor"><xsl:value-of select="vendor"/></xsl:variable>
+ <xsl:variable
name="vendor_id"><xsl:value-of select="vendor_id"/></xsl:variable>
+ <a href="javascript:void()"
+ onMouseOver="overlib('{$vendor}',
CAPTION, '{$vendor_id}')"
+ onMouseOut="nd()">
+ <xsl:value-of select="vendor_id"/></a>
+
+ </td>
+ <td class="small_text" align="right">
+ <input type="hidden"
name="values[invoice_count][{$counter}]" value="{invoice_count}">
+ </input>
+ <xsl:value-of select="invoice_count"/>
+ </td>
+ <td class="small_text" align="center">
+ <xsl:value-of select="type"/>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:variable
name="link_period"><xsl:value-of
select="link_period"/>&voucher_id=<xsl:value-of
select="voucher_id"/>&period=<xsl:value-of select="period"/></xsl:variable>
+ <xsl:variable
name="lang_period_help"><xsl:value-of select="lang_period_help"/></xsl:variable>
+ <xsl:variable
name="lang_period"><xsl:value-of select="lang_period"/></xsl:variable>
+ <a href="javascript:var
w=window.open('{$link_period}','','width=150,height=150')"
+
onMouseOver="overlib('{$lang_period_help}', CAPTION, '{$lang_period}')"
+ onMouseOut="nd()">
+ <xsl:value-of select="period"/></a>
+ </td>
+ <td align="center">
+ <xsl:choose>
+ <xsl:when test="kreditnota='1'">
+ <input type="checkbox"
name="values[kreditnota][{$counter}]" value="true" checked="checked"
onMouseout="window.status='';return true;">
+ </input>
+ </xsl:when>
+ <xsl:otherwise>
+ <input type="checkbox"
name="values[kreditnota][{$counter}]" value="true"
onMouseout="window.status='';return true;">
+ </input>
+ </xsl:otherwise>
+ </xsl:choose>
+ </td>
+ <td class="small_text" align="center">
+ <xsl:choose>
+ <xsl:when test="is_janitor">
+ <input type="radio"
name="values[sign][{$counter}]" value="sign_none"
onMouseout="window.status='';return true;">
+ </input>
+ </xsl:when>
+ <xsl:when test="is_supervisor">
+ <input type="radio"
name="values[sign][{$counter}]" value="sign_none"
onMouseout="window.status='';return true;">
+ </input>
+ </xsl:when>
+ <xsl:when
test="is_budget_responsible">
+ <input type="radio"
name="values[sign][{$counter}]" value="sign_none"
onMouseout="window.status='';return true;">
+ </input>
+ </xsl:when>
+ <xsl:otherwise>
+ </xsl:otherwise>
+ </xsl:choose>
+ </td>
+ <td class="small_text" align="right">
+
+ <xsl:choose>
+ <xsl:when
test="is_janitor='32'">
+ <xsl:choose>
+ <xsl:when
test="jan_date=''">
+ <input
type="radio" name="values[sign][{$counter}]" value="sign_janitor"
onMouseout="window.status='';return true;">
+
</input>
+ </xsl:when>
+ <xsl:otherwise>
+
<xsl:choose>
+
<xsl:when test="janitor = $current_user">
+
<input type="radio" name="values[sign][{$counter}]"
value="sign_janitor" checked="checked" onMouseout="window.status='';return
true;">
+
</input>
+
</xsl:when>
+
<xsl:otherwise>
+
<input type="checkbox" name="" value="" checked="checked"
disabled="disabled" ></input>
+
</xsl:otherwise>
+
</xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when
test="jan_date=''">
+ </xsl:when>
+ <xsl:otherwise>
+ <input
type="checkbox" name="" value="" checked="checked" disabled="disabled" ></input>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:value-of select="janitor"/>
+ </td>
+ <td class="small_text" align="right">
+
+ <xsl:choose>
+ <xsl:when
test="is_supervisor='64'"><xsl:value-of select="super_date"/>
+ <xsl:choose>
+ <xsl:when
test="super_date=''">
+ <input
type="radio" name="values[sign][{$counter}]" value="sign_supervisor"
onMouseout="window.status='';return true;">
+
</input>
+ </xsl:when>
+ <xsl:when
test="super_date!=''">
+
<xsl:choose>
+
<xsl:when test="supervisor = $current_user">
+
<input type="radio" name="values[sign][{$counter}]"
value="sign_supervisor" checked="checked" onMouseout="window.status='';return
true;">
+
</input>
+
</xsl:when>
+
<xsl:otherwise>
+
<input type="checkbox" name="" value="" checked="checked"
disabled="disabled" ></input>
+
</xsl:otherwise>
+
</xsl:choose>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when
test="super_date=''">
+ </xsl:when>
+ <xsl:otherwise>
+ <input
type="checkbox" name="" value="" checked="checked" disabled="disabled" ></input>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:value-of select="supervisor"/>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:choose>
+ <xsl:when
test="is_budget_responsible='128'">
+ <xsl:choose>
+ <xsl:when
test="budget_date=''">
+ <input
type="radio" name="values[sign][{$counter}]" value="sign_budget_responsible"
onMouseout="window.status='';return true;">
+
</input>
+ </xsl:when>
+ <xsl:otherwise>
+
<xsl:choose>
+
<xsl:when test="budget_responsible = $current_user">
+
<input type="radio" name="values[sign][{$counter}]"
value="sign_budget_responsible" checked="checked"
onMouseout="window.status='';return true;">
+
</input>
+
</xsl:when>
+
<xsl:otherwise>
+
<input type="checkbox" name="" value="" checked="checked"
disabled="disabled" ></input>
+
</xsl:otherwise>
+
</xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when
test="budget_date=''">
+ </xsl:when>
+ <xsl:otherwise>
+ <input
type="checkbox" name="" value="" checked="checked" disabled="disabled" ></input>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:value-of
select="budget_responsible"/>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:choose>
+ <xsl:when
test="is_transfer='16'">
+ <xsl:choose>
+ <xsl:when
test="transfer_date=''">
+ <input
type="checkbox" name="values[transfer][{$counter}]" value="true"
onMouseout="window.status='';return true;">
+ </input>
+ </xsl:when>
+ <xsl:otherwise>
+ <input
type="checkbox" name="values[transfer][{$counter}]" value="true"
checked="checked" onMouseout="window.status='';return true;">
+
</input>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when
test="transfer_id!=''">
+ <input
type="checkbox" name="" value="" checked="checked" disabled="disabled" ></input>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:value-of select="transfer_id"/>
+ </td>
+ <xsl:choose>
+ <xsl:when test="//acl_delete!=''">
+ <xsl:variable
name="lang_delete_statustext"><xsl:value-of
select="lang_delete_statustext"/></xsl:variable>
+ <td class="small_text"
align="center">
+ <xsl:variable
name="link_delete"><xsl:value-of select="link_delete"/></xsl:variable>
+ <a href="{$link_delete}"
onMouseover="window.status='{$lang_delete_statustext}';return true;"
onMouseout="window.status='';return true;"><xsl:value-of
select="text_delete"/></a>
+ </td>
+ </xsl:when>
+ </xsl:choose>
+ </tr>
+ </xsl:template>
+
+
+
+<!-- list_voucher_paid -->
+
+ <xsl:template match="list_voucher_paid">
+ <div id="overDiv" style="position:absolute;
visibility:hide;z-index:1;"></div>
+ <xsl:variable name="overlib_source"><xsl:value-of
select="overlib_source"/></xsl:variable>
+ <SCRIPT LANGUAGE="JavaScript" SRC="{$overlib_source}"></SCRIPT>
+
+ <script language="JavaScript">
+ self.name="first_Window";
+ function abook()
+ {
+ Window1=window.open('<xsl:value-of
select="addressbook_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
+ }
+ function property_lookup()
+ {
+ Window1=window.open('<xsl:value-of
select="property_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
+ }
+ </script>
+
+ <xsl:call-template name="menu"/>
+ <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
+ <div align="left">
+ <form method="post" name="form" action="{$form_action}">
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <xsl:choose>
+ <xsl:when test="msgbox_data != ''">
+ <tr>
+ <td align="left" colspan="3">
+ <xsl:call-template
name="msgbox"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+
+ <tr>
+ <td>
+ <input type="text" id="start_date"
name="start_date" size="10" value="{start_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_start_date_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ <script type="text/javascript">
+ document.writeln('<img
id="start_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
+ <xsl:value-of
select="calendar_setup_start"/>
+ </script>
+ </td>
+ <td>
+ <input type="text" id="end_date"
name="end_date" size="10" value="{end_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_end_date_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ <script type="text/javascript">
+ document.writeln('<img
id="end_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
+ <xsl:value-of
select="calendar_setup_end"/>
+ </script>
+ </td>
+ <td>
+ <input type="text" size="8"
name="workorder_id" value="{workorder_id}" onMouseout="window.status='';return
true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_workorder_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ <a href="javascript:void()"
+
onMouseOver="overlib('{lang_workorder_statustext}', CAPTION,
'{lang_workorder}')"
+ onMouseOut="nd()">
+ <xsl:value-of
select="lang_workorder"/></a>
+ </td>
+
+ <td align="left">
+ <input type="text" name="vendor_id"
value="{vendor_id}" size="4" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_vendor_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ <a href="javascript:abook()"
+
onMouseOver="overlib('{lang_select_vendor_statustext}', CAPTION,
'{lang_vendor}')"
+ onMouseOut="nd()">
+ <xsl:value-of
select="lang_vendor"/></a>
+
+ <input type="hidden"
name="vendor_name"></input>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <xsl:call-template name="cat_select"/>
+ </td>
+ <td align="left">
+ <xsl:call-template
name="user_lid_select"/>
+ </td>
+ <td align="left">
+ <input type="text" name="loc1"
value="{loc1}" size="4" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_property_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ <a href="javascript:property_lookup()"
+
onMouseOver="overlib('{lang_select_property_statustext}', CAPTION,
'{lang_property}')"
+ onMouseOut="nd()">
+ <xsl:value-of
select="lang_property"/></a>
+
+ <input type="hidden"
name="loc1_name"></input>
+ </td>
+
+ <td align="left">
+ <input type="text" name="voucher_id"
value="{voucher_id}" size="8" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_voucher_id_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="lang_voucher_id"/>
+ </td>
+
+ <td align="left">
+ <xsl:variable
name="lang_search"><xsl:value-of select="lang_search"/></xsl:variable>
+ <input type="submit"
name="submit_search" value="{$lang_search}" onMouseout="window.status='';return
true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_search_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="11" width="100%">
+ <xsl:call-template name="nextmatchs"/>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <xsl:apply-templates
select="table_header_list_voucher_paid"/>
+
+ <xsl:choose>
+ <xsl:when
test="values_list_voucher_paid[voucher_id]">
+ <xsl:apply-templates
select="values_list_voucher_paid"/>
+ <tr>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td class="th_text"
align="right">
+ <xsl:value-of
select="sum"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:variable name="img_check"><xsl:value-of
select="img_check"/></xsl:variable>
+ </table>
+ </xsl:template>
+
+
+ <xsl:template match="table_header_list_voucher_paid">
+ <xsl:variable name="sort_voucher"><xsl:value-of
select="sort_voucher"/></xsl:variable>
+ <xsl:variable name="sort_voucher_date"><xsl:value-of
select="sort_voucher_date"/></xsl:variable>
+ <xsl:variable name="sort_vendor_id"><xsl:value-of
select="sort_vendor_id"/></xsl:variable>
+ <tr class="th">
+ <td class="th_text" width="5%" align="right">
+ <a href="{$sort_voucher}"><xsl:value-of
select="lang_voucher"/></a>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <a
href="{$sort_voucher_date}"><xsl:value-of select="lang_voucher_date"/></a>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <xsl:value-of select="lang_days"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of select="lang_sum"/>
+ </td>
+ <td class="th_text" width="4%" align="right">
+ <a
href="{$sort_vendor_id}"><xsl:value-of select="lang_vendor_id"/></a>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of
select="lang_num_sub_invoice"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of select="lang_type"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of select="lang_janitor"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of select="lang_supervisor"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of
select="lang_budget_responsible"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of select="lang_transfer"/>
+ </td>
+ </tr>
+ </xsl:template>
+
+ <xsl:template match="values_list_voucher_paid">
+
+ <xsl:variable name="counter"><xsl:value-of
select="counter"/></xsl:variable>
+ <xsl:variable name="current_user"><xsl:value-of
select="current_user"/></xsl:variable>
+ <tr>
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="@class">
+ <xsl:value-of
select="@class"/>
+ </xsl:when>
+ <xsl:when test="position() mod
2 = 0">
+
<xsl:text>row_off</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+
<xsl:text>row_on</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+
+ <td align="right">
+ <xsl:variable
name="link_sub"><xsl:value-of select="link_sub"/>&voucher_id=<xsl:value-of
select="voucher_id"/>&paid=true</xsl:variable>
+ <xsl:variable
name="lang_sub_help"><xsl:value-of select="lang_sub_help"/></xsl:variable>
+ <xsl:variable
name="lang_sub"><xsl:value-of select="lang_sub"/></xsl:variable>
+ <a href="{$link_sub}"
+
onMouseOver="overlib('{$lang_sub_help}', CAPTION, '{$lang_sub}')"
+ onMouseOut="nd()">
+ <xsl:value-of select="voucher_id"/></a>
+ </td>
+ <td align="right">
+ <xsl:variable
name="lang_payment_date"><xsl:value-of
select="lang_payment_date"/></xsl:variable>
+ <xsl:variable
name="payment_date"><xsl:value-of select="payment_date"/></xsl:variable>
+ <a href="javascript:void()"
+ onMouseOver="overlib('{$payment_date}',
CAPTION, '{$lang_payment_date}')"
+ onMouseOut="nd()">
+ <xsl:value-of
select="voucher_date"/></a>
+ </td>
+ <td align="right">
+ <xsl:value-of select="num_days"/>
+ </td>
+ <td align="right">
+ <xsl:value-of select="amount"/>
+ </td>
+ <td align="right">
+ <xsl:variable
name="vendor"><xsl:value-of select="vendor"/></xsl:variable>
+ <xsl:variable
name="vendor_id"><xsl:value-of select="vendor_id"/></xsl:variable>
+ <a href="javascript:void()"
+ onMouseOver="overlib('{$vendor}',
CAPTION, '{$vendor_id}')"
+ onMouseOut="nd()">
+ <xsl:value-of select="vendor_id"/></a>
+
+ </td>
+ <td align="right">
+ <xsl:value-of select="invoice_count"/>
+ </td>
+ <td align="center">
+ <xsl:value-of select="type"/>
+ </td>
+ <td align="center">
+ <xsl:value-of select="jan_date"/> -
<xsl:value-of select="janitor"/>
+ </td>
+ <td align="center">
+ <xsl:value-of select="super_date"/> -
<xsl:value-of select="supervisor"/>
+ </td>
+ <td align="center">
+ <xsl:value-of select="budget_date"/> -
<xsl:value-of select="budget_responsible"/>
+ </td>
+ <td align="center">
+ <xsl:value-of select="transfer_date"/>
- <xsl:value-of select="transfer_id"/>
+ </td>
+ </tr>
+ </xsl:template>
+
+
+<!-- consume -->
+
+ <xsl:template match="consume">
+ <div id="overDiv" style="position:absolute;
visibility:hide;z-index:1;"></div>
+ <xsl:variable name="overlib_source"><xsl:value-of
select="overlib_source"/></xsl:variable>
+ <SCRIPT LANGUAGE="JavaScript" SRC="{$overlib_source}"></SCRIPT>
+
+ <script language="JavaScript">
+ self.name="first_Window";
+ function abook()
+ {
+ Window1=window.open('<xsl:value-of
select="addressbook_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
+ }
+ function property_lookup()
+ {
+ Window1=window.open('<xsl:value-of
select="property_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
+ }
+ </script>
+
+ <xsl:call-template name="menu"/>
+ <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
+ <div align="left">
+ <form method="post" name="form" action="{$form_action}">
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <xsl:choose>
+ <xsl:when test="msgbox_data != ''">
+ <tr>
+ <td align="left" colspan="3">
+ <xsl:call-template
name="msgbox"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <tr>
+ <td>
+ <input type="text" id="start_date"
name="start_date" size="10" value="{start_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_start_date_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ <script type="text/javascript">
+ document.writeln('<img
id="start_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
+ <xsl:value-of
select="calendar_setup_start"/>
+ </script>
+ </td>
+ <td>
+ <input type="text" id="end_date"
name="end_date" size="10" value="{end_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_end_date_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ <script type="text/javascript">
+ document.writeln('<img
id="end_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
+ <xsl:value-of
select="calendar_setup_end"/>
+ </script>
+ </td>
+ <td>
+ <input type="text" size="8"
name="workorder_id" value="{workorder_id}" onMouseout="window.status='';return
true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_workorder_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ <a href="javascript:void()"
+
onMouseOver="overlib('{lang_workorder_statustext}', CAPTION,
'{lang_workorder}')"
+ onMouseOut="nd()">
+ <xsl:value-of
select="lang_workorder"/></a>
+ </td>
+
+ <td align="left">
+ <input type="text" name="vendor_id"
onClick="abook()" value="{vendor_id}" size="4"
onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_vendor_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ <a href="javascript:abook()"
+
onMouseOver="overlib('{lang_select_vendor_statustext}', CAPTION,
'{lang_vendor}')"
+ onMouseOut="nd()">
+ <xsl:value-of
select="lang_vendor"/></a>
+
+ <input type="hidden" name="vendor_name"
value="{vendor_name}"></input>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <xsl:call-template name="cat_select"/>
+ </td>
+ <td align="left">
+ <xsl:call-template
name="select_district"/>
+ </td>
+ <td align="left">
+ <xsl:variable
name="lang_account_class_statustext"><xsl:value-of
select="lang_account_class_statustext"/></xsl:variable>
+ <xsl:variable
name="select_account_class_name"><xsl:value-of
select="select_account_class_name"/></xsl:variable>
+ <select
name="{$select_account_class_name}" class="forms"
onMouseover="window.status='{$lang_account_class_statustext}'; return true;"
onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_no_account_class_"/></option>
+ <xsl:apply-templates
select="account_class_list"/>
+ </select>
+
+ </td>
+
+ <td align="left">
+ <input type="text" name="loc1"
onClick="property_lookup()" value="{loc1}" size="4"
onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_property_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ <a href="javascript:property_lookup()"
+
onMouseOver="overlib('{lang_select_property_statustext}', CAPTION,
'{lang_property}')"
+ onMouseOut="nd()">
+ <xsl:value-of
select="lang_property"/></a>
+
+ <input type="hidden"
name="loc1_name"></input>
+ </td>
+ <td align="left">
+ <xsl:variable
name="lang_search"><xsl:value-of select="lang_search"/></xsl:variable>
+ <input type="submit"
name="submit_search" value="{$lang_search}" onMouseout="window.status='';return
true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_search_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <xsl:choose>
+ <xsl:when test="vendor_name!=''">
+ <tr>
+ <td width="25%" class="th_text"
align="left">
+ <xsl:value-of
select="lang_vendor"/>
+ </td>
+ <td width="25%" class="th_text"
align="left">
+ <xsl:value-of
select="vendor_name"/>
+ </td>
+ <td width="50%">
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="loc1!=''">
+ <tr>
+ <td width="25%" class="th_text"
align="left">
+ <xsl:value-of
select="lang_property"/>
+ </td>
+ <td width="25%" class="th_text"
align="left">
+ <xsl:value-of
select="loc1"/>
+ </td>
+ <td width="50%">
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="workorder_id!=''">
+ <tr>
+ <td width="25%" class="th_text"
align="left">
+ <xsl:value-of
select="lang_workorder"/>
+ </td>
+ <td width="25%" class="th_text"
align="left">
+ <xsl:value-of
select="workorder_id"/>
+ </td>
+ <td width="50%">
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+
+ </table>
+
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <xsl:apply-templates select="table_header_consume"/>
+
+ <xsl:choose>
+ <xsl:when test="values_consume[consume]">
+ <xsl:apply-templates
select="values_consume"/>
+
+ </xsl:when>
+ </xsl:choose>
+ <tr>
+ <td>
+ </td>
+ <td>
+ </td>
+ <td class="th_text" align="right">
+ <xsl:value-of select="lang_sum"/>
+ </td>
+ <td class="th_text" align="right">
+ <xsl:value-of select="sum"/>
+ </td>
+ </tr>
+ </table>
+ </xsl:template>
+
+ <xsl:template match="account_class_list">
+ <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="id"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="id"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="table_header_consume">
+ <tr class="th">
+ <td class="th_text" width="10%" align="right">
+ <xsl:value-of select="lang_district"/>
+ </td>
+ <td class="th_text" width="10%" align="right">
+ <xsl:value-of select="lang_period"/>
+ </td>
+ <td class="th_text" width="25%" align="right">
+ <xsl:value-of
select="lang_budget_account"/>
+ </td>
+ <td class="th_text" width="55%" align="right">
+ <xsl:value-of select="lang_consume"/>
+ </td>
+ </tr>
+ </xsl:template>
+
+ <xsl:template match="values_consume">
+ <tr>
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="@class">
+ <xsl:value-of
select="@class"/>
+ </xsl:when>
+ <xsl:when test="position() mod
2 = 0">
+
<xsl:text>row_off</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+
<xsl:text>row_on</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+
+ <td align="right">
+ <xsl:value-of select="district_id"/>
+ </td>
+ <td align="center">
+ <xsl:value-of select="period"/>
+ </td>
+ <td align="center">
+ <xsl:value-of select="account_class"/>
+ </td>
+ <td align="right">
+ <xsl:value-of select="consume"/>
+ </td>
+ </tr>
+ </xsl:template>
+
+<!-- debug-->
+
+ <xsl:template match="debug">
+ <div align="left">
+ <table width="50%" cellpadding="2" cellspacing="2"
align="center">
+
+ <tr>
+ <td class="th_text">
+ <xsl:value-of select="lang_bilagsnr"/>
+ </td>
+ <td>
+ <xsl:value-of select="bilagsnr"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="th_text">
+ <xsl:value-of select="lang_type"/>
+ </td>
+ <td>
+ <xsl:value-of select="artid"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="th_text">
+ <xsl:value-of select="lang_vendor"/>
+ </td>
+ <td>
+ <xsl:value-of select="spvend_code"/>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="vendor_name"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="th_text">
+ <xsl:value-of
select="lang_fakturadato"/>
+ </td>
+ <td>
+ <xsl:value-of select="fakturadato"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="th_text">
+ <xsl:value-of
select="lang_forfallsdato"/>
+ </td>
+ <td>
+ <xsl:value-of select="forfallsdato"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="th_text">
+ <xsl:value-of select="lang_janitor"/>
+ </td>
+ <td>
+ <xsl:value-of select="oppsynsmannid"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="th_text">
+ <xsl:value-of select="lang_supervisor"/>
+ </td>
+ <td>
+ <xsl:value-of select="saksbehandlerid"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="th_text">
+ <xsl:value-of
select="lang_budget_responsible"/>
+ </td>
+ <td>
+ <xsl:value-of
select="budsjettansvarligid"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="th_text">
+ <xsl:value-of select="lang_project_id"/>
+ </td>
+ <td>
+ <xsl:value-of select="project_id"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="th_text">
+ <xsl:value-of select="lang_sum"/>
+ </td>
+ <td>
+ <xsl:value-of select="sum"/>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <tr class="th">
+ <xsl:call-template name="table_header"/>
+ </tr>
+ <xsl:call-template name="values_debug"/>
+ <xsl:apply-templates select="table_add"/>
+ </table>
+ </xsl:template>
+
+ <xsl:template name="values_debug">
+ <xsl:for-each select="values" >
+ <tr>
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="@class">
+ <xsl:value-of select="@class"/>
+ </xsl:when>
+ <xsl:when test="position() mod 2 = 0">
+ <xsl:text>row_off</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>row_on</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <xsl:for-each select="row" >
+ <td align="{align}">
+ <xsl:value-of select="value"/>
+ </td>
+ </xsl:for-each>
+ </tr>
+ </xsl:for-each>
+ </xsl:template>
+
+ <xsl:template match="table_add">
+ <tr>
+ <td height="50">
+ <xsl:variable
name="add_action"><xsl:value-of select="add_action"/></xsl:variable>
+ <xsl:variable
name="lang_add"><xsl:value-of select="lang_add"/></xsl:variable>
+ <form method="post"
action="{$add_action}">
+ <input type="submit" name="add"
value="{$lang_add}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="lang_add_statustext"/>
+ <xsl:text>';
return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </form>
+ </td>
+ <td height="50">
+ <xsl:variable
name="cancel_action"><xsl:value-of select="cancel_action"/></xsl:variable>
+ <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
+ <form method="post"
action="{$cancel_action}">
+ <input type="submit"
name="cancel" value="{$lang_cancel}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="lang_cancel_statustext"/>
+ <xsl:text>';
return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </form>
+ </td>
+ </tr>
+ </xsl:template>
+
+<!-- add / edit -->
+ <xsl:template match="add">
+
+ <script language="JavaScript">
+ self.name="first_Window";
+ function abook()
+ {
+ Window1=window.open('<xsl:value-of
select="addressbook_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
+ }
+ </script>
+
+ <xsl:call-template name="menu"/>
+ <div align="left">
+ <table cellpadding="2" cellspacing="2" width="80%"
align="center">
+ <tr>
+ <td colspan="2" align="center">
+ <xsl:value-of select="message"/>
+ </td>
+ </tr>
+ <xsl:choose>
+ <xsl:when test="msgbox_data != ''">
+ <tr>
+ <td align="left" colspan="3">
+ <xsl:call-template
name="msgbox"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
+ <form method="post" name="form" action="{$form_action}">
+
+ <tr>
+ <td>
+ <xsl:value-of select="lang_auto_tax"/>
+ </td>
+ <td>
+ <input type="checkbox" name="auto_tax"
value="True" checked="checked" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_auto_tax_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ <xsl:call-template name="location_form"/>
+ <xsl:call-template name="b_account_form"/>
+ <tr>
+ <td valign="top">
+ <xsl:variable
name="lang_vendor"><xsl:value-of select="lang_vendor"/></xsl:variable>
+ <input type="button" name="convert"
value="{$lang_vendor}" onClick="abook();" onMouseout="window.status='';return
true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_select_vendor_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ <td>
+ <input type="text" name="vendor_id"
value="{value_vendor_id}" size="4" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_vendor_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ <input type="text" name="vendor_name"
value="{value_vendor_name}" size="20" onMouseout="window.status='';return
true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_vendor_name_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_janitor"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_janitor_statustext"><xsl:value-of
select="lang_janitor_statustext"/></xsl:variable>
+ <xsl:variable
name="select_janitor"><xsl:value-of select="select_janitor"/></xsl:variable>
+ <select name="{$select_janitor}"
class="forms" onMouseover="window.status='{$lang_janitor_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_no_janitor"/></option>
+ <xsl:apply-templates
select="janitor_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_supervisor"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_supervisor_statustext"><xsl:value-of
select="lang_supervisor_statustext"/></xsl:variable>
+ <xsl:variable
name="select_supervisor"><xsl:value-of
select="select_supervisor"/></xsl:variable>
+ <select name="{$select_supervisor}"
class="forms" onMouseover="window.status='{$lang_supervisor_statustext}';
return true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_no_supervisor"/></option>
+ <xsl:apply-templates
select="supervisor_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_budget_responsible"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_budget_responsible_statustext"><xsl:value-of
select="lang_budget_responsible_statustext"/></xsl:variable>
+ <xsl:variable
name="select_budget_responsible"><xsl:value-of
select="select_budget_responsible"/></xsl:variable>
+ <select
name="{$select_budget_responsible}" class="forms"
onMouseover="window.status='{$lang_budget_responsible_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_select_budget_responsible"/></option>
+ <xsl:apply-templates
select="budget_responsible_list"/>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_order"/>
+ </td>
+ <td>
+ <input type="text" name="order"
value="{value_order}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_order_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_art"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_art_statustext"><xsl:value-of
select="lang_art_statustext"/></xsl:variable>
+ <xsl:variable
name="select_art"><xsl:value-of select="select_art"/></xsl:variable>
+ <select name="{$select_art}"
class="forms" onMouseover="window.status='{$lang_art_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_select_art"/></option>
+ <xsl:apply-templates
select="art_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_type"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_type_statustext"><xsl:value-of
select="lang_type_statustext"/></xsl:variable>
+ <xsl:variable
name="select_type"><xsl:value-of select="select_type"/></xsl:variable>
+ <select name="{$select_type}"
class="forms" onMouseover="window.status='{$lang_type_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_no_type"/></option>
+ <xsl:apply-templates
select="type_list"/>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_dimb"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_dimb_statustext"><xsl:value-of
select="lang_dimb_statustext"/></xsl:variable>
+ <xsl:variable
name="select_dimb"><xsl:value-of select="select_dimb"/></xsl:variable>
+ <select name="{$select_dimb}"
class="forms" onMouseover="window.status='{$lang_dimb_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_no_dimb"/></option>
+ <xsl:apply-templates
select="dimb_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_invoice_number"/>
+ </td>
+ <td>
+ <input type="text" name="invoice_num"
value="{value_invoice_num}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_invoice_num_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_kidnr"/>
+ </td>
+ <td>
+ <input type="text" name="kid_nr"
value="{value_kid_nr}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_kid_nr_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_amount"/>
+ </td>
+ <td>
+ <input type="text" name="amount"
value="{value_amount}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_amount_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_invoice_date"/>
+ </td>
+ <td>
+ <input type="text" id="invoice_date"
name="invoice_date" size="10" value="{value_invoice_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_invoice_date_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ <script type="text/javascript">
+ document.writeln('<img
id="invoice_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
+ <xsl:value-of
select="calendar_setup_invoice"/>
+ </script>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_no_of_days"/>
+ </td>
+ <td>
+ <input type="text" name="num_days"
value="{value_num_days}" size="4" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_num_days_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ </td>
+ </tr>
+
+ <tr>
+
+ <td valign="top">
+ <xsl:value-of
select="lang_payment_date"/>
+ </td>
+ <td>
+ <input type="text" id="payment_date"
name="payment_date" size="10" value="{value_payment_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_payment_date_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ <script type="text/javascript">
+ document.writeln('<img
id="payment_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
+ <xsl:value-of
select="calendar_setup_payment"/>
+ </script>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_merknad"/>
+ </td>
+ <td>
+ <textarea cols="60" rows="10"
name="merknad" wrap="virtual" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_merknad_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ <xsl:value-of
select="value_merknad"/>
+ </textarea>
+
+ </td>
+ </tr>
+
+ <tr height="50">
+ <td>
+ <xsl:variable
name="lang_add"><xsl:value-of select="lang_add"/></xsl:variable>
+ <input type="submit" name="add_invoice"
value="{$lang_add}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_add_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ </form>
+ <tr>
+ <td>
+ <xsl:variable
name="cancel_action"><xsl:value-of select="cancel_action"/></xsl:variable>
+ <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
+ <form method="post"
action="{$cancel_action}">
+ <input type="submit"
name="done" value="{$lang_cancel}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="lang_cancel_statustext"/>
+ <xsl:text>';
return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </form>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </xsl:template>
+
+<!-- import -->
+
+ <xsl:template match="import">
+
+ <script language="JavaScript">
+ self.name="first_Window";
+ function abook()
+ {
+ Window1=window.open('<xsl:value-of
select="addressbook_link"/>',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
+ }
+ </script>
+
+ <xsl:call-template name="menu"/>
+ <div align="left">
+ <table cellpadding="2" cellspacing="2" width="80%"
align="center">
+ <tr>
+ <td colspan="2" align="center">
+ <xsl:value-of select="message"/>
+ </td>
+ </tr>
+ <xsl:choose>
+ <xsl:when test="msgbox_data != ''">
+ <tr>
+ <td align="left" colspan="3">
+ <xsl:call-template
name="msgbox"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
+ <form ENCTYPE="multipart/form-data" method="post"
name="form" action="{$form_action}">
+
+ <tr>
+ <td>
+ <xsl:value-of select="lang_auto_tax"/>
+ </td>
+ <td>
+ <input type="checkbox" name="auto_tax"
value="True" checked="checked" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_auto_tax_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_art"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_art_statustext"><xsl:value-of
select="lang_art_statustext"/></xsl:variable>
+ <xsl:variable
name="select_art"><xsl:value-of select="select_art"/></xsl:variable>
+ <select name="{$select_art}"
class="forms" onMouseover="window.status='{$lang_art_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_select_art"/></option>
+ <xsl:apply-templates
select="art_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_type"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_type_statustext"><xsl:value-of
select="lang_type_statustext"/></xsl:variable>
+ <xsl:variable
name="select_type"><xsl:value-of select="select_type"/></xsl:variable>
+ <select name="{$select_type}"
class="forms" onMouseover="window.status='{$lang_type_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_no_type"/></option>
+ <xsl:apply-templates
select="type_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_dimb"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_dimb_statustext"><xsl:value-of
select="lang_dimb_statustext"/></xsl:variable>
+ <xsl:variable
name="select_dimb"><xsl:value-of select="select_dimb"/></xsl:variable>
+ <select name="{$select_dimb}"
class="forms" onMouseover="window.status='{$lang_dimb_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_no_dimb"/></option>
+ <xsl:apply-templates
select="dimb_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_invoice_number"/>
+ </td>
+ <td>
+ <input type="text" name="invoice_num"
value="{value_invoice_num}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_invoice_num_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_kidnr"/>
+ </td>
+ <td>
+ <input type="text" name="kid_nr"
value="{value_kid_nr}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_kid_nr_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:variable
name="lang_vendor"><xsl:value-of select="lang_vendor"/></xsl:variable>
+ <input type="button" name="convert"
value="{$lang_vendor}" onClick="abook();" onMouseout="window.status='';return
true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_select_vendor_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ <td>
+ <input type="text" name="vendor_id"
value="{value_vendor_id}" size="6" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_vendor_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ <input type="text" name="vendor_name"
value="{value_vendor_name}" size="20" onMouseout="window.status='';return
true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_vendor_name_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_janitor"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_janitor_statustext"><xsl:value-of
select="lang_janitor_statustext"/></xsl:variable>
+ <xsl:variable
name="select_janitor"><xsl:value-of select="select_janitor"/></xsl:variable>
+ <select name="{$select_janitor}"
class="forms" onMouseover="window.status='{$lang_janitor_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_no_janitor"/></option>
+ <xsl:apply-templates
select="janitor_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_supervisor"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_supervisor_statustext"><xsl:value-of
select="lang_supervisor_statustext"/></xsl:variable>
+ <xsl:variable
name="select_supervisor"><xsl:value-of
select="select_supervisor"/></xsl:variable>
+ <select name="{$select_supervisor}"
class="forms" onMouseover="window.status='{$lang_supervisor_statustext}';
return true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_no_supervisor"/></option>
+ <xsl:apply-templates
select="supervisor_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_budget_responsible"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_budget_responsible_statustext"><xsl:value-of
select="lang_budget_responsible_statustext"/></xsl:variable>
+ <xsl:variable
name="select_budget_responsible"><xsl:value-of
select="select_budget_responsible"/></xsl:variable>
+ <select
name="{$select_budget_responsible}" class="forms"
onMouseover="window.status='{$lang_budget_responsible_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_select_budget_responsible"/></option>
+ <xsl:apply-templates
select="budget_responsible_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_invoice_date"/>
+ </td>
+ <td>
+ <input type="text" id="invoice_date"
name="invoice_date" size="10" value="{value_invoice_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_invoice_date_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ <script type="text/javascript">
+ document.writeln('<img
id="invoice_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
+ <xsl:value-of
select="calendar_setup_invoice"/>
+ </script>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_no_of_days"/>
+ </td>
+ <td>
+ <input type="text" name="num_days"
value="{value_num_days}" size="4" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_num_days_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ </td>
+ </tr>
+
+ <tr>
+
+ <td valign="top">
+ <xsl:value-of
select="lang_payment_date"/>
+ </td>
+ <td>
+ <input type="text" id="payment_date"
name="payment_date" size="10" value="{value_payment_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_payment_date_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ <script type="text/javascript">
+ document.writeln('<img
id="payment_date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
+ <xsl:value-of
select="calendar_setup_payment"/>
+ </script>
+ </td>
+ </tr>
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_file"/>
+ </td>
+ <td>
+ <input type="file" name="tsvfile"
onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_file_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of select="lang_conv"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_conv_statustext"><xsl:value-of
select="lang_conv_statustext"/></xsl:variable>
+ <xsl:variable
name="select_conv"><xsl:value-of select="select_conv"/></xsl:variable>
+ <select name="{$select_conv}"
class="forms" onMouseover="window.status='{$lang_conv_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_select_conversion"/></option>
+ <xsl:apply-templates
select="conv_list"/>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <xsl:value-of select="lang_debug"/>
+ </td>
+ <td>
+ <input type="checkbox" name="download"
value="True" checked="checked" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_debug_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ <tr height="50">
+ <td>
+ <xsl:variable
name="lang_import"><xsl:value-of select="lang_import"/></xsl:variable>
+ <input type="submit" name="convert"
value="{$lang_import}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_import_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ </form>
+ <tr>
+ <td>
+ <xsl:variable
name="cancel_action"><xsl:value-of select="cancel_action"/></xsl:variable>
+ <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
+ <form method="post"
action="{$cancel_action}">
+ <input type="submit"
name="done" value="{$lang_cancel}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="lang_cancel_statustext"/>
+ <xsl:text>';
return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </form>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </xsl:template>
+
+<!-- art_list -->
+
+ <xsl:template match="art_list">
+ <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="num"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="num"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- type_list -->
+
+ <xsl:template match="type_list">
+ <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="num"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="num"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- dimb_list -->
+
+ <xsl:template match="dimb_list">
+ <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="num"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="num"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+<!-- janitor_list -->
+
+ <xsl:template match="janitor_list">
+ <xsl:variable name="lid"><xsl:value-of select="lid"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$lid}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="firstname"/> <xsl:value-of select="lastname"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$lid}"><xsl:value-of
disable-output-escaping="yes" select="firstname"/> <xsl:value-of
select="lastname"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- supervisor_list -->
+
+ <xsl:template match="supervisor_list">
+ <xsl:variable name="lid"><xsl:value-of select="lid"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$lid}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="firstname"/> <xsl:value-of select="lastname"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$lid}"><xsl:value-of
disable-output-escaping="yes" select="firstname"/> <xsl:value-of
select="lastname"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- budget_responsible_list -->
+
+ <xsl:template match="budget_responsible_list">
+ <xsl:variable name="lid"><xsl:value-of select="lid"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$lid}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="firstname"/> <xsl:value-of select="lastname"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$lid}"><xsl:value-of
disable-output-escaping="yes" select="firstname"/> <xsl:value-of
select="lastname"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+<!-- conv_list -->
+
+ <xsl:template match="conv_list">
+ <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="name"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="name"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- rollback_file_list -->
+
+ <xsl:template match="rollback_file_list">
+ <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="name"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="name"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- tax_code_list -->
+
+ <xsl:template match="tax_code_list">
+ <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected">
+ <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="id"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="id"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!-- export -->
+
+ <xsl:template match="export">
+ <xsl:call-template name="menu"/>
+ <div align="left">
+ <table cellpadding="2" cellspacing="2" width="80%"
align="center">
+ <xsl:choose>
+ <xsl:when test="msgbox_data != ''">
+ <tr>
+ <td align="left" colspan="3">
+ <xsl:call-template
name="msgbox"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
+ <form method="post" name="form" action="{$form_action}">
+
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_select_conv"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_conv_statustext"><xsl:value-of
select="lang_conv_statustext"/></xsl:variable>
+ <xsl:variable
name="select_conv"><xsl:value-of select="select_conv"/></xsl:variable>
+ <select name="{$select_conv}"
class="forms" onMouseover="window.status='{$lang_conv_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_select_conv"/></option>
+ <xsl:apply-templates
select="conv_list"/>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_force_period_year"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_force_period_year_statustext"><xsl:value-of
select="lang_force_period_year_statustext"/></xsl:variable>
+ <select
name="values[force_period_year]" class="forms"
onMouseover="window.status='{$lang_force_period_year_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_select_year"/></option>
+ <xsl:apply-templates
select="force_period_year"/>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <xsl:value-of
select="lang_export_to_file"/>
+ </td>
+ <td>
+ <input type="checkbox"
name="values[download]" value="on" checked="checked"
onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_debug_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ </td>
+ <td>
+ <xsl:variable
name="link_rollback_file"><xsl:value-of
select="link_rollback_file"/></xsl:variable>
+ <a
href="{$link_rollback_file}"><xsl:value-of select="lang_rollback_file"/></a>
+ </td>
+ </tr>
+
+ <tr height="50">
+ <td>
+ <xsl:variable
name="lang_submit"><xsl:value-of select="lang_submit"/></xsl:variable>
+ <input type="submit"
name="values[submit]" value="{$lang_submit}"
onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_import_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ </form>
+ <tr>
+ <td>
+ <xsl:variable
name="cancel_action"><xsl:value-of select="cancel_action"/></xsl:variable>
+ <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
+ <form method="post"
action="{$cancel_action}">
+ <input type="submit"
name="done" value="{$lang_cancel}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="lang_cancel_statustext"/>
+ <xsl:text>';
return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </form>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </xsl:template>
+
+
+<!-- rollback -->
+
+ <xsl:template match="rollback">
+ <xsl:call-template name="menu"/>
+ <div align="left">
+ <table cellpadding="2" cellspacing="2" width="80%"
align="center">
+ <xsl:choose>
+ <xsl:when test="msgbox_data != ''">
+ <tr>
+ <td align="left" colspan="3">
+ <xsl:call-template
name="msgbox"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
+ <form method="post" name="form" action="{$form_action}">
+
+
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_select_conv"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_conv_statustext"><xsl:value-of
select="lang_conv_statustext"/></xsl:variable>
+ <xsl:variable
name="select_conv"><xsl:value-of select="select_conv"/></xsl:variable>
+ <select name="{$select_conv}"
class="forms" onMouseover="window.status='{$lang_conv_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_select_conv"/></option>
+ <xsl:apply-templates
select="conv_list"/>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <xsl:value-of
select="lang_select_file"/>
+ </td>
+ <td valign="top">
+ <xsl:variable
name="lang_file_statustext"><xsl:value-of
select="lang_file_statustext"/></xsl:variable>
+ <xsl:variable
name="select_file"><xsl:value-of select="select_file"/></xsl:variable>
+ <select name="{$select_file}"
class="forms" onMouseover="window.status='{$lang_file_statustext}'; return
true;" onMouseout="window.status='';return true;">
+ <option value=""><xsl:value-of
select="lang_no_file"/></option>
+ <xsl:apply-templates
select="rollback_file_list"/>
+ </select>
+ </td>
+ </tr>
+
+
+ <tr>
+
+ <td valign="top">
+ <xsl:value-of select="lang_date"/>
+ </td>
+ <td>
+ <input type="text" id="date"
name="date" size="10" value="{value_date}" readonly="readonly"
onMouseout="window.status='';return true;" >
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_date_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+
+ <script type="text/javascript">
+ document.writeln('<img
id="date-trigger" src="{date_img}" title="{lang_datetitle}"
style="cursor:pointer; cursor:hand;"/>');
+ <xsl:value-of select="calendar_setup"/>
+ </script>
+ </td>
+ </tr>
+
+ <tr height="50">
+ <td>
+ <xsl:variable
name="lang_submit"><xsl:value-of select="lang_submit"/></xsl:variable>
+ <input type="submit"
name="values[submit]" value="{$lang_submit}"
onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+ <xsl:value-of
select="lang_import_statustext"/>
+ <xsl:text>'; return
true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ </form>
+ <tr>
+ <td>
+ <xsl:variable
name="cancel_action"><xsl:value-of select="cancel_action"/></xsl:variable>
+ <xsl:variable
name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
+ <form method="post"
action="{$cancel_action}">
+ <input type="submit"
name="done" value="{$lang_cancel}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="lang_cancel_statustext"/>
+ <xsl:text>';
return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </form>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </xsl:template>
+
+
+<!--list_invoice_sub-->
+
+ <xsl:template match="list_invoice_sub">
+ <div id="overDiv" style="position:absolute;
visibility:hide;z-index:1;"></div>
+ <xsl:variable name="overlib_source"><xsl:value-of
select="overlib_source"/></xsl:variable>
+ <SCRIPT LANGUAGE="JavaScript" SRC="{$overlib_source}"></SCRIPT>
+ <SCRIPT LANGUAGE="JavaScript" SRC="{check_source}"></SCRIPT>
+
+ <xsl:call-template name="menu"/>
+ <table width="80%" cellpadding="2" cellspacing="2"
align="center">
+ <xsl:choose>
+ <xsl:when test="msgbox_data != ''">
+ <tr>
+ <td align="left" colspan="3">
+ <xsl:call-template
name="msgbox"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="vendor!=''">
+ <tr>
+ <td width="25%" class="th_text"
align="left">
+ <xsl:value-of
select="lang_vendor"/>
+ </td>
+ <td width="25%" class="th_text"
align="left">
+ <xsl:value-of
select="vendor"/>
+ </td>
+ <td width="50%">
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="voucher_id!=''">
+ <tr>
+ <td width="25%" class="th_text"
align="left">
+ <xsl:value-of
select="lang_voucher_id"/>
+ </td>
+ <td width="25%" class="th_text"
align="left">
+ <xsl:value-of
select="voucher_id"/>
+ </td>
+ <td width="50%">
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ </table>
+ <table width="100%" cellpadding="2" cellspacing="2"
align="center">
+ <xsl:variable name="form_action"><xsl:value-of
select="form_action"/></xsl:variable>
+ <form method="post" name="form" action="{$form_action}">
+ <xsl:apply-templates
select="table_header_list_invoice_sub"/>
+
+ <xsl:choose>
+ <xsl:when test="values_list_invoice_sub[id]">
+ <xsl:apply-templates
select="values_list_invoice_sub"/>
+ <xsl:variable
name="img_check"><xsl:value-of select="img_check"/></xsl:variable>
+ <tr>
+ <td></td>
+ <td align="center">
+ <a
href="javascript:check_all_checkbox('values[close_order]')"><img
src="{$img_check}" border="0" height="16" width="21"
alt="{lang_select_all}"/></a>
+ </td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td class="small_text"
align="right">
+ <xsl:value-of
select="sum"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <tr height="50">
+ <td>
+ <xsl:choose>
+ <xsl:when test="paid=''">
+ <xsl:variable
name="lang_save"><xsl:value-of select="lang_save"/></xsl:variable>
+ <input type="submit"
name="values[save]" value="{$lang_save}" onMouseout="window.status='';return
true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="lang_save_statustext"/>
+
<xsl:text>'; return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </xsl:when>
+ </xsl:choose>
+ </td>
+ </tr>
+ </form>
+ <tr>
+ <td>
+ <xsl:variable
name="done_action"><xsl:value-of select="done_action"/></xsl:variable>
+ <xsl:variable
name="lang_done"><xsl:value-of select="lang_done"/></xsl:variable>
+ <form method="post"
action="{$done_action}">
+ <input type="submit"
name="done" value="{$lang_done}" onMouseout="window.status='';return true;">
+ <xsl:attribute
name="onMouseover">
+
<xsl:text>window.status='</xsl:text>
+
<xsl:value-of select="lang_done_statustext"/>
+ <xsl:text>';
return true;</xsl:text>
+ </xsl:attribute>
+ </input>
+ </form>
+ </td>
+ </tr>
+
+ </table>
+ </xsl:template>
+
+ <xsl:template match="table_header_list_invoice_sub">
+ <xsl:variable name="sort_workorder"><xsl:value-of
select="sort_workorder"/></xsl:variable>
+ <xsl:variable name="sort_budget_account"><xsl:value-of
select="sort_budget_account"/></xsl:variable>
+ <xsl:variable name="sort_sum"><xsl:value-of
select="sort_sum"/></xsl:variable>
+ <xsl:variable name="sort_dima"><xsl:value-of
select="sort_dima"/></xsl:variable>
+ <tr class="th">
+ <td class="th_text" width="5%" align="right">
+ <a
href="{$sort_workorder}"><xsl:value-of select="lang_workorder"/></a>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <xsl:value-of
select="lang_close_order"/>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <xsl:value-of
select="lang_charge_tenant"/>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <xsl:value-of select="lang_invoice_id"/>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <a
href="{$sort_budget_account}"><xsl:value-of select="lang_budget_account"/></a>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <a href="{$sort_sum}"><xsl:value-of
select="lang_sum"/></a>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <a href="{$sort_dima}"><xsl:value-of
select="lang_dima"/></a>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <xsl:value-of select="lang_dimb"/>
+ </td>
+ <td class="th_text" width="5%" align="right">
+ <xsl:value-of select="lang_dimd"/>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <xsl:value-of select="lang_tax_code"/>
+ </td>
+ <td class="th_text" width="2%" align="right">
+ <xsl:value-of select="lang_remark"/>
+ </td>
+ </tr>
+ </xsl:template>
+
+ <xsl:template match="values_list_invoice_sub">
+
+ <xsl:variable name="counter"><xsl:value-of
select="counter"/></xsl:variable>
+ <xsl:variable name="current_user"><xsl:value-of
select="current_user"/></xsl:variable>
+ <tr>
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="@class">
+ <xsl:value-of
select="@class"/>
+ </xsl:when>
+ <xsl:when test="position() mod
2 = 0">
+
<xsl:text>row_off</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+
<xsl:text>row_on</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+
+ <td align="right">
+ <input type="hidden"
name="values[counter][{$counter}]" value="{counter}">
+ </input>
+ <input type="hidden"
name="values[id][{$counter}]" value="{id}">
+ </input>
+ <input type="hidden"
name="values[workorder_id][{$counter}]" value="{workorder_id}">
+ </input>
+ <xsl:variable
name="link_order"><xsl:value-of
select="link_order"/>&order_id=<xsl:value-of
select="workorder_id"/></xsl:variable>
+ <a href="{$link_order}"
target="_blank"><xsl:value-of select="workorder_id"/></a>
+ </td>
+ <td class="small_text" align="center">
+ <xsl:choose>
+ <xsl:when
test="workorder_id=''">
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when
test="paid=''">
+ <input
type="hidden" name="values[close_order_orig][{$counter}]" value="{closed}">
+ </input>
+
<xsl:choose>
+
<xsl:when test="closed='1'">
+
<input type="checkbox" name="values[close_order][{$counter}]"
value="true" checked="checked" onMouseout="window.status='';return true;">
+
</input>
+
</xsl:when>
+
<xsl:otherwise>
+
<input type="checkbox" name="values[close_order][{$counter}]"
value="true" onMouseout="window.status='';return true;">
+
</input>
+
</xsl:otherwise>
+
</xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+
<xsl:choose>
+
<xsl:when test="closed='1'">
+
<b>x</b>
+
</xsl:when>
+
</xsl:choose>
+
</xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </td>
+ <td class="small_text" align="center">
+ <xsl:choose>
+ <xsl:when
test="charge_tenant='1'">
+ <xsl:choose>
+ <xsl:when
test="claim_issued=''">
+
<xsl:variable name="link_claim"><xsl:value-of
select="link_claim"/>&project_id=<xsl:value-of
select="project_id"/></xsl:variable>
+ <a
href="{$link_claim}" target="_blank"><xsl:value-of select="//lang_claim"/></a>
+ </xsl:when>
+ </xsl:choose>
+ <b>x</b>
+ </xsl:when>
+ </xsl:choose>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:value-of select="invoice_id"/>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:choose>
+ <xsl:when test="paid='true'">
+ <xsl:value-of
select="budget_account"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <input type="text"
size="7" name="values[budget_account][{$counter}]" value="{budget_account}">
+ </input>
+ </xsl:otherwise>
+ </xsl:choose>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:value-of select="amount"/>
+ </td>
+ <td class="small_text" align="center">
+ <xsl:choose>
+ <xsl:when test="paid='true'">
+ <xsl:value-of
select="dima"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <input type="text"
size="7" name="values[dima][{$counter}]" value="{dima}">
+ </input>
+ </xsl:otherwise>
+ </xsl:choose>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:value-of select="dimb"/>
+ </td>
+ <td class="small_text" align="center">
+ <xsl:choose>
+ <xsl:when test="paid='true'">
+ <xsl:value-of
select="dimd"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <input type="text"
size="4" name="values[dimd][{$counter}]" value="{dimd}">
+ </input>
+ </xsl:otherwise>
+ </xsl:choose>
+ </td>
+ <td class="small_text" align="center">
+ <xsl:choose>
+ <xsl:when test="paid='true'">
+ <xsl:value-of
select="tax_code"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable
name="lang_tax_code_statustext"><xsl:value-of
select="lang_tax_code_statustext"/></xsl:variable>
+ <select
name="values[tax_code][{$counter}]" class="forms"
onMouseover="window.status='{$lang_tax_code_statustext}'; return true;"
onMouseout="window.status='';return true;">
+
<xsl:apply-templates select="tax_code_list"/>
+ </select>
+ </xsl:otherwise>
+ </xsl:choose>
+ </td>
+ <td class="small_text" align="right">
+ <xsl:choose>
+ <xsl:when test="remark='1'">
+ <xsl:variable
name="link_remark"><xsl:value-of select="link_remark"/>&id=<xsl:value-of
select="id"/>&paid=<xsl:value-of select="paid"/></xsl:variable>
+ <xsl:variable
name="lang_remark_help"><xsl:value-of select="lang_remark_help"/></xsl:variable>
+ <xsl:variable
name="lang_remark"><xsl:value-of select="lang_remark"/></xsl:variable>
+ <a href="javascript:var
w=window.open('{$link_remark}','','width=550,height=400,scrollbars')"
+
onMouseOver="overlib('{$lang_remark_help}', CAPTION, '{$lang_remark}')"
+ onMouseOut="nd()">
+ <xsl:value-of
select="lang_remark"/></a>
+ </xsl:when>
+ </xsl:choose>
+ </td>
+
+ </tr>
+ </xsl:template>
+
+ <xsl:template match="force_period_year">
+ <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="selected='selected'">
+ <option value="{$id}"
selected="selected"><xsl:value-of disable-output-escaping="yes"
select="id"/></option>
+ </xsl:when>
+ <xsl:otherwise>
+ <option value="{$id}"><xsl:value-of
disable-output-escaping="yes" select="id"/></option>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] property inc/class.acl2.inc.php inc/class.boXpo...,
Sigurd Nes <=