fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [12078] rental: tweak contract


From: Sigurd Nes
Subject: [Fmsystem-commits] [12078] rental: tweak contract
Date: Sun, 07 Sep 2014 16:40:12 +0000

Revision: 12078
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=12078
Author:   sigurdne
Date:     2014-09-07 16:40:11 +0000 (Sun, 07 Sep 2014)
Log Message:
-----------
rental: tweak contract

Modified Paths:
--------------
    trunk/rental/inc/class.socontract.inc.php
    trunk/rental/inc/class.soprice_item.inc.php
    trunk/rental/inc/class.uicontract.inc.php
    trunk/rental/inc/model/class.contract.inc.php
    trunk/rental/setup/phpgw_no.lang
    trunk/rental/setup/setup.inc.php
    trunk/rental/setup/tables_current.inc.php
    trunk/rental/setup/tables_update.inc.php
    trunk/rental/templates/base/contract.php
    trunk/rental/templates/base/contract_list_partial.php

Added Paths:
-----------
    trunk/rental/js/rental/contract.edit.js

Property Changed:
----------------
    trunk/


Property changes on: trunk
___________________________________________________________________
Modified: svn:ignore
   - header.inc.php
.svnignore
.cache
.settings
.project
.*.swp
nbproject
.buildpath

   + header.inc.php
.svnignore
.cache
.settings
.project
.*.swp
nbproject
.buildpath
.~lock.hms_1_1.xml#


Modified: trunk/rental/inc/class.socontract.inc.php
===================================================================
--- trunk/rental/inc/class.socontract.inc.php   2014-09-07 16:36:02 UTC (rev 
12077)
+++ trunk/rental/inc/class.socontract.inc.php   2014-09-07 16:40:11 UTC (rev 
12078)
@@ -236,17 +236,32 @@
                 * - ended:
                 * the end date is smaller than the target date
                 */
