From f184b969798ca3835dfc288e1c44c22c31c66481 Mon Sep 17 00:00:00 2001 From: seek3r Date: Wed, 23 May 2001 19:07:45 +0000 Subject: [PATCH] Initial revision --- infolog/csv_import.php | 326 ++++++++++++++ infolog/delete.php | 82 ++++ infolog/doc/create_tables.mysql | 56 +++ infolog/doc/lang_de.sql | 71 ++++ infolog/edit.php | 321 ++++++++++++++ infolog/inc/about.inc.php | 8 + infolog/inc/class.info.inc.php | 402 ++++++++++++++++++ infolog/inc/header.inc.php | 16 + infolog/inc/hook_admin.inc.php | 20 + infolog/inc/hook_info_about.inc.php | 8 + infolog/inc/hook_preferences.inc.php | 40 ++ infolog/index.php | 231 ++++++++++ infolog/setup/details.inc.php | 10 + infolog/setup/setup_info.inc.php | 3 + infolog/templates/default/csv_import.tpl | 65 +++ infolog/templates/default/delete.tpl | 50 +++ infolog/templates/default/form.tpl | 161 +++++++ infolog/templates/default/images/billed.gif | Bin 0 -> 157 bytes infolog/templates/default/images/call.gif | Bin 0 -> 198 bytes infolog/templates/default/images/confirm.gif | Bin 0 -> 150 bytes infolog/templates/default/images/delete.gif | Bin 0 -> 153 bytes infolog/templates/default/images/done.gif | Bin 0 -> 133 bytes infolog/templates/default/images/edit.gif | Bin 0 -> 159 bytes infolog/templates/default/images/email.gif | Bin 0 -> 202 bytes infolog/templates/default/images/index.html | 34 ++ infolog/templates/default/images/navbar.gif | Bin 0 -> 1535 bytes infolog/templates/default/images/new.gif | Bin 0 -> 141 bytes infolog/templates/default/images/note.gif | Bin 0 -> 134 bytes infolog/templates/default/images/offer.gif | Bin 0 -> 137 bytes infolog/templates/default/images/ongoing.gif | Bin 0 -> 160 bytes infolog/templates/default/images/parent.gif | Bin 0 -> 156 bytes infolog/templates/default/images/phone.gif | Bin 0 -> 159 bytes infolog/templates/default/images/reject.gif | Bin 0 -> 155 bytes infolog/templates/default/images/task.gif | Bin 0 -> 137 bytes infolog/templates/default/images/view.gif | Bin 0 -> 145 bytes .../templates/default/images/will-call.gif | Bin 0 -> 152 bytes infolog/templates/default/info.css | 10 + infolog/templates/default/list.tpl | 91 ++++ infolog/templates/default/preference_acl.tpl | 25 ++ .../templates/default/preference_acl_row.tpl | 9 + .../templates/default/preference_colspan.tpl | 8 + 41 files changed, 2047 insertions(+) create mode 100644 infolog/csv_import.php create mode 100644 infolog/delete.php create mode 100644 infolog/doc/create_tables.mysql create mode 100644 infolog/doc/lang_de.sql create mode 100644 infolog/edit.php create mode 100644 infolog/inc/about.inc.php create mode 100644 infolog/inc/class.info.inc.php create mode 100644 infolog/inc/header.inc.php create mode 100644 infolog/inc/hook_admin.inc.php create mode 100644 infolog/inc/hook_info_about.inc.php create mode 100644 infolog/inc/hook_preferences.inc.php create mode 100644 infolog/index.php create mode 100644 infolog/setup/details.inc.php create mode 100644 infolog/setup/setup_info.inc.php create mode 100644 infolog/templates/default/csv_import.tpl create mode 100644 infolog/templates/default/delete.tpl create mode 100644 infolog/templates/default/form.tpl create mode 100644 infolog/templates/default/images/billed.gif create mode 100644 infolog/templates/default/images/call.gif create mode 100644 infolog/templates/default/images/confirm.gif create mode 100644 infolog/templates/default/images/delete.gif create mode 100644 infolog/templates/default/images/done.gif create mode 100644 infolog/templates/default/images/edit.gif create mode 100644 infolog/templates/default/images/email.gif create mode 100644 infolog/templates/default/images/index.html create mode 100644 infolog/templates/default/images/navbar.gif create mode 100644 infolog/templates/default/images/new.gif create mode 100644 infolog/templates/default/images/note.gif create mode 100644 infolog/templates/default/images/offer.gif create mode 100644 infolog/templates/default/images/ongoing.gif create mode 100644 infolog/templates/default/images/parent.gif create mode 100644 infolog/templates/default/images/phone.gif create mode 100644 infolog/templates/default/images/reject.gif create mode 100644 infolog/templates/default/images/task.gif create mode 100644 infolog/templates/default/images/view.gif create mode 100644 infolog/templates/default/images/will-call.gif create mode 100644 infolog/templates/default/info.css create mode 100644 infolog/templates/default/list.tpl create mode 100644 infolog/templates/default/preference_acl.tpl create mode 100644 infolog/templates/default/preference_acl_row.tpl create mode 100644 infolog/templates/default/preference_colspan.tpl diff --git a/infolog/csv_import.php b/infolog/csv_import.php new file mode 100644 index 0000000000..aee2cd9fe0 --- /dev/null +++ b/infolog/csv_import.php @@ -0,0 +1,326 @@ + * + * -------------------------------------------- * + * This program is free software; you can redistribute it and/or modify it * + * under the terms of the GNU General Public License as published by the * + * Free Software Foundation; either version 2 of the License, or (at your * + * option) any later version. * + \**************************************************************************/ + + /* $Id$ */ + + $phpgw_info["flags"]["currentapp"] = "info"; + $phpgw_info["flags"]["enable_contacts_class"] = True; + include("../header.inc.php"); + + $phpgw->info = createobject('info.info'); + + $t = new Template($phpgw_info["server"]["app_tpl"]); // $t->unknows = 'keep'; $t->debug = 1; + $t->set_file(array("import" => "csv_import.tpl")); + $t->set_block('import','filename','filenamehandle'); + $t->set_block('import','fheader','fheaderhandle'); + $t->set_block('import','fields','fieldshandle'); + $t->set_block('import','ffooter','ffooterhandle'); + $t->set_block('import','imported','importedhandle'); + + // $t->set_var("navbar_bg",$phpgw_info["theme"]["navbar_bg"]); + // $t->set_var("navbar_text",$phpgw_info["theme"]["navbar_text"]); + + if ($action == 'download' && (!$fieldsep || !$csvfile || !($fp=fopen($csvfile,"r")))) { + $action = ''; + } + $t->set_var("action_url",$phpgw->link("/info/csv_import.php")); + $t->set_var( $phpgw->info->setStyleSheet( )); + $t->set_var("lang_info_action",lang("Import CSV-File into Info Log")); + + $PSep = '||'; // Pattern-Separator, separats the pattern-replacement-pairs in trans + $ASep = '|>'; // Assignment-Separator, separats pattern and replacesment + $VPre = '|#'; // Value-Prefix, is expanded to \ for ereg_replace + $CPre = '|['; $CPreReg = '\|\['; // |{csv-fieldname} is expanded to the value of the csv-field + $CPos = ']'; $CPosReg = '\]'; // if used together with @ (replacement is eval-ed) value gets autom. quoted + +function dump_array( $arr ) { + while (list($key,$val) = each($arr)) + $ret .= ($ret ? ',' : '(') . "'$key' => '$val'"; + return $ret.')'; +} + +function index( $value,$arr ) { + while (list ($key,$val) = each($arr)) + if ($value == $val) + return $key; + return False; +} + +function addr_id( $n_family,$n_given,$org_name ) { // find in Addressbook, at least n_family AND (n_given OR org_name) have to match + $contacts = createobject('phpgwapi.contacts'); + + $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" ); + if (!count($addrs)) + $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given" ); + if (!count($addrs)) + $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name" ); + + if (count($addrs)) + return $addrs[0]['id']; + + return False; +} + +$cat2id = array( ); + +function cat_id( $cats ) +{ + if (!$cats) + return ''; + + $cats = explode(',',$cats); + + while (list($k,$cat) = each($cats)) { + if (isset($cat2id[$cat])) { + $ids[$cat] = $cat2id[$cat]; // cat is in cache + } else { + if (!is_object($phpgw->categories)) { + $phpgw->categories = createobject('phpgwapi.categories'); + } + if ($id = $phpgw->categories->name2id( $cat )) { // cat exists + $cat2id[$cat] = $ids[$cat] = $id; + } else { // create new cat + $phpgw->categories->add( $cat,0,$cat,'','public',0); + $cat2id[$cat] = $ids[$cat] = $phpgw->categories->name2id( $cat ); + } + } + } + return implode( ',',$ids ); +} + + switch ($action) { + case '': // Start, ask Filename + $t->set_var('lang_csvfile',lang('CSV-Filename')); + $t->set_var('lang_fieldsep',lang('Fieldseparator')); + $t->set_var('fieldsep',$fieldsep ? $fieldsep : ','); + $t->set_var('submit',lang('Download')); + $t->set_var('csvfile',$csvfile); + $t->set_var('enctype','ENCTYPE="multipart/form-data"'); + $hiddenvars .= ''."\n"; + + $t->parse('filenamehandle','filename'); + break; + + case 'download': + $pref_file = '/tmp/csv_import_info_log.php'; + if (is_readable($pref_file) && ($prefs = fopen($pref_file,'r'))) { + eval(fread($prefs,8000)); + // echo "

