fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [12601] rental: configurable valid contract types


From: Sigurd Nes
Subject: [Fmsystem-commits] [12601] rental: configurable valid contract types
Date: Thu, 15 Jan 2015 09:11:52 +0000

Revision: 12601
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=12601
Author:   sigurdne
Date:     2015-01-15 09:11:50 +0000 (Thu, 15 Jan 2015)
Log Message:
-----------
rental: configurable valid contract types

Modified Paths:
--------------
    trunk/rental/inc/hook_config.inc.php
    trunk/rental/templates/base/config.tpl
    trunk/rental/templates/base/contract_list.php

Modified: trunk/rental/inc/hook_config.inc.php
===================================================================
--- trunk/rental/inc/hook_config.inc.php        2015-01-14 23:55:16 UTC (rev 
12600)
+++ trunk/rental/inc/hook_config.inc.php        2015-01-15 09:11:50 UTC (rev 
12601)
@@ -184,3 +184,31 @@
                }
                return $out;
        }
+
+       /**
+       * Get HTML checkbox with contract_types that are valid for new contracts
+       *
+       * @param $config
+       * @return string HTML checkboxes to be placed in a table
+       */
+       function contract_types($config)
+       {
+               phpgw::import_class('rental.socontract');
+               $types = 
rental_socontract::get_instance()->get_fields_of_responsibility();
+               $types_assigned = isset($config['contract_types']) ? 
$config['contract_types'] : array();
+               $out = '';
+               foreach ( $types as $type => $_label)
+               {
+                       $label = 
$GLOBALS['phpgw']->translation->translate($_label, array(), false, 'rental');
+                       $checked = '';
+                       if ( in_array($type, $types_assigned))
+                       {
+                               $checked = ' checked';
+                       }
+
+                       $out .=  <<<HTML
+                       <tr><td><input type="checkbox" 
name="newsettings[contract_types][]" value="{$type}" 
{$checked}><label>{$label}</label></td></tr>
+HTML;
+               }
+               return $out;
+       }

Modified: trunk/rental/templates/base/config.tpl
===================================================================
--- trunk/rental/templates/base/config.tpl      2015-01-14 23:55:16 UTC (rev 
12600)
+++ trunk/rental/templates/base/config.tpl      2015-01-15 09:11:50 UTC (rev 
12601)
@@ -159,6 +159,16 @@
                        <td>{lang_path_to_wkhtmltopdf}:</td>
                        <td><input name="newsettings[path_to_wkhtmltopdf]" 
value="{value_path_to_wkhtmltopdf}"></td>
                </tr>
+               <tr class="row_off">
+                       <td valign = 'top'>{lang_contract_types}:</td>
+                       <td>
+                               <!--to be able to blank the setting - need an 
empty value-->
+                               <input type = 'hidden' 
name="newsettings[contract_types][]" value="">
+                               <table>
+                                       {hook_contract_types}
+                               </table>
+                       </td>
+               </tr>
 
                <!-- END body -->
                <!-- BEGIN footer -->

Modified: trunk/rental/templates/base/contract_list.php
===================================================================
--- trunk/rental/templates/base/contract_list.php       2015-01-14 23:55:16 UTC 
(rev 12600)
+++ trunk/rental/templates/base/contract_list.php       2015-01-15 09:11:50 UTC 
(rev 12601)
@@ -26,10 +26,27 @@
        <h3><?php echo lang('t_new_contract') ?></h3>
        <select name="location_id" id="location_id">
                <?php
+                       $config = CreateObject('phpgwapi.config','rental');
+                       $config->read();
+                       $valid_contract_types = array();
+                       if(isset($config->config_data['contract_types']) && 
is_array($config->config_data['contract_types']))
+                       {
+                               foreach ($config->config_data['contract_types'] 
as $_key => $_value)
+                               {
+                                       if($_value)
+                                       {
+                                               $valid_contract_types[] = 
$_value;
+                                       }
+                               }
+                       }
+
                $types = 
rental_socontract::get_instance()->get_fields_of_responsibility();
                foreach($types as $id => $label)
                {
-
+                       if($valid_contract_types && 
!in_array($id,$valid_contract_types))
+                       {
+                               continue;
+                       }
                        $names = $this->locations->get_name($id);
                        if($names['appname'] == 
$GLOBALS['phpgw_info']['flags']['currentapp'])
                        {




reply via email to

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