-               if(isset($filters['contract_status']) && 
$filters['contract_status'] != 'all'){
+               if($filters['start_date_report'])
+               {
+                       $filters['contract_status'] = 'all';
+                       $filter_clauses[] = "contract.date_end > 
{$filters['start_date_report']}";
+                       $filter_clauses[] = "contract.date_start < 
{$filters['start_date_report']}";
 
-                       if(isset($filters['status_date_hidden']) && 
$filters['status_date_hidden'] != "")
+               }
+               if($filters['end_date_report'])
+               {
+                       $filters['contract_status'] = 'all';
+                       $filter_clauses[] = "contract.date_end < 
{$filters['end_date_report']}";
+
+               }
+//_debug_array($filtes);die();
+               if(isset($filters['contract_status']) && 
$filters['contract_status'] != 'all')
+               {
+                       if(isset($filters['status_date']) && 
$filters['status_date'])
                        {
-                               $ts_query = 
strtotime($filters['status_date_hidden']); // target timestamp specified by user
+                               $ts_query = $filters['status_date']; // target 
timestamp specified by user
                        }
                        else
                        {
                                $ts_query = strtotime(date('Y-m-d')); // 
timestamp for query (today)
                        }
-                       switch($filters['contract_status']){
+                       switch($filters['contract_status'])
+                       {
                                case 'under_planning':
                                        $filter_clauses[] = 
"contract.date_start > {$ts_query} OR contract.date_start IS NULL";
                                        break;
@@ -324,7 +339,7 @@
                {
                        // columns to retrieve
                        $columns[] = 'contract.id AS contract_id';
-                       $columns[] = 'contract.date_start, contract.date_end, 
contract.old_contract_id, contract.executive_officer, contract.last_updated, 
contract.location_id, contract.billing_start, contract.service_id, 
contract.responsibility_id, contract.reference, contract.invoice_header, 
contract.project_id, billing.deleted, contract.account_in, 
contract.account_out, contract.term_id, contract.security_type, 
contract.security_amount, contract.comment, contract.due_date, 
contract.contract_type_id,contract.rented_area,contract.adjustable,contract.adjustment_interval,contract.adjustment_share,contract.adjustment_year,contract.publish_comment';
+                       $columns[] = 'contract.date_start, contract.date_end, 
contract.old_contract_id, contract.executive_officer, contract.last_updated, 
contract.location_id, contract.billing_start, contract.billing_end, 
contract.service_id, contract.responsibility_id, contract.reference, 
contract.invoice_header, contract.project_id, billing.deleted, 
contract.account_in, contract.account_out, contract.term_id, 
contract.security_type, contract.security_amount, contract.comment, 
contract.due_date, 
contract.contract_type_id,contract.rented_area,contract.adjustable,contract.adjustment_interval,contract.adjustment_share,contract.adjustment_year,contract.publish_comment';
                        $columns[] = 'party.id AS party_id';
                        $columns[] = 'party.first_name, party.last_name, 
party.company_name, party.department, party.org_enhet_id';
                        $columns[] = 'c_t.is_payer';
@@ -385,6 +400,7 @@
                                )
                        );
                        
$contract->set_billing_start_date($this->unmarshal($this->db->f('billing_start'),'int'));
+                       
$contract->set_billing_end_date($this->unmarshal($this->db->f('billing_end'),'int'));
                        
$contract->set_old_contract_id($this->unmarshal($this->db->f('old_contract_id'),'string'));
                        
$contract->set_contract_type_title($this->unmarshal($this->db->f('title'),'string'));
                        
$contract->set_comment($this->unmarshal($this->db->f('comment'),'string'));
@@ -580,6 +596,7 @@
                $values[] = "invoice_header = ".        
$this->marshal($contract->get_invoice_header(),'string');
                $values[] = "term_id = " .                      
$this->marshal($contract->get_term_id(), 'int');
                $values[] = "billing_start = " .        
$this->marshal($contract->get_billing_start_date(), 'int');
+               $values[] = "billing_end = " .          
$this->marshal($contract->get_billing_end_date(), 'int');
                $values[] = "reference = ".             
$this->marshal($contract->get_reference(),'string');
 
                // FORM COLUMN 2
@@ -726,6 +743,11 @@
                        $values[] = 
$this->marshal($contract->get_billing_start_date(), 'int');
                }
 
+               if ($contract->get_billing_end_date()) {
+                       $cols[] = 'billing_end';
+                       $values[] = 
$this->marshal($contract->get_billing_end_date(), 'int');
+               }
+
                if ($contract->get_contract_date()) {
                        $cols[] = 'date_start';
                        $cols[] = 'date_end';

Modified: trunk/rental/inc/class.soprice_item.inc.php
===================================================================
--- trunk/rental/inc/class.soprice_item.inc.php 2014-09-07 16:36:02 UTC (rev 
12077)
+++ trunk/rental/inc/class.soprice_item.inc.php 2014-09-07 16:40:11 UTC (rev 
12078)
@@ -361,7 +361,21 @@
                                (str_replace(',','.',$price_item->get_price()) 
* $factor),
                                str_replace(',','.',$total_price)
                        );
-                       $q = "INSERT INTO rental_contract_price_item 
(price_item_id, contract_id, title, area, agresso_id, is_area, price, 
total_price) VALUES (" . join(',', $values) . ")";
+                               $start_date_field = '';
+                               $end_date_field = '';
+
+                       if( $start_date = $contract->get_billing_start_date())
+                       {
+                               $values[] = $start_date;
+                               $start_date_field = ", date_start";
+                       }
+                       if( $end_date = $contract->get_billing_end_date())
+                       {
+                               $values[] = $end_date;
+                               $end_date_field = ", date_end";
+                       }
+
+                       $q = "INSERT INTO rental_contract_price_item 
(price_item_id, contract_id, title, area, agresso_id, is_area, price, 
total_price {$start_date_field} {$end_date_field}) VALUES (" . join(',', 
$values) . ")";
                        //var_dump($q);
                        $result = $this->db->query($q);
                        if($result)

Modified: trunk/rental/inc/class.uicontract.inc.php
===================================================================
--- trunk/rental/inc/class.uicontract.inc.php   2014-09-07 16:36:02 UTC (rev 
12077)
+++ trunk/rental/inc/class.uicontract.inc.php   2014-09-07 16:40:11 UTC (rev 
12078)
@@ -16,6 +16,8 @@
        include_class('rental', 'contract_price_item', 'inc/model/');
        include_class('rental', 'notification', 'inc/model/');
 
+       phpgw::import_class('phpgwapi.datetime');
+
        class rental_uicontract extends rental_uicommon
        {
                private $pdf_templates = array();
@@ -151,7 +153,8 @@
                                        
                                        break;
                                case 'contracts_for_composite': // ... all 
contracts this composite is involved in, filters (status and date)
-                                       $filters = array('composite_id' => 
phpgw::get_var('composite_id'),'contract_status' => 
phpgw::get_var('contract_status'), 'contract_type' => 
phpgw::get_var('contract_type'), 'status_date_hidden' => 
phpgw::get_var('date_status_hidden'));
+                                       $filters = array('composite_id' => 
phpgw::get_var('composite_id'),'contract_status' => 
phpgw::get_var('contract_status'), 'contract_type' => 
phpgw::get_var('contract_type'));
+                                       $filters['status_date']                 
= phpgwapi_datetime::date_to_timestamp(phpgw::get_var('date_status'));
                                        break;
                                case 'get_contract_warnings':   //get the 
contract warnings
                                        $contract = 
rental_socontract::get_instance()->get_single(phpgw::get_var('contract_id'));
@@ -167,7 +170,11 @@
                                        phpgwapi_cache::session_set('rental', 
'contract_status', phpgw::get_var('contract_status'));
                                        phpgwapi_cache::session_set('rental', 
'contract_status_date', phpgw::get_var('date_status'));
                                        phpgwapi_cache::session_set('rental', 
'contract_type', phpgw::get_var('contract_type'));
-                                       $filters = array('contract_status' => 
phpgw::get_var('contract_status'), 'contract_type' => 
phpgw::get_var('contract_type'), 'status_date_hidden' => 
phpgw::get_var('date_status_hidden'));
+                                       $filters = array('contract_status' => 
phpgw::get_var('contract_status'), 'contract_type' => 
phpgw::get_var('contract_type'));
+                                       $filters['status_date']                 
= phpgwapi_datetime::date_to_timestamp(phpgw::get_var('date_status'));
+                                       $filters['start_date_report']   = 
phpgwapi_datetime::date_to_timestamp(phpgw::get_var('start_date_report'));
+                                       $filters['end_date_report']             
= phpgwapi_datetime::date_to_timestamp(phpgw::get_var('end_date_report'));
+//                                     _debug_array($filters);
                        }
                        if($type != 'get_contract_warnings'){
                                $result_objects = 
rental_socontract::get_instance()->get($start_index, $num_of_objects, 
$sort_field, $sort_ascending, $search_for, $search_type, $filters);
@@ -336,6 +343,9 @@
                 */
                public function index()
                {
+//                     phpgw::import_class('phpgwapi.jquery');
+//                     phpgwapi_jquery::load_widget('core');
+//                     self::add_javascript('rental', 'rental', 
'contract.index.js');
 
                        $search_for = phpgw::get_var('search_for');
                        if($search_for)
@@ -450,6 +460,10 @@
                        $contract_id = (int)phpgw::get_var('id');
                        $location_id = (int)phpgw::get_var('location_id');
                        $update_price_items = false;
+
+                       phpgw::import_class('phpgwapi.jquery');
+                       phpgwapi_jquery::load_widget('core');
+                       self::add_javascript('rental', 'rental', 
'contract.edit.js');
                        
                        $message = null;
                        $error = null;
@@ -497,8 +511,8 @@
                                        }
                                }
                                
-                               $date_start =  
strtotime(phpgw::get_var('date_start_hidden'));
-                               $date_end =  
strtotime(phpgw::get_var('date_end_hidden'));
+                               $date_start =  
phpgwapi_datetime::date_to_timestamp(phpgw::get_var('date_start'));
+                               $date_end =  
phpgwapi_datetime::date_to_timestamp(phpgw::get_var('date_end'));
                                
                                if(isset($contract)){ 
                                        $contract->set_contract_date(new 
rental_contract_date($date_start, $date_end));
@@ -512,7 +526,8 @@
                                                
$contract->set_location_id($location_id); // only present when new contract
                                        }
                                        
$contract->set_term_id(phpgw::get_var('billing_term'));
-                                       
$contract->set_billing_start_date(strtotime(phpgw::get_var('billing_start_date_hidden')));
+                                       
$contract->set_billing_start_date(phpgwapi_datetime::date_to_timestamp(phpgw::get_var('billing_start_date')));
+                                       
$contract->set_billing_end_date(phpgwapi_datetime::date_to_timestamp(phpgw::get_var('billing_end_date')));
                                        
$contract->set_service_id(phpgw::get_var('service_id'));
                                        
$contract->set_responsibility_id(phpgw::get_var('responsibility_id'));
                                        
$contract->set_reference(phpgw::get_var('reference'));
@@ -539,7 +554,7 @@
                                        //}
                                        
                                        
$contract->set_project_id(phpgw::get_var('project_id'));
-                                       
$contract->set_due_date(strtotime(phpgw::get_var('due_date_hidden')));
+                                       
$contract->set_due_date(phpgwapi_datetime::date_to_timestamp(phpgw::get_var('due_date')));
                                        
$contract->set_contract_type_id(phpgw::get_var('contract_type'));
                                        $old_rented_area = 
$contract->get_rented_area();
                                        $new_rented_area = 
phpgw::get_var('rented_area');
@@ -618,10 +633,10 @@
                                {
                                        $account_id = 
phpgw::get_var('notification_target');
                                        $location_id = 
phpgw::get_var('notification_location');
-                                       $date = 
phpgw::get_var('date_notification_hidden');
+                                       $date = 
phpgw::get_var('date_notification');
                                        if($date)
                                        {
-                                               $date = strtotime($date);
+                                               $date = 
phpgwapi_datetime::date_to_timestamp($date);
                                        }
                                        $notification = new 
rental_notification(-1, $account_id, $location_id, $contract_id, $date, 
phpgw::get_var('notification_message'), 
phpgw::get_var('notification_recurrence'));
                                        if 
(rental_sonotification::get_instance()->store($notification))
@@ -714,6 +729,7 @@
                                $contract->set_contract_date(null);
                                $contract->set_due_date(null);
                                $contract->set_billing_start_date(null);
+                               $contract->set_billing_end_date(null);
                                if($so_contract->store($contract))
                                {
                                        // copy the contract

Modified: trunk/rental/inc/model/class.contract.inc.php
===================================================================
--- trunk/rental/inc/model/class.contract.inc.php       2014-09-07 16:36:02 UTC 
(rev 12077)
+++ trunk/rental/inc/model/class.contract.inc.php       2014-09-07 16:40:11 UTC 
(rev 12078)
@@ -42,6 +42,7 @@
                protected $parties;
                protected $contract_date;
                protected $billing_start_date;
+               protected $billing_end_date;
                protected $location_id;
                protected $term_id;
                protected $term_id_title;
@@ -210,6 +211,31 @@
                        return '';
                }
 
+               public function set_billing_end_date($date)
+               {
+                       $this->billing_end_date = $date;
+               }
+
+               /**
+                * Returns date of when the last invoice should be produced for 
the
+                * contract.
+                * @return string with UNIX time.
+                */
+               public function get_billing_end_date()
+               {
+                       if(isset($this->billing_end_date))
+                       {
+                               return $this->billing_end_date;
+                       }
+
+                       if(isset($this->contract_date))
+                       {
+                               return $this->contract_date->get_end_date();
+                       }
+
+                       return '';
+               }
+
                public function set_location_id($location_id)
                {
                        $this->field_of_responsibility_id = (int) $location_id;
@@ -1210,6 +1236,16 @@
                                        }
                                }
 
+                               // If set, the billing date must be between the 
contract's start date and end date
+                               $billing_end = $this->get_billing_end_date();
+                               if(isset($billing_end) && 
is_numeric($billing_end) && $billing_end > 0)
+                               {
+                                       if($billing_end < $start_date || 
(isset($end_date) && $billing_end > $end_date))
+                                       {
+                                               
$this->set_consistency_warning(lang('warning_billing_end_date_between'));
+                                       }
+                               }
+
                                // If set, the due date must be between the 
contract's start date and end date
                                $due_date = $this->get_due_date();
                                if(isset($due_date) && is_numeric($due_date) && 
$due_date > 0)

Copied: trunk/rental/js/rental/contract.edit.js (from rev 12073, 
trunk/property/js/yahoo/tts.view.js)
===================================================================
--- trunk/rental/js/rental/contract.edit.js                             (rev 0)
+++ trunk/rental/js/rental/contract.edit.js     2014-09-07 16:40:11 UTC (rev 
12078)
@@ -0,0 +1,24 @@
+$(document).ready(function(){
+       $("#date_start").change(function(){
+
+               var date_start = $("#date_start").val();
+               var billing_start = $("#billing_start_date").val();
+               if(!billing_start)
+               {
+                       $("#billing_start_date").val(date_start);
+               }
+
+       });
+
+       $("#date_end").change(function(){
+
+               var date_end = $("#date_end").val();
+               var billing_end_date = $("#billing_end_date").val();
+               if(!billing_end_date)
+               {
+                       $("#billing_end_date").val(date_end);
+               }
+
+       });
+
+});
\ No newline at end of file

Modified: trunk/rental/setup/phpgw_no.lang
===================================================================
--- trunk/rental/setup/phpgw_no.lang    2014-09-07 16:36:02 UTC (rev 12077)
+++ trunk/rental/setup/phpgw_no.lang    2014-09-07 16:40:11 UTC (rev 12078)
@@ -65,6 +65,7 @@
 billing_external       rental  no      Ekstern
 billing_internal       rental  no      Intern
 billing_start  rental  no      Fakturastart
+billing_end    rental  no      Fakturastopp
 billing_term   rental  no      Termin
 billing_terms  rental  no      Terminer
 billing_unit   rental  no      Ansvar-/tjenestested    
@@ -587,6 +588,7 @@
 user_not_in_fellesdata rental  no      Personen finnes ikke i Fellesdata.
 user_found_in_PE       rental  no      Personen er bruker av dette systemet.
 warning_billing_date_between   rental  no      Fakturastart må være innenfor 
kontraktens datoer!
+warning_billing_end_date_between       rental  no      Fakturastopp må være 
innenfor kontraktens datoer!
 warning_due_date_between       rental  no      Opsjonsfrist må være innenfor 
kontraktens datoer!
 warning_lacking_start_date     rental  no      Kontrakten mangler start-dato!
 warning_price_item_date_between        rental  no      Priselementets datoer 
må være innenfor kontraktens datoer!
@@ -596,4 +598,4 @@
 yes    rental  no      Ja
 your_notifications     rental  no      Dine varsler
 Download Excel export  rental  no      Last ned eksportfil i Excel-format
-free_of_charge rental  no      Vederlagsfritt
\ No newline at end of file
+free_of_charge rental  no      Vederlagsfritt

Modified: trunk/rental/setup/setup.inc.php
===================================================================
--- trunk/rental/setup/setup.inc.php    2014-09-07 16:36:02 UTC (rev 12077)
+++ trunk/rental/setup/setup.inc.php    2014-09-07 16:40:11 UTC (rev 12078)
@@ -1,6 +1,6 @@
 <?php
        $setup_info['rental']['name'] = 'rental';               // Module 
identifier
-       $setup_info['rental']['version'] = '0.1.0.18';  // Current module 
version
+       $setup_info['rental']['version'] = '0.1.0.19';  // Current module 
version
        $setup_info['rental']['app_order'] = 51;                // (?)
        $setup_info['rental']['tables'] = array(
                'rental_party',                                         // All 
contract participants, tenants etc.

Modified: trunk/rental/setup/tables_current.inc.php
===================================================================
--- trunk/rental/setup/tables_current.inc.php   2014-09-07 16:36:02 UTC (rev 
12077)
+++ trunk/rental/setup/tables_current.inc.php   2014-09-07 16:40:11 UTC (rev 
12078)
@@ -110,7 +110,8 @@
                                'id' =>                                 
array('type' => 'int', 'precision' => '4', 'nullable' => false),
                                'date_start' =>                 array('type' => 
'int', 'precision' => '8', 'nullable' => true),
                                'date_end' =>                   array('type' => 
'int', 'precision' => '8', 'nullable' => true),
-                               'billing_start' =>              array('type' => 
'int', 'precision' => '8', 'nullable' => true),                                 
        
+                               'billing_start' =>              array('type' => 
'int', 'precision' => '8', 'nullable' => true),
+                               'billing_end' =>                array('type' => 
'int', 'precision' => '8', 'nullable' => true),
                                'location_id' =>                array('type' => 
'int', 'precision' => '4', 'nullable' => false), // Contract type
                                'term_id' =>                    array('type' => 
'int', 'precision' => '4', 'nullable' => true),
                                'security_type' =>              array('type' => 
'int', 'precision' => '4', 'nullable' => true),

Modified: trunk/rental/setup/tables_update.inc.php
===================================================================
--- trunk/rental/setup/tables_update.inc.php    2014-09-07 16:36:02 UTC (rev 
12077)
+++ trunk/rental/setup/tables_update.inc.php    2014-09-07 16:40:11 UTC (rev 
12078)
@@ -341,3 +341,16 @@
                return $GLOBALS['setup_info']['rental']['currentver'];
        }
 
+       $test[] = '0.1.0.18';
+       function rental_upgrade0_1_0_18()
+       {
+
+               
$GLOBALS['phpgw_setup']->oProc->AddColumn('rental_contract','billing_end',array(
+                       'type' => 'int',
+                       'precision' => 8,
+                       'nullable' => 'True'
+               ));
+
+               $GLOBALS['setup_info']['rental']['currentver'] = '0.1.0.19';
+               return $GLOBALS['setup_info']['rental']['currentver'];
+       }

Modified: trunk/rental/templates/base/contract.php
===================================================================
--- trunk/rental/templates/base/contract.php    2014-09-07 16:36:02 UTC (rev 
12077)
+++ trunk/rental/templates/base/contract.php    2014-09-07 16:40:11 UTC (rev 
12078)
@@ -369,12 +369,14 @@
                                        </dt>
                                        <dd>
                                                <?php
-                                                       $start_date = 
$contract->get_contract_date() && 
$contract->get_contract_date()->has_start_date() ? 
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'], 
$contract->get_contract_date()->get_start_date()) : '-';
-                                                       $start_date_yui = 
$contract->get_contract_date() && 
$contract->get_contract_date()->has_start_date() ? date('Y-m-d', 
$contract->get_contract_date()->get_start_date()) : '';
-                                                       $start_date_cal = 
$GLOBALS['phpgw']->yuical->add_listener('date_start', $start_date);?>
-                                               <?php if ($editable) {
-                                                               echo 
$start_date_cal;
-                                                       } else {
+                                                       $start_date = 
$contract->get_contract_date() && 
$contract->get_contract_date()->has_start_date() ? 
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'], 
$contract->get_contract_date()->get_start_date()) : '';
+                                                       $start_date_yui = 
$contract->get_contract_date() && 
$contract->get_contract_date()->has_start_date() ? 
$GLOBALS['phpgw']->common->show_date($contract->get_contract_date()->get_start_date())
 : '';
