mirror of
				https://github.com/nerzhul/ocsms.git
				synced 2025-10-30 18:07:36 +00:00 
			
		
		
		
	Show the multiple phone numbers into the header
This commit is contained in:
		
							parent
							
								
									36cd0d0597
								
							
						
					
					
						commit
						b8d0e66a9d
					
				| @ -114,6 +114,7 @@ class SmsController extends Controller { | |||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 		$messages = array(); | 		$messages = array(); | ||||||
|  | 		$phoneNumbers = array(); | ||||||
| 		 | 		 | ||||||
| 		// Contact resolved
 | 		// Contact resolved
 | ||||||
| 		if ($contactName != "") { | 		if ($contactName != "") { | ||||||
| @ -128,22 +129,25 @@ class SmsController extends Controller { | |||||||
| 				for ($i=0; $i < $ctPn; $i++) { | 				for ($i=0; $i < $ctPn; $i++) { | ||||||
| 					$messages = $messages + | 					$messages = $messages + | ||||||
| 						$this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $iContacts[$contactName][$i], $lastDate); | 						$this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $iContacts[$contactName][$i], $lastDate); | ||||||
|  | 					$phoneNumbers[] = $iContacts[$contactName][$i]; | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 			// This case mustn't be reached, but add it.
 | 			// This case mustn't be reached, but add it.
 | ||||||
| 			else { | 			else { | ||||||
| 				$messages = $this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $phoneNumber, $lastDate); | 				$messages = $this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $phoneNumber, $lastDate); | ||||||
|  | 				$phoneNumbers[] = $phoneNumber; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		else { | 		else { | ||||||
| 			$messages = $this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $phoneNumber, $lastDate); | 			$messages = $this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $phoneNumber, $lastDate); | ||||||
|  | 			$phoneNumbers[] = $phoneNumber; | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 		// Order by id (date)
 | 		// Order by id (date)
 | ||||||
| 		ksort($messages); | 		ksort($messages); | ||||||
| 		 | 		 | ||||||
| 		// @ TODO: filter correctly
 | 		// @ TODO: filter correctly
 | ||||||
| 		return new JSONResponse(array("conversation" => $messages, "contactName" => $contactName)); | 		return new JSONResponse(array("conversation" => $messages, "contactName" => $contactName, "phoneNumbers" => $phoneNumbers)); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
|  | |||||||
							
								
								
									
										21
									
								
								js/script.js
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								js/script.js
									
									
									
									
									
								
							| @ -58,15 +58,32 @@ function fetchConversation(phoneNumber) { | |||||||
| 			'phoneNumber': phoneNumber | 			'phoneNumber': phoneNumber | ||||||
| 		}, | 		}, | ||||||
| 		function(jsondata, status) { | 		function(jsondata, status) { | ||||||
|  | 			var phoneNumberLabel = phoneNumber; | ||||||
|  | 
 | ||||||
|  | 			if (typeof jsondata['phoneNumbers'] != 'undefined') { | ||||||
|  | 				len = jsondata["phoneNumbers"].length; | ||||||
|  | 				ctLen = 0; | ||||||
|  | 				phoneNumberLabel = ''; | ||||||
|  | 
 | ||||||
|  | 				$.each(jsondata["phoneNumbers"], function(id, val) { | ||||||
|  | 					phoneNumberLabel += val; | ||||||
|  | 					ctLen++; | ||||||
|  | 					if (ctLen != len) { | ||||||
|  | 						phoneNumberLabel += ","; | ||||||
|  | 					} | ||||||
|  | 					phoneNumberLabel += " "; | ||||||
|  | 				}); | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
| 			conversationBuf = formatConversation(jsondata); | 			conversationBuf = formatConversation(jsondata); | ||||||
| 			conversationBuf += '<div class="msg-endtag"></div>'; | 			conversationBuf += '<div class="msg-endtag"></div>'; | ||||||
| 			if (typeof jsondata['contactName'] == 'undefined') { | 			if (typeof jsondata['contactName'] == 'undefined') { | ||||||
| 				$('#ocsms-phone-label').html(phoneNumber); | 				$('#ocsms-phone-label').html(phoneNumberLabel); | ||||||
| 				$('#ocsms-phone-opt-number').html(''); | 				$('#ocsms-phone-opt-number').html(''); | ||||||
| 			} | 			} | ||||||
| 			else { | 			else { | ||||||
| 				$('#ocsms-phone-label').html(jsondata['contactName']); | 				$('#ocsms-phone-label').html(jsondata['contactName']); | ||||||
| 				$('#ocsms-phone-opt-number').html(phoneNumber); | 				$('#ocsms-phone-opt-number').html(phoneNumberLabel); | ||||||
| 			} | 			} | ||||||
| 			 | 			 | ||||||
| 			if ($('#app-content-header').is(':hidden')) { | 			if ($('#app-content-header').is(':hidden')) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user