[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] property/inc/custom/organize_drawing.php, 1.1.2.4
From: |
nomail |
Subject: |
[Phpgroupware-cvs] property/inc/custom/organize_drawing.php, 1.1.2.4 |
Date: |
Sun, 7 Nov 2004 15:44:40 +0100 |
Update of /property/inc/custom
Modified Files:
Branch: proposed-0_9_18-branch
organize_drawing.php
date: 2004/11/07 14:44:40; author: sigurdne; state: Exp; lines: +143 -60
Log Message:
no message
=====================================================================
Index: property/inc/custom/organize_drawing.php
diff -u property/inc/custom/organize_drawing.php:1.1.2.3
property/inc/custom/organize_drawing.php:1.1.2.4
--- property/inc/custom/organize_drawing.php:1.1.2.3 Sat Nov 6 22:09:34 2004
+++ property/inc/custom/organize_drawing.php Sun Nov 7 14:44:40 2004
@@ -19,38 +19,63 @@
if($data['enabled']==1)
{
$confirm = True;
+ $execute = True;
+ $cron = True;
}
else
{
$confirm =
get_var('confirm',array('POST'));
+ $execute =
get_var('execute',array('GET'));
}
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.custom_functions.index',
- 'function' =>'organize_drawing'
- );
+ if(!$execute)
+ {
+ $dry_run=True;
+ }
if ($confirm)
{
- $receipt= $this->execute();
+ $this->receipt= $this->execute($dry_run,$cron);
}
else
{
- $lang_confirm_msg = 'Vil du virkelig
utføre denne operasjonen';
- $lang_yes = lang('yes');
+ $this->confirm($execute=False);
+ }
+ }
+
+ function confirm($execute='',$done='')
+ {
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.custom_functions.index',
+ 'function' =>'organize_drawing',
+ 'execute' =>$execute
+ );
+
+ if(!$done)
+ {
+ if(!$execute)
+ {
+ $lang_confirm_msg = 'Gå videre
for å se hva som blir lagt til';
+ }
+ 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);
+
+ $msgbox_data =
$this->bocommon->msgbox_data($this->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'],
+ 'message' =>
$this->receipt['message'],
'lang_confirm_msg' =>
$lang_confirm_msg,
'lang_yes' =>
$lang_yes,
'lang_yes_statustext' => 'Organisere
tegninger i register og på disk',
@@ -65,32 +90,42 @@
$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 execute()
+ function execute($dry_run='',$cron='')
{
- $file_list = $this->get_files();
-// _debug_array($file_list);
+ $file_list = $this->get_files();
- if (isSet($file_list) AND is_array($file_list))
+ if($dry_run)
{
- foreach($file_list as $file_entry)
- {
- $loc1_list[$file_entry['loc1']] = True;
- }
-
- $loc1_list = array_keys($loc1_list);
-
- for ($i=0;$i<count($loc1_list);$i++)
+ $this->confirm($execute=True);
+ _debug_array($file_list);
+ }
+ else
+ {
+ if (isSet($file_list) AND is_array($file_list))
{
- $this->create_loc1_dir($loc1_list[$i]);
+ foreach($file_list as $file_entry)
+ {
+ $loc1_list[$file_entry['loc1']]
= True;
+ }
+
+ $loc1_list = array_keys($loc1_list);
+
+ for ($i=0;$i<count($loc1_list);$i++)
+ {
+
$this->create_loc1_dir($loc1_list[$i]);
+ }
+
+ for ($i=0;$i<count($file_list);$i++)
+ {
+
$this->copy_files($file_list[$i]);
+ }
}
-
- for ($i=0;$i<count($file_list);$i++)
+ if(!$cron)
{
- $this->copy_files($file_list[$i]);
+
$this->confirm($execute=false,$done=True);
}
}
}
@@ -143,6 +178,7 @@
unset($loc3);
$type =
$drawing_type[substr($myfilearray[$i],10,1)];
$location_code = $loc1 . '-' . $loc2;
+ $nr = substr($myfilearray[$i],-8,3);
}
$branch =
$drawing_branch[substr($myfilearray[$i],-5,1)];
@@ -156,6 +192,7 @@
'loc2' => $loc2,
'loc3' => $loc3,
'type' => $type,
+ 'nr' => $nr,
'etasje' => $etasje,
'branch' => $branch,
'location_code' =>
$location_code,
@@ -184,74 +221,120 @@
function create_loc1_dir($loc1='')
{
if(!$this->vfs->file_exists(array(
- 'string' => $this->fakebase . SEP .
'drawing' . SEP . $loc1,
+ 'string' => $this->fakebase . SEP .
'document' . SEP . $loc1,
'relatives' => Array(RELATIVE_NONE)
)))
{
$this->vfs->override_acl = 1;
if(!$this->vfs->mkdir (array(
- 'string' => $this->fakebase. SEP .
'drawing' . SEP . $loc1,
+ 'string' => $this->fakebase. SEP .
'document' . SEP . $loc1,
'relatives' => array(
RELATIVE_NONE
)
)))
{
-
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . 'drawing' . SEP . $loc1);
+
$this->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 . 'drawing' . SEP . $loc1);
+
$this->receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . 'document' . SEP . $loc1);
}
$this->vfs->override_acl = 0;
}
- return $receipt;
+ return $this->receipt;
}
function copy_files($values)
{
- $to_file = $this->fakebase . SEP . 'drawing' . SEP .
$values['loc1'] . SEP . $values['file_name'];
+ $to_file = $this->fakebase . SEP . 'document' . SEP .
$values['loc1'] . SEP . $values['file_name'];
$from_file = $this->dir . SEP . $values['file_name'];
$this->vfs->override_acl = 1;
//_debug_array($to_file);
- if(!$this->vfs->cp (array (
- 'from' => $from_file,
- 'to' => $to_file,
- 'relatives' => array
(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
+ if($this->vfs->file_exists(array(
+ 'string' => $to_file,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
{
- $receipt['error'][]=array('msg'=>lang('Failed
to copy file !') . $values['file_name']);
+
$this->receipt['error'][]=array('msg'=>lang('File %1 already
exists!',$values['file_name']));
}
else
{
- $this->db->query("INSERT INTO fm_drawing
(drawing_name,title,access,category,entry_date,drawing_date,version,coordinator,status,"
- .
"descr,location_code,floor_id,address,branch_id,vendor_id,user_id $cols) "
- . "VALUES ('"
- . $values['file_name']. "','"
- . $values['file_name']. "','"
- . "public','"
- . $values['cat_id']. "','"
- . time() . "','"
- . $values['values_date']. "','"
- . $values['version']. "','"
- . $values['coordinator']. "','"
- . $values['status']. "','"
- . $values['descr']. "','"
- . $values['location_code']. "','"
- . $values['floor_id'] . "','"
- . $address . "','"
- . $values['branch_id']. "','"
- . $values['vendor_id']. "','"
- . $this->account. "' $vals)",__LINE__,__FILE__);
- }
- $this->vfs->override_acl = 0;
+ if(!$this->vfs->cp (array (
+ 'from' => $from_file,
+ 'to' => $to_file,
+ 'relatives' => array
(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
+ {
+
$this->receipt['error'][]=array('msg'=>lang('Failed to copy file !') .
$values['file_name']);
+ }
+ else
+ {
+ $address =
$this->get_address($values['loc1'],$values['loc2'],$values['loc3']);
+ if($values['etasje'])
+ {
+ $values['title'] =
$this->db->db_addslashes($values['branch'] . ', ' .$values['type'] . ', etasje:
' . $values['etasje']);
+ }
+ else
+ {
+ $values['title'] =
$this->db->db_addslashes($values['branch'] . ', ' . $values['type'] . ' nr: ' .
$values['nr']);
+ }
+
+ $insert_values= array(
+ $values['file_name'],
+ $values['title'],
+ 'public',
+ 4,
+ time(),
+ $values['values_date'],
+ $values['version'],
+ $values['coordinator'],
+ $values['status'],
+ $values['location_code'],
+ $address,
+ $values['branch_id'],
+ $values['vendor_id'],
+ $this->account,
+ $values['loc1'],
+ $values['loc2'],
+ $values['loc3'],
+ );
+
+ $insert_values =
$this->bocommon->validate_db_insert($insert_values);
+
+ $sql = "INSERT INTO fm_document
(document_name,title,access,category,entry_date,document_date,version,coordinator,status,"
+ .
"location_code,address,branch_id,vendor_id,user_id,loc1,loc2,loc3) "
+ . "VALUES ($insert_values)";
+ unlink($from_file);
- return $receipt;
+
$this->db->query($sql,__LINE__,__FILE__);
+
$this->receipt['message'][]=array('msg'=>lang('File %1
copied!',$values['file_name']));
+
$this->receipt['message'][]=array('msg'=>lang('File %1 deleted!',$from_file));
+ }
+ }
+
+ $this->vfs->override_acl = 0;
+ return $this->receipt;
}
+ function get_address($loc1='',$loc2='',$loc3='')
+ {
+ if ($loc3)
+ {
+ $sql = "SELECT loc3_name as address FROM
fm_location3 WHERE loc1='$loc1' AND loc2='$loc2' AND loc3='$loc3'";
+ }
+ else
+ {
+ $sql = "SELECT loc2_name as address FROM
fm_location2 WHERE loc1='$loc1' AND loc2='$loc2'";
+ }
+
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ return $this->db->f('address');
+ }
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] property/inc/custom/organize_drawing.php, 1.1.2.4,
nomail <=