public function getOrder($id)
 {
     $data['orders'] = orders::where('purchaseorders_id', $id)->get();
     $previousOrder = "";
     $nextOrder = "";
     $data['previousOrder'] = $previousOrder;
     $data['nextOrder'] = $nextOrder;
     $data['total'] = $data['orders']->sum('amount');
     $data['totalquantity'] = orders::where('purchaseorders_id', $id)->count();
     $purchaseorder = purchaseorder::find($id);
     $data['purchaseOrder'] = $purchaseorder;
     $status = "";
     $form = "";
     // switch($data['purchaseOrder']->status){
     // 	case "pending":
     // 		$status = "<b style = 'color:orange'>pending</b>";
     // 		$form = "<form action = '' method = 'post'>
     // 			".csrf_field()."
     // 			<input type = 'hidden' name = 'purchaseorders_id' value = '".$id."'/>
     // 			<input type = 'submit' name = 'btnProcessDelivery' value = 'Process delivery' />
     // 		</form>";
     // 	break;
     // 	case "cancelled":
     // 		$status = "<b style = 'color:orange'>cancelled</b>";
     // 		$form = "";
     // 	break;
     // 	case "on-delivery-process":
     // 		$status = "<b style = 'color:green'>on-delivery-process</b>";
     // 		$form = "<form action = '' method = 'post'>
     // 			".csrf_field()."
     // 			<input type = 'hidden' name = 'purchaseorders_id' value = '".$id."'/>
     // 			<input type = 'submit' name = 'btnClose' value = 'Close' />
     // 		</form>";
     // 	break;
     // 	case "closed":
     // 		$status = "<b style = 'color:green'>closed</b>";
     // 		$form = "";
     // 	break;
     // }
     $data['status'] = $status;
     $deadlineColor = "black";
     if ($purchaseorder->status == "pending" || $purchaseorder->status == "on-delivery-process") {
         $datetime1 = new DateTime(date("Y-m-d"));
         $datetime2 = new DateTime($purchaseorder->deadline);
         $interval = $datetime1->diff($datetime2);
         $days = $interval->days;
         if ($days < 3) {
             $deadlineColor = "red";
         } else {
             if ($days < 5) {
                 $deadlineColor = "orange";
             } else {
                 if ($days == 7) {
                     $deadlineColor = "green";
                 }
             }
         }
     }
     $data['deadlineColor'] = $deadlineColor;
     $data['audittrails'] = audittrail::where('purchaseorder_id', $purchaseorder->id)->get();
     return view('orderdetails', $data);
 }
Пример #2
0
 public function getOrder($id)
 {
     $match = ['purchaseorders_id' => $id];
     $data['orders'] = orders::where($match)->get();
     $data['total'] = $data['orders']->sum('amount');
     $data['totalquantity'] = orders::where('purchaseorders_id', $id)->count();
     $purchaseorder = purchaseorder::find($id);
     if ($purchaseorder->user_id != Auth::user()->id) {
         return redirect("/home");
     }
     $data['purchaseOrder'] = $purchaseorder;
     $status = "";
     switch ($data['purchaseOrder']->status) {
         case "pending":
             $status = "<b style = 'color:orange'>pending</b>";
             break;
         case "cancelled":
             $status = "<b style = 'color:orange'>cancelled</b>";
             break;
         case "on-delivery-process":
             $status = "<b style = 'color:green'>on-delivery-process</b>";
             break;
         case "closed":
             $status = "<b style = 'color:green'>closed</b>";
             break;
     }
     $data['status'] = $status;
     $deadlineColor = "black";
     if ($purchaseorder->status == "pending" || $purchaseorder->status == "on-delivery-process") {
         $datetime1 = new DateTime(date("Y-m-d"));
         $datetime2 = new DateTime($purchaseorder->deadline);
         $interval = $datetime1->diff($datetime2);
         $days = $interval->days;
         if ($days < 3) {
             $deadlineColor = "red";
         } else {
             if ($days < 5) {
                 $deadlineColor = "orange";
             } else {
                 if ($days == 7) {
                     $deadlineColor = "green";
                 }
             }
         }
     }
     $data['deadlineColor'] = $deadlineColor;
     return view('orderdetails', $data);
 }