fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [16150] more on rental


From: sigurdne
Subject: [Fmsystem-commits] [16150] more on rental
Date: Wed, 11 Jan 2017 10:29:33 -0500 (EST)

Revision: 16150
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16150
Author:   sigurdne
Date:     2017-01-11 10:29:32 -0500 (Wed, 11 Jan 2017)
Log Message:
-----------
more on rental

Modified Paths:
--------------
    trunk/rental/inc/class.boemail_out.inc.php
    trunk/rental/inc/class.soemail_out.inc.php
    trunk/rental/inc/class.uiemail_out.inc.php
    trunk/rental/templates/base/email_out.xsl

Modified: trunk/rental/inc/class.boemail_out.inc.php
===================================================================
--- trunk/rental/inc/class.boemail_out.inc.php  2017-01-11 07:41:24 UTC (rev 
16149)
+++ trunk/rental/inc/class.boemail_out.inc.php  2017-01-11 15:29:32 UTC (rev 
16150)
@@ -101,4 +101,9 @@
 
                        return $values;
                }
+
+               public function get_composite_candidates( $composite_id )
+               {
+                       return 
rental_soemail_out::get_instance()->get_composite_candidates($composite_id);
+               }
        }
\ No newline at end of file

Modified: trunk/rental/inc/class.soemail_out.inc.php
===================================================================
--- trunk/rental/inc/class.soemail_out.inc.php  2017-01-11 07:41:24 UTC (rev 
16149)
+++ trunk/rental/inc/class.soemail_out.inc.php  2017-01-11 15:29:32 UTC (rev 
16150)
@@ -113,4 +113,48 @@
                        return  $this->db->transaction_commit();
                }
 
+               public function get_composite_candidates( $composite_id )
+               {
+                       $composite_id = (int) $composite_id;
+                       $values = array();
+                       $ts_query = strtotime(date('Y-m-d')); // timestamp for 
query (today)
+
+                       $sql = "SELECT email, first_name, last_name, 
company_name, rental_party.id"
+                               . " FROM rental_contract_composite"
+                               . " {$this->join} rental_contract ON 
rental_contract_composite.contract_id = rental_contract.id"
+                               . " {$this->join} rental_contract_party ON 
rental_contract_party.contract_id = rental_contract.id"
+                               . " {$this->join} rental_party ON 
rental_contract_party.party_id = rental_party.id"
+                               . " WHERE 
rental_contract_composite.composite_id = {$composite_id}"
+                               . " AND rental_contract.date_start <= 
{$ts_query} AND ( rental_contract.date_end >= {$ts_query} OR 
rental_contract.date_end IS NULL)";
+
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       while ($this->db->next_record())
+                       {
+                               $first_name = $this->db->f('first_name',true);
+                               $last_name = $this->db->f('last_name',true);
+                               $company_name = 
$this->db->f('company_name',true);
+
+                               $name = '';
+                               if($last_name)
+                               {
+                                       $name .= "$last_name, $first_name";
+                               }
+                               if($last_name && $company_name)
+                               {
+                                       $name .= " ({$company_name})";
+                               }
+                               else if($company_name)
+                               {
+                                       $name = $company_name;
+                               }
+
+                               $values[] = array(
+                                       'id'    => $this->db->f('id'),
+                                       'name'  => $name,
+                                       'email' => $this->db->f('email',true),
+                               );
+                       }
+                       return $values;
+               }
+
        }
\ No newline at end of file

Modified: trunk/rental/inc/class.uiemail_out.inc.php
===================================================================
--- trunk/rental/inc/class.uiemail_out.inc.php  2017-01-11 07:41:24 UTC (rev 
16149)
+++ trunk/rental/inc/class.uiemail_out.inc.php  2017-01-11 15:29:32 UTC (rev 
16150)
@@ -41,7 +41,8 @@
                        'view' => true,
                        'edit' => true,
                        'save' => true,
-                       'get' => true
+                       'get' => true,
+                       'get_candidates' => true
                );
 
                protected
@@ -191,6 +192,59 @@
                                )
                        );
 
