<?php

/**
 * This is the model class for table "customer".
 *
 * The followings are the available columns in table 'customer':
 * @property integer $customerid
 * @property string $customername
 * @property integer $status
 * @property string $inmatenumber
 * @property string $contactnamefirst
 * @property string $contactnamelast
 * @property string $contactnamemiddle
 * @property integer $location
 * @property string $notes
 * @property string $firstname
 * @property string $lastname
 * @property string $address1
 * @property string $address2
 * @property string $city
 * @property string $state
 * @property string $zip
 * @property string $phone1
 * @property string $phone2
 * @property string $phone3
 * @property string $ptype1
 * @property string $ptype2
 * @property string $ptype3
 * @property string $email
 * @property string $username
 * @property string $userpassword
 * @property integer $allowuserlogin
 * @property integer $billingmethod
 * @property integer $invoicecycle
 * @property string $billstart
 * @property double $creditbalance
 * @property double $postpaidlimit
 * @property string $lastbilldate
 * @property double $postpaidbalance
 * @property string $bilemail
 * @property string $billingtype
 * @property double $depositbalance
 * @property double $pernumbercharges
 * @property integer $freenumbers
 * @property string $prepaidamount
 * @property string $accountcode
 * @property string $carrierid
 * @property integer $rate_id
 * @property integer $hidecallerid
 * @property integer $cnamerelay
 */
class Account extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'customer';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('status, location, allowuserlogin, billingmethod, invoicecycle, freenumbers, rate_id, hidecallerid, cnamerelay', 'numerical', 'integerOnly'=>true),
			array('creditbalance, postpaidlimit, postpaidbalance, depositbalance, pernumbercharges', 'numerical'),
			array('customername', 'length', 'max'=>32),
			array('inmatenumber, contactnamefirst, contactnamelast, contactnamemiddle, firstname, lastname, city, state, phone1, phone2, phone3, ptype1, ptype2, ptype3, email, username, userpassword', 'length', 'max'=>50),
			array('address1, address2, accountcode', 'length', 'max'=>200),
			array('zip', 'length', 'max'=>12),
			array('bilemail', 'length', 'max'=>128),
			array('billingtype', 'length', 'max'=>10),
			array('prepaidamount', 'length', 'max'=>25),
			array('carrierid', 'length', 'max'=>64),
			array('notes, billstart, lastbilldate', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('customerid, customername, status, inmatenumber, contactnamefirst, contactnamelast, contactnamemiddle, location, notes, firstname, lastname, address1, address2, city, state, zip, phone1, phone2, phone3, ptype1, ptype2, ptype3, email, username, userpassword, allowuserlogin, billingmethod, invoicecycle, billstart, creditbalance, postpaidlimit, lastbilldate, postpaidbalance, bilemail, billingtype, depositbalance, pernumbercharges, freenumbers, prepaidamount, accountcode, carrierid, rate_id, hidecallerid, cnamerelay', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'customerid' => 'Customerid',
			'customername' => 'Customername',
			'status' => 'Status',
			'inmatenumber' => 'Inmatenumber',
			'contactnamefirst' => 'Contactnamefirst',
			'contactnamelast' => 'Contactnamelast',
			'contactnamemiddle' => 'Contactnamemiddle',
			'location' => 'Location',
			'notes' => 'Notes',
			'firstname' => 'Firstname',
			'lastname' => 'Lastname',
			'address1' => 'Address1',
			'address2' => 'Address2',
			'city' => 'City',
			'state' => 'State',
			'zip' => 'Zip',
			'phone1' => 'Phone1',
			'phone2' => 'Phone2',
			'phone3' => 'Phone3',
			'ptype1' => 'Ptype1',
			'ptype2' => 'Ptype2',
			'ptype3' => 'Ptype3',
			'email' => 'Email',
			'username' => 'Username',
			'userpassword' => 'Userpassword',
			'allowuserlogin' => 'Allowuserlogin',
			'billingmethod' => 'Billingmethod',
			'invoicecycle' => 'Invoicecycle',
			'billstart' => 'Billstart',
			'creditbalance' => 'Creditbalance',
			'postpaidlimit' => 'Postpaidlimit',
			'lastbilldate' => 'Lastbilldate',
			'postpaidbalance' => 'Postpaidbalance',
			'bilemail' => 'Bilemail',
			'billingtype' => 'Billingtype',
			'depositbalance' => 'Depositbalance',
			'pernumbercharges' => 'Pernumbercharges',
			'freenumbers' => 'Freenumbers',
			'prepaidamount' => 'Prepaidamount',
			'accountcode' => 'Accountcode',
			'carrierid' => 'Carrierid',
			'rate_id' => 'Rate',
			'hidecallerid' => 'Hidecallerid',
			'cnamerelay' => 'Cnamerelay',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('customerid',$this->customerid);
		$criteria->compare('customername',$this->customername,true);
		$criteria->compare('status',$this->status);
		$criteria->compare('inmatenumber',$this->inmatenumber,true);
		$criteria->compare('contactnamefirst',$this->contactnamefirst,true);
		$criteria->compare('contactnamelast',$this->contactnamelast,true);
		$criteria->compare('contactnamemiddle',$this->contactnamemiddle,true);
		$criteria->compare('location',$this->location);
		$criteria->compare('notes',$this->notes,true);
		$criteria->compare('firstname',$this->firstname,true);
		$criteria->compare('lastname',$this->lastname,true);
		$criteria->compare('address1',$this->address1,true);
		$criteria->compare('address2',$this->address2,true);
		$criteria->compare('city',$this->city,true);
		$criteria->compare('state',$this->state,true);
		$criteria->compare('zip',$this->zip,true);
		$criteria->compare('phone1',$this->phone1,true);
		$criteria->compare('phone2',$this->phone2,true);
		$criteria->compare('phone3',$this->phone3,true);
		$criteria->compare('ptype1',$this->ptype1,true);
		$criteria->compare('ptype2',$this->ptype2,true);
		$criteria->compare('ptype3',$this->ptype3,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('username',$this->username,true);
		$criteria->compare('userpassword',$this->userpassword,true);
		$criteria->compare('allowuserlogin',$this->allowuserlogin);
		$criteria->compare('billingmethod',$this->billingmethod);
		$criteria->compare('invoicecycle',$this->invoicecycle);
		$criteria->compare('billstart',$this->billstart,true);
		$criteria->compare('creditbalance',$this->creditbalance);
		$criteria->compare('postpaidlimit',$this->postpaidlimit);
		$criteria->compare('lastbilldate',$this->lastbilldate,true);
		$criteria->compare('postpaidbalance',$this->postpaidbalance);
		$criteria->compare('bilemail',$this->bilemail,true);
		$criteria->compare('billingtype',$this->billingtype,true);
		$criteria->compare('depositbalance',$this->depositbalance);
		$criteria->compare('pernumbercharges',$this->pernumbercharges);
		$criteria->compare('freenumbers',$this->freenumbers);
		$criteria->compare('prepaidamount',$this->prepaidamount,true);
		$criteria->compare('accountcode',$this->accountcode,true);
		$criteria->compare('carrierid',$this->carrierid,true);
		$criteria->compare('rate_id',$this->rate_id);
		$criteria->compare('hidecallerid',$this->hidecallerid);
		$criteria->compare('cnamerelay',$this->cnamerelay);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Account the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
