/** * @desc Formulario de creación/edición de clientes **/ function formClients($edit = 0) { global $xoopsModule, $db; $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; $page = isset($_REQUEST['pag']) ? $_REQUEST['pag'] : ''; $limit = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 15; $ruta = "pag={$page}&limit={$limit}"; if ($edit) { //Verificamos si el cliente es válido if ($id <= 0) { redirectMsg('./clients.php?' . $ruta, __('You must provide a customer ID', 'works'), 1); die; } //Verificamos si el cliente existe $client = new PWClient($id); if ($client->isNew()) { redirectMsg('./clients.php?' . $ruta, __('Specified customer does not exists!', 'works'), 1); die; } } xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » <a href='./clients.php'>" . __('Customers', 'works') . "</a> »" . ($edit ? __('Edit Customer', 'works') : __('New Customer', 'works'))); RMTemplate::get()->assign('xoops_pagetitle', __('Customers', 'works')); PWFunctions::toolbar(); xoops_cp_header(); $form = new RMForm($edit ? __('Edit Customer', 'works') : __('New Customer', 'works'), 'frmClient', 'clients.php'); $form->addElement(new RMFormText(__('Name', 'works'), 'name', 50, 200, $edit ? $client->name() : ''), true); $form->addElement(new RMFormText(__('Company', 'works'), 'business', 50, 200, $edit ? $client->businessName() : '')); $form->addElement(new RMFormText(__('Email address', 'works'), 'mail', 50, 100, $edit ? $client->email() : '')); $form->addElement(new RMFormTextArea(__('Description', 'works'), 'desc', 4, 50, $edit ? $client->desc() : ''), true); //Tipos de Cliente $ele = new RMFormSelect(__('Type', 'works'), 'type'); $ele->addOption(0, _SELECT); $result = $db->query("SELECT * FROM " . $db->prefix('pw_types')); while ($row = $db->fetchArray($result)) { $ele->addOption($row['id_type'], $row['type'], $edit ? $row['id_type'] == $client->type() ? 1 : 0 : 0); } $form->addElement($ele, true, 'noselect:0'); $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save')); $form->addElement(new RMFormHidden('id', $id)); $form->addElement(new RMFormHidden('page', $page)); $form->addElement(new RMFormHidden('limit', $limit)); $ele = new RMFormButtonGroup(); $ele->addButton('sbt', $edit ? __('Save Changes', 'works') : __('Create Customer', 'works'), 'submit'); $ele->addButton('cancel', __('Cancel', 'works'), 'button', 'onclick="window.location=\'clients.php?' . $ruta . '\';"'); $form->addElement($ele); //Event $form = RMEvents::get()->run_event('works.form.customers', $form); $form->display(); xoops_cp_footer(); }
/** * @desc Formulario de creación/edición de Tipos de cliente **/ function formTypes($edit = 0) { global $tpl, $xoopsModule; $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0; if ($edit) { //Verificamos si nos proporcionaron al menos un tipo para editar if (!is_array($ids)) { redirectMsg('./types.php', __('You must provide a type ID at least', 'works'), 1); die; } if (!is_array($ids)) { $ids = array($ids); } } PWFunctions::toolbar(); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » <a href='./types.php'>" . __('Customer types', 'works') . "</a> » " . ($edit ? __('Edit type', 'works') : __('New type', 'works'))); RMTemplate::get()->assign('xoops_pagetitle', __('Add Customers types', 'works')); xoops_cp_header(); $form = new RMForm($edit ? __('Edit Type', 'works') : __('New Type', 'works'), 'frmtype', 'types.php'); $num = 10; if ($edit) { foreach ($ids as $k) { //Verificamos si el tipo es válido if ($k <= 0) { continue; } //Verificamos si el tipo existe $type = new PWType($k); if ($type->isNew()) { continue; } $form->addElement(new RMFormText(__('Type name', 'works'), 'type[' . $type->id() . ']', 50, 100, $edit ? $type->type() : '')); } } else { for ($i = 1; $i <= $num; $i++) { $form->addElement(new RMFormText(__('Type name', 'works'), 'type[' . $i . ']', 50, 100, $edit ? '' : '')); } } $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save')); $ele = new RMFormButtonGroup(); $ele->addButton('sbt', $edit ? __('Save Changes', 'works') : __('Save Customer Types', 'works'), 'submit'); $ele->addButton('cancel', __('Cancel', 'works'), 'button', 'onclick="window.location=\'types.php\';"'); $form->addElement($ele); $form->display(); xoops_cp_footer(); }
function formCategory($edit = 0) { global $mc, $xoopsModule, $db; PWFunctions::toolbar(); RMTemplate::get()->assign('xoops_pagetitle', $edit ? __('Edit Category', 'works') : __('Add Category', 'works')); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » \n\t\t<a href='categos.php'>" . __('Categories', 'works') . '</a> » ' . ($edit ? __('Edit Category', 'works') : __('Add Category', 'works'))); xoops_cp_header(); $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; if ($edit) { //Verificamos si la categoría es válida if ($id <= 0) { redirectMsg('./categos.php?op=edit&id=' . $id, __('Provide a category ID!', 'works'), 1); die; } //Verificamos si la categoría existe $cat = new PWCategory($id); if ($cat->isNew()) { redirectMsg('./categos.php?op=edit&id=' . $id, __('Specified category was not found!', 'works'), 1); die; } } $form = new RMForm($edit ? __('Edit Category', 'works') : __('Add Category', 'works'), 'frmNew', 'categos.php'); $form->addElement(new RMFormText(__('Name', 'works'), 'name', 50, 150, $edit ? $cat->name() : ''), true); if ($edit) { $form->addElement(new RMFormText(__('Short name', 'works'), 'nameid', 50, 150, $cat->nameId()), true); } $form->addElement(new RMFormEditor(__('Description', 'works'), 'desc', '100%', '250px', $edit ? $cat->desc('e') : '')); $form->addElement(new RMFormYesNo(__('Enable category', 'works'), 'active', $edit ? $cat->active() : 1)); $form->addElement(new RMFormText(__('Display order', 'works'), 'order', 8, 3, $edit ? $cat->order() : 0), true, 'num'); $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save')); if ($edit) { $form->addElement(new RMFormHidden('id', $cat->id())); } $ele = new RMFormButtonGroup(); $ele->addButton('sbt', $edit ? __('Save Changes!', 'works') : __('Add Now!', 'works'), 'submit'); $ele->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'categos.php\';"'); $form->addElement($ele); $form = RMEvents::get()->run_event('works.form.categories', $form); $form->display(); xoops_cp_footer(); }
/** * @desc Formulario de creación/edición de Imágenes **/ function formImages($edit = 0) { global $xoopsModule, $xoopsModuleConfig; $id = rmc_server_var($_REQUEST, 'id', 0); $work = rmc_server_var($_REQUEST, 'work', 0); $page = rmc_server_var($_REQUEST, 'page', 0); $ruta = "&page={$page}"; //Verificamos que el trabajo sea válido if ($work <= 0) { redirectMsg('./works.php', __('You must specify a work ID!', 'works'), 1); die; } //Verificamos que el trabajo exista $work = new PWWork($work); if ($work->isNew()) { redirectMsg('./works.php', __('Specified work does not exists!', 'works'), 1); die; } if ($edit) { //Verificamos que la imagen sea válida if ($id <= 0) { redirectMsg('./images.php?work=' . $work->id() . $ruta, __('You must specify an image ID!', 'works'), 1); die; } //Verificamos que la imagen exista $img = new PWImage($id); if ($img->isNew()) { redirectMsg('./images.php?work=' . $work->id() . $ruta, __('Specified image does not exists!', 'works'), 1); die; } } PWFunctions::toolbar(); RMTemplate::get()->assign('xoops_pagetitle', $work->title() . ' » ' . __('Work Images', 'works')); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » <a href='./images.php?work=" . $work->id() . "'>" . __('Work Images', 'works') . "</a> »" . ($edit ? __('Edit Image', 'works') : __('Add Image', 'works'))); xoops_cp_header(); $form = new RMForm($edit ? __('Edit Image', 'works') : __('Add Image', 'works'), 'frmImg', 'images.php'); $form->setExtra("enctype='multipart/form-data'"); $form->addElement(new RMFormText(__('Title', 'works'), 'title', 50, 100, $edit ? $img->title() : ''), true); $form->addElement(new RMFormFile(__('Image file', 'works'), 'image', 45, $xoopsModuleConfig['size_image'] * 1024), $edit ? false : true); if ($edit) { $form->addElement(new RMFormLabel(__('Current image file', 'works'), "<img src='" . XOOPS_UPLOAD_URL . "/works/ths/" . $img->image() . "' />")); } $form->addElement(new RMFormTextArea(__('Description', 'works'), 'desc', 4, 50, $edit ? $img->desc() : '')); $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save')); $form->addElement(new RMFormHidden('id', $id)); $form->addElement(new RMFormHidden('work', $work->id())); $form->addElement(new RMFormHidden('page', $page)); $form->addElement(new RMFormHidden('limit', $limit)); $ele = new RMFormButtonGroup(); $ele->addButton('sbt', _SUBMIT, 'submit'); $ele->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'images.php?work=' . $work->id() . $ruta . '\';"'); $form->addElement($ele); $form->display(); xoops_cp_footer(); }
<?php // $Id$ // -------------------------------------------------------------- // Professional Works // Module for personals and professionals portfolios // Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- define('RMCLOCATION', 'index'); include 'header.php'; define('WORKS_LOCATION', 'dashboard'); PWFunctions::toolbar(); // Widgets $widgets_right = array(); $widgets_left = array(); $widgets_right = RMEvents::get()->run_event('works.dashboard.right.widgets', $widgets_right); $widgets_left = RMEvents::get()->run_event('works.dashboard.left.widgets', $widgets_left); //Categorías $sql = "SELECT COUNT(*) FROM " . $db->prefix('pw_categos'); list($categories) = $db->fetchRow($db->query($sql)); //Tipos de Cliente $sql = "SELECT COUNT(*) FROM " . $db->prefix('pw_types'); list($types) = $db->fetchRow($db->query($sql)); //Clientes $sql = "SELECT COUNT(*) FROM " . $db->prefix('pw_clients'); list($customers) = $db->fetchRow($db->query($sql)); //Trabajos $sql = "SELECT COUNT(*) FROM " . $db->prefix('pw_works'); list($works) = $db->fetchRow($db->query($sql));
/** * Add meta data */ function works_meta_data() { global $xoopsModule, $xoopsSecurity; $id = rmc_server_var($_GET, 'id', 0); $page = rmc_server_var($_GET, 'page', 0); if ($id <= 0) { redirectMsg('works.php', __('You must provide a work ID!', 'works'), 0); die; } $work = new PWWork($id); if ($work->isNew()) { redirectMsg('works.php', __('Specified work does not exists!', 'works'), 0); die; } PWFunctions::toolbar(); RMTemplate::get()->add_style('admin.css', 'works'); RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js'); RMTemplate::get()->add_script('../include/js/admin_works.js'); RMTemplate::get()->add_head("<script type='text/javascript'>\nvar pw_message='" . __('Do you really want to delete selected works?', 'works') . "';\n\n var pw_select_message = '" . __('You must select some work before to execute this action!', 'works') . "';</script>"); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » " . __('Work Custom Fields', 'works')); // Load metas $metas = array(); $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix("pw_meta") . " WHERE work='{$id}'"; $result = $db->query($sql); while ($row = $db->fetchArray($result)) { $metas[] = $row; } xoops_cp_header(); include RMTemplate::get()->get_template('admin/pw_metas.php', 'module', 'works'); xoops_cp_footer(); }