<?php
global $website_options;

include ('views/_header.tpl.php');
?>

<style>
	#mmen { display:none; }
	a.btn-black-slim { 
	    width: 100%;
	    margin-bottom: 10px;
	    background: #000;
	    color: #ddd;
	    border: 0px;
	    text-shadow: 0px 0px 0px;
	    font-size: 15px;
	    font-family: 'Open Sans',Arial,Helvetica Neue,Helvetica,sans-serif;
	    font-weight: 300;
	    letter-spacing: 1px;
	    border-radius: 50px !important;
	    -moz-border-radius: 50px;
	    -webkit-border-radius: 50px;
	    height: 48px !important;
	    padding: 10px 25px 10px !important;
	}
	a.btn-black-slim:hover { 
		background:#222;
		color:#fff;
	}	
</style>

<div class="layout-2cols">
	<div class="content grid_8">
		<div class="project-detail">
			<div class="project-tab-detail tabbable accordion">
				<ul class="nav nav-tabs clearfix">
					<li class="active"><a href="#">Profile</a></li>
					<li><a href="#">My Pictures</a></li>

                    <?php if ($user['account_type'] == "Company") : ?>
                        <?php if ($website_options['enable_deals']) : ?>
                      <li><a href="#" class="be-fc-orange">My Deals</a></li>
                        <?php else : ?>
                      <li><a href="#" class="be-fc-orange">My Projects</a></li>
                      <li><a href="#" class="be-fc-orange">My Listings</a></li>
                        <?php endif; ?>
                    <?php endif; ?>
                      <li><a href="#" class="be-fc-orange">I&rsquo;m
							Following</a></li>
					<li><a href="#" class="be-fc-orange">My Favorites</a></li>
                    <?php if ($user['account_type'] != "Company") : ?>
                        <?php if ($website_options['enable_proposals']) : ?>
                      <li><a href="#" class="be-fc-orange">My Jobs</a></li>
					<li><a href="#" class="be-fc-orange">My Proposals</a></li>
                        <?php endif; ?>
                    <?php endif; ?>
                    </ul>
				<div class="tab-content">
					<div>
						<h3 class="rs alternate-tab accordion-label">Profile</h3>
						<div class="tab-pane accordion-content active">
							<div class="form form-profile" style="width:auto;">
								<form method="post" enctype="multipart/form-data">
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Name:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1" name="name"
												value="<?= $user['name']; ?>">
											<p class="rs description-input">Your name is displayed on
												your profile.</p>
										</div>
									</div>

<?php if ($user['account_type'] != 'Company') : ?>
    Company Account Type
<?php endif; ?>
                                        <div class="row-item clearfix">
										<label class="lbl" for="txt_location">Location:</label>
										<div class="val">
											<input class="txt" type="text" onblur="geocodeAddress();" id="txt_location" name="location" value="<?= $user['location']; ?>">
											<!-- LOCATION LAT LNG input -->
											<input name='location_lat' value="<?= $user['location_lat']; ?>" /> 
											<input name='location_lng' value="<?= $user['location_lng']; ?>" /> 
											<input name='location_last_lat' value="<?= $user['location_last_lat']; ?>" /> 
											<input name='location_last_lng' value="<?= $user['location_last_lng']; ?>" />

											<!-- <button class="btn btn-white">Choose location</button> -->
										</div>
									</div>

									<!-- GOOGLE MAP -->
									<script src='/static/js/googlemaps/GoogleMapsProfile.js'></script>
									<div class="row-item clearfix">
										<div id="map-canvas" style="width: 100%;"></div>
									</div>



                                    <div class="row-item clearfix">
										<label class="lbl" for="txt_location">Phone Number:</label>
										<div class="val">
											<input class="txt" type="text" name="phone"
												value="<?= $user['phone']; ?>" placeholder="+13125552020">
											<p class="rs description-input">+13125552020</p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_location">Profile picture:</label>
										<div class="val">
											<input class="txt" type="file" name="image" />
											<!-- <button class="btn btn-white">Choose location</button> -->
										</div>
									</div>
                                    <div class="row-item clearfix">
										<label class="lbl" for="txt_bio">Biography:</label>
										<div class="val">
											<textarea class="txt fill-width" name="biography"
												id="txt_bio" cols="30" rows="10"><?= $user['biography']; ?></textarea>
											<p class="rs description-input">We suggest a short bio. If
												it’s 300 characters or less it’ll look great on your
												profile.</p>
										</div>
									</div>

