1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
<?php
use Illuminate\Database\Capsule\Manager as DB; use Carbon\Carbon as Carbon;
class Notification extends BaseModel{ protected $table = "notification"; protected $primaryKey = 'id';
public static function create(array $attributes) { $model = new static($attributes);
$model->save();
return $model; }
public static function get_notification($customer=0) { if(!empty($customer)){ $rows = Notification::where("customer_id", $_SESSION["customer_id"])->where("deleted", "0")->orderBy("read", "ASC")->orderBy("createdate", "DESC")->get(); }else{ $rows = Notification::where("cmsloginid", $_SESSION["cmsloginid"])->where("deleted", "0")->orderBy("read", "ASC")->orderBy("createdate", "DESC")->get(); }
if(!empty($rows)){ $rows = $rows->toArray(); foreach ($rows as $key => $row){ $sql = "select * from `".$row["table_name"]."` where id = ? "; $parameters = array($row["table_id"]); $result = bind_pdo($sql, $parameters, "selectone");
if($row["type"] == "NEGOTIATION_REQUEST"){ $rows[$key]["title"] = _lang("Customer has sent the negotiation request.")."<br>"._lang("Order No.")." : <a href='supplier_order_service_modifyform.php?id=".$row["table_id"]."' target='_blank'>".$result["code"]."</a>"; }else if($row["type"] == "NEGOTIATION_OFFER"){ $rows[$key]["title"] = _lang("Merchant has offered the negotiation quote.")."<br>"._lang("Order No.")." : <a href='order_detail_service.php?id=".$row["table_id"]."' target='_blank'>".$result["code"]."</a>"; }else if($row["type"] == "NEGOTIATION_ACCEPT"){ $rows[$key]["title"] = _lang("Customer has accepted the negotiation quote.")."<br>"._lang("Order No.")." : <a href='supplier_order_service_modifyform.php?id=".$row["table_id"]."' target='_blank'>".$result["code"]."</a>"; }else if($row["type"] == "NEGOTIATION_REJECT"){ $rows[$key]["title"] = _lang("Customer has rejected the negotiation quote.")."<br>"._lang("Order No.")." : <a href='supplier_order_service_modifyform.php?id=".$row["table_id"]."' target='_blank'>".$result["code"]."</a>"; }else if($row["type"] == "NEGOTIATION_PAID"){ $rows[$key]["title"] = _lang("Customer has paid the negotiation quote.")."<br>"._lang("Order No.")." : <a href='supplier_order_service_modifyform.php?id=".$row["table_id"]."' target='_blank'>".$result["code"]."</a>"; }else if($row["type"] == "NEGOTIATION_TERMINATED"){ $rows[$key]["title"] = _lang("Customer has terminated the negotiation quote.")."<br>"._lang("Order No.")." : <a href='supplier_order_service_modifyform.php?id=".$row["table_id"]."' target='_blank'>".$result["code"]."</a>"; }else if($row["type"] == "NEGOTIATION_IN_PROGRESS"){ $rows[$key]["title"] = _lang("Merchant has in progress production.")."<br>"._lang("Order No.")." : <a href='order_detail_service.php?id=".$row["table_id"]."' target='_blank'>".$result["code"]."</a>"; }else if($row["type"] == "NEGOTIATION_REVIEW"){ $rows[$key]["title"] = _lang("Merchant provides a review the negotiation quote.")."<br>"._lang("Order No.")." : <a href='order_detail_service.php?id=".$row["table_id"]."' target='_blank'>".$result["code"]."</a>"; }else if($row["type"] == "NEGOTIATION_REVIEW_COMPLETE"){ $rows[$key]["title"] = _lang("Customer has accepted a review the negotiation quote.")."<br>"._lang("Order No.")." : <a href='supplier_order_service_modifyform.php?id=".$row["table_id"]."' target='_blank'>".$result["code"]."</a>"; }else if($row["type"] == "NEGOTIATION_COMPLETE"){ $rows[$key]["title"] = _lang("The negotiation quote has completed.")."<br>"._lang("Order No.")." : <a href='supplier_order_service_modifyform.php?id=".$row["table_id"]."' target='_blank'>".$result["code"]."</a>"; }else if($row["type"] == "NEGOTIATION_IN_PROGRESS_REJECT"){ $rows[$key]["title"] = _lang("Customer has reject a review the negotiation quote.")."<br>"._lang("Order No.")." : <a href='supplier_order_service_modifyform.php?id=".$row["table_id"]."' target='_blank'>".$result["code"]."</a>"; }else if($row["type"] == "CHAT"){ //find order item $order_item = OrderItem::find($result["order_item_id"]); //find supplier order $supplier_order = SupplierOrder::find($order_item["supplier_order_id"]);
$rows[$key]["title"] = _lang("Chat")."<br>"._lang("Order No.")." : <a href='supplier_order_service_modifyform.php?id=".$supplier_order["id"]."' target='_blank'>".$supplier_order["code"]."</a>"; } }
return $rows; } }
public static function get_unread_notification($customer=0) { if(!empty($customer)){ $rows = Notification::where("customer_id", $_SESSION["customer_id"])->where("deleted", "0")->where("read", "0")->orderBy("read", "ASC")->orderBy("createdate", "DESC")->get(); }else{ $rows = Notification::where("cmsloginid", $_SESSION["cmsloginid"])->where("deleted", "0")->where("read", "0")->orderBy("read", "ASC")->orderBy("createdate", "DESC")->get(); }
if(!empty($rows)){ $rows = $rows->toArray(); return $rows; } }
public static function read_notification($customer=0) { if(!empty($customer)){ Notification::where("customer_id", $_SESSION["customer_id"])->where("deleted", "0")->update(array("read"=>1, "read_date"=>date("Y-m-d H:i:s"))); }else{ Notification::where("cmsloginid", $_SESSION["cmsloginid"])->where("deleted", "0")->update(array("read"=>1, "read_date"=>date("Y-m-d H:i:s"))); } }
}
|