+                                                       if ($editable)
+                                                       {
+                                                               echo 
$GLOBALS['phpgw']->jqcal->add_listener('date_start', 'date', $start_date);
+                                                       }
+                                                       else
+                                                       {
                                                                echo 
$start_date;
                                                        }
                                                ?>
@@ -385,15 +387,17 @@
                                        </dt>
                                        <dd>
                                                <?php
-                                                       $end_date = 
$contract->get_contract_date() && 
$contract->get_contract_date()->has_end_date() ? 
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'], 
$contract->get_contract_date()->get_end_date()) : '-';
-                                                       $end_date_yui = 
$contract->get_contract_date() && 
$contract->get_contract_date()->has_end_date() ? date('Y-m-d', 
$contract->get_contract_date()->get_end_date()) : '';
-                                                       $end_date_cal =  
$GLOBALS['phpgw']->yuical->add_listener('date_end', $end_date);
-                                               ?>
-                                               <?php if ($editable) {
-                                                               echo 
$end_date_cal;
-                                                       } else {
+                                                       $end_date = 
$contract->get_contract_date() && 
$contract->get_contract_date()->has_end_date() ? 
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'], 
$contract->get_contract_date()->get_end_date()) : '';
+                                                       $end_date_yui = 
$contract->get_contract_date() && 
$contract->get_contract_date()->has_end_date() ? 
$GLOBALS['phpgw']->common->show_date($contract->get_contract_date()->get_end_date())
 : '';
