fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [7388]


From: Erik Holm-Larsen
Subject: [Fmsystem-commits] [7388]
Date: Thu, 16 Jun 2011 11:54:44 +0000

Revision: 7388
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7388
Author:   erikhl
Date:     2011-06-16 11:54:43 +0000 (Thu, 16 Jun 2011)
Log Message:
-----------


Modified Paths:
--------------
    trunk/activitycalendar/inc/class.soactivity.inc.php
    trunk/activitycalendar/inc/class.socontactperson.inc.php
    trunk/activitycalendar/inc/class.uiactivities.inc.php
    trunk/activitycalendar/inc/class.uiorganization.inc.php
    trunk/activitycalendar/js/activitycalendar/common.js
    trunk/activitycalendar/templates/base/activity.php
    trunk/activitycalendar/templates/base/common.php

Modified: trunk/activitycalendar/inc/class.soactivity.inc.php
===================================================================
--- trunk/activitycalendar/inc/class.soactivity.inc.php 2011-06-16 10:30:40 UTC 
(rev 7387)
+++ trunk/activitycalendar/inc/class.soactivity.inc.php 2011-06-16 11:54:43 UTC 
(rev 7388)
@@ -344,11 +344,21 @@
                        
$activity->set_description($this->unmarshal($this->db->f('description'), 
'string'));
                        
$activity->set_arena($this->unmarshal($this->db->f('arena'), 'string'));
                        
$activity->set_time($this->unmarshal($this->db->f('time'), 'string'));
-                       
$activity->set_contact_person_1($this->unmarshal($this->db->f('contact_person_1'),
 'int'));
-                       
$activity->set_contact_person_2($this->unmarshal($this->db->f('contact_person_2'),
 'int'));
                        
$activity->set_last_change_date($this->unmarshal($this->db->f('last_change_date'),
 'int'));
                        
$activity->set_special_adaptation($this->unmarshal($this->db->f('special_adaptation',
 'bool')));
                        
$activity->set_secret($this->unmarshal($this->db->f('secret'), 'string'));
+                       
+                       if($activity->get_group_id() && 
$activity->get_group_id() > 0)
+                       {
+                               $contacts = 
activitycalendar_sogroup::get_instance()->get_contacts($activity->get_group_id());
+                               $activity->set_contact_persons($contacts);
+                       }
+                       else if($activity->get_organization_id() && 
$activity->get_organization_id() > 0)
+                       {
+                               $contacts = 
activitycalendar_soorganization::get_instance()->get_contacts($activity->get_organization_id());
+                               $activity->set_contact_persons($contacts);
+                       }
+                       
                }
                return $activity;
        }
@@ -734,4 +744,220 @@
                }
                return $categories;
        }
