'doSummary', 'list' => 'doList', 'cancel' => 'doBack', 'edit' =>'doEdit', 'update' => 'doUpdate', 'preview'=> 'doPreview', 'view_email' => 'doViewEmail', 'del' => 'doDelete', 'save_company_template'=>'doSaveLocationTemplate', 'save_as_company_template'=>'doSaveAsLocationTemplate', 'load_company_template'=>'doLoadLocationTemplate', 'del_company_template'=>'doDeleteLocationTemplate', 'test'=>'doTest', 'choose_recipients'=>'doChooseRecipients', 'send'=>'doSend', 'done'=>'doDone', ); var $editAlias = 'account/broadcast-email/send'; var $adminEnd = true; var $moneyFields = array('property_size_min'=>'Size Min', 'property_size_max'=>'Size Max'); function initAction() { if (!empty($this->action)) { return; } if(isset($_REQUEST['action'])) { $this->action = $_REQUEST['action']; return; } if (isset($_REQUEST['submit_btn'])) { $this->action = 'list'; return; } } function exec() { $this->initAction(); if ( !key_exists($this->action, $this->actions) ){ if ($this->defaultAction) { $this->action = $this->defaultAction; } else { $actionNames = array_keys($this->actions); $this->action = $actionNames[0]; } } $function = $this->actions[$this->action]; if ($this->isXmlHttpRequest()) { $function .= 'Ajax'; } if (method_exists($this, $function)) { $this->$function(); } else { exit; } } function _doListBind(&$DB_List) { $DB_List->def_order_by = 'added DESC'; $DB_List->insertColLast('individual_img', array( 'title'=>'Photo', 'imgW' =>'35', 'imgH' =>'50', 'no_img_url'=>'img/no_forum_photo.jpg', 'tpl'=>'BroadcastEmail/Repository/List/cells/img.tpl', 'params'=>array('individual_img'), )); $DB_List->insertColLast('type', array( 'title'=>'Type', 'order_by'=>'type', 'width'=>70, 'tpl'=>DB_LIST_CELL_TEXT, 'params'=>array('type'), )); $DB_List->insertColLast('subject', array( 'title'=>'Subject', 'order_by'=>'subject', 'width'=>100, 'tpl'=>DB_LIST_CELL_TEXT, 'params'=>array('subject'), )); $DB_List->insertColLast('individual_full_name', array( 'title'=>'Individual Name', 'order_by'=>'individual_full_name', 'width'=>100, 'tpl'=>'BroadcastEmail/Repository/List/cells/individual_name.tpl', 'params'=>array('individual_full_name'), )); $DB_List->insertColLast('company_name', array( 'title'=>'Company Name', 'order_by'=>'company_name', 'width'=>100, 'tpl'=>DB_LIST_CELL_TEXT, 'params'=>array('company_name'), )); $DB_List->insertColLast('added', array( 'title'=>'Date', 'order_by'=>'added', 'width'=>80, 'date_format'=>'%B %d, %Y', 'tpl' => DB_LIST_CELL_DATE, 'params'=> array('added') )); $DB_List->insertColLast('options', array( 'title'=>'Options', 'tpl'=>'BroadcastEmail/Repository/List/cells/options.tpl', 'url'=>BASE_URL.'/'.CURR_PAGE.'', 'params'=>array('id'), )); $DB_List->bind(); return true; } function getFilterForm() { require_once 'class/Form/Form.class.php'; $form = new Form($this->Doc, 'form_search_email', 'get', '', '_self', array('class'=>'form form_search_email')); $form->tpl = SiteMap::getPath('BroadcastEmail/tpl/Repository/filter.tpl'); $form->setRendType(FORM_RENDERER_ARRAY_SMARTY); $listDays = array(1, 3, 5, 7, 15, 30, 60, 90, 120); $listDays = array_combine($listDays, $listDays); $form->addElement('extended_select', 'day_cnt', 'Search Emails Sent Within:', array(''=>'All') + $listDays, array('style'=>'width:45px;'), array('after'=>' days')); $form->addElement('select', 'id_type', 'Type of Email', array('all'=>'All Types') + (array)$this->DBObj->getDEmailType4Select()); $form->addElement('select', 'subtype_id', 'Transaction Type', array('all'=>'All Types') + (array)$this->DBObj->getDEmailSubType4Select()); $form->addElement('select', 'location_id', 'Location', array('all'=>'All Locations') + (array)$this->DBObj->getDPropertyLocation4Select()); $form->addElement('select', 'primary_use_id', 'Real Estate Type', array('all'=>'All Types') + (array)$this->DBObj->getDPrimaryUse4Select()); $form->addElement('checkbox', 'investment', 'Investment only'); //$form->addElement('select', 'id_specialty', 'Markets of Specialty:', array('all'=>'All Markets of Specialty') + (array)$this->DBObj->getDSpecialty4Select('sorter', "profile = 'y'")); //$form->addElement('select', 'subject_radio3', 'Sale, Lease or Sublease:', array('all'=>'All', 'lease'=>'Lease', 'sublease'=>'Sublease', 'sale'=>'Sale', 'sale_or_lease'=>'Sale or Lease')); $form->addElement('text', 'subject', 'Subject'); $form->addElement('text', 'sender', 'Sender name or email address'); $form->addElement('text', 'property_size', 'Size', array('class'=>'inp_width', 'size'=>'10', 'style'=>'width:170px;')); $form->addElement('text', 'property_size_min', 'Size', array('class'=>'property_size_min', 'emptybg'=>'img/bg_no_min.gif', 'size'=>'10')); $form->addElement('text', 'property_size_max', 'Size', array('class'=>'property_size_max', 'emptybg'=>'img/bg_no_max.gif', 'size'=>'10')); $elList = $this->formCreateRadioboxList($form, 'property_unit', array('sf'=>'square feet', 'acres'=>'acres')); $form->addGroup($elList, 'gPropertyUnit', '', ' ', false); $form->addElement('advcheckbox', 'use_range', '', 'Use a Range', array('id'=>'use_range'), array('n', 'y')); $form->addElement('submit', 'submit_btn', 'Search', array( 'class' => 'btn') ); $form->addElement('button', 'advanced_search', 'Advanced Search', array( 'class' => 'btn', 'onclick="return false;"', 'id'=>'advanced_search_btn') ); $form->addElement('button', 'cancel', 'Clear Entries', array( 'class' => 'btn' , 'onclick' => "document.location.href='".Constant::get('BASE_URL').'/'.CURR_PAGE."'" )); $form->addElement('hidden', 'search_type', 'simple'); $form->addFormRule(array($this, 'validFilterForm')); $form->setAttribute('onsubmit', "return validate_broadcast_email_filter(this);"); return $form; } function validFilterForm($data) { $this->fixMoneyFields($data); $err = array(); $regex_numeric = "/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/"; foreach ($this->moneyFields as $name => $title) { if (!empty($data[$name]) && !preg_match($regex_numeric, $data[$name])) { $err[$name] = $title.' is in wrong format'; } } if ( $data['unit_range'] == 'y' && !empty($data['property_size_min']) && !empty($data['property_size_max']) && empty($err['property_size_min']) && empty($err['property_size_min']) && $data['property_size_min'] > $data['property_size_max'] ) { $err['property_size_min'] = 'The Low value must be less than the High value'; } return (empty($err)) ? true : $err; } function fixMoneyFields(&$data) { foreach ($this->moneyFields as $name=>$title) { if (!empty($data[$name])) { $data[$name] = str_replace(array(',', ' '), '', $data[$name]); } } } function doSummary() { $filterForm = $this->getFilterForm(); $filterForm->setDefaults(array('day_cnt'=>'30', 'property_unit'=>'sf')); $this->renderFilterForm($filterForm); $this->_saveBackUrl(); $item = array(); $item['list'] = $this->DBObj->getSummary(); $item['tpl'] = SiteMap::getPath('BroadcastEmail/tpl/Repository/summary.tpl'); $item['edit_link'] = BASE_URL.'/'.CURR_PAGE; $item['del_link'] = BASE_URL.'/'.CURR_PAGE; $this->Doc->addContent($item); } function doDelete() { Session::setData($this->_getPage4SaveMessage(), 'msg', $this->DBObj->itemName.' has been deleted'); $this->DBObj->delete(); $this->doBack(); return true; } function doBack() { require_once 'class/HTTP.php'; $backUrl = $this->getBackUrl(); if (empty($backUrl)){ skHTTP::redirect(Constant::get('BASE_URL').'/'.CURR_PAGE); }else { $this->clearBackUrl(); skHTTP::redirect($backUrl); } } function getBackUrl() { $url = Session::getData(CURR_PAGE, 'query_string'); if (empty($url)) { $url = BASE_URL.'/'.CURR_PAGE; } return $url; //return Session::getData(CURR_PAGE, 'query_string'); } function addLink() { $addLink = array( 'tpl' => 'center_link.tpl', 'link' => $this->getBackUrl(), 'title' => 'Back to list', ); $this->Doc->addContent($addLink); } function doEdit() { $this->addLink(); $this->DBObj->initFromDB(); $item = $this->DBObj->getData(); if (empty($item)) { $this->Doc->displayError('Invalid Email ID'); return false; } $form = $this->_getEditForm(); $form->setDefaults($item); $this->renderForm($form); } function doPreview() { $this->addLink(); $this->DBObj->initFromDB(); $item = $this->DBObj->getData(); if (empty($item)) { $this->Doc->displayError('Invalid Email ID'); return false; } $item['tpl'] = SiteMap::getPath('BroadcastEmail/tpl/preview.tpl'); $item['back_url'] = $this->getBackUrl(); $item['mode'] = 'preview'; $item['tabs'] = $this->getTabMenu(); $this->Doc->addContent($item); $this->Doc->addItemProp('JSs', 'js/broadcast_email_form.js'); } function doViewEmail() { $item = $this->DBObj->getFromDB4View($this->DBObj->id); $this->Doc->setMainTpl('Doc/site_popup.tpl'); if (empty($item)) { $this->Doc->displayError('Invalid Email ID'); return false; } $item['tpl'] = SiteMap::getPath('BroadcastEmail/tpl/view_email.tpl'); $this->Doc->content['ITEMS'] = array(); $this->Doc->content['DOC']['title'] = $item['subject']; require_once('class/Const.php'); Constant::set('DEBUG', false); $this->Doc->assign('show_close_btn', 1); $this->Doc->addContent($item); } function getTabMenu() { $menu = array( 'new_edit'=>array('index'=>1, 'alias'=>CURR_PAGE_FULL.'?action=edit&id='.$this->DBObj->id, 'title'=>'Edit Message'), 'preview'=>array('index'=>2, 'alias'=>CURR_PAGE_FULL.'?action=preview&id='.$this->DBObj->id, 'title'=>'Preview Message'), ); return $menu; } function renderFilterForm($filterForm) { $filterForm->exec(); $this->Doc->addItemProp('JSs', 'js/admin_email_repository.js'); $this->Doc->addItemProp('JSs', 'js/jquery.bginput.js'); $this->Doc->addItemProp('JSs', 'js/broadcast_email_form.js'); $this->Doc->addItemProp('initFuncs', 'bginput_init'); $this->Doc->addItemProp('initFuncsEx', array('name'=>'initEmailRepositoryFilter', 'params'=>array($filterForm->_attributes['id']))); } function doList() { $filterForm = $this->getFilterForm(); if ($validFilter = $filterForm->validate()) { $data = $filterForm->exportValues(); $this->fixMoneyFields($data); $this->DBObj->setFilter($data); } $this->renderFilterForm($filterForm); if ($validFilter) { $this->_saveBackUrl(); require_once('class/DB/List/List.php'); $DB_List = new DB_List($this->Doc, $this->DBObj, $this->functionalFields); $DB_List->urlVarNames = array_keys($this->DBObj->filter); $DB_List->urlVarNames[] = 'ipp'; $this->_doListBind($DB_List); $DB_List->exec(); } return true; } }