partial #5042
This commit is contained in:
parent
226dac72be
commit
2fe2fdd630
@ -28,7 +28,6 @@ class Crunchbutton_Support extends Cana_Table_Trackchange {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getFirstCustomerMessage(){
|
public function getFirstCustomerMessage(){
|
||||||
if( $this->id_support ){
|
if( $this->id_support ){
|
||||||
$first_cs_reply = Crunchbutton_Support_Message::q( 'SELECT MIN( id_support_message ) AS id_support_message FROM support_message WHERE id_support = ' . $this->id_support . ' AND ( `from` = "' . Crunchbutton_Support_Message::TYPE_FROM_REP . '" OR `from` = "' . Crunchbutton_Support_Message::TYPE_FROM_SYSTEM . '" )' );
|
$first_cs_reply = Crunchbutton_Support_Message::q( 'SELECT MIN( id_support_message ) AS id_support_message FROM support_message WHERE id_support = ' . $this->id_support . ' AND ( `from` = "' . Crunchbutton_Support_Message::TYPE_FROM_REP . '" OR `from` = "' . Crunchbutton_Support_Message::TYPE_FROM_SYSTEM . '" )' );
|
||||||
@ -343,6 +342,7 @@ class Crunchbutton_Support extends Cana_Table_Trackchange {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function addCustomerMessage( $params = [] ){
|
public function addCustomerMessage( $params = [] ){
|
||||||
|
|
||||||
$messageParams[ 'id_admin' ] = NULL;
|
$messageParams[ 'id_admin' ] = NULL;
|
||||||
$messageParams[ 'type' ] = Crunchbutton_Support_Message::TYPE_SMS;
|
$messageParams[ 'type' ] = Crunchbutton_Support_Message::TYPE_SMS;
|
||||||
$messageParams[ 'from' ] = Crunchbutton_Support_Message::TYPE_FROM_CLIENT;
|
$messageParams[ 'from' ] = Crunchbutton_Support_Message::TYPE_FROM_CLIENT;
|
||||||
@ -363,16 +363,19 @@ class Crunchbutton_Support extends Cana_Table_Trackchange {
|
|||||||
|
|
||||||
public function autoReply(){
|
public function autoReply(){
|
||||||
|
|
||||||
$body = $this->autoReplyMessage();
|
$support = Crunchbutton_Support::o( $this->id_support );
|
||||||
|
|
||||||
if( $this->shoudAutoReply() && $body ){
|
$body = $support->autoReplyMessage();
|
||||||
|
|
||||||
|
if( $support->shoudAutoReply() && $body ){
|
||||||
|
|
||||||
$messageParams[ 'type' ] = Crunchbutton_Support_Message::TYPE_AUTO_REPLY;
|
$messageParams[ 'type' ] = Crunchbutton_Support_Message::TYPE_AUTO_REPLY;
|
||||||
$messageParams[ 'from' ] = Crunchbutton_Support_Message::TYPE_FROM_SYSTEM;
|
$messageParams[ 'from' ] = Crunchbutton_Support_Message::TYPE_FROM_SYSTEM;
|
||||||
$messageParams[ 'visibility' ] = Crunchbutton_Support_Message::TYPE_VISIBILITY_EXTERNAL;
|
$messageParams[ 'visibility' ] = Crunchbutton_Support_Message::TYPE_VISIBILITY_EXTERNAL;
|
||||||
$messageParams[ 'phone' ] = $params[ 'phone' ];
|
$messageParams[ 'phone' ] = $support->phone;
|
||||||
$messageParams[ 'body' ] = $body;
|
$messageParams[ 'body' ] = $body;
|
||||||
$message = $this->addMessage( $messageParams );
|
|
||||||
|
$message = $support->addMessage( $messageParams );
|
||||||
|
|
||||||
Crunchbutton_Message_Sms::send([
|
Crunchbutton_Message_Sms::send([
|
||||||
'to' => $message->phone,
|
'to' => $message->phone,
|
||||||
@ -392,11 +395,12 @@ class Crunchbutton_Support extends Cana_Table_Trackchange {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function lastAutoReplyByPhone( $phone ){
|
public function lastAutoReplyByPhone( $phone ){
|
||||||
$support_message = Crunchbutton_Support_Message::q( 'SELECT sm.* FROM support s
|
$query = 'SELECT sm.* FROM support s
|
||||||
INNER JOIN support_message sm ON sm.id_support = s.id_support
|
INNER JOIN support_message sm ON sm.id_support = s.id_support
|
||||||
WHERE s.phone = "' . $phone . '"
|
WHERE s.phone = "' . $phone . '"
|
||||||
AND sm.type = "' . Crunchbutton_Support_Message::TYPE_AUTO_REPLY . '"
|
AND sm.type = "' . Crunchbutton_Support_Message::TYPE_AUTO_REPLY . '"
|
||||||
ORDER BY id_support_message DESC LIMIT 1' )->get( 0 );
|
ORDER BY id_support_message DESC LIMIT 1';
|
||||||
|
$support_message = Crunchbutton_Support_Message::q( $query )->get( 0 );
|
||||||
if( $support_message->id_support_message ){
|
if( $support_message->id_support_message ){
|
||||||
return $support_message;
|
return $support_message;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user