+       function update_organization($org_info)
+       {
+               $name = $org_info['name'];
+               $orgid = (int)$org_info['orgid'];
+               $homepage = $org_info['homepage'];
+               $phone = $org_info['phone'];
+               $email = $org_info['email'];
+               $description = $org_info['description'];
+               $street = $org_info['street'];
+               $zip = $org_info['zip'];
+               if($zip && strlen($zip) > 5)
+               {
+                       $zip_code = substr($zip,0,4);
+                       $city = substr($zip, 5);
+               }
+               else
+               {
+                       $zip_code = '';
+                       $city = '';
+               }
+               $district = $org_info['district'];
+               $activity_id = $org_info['activity_id'];
+               $show_in_portal = 1; 
+               
+               $values = array(
+                       'name = ' . $this->marshal($name, 'string'),
+                       'homepage = ' . $this->marshal($homepage, 'string'),
+                       'phone = ' . $this->marshal($phone, 'string'),
+                       'email = ' . $this->marshal($email, 'string'),
+                       'description = ' . $this->marshal($description, 
'string'),
+                       'street = ' . $this->marshal($street, 'string'),
+                       'zip_code = ' . $this->marshal($zip_code, 'string'),
+                       'city = ' . $this->marshal($city, 'string'),
+                       'district = ' . $this->marshal($district),
+                       'activity_id = ' . $this->marshal($activity_id, 'int'),
+                       'show_in_portal = 1'
+               );
+               
+               $result = $this->db->query('UPDATE bb_organization SET ' . 
join(',', $values) . " WHERE id=$orgid", __LINE__,__FILE__);
+       }
+       function add_organization($org_info)
+       {
+               $name = $org_info['name'];
+               $orgnr = $org_info['orgnr'];
+               $homepage = $org_info['homepage'];
+               $phone = $org_info['phone'];
+               $email = $org_info['email'];
+               $description = $org_info['description'];
+               $street = $org_info['street'];
+               $zip = $org_info['zip'];
+               if($zip && strlen($zip) > 5)
+               {
+                       $zip_code = substr($zip,0,4);
+                       $city = substr($zip, 5);
+               }
+               else
+               {
+                       $zip_code = '';
+                       $city = '';
+               }
+               $district = $org_info['district'];
+               $activity_id = $org_info['activity_id'];
+               $show_in_portal = 1; 
+               
+               $columns[] = 'name';
+               $columns[] = 'homepage';
+               $columns[] = 'phone';
+               $columns[] = 'email';
+               $columns[] = 'description';
+               $columns[] = 'street';
+               $columns[] = 'zip_code';
+               $columns[] = 'city';
+               $columns[] = 'district';
+               $columns[] = 'organization_number';
+               $columns[] = 'activity_id';
+               $columns[] = 'show_in_portal';
+               $cols = implode(',',$columns);
+               
+               $values[] = "{$name}";
+               $values[] = "{$homepage}";
+               $values[] = "{$phone}";
+               $values[] = "{$email}";
+               $values[] = "{$description}";
+               $values[] = "{$street}";
+               $values[] = "{$zip_code}";
+               $values[] = "{$city}";
+               $values[] = "{$orgnr}";
+               $values[] = "{$district}";
+               $values[] = $activity_id;
+               $values[] = $show_in_portal;
+               $vals = implode(',',$values);
+               
+               $sql = "INSERT INTO bb_organization ({$cols}) VALUES ({$vals})";
+       $result = $this->db->query($sql, __LINE__, __FILE__);
+               if(isset($result))
+               {
+                       return $this->db->get_last_insert_id('bb_organization', 
'id');
+               }
+               else
+               {
+                       return 0;
+               }
+       }
+       
+       function add_group($group_info)
+       {
+               $name = $org_info['name'];
+               $orgid = $org_info['organization_id'];
+               $description = $org_info['description'];
+               $activity_id = $org_info['activity_id'];
+               $show_in_portal = 1; 
+               
+               $columns[] = 'name';
+               $columns[] = 'description';
+               $columns[] = 'organization_id';
+               $columns[] = 'activity_id';
+               $columns[] = 'show_in_portal';
+               $cols = implode(',',$columns);
+               
+               $values[] = "{$name}";
+               $values[] = "{$description}";
+               $values[] = "{$orgid}";
+               $values[] = $activity_id;
+               $values[] = $show_in_portal;
+               $vals = implode(',',$values);
+               
+               $sql = "INSERT INTO bb_group ({$cols}) VALUES ({$vals})";
+       $result = $this->db->query($sql, __LINE__, __FILE__);
+               if(isset($result))
+               {
+                       return $this->db->get_last_insert_id('bb_group', 'id');
+               }
+               else
+               {
+                       return 0;
+               }
+       }
+       
+       function delete_contact_persons($org_id)
+       {
+               if($org_id)
+               {
+                       $org = (int)$org_id;
+                       $sql = "DELETE FROM bb_organization_contact WHERE 
organization_id={$org}";
+                       $result = $this->db->query($sql, __LINE__, __FILE__);
+                       return isset($result);
+               }
+/*             else if($group_id)
+               {
+                       $group = (int)$group_id;
+                       $sql = "DELETE FROM bb_group_contact WHERE 
group_id={$group}";
+                       $result = $this->db->query($sql, __LINE__, __FILE__);
+                       return isset($result);
+               }*/
+       }
+       
+       function add_contact_person_org($contact)
+       {
+               $name = $contact2['name'];
+               $phone = $contact2['phone'];
+               $mail = $contact2['mail'];
+               $org_id = $contact2['org_id'];
+               $ssn = '';
+               
+               $columns[] = 'name';
+               $columns[] = 'ssn';
+               $columns[] = 'phone';
+               $columns[] = 'email';
+               $columns[] = 'organization_id';
+               $cols = implode(',',$columns);
+               
+               $values[] = "{$name}";
+               $values[] = "{$ssn}";
+               $values[] = "{$phone}";
+               $values[] = "{$mail}";
+               $values[] = $org_id;
+               $vals = implode(',',$values);
+               
+               $sql = "INSERT INTO bb_organization_contact ({$cols}) VALUES 
({$vals})";
+       $result = $this->db->query($sql, __LINE__, __FILE__);
+               return isset($result);
+       }
+       
+       function update_contact_person_org($contact)
+       {
+               
+       }
+       
+       function add_contact_person_group($contact)
+       {
+               $name = $contact2['name'];
+               $phone = $contact2['phone'];
+               $mail = $contact2['mail'];
+               $org_id = $contact2['group_id'];
+               
+               $columns[] = 'name';
+               $columns[] = 'phone';
+               $columns[] = 'email';
+               $columns[] = 'group_id';
+               $cols = implode(',',$columns);
+               
+               $values[] = "{$name}";
+               $values[] = "{$phone}";
+               $values[] = "{$mail}";
+               $values[] = $org_id;
+               $vals = implode(',',$values);
+               
+               $sql = "INSERT INTO bb_group_contact ({$cols}) VALUES 
({$vals})";
+       $result = $this->db->query($sql, __LINE__, __FILE__);
+               return isset($result);
+       }
+       
+       function update_contact_person_group($contact)
+       {
+               
+       }
 }