<?php if ($user['account_type'] != 'Company') : ?>

									<div class="row-item clearfix">
										<label class="lbl" for="txt_bio">Interests:</label>
										<div class="val">
											<input class="txt interests-ac" name="interests" value="<?= $user['interests'] ?>">
											<p class="rs description-input">Add your Interests. Deals may be pointed
																			to you by SMS in case you match specific
																			targetting campaigns.</p>
										</div>
									</div>

									<div class="row-item clearfix">
										<label class="lbl" for="txt_bio">Maximum Deal Alerts / Day:</label>
										<div class="val">
											<input class="txt interests-ac" name="max_daily_alerts" value="<?= $user['max_daily_alerts'] ?>">
											<p class="rs description-input">Set the maximum count of deal Alerts
																			(SMS) you would like to get per Day.</p>
										</div>
									</div>

<?php endif; ?>
                                        <div class="row-item clearfix">
										<label class="lbl" for="txt_name2">Profile URL:</label>
										<div class="val">
											<p class="rs display-val">
												<a href="/profile/<?= $user['user_slug']; ?>"
                    class="be-fc-orange"><?= get('siteroot') ?>profile/</a><input style="max-height:60px; height:auto; width: auto;" type="text" name="user_slug" value="<?= $user['user_slug']; ?>" />
											</p>

										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_web">Web:</label>
										<div class="val">
											<input class="txt txt-website" name="website" type="text"
												id="txt_web" value="<?= $user['website'] ?>"
												placeholder="http://yourwebsite.com">
											<p class="rs description-input">http://yourwebsite.com</p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">LinkedIn URL:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1"
												name="linkedin_account"
												value="<?= $user['linkedin_account']; ?>">
											<p class="rs description-input">https://www.linkedin.com/profile/view?id=16064724</p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Paypal E-Mail:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1"
												name="paypal_email" value="<?= $user['paypal_email']; ?>">
											<p class="rs description-input">You PayPal account is used
												for any payments that must be done to you.</p>
										</div>
									</div>

									For project owners. Next data is used for any payments that
									must be done to you.
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Credit Card:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1"
												name="creditcard" value="<?= $user['creditcard'] ?>" />
											<p class="rs description-input">Enter creditcard number</p>
										</div>
									</div>

									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Credit Card Expiration Date:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1"
												name="x_exp_date" value="<?= $user['x_exp_date'] ?>" />
											<p class="rs description-input">Enter Expiration Date</p>
										</div>
									</div>

									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Bank Account number:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1"
												name="x_bank_acct_num"
												value="<?= $user['x_bank_acct_num'] ?>" />
											<p class="rs description-input">Enter Bank Account number</p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Bank Account Type:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1"
												name="x_bank_acct_type"
												value="<?= $user['x_bank_acct_type'] ?>" />
											<p class="rs description-input">Enter Bank Account Type</p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Bank ABA Routing Code:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1"
												name="x_bank_aba_code"
												value="<?= $user['x_bank_aba_code'] ?>" />
											<p class="rs description-input">Enter Bank ABA Routing Code</p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Bank Name:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1"
												name="x_bank_name" value="<?= $user['x_bank_name'] ?>" />
											<p class="rs description-input">Enter Bank Name</p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">First Name:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1"
												name="x_first_name" value="<?= $user['x_first_name'] ?>" />
											<p class="rs description-input">Enter First Name</p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Last Name:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1"
												name="x_last_name" value="<?= $user['x_last_name'] ?>" />
											<p class="rs description-input">Enter Last Name</p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Company:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1"
												name="x_company" value="<?= $user['x_company'] ?>" />
											<p class="rs description-input">Enter Company</p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Address:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1" name="x_adress"
												value="<?= $user['x_adress'] ?>" />
											<p class="rs description-input">Enter Address</p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">City:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1" name="x_city"
												value="<?= $user['x_city'] ?>" />
											<p class="rs description-input">Enter City</p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">State:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1" name="x_state"
												value="<?= $user['x_state'] ?>" />
											<p class="rs description-input">Enter State</p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">ZIP:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1" name="x_zip"
												value="<?= $user['x_zip'] ?>" />
											<p class="rs description-input">Enter ZIP</p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Phone:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1" name="x_phone"
												value="<?= $user['x_phone'] ?>" />
											<p class="rs description-input">Enter Phone</p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Fax:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1" name="x_fax"
												value="<?= $user['x_fax'] ?>" />
											<p class="rs description-input">Enter Fax</p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Email:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1" name="x_email"
												value="<?= $user['x_email'] ?>" />
											<p class="rs description-input">Enter Email</p>
										</div>
									</div>

