From: Verdon V. <ve...@us...> - 2008-12-05 15:23:04
|
Update of /cvsroot/phpwebsite-comm/modules/vshop/class In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13083/class Modified Files: vShop.php vShop_Forms.php vShop_Tax.php Added Files: vShop_Option_set.php vShop_Option_value.php Log Message: initial 0.7.0 work --- NEW FILE: vShop_Option_set.php --- <?php /** * vshop - phpwebsite module * * See docs/AUTHORS and docs/COPYRIGHT for relevant info. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @version $Id: vShop_Option_set.php,v 1.1 2008/12/05 15:22:52 verdonv Exp $ * @author Verdon Vaillancourt <verdonv at users dot sourceforge dot net> */ class vShop_Option_set { public $id = 0; public $title = null; public $type = 0; public $_error = null; public function __construct($id=0) { if (!$id) { return; } $this->id = (int)$id; $this->init(); } public function init() { $db = new PHPWS_DB('vshop_option_sets'); $result = $db->loadObject($this); if (PEAR::isError($result)) { $this->_error = & $result; $this->id = 0; } elseif (!$result) { $this->id = 0; } } public function setTitle($title) { $this->title = strip_tags($title); } public function setType($type) { $this->type = (int)$type; } public function getTitle($print=false) { if (empty($this->title)) { return null; } if ($print) { return PHPWS_Text::parseOutput($this->title); } else { return $this->title; } } public function getType($print=false) { if (empty($this->type)) { return null; } if ($print) { require PHPWS_SOURCE_DIR . 'mod/vshop/inc/option_types.php'; return $types[$this->type]; } else { return $this->type; } } public function getAllValues($limit=false) { PHPWS_Core::initModClass('vshop', 'vShop_Option_value.php'); $db = new PHPWS_DB('vshop_option_values'); $db->addOrder('sort asc'); $db->addOrder('title asc'); $db->addWhere('set_id', $this->id); if ($limit) { $db->setLimit((int)$limit); } $result = $db->getObjects('vShop_Option_value'); return $result; } public function getQtyValues() { $db = new PHPWS_DB('vshop_option_values'); $db->addWhere('set_id', $this->id); $qty = $db->count(); return $qty; } public function view() { if (!$this->id) { PHPWS_Core::errorPage(404); } $tpl['OPTION_SET_LINKS'] = $this->links(); $tpl['TITLE'] = $this->getTitle(true); $tpl['TYPE'] = $this->getType(true); $tpl['SET_LABEL'] = dgettext('vshop', 'Set details'); $tpl['VALUES_LABEL'] = dgettext('vshop', 'Possible values'); $tpl['TITLE_LABEL'] = dgettext('vshop', 'Name: '); $tpl['TYPE_LABEL'] = dgettext('vshop', 'Element type: '); $values = $this->getAllValues(); if (PHPWS_Error::logIfError($values)) { $this->vshop->content = dgettext('vshop', 'An error occurred when accessing this set\'s values.'); return; } if ($values) { foreach ($values as $value) { $tpl['values'][] = $value->viewTpl(); } } else { if (Current_User::allow('vshop', 'settings')) $tpl['EMPTY'] = dgettext('vshop', 'Click on "New value" to start.'); } return PHPWS_Template::process($tpl, 'vshop', 'view_option_set.tpl'); } public function links() { $links = array(); if (Current_User::allow('vshop', 'settings')) { $vars['option_set_id'] = $this->id; $vars['aop'] = 'edit_option_set'; $links[] = PHPWS_Text::secureLink(dgettext('vshop', 'Edit option set'), 'vshop', $vars); } if (Current_User::allow('vshop', 'settings')) { $vars['aop'] = 'new_option_value'; $links[] = PHPWS_Text::secureLink(dgettext('vshop', 'Add Value'), 'vshop', $vars); } // $links = array_merge($links, vShop::navLinks()); if($links) return implode(' | ', $links); } public function delete() { if (!$this->id) { return; } $db = new PHPWS_DB('vshop_option_sets'); $db->addWhere('id', $this->id); PHPWS_Error::logIfError($db->delete()); } public function rowTag() { // $vars['id'] = $this->id; $vars['option_set_id'] = $this->id; $links = array(); if (Current_User::allow('vshop', 'settings')) { $vars['aop'] = 'new_option_value'; $links[] = PHPWS_Text::secureLink(dgettext('vshop', 'Add Value'), 'vshop', $vars); } if (Current_User::allow('vshop', 'settings')) { $vars['aop'] = 'edit_option_set'; $links[] = PHPWS_Text::secureLink(dgettext('vshop', 'Edit'), 'vshop', $vars); $vars['aop'] = 'delete_option_set'; $js['ADDRESS'] = PHPWS_Text::linkAddress('vshop', $vars, true); $js['QUESTION'] = sprintf(dgettext('vshop', 'Are you sure you want to delete the option set %s?'), $this->getTitle()); $js['LINK'] = dgettext('vshop', 'Delete'); $links[] = javascript('confirm', $js); } $tpl['TITLE'] = $this->viewLink(); $tpl['TYPE'] = $this->getType(true); $tpl['VALUES'] = $this->getQtyValues(); if($links) $tpl['ACTION'] = implode(' | ', $links); return $tpl; } public function save() { $db = new PHPWS_DB('vshop_option_sets'); $result = $db->saveObject($this); if (PEAR::isError($result)) { return $result; } } public function viewLink() { $vars['aop'] = 'view_option_set'; $vars['option_set'] = $this->id; return PHPWS_Text::moduleLink(dgettext('vshop', $this->title), 'vshop', $vars); } } ?> Index: vShop.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/vshop/class/vShop.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** vShop.php 3 Dec 2008 22:17:42 -0000 1.4 --- vShop.php 5 Dec 2008 15:22:52 -0000 1.5 *************** *** 27,39 **** class vShop { ! public $forms = null; ! public $panel = null; ! public $title = null; ! public $message = null; ! public $content = null; ! public $dept = null; ! public $item = null; ! public $tax = null; ! public $order = null; --- 27,42 ---- class vShop { ! public $forms = null; ! public $panel = null; ! public $title = null; ! public $message = null; ! public $content = null; ! public $dept = null; ! public $item = null; ! public $tax = null; ! public $order = null; ! public $option_set = null; ! public $option_value = null; ! public $attribute = null; *************** *** 55,58 **** --- 58,72 ---- case 'post_tax': case 'delete_tax': + case 'view_option_set': + case 'new_option_set': + case 'edit_option_set': + case 'post_option_set': + case 'delete_option_set': + case 'view_option_value': + case 'new_option_value': + case 'edit_option_value': + case 'post_option_value': + case 'delete_option_value': + PHPWS_Core::initModClass('vshop', 'vShop_Forms.php'); $settingsPanel = vShop_Forms::settingsPanel(); *************** *** 68,72 **** if (isset($_GET['tab'])) { PHPWS_Core::initModClass('vshop', 'vShop_Forms.php'); ! if ($_GET['tab'] == 'settings' || $_GET['tab'] == 'taxes') { $settingsPanel = vShop_Forms::settingsPanel(); $settingsPanel->enableSecure(); --- 82,86 ---- if (isset($_GET['tab'])) { PHPWS_Core::initModClass('vshop', 'vShop_Forms.php'); ! if ($_GET['tab'] == 'settings' || $_GET['tab'] == 'taxes' || $_GET['tab'] == 'option_sets' || $_GET['tab'] == 'option_values') { $settingsPanel = vShop_Forms::settingsPanel(); $settingsPanel->enableSecure(); *************** *** 208,211 **** --- 222,318 ---- + case 'view_option_set': + $settingsPanel->setCurrentTab('option_sets'); + $this->loadOption_set(); + $this->title = $this->option_set->getTitle(true); + $this->content = $this->option_set->view(); + break; + + case 'new_option_set': + case 'edit_option_set': + $settingsPanel->setCurrentTab('option_sets'); + if (!Current_User::authorized('vshop', 'settings')) { + Current_User::disallow(); + } + $this->loadForm('edit_option_set'); + break; + + case 'post_option_set': + $settingsPanel->setCurrentTab('option_sets'); + if (!Current_User::authorized('vshop', 'settings')) { + Current_User::disallow(); + } + if ($this->postOption_set()) { + if (PHPWS_Error::logIfError($this->option_set->save())) { + $this->forwardMessage(dgettext('vshop', 'Error occurred when saving option set.')); + PHPWS_Core::reroute('index.php?module=vshop&aop=menu&tab=option_sets'); + } else { + $this->forwardMessage(dgettext('vshop', 'Option set saved successfully.')); + PHPWS_Core::reroute('index.php?module=vshop&aop=menu&tab=option_sets'); + } + } else { + $this->loadForm('edit_option_set'); + } + break; + + case 'delete_option_set': + $settingsPanel->setCurrentTab('option_sets'); + if (!Current_User::authorized('vshop', 'settings')) { + Current_User::disallow(); + } + $this->loadOption_set(); + $this->option_set->delete(); + $this->message = dgettext('vshop', 'Option set deleted.'); + $this->loadForm('option_sets'); + break; + + + case 'view_option_value': + $settingsPanel->setCurrentTab('option_values'); + $this->loadOption_value(); + $this->title = $this->option_value->getTitle(true); + $this->content = $this->option_value->view(); + break; + + case 'new_option_value': + case 'edit_option_value': + $settingsPanel->setCurrentTab('option_values'); + if (!Current_User::authorized('vshop', 'settings')) { + Current_User::disallow(); + } + // $this->loadOption_value(); + $this->loadForm('edit_option_value'); + break; + + case 'post_option_value': + $settingsPanel->setCurrentTab('option_values'); + if (!Current_User::authorized('vshop', 'settings')) { + Current_User::disallow(); + } + if ($this->postOption_value()) { + if (PHPWS_Error::logIfError($this->option_value->save())) { + $this->forwardMessage(dgettext('vshop', 'Error occurred when saving option set value.')); + PHPWS_Core::reroute('index.php?module=vshop&aop=menu&tab=option_values'); + } else { + $this->forwardMessage(dgettext('vshop', 'Option set value saved successfully.')); + PHPWS_Core::reroute('index.php?module=vshop&aop=menu&tab=option_values'); + } + } else { + $this->loadForm('edit_option_value'); + } + break; + + case 'delete_option_value': + $settingsPanel->setCurrentTab('option_values'); + if (!Current_User::authorized('vshop', 'settings')) { + Current_User::disallow(); + } + $this->loadOption_value(); + $this->option_value->delete(); + $this->message = dgettext('vshop', 'Option set value deleted.'); + $this->loadForm('option_values'); + break; + + case 'post_settings': $settingsPanel->setCurrentTab('settings'); *************** *** 330,333 **** --- 437,450 ---- case 'post_tax': case 'delete_tax': + case 'view_option_set': + case 'new_option_set': + case 'edit_option_set': + case 'post_option_set': + case 'delete_option_set': + case 'view_option_value': + case 'new_option_value': + case 'edit_option_value': + case 'post_option_value': + case 'delete_option_value': $settingsPanel->setContent($this->content); $this->content = $settingsPanel->display(); *************** *** 340,344 **** case 'menu': if (isset($_GET['tab'])) { ! if ($_GET['tab'] == 'settings' || $_GET['tab'] == 'taxes') { $settingsPanel->setContent($this->content); $this->content = $settingsPanel->display(); --- 457,461 ---- case 'menu': if (isset($_GET['tab'])) { ! if ($_GET['tab'] == 'settings' || $_GET['tab'] == 'taxes' || $_GET['tab'] == 'option_sets' || $_GET['tab'] == 'option_values') { $settingsPanel->setContent($this->content); $this->content = $settingsPanel->display(); *************** *** 677,680 **** --- 794,846 ---- + public function loadOption_set($id=0) + { + PHPWS_Core::initModClass('vshop', 'vShop_Option_set.php'); + + if ($id) { + $this->option_set = new vShop_Option_set($id); + } elseif (isset($_REQUEST['option_set_id'])) { + $this->option_set = new vShop_Option_set($_REQUEST['option_set_id']); + // } elseif (isset($_REQUEST['id'])) { + // $this->option_set = new vShop_Option_set($_REQUEST['id']); + } elseif (isset($_REQUEST['option_set'])) { + $this->option_set = new vShop_Option_set($_REQUEST['option_set']); + } else { + $this->option_set = new vShop_Option_set; + } + } + + + public function loadOption_value($id=0) + { + PHPWS_Core::initModClass('vshop', 'vShop_Option_value.php'); + + if ($id) { + $this->option_value = new vShop_Option_value($id); + } elseif (isset($_REQUEST['option_value_id'])) { + $this->option_value = new vShop_Option_value($_REQUEST['option_value_id']); + // } elseif (isset($_REQUEST['id'])) { + // $this->option_value = new vShop_Option_value($_REQUEST['id']); + } elseif (isset($_REQUEST['option_value'])) { + $this->option_value = new vShop_Option_value($_REQUEST['option_value']); + } else { + $this->option_value = new vShop_Option_value; + } + //print_r($this->option_value->set_id); exit; + //print_r($this->option_set); exit; + if (empty($this->option_set)) { + if (isset($this->option_value->set_id)) { + $this->loadOption_set($this->option_value->set_id); + } elseif (isset($_REQUEST['option_set_id'])) { + $this->loadOption_set($_REQUEST['option_set_id']); + $this->option_value->set_id = $_REQUEST['option_set_id']; + } else { + $this->loadOption_set(); + $this->option_value->set_id = $this->option_set->id; + } + } + } + + public function loadOrder($id=0) { *************** *** 841,844 **** --- 1007,1059 ---- + public function postOption_set() + { + $this->loadOption_set(); + + if (empty($_POST['title'])) { + $errors[] = dgettext('vshop', 'You must give this option set a title.'); + } else { + $this->option_set->setTitle($_POST['title']); + } + + if (!empty($_POST['type']) ) { + $this->option_set->setType((int)$_POST['type']); + } + + if (isset($errors)) { + $this->message = implode('<br />', $errors); + $this->loadForm('edit_option_set'); + return false; + } else { + return true; + } + + } + + + public function postOption_value() + { + $this->loadOption_value(); + //print_r($_POST); exit; + if (empty($_POST['title'])) { + $errors[] = dgettext('vshop', 'You must give this option value a title.'); + } else { + $this->option_value->setTitle($_POST['title']); + } + + $this->option_value->setSet_id($_POST['set_id']); + $this->option_value->setSort($_POST['sort']); + + if (isset($errors)) { + $this->message = implode('<br />', $errors); + $this->loadForm('edit_option_value'); + return false; + } else { + return true; + } + + } + + public function postSettings() { Index: vShop_Tax.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/vshop/class/vShop_Tax.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** vShop_Tax.php 25 Nov 2008 15:19:30 -0000 1.1.1.1 --- vShop_Tax.php 5 Dec 2008 15:22:52 -0000 1.2 *************** *** 165,169 **** $links = array(); ! if (Current_User::allow('vshop', 'setting')) { $vars['aop'] = 'edit_tax'; $links[] = PHPWS_Text::secureLink(dgettext('vshop', 'Edit'), 'vshop', $vars); --- 165,169 ---- $links = array(); ! if (Current_User::allow('vshop', 'settings')) { $vars['aop'] = 'edit_tax'; $links[] = PHPWS_Text::secureLink(dgettext('vshop', 'Edit'), 'vshop', $vars); --- NEW FILE: vShop_Option_value.php --- <?php /** * vshop - phpwebsite module * * See docs/AUTHORS and docs/COPYRIGHT for relevant info. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @version $Id: vShop_Option_value.php,v 1.1 2008/12/05 15:22:52 verdonv Exp $ * @author Verdon Vaillancourt <verdonv at users dot sourceforge dot net> */ class vShop_Option_value { public $id = 0; public $set_id = null; public $sort = 0; public $title = null; public $_error = null; public function __construct($id=0) { if (!$id) { return; } $this->id = (int)$id; $this->init(); } public function init() { $db = new PHPWS_DB('vshop_option_values'); $result = $db->loadObject($this); if (PEAR::isError($result)) { $this->_error = & $result; $this->id = 0; } elseif (!$result) { $this->id = 0; } } public function setTitle($title) { $this->title = strip_tags($title); } public function setSet_id($set_id) { $this->set_id = (int)$set_id; } public function setSort($sort) { //print_r($sort); exit; $this->sort = (int)$sort; } public function getTitle($print=false) { if (empty($this->title)) { return null; } if ($print) { return PHPWS_Text::parseOutput($this->title); } else { return $this->title; } } public function getSet($print=false) { if (empty($this->set_id)) { return null; } if ($print) { PHPWS_Core::initModClass('vshop', 'vShop_Option_set.php'); $set = new vShop_Option_set($this->set_id); return $set->viewLink(); } else { return $this->set_id; } } public function view() { if (!$this->id) { PHPWS_Core::errorPage(404); } $tpl['OPTION_VALUE_LINKS'] = $this->links(); $tpl['TITLE'] = $this->getTitle(true); $tpl['SET'] = $this->getSet(true); return PHPWS_Template::process($tpl, 'vshop', 'view_option_value.tpl'); } public function links() { $links = array(); if (Current_User::allow('vshop', 'settings')) { $vars['option_value_id'] = $this->id; $vars['aop'] = 'edit_option_value'; $links[] = PHPWS_Text::secureLink(dgettext('vshop', 'Edit option value'), 'vshop', $vars); } // $links = array_merge($links, vShop::navLinks()); if($links) return implode(' | ', $links); } public function delete() { if (!$this->id) { return; } $db = new PHPWS_DB('vshop_option_values'); $db->addWhere('id', $this->id); PHPWS_Error::logIfError($db->delete()); } public function rowTag() { // $vars['id'] = $this->id; $vars['option_value_id'] = $this->id; $links = array(); if (Current_User::allow('vshop', 'settings')) { $vars['aop'] = 'edit_option_value'; $links[] = PHPWS_Text::secureLink(dgettext('vshop', 'Edit'), 'vshop', $vars); $vars['aop'] = 'delete_option_value'; $js['ADDRESS'] = PHPWS_Text::linkAddress('vshop', $vars, true); $js['QUESTION'] = sprintf(dgettext('vshop', 'Are you sure you want to delete the option value %s?'), $this->getTitle()); $js['LINK'] = dgettext('vshop', 'Delete'); $links[] = javascript('confirm', $js); } $tpl['TITLE'] = $this->viewLink(); $tpl['SET'] = $this->getSet(true); $tpl['SORT'] = $this->sort; if($links) $tpl['ACTION'] = implode(' | ', $links); return $tpl; } public function viewTpl() { $vars['option_value_id'] = $this->id; $vars['option_set_id'] = $this->set_id; $links = array(); // $links[] = $this->addLink(true) . ' ' . $this->addLink(); if (Current_User::allow('vshop', 'settings')) { $vars['aop'] = 'edit_option_value'; $links[] = PHPWS_Text::secureLink(dgettext('vshop', 'Edit'), 'vshop', $vars); } if (Current_User::allow('vshop', 'edit_items')) { $vars['aop'] = 'delete_option_value'; $js['ADDRESS'] = PHPWS_Text::linkAddress('vshop', $vars, true); $js['QUESTION'] = sprintf(dgettext('vshop', 'Are you sure you want to delete the value %s?'), $this->getTitle()); $js['LINK'] = dgettext('vshop', 'Delete'); $links[] = javascript('confirm', $js); } $tpl['VALUE_TITLE'] = $this->viewLink(); if($links) $tpl['VALUE_LINKS'] = implode(' | ', $links); return $tpl; } public function save() { $db = new PHPWS_DB('vshop_option_values'); //print_r($db); exit; // $db->setTestMode(); //print_r($this); exit; $result = $db->saveObject($this); //print_r($result); exit; if (PEAR::isError($result)) { return $result; } } public function viewLink() { $vars['aop'] = 'view_option_value'; $vars['option_value'] = $this->id; return PHPWS_Text::moduleLink(dgettext('vshop', $this->title), 'vshop', $vars); } } ?> Index: vShop_Forms.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/vshop/class/vShop_Forms.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** vShop_Forms.php 3 Dec 2008 22:17:42 -0000 1.4 --- vShop_Forms.php 5 Dec 2008 15:22:52 -0000 1.5 *************** *** 59,62 **** --- 59,67 ---- break; + case 'settings': + $this->vshop->panel->setCurrentTab('settings'); + $this->editSettings(); + break; + case 'new_tax': case 'edit_tax': *************** *** 72,78 **** break; ! case 'settings': ! $this->vshop->panel->setCurrentTab('settings'); ! $this->editSettings(); break; --- 77,104 ---- break; ! case 'new_option_set': ! case 'edit_option_set': ! if (empty($this->vshop->option_set)) { ! $this->vshop->loadOption_set(); ! } ! $this->editOptionSet(); ! break; ! ! case 'option_sets': ! $this->vshop->panel->setCurrentTab('option_sets'); ! $this->listOptionSets(); ! break; ! ! case 'new_option_value': ! case 'edit_option_value': ! if (empty($this->vshop->option_value)) { ! $this->vshop->loadOption_value(); ! } ! $this->editOptionValue(); ! break; ! ! case 'option_values': ! $this->vshop->panel->setCurrentTab('option_values'); ! $this->listOptionValues(); break; *************** *** 132,135 **** --- 158,166 ---- } + if (Current_User::allow('vshop', 'settings')){ + $tags['option_sets'] = array('title'=>dgettext('vshop', 'Option Sets'), 'link'=>$link); + $tags['option_values'] = array('title'=>dgettext('rolodex', 'Option Values'), 'link'=>$link); + } + $panel = new PHPWS_Panel('vshop-settings-panel'); $panel->quickSetTabs($tags); *************** *** 272,275 **** --- 303,369 ---- + public function listOptionSets() + { + if (Current_User::allow('vshop', 'settings') && isset($_REQUEST['uop'])) { + $link[] = PHPWS_Text::secureLink(dgettext('vshop', 'Add new option set'), 'vshop', array('aop'=>'new_option_set')); + MiniAdmin::add('vshop', $link); + } + + $ptags['TITLE_HEADER'] = dgettext('vshop', 'Name'); + $ptags['TYPE_HEADER'] = dgettext('vshop', 'Type'); + $ptags['VALUES_HEADER'] = dgettext('vshop', 'Values'); + + PHPWS_Core::initModClass('vshop', 'vShop_Option_set.php'); + PHPWS_Core::initCoreClass('DBPager.php'); + $pager = new DBPager('vshop_option_sets', 'vShop_Option_set'); + $pager->setModule('vshop'); + + $pager->setOrder('title', 'asc', true); + $pager->setTemplate('list_option_sets.tpl'); + $pager->addRowTags('rowTag'); + $num = $pager->getTotalRows(); + if ($num == '0') { + $vars['aop'] = 'menu'; + $vars['tab'] = 'settings'; + $vars2['aop'] = 'new_option_set'; + $ptags['EMPTY_MESSAGE'] = sprintf(dgettext('vshop', 'Check your %s then create a %s to begin'), PHPWS_Text::secureLink(dgettext('vshop', 'Settings'), 'vshop', $vars), PHPWS_Text::secureLink(dgettext('vshop', 'New Option Set'), 'vshop', $vars2)); + } + if (Current_User::allow('vshop', 'settings', null, null, true)) { + $vars['aop'] = 'new_option_set'; + $ptags['ADD_LINK'] = PHPWS_Text::secureLink(dgettext('vshop', 'Add Option Set'), 'vshop', $vars); + } + $pager->addPageTags($ptags); + $pager->addToggle('class="toggle1"'); + $pager->cacheQueries(); + + $this->vshop->content = $pager->get(); + $this->vshop->title = sprintf(dgettext('vshop', '%s Option Sets'), PHPWS_Text::parseOutput(PHPWS_Settings::get('vshop', 'mod_title'))); + } + + + public function listOptionValues() + { + + $ptags['TITLE_HEADER'] = dgettext('vshop', 'Name'); + $ptags['SET_HEADER'] = dgettext('vshop', 'Set'); + $ptags['SORT_HEADER'] = dgettext('vshop', 'Sort'); + + PHPWS_Core::initModClass('vshop', 'vShop_Option_value.php'); + PHPWS_Core::initCoreClass('DBPager.php'); + $pager = new DBPager('vshop_option_values', 'vShop_Option_value'); + $pager->setModule('vshop'); + + $pager->setOrder('title', 'asc', true); + $pager->setTemplate('list_option_values.tpl'); + $pager->addRowTags('rowTag'); + $pager->addPageTags($ptags); + $pager->addToggle('class="toggle1"'); + $pager->cacheQueries(); + + $this->vshop->content = $pager->get(); + $this->vshop->title = sprintf(dgettext('vshop', '%s Option Values'), PHPWS_Text::parseOutput(PHPWS_Settings::get('vshop', 'mod_title'))); + } + + public function listOrders($completed=1,$cancelled=0) { *************** *** 438,441 **** --- 532,537 ---- $tpl['INFO_LABEL'] = dgettext('vshop', 'Item details'); + + $this->vshop->content = PHPWS_Template::process($tpl, 'vshop', 'edit_item.tpl'); } *************** *** 482,485 **** --- 578,663 ---- + public function editOptionSet() + { + $form = new PHPWS_Form; + $option_set = & $this->vshop->option_set; + require PHPWS_SOURCE_DIR . 'mod/vshop/inc/option_types.php'; + + $form->addHidden('module', 'vshop'); + $form->addHidden('aop', 'post_option_set'); + if ($option_set->id) { + $this->vshop->title = dgettext('vshop', 'Update option set'); + $form->addHidden('option_set_id', $option_set->id); + $form->addSubmit(dgettext('vshop', 'Update')); + } else { + $this->vshop->title = dgettext('vshop', 'Add new option set'); + $form->addSubmit(dgettext('vshop', 'Add')); + } + + $form->addText('title', $option_set->title); + $form->setSize('title', 40); + $form->setRequired('title'); + $form->setLabel('title', dgettext('vshop', 'Title')); + + $form->addSelect('type', $types); + $form->setLabel('type', dgettext('vshop', 'Element type')); + $form->setMatch('type', $option_set->type); + + $tpl = $form->getTemplate(); + $tpl['INFO_LABEL'] = dgettext('vshop', 'Option set details'); + + $this->vshop->content = PHPWS_Template::process($tpl, 'vshop', 'edit_option_set.tpl'); + } + + + public function editOptionValue() + { + $form = new PHPWS_Form; + $option_value = & $this->vshop->option_value; + //print_r($option_value); exit; + // require PHPWS_SOURCE_DIR . 'mod/vshop/inc/zones.php'; + + $form->addHidden('module', 'vshop'); + $form->addHidden('aop', 'post_option_value'); + if ($option_value->id) { + $this->vshop->title = dgettext('vshop', 'Update option set value'); + $form->addHidden('option_value_id', $option_value->id); + $form->addSubmit(dgettext('vshop', 'Update')); + } else { + $this->vshop->title = dgettext('vshop', 'Add new option set value'); + $form->addSubmit(dgettext('vshop', 'Add')); + } + + $form->addText('title', $option_value->title); + $form->setSize('title', 40); + $form->setRequired('title'); + $form->setLabel('title', dgettext('vshop', 'Title')); + + PHPWS_Core::initModClass('vshop', 'vShop_Option_set.php'); + $db = new PHPWS_DB('vshop_option_sets'); + $db->addColumn('id'); + $db->addColumn('title'); + $result = $db->getObjects('vShop_Option_set'); + if ($result) { + foreach ($result as $set) { + $choices[$set->id] = $set->title; + } + $form->addSelect('set_id', $choices); + $form->setLabel('set_id', dgettext('vshop', 'Option Set')); + $form->setMatch('set_id', $option_value->set_id); + } + + $form->addText('sort', $option_value->sort); + $form->setSize('sort', 3); + $form->setRequired('sort'); + $form->setLabel('sort', dgettext('vshop', 'Sort order')); + + $tpl = $form->getTemplate(); + $tpl['INFO_LABEL'] = dgettext('vshop', 'Option set value details'); + + $this->vshop->content = PHPWS_Template::process($tpl, 'vshop', 'edit_option_value.tpl'); + } + + public function editOrder() { |