Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Mar 12, 2015
2 parents b451a99 + 7999452 commit e6184d1
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
7 changes: 5 additions & 2 deletions app/controllers/AdminItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ public function editProcess($id){
if(($item->Cost != Input::get('Cost')) || ($item->Quantity != Input::get('Quantity')) || ($item->Shipping != Input::get('Shipping'))){
//Oh noes, we gotta figure out what to do next
$originalTotalCost = ($item->Cost * $item->Quantity) + $item->Shipping;
$newTotalCost = (Input::get('Cost') * Input::get('Quantity')) + $item->Shipping;
$newTotalCost = (Input::get('Cost') * Input::get('Quantity')) + Input::get('Shipping');
$amount = abs($originalTotalCost - $newTotalCost);
//Also pull in the account
$order = $item->Order()->first();
$project = $order->Project()->first();
$account = $project->Account()->first();
if($originalTotalCost > $newTotalCost){
$account->Deposit('RECONCILE',$amount,$item->id);
$account->Deposit('RECONCILE',$amount,$item->OrderID);
}elseif($originalTotalCost < $newTotalCost){
if(!$account->Withdrawl('RECONCILE',$amount,$item->id)){
return Redirect::to('/admin/orders/'.$item->OrderID)->with('error',array('Insufficient funds to cover changes'));
Expand Down Expand Up @@ -97,6 +97,8 @@ public function massStatusChangeProcess(){
foreach($itemCollection as $item){
$item->changeStatus($newStatus);
}
//After we are done let's update the order
Order::recalculate($orderID);
$order = Order::find($orderID);
$user = $order->User()->first();
//Prepare the email, different emails based on the status we are updating to.
Expand All @@ -111,6 +113,7 @@ public function massStatusChangeProcess(){
Mail::send('emails.orderPickup', array('person'=>$user,'order'=>$order,'items'=>$itemCollection), function($message) use($user){
$message->to($user->Email,$user->FirstName.' '.$user->LastName)->subject('IPRO order ready for pickup!');
});

break;
case 5://picked up
//Pickup script sends an email, see AdminPickupController
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/AdminProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function overview($iproid){
$budgetReq = $project->BudgetRequests()->get();
View::share('budgetRequests',$budgetReq);
//Account
$acct = $project->Account()->get();
$acct = $project->Account()->first();
View::share('account',$acct);
//Students
$students = $project->Users()->get();
Expand Down
12 changes: 9 additions & 3 deletions app/controllers/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public function newOrderProcess($id){
$item = new Item;
$item->Name = $itemNames[$i];
$item->Link = $itemLinks[$i];
if(!filter_var($item->Link,FILTER_VALIDATE_URL)){
//Url is invalid
array_push($order_error, 'Link "'.$item->Link.'" for '.$item->Name.' is invalid. All links must be in form "http://website.tld".');
$order_has_error = true;
}
$item->PartNumber = $itemPNs[$i];
$item->Cost = floatval(str_replace('$','',$itemCosts[$i]));
$item->Quantity = $itemQuantities[$i];
Expand Down Expand Up @@ -114,9 +119,7 @@ public function newOrderProcess($id){
}
//Make the array unique
array_unique($approvedPickups);
if($order_has_error){
return Redirect::to('/project/'.$id.'/orders/new')->with('error',$order_error)->with('items',$itemArray);
}

//Ok all passed, we have enough funding, and all items are validated, let's create this order
$order = new Order;
$order->PeopleID = Auth::id();
Expand All @@ -135,6 +138,9 @@ public function newOrderProcess($id){
array_push($order_error, 'Your order contains errors, please correct them');
}
}
if($order_has_error){
return Redirect::to('/project/'.$id.'/orders/new')->with('error',$order_error)->with('items',$itemArray);
}
//order should now have an id
//Save all the items
if(!$order_has_error){
Expand Down
6 changes: 4 additions & 2 deletions app/views/Orders/new.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
@foreach(Session::get('items') as $item)
addMoreItems('{{ $item->Name }}', '{{ $item->Link }}', '{{ $item->PartNumber }}', '{{ $item->Cost }}', '{{ $item->Quantity }}','{{ $item->Shipping }}', '{{ $item->Justification }}');
@endforeach
recalculateAllTC();
@else
addMoreItems();
@endif
Expand Down Expand Up @@ -180,9 +181,10 @@ function addMoreItems(itemName,itemLink,itemPN,itemCost,itemQuantity,shippingCos
$('#totalCost'+ItemID).maskMoney({thousands:',', decimal:'.', allowZero:true, prefix: '$ '});
$('#shippingCost'+ItemID).maskMoney({thousands:',', decimal:'.', allowZero:true, prefix: '$ '});
$('#Cost'+ItemID).maskMoney('mask');
$('#totalCost'+ItemID).maskMoney('mask',0.00);
$('#shippingCost'+ItemID).maskMoney('mask',0.00);
$('#totalCost'+ItemID).maskMoney('mask');
$('#shippingCost'+ItemID).maskMoney('mask');
$('#Quantity'+ItemID).numeric();
recalculateSingleTC(ItemID);
}
function recalculateSingleTC(itemid){
Expand Down
6 changes: 5 additions & 1 deletion app/views/admin/projects/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
<div class="form-group">`
<select class="form-control" id="semester_selection">
@foreach ($semesters as $semester)
<option value="{{ $semester->id }}">{{ $semester->Name }}</option>
<option
@if($activeSemester->id == $semester->id)
selected="selected"
@endif
value="{{ $semester->id }}">{{ $semester->Name }}</option>
@endforeach
</select></div>
<div class="form-group">
Expand Down
1 change: 1 addition & 0 deletions app/views/admin/projects/overview.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<li><a href="{{URL::route("project.groupmanager",$project->id)}}">Group Manager</a></li>
</ul>
</div>
<div class="pull-right">Account Balance: ${{ number_format($account->Balance,2) }}</div>
</h1>
<h3>{{$project->Name}}</h3>
</div>
Expand Down

0 comments on commit e6184d1

Please sign in to comment.