[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] property/inc/custom/oppdater_utgaatt_objekt.php, 1.1.
From: |
nomail |
Subject: |
[Phpgroupware-cvs] property/inc/custom/oppdater_utgaatt_objekt.php, 1.1.2.1 |
Date: |
Fri, 5 Nov 2004 16:09:49 +0100 |
Update of /property/inc/custom
Added Files:
Branch: proposed-0_9_18-branch
oppdater_utgaatt_objekt.php
date: 2004/11/05 15:09:49; author: sigurdne; state: Exp; lines: +145 -0
Log Message:
no message
=====================================================================
<?php
class oppdater_utgaatt_objekt
{
function oppdater_utgaatt_objekt($data='')
{
$this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
$this->bocommon =
CreateObject($this->currentapp.'.bocommon');
$this->db =
$GLOBALS['phpgw']->db;
$this->db2 = $this->db;
$this->soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
$this->socommon =
CreateObject($this->currentapp.'.socommon');
$this->join =
$this->socommon->join;
$this->left_join =
$this->socommon->left_join;
if($data['enabled']==1)
{
$confirm = True;
}
else
{
$confirm =
get_var('confirm',array('POST'));
}
$link_data = array
(
'menuaction' =>
$this->currentapp.'.custom_functions.index',
'function' =>'oppdater_utgaatt_objekt'
);
if ($confirm)
{
$receipt= $this->run();
}
else
{
$lang_confirm_msg = 'Vil du virkelig
utføre denne operasjonen';
$lang_yes = lang('yes');
}
$GLOBALS['phpgw']->xslttpl->add_file(array('confirm_custom'));
$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'),
'run_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
'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'),
'lang_done' =>
'Avbryt',
'lang_done_statustext' => 'tilbake'
);
$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('confirm' => $data));
$GLOBALS['phpgw']->xslttpl->pp();
}
function run()
{
$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;
}
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] property/inc/custom/oppdater_utgaatt_objekt.php, 1.1.2.1,
nomail <=