+                                                       if ($editable)
+                                                       {
+                                                               echo 
$GLOBALS['phpgw']->jqcal->add_listener('date_end', 'date', $end_date);
+                                                       }
+                                                       else
+                                                       {
                                                                echo $end_date;
-                                                }?>
+                                                       }
+                                                ?>
                                                <br/>
                                        </dd>
                                        <dt>
@@ -401,11 +405,15 @@
                                        </dt>
                                        <dd>
                                                <?php
-                                                       $due_date = 
$contract->get_due_date() ? 
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'], 
$contract->get_due_date()) : '-';
-                                                       $due_date_yui = 
$contract->get_due_date() ? date('Y-m-d', $contract->get_due_date()) : '';
-                                                       if ($editable) {
-                                                               echo 
$GLOBALS['phpgw']->yuical->add_listener('due_date', $due_date);
-                                                       } else {
+                                                       $due_date = 
$contract->get_due_date() ? 
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'], 
$contract->get_due_date()) : '';
+                                                       $due_date_yui = 
$contract->get_due_date() ? 
$GLOBALS['phpgw']->common->show_date($contract->get_due_date()) : '';
+                                                       if ($editable)
+                                                       {
+                                                               echo 
$GLOBALS['phpgw']->jqcal->add_listener('due_date', 'date', $due_date);
+                                       //                      echo 
$GLOBALS['phpgw']->yuical->add_listener('due_date', $due_date);
+                                                       }
+                                                       else
+                                                       {
                                                                echo $due_date;
                                                        }
                                                ?>
