<?php

/**
 * @file
 * Default theme implementation to present all user profile data.
 *
 * This template is used when viewing a registered member's profile page,
 * e.g., example.com/user/123. 123 being the users ID.
 *
 * Use render($user_profile) to print all profile items, or print a subset
 * such as render($user_profile['user_picture']). Always call
 * render($user_profile) at the end in order to print all remaining items. If
 * the item is a category, it will contain all its profile items. By default,
 * $user_profile['summary'] is provided, which contains data on the user's
 * history. Other data can be included by modules. $user_profile['user_picture']
 * is available for showing the account picture.
 *
 * Available variables:
 *   - $user_profile: An array of profile items. Use render() to print them.
 *   - Field variables: for each field instance attached to the user a
 *     corresponding variable is defined; e.g., $account->field_example has a
 *     variable $field_example defined. When needing to access a field's raw
 *     values, developers/themers are strongly encouraged to use these
 *     variables. Otherwise they will have to explicitly specify the desired
 *     field language, e.g. $account->field_example['en'], thus overriding any
 *     language negotiation rule that was previously applied.
 *
 * @see user-profile-category.tpl.php
 *   Where the html is handled for the group.
 * @see user-profile-item.tpl.php
 *   Where the html is handled for each item in the group.
 * @see template_preprocess_user_profile()
 *
 * @ingroup themeable
 */
?>
<div class="profile"<?php print $attributes; ?>>
    <?php
        $u="[user:feed-node:author:hybridauth]";
        //echo $u;
		global $user;
		$uid=$user->uid;
		//$user_profile['profile_main']['#title'] = $user_profile['field_firstname']['#object']->field_firstname['und'][0]['value'];
        $uname=$user_profile['field_firstname']['#object']->name;
        $email=$user_profile['field_firstname']['#object']->mail;
        $first_name=$user_profile['field_firstname']['#object']->field_firstname['und'][0]['value'];
        $last_name=$user_profile['field_firstname']['#object']->field_lastname['und'][0]['value'];
        $sectors=array();
        foreach($user_profile['field_firstname']['#object']->field_sectors['und'] as $sec){
            $sectors[]=$sec['value'];
        }
        $dt=array();
        foreach($user_profile['field_firstname']['#object']->field_document_type['und'] as $d){
            $dt[]=$d['value'];
        }
        $op=array();
        foreach($user_profile['field_firstname']['#object']->field_opportunities['und'] as $o){
            $op[]=$o['value'];
        }
        $country=$user_profile['field_firstname']['#object']->field_az_cf_core_postal_address['und'][0]['country'];
        $state=$user_profile['field_firstname']['#object']->field_az_cf_core_postal_address['und'][0]['administrative_area'];
        $city=$user_profile['field_firstname']['#object']->field_az_cf_core_postal_address['und'][0]['locality'];
        $address2=$user_profile['field_firstname']['#object']->field_az_cf_core_postal_address['und'][0]['premise'];
        $address1=$user_profile['field_firstname']['#object']->field_az_cf_core_postal_address['und'][0]['thoroughfare'];
        $pincode=$user_profile['field_firstname']['#object']->field_az_cf_core_postal_address['und'][0]['postal_code'];
		if($user_profile['field_firstname']['#object']->picture=="")
			$image_path="/sites/all/themes/niua_smartnet/img/noimg.jpg";
		else
        	$image_path=file_create_url(file_load($user_profile['field_firstname']['#object']->picture->fid)->uri);
        $designation=$user_profile['field_firstname']['#object']->field_user_designation['und'][0]['value'];
        $title=$user_profile['field_firstname']['#object']->field_user_title['und'][0]['value'];
        $desc=$user_profile['field_firstname']['#object']->field_az_cf_core_description['und'][0]['value'];
    ?>

</div>
<script>
$(document).ready(function(){    
    $('#accordProfile').on('shown', function () {
       $(".icon-chevron-down").removeClass("icon-chevron-down").addClass("icon-chevron-up");
    });

    $('#accordProfile').on('hidden', function () {
       $(".icon-chevron-up").removeClass("icon-chevron-up").addClass("icon-chevron-down");
    });
});
</script>
<style type="text/css">

.img-circle {
    border: 5px solid #ccc;
    border-radius: 50%;
    padding: 5px;
    width: 140px;
}