defaults = array".dump_array($defaults)."

\n"; + } else { + $defaults = array(); + } + $t->set_var('lang_csv_fieldname',lang('CSV-Fieldname')); + $t->set_var('lang_info_fieldname',lang('Info Log-Fieldname')); + $t->set_var('lang_translation',lang("Translation").' '.lang('help').''); + $t->set_var('submit',lang('Import')); + $t->set_var('lang_debug',lang('Test Import (show importable records only in browser)')); + $t->parse('fheaderhandle','fheader'); + $hiddenvars .= ''."\n". + '\n". + '\n"; + + $info_names = array( 'type' => 'Type: task,phone,note,confirm,reject,email,fax', + 'from' => 'From: text(64) free text if no Addressbook-entry assigned', + 'addr' => 'Addr: text(64) phone-nr/email-address', + 'subject' => 'Subject: text(64)', + 'des' => 'Description: text long free text', + 'owner' => 'Owner: int(11) user-id of owner, if empty current user', + 'responsible' => 'Responsible: int(11) user-id of resp. person', + 'access' => 'Access: public,private', + 'cat' => 'Cathegory: int(11) cathegory-id', + 'datecreated' => 'Date Created: DateTime if empty = Start Date or now', + 'startdate' => 'Start Date: DateTime', + 'enddate' => 'End Date: DateTime', + 'pri' => 'Priority: urgent,high,normal,low', + 'time' => 'Time: int(11) time used in min', + 'bill_cat' => 'Billing Cathegory: int(11)', + 'status' => 'Status: offer,ongoing,call,will-call,done,billed', + 'confirm' => 'Confirmation: not,accept,finish,both when to confirm', + 'cat_id' => 'Categorie id(s), to set use @cat_id(Cat1,Cat2)', + 'addr_id' => 'Addressbook id, to set use @addr_id(nlast,nfirst,org)' ); + + $mktime_lotus = "${PSep}0?([0-9]+)[ .:-]+0?([0-9]*)[ .:-]+0?([0-9]*)[ .:-]+0?([0-9]*)[ .:-]+0?([0-9]*)[ .:-]+0?([0-9]*).*$ASep@mktime(${VPre}4,${VPre}5,${VPre}6,${VPre}2,${VPre}3,${VPre}1)"; + + $defaults += array( 'Land' => "addr$PSep.*[(]+([0-9]+)[)]+$ASep+${VPre}1 (${CPre}Ortsvorwahl$CPos) ${CPre}Telefon$CPos$PSep${CPre}Telefon$CPos", + 'Notiz' => 'des', + 'Privat' => "access${PSep}1${ASep}private${PSep}public", + 'Startdatum' => 'startdate'.$mktime_lotus, + 'Enddatum' => 'enddate'.$mktime_lotus, + 'Erledigt' => "status${PSep}1${ASep}done${PSep}call", + 'Nachname' => "addr_id${PSep}@addr_id(${CPre}Nachname$CPos,${CPre}Vorname$CPos,${CPre}Firma$CPos)", + 'Firma' => "from${PSep}.+$ASep${CPre}Firma$CPos: ${CPre}Nachname$CPos, ${CPre}Vorname$CPos". + "${PSep}${CPre}Nachname$CPos, ${CPre}Vorname$CPos", + 'no CSV 1' => "type${PSep}phone", + 'no CSV 2' => "subject${PSep}@substr(${CPre}Notiz$CPos,0,60).' ...'" ); + + $info_name_options = "