@@ -459,16 +467,38 @@
                                        </dt>
                                        <dd>
                                                <?php
-                                                       $billing_start_date = 
$contract->get_billing_start_date() ? 
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'], 
$contract->get_billing_start_date()) : '-';
-                                                       $billing_start_date_yui 
= $contract->get_billing_start_date() ? date('Y-m-d', 
$contract->get_billing_start_date()) : '';
-                                                       if ($editable) {
-                                                               echo 
$GLOBALS['phpgw']->yuical->add_listener('billing_start_date', 
$billing_start_date);
-                                                       } else {
+                                                       $billing_start_date = 
$contract->get_billing_start_date() ? 
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'], 
$contract->get_billing_start_date()) : '';
+                                                       $billing_start_date_yui 
= $contract->get_billing_start_date() ? 
$GLOBALS['phpgw']->common->show_date($contract->get_billing_start_date()) : '';
+                                                       if ($editable)
+                                                       {
+//                                                             echo 
$GLOBALS['phpgw']->yuical->add_listener('billing_start_date', 
$billing_start_date);
+                                                               echo 
$GLOBALS['phpgw']->jqcal->add_listener('billing_start_date', 'date', 
$billing_start_date);
+                                                       }
+                                                       else
+                                                       {
                                                                echo 
$billing_start_date;
                                                        }
                                                ?>
                                        </dd>
                                        <dt>