Modified: trunk/activitycalendar/inc/class.socontactperson.inc.php
===================================================================
--- trunk/activitycalendar/inc/class.socontactperson.inc.php    2011-06-16 
10:30:40 UTC (rev 7387)
+++ trunk/activitycalendar/inc/class.socontactperson.inc.php    2011-06-16 
11:54:43 UTC (rev 7388)
@@ -186,10 +186,10 @@
        {
                $result = "Ingen";
        if(isset($id)){
-               $q1="SELECT name FROM bb_group_contact WHERE id={$id}";
+               $q1="SELECT name, phone, email FROM bb_group_contact WHERE 
id={$id}";
                        $this->db->query($q1, __LINE__, __FILE__);
                        while($this->db->next_record()){
-                               $result = $this->db->f('name');
+                               $result = $this->db->f('name') . "<br/>" . 
$this->db->f('phone') . "<br/>" . $this->db->f('email');
                        }
        }
                return $result;
@@ -199,10 +199,10 @@
        {
                $result = "Ingen";
        if(isset($id)){
-               $q1="SELECT name FROM bb_organization_contact WHERE id={$id}";
+               $q1="SELECT name, phone, email FROM bb_organization_contact 
WHERE id={$id}";
                        $this->db->query($q1, __LINE__, __FILE__);
                        while($this->db->next_record()){
-                               $result = $this->db->f('name');
+                               $result = $this->db->f('name') . "<br/>" . 
$this->db->f('phone') . "<br/>" . $this->db->f('email');
                        }
        }
                return $result;
@@ -210,7 +210,7 @@
        
        function get_mailaddress_for_group_contact($contact_person_id)
        {
-               if(isset($contact_person_id)){
+               if($contact_person_id){
                $q1="SELECT email FROM bb_group_contact WHERE 
id={$contact_person_id}";
                        $this->db->query($q1, __LINE__, __FILE__);
                        while($this->db->next_record()){
@@ -222,8 +222,8 @@
        
        function get_mailaddress_for_org_contact($contact_person_id)
        {
-               if(isset($contact_person_id)){
-               $q1="SELECT email FROM bb_group_contact WHERE 
id={$contact_person_id}";
+               if($contact_person_id){
+               $q1="SELECT email FROM bb_organization_contact WHERE 
id={$contact_person_id}";
                        $this->db->query($q1, __LINE__, __FILE__);
                        while($this->db->next_record()){
                                $result = $this->db->f('email');

Modified: trunk/activitycalendar/inc/class.uiactivities.inc.php
===================================================================
--- trunk/activitycalendar/inc/class.uiactivities.inc.php       2011-06-16 
10:30:40 UTC (rev 7387)
+++ trunk/activitycalendar/inc/class.uiactivities.inc.php       2011-06-16 
11:54:43 UTC (rev 7388)
@@ -41,6 +41,7 @@
        
        public function index()
        {
+               //$message = phpgw::get_var('message');
                $this->render('activity_list.php');
                
        }
@@ -308,17 +309,21 @@
        
        //var_dump($subject);
        //var_dump($body);
+       //var_dump($activity->get_organization_id() . " ; " . 
$activity->get_group_id());
        
-       
-       if($activity->get_group_id())
+       if($activity->get_group_id() && $activity->get_group_id() > 0)
        {
+               //$contact_person2 = 
activitycalendar_socontactperson::get_instance()->get_group_contact2($activity>get_group_id());
                
activitycalendar_uiactivities::send_mailnotification_to_group($activity->get_contact_person_2(),
 $subject, $body);
        }
-       else if($activity->get_organization_id())
+       else if($activity->get_organization_id() && 
$activity->get_organization_id() > 0)
        {
+               //$contact_person2 = 
activitycalendar_socontactperson::get_instance()->get_oup_contact2($activity>get_group_id());
                
activitycalendar_uiactivities::send_mailnotification_to_organization($activity->get_contact_person_2(),
 $subject, $body);
        }
        
+       $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'activitycalendar.uiactivities.index', 'message' => 'E-post sendt'));
+       
     }
     
        function send_mailnotification_to_organization($contact_person_id, 
$subject, $body)
@@ -342,6 +347,8 @@
                
                $mailtoAddress = 
activitycalendar_socontactperson::get_instance()->get_mailaddress_for_org_contact($contact_person_id);
                //$mailtoAddress = "address@hidden";
+               
+               //var_dump($mailtoAddress);
 
                if (strlen($mailtoAddress) > 0) 
                {

Modified: trunk/activitycalendar/inc/class.uiorganization.inc.php
===================================================================
--- trunk/activitycalendar/inc/class.uiorganization.inc.php     2011-06-16 
10:30:40 UTC (rev 7387)
+++ trunk/activitycalendar/inc/class.uiorganization.inc.php     2011-06-16 
11:54:43 UTC (rev 7388)
@@ -4,13 +4,15 @@
 phpgw::import_class('activitycalendar.sogroup');
 
 include_class('activitycalendar', 'organization', 'inc/model/');
+include_class('activitycalendar', 'group', 'inc/model/');
 
 class activitycalendar_uiorganization extends activitycalendar_uicommon
 {
        public $public_functions = array
        (
                'index'                         => true,
-               'query'                         => true
+               'query'                         => true,
+               'get_organization_groups' => true
        );
        
        public function __construct()
@@ -23,10 +25,36 @@
        
        public function index()
        {
+               if(phpgw::get_var('phpgw_return_as') == 'json') {
+                       return $this->index_json();
+               }
+                       
                $this->render('organization_list.php');
        }
        
+       public function index_json()
+       {
+               $organizations = 
activitycalendar_soorganization::get_instance()->get(); //get organizations
+               array_walk($organizations["results"], array($this, 
"_add_links"), "booking.uiorganization.show");
 
+               foreach($organizations["results"] as &$organization) {
+
+                       $contact = (isset($organization['contacts']) && 
isset($organization['contacts'][0])) ? $organization['contacts'][0] : null;
+
+                       if ($contact) {
+                               $organization += array(
+                                                       "primary_contact_name"  
=> ($contact["name"])  ? $contact["name"] : '',
+                                                       "primary_contact_phone" 
=> ($contact["phone"]) ? $contact["phone"] : '',
+                                                       "primary_contact_email" 
=> ($contact["email"]) ? $contact["email"] : '',
+                               );
+                       }
+               }
+
+               return $this->yui_results($organizations);
+       }
+       
+       
+
        /**
         * (non-PHPdoc)
         * @see rental/inc/rental_uicommon#query()
@@ -117,6 +145,39 @@
                
                return $this->yui_results($organization_data, 'total_records', 
'results');
        }
+       
+       public function get_organization_groups()
+       {
+               $org_id = phpgw::get_var('orgid');
+               $group_id = phpgw::get_var('groupid');
+               $returnHTML = "<option value='0'>Ingen gruppe valgt</option>";
+               if($org_id)
+               {
+                       $groups = 
activitycalendar_sogroup::get_instance()->get(null, null, null, null, null, 
null, array('org_id' => $org_id));
+                       foreach ($groups as $group) {
+                               if(isset($group))
+                               {
+                                       //$res_g = $group->serialize();
+                                       $selected = "";
+                                       if($group_id && $group_id > 0)
+                                       {
+                                               $gr_id = (int)$group_id; 
+                                               if($gr_id == $group->get_id())
+                                               {
+                                                       $selected = "selected";
+                                               }
+                                       }
+                                       $group_html[] = "<option value='" . 
$group->get_id() . "'". $selected_group . ">" . $group->get_name() . 
"</option>";
+                               }
+                       }
+                   $html = implode(' ' , $group_html);
+                   $returnHTML = $returnHTML . ' ' . $html;
+               }
+               
+               
+               return $returnHTML;
+               //return "<option>Ingen gruppe valgt</option>";
+       }
 
        /**
         * Public method. Called when a user wants to view information about a 
party.

Modified: trunk/activitycalendar/js/activitycalendar/common.js
===================================================================
--- trunk/activitycalendar/js/activitycalendar/common.js        2011-06-16 
10:30:40 UTC (rev 7387)
+++ trunk/activitycalendar/js/activitycalendar/common.js        2011-06-16 
11:54:43 UTC (rev 7388)
@@ -257,3 +257,32 @@
         YAHOO.util.Dom.replaceClass(fieldname + "_edit", "showit", "hideit");
     }
 }
+
+/*
+YAHOO.activitycalendar.autocompleteHelper = function(url, field, hidden, 
container, label_attr) {
+       label_attr = label_attr || 'name';
+       var myDataSource = new YAHOO.util.DataSource(url);
+       myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
+       myDataSource.connXhrMode = "queueRequests";
+       myDataSource.responseSchema = {
+               resultsList: "ResultSet.Result",
+               fields: [label_attr, 'id']
+       };
+       myDataSource.maxCacheEntries = 5; 
+       console.log(myDataSource);
+       console.log(field);
+       console.log(container);
+       console.log(YAHOO.widget.AutoComplete);
+       var ac = new YAHOO.widget.AutoComplete(field, container, myDataSource);
+       ac.queryQuestionMark = false;
+       ac.resultTypeList = false;
+       ac.forceSelection = true;
+       console.log(ac);
+       
+       ac.itemSelectEvent.subscribe(function(sType, aArgs) {
+               console.log(aArgs[2]);
+               YAHOO.util.Dom.get(hidden).value = aArgs[2].id;
+       });
+       return ac;
+};
+*/
\ No newline at end of file

Modified: trunk/activitycalendar/templates/base/activity.php
===================================================================
--- trunk/activitycalendar/templates/base/activity.php  2011-06-16 10:30:40 UTC 
(rev 7387)
+++ trunk/activitycalendar/templates/base/activity.php  2011-06-16 11:54:43 UTC 
(rev 7388)
@@ -5,6 +5,40 @@
        $contpers_so = activitycalendar_socontactperson::get_instance();
 ?>
 
+<script type="text/javascript">
+
+function get_available_groups()
+{
+       var org_id = document.getElementById('organization_id').value;
+       var group_select = document.getElementById('group_id');
+       //alert(group_select);
+<?php if($activity->get_group_id()){?>
+       url = 
"index.php?menuaction=activitycalendar.uiorganization.get_organization_groups&amp;phpgw_return_as=json&amp;orgid="
 + org_id + "&amp;groupid=" + <?php echo $activity->get_group_id();?>;
+<?php }else{?>
+       url = 
"index.php?menuaction=activitycalendar.uiorganization.get_organization_groups&amp;phpgw_return_as=json&amp;orgid="
 + org_id;
+<?php }?>
+       
+/*     $.ajax({url: url, 
+               success:  function(response) {
+                       $("#group_id").innerHTML = response;
+               }
+       });
+*/
+       var callback = {
+               success: function(response){
+                                       //alert("det funker");
+                                       group_select.innerHTML = 
response.responseText;
+                               },
+               failure: function(o) {
+                                        alert("AJAX doesn't work"); //FAILURE
+                                }
+       }
+       var trans = YAHOO.util.Connect.asyncRequest('GET', url, callback, null);
+       
+}
+
+</script>
+
 <div class="yui-content">
        <div id="details">
                <h1><img src="<?php echo ACTIVITYCALENDAR_IMAGE_PATH 
?>images/32x32/custom/contact.png" /><?php echo lang('activity') ?></h1>
@@ -42,7 +76,7 @@
                                        if ($editable)
                                        {
                                                ?>
-                                               <select name="organization_id">
+                                               <select name="organization_id" 
id="organization_id" onchange="javascript:get_available_groups();">
                                                        <option value="">Ingen 
organisasjon valgt</option>
                                                        <?php
                                                        foreach($organizations 
as $organization)
@@ -74,14 +108,8 @@
                                        if ($editable)
                                        {
                                                ?>
-                                               <select name="group_id">
+                                               <select name="group_id" 
id="group_id">
                                                        <option value="0">Ingen 
gruppe valgt</option>
-                                                       <?php
-                                                       foreach($groups as 
$group)
-                                                       {
-                                                               echo "<option 
".($current_group_id == $group->get_id() ? 'selected="selected"' : "")." 
value=\"{$group->get_id()}\">".$group->get_name()."</option>";
-                                                       }
-                                                       ?>
                                                </select>
                                                <?php
                                        ?>

Modified: trunk/activitycalendar/templates/base/common.php
===================================================================
--- trunk/activitycalendar/templates/base/common.php    2011-06-16 10:30:40 UTC 
(rev 7387)
+++ trunk/activitycalendar/templates/base/common.php    2011-06-16 11:54:43 UTC 
(rev 7388)
@@ -957,4 +957,29 @@
         return ret;
     });
 }
+/*
+YAHOO.activitycalendar.autocompleteHelper = function(url, field, hidden, 
container, label_attr) {
+       label_attr = label_attr || 'name';
+       var myDataSource = new YAHOO.util.DataSource(url);
+       myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
+       myDataSource.connXhrMode = "queueRequests";
+       myDataSource.responseSchema = {
+               resultsList: "ResultSet.Result",
+               fields: [label_attr, 'id']
+       };
+       myDataSource.maxCacheEntries = 5; 
+       console.log(myDataSource);
+       console.log(field);
+       console.log(container);
+       var ac = new YAHOO.widget.AutoComplete(field, container, myDataSource);
+       ac.queryQuestionMark = false;
+       ac.resultTypeList = false;
+       ac.forceSelection = true;
+       console.log(ac);
+       ac.itemSelectEvent.subscribe(function(sType, aArgs) {
+               YAHOO.util.Dom.get(hidden).value = aArgs[2].id;
+       });
+       return ac;
+};
+*/
 </script>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]