<?php
// --------------------------------------------------------------------------
//
// Esvon Classifieds v.4.0
// Copyright(C), Esvon LTD, 2001-2010, All Rights Reserved.
// E-mail: hide@address.com
//
// All forms of reproduction, including, but not limited to, internet posting,
// printing, e-mailing, faxing and recording are strictly prohibited.
// One license required per site running Esvon Classifieds.
// To obtain a license for using Esvon Classifieds, please register at
// http://www.esvon.com/pg/products/p_classifieds/
//
// --------------------------------------------------------------------------
if(!defined('SITE_PATH')) die('Access denied');
include SITE_PATH.'inc/class.item_adm.php';
class SiteRemindAdm extends SiteItemAdm {
function SiteRemindAdm(){ // constructor
parent::SiteItemAdm();
$this->TBL_ITEM = hwModTable(HW_MOD,'remind');
$this->ADM_TPL_PATH = HW_MOD_TPL.'remind_'; // with files prefix
$this->PAGE_URL = HW_MOD_URL.'&file=exp_remind&';
$this->FS_FILE = HW_MOD_TPL.'remind_fields.txt';
if ($_POST['go']) {
if(is_array($_POST['ch_all'])){
$sql = implode(',', array_map(array($this->db,'esc'), $_POST['ch_all']));
$sql = 'UPDATE '.$this->TBL_ITEM.' SET enabled=0 WHERE id IN('.$sql.')';
$this->db->query($sql);
}
if(is_array($_POST['ch_on'])){
$sql = implode(',', array_map(array($this->db,'esc'), $_POST['ch_on']));
$sql = 'UPDATE '.$this->TBL_ITEM.' SET enabled=1 WHERE id IN('.$sql.')';
$this->db->query($sql);
}
$this->ERR_MSG = hwLng('updated_ok');
}
}
function ListShow() {
if(!$_REQUEST['sort_by']) $_REQUEST['sort_by'] = 'type, days DESC';
parent::ListShow();
}
function ListRenderRow(&$v){
static $A_PLAN;
if (!isset($A_PLAN)) $A_PLAN = RemindGetPlan(true);
$v['plan_name'] = $A_PLAN[$v['type']][$v['plan']];
$v['enabled'] = $v['enabled'] ? 'checked' : '';
}
function EditRenderTpl(&$tpl,$a_Item){
$_POST['type'] = $a_Item['type']; // for RemindGetPlan() only
return parent::EditRenderTpl($tpl,$a_Item) + array('type' => $a_Item['type']);
}
function AddRenderTpl(&$tpl){
if(!$_POST['go'] && $_GET['likeid']){
$a_Item = $this->db->one_assoc('SELECT * FROM '.$this->TBL_ITEM.' WHERE id='.(int)$_GET['likeid']);
$this->O_FS->rewind();
while($o_f = &$this->O_FS->next()){
$_POST[$o_f->ID] = $a_Item[$o_f->ID];
}
}
return parent::AddRenderTpl($tpl) + array('type' => html_esc($_POST['type']));
}
function AddFormShow(){
ob_start();
parent::AddFormShow();
$buf = ob_get_contents();
ob_end_clean();
if(!strpos($buf,'<select name=type')) trigger_error('Select Not Found', E_USER_ERROR);
echo str_replace('<select name=type','<select name=type OnChange="ReloadType()"',$buf);
}
}
$O_ADM = new SiteRemindAdm;
$O_ADM->ShowPage();
// other funcs
function RemindGetPlan($all_types = false) {
global $db;
$A_PLAN = array(
'SUB' => array('' => 'ALL PLANS'),
'FEE' => array('' => 'ALL PLANS'),
'EXTRA' => array('' => 'ALL EXTRA OPTIONS'),
);
$res = $db->query('SELECT id,name,type FROM '.TBL_PAY_PLAN.' WHERE type IN("SUB","FEE")');
while($v = mysql_fetch_assoc($res)) $A_PLAN[$v['type']][$v['id']] = "$v[name] [$v[id]]";
$A_OPT = hwGetExtraOptions();
if($A_OPT) foreach($A_OPT as $v){
$A_PLAN['EXTRA'][$v['ID']] = "$v[NAME] [$v[ID]]";
}
if(!$all_types) $A_PLAN = $A_PLAN[$_POST['type']];
return $A_PLAN;
}
?>