+                       $candidates_def = array(
+                               array('key' => 'id', 'label' => '#', 'sortable' 
=> true, 'resizeable' => true),
+                               array('key' => 'name', 'label' => lang('name'), 
'sortable' => true, 'resizeable' => true),
+                               array('key' => 'email', 'label' => 
lang('email'), 'sortable' => true, 'resizeable' => true),
+                       );
+
+                       $tabletools = array
+                               (
+                               array('my_name' => 'select_all'),
+                               array('my_name' => 'select_none')
+                       );
+
+                       $tabletools[] = array
+                               (
+                               'my_name' => 'add',
+                               'text' => lang('add'),
+                               'type' => 'custom',
+                               'custom_code' => "
+                                               var api = oTable1.api();
+                                               var selected = api.rows( { 
selected: true } ).data();
+
+                                               var numSelected =       
selected.length;
+
+                                               if (numSelected ==0){
+                                                       alert('None selected');
+                                                       return false;
+                                               }
+                                               var ids = [];
+                                               for ( var n = 0; n < 
selected.length; ++n )
+                                               {
+                                                       var aData = selected[n];
+                                                       ids.push(aData['id']);
+                                               }
+                                               
onActionsClick_candidates('add', ids);
+                                               "
+                       );
+
+                       $datatable_def[] = array
+                               (
+                               'container' => 'datatable-container_1',
+                               'requestUrl' => "''",
+//                             'requestUrl' => 
json_encode(self::link(array('menuaction' => 'property.notify.update_data',
+//                                             'location_id' => $location_id, 
'location_item_id' => $id, 'action' => 'refresh_notify_contact',
+//                                             'phpgw_return_as' => 'json'))),
+                               'ColumnDefs' => $candidates_def,
+                               'data' => json_encode(array()),
+                               'tabletools' => $tabletools,
+                               'config' => array(
+                                       array('disableFilter' => true),
+                                       array('disablePagination' => true)
+                               )
+                       );
+
                        $data = array(
                                'datatable_def' => $datatable_def,
                                'form_action' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'rental.uiemail_out.save')),
@@ -230,4 +284,27 @@
                {
                        parent::save();
                }
+
+               public function get_candidates( )
+               {
+                       if (empty($this->permissions[PHPGW_ACL_ADD]))
+                       {
+                               phpgw::no_access();
+                       }
+                       $type =  phpgw::get_var('type', 'string');
+                       $id =  phpgw::get_var('id', 'int');
+
+                       switch ($type)
+                       {
+                               case 'composite':
+                                       $values = 
$this->bo->get_composite_candidates($id);
+                                       break;
+
+                               default:
+                                       $values = array();
+                                       break;
+                       }
+
+                       return $this->jquery_results(array('results' => 
$values));
+               }
        }
\ No newline at end of file

Modified: trunk/rental/templates/base/email_out.xsl
===================================================================
--- trunk/rental/templates/base/email_out.xsl   2017-01-11 07:41:24 UTC (rev 
16149)
+++ trunk/rental/templates/base/email_out.xsl   2017-01-11 15:29:32 UTC (rev 
16150)
@@ -130,6 +130,24 @@
                                                        </input>
                                                        <div 
id="composite_container"/>
                                                </div>
+                                       <div class="pure-control-group">
+                                               <label>
+                                                       <xsl:value-of 
select="php:function('lang', 'candidates')"/>
+                                               </label>
+
+                                               <xsl:for-each 
select="datatable_def">
+                                                       <xsl:if test="container 
= 'datatable-container_1'">
+                                                               
<xsl:call-template name="table_setup">
+                                                                       
<xsl:with-param name="container" select ='container'/>
+                                                                       
<xsl:with-param name="requestUrl" select ='requestUrl'/>
+                                                                       
<xsl:with-param name="ColumnDefs" select ='ColumnDefs'/>
+                                                                       
<xsl:with-param name="data" select ='data'/>
+                                                                       
<xsl:with-param name="tabletools" select ='tabletools'/>
+                                                                       
<xsl:with-param name="config" select ='config'/>
+                                                               
</xsl:call-template>
+                                                       </xsl:if>
+                                               </xsl:for-each>
+                                       </div>
                                        </fieldset>
 
                                </div>




reply via email to

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