Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
master
Go to file
 
 
Cannot retrieve contributors at this time
327 lines (270 sloc) 16.8 KB
<?php
/**
* The template for displaying Archive pages.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package uc-purchasing
* @author John Calande / UConn Webdev lab
*
*/
get_header(); ?>
<div id="page-archive">
<div class="row">
<div class="col-sm-12">
<section id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<header class="entry-header">
<h1 class="page-title">
<?php
$postType = get_post_type_object(get_post_type($post));
if ($postType) {
_e( get_the_title(), 'cs' );
}
?>
</h1>
</header><!-- .page-header -->
<div class="entry-content">
<?php
//
// Let's grab the URL query parameters -
//
$search_for = $_GET['search_contracts'];
$vc = $_GET['vc'];
//
// If the user hasn't selected column ordering,
// default to sorting by contract_name
//
$order_by_column = $_GET['order_by_column'];
if ( empty( $order_by_column ) ){
$order_by_column = 'contract_name';
}
if ( empty( $search_for ) ){
$search_for = '';
}
?>
<h3>Vendor Characteristic Reference</h3>
<!-- S E A R C H C O N T R A C T S F O R M -->
<form id="search_form" method="get" action="">
<!-- V E N D O R C H A R A C T E R I S T I C I M A G E I C O N S -->
<div>
<figure id="attachment_2017" style="width: 75px" class="alignleft"><img class="wp-image-2017" title="Code of Conduct Vendor" src="http://purchasing.uconn.edu/wp-content/uploads/sites/49/2015/06/CodeConduct_business_w_words_button.png" alt="Code of Conduct Vendor" width="75" height="75" /><figcaption class="wp-caption-text"><input type="checkbox" name="vc[]" value="CCV" <?php if(in_array('CCV',$vc)) echo 'checked'; ?> />CCV</figcaption></a></figure>
<figure id="attachment_2019" style="width: 75px" class="alignleft"><img class="wp-image-2019" title="Enhanced Code of Conduct Vendor" src="http://purchasing.uconn.edu/wp-content/uploads/sites/49/2015/06/CodeConduct_enhanced_business_w_words_button.png" alt="Enhanced Code of Conduct Vendor" width="75" height="75" /><figcaption class="wp-caption-text"><input type="checkbox" name="vc[]" value="CCV_PLUS" <?php if(in_array('CCV_PLUS',$vc)) echo 'checked'; ?> />CCV+</figcaption></a></figure>
<figure id="attachment_2021" style="width: 75px" class="alignleft"><img class="wp-image-2021" title="Connecticut Based Business" src="http://purchasing.uconn.edu/wp-content/uploads/sites/49/2015/06/CT_business_w_words_button.png" alt="Connecticut Based Business" width="75" height="75" /><figcaption class="wp-caption-text"><input type="checkbox" name="vc[]" value="CTB" <?php if(in_array('CTB',$vc)) echo 'checked'; ?> />CTB</figcaption></a></figure>
<figure id="attachment_2023" style="width: 75px" class="alignleft"><img class="wp-image-2023" title="Disabled Business" src="http://purchasing.uconn.edu/wp-content/uploads/sites/49/2015/06/disabled_business_w_words_button.png" alt="Disabled Based Business" width="75" height="75" /><figcaption class="wp-caption-text"><input type="checkbox" name="vc[]" value="DISBE" <?php if(in_array('DISBE',$vc)) echo 'checked'; ?> />DISBE</figcaption></a></figure>
<figure id="attachment_2015" style="width: 75px" class="alignleft"><img class="wp-image-2015" title="Minority Based Business" src="http://purchasing.uconn.edu/wp-content/uploads/sites/49/2015/06/minority_business_w_words_button.png" alt="Minority Business" width="75" height="75" /><figcaption class="wp-caption-text"><input type="checkbox" name="vc[]" value="MBE" <?php if(in_array('MBE',$vc)) echo 'checked'; ?> />MBE</figcaption></a></figure>
<figure id="attachment_2002" style="width: 75px" class="alignleft"><img class="wp-image-2002" title="Small Business" src="http://purchasing.uconn.edu/wp-content/uploads/sites/49/2015/06/small_business_w_words_button.png" alt="Small Business" width="75" height="75" /><figcaption class="wp-caption-text"><input type="checkbox" name="vc[]" value="SBE" <?php if(in_array('SBE',$vc)) echo 'checked'; ?> />SBE</figcaption></a></figure>
<figure id="attachment_2004" style="width: 75px" class="alignleft"><img class="wp-image-2004" title="Women Based Business" src="http://purchasing.uconn.edu/wp-content/uploads/sites/49/2015/06/women_business_w_words_button.png" alt="Women Based Business" width="75" height="75" /><figcaption class="wp-caption-text"><input type="checkbox" name="vc[]" value="WBE" <?php if(in_array('WBE',$vc)) echo 'checked'; ?> />WBE</figcaption></a></figure>
</div>
<div style="clear:both;"></div>
<div class="alignleft">
<input type="text" name="search_contracts" id="search_contracts" size="25" value="<?php echo $search_for ?>" />&nbsp;<input type="submit" value="<?php _e('Search'); ?>" /> <input type="button" value="<?php _e('View All'); ?>" class="clearsubmit" />
<input type="hidden" name="order_by_column" id="order_by_column" value="<?php echo $order_by_column ?>" />
</div>
</form>
<?php
$urlvc = '';
if(count($vc) > 0){
foreach($vc as $c){
$urlvc .= 'vc[]='.$c.'&';
}
}
?>
<table class="table table-striped">
<thead>
<tr style="background-color: #000e2f; color: #ffffff;"> <!-- LINK TO SORT BY COLUMN -->
<?php //Check Contract Type
$contract_type = get_post_meta( get_the_ID(), 'uc-purchasing', true );
if($contract_type == 'Construction-Awards' || $contract_type == 'Professional-Services-Awards')
{
?>
<td><strong><a href="?<?php echo $urlvc ?>&order_by_column=contract_name&search_contracts=<?php echo $search_for ?>" style="color: #ffffff;">Project Number</a></strong></td>
<td><strong><a href="?<?php echo $urlvc ?>&order_by_column=contract_number&search_contracts=<?php echo $search_for ?>" style="color: #ffffff;">Award Date</a></strong></td>
<td><strong><a href="?<?php echo $urlvc ?>&order_by_column=contract_expires&search_contracts=<?php echo $search_for ?>" style="color: #ffffff;">Project Description</a></strong></td>
<td><strong><a href="?<?php echo $urlvc ?>&order_by_column=contract_vendor_name&search_contracts=<?php echo $search_for ?>" style="color: #ffffff;">Firm Awarded</a></strong></td>
<td><strong><a href="?<?php echo $urlvc ?>&order_by_column=contract_contact_name&search_contracts=<?php echo $search_for ?>" style="color: #ffffff;">Contract Value</a></span></td>
<td><strong><a href="?<?php echo $urlvc ?>&order_by_column=contract_contact_phone&search_contracts=<?php echo $search_for ?>" style="color: #ffffff;">CPCA Contact</a></span></td>
<?php } else { ?>
<td><strong><a href="?<?php echo $urlvc ?>&order_by_column=contract_name&search_contracts=<?php echo $search_for ?>" style="color: #ffffff;">Contract Name</a></strong></td>
<td><strong><a href="?<?php echo $urlvc ?>&order_by_column=contract_number&search_contracts=<?php echo $search_for ?>" style="color: #ffffff;">Contract No.</a></strong></td>
<td><strong><a href="?<?php echo $urlvc ?>&order_by_column=contract_expires&search_contracts=<?php echo $search_for ?>" style="color: #ffffff;">Expires</a></strong></td>
<td><strong><a href="?<?php echo $urlvc ?>&order_by_column=contract_vendor_name&search_contracts=<?php echo $search_for ?>" style="color: #ffffff;">Vendor Name</a></strong></td>
<td><strong><a href="?<?php echo $urlvc ?>&order_by_column=contract_contact_name&search_contracts=<?php echo $search_for ?>" style="color: #ffffff;">Contact Name</a></span></td>
<td><strong><a href="?<?php echo $urlvc ?>&order_by_column=contract_contact_phone&search_contracts=<?php echo $search_for ?>" style="color: #ffffff;">Contact Phone</a></span></td>
<?php
};
?>
<td><strong><a href="?<?php echo $urlvc ?>&order_by_column=contract_vendor_characteristics&search_contracts=<?php echo $search_for ?>" style="color: #ffffff;">Vendor Characteristics</a></strong></td>
</tr>
</thead>
<tbody>
<?php
//
// we pass 'CCV_PLUS' on the URL ( "+" is reserved )
// so let's convert, as CCV+ is what's stored in the database -
//
$vc = str_replace('CCV_PLUS','CCV+',$vc);
//
// Are we selecting posts based on a click in a column header ($orderby)
// or are we selecting based on a click on one of the vendor_characteristic ($vc)
// icons? Or, are we searching?
// ('meta_value' - Note that a 'meta_key=keyname' must also be present in the query.)
// Note the double-quotes around $vc, so we find the exact match within the
// contract_vendor_characteristics field
//
$query_args = array(
'post_type' => 'uc_contract',
'posts_per_page' => -1,
'order' => 'ASC',
'exclude_empty_meta' => false, // alleged patch to include NULL field values
'exclude_empty' => false, // alleged patch to include NULL field values
'relation' => 'OR',
'_meta_or_title' => $search_for,
'meta_query' => array(
'exclude_empty_meta' => false,
'exclude_empty' => false,
'relation' => 'AND',
array(
'value' => $search_for,
'compare' => 'LIKE',
),
array(
'key' => 'contract_type',
'value' => get_post_meta( get_the_ID(), 'uc-purchasing', true ),
'compare' => 'LIKE',
)
),
);
if($order_by_column == 'contract_name'){
$query_args['orderby'] = 'title';
}
else {
$query_args['orderby'] = 'meta_value';
$query_args['meta_key'] = $order_by_column; //'contract_name', etc.
}
foreach($vc as $c){
$query_args['meta_query'][] = array(
//
// should be able to switch these to just $vc (without the quotes) and LIKE can become
// OR vc1 OR vc2 OR vc3... etc. (How would we do IN( CCV, MBE, SBE...)
//
'key' => 'contract_vendor_characteristics',
'value' => ( empty($vc) ? 'null' : ('"'.$c.'"') ),
'compare' => ( empty($vc) ? 'NOT EXISTS' : 'LIKE' ),
);
}
//
// run the query, and show our resulting post data
//
$my_query = new WP_Query($query_args);
while( $my_query->have_posts() ){
$my_query->the_post();
// FILE Attachment Link -
// We want to create a link using the Contract Number
//
// Note that we have 2 scenarios here...
// One is adding new contract files from the Dashboard.
// In this case, we get back an array (File type)
// When new contracts are created from the add_contract page
// we only get the URL.
// So here we check for an array -
//
$file_url = '';
$file_url = get_field('contract_file');
if( is_array($file_url)){
$file_url = $file_url['url'];
}
elseif( is_numeric($file_url)){
$file_url = wp_get_attachment_url($file_url);
}
?>
<!-- Contract ROWS -->
<tr>
<?php //Check Contract Type
if($contract_type == 'Construction-Awards' || $contract_type == 'Professional-Services-Awards')
{
?>
<td><strong><?php echo get_field('cpca_project_number')?></strong></td>
<td><strong><?php echo get_field('cpca_award_date')?></strong></td>
<td><?php echo get_field('cpca_award_description')?></td>
<td><strong><?php echo get_field('cpca_firm_awarded')?></strong></td>
<td><?php echo( get_field('cpca_contract_value') ) ?></td>
<td><a href="mailto:<?php echo get_field('cpca_contact_email')?>"><?php echo get_field('cpca_contact_name')?></a><br/><?php echo get_field('cpca_contact_phone')?></td>
<?php } else { ?>
<td><strong><?php echo get_the_title()?></strong></td>
<?php if ( ! empty( $file_url ) ){ ?>
<td><strong><a href="<?php echo $file_url ?>"><?php echo get_field('contract_number')?></a></strong></td>
<?php }else{ ?>
<td><strong><?php echo get_field('contract_number')?></strong></td>
<?php } ?>
<td><?php echo get_field('contract_expires')?></td>
<td><?php echo( get_field('contract_vendor_name') ) ?></td>
<td><?php echo get_field('contract_contact_name')?></td>
<td><?php echo get_field('contract_contact_phone')?></td>
<?php }; ?>
<td>
<div>
<?php
//
// The Vendor Characteristics field of the contract consists of a set of checkboxes.
// We will display an icon for each characteristic checked per row, so
// there may be more than one icon per row / record. In this case,
// we'll just display them in sequence horizontally
//
$checkbox_values = get_field( 'contract_vendor_characteristics' );
$image_name = '';
$alt = '';
if ( ! empty( $checkbox_values ) ){
foreach( $checkbox_values as $caption ){
switch( $caption ){
case 'CCV':
$image_name = 'CodeConduct_business_button.png';
$alt = 'Code of Conduct Vendor';
break;
case 'CCV+':
$image_name = 'CodeConduct_enhanced_business_button.png';
$alt = 'Enhanced Code of Conduct Vendor';
break;
case 'CTB':
$image_name = 'CT_business_button.png';
$alt = 'Connecticut Based Business';
break;
case 'DISBE':
$image_name = 'disabled_business_button.png';
$alt = 'Disabled Based Business';
break;
case 'MBE':
$image_name = 'minority_business_button.png';
$alt = 'Minority Business';
break;
case 'SBE':
$image_name = 'small_business_button.png';
$alt = 'Small Business';
break;
case 'WBE':
$image_name = 'women_business_button.png';
$alt = 'Women Based Business';
break;
default:
break;
} // end switch
//
// Pump out the next vendor characteristic icon for this row
// There may be more than one.
//
echo '<figure id="attachment_2016" style="width: 40px" class="wp-caption alignleft"><img class="size-full wp-image-2016" src="http://purchasing.uconn.edu/wp-content/uploads/sites/49/2015/06/'.$image_name.'" alt="'.$alt.'" width="40" height="40" /><figcaption class="wp-caption-text">'.$caption.'</figcaption></figure>';
} // foreach
} // if ! empty checkbox_values
?>
</div>
</td>
</tr>
<?php } wp_reset_query(); // endwhile; ?>
</tbody>
</table>
</main><!-- #main -->
</section><!-- #primary -->
</div>
</div>
</div>
<?php get_footer(); ?>
You can’t perform that action at this time.