+                                               <label 
for="billing_end_date"><?php echo lang('billing_end') ?></label>
+                                       </dt>
+                                       <dd>
+                                               <?php
+                                                       $billing_end_date = 
$contract->get_billing_end_date() ? 
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'], 
$contract->get_billing_end_date()) : '';
+                                                       $billing_end_date_yui = 
$contract->get_billing_end_date() ? 
$GLOBALS['phpgw']->common->show_date($contract->get_billing_end_date()) : '';
+                                                       if ($editable)
+                                                       {
+//                                                             echo 
$GLOBALS['phpgw']->yuical->add_listener('billing_end_date', $billing_end_date);
+                                                               echo 
$GLOBALS['phpgw']->jqcal->add_listener('billing_end_date', 'date', 
$billing_end_date);
+                                                       }
+                                                       else
+                                                       {
+                                                               echo 
$billing_end_date;
+                                                       }
+                                               ?>
+                                       </dd>
+                                       <dt>
                                                <label for="reference"><?php 
echo lang('reference') ?></label>
                                        </dt>
                                        <dd>
@@ -858,11 +888,14 @@
                        ?>
                                <form 
action="?menuaction=rental.uicontract.edit&id=<?php echo $contract->get_id() 
?>" method="post">
                                        <?php
-                                       $notification_date = date('Y-m-d');
-                                       if(isset($notification))
+                                       if(isset($notification))//Never??
                                        {
-                                               $notification_date = 
date('Y-m-d',$notification->get_date());
+                                               $notification_date = 
$GLOBALS['phpgw']->common->show_date($notification->get_date());
                                        }