<?php if ($user['account_type'] == "Model") : ?>

                                        <div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Instagram Username:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1"
												name="instagram_username"
												value="<?= $user['instagram_username']; ?>">
											<p class="rs description-input">Your Instagram account is
												used to display a photo gallery containing your Instagram
												photos.</p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Your Height:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1" name="height"
												value="<?= $user['height']; ?>" placeholder="5'7&quot;">
											<p class="rs description-input">Enter your Height in Feet and
												Inches (5'7").</p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Your Weight:</label>
										<div class="val">
											<input class="txt" type="text" id="txt_name1" name="weight"
												value="<?= $user['weight']; ?>" placeholder="115">
											<p class="rs description-input">Enter your Height in Pounds.
												(115)</p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Your Eye Color:</label>
										<div class="val">
											<select class="txt" name="eye_color">
                                                <?php
												foreach ( [
														'blue',
														'brown',
														'green',
														'light brown',
														'yellow',
														'red',
														'hazel',
														'other'
												] as $col ) :
													$sel = $user ['eye_color'] == $col ? " selected='selected'" : "";
													?>

                                                <option
													value="<?= $col ?>" <?= $sel ?>><?= ucwords($col) ?></option>

                                                <?php
												endforeach;
												?>
                                                </select>
											<p class="rs description-input">Select your Eye color.</p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">About:</label>
										<div class="val">
											<textarea class="txt fill-width" name="willing_to_do"
												id="txt_bio" cols="30" rows="5"><?= $user['willing_to_do']; ?></textarea>
											<p class="rs description-input">Please enter a description
												</p>
										</div>
									</div>

<?php elseif ($user['account_type'] == "Company") : ?>

                                        <?php
	$categoryModel = new categoryModel ();
	$categories = $categoryModel->getList ();
	?>
                                        <div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Business Category:</label>
										<div class="val">
											<select name="category_id" class="txt fill-width">
												<option value="">Please select a category</option>

                                                    <?php
	foreach ( $categories as $category ) :
		$sel = $user ['category_id'] == $category ['id'] ? ' selected="selected"' : '';
		?>
                                                    <option
													value="<?= $category['id'] ?>" <?= $sel ?>><?= $category['title'] ?></option>
                                                    <?php endforeach; ?>

                                                </select>
											<p class="rs description-input">Select a business category</p>
										</div>
									</div>

                                    <!--
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Physical Address:</label>
										<div class="val">
											<p class="rs description-input">Enter the Physical address of
												your Business</p>
											<input name="location" onblur="geocodeAddress();"
												id="txt_address" class="txt fill-width" type="text"
												placeholder="Enter physical address"
												value="<?= $user['location'] ?>" /> <input type='hidden'
												name='location_lat' value="<?= $user['location_lat'] ?>" />
											<input type='hidden' name='location_lng'
												value="<?= $user['location_lng'] ?>" />
										</div>
									</div>
									<script src='/static/js/googlemaps/GoogleMapsProfile.js'></script>
									<div class="row-item clearfix">
										<div id="map-canvas" style="width: 100%;"></div>
									</div>
									-->

									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Mailing Address:</label>
										<div class="val">
											<label><input type="checkbox" id="add_mailing_addr" />&nbsp;Add a different mailing address</label>
											<br /> 
											<input disabled name="mailing_address" id="txt_address2" class="txt fill-width" 
												type="text" placeholder="Enter mailing address" value="<?= $user['mailing_address'] ?>" />
											<p class="rs description-input"></p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Mailing Address2:</label>
										<div class="val">
											<input name="mailing_address2" id="txt_address2" class="txt fill-width" 
												type="text" placeholder="Unit #" value="<?= $user['mailing_address2'] ?>" />
											<p class="rs description-input"></p>
										</div>
									</div>					
													
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Contact Name:</label>
										<div class="val">
											<input name="contact_name" id="txt_contactname"
												class="txt fill-width" type="text"
												placeholder="Enter contact name"
												value="<?= $user['contact_name'] ?>" />
											<p class="rs description-input"></p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Contact E-Mail:</label>
										<div class="val">
											<input name="contact_email" id="txt_contactmail"
												class="txt fill-width" type="text"
												placeholder="Enter contact e-mail address"
												value="<?= $user['contact_email'] ?>" />
											<p class="rs description-input"></p>
										</div>
									</div>
									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Contact Phone:</label>
										<div class="val">
											<input name="contact_phone" id="txt_contactphone"
												class="txt fill-width" type="text"
												placeholder="Enter contact phone number"
												value="<?= $user['contact_phone'] ?>" />
											<p class="rs description-input"></p>
										</div>
									</div>
<!--									<div class="row-item clearfix">
										<label class="lbl" for="txt_name1">Best Time to be Reached:</label>
										<div class="val">
											<input name="contact_best_time" id="txt_besttime"
												class="txt fill-width" type="text"
												placeholder="Best time to be reached (8am-6pm)"
												value="<?= $user['contact_best_time'] ?>" />
											<p class="rs description-input"></p>
										</div>
									</div>-->

<?php endif; ?>

                                        <p
										class="wrap-btn-submit rs ta-r">
										<button class="btn btn-blue btn-submit-all">Save all settings</button>
									</p>
								</form>
							</div>
						</div>
						<!--end: .tab-pane (Profile) -->
					</div>

					<div>
						<h3 class="rs alternate-tab accordion-label">My Pictures</h3>

						<div class="tab-pane accordion-content">
							<div class="form form-profile">

							<?php require 'views/profile/form-mypictures.tpl.php'; ?>

							</div>
						</div>
						<!--end: .tab-pane (My Pictures) -->
					</div>


<?php if ($user['account_type'] == "Company") : ?>

                        <div>
                            <?php if ($website_options['enable_deals']) : ?>
                            <h3 class="rs alternate-tab accordion-label">My
							     Deals
							 </h3>
                            <?php else : ?>
                            <h3 class="rs alternate-tab accordion-label">My
							     Projects
							</h3>
							<h3 class="rs alternate-tab accordion-label">My
                                 Listings
                            </h3>
                            <?php endif; ?>

                            <div class="tab-pane accordion-content">

                                <?php if (empty ( $myProjects )) : ?>

                                <p style="padding: 5px;">You have not
								created any Projects yet !</p>


                            	<?php endif; ?>

                                <?php foreach ( $myProjects as $project ) :

                            		if ($website_options ['enable_deals'])
                            			require 'views/profile/projectrow-deal.tpl.php';
                            		else
                            			require 'views/profile/projectrow-default.tpl.php';
                            	    endforeach 
                            	   ; ?>

                            </div>
						    <!--end: .tab-pane (Projects) -->
						    
						    <!-- LISTINGS START HERE -->
						 
                            <div class="tab-pane accordion-content">

                                <?php if (empty ( $myListings )) : ?>

                                <p style="padding: 5px;">You have not
                                created any Listings yet !</p>


                                <?php endif; ?>

                                <?php  foreach ( $myListings as $listing ) {
                                   //   onerror="this.src='img/delogo.jpg';"
                                   //    onerror="this.src=\'img/delogo.jpg\';"
                                    $errorimg = "onerror=\"this.src='/static/images/filler-img-med.jpg';\"";
                                    
                                    echo "<div style='float:left; width:100px; height:100px; overflow:hidden; background:#ccc; margin: 0 5px 5px 0;'><a href='#'> 
                                        <img src='/{$listing['main_img']}' style='width:100px; min-height:100%; clear:both; object-fit:cover' 
                                        {$errorimg} /></div></a>
                                        <div style='float:left;'><b>{$listing['title']}</b>
                                        <br /><br />
                                        <a href='/llpricing?lid={$listing['id']}' class='btn btn-blue'>Upgrade this Listing</a> <a href='/project/{$listing['id']}' class='btn btn-blue' target='_blank'>View Listing</a>
                                        </div>
                                        <div class='clear'></div>
                                        ";
                               
                                } ?>

                            </div>
                            <!--end: .tab-pane (Projects) -->						 
						 
					<!-- USER TYPE COMPANY TABS END HERE -->	    
					</div>

<?php endif; ?>

						<div>
						<h3 class="rs alternate-tab accordion-label">Followed Users</h3>
						<div class="tab-pane accordion-content"
							style="padding: 8px; margin-top: 0px;">

                                <?php
								if (empty ( $followedUsers )) :
									?>

                                <p style="padding: 5px;">You are not Following anyone yet !</p>

								<?php
                                endif;
								?>

                            	<?php

								foreach ( $followedUsers as $fuser ) {
									echo "<div style='float:left; width:100px; height:100px; overflow:hidden; background:#ccc; margin: 0 5px 5px 0;'><a href='/profile/{$fuser['user_slug']}'>
										<img src='{$fuser['image']}' style='width:100px;  clear:both;' /></div></a>
										<div style='display:none; float:left;'><b>{$fuser['name']}</b><br />{$fuser['project_count']} projects<br />
										{$fuser['avg_rating_received']} average rating</div>";
								} ?>
                            	<div style="clear: both"></div>
						</div>
					</div>

					<div>
						<h3 class="rs alternate-tab accordion-label">My Favorites</h3>
						<div class="tab-pane accordion-content">
                                <?php
								if (empty ( $favorites )) :
									?>

                                <p style="padding: 5px;">You have not added Favorites yet !</p>

								<?php
                                endif; ?>

                                <?php
								foreach ( $favorites as $objid => $favorite_object ) :

									if ($website_options['enable_deals'] && userModel::FAVTYPE_PROJECT == $favorite_object ['favorite_type'])
										require 'views/profile/favorite-deals.tpl.php';
									else
										require 'views/profile/favorite-default.tpl.php';
								endforeach ;
								?>
                            </div>
						<!--end: .tab-pane -->
					</div>

<?php if ($user['account_type'] != "Company") : ?>

    <?php if ($website_options['enable_proposals']) : ?>

                        <div>
						<h3 class="rs alternate-tab accordion-label">My Jobs</h3>
						<div class="tab-pane accordion-content">
                                <?php
		if (empty ( $jobs )) :
			?>

                            <p style="padding: 5px;">You have not worked on any Job yet !</p>


		<?php
                                endif;
		?>

                                <?php
		foreach ( $jobs as $objid => $job_proposal ) :
			$rating = in_array ( $job_proposal ['project'] ['status'], array (
					"reviewed",
					"withdrawn"
			) ) ? "Rating: <b>" . $job_proposal ['rating'] . "</b> / 5" : "";
			?>
                                <div
								class="box-marked-project project-short inside-tab favorited-object">
								<div class="top-project-info">
									<div class="content-info-short clearfix">
										<a href="/project/<?= $job_proposal['project_id'] ?>"
											class="thumb-img"> <img
											src="/<?= $job_proposal['project']['main_img'] ?>"
											alt="<?= $job_proposal['project']['title'] ?>"
											style="max-height: 200px;">
										</a>
										<div class="wrap-short-detail">
											<h3 class="rs acticle-title">
												<a class="be-fc-orange"
													href="/project/<?= $job_proposal['project_id'] ?>"><?= $job_proposal['project']['title'] ?></a>
											</h3>
											<p class="rs">
												<span>Proposal Date: </span><b><?= date("Y-m-d h:i:s A", strtotime($job_proposal['timestamp'])) ?></b>
											</p>
											<p class="rs">
												<span>Amount: </span><span class="property-price">$<?= $job_proposal['amount'] ?></span>
											</p>
											<p class="rs">
												<span>Status: </span><b><?= ucfirst($job_proposal['project']['status']) ?></b>
											</p>
                                                <?= $rating?>
                                            </div>
										<p class="rs clearfix comment-view"></p>
									</div>
								</div>
								<!--end: .top-project-info -->
							</div>
                                <?php
		endforeach
		;
		?>

                            </div>
						<!--end: .tab-pane -->
					</div>

					<div>
						<h3 class="rs alternate-tab accordion-label">My Proposals</h3>
						<div class="tab-pane accordion-content">
                                <?php
		if (empty ( $proposals )) :
			?>

                                <p style="padding: 5px;">You have not
								sent any Proposals yet !</p>


		<?php
                                endif;
		?>

                                <?php
		foreach ( $proposals as $objid => $proposal ) :
			$status = "created" == $proposal ['project'] ['status'] ? "No one Hired yet." : $proposal ['project'] ['status'];
			$rating = in_array ( $proposal ['project'] ['status'], array (
					"reviewed",
					"withdrawn"
			) ) ? "Rating: <b>" . $proposal ['rating'] . "</b> / 5" : "";
			?>
                                <div
								class="box-marked-project project-short inside-tab favorited-object">
								<div class="top-project-info">
									<div class="content-info-short clearfix">
										<a href="/project/<?= $proposal['project_id'] ?>"
											class="thumb-img"> <img
											src="/<?= $proposal['project']['main_img'] ?>"
											alt="<?= $proposal['project']['title'] ?>"
											style="max-height: 200px;">
										</a>
										<div class="wrap-short-detail">
											<h3 class="rs acticle-title">
												<a class="be-fc-orange"
													href="/project/<?= $proposal['project_id'] ?>"><?= $proposal['project']['title'] ?></a>
											</h3>
											<p class="rs">
												<span>Proposal Date: </span><b><?= date("Y-m-d h:i:s A", strtotime($proposal['timestamp'])) ?></b>
											</p>
											<p class="rs">
												<span>Amount: </span><span class="property-price">$<?= $proposal['amount'] ?></span>
											</p>
											<p class="rs">
												<span>Status: </span><b><?= ucfirst($status) ?></b>
											</p>
                                                <?= $rating?>
                                            </div>
										<p class="rs clearfix comment-view"></p>
									</div>
								</div>
								<!--end: .top-project-info -->
							</div>
                                <?php
		endforeach
		;
		?>

                            </div>
						<!--end: .tab-pane -->
					</div>

    <?php endif; /* deals or proposals */ ?>

<?php endif; ?>

                    </div>
				<!--end: .tab-content -->
			</div>
			<!--end: .project-tab-detail -->
		</div>
	</div>
	<!--end: .content -->
	<div class="sidebar grid_4">
		<div class="box-gray project-author" style="margin-bottom:0px;">
			<h3 class="title-box">Customer Info</h3>
			<div class="media">
				<a href="/profile/<?= $user['user_slug']; ?>" class="thumb-left"> <img
					src="<?= $user['image'] ?>" alt="<?= $user['name'] ?>" />
				</a>
				<div class="media-body">
					<h4 class="rs pb10">
						<a href="/profile/<?= $user['user_slug']; ?>"
							class="be-fc-orange fw-b"><?= $user['name'] ?></a>
					</h4>
					<p class="rs"><?= $user['location'] ?></p>
					<p class="rs fc-gray"><?= count($myProjects) ?> Projects</p>
					<p class="rs fc-gray"><?= $user['reviews_count'] ?> Reviews</p>
				</div>
			</div>
			<div class="author-action">
				<!-- <a class="btn btn-red" href="#">Edit info</a> -->
				<a class="btn btn-white" href="/auth/logout">Logout</a>
			</div>
		</div>
		<!--end: .project-author -->
		<div style="width: 100%; height: auto; padding: 10px 0; text-align: center;">
		
        <?php 
            require_once '3rdparty/phpqrcode/qrlib.php';
            
            //$PNG_TEMP_DIR = dirname(__FILE__).DIRECTORY_SEPARATOR.'members'.DIRECTORY_SEPARATOR;
            $PNG_TEMP_DIR = '/home/sqdash/public_html/preorder/3rdparty/customers/';
            $PNG_WEB_DIR = '3rdparty/phpqrcode/customers/';
            $fname = 'cust_' . $user['id'] . '.png';
            $filename2 = '3rdparty/phpqrcode/customers/' . $fname;
            $filename = $PNG_TEMP_DIR.$fname;
            $url = 'https://preorder.sqdash.co/admin/scan?uid='.$user['id'];
            
            //$qr_string = array(
            //    'website' => 'https://preorder.sqdash.co/'.$page['slug'],
            //);
            //echo "<br />"; 
            //$qrString = json_encode($qr_string);
            $qrString = "Open 'https://preorder.sqdash.co/admin/scan?uid=".$user['id']."' to take E-Wallet payment.";
			//$qrString = "Open to verify the Vax or Clearance Pass.";
            //echo $qrString;
            QRcode::png($qrString, $filename2);
            //QRcode::png('https://preorder.sqdash.co/pinipico', $filename2);
        
            //echo "<br /><br /><br />";
            //echo "PNG TEMP DIR: " . $PNG_TEMP_DIR ."<br />";
            //echo "PNG WEB DIR: " . $PNG_WEB_DIR ."<br />";
            //echo "IMG FILE NAME: " . $fname ."<br />";
            //echo "IMG PATH: " . $filename2 ."<br />";
            //echo "IMG PATH: " . $filename ."<br />";
            //echo "<br /><br /><br />";
        
            echo '<div style="background: url(/static/images/qr_code_reverse_scan_border.png) no-repeat; background-size:contain; margin:0 auto; margin-top:10px; padding:30px; height:150px; width:150px;"><img src="/'.$PNG_WEB_DIR.basename($filename).'"alt="My E-Wallet QR Code" 
				style="border:1px solid #ddd; width:150px; height:auto;" /></div>'; 
            //echo "<br /><br /><br />"; 
       ?> 
       <br /><br />		
		
		
			<span style="color: #4ba220; font-size: 48px; font-weight: 600;">$<?= number_format(($user['credits']/100),2,'.',','); ?></span><br />
			<span style="color: #aaa; font-weight:300">Your E-Wallet Balance</span> <br />
			<br /> 
			<a href="/payments/buy" class="btn-black-slim">Load E-Wallet</a>
			<br /> <br />

			<hr style="height: 1px; border-top: 1px dashed #ccc; border-left: 0px; border-right: 0px; border-bottom: 0px; 
			margin: 0 auto; margin-top: 10px; margin-bottom: 10px; width: 60%;">
			<br />

                <?php if ($website_options['enable_proposals']) : ?>
            	<span
				style="color: #4ba220; font-size: 48px; font-weight: bold;"><?= $user['avg_rating_received'] ?></span><br />
			<span style="color: #aaa;">Average Rating Received</span> <br />
			<br />
			<hr
				style="height: 1px; border-top: 1px dashed #ccc; border-left: 0px; border-right: 0px; border-bottom: 0px; margin: 0 auto; margin-top: 10px; margin-bottom: 10px; width: 60%;">
			<br /> <span
				style="color: #4ba220; font-size: 48px; font-weight: bold;"><?= $user['avg_rating_given'] ?></span><br />
			<span style="color: #aaa;">Average Rating Given</span> <br />
			<br />
			<hr
				style="height: 1px; border-top: 1px dashed #ccc; border-left: 0px; border-right: 0px; border-bottom: 0px; margin: 0 auto; margin-top: 10px; margin-bottom: 10px; width: 60%;">
			<br />
                <?php endif; ?>

            </div>
	</div>
	<!--end: .sidebar -->
	<div class="clear"></div>
</div>


<script type="text/javascript">
// utilities for multi-selection autocomplete
function split(val) {
	return val.split(/,\s*/);
}
function extractLast(term) {
	return split(term).pop();
}
// end utilities

$(document).ready(function()
{
    $("#add_mailing_addr").change(function()
    {
        if ($(this).is(":checked")) {
            $("input[name='mailing_address']").removeProp("disabled");
            $("input[name='mailing_address']").focus();
        }
        else
            $("input[name='mailing_address']").prop("disabled", true);
    });

    $(".interests-ac")
    .bind("keydown", function(event) {
		if (event.keyCode === $.ui.keyCode.TAB
			&& $(this).autocomplete("instance").menu.active)
			// prevent value inserted on focus
			event.preventDefault();
	})
	.autocomplete({
		source: function(request, response) {
			$.getJSON("/interest/search", {
				term: extractLast(request.term)
			}, response);
		},
		search: function() {
			// custom minLength
			var term = extractLast(this.value);
			if (term.length < 2)
				return false;
		},
		focus: function() {
			// prevent value inserted on focus
			return false;
		},
		select: function( event, ui ) {
			var terms = split(this.value);
			// remove the current input
			terms.pop();
			// add the selected item
			terms.push(ui.item.value);
			// add placeholder to get the comma-and-space at the end
			terms.push("");
			this.value = terms.join(", ");
			return false;
		}
	});
});
</script>

<?php
include 'views/_footer.tpl.php';
?>