#sidebar{	background:#f9f9f9;padding:20px 10px 0 10px;}
.details{;background:#ecf0f1; min-height:375px; height:auto;}
.un{padding-bottom:5px; border-bottom:1px solid #ccc;}
.pi{margin-top:15px;}
h1.user-name{font-size:18px;}
h5.position {
    background: #666 none repeat scroll 0 0;
    color: #fff;
    padding:5px 15px;
}
.table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > tfoot > tr > th, .table > thead > tr > td, .table > thead > tr > th{border-top:0px; border-bottom:1px solid #ddd;}
.panel-title.fieldset-legend {
    /* symbol for "opening" panels */
    font-family: 'Glyphicons Halflings';  /* essential for enabling glyphicon */
    content: "\e114";    /* adjust as needed, taken from bootstrap.css */
    float: right !important;        /* adjust as needed */
    color: grey !important;         /* adjust as needed */
}
.panel-title.fieldset-legend.collapsed {
    /* symbol for "collapsed" panels */
    content: "\e080";    /* adjust as needed, taken from bootstrap.css */
}
</style>

<div class="row">
    <?php if(!in_array("Training Institute",$user_profile['field_firstname']['#object']->roles) || $user->uid == $user_profile['field_firstname']['#object']->uid){ ?>

<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 details">

<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12 text-center" id="pers-info">
				<div id="sidebar">
					<div class="user">
						<div class="text-center">
							<img src="<?php echo $image_path; ?>" class="img-circle">
						</div>
						<div class="user-head">
                            <?php if(in_array("Training Institute",$user_profile['field_firstname']['#object']->roles)){ ?>
                            <h1 class="user-name"><?php echo $title." ".$first_name; ?></h1>
                            <?php }else{ ?>
                            <h1 class="user-name"><?php echo $title." ".$first_name." ".$last_name; ?></h1>
                            <?php } ?>
                            <?php if(!in_array("Training Institute",$user_profile['field_firstname']['#object']->roles)){ ?>
                            <h6><?php echo $email; ?></h6> 
                            <?php } ?>
							<h5 class="position"><?php echo $designation; ?></h5>
						</div>
					</div>
					</div>
                   <?php if($user->uid == $user_profile['field_firstname']['#object']->uid){ ?>                
                	<p><a href="/user/<?php echo $uid; ?>/edit" ><img src="https://smartnet.niua.org/sites/default/files/edit.png"  style="width:175px;" /></a></p>
                <?php }else{ ?>
                	<p><a href="/user-contributions/<?php echo $user_profile['field_firstname']['#object']->uid ?>" ><img src="https://smartnet.niua.org/sites/default/files/contri.png"  style="width:175px;" /></a></p>
                    <p><a href="#" ><img src="https://smartnet.niua.org/sites/default/files/pub.png"  style="width:175px;" /></a></p>
                    <?php if(in_array("Training Institute",$user_profile['field_firstname']['#object']->roles)){ ?>
                    <?php } ?>
                <?php } ?>
        
				</div>

<div class="col-lg-8 col-md-8 col-sm-8 col-xs-12 details">
               <div class="col-xs-12 pi">
                <div class="panel panel-default">
                  <div class="panel-heading">Description</div>
                  <div class="panel-body">
                  <?php echo $desc; ?>
                  </div>
                  </div>
                  </div>
                  
                <?php
                    if($user->uid == $user_profile['field_firstname']['#object']->uid || $user->uid == 1){
                ?>
              <!--
                <div class="col-xs-6  pi">
                <div class="panel panel-default">
                  <div class="panel-heading">Personal Info</div>
                  <div class="panel-body">
                   
                  
                  
                  <table class="table table-hover">
                    <tbody>
                      <tr>
                        <td><strong>Address 1:</strong></td>
                        <td><?php //echo $address1; ?></td>
                      </tr>
                      <tr>
                        <td><strong>Address 2:</strong></td>
                        <td><?php //echo $address2; ?></td>
                      </tr>
                      <tr>
                        <td><strong>City:</strong></td>
                        <td><?php //echo $city; ?></td>
                      </tr>
                      <tr>
                        <td><strong>Pincode:</strong></td>
                        <td><?php //echo $pincode; ?></td>
                      </tr>
                      <tr>
                        <td><strong>State:</strong></td>
                        <td><?php //echo $state; ?></td>
                      </tr>
                      <tr>
                        <td><strong>Country:</strong></td>
                        <td><?php //echo $country; ?></td>
                      </tr>
                    </tbody>
                  </table>

                  </div>
                </div>
                </div>
			 <div class="col-xs-6  pi">
                <div class="panel panel-default">
                  <div class="panel-heading">Preferences</div>
                  <div class="panel-body">
                    <strong>Sectors:</strong> <br/>
						<?php
                        foreach($sectors as $sec){
                            //echo ucwords($sec)."<br/>";
                        }
                        ?>
                        <br/>
                        <strong>Document Type:</strong> <br/>
                        <?php
                        foreach($dt as $d){
                            //echo ucwords($d)."<br/>";
                        }
                        ?>
                        <br/>
                       <strong> Opportunities:</strong> <br/>
                        <?php
                        foreach($op as $o){
                            //echo ucwords($o)."<br/>";
                        }
                        ?>
                  </div>
          
                </div>
                </div>-->
                <?php } ?>
		</div>

</div>
    <?php } else { ?>
    
    
     <div class="col-xs-12">
    <div class="pull-left"><p><a href="/training-institute/<?php echo $user_profile['field_firstname']['#object']->uid; ?>" class="btn btn-info clickuser" style="text-align:center;">Training Institute Profile</a></p> </div>
    <div class="pull-right"><button data-toggle="collapse" data-target="#info" class="btn btn-info clickuser" style="text-align:center;">View Profile</button></div>
    </div>
    
     

    


<div id="info" class="collapse">
    <p>&nbsp;</p>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 details">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12 text-center" id="pers-info">
				<div id="sidebar">
					<div class="user">
						<div class="text-center">
							<img src="<?php echo $image_path; ?>" class="img-circle">
						</div>
						<div class="user-head">
                            <?php if(in_array("Training Institute",$user_profile['field_firstname']['#object']->roles)){ ?>
                            <h1 class="user-name"><?php echo $title." ".$first_name; ?></h1>
                            <?php }else{ ?>
                            <h1 class="user-name"><?php echo $title." ".$first_name." ".$last_name; ?></h1>
                            <?php } ?>
                            <?php if(!in_array("Training Institute",$user_profile['field_firstname']['#object']->roles)){ ?>
                            <h6><?php echo $email; ?></h6> 
                            <?php } ?>
							<h5 class="position"><?php echo $designation; ?></h5>
						</div>
					</div>
					</div>
                   <?php if($user->uid == $user_profile['field_firstname']['#object']->uid){ ?>                
                	<p><a href="/user/<?php echo $uid; ?>/edit" ><img src="https://smartnet.niua.org/sites/default/files/edit.png"  style="width:175px;" /></a></p>
                <?php }else{ ?>
                	<p><a href="/user-contributions/<?php echo $user_profile['field_firstname']['#object']->uid ?>" ><img src="https://smartnet.niua.org/sites/default/files/contri.png"  style="width:175px;" /></a></p>
                    <p><a href="#" ><img src="https://smartnet.niua.org/sites/default/files/pub.png"  style="width:175px;" /></a></p>
                <?php } ?>
        
				</div>

<div class="col-lg-8 col-md-8 col-sm-8 col-xs-12 details">
               <div class="col-xs-12 pi">
                <div class="panel panel-default">
                  <div class="panel-heading">Description</div>
                  <div class="panel-body">
                  <?php echo $desc; ?>
                  </div>
                  </div>
                  </div>
                  
                <?php
                    if($user->uid == $user_profile['field_firstname']['#object']->uid || $user->uid == 1){
                ?>
              <!--
                <div class="col-xs-6  pi">
                <div class="panel panel-default">
                  <div class="panel-heading">Personal Info</div>
                  <div class="panel-body">
                   
                  
                  
                  <table class="table table-hover">
                    <tbody>
                      <tr>
                        <td><strong>Address 1:</strong></td>
                        <td><?php //echo $address1; ?></td>
                      </tr>
                      <tr>
                        <td><strong>Address 2:</strong></td>
                        <td><?php //echo $address2; ?></td>
                      </tr>
                      <tr>
                        <td><strong>City:</strong></td>
                        <td><?php //echo $city; ?></td>
                      </tr>
                      <tr>
                        <td><strong>Pincode:</strong></td>
                        <td><?php //echo $pincode; ?></td>
                      </tr>
                      <tr>
                        <td><strong>State:</strong></td>
                        <td><?php //echo $state; ?></td>
                      </tr>
                      <tr>
                        <td><strong>Country:</strong></td>
                        <td><?php //echo $country; ?></td>
                      </tr>
                    </tbody>
                  </table>

                  </div>
                </div>
                </div>
			 <div class="col-xs-6  pi">
                <div class="panel panel-default">
                  <div class="panel-heading">Preferences</div>
                  <div class="panel-body">
                    <strong>Sectors:</strong> <br/>
						<?php
                        foreach($sectors as $sec){
                            //echo ucwords($sec)."<br/>";
                        }
                        ?>
                        <br/>
                        <strong>Document Type:</strong> <br/>
                        <?php
                        foreach($dt as $d){
                            //echo ucwords($d)."<br/>";
                        }
                        ?>
                        <br/>
                       <strong> Opportunities:</strong> <br/>
                        <?php
                        foreach($op as $o){
                            //echo ucwords($o)."<br/>";
                        }
                        ?>
                  </div>
          
                </div>
                </div>-->
    </div>
                <?php } ?>
		</div>    
</div>



    <?php } ?>
    
    
</div>