+                                       else
+                                       {
+                                               $notification_date = 
$GLOBALS['phpgw']->common->show_date(time());
+                                       }
                                        ?>
 
 
@@ -872,8 +905,11 @@
 
                                                                <label 
for="calendarNotificationDate"><?php echo lang('date') ?></label>
                                                                <!--<input 
type="text" name="date_notification" id="date_notification" size="10" 
value="<?php echo isset($notification) ? 
htmlentities($notification->get_date()) : '' ?>" /> -->
-                                                               <?php echo 
$GLOBALS['phpgw']->yuical->add_listener('date_notification', 
$notification_date); ?>
-                                                               <?php echo 
rental_uicommon::get_field_error($notification, 'date') ?>
+                                                               <?php 
+       //                                                              echo 
$GLOBALS['phpgw']->yuical->add_listener('date_notification', 
$notification_date);
+                                                                       echo 
$GLOBALS['phpgw']->jqcal->add_listener('date_notification', 'date', 
$notification_date);
+                                                                       echo 
rental_uicommon::get_field_error($notification, 'date')
+                                                               ?>
                                                                        <label 
for="notification_recurrence"><?php echo lang('recurrence') ?></label>
                                                                <select 
name="notification_recurrence" id="notification_recurrence">
                                                                        <option 
