<?php
class SmsController extends AppController {

	var $name = 'Sms';
	var $components = array('Session');
	var $uses=array('Report','PhoneNum');
	var $helpers = array('Form', 'Html', 'Text','Javascript', 'Time', 'Number', 'Session', 'Paginator', 'Ajax', 'Cache');

	
	function index() {
		$this->paginate['limit'] = 50;
		$this->paginate['conditions'] = array('status' => 1);
		$this->paginate['order'] = array('id' => 'desc');
		$this->set('listitems', $this->paginate('Report'));	

	}
	
	function phone_numbers() {
		$this->paginate['limit'] = 50;
		//$this->paginate['conditions'] = array('status' => 1);
		$this->paginate['order'] = array('id' => 'desc');
		$this->set('listitems', $this->paginate('PhoneNum'));	

	}
	
	function view($id) {
		$this->Home->id = $id;
		$this->set('item', $this->Report->read());

	}

	function add() {
		if (!empty($this->data)) {
		
			if ($this->PhoneNum->save($this->data)) {
				$this->Session->setFlash('Saved Successfully.');
				$this->redirect(array('action' => 'unpublished'));
			}
		}
	}
	
	function new_sms() {
		if (!empty($this->data)) {
		
			if ($this->Report->save($this->data)) {
				$this->Session->setFlash('Saved Successfully.');
				$this->redirect(array('action' => 'unpublished'));
			}
		}
	}
	
	function delete($id) {
	if ($this->Report->delete($id)) {
		$this->Session->setFlash('Deleted Succesfully.');
		$this->redirect($this->referer());
								  }
	}
	
	function delete_phone_number($id) {
	if ($this->PhoneNum->delete($id)) {
		$this->Session->setFlash('Deleted Succesfully.');
		$this->redirect($this->referer());
								  }
	}
	
	function edit($id = null) {
	$this->PhoneNum->id = $id;
	if (empty($this->data)) {
		$this->data = $this->PhoneNum->read();
	} else {
	
		if ($this->PhoneNum->save($this->data)) {
			$this->Session->setFlash('Updated Successfully.');
			$this->redirect(array('action' => 'unpublished'));
			}
		}
	}
	

}
?>
