Plugin Directory

Changeset 2327478


Ignore:
Timestamp:
06/19/2020 01:52:20 PM (6 years ago)
Author:
chuhpl
Message:

Added contact info to the lend array for the check in page.
Added contact info display on the check in page to show any contact data if it exists.
Fixed the check in page to work in PHP 5 (array_column wasn't working with an array of post objects) so it doesn't always show as empty.

Location:
lendingq
Files:
23 added
4 edited

Legend:

Unmodified
Added
Removed
  • lendingq/trunk/lendingq.php

    r2325180 r2327478  
    44Plugin URI: https://wordpress.org/plugins/lendingq/
    55Description: A simple system to manage the lending of items (like hotspots) with an integrated waiting list.
    6 Version: 0.96
     6Version: 0.96.1
    77License: GPLv2 or later
    88Text Domain: lendingq
     
    16421642            $temp_it = get_the_terms( $post->ID, 'lendingq_item_type' );
    16431643            $temp_loc = get_the_terms( $post->ID, 'lendingq_location' );
    1644             $lend['card']           = $post_meta['card'][0];
     1644           
     1645           
    16451646            $lend['contact']        = $contact;
    16461647            $lend['item_type']      = current($temp_it)->slug;
    16471648            $lend['location']       = current($temp_loc)->slug;
    1648             $lend['name']           = $post_meta['name'][0];
    1649             $lend['notes']          = $post_meta['notes'][0];
    1650             $lend['staff']          = $post_meta['staff'][0];
    1651             $lend['waiting_date']   = $post_meta['waiting_date'][0];
     1649           
     1650            foreach( ['card', 'name', 'notes', 'staff', 'waiting_date', 'contact_date', 'contact_staff', 'contact_notes' ] as $key )
     1651            {
     1652                $lend[$key] = ( !isset( $post_meta[$key][0] ) ) ? null : $post_meta[$key][0];
     1653            }
     1654           
    16521655            require( LENDINGQ_PATH . '/template_check_out_form.php' );
    16531656        } // END function lendingq_check_out()
  • lendingq/trunk/readme.txt

    r2325181 r2327478  
    55Tested up to: 5.4
    66Stable tag: trunk
    7 Requires PHP: 5.5
     7Requires PHP: 5.6
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    3333
    3434== Changelog ==
     35= 0.96.1 =
     36* Added contact info to the lend array for the check in page.
     37* Added contact info display on the check in page to show any contact data if it exists.
     38* Fixed the check in page to work in PHP 5 (array_column wasn't working with an array of post objects) so it doesn't always show as empty.
     39
    3540= 0.96 =
    3641* Added the ability to filter the Check Out page by location.
  • lendingq/trunk/template_check_in_list.php

    r2325180 r2327478  
    33
    44if( !empty( $post_list ) ) {
    5     foreach( array_column( $post_list, 'post_status', 'ID' ) as $key => $val ) {
    6         if( $val == 'checked_out' ) $loaned_count++;
     5    foreach( $post_list as $key => $val ) {
     6        if( $val->post_status == 'checked_out' ) $loaned_count++;
    77    }
    88}
  • lendingq/trunk/template_check_out_form.php

    r2325180 r2327478  
    33    <?php _e( 'Please double check this information before selecting an item to checkout from the drop down below.', 'lendingq'); ?>
    44    <form action="<?php echo admin_url( 'admin-post.php' ) ?>">
    5     <table class="form-table" role="presentation">
    6         <tbody>
    7             <tr>
    8                 <th scope="row"><?php _e( 'Name', 'lendingq'); ?></th>
    9                 <td><?php echo $lend['name']; ?></td>
    10             </tr>
    11             <tr>
    12                 <th scope="row"><?php _e( 'Card', 'lendingq'); ?></th>
    13                 <td><?php echo $lend['card']; ?></td>
    14             </tr>
    15             <tr>
    16                 <th scope="row"><?php _e( 'Contact', 'lendingq'); ?></th>
    17                 <td><?php echo $lend['contact']; ?></td>
    18             </tr>
    19             <tr>
    20                 <th scope="row"><?php _e( 'Helped by', 'lendingq'); ?></th>
    21                 <td><?php echo $lend['staff']; ?></td>
    22             </tr>
    23             <tr>
    24                 <th scope="row"><?php _e( 'Item Type', 'lendingq'); ?></th>
    25                 <td><?php echo $item_types[$lend['item_type']]; ?></td>
    26             </tr>
    27             <tr>
    28                 <th scope="row"><?php _e( 'Location', 'lendingq'); ?></th>
    29                 <td><?php echo $locations[$lend['location']]; ?></td>
    30             </tr>
    31             <tr>
    32                 <th scope="row"><?php _e( 'Notes', 'lendingq'); ?></th>
    33                 <td><?php echo $lend['notes']; ?></td>
    34             </tr>
    35             <tr>
    36                 <th scope="row"><?php _e( 'Item to Lend', 'lendingq'); ?></th>
    37                 <td><?php
    38                     # check there is stock
    39                     $args = [
    40                                     'numberposts' => -1,
    41                                     'post_type'=> 'lendingq_stock',
    42                                     'post_status'    => 'item_available'
    43                     ];
    44                     $item_list = get_posts( $args );
    45                     $available = [];
    46                     foreach( $item_list as $key => $post ) {
    47                         $temp = [];
    48                         $location_raw       = get_the_terms( $post->ID, 'lendingq_location' );
    49                         $location           = $location_raw[0]->slug;
    50                         $item_type_raw      = get_the_terms( $post->ID, 'lendingq_item_type' );
    51                         $item_type          = $item_type_raw[0]->slug;
    52                         if( $location == $lend['location'] and $item_type == $lend['item_type'] ) {
    53                             $available[$post->ID] = $post;   
     5        <table class="form-table" role="presentation">
     6            <tbody>
     7                <tr>
     8                    <th scope="row"><?php _e( 'Name', 'lendingq'); ?></th>
     9                    <td><?php echo $lend['name']; ?></td>
     10                </tr>
     11                <tr>
     12                    <th scope="row"><?php _e( 'Card', 'lendingq'); ?></th>
     13                    <td><?php echo $lend['card']; ?></td>
     14                </tr>
     15                <tr>
     16                    <th scope="row"><?php _e( 'Contact', 'lendingq'); ?></th>
     17                    <td><?php echo $lend['contact']; ?></td>
     18                </tr>
     19                <tr>
     20                    <th scope="row"><?php _e( 'Helped by', 'lendingq'); ?></th>
     21                    <td><?php echo $lend['staff']; ?></td>
     22                </tr>
     23                <tr>
     24                    <th scope="row"><?php _e( 'Item Type', 'lendingq'); ?></th>
     25                    <td><?php echo $item_types[$lend['item_type']]; ?></td>
     26                </tr>
     27                <tr>
     28                    <th scope="row"><?php _e( 'Location', 'lendingq'); ?></th>
     29                    <td><?php echo $locations[$lend['location']]; ?></td>
     30                </tr>
     31                <tr>
     32                    <th scope="row"><?php _e( 'Notes', 'lendingq'); ?></th>
     33                    <td><?php echo $lend['notes']; ?></td>
     34                </tr>
     35            </tbody>
     36        </table>
     37        <?php
     38        if( !empty( $lend['contact_date'] ) ) {
     39            ?>
     40        <hr style="border: 1px solid grey;">
     41        <table class="form-table" role="presentation">
     42            <tbody>     
     43                <tr>
     44                    <th scope="row"><?php _e( 'Contacted by', 'lendingq'); ?></th>
     45                    <td><?php echo $lend['contact_staff']; ?></td>
     46                </tr>
     47                <tr>
     48                    <th scope="row"><?php _e( 'Contact date', 'lendingq'); ?></th>
     49                    <td><?php echo date_i18n( get_option( 'date_format' ), $lend['contact_date'] ) . ' - ' . date_i18n( get_option( 'time_format' ), $lend['contact_date'] ); ?></td>
     50                </tr>
     51                <tr>
     52                    <th scope="row"><?php _e( 'Contact Notes', 'lendingq'); ?></th>
     53                    <td><?php echo nl2br( $lend['contact_notes'] ); ?></td>
     54                </tr>
     55            </tbody>
     56        </table>
     57        <?php
     58        }
     59        ?>
     60        <hr style="border: 1px solid grey;">
     61        <table class="form-table" role="presentation">
     62            <tbody>     
     63                <tr>
     64                    <th scope="row"><?php _e( 'Item to Lend', 'lendingq'); ?></th>
     65                    <td><?php
     66                        # check there is stock
     67                        $args = [
     68                                        'numberposts' => -1,
     69                                        'post_type'=> 'lendingq_stock',
     70                                        'post_status'    => 'item_available'
     71                        ];
     72                        $item_list = get_posts( $args );
     73                        $available = [];
     74                        foreach( $item_list as $key => $post ) {
     75                            $temp = [];
     76                            $location_raw       = get_the_terms( $post->ID, 'lendingq_location' );
     77                            $location           = $location_raw[0]->slug;
     78                            $item_type_raw      = get_the_terms( $post->ID, 'lendingq_item_type' );
     79                            $item_type          = $item_type_raw[0]->slug;
     80                            if( $location == $lend['location'] and $item_type == $lend['item_type'] ) {
     81                                $available[$post->ID] = $post;   
     82                            }
    5483                        }
    55                     }
    56                     if( count( $available ) == 0 ) {
    57                         echo '<strong>'. __( 'There is currently no stock available for this lending.', 'lendingq' ).'</strong>';
    58                     } else {
    59                         echo '<select name="lending_item" id="lending_item">';
    60                         foreach( $available as $key => $val ) {
    61                             echo "<option value=\"{$key}\">{$val->post_title}</option>";
     84                        if( count( $available ) == 0 ) {
     85                            echo '<strong>'. __( 'There is currently no stock available for this lending.', 'lendingq' ).'</strong>';
     86                        } else {
     87                            echo '<select name="lending_item" id="lending_item">';
     88                            foreach( $available as $key => $val ) {
     89                                echo "<option value=\"{$key}\">{$val->post_title}</option>";
     90                            }
     91                            echo '</select>';
    6292                        }
    63                         echo '</select>';
    64                     }
    65                     ?></td>
    66             </tr>
    67         </tbody>
    68     </table>
     93                        ?></td>
     94                </tr>
     95            </tbody>
     96        </table>
    6997        <input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>">
    7098        <input type="hidden" name="action" id="action" value="lendingq_checkout">
Note: See TracChangeset for help on using the changeset viewer.