<?php echo isset($notification) && $notification->get_recurrence() == 
rental_notification::RECURRENCE_NEVER ? 'selected="selected"' : '' 
?>value="<?php echo rental_notification::RECURRENCE_NEVER ?>"><?php echo 
lang('never') ?></option>

Modified: trunk/rental/templates/base/contract_list_partial.php
===================================================================
--- trunk/rental/templates/base/contract_list_partial.php       2014-09-07 
16:36:02 UTC (rev 12077)
+++ trunk/rental/templates/base/contract_list_partial.php       2014-09-07 
16:40:11 UTC (rev 12078)
@@ -121,7 +121,7 @@
                
'index.php?menuaction=rental.uicontract.query&amp;phpgw_return_as=json<?php 
echo $url_add_on ?>&amp;editable=<?php echo $editable ? "true" : "false"; ?>',
                columnDefs,
                '<?php echo $list_id ?>_form',
-               ['<?php echo $list_id ?>_ctrl_toggle_contract_status','<?php 
echo $list_id ?>_ctrl_toggle_contract_type','date_status'],
+               ['<?php echo $list_id ?>_ctrl_toggle_contract_status','<?php 
echo $list_id ?>_ctrl_toggle_contract_type','date_status_hidden'],
                '<?php echo $list_id ?>_container',
                '<?php echo $list_id ?>_paginator',
                '<?php echo $list_id ?>',
@@ -150,7 +150,7 @@
                var startDate = 
document.getElementById('start_date_report').value;
                var endDate = document.getElementById('end_date_report').value;
         
-        var dl = window.open('index.php?menuaction=rental.uicontract.download'+
+        var url = 'index.php?menuaction=rental.uicontract.download'+
             '&amp;type='+ctype+
             '&amp;contract_type='+typeoption+
             '&amp;contract_status='+statusoption+
@@ -158,9 +158,12 @@
             '&amp;query='+query+
             '&amp;search_option='+sOption+
             //'&amp;results=100'+
-            '&amp;date_start='+startDate+
-            '&amp;date_end='+endDate+
-            '&amp;export=true');
+            '&amp;start_date_report='+startDate+
+            '&amp;end_date_report='+endDate+
+            '&amp;export=true';
+  //          alert(url);
+
+        var dl = window.open(url);
     }
 
     function contract_export_price_items(ctype) {
@@ -260,9 +263,9 @@
                        <a href="javascript:contract_export('<?php echo 
$list_id ?>');"><img src="<?php echo RENTAL_TEMPLATE_PATH 
?>images/16x16/mimetypes/x-office-spreadsheet.png" alt="<?php echo 
lang('export_contracts') ?>" title="<?php echo lang('export_contracts') ?>" 
/></a>
                        <a href="javascript:contract_export_price_items('<?php 
echo $list_id ?>');"><img src="<?php echo RENTAL_TEMPLATE_PATH 
?>images/16x16/mimetypes/x-office-spreadsheet.png" alt="<?php echo 
lang('export_contract_price_items') ?>" title="<?php echo 
lang('export_contract_price_items') ?>" /></a>
                        <label class="toolbar_element_label" 
for="start_date_report" id="label_start_date_report"><?php echo 
lang('date_start') ?></label>
-                       <?php echo 
$GLOBALS['phpgw']->yuical->add_listener('start_date_report', 
$notification_date); ?>
+                       <?php echo 
$GLOBALS['phpgw']->yuical->add_listener('start_date_report',  
$notification_date); ?>
                        <label class="toolbar_element_label" 
for="end_date_report" id="label_end_date_report"><?php echo lang('date_end') 
?></label>
-                       <?php echo 
$GLOBALS['phpgw']->yuical->add_listener('end_date_report', $notification_date); 
?>
+                       <?php echo 
$GLOBALS['phpgw']->yuical->add_listener('end_date_report',  
$notification_date); ?>
                </div>
        </fieldset>
 </form>
@@ -290,7 +293,7 @@
        alert("tester1");
     function date_event() {
         alert("i date_event");
-        var hidden_date = document.getElementById('date_status_hidden');
+        var hidden_date = document.getElementById('date_status');
         if(hidden_date != undefined) {
             var date = datestatus.value.split("/");
             hidden_date.value = date[2]+"-"+date[1]+"-"+date[0];




reply via email to

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